@warp-ds/elements 2.10.0-next.1 → 2.10.0-next.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/api.js +1 -1
- package/dist/api.js.map +1 -1
- package/dist/custom-elements.json +233 -87
- package/dist/docs/affix/affix.md +2 -2
- package/dist/docs/affix/styling.md +1 -0
- package/dist/docs/alert/alert.md +2 -2
- package/dist/docs/alert/styling.md +1 -0
- package/dist/docs/attention/attention.md +2 -0
- package/dist/docs/attention/styling.md +1 -0
- package/dist/docs/badge/badge.md +2 -0
- package/dist/docs/badge/styling.md +1 -0
- package/dist/docs/box/box.md +22 -40
- package/dist/docs/box/examples.md +20 -38
- package/dist/docs/box/styling.md +1 -0
- package/dist/docs/breadcrumbs/breadcrumbs.md +8 -2
- package/dist/docs/breadcrumbs/examples.md +7 -1
- package/dist/docs/breadcrumbs/styling.md +1 -0
- package/dist/docs/button/button.md +73 -2
- package/dist/docs/button/styling.md +72 -0
- package/dist/docs/card/accessibility.md +74 -0
- package/dist/docs/card/api.md +9 -3
- package/dist/docs/card/card.md +236 -5
- package/dist/docs/card/examples.md +75 -0
- package/dist/docs/card/styling.md +1 -0
- package/dist/docs/card/usage.md +76 -0
- package/dist/docs/checkbox/api.md +128 -0
- package/dist/docs/checkbox/checkbox.md +134 -0
- package/dist/docs/checkbox-group/accessibility.md +71 -0
- package/dist/docs/checkbox-group/api.md +79 -0
- package/dist/docs/checkbox-group/checkbox-group.md +492 -0
- package/dist/docs/checkbox-group/examples.md +105 -0
- package/dist/docs/checkbox-group/styling.md +132 -0
- package/dist/docs/checkbox-group/usage.md +95 -0
- package/dist/docs/combobox/accessibility.md +71 -0
- package/dist/docs/combobox/api.md +60 -30
- package/dist/docs/combobox/combobox.md +205 -32
- package/dist/docs/combobox/examples.md +44 -0
- package/dist/docs/combobox/styling.md +1 -0
- package/dist/docs/combobox/usage.md +28 -0
- package/dist/docs/datepicker/accessibility.md +25 -0
- package/dist/docs/datepicker/api.md +22 -14
- package/dist/docs/datepicker/datepicker.md +208 -16
- package/dist/docs/datepicker/examples.md +75 -0
- package/dist/docs/datepicker/styling.md +1 -0
- package/dist/docs/datepicker/usage.md +84 -0
- package/dist/docs/expandable/api.md +20 -32
- package/dist/docs/expandable/examples.md +54 -0
- package/dist/docs/expandable/expandable.md +74 -32
- package/dist/docs/expandable/styling.md +1 -0
- package/dist/docs/icon/accessibility.md +5 -0
- package/dist/docs/icon/api.md +43 -0
- package/dist/docs/icon/examples.md +45 -0
- package/dist/docs/icon/icon.md +115 -0
- package/dist/docs/icon/styling.md +1 -0
- package/dist/docs/icon/usage.md +11 -0
- package/dist/docs/index.md +46 -0
- package/dist/docs/link/api.md +18 -22
- package/dist/docs/link/examples.md +75 -0
- package/dist/docs/link/link.md +113 -24
- package/dist/docs/link/styling.md +1 -0
- package/dist/docs/link/usage.md +18 -0
- package/dist/docs/modal/modal.md +2 -0
- package/dist/docs/modal/styling.md +1 -0
- package/dist/docs/modal-footer/modal-footer.md +0 -6
- package/dist/docs/modal-header/modal-header.md +0 -6
- package/dist/docs/page-indicator/page-indicator.md +2 -0
- package/dist/docs/page-indicator/styling.md +1 -0
- package/dist/docs/pagination/pagination.md +2 -0
- package/dist/docs/pagination/styling.md +1 -0
- package/dist/docs/pill/pill.md +2 -0
- package/dist/docs/pill/styling.md +1 -0
- package/dist/docs/radio/radio.md +1 -7
- package/dist/docs/select/select.md +2 -0
- package/dist/docs/select/styling.md +1 -0
- package/dist/docs/slider/slider.md +2 -0
- package/dist/docs/slider/styling.md +1 -0
- package/dist/docs/slider-thumb/slider-thumb.md +2 -0
- package/dist/docs/slider-thumb/styling.md +1 -0
- package/dist/docs/step-indicator/step-indicator.md +2 -0
- package/dist/docs/step-indicator/styling.md +1 -0
- package/dist/docs/switch/styling.md +1 -0
- package/dist/docs/switch/switch.md +2 -0
- package/dist/docs/tabs/styling.md +1 -0
- package/dist/docs/tabs/tabs.md +2 -0
- package/dist/docs/textarea/styling.md +1 -0
- package/dist/docs/textarea/textarea.md +2 -0
- package/dist/docs/textfield/styling.md +1 -0
- package/dist/docs/textfield/textfield.md +2 -0
- package/dist/index.d.ts +932 -341
- package/dist/packages/affix/affix.hydration.test.js +1 -1
- package/dist/packages/affix/affix.js +4 -4
- package/dist/packages/affix/affix.js.map +4 -4
- package/dist/packages/alert/alert.hydration.test.js +1 -1
- package/dist/packages/alert/alert.js +3 -3
- package/dist/packages/alert/alert.js.map +3 -3
- package/dist/packages/attention/attention.hydration.test.js +1 -1
- package/dist/packages/attention/attention.js +397 -446
- package/dist/packages/attention/attention.js.map +4 -4
- package/dist/packages/attention/attention.test.js +1 -1
- package/dist/packages/badge/badge.hydration.test.js +1 -1
- package/dist/packages/box/box.hydration.test.js +1 -1
- package/dist/packages/box/box.js +1 -1
- package/dist/packages/box/box.js.map +1 -1
- package/dist/packages/breadcrumbs/breadcrumbs.hydration.test.js +3 -2
- package/dist/packages/breadcrumbs/breadcrumbs.js +4 -4
- package/dist/packages/breadcrumbs/breadcrumbs.js.map +3 -3
- package/dist/packages/button/button.hydration.test.js +1 -1
- package/dist/packages/button/button.js +387 -436
- package/dist/packages/button/button.js.map +4 -4
- package/dist/packages/button/button.stories.d.ts +29 -0
- package/dist/packages/button/button.stories.js +176 -2
- package/dist/packages/button/styles.d.ts +22 -1
- package/dist/packages/button/styles.js +390 -1
- package/dist/packages/card/card.d.ts +9 -6
- package/dist/packages/card/card.hydration.test.js +1 -1
- package/dist/packages/card/card.js +3 -3
- package/dist/packages/card/card.js.map +4 -4
- package/dist/packages/checkbox/checkbox.d.ts +45 -14
- package/dist/packages/checkbox/checkbox.hydration.test.js +1 -1
- package/dist/packages/checkbox/checkbox.js +3 -3
- package/dist/packages/checkbox/checkbox.js.map +3 -3
- package/dist/packages/checkbox/checkbox.react.stories.d.ts +1 -1
- package/dist/packages/checkbox/checkbox.stories.d.ts +2 -2
- package/dist/packages/checkbox/checkbox.test.js +1 -1
- package/dist/packages/checkbox/react.d.ts +2 -2
- package/dist/packages/checkbox-group/checkbox-group.a11y.test.js +1 -1
- package/dist/packages/checkbox-group/checkbox-group.d.ts +35 -8
- package/dist/packages/checkbox-group/checkbox-group.hydration.test.js +1 -1
- package/dist/packages/checkbox-group/checkbox-group.js +6 -6
- package/dist/packages/checkbox-group/checkbox-group.js.map +4 -4
- package/dist/packages/checkbox-group/react.d.ts +3 -3
- package/dist/packages/combobox/combobox.a11y.test.js +24 -0
- package/dist/packages/combobox/combobox.d.ts +65 -45
- package/dist/packages/combobox/combobox.hydration.test.js +39 -1
- package/dist/packages/combobox/combobox.js +21 -21
- package/dist/packages/combobox/combobox.js.map +4 -4
- package/dist/packages/combobox/combobox.stories.js +28 -15
- package/dist/packages/combobox/combobox.test.js +110 -0
- package/dist/packages/datepicker/DatePicker.test.js +1 -1
- package/dist/packages/datepicker/datepicker.d.ts +22 -30
- package/dist/packages/datepicker/datepicker.hydration.test.js +1 -1
- package/dist/packages/datepicker/datepicker.js +49 -49
- package/dist/packages/datepicker/datepicker.js.map +4 -4
- package/dist/packages/datepicker/datepicker.test.js +1 -1
- package/dist/packages/expandable/expandable.d.ts +11 -32
- package/dist/packages/expandable/expandable.hydration.test.js +1 -1
- package/dist/packages/expandable/expandable.js +11 -11
- package/dist/packages/expandable/expandable.js.map +3 -3
- package/dist/packages/expandable/expandable.react.stories.d.ts +2 -2
- package/dist/packages/expandable/react.d.ts +1 -1
- package/dist/packages/icon/icon.d.ts +16 -4
- package/dist/packages/icon/icon.hydration.test.js +1 -1
- package/dist/packages/icon/icon.js +2 -2
- package/dist/packages/icon/icon.js.map +3 -3
- package/dist/packages/icon/icon.react.stories.d.ts +1 -1
- package/dist/packages/icon/react.d.ts +2 -2
- package/dist/packages/link/link.d.ts +15 -16
- package/dist/packages/link/link.hydration.test.js +1 -1
- package/dist/packages/link/link.js +420 -190
- package/dist/packages/link/link.js.map +4 -4
- package/dist/packages/link/link.test.js +1 -1
- package/dist/packages/link/styles.d.ts +5 -0
- package/dist/packages/link/styles.js +80 -0
- package/dist/packages/modal/modal.d.ts +1 -0
- package/dist/packages/modal/modal.hydration.test.js +1 -1
- package/dist/packages/modal/modal.js +4 -4
- package/dist/packages/modal/modal.js.map +3 -3
- package/dist/packages/modal/modal.react.stories.d.ts +4 -4
- package/dist/packages/modal/modal.react.stories.js +9 -1
- package/dist/packages/modal/react.d.ts +34 -4
- package/dist/packages/modal/react.js +30 -0
- package/dist/packages/modal-header/modal-header.js +11 -9
- package/dist/packages/modal-header/modal-header.js.map +4 -4
- package/dist/packages/page-indicator/page-indicator.hydration.test.js +1 -1
- package/dist/packages/page-indicator/page-indicator.js +5 -5
- package/dist/packages/page-indicator/page-indicator.js.map +3 -3
- package/dist/packages/pagination/pagination.hydration.test.js +1 -1
- package/dist/packages/pagination/pagination.js +4 -4
- package/dist/packages/pagination/pagination.js.map +4 -4
- package/dist/packages/pagination/pagination.test.js +1 -1
- package/dist/packages/pill/pill.hydration.test.js +1 -1
- package/dist/packages/pill/pill.js +3 -3
- package/dist/packages/pill/pill.js.map +4 -4
- package/dist/packages/radio/radio.hydration.test.js +1 -1
- package/dist/packages/radio/radio.js +3 -3
- package/dist/packages/radio/radio.js.map +3 -3
- package/dist/packages/radio/radio.test.js +1 -1
- package/dist/packages/radio-group/radio-group.a11y.test.js +7 -3
- package/dist/packages/radio-group/radio-group.hydration.test.js +6 -2
- package/dist/packages/radio-group/radio-group.js +11 -11
- package/dist/packages/radio-group/radio-group.js.map +4 -4
- package/dist/packages/select/select.a11y.test.js +6 -2
- package/dist/packages/select/select.hydration.test.js +1 -1
- package/dist/packages/select/select.js +7 -7
- package/dist/packages/select/select.js.map +4 -4
- package/dist/packages/select/select.test.js +4 -2
- package/dist/packages/slider/slider.hydration.test.js +7 -2
- package/dist/packages/slider/slider.js +5 -5
- package/dist/packages/slider/slider.js.map +4 -4
- package/dist/packages/slider/slider.react.stories.js +2 -2
- package/dist/packages/slider/slider.test.js +1 -1
- package/dist/packages/slider-thumb/slider-thumb.hydration.test.js +1 -1
- package/dist/packages/slider-thumb/slider-thumb.js +20 -20
- package/dist/packages/slider-thumb/slider-thumb.js.map +4 -4
- package/dist/packages/step/step.hydration.test.js +1 -1
- package/dist/packages/step/step.js +8 -8
- package/dist/packages/step/step.js.map +4 -4
- package/dist/packages/step-indicator/step-indicator.hydration.test.js +1 -1
- package/dist/packages/switch/switch.a11y.test.js +1 -1
- package/dist/packages/switch/switch.hydration.test.js +1 -1
- package/dist/packages/switch/switch.js +1 -1
- package/dist/packages/switch/switch.js.map +1 -1
- package/dist/packages/tab/tab.hydration.test.js +1 -1
- package/dist/packages/tab/tab.js +10 -10
- package/dist/packages/tab/tab.js.map +2 -2
- package/dist/packages/tab-panel/tab-panel.hydration.test.js +1 -1
- package/dist/packages/tab-panel/tab-panel.js +3 -3
- package/dist/packages/tab-panel/tab-panel.js.map +2 -2
- package/dist/packages/tabs/tabs.a11y.test.js +2 -2
- package/dist/packages/tabs/tabs.hydration.test.js +1 -1
- package/dist/packages/tabs/tabs.js +1 -1
- package/dist/packages/tabs/tabs.js.map +2 -2
- package/dist/packages/tabs/tabs.test.js +4 -4
- package/dist/packages/textarea/textarea.hydration.test.js +1 -1
- package/dist/packages/textarea/textarea.js +4 -4
- package/dist/packages/textarea/textarea.js.map +3 -3
- package/dist/packages/textarea/textarea.test.js +1 -1
- package/dist/packages/textfield/textfield.hydration.test.js +1 -1
- package/dist/packages/textfield/textfield.js +1 -1
- package/dist/packages/textfield/textfield.js.map +1 -1
- package/dist/packages/textfield/textfield.test.js +1 -1
- package/dist/packages/toast/toast.js +6 -6
- package/dist/packages/toast/toast.js.map +4 -4
- package/dist/packages/toast/toast.stories.d.ts +1 -5
- package/dist/packages/toast/toast.stories.js +0 -17
- package/dist/packages/toast-container/toast-container.js +2 -2
- package/dist/packages/toast-container/toast-container.js.map +2 -2
- package/dist/web-types.json +238 -103
- package/eik/index.js +2536 -0
- package/package.json +15 -9
- package/dist/docs/modal-footer/accessibility.md +0 -1
- package/dist/docs/modal-footer/examples.md +0 -1
- package/dist/docs/modal-footer/usage.md +0 -1
- package/dist/docs/modal-header/accessibility.md +0 -1
- package/dist/docs/modal-header/examples.md +0 -1
- package/dist/docs/modal-header/usage.md +0 -1
- package/dist/docs/radio/accessibility.md +0 -1
- package/dist/docs/radio/examples.md +0 -1
- package/dist/docs/radio/usage.md +0 -1
- package/dist/packages/button/styles/w-button.styles.d.ts +0 -1
- package/dist/packages/button/styles/w-button.styles.js +0 -282
- package/dist/packages/link/styles/w-link.styles.d.ts +0 -1
- package/dist/packages/link/styles/w-link.styles.js +0 -213
|
@@ -6,14 +6,198 @@ An input for dates.
|
|
|
6
6
|
|
|
7
7
|
Uses the `lang` attribute on either the element or on `<html>` to determine the locale options.
|
|
8
8
|
|
|
9
|
-
[See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/forms-datepicker--docs)
|
|
10
|
-
|
|
11
9
|
## Usage
|
|
12
10
|
|
|
11
|
+
Datepicker lets users type or choose a calendar date.
|
|
12
|
+
|
|
13
|
+
Use `w-datepicker` when the user needs to provide one specific date, such as a travel date, appointment date, or deadline. The component is form-associated and submits an ISO date value.
|
|
14
|
+
|
|
15
|
+
### Basic Datepicker
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<w-datepicker label="Date" name="date"></w-datepicker>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Always provide a visible `label`.
|
|
22
|
+
|
|
23
|
+
### Value
|
|
24
|
+
|
|
25
|
+
Use `value` to set the selected date. The value should use `YYYY-MM-DD` format.
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<w-datepicker label="Start date" name="start-date" value="2026-06-15"></w-datepicker>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The same value is submitted with the form.
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<form>
|
|
35
|
+
<w-datepicker label="Departure date" name="departure"></w-datepicker>
|
|
36
|
+
<w-button type="submit">Search</w-button>
|
|
37
|
+
</form>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Locale
|
|
41
|
+
|
|
42
|
+
Datepicker uses the `lang` attribute on the component, or the `lang` attribute on `<html>`, to choose locale-specific calendar labels and formatting.
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<w-datepicker label="Dato" name="date" lang="nb"></w-datepicker>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The component includes built-in locale support for `en`, `nb`, `sv`, `da`, and `fi`.
|
|
49
|
+
|
|
50
|
+
### Formatting
|
|
51
|
+
|
|
52
|
+
Use `header-format`, `weekday-format`, and `day-format` to control calendar display and accessible day labels.
|
|
53
|
+
|
|
54
|
+
```html
|
|
55
|
+
<w-datepicker
|
|
56
|
+
label="Date"
|
|
57
|
+
name="date"
|
|
58
|
+
header-format="MMMM yyyy"
|
|
59
|
+
weekday-format="EEEEEE"
|
|
60
|
+
day-format="PPPP"
|
|
61
|
+
></w-datepicker>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
These formats use `date-fns/format` syntax. Keep `day-format` descriptive because it is used as the accessible name for each day in the calendar.
|
|
65
|
+
|
|
66
|
+
### Disable Dates
|
|
67
|
+
|
|
68
|
+
Use `isDayDisabled` to prevent users from selecting certain dates from the calendar.
|
|
69
|
+
|
|
70
|
+
This property must be set on the element instance in JavaScript.
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<w-datepicker id="booking-date" label="Booking date" name="booking-date"></w-datepicker>
|
|
74
|
+
|
|
75
|
+
<script type="module">
|
|
76
|
+
const datepicker = document.querySelector('#booking-date');
|
|
77
|
+
|
|
78
|
+
datepicker.isDayDisabled = (day) => day.getDay() === 0;
|
|
79
|
+
</script>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Disabled dates cannot be selected from the calendar.
|
|
83
|
+
|
|
84
|
+
### About change events
|
|
85
|
+
|
|
86
|
+
With events the datepicker works much like the native `<input type="date">`:
|
|
87
|
+
|
|
88
|
+
- When the user types in the input field the component fires [`input` events](https://developer.mozilla.org/en-US/docs/Web/API/Element/input_event).
|
|
89
|
+
- When the user clicks a date in the calendar the component fires [`change` events](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event).
|
|
90
|
+
|
|
91
|
+
Note that the component does not fire a `change` event when typing in the input field. This is intentional.
|
|
92
|
+
|
|
93
|
+
You can listen to the [`blur` event](https://developer.mozilla.org/en-US/docs/Web/API/Element/blur_event) if you only care about getting a value, no matter if it was typed or chosen via the calendar. Note that the `blur` event might not fire if the user types and submits the form without leaving the input field. If you use the `blur` event to update JavaScript state you should read the value from the datepicker in your `submit` handler as well.
|
|
94
|
+
|
|
13
95
|
## Accessibility
|
|
14
96
|
|
|
97
|
+
Datepicker renders a labeled date input with a button that opens a calendar dialog. The calendar uses a grid of dates and moves focus into the calendar when it opens.
|
|
98
|
+
|
|
99
|
+
### Provide A Label
|
|
100
|
+
|
|
101
|
+
Always provide a visible label.
|
|
102
|
+
|
|
103
|
+
```html
|
|
104
|
+
<w-datepicker label="Departure date" name="departure"></w-datepicker>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The label should describe the date being requested. Avoid generic labels such as "Date" when there are several date fields on the same page.
|
|
108
|
+
|
|
109
|
+
### Calendar Dialog
|
|
110
|
+
|
|
111
|
+
The calendar popup is rendered as a dialog with `aria-modal="true"`. The month heading is announced with `aria-live="polite"` when users move between months.
|
|
112
|
+
|
|
113
|
+
Each date in the calendar grid has an accessible name formatted using `day-format`.
|
|
114
|
+
|
|
115
|
+
```html
|
|
116
|
+
<w-datepicker label="Date" name="date" day-format="PPPP"></w-datepicker>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Use a descriptive `day-format` so screen reader users hear the full date, not only the day number.
|
|
120
|
+
See [the Date FNS docs](https://date-fns.org/v4.1.0/docs/format) for formatting options.
|
|
121
|
+
|
|
15
122
|
## Examples
|
|
16
123
|
|
|
124
|
+
### Basic
|
|
125
|
+
|
|
126
|
+
<elements-example>
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<w-datepicker label="Date" name="date"></w-datepicker>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
</elements-example>
|
|
133
|
+
|
|
134
|
+
### With Value
|
|
135
|
+
|
|
136
|
+
<elements-example>
|
|
137
|
+
|
|
138
|
+
```html
|
|
139
|
+
<w-datepicker label="Start date" name="start-date" value="2026-06-15"></w-datepicker>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
</elements-example>
|
|
143
|
+
|
|
144
|
+
### Locale
|
|
145
|
+
|
|
146
|
+
<elements-example>
|
|
147
|
+
|
|
148
|
+
```html
|
|
149
|
+
<w-datepicker label="Dato" name="date" lang="nb"></w-datepicker>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
</elements-example>
|
|
153
|
+
|
|
154
|
+
### Custom Formats
|
|
155
|
+
|
|
156
|
+
<elements-example>
|
|
157
|
+
|
|
158
|
+
```html
|
|
159
|
+
<w-datepicker
|
|
160
|
+
label="Date"
|
|
161
|
+
name="date"
|
|
162
|
+
header-format="MMMM yyyy"
|
|
163
|
+
weekday-format="EEEEEE"
|
|
164
|
+
day-format="PPPP"
|
|
165
|
+
></w-datepicker>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
</elements-example>
|
|
169
|
+
|
|
170
|
+
### Form Associated
|
|
171
|
+
|
|
172
|
+
<elements-example>
|
|
173
|
+
|
|
174
|
+
```html
|
|
175
|
+
<form>
|
|
176
|
+
<w-datepicker label="Departure date" name="departure"></w-datepicker>
|
|
177
|
+
<w-button type="submit">Search</w-button>
|
|
178
|
+
</form>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
</elements-example>
|
|
182
|
+
|
|
183
|
+
### Disabled Calendar Dates
|
|
184
|
+
|
|
185
|
+
<elements-example>
|
|
186
|
+
|
|
187
|
+
```html
|
|
188
|
+
<w-datepicker id="booking-date" label="Booking date" name="booking-date"></w-datepicker>
|
|
189
|
+
|
|
190
|
+
<script type="module">
|
|
191
|
+
const datepicker = document.querySelector('#booking-date');
|
|
192
|
+
|
|
193
|
+
datepicker.isDayDisabled = (day) => day.getDay() === 0;
|
|
194
|
+
</script>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
</elements-example>
|
|
198
|
+
|
|
199
|
+
## Styling API
|
|
200
|
+
|
|
17
201
|
## `<w-datepicker>` API
|
|
18
202
|
|
|
19
203
|
Unless otherwise noted all properties are HTML attributes (as opposed to JavaScript object properties).
|
|
@@ -23,15 +207,15 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
23
207
|
| Name | Type | Default | Summary |
|
|
24
208
|
|-|-|-|-|
|
|
25
209
|
| calendar (JS only) | `HTMLDivElement` | `-` | - |
|
|
26
|
-
| day-format | `string` | `'PPPP'` |
|
|
27
|
-
| header-format | `string` | `'MMMM yyyy'` |
|
|
210
|
+
| day-format | `string` | `'PPPP'` | The date format used for calendar day accessible names. |
|
|
211
|
+
| header-format | `string` | `'MMMM yyyy'` | The date format used in the calendar header. |
|
|
28
212
|
| input (JS only) | `HTMLInputElement` | `-` | - |
|
|
29
213
|
| isCalendarOpen (JS only) | `boolean` | `false` | - |
|
|
30
|
-
| isDayDisabled (JS only) | `(day: Date) => boolean` | `-` |
|
|
31
|
-
| label | `string` | `-` |
|
|
32
|
-
| lang | `string` | `-` |
|
|
214
|
+
| isDayDisabled (JS only) | `(day: Date) => boolean` | `-` | Function used to disable dates in the calendar. |
|
|
215
|
+
| label | `string` | `-` | The label displayed above the date input. |
|
|
216
|
+
| lang | `string` | `-` | The locale used for calendar labels and date formatting. |
|
|
33
217
|
| month (JS only) | `unknown` | `-` | - |
|
|
34
|
-
| name | `string` | `-` |
|
|
218
|
+
| name | `string` | `-` | The name submitted with the date value. |
|
|
35
219
|
| navigationDate (JS only) | `Date` | `-` | - |
|
|
36
220
|
| previousMonthButton (JS only) | `HTMLButtonElement` | `-` | This is the first focusable element, needed for the modal focus trap. |
|
|
37
221
|
| selectedCell (JS only) | `HTMLTableCellElement` | `-` | - |
|
|
@@ -39,8 +223,8 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
39
223
|
| shadowRootOptions (JS only) | `object` | `{ ...LitElement.shadowRootOptions, delegatesFocus: true, }` | - |
|
|
40
224
|
| todayCell (JS only) | `HTMLTableCellElement` | `-` | - |
|
|
41
225
|
| toggleButton (JS only) | `HTMLButtonElement` | `-` | - |
|
|
42
|
-
| value | `string` | `-` |
|
|
43
|
-
| weekday-format | `string` | `'EEEEEE'` |
|
|
226
|
+
| value | `string` | `-` | The selected date value. |
|
|
227
|
+
| weekday-format | `string` | `'EEEEEE'` | The weekday format shown above the calendar grid. |
|
|
44
228
|
| weeks (JS only) | `unknown` | `-` | - |
|
|
45
229
|
| wrapper (JS only) | `HTMLDivElement` | `-` | - |
|
|
46
230
|
|
|
@@ -55,7 +239,7 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
55
239
|
|
|
56
240
|
#### day-format
|
|
57
241
|
|
|
58
|
-
|
|
242
|
+
The date format used for calendar day accessible names.
|
|
59
243
|
|
|
60
244
|
The syntax is defined by [date-fns/format](https://date-fns.org/v4.1.0/docs/format).
|
|
61
245
|
|
|
@@ -64,7 +248,7 @@ The syntax is defined by [date-fns/format](https://date-fns.org/v4.1.0/docs/form
|
|
|
64
248
|
|
|
65
249
|
#### header-format
|
|
66
250
|
|
|
67
|
-
|
|
251
|
+
The date format used in the calendar header.
|
|
68
252
|
|
|
69
253
|
The syntax is defined by [date-fns/format](https://date-fns.org/v4.1.0/docs/format).
|
|
70
254
|
|
|
@@ -87,23 +271,27 @@ The syntax is defined by [date-fns/format](https://date-fns.org/v4.1.0/docs/form
|
|
|
87
271
|
|
|
88
272
|
#### isDayDisabled (JS only)
|
|
89
273
|
|
|
90
|
-
|
|
274
|
+
Function used to disable dates in the calendar.
|
|
91
275
|
|
|
92
|
-
|
|
276
|
+
Set this on the element instance in JavaScript, not as an HTML attribute. Disabled dates cannot be selected from the calendar.
|
|
93
277
|
|
|
94
278
|
- Type: `(day: Date) => boolean`
|
|
95
279
|
- Default: `-`
|
|
96
280
|
|
|
97
281
|
#### label
|
|
98
282
|
|
|
283
|
+
The label displayed above the date input.
|
|
99
284
|
|
|
285
|
+
Use this to give the datepicker a visible and accessible name.
|
|
100
286
|
|
|
101
287
|
- Type: `string`
|
|
102
288
|
- Default: `-`
|
|
103
289
|
|
|
104
290
|
#### lang
|
|
105
291
|
|
|
106
|
-
|
|
292
|
+
The locale used for calendar labels and date formatting.
|
|
293
|
+
|
|
294
|
+
This takes precedence over the `<html>` `lang` attribute. Supported built-in locales are `en`, `nb`, `sv`, `da`, and `fi`.
|
|
107
295
|
|
|
108
296
|
- Type: `string`
|
|
109
297
|
- Default: `-`
|
|
@@ -117,7 +305,9 @@ Takes precedence over the `<html>` lang attribute.
|
|
|
117
305
|
|
|
118
306
|
#### name
|
|
119
307
|
|
|
308
|
+
The name submitted with the date value.
|
|
120
309
|
|
|
310
|
+
Use this when the datepicker belongs to a form and its value should be included in form data.
|
|
121
311
|
|
|
122
312
|
- Type: `string`
|
|
123
313
|
- Default: `-`
|
|
@@ -177,14 +367,16 @@ the query will point to an element that doesn't exist anymore.
|
|
|
177
367
|
|
|
178
368
|
#### value
|
|
179
369
|
|
|
370
|
+
The selected date value.
|
|
180
371
|
|
|
372
|
+
Use an ISO date string in `YYYY-MM-DD` format. The value is submitted with the form and is reset to its initial value when the form resets.
|
|
181
373
|
|
|
182
374
|
- Type: `string`
|
|
183
375
|
- Default: `-`
|
|
184
376
|
|
|
185
377
|
#### weekday-format
|
|
186
378
|
|
|
187
|
-
|
|
379
|
+
The weekday format shown above the calendar grid.
|
|
188
380
|
|
|
189
381
|
The syntax is defined by [date-fns/format](https://date-fns.org/v4.1.0/docs/format).
|
|
190
382
|
|
|
@@ -1 +1,76 @@
|
|
|
1
1
|
## Examples
|
|
2
|
+
|
|
3
|
+
### Basic
|
|
4
|
+
|
|
5
|
+
<elements-example>
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<w-datepicker label="Date" name="date"></w-datepicker>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
</elements-example>
|
|
12
|
+
|
|
13
|
+
### With Value
|
|
14
|
+
|
|
15
|
+
<elements-example>
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<w-datepicker label="Start date" name="start-date" value="2026-06-15"></w-datepicker>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
</elements-example>
|
|
22
|
+
|
|
23
|
+
### Locale
|
|
24
|
+
|
|
25
|
+
<elements-example>
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<w-datepicker label="Dato" name="date" lang="nb"></w-datepicker>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
</elements-example>
|
|
32
|
+
|
|
33
|
+
### Custom Formats
|
|
34
|
+
|
|
35
|
+
<elements-example>
|
|
36
|
+
|
|
37
|
+
```html
|
|
38
|
+
<w-datepicker
|
|
39
|
+
label="Date"
|
|
40
|
+
name="date"
|
|
41
|
+
header-format="MMMM yyyy"
|
|
42
|
+
weekday-format="EEEEEE"
|
|
43
|
+
day-format="PPPP"
|
|
44
|
+
></w-datepicker>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
</elements-example>
|
|
48
|
+
|
|
49
|
+
### Form Associated
|
|
50
|
+
|
|
51
|
+
<elements-example>
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<form>
|
|
55
|
+
<w-datepicker label="Departure date" name="departure"></w-datepicker>
|
|
56
|
+
<w-button type="submit">Search</w-button>
|
|
57
|
+
</form>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
</elements-example>
|
|
61
|
+
|
|
62
|
+
### Disabled Calendar Dates
|
|
63
|
+
|
|
64
|
+
<elements-example>
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<w-datepicker id="booking-date" label="Booking date" name="booking-date"></w-datepicker>
|
|
68
|
+
|
|
69
|
+
<script type="module">
|
|
70
|
+
const datepicker = document.querySelector('#booking-date');
|
|
71
|
+
|
|
72
|
+
datepicker.isDayDisabled = (day) => day.getDay() === 0;
|
|
73
|
+
</script>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
</elements-example>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Styling API
|
|
@@ -1 +1,85 @@
|
|
|
1
1
|
## Usage
|
|
2
|
+
|
|
3
|
+
Datepicker lets users type or choose a calendar date.
|
|
4
|
+
|
|
5
|
+
Use `w-datepicker` when the user needs to provide one specific date, such as a travel date, appointment date, or deadline. The component is form-associated and submits an ISO date value.
|
|
6
|
+
|
|
7
|
+
### Basic Datepicker
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<w-datepicker label="Date" name="date"></w-datepicker>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Always provide a visible `label`.
|
|
14
|
+
|
|
15
|
+
### Value
|
|
16
|
+
|
|
17
|
+
Use `value` to set the selected date. The value should use `YYYY-MM-DD` format.
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<w-datepicker label="Start date" name="start-date" value="2026-06-15"></w-datepicker>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The same value is submitted with the form.
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<form>
|
|
27
|
+
<w-datepicker label="Departure date" name="departure"></w-datepicker>
|
|
28
|
+
<w-button type="submit">Search</w-button>
|
|
29
|
+
</form>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Locale
|
|
33
|
+
|
|
34
|
+
Datepicker uses the `lang` attribute on the component, or the `lang` attribute on `<html>`, to choose locale-specific calendar labels and formatting.
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<w-datepicker label="Dato" name="date" lang="nb"></w-datepicker>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The component includes built-in locale support for `en`, `nb`, `sv`, `da`, and `fi`.
|
|
41
|
+
|
|
42
|
+
### Formatting
|
|
43
|
+
|
|
44
|
+
Use `header-format`, `weekday-format`, and `day-format` to control calendar display and accessible day labels.
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<w-datepicker
|
|
48
|
+
label="Date"
|
|
49
|
+
name="date"
|
|
50
|
+
header-format="MMMM yyyy"
|
|
51
|
+
weekday-format="EEEEEE"
|
|
52
|
+
day-format="PPPP"
|
|
53
|
+
></w-datepicker>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
These formats use `date-fns/format` syntax. Keep `day-format` descriptive because it is used as the accessible name for each day in the calendar.
|
|
57
|
+
|
|
58
|
+
### Disable Dates
|
|
59
|
+
|
|
60
|
+
Use `isDayDisabled` to prevent users from selecting certain dates from the calendar.
|
|
61
|
+
|
|
62
|
+
This property must be set on the element instance in JavaScript.
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<w-datepicker id="booking-date" label="Booking date" name="booking-date"></w-datepicker>
|
|
66
|
+
|
|
67
|
+
<script type="module">
|
|
68
|
+
const datepicker = document.querySelector('#booking-date');
|
|
69
|
+
|
|
70
|
+
datepicker.isDayDisabled = (day) => day.getDay() === 0;
|
|
71
|
+
</script>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Disabled dates cannot be selected from the calendar.
|
|
75
|
+
|
|
76
|
+
### About change events
|
|
77
|
+
|
|
78
|
+
With events the datepicker works much like the native `<input type="date">`:
|
|
79
|
+
|
|
80
|
+
- When the user types in the input field the component fires [`input` events](https://developer.mozilla.org/en-US/docs/Web/API/Element/input_event).
|
|
81
|
+
- When the user clicks a date in the calendar the component fires [`change` events](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event).
|
|
82
|
+
|
|
83
|
+
Note that the component does not fire a `change` event when typing in the input field. This is intentional.
|
|
84
|
+
|
|
85
|
+
You can listen to the [`blur` event](https://developer.mozilla.org/en-US/docs/Web/API/Element/blur_event) if you only care about getting a value, no matter if it was typed or chosen via the calendar. Note that the `blur` event might not fire if the user types and submits the form without leaving the input field. If you use the `blur` event to update JavaScript state you should read the value from the datepicker in your `submit` handler as well.
|
|
@@ -6,57 +6,43 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
6
6
|
|
|
7
7
|
| Name | Type | Default | Summary |
|
|
8
8
|
|-|-|-|-|
|
|
9
|
-
|
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
| no-chevron | `boolean` | `false` | - |
|
|
19
|
-
| title | `string` | `-` | - |
|
|
9
|
+
| animated | `boolean` | `false` | Will animate the expansion/collapse |
|
|
10
|
+
| bleed | `boolean` | `false` | Will make the expandable full-width on the sm breakpoint size |
|
|
11
|
+
| box | `boolean` | `false` | Will make the expandable a Box |
|
|
12
|
+
| button-class | `string` | `-` | **Deprecated**: Probably does not work the way you expect. The class must exist inside the shadow DOM of the component. |
|
|
13
|
+
| content-class | `string` | `-` | **Deprecated**: Probably does not work the way you expect. The class must exist inside the shadow DOM of the component. |
|
|
14
|
+
| expanded | `boolean` | `false` | Controls component's expanded state |
|
|
15
|
+
| heading-level | `number` | `-` | Wrap the toggle button in a heading element with the specified level. If headingLevel is not specified, the button will not be wrapped by a heading element. |
|
|
16
|
+
| no-chevron | `boolean` | `false` | Controls chevron visibility |
|
|
17
|
+
| title | `string` | `-` | Component title. Used to display the title value which is always present regardless of whether the component is open or closed. |
|
|
20
18
|
|
|
21
19
|
### Property Details
|
|
22
20
|
|
|
23
|
-
#### _hasTitle
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- Type: `boolean`
|
|
28
|
-
- Default: `true`
|
|
29
|
-
|
|
30
|
-
#### _showChevronUp
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
- Type: `boolean`
|
|
35
|
-
- Default: `false`
|
|
36
|
-
|
|
37
21
|
#### animated
|
|
38
22
|
|
|
39
|
-
|
|
23
|
+
Will animate the expansion/collapse
|
|
40
24
|
|
|
41
25
|
- Type: `boolean`
|
|
42
26
|
- Default: `false`
|
|
43
27
|
|
|
44
28
|
#### bleed
|
|
45
29
|
|
|
46
|
-
|
|
30
|
+
Will make the expandable full-width on the sm breakpoint size
|
|
47
31
|
|
|
48
32
|
- Type: `boolean`
|
|
49
33
|
- Default: `false`
|
|
50
34
|
|
|
51
35
|
#### box
|
|
52
36
|
|
|
53
|
-
|
|
37
|
+
Will make the expandable a Box
|
|
54
38
|
|
|
55
39
|
- Type: `boolean`
|
|
56
40
|
- Default: `false`
|
|
57
41
|
|
|
58
42
|
#### button-class
|
|
59
43
|
|
|
44
|
+
**Deprecated**: Probably does not work the way you expect. The class must exist inside the shadow DOM of the component.
|
|
45
|
+
|
|
60
46
|
|
|
61
47
|
|
|
62
48
|
- Type: `string`
|
|
@@ -64,6 +50,8 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
64
50
|
|
|
65
51
|
#### content-class
|
|
66
52
|
|
|
53
|
+
**Deprecated**: Probably does not work the way you expect. The class must exist inside the shadow DOM of the component.
|
|
54
|
+
|
|
67
55
|
|
|
68
56
|
|
|
69
57
|
- Type: `string`
|
|
@@ -71,28 +59,28 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
71
59
|
|
|
72
60
|
#### expanded
|
|
73
61
|
|
|
74
|
-
|
|
62
|
+
Controls component's expanded state
|
|
75
63
|
|
|
76
64
|
- Type: `boolean`
|
|
77
65
|
- Default: `false`
|
|
78
66
|
|
|
79
67
|
#### heading-level
|
|
80
68
|
|
|
81
|
-
|
|
69
|
+
Wrap the toggle button in a heading element with the specified level. If headingLevel is not specified, the button will not be wrapped by a heading element.
|
|
82
70
|
|
|
83
71
|
- Type: `number`
|
|
84
72
|
- Default: `-`
|
|
85
73
|
|
|
86
74
|
#### no-chevron
|
|
87
75
|
|
|
88
|
-
|
|
76
|
+
Controls chevron visibility
|
|
89
77
|
|
|
90
78
|
- Type: `boolean`
|
|
91
79
|
- Default: `false`
|
|
92
80
|
|
|
93
81
|
#### title
|
|
94
82
|
|
|
95
|
-
|
|
83
|
+
Component title. Used to display the title value which is always present regardless of whether the component is open or closed.
|
|
96
84
|
|
|
97
85
|
- Type: `string`
|
|
98
86
|
- Default: `-`
|
|
@@ -1 +1,55 @@
|
|
|
1
1
|
## Examples
|
|
2
|
+
|
|
3
|
+
<elements-example>
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<w-expandable title="I'm expandable" animated>
|
|
7
|
+
<p>with expanded content</p>
|
|
8
|
+
</w-expandable>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
</elements-example>
|
|
12
|
+
|
|
13
|
+
### Expandable box
|
|
14
|
+
|
|
15
|
+
<elements-example>
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<w-expandable title="I'm expandable" animated box>
|
|
19
|
+
<p>with expanded content</p>
|
|
20
|
+
</w-expandable>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
</elements-example>
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Expandable box with custom title
|
|
27
|
+
|
|
28
|
+
This can be used if more control over styling is needed than the `title` prop allows
|
|
29
|
+
|
|
30
|
+
<elements-example>
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<w-expandable animated box>
|
|
34
|
+
<div slot="title" class="flex flex-row items-center">
|
|
35
|
+
<w-icon-bag-16></w-icon-bag-16>
|
|
36
|
+
<p class="ml-8 mb-0">This is a title with an icon</p>
|
|
37
|
+
</div>
|
|
38
|
+
<p>with expanded content</p>
|
|
39
|
+
</w-expandable>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
</elements-example>
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### With expanded prop
|
|
46
|
+
|
|
47
|
+
<elements-example>
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<w-expandable animated box title="I'm expanded by default" expanded>
|
|
51
|
+
<p>content should be visible</p>
|
|
52
|
+
</w-expandable>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
</elements-example>
|