@vmz/ui 0.2.3 → 0.2.4
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/package.json +1 -1
- package/src/components/Accordion.vmz +46 -63
- package/src/components/Alert.vmz +35 -38
- package/src/components/AppShell.vmz +92 -75
- package/src/components/Autocomplete.vmz +91 -119
- package/src/components/Avatar.vmz +37 -8
- package/src/components/Badge.vmz +29 -23
- package/src/components/Breadcrumb.vmz +36 -34
- package/src/components/BulkActions.vmz +22 -28
- package/src/components/Button.vmz +139 -121
- package/src/components/Callout.vmz +33 -36
- package/src/components/Card.vmz +68 -51
- package/src/components/Checkbox.vmz +28 -47
- package/src/components/CodeBlock.vmz +31 -25
- package/src/components/Collapse.vmz +34 -16
- package/src/components/ConsoleShell.vmz +107 -110
- package/src/components/Content.vmz +8 -4
- package/src/components/DataTable.vmz +124 -150
- package/src/components/DatePicker.vmz +526 -521
- package/src/components/Dialog.vmz +408 -327
- package/src/components/Divider.vmz +38 -11
- package/src/components/Drawer.vmz +325 -318
- package/src/components/Dropdown.vmz +53 -19
- package/src/components/Empty.vmz +23 -21
- package/src/components/Field.vmz +77 -83
- package/src/components/FilterBar.vmz +8 -10
- package/src/components/Flex.vmz +21 -6
- package/src/components/Footer.vmz +9 -4
- package/src/components/Form.vmz +35 -46
- package/src/components/FormItem.vmz +44 -43
- package/src/components/Grid.vmz +22 -6
- package/src/components/Header.vmz +11 -4
- package/src/components/Icon.vmz +43 -44
- package/src/components/Layout.vmz +9 -4
- package/src/components/Link.vmz +17 -25
- package/src/components/List.vmz +62 -75
- package/src/components/Menu.vmz +182 -197
- package/src/components/Notification.vmz +35 -38
- package/src/components/Pagination.vmz +37 -47
- package/src/components/Popover.vmz +157 -171
- package/src/components/Progress.vmz +36 -10
- package/src/components/Prose.vmz +29 -31
- package/src/components/QueryForm.vmz +14 -22
- package/src/components/RadioGroup.vmz +70 -84
- package/src/components/Result.vmz +36 -38
- package/src/components/Segmented.vmz +43 -22
- package/src/components/Select.vmz +404 -411
- package/src/components/Sider.vmz +21 -4
- package/src/components/Skeleton.vmz +34 -42
- package/src/components/Space.vmz +24 -9
- package/src/components/Spinner.vmz +17 -23
- package/src/components/Steps.vmz +48 -51
- package/src/components/Switch.vmz +50 -60
- package/src/components/Table.vmz +81 -84
- package/src/components/Tabs.vmz +66 -88
- package/src/components/Tag.vmz +36 -11
- package/src/components/TextArea.vmz +73 -77
- package/src/components/Timeline.vmz +36 -32
- package/src/components/Toc.vmz +31 -37
- package/src/components/Tooltip.vmz +25 -35
- package/src/components/Tree.vmz +127 -144
- package/src/components/Typography.vmz +33 -7
- package/src/components/Upload.vmz +1135 -1057
|
@@ -1,73 +1,47 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
aria-label="Dismiss drawer"
|
|
19
|
-
@click="dismiss"
|
|
20
|
-
></button>
|
|
21
|
-
<div
|
|
22
|
-
class="vmz-ui-drawer__panel"
|
|
23
|
-
role="dialog"
|
|
24
|
-
aria-modal="true"
|
|
25
|
-
:aria-labelledby="titleId"
|
|
26
|
-
tabindex="-1"
|
|
27
|
-
data-vmz-overlay-layer="panel"
|
|
28
|
-
data-vmz-focus="enter"
|
|
29
|
-
data-vmz-motion="overlay-enter"
|
|
30
|
-
data-vmz-motion-token="motion.overlay"
|
|
31
|
-
:onKeyDown="onPanelKeyDown"
|
|
32
|
-
>
|
|
33
|
-
<h2 :id="titleId" class="vmz-ui-drawer__title">{{ title }}</h2>
|
|
34
|
-
<div class="vmz-ui-drawer__body">
|
|
35
|
-
<slot />
|
|
36
|
-
</div>
|
|
37
|
-
<div class="vmz-ui-drawer__actions">
|
|
38
|
-
<button type="button" class="vmz-ui-drawer__close" data-vmz-focus="close" @click="dismiss">
|
|
39
|
-
Close
|
|
40
|
-
</button>
|
|
41
|
-
</div>
|
|
2
|
+
<div data-vmz-ui="drawer" :data-vmz-overlay-open="open" class="vmz-ui-drawer-root">
|
|
3
|
+
<div v-if="open" data-vmz-overlay="drawer" data-vmz-overlay-owner="drawer" :data-vmz-overlay-stack="stackLevel" class="vmz-ui-drawer">
|
|
4
|
+
<button type="button" data-vmz-overlay-layer="backdrop" aria-label="Dismiss drawer" @click="dismiss" class="vmz-ui-drawer__backdrop" />
|
|
5
|
+
<div role="dialog" aria-modal="true" :aria-labelledby="titleId" tabindex="-1" data-vmz-overlay-layer="panel" data-vmz-focus="enter" data-vmz-motion="overlay-enter" data-vmz-motion-token="motion.overlay" :onKeyDown="onPanelKeyDown" class="vmz-ui-drawer__panel">
|
|
6
|
+
<h2 :id="titleId" class="vmz-ui-drawer__title">
|
|
7
|
+
{{ title }}
|
|
8
|
+
</h2>
|
|
9
|
+
<div class="vmz-ui-drawer__body">
|
|
10
|
+
<slot />
|
|
11
|
+
</div>
|
|
12
|
+
<div class="vmz-ui-drawer__actions">
|
|
13
|
+
<button type="button" data-vmz-focus="close" @click="dismiss" class="vmz-ui-drawer__close">
|
|
14
|
+
Close
|
|
15
|
+
</button>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
42
18
|
</div>
|
|
43
|
-
</div>
|
|
44
19
|
</div>
|
|
45
20
|
</template>
|
|
46
|
-
|
|
47
21
|
<style>
|
|
48
|
-
|
|
22
|
+
.vmz-ui-drawer-root {
|
|
49
23
|
display: block;
|
|
50
|
-
|
|
24
|
+
}
|
|
51
25
|
|
|
52
|
-
|
|
26
|
+
.vmz-ui-drawer {
|
|
53
27
|
position: fixed;
|
|
54
28
|
inset: 0;
|
|
55
29
|
z-index: 40;
|
|
56
|
-
|
|
30
|
+
}
|
|
57
31
|
|
|
58
|
-
|
|
32
|
+
.vmz-ui-drawer[data-vmz-overlay-stack="1"] {
|
|
59
33
|
z-index: 50;
|
|
60
|
-
|
|
34
|
+
}
|
|
61
35
|
|
|
62
|
-
|
|
36
|
+
.vmz-ui-drawer[data-vmz-overlay-stack="2"] {
|
|
63
37
|
z-index: 60;
|
|
64
|
-
|
|
38
|
+
}
|
|
65
39
|
|
|
66
|
-
|
|
40
|
+
.vmz-ui-drawer[data-vmz-overlay-stack="3"] {
|
|
67
41
|
z-index: 70;
|
|
68
|
-
|
|
42
|
+
}
|
|
69
43
|
|
|
70
|
-
|
|
44
|
+
.vmz-ui-drawer__backdrop {
|
|
71
45
|
position: absolute;
|
|
72
46
|
inset: 0;
|
|
73
47
|
border: 0;
|
|
@@ -75,10 +49,11 @@
|
|
|
75
49
|
margin: 0;
|
|
76
50
|
cursor: pointer;
|
|
77
51
|
background: rgba(0, 0, 0, 0.45);
|
|
78
|
-
animation: vmz-ui-drawer-fade-in var(--vmz-motion-overlay-duration)
|
|
79
|
-
|
|
52
|
+
animation: vmz-ui-drawer-fade-in var(--vmz-motion-overlay-duration)
|
|
53
|
+
var(--vmz-motion-overlay-easing);
|
|
54
|
+
}
|
|
80
55
|
|
|
81
|
-
|
|
56
|
+
.vmz-ui-drawer__panel {
|
|
82
57
|
position: absolute;
|
|
83
58
|
top: 0;
|
|
84
59
|
right: 0;
|
|
@@ -94,41 +69,44 @@
|
|
|
94
69
|
outline: none;
|
|
95
70
|
display: flex;
|
|
96
71
|
flex-direction: column;
|
|
97
|
-
animation: vmz-ui-drawer-panel-in var(--vmz-motion-overlay-duration)
|
|
98
|
-
|
|
72
|
+
animation: vmz-ui-drawer-panel-in var(--vmz-motion-overlay-duration)
|
|
73
|
+
var(--vmz-motion-overlay-easing);
|
|
74
|
+
}
|
|
99
75
|
|
|
100
|
-
|
|
101
|
-
|
|
76
|
+
.vmz-ui-drawer[data-vmz-motion-adopt="true"] .vmz-ui-drawer__backdrop,
|
|
77
|
+
.vmz-ui-drawer[data-vmz-motion-adopt="true"] .vmz-ui-drawer__panel {
|
|
102
78
|
animation: none;
|
|
103
|
-
|
|
79
|
+
}
|
|
104
80
|
|
|
105
|
-
|
|
106
|
-
animation: vmz-ui-drawer-fade-out var(--vmz-motion-overlay-duration)
|
|
107
|
-
|
|
81
|
+
.vmz-ui-drawer[data-vmz-motion-phase="exit"] .vmz-ui-drawer__backdrop {
|
|
82
|
+
animation: vmz-ui-drawer-fade-out var(--vmz-motion-overlay-duration)
|
|
83
|
+
var(--vmz-motion-overlay-easing);
|
|
84
|
+
}
|
|
108
85
|
|
|
109
|
-
|
|
110
|
-
animation: vmz-ui-drawer-panel-out var(--vmz-motion-overlay-duration)
|
|
111
|
-
|
|
86
|
+
.vmz-ui-drawer[data-vmz-motion-phase="exit"] .vmz-ui-drawer__panel {
|
|
87
|
+
animation: vmz-ui-drawer-panel-out var(--vmz-motion-overlay-duration)
|
|
88
|
+
var(--vmz-motion-overlay-easing);
|
|
89
|
+
}
|
|
112
90
|
|
|
113
|
-
|
|
91
|
+
.vmz-ui-drawer__panel:focus-visible {
|
|
114
92
|
box-shadow: 0 0 0 2px var(--vmz-focus-ring);
|
|
115
|
-
|
|
93
|
+
}
|
|
116
94
|
|
|
117
|
-
|
|
95
|
+
.vmz-ui-drawer__title {
|
|
118
96
|
margin: 0 0 0.75rem;
|
|
119
97
|
font-size: 1rem;
|
|
120
98
|
font-weight: 600;
|
|
121
99
|
color: var(--vmz-text-ink);
|
|
122
|
-
|
|
100
|
+
}
|
|
123
101
|
|
|
124
|
-
|
|
102
|
+
.vmz-ui-drawer__body {
|
|
125
103
|
flex: 1;
|
|
126
104
|
margin-bottom: 1rem;
|
|
127
105
|
overflow: auto;
|
|
128
106
|
color: var(--vmz-text-ink);
|
|
129
|
-
|
|
107
|
+
}
|
|
130
108
|
|
|
131
|
-
|
|
109
|
+
.vmz-ui-drawer__close {
|
|
132
110
|
font: inherit;
|
|
133
111
|
font-size: 0.875rem;
|
|
134
112
|
font-weight: 400;
|
|
@@ -139,282 +117,311 @@
|
|
|
139
117
|
cursor: pointer;
|
|
140
118
|
background: var(--vmz-surface-paper, #fff);
|
|
141
119
|
color: var(--vmz-text-ink);
|
|
142
|
-
|
|
120
|
+
}
|
|
143
121
|
|
|
144
|
-
|
|
122
|
+
.vmz-ui-drawer__close:hover {
|
|
145
123
|
color: var(--vmz-action-primary-background);
|
|
146
124
|
border-color: var(--vmz-action-primary-background);
|
|
147
|
-
|
|
125
|
+
}
|
|
148
126
|
|
|
149
|
-
|
|
127
|
+
.vmz-ui-drawer__close:focus-visible {
|
|
150
128
|
box-shadow: 0 0 0 2px var(--vmz-focus-ring);
|
|
151
|
-
|
|
129
|
+
}
|
|
152
130
|
|
|
153
|
-
|
|
131
|
+
@keyframes vmz-ui-drawer-fade-in {
|
|
154
132
|
from {
|
|
155
|
-
|
|
133
|
+
opacity: 0;
|
|
156
134
|
}
|
|
157
135
|
to {
|
|
158
|
-
|
|
136
|
+
opacity: 1;
|
|
159
137
|
}
|
|
160
|
-
|
|
138
|
+
}
|
|
161
139
|
|
|
162
|
-
|
|
140
|
+
@keyframes vmz-ui-drawer-panel-in {
|
|
163
141
|
from {
|
|
164
|
-
|
|
165
|
-
|
|
142
|
+
opacity: 0;
|
|
143
|
+
transform: translateX(0.75rem);
|
|
166
144
|
}
|
|
167
145
|
to {
|
|
168
|
-
|
|
169
|
-
|
|
146
|
+
opacity: 1;
|
|
147
|
+
transform: none;
|
|
170
148
|
}
|
|
171
|
-
|
|
149
|
+
}
|
|
172
150
|
|
|
173
|
-
|
|
151
|
+
@keyframes vmz-ui-drawer-fade-out {
|
|
174
152
|
from {
|
|
175
|
-
|
|
153
|
+
opacity: 1;
|
|
176
154
|
}
|
|
177
155
|
to {
|
|
178
|
-
|
|
156
|
+
opacity: 0;
|
|
179
157
|
}
|
|
180
|
-
|
|
158
|
+
}
|
|
181
159
|
|
|
182
|
-
|
|
160
|
+
@keyframes vmz-ui-drawer-panel-out {
|
|
183
161
|
from {
|
|
184
|
-
|
|
185
|
-
|
|
162
|
+
opacity: 1;
|
|
163
|
+
transform: none;
|
|
186
164
|
}
|
|
187
165
|
to {
|
|
188
|
-
|
|
189
|
-
|
|
166
|
+
opacity: 0;
|
|
167
|
+
transform: translateX(0.75rem);
|
|
190
168
|
}
|
|
191
|
-
|
|
169
|
+
}
|
|
192
170
|
|
|
193
|
-
|
|
171
|
+
@media (prefers-reduced-motion: reduce) {
|
|
194
172
|
.vmz-ui-drawer__backdrop,
|
|
195
173
|
.vmz-ui-drawer__panel,
|
|
196
|
-
.vmz-ui-drawer[data-vmz-motion-phase=
|
|
197
|
-
.vmz-ui-drawer[data-vmz-motion-phase=
|
|
198
|
-
|
|
174
|
+
.vmz-ui-drawer[data-vmz-motion-phase="exit"] .vmz-ui-drawer__backdrop,
|
|
175
|
+
.vmz-ui-drawer[data-vmz-motion-phase="exit"] .vmz-ui-drawer__panel {
|
|
176
|
+
animation: none;
|
|
199
177
|
}
|
|
200
|
-
|
|
178
|
+
}
|
|
201
179
|
</style>
|
|
202
|
-
|
|
203
180
|
<script client>
|
|
204
181
|
/**
|
|
205
|
-
* VMZ UI — Drawer (UI2).
|
|
206
|
-
* Same overlay ownership / focus / Escape / stack as Dialog.
|
|
207
|
-
* SSR/resume adopt skips enter replay; dismiss plays overlay-exit then calls onClose.
|
|
208
|
-
*/
|
|
182
|
+
* VMZ UI — Drawer (UI2).
|
|
183
|
+
* Same overlay ownership / focus / Escape / stack as Dialog.
|
|
184
|
+
* SSR/resume adopt skips enter replay; dismiss plays overlay-exit then calls onClose.
|
|
185
|
+
*/
|
|
209
186
|
export default class Drawer {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
187
|
+
public open: boolean = false;
|
|
188
|
+
public title: string = "Drawer";
|
|
189
|
+
public titleId: string = "vmz-drawer-title";
|
|
190
|
+
public stackLevel: string = "0";
|
|
191
|
+
public onClose: (() => void) | null = null;
|
|
192
|
+
_restoreFocus = null;
|
|
193
|
+
_panel = null;
|
|
194
|
+
_docKeyHandler = null;
|
|
195
|
+
_observer = null;
|
|
196
|
+
_adoptNextEnter = false;
|
|
197
|
+
_exiting = false;
|
|
198
|
+
_exitTimer = null;
|
|
199
|
+
/** Motion generation — exit timer and cancel edges key off this owner counter. */
|
|
200
|
+
_motionGen = 0;
|
|
201
|
+
async onMount() {
|
|
202
|
+
if (typeof document === "undefined" || typeof MutationObserver === "undefined") return;
|
|
203
|
+
const root = this.__vmzDomRoot;
|
|
204
|
+
if (!root || typeof root.querySelector !== "function") return;
|
|
205
|
+
if (root.querySelector('[data-vmz-overlay="drawer"]')) this._adoptNextEnter = true;
|
|
206
|
+
this._observer = new MutationObserver(() => this._syncFromDom());
|
|
207
|
+
this._observer.observe(root, {
|
|
208
|
+
childList: true,
|
|
209
|
+
subtree: true,
|
|
210
|
+
});
|
|
211
|
+
this._syncFromDom();
|
|
212
|
+
}
|
|
213
|
+
onDestroy() {
|
|
214
|
+
if (this._exitTimer) {
|
|
215
|
+
clearTimeout(this._exitTimer);
|
|
216
|
+
this._exitTimer = null;
|
|
217
|
+
}
|
|
218
|
+
this._exiting = false;
|
|
219
|
+
if (this._observer) {
|
|
220
|
+
this._observer.disconnect();
|
|
221
|
+
this._observer = null;
|
|
222
|
+
}
|
|
223
|
+
this._teardownDocKey();
|
|
224
|
+
this._panel = null;
|
|
225
|
+
this._restoreFocus = null;
|
|
226
|
+
}
|
|
227
|
+
dismiss() {
|
|
228
|
+
if (!this._isTopmostStack()) return;
|
|
229
|
+
if (this._exiting) {
|
|
230
|
+
this._cancelExit("reverse");
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const panel = this._panel;
|
|
234
|
+
const overlay =
|
|
235
|
+
panel && typeof panel.closest === "function"
|
|
236
|
+
? panel.closest('[data-vmz-overlay="drawer"]')
|
|
237
|
+
: null;
|
|
238
|
+
const reduce =
|
|
239
|
+
typeof window !== "undefined" &&
|
|
240
|
+
typeof window.matchMedia === "function" &&
|
|
241
|
+
window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
242
|
+
if (panel && overlay && !reduce) {
|
|
243
|
+
this._exiting = true;
|
|
244
|
+
const exitGen = this._motionGen;
|
|
245
|
+
overlay.setAttribute("data-vmz-motion-phase", "exit");
|
|
246
|
+
overlay.removeAttribute("data-vmz-motion-cancelled");
|
|
247
|
+
panel.setAttribute("data-vmz-motion", "overlay-exit");
|
|
248
|
+
const ms = this._overlayDurationMs(panel);
|
|
249
|
+
this._exitTimer = setTimeout(() => {
|
|
250
|
+
this._exitTimer = null;
|
|
251
|
+
if (!this._exiting || exitGen !== this._motionGen) return;
|
|
252
|
+
this._exiting = false;
|
|
253
|
+
this.emit("close");
|
|
254
|
+
if (typeof this.onClose === "function") this.onClose();
|
|
255
|
+
}, ms);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
this.emit("close");
|
|
259
|
+
if (typeof this.onClose === "function") this.onClose();
|
|
260
|
+
}
|
|
261
|
+
_cancelExit(reason) {
|
|
262
|
+
if (this._exitTimer) {
|
|
263
|
+
clearTimeout(this._exitTimer);
|
|
264
|
+
this._exitTimer = null;
|
|
265
|
+
}
|
|
266
|
+
this._exiting = false;
|
|
267
|
+
this._motionGen += 1;
|
|
268
|
+
const panel = this._panel;
|
|
269
|
+
const overlay =
|
|
270
|
+
panel && typeof panel.closest === "function"
|
|
271
|
+
? panel.closest('[data-vmz-overlay="drawer"]')
|
|
272
|
+
: null;
|
|
273
|
+
if (overlay) {
|
|
274
|
+
overlay.removeAttribute("data-vmz-motion-phase");
|
|
275
|
+
overlay.setAttribute("data-vmz-motion-cancelled", reason || "true");
|
|
276
|
+
overlay.setAttribute("data-vmz-motion-gen", String(this._motionGen));
|
|
277
|
+
}
|
|
278
|
+
if (panel) {
|
|
279
|
+
panel.setAttribute("data-vmz-motion", "overlay-enter");
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
_overlayDurationMs(panel) {
|
|
283
|
+
try {
|
|
284
|
+
const raw =
|
|
285
|
+
(
|
|
286
|
+
getComputedStyle(panel).getPropertyValue("--vmz-motion-overlay-duration") || ""
|
|
287
|
+
).trim() || "180ms";
|
|
288
|
+
if (raw.endsWith("ms")) return Math.max(0, Number.parseFloat(raw) || 180);
|
|
289
|
+
if (raw.endsWith("s")) return Math.max(0, (Number.parseFloat(raw) || 0.18) * 1e3);
|
|
290
|
+
return 180;
|
|
291
|
+
} catch {
|
|
292
|
+
return 180;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
_isTopmostStack() {
|
|
296
|
+
if (typeof document === "undefined") return true;
|
|
297
|
+
const root = this.__vmzDomRoot;
|
|
298
|
+
const mine =
|
|
299
|
+
root && typeof root.querySelector === "function"
|
|
300
|
+
? root.querySelector("[data-vmz-overlay][data-vmz-overlay-stack]")
|
|
301
|
+
: null;
|
|
302
|
+
if (!mine) return true;
|
|
303
|
+
const myStack = Number(
|
|
304
|
+
mine.getAttribute("data-vmz-overlay-stack") || this.stackLevel || "0",
|
|
305
|
+
);
|
|
306
|
+
const open = [...document.querySelectorAll("[data-vmz-overlay][data-vmz-overlay-stack]")];
|
|
307
|
+
let max = -Infinity;
|
|
308
|
+
for (const el of open) {
|
|
309
|
+
const n = Number(el.getAttribute("data-vmz-overlay-stack") || "0");
|
|
310
|
+
if (Number.isFinite(n) && n > max) max = n;
|
|
311
|
+
}
|
|
312
|
+
if (!Number.isFinite(max)) return true;
|
|
313
|
+
if ((Number.isFinite(myStack) ? myStack : 0) < max) return false;
|
|
314
|
+
if ((Number.isFinite(myStack) ? myStack : 0) > max) return true;
|
|
315
|
+
const same = open.filter(
|
|
316
|
+
(el) => Number(el.getAttribute("data-vmz-overlay-stack") || "0") === max,
|
|
317
|
+
);
|
|
318
|
+
return same[same.length - 1] === mine;
|
|
319
|
+
}
|
|
320
|
+
onPanelKeyDown(ev) {
|
|
321
|
+
if (!ev || ev.key !== "Tab") return;
|
|
322
|
+
const panel = this._panel;
|
|
323
|
+
if (!panel) return;
|
|
324
|
+
const nodes = panel.querySelectorAll(
|
|
325
|
+
'a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])',
|
|
326
|
+
);
|
|
327
|
+
const list = [];
|
|
328
|
+
for (const n of nodes) {
|
|
329
|
+
if (n instanceof HTMLElement && n.offsetParent !== null) list.push(n);
|
|
330
|
+
}
|
|
331
|
+
if (panel.tabIndex >= 0) list.unshift(panel);
|
|
332
|
+
if (!list.length) {
|
|
333
|
+
ev.preventDefault();
|
|
334
|
+
panel.focus();
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
const first = list[0];
|
|
338
|
+
const last = list[list.length - 1];
|
|
339
|
+
const active = document.activeElement;
|
|
340
|
+
if (ev.shiftKey) {
|
|
341
|
+
if (active === first || active === panel) {
|
|
342
|
+
ev.preventDefault();
|
|
343
|
+
last.focus();
|
|
344
|
+
}
|
|
345
|
+
} else if (active === last) {
|
|
346
|
+
ev.preventDefault();
|
|
347
|
+
first.focus();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
_syncFromDom() {
|
|
351
|
+
const root = this.__vmzDomRoot;
|
|
352
|
+
const panel =
|
|
353
|
+
root && typeof root.querySelector === "function"
|
|
354
|
+
? root.querySelector('[data-vmz-overlay="drawer"] [data-vmz-focus="enter"]')
|
|
355
|
+
: null;
|
|
356
|
+
if (panel && !this._panel) this._enterFocus(panel);
|
|
357
|
+
else if (!panel && this._panel) this._exitFocus();
|
|
358
|
+
}
|
|
359
|
+
_enterFocus(panel) {
|
|
360
|
+
if (typeof document === "undefined") return;
|
|
361
|
+
const active = document.activeElement;
|
|
362
|
+
if (!this._restoreFocus) {
|
|
363
|
+
const root = this.__vmzDomRoot;
|
|
364
|
+
const outside =
|
|
365
|
+
active instanceof HTMLElement &&
|
|
366
|
+
active !== document.body &&
|
|
367
|
+
!(root && typeof root.contains === "function" && root.contains(active));
|
|
368
|
+
if (outside) this._restoreFocus = active;
|
|
369
|
+
}
|
|
370
|
+
this._panel = panel instanceof HTMLElement ? panel : null;
|
|
371
|
+
const overlay =
|
|
372
|
+
this._panel && typeof this._panel.closest === "function"
|
|
373
|
+
? this._panel.closest('[data-vmz-overlay="drawer"]')
|
|
374
|
+
: null;
|
|
375
|
+
if (this._exiting) {
|
|
376
|
+
this._cancelExit("reenter");
|
|
377
|
+
} else {
|
|
378
|
+
this._motionGen += 1;
|
|
379
|
+
}
|
|
380
|
+
if (overlay) {
|
|
381
|
+
overlay.setAttribute("data-vmz-motion-gen", String(this._motionGen));
|
|
382
|
+
}
|
|
383
|
+
if (this._adoptNextEnter && overlay) {
|
|
384
|
+
overlay.setAttribute("data-vmz-motion-adopt", "true");
|
|
385
|
+
this._panel.setAttribute("data-vmz-motion", "overlay-stable");
|
|
386
|
+
this._adoptNextEnter = false;
|
|
387
|
+
} else if (overlay) {
|
|
388
|
+
overlay.removeAttribute("data-vmz-motion-adopt");
|
|
389
|
+
overlay.removeAttribute("data-vmz-motion-phase");
|
|
390
|
+
overlay.removeAttribute("data-vmz-motion-cancelled");
|
|
391
|
+
this._panel.setAttribute("data-vmz-motion", "overlay-enter");
|
|
392
|
+
}
|
|
393
|
+
if (this._panel && typeof this._panel.focus === "function") this._panel.focus();
|
|
394
|
+
if (!this._docKeyHandler) {
|
|
395
|
+
this._docKeyHandler = (ev) => {
|
|
396
|
+
if (ev.key !== "Escape") return;
|
|
397
|
+
if (ev.defaultPrevented) return;
|
|
398
|
+
if (!this._isTopmostStack()) return;
|
|
399
|
+
ev.preventDefault();
|
|
400
|
+
ev.stopPropagation();
|
|
401
|
+
this.dismiss();
|
|
402
|
+
};
|
|
403
|
+
document.addEventListener("keydown", this._docKeyHandler);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
_exitFocus() {
|
|
407
|
+
if (this._exitTimer) {
|
|
408
|
+
clearTimeout(this._exitTimer);
|
|
409
|
+
this._exitTimer = null;
|
|
410
|
+
}
|
|
411
|
+
this._exiting = false;
|
|
412
|
+
this._teardownDocKey();
|
|
413
|
+
this._panel = null;
|
|
414
|
+
const restore = this._restoreFocus;
|
|
415
|
+
this._restoreFocus = null;
|
|
416
|
+
if (restore && typeof restore.focus === "function" && document.contains(restore)) {
|
|
417
|
+
restore.focus();
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
_teardownDocKey() {
|
|
421
|
+
if (typeof document !== "undefined" && this._docKeyHandler) {
|
|
422
|
+
document.removeEventListener("keydown", this._docKeyHandler);
|
|
423
|
+
}
|
|
424
|
+
this._docKeyHandler = null;
|
|
425
|
+
}
|
|
419
426
|
}
|
|
420
427
|
</script>
|