@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,191 +1,191 @@
1
- <template>
2
- <div data-vmz-ui="tree" class="vmz-ui-tree">
3
- <p v-if="label" :id="labelId" class="vmz-ui-tree__label">
4
- {{ label }}
5
- </p>
6
- <ul role="tree" :aria-labelledby="labelId" :aria-label="label" @click="onTreeClick" :onKeyDown="onTreeKeyDown" class="vmz-ui-tree__items">
7
- <li v-for="item in items" :key="item.id" role="treeitem" :id="item.id" :data-vmz-tree-item="item.id" :data-depth="item.depth" :aria-selected="selected === item.id ? 'true' : 'false'" :aria-expanded="item.expandedAttr" :tabindex="selected === item.id ? 0 : -1" class="vmz-ui-tree__item" :style="item.padStyle">
8
- <button v-if="item.expandable" type="button" :data-vmz-tree-twist="item.id" :aria-label="item.twistLabel" tabindex="-1" class="vmz-ui-tree__twist">
9
- {{ item.expanded ? '−' : '+' }}
10
- </button>
11
- <span v-if="!item.expandable" aria-hidden="true" class="vmz-ui-tree__twist-spacer" />
12
- <span :data-vmz-tree-title="item.id" class="vmz-ui-tree__title">
13
- {{ item.title }}
14
- </span>
15
- </li>
16
- </ul>
17
- </div>
18
- </template>
19
- <style>
20
- .vmz-ui-tree {
21
- display: flex;
22
- flex-direction: column;
23
- gap: 0.375rem;
24
- max-width: 28rem;
25
- }
26
-
27
- .vmz-ui-tree__label {
28
- margin: 0;
29
- font-weight: 600;
30
- color: var(--vmz-text-ink);
31
- }
32
-
33
- .vmz-ui-tree__items {
34
- margin: 0;
35
- padding: 0.25rem;
36
- list-style: none;
37
- border: 1px solid var(--vmz-line-default);
38
- border-radius: var(--vmz-radius-md, 6px);
39
- background: var(--vmz-surface-paper);
40
- color: var(--vmz-text-ink);
41
- }
42
-
43
- .vmz-ui-tree__item {
44
- display: flex;
45
- align-items: center;
46
- gap: 0.375rem;
47
- padding: var(--vmz-density-compact-padding-y) var(--vmz-density-compact-padding-x);
48
- border-radius: var(--vmz-radius-md, 6px);
49
- cursor: pointer;
50
- outline: none;
51
- }
52
-
53
- .vmz-ui-tree__item[aria-selected="true"] {
54
- background: var(--vmz-action-primary-background);
55
- color: var(--vmz-action-primary-foreground);
56
- }
57
-
58
- .vmz-ui-tree__item:hover {
59
- background: color-mix(in srgb, var(--vmz-action-primary-background) 14%, transparent);
60
- }
61
-
62
- .vmz-ui-tree__item[aria-selected="true"]:hover {
63
- background: var(--vmz-action-primary-hover);
64
- }
65
-
66
- .vmz-ui-tree__item:focus-visible {
67
- box-shadow: 0 0 0 3px var(--vmz-focus-ring);
68
- }
69
-
70
- .vmz-ui-tree__twist {
71
- flex: 0 0 auto;
72
- width: 1.35rem;
73
- height: 1.35rem;
74
- padding: 0;
75
- border: 1px solid var(--vmz-line-default);
76
- border-radius: var(--vmz-radius-md, 6px);
77
- background: var(--vmz-surface-mist);
78
- color: inherit;
79
- font: inherit;
80
- font-weight: 700;
81
- line-height: 1;
82
- cursor: pointer;
83
- outline: none;
84
- }
85
-
86
- .vmz-ui-tree__twist:focus-visible {
87
- box-shadow: 0 0 0 3px var(--vmz-focus-ring);
88
- }
89
-
90
- .vmz-ui-tree__twist-spacer {
91
- flex: 0 0 auto;
92
- width: 1.35rem;
93
- }
94
-
95
- .vmz-ui-tree__title {
96
- flex: 1 1 auto;
97
- }
98
- </style>
99
- <script client>
100
- /**
101
- * VMZ UI — Tree (ordinary hierarchy).
102
- * Parent owns visible flat rows + selected + expand state.
103
- * Not virtualized / not DataGrid tree mode.
104
- */
105
- export default class Tree {
106
- public label: string = "Tree";
107
- public labelId: string = "vmz-tree-label";
108
- public selected: string = "";
109
- /**
110
- * @type {{
111
- * id: string,
112
- * title: string,
113
- * depth: string,
114
- * expandable: boolean,
115
- * expanded: boolean,
116
- * expandedAttr: string,
117
- * twistLabel: string,
118
- * padStyle: string
119
- * }[]}
120
- */
121
- public items: {
122
- id: string;
123
- title: string;
124
- depth: string;
125
- expandable: boolean;
126
- expanded: boolean;
127
- expandedAttr: string;
128
- twistLabel: string;
129
- padStyle: string;
130
- }[] = [];
131
- public onSelect: ((id: string) => void) | null = null;
132
- public onToggle: ((id: string) => void) | null = null;
133
- select(id) {
134
- if (typeof this.onSelect === "function") this.onSelect(id);
135
- }
136
- toggle(id) {
137
- if (typeof this.onToggle === "function") this.onToggle(id);
138
- }
139
- onTreeClick(ev) {
140
- const t = ev && ev.target;
141
- const twist =
142
- t && typeof t.closest === "function" ? t.closest("[data-vmz-tree-twist]") : null;
143
- if (twist) {
144
- const id =
145
- typeof twist.getAttribute === "function"
146
- ? twist.getAttribute("data-vmz-tree-twist")
147
- : null;
148
- if (id) {
149
- ev.preventDefault();
150
- ev.stopPropagation();
151
- this.toggle(id);
152
- }
153
- return;
154
- }
155
- const el = t && typeof t.closest === "function" ? t.closest("[data-vmz-tree-item]") : null;
156
- const id =
157
- el && typeof el.getAttribute === "function"
158
- ? el.getAttribute("data-vmz-tree-item")
159
- : null;
160
- if (id) this.select(id);
161
- }
162
- onTreeKeyDown(ev) {
163
- if (!ev || !this.items?.length) return;
164
- const ids = this.items.map((it) => it.id);
165
- const idx = Math.max(0, ids.indexOf(this.selected));
166
- const cur = this.items[idx];
167
- if (ev.key === "ArrowRight" && cur?.expandable && !cur.expanded) {
168
- ev.preventDefault();
169
- this.toggle(cur.id);
170
- return;
171
- }
172
- if (ev.key === "ArrowLeft" && cur?.expandable && cur.expanded) {
173
- ev.preventDefault();
174
- this.toggle(cur.id);
175
- return;
176
- }
177
- let next = idx;
178
- if (ev.key === "ArrowDown") next = (idx + 1) % ids.length;
179
- else if (ev.key === "ArrowUp") next = (idx - 1 + ids.length) % ids.length;
180
- else if (ev.key === "Home") next = 0;
181
- else if (ev.key === "End") next = ids.length - 1;
182
- else if (ev.key === "Enter" || ev.key === " ") {
183
- ev.preventDefault();
184
- if (cur) this.select(cur.id);
185
- return;
186
- } else return;
187
- ev.preventDefault();
188
- this.select(ids[next]);
189
- }
190
- }
191
- </script>
1
+ <template>
2
+ <div data-vmz-ui="tree" class="vmz-ui-tree">
3
+ <p v-if="label" :id="labelId" class="vmz-ui-tree__label">
4
+ {{ label }}
5
+ </p>
6
+ <ul role="tree" :aria-labelledby="labelId" :aria-label="label" @click="onTreeClick" :onKeyDown="onTreeKeyDown" class="vmz-ui-tree__items">
7
+ <li v-for="item in items" :key="item.id" role="treeitem" :id="item.id" :data-vmz-tree-item="item.id" :data-depth="item.depth" :aria-selected="selected === item.id ? 'true' : 'false'" :aria-expanded="item.expandedAttr" :tabindex="selected === item.id ? 0 : -1" class="vmz-ui-tree__item" :style="item.padStyle">
8
+ <button v-if="item.expandable" type="button" :data-vmz-tree-twist="item.id" :aria-label="item.twistLabel" tabindex="-1" class="vmz-ui-tree__twist">
9
+ {{ item.expanded ? '−' : '+' }}
10
+ </button>
11
+ <span v-if="!item.expandable" aria-hidden="true" class="vmz-ui-tree__twist-spacer" />
12
+ <span :data-vmz-tree-title="item.id" class="vmz-ui-tree__title">
13
+ {{ item.title }}
14
+ </span>
15
+ </li>
16
+ </ul>
17
+ </div>
18
+ </template>
19
+ <style>
20
+ .vmz-ui-tree {
21
+ display: flex;
22
+ flex-direction: column;
23
+ gap: 0.375rem;
24
+ max-width: 28rem;
25
+ }
26
+
27
+ .vmz-ui-tree__label {
28
+ margin: 0;
29
+ font-weight: 600;
30
+ color: var(--vmz-text-ink);
31
+ }
32
+
33
+ .vmz-ui-tree__items {
34
+ margin: 0;
35
+ padding: 0.25rem;
36
+ list-style: none;
37
+ border: 1px solid var(--vmz-line-default);
38
+ border-radius: var(--vmz-radius-md, 6px);
39
+ background: var(--vmz-surface-paper);
40
+ color: var(--vmz-text-ink);
41
+ }
42
+
43
+ .vmz-ui-tree__item {
44
+ display: flex;
45
+ align-items: center;
46
+ gap: 0.375rem;
47
+ padding: var(--vmz-density-compact-padding-y) var(--vmz-density-compact-padding-x);
48
+ border-radius: var(--vmz-radius-md, 6px);
49
+ cursor: pointer;
50
+ outline: none;
51
+ }
52
+
53
+ .vmz-ui-tree__item[aria-selected="true"] {
54
+ background: var(--vmz-action-primary-background);
55
+ color: var(--vmz-action-primary-foreground);
56
+ }
57
+
58
+ .vmz-ui-tree__item:hover {
59
+ background: color-mix(in srgb, var(--vmz-action-primary-background) 14%, transparent);
60
+ }
61
+
62
+ .vmz-ui-tree__item[aria-selected="true"]:hover {
63
+ background: var(--vmz-action-primary-hover);
64
+ }
65
+
66
+ .vmz-ui-tree__item:focus-visible {
67
+ box-shadow: 0 0 0 3px var(--vmz-focus-ring);
68
+ }
69
+
70
+ .vmz-ui-tree__twist {
71
+ flex: 0 0 auto;
72
+ width: 1.35rem;
73
+ height: 1.35rem;
74
+ padding: 0;
75
+ border: 1px solid var(--vmz-line-default);
76
+ border-radius: var(--vmz-radius-md, 6px);
77
+ background: var(--vmz-surface-mist);
78
+ color: inherit;
79
+ font: inherit;
80
+ font-weight: 700;
81
+ line-height: 1;
82
+ cursor: pointer;
83
+ outline: none;
84
+ }
85
+
86
+ .vmz-ui-tree__twist:focus-visible {
87
+ box-shadow: 0 0 0 3px var(--vmz-focus-ring);
88
+ }
89
+
90
+ .vmz-ui-tree__twist-spacer {
91
+ flex: 0 0 auto;
92
+ width: 1.35rem;
93
+ }
94
+
95
+ .vmz-ui-tree__title {
96
+ flex: 1 1 auto;
97
+ }
98
+ </style>
99
+ <script client>
100
+ /**
101
+ * VMZ UI — Tree (ordinary hierarchy).
102
+ * Parent owns visible flat rows + selected + expand state.
103
+ * Not virtualized / not DataGrid tree mode.
104
+ */
105
+ export default class Tree {
106
+ public label: string = "Tree";
107
+ public labelId: string = "vmz-tree-label";
108
+ public selected: string = "";
109
+ /**
110
+ * @type {{
111
+ * id: string,
112
+ * title: string,
113
+ * depth: string,
114
+ * expandable: boolean,
115
+ * expanded: boolean,
116
+ * expandedAttr: string,
117
+ * twistLabel: string,
118
+ * padStyle: string
119
+ * }[]}
120
+ */
121
+ public items: {
122
+ id: string;
123
+ title: string;
124
+ depth: string;
125
+ expandable: boolean;
126
+ expanded: boolean;
127
+ expandedAttr: string;
128
+ twistLabel: string;
129
+ padStyle: string;
130
+ }[] = [];
131
+ public onSelect: ((id: string) => void) | null = null;
132
+ public onToggle: ((id: string) => void) | null = null;
133
+ select(id) {
134
+ if (typeof this.onSelect === "function") this.onSelect(id);
135
+ }
136
+ toggle(id) {
137
+ if (typeof this.onToggle === "function") this.onToggle(id);
138
+ }
139
+ onTreeClick(ev) {
140
+ const t = ev && ev.target;
141
+ const twist =
142
+ t && typeof t.closest === "function" ? t.closest("[data-vmz-tree-twist]") : null;
143
+ if (twist) {
144
+ const id =
145
+ typeof twist.getAttribute === "function"
146
+ ? twist.getAttribute("data-vmz-tree-twist")
147
+ : null;
148
+ if (id) {
149
+ ev.preventDefault();
150
+ ev.stopPropagation();
151
+ this.toggle(id);
152
+ }
153
+ return;
154
+ }
155
+ const el = t && typeof t.closest === "function" ? t.closest("[data-vmz-tree-item]") : null;
156
+ const id =
157
+ el && typeof el.getAttribute === "function"
158
+ ? el.getAttribute("data-vmz-tree-item")
159
+ : null;
160
+ if (id) this.select(id);
161
+ }
162
+ onTreeKeyDown(ev) {
163
+ if (!ev || !this.items?.length) return;
164
+ const ids = this.items.map((it) => it.id);
165
+ const idx = Math.max(0, ids.indexOf(this.selected));
166
+ const cur = this.items[idx];
167
+ if (ev.key === "ArrowRight" && cur?.expandable && !cur.expanded) {
168
+ ev.preventDefault();
169
+ this.toggle(cur.id);
170
+ return;
171
+ }
172
+ if (ev.key === "ArrowLeft" && cur?.expandable && cur.expanded) {
173
+ ev.preventDefault();
174
+ this.toggle(cur.id);
175
+ return;
176
+ }
177
+ let next = idx;
178
+ if (ev.key === "ArrowDown") next = (idx + 1) % ids.length;
179
+ else if (ev.key === "ArrowUp") next = (idx - 1 + ids.length) % ids.length;
180
+ else if (ev.key === "Home") next = 0;
181
+ else if (ev.key === "End") next = ids.length - 1;
182
+ else if (ev.key === "Enter" || ev.key === " ") {
183
+ ev.preventDefault();
184
+ if (cur) this.select(cur.id);
185
+ return;
186
+ } else return;
187
+ ev.preventDefault();
188
+ this.select(ids[next]);
189
+ }
190
+ }
191
+ </script>