@vmz/ui 0.3.6 → 0.3.7

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.
Files changed (42) hide show
  1. package/README.md +51 -51
  2. package/package.json +2 -2
  3. package/src/components/Accordion.vmz +94 -94
  4. package/src/components/AppShell.vmz +5 -2
  5. package/src/components/Autocomplete.vmz +154 -154
  6. package/src/components/Badge.vmz +70 -70
  7. package/src/components/Breadcrumb.vmz +72 -72
  8. package/src/components/BulkActions.vmz +51 -51
  9. package/src/components/Button.vmz +213 -211
  10. package/src/components/Callout.vmz +77 -77
  11. package/src/components/Card.vmz +120 -120
  12. package/src/components/Checkbox.vmz +55 -55
  13. package/src/components/CodeBlock.vmz +21 -6
  14. package/src/components/ConsoleShell.vmz +251 -251
  15. package/src/components/DataTable.vmz +194 -194
  16. package/src/components/DatePicker.vmz +674 -674
  17. package/src/components/Dialog.vmz +17 -1
  18. package/src/components/Drawer.vmz +427 -427
  19. package/src/components/Dropdown.vmz +51 -5
  20. package/src/components/Empty.vmz +54 -54
  21. package/src/components/Field.vmz +115 -115
  22. package/src/components/FormItem.vmz +79 -79
  23. package/src/components/Link.vmz +5 -1
  24. package/src/components/List.vmz +102 -102
  25. package/src/components/Menu.vmz +243 -243
  26. package/src/components/Pagination.vmz +71 -69
  27. package/src/components/Popover.vmz +223 -223
  28. package/src/components/Prose.vmz +81 -81
  29. package/src/components/RadioGroup.vmz +124 -124
  30. package/src/components/Segmented.vmz +51 -51
  31. package/src/components/Select.vmz +533 -533
  32. package/src/components/Steps.vmz +103 -103
  33. package/src/components/Switch.vmz +98 -98
  34. package/src/components/Table.vmz +165 -165
  35. package/src/components/Tabs.vmz +110 -110
  36. package/src/components/Tag.vmz +43 -43
  37. package/src/components/TextArea.vmz +118 -118
  38. package/src/components/Timeline.vmz +76 -76
  39. package/src/components/Toc.vmz +74 -74
  40. package/src/components/Tooltip.vmz +58 -58
  41. package/src/components/Tree.vmz +191 -191
  42. package/src/components/Upload.vmz +1299 -1289
