@xleddyl/443-components-vue 0.16.94 → 0.16.96
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/CATALOG.md +175 -170
- package/README.md +51 -7
- package/dist/components/data/RecordList.vue +44 -6
- package/dist/components/data/RecordList.vue.d.ts +4 -1
- package/dist/components/data/SortableList.vue +120 -0
- package/dist/components/data/SortableList.vue.d.ts +48 -0
- package/dist/components/data/Table.vue +43 -3
- package/dist/components/data/Table.vue.d.ts +8 -2
- package/dist/components/data/TileGrid.vue +274 -0
- package/dist/components/data/TileGrid.vue.d.ts +51 -0
- package/dist/components/data/Tree.vue +84 -24
- package/dist/components/data/Tree.vue.d.ts +9 -9
- package/dist/components/data/index.d.ts +2 -0
- package/dist/components/data/index.mjs +2 -0
- package/dist/components/data/types.d.ts +40 -1
- package/dist/components/layout/Accordion.vue +6 -2
- package/dist/components/layout/Accordion.vue.d.ts +3 -0
- package/dist/components/overlays/Popover.vue +4 -2
- package/dist/components/overlays/Popover.vue.d.ts +2 -0
- package/dist/composables/useSortable.d.ts +1 -0
- package/dist/composables/useSortable.mjs +53 -11
- package/dist/icons/builtin.d.ts +1 -0
- package/dist/icons/builtin.mjs +1 -0
- package/dist/internal/data/sortable.d.ts +6 -1
- package/dist/internal/data/sortable.mjs +51 -0
- package/dist/locale/de.mjs +12 -0
- package/dist/locale/en.mjs +12 -0
- package/dist/locale/it.mjs +12 -0
- package/dist/locale/types.d.ts +12 -0
- package/dist/styles/data/record-list.css +54 -0
- package/dist/styles/data/sortable-list.css +185 -0
- package/dist/styles/data/table.css +12 -0
- package/dist/styles/data/tile-grid.css +144 -0
- package/dist/styles/data/tree.css +57 -4
- package/dist/styles/data.css +2 -0
- package/dist/styles/forced-colors.css +34 -0
- package/dist/styles/layout/accordion.css +4 -5
- package/dist/styles/layout/card.css +2 -0
- package/dist/styles/overlays/popover.css +6 -0
- package/dist/styles/shared.css +11 -1
- package/package.json +1 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="k-tile-grid"
|
|
4
|
+
:class="{
|
|
5
|
+
'is-selectable': selectable,
|
|
6
|
+
'is-sortable': canSort,
|
|
7
|
+
'has-handle': Boolean(handle),
|
|
8
|
+
'has-selection': selectable && selected.length > 0,
|
|
9
|
+
'is-dragging': sorter.dragging.value !== null || dragKeys.length > 0,
|
|
10
|
+
'is-disabled': disabled
|
|
11
|
+
}"
|
|
12
|
+
>
|
|
13
|
+
<Grid :min-item-width="minItemWidth" :columns="columns ?? MAX_COLUMNS" :gap="gap">
|
|
14
|
+
<div
|
|
15
|
+
v-if="items.length"
|
|
16
|
+
ref="list"
|
|
17
|
+
class="k-tile-grid-list"
|
|
18
|
+
:role="selectable ? 'listbox' : 'list'"
|
|
19
|
+
:aria-label="labelText"
|
|
20
|
+
:aria-multiselectable="selectable ? 'true' : void 0"
|
|
21
|
+
:aria-disabled="selectable && disabled ? 'true' : void 0"
|
|
22
|
+
:aria-describedby="hintText ? hintId : void 0"
|
|
23
|
+
>
|
|
24
|
+
<div
|
|
25
|
+
v-for="(item, index) in items"
|
|
26
|
+
:key="keyOf(item, index)"
|
|
27
|
+
class="k-tile-grid-item"
|
|
28
|
+
:class="{
|
|
29
|
+
'is-moving': sorter.dragging.value === index,
|
|
30
|
+
'is-dragging': isDragged(item, index)
|
|
31
|
+
}"
|
|
32
|
+
:role="selectable ? 'option' : 'listitem'"
|
|
33
|
+
:aria-selected="selectable ? isSelected(item, index) : void 0"
|
|
34
|
+
:aria-label="itemLabel ? itemLabel(item) : void 0"
|
|
35
|
+
:tabindex="index === focusIndex ? 0 : -1"
|
|
36
|
+
:draggable="canDragOut ? 'true' : void 0"
|
|
37
|
+
v-bind="canSort ? sorter.itemProps(index) : void 0"
|
|
38
|
+
@focus="focusIndex = index"
|
|
39
|
+
@click="onTileClick($event, item, index)"
|
|
40
|
+
@keydown="onTileKeydown($event, item, index)"
|
|
41
|
+
@dragstart="onDragStart($event, item, index)"
|
|
42
|
+
@dragend="onDragEnd($event, item)"
|
|
43
|
+
>
|
|
44
|
+
<div class="k-tile-grid-tile">
|
|
45
|
+
<slot
|
|
46
|
+
name="tile"
|
|
47
|
+
:item="item"
|
|
48
|
+
:index="index"
|
|
49
|
+
:selected="isSelected(item, index)"
|
|
50
|
+
:dragging="sorter.dragging.value === index || isDragged(item, index)"
|
|
51
|
+
/>
|
|
52
|
+
<span
|
|
53
|
+
v-if="selectable"
|
|
54
|
+
class="k-tile-grid-check"
|
|
55
|
+
aria-hidden="true"
|
|
56
|
+
@click.stop="onCheckClick($event, item, index)"
|
|
57
|
+
>
|
|
58
|
+
<Icon name="check" />
|
|
59
|
+
</span>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
<div v-if="$slots.add" class="k-tile-grid-add">
|
|
64
|
+
<slot name="add" />
|
|
65
|
+
</div>
|
|
66
|
+
</Grid>
|
|
67
|
+
<span v-if="hintText" :id="hintId" class="k-visually-hidden">{{ hintText }}</span>
|
|
68
|
+
<LiveRegion :message="sorter.announcement.value" />
|
|
69
|
+
</div>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<script setup>
|
|
73
|
+
import { computed, ref, useId, useTemplateRef, watch } from "vue";
|
|
74
|
+
import { useLocale } from "../../composables/useLocale";
|
|
75
|
+
import { useSortable } from "../../composables/useSortable";
|
|
76
|
+
import LiveRegion from "../../internal/core/LiveRegion.vue";
|
|
77
|
+
import { gridNeighbor, isRtl, layoutRect } from "../../internal/data/sortable";
|
|
78
|
+
import Icon from "../core/Icon.vue";
|
|
79
|
+
import Grid from "../layout/Grid.vue";
|
|
80
|
+
const props = defineProps({
|
|
81
|
+
itemKey: { type: [String, Function], required: false, default: "id" },
|
|
82
|
+
itemLabel: { type: Function, required: false },
|
|
83
|
+
label: { type: String, required: false },
|
|
84
|
+
minItemWidth: { type: String, required: false, default: "10rem" },
|
|
85
|
+
columns: { type: Number, required: false },
|
|
86
|
+
gap: { type: String, required: false, default: "md" },
|
|
87
|
+
selectable: { type: Boolean, required: false },
|
|
88
|
+
sortable: { type: Boolean, required: false },
|
|
89
|
+
handle: { type: String, required: false },
|
|
90
|
+
dragData: { type: Function, required: false },
|
|
91
|
+
dragEffect: { type: null, required: false, default: "move" },
|
|
92
|
+
disabled: { type: Boolean, required: false },
|
|
93
|
+
onActivate: { type: Function, required: false }
|
|
94
|
+
});
|
|
95
|
+
const items = defineModel("items", { type: Array, ...{ required: true } });
|
|
96
|
+
const selected = defineModel("selected", { type: Array, ...{ default: () => [] } });
|
|
97
|
+
const emit = defineEmits(["move", "itemDragStart", "itemDragEnd"]);
|
|
98
|
+
defineSlots();
|
|
99
|
+
const MAX_COLUMNS = 64;
|
|
100
|
+
const INTERACTIVE = 'a, button, input, select, textarea, label, summary, [role="button"]';
|
|
101
|
+
const { t } = useLocale();
|
|
102
|
+
const hintId = `${useId()}-hint`;
|
|
103
|
+
const list = useTemplateRef("list");
|
|
104
|
+
const focusIndex = ref(0);
|
|
105
|
+
const anchor = ref(null);
|
|
106
|
+
const dragKeys = ref([]);
|
|
107
|
+
const canSort = computed(() => props.sortable && !props.disabled);
|
|
108
|
+
const canDragOut = computed(() => Boolean(props.dragData) && !canSort.value && !props.disabled);
|
|
109
|
+
const canSelect = computed(() => props.selectable && !props.disabled);
|
|
110
|
+
const labelText = computed(() => props.label ?? t("tileGrid.label"));
|
|
111
|
+
const hintText = computed(() => {
|
|
112
|
+
const parts = [t("tileGrid.navigateHint")];
|
|
113
|
+
if (canSelect.value) parts.push(t("tileGrid.selectHint"));
|
|
114
|
+
if (canSort.value) parts.push(t("tileGrid.sortHint"));
|
|
115
|
+
return parts.join(". ");
|
|
116
|
+
});
|
|
117
|
+
function keyOf(item, index) {
|
|
118
|
+
if (typeof props.itemKey === "function") return props.itemKey(item, index);
|
|
119
|
+
const value = item?.[props.itemKey];
|
|
120
|
+
return typeof value === "string" || typeof value === "number" ? value : index;
|
|
121
|
+
}
|
|
122
|
+
function labelOf(item) {
|
|
123
|
+
return props.itemLabel ? props.itemLabel(item) : String(keyOf(item, items.value.indexOf(item)));
|
|
124
|
+
}
|
|
125
|
+
const selectedSet = computed(() => new Set(selected.value));
|
|
126
|
+
function isSelected(item, index) {
|
|
127
|
+
return Boolean(props.selectable) && selectedSet.value.has(keyOf(item, index));
|
|
128
|
+
}
|
|
129
|
+
function isDragged(item, index) {
|
|
130
|
+
return dragKeys.value.includes(keyOf(item, index));
|
|
131
|
+
}
|
|
132
|
+
watch(
|
|
133
|
+
() => items.value.length,
|
|
134
|
+
(length) => {
|
|
135
|
+
if (focusIndex.value >= length) focusIndex.value = Math.max(0, length - 1);
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
const sorter = useSortable(list, {
|
|
139
|
+
items: () => items.value,
|
|
140
|
+
orientation: "grid",
|
|
141
|
+
handle: props.handle ?? ".k-tile-grid-tile",
|
|
142
|
+
preview: ".k-tile-grid-tile",
|
|
143
|
+
disabled: () => !canSort.value,
|
|
144
|
+
label: labelOf,
|
|
145
|
+
onMove: (next, move) => {
|
|
146
|
+
items.value = next;
|
|
147
|
+
focusIndex.value = move.to;
|
|
148
|
+
emit("move", { item: move.item, from: move.from, to: move.to, items: next });
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
function toggle(item, index, event) {
|
|
152
|
+
if (!canSelect.value) return;
|
|
153
|
+
const key = keyOf(item, index);
|
|
154
|
+
if (event?.shiftKey && anchor.value !== null) {
|
|
155
|
+
const keys = items.value.map((entry, position) => keyOf(entry, position));
|
|
156
|
+
const from = keys.indexOf(anchor.value);
|
|
157
|
+
if (from !== -1) {
|
|
158
|
+
const range = keys.slice(Math.min(from, index), Math.max(from, index) + 1);
|
|
159
|
+
selected.value = [.../* @__PURE__ */ new Set([...selected.value, ...range])];
|
|
160
|
+
anchor.value = key;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
selected.value = selectedSet.value.has(key) ? selected.value.filter((entry) => entry !== key) : [...selected.value, key];
|
|
165
|
+
anchor.value = key;
|
|
166
|
+
}
|
|
167
|
+
function selectAll() {
|
|
168
|
+
if (!canSelect.value) return;
|
|
169
|
+
const keys = items.value.map((item, index) => keyOf(item, index));
|
|
170
|
+
selected.value = [.../* @__PURE__ */ new Set([...selected.value, ...keys])];
|
|
171
|
+
}
|
|
172
|
+
function activate(item, index, event) {
|
|
173
|
+
if (props.onActivate) props.onActivate(item, index, event);
|
|
174
|
+
else toggle(item, index, event);
|
|
175
|
+
}
|
|
176
|
+
function onCheckClick(event, item, index) {
|
|
177
|
+
focusIndex.value = index;
|
|
178
|
+
toggle(item, index, event);
|
|
179
|
+
}
|
|
180
|
+
function onTileClick(event, item, index) {
|
|
181
|
+
const tile = event.currentTarget;
|
|
182
|
+
const origin = event.target?.closest(INTERACTIVE);
|
|
183
|
+
if (origin && origin !== tile && tile.contains(origin)) return;
|
|
184
|
+
const selecting = selected.value.length > 0 || event.shiftKey || event.metaKey || event.ctrlKey;
|
|
185
|
+
if (canSelect.value && selecting) toggle(item, index, event);
|
|
186
|
+
else activate(item, index, event);
|
|
187
|
+
}
|
|
188
|
+
function tileElements() {
|
|
189
|
+
return Array.from(list.value?.children ?? []);
|
|
190
|
+
}
|
|
191
|
+
function focusTile(index) {
|
|
192
|
+
focusIndex.value = index;
|
|
193
|
+
tileElements()[index]?.focus();
|
|
194
|
+
}
|
|
195
|
+
function navigationTarget(event, index) {
|
|
196
|
+
const count = items.value.length;
|
|
197
|
+
const rtl = isRtl(list.value);
|
|
198
|
+
switch (event.key) {
|
|
199
|
+
case "ArrowLeft":
|
|
200
|
+
return rtl ? index + 1 : index - 1;
|
|
201
|
+
case "ArrowRight":
|
|
202
|
+
return rtl ? index - 1 : index + 1;
|
|
203
|
+
case "ArrowUp":
|
|
204
|
+
case "ArrowDown":
|
|
205
|
+
return gridNeighbor(
|
|
206
|
+
tileElements().map(layoutRect),
|
|
207
|
+
index,
|
|
208
|
+
event.key === "ArrowUp" ? -1 : 1
|
|
209
|
+
);
|
|
210
|
+
case "Home":
|
|
211
|
+
return 0;
|
|
212
|
+
case "End":
|
|
213
|
+
return count - 1;
|
|
214
|
+
default:
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function onTileKeydown(event, item, index) {
|
|
219
|
+
if (event.target !== event.currentTarget || event.altKey) return;
|
|
220
|
+
const modifier = event.ctrlKey || event.metaKey;
|
|
221
|
+
if (event.key === " " && !modifier) {
|
|
222
|
+
if (!canSelect.value) return;
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
toggle(item, index, event);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (event.key === "Enter" && !modifier) {
|
|
228
|
+
if (!props.onActivate && !canSelect.value) return;
|
|
229
|
+
event.preventDefault();
|
|
230
|
+
activate(item, index, event);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (modifier && event.key.toLowerCase() === "a") {
|
|
234
|
+
if (!canSelect.value) return;
|
|
235
|
+
event.preventDefault();
|
|
236
|
+
selectAll();
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (modifier) return;
|
|
240
|
+
const target = navigationTarget(event, index);
|
|
241
|
+
if (target === null) return;
|
|
242
|
+
event.preventDefault();
|
|
243
|
+
if (target >= 0 && target < items.value.length) focusTile(target);
|
|
244
|
+
}
|
|
245
|
+
function draggedGroup(item) {
|
|
246
|
+
if (!props.selectable || !selectedSet.value.has(keyOf(item, items.value.indexOf(item))))
|
|
247
|
+
return [item];
|
|
248
|
+
return items.value.filter((entry, index) => isSelected(entry, index));
|
|
249
|
+
}
|
|
250
|
+
let dragged = [];
|
|
251
|
+
function onDragStart(event, item, index) {
|
|
252
|
+
if (canSort.value) event.preventDefault();
|
|
253
|
+
if (!canDragOut.value || !event.dataTransfer || !props.dragData) return;
|
|
254
|
+
const group = draggedGroup(item);
|
|
255
|
+
const data = props.dragData(item, group);
|
|
256
|
+
if (!data) {
|
|
257
|
+
event.preventDefault();
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
for (const [type, value] of Object.entries(data)) event.dataTransfer.setData(type, value);
|
|
261
|
+
event.dataTransfer.effectAllowed = props.dragEffect;
|
|
262
|
+
focusIndex.value = index;
|
|
263
|
+
dragged = group;
|
|
264
|
+
dragKeys.value = group.map((entry) => keyOf(entry, items.value.indexOf(entry)));
|
|
265
|
+
emit("itemDragStart", { item, items: group, event });
|
|
266
|
+
}
|
|
267
|
+
function onDragEnd(event, item) {
|
|
268
|
+
if (!dragKeys.value.length) return;
|
|
269
|
+
const group = dragged;
|
|
270
|
+
dragged = [];
|
|
271
|
+
dragKeys.value = [];
|
|
272
|
+
emit("itemDragEnd", { item, items: group, event });
|
|
273
|
+
}
|
|
274
|
+
</script>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { LayoutGap } from '../layout/types';
|
|
2
|
+
import type { RowKey, TileGridDrag, TileGridDragData, TileGridMove } from './types';
|
|
3
|
+
declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<({
|
|
5
|
+
itemKey?: string | ((item: T, index: number) => RowKey);
|
|
6
|
+
itemLabel?: (item: T) => string;
|
|
7
|
+
label?: string;
|
|
8
|
+
minItemWidth?: string;
|
|
9
|
+
columns?: number;
|
|
10
|
+
gap?: LayoutGap;
|
|
11
|
+
selectable?: boolean;
|
|
12
|
+
sortable?: boolean;
|
|
13
|
+
handle?: string;
|
|
14
|
+
dragData?: (item: T, items: T[]) => TileGridDragData | null | undefined;
|
|
15
|
+
dragEffect?: DataTransfer["effectAllowed"];
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
onActivate?: (item: T, index: number, event: MouseEvent | KeyboardEvent) => void;
|
|
18
|
+
} & {
|
|
19
|
+
items: T[];
|
|
20
|
+
selected?: RowKey[];
|
|
21
|
+
}) & {
|
|
22
|
+
onMove?: ((move: TileGridMove<T>) => any) | undefined;
|
|
23
|
+
"onUpdate:selected"?: ((value: RowKey[]) => any) | undefined;
|
|
24
|
+
onItemDragStart?: ((drag: TileGridDrag<T>) => any) | undefined;
|
|
25
|
+
onItemDragEnd?: ((drag: TileGridDrag<T>) => any) | undefined;
|
|
26
|
+
"onUpdate:items"?: ((value: T[]) => any) | undefined;
|
|
27
|
+
} & Partial<import("vue").HTMLAttributes & import("vue").ReservedProps>> & (typeof globalThis extends {
|
|
28
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
29
|
+
} ? P : {});
|
|
30
|
+
expose: (exposed: {}) => void;
|
|
31
|
+
attrs: any;
|
|
32
|
+
slots: {
|
|
33
|
+
tile?: (props: {
|
|
34
|
+
item: T;
|
|
35
|
+
index: number;
|
|
36
|
+
selected: boolean;
|
|
37
|
+
dragging: boolean;
|
|
38
|
+
}) => unknown;
|
|
39
|
+
add?: () => unknown;
|
|
40
|
+
};
|
|
41
|
+
emit: (((evt: "move", move: TileGridMove<T>) => void) & ((evt: "itemDragStart", drag: TileGridDrag<T>) => void) & ((evt: "itemDragEnd", drag: TileGridDrag<T>) => void)) & (((event: "update:selected", value: RowKey[]) => void) & ((event: "update:items", value: T[]) => void));
|
|
42
|
+
}>) => import("vue").VNode & {
|
|
43
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
44
|
+
};
|
|
45
|
+
declare const _default: typeof __VLS_export;
|
|
46
|
+
export default _default;
|
|
47
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
48
|
+
[K in keyof T]: T[K];
|
|
49
|
+
} : {
|
|
50
|
+
[K in keyof T as K]: T[K];
|
|
51
|
+
}) & {};
|
|
@@ -35,14 +35,16 @@
|
|
|
35
35
|
:class="{
|
|
36
36
|
'is-moving': dragId === entry.node.id,
|
|
37
37
|
'is-highlighted': highlightedSet.has(entry.node.id),
|
|
38
|
-
'is-invalid': entry.node.invalid
|
|
38
|
+
'is-invalid': entry.node.invalid,
|
|
39
|
+
'is-muted': entry.node.muted,
|
|
40
|
+
'is-link': links.has(entry.node.id)
|
|
39
41
|
}"
|
|
40
42
|
:data-drop="dropState?.id === entry.node.id ? dropState.position : void 0"
|
|
41
43
|
:style="{
|
|
42
44
|
'--k-tree-level': entry.level - 1,
|
|
43
45
|
'--k-row-delay': rowDelay(index - revealAnchor - 1)
|
|
44
46
|
}"
|
|
45
|
-
@click="
|
|
47
|
+
@click="onRowClick($event, entry)"
|
|
46
48
|
@keydown="onKeydown($event, entry, index)"
|
|
47
49
|
@focus="focusId = entry.node.id"
|
|
48
50
|
@pointerenter="onRowEnter(entry)"
|
|
@@ -76,29 +78,47 @@
|
|
|
76
78
|
<Icon :name="entry.node.icon" />
|
|
77
79
|
</span>
|
|
78
80
|
<span v-if="entry.node.invalid" class="k-tree-invalid" aria-hidden="true" />
|
|
79
|
-
<span
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
:
|
|
84
|
-
|
|
81
|
+
<span class="k-tree-body">
|
|
82
|
+
<component
|
|
83
|
+
:is="links.get(entry.node.id)?.is ?? 'span'"
|
|
84
|
+
v-bind="links.get(entry.node.id)?.attrs"
|
|
85
|
+
:id="textId(entry.node.id)"
|
|
86
|
+
class="k-tree-text"
|
|
87
|
+
:class="{ 'k-tree-link': links.has(entry.node.id) }"
|
|
88
|
+
:tabindex="links.has(entry.node.id) ? -1 : void 0"
|
|
89
|
+
@focus="links.has(entry.node.id) && focusNode(entry.node.id)"
|
|
85
90
|
>
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
:
|
|
90
|
-
|
|
91
|
-
:class="`k-tree-description-${entry.node.descriptionVariant ?? descriptionVariant}`"
|
|
92
|
-
>{{ entry.node.description }}</span
|
|
91
|
+
<slot
|
|
92
|
+
name="label"
|
|
93
|
+
:node="entry.node"
|
|
94
|
+
:level="entry.level"
|
|
95
|
+
:invalid="Boolean(entry.node.invalid)"
|
|
93
96
|
>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
<span
|
|
98
|
+
:id="labelId(entry.node.id)"
|
|
99
|
+
class="k-tree-label"
|
|
100
|
+
:title="entry.node.label"
|
|
101
|
+
>{{ entry.node.label }}</span
|
|
102
|
+
>
|
|
103
|
+
<span
|
|
104
|
+
v-if="entry.node.description"
|
|
105
|
+
:id="descriptionId(entry.node.id)"
|
|
106
|
+
class="k-tree-description"
|
|
107
|
+
:class="`k-tree-description-${descriptionVariantOf(entry.node)}`"
|
|
108
|
+
:title="
|
|
109
|
+
descriptionVariantOf(entry.node) === 'mono' ? entry.node.description : void 0
|
|
110
|
+
"
|
|
111
|
+
>{{ entry.node.description }}</span
|
|
112
|
+
>
|
|
113
|
+
</slot>
|
|
114
|
+
</component>
|
|
115
|
+
<span
|
|
116
|
+
v-if="entry.node.meta || $slots.meta"
|
|
117
|
+
:id="metaId(entry.node.id)"
|
|
118
|
+
class="k-tree-meta"
|
|
119
|
+
>
|
|
120
|
+
<slot name="meta" :node="entry.node">{{ entry.node.meta }}</slot>
|
|
121
|
+
</span>
|
|
102
122
|
</span>
|
|
103
123
|
<span v-if="checkmark && selectable" class="k-tree-check" aria-hidden="true">
|
|
104
124
|
<Icon v-if="selected === entry.node.id" name="check" />
|
|
@@ -175,6 +195,7 @@ import LiveRegion from "../../internal/core/LiveRegion.vue";
|
|
|
175
195
|
import { useLiveMessage } from "../../internal/core/live";
|
|
176
196
|
import { hasFocusWithin, isFocusLost } from "../../internal/core/focus";
|
|
177
197
|
import { useTypeahead } from "../../internal/core/roving";
|
|
198
|
+
import { useLinkResolver } from "../../internal/core/link";
|
|
178
199
|
import { joinIds } from "../../internal/forms/control";
|
|
179
200
|
import Button from "../core/Button.vue";
|
|
180
201
|
import Icon from "../core/Icon.vue";
|
|
@@ -279,6 +300,9 @@ function describedBy(entry) {
|
|
|
279
300
|
canReorder.value && !entry.node.disabled ? hintId : void 0
|
|
280
301
|
);
|
|
281
302
|
}
|
|
303
|
+
function descriptionVariantOf(node) {
|
|
304
|
+
return node.descriptionVariant ?? props.descriptionVariant;
|
|
305
|
+
}
|
|
282
306
|
function isExpanded(id) {
|
|
283
307
|
return expandedSet.value.has(id);
|
|
284
308
|
}
|
|
@@ -317,6 +341,17 @@ const rovingId = computed(() => {
|
|
|
317
341
|
if (list.some((entry) => entry.node.id === focusId.value)) return focusId.value;
|
|
318
342
|
return list.find((entry) => entry.node.id === selected.value)?.node.id ?? list[0]?.node.id;
|
|
319
343
|
});
|
|
344
|
+
const { resolveLink } = useLinkResolver();
|
|
345
|
+
const links = computed(() => {
|
|
346
|
+
const map = /* @__PURE__ */ new Map();
|
|
347
|
+
if (control.disabled.value) return map;
|
|
348
|
+
for (const entry of visible.value) {
|
|
349
|
+
if (entry.node.disabled) continue;
|
|
350
|
+
const link = resolveLink(entry.node);
|
|
351
|
+
if (link) map.set(entry.node.id, link);
|
|
352
|
+
}
|
|
353
|
+
return map;
|
|
354
|
+
});
|
|
320
355
|
const hasInvalid = computed(() => visible.value.some((entry) => entry.node.invalid));
|
|
321
356
|
function hasMoveButtons(entry) {
|
|
322
357
|
return canReorder.value && props.moveButtons && !entry.node.disabled;
|
|
@@ -357,6 +392,28 @@ function activate(entry) {
|
|
|
357
392
|
if (props.selectable) selected.value = entry.node.id;
|
|
358
393
|
emit("select", entry.node);
|
|
359
394
|
}
|
|
395
|
+
function onRowClick(event, entry) {
|
|
396
|
+
const modified = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
|
|
397
|
+
if (modified && links.value.has(entry.node.id)) return;
|
|
398
|
+
activate(entry);
|
|
399
|
+
}
|
|
400
|
+
function openLink(event, entry) {
|
|
401
|
+
if (!links.value.has(entry.node.id)) return false;
|
|
402
|
+
const element = tree.value?.querySelector(`#${CSS.escape(textId(entry.node.id))}`);
|
|
403
|
+
if (!element) return false;
|
|
404
|
+
element.dispatchEvent(
|
|
405
|
+
new MouseEvent("click", {
|
|
406
|
+
bubbles: true,
|
|
407
|
+
cancelable: true,
|
|
408
|
+
view: window,
|
|
409
|
+
ctrlKey: event.ctrlKey,
|
|
410
|
+
metaKey: event.metaKey,
|
|
411
|
+
shiftKey: event.shiftKey,
|
|
412
|
+
altKey: event.altKey
|
|
413
|
+
})
|
|
414
|
+
);
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
360
417
|
function focusNode(id) {
|
|
361
418
|
if (id === void 0 || id === null) return;
|
|
362
419
|
focusId.value = id;
|
|
@@ -508,9 +565,12 @@ function onKeydown(event, entry, position) {
|
|
|
508
565
|
else focusNode(entry.parentId);
|
|
509
566
|
break;
|
|
510
567
|
case "Enter":
|
|
568
|
+
if (openLink(event, entry)) break;
|
|
569
|
+
activate(entry);
|
|
570
|
+
toggle(entry, position);
|
|
571
|
+
break;
|
|
511
572
|
case " ":
|
|
512
573
|
activate(entry);
|
|
513
|
-
if (event.key === "Enter") toggle(entry, position);
|
|
514
574
|
break;
|
|
515
575
|
default:
|
|
516
576
|
return;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import type { IconName } from '../../composables/useIcons';
|
|
2
2
|
import type { TreeDescriptionVariant, TreeMove, TreeNode, TreeNodeId, TreeSize } from './types';
|
|
3
|
-
declare var
|
|
3
|
+
declare var __VLS_20: {
|
|
4
4
|
node: TreeNode;
|
|
5
5
|
level: number;
|
|
6
6
|
invalid: boolean;
|
|
7
|
-
},
|
|
7
|
+
}, __VLS_22: {
|
|
8
8
|
node: TreeNode;
|
|
9
|
-
},
|
|
9
|
+
}, __VLS_37: {
|
|
10
10
|
node: TreeNode;
|
|
11
11
|
level: number;
|
|
12
12
|
selected: boolean;
|
|
13
13
|
expanded: boolean;
|
|
14
14
|
highlighted: boolean;
|
|
15
15
|
hovered: boolean;
|
|
16
|
-
},
|
|
16
|
+
}, __VLS_39: {}, __VLS_48: {};
|
|
17
17
|
type __VLS_Slots = {} & {
|
|
18
|
-
label?: (props: typeof
|
|
18
|
+
label?: (props: typeof __VLS_20) => any;
|
|
19
19
|
} & {
|
|
20
|
-
meta?: (props: typeof
|
|
20
|
+
meta?: (props: typeof __VLS_22) => any;
|
|
21
21
|
} & {
|
|
22
|
-
actions?: (props: typeof
|
|
22
|
+
actions?: (props: typeof __VLS_37) => any;
|
|
23
23
|
} & {
|
|
24
|
-
empty?: (props: typeof
|
|
24
|
+
empty?: (props: typeof __VLS_39) => any;
|
|
25
25
|
} & {
|
|
26
|
-
'empty-actions'?: (props: typeof
|
|
26
|
+
'empty-actions'?: (props: typeof __VLS_48) => any;
|
|
27
27
|
};
|
|
28
28
|
declare const __VLS_base: import("vue").DefineComponent<{
|
|
29
29
|
nodes: TreeNode[];
|
|
@@ -6,12 +6,14 @@ export { default as FilterPill } from './FilterPill.vue';
|
|
|
6
6
|
export { default as FilterPills } from './FilterPills.vue';
|
|
7
7
|
export { default as Pagination } from './Pagination.vue';
|
|
8
8
|
export { default as SelectionBar } from './SelectionBar.vue';
|
|
9
|
+
export { default as SortableList } from './SortableList.vue';
|
|
9
10
|
export { default as Stat } from './Stat.vue';
|
|
10
11
|
export { default as Table } from './Table.vue';
|
|
11
12
|
export { default as Tag } from './Tag.vue';
|
|
12
13
|
export { default as TagList } from './TagList.vue';
|
|
13
14
|
export { default as RecordList } from './RecordList.vue';
|
|
14
15
|
export { default as Thumbnail } from './Thumbnail.vue';
|
|
16
|
+
export { default as TileGrid } from './TileGrid.vue';
|
|
15
17
|
export { default as Timeline } from './Timeline.vue';
|
|
16
18
|
export { default as Tree } from './Tree.vue';
|
|
17
19
|
export type * from './types';
|
|
@@ -6,12 +6,14 @@ export { default as FilterPill } from "./FilterPill.vue";
|
|
|
6
6
|
export { default as FilterPills } from "./FilterPills.vue";
|
|
7
7
|
export { default as Pagination } from "./Pagination.vue";
|
|
8
8
|
export { default as SelectionBar } from "./SelectionBar.vue";
|
|
9
|
+
export { default as SortableList } from "./SortableList.vue";
|
|
9
10
|
export { default as Stat } from "./Stat.vue";
|
|
10
11
|
export { default as Table } from "./Table.vue";
|
|
11
12
|
export { default as Tag } from "./Tag.vue";
|
|
12
13
|
export { default as TagList } from "./TagList.vue";
|
|
13
14
|
export { default as RecordList } from "./RecordList.vue";
|
|
14
15
|
export { default as Thumbnail } from "./Thumbnail.vue";
|
|
16
|
+
export { default as TileGrid } from "./TileGrid.vue";
|
|
15
17
|
export { default as Timeline } from "./Timeline.vue";
|
|
16
18
|
export { default as Tree } from "./Tree.vue";
|
|
17
19
|
export { applyTreeMove } from "../../internal/data/tree.mjs";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HTMLAttributes } from 'vue';
|
|
2
|
+
import type { ColorValue, LinkTarget, Tone } from '../core/types';
|
|
2
3
|
import type { IconName } from '../../composables/useIcons';
|
|
3
4
|
import type { MenuItems } from '../overlays/types';
|
|
4
5
|
export type BadgeVariant = 'soft' | 'solid' | 'outline';
|
|
@@ -24,6 +25,15 @@ export interface TableColumn<T = Record<string, unknown>> {
|
|
|
24
25
|
format?: (value: unknown, row: T) => string;
|
|
25
26
|
class?: string;
|
|
26
27
|
}
|
|
28
|
+
export type TableRowAttrs = HTMLAttributes & {
|
|
29
|
+
[key: `data-${string}`]: string | number | boolean | undefined;
|
|
30
|
+
};
|
|
31
|
+
export type TableDragData = Record<string, string>;
|
|
32
|
+
export interface TableRowDrag<T> {
|
|
33
|
+
row: T;
|
|
34
|
+
rows: T[];
|
|
35
|
+
event: DragEvent;
|
|
36
|
+
}
|
|
27
37
|
export type PageSize = number | 'all';
|
|
28
38
|
export interface PaginationItem {
|
|
29
39
|
type: 'page' | 'ellipsis';
|
|
@@ -74,6 +84,10 @@ export interface TreeNode {
|
|
|
74
84
|
icon?: string;
|
|
75
85
|
disabled?: boolean;
|
|
76
86
|
invalid?: boolean;
|
|
87
|
+
muted?: boolean;
|
|
88
|
+
to?: LinkTarget;
|
|
89
|
+
href?: string;
|
|
90
|
+
target?: string;
|
|
77
91
|
children?: TreeNode[];
|
|
78
92
|
}
|
|
79
93
|
export type TreeDescriptionVariant = 'text' | 'mono';
|
|
@@ -120,6 +134,26 @@ export interface TagListDrop {
|
|
|
120
134
|
dataTransfer: DataTransfer | null;
|
|
121
135
|
event: DragEvent;
|
|
122
136
|
}
|
|
137
|
+
export interface SortableListItem {
|
|
138
|
+
value: string | number;
|
|
139
|
+
label: string;
|
|
140
|
+
description?: string;
|
|
141
|
+
icon?: IconName;
|
|
142
|
+
disabled?: boolean;
|
|
143
|
+
}
|
|
144
|
+
export type SortableListSize = 'sm' | 'md';
|
|
145
|
+
export type TileGridDragData = Record<string, string>;
|
|
146
|
+
export interface TileGridMove<T> {
|
|
147
|
+
item: T;
|
|
148
|
+
from: number;
|
|
149
|
+
to: number;
|
|
150
|
+
items: T[];
|
|
151
|
+
}
|
|
152
|
+
export interface TileGridDrag<T> {
|
|
153
|
+
item: T;
|
|
154
|
+
items: T[];
|
|
155
|
+
event: DragEvent;
|
|
156
|
+
}
|
|
123
157
|
export type TagListAccept = string | string[] | ((event: DragEvent) => boolean);
|
|
124
158
|
export interface RecordListItem {
|
|
125
159
|
id: string | number;
|
|
@@ -129,4 +163,9 @@ export interface RecordListItem {
|
|
|
129
163
|
label: string;
|
|
130
164
|
tone?: Tone;
|
|
131
165
|
};
|
|
166
|
+
icon?: IconName;
|
|
167
|
+
meta?: string;
|
|
168
|
+
to?: LinkTarget;
|
|
169
|
+
href?: string;
|
|
170
|
+
target?: string;
|
|
132
171
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
3
|
class="k-accordion"
|
|
4
|
-
:class="[
|
|
4
|
+
:class="[
|
|
5
|
+
`k-accordion-${variant}`,
|
|
6
|
+
{ 'is-neutral': contentVariant === 'neutral', 'is-flush': !padded }
|
|
7
|
+
]"
|
|
5
8
|
>
|
|
6
9
|
<div
|
|
7
10
|
v-for="(item, index) in items"
|
|
@@ -66,7 +69,8 @@ const props = defineProps({
|
|
|
66
69
|
collapsible: { type: Boolean, required: false, default: true },
|
|
67
70
|
level: { type: Number, required: false, default: 3 },
|
|
68
71
|
variant: { type: String, required: false, default: "card" },
|
|
69
|
-
contentVariant: { type: String, required: false, default: "text" }
|
|
72
|
+
contentVariant: { type: String, required: false, default: "text" },
|
|
73
|
+
padded: { type: Boolean, required: false, default: true }
|
|
70
74
|
});
|
|
71
75
|
const model = defineModel({ type: [String, Number, Array, null], ...{ default: null } });
|
|
72
76
|
const baseId = useId();
|
|
@@ -20,6 +20,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
20
20
|
level?: HeadingLevel;
|
|
21
21
|
variant?: AccordionVariant;
|
|
22
22
|
contentVariant?: AccordionContentVariant;
|
|
23
|
+
padded?: boolean;
|
|
23
24
|
modelValue?: Value | Value[] | null;
|
|
24
25
|
key?: PropertyKey | undefined;
|
|
25
26
|
prefix?: string | undefined | undefined;
|
|
@@ -222,6 +223,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
222
223
|
level?: HeadingLevel;
|
|
223
224
|
variant?: AccordionVariant;
|
|
224
225
|
contentVariant?: AccordionContentVariant;
|
|
226
|
+
padded?: boolean;
|
|
225
227
|
modelValue?: Value | Value[] | null;
|
|
226
228
|
key?: PropertyKey | undefined;
|
|
227
229
|
prefix?: string | undefined | undefined;
|
|
@@ -422,6 +424,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
422
424
|
level: HeadingLevel;
|
|
423
425
|
collapsible: boolean;
|
|
424
426
|
contentVariant: AccordionContentVariant;
|
|
427
|
+
padded: boolean;
|
|
425
428
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
426
429
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
427
430
|
declare const _default: typeof __VLS_export;
|