@warp-ds/elements 2.9.1-next.5 → 2.9.1-next.6
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 +25 -20
- package/dist/docs/slider/examples.md +30 -75
- package/dist/docs/slider/slider.md +30 -75
- package/dist/docs/step/api.md +11 -9
- package/dist/docs/step/step.md +11 -15
- package/dist/docs/step-indicator/api.md +4 -4
- package/dist/docs/step-indicator/examples.md +81 -0
- package/dist/docs/step-indicator/step-indicator.md +97 -6
- package/dist/docs/step-indicator/usage.md +12 -0
- package/dist/docs/switch/accessibility.md +2 -0
- package/dist/docs/switch/api.md +11 -17
- package/dist/docs/switch/examples.md +16 -0
- package/dist/docs/switch/switch.md +36 -18
- package/dist/docs/switch/usage.md +6 -0
- package/dist/index.d.ts +64 -56
- package/dist/packages/affix/affix.react.stories.d.ts +3 -1
- package/dist/packages/affix/affix.react.test.d.ts +1 -0
- package/dist/packages/affix/affix.react.test.js +3 -0
- package/dist/packages/affix/react.d.ts +4 -1
- package/dist/packages/affix/react.js +7 -1
- package/dist/packages/attention/attention.react.test.d.ts +1 -0
- package/dist/packages/attention/attention.react.test.js +8 -0
- package/dist/packages/attention/react.d.ts +2 -2
- package/dist/packages/attention/react.js +10 -1
- package/dist/packages/checkbox-group/checkbox-group.react.test.d.ts +1 -0
- package/dist/packages/checkbox-group/checkbox-group.react.test.js +5 -0
- package/dist/packages/checkbox-group/react.d.ts +4 -1
- package/dist/packages/checkbox-group/react.js +7 -1
- package/dist/packages/combobox/combobox.react.stories.d.ts +20 -8
- package/dist/packages/combobox/combobox.react.test.d.ts +1 -0
- package/dist/packages/combobox/combobox.react.test.js +9 -0
- package/dist/packages/combobox/react.d.ts +13 -6
- package/dist/packages/combobox/react.js +11 -1
- package/dist/packages/datepicker/datepicker.react.stories.d.ts +18 -10
- package/dist/packages/datepicker/datepicker.react.test.d.ts +1 -0
- package/dist/packages/datepicker/datepicker.react.test.js +7 -0
- package/dist/packages/datepicker/react.d.ts +13 -8
- package/dist/packages/datepicker/react.js +9 -1
- package/dist/packages/expandable/expandable.react.stories.d.ts +12 -2
- package/dist/packages/expandable/expandable.react.test.d.ts +1 -0
- package/dist/packages/expandable/expandable.react.test.js +8 -0
- package/dist/packages/expandable/react.d.ts +7 -1
- package/dist/packages/expandable/react.js +10 -1
- package/dist/packages/link/link.react.stories.d.ts +6 -2
- package/dist/packages/link/link.react.test.d.ts +1 -0
- package/dist/packages/link/link.react.test.js +3 -0
- package/dist/packages/link/react.d.ts +4 -1
- package/dist/packages/link/react.js +7 -1
- package/dist/packages/modal/modal.react.stories.d.ts +10 -6
- package/dist/packages/modal/modal.react.test.d.ts +1 -0
- package/dist/packages/modal/modal.react.test.js +6 -0
- package/dist/packages/modal/react.d.ts +10 -6
- package/dist/packages/modal/react.js +8 -1
- package/dist/packages/modal-header/modal-header.react.test.d.ts +1 -0
- package/dist/packages/modal-header/modal-header.react.test.js +3 -0
- package/dist/packages/modal-header/react.d.ts +7 -4
- package/dist/packages/modal-header/react.js +7 -1
- package/dist/packages/page-indicator/page-indicator.react.stories.d.ts +8 -2
- package/dist/packages/page-indicator/page-indicator.react.test.d.ts +1 -0
- package/dist/packages/page-indicator/page-indicator.react.test.js +6 -0
- package/dist/packages/page-indicator/react.d.ts +5 -1
- package/dist/packages/page-indicator/react.js +8 -1
- package/dist/packages/pagination/pagination.react.stories.d.ts +14 -6
- package/dist/packages/pagination/pagination.react.test.d.ts +1 -0
- package/dist/packages/pagination/pagination.react.test.js +7 -0
- package/dist/packages/pagination/react.d.ts +9 -4
- package/dist/packages/pagination/react.js +9 -1
- package/dist/packages/pill/pill.react.stories.d.ts +20 -8
- package/dist/packages/pill/pill.react.test.d.ts +1 -0
- package/dist/packages/pill/pill.react.test.js +9 -0
- package/dist/packages/pill/react.d.ts +13 -6
- package/dist/packages/pill/react.js +11 -1
- package/dist/packages/radio-group/radio-group.react.test.d.ts +1 -0
- package/dist/packages/radio-group/radio-group.react.test.js +5 -0
- package/dist/packages/radio-group/react.d.ts +9 -6
- package/dist/packages/radio-group/react.js +7 -1
- package/dist/packages/select/react.d.ts +9 -4
- package/dist/packages/select/react.js +9 -1
- package/dist/packages/select/select.react.stories.d.ts +14 -6
- package/dist/packages/select/select.react.test.d.ts +1 -0
- package/dist/packages/select/select.react.test.js +7 -0
- package/dist/packages/slider/react.d.ts +6 -1
- package/dist/packages/slider/react.js +9 -1
- package/dist/packages/slider/slider.react.stories.d.ts +6 -1
- package/dist/packages/slider/slider.react.test.d.ts +1 -0
- package/dist/packages/slider/slider.react.test.js +7 -0
- package/dist/packages/slider-thumb/react.d.ts +8 -5
- package/dist/packages/slider-thumb/react.js +8 -1
- package/dist/packages/slider-thumb/slider-thumb.react.test.d.ts +1 -0
- package/dist/packages/slider-thumb/slider-thumb.react.test.js +6 -0
- package/dist/packages/step/step.d.ts +8 -4
- package/dist/packages/step/step.js.map +2 -2
- package/dist/packages/step-indicator/step-indicator.d.ts +5 -6
- package/dist/packages/step-indicator/step-indicator.js.map +2 -2
- package/dist/packages/switch/switch.d.ts +21 -8
- package/dist/packages/switch/switch.js +1 -1
- package/dist/packages/switch/switch.js.map +2 -2
- package/dist/packages/tab/react.d.ts +9 -6
- package/dist/packages/tab/react.js +7 -1
- package/dist/packages/tab/tab.react.test.d.ts +1 -0
- package/dist/packages/tab/tab.react.test.js +3 -0
- package/dist/packages/textarea/react.d.ts +16 -10
- package/dist/packages/textarea/react.js +10 -1
- package/dist/packages/textarea/textarea.react.stories.d.ts +22 -12
- package/dist/packages/textarea/textarea.react.test.d.ts +1 -0
- package/dist/packages/textarea/textarea.react.test.js +8 -0
- package/dist/packages/textfield/react.d.ts +16 -10
- package/dist/packages/textfield/react.js +10 -1
- package/dist/packages/textfield/textfield.react.stories.d.ts +22 -12
- package/dist/packages/textfield/textfield.react.test.d.ts +1 -0
- package/dist/packages/textfield/textfield.react.test.js +8 -0
- package/dist/tests/react-ssr-attributes.d.ts +8 -0
- package/dist/tests/react-ssr-attributes.js +12 -0
- package/dist/web-types.json +73 -15
- package/package.json +1 -1
- package/dist/docs/step/accessibility.md +0 -1
- package/dist/docs/step/examples.md +0 -1
- package/dist/docs/step/usage.md +0 -1
package/dist/docs/step/step.md
CHANGED
|
@@ -4,35 +4,31 @@
|
|
|
4
4
|
|
|
5
5
|
Individual step component that shows a single step in a process
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
### `<w-step>` API
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Examples
|
|
12
|
-
|
|
13
|
-
## `<w-step>` API
|
|
14
|
-
|
|
15
|
-
Unless otherwise noted all properties are HTML attributes (as opposed to JavaScript object properties).
|
|
16
|
-
|
|
17
|
-
### Properties
|
|
9
|
+
#### Properties
|
|
18
10
|
|
|
19
11
|
| Name | Type | Default | Summary |
|
|
20
12
|
|-|-|-|-|
|
|
21
|
-
| active | `boolean` | `false` |
|
|
22
|
-
| completed | `boolean` | `false` |
|
|
13
|
+
| active | `boolean` | `false` | Whether this step is active. |
|
|
14
|
+
| completed | `boolean` | `false` | Whether this step is completed. |
|
|
23
15
|
|
|
24
|
-
|
|
16
|
+
#### Property Details
|
|
25
17
|
|
|
26
|
-
|
|
18
|
+
##### active
|
|
27
19
|
|
|
20
|
+
Whether this step is active.
|
|
28
21
|
|
|
22
|
+
The active step displays a filled indicator.
|
|
29
23
|
|
|
30
24
|
- Type: `boolean`
|
|
31
25
|
- Default: `false`
|
|
32
26
|
|
|
33
|
-
|
|
27
|
+
##### completed
|
|
34
28
|
|
|
29
|
+
Whether this step is completed.
|
|
35
30
|
|
|
31
|
+
Completed steps display a checkmark icon and a filled indicator.
|
|
36
32
|
|
|
37
33
|
- Type: `boolean`
|
|
38
34
|
- Default: `false`
|
|
@@ -6,21 +6,21 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
6
6
|
|
|
7
7
|
| Name | Type | Default | Summary |
|
|
8
8
|
|-|-|-|-|
|
|
9
|
-
| horizontal | `boolean` | `false` |
|
|
10
|
-
| right | `boolean` | `false` |
|
|
9
|
+
| horizontal | `boolean` | `false` | Display steps horizontally instead of vertically |
|
|
10
|
+
| right | `boolean` | `false` | Align steps to the right (vertical layout only) |
|
|
11
11
|
|
|
12
12
|
### Property Details
|
|
13
13
|
|
|
14
14
|
#### horizontal
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Display steps horizontally instead of vertically
|
|
17
17
|
|
|
18
18
|
- Type: `boolean`
|
|
19
19
|
- Default: `false`
|
|
20
20
|
|
|
21
21
|
#### right
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Align steps to the right (vertical layout only)
|
|
24
24
|
|
|
25
25
|
- Type: `boolean`
|
|
26
26
|
- Default: `false`
|
|
@@ -1 +1,82 @@
|
|
|
1
1
|
## Examples
|
|
2
|
+
|
|
3
|
+
<elements-example>
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<w-step-indicator>
|
|
7
|
+
<w-step completed>
|
|
8
|
+
<h4>Step one</h4>
|
|
9
|
+
<p>This step is completed</p>
|
|
10
|
+
</w-step>
|
|
11
|
+
<w-step active>
|
|
12
|
+
<h4>Step two</h4>
|
|
13
|
+
<p>This is the current step</p>
|
|
14
|
+
</w-step>
|
|
15
|
+
<w-step>
|
|
16
|
+
<h4>Step three</h4>
|
|
17
|
+
<p>This step is upcoming</p>
|
|
18
|
+
</w-step>
|
|
19
|
+
</w-step-indicator>
|
|
20
|
+
|
|
21
|
+
<script type="module">
|
|
22
|
+
// Update step states programmatically
|
|
23
|
+
const steps = document.querySelectorAll('w-step');
|
|
24
|
+
|
|
25
|
+
// Mark a step as completed
|
|
26
|
+
steps[0].completed = true;
|
|
27
|
+
|
|
28
|
+
// Mark a step as active
|
|
29
|
+
steps[1].active = true;
|
|
30
|
+
</script>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
</elements-example>
|
|
34
|
+
|
|
35
|
+
### Horizontal steps
|
|
36
|
+
|
|
37
|
+
<elements-example>
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<w-step-indicator horizontal>
|
|
42
|
+
<w-step completed>
|
|
43
|
+
<h4>Step 1</h4>
|
|
44
|
+
<p>Completed</p>
|
|
45
|
+
</w-step>
|
|
46
|
+
<w-step active>
|
|
47
|
+
<h4>Step 2</h4>
|
|
48
|
+
<p>In progress</p>
|
|
49
|
+
</w-step>
|
|
50
|
+
<w-step>
|
|
51
|
+
<h4>Step 3</h4>
|
|
52
|
+
<p>Upcoming</p>
|
|
53
|
+
</w-step>
|
|
54
|
+
</w-step-indicator>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
</elements-example>
|
|
58
|
+
|
|
59
|
+
### Right-aligned vertical steps
|
|
60
|
+
|
|
61
|
+
`right` can not be used with `horizontal` (`horizontal` wins).
|
|
62
|
+
|
|
63
|
+
<elements-example>
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<w-step-indicator right>
|
|
67
|
+
<w-step completed>
|
|
68
|
+
<h4>Step 1</h4>
|
|
69
|
+
<p>Completed</p>
|
|
70
|
+
</w-step>
|
|
71
|
+
<w-step active>
|
|
72
|
+
<h4>Step 2</h4>
|
|
73
|
+
<p>In progress</p>
|
|
74
|
+
</w-step>
|
|
75
|
+
<w-step>
|
|
76
|
+
<h4>Step 3</h4>
|
|
77
|
+
<p>Upcoming</p>
|
|
78
|
+
</w-step>
|
|
79
|
+
</w-step-indicator>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
</elements-example>
|
|
@@ -4,14 +4,105 @@
|
|
|
4
4
|
|
|
5
5
|
Steps are used to show progress through a process or to guide users through a multi-step task.
|
|
6
6
|
|
|
7
|
-
[See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/components-steps--docs)
|
|
8
|
-
|
|
9
7
|
## Usage
|
|
10
8
|
|
|
9
|
+
The steps component consists of two custom elements that work together:
|
|
10
|
+
|
|
11
|
+
- `<w-step-indicator>` - The container that manages step layout and orientation
|
|
12
|
+
- `<w-step>` - Individual step items within the indicator
|
|
13
|
+
|
|
14
|
+
Each `<w-step>` can be marked as `active` or `completed` to indicate progress. The `<w-step-indicator>` component automatically handles:
|
|
15
|
+
|
|
16
|
+
- Vertical and horizontal layouts
|
|
17
|
+
- Left and right alignment (for vertical layout)
|
|
18
|
+
- Visual connecting lines between steps
|
|
19
|
+
- ARIA attributes for accessibility
|
|
20
|
+
|
|
11
21
|
## Accessibility
|
|
12
22
|
|
|
13
23
|
## Examples
|
|
14
24
|
|
|
25
|
+
<elements-example>
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<w-step-indicator>
|
|
29
|
+
<w-step completed>
|
|
30
|
+
<h4>Step one</h4>
|
|
31
|
+
<p>This step is completed</p>
|
|
32
|
+
</w-step>
|
|
33
|
+
<w-step active>
|
|
34
|
+
<h4>Step two</h4>
|
|
35
|
+
<p>This is the current step</p>
|
|
36
|
+
</w-step>
|
|
37
|
+
<w-step>
|
|
38
|
+
<h4>Step three</h4>
|
|
39
|
+
<p>This step is upcoming</p>
|
|
40
|
+
</w-step>
|
|
41
|
+
</w-step-indicator>
|
|
42
|
+
|
|
43
|
+
<script type="module">
|
|
44
|
+
// Update step states programmatically
|
|
45
|
+
const steps = document.querySelectorAll('w-step');
|
|
46
|
+
|
|
47
|
+
// Mark a step as completed
|
|
48
|
+
steps[0].completed = true;
|
|
49
|
+
|
|
50
|
+
// Mark a step as active
|
|
51
|
+
steps[1].active = true;
|
|
52
|
+
</script>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
</elements-example>
|
|
56
|
+
|
|
57
|
+
### Horizontal steps
|
|
58
|
+
|
|
59
|
+
<elements-example>
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<w-step-indicator horizontal>
|
|
64
|
+
<w-step completed>
|
|
65
|
+
<h4>Step 1</h4>
|
|
66
|
+
<p>Completed</p>
|
|
67
|
+
</w-step>
|
|
68
|
+
<w-step active>
|
|
69
|
+
<h4>Step 2</h4>
|
|
70
|
+
<p>In progress</p>
|
|
71
|
+
</w-step>
|
|
72
|
+
<w-step>
|
|
73
|
+
<h4>Step 3</h4>
|
|
74
|
+
<p>Upcoming</p>
|
|
75
|
+
</w-step>
|
|
76
|
+
</w-step-indicator>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
</elements-example>
|
|
80
|
+
|
|
81
|
+
### Right-aligned vertical steps
|
|
82
|
+
|
|
83
|
+
`right` can not be used with `horizontal` (`horizontal` wins).
|
|
84
|
+
|
|
85
|
+
<elements-example>
|
|
86
|
+
|
|
87
|
+
```html
|
|
88
|
+
<w-step-indicator right>
|
|
89
|
+
<w-step completed>
|
|
90
|
+
<h4>Step 1</h4>
|
|
91
|
+
<p>Completed</p>
|
|
92
|
+
</w-step>
|
|
93
|
+
<w-step active>
|
|
94
|
+
<h4>Step 2</h4>
|
|
95
|
+
<p>In progress</p>
|
|
96
|
+
</w-step>
|
|
97
|
+
<w-step>
|
|
98
|
+
<h4>Step 3</h4>
|
|
99
|
+
<p>Upcoming</p>
|
|
100
|
+
</w-step>
|
|
101
|
+
</w-step-indicator>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
</elements-example>
|
|
105
|
+
|
|
15
106
|
## `<w-step-indicator>` API
|
|
16
107
|
|
|
17
108
|
Unless otherwise noted all properties are HTML attributes (as opposed to JavaScript object properties).
|
|
@@ -20,21 +111,21 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
20
111
|
|
|
21
112
|
| Name | Type | Default | Summary |
|
|
22
113
|
|-|-|-|-|
|
|
23
|
-
| horizontal | `boolean` | `false` |
|
|
24
|
-
| right | `boolean` | `false` |
|
|
114
|
+
| horizontal | `boolean` | `false` | Display steps horizontally instead of vertically |
|
|
115
|
+
| right | `boolean` | `false` | Align steps to the right (vertical layout only) |
|
|
25
116
|
|
|
26
117
|
### Property Details
|
|
27
118
|
|
|
28
119
|
#### horizontal
|
|
29
120
|
|
|
30
|
-
|
|
121
|
+
Display steps horizontally instead of vertically
|
|
31
122
|
|
|
32
123
|
- Type: `boolean`
|
|
33
124
|
- Default: `false`
|
|
34
125
|
|
|
35
126
|
#### right
|
|
36
127
|
|
|
37
|
-
|
|
128
|
+
Align steps to the right (vertical layout only)
|
|
38
129
|
|
|
39
130
|
- Type: `boolean`
|
|
40
131
|
- Default: `false`
|
|
@@ -1 +1,13 @@
|
|
|
1
1
|
## Usage
|
|
2
|
+
|
|
3
|
+
The steps component consists of two custom elements that work together:
|
|
4
|
+
|
|
5
|
+
- `<w-step-indicator>` - The container that manages step layout and orientation
|
|
6
|
+
- `<w-step>` - Individual step items within the indicator
|
|
7
|
+
|
|
8
|
+
Each `<w-step>` can be marked as `active` or `completed` to indicate progress. The `<w-step-indicator>` component automatically handles:
|
|
9
|
+
|
|
10
|
+
- Vertical and horizontal layouts
|
|
11
|
+
- Left and right alignment (for vertical layout)
|
|
12
|
+
- Visual connecting lines between steps
|
|
13
|
+
- ARIA attributes for accessibility
|
package/dist/docs/switch/api.md
CHANGED
|
@@ -6,45 +6,39 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
6
6
|
|
|
7
7
|
| Name | Type | Default | Summary |
|
|
8
8
|
|-|-|-|-|
|
|
9
|
-
| checked | `boolean` | `false` |
|
|
10
|
-
| disabled | `boolean` | `false` |
|
|
11
|
-
| name | `string` | `-` |
|
|
12
|
-
|
|
|
13
|
-
| value | `string` | `-` | - |
|
|
9
|
+
| checked | `boolean` | `false` | Whether the switch is on (checked). |
|
|
10
|
+
| disabled | `boolean` | `false` | Whether the switch is disabled. |
|
|
11
|
+
| name | `string` | `-` | Name used when submitting an HTML form. |
|
|
12
|
+
| value | `string` | `-` | Value submitted when the switch is checked. |
|
|
14
13
|
|
|
15
14
|
### Property Details
|
|
16
15
|
|
|
17
16
|
#### checked
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
Whether the switch is on (checked).
|
|
20
19
|
|
|
21
20
|
- Type: `boolean`
|
|
22
21
|
- Default: `false`
|
|
23
22
|
|
|
24
23
|
#### disabled
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
Whether the switch is disabled.
|
|
27
26
|
|
|
28
27
|
- Type: `boolean`
|
|
29
28
|
- Default: `false`
|
|
30
29
|
|
|
31
30
|
#### name
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
Name used when submitting an HTML form.
|
|
34
33
|
|
|
35
34
|
- Type: `string`
|
|
36
35
|
- Default: `-`
|
|
37
36
|
|
|
38
|
-
#### shadowRootOptions (JS only)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
- Type: `object`
|
|
43
|
-
- Default: `{ ...LitElement.shadowRootOptions, delegatesFocus: true, }`
|
|
44
|
-
|
|
45
37
|
#### value
|
|
46
38
|
|
|
39
|
+
Value submitted when the switch is checked.
|
|
47
40
|
|
|
41
|
+
The component reports `null` as the value in the `change` event when `value` is an empty string.
|
|
48
42
|
|
|
49
43
|
- Type: `string`
|
|
50
44
|
- Default: `-`
|
|
@@ -53,8 +47,8 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
53
47
|
|
|
54
48
|
#### change
|
|
55
49
|
|
|
50
|
+
Dispatched when the switch toggles. Includes boolean `checked` and string/null `value` on `details`.
|
|
56
51
|
|
|
57
|
-
|
|
58
|
-
- Type: `CustomEvent`
|
|
52
|
+
- Type: `WarpSwitchChangeEvent`
|
|
59
53
|
|
|
60
54
|
|
|
@@ -1 +1,17 @@
|
|
|
1
1
|
## Examples
|
|
2
|
+
|
|
3
|
+
<elements-example>
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<w-switch id="demo-switch" name="marketing" value="yes"></w-switch>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
const el = document.querySelector('#demo-switch');
|
|
10
|
+
el.addEventListener('change', (event) => {
|
|
11
|
+
// event.detail = { checked: boolean, value: string | null }
|
|
12
|
+
console.log('changed', event.detail);
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
</elements-example>
|
|
@@ -2,14 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
## Description
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The Switch component allows users to toggle between two states.
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
9
|
+
`<w-switch>` is a form-associated toggle component.
|
|
10
|
+
|
|
11
|
+
- It reflects its `name`, `value`, `checked`, and `disabled` properties to attributes.
|
|
12
|
+
- It dispatches a bubbling `change` `CustomEvent` when toggled (when not disabled).
|
|
13
|
+
- When used in a form, the control submits `value` only when `checked` is `true` (otherwise it submits nothing).
|
|
14
|
+
|
|
9
15
|
## Accessibility
|
|
10
16
|
|
|
17
|
+
The internal control is rendered as a native `button` with `role="switch"` and `aria-checked` / `aria-disabled`.
|
|
18
|
+
|
|
11
19
|
## Examples
|
|
12
20
|
|
|
21
|
+
<elements-example>
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<w-switch id="demo-switch" name="marketing" value="yes"></w-switch>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
const el = document.querySelector('#demo-switch');
|
|
28
|
+
el.addEventListener('change', (event) => {
|
|
29
|
+
// event.detail = { checked: boolean, value: string | null }
|
|
30
|
+
console.log('changed', event.detail);
|
|
31
|
+
});
|
|
32
|
+
</script>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
</elements-example>
|
|
36
|
+
|
|
13
37
|
## `<w-switch>` API
|
|
14
38
|
|
|
15
39
|
Unless otherwise noted all properties are HTML attributes (as opposed to JavaScript object properties).
|
|
@@ -18,45 +42,39 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
18
42
|
|
|
19
43
|
| Name | Type | Default | Summary |
|
|
20
44
|
|-|-|-|-|
|
|
21
|
-
| checked | `boolean` | `false` |
|
|
22
|
-
| disabled | `boolean` | `false` |
|
|
23
|
-
| name | `string` | `-` |
|
|
24
|
-
|
|
|
25
|
-
| value | `string` | `-` | - |
|
|
45
|
+
| checked | `boolean` | `false` | Whether the switch is on (checked). |
|
|
46
|
+
| disabled | `boolean` | `false` | Whether the switch is disabled. |
|
|
47
|
+
| name | `string` | `-` | Name used when submitting an HTML form. |
|
|
48
|
+
| value | `string` | `-` | Value submitted when the switch is checked. |
|
|
26
49
|
|
|
27
50
|
### Property Details
|
|
28
51
|
|
|
29
52
|
#### checked
|
|
30
53
|
|
|
31
|
-
|
|
54
|
+
Whether the switch is on (checked).
|
|
32
55
|
|
|
33
56
|
- Type: `boolean`
|
|
34
57
|
- Default: `false`
|
|
35
58
|
|
|
36
59
|
#### disabled
|
|
37
60
|
|
|
38
|
-
|
|
61
|
+
Whether the switch is disabled.
|
|
39
62
|
|
|
40
63
|
- Type: `boolean`
|
|
41
64
|
- Default: `false`
|
|
42
65
|
|
|
43
66
|
#### name
|
|
44
67
|
|
|
45
|
-
|
|
68
|
+
Name used when submitting an HTML form.
|
|
46
69
|
|
|
47
70
|
- Type: `string`
|
|
48
71
|
- Default: `-`
|
|
49
72
|
|
|
50
|
-
#### shadowRootOptions (JS only)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
- Type: `object`
|
|
55
|
-
- Default: `{ ...LitElement.shadowRootOptions, delegatesFocus: true, }`
|
|
56
|
-
|
|
57
73
|
#### value
|
|
58
74
|
|
|
75
|
+
Value submitted when the switch is checked.
|
|
59
76
|
|
|
77
|
+
The component reports `null` as the value in the `change` event when `value` is an empty string.
|
|
60
78
|
|
|
61
79
|
- Type: `string`
|
|
62
80
|
- Default: `-`
|
|
@@ -65,8 +83,8 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
65
83
|
|
|
66
84
|
#### change
|
|
67
85
|
|
|
86
|
+
Dispatched when the switch toggles. Includes boolean `checked` and string/null `value` on `details`.
|
|
68
87
|
|
|
69
|
-
|
|
70
|
-
- Type: `CustomEvent`
|
|
88
|
+
- Type: `WarpSwitchChangeEvent`
|
|
71
89
|
|
|
72
90
|
|
|
@@ -1 +1,7 @@
|
|
|
1
1
|
## Usage
|
|
2
|
+
|
|
3
|
+
`<w-switch>` is a form-associated toggle component.
|
|
4
|
+
|
|
5
|
+
- It reflects its `name`, `value`, `checked`, and `disabled` properties to attributes.
|
|
6
|
+
- It dispatches a bubbling `change` `CustomEvent` when toggled (when not disabled).
|
|
7
|
+
- When used in a form, the control submits `value` only when `checked` is `true` (otherwise it submits nothing).
|