@@ -1,427 +1,427 @@
1
- <template>
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>
18
- </div>
19
- </div>
20
- </template>
21
- <style>
22
- .vmz-ui-drawer-root {
23
- display: block;
24
- }
25
-
26
- .vmz-ui-drawer {
27
- position: fixed;
28
- inset: 0;
29
- z-index: 40;
30
- }
31
-
32
- .vmz-ui-drawer[data-vmz-overlay-stack="1"] {
33
- z-index: 50;
34
- }
35
-
36
- .vmz-ui-drawer[data-vmz-overlay-stack="2"] {
37
- z-index: 60;
38
- }
39
-
40
- .vmz-ui-drawer[data-vmz-overlay-stack="3"] {
41
- z-index: 70;
42
- }
43
-
44
- .vmz-ui-drawer__backdrop {
45
- position: absolute;
46
- inset: 0;
47
- border: 0;
48
- padding: 0;
49
- margin: 0;
50
- cursor: pointer;
51
- background: rgba(0, 0, 0, 0.45);
52
- animation: vmz-ui-drawer-fade-in var(--vmz-motion-overlay-duration)
53
- var(--vmz-motion-overlay-easing);
54
- }
55
-
56
- .vmz-ui-drawer__panel {
57
- position: absolute;
58
- top: 0;
59
- right: 0;
60
- z-index: 1;
61
- box-sizing: border-box;
62
- width: min(23.75rem, 100vw);
63
- height: 100%;
64
- padding: 1.25rem 1.5rem;
65
- border-left: 1px solid var(--vmz-line-subtle, var(--vmz-line-default));
66
- background: var(--vmz-surface-paper, #fff);
67
- color: var(--vmz-text-ink);
68
- box-shadow: var(--vmz-shadow-popup);
69
- outline: none;
70
- display: flex;
71
- flex-direction: column;
72
- animation: vmz-ui-drawer-panel-in var(--vmz-motion-overlay-duration)
73
- var(--vmz-motion-overlay-easing);
74
- }
75
-
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 {
78
- animation: none;
79
- }
80
-
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
- }
85
-
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
- }
90
-
91
- .vmz-ui-drawer__panel:focus-visible {
92
- box-shadow: 0 0 0 3px var(--vmz-focus-ring);
93
- }
94
-
95
- .vmz-ui-drawer__title {
96
- margin: 0 0 0.75rem;
97
- font-size: 1rem;
98
- font-weight: 600;
99
- color: var(--vmz-text-ink);
100
- }
101
-
102
- .vmz-ui-drawer__body {
103
- flex: 1;
104
- margin-bottom: 1rem;
105
- overflow: auto;
106
- color: var(--vmz-text-ink);
107
- }
108
-
109
- .vmz-ui-drawer__close {
110
- font: inherit;
111
- font-size: 0.875rem;
112
- font-weight: 400;
113
- min-height: var(--vmz-control-height, 2rem);
114
- padding: 0.25rem 1rem;
115
- border: 1px solid var(--vmz-line-default);
116
- border-radius: var(--vmz-radius-md, 6px);
117
- cursor: pointer;
118
- background: var(--vmz-surface-paper, #fff);
119
- color: var(--vmz-text-ink);
120
- }
121
-
122
- .vmz-ui-drawer__close:hover {
123
- color: var(--vmz-action-primary-background);
124
- border-color: var(--vmz-action-primary-background);
125
- }
126
-
127
- .vmz-ui-drawer__close:focus-visible {
128
- box-shadow: 0 0 0 3px var(--vmz-focus-ring);
129
- }
130
-
131
- @keyframes vmz-ui-drawer-fade-in {
132
- from {
133
- opacity: 0;
134
- }
135
- to {
136
- opacity: 1;
137
- }
138
- }
139
-
140
- @keyframes vmz-ui-drawer-panel-in {
141
- from {
142
- opacity: 0;
143
- transform: translateX(0.75rem);
144
- }
145
- to {
146
- opacity: 1;
147
- transform: none;
148
- }
149
- }
150
-
151
- @keyframes vmz-ui-drawer-fade-out {
152
- from {
153
- opacity: 1;
154
- }
155
- to {
156
- opacity: 0;
157
- }
158
- }
159
-
160
- @keyframes vmz-ui-drawer-panel-out {
161
- from {
162
- opacity: 1;
163
- transform: none;
164
- }
165
- to {
166
- opacity: 0;
167
- transform: translateX(0.75rem);
168
- }
169
- }
170
-
171
- @media (prefers-reduced-motion: reduce) {
172
- .vmz-ui-drawer__backdrop,
173
- .vmz-ui-drawer__panel,
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;
177
- }
178
- }
179
- </style>
180
- <script client>
181
- /**
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
- */
186
- export default class Drawer {
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
- }
426
- }
427
- </script>
1
+ <template>
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>
18
+ </div>
19
+ </div>
20
+ </template>
21
+ <style>
22
+ .vmz-ui-drawer-root {
23
+ display: block;
24
+ }
25
+
26
+ .vmz-ui-drawer {
27
+ position: fixed;
28
+ inset: 0;
29
+ z-index: 40;
30
+ }
31
+
32
+ .vmz-ui-drawer[data-vmz-overlay-stack="1"] {
33
+ z-index: 50;
34
+ }
35
+
36
+ .vmz-ui-drawer[data-vmz-overlay-stack="2"] {
37
+ z-index: 60;
38
+ }
39
+
40
+ .vmz-ui-drawer[data-vmz-overlay-stack="3"] {
41
+ z-index: 70;
42
+ }
43
+
44
+ .vmz-ui-drawer__backdrop {
45
+ position: absolute;
46
+ inset: 0;
47
+ border: 0;
48
+ padding: 0;
49
+ margin: 0;
50
+ cursor: pointer;
51
+ background: rgba(0, 0, 0, 0.45);
52
+ animation: vmz-ui-drawer-fade-in var(--vmz-motion-overlay-duration)
53
+ var(--vmz-motion-overlay-easing);
54
+ }
55
+
56
+ .vmz-ui-drawer__panel {
57
+ position: absolute;
58
+ top: 0;
59
+ right: 0;
60
+ z-index: 1;
61
+ box-sizing: border-box;
62
+ width: min(23.75rem, 100vw);
63
+ height: 100%;
64
+ padding: 1.25rem 1.5rem;
65
+ border-left: 1px solid var(--vmz-line-subtle, var(--vmz-line-default));
66
+ background: var(--vmz-surface-paper, #fff);
67
+ color: var(--vmz-text-ink);
68
+ box-shadow: var(--vmz-shadow-popup);
69
+ outline: none;
70
+ display: flex;
71
+ flex-direction: column;
72
+ animation: vmz-ui-drawer-panel-in var(--vmz-motion-overlay-duration)
73
+ var(--vmz-motion-overlay-easing);
74
+ }
75
+
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 {
78
+ animation: none;
79
+ }
80
+
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
+ }
85
+
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
+ }
90
+
91
+ .vmz-ui-drawer__panel:focus-visible {
92
+ box-shadow: 0 0 0 3px var(--vmz-focus-ring);
93
+ }
94
+
95
+ .vmz-ui-drawer__title {
96
+ margin: 0 0 0.75rem;
97
+ font-size: 1rem;
98
+ font-weight: 600;
99
+ color: var(--vmz-text-ink);
100
+ }
101
+
102
+ .vmz-ui-drawer__body {
103
+ flex: 1;
104
+ margin-bottom: 1rem;
105
+ overflow: auto;
106
+ color: var(--vmz-text-ink);
107
+ }
108
+
109
+ .vmz-ui-drawer__close {
110
+ font: inherit;
111
+ font-size: 0.875rem;
112
+ font-weight: 400;
113
+ min-height: var(--vmz-control-height, 2rem);
114
+ padding: 0.25rem 1rem;
115
+ border: 1px solid var(--vmz-line-default);
116
+ border-radius: var(--vmz-radius-md, 6px);
117
+ cursor: pointer;
118
+ background: var(--vmz-surface-paper, #fff);
119
+ color: var(--vmz-text-ink);
120
+ }
121
+
122
+ .vmz-ui-drawer__close:hover {
123
+ color: var(--vmz-action-primary-background);
124
+ border-color: var(--vmz-action-primary-background);
125
+ }
126
+
127
+ .vmz-ui-drawer__close:focus-visible {
128
+ box-shadow: 0 0 0 3px var(--vmz-focus-ring);
129
+ }
130
+
131
+ @keyframes vmz-ui-drawer-fade-in {
132
+ from {
133
+ opacity: 0;
134
+ }
135
+ to {
136
+ opacity: 1;
137
+ }
138
+ }
139
+
140
+ @keyframes vmz-ui-drawer-panel-in {
141
+ from {
142
+ opacity: 0;
143
+ transform: translateX(0.75rem);
144
+ }
145
+ to {
146
+ opacity: 1;
147
+ transform: none;
148
+ }
149
+ }
150
+
151
+ @keyframes vmz-ui-drawer-fade-out {
152
+ from {
153
+ opacity: 1;
154
+ }
155
+ to {
156
+ opacity: 0;
157
+ }
158
+ }
159
+
160
+ @keyframes vmz-ui-drawer-panel-out {
161
+ from {
162
+ opacity: 1;
163
+ transform: none;
164
+ }
165
+ to {
166
+ opacity: 0;
167
+ transform: translateX(0.75rem);
168
+ }
169
+ }
170
+
171
+ @media (prefers-reduced-motion: reduce) {
172
+ .vmz-ui-drawer__backdrop,
173
+ .vmz-ui-drawer__panel,
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;
177
+ }
178
+ }
179
+ </style>
180
+ <script client>
181
+ /**
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
+ */
186
+ export default class Drawer {
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
+ }
426
+ }
427
+ </script>