@vmz/ui 0.1.0 → 0.1.2
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 +8 -0
- package/contracts/token-requirements.v0.json +2 -6
- package/package.json +18 -2
- package/presets/web-surface.v0.json +24 -10
- package/src/components/Accordion.vmz +88 -89
- package/src/components/Alert.vmz +64 -63
- package/src/components/AppShell.vmz +64 -45
- package/src/components/Autocomplete.vmz +152 -151
- package/src/components/Avatar.vmz +16 -0
- package/src/components/Badge.vmz +46 -46
- package/src/components/Breadcrumb.vmz +52 -48
- package/src/components/BulkActions.vmz +37 -37
- package/src/components/Button.vmz +90 -75
- package/src/components/Callout.vmz +61 -61
- package/src/components/Card.vmz +58 -51
- package/src/components/Checkbox.vmz +56 -53
- package/src/components/CodeBlock.vmz +51 -51
- package/src/components/Collapse.vmz +20 -0
- package/src/components/ConsoleShell.vmz +134 -99
- package/src/components/Content.vmz +11 -0
- package/src/components/DataTable.vmz +197 -196
- package/src/components/DatePicker.vmz +613 -536
- package/src/components/Dialog.vmz +365 -384
- package/src/components/Divider.vmz +19 -0
- package/src/components/Drawer.vmz +361 -378
- package/src/components/Dropdown.vmz +22 -0
- package/src/components/Empty.vmz +36 -36
- package/src/components/Field.vmz +69 -40
- package/src/components/FilterBar.vmz +15 -15
- package/src/components/Flex.vmz +12 -0
- package/src/components/Footer.vmz +11 -0
- package/src/components/Form.vmz +56 -58
- package/src/components/FormItem.vmz +59 -59
- package/src/components/Grid.vmz +12 -0
- package/src/components/Header.vmz +11 -0
- package/src/components/Icon.vmz +86 -0
- package/src/components/Layout.vmz +11 -0
- package/src/components/Link.vmz +33 -33
- package/src/components/List.vmz +96 -96
- package/src/components/Menu.vmz +229 -240
- package/src/components/Notification.vmz +62 -62
- package/src/components/Pagination.vmz +63 -65
- package/src/components/Popover.vmz +202 -219
- package/src/components/Progress.vmz +18 -0
- package/src/components/Prose.vmz +61 -61
- package/src/components/QueryForm.vmz +26 -27
- package/src/components/RadioGroup.vmz +116 -113
- package/src/components/Result.vmz +63 -63
- package/src/components/Segmented.vmz +29 -0
- package/src/components/Select.vmz +462 -290
- package/src/components/Sider.vmz +6 -0
- package/src/components/Skeleton.vmz +58 -58
- package/src/components/Space.vmz +15 -0
- package/src/components/Spinner.vmz +29 -29
- package/src/components/Steps.vmz +86 -86
- package/src/components/Switch.vmz +86 -88
- package/src/components/Table.vmz +116 -114
- package/src/components/Tabs.vmz +113 -112
- package/src/components/Tag.vmz +8 -0
- package/src/components/TextArea.vmz +76 -49
- package/src/components/Timeline.vmz +55 -50
- package/src/components/Toc.vmz +64 -60
- package/src/components/Tooltip.vmz +51 -51
- package/src/components/Tree.vmz +184 -190
- package/src/components/Typography.vmz +9 -0
- package/src/components/Upload.vmz +1130 -1151
package/src/components/Menu.vmz
CHANGED
|
@@ -1,270 +1,259 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="vmz-ui-menu" data-vmz-ui="menu" data-vmz-overlay-open={open}>
|
|
3
|
-
<button
|
|
4
|
-
type="button"
|
|
5
|
-
class="vmz-ui-menu__trigger"
|
|
6
|
-
data-vmz-menu="trigger"
|
|
7
|
-
aria-haspopup="menu"
|
|
8
|
-
aria-expanded={open ? 'true' : 'false'}
|
|
9
|
-
aria-controls={menuId}
|
|
10
|
-
onClick={toggle}
|
|
11
|
-
onKeyDown={onTriggerKeyDown}
|
|
12
|
-
>
|
|
13
|
-
{label}
|
|
14
|
-
</button>
|
|
15
|
-
<div
|
|
16
|
-
if={open}
|
|
17
|
-
id={menuId}
|
|
18
|
-
class="vmz-ui-menu__panel"
|
|
19
|
-
role="menu"
|
|
20
|
-
data-vmz-overlay="menu"
|
|
21
|
-
data-vmz-overlay-owner="menu"
|
|
22
|
-
data-vmz-focus="enter"
|
|
23
|
-
tabindex="-1"
|
|
24
|
-
onKeyDown={onMenuKeyDown}
|
|
25
|
-
>
|
|
26
3
|
<button
|
|
27
|
-
each={items}
|
|
28
|
-
as="item"
|
|
29
|
-
key={item.id}
|
|
30
4
|
type="button"
|
|
31
|
-
class="vmz-ui-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
5
|
+
class="vmz-ui-menu__trigger"
|
|
6
|
+
data-vmz-menu="trigger"
|
|
7
|
+
aria-haspopup="menu"
|
|
8
|
+
aria-expanded={open ? 'true' : 'false'}
|
|
9
|
+
aria-controls={menuId}
|
|
10
|
+
onClick={toggle}
|
|
11
|
+
onKeyDown={onTriggerKeyDown}
|
|
35
12
|
>
|
|
36
|
-
{
|
|
13
|
+
{label}
|
|
37
14
|
</button>
|
|
15
|
+
<div
|
|
16
|
+
if={open}
|
|
17
|
+
id={menuId}
|
|
18
|
+
class="vmz-ui-menu__panel"
|
|
19
|
+
role="menu"
|
|
20
|
+
data-vmz-overlay="menu"
|
|
21
|
+
data-vmz-overlay-owner="menu"
|
|
22
|
+
data-vmz-focus="enter"
|
|
23
|
+
tabindex="-1"
|
|
24
|
+
onKeyDown={onMenuKeyDown}
|
|
25
|
+
>
|
|
26
|
+
<button
|
|
27
|
+
each={items}
|
|
28
|
+
as="item"
|
|
29
|
+
key={item.id}
|
|
30
|
+
type="button"
|
|
31
|
+
class="vmz-ui-menu__item"
|
|
32
|
+
role="menuitem"
|
|
33
|
+
data-vmz-menu-item={item.id}
|
|
34
|
+
onClick={onItemClick}
|
|
35
|
+
>
|
|
36
|
+
{item.title}
|
|
37
|
+
</button>
|
|
38
|
+
</div>
|
|
38
39
|
</div>
|
|
39
|
-
</div>
|
|
40
40
|
</template>
|
|
41
41
|
|
|
42
42
|
<style>
|
|
43
|
-
.vmz-ui-menu {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.vmz-ui-menu__trigger {
|
|
49
|
-
font: inherit;
|
|
50
|
-
font-weight: 600;
|
|
51
|
-
padding: 0.45rem 0.8rem;
|
|
52
|
-
border: 1px solid var(--vmz-action-primary-background);
|
|
53
|
-
border-radius: 2px;
|
|
54
|
-
cursor: pointer;
|
|
55
|
-
background: var(--vmz-action-primary-background);
|
|
56
|
-
color: var(--vmz-action-primary-foreground);
|
|
57
|
-
outline: none;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.vmz-ui-menu__trigger:focus-visible {
|
|
61
|
-
box-shadow: 0 0 0 2px var(--vmz-focus-ring);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.vmz-ui-menu__panel {
|
|
65
|
-
position: absolute;
|
|
66
|
-
z-index: 30;
|
|
67
|
-
top: calc(100% + 0.25rem);
|
|
68
|
-
left: 0;
|
|
69
|
-
min-width: 10rem;
|
|
70
|
-
padding: 0.25rem;
|
|
71
|
-
border: 1px solid var(--vmz-action-primary-background);
|
|
72
|
-
border-radius: 2px;
|
|
73
|
-
background: var(--vmz-action-primary-foreground);
|
|
74
|
-
color: var(--vmz-action-primary-active);
|
|
75
|
-
outline: none;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.vmz-ui-menu__panel:focus-visible {
|
|
79
|
-
box-shadow: 0 0 0 2px var(--vmz-focus-ring);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.vmz-ui-menu__item {
|
|
83
|
-
display: block;
|
|
84
|
-
width: 100%;
|
|
85
|
-
text-align: left;
|
|
86
|
-
font: inherit;
|
|
87
|
-
padding: 0.4rem 0.65rem;
|
|
88
|
-
border: 0;
|
|
89
|
-
border-radius: 2px;
|
|
90
|
-
background: transparent;
|
|
91
|
-
color: inherit;
|
|
92
|
-
cursor: pointer;
|
|
93
|
-
outline: none;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.vmz-ui-menu__item:hover,
|
|
97
|
-
.vmz-ui-menu__item:focus-visible {
|
|
98
|
-
background: color-mix(in srgb, var(--vmz-action-primary-background) 18%, transparent);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.vmz-ui-menu__item:focus-visible {
|
|
102
|
-
box-shadow: 0 0 0 2px var(--vmz-focus-ring);
|
|
103
|
-
}
|
|
104
|
-
</style>
|
|
105
|
-
|
|
106
|
-
<script client>
|
|
107
|
-
/**
|
|
108
|
-
* VMZ UI — Menu (UI2).
|
|
109
|
-
* Parent owns `open`; Escape / choose closes via onClose; focus restore to trigger.
|
|
110
|
-
*/
|
|
111
|
-
export default class Menu {
|
|
112
|
-
public label: string = 'Menu';
|
|
113
|
-
public open: boolean = false;
|
|
114
|
-
public menuId: string = 'vmz-menu';
|
|
115
|
-
/** @type {{ id: string, title: string }[]} */
|
|
116
|
-
public items: { id: string; title: string }[] = [];
|
|
117
|
-
public onOpenChange: ((open: boolean) => void) | null = null;
|
|
118
|
-
public onSelect: ((id: string) => void) | null = null;
|
|
119
|
-
|
|
120
|
-
_restoreFocus = null;
|
|
121
|
-
_panel = null;
|
|
122
|
-
_docKeyHandler = null;
|
|
123
|
-
_docPointerHandler = null;
|
|
124
|
-
_observer = null;
|
|
125
|
-
|
|
126
|
-
async onMount() {
|
|
127
|
-
if (typeof document === 'undefined' || typeof MutationObserver === 'undefined') return;
|
|
128
|
-
const root = this.__vmzDomRoot;
|
|
129
|
-
if (!root || typeof root.querySelector !== 'function') return;
|
|
130
|
-
this._observer = new MutationObserver(() => this._syncFromDom());
|
|
131
|
-
this._observer.observe(root, { childList: true, subtree: true });
|
|
132
|
-
this._syncFromDom();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
onDestroy() {
|
|
136
|
-
if (this._observer) {
|
|
137
|
-
this._observer.disconnect();
|
|
138
|
-
this._observer = null;
|
|
139
|
-
}
|
|
140
|
-
this._teardownDoc();
|
|
141
|
-
this._panel = null;
|
|
142
|
-
this._restoreFocus = null;
|
|
43
|
+
.vmz-ui-menu {
|
|
44
|
+
position: relative;
|
|
45
|
+
display: inline-block;
|
|
143
46
|
}
|
|
144
47
|
|
|
145
|
-
|
|
146
|
-
|
|
48
|
+
.vmz-ui-menu__trigger {
|
|
49
|
+
font: inherit;
|
|
50
|
+
font-size: 0.875rem;
|
|
51
|
+
font-weight: 400;
|
|
52
|
+
min-height: var(--vmz-control-height, 2rem);
|
|
53
|
+
padding: 0.25rem 0.75rem;
|
|
54
|
+
border: 1px solid var(--vmz-line-default);
|
|
55
|
+
border-radius: var(--vmz-radius-md, 6px);
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
background: var(--vmz-surface-paper, #fff);
|
|
58
|
+
color: var(--vmz-text-ink);
|
|
59
|
+
outline: none;
|
|
147
60
|
}
|
|
148
61
|
|
|
149
|
-
|
|
150
|
-
|
|
62
|
+
.vmz-ui-menu__trigger:hover {
|
|
63
|
+
color: var(--vmz-action-primary-background);
|
|
64
|
+
border-color: var(--vmz-action-primary-background);
|
|
151
65
|
}
|
|
152
66
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
this.close();
|
|
67
|
+
.vmz-ui-menu__trigger:focus-visible {
|
|
68
|
+
box-shadow: 0 0 0 2px var(--vmz-focus-ring);
|
|
156
69
|
}
|
|
157
70
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
71
|
+
.vmz-ui-menu__panel {
|
|
72
|
+
position: absolute;
|
|
73
|
+
z-index: 30;
|
|
74
|
+
top: calc(100% + 0.25rem);
|
|
75
|
+
left: 0;
|
|
76
|
+
min-width: 10rem;
|
|
77
|
+
padding: 0.25rem;
|
|
78
|
+
border: 1px solid var(--vmz-line-default);
|
|
79
|
+
border-radius: var(--vmz-radius-md, 6px);
|
|
80
|
+
background: var(--vmz-surface-paper, #fff);
|
|
81
|
+
color: var(--vmz-text-ink);
|
|
82
|
+
box-shadow: var(--vmz-shadow-popup);
|
|
83
|
+
outline: none;
|
|
162
84
|
}
|
|
163
85
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if ((ev.key === 'ArrowDown' || ev.key === 'Enter' || ev.key === ' ') && !this.open) {
|
|
167
|
-
ev.preventDefault();
|
|
168
|
-
if (typeof this.onOpenChange === 'function') this.onOpenChange(true);
|
|
169
|
-
}
|
|
86
|
+
.vmz-ui-menu__panel:focus-visible {
|
|
87
|
+
box-shadow: 0 0 0 2px var(--vmz-focus-ring);
|
|
170
88
|
}
|
|
171
89
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
if (ev.key === 'ArrowDown') {
|
|
185
|
-
ev.preventDefault();
|
|
186
|
-
nodes[(idx + 1 + nodes.length) % nodes.length].focus();
|
|
187
|
-
} else if (ev.key === 'ArrowUp') {
|
|
188
|
-
ev.preventDefault();
|
|
189
|
-
nodes[(idx - 1 + nodes.length) % nodes.length].focus();
|
|
190
|
-
} else if (ev.key === 'Home') {
|
|
191
|
-
ev.preventDefault();
|
|
192
|
-
nodes[0].focus();
|
|
193
|
-
} else if (ev.key === 'End') {
|
|
194
|
-
ev.preventDefault();
|
|
195
|
-
nodes[nodes.length - 1].focus();
|
|
196
|
-
}
|
|
90
|
+
.vmz-ui-menu__item {
|
|
91
|
+
display: block;
|
|
92
|
+
width: 100%;
|
|
93
|
+
text-align: left;
|
|
94
|
+
font: inherit;
|
|
95
|
+
padding: 0.4rem 0.65rem;
|
|
96
|
+
border: 0;
|
|
97
|
+
border-radius: var(--vmz-radius-md, 6px);
|
|
98
|
+
background: transparent;
|
|
99
|
+
color: inherit;
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
outline: none;
|
|
197
102
|
}
|
|
198
103
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
root && typeof root.querySelector === 'function'
|
|
203
|
-
? root.querySelector('[data-vmz-overlay="menu"][data-vmz-focus="enter"]')
|
|
204
|
-
: null;
|
|
205
|
-
if (panel && !this._panel) this._enterFocus(panel);
|
|
206
|
-
else if (!panel && this._panel) this._exitFocus();
|
|
104
|
+
.vmz-ui-menu__item:hover,
|
|
105
|
+
.vmz-ui-menu__item:focus-visible {
|
|
106
|
+
background: color-mix(in srgb, var(--vmz-action-primary-background) 18%, transparent);
|
|
207
107
|
}
|
|
208
108
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const root = this.__vmzDomRoot;
|
|
212
|
-
const trigger =
|
|
213
|
-
root && typeof root.querySelector === 'function'
|
|
214
|
-
? root.querySelector('[data-vmz-menu="trigger"]')
|
|
215
|
-
: null;
|
|
216
|
-
const active = document.activeElement;
|
|
217
|
-
if (!this._restoreFocus) {
|
|
218
|
-
if (trigger instanceof HTMLElement) this._restoreFocus = trigger;
|
|
219
|
-
else if (active instanceof HTMLElement) this._restoreFocus = active;
|
|
220
|
-
}
|
|
221
|
-
this._panel = panel instanceof HTMLElement ? panel : null;
|
|
222
|
-
const first =
|
|
223
|
-
this._panel && typeof this._panel.querySelector === 'function'
|
|
224
|
-
? this._panel.querySelector('[role="menuitem"]')
|
|
225
|
-
: null;
|
|
226
|
-
if (first && typeof first.focus === 'function') first.focus();
|
|
227
|
-
else if (this._panel && typeof this._panel.focus === 'function') this._panel.focus();
|
|
228
|
-
|
|
229
|
-
if (!this._docKeyHandler) {
|
|
230
|
-
this._docKeyHandler = (ev) => {
|
|
231
|
-
if (ev.key === 'Escape') {
|
|
232
|
-
ev.preventDefault();
|
|
233
|
-
this.close();
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
document.addEventListener('keydown', this._docKeyHandler);
|
|
237
|
-
}
|
|
238
|
-
if (!this._docPointerHandler) {
|
|
239
|
-
this._docPointerHandler = (ev) => {
|
|
240
|
-
const t = ev.target;
|
|
241
|
-
if (!(t instanceof Node)) return;
|
|
242
|
-
if (root && typeof root.contains === 'function' && root.contains(t)) return;
|
|
243
|
-
this.close();
|
|
244
|
-
};
|
|
245
|
-
document.addEventListener('pointerdown', this._docPointerHandler, true);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
_exitFocus() {
|
|
250
|
-
this._teardownDoc();
|
|
251
|
-
this._panel = null;
|
|
252
|
-
const restore = this._restoreFocus;
|
|
253
|
-
this._restoreFocus = null;
|
|
254
|
-
if (restore && typeof restore.focus === 'function' && document.contains(restore)) {
|
|
255
|
-
restore.focus();
|
|
256
|
-
}
|
|
109
|
+
.vmz-ui-menu__item:focus-visible {
|
|
110
|
+
box-shadow: 0 0 0 2px var(--vmz-focus-ring);
|
|
257
111
|
}
|
|
112
|
+
</style>
|
|
258
113
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
114
|
+
<script client>
|
|
115
|
+
/**
|
|
116
|
+
* VMZ UI — Menu (UI2).
|
|
117
|
+
* Parent owns `open`; Escape / choose closes via onClose; focus restore to trigger.
|
|
118
|
+
*/
|
|
119
|
+
export default class Menu {
|
|
120
|
+
public label: string = "Menu";
|
|
121
|
+
public open: boolean = false;
|
|
122
|
+
public menuId: string = "vmz-menu";
|
|
123
|
+
/** @type {{ id: string, title: string }[]} */
|
|
124
|
+
public items: {
|
|
125
|
+
id: string;
|
|
126
|
+
title: string;
|
|
127
|
+
}[] = [];
|
|
128
|
+
public onOpenChange: ((open: boolean) => void) | null = null;
|
|
129
|
+
public onSelect: ((id: string) => void) | null = null;
|
|
130
|
+
_restoreFocus = null;
|
|
131
|
+
_panel = null;
|
|
132
|
+
_docKeyHandler = null;
|
|
133
|
+
_docPointerHandler = null;
|
|
134
|
+
_observer = null;
|
|
135
|
+
async onMount() {
|
|
136
|
+
if (typeof document === "undefined" || typeof MutationObserver === "undefined") return;
|
|
137
|
+
const root = this.__vmzDomRoot;
|
|
138
|
+
if (!root || typeof root.querySelector !== "function") return;
|
|
139
|
+
this._observer = new MutationObserver(() => this._syncFromDom());
|
|
140
|
+
this._observer.observe(root, {
|
|
141
|
+
childList: true,
|
|
142
|
+
subtree: true
|
|
143
|
+
});
|
|
144
|
+
this._syncFromDom();
|
|
145
|
+
}
|
|
146
|
+
onDestroy() {
|
|
147
|
+
if (this._observer) {
|
|
148
|
+
this._observer.disconnect();
|
|
149
|
+
this._observer = null;
|
|
150
|
+
}
|
|
151
|
+
this._teardownDoc();
|
|
152
|
+
this._panel = null;
|
|
153
|
+
this._restoreFocus = null;
|
|
154
|
+
}
|
|
155
|
+
toggle() {
|
|
156
|
+
if (typeof this.onOpenChange === "function") this.onOpenChange(!this.open);
|
|
157
|
+
}
|
|
158
|
+
close() {
|
|
159
|
+
if (typeof this.onOpenChange === "function") this.onOpenChange(false);
|
|
160
|
+
}
|
|
161
|
+
choose(id) {
|
|
162
|
+
if (typeof this.onSelect === "function") this.onSelect(id);
|
|
163
|
+
this.close();
|
|
164
|
+
}
|
|
165
|
+
onItemClick(ev) {
|
|
166
|
+
const el = ev?.currentTarget;
|
|
167
|
+
const id = el && typeof el.getAttribute === "function" ? el.getAttribute("data-vmz-menu-item") : null;
|
|
168
|
+
if (id) this.choose(id);
|
|
169
|
+
}
|
|
170
|
+
onTriggerKeyDown(ev) {
|
|
171
|
+
if (!ev) return;
|
|
172
|
+
if ((ev.key === "ArrowDown" || ev.key === "Enter" || ev.key === " ") && !this.open) {
|
|
173
|
+
ev.preventDefault();
|
|
174
|
+
if (typeof this.onOpenChange === "function") this.onOpenChange(true);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
onMenuKeyDown(ev) {
|
|
178
|
+
if (!ev || !this._panel) return;
|
|
179
|
+
if (ev.key === "Escape") {
|
|
180
|
+
ev.preventDefault();
|
|
181
|
+
this.close();
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const nodes = [...this._panel.querySelectorAll("[role=\"menuitem\"]")].filter((n) => n instanceof HTMLElement && n.offsetParent !== null);
|
|
185
|
+
if (!nodes.length) return;
|
|
186
|
+
const idx = nodes.indexOf(document.activeElement);
|
|
187
|
+
if (ev.key === "ArrowDown") {
|
|
188
|
+
ev.preventDefault();
|
|
189
|
+
nodes[(idx + 1 + nodes.length) % nodes.length].focus();
|
|
190
|
+
} else if (ev.key === "ArrowUp") {
|
|
191
|
+
ev.preventDefault();
|
|
192
|
+
nodes[(idx - 1 + nodes.length) % nodes.length].focus();
|
|
193
|
+
} else if (ev.key === "Home") {
|
|
194
|
+
ev.preventDefault();
|
|
195
|
+
nodes[0].focus();
|
|
196
|
+
} else if (ev.key === "End") {
|
|
197
|
+
ev.preventDefault();
|
|
198
|
+
nodes[nodes.length - 1].focus();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
_syncFromDom() {
|
|
202
|
+
const root = this.__vmzDomRoot;
|
|
203
|
+
const panel = root && typeof root.querySelector === "function" ? root.querySelector("[data-vmz-overlay=\"menu\"][data-vmz-focus=\"enter\"]") : null;
|
|
204
|
+
if (panel && !this._panel) this._enterFocus(panel);
|
|
205
|
+
else if (!panel && this._panel) this._exitFocus();
|
|
206
|
+
}
|
|
207
|
+
_enterFocus(panel) {
|
|
208
|
+
if (typeof document === "undefined") return;
|
|
209
|
+
const root = this.__vmzDomRoot;
|
|
210
|
+
const trigger = root && typeof root.querySelector === "function" ? root.querySelector("[data-vmz-menu=\"trigger\"]") : null;
|
|
211
|
+
const active = document.activeElement;
|
|
212
|
+
if (!this._restoreFocus) {
|
|
213
|
+
if (trigger instanceof HTMLElement) this._restoreFocus = trigger;
|
|
214
|
+
else if (active instanceof HTMLElement) this._restoreFocus = active;
|
|
215
|
+
}
|
|
216
|
+
this._panel = panel instanceof HTMLElement ? panel : null;
|
|
217
|
+
const first = this._panel && typeof this._panel.querySelector === "function" ? this._panel.querySelector("[role=\"menuitem\"]") : null;
|
|
218
|
+
if (first && typeof first.focus === "function") first.focus();
|
|
219
|
+
else if (this._panel && typeof this._panel.focus === "function") this._panel.focus();
|
|
220
|
+
if (!this._docKeyHandler) {
|
|
221
|
+
this._docKeyHandler = (ev) => {
|
|
222
|
+
if (ev.key === "Escape") {
|
|
223
|
+
ev.preventDefault();
|
|
224
|
+
this.close();
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
document.addEventListener("keydown", this._docKeyHandler);
|
|
228
|
+
}
|
|
229
|
+
if (!this._docPointerHandler) {
|
|
230
|
+
this._docPointerHandler = (ev) => {
|
|
231
|
+
const t = ev.target;
|
|
232
|
+
if (!(t instanceof Node)) return;
|
|
233
|
+
if (root && typeof root.contains === "function" && root.contains(t)) return;
|
|
234
|
+
this.close();
|
|
235
|
+
};
|
|
236
|
+
document.addEventListener("pointerdown", this._docPointerHandler, true);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
_exitFocus() {
|
|
240
|
+
this._teardownDoc();
|
|
241
|
+
this._panel = null;
|
|
242
|
+
const restore = this._restoreFocus;
|
|
243
|
+
this._restoreFocus = null;
|
|
244
|
+
if (restore && typeof restore.focus === "function" && document.contains(restore)) {
|
|
245
|
+
restore.focus();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
_teardownDoc() {
|
|
249
|
+
if (typeof document !== "undefined") {
|
|
250
|
+
if (this._docKeyHandler) document.removeEventListener("keydown", this._docKeyHandler);
|
|
251
|
+
if (this._docPointerHandler) {
|
|
252
|
+
document.removeEventListener("pointerdown", this._docPointerHandler, true);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
this._docKeyHandler = null;
|
|
256
|
+
this._docPointerHandler = null;
|
|
257
|
+
}
|
|
269
258
|
}
|
|
270
259
|
</script>
|
|
@@ -1,83 +1,83 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
class="vmz-ui-notification"
|
|
4
|
+
data-vmz-ui="notification"
|
|
5
|
+
data-tone={tone}
|
|
6
|
+
role={roleName}
|
|
7
|
+
>
|
|
8
|
+
<p if={title} class="vmz-ui-notification__title">{title}</p>
|
|
9
|
+
<p if={description} class="vmz-ui-notification__description">{description}</p>
|
|
10
|
+
<div class="vmz-ui-notification__actions">
|
|
11
|
+
<slot />
|
|
12
|
+
</div>
|
|
12
13
|
</div>
|
|
13
|
-
</div>
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
16
|
<style>
|
|
17
|
-
.vmz-ui-notification {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
17
|
+
.vmz-ui-notification {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
gap: var(--vmz-density-control-gap);
|
|
21
|
+
padding: var(--vmz-density-control-padding-y) var(--vmz-density-control-padding-x);
|
|
22
|
+
border: 1px solid var(--vmz-status-info-accent);
|
|
23
|
+
border-radius: var(--vmz-radius-md, 6px);
|
|
24
|
+
background: color-mix(in srgb, var(--vmz-status-info-accent) 10%, transparent);
|
|
25
|
+
color: var(--vmz-status-info-foreground);
|
|
26
|
+
}
|
|
27
27
|
|
|
28
|
-
.vmz-ui-notification[data-tone='info'] {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
28
|
+
.vmz-ui-notification[data-tone='info'] {
|
|
29
|
+
border-color: var(--vmz-status-info-accent);
|
|
30
|
+
background: color-mix(in srgb, var(--vmz-status-info-accent) 10%, transparent);
|
|
31
|
+
color: var(--vmz-status-info-foreground);
|
|
32
|
+
}
|
|
33
33
|
|
|
34
|
-
.vmz-ui-notification[data-tone='success'] {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
34
|
+
.vmz-ui-notification[data-tone='success'] {
|
|
35
|
+
border-color: var(--vmz-status-success-accent);
|
|
36
|
+
background: color-mix(in srgb, var(--vmz-status-success-accent) 10%, transparent);
|
|
37
|
+
color: var(--vmz-status-success-foreground);
|
|
38
|
+
}
|
|
39
39
|
|
|
40
|
-
.vmz-ui-notification[data-tone='warning'] {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
40
|
+
.vmz-ui-notification[data-tone='warning'] {
|
|
41
|
+
border-color: var(--vmz-status-warning-accent);
|
|
42
|
+
background: color-mix(in srgb, var(--vmz-status-warning-accent) 10%, transparent);
|
|
43
|
+
color: var(--vmz-status-warning-foreground);
|
|
44
|
+
}
|
|
45
45
|
|
|
46
|
-
.vmz-ui-notification[data-tone='danger'] {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
46
|
+
.vmz-ui-notification[data-tone='danger'] {
|
|
47
|
+
border-color: var(--vmz-status-danger-accent);
|
|
48
|
+
background: color-mix(in srgb, var(--vmz-status-danger-accent) 10%, transparent);
|
|
49
|
+
color: var(--vmz-status-danger-foreground);
|
|
50
|
+
}
|
|
51
51
|
|
|
52
|
-
:where([data-density='compact']) .vmz-ui-notification {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
52
|
+
:where([data-density='compact']) .vmz-ui-notification {
|
|
53
|
+
gap: var(--vmz-density-compact-gap);
|
|
54
|
+
padding: var(--vmz-density-compact-padding-y) var(--vmz-density-compact-padding-x);
|
|
55
|
+
}
|
|
56
56
|
|
|
57
|
-
.vmz-ui-notification__title {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
57
|
+
.vmz-ui-notification__title {
|
|
58
|
+
margin: 0;
|
|
59
|
+
font-weight: 700;
|
|
60
|
+
}
|
|
61
61
|
|
|
62
|
-
.vmz-ui-notification__description {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
62
|
+
.vmz-ui-notification__description {
|
|
63
|
+
margin: 0;
|
|
64
|
+
opacity: 0.9;
|
|
65
|
+
}
|
|
66
66
|
|
|
67
|
-
.vmz-ui-notification__actions:empty {
|
|
68
|
-
|
|
69
|
-
}
|
|
67
|
+
.vmz-ui-notification__actions:empty {
|
|
68
|
+
display: none;
|
|
69
|
+
}
|
|
70
70
|
</style>
|
|
71
71
|
|
|
72
72
|
<script client>
|
|
73
73
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
* VMZ UI — Notification (UI4 Commercial Surface).
|
|
75
|
+
* Ephemeral feedback surface; tones share status.* tokens with Alert.
|
|
76
|
+
*/
|
|
77
77
|
export default class Notification {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
public title: string = "";
|
|
79
|
+
public description: string = "";
|
|
80
|
+
public tone: string = "info";
|
|
81
|
+
public roleName: string = "status";
|
|
82
82
|
}
|
|
83
83
|
</script>
|