diff --git a/docs/src/pages/components/DatePicker.svx b/docs/src/pages/components/DatePicker.svx index 732690a8..9c2cf946 100644 --- a/docs/src/pages/components/DatePicker.svx +++ b/docs/src/pages/components/DatePicker.svx @@ -7,7 +7,39 @@ components: ["DatePicker", "DatePickerInput", "DatePickerSkeleton"] import Preview from "../../components/Preview.svelte"; -### Default (simple) +Carbon uses the zero dependency [flatpickr](https://github.com/flatpickr/flatpickr) library for its underlying calendar implementation. + +Set `datePickerType` to `"single"` or `"range"` for the calendar functionality. + +Specify [flatpickr options](https://flatpickr.js.org/options/) through the `flatpickrProps` prop. + + +
+ If using Rollup, specify inlineDynamicImports: true in your rollup.config.js. +
+
+ +### Single + +By default, the `flatpickr` option `static` is set to `true` so that the calendar is positioned inside the wrapper and next to the input element. This is required for the calendar position to work inside a [Modal](/components/Modal). + +Set `flatpickrProps.static` to `false` to opt out of this behavior. + + + +### Range + +Set `datePickerType` to `"range"` for the range variant. + + + +### DatePicker in a modal + + + +### Simple + +By default, the "simple" date picker does not have a dropdown calendar. @@ -61,30 +93,6 @@ components: ["DatePicker", "DatePickerInput", "DatePickerSkeleton"] -### Single - - -
- If using Rollup, specify inlineDynamicImports: true in your rollup.config.js. -
-
- - - -### Range - - - -### DatePicker in a modal - -Use `flatpickrProps` to set `static: true` for the calendar to be positioned relative to the input element. - -This is needed when placing a `DatePicker` inside of a `Modal` component. - -Refer to [flatpickr options](https://flatpickr.js.org/options/) for a full list of config options. - - - ### Skeleton diff --git a/docs/src/pages/framed/DatePicker/DatePickerModal.svelte b/docs/src/pages/framed/DatePicker/DatePickerModal.svelte index ea33e5e9..af4eb2ad 100644 --- a/docs/src/pages/framed/DatePicker/DatePickerModal.svelte +++ b/docs/src/pages/framed/DatePicker/DatePickerModal.svelte @@ -8,7 +8,7 @@ primaryButtonText="Confirm" secondaryButtonText="Cancel" > - + diff --git a/src/DatePicker/DatePicker.svelte b/src/DatePicker/DatePicker.svelte index f75089b3..b210d6e5 100644 --- a/src/DatePicker/DatePicker.svelte +++ b/src/DatePicker/DatePicker.svelte @@ -216,6 +216,9 @@ locale, maxDate, minDate, + // default to static: true so the + // date picker works inside a modal + static: true, ...flatpickrProps, }); }