Skip to content

Commit

Permalink
feat(Calendar, DatePicker, DateRangePicker, TimePicker): add keyboard…
Browse files Browse the repository at this point in the history
… support, improve syntax
  • Loading branch information
mrholek committed Oct 19, 2023
1 parent 949481b commit 5af7c3d
Show file tree
Hide file tree
Showing 7 changed files with 436 additions and 198 deletions.
16 changes: 8 additions & 8 deletions docs/assets/js/snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@
const optionsDatePickerCustomFormats1 = {
locale: 'en-US',
date: new Date(2022, 8, 3),
inputDateFormat: date => dayjs(date).format('MMMM DD, YYYY'),
inputDateParse: date => dayjs(date, 'MMMM DD, YYYY').toDate()
inputDateFormat: date => dayjs(date).locale('en').format('MMMM DD, YYYY'),
inputDateParse: date => dayjs(date, 'MMMM DD, YYYY', 'en').toDate()
}

new coreui.DatePicker(myDatePickerCustomFormats1, optionsDatePickerCustomFormats1)
Expand All @@ -338,8 +338,8 @@
const optionsDatePickerCustomFormats2 = {
locale: 'es-ES',
date: new Date(2022, 8, 3),
inputDateFormat: date => dayjs(date).format('YYYY MMMM DD'),
inputDateParse: date => dayjs(date, 'YYYY MMMM DD').toDate()
inputDateFormat: date => dayjs(date).locale('es').format('YYYY MMMM DD'),
inputDateParse: date => dayjs(date, 'YYYY MMMM DD', 'es').toDate()
}

new coreui.DatePicker(myDatePickerCustomFormats2, optionsDatePickerCustomFormats2)
Expand Down Expand Up @@ -379,8 +379,8 @@
locale: 'en-US',
startDate: new Date(2022, 8, 3),
endDate: new Date(2022, 8, 17),
inputDateFormat: date => dayjs(date).format('MMMM DD, YYYY'),
inputDateParse: date => dayjs(date, 'MMMM DD, YYYY').toDate()
inputDateFormat: date => dayjs(date).locale('en').format('MMMM DD, YYYY'),
inputDateParse: date => dayjs(date, 'MMMM DD, YYYY', 'en').toDate()
}

new coreui.DateRangePicker(myDateRangePickerCustomFormats1, optionsDateRangePickerCustomFormats1)
Expand All @@ -396,8 +396,8 @@
locale: 'es-ES',
startDate: new Date(2022, 8, 3),
endDate: new Date(2022, 8, 17),
inputDateFormat: date => dayjs(date).format('YYYY MMMM DD'),
inputDateParse: date => dayjs(date, 'YYYY MMMM DD').toDate()
inputDateFormat: date => dayjs(date).locale('es').format('YYYY MMMM DD'),
inputDateParse: date => dayjs(date, 'YYYY MMMM DD', 'es').toDate()
}

new coreui.DateRangePicker(myDateRangePickerCustomFormats2, optionsDateRangePickerCustomFormats2)
Expand Down
1 change: 1 addition & 0 deletions docs/content/forms/date-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ The `inputDateFormat` property formats the date into a custom string, while the
```html
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/plugin/customParseFormat.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/locale/en.js"></script>
```

{{< js-docs name="date-picker-custom-formats1" file="docs/assets/js/snippets.js" >}}
Expand Down
1 change: 1 addition & 0 deletions docs/layouts/partials/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{{- if eq .Params.dayjs true -}}
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/plugin/customParseFormat.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/locale/en.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/locale/es.js"></script>
{{- end }}

Expand Down
Loading

0 comments on commit 5af7c3d

Please sign in to comment.