|
| 1 | +### JavaScript |
| 2 | + |
| 3 | +The date picker is built on top of [Flatpickr](https://chmln.github.io/flatpickr/), so the [events](https://chmln.github.io/flatpickr/events/) and [config options](https://chmln.github.io/flatpickr/options/) that come with Flatpickr is therefore available to the date picker. This includes methods for setting a min date, max date, disabling date(s), specifiying a range of dates, and more. |
| 4 | + |
| 5 | +#### Public Methods |
| 6 | + |
| 7 | +| Name | Params | Description | |
| 8 | +|---------|---------|----------------------| |
| 9 | +| release | | Deletes the instance | |
| 10 | + |
| 11 | +#### Options |
| 12 | + |
| 13 | +| Option | Default Selector | Description | |
| 14 | +|-----------------------------|-------------------------------------|-------------------------------------------------------| |
| 15 | +| selectorInit | [data-date-picker] | Element for initializing instance | |
| 16 | +| selectorDatePickerInput | [data-date-picker-input] | Input element | |
| 17 | +| selectorDatePickerInputFrom | [data-date-picker-input-from] | For ranged calendars only: The "From date" input element | |
| 18 | +| selectorDatePickerInputTo | [data-date-picker-input-to] | For ranged calendars only: The "To date" input element | |
| 19 | +| selectorDatePickerIcon | [data-date-picker-icon] | Calendar icon | |
| 20 | +| classCalendarContainer | .bx--date-picker__calendar | Class selector for the calendar container | |
| 21 | +| classMonth | .bx--date-picker__month | Class selector for the calendar month | |
| 22 | +| classWeekdays | .bx--date-picker__weekdays | Class selector for the calendar weekdays | |
| 23 | +| classDays | .bx--date-picker__days | Class selector for the calendar days | |
| 24 | +| classWeekday | .bx--date-picker__weekday | Class selector for a calendar weekday | |
| 25 | +| classDay | .bx--date-picker__day | Class selector for a calendar day | |
| 26 | +| attribType | data-date-picker-type | Specifies the calendar mode (single or range) | |
| 27 | +| dateFormat | 'm/d/Y' | The date format given to the calendar instance | |
| 28 | + |
| 29 | + |
| 30 | +### FAQ |
| 31 | + |
| 32 | +#### Using and understanding Date Picker |
| 33 | + |
| 34 | +There are 3 different date picker types: |
| 35 | + |
| 36 | +| Type | data-date-picker-type | |
| 37 | +|--|--| |
| 38 | +| A simple date picker without a calendar | No data attributes needed | |
| 39 | +| A single date picker | [data-date-picker-type="single"] | |
| 40 | +| A ranged date picker | [data-date-picker-type="range"] | |
| 41 | + |
| 42 | +**The simple date picker** is a text input without a calendar. You can specify the pattern for the text input to make sure the user enters the correct date format. The default regex pattern that ships with the |
| 43 | +simple date picker is \d{1,2}/\d{4} ('dd/yyyy' for short date pickers) and \d{1,2}/\d{1,2}/\d{4} ('dd/mm/yyyy' or mm/dd/yyyy). The simple date picker does not require any JavaScript. |
| 44 | + |
| 45 | +**The single date picker** is a text input with a calendar instance attached to it. It also ships with a calendar icon inside the input field. The calendar will open when the input is focused, and the user can both type in a date or select a day from the calendar. The single date picker requires JavaScript, so the data attributes `data-date-picker` and `data-date-picker-type="single"` are required on the parent div, and the data attribute `data-date-picker-input` is required on the input field. |
| 46 | + |
| 47 | +**The ranged date picker** has two text inputs with a ranged calendar instance attached to them. The ranged date picker requires JavaScript, so the data attributes `data-date-picker` and `data-date-picker-type="range"` are required on the parent div, and the data attributes `data-date-picker-input-from` and `data-date-picker-input-to` are required on the two input fields. |
| 48 | + |
| 49 | +#### Localization |
| 50 | + |
| 51 | +Date Picker supports localization, and you can specify the date format by overriding the component option `dateFormat`. Supported date formats are listed [here](https://chmln.github.io/flatpickr/formatting/). |
| 52 | + |
| 53 | +To localize the date picker globally, please follow [these instructions](https://chmln.github.io/flatpickr/localization/). |
0 commit comments