@warp-ds/elements 2.9.2-next.1 → 2.10.0-next.1
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 +275 -58
- package/dist/docs/button/accessibility.md +42 -0
- package/dist/docs/button/api.md +63 -39
- package/dist/docs/button/button.md +322 -40
- package/dist/docs/button/examples.md +126 -0
- package/dist/docs/button/usage.md +89 -0
- package/dist/docs/modal/accessibility.md +1 -0
- package/dist/docs/modal/api.md +51 -0
- package/dist/docs/modal/examples.md +67 -0
- package/dist/docs/modal/modal.md +238 -0
- package/dist/docs/modal/usage.md +110 -0
- package/dist/docs/modal-footer/accessibility.md +1 -0
- package/dist/docs/modal-footer/api.md +11 -0
- package/dist/docs/modal-footer/examples.md +1 -0
- package/dist/docs/modal-footer/modal-footer.md +23 -0
- package/dist/docs/modal-footer/usage.md +1 -0
- package/dist/docs/modal-header/accessibility.md +1 -0
- package/dist/docs/modal-header/api.md +42 -0
- package/dist/docs/modal-header/examples.md +1 -0
- package/dist/docs/modal-header/modal-header.md +54 -0
- package/dist/docs/modal-header/usage.md +1 -0
- package/dist/docs/page-indicator/api.md +6 -6
- package/dist/docs/page-indicator/examples.md +8 -0
- package/dist/docs/page-indicator/page-indicator.md +23 -6
- package/dist/docs/page-indicator/usage.md +8 -0
- package/dist/docs/pagination/api.md +12 -10
- package/dist/docs/pagination/examples.md +20 -0
- package/dist/docs/pagination/pagination.md +50 -12
- package/dist/docs/pagination/usage.md +18 -0
- package/dist/docs/pill/accessibility.md +2 -0
- package/dist/docs/pill/api.md +10 -26
- package/dist/docs/pill/examples.md +23 -0
- package/dist/docs/pill/pill.md +43 -28
- package/dist/docs/pill/usage.md +8 -0
- package/dist/index.d.ts +305 -289
- package/dist/packages/attention/attention.js +23 -21
- package/dist/packages/attention/attention.js.map +3 -3
- package/dist/packages/button/button.d.ts +54 -37
- package/dist/packages/button/button.js +17 -15
- package/dist/packages/button/button.js.map +3 -3
- package/dist/packages/button/button.react.stories.d.ts +2 -2
- package/dist/packages/button/react.d.ts +1 -1
- package/dist/packages/modal/index.d.ts +4 -4
- package/dist/packages/modal/index.js +4 -4
- package/dist/packages/modal/modal.d.ts +21 -12
- 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 +3 -3
- package/dist/packages/modal/modal.stories.d.ts +2 -1
- package/dist/packages/modal/modal.stories.js +85 -3
- package/dist/packages/modal/react.d.ts +2 -2
- package/dist/packages/modal-footer/modal-footer.d.ts +5 -3
- package/dist/packages/modal-footer/modal-footer.js +4 -4
- package/dist/packages/modal-footer/modal-footer.js.map +3 -3
- package/dist/packages/modal-footer/react.d.ts +1 -1
- package/dist/packages/modal-header/modal-header.d.ts +21 -11
- package/dist/packages/modal-header/modal-header.js +1 -1
- package/dist/packages/modal-header/modal-header.js.map +3 -3
- package/dist/packages/modal-header/react.d.ts +2 -2
- package/dist/packages/page-indicator/page-indicator.d.ts +9 -14
- package/dist/packages/page-indicator/page-indicator.js.map +2 -2
- package/dist/packages/pagination/pagination.d.ts +11 -11
- package/dist/packages/pagination/pagination.js.map +2 -2
- package/dist/packages/pill/pill.d.ts +14 -29
- package/dist/packages/pill/pill.js.map +2 -2
- package/dist/packages/pill/pill.react.stories.d.ts +2 -2
- package/dist/packages/pill/react.d.ts +1 -1
- package/dist/web-types.json +272 -70
- package/package.json +5 -5
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
## `<w-modal>` API
|
|
2
|
+
|
|
3
|
+
Unless otherwise noted all properties are HTML attributes (as opposed to JavaScript object properties).
|
|
4
|
+
|
|
5
|
+
### Properties
|
|
6
|
+
|
|
7
|
+
| Name | Type | Default | Summary |
|
|
8
|
+
|-|-|-|-|
|
|
9
|
+
| content-id | `string` | `-` | - |
|
|
10
|
+
| ignore-backdrop-clicks | `boolean` | `false` | Ignores clicks to the backdrop when set |
|
|
11
|
+
| show | `boolean` | `false` | Controls if the modal should show or hide. |
|
|
12
|
+
|
|
13
|
+
### Property Details
|
|
14
|
+
|
|
15
|
+
#### content-id
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
- Type: `string`
|
|
20
|
+
- Default: `-`
|
|
21
|
+
|
|
22
|
+
#### ignore-backdrop-clicks
|
|
23
|
+
|
|
24
|
+
Ignores clicks to the backdrop when set
|
|
25
|
+
|
|
26
|
+
- Type: `boolean`
|
|
27
|
+
- Default: `false`
|
|
28
|
+
|
|
29
|
+
#### show
|
|
30
|
+
|
|
31
|
+
Controls if the modal should show or hide.
|
|
32
|
+
|
|
33
|
+
You can also call the `open()` and `close()` methods.
|
|
34
|
+
|
|
35
|
+
- Type: `boolean`
|
|
36
|
+
- Default: `false`
|
|
37
|
+
|
|
38
|
+
### Events
|
|
39
|
+
|
|
40
|
+
#### hidden
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
- Type: `CustomEvent`
|
|
45
|
+
#### shown
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
- Type: `CustomEvent`
|
|
50
|
+
|
|
51
|
+
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
## Examples
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### With a titlebar
|
|
6
|
+
|
|
7
|
+
<elements-example>
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<div>
|
|
11
|
+
<w-button aria-haspopup='dialog'>
|
|
12
|
+
Open a modal
|
|
13
|
+
</w-button>
|
|
14
|
+
<w-modal>
|
|
15
|
+
<w-modal-header
|
|
16
|
+
slot='header'
|
|
17
|
+
title='An example modal'
|
|
18
|
+
></w-modal-header>
|
|
19
|
+
<div slot='content'>
|
|
20
|
+
<w-button variant='utility' small>
|
|
21
|
+
Toggle back button
|
|
22
|
+
</w-button>
|
|
23
|
+
<p>
|
|
24
|
+
I bomb atomically, Socrates' philosophies and hypotheses...
|
|
25
|
+
</p>
|
|
26
|
+
<p>
|
|
27
|
+
First I'm gonna getcha, once I gotcha, I gat-cha...
|
|
28
|
+
</p>
|
|
29
|
+
</div>
|
|
30
|
+
<w-modal-footer slot='footer'>
|
|
31
|
+
<w-button variant='primary'>
|
|
32
|
+
OK
|
|
33
|
+
</w-button>
|
|
34
|
+
</w-modal-footer>
|
|
35
|
+
</w-modal>
|
|
36
|
+
</div>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
</elements-example>
|
|
40
|
+
|
|
41
|
+
### With an image at the top
|
|
42
|
+
|
|
43
|
+
<elements-example>
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<w-button aria-haspopup="dialog" commandfor="my-modal" command="show-modal">
|
|
47
|
+
Open a modal
|
|
48
|
+
</w-button>
|
|
49
|
+
<w-modal id="my-modal">
|
|
50
|
+
<w-modal-header slot="header" title="Look a doggo!">
|
|
51
|
+
<img
|
|
52
|
+
slot="top"
|
|
53
|
+
class="h-[256] w-full object-cover"
|
|
54
|
+
src="/pages/public/unocssmusical.jpeg"
|
|
55
|
+
alt="AI-generated picture of a band in colourful setup"
|
|
56
|
+
>
|
|
57
|
+
</w-modal-header>
|
|
58
|
+
<div slot="content">
|
|
59
|
+
<p>I bomb atomically, Socrates' philosophies and hypotheses...</p>
|
|
60
|
+
</div>
|
|
61
|
+
<w-modal-footer slot="footer">
|
|
62
|
+
<w-button variant="primary" id="modal-close-button-two">OK</w-button>
|
|
63
|
+
</w-modal-footer>
|
|
64
|
+
</w-modal>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
</elements-example>
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# Modal (w-modal)
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
Modals (or dialogs) display important information that users need to acknowledge.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
To creat a modal you need three different components:
|
|
10
|
+
|
|
11
|
+
- `<w-modal>` - the parent component.
|
|
12
|
+
- `<w-modal-header>` - for the title and close button.
|
|
13
|
+
- `<w-modal-footer>` - for the actions such as Cancel and Confirm.
|
|
14
|
+
|
|
15
|
+
### JavaScript API
|
|
16
|
+
|
|
17
|
+
To open and close the modal using JavaScript, get a reference to the `<w-modal>` and call `open()` and `close()` respectively.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
<elements-example>
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<w-button data-testid="js-example-show" aria-haspopup="dialog">Show me some lyrics</w-button>
|
|
24
|
+
<w-modal data-testid="js-example-modal">
|
|
25
|
+
<w-modal-header slot="header" title="Triumph by Wu Tang Clan"></w-modal-header>
|
|
26
|
+
<div slot="content">
|
|
27
|
+
<p>
|
|
28
|
+
My beats travel like a vortex through your spine, to the top of your
|
|
29
|
+
cerebral cortex. The rebel, I make more noise than heavy metal. Now,
|
|
30
|
+
lo and behold, another deadly episode, bound to catch another charge
|
|
31
|
+
when I explode Perpendicular to the square we stay in gold like
|
|
32
|
+
Flair, escape from your dragon's lair in particular. Handcuffed in
|
|
33
|
+
the back of a bus, forty of us. Slammin a hype verse til ya head
|
|
34
|
+
burst. Handcuffed in the back of a bus, forty of us. I bomb
|
|
35
|
+
atomically Socrates' philosophies and hypothesis can't define how I
|
|
36
|
+
be dropping these mockeries. I be that insane one from the psycho
|
|
37
|
+
ward, I'm on the trigger, plus I got the Wu-Tang sword. Step through
|
|
38
|
+
your section with the Force like Luke Skywalker, rhyme author,
|
|
39
|
+
orchestrate mind torture.
|
|
40
|
+
</p>
|
|
41
|
+
</div>
|
|
42
|
+
<w-modal-footer slot="footer">
|
|
43
|
+
<div class="flex gap-16">
|
|
44
|
+
<w-button variant="secondary" data-testid="js-example-cancel">Cancel</w-button>
|
|
45
|
+
<w-button variant="primary" data-testid="js-example-confirm">Confirm</w-button>
|
|
46
|
+
</div>
|
|
47
|
+
</w-modal-footer>
|
|
48
|
+
</w-modal>
|
|
49
|
+
|
|
50
|
+
<script>
|
|
51
|
+
const modal = document.querySelector('w-modal[data-testid="js-example-modal"]');
|
|
52
|
+
|
|
53
|
+
const openButton = document.querySelector('w-button[data-testid="js-example-show"]');
|
|
54
|
+
const confirmButton = document.querySelector('w-button[data-testid="js-example-confirm"]');
|
|
55
|
+
const cancelButton = document.querySelector('w-button[data-testid="js-example-cancel"]');
|
|
56
|
+
|
|
57
|
+
openButton.addEventListener('click', () => modal.open());
|
|
58
|
+
confirmButton.addEventListener('click', () => modal.close());
|
|
59
|
+
cancelButton.addEventListener('click', () => modal.close());
|
|
60
|
+
</script>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
</elements-example>
|
|
64
|
+
|
|
65
|
+
### Invoker Commands
|
|
66
|
+
|
|
67
|
+
In [supported browsers](https://caniuse.com/?search=commandfor) (or [if you include the polyfill](https://github.com/keithamus/invokers-polyfill)) you can use the [Invoker Commands API](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API) to potentially skip JavaScript alltogether.
|
|
68
|
+
|
|
69
|
+
The available commands for `<w-modal>` are:
|
|
70
|
+
|
|
71
|
+
- `--show-modal`
|
|
72
|
+
- `--close`
|
|
73
|
+
- `--confirm`
|
|
74
|
+
|
|
75
|
+
<elements-example>
|
|
76
|
+
|
|
77
|
+
```html
|
|
78
|
+
<w-button commandfor="invoker-modal" command="--show-modal" aria-haspopup="dialog">Show me some lyrics</w-button>
|
|
79
|
+
<w-modal id="invoker-modal">
|
|
80
|
+
<w-modal-header slot="header" title="Triumph by Wu Tang Clan"></w-modal-header>
|
|
81
|
+
<div slot="content">
|
|
82
|
+
<p>
|
|
83
|
+
First I'm gonna getcha, once I gotcha, I gat-cha, You could never
|
|
84
|
+
capture the Method Man's stature. So uhh, tic toc and keep ticking,
|
|
85
|
+
while I get you flipping off what I'm kicking. Yes, the rhythm, the
|
|
86
|
+
rebel, alone in my level heat it up past the boiling point of metal.
|
|
87
|
+
Shackling the masses with drastic rap tactics, graphic displays melt
|
|
88
|
+
the steel like blacksmiths. My beats travel like a vortex through
|
|
89
|
+
your spine, to the top of your cerebral cortex. Yes, the rhythm, the
|
|
90
|
+
rebel, alone in my level heat it up past the boiling point of metal.
|
|
91
|
+
Small change, they putting shame in the game. Murderous material,
|
|
92
|
+
made by a madman, it's the mic wrecker, Inspector, bad man.
|
|
93
|
+
</p>
|
|
94
|
+
</div>
|
|
95
|
+
<w-modal-footer slot="footer">
|
|
96
|
+
<div class="flex gap-16">
|
|
97
|
+
<w-button variant="secondary" commandfor="invoker-modal" command="--close">Dope</w-button>
|
|
98
|
+
<w-button variant="primary" commandfor="invoker-modal" command="--confirm">Dope</w-button>
|
|
99
|
+
</div>
|
|
100
|
+
</w-modal-footer>
|
|
101
|
+
</w-modal>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
</elements-example>
|
|
105
|
+
|
|
106
|
+
Since `--confirm` and `--cancel` both close the modal, but mean different things, listen for the `command` event on `w-modal` to do stuff on the `--confirm` event, such as submit a response to an API. You can listen for the other commands as well (including `--show-modal`) if you need to add tracking events for example.
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
const modal = document.querySelector('w-modal');
|
|
110
|
+
|
|
111
|
+
modal.addEventListener('command', function (event: CommandEvent) {
|
|
112
|
+
if (event.command === '--confirm') {
|
|
113
|
+
console.log("Doing stuff!");
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Accessibility
|
|
119
|
+
|
|
120
|
+
## Examples
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
### With a titlebar
|
|
125
|
+
|
|
126
|
+
<elements-example>
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<div>
|
|
130
|
+
<w-button aria-haspopup='dialog'>
|
|
131
|
+
Open a modal
|
|
132
|
+
</w-button>
|
|
133
|
+
<w-modal>
|
|
134
|
+
<w-modal-header
|
|
135
|
+
slot='header'
|
|
136
|
+
title='An example modal'
|
|
137
|
+
></w-modal-header>
|
|
138
|
+
<div slot='content'>
|
|
139
|
+
<w-button variant='utility' small>
|
|
140
|
+
Toggle back button
|
|
141
|
+
</w-button>
|
|
142
|
+
<p>
|
|
143
|
+
I bomb atomically, Socrates' philosophies and hypotheses...
|
|
144
|
+
</p>
|
|
145
|
+
<p>
|
|
146
|
+
First I'm gonna getcha, once I gotcha, I gat-cha...
|
|
147
|
+
</p>
|
|
148
|
+
</div>
|
|
149
|
+
<w-modal-footer slot='footer'>
|
|
150
|
+
<w-button variant='primary'>
|
|
151
|
+
OK
|
|
152
|
+
</w-button>
|
|
153
|
+
</w-modal-footer>
|
|
154
|
+
</w-modal>
|
|
155
|
+
</div>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
</elements-example>
|
|
159
|
+
|
|
160
|
+
### With an image at the top
|
|
161
|
+
|
|
162
|
+
<elements-example>
|
|
163
|
+
|
|
164
|
+
```html
|
|
165
|
+
<w-button aria-haspopup="dialog" commandfor="my-modal" command="show-modal">
|
|
166
|
+
Open a modal
|
|
167
|
+
</w-button>
|
|
168
|
+
<w-modal id="my-modal">
|
|
169
|
+
<w-modal-header slot="header" title="Look a doggo!">
|
|
170
|
+
<img
|
|
171
|
+
slot="top"
|
|
172
|
+
class="h-[256] w-full object-cover"
|
|
173
|
+
src="/pages/public/unocssmusical.jpeg"
|
|
174
|
+
alt="AI-generated picture of a band in colourful setup"
|
|
175
|
+
>
|
|
176
|
+
</w-modal-header>
|
|
177
|
+
<div slot="content">
|
|
178
|
+
<p>I bomb atomically, Socrates' philosophies and hypotheses...</p>
|
|
179
|
+
</div>
|
|
180
|
+
<w-modal-footer slot="footer">
|
|
181
|
+
<w-button variant="primary" id="modal-close-button-two">OK</w-button>
|
|
182
|
+
</w-modal-footer>
|
|
183
|
+
</w-modal>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
</elements-example>
|
|
187
|
+
|
|
188
|
+
## `<w-modal>` API
|
|
189
|
+
|
|
190
|
+
Unless otherwise noted all properties are HTML attributes (as opposed to JavaScript object properties).
|
|
191
|
+
|
|
192
|
+
### Properties
|
|
193
|
+
|
|
194
|
+
| Name | Type | Default | Summary |
|
|
195
|
+
|-|-|-|-|
|
|
196
|
+
| content-id | `string` | `-` | - |
|
|
197
|
+
| ignore-backdrop-clicks | `boolean` | `false` | Ignores clicks to the backdrop when set |
|
|
198
|
+
| show | `boolean` | `false` | Controls if the modal should show or hide. |
|
|
199
|
+
|
|
200
|
+
### Property Details
|
|
201
|
+
|
|
202
|
+
#### content-id
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
- Type: `string`
|
|
207
|
+
- Default: `-`
|
|
208
|
+
|
|
209
|
+
#### ignore-backdrop-clicks
|
|
210
|
+
|
|
211
|
+
Ignores clicks to the backdrop when set
|
|
212
|
+
|
|
213
|
+
- Type: `boolean`
|
|
214
|
+
- Default: `false`
|
|
215
|
+
|
|
216
|
+
#### show
|
|
217
|
+
|
|
218
|
+
Controls if the modal should show or hide.
|
|
219
|
+
|
|
220
|
+
You can also call the `open()` and `close()` methods.
|
|
221
|
+
|
|
222
|
+
- Type: `boolean`
|
|
223
|
+
- Default: `false`
|
|
224
|
+
|
|
225
|
+
### Events
|
|
226
|
+
|
|
227
|
+
#### hidden
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
- Type: `CustomEvent`
|
|
232
|
+
#### shown
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
- Type: `CustomEvent`
|
|
237
|
+
|
|
238
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
## Usage
|
|
2
|
+
|
|
3
|
+
To creat a modal you need three different components:
|
|
4
|
+
|
|
5
|
+
- `<w-modal>` - the parent component.
|
|
6
|
+
- `<w-modal-header>` - for the title and close button.
|
|
7
|
+
- `<w-modal-footer>` - for the actions such as Cancel and Confirm.
|
|
8
|
+
|
|
9
|
+
### JavaScript API
|
|
10
|
+
|
|
11
|
+
To open and close the modal using JavaScript, get a reference to the `<w-modal>` and call `open()` and `close()` respectively.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
<elements-example>
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<w-button data-testid="js-example-show" aria-haspopup="dialog">Show me some lyrics</w-button>
|
|
18
|
+
<w-modal data-testid="js-example-modal">
|
|
19
|
+
<w-modal-header slot="header" title="Triumph by Wu Tang Clan"></w-modal-header>
|
|
20
|
+
<div slot="content">
|
|
21
|
+
<p>
|
|
22
|
+
My beats travel like a vortex through your spine, to the top of your
|
|
23
|
+
cerebral cortex. The rebel, I make more noise than heavy metal. Now,
|
|
24
|
+
lo and behold, another deadly episode, bound to catch another charge
|
|
25
|
+
when I explode Perpendicular to the square we stay in gold like
|
|
26
|
+
Flair, escape from your dragon's lair in particular. Handcuffed in
|
|
27
|
+
the back of a bus, forty of us. Slammin a hype verse til ya head
|
|
28
|
+
burst. Handcuffed in the back of a bus, forty of us. I bomb
|
|
29
|
+
atomically Socrates' philosophies and hypothesis can't define how I
|
|
30
|
+
be dropping these mockeries. I be that insane one from the psycho
|
|
31
|
+
ward, I'm on the trigger, plus I got the Wu-Tang sword. Step through
|
|
32
|
+
your section with the Force like Luke Skywalker, rhyme author,
|
|
33
|
+
orchestrate mind torture.
|
|
34
|
+
</p>
|
|
35
|
+
</div>
|
|
36
|
+
<w-modal-footer slot="footer">
|
|
37
|
+
<div class="flex gap-16">
|
|
38
|
+
<w-button variant="secondary" data-testid="js-example-cancel">Cancel</w-button>
|
|
39
|
+
<w-button variant="primary" data-testid="js-example-confirm">Confirm</w-button>
|
|
40
|
+
</div>
|
|
41
|
+
</w-modal-footer>
|
|
42
|
+
</w-modal>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
const modal = document.querySelector('w-modal[data-testid="js-example-modal"]');
|
|
46
|
+
|
|
47
|
+
const openButton = document.querySelector('w-button[data-testid="js-example-show"]');
|
|
48
|
+
const confirmButton = document.querySelector('w-button[data-testid="js-example-confirm"]');
|
|
49
|
+
const cancelButton = document.querySelector('w-button[data-testid="js-example-cancel"]');
|
|
50
|
+
|
|
51
|
+
openButton.addEventListener('click', () => modal.open());
|
|
52
|
+
confirmButton.addEventListener('click', () => modal.close());
|
|
53
|
+
cancelButton.addEventListener('click', () => modal.close());
|
|
54
|
+
</script>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
</elements-example>
|
|
58
|
+
|
|
59
|
+
### Invoker Commands
|
|
60
|
+
|
|
61
|
+
In [supported browsers](https://caniuse.com/?search=commandfor) (or [if you include the polyfill](https://github.com/keithamus/invokers-polyfill)) you can use the [Invoker Commands API](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API) to potentially skip JavaScript alltogether.
|
|
62
|
+
|
|
63
|
+
The available commands for `<w-modal>` are:
|
|
64
|
+
|
|
65
|
+
- `--show-modal`
|
|
66
|
+
- `--close`
|
|
67
|
+
- `--confirm`
|
|
68
|
+
|
|
69
|
+
<elements-example>
|
|
70
|
+
|
|
71
|
+
```html
|
|
72
|
+
<w-button commandfor="invoker-modal" command="--show-modal" aria-haspopup="dialog">Show me some lyrics</w-button>
|
|
73
|
+
<w-modal id="invoker-modal">
|
|
74
|
+
<w-modal-header slot="header" title="Triumph by Wu Tang Clan"></w-modal-header>
|
|
75
|
+
<div slot="content">
|
|
76
|
+
<p>
|
|
77
|
+
First I'm gonna getcha, once I gotcha, I gat-cha, You could never
|
|
78
|
+
capture the Method Man's stature. So uhh, tic toc and keep ticking,
|
|
79
|
+
while I get you flipping off what I'm kicking. Yes, the rhythm, the
|
|
80
|
+
rebel, alone in my level heat it up past the boiling point of metal.
|
|
81
|
+
Shackling the masses with drastic rap tactics, graphic displays melt
|
|
82
|
+
the steel like blacksmiths. My beats travel like a vortex through
|
|
83
|
+
your spine, to the top of your cerebral cortex. Yes, the rhythm, the
|
|
84
|
+
rebel, alone in my level heat it up past the boiling point of metal.
|
|
85
|
+
Small change, they putting shame in the game. Murderous material,
|
|
86
|
+
made by a madman, it's the mic wrecker, Inspector, bad man.
|
|
87
|
+
</p>
|
|
88
|
+
</div>
|
|
89
|
+
<w-modal-footer slot="footer">
|
|
90
|
+
<div class="flex gap-16">
|
|
91
|
+
<w-button variant="secondary" commandfor="invoker-modal" command="--close">Dope</w-button>
|
|
92
|
+
<w-button variant="primary" commandfor="invoker-modal" command="--confirm">Dope</w-button>
|
|
93
|
+
</div>
|
|
94
|
+
</w-modal-footer>
|
|
95
|
+
</w-modal>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
</elements-example>
|
|
99
|
+
|
|
100
|
+
Since `--confirm` and `--cancel` both close the modal, but mean different things, listen for the `command` event on `w-modal` to do stuff on the `--confirm` event, such as submit a response to an API. You can listen for the other commands as well (including `--show-modal`) if you need to add tracking events for example.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
const modal = document.querySelector('w-modal');
|
|
104
|
+
|
|
105
|
+
modal.addEventListener('command', function (event: CommandEvent) {
|
|
106
|
+
if (event.command === '--confirm') {
|
|
107
|
+
console.log("Doing stuff!");
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Accessibility
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Examples
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# ModalFooter (w-modal-footer)
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
The footer section of a modal, typically where you place actions.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
## Accessibility
|
|
10
|
+
|
|
11
|
+
## Examples
|
|
12
|
+
|
|
13
|
+
### `<w-modal-footer>` API
|
|
14
|
+
|
|
15
|
+
#### Properties
|
|
16
|
+
|
|
17
|
+
| Name | Type | Default | Summary |
|
|
18
|
+
|-|-|-|-|
|
|
19
|
+
|
|
20
|
+
#### Property Details
|
|
21
|
+
|
|
22
|
+
No public fields documented.
|
|
23
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Usage
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Accessibility
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
### `<w-modal-header>` API
|
|
2
|
+
|
|
3
|
+
#### Properties
|
|
4
|
+
|
|
5
|
+
| Name | Type | Default | Summary |
|
|
6
|
+
|-|-|-|-|
|
|
7
|
+
| back | `boolean` | `false` | Whether the modal header should have a back button |
|
|
8
|
+
| no-close | `boolean` | `false` | Lets you hide the close button in the header |
|
|
9
|
+
| title | `string` | `-` | A short but descriptive title for the modal |
|
|
10
|
+
|
|
11
|
+
#### Property Details
|
|
12
|
+
|
|
13
|
+
##### back
|
|
14
|
+
|
|
15
|
+
Whether the modal header should have a back button
|
|
16
|
+
|
|
17
|
+
- Type: `boolean`
|
|
18
|
+
- Default: `false`
|
|
19
|
+
|
|
20
|
+
##### no-close
|
|
21
|
+
|
|
22
|
+
Lets you hide the close button in the header
|
|
23
|
+
|
|
24
|
+
- Type: `boolean`
|
|
25
|
+
- Default: `false`
|
|
26
|
+
|
|
27
|
+
##### title
|
|
28
|
+
|
|
29
|
+
A short but descriptive title for the modal
|
|
30
|
+
|
|
31
|
+
- Type: `string`
|
|
32
|
+
- Default: `-`
|
|
33
|
+
|
|
34
|
+
#### Events
|
|
35
|
+
|
|
36
|
+
##### backClicked
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
- Type: `CustomEvent`
|
|
41
|
+
|
|
42
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Examples
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# ModalHeader (w-modal-header)
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
The header section of a modal, typically where you place the title and a close button.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
## Accessibility
|
|
10
|
+
|
|
11
|
+
## Examples
|
|
12
|
+
|
|
13
|
+
### `<w-modal-header>` API
|
|
14
|
+
|
|
15
|
+
#### Properties
|
|
16
|
+
|
|
17
|
+
| Name | Type | Default | Summary |
|
|
18
|
+
|-|-|-|-|
|
|
19
|
+
| back | `boolean` | `false` | Whether the modal header should have a back button |
|
|
20
|
+
| no-close | `boolean` | `false` | Lets you hide the close button in the header |
|
|
21
|
+
| title | `string` | `-` | A short but descriptive title for the modal |
|
|
22
|
+
|
|
23
|
+
#### Property Details
|
|
24
|
+
|
|
25
|
+
##### back
|
|
26
|
+
|
|
27
|
+
Whether the modal header should have a back button
|
|
28
|
+
|
|
29
|
+
- Type: `boolean`
|
|
30
|
+
- Default: `false`
|
|
31
|
+
|
|
32
|
+
##### no-close
|
|
33
|
+
|
|
34
|
+
Lets you hide the close button in the header
|
|
35
|
+
|
|
36
|
+
- Type: `boolean`
|
|
37
|
+
- Default: `false`
|
|
38
|
+
|
|
39
|
+
##### title
|
|
40
|
+
|
|
41
|
+
A short but descriptive title for the modal
|
|
42
|
+
|
|
43
|
+
- Type: `string`
|
|
44
|
+
- Default: `-`
|
|
45
|
+
|
|
46
|
+
#### Events
|
|
47
|
+
|
|
48
|
+
##### backClicked
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
- Type: `CustomEvent`
|
|
53
|
+
|
|
54
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Usage
|
|
@@ -6,22 +6,22 @@ Unless otherwise noted all properties are HTML attributes (as opposed to JavaScr
|
|
|
6
6
|
|
|
7
7
|
| Name | Type | Default | Summary |
|
|
8
8
|
|-|-|-|-|
|
|
9
|
-
| page-count | `number` |
|
|
10
|
-
| selected-page | `number` |
|
|
9
|
+
| page-count | `number` | `1` | Total number of pages |
|
|
10
|
+
| selected-page | `number` | `1` | Currently selected page (1-based index) |
|
|
11
11
|
|
|
12
12
|
### Property Details
|
|
13
13
|
|
|
14
14
|
#### page-count
|
|
15
15
|
|
|
16
|
-
Total number of pages
|
|
16
|
+
Total number of pages
|
|
17
17
|
|
|
18
18
|
- Type: `number`
|
|
19
|
-
- Default:
|
|
19
|
+
- Default: `1`
|
|
20
20
|
|
|
21
21
|
#### selected-page
|
|
22
22
|
|
|
23
|
-
Currently selected page (1-based index
|
|
23
|
+
Currently selected page (1-based index)
|
|
24
24
|
|
|
25
25
|
- Type: `number`
|
|
26
|
-
- Default:
|
|
26
|
+
- Default: `1`
|
|
27
27
|
|