mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
fix(date-picker): type locale prop using flatpickr types (#906)
Fixes #855
This commit is contained in:
parent
36f6a327b2
commit
a308c89e42
5 changed files with 25 additions and 17 deletions
|
@ -1051,20 +1051,20 @@ None.
|
|||
|
||||
### Props
|
||||
|
||||
| Prop name | Kind | Reactive | Type | Default value | Description |
|
||||
| :------------- | :--------------- | :------- | :---------------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------- |
|
||||
| valueTo | <code>let</code> | Yes | <code>string</code> | <code>""</code> | Specify the date picker end date value (to)<br />Only works with the "range" date picker type |
|
||||
| valueFrom | <code>let</code> | Yes | <code>string</code> | <code>""</code> | Specify the date picker start date value (from)<br />Only works with the "range" date picker type |
|
||||
| value | <code>let</code> | Yes | <code>number | string</code> | <code>""</code> | Specify the date picker input value |
|
||||
| datePickerType | <code>let</code> | No | <code>"simple" | "single" | "range"</code> | <code>"simple"</code> | Specify the date picker type |
|
||||
| dateFormat | <code>let</code> | No | <code>string</code> | <code>"m/d/Y"</code> | Specify the date format |
|
||||
| maxDate | <code>let</code> | No | <code>null | string | Date</code> | <code>null</code> | Specify the maximum date |
|
||||
| minDate | <code>let</code> | No | <code>null | string | Date</code> | <code>null</code> | Specify the minimum date |
|
||||
| locale | <code>let</code> | No | <code>string</code> | <code>"en"</code> | Specify the locale |
|
||||
| short | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the short variant |
|
||||
| light | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the light variant |
|
||||
| id | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the date picker element |
|
||||
| flatpickrProps | <code>let</code> | No | <code>import("flatpickr/dist/types/options").Options</code> | <code>{}</code> | Override the options passed to the Flatpickr instance<br />https://flatpickr.js.org/options |
|
||||
| Prop name | Kind | Reactive | Type | Default value | Description |
|
||||
| :------------- | :--------------- | :------- | :--------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------- |
|
||||
| valueTo | <code>let</code> | Yes | <code>string</code> | <code>""</code> | Specify the date picker end date value (to)<br />Only works with the "range" date picker type |
|
||||
| valueFrom | <code>let</code> | Yes | <code>string</code> | <code>""</code> | Specify the date picker start date value (from)<br />Only works with the "range" date picker type |
|
||||
| value | <code>let</code> | Yes | <code>number | string</code> | <code>""</code> | Specify the date picker input value |
|
||||
| datePickerType | <code>let</code> | No | <code>"simple" | "single" | "range"</code> | <code>"simple"</code> | Specify the date picker type |
|
||||
| dateFormat | <code>let</code> | No | <code>string</code> | <code>"m/d/Y"</code> | Specify the date format |
|
||||
| maxDate | <code>let</code> | No | <code>null | string | Date</code> | <code>null</code> | Specify the maximum date |
|
||||
| minDate | <code>let</code> | No | <code>null | string | Date</code> | <code>null</code> | Specify the minimum date |
|
||||
| locale | <code>let</code> | No | <code>import("flatpickr/dist/types/locale").CustomLocale | import("flatpickr/dist/types/locale").key</code> | <code>"en"</code> | Specify the locale |
|
||||
| short | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to use the short variant |
|
||||
| light | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the light variant |
|
||||
| id | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the date picker element |
|
||||
| flatpickrProps | <code>let</code> | No | <code>import("flatpickr/dist/types/options").Options</code> | <code>{}</code> | Override the options passed to the Flatpickr instance<br />https://flatpickr.js.org/options |
|
||||
|
||||
### Slots
|
||||
|
||||
|
|
|
@ -2659,7 +2659,7 @@
|
|||
"name": "locale",
|
||||
"kind": "let",
|
||||
"description": "Specify the locale",
|
||||
"type": "string",
|
||||
"type": "import(\"flatpickr/dist/types/locale\").CustomLocale | import(\"flatpickr/dist/types/locale\").key",
|
||||
"value": "\"en\"",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
|
|
|
@ -44,7 +44,10 @@
|
|||
*/
|
||||
export let minDate = null;
|
||||
|
||||
/** Specify the locale */
|
||||
/**
|
||||
* Specify the locale
|
||||
* @type {import("flatpickr/dist/types/locale").CustomLocale | import("flatpickr/dist/types/locale").key}
|
||||
*/
|
||||
export let locale = "en";
|
||||
|
||||
/** Set to `true` to use the short variant */
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<script lang="ts">
|
||||
import { DatePicker, DatePickerSkeleton, DatePickerInput } from "../types";
|
||||
import { Russian } from "flatpickr/dist/l10n/ru.js";
|
||||
</script>
|
||||
|
||||
<DatePicker
|
||||
locale="{Russian}"
|
||||
datePickerType="single"
|
||||
flatpickrProps="{{ static: true }}"
|
||||
on:change
|
||||
|
@ -11,6 +13,7 @@
|
|||
</DatePicker>
|
||||
|
||||
<DatePicker
|
||||
locale="az"
|
||||
on:change="{(e) => {
|
||||
console.log(e.detail);
|
||||
}}"
|
||||
|
|
4
types/DatePicker/DatePicker.svelte.d.ts
vendored
4
types/DatePicker/DatePicker.svelte.d.ts
vendored
|
@ -51,7 +51,9 @@ export interface DatePickerProps
|
|||
* Specify the locale
|
||||
* @default "en"
|
||||
*/
|
||||
locale?: string;
|
||||
locale?:
|
||||
| import("flatpickr/dist/types/locale").CustomLocale
|
||||
| import("flatpickr/dist/types/locale").key;
|
||||
|
||||
/**
|
||||
* Set to `true` to use the short variant
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue