@vmz/ui 0.0.3 → 0.1.0
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 +28 -1
- 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 +643 -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 +78 -5
- package/src/components/Callout.vmz +80 -0
- package/src/components/Card.vmz +80 -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 +591 -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 +355 -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 +1233 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="vmz-ui-datatable-wrap"
|
|
4
|
+
data-vmz-ui="data-table"
|
|
5
|
+
data-sort-key={sortKey}
|
|
6
|
+
data-sort-dir={sortDir}
|
|
7
|
+
data-selected-count={selectedCount}
|
|
8
|
+
>
|
|
9
|
+
<table class="vmz-ui-datatable">
|
|
10
|
+
<thead onClick={onHeadClick}>
|
|
11
|
+
<tr>
|
|
12
|
+
<th scope="col" class="vmz-ui-datatable__check">
|
|
13
|
+
<input
|
|
14
|
+
type="checkbox"
|
|
15
|
+
class="vmz-ui-datatable__box"
|
|
16
|
+
data-vmz-select-all="true"
|
|
17
|
+
aria-label={selectAllLabel}
|
|
18
|
+
checked={allSelected}
|
|
19
|
+
/>
|
|
20
|
+
</th>
|
|
21
|
+
<th each={columns} as="col" key={col.id} scope="col" data-vmz-col={col.id}>
|
|
22
|
+
<button type="button" class="vmz-ui-datatable__sort" data-vmz-sort={col.id}>
|
|
23
|
+
{col.title}
|
|
24
|
+
</button>
|
|
25
|
+
</th>
|
|
26
|
+
<th if={hasRowAction} scope="col">{actionTitle}</th>
|
|
27
|
+
</tr>
|
|
28
|
+
</thead>
|
|
29
|
+
<tbody onClick={onBodyClick}>
|
|
30
|
+
<tr
|
|
31
|
+
each={rows}
|
|
32
|
+
as="row"
|
|
33
|
+
key={row.id}
|
|
34
|
+
data-vmz-row={row.id}
|
|
35
|
+
data-selected={row.selectedAttr}
|
|
36
|
+
>
|
|
37
|
+
<td class="vmz-ui-datatable__check">
|
|
38
|
+
<input
|
|
39
|
+
type="checkbox"
|
|
40
|
+
class="vmz-ui-datatable__box"
|
|
41
|
+
data-vmz-select={row.id}
|
|
42
|
+
aria-label={row.selectLabel}
|
|
43
|
+
checked={row.selected}
|
|
44
|
+
/>
|
|
45
|
+
</td>
|
|
46
|
+
<td each={row.cells} as="cell">{cell}</td>
|
|
47
|
+
<td if={hasRowAction}>
|
|
48
|
+
<button
|
|
49
|
+
type="button"
|
|
50
|
+
class="vmz-ui-datatable__row-action"
|
|
51
|
+
data-vmz-row-action={row.id}
|
|
52
|
+
disabled={rowActionDisabled}
|
|
53
|
+
>
|
|
54
|
+
{actionLabel}
|
|
55
|
+
</button>
|
|
56
|
+
</td>
|
|
57
|
+
</tr>
|
|
58
|
+
</tbody>
|
|
59
|
+
</table>
|
|
60
|
+
</div>
|
|
61
|
+
</template>
|
|
62
|
+
|
|
63
|
+
<style>
|
|
64
|
+
.vmz-ui-datatable-wrap {
|
|
65
|
+
max-height: 16rem;
|
|
66
|
+
overflow: auto;
|
|
67
|
+
border: 1px solid var(--vmz-line-default);
|
|
68
|
+
border-radius: 2px;
|
|
69
|
+
background: var(--vmz-surface-paper);
|
|
70
|
+
color: var(--vmz-text-ink);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.vmz-ui-datatable {
|
|
74
|
+
width: 100%;
|
|
75
|
+
border-collapse: collapse;
|
|
76
|
+
font: inherit;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.vmz-ui-datatable th,
|
|
80
|
+
.vmz-ui-datatable td {
|
|
81
|
+
padding: var(--vmz-density-compact-padding-y) var(--vmz-density-compact-padding-x);
|
|
82
|
+
text-align: left;
|
|
83
|
+
border-bottom: 1px solid var(--vmz-line-default);
|
|
84
|
+
vertical-align: middle;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.vmz-ui-datatable thead th {
|
|
88
|
+
position: sticky;
|
|
89
|
+
top: 0;
|
|
90
|
+
z-index: 1;
|
|
91
|
+
font-weight: 700;
|
|
92
|
+
color: var(--vmz-action-primary-active);
|
|
93
|
+
background: var(--vmz-surface-mist);
|
|
94
|
+
box-shadow: 0 1px 0 var(--vmz-line-default);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.vmz-ui-datatable__check {
|
|
98
|
+
width: 2.25rem;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.vmz-ui-datatable__box {
|
|
102
|
+
width: 1rem;
|
|
103
|
+
height: 1rem;
|
|
104
|
+
accent-color: var(--vmz-action-primary-background);
|
|
105
|
+
outline: none;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.vmz-ui-datatable__box:focus-visible {
|
|
109
|
+
box-shadow: 0 0 0 2px var(--vmz-focus-ring);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.vmz-ui-datatable tr[data-selected='true'] {
|
|
113
|
+
background: color-mix(in srgb, var(--vmz-action-primary-background) 12%, transparent);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.vmz-ui-datatable__sort {
|
|
117
|
+
font: inherit;
|
|
118
|
+
font-weight: 700;
|
|
119
|
+
padding: 0;
|
|
120
|
+
border: 0;
|
|
121
|
+
background: transparent;
|
|
122
|
+
color: inherit;
|
|
123
|
+
cursor: pointer;
|
|
124
|
+
outline: none;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.vmz-ui-datatable__sort:focus-visible {
|
|
128
|
+
box-shadow: 0 0 0 2px var(--vmz-focus-ring);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.vmz-ui-datatable__row-action {
|
|
132
|
+
font: inherit;
|
|
133
|
+
font-weight: 600;
|
|
134
|
+
padding: 0.3rem 0.55rem;
|
|
135
|
+
border: 1px solid var(--vmz-action-primary-background);
|
|
136
|
+
border-radius: 2px;
|
|
137
|
+
background: transparent;
|
|
138
|
+
color: var(--vmz-action-primary-active);
|
|
139
|
+
cursor: pointer;
|
|
140
|
+
outline: none;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.vmz-ui-datatable__row-action:focus-visible {
|
|
144
|
+
box-shadow: 0 0 0 2px var(--vmz-focus-ring);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.vmz-ui-datatable__row-action:disabled {
|
|
148
|
+
opacity: 0.55;
|
|
149
|
+
cursor: not-allowed;
|
|
150
|
+
}
|
|
151
|
+
</style>
|
|
152
|
+
|
|
153
|
+
<script client>
|
|
154
|
+
/**
|
|
155
|
+
* VMZ UI — DataTable (ordinary Console table).
|
|
156
|
+
* Parent owns rows + selection + sort. Sticky header.
|
|
157
|
+
* Large-grid features live outside this package.
|
|
158
|
+
*/
|
|
159
|
+
export default class DataTable {
|
|
160
|
+
/** @type {{ id: string, title: string }[]} */
|
|
161
|
+
public columns: { id: string; title: string }[] = [];
|
|
162
|
+
/**
|
|
163
|
+
* @type {{
|
|
164
|
+
* id: string,
|
|
165
|
+
* cells: string[],
|
|
166
|
+
* selected: boolean,
|
|
167
|
+
* selectedAttr: string,
|
|
168
|
+
* selectLabel: string
|
|
169
|
+
* }[]}
|
|
170
|
+
*/
|
|
171
|
+
public rows: {
|
|
172
|
+
id: string;
|
|
173
|
+
cells: string[];
|
|
174
|
+
selected: boolean;
|
|
175
|
+
selectedAttr: string;
|
|
176
|
+
selectLabel: string;
|
|
177
|
+
}[] = [];
|
|
178
|
+
public hasRowAction: boolean = false;
|
|
179
|
+
public rowActionDisabled: boolean = false;
|
|
180
|
+
public actionTitle: string = 'Action';
|
|
181
|
+
public actionLabel: string = 'Open';
|
|
182
|
+
public sortKey: string = '';
|
|
183
|
+
public sortDir: string = 'asc';
|
|
184
|
+
public selectedCount: string = '0';
|
|
185
|
+
public allSelected: boolean = false;
|
|
186
|
+
public selectAllLabel: string = 'Select all rows';
|
|
187
|
+
public onRowAction: ((rowId: string) => void) | null = null;
|
|
188
|
+
public onSort: ((columnId: string) => void) | null = null;
|
|
189
|
+
public onToggleRow: ((rowId: string) => void) | null = null;
|
|
190
|
+
public onToggleAll: (() => void) | null = null;
|
|
191
|
+
|
|
192
|
+
onBodyClick(ev) {
|
|
193
|
+
const t = ev && ev.target;
|
|
194
|
+
if (!t || typeof t.closest !== 'function') return;
|
|
195
|
+
const select = t.closest('[data-vmz-select]');
|
|
196
|
+
if (select) {
|
|
197
|
+
const id = select.getAttribute('data-vmz-select');
|
|
198
|
+
if (id && typeof this.onToggleRow === 'function') this.onToggleRow(id);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const action = t.closest('[data-vmz-row-action]');
|
|
202
|
+
if (!action || action.disabled) return;
|
|
203
|
+
const id = action.getAttribute('data-vmz-row-action');
|
|
204
|
+
if (id && typeof this.onRowAction === 'function') this.onRowAction(id);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
onHeadClick(ev) {
|
|
208
|
+
const t = ev && ev.target;
|
|
209
|
+
if (!t || typeof t.closest !== 'function') return;
|
|
210
|
+
if (t.closest('[data-vmz-select-all]')) {
|
|
211
|
+
if (typeof this.onToggleAll === 'function') this.onToggleAll();
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const sort = t.closest('[data-vmz-sort]');
|
|
215
|
+
if (!sort) return;
|
|
216
|
+
const id = sort.getAttribute('data-vmz-sort');
|
|
217
|
+
if (id && typeof this.onSort === 'function') this.onSort(id);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
</script>
|