You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(DatePicker, DateRangePicker): remove the dependency on date-fns within the component, allowing the option to provide custom functions for date formatting and parsing.
Copy file name to clipboardExpand all lines: docs/content/forms/date-picker.md
+45-1Lines changed: 45 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ group: forms
6
6
toc: true
7
7
pro_component: true
8
8
other_frameworks: date-picker
9
+
dayjs: true
9
10
---
10
11
11
12
## Example
@@ -236,6 +237,48 @@ RTL support is built-in and can be explicitly controlled through the `$enable-rt
236
237
</div>
237
238
{{< /example >}}
238
239
240
+
## Custom formats
241
+
242
+
As of v5.0.0, the `format` property is removed in Date Picker. Instead, utilize the `inputDateFormat` to format dates into custom strings and `inputDateParse` to parse custom strings into Date objects.
243
+
244
+
The provided code demonstrates how to use the `inputDateFormat` and `inputDateParse` properties. In this example, we use the `dayjs` library to format and parse dates.
245
+
246
+
The `inputDateFormat` property formats the date into a custom string, while the `inputDateParse` property parses a custom string into a Date object. The code showcases the date range in different formats based on locale, such as 'MMMM DD, YYYY' and 'YYYY MMMM DD', and accommodates different locales, like 'en-US' and 'es-ES'.
|`disabledDates`| array | null |`null`| Specify the list of dates that cannot be selected. |
283
326
|`firstDayOfWeek`| number |`1`| <p>Sets the day of start week.</p><ul><li>`0` - Sunday</li><li>`1` - Monday</li><li>`2` - Tuesday</li><li>`3` - Wednesday</li><li>`4` - Thursday</li><li>`5` - Friday</li><li>`6` - Saturday</li></ul> |
284
327
|`footer`| boolean |`false`| Toggle visibility of footer element. |
285
-
|`format`| string || Set date format. We use date-fns to format dates. Visit <ahref="https://date-fns.org/v2.28.0/docs/format"target="_blank"rel="nofollow">https://date-fns.org/v2.28.0/docs/format</a> to check accepted patterns. |
286
328
|`indicator`| boolean |`true`| Toggle visibility or set the content of the input indicator. |
329
+
|`inputDateFormat`| function |`null`| Custom function to format the selected date into a string according to a custom format. |
330
+
|`inputDateParse`| function |`null`| Custom function to parse the input value into a valid Date object. |
287
331
|`inputReadOnly`| boolean |`false`| Toggle the readonly state for the component. |
288
332
|`invalid`| boolean |`false`| Toggle the invalid state for the component. |
289
333
|`locale`| string |`'default'`| Sets the default locale for components. If not set, it is inherited from the navigator.language. |
Copy file name to clipboardExpand all lines: docs/content/forms/date-range-picker.md
+45-1Lines changed: 45 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ group: forms
6
6
toc: true
7
7
pro_component: true
8
8
other_frameworks: date-range-picker
9
+
dayjs: true
9
10
---
10
11
11
12
## Example
@@ -279,6 +280,48 @@ RTL support is built-in and can be explicitly controlled through the `$enable-rt
279
280
</div>
280
281
{{< /example >}}
281
282
283
+
## Custom formats
284
+
285
+
As of v5.0.0, the `format` property is removed in Date Range Picker. Instead, utilize the `inputDateFormat` to format dates into custom strings and `inputDateParse` to parse custom strings into Date objects.
286
+
287
+
The provided code demonstrates how to use the `inputDateFormat` and `inputDateParse` properties. In this example, we use the `dayjs` library to format and parse dates.
288
+
289
+
The `inputDateFormat` property formats the date into a custom string, while the `inputDateParse` property parses a custom string into a Date object. The code showcases the date range in different formats based on locale, such as 'MMMM DD, YYYY' and 'YYYY MMMM DD', and accommodates different locales, like 'en-US' and 'es-ES'.
|`endName`| string |`null`| Set the name attribute for the end date input element. |
327
370
|`firstDayOfWeek`| number |`1`| <p>Sets the day of start week.</p> <ul><li>`0` - Sunday</li><li>`1` - Monday</li><li>`2` - Tuesday</li><li>`3` - Wednesday</li><li>`4` - Thursday</li><li>`5` - Friday</li><li>`6` - Saturday</li></ul> |
328
371
|`footer`| boolean |`false`| Toggle visibility of footer element. |
329
-
|`format`| string || Set date format. We use date-fns to format dates. Visit <ahref="https://date-fns.org/v2.28.0/docs/format"target="_blank"rel="nofollow">https://date-fns.org/v2.28.0/docs/format</a> to check accepted patterns. |
330
372
|`indicator`| boolean |`true`| Toggle visibility or set the content of the input indicator. |
373
+
|`inputDateFormat`| function |`null`| Custom function to format the selected date into a string according to a custom format. |
374
+
|`inputDateParse`| function |`null`| Custom function to parse the input value into a valid Date object. |
331
375
|`inputReadOnly`| boolean |`false`| Toggle the readonly state for the component. |
332
376
|`invalid`| boolean |`false`| Toggle the invalid state for the component. |
333
377
|`locale`| string |`'default'`| Sets the default locale for components. If not set, it is inherited from the navigator.language. |
Copy file name to clipboardExpand all lines: docs/content/migration.md
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
layout: docs
3
3
title: Migrating to v5
4
-
description: Track and review changes to the CoreUI for Bootstrap source files, documentation, and components to help you migrate from v3 to v4.
4
+
description: Track and review changes to the CoreUI for Bootstrap source files, documentation, and components to help you migrate from v4 to v5.
5
5
group: migration
6
6
aliases: "/migration/"
7
7
toc: true
@@ -89,6 +89,16 @@ Learn more by reading the new [color modes documentation]({{< docsref "/customiz
89
89
90
90
- <spanclass="badge text-warning-emphasis bg-warning-subtle">Deprecated</span> The `.btn-close-white` class has been deprecated and replaced with `data-coreui-theme="dark"` on the close button or any parent element. [See the docs for an example.]({{< docsref "/components/close-button#dark-variant" >}})
91
91
92
+
#### Date Picker
93
+
94
+
- <spanclass="badge bg-danger">Breaking</span> Removed option `format`, use `inputDateFormat` instead of. [See the docs for an example.]({{< docsref "/forms/date-picker#custom-formats" >}})
95
+
- <spanclass="badge bg-danger">Breaking</span> `dateChange.coreui.date-picker` event return only the date object, instead of the date object and formatted string.
96
+
97
+
#### Date Range Picker
98
+
99
+
- <spanclass="badge bg-danger">Breaking</span> Removed option `format`, use `inputDateFormat` instead of. [See the docs for an example.]({{< docsref "/forms/date-range-picker#custom-formats" >}})
100
+
- <spanclass="badge bg-danger">Breaking</span> `startDateChange.coreui.date-range-picker` and `endDateChange.coreui.date-range-picker` events return only the date object, instead of the date object and formatted string.
101
+
92
102
#### Dropdowns
93
103
94
104
- <spanclass="badge text-warning-emphasis bg-warning-subtle">Deprecated</span> The `.dropdown-menu-dark` class has been deprecated and replaced with `data-coreui-theme="dark"` on the dropdown or any parent element. [See the docs for an example.]({{< docsref "/components/dropdowns#dark-dropdowns" >}})
0 commit comments