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