@selectwin/kit 0.1.208 → 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.
@@ -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
@@ -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