@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,78 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="vmz-ui-form-item"
|
|
4
|
+
data-vmz-ui="form-item"
|
|
5
|
+
data-required={requiredAttr}
|
|
6
|
+
data-invalid={invalidAttr}
|
|
7
|
+
>
|
|
8
|
+
<label if={label} class="vmz-ui-form-item__label" for={controlId}>
|
|
9
|
+
<span>{label}</span>
|
|
10
|
+
<span if={required} class="vmz-ui-form-item__required" aria-hidden="true">*</span>
|
|
11
|
+
</label>
|
|
12
|
+
<div class="vmz-ui-form-item__control">
|
|
13
|
+
<slot />
|
|
14
|
+
</div>
|
|
15
|
+
<p if={description} id={descriptionId} class="vmz-ui-form-item__description">{description}</p>
|
|
16
|
+
<p if={error} id={errorId} class="vmz-ui-form-item__error" role="alert">{error}</p>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<style>
|
|
21
|
+
.vmz-ui-form-item {
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
gap: 0.35rem;
|
|
25
|
+
max-width: 28rem;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.vmz-ui-form-item__label {
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
align-items: baseline;
|
|
31
|
+
gap: 0.25rem;
|
|
32
|
+
font: inherit;
|
|
33
|
+
font-weight: 600;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.vmz-ui-form-item__required {
|
|
37
|
+
color: var(--vmz-status-danger-accent);
|
|
38
|
+
font-weight: 700;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.vmz-ui-form-item__control {
|
|
42
|
+
min-width: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.vmz-ui-form-item__description {
|
|
46
|
+
margin: 0;
|
|
47
|
+
opacity: 0.75;
|
|
48
|
+
font-size: 0.9em;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.vmz-ui-form-item__error {
|
|
52
|
+
margin: 0;
|
|
53
|
+
color: var(--vmz-status-danger-foreground);
|
|
54
|
+
font-size: 0.9em;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.vmz-ui-form-item[data-invalid='true'] .vmz-ui-form-item__control :where(input, select, textarea) {
|
|
58
|
+
border-color: var(--vmz-status-danger-accent);
|
|
59
|
+
}
|
|
60
|
+
</style>
|
|
61
|
+
|
|
62
|
+
<script client>
|
|
63
|
+
/**
|
|
64
|
+
* VMZ UI — FormItem.
|
|
65
|
+
* Label / description / error shell for slotted controls; parent owns validation strings.
|
|
66
|
+
*/
|
|
67
|
+
export default class FormItem {
|
|
68
|
+
public label: string = '';
|
|
69
|
+
public description: string = '';
|
|
70
|
+
public error: string = '';
|
|
71
|
+
public required: boolean = false;
|
|
72
|
+
public requiredAttr: string = 'false';
|
|
73
|
+
public invalidAttr: string = 'false';
|
|
74
|
+
public controlId: string = 'vmz-form-item';
|
|
75
|
+
public descriptionId: string = 'vmz-form-item-desc';
|
|
76
|
+
public errorId: string = 'vmz-form-item-err';
|
|
77
|
+
}
|
|
78
|
+
</script>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<a
|
|
3
|
+
class="vmz-ui-link"
|
|
4
|
+
data-vmz-ui="link"
|
|
5
|
+
href={href}
|
|
6
|
+
target={target}
|
|
7
|
+
rel={rel}
|
|
8
|
+
>
|
|
9
|
+
<slot />
|
|
10
|
+
</a>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<style>
|
|
14
|
+
.vmz-ui-link {
|
|
15
|
+
font: inherit;
|
|
16
|
+
font-weight: 600;
|
|
17
|
+
color: var(--vmz-action-primary-background);
|
|
18
|
+
text-decoration: underline;
|
|
19
|
+
text-underline-offset: 0.15em;
|
|
20
|
+
text-decoration-thickness: 1px;
|
|
21
|
+
outline: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.vmz-ui-link:hover {
|
|
25
|
+
color: var(--vmz-action-primary-hover);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.vmz-ui-link:active {
|
|
29
|
+
color: var(--vmz-action-primary-active);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.vmz-ui-link:focus-visible {
|
|
33
|
+
box-shadow: 0 0 0 2px var(--vmz-focus-ring);
|
|
34
|
+
border-radius: 2px;
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
37
|
+
|
|
38
|
+
<script client>
|
|
39
|
+
/**
|
|
40
|
+
* VMZ UI — Link (Foundation).
|
|
41
|
+
* Navigation / inline text link; tokens only, no brand hex.
|
|
42
|
+
*/
|
|
43
|
+
export default class Link {
|
|
44
|
+
public href: string = '#';
|
|
45
|
+
public target: string = '';
|
|
46
|
+
public rel: string = '';
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="vmz-ui-list" data-vmz-ui="list">
|
|
3
|
+
<p if={label} class="vmz-ui-list__label" id={labelId}>{label}</p>
|
|
4
|
+
<ul
|
|
5
|
+
class="vmz-ui-list__items"
|
|
6
|
+
role="listbox"
|
|
7
|
+
aria-labelledby={labelId}
|
|
8
|
+
aria-label={label}
|
|
9
|
+
onClick={onListClick}
|
|
10
|
+
onKeyDown={onListKeyDown}
|
|
11
|
+
>
|
|
12
|
+
<li
|
|
13
|
+
each={items}
|
|
14
|
+
as="item"
|
|
15
|
+
key={item.id}
|
|
16
|
+
class="vmz-ui-list__item"
|
|
17
|
+
role="option"
|
|
18
|
+
id={item.id}
|
|
19
|
+
data-vmz-list-item={item.id}
|
|
20
|
+
aria-selected={selected === item.id ? 'true' : 'false'}
|
|
21
|
+
tabindex={selected === item.id ? 0 : -1}
|
|
22
|
+
>
|
|
23
|
+
{item.title}
|
|
24
|
+
</li>
|
|
25
|
+
</ul>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<style>
|
|
30
|
+
.vmz-ui-list {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
gap: 0.35rem;
|
|
34
|
+
max-width: 28rem;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.vmz-ui-list__label {
|
|
38
|
+
margin: 0;
|
|
39
|
+
font-weight: 600;
|
|
40
|
+
color: var(--vmz-text-ink);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.vmz-ui-list__items {
|
|
44
|
+
margin: 0;
|
|
45
|
+
padding: 0.25rem;
|
|
46
|
+
list-style: none;
|
|
47
|
+
border: 1px solid var(--vmz-line-default);
|
|
48
|
+
border-radius: 2px;
|
|
49
|
+
background: var(--vmz-surface-paper);
|
|
50
|
+
color: var(--vmz-text-ink);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.vmz-ui-list__item {
|
|
54
|
+
padding: var(--vmz-density-control-padding-y) var(--vmz-density-control-padding-x);
|
|
55
|
+
border-radius: 2px;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
outline: none;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.vmz-ui-list__item[aria-selected='true'] {
|
|
61
|
+
background: var(--vmz-action-primary-background);
|
|
62
|
+
color: var(--vmz-action-primary-foreground);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.vmz-ui-list__item:hover {
|
|
66
|
+
background: color-mix(in srgb, var(--vmz-action-primary-background) 14%, transparent);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.vmz-ui-list__item[aria-selected='true']:hover {
|
|
70
|
+
background: var(--vmz-action-primary-hover);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.vmz-ui-list__item:focus-visible {
|
|
74
|
+
box-shadow: 0 0 0 2px var(--vmz-focus-ring);
|
|
75
|
+
}
|
|
76
|
+
</style>
|
|
77
|
+
|
|
78
|
+
<script client>
|
|
79
|
+
/**
|
|
80
|
+
* VMZ UI — List (ordinary selectable list).
|
|
81
|
+
* Parent owns `selected` id; click + Arrow/Home/End. Not a DataGrid.
|
|
82
|
+
*/
|
|
83
|
+
export default class List {
|
|
84
|
+
public label: string = 'List';
|
|
85
|
+
public labelId: string = 'vmz-list-label';
|
|
86
|
+
public selected: string = '';
|
|
87
|
+
/** @type {{ id: string, title: string }[]} */
|
|
88
|
+
public items: { id: string; title: string }[] = [];
|
|
89
|
+
public onSelect: ((id: string) => void) | null = null;
|
|
90
|
+
|
|
91
|
+
select(id) {
|
|
92
|
+
if (typeof this.onSelect === 'function') this.onSelect(id);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
onListClick(ev) {
|
|
96
|
+
const t = ev && ev.target;
|
|
97
|
+
const el = t && typeof t.closest === 'function' ? t.closest('[data-vmz-list-item]') : null;
|
|
98
|
+
const id = el && typeof el.getAttribute === 'function' ? el.getAttribute('data-vmz-list-item') : null;
|
|
99
|
+
if (id) this.select(id);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
onListKeyDown(ev) {
|
|
103
|
+
if (!ev || !this.items?.length) return;
|
|
104
|
+
const ids = this.items.map((it) => it.id);
|
|
105
|
+
const idx = Math.max(0, ids.indexOf(this.selected));
|
|
106
|
+
let next = idx;
|
|
107
|
+
if (ev.key === 'ArrowDown') next = (idx + 1) % ids.length;
|
|
108
|
+
else if (ev.key === 'ArrowUp') next = (idx - 1 + ids.length) % ids.length;
|
|
109
|
+
else if (ev.key === 'Home') next = 0;
|
|
110
|
+
else if (ev.key === 'End') next = ids.length - 1;
|
|
111
|
+
else return;
|
|
112
|
+
ev.preventDefault();
|
|
113
|
+
this.select(ids[next]);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
</script>
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
<template>
|
|
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
|
+
<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>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<style>
|
|
43
|
+
.vmz-ui-menu {
|
|
44
|
+
position: relative;
|
|
45
|
+
display: inline-block;
|
|
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;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
toggle() {
|
|
146
|
+
if (typeof this.onOpenChange === 'function') this.onOpenChange(!this.open);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
close() {
|
|
150
|
+
if (typeof this.onOpenChange === 'function') this.onOpenChange(false);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
choose(id) {
|
|
154
|
+
if (typeof this.onSelect === 'function') this.onSelect(id);
|
|
155
|
+
this.close();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
onItemClick(ev) {
|
|
159
|
+
const el = ev?.currentTarget;
|
|
160
|
+
const id = el && typeof el.getAttribute === 'function' ? el.getAttribute('data-vmz-menu-item') : null;
|
|
161
|
+
if (id) this.choose(id);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
onTriggerKeyDown(ev) {
|
|
165
|
+
if (!ev) return;
|
|
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
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
onMenuKeyDown(ev) {
|
|
173
|
+
if (!ev || !this._panel) return;
|
|
174
|
+
if (ev.key === 'Escape') {
|
|
175
|
+
ev.preventDefault();
|
|
176
|
+
this.close();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const nodes = [...this._panel.querySelectorAll('[role="menuitem"]')].filter(
|
|
180
|
+
(n) => n instanceof HTMLElement && n.offsetParent !== null,
|
|
181
|
+
);
|
|
182
|
+
if (!nodes.length) return;
|
|
183
|
+
const idx = nodes.indexOf(document.activeElement);
|
|
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
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
_syncFromDom() {
|
|
200
|
+
const root = this.__vmzDomRoot;
|
|
201
|
+
const panel =
|
|
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();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
_enterFocus(panel) {
|
|
210
|
+
if (typeof document === 'undefined') return;
|
|
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
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
_teardownDoc() {
|
|
260
|
+
if (typeof document !== 'undefined') {
|
|
261
|
+
if (this._docKeyHandler) document.removeEventListener('keydown', this._docKeyHandler);
|
|
262
|
+
if (this._docPointerHandler) {
|
|
263
|
+
document.removeEventListener('pointerdown', this._docPointerHandler, true);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
this._docKeyHandler = null;
|
|
267
|
+
this._docPointerHandler = null;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
</script>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
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>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<style>
|
|
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: 2px;
|
|
24
|
+
background: color-mix(in srgb, var(--vmz-status-info-accent) 10%, transparent);
|
|
25
|
+
color: var(--vmz-status-info-foreground);
|
|
26
|
+
}
|
|
27
|
+
|
|
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
|
+
|
|
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
|
+
|
|
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
|
+
|
|
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
|
+
|
|
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
|
+
|
|
57
|
+
.vmz-ui-notification__title {
|
|
58
|
+
margin: 0;
|
|
59
|
+
font-weight: 700;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.vmz-ui-notification__description {
|
|
63
|
+
margin: 0;
|
|
64
|
+
opacity: 0.9;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.vmz-ui-notification__actions:empty {
|
|
68
|
+
display: none;
|
|
69
|
+
}
|
|
70
|
+
</style>
|
|
71
|
+
|
|
72
|
+
<script client>
|
|
73
|
+
/**
|
|
74
|
+
* VMZ UI — Notification (UI4 Commercial Surface).
|
|
75
|
+
* Ephemeral feedback surface; tones share status.* tokens with Alert.
|
|
76
|
+
*/
|
|
77
|
+
export default class Notification {
|
|
78
|
+
public title: string = '';
|
|
79
|
+
public description: string = '';
|
|
80
|
+
public tone: string = 'info';
|
|
81
|
+
public roleName: string = 'status';
|
|
82
|
+
}
|
|
83
|
+
</script>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nav class="vmz-ui-pagination" data-vmz-ui="pagination" aria-label={label}>
|
|
3
|
+
<button
|
|
4
|
+
type="button"
|
|
5
|
+
class="vmz-ui-pagination__btn"
|
|
6
|
+
disabled={prevDisabled}
|
|
7
|
+
onClick={onPrevClick}
|
|
8
|
+
>
|
|
9
|
+
Previous
|
|
10
|
+
</button>
|
|
11
|
+
<p class="vmz-ui-pagination__status" data-dogfood="page-status">{status}</p>
|
|
12
|
+
<button
|
|
13
|
+
type="button"
|
|
14
|
+
class="vmz-ui-pagination__btn"
|
|
15
|
+
disabled={nextDisabled}
|
|
16
|
+
onClick={onNextClick}
|
|
17
|
+
>
|
|
18
|
+
Next
|
|
19
|
+
</button>
|
|
20
|
+
</nav>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<style>
|
|
24
|
+
.vmz-ui-pagination {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
align-items: center;
|
|
28
|
+
gap: 0.65rem 1rem;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.vmz-ui-pagination__btn {
|
|
32
|
+
font: inherit;
|
|
33
|
+
font-weight: 600;
|
|
34
|
+
padding: 0.35rem 0.7rem;
|
|
35
|
+
border: 1px solid var(--vmz-action-primary-background);
|
|
36
|
+
border-radius: 2px;
|
|
37
|
+
background: transparent;
|
|
38
|
+
color: var(--vmz-action-primary-active);
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
outline: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.vmz-ui-pagination__btn:focus-visible {
|
|
44
|
+
box-shadow: 0 0 0 2px var(--vmz-focus-ring);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.vmz-ui-pagination__btn:disabled {
|
|
48
|
+
opacity: 0.55;
|
|
49
|
+
cursor: not-allowed;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.vmz-ui-pagination__status {
|
|
53
|
+
margin: 0;
|
|
54
|
+
font-weight: 600;
|
|
55
|
+
}
|
|
56
|
+
</style>
|
|
57
|
+
|
|
58
|
+
<script client>
|
|
59
|
+
/**
|
|
60
|
+
* VMZ UI — Pagination (Console composition skeleton).
|
|
61
|
+
* Parent owns page / pageCount; buttons call onPrev / onNext.
|
|
62
|
+
*/
|
|
63
|
+
export default class Pagination {
|
|
64
|
+
public label: string = 'Pagination';
|
|
65
|
+
public status: string = 'Page 1 / 1';
|
|
66
|
+
public prevDisabled: boolean = true;
|
|
67
|
+
public nextDisabled: boolean = true;
|
|
68
|
+
public onPrev: (() => void) | null = null;
|
|
69
|
+
public onNext: (() => void) | null = null;
|
|
70
|
+
|
|
71
|
+
onPrevClick() {
|
|
72
|
+
if (this.prevDisabled) return;
|
|
73
|
+
if (typeof this.onPrev === 'function') this.onPrev();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
onNextClick() {
|
|
77
|
+
if (this.nextDisabled) return;
|
|
78
|
+
if (typeof this.onNext === 'function') this.onNext();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
</script>
|