@shtabapp/ui-kit 1.46.0 → 1.47.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/CHANGELOG.md +6 -0
- package/dist/{SColorPicker-ksmNupJa.js → SColorPicker-BqsD-5xA.js} +1 -1
- package/dist/{SColorPicker-BIrkgFys.cjs → SColorPicker-CeKB3QS1.cjs} +1 -1
- package/dist/SList-DAzztC-7.js +514 -0
- package/dist/SList-S18K8mlH.cjs +1 -0
- package/dist/{SSelect-DS2EGmjV.js → SSelect-Bntb-dgY.js} +1 -1
- package/dist/{SSelect-CkV6gq4S.cjs → SSelect-DcTEwHx6.cjs} +1 -1
- package/dist/components/SList/SList.types.d.ts +11 -0
- package/dist/components/SList/SList.types.d.ts.map +1 -1
- package/dist/components/SList/SList.vue.d.ts +11 -3
- package/dist/components/SList/SList.vue.d.ts.map +1 -1
- package/dist/composables/useFlatTreeList.d.ts +4 -1
- package/dist/composables/useFlatTreeList.d.ts.map +1 -1
- package/dist/entries/color-picker.cjs +1 -1
- package/dist/entries/color-picker.js +1 -1
- package/dist/entries/list.cjs +1 -1
- package/dist/entries/list.js +1 -1
- package/dist/entries/select.cjs +1 -1
- package/dist/entries/select.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/package.json +3 -3
- package/dist/SList-BtfUntkw.js +0 -437
- package/dist/SList-fZQdPkFG.cjs +0 -1
package/dist/SList-BtfUntkw.js
DELETED
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
import { n as e, o as t, r as n, t as r } from "./useSelectionGroup-cKj38lEN.js";
|
|
2
|
-
import { r as i, t as a } from "./SListItem-BRXZEePg.js";
|
|
3
|
-
import { Fragment as o, computed as s, createBlock as c, createElementBlock as l, createElementVNode as u, defineComponent as d, mergeModels as f, mergeProps as p, nextTick as ee, normalizeClass as m, normalizeStyle as h, openBlock as g, provide as te, renderList as _, renderSlot as v, toValue as y, unref as b, useId as ne, useModel as x, useSlots as re, useTemplateRef as S } from "vue";
|
|
4
|
-
import { ESIconName as C } from "@shtabapp/ui-kit-primitives";
|
|
5
|
-
import { useInfiniteScroll as w } from "@vueuse/core";
|
|
6
|
-
import { useVirtualizer as ie } from "@tanstack/vue-virtual";
|
|
7
|
-
//#region src/composables/useFlatTreeList.ts
|
|
8
|
-
var T = (e, t) => {
|
|
9
|
-
if (typeof t == "function") return t(e);
|
|
10
|
-
let n = e[t];
|
|
11
|
-
return typeof n == "string" ? n : typeof n == "number" ? String(n) : "";
|
|
12
|
-
}, E = (e, t) => {
|
|
13
|
-
let n = e[t];
|
|
14
|
-
return Array.isArray(n) ? n.filter((e) => typeof e == "object" && !!e) : [];
|
|
15
|
-
}, D = (e, t, n, r) => {
|
|
16
|
-
E(e, n).forEach((e) => {
|
|
17
|
-
let i = T(e, t);
|
|
18
|
-
i && r.add(i), D(e, t, n, r);
|
|
19
|
-
});
|
|
20
|
-
}, O = (e, t, n, r) => {
|
|
21
|
-
for (let i of e) {
|
|
22
|
-
if (T(i, n) === t) return i;
|
|
23
|
-
let e = O(E(i, r), t, n, r);
|
|
24
|
-
if (e) return e;
|
|
25
|
-
}
|
|
26
|
-
}, k = (e, t, n, r, i, a, o) => {
|
|
27
|
-
e.forEach((e) => {
|
|
28
|
-
let s = T(e, t);
|
|
29
|
-
if (!s) return;
|
|
30
|
-
let c = E(e, n), l = c.length > 0, u = r.includes(s);
|
|
31
|
-
o.push({
|
|
32
|
-
key: s,
|
|
33
|
-
item: e,
|
|
34
|
-
depth: i,
|
|
35
|
-
flatIndex: o.length,
|
|
36
|
-
hasChildren: l,
|
|
37
|
-
expanded: u,
|
|
38
|
-
parentKey: a
|
|
39
|
-
}), l && u && k(c, t, n, r, i + 1, s, o);
|
|
40
|
-
});
|
|
41
|
-
}, A = ({ items: e, childrenKey: t, itemKey: n, expanded: r }) => ({
|
|
42
|
-
flatRows: s(() => {
|
|
43
|
-
let i = [], a = y(e), o = y(t);
|
|
44
|
-
return k(a, y(n), o, r.value, 0, void 0, i), i;
|
|
45
|
-
}),
|
|
46
|
-
toggleExpanded: (i) => {
|
|
47
|
-
let a = y(e), o = y(t), s = y(n), c = new Set(r.value);
|
|
48
|
-
if (c.has(i)) {
|
|
49
|
-
c.delete(i);
|
|
50
|
-
let e = O(a, i, s, o);
|
|
51
|
-
if (e) {
|
|
52
|
-
let t = /* @__PURE__ */ new Set();
|
|
53
|
-
D(e, s, o, t), t.forEach((e) => {
|
|
54
|
-
c.delete(e);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
} else c.add(i);
|
|
58
|
-
r.value = [...c];
|
|
59
|
-
},
|
|
60
|
-
isExpanded: (e) => r.value.includes(e)
|
|
61
|
-
}), j = (e, t) => w(e, () => {
|
|
62
|
-
t.onEndReached();
|
|
63
|
-
}, {
|
|
64
|
-
distance: y(t.distance),
|
|
65
|
-
canLoadMore: () => t.canLoadMore === void 0 ? !0 : y(t.canLoadMore),
|
|
66
|
-
direction: "bottom"
|
|
67
|
-
}), M = /* @__PURE__ */ function(e) {
|
|
68
|
-
return e.NONE = "none", e.TWO_X_SMALL = "2x-small", e.X_SMALL = "x-small", e.SMALL = "small", e.MEDIUM = "medium", e.X_MEDIUM = "x-medium", e.LARGE = "large", e.X_LARGE = "x-large", e.TWO_X_LARGE = "2x-large", e;
|
|
69
|
-
}({}), N = M.TWO_X_SMALL, ae = {
|
|
70
|
-
[M.NONE]: "var(--s-ui-space-gap-none)",
|
|
71
|
-
[M.TWO_X_SMALL]: "var(--s-ui-space-gap-2x-small)",
|
|
72
|
-
[M.X_SMALL]: "var(--s-ui-space-gap-x-small)",
|
|
73
|
-
[M.SMALL]: "var(--s-ui-space-gap-small)",
|
|
74
|
-
[M.MEDIUM]: "var(--s-ui-space-gap-medium)",
|
|
75
|
-
[M.X_MEDIUM]: "var(--s-ui-space-gap-x-medium)",
|
|
76
|
-
[M.LARGE]: "var(--s-ui-space-gap-large)",
|
|
77
|
-
[M.X_LARGE]: "var(--s-ui-space-gap-x-large)",
|
|
78
|
-
[M.TWO_X_LARGE]: "var(--s-ui-space-gap-2x-large)"
|
|
79
|
-
}, oe = {
|
|
80
|
-
[M.NONE]: 0,
|
|
81
|
-
[M.TWO_X_SMALL]: 2,
|
|
82
|
-
[M.X_SMALL]: 4,
|
|
83
|
-
[M.SMALL]: 8,
|
|
84
|
-
[M.MEDIUM]: 12,
|
|
85
|
-
[M.X_MEDIUM]: 16,
|
|
86
|
-
[M.LARGE]: 20,
|
|
87
|
-
[M.X_LARGE]: 24,
|
|
88
|
-
[M.TWO_X_LARGE]: 32
|
|
89
|
-
}, se = (e, t) => `s-ui-list-option-${e}-${t}`, P = (e, t) => {
|
|
90
|
-
let n = e[t];
|
|
91
|
-
if (typeof n == "string") return n;
|
|
92
|
-
}, F = (e, t) => {
|
|
93
|
-
let n = e[t];
|
|
94
|
-
return typeof n == "boolean" ? n : !1;
|
|
95
|
-
}, I = (e) => e in C, L = (e, t) => {
|
|
96
|
-
let n = e[t];
|
|
97
|
-
if (typeof n == "string" && n.length > 0 && I(n)) return n;
|
|
98
|
-
}, R = (e, t) => typeof t == "string" && t ? t : Array.isArray(t) && t[0] ? t[0] : e, ce = (e) => e.some((e) => e.hasChildren || e.parentKey), z = (e, t, n) => {
|
|
99
|
-
if (!e.hasChildren) return null;
|
|
100
|
-
if (!e.expanded) return {
|
|
101
|
-
type: "expand",
|
|
102
|
-
rowKey: t
|
|
103
|
-
};
|
|
104
|
-
let r = n.find((e) => e.parentKey === t);
|
|
105
|
-
return r ? {
|
|
106
|
-
type: "select",
|
|
107
|
-
rowKey: r.key
|
|
108
|
-
} : null;
|
|
109
|
-
}, B = (e, t) => e.hasChildren && e.expanded ? {
|
|
110
|
-
type: "collapse",
|
|
111
|
-
rowKey: t
|
|
112
|
-
} : e.parentKey ? {
|
|
113
|
-
type: "select",
|
|
114
|
-
rowKey: e.parentKey
|
|
115
|
-
} : null, le = (e, t, n) => {
|
|
116
|
-
let r = n.find((e) => e.key === t);
|
|
117
|
-
return r ? e === "ArrowRight" ? z(r, t, n) : B(r, t) : null;
|
|
118
|
-
}, V = (e, t, n, r) => {
|
|
119
|
-
for (let i = t; i >= 0 && i < e.length; i += n) {
|
|
120
|
-
let t = e[i];
|
|
121
|
-
if (t && t.depth <= r) return t.key;
|
|
122
|
-
}
|
|
123
|
-
return null;
|
|
124
|
-
}, ue = (e, t, n) => {
|
|
125
|
-
let r = n.findIndex((e) => e.key === t);
|
|
126
|
-
if (r === -1) return null;
|
|
127
|
-
let i = n[r];
|
|
128
|
-
if (!i) return null;
|
|
129
|
-
let a = e === "ArrowDown" ? 1 : -1;
|
|
130
|
-
return V(n, r + a, a, i.depth);
|
|
131
|
-
}, de = ["role", "aria-multiselectable"], fe = [
|
|
132
|
-
"aria-multiselectable",
|
|
133
|
-
"aria-activedescendant",
|
|
134
|
-
"tabindex"
|
|
135
|
-
], pe = ["data-index"], me = {
|
|
136
|
-
key: 2,
|
|
137
|
-
class: "s-ui-list__static"
|
|
138
|
-
}, H = /* @__PURE__ */ d({
|
|
139
|
-
__name: "SList",
|
|
140
|
-
props: /*@__PURE__*/ f({
|
|
141
|
-
items: {},
|
|
142
|
-
itemKey: {
|
|
143
|
-
type: [String, Function],
|
|
144
|
-
default: "id"
|
|
145
|
-
},
|
|
146
|
-
childrenKey: { default: "children" },
|
|
147
|
-
titleKey: { default: "title" },
|
|
148
|
-
subtitleKey: { default: "subtitle" },
|
|
149
|
-
iconLeftKey: { default: "iconLeft" },
|
|
150
|
-
disabledKey: { default: "disabled" },
|
|
151
|
-
itemProps: { type: Function },
|
|
152
|
-
selectionMode: { default: () => e.NONE },
|
|
153
|
-
mandatory: {
|
|
154
|
-
type: Boolean,
|
|
155
|
-
default: !1
|
|
156
|
-
},
|
|
157
|
-
virtual: { type: Boolean },
|
|
158
|
-
gap: { default: () => N },
|
|
159
|
-
estimateItemSize: { default: 36 },
|
|
160
|
-
overscan: { default: 5 },
|
|
161
|
-
endReachedDistance: { default: 0 },
|
|
162
|
-
canLoadMore: { type: Function },
|
|
163
|
-
height: { default: 320 },
|
|
164
|
-
maxHeight: {},
|
|
165
|
-
revealRight: {
|
|
166
|
-
type: Boolean,
|
|
167
|
-
default: !1
|
|
168
|
-
},
|
|
169
|
-
expandOnClick: {
|
|
170
|
-
type: Boolean,
|
|
171
|
-
default: !1
|
|
172
|
-
}
|
|
173
|
-
}, {
|
|
174
|
-
modelValue: {},
|
|
175
|
-
modelModifiers: {},
|
|
176
|
-
selected: {},
|
|
177
|
-
selectedModifiers: {},
|
|
178
|
-
expanded: { default: () => [] },
|
|
179
|
-
expandedModifiers: {}
|
|
180
|
-
}),
|
|
181
|
-
emits: /*@__PURE__*/ f(["endReached"], [
|
|
182
|
-
"update:modelValue",
|
|
183
|
-
"update:selected",
|
|
184
|
-
"update:expanded"
|
|
185
|
-
]),
|
|
186
|
-
setup(d, { expose: f, emit: y }) {
|
|
187
|
-
let C = x(d, "modelValue"), w = x(d, "selected"), T = x(d, "expanded"), E = y, D = re(), O = ne(), k = S("scrollElementRef"), M = S("listRootElementRef"), N = s(() => oe[d.gap]), I = s(() => d.items !== void 0), z = s(() => I.value ? d.virtual === void 0 ? !0 : d.virtual : !1), { flatRows: B, toggleExpanded: V } = A({
|
|
188
|
-
items: () => d.items ?? [],
|
|
189
|
-
childrenKey: () => d.childrenKey,
|
|
190
|
-
itemKey: () => d.itemKey,
|
|
191
|
-
expanded: T
|
|
192
|
-
}), H = ie(s(() => ({
|
|
193
|
-
count: B.value.length,
|
|
194
|
-
getScrollElement: () => k.value,
|
|
195
|
-
estimateSize: () => d.estimateItemSize,
|
|
196
|
-
gap: N.value,
|
|
197
|
-
overscan: d.overscan
|
|
198
|
-
}))), U = s(() => {
|
|
199
|
-
if (I.value) return B.value.map((e) => e.key);
|
|
200
|
-
}), W = s(() => {
|
|
201
|
-
let e = /* @__PURE__ */ new Set();
|
|
202
|
-
for (let t of B.value) F(t.item, d.disabledKey) && e.add(t.key);
|
|
203
|
-
return e;
|
|
204
|
-
}), G = async (e) => {
|
|
205
|
-
if (!z.value) return;
|
|
206
|
-
let t = B.value.findIndex((t) => t.key === e);
|
|
207
|
-
t !== -1 && (H.value.scrollToIndex(t, { align: "auto" }), await new Promise((e) => {
|
|
208
|
-
requestAnimationFrame(() => {
|
|
209
|
-
e();
|
|
210
|
-
});
|
|
211
|
-
}), await ee());
|
|
212
|
-
}, K = (e) => se(O, e), q = t({
|
|
213
|
-
modelValue: () => w.value,
|
|
214
|
-
onUpdateModelValue: (e) => {
|
|
215
|
-
w.value = e;
|
|
216
|
-
},
|
|
217
|
-
mode: () => d.selectionMode,
|
|
218
|
-
mandatory: () => d.mandatory,
|
|
219
|
-
orientation: () => n.VERTICAL,
|
|
220
|
-
enableTabNavigation: !0,
|
|
221
|
-
focusMode: () => z.value ? r.ACTIVE_DESCENDANT : r.DOM,
|
|
222
|
-
orderedValues: U,
|
|
223
|
-
isValueDisabled: (e) => W.value.has(e),
|
|
224
|
-
onBeforeFocusItem: async (e) => {
|
|
225
|
-
await G(e);
|
|
226
|
-
},
|
|
227
|
-
onFocusGroup: () => {
|
|
228
|
-
k.value?.focus();
|
|
229
|
-
}
|
|
230
|
-
}), J = s(() => I.value && ce(B.value)), Y = () => {
|
|
231
|
-
if (z.value) {
|
|
232
|
-
k.value?.focus();
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
M.value?.focus();
|
|
236
|
-
}, X = () => {
|
|
237
|
-
q.focusedValue.value = void 0, C.value = void 0;
|
|
238
|
-
let e = document.activeElement;
|
|
239
|
-
e instanceof HTMLElement && e !== k.value && e.blur(), Y();
|
|
240
|
-
}, Z = async (e) => {
|
|
241
|
-
z.value && await G(e);
|
|
242
|
-
}, he = async (e) => {
|
|
243
|
-
if (X(), e.type === "expand" || e.type === "collapse") {
|
|
244
|
-
V(e.rowKey), q.select(e.rowKey, !1), await Z(e.rowKey);
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
q.select(e.rowKey, !1), await Z(e.rowKey);
|
|
248
|
-
}, ge = async (e, t) => {
|
|
249
|
-
if (!J.value || e.key !== "ArrowUp" && e.key !== "ArrowDown") return !1;
|
|
250
|
-
let n = R(t, w.value), r = ue(e.key, n, B.value);
|
|
251
|
-
return r ? (e.preventDefault(), X(), q.select(r, !1), await Z(r), !0) : !1;
|
|
252
|
-
}, _e = async (e, t) => {
|
|
253
|
-
if (!J.value || e.key !== "ArrowLeft" && e.key !== "ArrowRight") return !1;
|
|
254
|
-
let n = R(t, w.value), r = le(e.key, n, B.value);
|
|
255
|
-
return r ? (e.preventDefault(), await he(r), !0) : !1;
|
|
256
|
-
}, Q = () => {
|
|
257
|
-
if (C.value) return C.value;
|
|
258
|
-
let e = R("", w.value);
|
|
259
|
-
if (e) return e;
|
|
260
|
-
let t = U.value;
|
|
261
|
-
if (t) {
|
|
262
|
-
for (let e of t) if (!W.value.has(e)) return e;
|
|
263
|
-
}
|
|
264
|
-
}, ve = () => Q(), ye = async (e) => {
|
|
265
|
-
let t = ve();
|
|
266
|
-
t && await $(e, t);
|
|
267
|
-
}, $ = async (e, t) => {
|
|
268
|
-
await ge(e, t) || await _e(e, t) || (await q.handleItemKeydown(e, t), C.value = q.focusedValue.value, !q.focusedValue.value && !z.value && Y());
|
|
269
|
-
}, be = async (e) => {
|
|
270
|
-
let t = Q();
|
|
271
|
-
t && await $(e, t);
|
|
272
|
-
}, xe = async (e) => {
|
|
273
|
-
if (z.value || e.target !== M.value) return;
|
|
274
|
-
let t = Q();
|
|
275
|
-
t && await $(e, t);
|
|
276
|
-
}, Se = async () => {
|
|
277
|
-
let e = Q();
|
|
278
|
-
if (!e) {
|
|
279
|
-
Y();
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
await q.focusItem(e, !1);
|
|
283
|
-
};
|
|
284
|
-
te(i, {
|
|
285
|
-
mode: () => d.selectionMode,
|
|
286
|
-
isSelected: q.isSelected,
|
|
287
|
-
selectItem: q.toggle,
|
|
288
|
-
registerItem: q.registerItem,
|
|
289
|
-
getItemTabIndex: q.getItemTabIndex,
|
|
290
|
-
getGroupTabIndex: q.getGroupTabIndex,
|
|
291
|
-
handleItemKeydown: $,
|
|
292
|
-
activeKey: () => C.value,
|
|
293
|
-
setActiveKey: (e) => {
|
|
294
|
-
C.value = e;
|
|
295
|
-
},
|
|
296
|
-
isExpanded: (e) => T.value.includes(e),
|
|
297
|
-
toggleExpanded: (e) => {
|
|
298
|
-
if (I.value) {
|
|
299
|
-
V(e);
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
let t = new Set(T.value);
|
|
303
|
-
t.has(e) ? t.delete(e) : t.add(e), T.value = [...t];
|
|
304
|
-
},
|
|
305
|
-
revealRight: () => d.revealRight,
|
|
306
|
-
expandOnClick: () => d.expandOnClick,
|
|
307
|
-
getItemOptionId: (e) => {
|
|
308
|
-
if (z.value) return K(e);
|
|
309
|
-
},
|
|
310
|
-
usesActiveDescendantNavigation: () => z.value,
|
|
311
|
-
handlesTreeKeyboardNavigation: () => I.value
|
|
312
|
-
});
|
|
313
|
-
let Ce = s(() => H.value.getVirtualItems()), we = s(() => Ce.value.flatMap((e) => {
|
|
314
|
-
let t = B.value[e.index];
|
|
315
|
-
return t ? [{
|
|
316
|
-
virtualRow: e,
|
|
317
|
-
flatRow: t
|
|
318
|
-
}] : [];
|
|
319
|
-
})), Te = s(() => H.value.getTotalSize()), Ee = s(() => ({
|
|
320
|
-
height: `${Te.value}px`,
|
|
321
|
-
position: "relative",
|
|
322
|
-
width: "100%"
|
|
323
|
-
})), De = s(() => {
|
|
324
|
-
let e = {};
|
|
325
|
-
return typeof d.height == "number" ? e.height = `${d.height}px` : d.height && (e.height = d.height), d.maxHeight && (typeof d.maxHeight == "number" ? e.maxHeight = `${d.maxHeight}px` : e.maxHeight = d.maxHeight), e;
|
|
326
|
-
}), Oe = s(() => ({
|
|
327
|
-
"s-ui-list--virtual": z.value,
|
|
328
|
-
"s-ui-list--static": !z.value
|
|
329
|
-
})), ke = s(() => ({ "--s-ui-list-gap": ae[d.gap] })), Ae = s(() => ({ "s-ui-list__scroll--flat": I.value && !z.value })), je = s(() => {
|
|
330
|
-
if (d.selectionMode === e.MULTIPLE) return !0;
|
|
331
|
-
}), Me = s(() => {
|
|
332
|
-
if (!z.value) return "listbox";
|
|
333
|
-
}), Ne = s(() => {
|
|
334
|
-
if (!z.value) return je.value;
|
|
335
|
-
}), Pe = s(() => {
|
|
336
|
-
if (z.value) return q.getGroupTabIndex();
|
|
337
|
-
}), Fe = s(() => C.value ? C.value : R("", w.value)), Ie = s(() => {
|
|
338
|
-
if (!z.value) return;
|
|
339
|
-
let e = Fe.value;
|
|
340
|
-
if (e) return K(e);
|
|
341
|
-
});
|
|
342
|
-
j(() => k.value, {
|
|
343
|
-
distance: () => d.endReachedDistance,
|
|
344
|
-
canLoadMore: () => d.canLoadMore ? d.canLoadMore() : !0,
|
|
345
|
-
onEndReached: () => {
|
|
346
|
-
E("endReached", { direction: "bottom" });
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
let Le = (e) => ({
|
|
350
|
-
position: "absolute",
|
|
351
|
-
top: 0,
|
|
352
|
-
left: 0,
|
|
353
|
-
width: "100%",
|
|
354
|
-
transform: `translateY(${e.start}px)`
|
|
355
|
-
}), Re = (e) => {
|
|
356
|
-
e instanceof HTMLElement && H.value.measureElement(e);
|
|
357
|
-
}, ze = (e) => {
|
|
358
|
-
let t = e.item, n = {
|
|
359
|
-
rowKey: e.key,
|
|
360
|
-
depth: e.depth,
|
|
361
|
-
expandable: e.hasChildren,
|
|
362
|
-
expanded: e.expanded,
|
|
363
|
-
selected: q.isSelected(e.key),
|
|
364
|
-
active: C.value === e.key,
|
|
365
|
-
disabled: F(t, d.disabledKey),
|
|
366
|
-
title: P(t, d.titleKey),
|
|
367
|
-
subtitle: P(t, d.subtitleKey),
|
|
368
|
-
iconLeft: L(t, d.iconLeftKey),
|
|
369
|
-
revealRight: d.revealRight
|
|
370
|
-
};
|
|
371
|
-
return d.itemProps ? {
|
|
372
|
-
...n,
|
|
373
|
-
...d.itemProps(t, e)
|
|
374
|
-
} : n;
|
|
375
|
-
}, Be = (e) => ({
|
|
376
|
-
...e,
|
|
377
|
-
revealRight: d.revealRight,
|
|
378
|
-
toggleExpanded: () => {
|
|
379
|
-
V(e.key);
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
return f({
|
|
383
|
-
focusNavigation: Se,
|
|
384
|
-
handleKeyboardNavigation: be
|
|
385
|
-
}), (e, t) => (g(), l("div", {
|
|
386
|
-
ref_key: "listRootElementRef",
|
|
387
|
-
ref: M,
|
|
388
|
-
class: m(["s-ui-list", Oe.value]),
|
|
389
|
-
style: h(ke.value),
|
|
390
|
-
role: Me.value,
|
|
391
|
-
"aria-multiselectable": Ne.value,
|
|
392
|
-
tabindex: "-1",
|
|
393
|
-
onKeydown: xe
|
|
394
|
-
}, [I.value && z.value ? (g(), l("div", {
|
|
395
|
-
key: 0,
|
|
396
|
-
ref_key: "scrollElementRef",
|
|
397
|
-
ref: k,
|
|
398
|
-
class: m(["s-ui-list__scroll", Ae.value]),
|
|
399
|
-
style: h(De.value),
|
|
400
|
-
role: "listbox",
|
|
401
|
-
"aria-multiselectable": je.value,
|
|
402
|
-
"aria-activedescendant": Ie.value,
|
|
403
|
-
tabindex: Pe.value,
|
|
404
|
-
onKeydown: ye
|
|
405
|
-
}, [u("div", {
|
|
406
|
-
class: "s-ui-list__virtual-panel",
|
|
407
|
-
style: h(Ee.value)
|
|
408
|
-
}, [(g(!0), l(o, null, _(we.value, (t) => (g(), l("div", {
|
|
409
|
-
key: t.virtualRow.index,
|
|
410
|
-
class: "s-ui-list__virtual-row",
|
|
411
|
-
"data-index": t.virtualRow.index,
|
|
412
|
-
ref_for: !0,
|
|
413
|
-
ref: Re,
|
|
414
|
-
style: h(Le(t.virtualRow))
|
|
415
|
-
}, [b(D).item ? v(e.$slots, "item", p({
|
|
416
|
-
key: 0,
|
|
417
|
-
ref_for: !0
|
|
418
|
-
}, Be(t.flatRow))) : (g(), c(b(a), p({
|
|
419
|
-
key: 1,
|
|
420
|
-
ref_for: !0
|
|
421
|
-
}, ze(t.flatRow)), null, 16))], 12, pe))), 128))], 4)], 46, fe)) : I.value ? (g(), l("div", {
|
|
422
|
-
key: 1,
|
|
423
|
-
ref_key: "scrollElementRef",
|
|
424
|
-
ref: k,
|
|
425
|
-
class: m(["s-ui-list__scroll", Ae.value]),
|
|
426
|
-
style: h(De.value)
|
|
427
|
-
}, [(g(!0), l(o, null, _(b(B), (t) => (g(), l(o, { key: t.key }, [b(D).item ? v(e.$slots, "item", p({
|
|
428
|
-
key: 0,
|
|
429
|
-
ref_for: !0
|
|
430
|
-
}, Be(t))) : (g(), c(b(a), p({
|
|
431
|
-
key: 1,
|
|
432
|
-
ref_for: !0
|
|
433
|
-
}, ze(t)), null, 16))], 64))), 128))], 6)) : (g(), l("div", me, [v(e.$slots, "default")]))], 46, de));
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
|
-
//#endregion
|
|
437
|
-
export { M as a, P as i, F as n, j as o, L as r, A as s, H as t };
|
package/dist/SList-fZQdPkFG.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./useSelectionGroup-TaektE-I.cjs"),t=require("./SListItem-CdveotJe.cjs");let n=require("vue"),r=require("@shtabapp/ui-kit-primitives"),i=require("@vueuse/core"),a=require("@tanstack/vue-virtual");var o=(e,t)=>{if(typeof t==`function`)return t(e);let n=e[t];return typeof n==`string`?n:typeof n==`number`?String(n):``},s=(e,t)=>{let n=e[t];return Array.isArray(n)?n.filter(e=>typeof e==`object`&&!!e):[]},c=(e,t,n,r)=>{s(e,n).forEach(e=>{let i=o(e,t);i&&r.add(i),c(e,t,n,r)})},l=(e,t,n,r)=>{for(let i of e){if(o(i,n)===t)return i;let e=l(s(i,r),t,n,r);if(e)return e}},u=(e,t,n,r,i,a,c)=>{e.forEach(e=>{let l=o(e,t);if(!l)return;let d=s(e,n),f=d.length>0,p=r.includes(l);c.push({key:l,item:e,depth:i,flatIndex:c.length,hasChildren:f,expanded:p,parentKey:a}),f&&p&&u(d,t,n,r,i+1,l,c)})},d=({items:e,childrenKey:t,itemKey:r,expanded:i})=>({flatRows:(0,n.computed)(()=>{let a=[],o=(0,n.toValue)(e),s=(0,n.toValue)(t);return u(o,(0,n.toValue)(r),s,i.value,0,void 0,a),a}),toggleExpanded:a=>{let o=(0,n.toValue)(e),s=(0,n.toValue)(t),u=(0,n.toValue)(r),d=new Set(i.value);if(d.has(a)){d.delete(a);let e=l(o,a,u,s);if(e){let t=new Set;c(e,u,s,t),t.forEach(e=>{d.delete(e)})}}else d.add(a);i.value=[...d]},isExpanded:e=>i.value.includes(e)}),f=(e,t)=>(0,i.useInfiniteScroll)(e,()=>{t.onEndReached()},{distance:(0,n.toValue)(t.distance),canLoadMore:()=>t.canLoadMore===void 0?!0:(0,n.toValue)(t.canLoadMore),direction:`bottom`}),p=function(e){return e.NONE=`none`,e.TWO_X_SMALL=`2x-small`,e.X_SMALL=`x-small`,e.SMALL=`small`,e.MEDIUM=`medium`,e.X_MEDIUM=`x-medium`,e.LARGE=`large`,e.X_LARGE=`x-large`,e.TWO_X_LARGE=`2x-large`,e}({}),m=p.TWO_X_SMALL,ee={[p.NONE]:`var(--s-ui-space-gap-none)`,[p.TWO_X_SMALL]:`var(--s-ui-space-gap-2x-small)`,[p.X_SMALL]:`var(--s-ui-space-gap-x-small)`,[p.SMALL]:`var(--s-ui-space-gap-small)`,[p.MEDIUM]:`var(--s-ui-space-gap-medium)`,[p.X_MEDIUM]:`var(--s-ui-space-gap-x-medium)`,[p.LARGE]:`var(--s-ui-space-gap-large)`,[p.X_LARGE]:`var(--s-ui-space-gap-x-large)`,[p.TWO_X_LARGE]:`var(--s-ui-space-gap-2x-large)`},h={[p.NONE]:0,[p.TWO_X_SMALL]:2,[p.X_SMALL]:4,[p.SMALL]:8,[p.MEDIUM]:12,[p.X_MEDIUM]:16,[p.LARGE]:20,[p.X_LARGE]:24,[p.TWO_X_LARGE]:32},te=(e,t)=>`s-ui-list-option-${e}-${t}`,g=(e,t)=>{let n=e[t];if(typeof n==`string`)return n},_=(e,t)=>{let n=e[t];return typeof n==`boolean`?n:!1},v=e=>e in r.ESIconName,y=(e,t)=>{let n=e[t];if(typeof n==`string`&&n.length>0&&v(n))return n},b=(e,t)=>typeof t==`string`&&t?t:Array.isArray(t)&&t[0]?t[0]:e,x=e=>e.some(e=>e.hasChildren||e.parentKey),S=(e,t,n)=>{if(!e.hasChildren)return null;if(!e.expanded)return{type:`expand`,rowKey:t};let r=n.find(e=>e.parentKey===t);return r?{type:`select`,rowKey:r.key}:null},C=(e,t)=>e.hasChildren&&e.expanded?{type:`collapse`,rowKey:t}:e.parentKey?{type:`select`,rowKey:e.parentKey}:null,w=(e,t,n)=>{let r=n.find(e=>e.key===t);return r?e===`ArrowRight`?S(r,t,n):C(r,t):null},T=(e,t,n,r)=>{for(let i=t;i>=0&&i<e.length;i+=n){let t=e[i];if(t&&t.depth<=r)return t.key}return null},ne=(e,t,n)=>{let r=n.findIndex(e=>e.key===t);if(r===-1)return null;let i=n[r];if(!i)return null;let a=e===`ArrowDown`?1:-1;return T(n,r+a,a,i.depth)},re=[`role`,`aria-multiselectable`],ie=[`aria-multiselectable`,`aria-activedescendant`,`tabindex`],ae=[`data-index`],E={key:2,class:`s-ui-list__static`},D=(0,n.defineComponent)({__name:`SList`,props:(0,n.mergeModels)({items:{},itemKey:{type:[String,Function],default:`id`},childrenKey:{default:`children`},titleKey:{default:`title`},subtitleKey:{default:`subtitle`},iconLeftKey:{default:`iconLeft`},disabledKey:{default:`disabled`},itemProps:{type:Function},selectionMode:{default:()=>e.n.NONE},mandatory:{type:Boolean,default:!1},virtual:{type:Boolean},gap:{default:()=>m},estimateItemSize:{default:36},overscan:{default:5},endReachedDistance:{default:0},canLoadMore:{type:Function},height:{default:320},maxHeight:{},revealRight:{type:Boolean,default:!1},expandOnClick:{type:Boolean,default:!1}},{modelValue:{},modelModifiers:{},selected:{},selectedModifiers:{},expanded:{default:()=>[]},expandedModifiers:{}}),emits:(0,n.mergeModels)([`endReached`],[`update:modelValue`,`update:selected`,`update:expanded`]),setup(r,{expose:i,emit:o}){let s=(0,n.useModel)(r,`modelValue`),c=(0,n.useModel)(r,`selected`),l=(0,n.useModel)(r,`expanded`),u=o,p=(0,n.useSlots)(),m=(0,n.useId)(),v=(0,n.useTemplateRef)(`scrollElementRef`),S=(0,n.useTemplateRef)(`listRootElementRef`),C=(0,n.computed)(()=>h[r.gap]),T=(0,n.computed)(()=>r.items!==void 0),D=(0,n.computed)(()=>T.value?r.virtual===void 0?!0:r.virtual:!1),{flatRows:O,toggleExpanded:k}=d({items:()=>r.items??[],childrenKey:()=>r.childrenKey,itemKey:()=>r.itemKey,expanded:l}),A=(0,a.useVirtualizer)((0,n.computed)(()=>({count:O.value.length,getScrollElement:()=>v.value,estimateSize:()=>r.estimateItemSize,gap:C.value,overscan:r.overscan}))),j=(0,n.computed)(()=>{if(T.value)return O.value.map(e=>e.key)}),M=(0,n.computed)(()=>{let e=new Set;for(let t of O.value)_(t.item,r.disabledKey)&&e.add(t.key);return e}),N=async e=>{if(!D.value)return;let t=O.value.findIndex(t=>t.key===e);t!==-1&&(A.value.scrollToIndex(t,{align:`auto`}),await new Promise(e=>{requestAnimationFrame(()=>{e()})}),await(0,n.nextTick)())},P=e=>te(m,e),F=e.o({modelValue:()=>c.value,onUpdateModelValue:e=>{c.value=e},mode:()=>r.selectionMode,mandatory:()=>r.mandatory,orientation:()=>e.r.VERTICAL,enableTabNavigation:!0,focusMode:()=>D.value?e.t.ACTIVE_DESCENDANT:e.t.DOM,orderedValues:j,isValueDisabled:e=>M.value.has(e),onBeforeFocusItem:async e=>{await N(e)},onFocusGroup:()=>{v.value?.focus()}}),I=(0,n.computed)(()=>T.value&&x(O.value)),L=()=>{if(D.value){v.value?.focus();return}S.value?.focus()},R=()=>{F.focusedValue.value=void 0,s.value=void 0;let e=document.activeElement;e instanceof HTMLElement&&e!==v.value&&e.blur(),L()},z=async e=>{D.value&&await N(e)},B=async e=>{if(R(),e.type===`expand`||e.type===`collapse`){k(e.rowKey),F.select(e.rowKey,!1),await z(e.rowKey);return}F.select(e.rowKey,!1),await z(e.rowKey)},V=async(e,t)=>{if(!I.value||e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return!1;let n=b(t,c.value),r=ne(e.key,n,O.value);return r?(e.preventDefault(),R(),F.select(r,!1),await z(r),!0):!1},H=async(e,t)=>{if(!I.value||e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return!1;let n=b(t,c.value),r=w(e.key,n,O.value);return r?(e.preventDefault(),await B(r),!0):!1},U=()=>{if(s.value)return s.value;let e=b(``,c.value);if(e)return e;let t=j.value;if(t){for(let e of t)if(!M.value.has(e))return e}},W=()=>U(),G=async e=>{let t=W();t&&await K(e,t)},K=async(e,t)=>{await V(e,t)||await H(e,t)||(await F.handleItemKeydown(e,t),s.value=F.focusedValue.value,!F.focusedValue.value&&!D.value&&L())},q=async e=>{let t=U();t&&await K(e,t)},oe=async e=>{if(D.value||e.target!==S.value)return;let t=U();t&&await K(e,t)},se=async()=>{let e=U();if(!e){L();return}await F.focusItem(e,!1)};(0,n.provide)(t.r,{mode:()=>r.selectionMode,isSelected:F.isSelected,selectItem:F.toggle,registerItem:F.registerItem,getItemTabIndex:F.getItemTabIndex,getGroupTabIndex:F.getGroupTabIndex,handleItemKeydown:K,activeKey:()=>s.value,setActiveKey:e=>{s.value=e},isExpanded:e=>l.value.includes(e),toggleExpanded:e=>{if(T.value){k(e);return}let t=new Set(l.value);t.has(e)?t.delete(e):t.add(e),l.value=[...t]},revealRight:()=>r.revealRight,expandOnClick:()=>r.expandOnClick,getItemOptionId:e=>{if(D.value)return P(e)},usesActiveDescendantNavigation:()=>D.value,handlesTreeKeyboardNavigation:()=>T.value});let ce=(0,n.computed)(()=>A.value.getVirtualItems()),le=(0,n.computed)(()=>ce.value.flatMap(e=>{let t=O.value[e.index];return t?[{virtualRow:e,flatRow:t}]:[]})),ue=(0,n.computed)(()=>A.value.getTotalSize()),de=(0,n.computed)(()=>({height:`${ue.value}px`,position:`relative`,width:`100%`})),J=(0,n.computed)(()=>{let e={};return typeof r.height==`number`?e.height=`${r.height}px`:r.height&&(e.height=r.height),r.maxHeight&&(typeof r.maxHeight==`number`?e.maxHeight=`${r.maxHeight}px`:e.maxHeight=r.maxHeight),e}),fe=(0,n.computed)(()=>({"s-ui-list--virtual":D.value,"s-ui-list--static":!D.value})),pe=(0,n.computed)(()=>({"--s-ui-list-gap":ee[r.gap]})),Y=(0,n.computed)(()=>({"s-ui-list__scroll--flat":T.value&&!D.value})),X=(0,n.computed)(()=>{if(r.selectionMode===e.n.MULTIPLE)return!0}),me=(0,n.computed)(()=>{if(!D.value)return`listbox`}),he=(0,n.computed)(()=>{if(!D.value)return X.value}),Z=(0,n.computed)(()=>{if(D.value)return F.getGroupTabIndex()}),ge=(0,n.computed)(()=>s.value?s.value:b(``,c.value)),_e=(0,n.computed)(()=>{if(!D.value)return;let e=ge.value;if(e)return P(e)});f(()=>v.value,{distance:()=>r.endReachedDistance,canLoadMore:()=>r.canLoadMore?r.canLoadMore():!0,onEndReached:()=>{u(`endReached`,{direction:`bottom`})}});let ve=e=>({position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`}),ye=e=>{e instanceof HTMLElement&&A.value.measureElement(e)},Q=e=>{let t=e.item,n={rowKey:e.key,depth:e.depth,expandable:e.hasChildren,expanded:e.expanded,selected:F.isSelected(e.key),active:s.value===e.key,disabled:_(t,r.disabledKey),title:g(t,r.titleKey),subtitle:g(t,r.subtitleKey),iconLeft:y(t,r.iconLeftKey),revealRight:r.revealRight};return r.itemProps?{...n,...r.itemProps(t,e)}:n},$=e=>({...e,revealRight:r.revealRight,toggleExpanded:()=>{k(e.key)}});return i({focusNavigation:se,handleKeyboardNavigation:q}),(e,r)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,{ref_key:`listRootElementRef`,ref:S,class:(0,n.normalizeClass)([`s-ui-list`,fe.value]),style:(0,n.normalizeStyle)(pe.value),role:me.value,"aria-multiselectable":he.value,tabindex:`-1`,onKeydown:oe},[T.value&&D.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,{key:0,ref_key:`scrollElementRef`,ref:v,class:(0,n.normalizeClass)([`s-ui-list__scroll`,Y.value]),style:(0,n.normalizeStyle)(J.value),role:`listbox`,"aria-multiselectable":X.value,"aria-activedescendant":_e.value,tabindex:Z.value,onKeydown:G},[(0,n.createElementVNode)(`div`,{class:`s-ui-list__virtual-panel`,style:(0,n.normalizeStyle)(de.value)},[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(le.value,r=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,{key:r.virtualRow.index,class:`s-ui-list__virtual-row`,"data-index":r.virtualRow.index,ref_for:!0,ref:ye,style:(0,n.normalizeStyle)(ve(r.virtualRow))},[(0,n.unref)(p).item?(0,n.renderSlot)(e.$slots,`item`,(0,n.mergeProps)({key:0,ref_for:!0},$(r.flatRow))):((0,n.openBlock)(),(0,n.createBlock)((0,n.unref)(t.t),(0,n.mergeProps)({key:1,ref_for:!0},Q(r.flatRow)),null,16))],12,ae))),128))],4)],46,ie)):T.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,{key:1,ref_key:`scrollElementRef`,ref:v,class:(0,n.normalizeClass)([`s-ui-list__scroll`,Y.value]),style:(0,n.normalizeStyle)(J.value)},[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)((0,n.unref)(O),r=>((0,n.openBlock)(),(0,n.createElementBlock)(n.Fragment,{key:r.key},[(0,n.unref)(p).item?(0,n.renderSlot)(e.$slots,`item`,(0,n.mergeProps)({key:0,ref_for:!0},$(r))):((0,n.openBlock)(),(0,n.createBlock)((0,n.unref)(t.t),(0,n.mergeProps)({key:1,ref_for:!0},Q(r)),null,16))],64))),128))],6)):((0,n.openBlock)(),(0,n.createElementBlock)(`div`,E,[(0,n.renderSlot)(e.$slots,`default`)]))],46,re))}});Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return D}});
|