@selectwin/kit 0.1.207 → 0.1.209

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.
@@ -35,6 +35,11 @@ type SelectComboboxOwnProps = {
35
35
  allowCustom?: boolean;
36
36
  /** Rótulo da linha do valor livre. Padrão: `Usar "…"`. */
37
37
  customLabel?: (query: string) => ReactNode;
38
+ /**
39
+ * 0.1.208: a largura mínima do campo. O combobox mede pelo valor escolhido; numa barra de filtros ele pularia a cada
40
+ * troca e empurraria o resto da barra. Um comprimento CSS (`'16rem'`).
41
+ */
42
+ minWidth?: string;
38
43
  };
39
44
  export type SelectComboboxProps = SelectComboboxOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectComboboxOwnProps>;
40
45
  export declare const SelectCombobox: import('react').ForwardRefExoticComponent<SelectComboboxOwnProps & Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof SelectComboboxOwnProps> & import('react').RefAttributes<HTMLDivElement>>;
@@ -19,26 +19,30 @@ function f({ count: e, children: t }) {
19
19
  children: t
20
20
  });
21
21
  }
22
- var p = o(function({ label: i, value: o, onChange: p, options: m, placeholder: h, searchPlaceholder: g, labelAction: _, help: v, hint: y, error: b, emptyText: x, disabled: S, required: C, size: w = "md", searchable: T = !0, allowCustom: E = !1, customLabel: D, className: O, ...k }, A) {
23
- let j = n(), M = h ?? j.common.selectPlaceholder, N = g ?? j.common.searchPlaceholder, P = x ?? j.common.noResults, F = s(), [I, L] = l(!1), [R, z] = l(""), B = m.find((e) => e.value === o), V = B ? B.label : E && o ? o : null, H = c(() => {
24
- let e = R.trim().toLowerCase();
22
+ var p = o(function({ label: i, value: o, onChange: p, options: m, placeholder: h, searchPlaceholder: g, labelAction: _, help: v, hint: y, error: b, emptyText: x, disabled: S, required: C, size: w = "md", searchable: T = !0, allowCustom: E = !1, customLabel: D, minWidth: O, className: k, style: A, ...j }, M) {
23
+ let N = n(), P = h ?? N.common.selectPlaceholder, F = g ?? N.common.searchPlaceholder, I = x ?? N.common.noResults, L = s(), [R, z] = l(!1), [B, V] = l(""), H = m.find((e) => e.value === o), U = H ? H.label : E && o ? o : null, W = c(() => {
24
+ let e = B.trim().toLowerCase();
25
25
  return !T || !e ? m : m.filter((t) => {
26
26
  var n;
27
27
  return t.label.toLowerCase().includes(e) || ((n = t.secondary) == null ? void 0 : n.toLowerCase().includes(e));
28
28
  });
29
29
  }, [
30
30
  m,
31
- R,
31
+ B,
32
32
  T
33
- ]), U = R.trim(), W = U ? m.find((e) => e.label.toLowerCase() === U.toLowerCase()) : void 0, G = E && T && U !== "" && !W, K = () => {
34
- L(!1), z("");
35
- }, q = (e) => {
36
- p(e), K();
37
- }, J = b ? `${F}-err` : y ? `${F}-hint` : void 0;
33
+ ]), G = B.trim(), K = G ? m.find((e) => e.label.toLowerCase() === G.toLowerCase()) : void 0, q = E && T && G !== "" && !K, J = () => {
34
+ z(!1), V("");
35
+ }, Y = (e) => {
36
+ p(e), J();
37
+ }, X = b ? `${L}-err` : y ? `${L}-hint` : void 0;
38
38
  return /* @__PURE__ */ d("div", {
39
- ref: A,
40
- ...k,
41
- className: `select-field${w === "sm" ? " select-field--sm" : ""}${O ? " " + O : ""}`,
39
+ ref: M,
40
+ ...j,
41
+ style: O ? {
42
+ minWidth: O,
43
+ ...A
44
+ } : A,
45
+ className: `select-field${w === "sm" ? " select-field--sm" : ""}${k ? " " + k : ""}`,
42
46
  children: [
43
47
  (i || v || _) && /* @__PURE__ */ d("div", {
44
48
  className: "select-field__labelrow",
@@ -46,7 +50,7 @@ var p = o(function({ label: i, value: o, onChange: p, options: m, placeholder: h
46
50
  className: "select-field__labelwrap",
47
51
  children: [i && /* @__PURE__ */ u("label", {
48
52
  className: "select-field__label",
49
- htmlFor: F,
53
+ htmlFor: L,
50
54
  children: i
51
55
  }), v != null && v !== "" && /* @__PURE__ */ u(r, { content: v })]
52
56
  }), _]
@@ -54,24 +58,24 @@ var p = o(function({ label: i, value: o, onChange: p, options: m, placeholder: h
54
58
  /* @__PURE__ */ u("div", {
55
59
  className: "select-combobox",
56
60
  children: /* @__PURE__ */ u(a, {
57
- active: I,
58
- onClose: K,
61
+ active: R,
62
+ onClose: J,
59
63
  placement: "bottom-start",
60
64
  role: "listbox",
61
65
  matchWidth: !0,
62
66
  activator: /* @__PURE__ */ d("button", {
63
- id: F,
67
+ id: L,
64
68
  type: "button",
65
- className: `select-combobox__trigger${b ? " select-input--error" : ""}${I ? " is-open" : ""}`,
66
- onClick: () => I ? K() : L(!0),
69
+ className: `select-combobox__trigger${b ? " select-input--error" : ""}${R ? " is-open" : ""}`,
70
+ onClick: () => R ? J() : z(!0),
67
71
  disabled: S,
68
72
  "aria-haspopup": "listbox",
69
- "aria-expanded": I,
73
+ "aria-expanded": R,
70
74
  "aria-required": C || void 0,
71
- "aria-describedby": J,
75
+ "aria-describedby": X,
72
76
  children: [/* @__PURE__ */ u("span", {
73
- className: `select-combobox__value${V == null ? " is-placeholder" : ""}`,
74
- children: V ?? M
77
+ className: `select-combobox__value${U == null ? " is-placeholder" : ""}`,
78
+ children: U ?? P
75
79
  }), /* @__PURE__ */ u("span", {
76
80
  className: "select-combobox__caret",
77
81
  "aria-hidden": "true",
@@ -85,33 +89,33 @@ var p = o(function({ label: i, value: o, onChange: p, options: m, placeholder: h
85
89
  children: /* @__PURE__ */ u("input", {
86
90
  className: "select-combobox__searchinput",
87
91
  type: "text",
88
- value: R,
89
- onChange: (e) => z(e.target.value),
92
+ value: B,
93
+ onChange: (e) => V(e.target.value),
90
94
  onKeyDown: (e) => {
91
- e.key === "Enter" && E && U !== "" && (e.preventDefault(), q(W ? W.value : U));
95
+ e.key === "Enter" && E && G !== "" && (e.preventDefault(), Y(K ? K.value : G));
92
96
  },
93
- placeholder: N,
97
+ placeholder: F,
94
98
  autoFocus: !0
95
99
  })
96
100
  }), /* @__PURE__ */ d(f, {
97
- count: H.length + +!!G,
98
- children: [G && /* @__PURE__ */ u("button", {
101
+ count: W.length + +!!q,
102
+ children: [q && /* @__PURE__ */ u("button", {
99
103
  type: "button",
100
104
  role: "option",
101
105
  "aria-selected": !1,
102
106
  className: "select-combobox__option select-combobox__option--custom",
103
- onClick: () => q(U),
107
+ onClick: () => Y(G),
104
108
  children: /* @__PURE__ */ u("span", {
105
109
  className: "select-combobox__optiontext",
106
110
  children: /* @__PURE__ */ u("span", {
107
111
  className: "select-combobox__optionlabel",
108
- children: D ? D(U) : `Usar “${U}”`
112
+ children: D ? D(G) : `Usar “${G}”`
109
113
  })
110
114
  })
111
- }), H.length === 0 ? G ? null : /* @__PURE__ */ u("div", {
115
+ }), W.length === 0 ? q ? null : /* @__PURE__ */ u("div", {
112
116
  className: "select-combobox__empty",
113
- children: P
114
- }) : H.map((t) => {
117
+ children: I
118
+ }) : W.map((t) => {
115
119
  let n = t.value === o;
116
120
  return /* @__PURE__ */ d("button", {
117
121
  type: "button",
@@ -119,7 +123,7 @@ var p = o(function({ label: i, value: o, onChange: p, options: m, placeholder: h
119
123
  "aria-selected": n,
120
124
  disabled: t.disabled,
121
125
  className: `select-combobox__option${n ? " is-selected" : ""}`,
122
- onClick: () => q(t.value),
126
+ onClick: () => Y(t.value),
123
127
  children: [/* @__PURE__ */ d("span", {
124
128
  className: "select-combobox__optiontext",
125
129
  children: [/* @__PURE__ */ u("span", {
@@ -141,11 +145,11 @@ var p = o(function({ label: i, value: o, onChange: p, options: m, placeholder: h
141
145
  })
142
146
  }),
143
147
  b ? /* @__PURE__ */ u("p", {
144
- id: `${F}-err`,
148
+ id: `${L}-err`,
145
149
  className: "select-field__error",
146
150
  children: b
147
151
  }) : y ? /* @__PURE__ */ u("p", {
148
- id: `${F}-hint`,
152
+ id: `${L}-hint`,
149
153
  className: "select-field__hint",
150
154
  children: y
151
155
  }) : null
@@ -25,6 +25,8 @@ export interface SelectKitMessages {
25
25
  optional: string;
26
26
  notifications: string;
27
27
  needsAttention: string;
28
+ /** 0.1.209: o passo feito, para o leitor de tela (o visto do número é decorativo). */
29
+ done: string;
28
30
  };
29
31
  pagination: {
30
32
  label: string;
@@ -24,7 +24,8 @@ var r = {
24
24
  hidePassword: "Ocultar senha",
25
25
  optional: "(opcional)",
26
26
  notifications: "Notificações",
27
- needsAttention: "precisa de atenção"
27
+ needsAttention: "precisa de atenção",
28
+ done: "feito"
28
29
  },
29
30
  pagination: {
30
31
  label: "Paginação",
@@ -111,7 +112,8 @@ var r = {
111
112
  hidePassword: "Hide password",
112
113
  optional: "(optional)",
113
114
  notifications: "Notifications",
114
- needsAttention: "needs attention"
115
+ needsAttention: "needs attention",
116
+ done: "done"
115
117
  },
116
118
  pagination: {
117
119
  label: "Pagination",
@@ -25,6 +25,10 @@ type SelectSegmentedOwnProps = {
25
25
  disabled?: boolean;
26
26
  /** A recusa da escolha (0.1.141): a trilha com o contorno de erro e a frase embaixo, no lugar do `hint`. */
27
27
  error?: ReactNode;
28
+ /** `tabs` (padrão): a trilha troca um painel (tablist). `radio` (0.1.209): uma escolha (radiogroup). */
29
+ semantics?: 'tabs' | 'radio';
30
+ /** `sm` (0.1.209): o tier pequeno (28px) fora de um `.select-dense` — a linha de um menu, o cabeçalho de um cartão. */
31
+ size?: 'md' | 'sm';
28
32
  };
29
33
  export type SelectSegmentedProps = SelectSegmentedOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectSegmentedOwnProps>;
30
34
  export declare const SelectSegmented: import('react').ForwardRefExoticComponent<SelectSegmentedOwnProps & Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof SelectSegmentedOwnProps> & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,51 +1,61 @@
1
1
  import { forwardRef as e, useId as t, useLayoutEffect as n, useRef as r, useState as i } from "react";
2
2
  import { jsx as a, jsxs as o } from "react/jsx-runtime";
3
3
  //#region src/SelectSegmented.tsx
4
- var s = e(function({ value: e, onChange: s, options: c, ariaLabel: l, fullWidth: u = !1, label: d, hint: f, disabled: p = !1, error: m, className: h, ...g }, _) {
5
- let v = t(), y = Math.max(0, c.findIndex((t) => t.value === e)), b = r([]), [x, S] = i(null), C = c.map((e) => e.count ?? "").join(",");
4
+ var s = e(function({ value: e, onChange: s, options: c, ariaLabel: l, fullWidth: u = !1, label: d, hint: f, disabled: p = !1, error: m, semantics: h = "tabs", size: g = "md", className: _, ...v }, y) {
5
+ let b = t(), x = Math.max(0, c.findIndex((t) => t.value === e)), S = r([]), [C, w] = i(null), T = h === "radio", E = c.map((e) => e.count ?? "").join(",");
6
6
  n(() => {
7
7
  let e = () => {
8
- let e = b.current[y];
8
+ let e = S.current[x];
9
9
  if (!e) return;
10
10
  let t = {
11
11
  left: e.offsetLeft,
12
12
  width: e.offsetWidth
13
13
  };
14
- S((e) => e && e.left === t.left && e.width === t.width ? e : t);
14
+ w((e) => e && e.left === t.left && e.width === t.width ? e : t);
15
15
  };
16
16
  e();
17
17
  let t = typeof ResizeObserver < "u" ? new ResizeObserver(e) : null;
18
- return b.current.forEach((e) => e && (t == null ? void 0 : t.observe(e))), () => t == null ? void 0 : t.disconnect();
18
+ return S.current.forEach((e) => e && (t == null ? void 0 : t.observe(e))), () => t == null ? void 0 : t.disconnect();
19
19
  }, [
20
- y,
20
+ x,
21
21
  c.length,
22
- C
22
+ E
23
23
  ]);
24
- let w = x ? {
25
- left: x.left,
26
- width: x.width,
24
+ let D = C ? {
25
+ left: C.left,
26
+ width: C.width,
27
27
  opacity: 1
28
- } : { opacity: 0 }, T = /* @__PURE__ */ o("div", {
29
- ref: d == null ? _ : void 0,
30
- ...d == null ? g : {},
31
- className: `select-segmented${u ? " select-segmented--full" : ""}${p ? " select-segmented--disabled" : ""}${m != null && m !== !1 ? " select-segmented--error" : ""}${d == null && h ? " " + h : ""}`,
32
- role: "tablist",
28
+ } : { opacity: 0 }, O = d == null ? v : {}, k = (t) => {
29
+ var n, r;
30
+ if ((n = O.onKeyDown) == null || n.call(O, t), t.defaultPrevented || p || !c.length) return;
31
+ let i = S.current.findIndex((e) => e === t.target);
32
+ if (i < 0) return;
33
+ let a = t.key === "ArrowRight" || T && t.key === "ArrowDown", o = t.key === "ArrowLeft" || T && t.key === "ArrowUp", l = a ? (i + 1) % c.length : o ? (i - 1 + c.length) % c.length : t.key === "Home" ? 0 : t.key === "End" ? c.length - 1 : -1;
34
+ l < 0 || (t.preventDefault(), (r = S.current[l]) == null || r.focus(), c[l].value !== e && s(c[l].value));
35
+ }, A = /* @__PURE__ */ o("div", {
36
+ ref: d == null ? y : void 0,
37
+ ...O,
38
+ className: `select-segmented${u ? " select-segmented--full" : ""}${g === "sm" ? " select-segmented--sm" : ""}${p ? " select-segmented--disabled" : ""}${m != null && m !== !1 ? " select-segmented--error" : ""}${d == null && _ ? " " + _ : ""}`,
39
+ role: T ? "radiogroup" : "tablist",
33
40
  "aria-label": l,
34
- "aria-labelledby": d != null && !l ? v : void 0,
41
+ "aria-labelledby": d != null && !l ? b : void 0,
35
42
  "aria-disabled": p || void 0,
43
+ onKeyDown: k,
36
44
  children: [/* @__PURE__ */ a("span", {
37
45
  className: "select-segmented__pill",
38
46
  "aria-hidden": "true",
39
- style: w
47
+ style: D
40
48
  }), c.map((t, n) => {
41
49
  let r = t.value === e, i = !!t.count && t.count > 0, c = t.title && i ? `${t.title}, ${t.countLabel ?? t.count}` : t.title;
42
50
  return /* @__PURE__ */ o("button", {
43
51
  ref: (e) => {
44
- b.current[n] = e;
52
+ S.current[n] = e;
45
53
  },
46
54
  type: "button",
47
- role: "tab",
48
- "aria-selected": r,
55
+ role: T ? "radio" : "tab",
56
+ "aria-selected": T ? void 0 : r,
57
+ "aria-checked": T ? r : void 0,
58
+ tabIndex: n === x ? 0 : -1,
49
59
  className: `select-segmented__item${r ? " select-segmented__item--active" : ""}`,
50
60
  title: t.title,
51
61
  "aria-label": c,
@@ -58,28 +68,28 @@ var s = e(function({ value: e, onChange: s, options: c, ariaLabel: l, fullWidth:
58
68
  }) : null]
59
69
  }, t.value);
60
70
  })]
61
- }), E = m != null && m !== !1 && m !== "";
62
- return d == null && !E ? T : d == null ? /* @__PURE__ */ o("div", {
71
+ }), j = m != null && m !== !1 && m !== "";
72
+ return d == null && !j ? A : d == null ? /* @__PURE__ */ o("div", {
63
73
  className: "select-field",
64
- children: [T, /* @__PURE__ */ a("p", {
74
+ children: [A, /* @__PURE__ */ a("p", {
65
75
  className: "select-field__error",
66
76
  children: m
67
77
  })]
68
78
  }) : /* @__PURE__ */ o("div", {
69
- ref: _,
70
- ...g,
71
- className: `select-field${h ? " " + h : ""}`,
79
+ ref: y,
80
+ ...v,
81
+ className: `select-field${_ ? " " + _ : ""}`,
72
82
  children: [
73
83
  /* @__PURE__ */ a("div", {
74
84
  className: "select-field__labelrow",
75
85
  children: /* @__PURE__ */ a("span", {
76
86
  className: "select-field__label",
77
- id: v,
87
+ id: b,
78
88
  children: d
79
89
  })
80
90
  }),
81
- T,
82
- E ? /* @__PURE__ */ a("p", {
91
+ A,
92
+ j ? /* @__PURE__ */ a("p", {
83
93
  className: "select-field__error",
84
94
  children: m
85
95
  }) : f != null && /* @__PURE__ */ a("p", {
@@ -29,6 +29,14 @@ var o = n(function({ steps: n, current: o, onSelect: s, orientation: c = "horizo
29
29
  ")"
30
30
  ]
31
31
  }),
32
+ l === "done" && /* @__PURE__ */ a("span", {
33
+ className: "select-steps__sr",
34
+ children: [
35
+ "(",
36
+ p.common.done,
37
+ ")"
38
+ ]
39
+ }),
32
40
  m && c.description && /* @__PURE__ */ i("span", {
33
41
  className: "select-steps__desc",
34
42
  children: c.description
@@ -121,6 +121,11 @@ type SelectTableEmptyOwnProps = {
121
121
  action?: ReactNode;
122
122
  /** 0.1.207: o vazio que é um ERRO (a lista não carregou): o ícone no tom crítico. O `role="alert"` é de quem usa. */
123
123
  tone?: 'critical';
124
+ /**
125
+ * 0.1.208: a altura mínima, com o texto centrado nela — o vazio que fica no LUGAR de um gráfico ocupa a altura do
126
+ * gráfico, e o cartão não encolhe quando o período não tem dado. Um comprimento CSS (`'11.25rem'`).
127
+ */
128
+ minHeight?: string;
124
129
  };
125
130
  export type SelectTableEmptyProps = SelectTableEmptyOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectTableEmptyOwnProps>;
126
131
  export declare const SelectTableEmpty: import('react').ForwardRefExoticComponent<SelectTableEmptyOwnProps & Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof SelectTableEmptyOwnProps> & import('react').RefAttributes<HTMLDivElement>>;
@@ -212,11 +212,15 @@ var O = l(function({ children: e, align: n = "start", disclosure: r, className:
212
212
  children: r !== "none" && /* @__PURE__ */ g(t, {})
213
213
  }) : null, e]
214
214
  });
215
- }), k = l(function({ icon: e, title: t, subtitle: n, action: r, tone: i, className: a, ...o }, s) {
215
+ }), k = l(function({ icon: e, title: t, subtitle: n, action: r, tone: i, minHeight: a, className: o, style: s, ...c }, l) {
216
216
  return /* @__PURE__ */ _("div", {
217
- ref: s,
218
- ...o,
219
- className: `select-table-empty${i === "critical" ? " select-table-empty--critical" : ""}${a ? " " + a : ""}`,
217
+ ref: l,
218
+ ...c,
219
+ style: a ? {
220
+ minHeight: a,
221
+ ...s
222
+ } : s,
223
+ className: `select-table-empty${i === "critical" ? " select-table-empty--critical" : ""}${a ? " select-table-empty--fill" : ""}${o ? " " + o : ""}`,
220
224
  children: [
221
225
  e && /* @__PURE__ */ g("span", {
222
226
  className: "select-table-empty__icon",
@@ -4,6 +4,8 @@ export interface SelectTab {
4
4
  label: ReactNode;
5
5
  /** Status dot tone shown before the label. */
6
6
  dot?: 'success' | 'neutral' | 'warning';
7
+ /** O número do que a aba mostra (0.1.209), na língua do kit: as falhas das entregas, os itens de um estado. O 0 aparece. */
8
+ count?: number;
7
9
  }
8
10
  type SelectTabsOwnProps = {
9
11
  tabs: SelectTab[];
@@ -12,7 +14,9 @@ type SelectTabsOwnProps = {
12
14
  /** Right-aligned slot INSIDE the tab bar (shares the bottom border) — e.g. a board's
13
15
  * "Personalizar" trigger. Controls inside render on the small (28px) tier. */
14
16
  end?: ReactNode;
17
+ /** O id do conteúdo que as abas trocam (0.1.209): vira o `aria-controls` de cada aba. */
18
+ panelId?: string;
15
19
  };
16
20
  export type SelectTabsProps = SelectTabsOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectTabsOwnProps>;
17
- export declare function SelectTabs({ tabs, value, onChange, end, className, ...rest }: SelectTabsProps): import("react").JSX.Element;
21
+ export declare function SelectTabs({ tabs, value, onChange, end, panelId, className, onKeyDown, ...rest }: SelectTabsProps): import("react").JSX.Element;
18
22
  export {};
@@ -1,63 +1,88 @@
1
- import { useLayoutEffect as e, useRef as t, useState as n } from "react";
2
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
1
+ import { formatSelectNumber as e, useSelectLocale as t } from "./SelectLocale.js";
2
+ import { useLayoutEffect as n, useRef as r, useState as i } from "react";
3
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
3
4
  //#region src/SelectTabs.tsx
4
- function a({ tabs: a, value: o, onChange: s, end: c, className: l, ...u }) {
5
- let d = t(null), [f, p] = n({
5
+ function s({ tabs: s, value: c, onChange: l, end: u, panelId: d, className: f, onKeyDown: p, ...m }) {
6
+ let h = t(), g = r(null), _ = r([]), [v, y] = i({
6
7
  left: 0,
7
8
  width: 0
8
- });
9
- e(() => {
10
- let e = d.current;
9
+ }), b = s.findIndex((e) => e.id === c), x = s.map((e) => e.id).join("\0");
10
+ n(() => {
11
+ let e = g.current;
11
12
  if (!e) return;
12
13
  let t = () => {
13
14
  let t = e.querySelector(".select-tab--active");
14
15
  if (!t) {
15
- p((e) => e.width === 0 ? e : {
16
+ y((e) => e.width === 0 ? e : {
16
17
  left: e.left,
17
18
  width: 0
18
19
  });
19
20
  return;
20
21
  }
21
22
  let n = t.offsetLeft, r = t.offsetWidth;
22
- p((e) => e.left === n && e.width === r ? e : {
23
+ y((e) => e.left === n && e.width === r ? e : {
23
24
  left: n,
24
25
  width: r
25
26
  });
26
27
  };
27
28
  t();
28
29
  let n = typeof ResizeObserver < "u" ? new ResizeObserver(t) : null;
29
- return n == null || n.observe(e), () => n == null ? void 0 : n.disconnect();
30
- }, [o, a.length]);
31
- let m = {
32
- "--tab-ind-left": `${f.left}px`,
33
- "--tab-ind-width": `${f.width}px`
30
+ return n == null || n.observe(e), _.current.forEach((e) => e && (n == null ? void 0 : n.observe(e))), () => n == null ? void 0 : n.disconnect();
31
+ }, [
32
+ c,
33
+ s.length,
34
+ x
35
+ ]);
36
+ let S = (e) => {
37
+ var t;
38
+ if (p == null || p(e), e.defaultPrevented || !s.length) return;
39
+ let n = _.current.findIndex((t) => t === e.target);
40
+ if (n < 0) return;
41
+ let r = s.length - 1, i = e.key === "ArrowRight" ? (n + 1) % s.length : e.key === "ArrowLeft" ? (n - 1 + s.length) % s.length : e.key === "Home" ? 0 : e.key === "End" ? r : -1;
42
+ i < 0 || (e.preventDefault(), (t = _.current[i]) == null || t.focus(), s[i].id !== c && l(s[i].id));
43
+ }, C = {
44
+ "--tab-ind-left": `${v.left}px`,
45
+ "--tab-ind-width": `${v.width}px`
34
46
  };
35
- return /* @__PURE__ */ i("div", {
36
- ...u,
37
- className: `select-tabs${l ? " " + l : ""}`,
47
+ return /* @__PURE__ */ o("div", {
48
+ ...m,
49
+ className: `select-tabs${f ? " " + f : ""}`,
38
50
  role: "tablist",
39
- ref: d,
40
- style: m,
41
- children: [a.map((e) => {
42
- let t = e.id === o;
43
- return /* @__PURE__ */ i("button", {
51
+ ref: g,
52
+ style: C,
53
+ onKeyDown: S,
54
+ children: [s.map((t, n) => {
55
+ let r = t.id === c;
56
+ return /* @__PURE__ */ o("button", {
57
+ ref: (e) => {
58
+ _.current[n] = e;
59
+ },
44
60
  type: "button",
45
61
  role: "tab",
46
- "aria-selected": t,
47
- className: `select-tab${t ? " select-tab--active" : ""}`,
48
- onClick: () => s(e.id),
49
- children: [e.dot && /* @__PURE__ */ r("span", {
50
- className: `select-tab__dot select-tab__dot--${e.dot}`,
51
- "aria-hidden": "true"
52
- }), e.label]
53
- }, e.id);
54
- }), c != null && /* @__PURE__ */ r("div", {
62
+ "aria-selected": r,
63
+ "aria-controls": d,
64
+ tabIndex: r || b < 0 && n === 0 ? 0 : -1,
65
+ className: `select-tab${r ? " select-tab--active" : ""}`,
66
+ onClick: () => l(t.id),
67
+ children: [
68
+ t.dot && /* @__PURE__ */ a("span", {
69
+ className: `select-tab__dot select-tab__dot--${t.dot}`,
70
+ "aria-hidden": "true"
71
+ }),
72
+ t.label,
73
+ t.count !== void 0 && /* @__PURE__ */ a("span", {
74
+ className: "select-tab__count",
75
+ children: e(t.count, h)
76
+ })
77
+ ]
78
+ }, t.id);
79
+ }), u != null && /* @__PURE__ */ a("div", {
55
80
  className: "select-tabs__end",
56
- children: c
81
+ children: u
57
82
  })]
58
83
  });
59
84
  }
60
85
  //#endregion
61
- export { a as SelectTabs };
86
+ export { s as SelectTabs };
62
87
 
63
88
  //# sourceMappingURL=SelectTabs.js.map