@warp-ds/elements 2.10.0-next.3 → 2.10.0-next.5
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/dist/custom-elements.json +77 -14
- package/dist/docs/affix/affix.md +2 -0
- package/dist/docs/affix/styling.md +1 -0
- package/dist/docs/alert/alert.md +2 -0
- 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 -38
- package/dist/docs/box/examples.md +20 -38
- package/dist/docs/box/styling.md +1 -0
- package/dist/docs/breadcrumbs/breadcrumbs.md +8 -0
- package/dist/docs/breadcrumbs/examples.md +7 -1
- package/dist/docs/breadcrumbs/styling.md +1 -0
- package/dist/docs/button/button.md +73 -0
- package/dist/docs/button/styling.md +72 -0
- package/dist/docs/card/card.md +2 -0
- package/dist/docs/card/styling.md +1 -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/combobox.md +2 -0
- package/dist/docs/combobox/styling.md +1 -0
- package/dist/docs/datepicker/accessibility.md +25 -0
- package/dist/docs/datepicker/api.md +22 -14
- package/dist/docs/datepicker/datepicker.md +208 -14
- 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/icon.md +2 -0
- package/dist/docs/icon/styling.md +1 -0
- package/dist/docs/link/link.md +2 -0
- package/dist/docs/link/styling.md +1 -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 +0 -6
- 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 +164 -128
- package/dist/packages/affix/affix.hydration.test.js +1 -1
- package/dist/packages/alert/alert.hydration.test.js +1 -1
- 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/badge/badge.hydration.test.js +1 -1
- package/dist/packages/box/box.hydration.test.js +1 -1
- package/dist/packages/breadcrumbs/breadcrumbs.hydration.test.js +3 -2
- 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.hydration.test.js +1 -1
- package/dist/packages/checkbox/checkbox.d.ts +5 -3
- package/dist/packages/checkbox/checkbox.hydration.test.js +1 -1
- package/dist/packages/checkbox/checkbox.js +2 -2
- 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/react.d.ts +2 -2
- package/dist/packages/checkbox-group/checkbox-group.d.ts +5 -3
- 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 +3 -3
- package/dist/packages/checkbox-group/react.d.ts +3 -3
- 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.map +2 -2
- 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.map +2 -2
- 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.hydration.test.js +1 -1
- 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/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 +2 -2
- package/dist/packages/page-indicator/page-indicator.hydration.test.js +1 -1
- package/dist/packages/pagination/pagination.hydration.test.js +1 -1
- package/dist/packages/pill/pill.hydration.test.js +1 -1
- package/dist/packages/radio/radio.hydration.test.js +1 -1
- package/dist/packages/radio/radio.js.map +1 -1
- package/dist/packages/radio-group/radio-group.a11y.test.js +6 -2
- package/dist/packages/radio-group/radio-group.hydration.test.js +6 -2
- package/dist/packages/radio-group/radio-group.js +2 -2
- 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.test.js +4 -2
- package/dist/packages/slider/slider.hydration.test.js +7 -2
- package/dist/packages/slider/slider.js.map +1 -1
- package/dist/packages/slider/slider.react.stories.js +2 -2
- package/dist/packages/slider-thumb/slider-thumb.hydration.test.js +1 -1
- package/dist/packages/step/step.hydration.test.js +1 -1
- package/dist/packages/step-indicator/step-indicator.hydration.test.js +1 -1
- package/dist/packages/switch/switch.hydration.test.js +1 -1
- package/dist/packages/tab/tab.hydration.test.js +1 -1
- package/dist/packages/tab-panel/tab-panel.hydration.test.js +1 -1
- package/dist/packages/tabs/tabs.a11y.test.js +1 -1
- package/dist/packages/tabs/tabs.hydration.test.js +1 -1
- package/dist/packages/tabs/tabs.test.js +3 -3
- package/dist/packages/textarea/textarea.hydration.test.js +1 -1
- package/dist/packages/textfield/textfield.hydration.test.js +1 -1
- package/dist/web-types.json +91 -28
- package/eik/index.js +115 -0
- package/package.json +7 -4
- 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
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
## Styling API
|
|
2
|
+
|
|
3
|
+
This section documents the supported styling hooks for `<w-checkbox>`.
|
|
4
|
+
|
|
5
|
+
Use these hooks to customize appearance without relying on internal structure or selectors.
|
|
6
|
+
|
|
7
|
+
### Parts
|
|
8
|
+
|
|
9
|
+
The checkbox exposes a small set of parts that can be targeted for last‑mile layout or typography tweaks.
|
|
10
|
+
|
|
11
|
+
| Part | Targets | Typical use |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| `base` | wrapper element | layout adjustments (spacing, alignment) |
|
|
14
|
+
| `control` | checkbox control (box) | minor alignment or sizing tweaks |
|
|
15
|
+
| `input` | native `<input type="checkbox">` | focus / outline adjustments |
|
|
16
|
+
| `label` | label content | typography tweaks |
|
|
17
|
+
|
|
18
|
+
Example:
|
|
19
|
+
|
|
20
|
+
```css
|
|
21
|
+
w-checkbox::part(label) {
|
|
22
|
+
font-weight: 600;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
w-checkbox::part(control) {
|
|
26
|
+
margin-top: 1px;
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Parts are intended as an **escape hatch**.
|
|
31
|
+
Prefer component tokens for anything state‑ or size‑related.
|
|
32
|
+
|
|
33
|
+
### Component tokens (`--w-c-checkbox-*`)
|
|
34
|
+
|
|
35
|
+
Component tokens act as inputs to the checkbox styling.
|
|
36
|
+
They can be set directly on the component or inherited from a parent container.
|
|
37
|
+
|
|
38
|
+
```css
|
|
39
|
+
.settings-panel {
|
|
40
|
+
--w-c-checkbox-gap: 12px;
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Defaults are defined internally; setting a token is always optional.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
#### Layout & size
|
|
48
|
+
|
|
49
|
+
| Token | Purpose | Default |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| `--w-c-checkbox-gap` | space between control and label | `8px` |
|
|
52
|
+
| `--w-c-checkbox-control-size` | width/height of the control | `2rem` |
|
|
53
|
+
| `--w-c-checkbox-radius` | border radius of the control | `4px` |
|
|
54
|
+
| `--w-c-checkbox-border-width` | border width | `1px` |
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
#### Colors
|
|
58
|
+
|
|
59
|
+
| Token | Purpose | Default |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| `--w-c-checkbox-bg` | control background | theme default |
|
|
62
|
+
| `--w-c-checkbox-border-color` | control border color | theme default |
|
|
63
|
+
| `--w-c-checkbox-bg-checked` | background when checked | theme default |
|
|
64
|
+
| `--w-c-checkbox-border-color-checked` | border when checked | theme default |
|
|
65
|
+
| `--w-c-checkbox-icon-color` | icon color | theme default |
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
#### Invalid state
|
|
69
|
+
|
|
70
|
+
| Token | Purpose | Default |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| `--w-c-checkbox-border-color-invalid` | border color when invalid | theme default |
|
|
73
|
+
| `--w-c-checkbox-bg-invalid-checked` | background when invalid and checked | theme default |
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
#### Disabled state
|
|
77
|
+
|
|
78
|
+
| Token | Purpose | Default |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| `--w-c-checkbox-bg-disabled` | background when disabled | theme default |
|
|
81
|
+
| `--w-c-checkbox-border-color-disabled` | border when disabled | theme default |
|
|
82
|
+
| `--w-c-checkbox-bg-disabled-checked` | background when disabled and checked | theme default |
|
|
83
|
+
|
|
84
|
+
#### Focus
|
|
85
|
+
|
|
86
|
+
| Token | Purpose | Default |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| `--w-c-checkbox-outline-width` | focus outline width | `2px` |
|
|
89
|
+
| `--w-c-checkbox-outline-color` | focus outline color | theme default |
|
|
90
|
+
| `--w-c-checkbox-outline-offset` | focus outline offset | theme default |
|
|
91
|
+
|
|
92
|
+
#### Motion
|
|
93
|
+
|
|
94
|
+
| Token | Purpose | Default |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| `--w-c-checkbox-transition` | transition for control | `150ms cubic-bezier(0.4, 0, 0.2, 1)` |
|
|
97
|
+
|
|
98
|
+
Transitions are automatically disabled when `prefers-reduced-motion: reduce` is active.
|
|
99
|
+
|
|
100
|
+
### Examples
|
|
101
|
+
|
|
102
|
+
#### Compact checkbox
|
|
103
|
+
|
|
104
|
+
```css
|
|
105
|
+
.filters w-checkbox {
|
|
106
|
+
--w-c-checkbox-gap: 4px;
|
|
107
|
+
--w-c-checkbox-control-size: 1.6rem;
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Rounded checkbox
|
|
112
|
+
|
|
113
|
+
```css
|
|
114
|
+
w-checkbox {
|
|
115
|
+
--w-c-checkbox-radius: 9999px;
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### Contextual color override (advanced)
|
|
120
|
+
|
|
121
|
+
```css
|
|
122
|
+
.danger-zone w-checkbox {
|
|
123
|
+
--w-c-checkbox-border-color-checked: red;
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Guidelines
|
|
128
|
+
|
|
129
|
+
- Prefer **component tokens** for size, spacing, and state styling
|
|
130
|
+
- Use **parts** only for small, local tweaks
|
|
131
|
+
- Avoid relying on internal class names or selectors
|
|
132
|
+
- If multiple tokens are required to achieve a look, consider whether a new variant or design token is more appropriate
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
## Usage
|
|
2
|
+
|
|
3
|
+
Checkbox lets users select one or more options. Use it for independent yes/no choices, multi-select lists, and terms or consent confirmations.
|
|
4
|
+
|
|
5
|
+
Use `w-checkbox-group` when several checkboxes share one label, help text, optional indicator, or required validation.
|
|
6
|
+
|
|
7
|
+
### Basic Checkbox
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<w-checkbox name="newsletter" value="yes">Sign up for updates</w-checkbox>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The slotted text becomes the checkbox label.
|
|
14
|
+
|
|
15
|
+
### Checked State
|
|
16
|
+
|
|
17
|
+
Use `checked` when the checkbox should be selected by default.
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<w-checkbox name="alerts" value="email" checked>Email alerts</w-checkbox>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Listen for the `change` event when you need to react to user changes.
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<w-checkbox id="newsletter" name="newsletter" value="yes">Sign up for updates</w-checkbox>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
const checkbox = document.querySelector('#newsletter');
|
|
30
|
+
|
|
31
|
+
checkbox.addEventListener('change', () => {
|
|
32
|
+
console.log(checkbox.checked);
|
|
33
|
+
});
|
|
34
|
+
</script>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Form Submission
|
|
38
|
+
|
|
39
|
+
`w-checkbox` is form-associated. When checked, it submits its `name` and `value` with the form. When unchecked or disabled, it submits nothing.
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<form>
|
|
43
|
+
<w-checkbox name="newsletter" value="yes">Sign up for updates</w-checkbox>
|
|
44
|
+
<w-button type="submit">Submit</w-button>
|
|
45
|
+
</form>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
If no `value` is set, the submitted value defaults to `on`.
|
|
49
|
+
|
|
50
|
+
### Required
|
|
51
|
+
|
|
52
|
+
Use `required` when one standalone checkbox must be checked before form submission, such as accepting terms.
|
|
53
|
+
|
|
54
|
+
```html
|
|
55
|
+
<form>
|
|
56
|
+
<w-checkbox name="terms" value="accepted" required>Accept the terms</w-checkbox>
|
|
57
|
+
<w-button type="submit">Continue</w-button>
|
|
58
|
+
</form>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
For a set of options where at least one option is required, put `required` on `w-checkbox-group` instead.
|
|
62
|
+
|
|
63
|
+
### Checkbox Group
|
|
64
|
+
|
|
65
|
+
Use `w-checkbox-group` to group related options under a shared label and help text.
|
|
66
|
+
|
|
67
|
+
```html
|
|
68
|
+
<w-checkbox-group label="Interests" help-text="Select all that apply" name="interests">
|
|
69
|
+
<w-checkbox value="housing">Housing</w-checkbox>
|
|
70
|
+
<w-checkbox value="jobs">Jobs</w-checkbox>
|
|
71
|
+
<w-checkbox value="travel">Travel</w-checkbox>
|
|
72
|
+
</w-checkbox-group>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The group name is applied to child checkboxes that do not have their own `name`.
|
|
76
|
+
|
|
77
|
+
### Indeterminate
|
|
78
|
+
|
|
79
|
+
Use `indeterminate` when a parent checkbox represents a mixed set of child selections.
|
|
80
|
+
|
|
81
|
+
```html
|
|
82
|
+
<w-checkbox name="all-notifications" indeterminate>All notifications</w-checkbox>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Indeterminate is a visual state. When the user clicks the checkbox, the indeterminate state is cleared and the checkbox becomes checked.
|
|
86
|
+
|
|
87
|
+
### Invalid
|
|
88
|
+
|
|
89
|
+
Set `invalid` when validation is managed outside the component.
|
|
90
|
+
|
|
91
|
+
```html
|
|
92
|
+
<w-checkbox name="terms" value="accepted" invalid>Accept the terms</w-checkbox>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
When possible, place clear error text near the checkbox or group so users know how to correct the error.
|
|
@@ -155,6 +155,8 @@ combobox.options = [
|
|
|
155
155
|
|
|
156
156
|
Child option content is plain text. Rich option content is not supported.
|
|
157
157
|
|
|
158
|
+
## Styling API
|
|
159
|
+
|
|
158
160
|
## `<w-combobox>` API
|
|
159
161
|
|
|
160
162
|
Unless otherwise noted all properties are HTML attributes (as opposed to JavaScript object properties).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Styling API
|
|
@@ -1 +1,26 @@
|
|
|
1
1
|
## Accessibility
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
### Provide A Label
|
|
6
|
+
|
|
7
|
+
Always provide a visible label.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<w-datepicker label="Departure date" name="departure"></w-datepicker>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The label should describe the date being requested. Avoid generic labels such as "Date" when there are several date fields on the same page.
|
|
14
|
+
|
|
15
|
+
### Calendar Dialog
|
|
16
|
+
|
|
17
|
+
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.
|
|
18
|
+
|
|
19
|
+
Each date in the calendar grid has an accessible name formatted using `day-format`.
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<w-datepicker label="Date" name="date" day-format="PPPP"></w-datepicker>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Use a descriptive `day-format` so screen reader users hear the full date, not only the day number.
|
|
26
|
+
See [the Date FNS docs](https://date-fns.org/v4.1.0/docs/format) for formatting options.
|
|
@@ -7,15 +7,15 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
7
7
|
| Name | Type | Default | Summary |
|
|
8
8
|
|-|-|-|-|
|
|
9
9
|
| calendar (JS only) | `HTMLDivElement` | `-` | - |
|
|
10
|
-
| day-format | `string` | `'PPPP'` |
|
|
11
|
-
| header-format | `string` | `'MMMM yyyy'` |
|
|
10
|
+
| day-format | `string` | `'PPPP'` | The date format used for calendar day accessible names. |
|
|
11
|
+
| header-format | `string` | `'MMMM yyyy'` | The date format used in the calendar header. |
|
|
12
12
|
| input (JS only) | `HTMLInputElement` | `-` | - |
|
|
13
13
|
| isCalendarOpen (JS only) | `boolean` | `false` | - |
|
|
14
|
-
| isDayDisabled (JS only) | `(day: Date) => boolean` | `-` |
|
|
15
|
-
| label | `string` | `-` |
|
|
16
|
-
| lang | `string` | `-` |
|
|
14
|
+
| isDayDisabled (JS only) | `(day: Date) => boolean` | `-` | Function used to disable dates in the calendar. |
|
|
15
|
+
| label | `string` | `-` | The label displayed above the date input. |
|
|
16
|
+
| lang | `string` | `-` | The locale used for calendar labels and date formatting. |
|
|
17
17
|
| month (JS only) | `unknown` | `-` | - |
|
|
18
|
-
| name | `string` | `-` |
|
|
18
|
+
| name | `string` | `-` | The name submitted with the date value. |
|
|
19
19
|
| navigationDate (JS only) | `Date` | `-` | - |
|
|
20
20
|
| previousMonthButton (JS only) | `HTMLButtonElement` | `-` | This is the first focusable element, needed for the modal focus trap. |
|
|
21
21
|
| selectedCell (JS only) | `HTMLTableCellElement` | `-` | - |
|
|
@@ -23,8 +23,8 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
23
23
|
| shadowRootOptions (JS only) | `object` | `{ ...LitElement.shadowRootOptions, delegatesFocus: true, }` | - |
|
|
24
24
|
| todayCell (JS only) | `HTMLTableCellElement` | `-` | - |
|
|
25
25
|
| toggleButton (JS only) | `HTMLButtonElement` | `-` | - |
|
|
26
|
-
| value | `string` | `-` |
|
|
27
|
-
| weekday-format | `string` | `'EEEEEE'` |
|
|
26
|
+
| value | `string` | `-` | The selected date value. |
|
|
27
|
+
| weekday-format | `string` | `'EEEEEE'` | The weekday format shown above the calendar grid. |
|
|
28
28
|
| weeks (JS only) | `unknown` | `-` | - |
|
|
29
29
|
| wrapper (JS only) | `HTMLDivElement` | `-` | - |
|
|
30
30
|
|
|
@@ -39,7 +39,7 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
39
39
|
|
|
40
40
|
#### day-format
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
The date format used for calendar day accessible names.
|
|
43
43
|
|
|
44
44
|
The syntax is defined by [date-fns/format](https://date-fns.org/v4.1.0/docs/format).
|
|
45
45
|
|
|
@@ -48,7 +48,7 @@ The syntax is defined by [date-fns/format](https://date-fns.org/v4.1.0/docs/form
|
|
|
48
48
|
|
|
49
49
|
#### header-format
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
The date format used in the calendar header.
|
|
52
52
|
|
|
53
53
|
The syntax is defined by [date-fns/format](https://date-fns.org/v4.1.0/docs/format).
|
|
54
54
|
|
|
@@ -71,23 +71,27 @@ The syntax is defined by [date-fns/format](https://date-fns.org/v4.1.0/docs/form
|
|
|
71
71
|
|
|
72
72
|
#### isDayDisabled (JS only)
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
Function used to disable dates in the calendar.
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
Set this on the element instance in JavaScript, not as an HTML attribute. Disabled dates cannot be selected from the calendar.
|
|
77
77
|
|
|
78
78
|
- Type: `(day: Date) => boolean`
|
|
79
79
|
- Default: `-`
|
|
80
80
|
|
|
81
81
|
#### label
|
|
82
82
|
|
|
83
|
+
The label displayed above the date input.
|
|
83
84
|
|
|
85
|
+
Use this to give the datepicker a visible and accessible name.
|
|
84
86
|
|
|
85
87
|
- Type: `string`
|
|
86
88
|
- Default: `-`
|
|
87
89
|
|
|
88
90
|
#### lang
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
The locale used for calendar labels and date formatting.
|
|
93
|
+
|
|
94
|
+
This takes precedence over the `<html>` `lang` attribute. Supported built-in locales are `en`, `nb`, `sv`, `da`, and `fi`.
|
|
91
95
|
|
|
92
96
|
- Type: `string`
|
|
93
97
|
- Default: `-`
|
|
@@ -101,7 +105,9 @@ Takes precedence over the `<html>` lang attribute.
|
|
|
101
105
|
|
|
102
106
|
#### name
|
|
103
107
|
|
|
108
|
+
The name submitted with the date value.
|
|
104
109
|
|
|
110
|
+
Use this when the datepicker belongs to a form and its value should be included in form data.
|
|
105
111
|
|
|
106
112
|
- Type: `string`
|
|
107
113
|
- Default: `-`
|
|
@@ -161,14 +167,16 @@ the query will point to an element that doesn't exist anymore.
|
|
|
161
167
|
|
|
162
168
|
#### value
|
|
163
169
|
|
|
170
|
+
The selected date value.
|
|
164
171
|
|
|
172
|
+
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.
|
|
165
173
|
|
|
166
174
|
- Type: `string`
|
|
167
175
|
- Default: `-`
|
|
168
176
|
|
|
169
177
|
#### weekday-format
|
|
170
178
|
|
|
171
|
-
|
|
179
|
+
The weekday format shown above the calendar grid.
|
|
172
180
|
|
|
173
181
|
The syntax is defined by [date-fns/format](https://date-fns.org/v4.1.0/docs/format).
|
|
174
182
|
|
|
@@ -10,10 +10,196 @@ Uses the `lang` attribute on either the element or on `<html>` to determine the
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
+
Datepicker lets users type or choose a calendar date.
|
|
14
|
+
|
|
15
|
+
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.
|
|
16
|
+
|
|
17
|
+
### Basic Datepicker
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<w-datepicker label="Date" name="date"></w-datepicker>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Always provide a visible `label`.
|
|
24
|
+
|
|
25
|
+
### Value
|
|
26
|
+
|
|
27
|
+
Use `value` to set the selected date. The value should use `YYYY-MM-DD` format.
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<w-datepicker label="Start date" name="start-date" value="2026-06-15"></w-datepicker>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The same value is submitted with the form.
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<form>
|
|
37
|
+
<w-datepicker label="Departure date" name="departure"></w-datepicker>
|
|
38
|
+
<w-button type="submit">Search</w-button>
|
|
39
|
+
</form>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Locale
|
|
43
|
+
|
|
44
|
+
Datepicker uses the `lang` attribute on the component, or the `lang` attribute on `<html>`, to choose locale-specific calendar labels and formatting.
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<w-datepicker label="Dato" name="date" lang="nb"></w-datepicker>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The component includes built-in locale support for `en`, `nb`, `sv`, `da`, and `fi`.
|
|
51
|
+
|
|
52
|
+
### Formatting
|
|
53
|
+
|
|
54
|
+
Use `header-format`, `weekday-format`, and `day-format` to control calendar display and accessible day labels.
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<w-datepicker
|
|
58
|
+
label="Date"
|
|
59
|
+
name="date"
|
|
60
|
+
header-format="MMMM yyyy"
|
|
61
|
+
weekday-format="EEEEEE"
|
|
62
|
+
day-format="PPPP"
|
|
63
|
+
></w-datepicker>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
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.
|
|
67
|
+
|
|
68
|
+
### Disable Dates
|
|
69
|
+
|
|
70
|
+
Use `isDayDisabled` to prevent users from selecting certain dates from the calendar.
|
|
71
|
+
|
|
72
|
+
This property must be set on the element instance in JavaScript.
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<w-datepicker id="booking-date" label="Booking date" name="booking-date"></w-datepicker>
|
|
76
|
+
|
|
77
|
+
<script type="module">
|
|
78
|
+
const datepicker = document.querySelector('#booking-date');
|
|
79
|
+
|
|
80
|
+
datepicker.isDayDisabled = (day) => day.getDay() === 0;
|
|
81
|
+
</script>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Disabled dates cannot be selected from the calendar.
|
|
85
|
+
|
|
86
|
+
### About change events
|
|
87
|
+
|
|
88
|
+
With events the datepicker works much like the native `<input type="date">`:
|
|
89
|
+
|
|
90
|
+
- 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).
|
|
91
|
+
- 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).
|
|
92
|
+
|
|
93
|
+
Note that the component does not fire a `change` event when typing in the input field. This is intentional.
|
|
94
|
+
|
|
95
|
+
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.
|
|
96
|
+
|
|
13
97
|
## Accessibility
|
|
14
98
|
|
|
99
|
+
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.
|
|
100
|
+
|
|
101
|
+
### Provide A Label
|
|
102
|
+
|
|
103
|
+
Always provide a visible label.
|
|
104
|
+
|
|
105
|
+
```html
|
|
106
|
+
<w-datepicker label="Departure date" name="departure"></w-datepicker>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The label should describe the date being requested. Avoid generic labels such as "Date" when there are several date fields on the same page.
|
|
110
|
+
|
|
111
|
+
### Calendar Dialog
|
|
112
|
+
|
|
113
|
+
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.
|
|
114
|
+
|
|
115
|
+
Each date in the calendar grid has an accessible name formatted using `day-format`.
|
|
116
|
+
|
|
117
|
+
```html
|
|
118
|
+
<w-datepicker label="Date" name="date" day-format="PPPP"></w-datepicker>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Use a descriptive `day-format` so screen reader users hear the full date, not only the day number.
|
|
122
|
+
See [the Date FNS docs](https://date-fns.org/v4.1.0/docs/format) for formatting options.
|
|
123
|
+
|
|
15
124
|
## Examples
|
|
16
125
|
|
|
126
|
+
### Basic
|
|
127
|
+
|
|
128
|
+
<elements-example>
|
|
129
|
+
|
|
130
|
+
```html
|
|
131
|
+
<w-datepicker label="Date" name="date"></w-datepicker>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
</elements-example>
|
|
135
|
+
|
|
136
|
+
### With Value
|
|
137
|
+
|
|
138
|
+
<elements-example>
|
|
139
|
+
|
|
140
|
+
```html
|
|
141
|
+
<w-datepicker label="Start date" name="start-date" value="2026-06-15"></w-datepicker>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
</elements-example>
|
|
145
|
+
|
|
146
|
+
### Locale
|
|
147
|
+
|
|
148
|
+
<elements-example>
|
|
149
|
+
|
|
150
|
+
```html
|
|
151
|
+
<w-datepicker label="Dato" name="date" lang="nb"></w-datepicker>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
</elements-example>
|
|
155
|
+
|
|
156
|
+
### Custom Formats
|
|
157
|
+
|
|
158
|
+
<elements-example>
|
|
159
|
+
|
|
160
|
+
```html
|
|
161
|
+
<w-datepicker
|
|
162
|
+
label="Date"
|
|
163
|
+
name="date"
|
|
164
|
+
header-format="MMMM yyyy"
|
|
165
|
+
weekday-format="EEEEEE"
|
|
166
|
+
day-format="PPPP"
|
|
167
|
+
></w-datepicker>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
</elements-example>
|
|
171
|
+
|
|
172
|
+
### Form Associated
|
|
173
|
+
|
|
174
|
+
<elements-example>
|
|
175
|
+
|
|
176
|
+
```html
|
|
177
|
+
<form>
|
|
178
|
+
<w-datepicker label="Departure date" name="departure"></w-datepicker>
|
|
179
|
+
<w-button type="submit">Search</w-button>
|
|
180
|
+
</form>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
</elements-example>
|
|
184
|
+
|
|
185
|
+
### Disabled Calendar Dates
|
|
186
|
+
|
|
187
|
+
<elements-example>
|
|
188
|
+
|
|
189
|
+
```html
|
|
190
|
+
<w-datepicker id="booking-date" label="Booking date" name="booking-date"></w-datepicker>
|
|
191
|
+
|
|
192
|
+
<script type="module">
|
|
193
|
+
const datepicker = document.querySelector('#booking-date');
|
|
194
|
+
|
|
195
|
+
datepicker.isDayDisabled = (day) => day.getDay() === 0;
|
|
196
|
+
</script>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
</elements-example>
|
|
200
|
+
|
|
201
|
+
## Styling API
|
|
202
|
+
|
|
17
203
|
## `<w-datepicker>` API
|
|
18
204
|
|
|
19
205
|
Unless otherwise noted all properties are HTML attributes (as opposed to JavaScript object properties).
|
|
@@ -23,15 +209,15 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
23
209
|
| Name | Type | Default | Summary |
|
|
24
210
|
|-|-|-|-|
|
|
25
211
|
| calendar (JS only) | `HTMLDivElement` | `-` | - |
|
|
26
|
-
| day-format | `string` | `'PPPP'` |
|
|
27
|
-
| header-format | `string` | `'MMMM yyyy'` |
|
|
212
|
+
| day-format | `string` | `'PPPP'` | The date format used for calendar day accessible names. |
|
|
213
|
+
| header-format | `string` | `'MMMM yyyy'` | The date format used in the calendar header. |
|
|
28
214
|
| input (JS only) | `HTMLInputElement` | `-` | - |
|
|
29
215
|
| isCalendarOpen (JS only) | `boolean` | `false` | - |
|
|
30
|
-
| isDayDisabled (JS only) | `(day: Date) => boolean` | `-` |
|
|
31
|
-
| label | `string` | `-` |
|
|
32
|
-
| lang | `string` | `-` |
|
|
216
|
+
| isDayDisabled (JS only) | `(day: Date) => boolean` | `-` | Function used to disable dates in the calendar. |
|
|
217
|
+
| label | `string` | `-` | The label displayed above the date input. |
|
|
218
|
+
| lang | `string` | `-` | The locale used for calendar labels and date formatting. |
|
|
33
219
|
| month (JS only) | `unknown` | `-` | - |
|
|
34
|
-
| name | `string` | `-` |
|
|
220
|
+
| name | `string` | `-` | The name submitted with the date value. |
|
|
35
221
|
| navigationDate (JS only) | `Date` | `-` | - |
|
|
36
222
|
| previousMonthButton (JS only) | `HTMLButtonElement` | `-` | This is the first focusable element, needed for the modal focus trap. |
|
|
37
223
|
| selectedCell (JS only) | `HTMLTableCellElement` | `-` | - |
|
|
@@ -39,8 +225,8 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
39
225
|
| shadowRootOptions (JS only) | `object` | `{ ...LitElement.shadowRootOptions, delegatesFocus: true, }` | - |
|
|
40
226
|
| todayCell (JS only) | `HTMLTableCellElement` | `-` | - |
|
|
41
227
|
| toggleButton (JS only) | `HTMLButtonElement` | `-` | - |
|
|
42
|
-
| value | `string` | `-` |
|
|
43
|
-
| weekday-format | `string` | `'EEEEEE'` |
|
|
228
|
+
| value | `string` | `-` | The selected date value. |
|
|
229
|
+
| weekday-format | `string` | `'EEEEEE'` | The weekday format shown above the calendar grid. |
|
|
44
230
|
| weeks (JS only) | `unknown` | `-` | - |
|
|
45
231
|
| wrapper (JS only) | `HTMLDivElement` | `-` | - |
|
|
46
232
|
|
|
@@ -55,7 +241,7 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
55
241
|
|
|
56
242
|
#### day-format
|
|
57
243
|
|
|
58
|
-
|
|
244
|
+
The date format used for calendar day accessible names.
|
|
59
245
|
|
|
60
246
|
The syntax is defined by [date-fns/format](https://date-fns.org/v4.1.0/docs/format).
|
|
61
247
|
|
|
@@ -64,7 +250,7 @@ The syntax is defined by [date-fns/format](https://date-fns.org/v4.1.0/docs/form
|
|
|
64
250
|
|
|
65
251
|
#### header-format
|
|
66
252
|
|
|
67
|
-
|
|
253
|
+
The date format used in the calendar header.
|
|
68
254
|
|
|
69
255
|
The syntax is defined by [date-fns/format](https://date-fns.org/v4.1.0/docs/format).
|
|
70
256
|
|
|
@@ -87,23 +273,27 @@ The syntax is defined by [date-fns/format](https://date-fns.org/v4.1.0/docs/form
|
|
|
87
273
|
|
|
88
274
|
#### isDayDisabled (JS only)
|
|
89
275
|
|
|
90
|
-
|
|
276
|
+
Function used to disable dates in the calendar.
|
|
91
277
|
|
|
92
|
-
|
|
278
|
+
Set this on the element instance in JavaScript, not as an HTML attribute. Disabled dates cannot be selected from the calendar.
|
|
93
279
|
|
|
94
280
|
- Type: `(day: Date) => boolean`
|
|
95
281
|
- Default: `-`
|
|
96
282
|
|
|
97
283
|
#### label
|
|
98
284
|
|
|
285
|
+
The label displayed above the date input.
|
|
99
286
|
|
|
287
|
+
Use this to give the datepicker a visible and accessible name.
|
|
100
288
|
|
|
101
289
|
- Type: `string`
|
|
102
290
|
- Default: `-`
|
|
103
291
|
|
|
104
292
|
#### lang
|
|
105
293
|
|
|
106
|
-
|
|
294
|
+
The locale used for calendar labels and date formatting.
|
|
295
|
+
|
|
296
|
+
This takes precedence over the `<html>` `lang` attribute. Supported built-in locales are `en`, `nb`, `sv`, `da`, and `fi`.
|
|
107
297
|
|
|
108
298
|
- Type: `string`
|
|
109
299
|
- Default: `-`
|
|
@@ -117,7 +307,9 @@ Takes precedence over the `<html>` lang attribute.
|
|
|
117
307
|
|
|
118
308
|
#### name
|
|
119
309
|
|
|
310
|
+
The name submitted with the date value.
|
|
120
311
|
|
|
312
|
+
Use this when the datepicker belongs to a form and its value should be included in form data.
|
|
121
313
|
|
|
122
314
|
- Type: `string`
|
|
123
315
|
- Default: `-`
|
|
@@ -177,14 +369,16 @@ the query will point to an element that doesn't exist anymore.
|
|
|
177
369
|
|
|
178
370
|
#### value
|
|
179
371
|
|
|
372
|
+
The selected date value.
|
|
180
373
|
|
|
374
|
+
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
375
|
|
|
182
376
|
- Type: `string`
|
|
183
377
|
- Default: `-`
|
|
184
378
|
|
|
185
379
|
#### weekday-format
|
|
186
380
|
|
|
187
|
-
|
|
381
|
+
The weekday format shown above the calendar grid.
|
|
188
382
|
|
|
189
383
|
The syntax is defined by [date-fns/format](https://date-fns.org/v4.1.0/docs/format).
|
|
190
384
|
|