Skip to content

Commit 5af7c3d

Browse files
committed
feat(Calendar, DatePicker, DateRangePicker, TimePicker): add keyboard support, improve syntax
1 parent 949481b commit 5af7c3d

File tree

7 files changed

+436
-198
lines changed

7 files changed

+436
-198
lines changed

docs/assets/js/snippets.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@
322322
const optionsDatePickerCustomFormats1 = {
323323
locale: 'en-US',
324324
date: new Date(2022, 8, 3),
325-
inputDateFormat: date => dayjs(date).format('MMMM DD, YYYY'),
326-
inputDateParse: date => dayjs(date, 'MMMM DD, YYYY').toDate()
325+
inputDateFormat: date => dayjs(date).locale('en').format('MMMM DD, YYYY'),
326+
inputDateParse: date => dayjs(date, 'MMMM DD, YYYY', 'en').toDate()
327327
}
328328

329329
new coreui.DatePicker(myDatePickerCustomFormats1, optionsDatePickerCustomFormats1)
@@ -338,8 +338,8 @@
338338
const optionsDatePickerCustomFormats2 = {
339339
locale: 'es-ES',
340340
date: new Date(2022, 8, 3),
341-
inputDateFormat: date => dayjs(date).format('YYYY MMMM DD'),
342-
inputDateParse: date => dayjs(date, 'YYYY MMMM DD').toDate()
341+
inputDateFormat: date => dayjs(date).locale('es').format('YYYY MMMM DD'),
342+
inputDateParse: date => dayjs(date, 'YYYY MMMM DD', 'es').toDate()
343343
}
344344

345345
new coreui.DatePicker(myDatePickerCustomFormats2, optionsDatePickerCustomFormats2)
@@ -379,8 +379,8 @@
379379
locale: 'en-US',
380380
startDate: new Date(2022, 8, 3),
381381
endDate: new Date(2022, 8, 17),
382-
inputDateFormat: date => dayjs(date).format('MMMM DD, YYYY'),
383-
inputDateParse: date => dayjs(date, 'MMMM DD, YYYY').toDate()
382+
inputDateFormat: date => dayjs(date).locale('en').format('MMMM DD, YYYY'),
383+
inputDateParse: date => dayjs(date, 'MMMM DD, YYYY', 'en').toDate()
384384
}
385385

386386
new coreui.DateRangePicker(myDateRangePickerCustomFormats1, optionsDateRangePickerCustomFormats1)
@@ -396,8 +396,8 @@
396396
locale: 'es-ES',
397397
startDate: new Date(2022, 8, 3),
398398
endDate: new Date(2022, 8, 17),
399-
inputDateFormat: date => dayjs(date).format('YYYY MMMM DD'),
400-
inputDateParse: date => dayjs(date, 'YYYY MMMM DD').toDate()
399+
inputDateFormat: date => dayjs(date).locale('es').format('YYYY MMMM DD'),
400+
inputDateParse: date => dayjs(date, 'YYYY MMMM DD', 'es').toDate()
401401
}
402402

403403
new coreui.DateRangePicker(myDateRangePickerCustomFormats2, optionsDateRangePickerCustomFormats2)

docs/content/forms/date-picker.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ The `inputDateFormat` property formats the date into a custom string, while the
257257
```html
258258
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js"></script>
259259
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/plugin/customParseFormat.js"></script>
260+
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/locale/en.js"></script>
260261
```
261262

262263
{{< js-docs name="date-picker-custom-formats1" file="docs/assets/js/snippets.js" >}}

docs/layouts/partials/scripts.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
{{- if eq .Params.dayjs true -}}
1212
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js"></script>
1313
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/plugin/customParseFormat.js"></script>
14+
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/locale/en.js"></script>
1415
<script src="https://cdn.jsdelivr.net/npm/dayjs@1/locale/es.js"></script>
1516
{{- end }}
1617

0 commit comments

Comments
 (0)