@shtabapp/ui-kit 1.58.0 → 1.59.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/SChip-BL47yJ-i.cjs +1 -0
  3. package/dist/SChip-XCYvlpaS.js +102 -0
  4. package/dist/SSegmentControl-Dh_HmD4Z.cjs +1 -0
  5. package/dist/SSegmentControl-hAAYltQR.js +202 -0
  6. package/dist/STabs-BUafXb2Q.js +150 -0
  7. package/dist/STabs-h8sm-3do.cjs +1 -0
  8. package/dist/components/SChip/SChip.types.d.ts +4 -0
  9. package/dist/components/SChip/SChip.types.d.ts.map +1 -1
  10. package/dist/components/SChip/SChip.vue.d.ts +6 -2
  11. package/dist/components/SChip/SChip.vue.d.ts.map +1 -1
  12. package/dist/components/SSegmentControl/utils/useSegmentIndicator.d.ts.map +1 -1
  13. package/dist/components/STabs/utils/useTabsIndicator.d.ts +1 -1
  14. package/dist/components/STabs/utils/useTabsIndicator.d.ts.map +1 -1
  15. package/dist/entries/chip.cjs +1 -1
  16. package/dist/entries/chip.js +1 -1
  17. package/dist/entries/segment-control.cjs +1 -1
  18. package/dist/entries/segment-control.js +1 -1
  19. package/dist/entries/tabs.cjs +1 -1
  20. package/dist/entries/tabs.js +1 -1
  21. package/dist/getIndicatorMetricsPercent-CFGy_nB8.cjs +1 -0
  22. package/dist/getIndicatorMetricsPercent-CWrH_ONg.js +19 -0
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +3 -3
  25. package/dist/uikit-components.css +1 -1
  26. package/dist/utils/getIndicatorMetricsPercent.d.ts +22 -0
  27. package/dist/utils/getIndicatorMetricsPercent.d.ts.map +1 -0
  28. package/package.json +2 -2
  29. package/dist/SChip-DRz5BA4Z.cjs +0 -1
  30. package/dist/SChip-DvPazz7Y.js +0 -67
  31. package/dist/SSegmentControl-CmJEjfSR.js +0 -212
  32. package/dist/SSegmentControl-Dz-d3Y9v.cjs +0 -1
  33. package/dist/STabs-CTM8Nji_.js +0 -164
  34. package/dist/STabs-DeHqnjNJ.cjs +0 -1
@@ -0,0 +1,22 @@
1
+ export interface IIndicatorMetricsPercent {
2
+ left: number;
3
+ top: number;
4
+ width: number;
5
+ height: number;
6
+ }
7
+ export declare const emptyIndicatorMetricsPercent: () => IIndicatorMetricsPercent;
8
+ /**
9
+ * Метрики скользящего индикатора в процентах от трека (SSegmentControl, STabs).
10
+ *
11
+ * Проценты, а не пиксели, потому что отношение двух `getBoundingClientRect()` внутри одного
12
+ * поддерева не зависит от `transform` предков — масштаб сокращается. Абсолютные пиксели,
13
+ * снятые внутри масштабированного контейнера (модалка с scale-анимацией входа), остаются
14
+ * неверными навсегда: `ResizeObserver` следит за layout-боксом, а `transform` его не меняет,
15
+ * поэтому пересчёта после анимации не происходит.
16
+ *
17
+ * Знаменатель — border-box трека: он же и padding-box, то есть containing block для
18
+ * absolute-индикатора, потому что обводки в ките рисуются через `outline` (см. правило
19
+ * `borders-via-outline`), и `border` у трека нулевой.
20
+ */
21
+ export declare const getIndicatorMetricsPercent: (trackElement: HTMLElement, activeElement: HTMLElement) => IIndicatorMetricsPercent;
22
+ //# sourceMappingURL=getIndicatorMetricsPercent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIndicatorMetricsPercent.d.ts","sourceRoot":"","sources":["../../src/utils/getIndicatorMetricsPercent.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,eAAO,MAAM,4BAA4B,QAAO,wBAK9C,CAAA;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,0BAA0B,GACrC,cAAc,WAAW,EACzB,eAAe,WAAW,6BAgB3B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shtabapp/ui-kit",
3
- "version": "1.58.0",
3
+ "version": "1.59.1",
4
4
  "description": "Vue 3 component library by Shtab — 30+ typed components, design tokens, light/dark themes",
