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