5
5
  "keywords": [
6
6
  "shtab",
@@ -264,7 +264,7 @@
264
264
  "dependencies": {
265
265
  "chart.js": "^4.5.0",
266
266
  "vue-i18n": "^9.14.5",
267
- "@shtabapp/ui-kit-primitives": "^1.25.0",
267
+ "@shtabapp/ui-kit-primitives": "^1.26.0",
268
268
  "@shtabapp/ui-kit-tokens": "^1.19.0"
269
269
  },
270
270
  "devDependencies": {
@@ -1 +0,0 @@
1
- let e=require("vue");var t=function(e){return e.BLUE=`blue`,e.RED=`red`,e.WHITE=`white`,e.BILLING=`billing`,e}({}),n=function(e){return e.SIZE_20=`20`,e.SIZE_24=`24`,e.SIZE_32=`32`,e}({}),r=[`tabindex`,`aria-disabled`,`inert`],i={class:`s-ui-chip__content`},a={key:0,class:`s-ui-chip__icon`},o={key:1,class:`s-ui-chip__prefix`},s={key:0,class:`s-ui-chip__actions`},c=(0,e.defineComponent)({__name:`SChip`,props:{color:{default:()=>t.BLUE},disabled:{type:Boolean,default:!1},size:{default:()=>n.SIZE_32}},setup(c){let l=(0,e.useSlots)(),u=(0,e.computed)(()=>c.color===t.BILLING),d=(0,e.computed)(()=>c.disabled?!1:u.value),f=(0,e.computed)(()=>c.disabled?-1:0),p=(0,e.computed)(()=>[`s-ui-chip--color-${c.color}`,`s-ui-chip--size-${c.size}`,{"s-ui-chip--disabled":c.disabled}]),m=(0,e.computed)(()=>c.size===n.SIZE_20?`s-ui-typography-label-12-medium`:`s-ui-typography-label-14-medium`),h={[n.SIZE_20]:16,[n.SIZE_24]:20,[n.SIZE_32]:20},g=(0,e.computed)(()=>h[c.size]);return(t,n)=>((0,e.openBlock)(),(0,e.createElementBlock)(`span`,{class:(0,e.normalizeClass)([`s-ui-chip`,p.value]),tabindex:f.value,role:`group`,"aria-disabled":c.disabled?!0:void 0,inert:c.disabled?!0:void 0},[(0,e.createElementVNode)(`span`,i,[(0,e.unref)(l).icon?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,a,[(0,e.renderSlot)(t.$slots,`icon`,{billing:d.value,disabled:c.disabled,size:g.value})])):(0,e.createCommentVNode)(``,!0),(0,e.unref)(l).prefix?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,o,[(0,e.renderSlot)(t.$slots,`prefix`,{disabled:c.disabled,size:c.size})])):(0,e.createCommentVNode)(``,!0),(0,e.unref)(l).default?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,{key:2,class:(0,e.normalizeClass)([`s-ui-chip__label`,m.value])},[(0,e.renderSlot)(t.$slots,`default`)],2)):(0,e.createCommentVNode)(``,!0)]),(0,e.unref)(l).actions?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,s,[(0,e.renderSlot)(t.$slots,`actions`,{billing:u.value,disabled:c.disabled})])):(0,e.createCommentVNode)(``,!0)],10,r))}});Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});
@@ -1,67 +0,0 @@
1
- import { computed as e, createCommentVNode as t, createElementBlock as n, createElementVNode as r, defineComponent as i, normalizeClass as a, openBlock as o, renderSlot as s, unref as c, useSlots as l } from "vue";
2
- //#region src/components/SChip/SChip.types.ts
3
- var u = /* @__PURE__ */ function(e) {
4
- return e.BLUE = "blue", e.RED = "red", e.WHITE = "white", e.BILLING = "billing", e;
5
- }({}), d = /* @__PURE__ */ function(e) {
6
- return e.SIZE_20 = "20", e.SIZE_24 = "24", e.SIZE_32 = "32", e;
7
- }({}), f = [
8
- "tabindex",
9
- "aria-disabled",
10
- "inert"
11
- ], p = { class: "s-ui-chip__content" }, m = {
12
- key: 0,
13
- class: "s-ui-chip__icon"
14
- }, h = {
15
- key: 1,
16
- class: "s-ui-chip__prefix"
17
- }, g = {
18
- key: 0,
19
- class: "s-ui-chip__actions"
20
- }, _ = /* @__PURE__ */ i({
21
- __name: "SChip",
22
- props: {
23
- color: { default: () => u.BLUE },
24
- disabled: {
25
- type: Boolean,
26
- default: !1
27
- },
28
- size: { default: () => d.SIZE_32 }
29
- },
30
- setup(i) {
31
- let _ = l(), v = e(() => i.color === u.BILLING), y = e(() => i.disabled ? !1 : v.value), b = e(() => i.disabled ? -1 : 0), x = e(() => [
32
- `s-ui-chip--color-${i.color}`,
33
- `s-ui-chip--size-${i.size}`,
34
- { "s-ui-chip--disabled": i.disabled }
35
- ]), S = e(() => i.size === d.SIZE_20 ? "s-ui-typography-label-12-medium" : "s-ui-typography-label-14-medium"), C = {
36
- [d.SIZE_20]: 16,
37
- [d.SIZE_24]: 20,
38
- [d.SIZE_32]: 20
39
- }, w = e(() => C[i.size]);
40
- return (e, l) => (o(), n("span", {
41
- class: a(["s-ui-chip", x.value]),
42
- tabindex: b.value,
43
- role: "group",
44
- "aria-disabled": i.disabled ? !0 : void 0,
45
- inert: i.disabled ? !0 : void 0
46
- }, [r("span", p, [
47
- c(_).icon ? (o(), n("span", m, [s(e.$slots, "icon", {
48
- billing: y.value,
49
- disabled: i.disabled,
50
- size: w.value
51
- })])) : t("", !0),
52
- c(_).prefix ? (o(), n("span", h, [s(e.$slots, "prefix", {
53
- disabled: i.disabled,
54
- size: i.size
55
- })])) : t("", !0),
56
- c(_).default ? (o(), n("span", {
57
- key: 2,
58
- class: a(["s-ui-chip__label", S.value])
59
- }, [s(e.$slots, "default")], 2)) : t("", !0)
60
- ]), c(_).actions ? (o(), n("span", g, [s(e.$slots, "actions", {
61
- billing: v.value,
62
- disabled: i.disabled
63
- })])) : t("", !0)], 10, f));
64
- }
65
- });
66
- //#endregion
67
- export { u as n, d as r, _ as t };
@@ -1,212 +0,0 @@
1
- import { n as e } from "./SButton.types-CpdHQtyx.js";
2
- import { i as t, n, o as r, r as i } from "./useSelectionGroup-cKj38lEN.js";
3
- import { n as a, t as o } from "./useSelectLink-DClG5hGA.js";
4
- import { n as s, r as c, t as l } from "./useLink-Com5VhOk.js";
5
- import { Fragment as u, computed as d, createBlock as f, createCommentVNode as p, createElementBlock as m, createElementVNode as h, createVNode as g, defineComponent as _, inject as v, mergeModels as y, mergeProps as b, normalizeClass as x, normalizeStyle as S, openBlock as C, provide as w, ref as T, renderList as E, resolveDynamicComponent as D, toDisplayString as O, toValue as k, unref as A, useModel as j, useTemplateRef as M, watch as N, withCtx as P } from "vue";
6
- import { SIcon as F } from "@shtabapp/ui-kit-primitives";
7
- import { useResizeObserver as I } from "@vueuse/core";
8
- //#region src/components/SSegmentControl/utils/context.ts
9
- var L = Symbol("SSegmentControl"), R = {
10
- key: 0,
11
- class: "s-ui-segment-control__icon",
12
- "aria-hidden": "true"
13
- }, z = /* @__PURE__ */ _({
14
- __name: "SSegmentControlItem",
15
- props: { item: {} },
16
- setup(t) {
17
- let n = v(L, null), r = {
18
- [e.SMALL]: "s-ui-typography-label-12-medium",
19
- [e.MEDIUM]: "s-ui-typography-label-14-medium",
20
- [e.LARGE]: "s-ui-typography-label-16-medium"
21
- }, i = {
22
- [e.SMALL]: 16,
23
- [e.MEDIUM]: 20,
24
- [e.LARGE]: 24
25
- }, u = d(() => n ? k(n.size) : e.MEDIUM), h = d(() => r[u.value]), _ = d(() => i[u.value]), y = M("itemRootRef"), S = l(() => t.item.link, () => t.item.exact, () => t.item.replace);
26
- o({
27
- isRouterLink: S.isRouterLink,
28
- isActive: S.isActive,
29
- group: () => n,
30
- value: () => t.item.value
31
- });
32
- let w = d(() => !!(n && k(n.disabled)) || !!t.item.disabled), T = a({
33
- group: () => n,
34
- value: () => t.item.value,
35
- el: y,
36
- disabled: w
37
- }), E = d(() => S.isRouterLink.value ? S.isActive.value : T.isActive.value), j = S.linkPresentation, N = d(() => {
38
- let e = j.value;
39
- return e.mode === "none" ? "button" : e.rootTag;
40
- }), I = d(() => N.value === "button"), z = d(() => {
41
- if (n) return k(n.name);
42
- }), B = d(() => ({
43
- "s-ui-segment-control__item--selected": E.value,
44
- "s-ui-segment-control__item--icon-only": !!t.item.iconOnly,
45
- "s-ui-segment-control__item--link": c(t.item.link)
46
- })), V = d(() => ({
47
- ...s(j.value, { replace: t.item.replace }),
48
- disabled: I.value && w.value ? !0 : void 0,
49
- "aria-disabled": !I.value && w.value ? !0 : void 0
50
- })), H = d(() => w.value ? -1 : T.tabIndex.value ?? -1), U = (e) => {
51
- if (!w.value) {
52
- if (S.isRouterLink.value && (e.key === "Enter" || e.key === " " || e.key === "Spacebar")) {
53
- e.preventDefault(), S.navigate();
54
- return;
55
- }
56
- T.handleKeydown(e);
57
- }
58
- }, W = (e) => {
59
- if (w.value) {
60
- e.preventDefault(), e.stopPropagation();
61
- return;
62
- }
63
- S.isRouterLink.value || T.handleClick();
64
- };
65
- return (e, n) => (C(), f(D(N.value), b({
66
- ref_key: "itemRootRef",
67
- ref: y,
68
- role: "radio",
69
- class: ["s-ui-segment-control__item", B.value],
70
- type: I.value ? "button" : void 0
71
- }, V.value, {
72
- "aria-checked": E.value ? "true" : "false",
73
- tabindex: H.value,
74
- name: I.value ? z.value : void 0,
75
- onClick: W,
76
- onKeydown: U
77
- }), {
78
- default: P(() => [t.item.icon ? (C(), m("span", R, [g(A(F), {
79
- name: t.item.icon,
80
- size: _.value
81
- }, null, 8, ["name", "size"])])) : p("", !0), t.item.label && !t.item.iconOnly ? (C(), m("span", {
82
- key: 1,
83
- class: x(["s-ui-segment-control__label", h.value])
84
- }, O(t.item.label), 3)) : p("", !0)]),
85
- _: 1
86
- }, 16, [
87
- "class",
88
- "type",
89
- "aria-checked",
90
- "tabindex",
91
- "name"
92
- ]));
93
- }
94
- }), B = ".s-ui-segment-control__item", V = () => ({
95
- offsetX: 0,
96
- offsetY: 0,
97
- width: 0,
98
- height: 0
99
- }), H = ({ trackEl: e, activeIndex: t, itemCount: n }) => {
100
- let r = T(V()), i = () => {
101
- let n = k(e), i = k(t);
102
- if (!n || i < 0) {
103
- r.value = V();
104
- return;
105
- }
106
- let a = n.querySelectorAll(B).item(i);
107
- if (!(a instanceof HTMLElement)) {
108
- r.value = V();
109
- return;
110
- }
111
- let o = n.getBoundingClientRect(), s = a.getBoundingClientRect();
112
- r.value = {
113
- offsetX: s.left - o.left,
114
- offsetY: s.top - o.top,
115
- width: s.width,
116
- height: s.height
117
- };
118
- };
119
- return I(e, () => {
120
- i();
121
- }), N(() => [k(t), k(n)], () => {
122
- i();
123
- }, { immediate: !0 }), {
124
- indicatorStyle: d(() => {
125
- let { offsetX: e, offsetY: t, width: n, height: i } = r.value;
126
- return !n || !i ? { opacity: "0" } : {
127
- opacity: "1",
128
- left: `${e}px`,
129
- top: `${t}px`,
130
- width: `${n}px`,
131
- height: `${i}px`
132
- };
133
- }),
134
- updateMetrics: i
135
- };
136
- }, U = ["aria-disabled"], W = /* @__PURE__ */ _({
137
- __name: "SSegmentControl",
138
- props: /*@__PURE__*/ y({
139
- items: {},
140
- size: { default: () => e.MEDIUM },
141
- disabled: {
142
- type: Boolean,
143
- default: !1
144
- },
145
- mandatory: {
146
- type: Boolean,
147
- default: !0
148
- },
149
- name: {}
150
- }, {
151
- modelValue: {},
152
- modelModifiers: {}
153
- }),
154
- emits: /*@__PURE__*/ y(["change"], ["update:modelValue"]),
155
- setup(e, { emit: a }) {
156
- let o = j(e, "modelValue"), s = a, c = M("trackRef"), l = r({
157
- modelValue: () => o.value,
158
- onUpdateModelValue: (e) => {
159
- t(e) && (o.value = e, s("change", e));
160
- },
161
- mode: n.SINGLE,
162
- mandatory: () => e.mandatory,
163
- orientation: i.HORIZONTAL,
164
- loop: !0
165
- });
166
- w(L, {
167
- mode: () => n.SINGLE,
168
- isSelected: l.isSelected,
169
- selectItem: l.select,
170
- registerItem: l.registerItem,
171
- getItemTabIndex: l.getItemTabIndex,
172
- getGroupTabIndex: l.getGroupTabIndex,
173
- handleItemKeydown: l.handleItemKeydown,
174
- disabled: () => e.disabled,
175
- name: () => e.name,
176
- size: () => e.size
177
- });
178
- let { indicatorStyle: p } = H({
179
- trackEl: () => c.value,
180
- activeIndex: d(() => {
181
- let t = e.items.findIndex((e) => l.isSelected(e.value));
182
- return t >= 0 ? t : 0;
183
- }),
184
- itemCount: () => e.items.length
185
- }), g = d(() => ({
186
- [`s-ui-segment-control--size-${e.size}`]: !0,
187
- "s-ui-segment-control--disabled": e.disabled
188
- })), _ = (e, t) => `${String(e.value)}-${t}`, v = () => {
189
- if (o.value !== void 0 && o.value !== null) return;
190
- let t = e.items.find((e) => !e.disabled);
191
- t && (o.value = t.value);
192
- };
193
- return N(() => e.items, () => {
194
- v();
195
- }, { immediate: !0 }), (t, n) => (C(), m("div", b({
196
- ref_key: "trackRef",
197
- ref: c,
198
- class: ["s-ui-segment-control", g.value],
199
- role: "radiogroup",
200
- "aria-disabled": e.disabled || void 0
201
- }, t.$attrs), [h("span", {
202
- class: "s-ui-segment-control__indicator",
203
- style: S(A(p)),
204
- "aria-hidden": "true"
205
- }, null, 4), (C(!0), m(u, null, E(e.items, (e, t) => (C(), f(z, {
206
- key: _(e, t),
207
- item: e
208
- }, null, 8, ["item"]))), 128))], 16, U));
209
- }
210
- });
211
- //#endregion
212
- export { W as t };
@@ -1 +0,0 @@
1
- const e=require("./SButton.types-UKroD-ev.cjs"),t=require("./useSelectionGroup-TaektE-I.cjs"),n=require("./useSelectLink-DDdMmsJB.cjs"),r=require("./useLink-1LLWpdDZ.cjs");let i=require("vue"),a=require("@shtabapp/ui-kit-primitives"),o=require("@vueuse/core");var s=Symbol(`SSegmentControl`),c={key:0,class:`s-ui-segment-control__icon`,"aria-hidden":`true`},l=(0,i.defineComponent)({__name:`SSegmentControlItem`,props:{item:{}},setup(t){let o=(0,i.inject)(s,null),l={[e.n.SMALL]:`s-ui-typography-label-12-medium`,[e.n.MEDIUM]:`s-ui-typography-label-14-medium`,[e.n.LARGE]:`s-ui-typography-label-16-medium`},u={[e.n.SMALL]:16,[e.n.MEDIUM]:20,[e.n.LARGE]:24},d=(0,i.computed)(()=>o?(0,i.toValue)(o.size):e.n.MEDIUM),f=(0,i.computed)(()=>l[d.value]),p=(0,i.computed)(()=>u[d.value]),m=(0,i.useTemplateRef)(`itemRootRef`),h=r.t(()=>t.item.link,()=>t.item.exact,()=>t.item.replace);n.t({isRouterLink:h.isRouterLink,isActive:h.isActive,group:()=>o,value:()=>t.item.value});let g=(0,i.computed)(()=>!!(o&&(0,i.toValue)(o.disabled))||!!t.item.disabled),_=n.n({group:()=>o,value:()=>t.item.value,el:m,disabled:g}),v=(0,i.computed)(()=>h.isRouterLink.value?h.isActive.value:_.isActive.value),y=h.linkPresentation,b=(0,i.computed)(()=>{let e=y.value;return e.mode===`none`?`button`:e.rootTag}),x=(0,i.computed)(()=>b.value===`button`),S=(0,i.computed)(()=>{if(o)return(0,i.toValue)(o.name)}),C=(0,i.computed)(()=>({"s-ui-segment-control__item--selected":v.value,"s-ui-segment-control__item--icon-only":!!t.item.iconOnly,"s-ui-segment-control__item--link":r.r(t.item.link)})),w=(0,i.computed)(()=>({...r.n(y.value,{replace:t.item.replace}),disabled:x.value&&g.value?!0:void 0,"aria-disabled":!x.value&&g.value?!0:void 0})),T=(0,i.computed)(()=>g.value?-1:_.tabIndex.value??-1),E=e=>{if(!g.value){if(h.isRouterLink.value&&(e.key===`Enter`||e.key===` `||e.key===`Spacebar`)){e.preventDefault(),h.navigate();return}_.handleKeydown(e)}},D=e=>{if(g.value){e.preventDefault(),e.stopPropagation();return}h.isRouterLink.value||_.handleClick()};return(e,n)=>((0,i.openBlock)(),(0,i.createBlock)((0,i.resolveDynamicComponent)(b.value),(0,i.mergeProps)({ref_key:`itemRootRef`,ref:m,role:`radio`,class:[`s-ui-segment-control__item`,C.value],type:x.value?`button`:void 0},w.value,{"aria-checked":v.value?`true`:`false`,tabindex:T.value,name:x.value?S.value:void 0,onClick:D,onKeydown:E}),{default:(0,i.withCtx)(()=>[t.item.icon?((0,i.openBlock)(),(0,i.createElementBlock)(`span`,c,[(0,i.createVNode)((0,i.unref)(a.SIcon),{name:t.item.icon,size:p.value},null,8,[`name`,`size`])])):(0,i.createCommentVNode)(``,!0),t.item.label&&!t.item.iconOnly?((0,i.openBlock)(),(0,i.createElementBlock)(`span`,{key:1,class:(0,i.normalizeClass)([`s-ui-segment-control__label`,f.value])},(0,i.toDisplayString)(t.item.label),3)):(0,i.createCommentVNode)(``,!0)]),_:1},16,[`class`,`type`,`aria-checked`,`tabindex`,`name`]))}}),u=`.s-ui-segment-control__item`,d=()=>({offsetX:0,offsetY:0,width:0,height:0}),f=({trackEl:e,activeIndex:t,itemCount:n})=>{let r=(0,i.ref)(d()),a=()=>{let n=(0,i.toValue)(e),a=(0,i.toValue)(t);if(!n||a<0){r.value=d();return}let o=n.querySelectorAll(u).item(a);if(!(o instanceof HTMLElement)){r.value=d();return}let s=n.getBoundingClientRect(),c=o.getBoundingClientRect();r.value={offsetX:c.left-s.left,offsetY:c.top-s.top,width:c.width,height:c.height}};return(0,o.useResizeObserver)(e,()=>{a()}),(0,i.watch)(()=>[(0,i.toValue)(t),(0,i.toValue)(n)],()=>{a()},{immediate:!0}),{indicatorStyle:(0,i.computed)(()=>{let{offsetX:e,offsetY:t,width:n,height:i}=r.value;return!n||!i?{opacity:`0`}:{opacity:`1`,left:`${e}px`,top:`${t}px`,width:`${n}px`,height:`${i}px`}}),updateMetrics:a}},p=[`aria-disabled`],m=(0,i.defineComponent)({__name:`SSegmentControl`,props:(0,i.mergeModels)({items:{},size:{default:()=>e.n.MEDIUM},disabled:{type:Boolean,default:!1},mandatory:{type:Boolean,default:!0},name:{}},{modelValue:{},modelModifiers:{}}),emits:(0,i.mergeModels)([`change`],[`update:modelValue`]),setup(e,{emit:n}){let r=(0,i.useModel)(e,`modelValue`),a=n,o=(0,i.useTemplateRef)(`trackRef`),c=t.o({modelValue:()=>r.value,onUpdateModelValue:e=>{t.i(e)&&(r.value=e,a(`change`,e))},mode:t.n.SINGLE,mandatory:()=>e.mandatory,orientation:t.r.HORIZONTAL,loop:!0});(0,i.provide)(s,{mode:()=>t.n.SINGLE,isSelected:c.isSelected,selectItem:c.select,registerItem:c.registerItem,getItemTabIndex:c.getItemTabIndex,getGroupTabIndex:c.getGroupTabIndex,handleItemKeydown:c.handleItemKeydown,disabled:()=>e.disabled,name:()=>e.name,size:()=>e.size});let{indicatorStyle:u}=f({trackEl:()=>o.value,activeIndex:(0,i.computed)(()=>{let t=e.items.findIndex(e=>c.isSelected(e.value));return t>=0?t:0}),itemCount:()=>e.items.length}),d=(0,i.computed)(()=>({[`s-ui-segment-control--size-${e.size}`]:!0,"s-ui-segment-control--disabled":e.disabled})),m=(e,t)=>`${String(e.value)}-${t}`,h=()=>{if(r.value!==void 0&&r.value!==null)return;let t=e.items.find(e=>!e.disabled);t&&(r.value=t.value)};return(0,i.watch)(()=>e.items,()=>{h()},{immediate:!0}),(t,n)=>((0,i.openBlock)(),(0,i.createElementBlock)(`div`,(0,i.mergeProps)({ref_key:`trackRef`,ref:o,class:[`s-ui-segment-control`,d.value],role:`radiogroup`,"aria-disabled":e.disabled||void 0},t.$attrs),[(0,i.createElementVNode)(`span`,{class:`s-ui-segment-control__indicator`,style:(0,i.normalizeStyle)((0,i.unref)(u)),"aria-hidden":`true`},null,4),((0,i.openBlock)(!0),(0,i.createElementBlock)(i.Fragment,null,(0,i.renderList)(e.items,(e,t)=>((0,i.openBlock)(),(0,i.createBlock)(l,{key:m(e,t),item:e},null,8,[`item`]))),128))],16,p))}});Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return m}});
@@ -1,164 +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 { i, n as a, o, r as s } from "./useSelectionGroup-cKj38lEN.js";
4
- import { i as c, n as l, r as u } from "./STab-DY1TGadw.js";
5
- import { computed as d, createCommentVNode as f, createElementBlock as p, createElementVNode as m, createVNode as h, defineComponent as g, mergeModels as _, nextTick as v, normalizeClass as y, normalizeStyle as b, openBlock as x, provide as S, ref as C, renderSlot as w, toValue as T, unref as E, useModel as D, useTemplateRef as O, watch as k } from "vue";
6
- import { useResizeObserver as A, useScroll as j } from "@vueuse/core";
7
- //#region src/components/STabs/utils/useTabsIndicator.ts
8
- var M = ".s-ui-tab[aria-selected=\"true\"]", N = ({ trackEl: e, selectedValue: t, enabled: n }) => {
9
- let r = C({
10
- offsetX: 0,
11
- width: 0,
12
- isBilling: !1
13
- }), i = () => {
14
- if (!T(n)) {
15
- r.value = {
16
- offsetX: 0,
17
- width: 0,
18
- isBilling: !1
19
- };
20
- return;
21
- }
22
- let t = T(e);
23
- if (!t) {
24
- r.value = {
25
- offsetX: 0,
26
- width: 0,
27
- isBilling: !1
28
- };
29
- return;
30
- }
31
- let i = t.querySelector(M);
32
- if (!(i instanceof HTMLElement)) {
33
- r.value = {
34
- offsetX: 0,
35
- width: 0,
36
- isBilling: !1
37
- };
38
- return;
39
- }
40
- let a = t.getBoundingClientRect(), o = i.getBoundingClientRect();
41
- r.value = {
42
- offsetX: o.left - a.left,
43
- width: o.width,
44
- isBilling: i.classList.contains("s-ui-tab--billing")
45
- };
46
- };
47
- return A(e, () => {
48
- i();
49
- }), k(() => T(t), async () => {
50
- await v(), i();
51
- }, { immediate: !0 }), {
52
- indicatorStyle: d(() => {
53
- let { offsetX: e, width: t } = r.value;
54
- return t ? {
55
- opacity: "1",
56
- width: `${t}px`,
57
- transform: `translateX(${e}px)`
58
- } : { opacity: "0" };
59
- }),
60
- indicatorIsBilling: d(() => r.value.isBilling)
61
- };
62
- }, P = ["aria-disabled"], F = { class: "s-ui-tabs__body" }, I = /* @__PURE__ */ g({
63
- __name: "STabs",
64
- props: /*@__PURE__*/ _({
65
- appearance: { default: () => l.PRIMARY },
66
- size: { default: () => u.LARGE },
67
- disabled: {
68
- type: Boolean,
69
- default: !1
70
- },
71
- mandatory: {
72
- type: Boolean,
73
- default: !0
74
- },
75
- addable: {
76
- type: Boolean,
77
- default: !1
78
- },
79
- loop: {
80
- type: Boolean,
81
- default: !0
82
- }
83
- }, {
84
- modelValue: {},
85
- modelModifiers: {}
86
- }),
87
- emits: /*@__PURE__*/ _(["add"], ["update:modelValue"]),
88
- setup(u, { emit: g }) {
89
- let _ = D(u, "modelValue"), v = g, C = O("tabsBodyRef"), T = O("tabsTrackRef"), { arrivedState: k } = j(C, {
90
- throttle: 100,
91
- offset: { right: 1 }
92
- }), A = o({
93
- modelValue: () => _.value,
94
- onUpdateModelValue: (e) => {
95
- i(e) && (_.value = e);
96
- },
97
- mode: a.SINGLE,
98
- mandatory: () => u.mandatory,
99
- orientation: s.HORIZONTAL,
100
- loop: () => u.loop
101
- });
102
- S(c, {
103
- mode: () => a.SINGLE,
104
- isSelected: A.isSelected,
105
- selectItem: A.toggle,
106
- registerItem: A.registerItem,
107
- getItemTabIndex: A.getItemTabIndex,
108
- getGroupTabIndex: A.getGroupTabIndex,
109
- handleItemKeydown: A.handleItemKeydown,
110
- appearance: () => u.appearance,
111
- size: () => u.size,
112
- disabled: () => u.disabled
113
- });
114
- let M = d(() => u.appearance === l.PRIMARY), { indicatorStyle: I, indicatorIsBilling: L } = N({
115
- trackEl: () => T.value,
116
- selectedValue: () => _.value,
117
- enabled: M
118
- }), R = d(() => u.addable && !k.right), z = d(() => [
119
- `s-ui-tabs--appearance-${u.appearance}`,
120
- `s-ui-tabs--size-${u.size}`,
121
- u.addable ? "s-ui-tabs--addable" : void 0
122
- ]), B = () => {
123
- u.disabled || v("add");
124
- };
125
- return (i, a) => (x(), p("div", {
126
- class: y(["s-ui-tabs", z.value]),
127
- role: "tablist",
128
- "aria-orientation": "horizontal",
129
- "aria-disabled": u.disabled ? !0 : void 0
130
- }, [m("div", F, [m("div", {
131
- ref_key: "tabsBodyRef",
132
- ref: C,
133
- class: "s-ui-tabs__scroll"
134
- }, [m("div", {
135
- ref_key: "tabsTrackRef",
136
- ref: T,
137
- class: "s-ui-tabs__track"
138
- }, [M.value ? (x(), p("span", {
139
- key: 0,
140
- class: y(["s-ui-tabs__indicator", { "s-ui-tabs__indicator--billing": E(L) }]),
141
- style: b(E(I)),
142
- "aria-hidden": "true"
143
- }, null, 6)) : f("", !0), w(i.$slots, "default")], 512)], 512), u.addable ? (x(), p("span", {
144
- key: 0,
145
- class: y(["s-ui-tabs__fade", { "s-ui-tabs__fade--visible": R.value }]),
146
- "aria-hidden": "true"
147
- }, null, 2)) : f("", !0)]), u.addable ? w(i.$slots, "add", { key: 0 }, () => [h(E(r), {
148
- class: "s-ui-tabs__add",
149
- icon: "plus",
150
- appearance: E(n).BARE,
151
- variant: E(t).NEUTRAL,
152
- size: E(e).SMALL,
153
- disabled: u.disabled,
154
- onClick: B
155
- }, null, 8, [
156
- "appearance",
157
- "variant",
158
- "size",
159
- "disabled"
160
- ])]) : f("", !0)], 10, P));
161
- }
162
- });
163
- //#endregion
164
- export { I as t };
@@ -1 +0,0 @@
1
- const e=require("./SButton.types-UKroD-ev.cjs"),t=require("./SButton-C-z_q5CG.cjs"),n=require("./useSelectionGroup-TaektE-I.cjs"),r=require("./STab-BbzowB-Y.cjs");let i=require("vue"),a=require("@vueuse/core");var o=`.s-ui-tab[aria-selected="true"]`,s=({trackEl:e,selectedValue:t,enabled:n})=>{let r=(0,i.ref)({offsetX:0,width:0,isBilling:!1}),s=()=>{if(!(0,i.toValue)(n)){r.value={offsetX:0,width:0,isBilling:!1};return}let t=(0,i.toValue)(e);if(!t){r.value={offsetX:0,width:0,isBilling:!1};return}let a=t.querySelector(o);if(!(a instanceof HTMLElement)){r.value={offsetX:0,width:0,isBilling:!1};return}let s=t.getBoundingClientRect(),c=a.getBoundingClientRect();r.value={offsetX:c.left-s.left,width:c.width,isBilling:a.classList.contains(`s-ui-tab--billing`)}};return(0,a.useResizeObserver)(e,()=>{s()}),(0,i.watch)(()=>(0,i.toValue)(t),async()=>{await(0,i.nextTick)(),s()},{immediate:!0}),{indicatorStyle:(0,i.computed)(()=>{let{offsetX:e,width:t}=r.value;return t?{opacity:`1`,width:`${t}px`,transform:`translateX(${e}px)`}:{opacity:`0`}}),indicatorIsBilling:(0,i.computed)(()=>r.value.isBilling)}},c=[`aria-disabled`],l={class:`s-ui-tabs__body`},u=(0,i.defineComponent)({__name:`STabs`,props:(0,i.mergeModels)({appearance:{default:()=>r.n.PRIMARY},size:{default:()=>r.r.LARGE},disabled:{type:Boolean,default:!1},mandatory:{type:Boolean,default:!0},addable:{type:Boolean,default:!1},loop:{type:Boolean,default:!0}},{modelValue:{},modelModifiers:{}}),emits:(0,i.mergeModels)([`add`],[`update:modelValue`]),setup(o,{emit:u}){let d=(0,i.useModel)(o,`modelValue`),f=u,p=(0,i.useTemplateRef)(`tabsBodyRef`),m=(0,i.useTemplateRef)(`tabsTrackRef`),{arrivedState:h}=(0,a.useScroll)(p,{throttle:100,offset:{right:1}}),g=n.o({modelValue:()=>d.value,onUpdateModelValue:e=>{n.i(e)&&(d.value=e)},mode:n.n.SINGLE,mandatory:()=>o.mandatory,orientation:n.r.HORIZONTAL,loop:()=>o.loop});(0,i.provide)(r.i,{mode:()=>n.n.SINGLE,isSelected:g.isSelected,selectItem:g.toggle,registerItem:g.registerItem,getItemTabIndex:g.getItemTabIndex,getGroupTabIndex:g.getGroupTabIndex,handleItemKeydown:g.handleItemKeydown,appearance:()=>o.appearance,size:()=>o.size,disabled:()=>o.disabled});let _=(0,i.computed)(()=>o.appearance===r.n.PRIMARY),{indicatorStyle:v,indicatorIsBilling:y}=s({trackEl:()=>m.value,selectedValue:()=>d.value,enabled:_}),b=(0,i.computed)(()=>o.addable&&!h.right),x=(0,i.computed)(()=>[`s-ui-tabs--appearance-${o.appearance}`,`s-ui-tabs--size-${o.size}`,o.addable?`s-ui-tabs--addable`:void 0]),S=()=>{o.disabled||f(`add`)};return(n,r)=>((0,i.openBlock)(),(0,i.createElementBlock)(`div`,{class:(0,i.normalizeClass)([`s-ui-tabs`,x.value]),role:`tablist`,"aria-orientation":`horizontal`,"aria-disabled":o.disabled?!0:void 0},[(0,i.createElementVNode)(`div`,l,[(0,i.createElementVNode)(`div`,{ref_key:`tabsBodyRef`,ref:p,class:`s-ui-tabs__scroll`},[(0,i.createElementVNode)(`div`,{ref_key:`tabsTrackRef`,ref:m,class:`s-ui-tabs__track`},[_.value?((0,i.openBlock)(),(0,i.createElementBlock)(`span`,{key:0,class:(0,i.normalizeClass)([`s-ui-tabs__indicator`,{"s-ui-tabs__indicator--billing":(0,i.unref)(y)}]),style:(0,i.normalizeStyle)((0,i.unref)(v)),"aria-hidden":`true`},null,6)):(0,i.createCommentVNode)(``,!0),(0,i.renderSlot)(n.$slots,`default`)],512)],512),o.addable?((0,i.openBlock)(),(0,i.createElementBlock)(`span`,{key:0,class:(0,i.normalizeClass)([`s-ui-tabs__fade`,{"s-ui-tabs__fade--visible":b.value}]),"aria-hidden":`true`},null,2)):(0,i.createCommentVNode)(``,!0)]),o.addable?(0,i.renderSlot)(n.$slots,`add`,{key:0},()=>[(0,i.createVNode)((0,i.unref)(t.t),{class:`s-ui-tabs__add`,icon:`plus`,appearance:(0,i.unref)(e.t).BARE,variant:(0,i.unref)(e.r).NEUTRAL,size:(0,i.unref)(e.n).SMALL,disabled:o.disabled,onClick:S},null,8,[`appearance`,`variant`,`size`,`disabled`])]):(0,i.createCommentVNode)(``,!0)],10,c))}});Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return u}});