@selectwin/kit 0.1.258 → 0.1.259

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 (40) hide show
  1. package/README.md +31 -0
  2. package/dist/SelectActionBar.d.ts +29 -0
  3. package/dist/SelectActionBar.js +101 -0
  4. package/dist/SelectBadge.d.ts +9 -0
  5. package/dist/SelectBadge.js +26 -12
  6. package/dist/SelectBulkBar.d.ts +21 -0
  7. package/dist/SelectBulkBar.js +40 -0
  8. package/dist/SelectChannelPreview.d.ts +21 -1
  9. package/dist/SelectChannelPreview.js +100 -73
  10. package/dist/SelectColorField.d.ts +1 -5
  11. package/dist/SelectColorField.js +83 -101
  12. package/dist/SelectCombobox.d.ts +5 -0
  13. package/dist/SelectCombobox.js +52 -49
  14. package/dist/SelectDataTable.d.ts +17 -1
  15. package/dist/SelectDataTable.js +100 -90
  16. package/dist/SelectDeadlineBadge.d.ts +32 -0
  17. package/dist/SelectDeadlineBadge.js +73 -0
  18. package/dist/SelectFilterBar.js +5 -5
  19. package/dist/SelectListCard.d.ts +27 -1
  20. package/dist/SelectListCard.js +47 -22
  21. package/dist/SelectLocale.d.ts +62 -0
  22. package/dist/SelectLocale.js +173 -0
  23. package/dist/SelectMail.d.ts +9 -1
  24. package/dist/SelectMail.js +234 -207
  25. package/dist/SelectSection.d.ts +4 -4
  26. package/dist/SelectSection.js +77 -8
  27. package/dist/SelectTable.d.ts +13 -1
  28. package/dist/SelectTable.js +88 -79
  29. package/dist/SelectTabs.d.ts +10 -0
  30. package/dist/SelectTabs.js +68 -30
  31. package/dist/SelectWeekHours.d.ts +64 -0
  32. package/dist/SelectWeekHours.js +338 -0
  33. package/dist/index.d.ts +12 -2
  34. package/dist/index.js +188 -183
  35. package/dist/internal/color.d.ts +15 -0
  36. package/dist/internal/color.js +40 -0
  37. package/dist/internal/safeHref.d.ts +7 -0
  38. package/dist/internal/safeHref.js +12 -1
  39. package/dist/style.css +1 -1
  40. package/package.json +1 -1
@@ -2,15 +2,15 @@ import { ReactNode, ComponentPropsWithoutRef } from 'react';
2
2
  import { SelectHeadingLevel } from './internal/headingLevel';
3
3
  type SelectSectionOwnProps = {
4
4
  title?: ReactNode;
5
- /** Ajuda contextual: vira o "!" ao lado do título (SelectInfoTip). IGNORADA quando
6
- * `collapsible` — ali o head inteiro é um <button>, e botão dentro de botão é DOM
7
- * inválido. */
5
+ /** Ajuda contextual: vira o "!" ao lado do título (SelectInfoTip). 0.1.259: também na que recolhe — o cabeçalho dela
6
+ * passa a ser um título com o botão que abre e fecha dentro (botão dentro de botão é DOM inválido). */
8
7
  help?: ReactNode;
9
8
  /** Subdued line under the title (e.g. the step subtitle of a wizard card). Collapsible too:
10
9
  * there it is the SUMMARY of what is inside ("Liberação imediata · conclui com 90%"), so the
11
10
  * closed card still says what it holds. */
12
11
  description?: ReactNode;
13
- /** Right-aligned action in the head (e.g. an "Editar" link). Ignored when collapsible. */
12
+ /** Right-aligned action in the head (e.g. an "Editar" link). 0.1.259: também na que recolhe ("Mudar"), à direita, antes
13
+ * da seta; o clique nela é dela (não abre nem fecha). */
14
14
  action?: ReactNode;
15
15
  /** Make the head a button that expands/collapses the body. */
16
16
  collapsible?: boolean;
@@ -3,15 +3,84 @@ import { ChevronDownIcon as e } from "./icons.js";
3
3
  import { SelectInfoTip as t } from "./SelectInfoTip.js";
4
4
  import { registerSheetFrame as n } from "./internal/sheetBands.js";
5
5
  import { FrameBody as r, useInsideFrame as i } from "./internal/frame.js";
6
- import { HeadingScope as a, SelectHeading as o, nextHeadingLevel as s, useHeadingLevel as c } from "./internal/headingLevel.js";
7
- import { inertProps as l } from "./internal/inert.js";
6
+ import { inertProps as a } from "./internal/inert.js";
7
+ import { HeadingScope as o, SelectHeading as s, nextHeadingLevel as c, useHeadingLevel as l } from "./internal/headingLevel.js";
8
8
  import { forwardRef as u, useId as d, useState as f } from "react";
9
9
  import { jsx as p, jsxs as m } from "react/jsx-runtime";
10
10
  //#region src/SelectSection.tsx
11
11
  var h = u(function({ title: n, help: u, description: h, action: g, collapsible: _ = !1, defaultOpen: v = !0, open: y, onOpenChange: b, footer: x, flush: S = !1, list: C = !1, headingLevel: w, children: T, className: E, ...D }, O) {
12
- let k = c(w), [A, j] = f(v), M = y ?? A, N = d(), P = () => {
12
+ let k = l(w), [A, j] = f(v), M = y ?? A, N = d(), P = () => {
13
13
  y === void 0 && j(!M), b == null || b(!M);
14
14
  }, F = (i() ? " select-section--nested" : "") + (S ? " select-section--flush" : "") + (C ? " select-section--list" : ""), I = C ? "list" : "body";
15
+ if (_ && (u != null && u !== "" || g != null && g !== !1)) {
16
+ let i = (e) => {
17
+ let t = e.currentTarget, n = e.target;
18
+ if (!(n instanceof Element) || !t.contains(n)) return;
19
+ let r = n.closest("button, a[href], input, select, textarea, label, summary, [role=\"button\"], [tabindex]");
20
+ r && r !== t && t.contains(r) || P();
21
+ };
22
+ return /* @__PURE__ */ m("div", {
23
+ ref: O,
24
+ ...D,
25
+ className: `select-section select-section--collapsible select-section--split${F}${M ? " is-open" : ""}${E ? " " + E : ""}`,
26
+ children: [/* @__PURE__ */ m("div", {
27
+ className: "select-section__head select-section__head--split",
28
+ onClick: i,
29
+ children: [
30
+ /* @__PURE__ */ m("div", {
31
+ className: "select-section__heading",
32
+ children: [/* @__PURE__ */ m(s, {
33
+ level: k,
34
+ className: `select-section__title${u != null && u !== "" ? " select-section__title--help" : ""}`,
35
+ children: [/* @__PURE__ */ p("button", {
36
+ type: "button",
37
+ className: "select-section__toggle",
38
+ "aria-expanded": M,
39
+ "aria-controls": N,
40
+ "aria-describedby": h ? `${N}-desc` : void 0,
41
+ onClick: P,
42
+ children: n
43
+ }), u != null && u !== "" && /* @__PURE__ */ p(t, { content: u })]
44
+ }), h && /* @__PURE__ */ p("p", {
45
+ id: `${N}-desc`,
46
+ className: "select-section__desc",
47
+ children: h
48
+ })]
49
+ }),
50
+ g != null && g !== !1 ? /* @__PURE__ */ p("div", {
51
+ className: "select-section__action",
52
+ children: g
53
+ }) : null,
54
+ /* @__PURE__ */ p("span", {
55
+ className: "select-section__chevron",
56
+ "aria-hidden": "true",
57
+ children: /* @__PURE__ */ p(e, {})
58
+ })
59
+ ]
60
+ }), /* @__PURE__ */ p("div", {
61
+ id: N,
62
+ className: "select-section__collapse",
63
+ "data-open": M,
64
+ ...a(!M),
65
+ children: /* @__PURE__ */ m("div", {
66
+ className: "select-section__collapsewrap",
67
+ children: [/* @__PURE__ */ p("div", {
68
+ className: "select-section__body",
69
+ children: /* @__PURE__ */ p(o, {
70
+ level: c(k),
71
+ children: /* @__PURE__ */ p(r, {
72
+ kind: I,
73
+ children: T
74
+ })
75
+ })
76
+ }), x != null && x !== "" && /* @__PURE__ */ p("div", {
77
+ className: "select-section__foot",
78
+ children: x
79
+ })]
80
+ })
81
+ })]
82
+ });
83
+ }
15
84
  return _ ? /* @__PURE__ */ m("div", {
16
85
  ref: O,
17
86
  ...D,
@@ -40,12 +109,12 @@ var h = u(function({ title: n, help: u, description: h, action: g, collapsible:
40
109
  id: N,
41
110
  className: "select-section__collapse",
42
111
  "data-open": M,
43
- ...l(!M),
112
+ ...a(!M),
44
113
  children: /* @__PURE__ */ m("div", {
45
114
  className: "select-section__collapsewrap",
46
115
  children: [/* @__PURE__ */ p("div", {
47
116
  className: "select-section__body",
48
- children: /* @__PURE__ */ p(a, {
117
+ children: /* @__PURE__ */ p(o, {
49
118
  level: k,
50
119
  children: /* @__PURE__ */ p(r, {
51
120
  kind: I,
@@ -67,7 +136,7 @@ var h = u(function({ title: n, help: u, description: h, action: g, collapsible:
67
136
  className: "select-section__head",
68
137
  children: [/* @__PURE__ */ m("div", {
69
138
  className: "select-section__heading",
70
- children: [n && /* @__PURE__ */ m(o, {
139
+ children: [n && /* @__PURE__ */ m(s, {
71
140
  level: k,
72
141
  className: `select-section__title${u == null ? "" : " select-section__title--help"}`,
73
142
  children: [n, u != null && /* @__PURE__ */ p(t, { content: u })]
@@ -82,8 +151,8 @@ var h = u(function({ title: n, help: u, description: h, action: g, collapsible:
82
151
  }),
83
152
  /* @__PURE__ */ p("div", {
84
153
  className: "select-section__body",
85
- children: /* @__PURE__ */ p(a, {
86
- level: n ? s(k) : k,
154
+ children: /* @__PURE__ */ p(o, {
155
+ level: n ? c(k) : k,
87
156
  children: /* @__PURE__ */ p(r, {
88
157
  kind: I,
89
158
  children: T
@@ -138,9 +138,21 @@ type SelectTableRowOwnProps = {
138
138
  * chave, o menu) fica cheia.
139
139
  */
140
140
  muted?: boolean;
141
+ /**
142
+ * 0.1.259: o tom da linha (o chamado vencido): a borda da esquerda no tom. A cor não diz sozinha: o estado à vista
143
+ * (o ícone e o texto, o `SelectDeadlineBadge variant="text"`) vai numa célula, e o `toneLabel` o diz ao leitor de tela.
144
+ */
145
+ tone?: SelectTableRowTone;
146
+ /**
147
+ * 0.1.259: o tom em palavras ("Vencido"), para o leitor de tela: entra fora da vista no começo da célula de cabeçalho
148
+ * da linha (`header`), ou da primeira célula sem ela.
149
+ */
150
+ toneLabel?: string;
141
151
  };
142
152
  export type SelectTableRowProps = SelectTableRowOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectTableRowOwnProps | 'role'>;
143
- export declare function SelectTableRow({ children, onClick, expanded, nested, current, section, muted, className, ...rest }: SelectTableRowProps): import("react").JSX.Element;
153
+ /** 0.1.259: os tons da linha (a borda da esquerda): o vencido, o perto de vencer, o cumprido e o de informação. */
154
+ export type SelectTableRowTone = 'critical' | 'warning' | 'success' | 'info';
155
+ export declare function SelectTableRow({ children: childrenProp, onClick, expanded, nested, current, section, muted, tone, toneLabel, className, ...rest }: SelectTableRowProps): import("react").JSX.Element;
144
156
  type SelectTableCellOwnProps = {
145
157
  children: ReactNode;
146
158
  align?: 'start' | 'end' | 'center';
@@ -4,36 +4,36 @@ import { FrameBody as r, useFrameKind as i } from "./internal/frame.js";
4
4
  import { SelectAvatar as a } from "./SelectAvatar.js";
5
5
  import { SelectListChrome as o, listChromeShape as s } from "./internal/listChrome.js";
6
6
  import { SelectTableEmpty as c } from "./SelectTableEmpty.js";
7
- import { Children as l, createContext as u, forwardRef as d, useCallback as f, useContext as p, useId as m, useLayoutEffect as h, useRef as ee, useState as te } from "react";
8
- import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
7
+ import { Children as l, Fragment as u, cloneElement as d, createContext as f, forwardRef as p, isValidElement as m, useCallback as h, useContext as g, useId as _, useLayoutEffect as ee, useRef as te, useState as v } from "react";
8
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
9
9
  //#region src/SelectTable.tsx
10
- var y = 40, b = 1200, ne = 8;
11
- function x(e) {
10
+ var S = 40, C = 1200, w = 8;
11
+ function T(e) {
12
12
  let t = parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
13
13
  return `${Math.round(e / t * 1e3) / 1e3}rem`;
14
14
  }
15
- var S = u(0), C = d(function({ columns: t, children: a, empty: c, footer: u, title: d, headingLevel: p, help: g, description: C, action: T, filters: E, tools: D, onColumnResize: O, onColumnResizeReset: k, collapsible: A = !1, defaultOpen: j = !0, flush: M = !1, label: N, minWidth: P, sizing: F = "even", className: I, ...re }, L) {
16
- var R;
17
- let z = N ?? (typeof d == "string" ? d : void 0), [B, V] = te(j), H = m(), U = A && d != null ? {
18
- open: B,
19
- onToggle: () => V((e) => !e),
15
+ var E = f(0), D = p(function({ columns: t, children: a, empty: c, footer: u, title: d, headingLevel: f, help: p, description: m, action: g, filters: y, tools: D, onColumnResize: O, onColumnResizeReset: k, collapsible: A = !1, defaultOpen: j = !0, flush: M = !1, label: N, minWidth: P, sizing: F = "even", className: I, ...L }, R) {
16
+ var z;
17
+ let B = N ?? (typeof d == "string" ? d : void 0), [V, re] = v(j), H = _(), U = A && d != null ? {
18
+ open: V,
19
+ onToggle: () => re((e) => !e),
20
20
  controls: H
21
21
  } : void 0, W = l.count(a) === 0, G = W && !!c, { hasFilters: K, hasTitleRow: q } = s({
22
22
  title: d,
23
- description: C,
24
- action: T,
25
- filters: E,
23
+ description: m,
24
+ action: g,
25
+ filters: y,
26
26
  tools: D
27
- }), J = G && !q && !K, Y = (R = t[t.length - 1]) == null ? void 0 : R.label, ie = Y != null && Y !== "" && Y !== !1, X = i(), ae = X === "body", oe = X === "list", se = n({
27
+ }), J = G && !q && !K, Y = (z = t[t.length - 1]) == null ? void 0 : z.label, ie = Y != null && Y !== "" && Y !== !1, X = i(), ae = X === "body", oe = X === "list", se = n({
28
28
  selector: ".select-table__row",
29
29
  y: 8,
30
30
  duration: .45,
31
31
  stagger: .05,
32
32
  scroll: !0
33
- }), Z = t.length ? t.map((e) => e.width ?? `minmax(${e.minWidth ?? "var(--select-table-col-min, 6.5rem)"}, ${e.grow ?? 1}fr)`).join(" ") : "1fr", Q = ee(null), ce = f((e) => {
34
- Q.current = e, typeof L == "function" ? L(e) : L && (L.current = e);
35
- }, [L]);
36
- h(() => {
33
+ }), Z = t.length ? t.map((e) => e.width ?? `minmax(${e.minWidth ?? "var(--select-table-col-min, 6.5rem)"}, ${e.grow ?? 1}fr)`).join(" ") : "1fr", Q = te(null), ce = h((e) => {
34
+ Q.current = e, typeof R == "function" ? R(e) : R && (R.current = e);
35
+ }, [R]);
36
+ ee(() => {
37
37
  let e = Q.current;
38
38
  if (!e) return;
39
39
  if (F !== "content" || !t.some((e) => e.width == null)) {
@@ -74,9 +74,9 @@ var S = u(0), C = d(function({ columns: t, children: a, empty: c, footer: u, tit
74
74
  let o = Q.current;
75
75
  o == null || o.classList.add("select-table--resizing");
76
76
  let s = a, c = (t) => {
77
- s = Math.min(b, Math.max(y, a + (t.clientX - i))), $(e, s);
77
+ s = Math.min(C, Math.max(S, a + (t.clientX - i))), $(e, s);
78
78
  }, l = () => {
79
- window.removeEventListener("pointermove", c), window.removeEventListener("pointerup", l), window.removeEventListener("pointercancel", l), o == null || o.classList.remove("select-table--resizing"), O(e, x(s));
79
+ window.removeEventListener("pointermove", c), window.removeEventListener("pointerup", l), window.removeEventListener("pointercancel", l), o == null || o.classList.remove("select-table--resizing"), O(e, T(s));
80
80
  };
81
81
  window.addEventListener("pointermove", c), window.addEventListener("pointerup", l), window.addEventListener("pointercancel", l);
82
82
  }, ue = (e) => (t) => {
@@ -87,56 +87,56 @@ var S = u(0), C = d(function({ columns: t, children: a, empty: c, footer: u, tit
87
87
  let i = (n = t.currentTarget.parentElement) == null ? void 0 : n.getBoundingClientRect();
88
88
  if (!i) return;
89
89
  t.preventDefault();
90
- let a = ne * (t.shiftKey ? 10 : 1), o = Math.min(b, Math.max(y, i.width + r * a));
91
- $(e, o), O(e, x(o));
90
+ let a = w * (t.shiftKey ? 10 : 1), o = Math.min(C, Math.max(S, i.width + r * a));
91
+ $(e, o), O(e, T(o));
92
92
  };
93
- return /* @__PURE__ */ v("div", {
93
+ return /* @__PURE__ */ x("div", {
94
94
  ref: ce,
95
- ...re,
96
- className: `select-table${J ? " select-table--empty" : ""}${ae && !M ? " select-table--nested" : ""}${oe && !M ? " select-table--inlist" : ""}${M ? " select-table--flush" : ""}${U ? ` select-table--collapsible${B ? " is-open" : ""}` : ""}${ie ? " select-table--free-last" : ""}${I ? " " + I : ""}`,
95
+ ...L,
96
+ className: `select-table${J ? " select-table--empty" : ""}${ae && !M ? " select-table--nested" : ""}${oe && !M ? " select-table--inlist" : ""}${M ? " select-table--flush" : ""}${U ? ` select-table--collapsible${V ? " is-open" : ""}` : ""}${ie ? " select-table--free-last" : ""}${I ? " " + I : ""}`,
97
97
  style: {
98
98
  "--select-table-cols": Z,
99
99
  ...P ? { "--select-table-min": P } : {}
100
100
  },
101
- children: [/* @__PURE__ */ _(o, {
101
+ children: [/* @__PURE__ */ b(o, {
102
102
  title: d,
103
- headingLevel: p,
104
- help: U ? void 0 : g,
105
- description: C,
106
- action: T,
107
- filters: U ? void 0 : E,
103
+ headingLevel: f,
104
+ help: U ? void 0 : p,
105
+ description: m,
106
+ action: g,
107
+ filters: U ? void 0 : y,
108
108
  tools: U ? void 0 : D,
109
109
  toggle: U
110
- }), /* @__PURE__ */ v(w, {
110
+ }), /* @__PURE__ */ x(ne, {
111
111
  enabled: !!U,
112
- open: B,
112
+ open: V,
113
113
  id: H,
114
114
  children: [
115
- U && (E != null || D != null) ? /* @__PURE__ */ _(o, {
116
- filters: E,
115
+ U && (y != null || D != null) ? /* @__PURE__ */ b(o, {
116
+ filters: y,
117
117
  tools: D
118
118
  }) : null,
119
- /* @__PURE__ */ _("div", {
119
+ /* @__PURE__ */ b("div", {
120
120
  className: `select-table__scroll${G ? " select-table__scroll--empty" : ""}`,
121
- children: /* @__PURE__ */ v("div", {
121
+ children: /* @__PURE__ */ x("div", {
122
122
  className: "select-table__scrollinner",
123
123
  ...G ? {} : {
124
124
  role: "table",
125
- "aria-label": z
125
+ "aria-label": B
126
126
  },
127
- children: [!G && /* @__PURE__ */ _("div", {
127
+ children: [!G && /* @__PURE__ */ b("div", {
128
128
  className: "select-table__head",
129
129
  role: "row",
130
- children: t.map((n, r) => /* @__PURE__ */ v("div", {
130
+ children: t.map((n, r) => /* @__PURE__ */ x("div", {
131
131
  role: "columnheader",
132
132
  "aria-sort": n.sortable ? n.sortDir === "asc" ? "ascending" : n.sortDir === "desc" ? "descending" : "none" : void 0,
133
133
  className: `select-table__th select-table__cell--${n.align ?? "start"}${n.tone ? ` select-table__th--${n.tone}` : ""}`,
134
- children: [n.sortable ? /* @__PURE__ */ v("button", {
134
+ children: [n.sortable ? /* @__PURE__ */ x("button", {
135
135
  type: "button",
136
136
  className: `select-table__sortbtn${n.sortDir === "asc" ? " select-table__sortbtn--asc" : ""}${n.sortDir == null ? "" : " select-table__sortbtn--active"}`,
137
137
  onClick: n.onSort,
138
- children: [n.label, /* @__PURE__ */ _(e, {})]
139
- }) : n.label, O && n.resizable !== !1 && r < t.length - 1 && /* @__PURE__ */ _("span", {
138
+ children: [n.label, /* @__PURE__ */ b(e, {})]
139
+ }) : n.label, O && n.resizable !== !1 && r < t.length - 1 && /* @__PURE__ */ b("span", {
140
140
  role: "separator",
141
141
  "aria-orientation": "vertical",
142
142
  "aria-label": "Ajustar a largura da coluna",
@@ -147,14 +147,14 @@ var S = u(0), C = d(function({ columns: t, children: a, empty: c, footer: u, tit
147
147
  onDoubleClick: k ? () => k(r) : void 0
148
148
  })]
149
149
  }, r))
150
- }), /* @__PURE__ */ _("div", {
150
+ }), /* @__PURE__ */ b("div", {
151
151
  className: "select-table__body",
152
- children: /* @__PURE__ */ _("div", {
152
+ children: /* @__PURE__ */ b("div", {
153
153
  className: "select-table__rows",
154
154
  ref: se,
155
- children: /* @__PURE__ */ _(S.Provider, {
155
+ children: /* @__PURE__ */ b(E.Provider, {
156
156
  value: t.length,
157
- children: /* @__PURE__ */ _(r, { children: W && c ? /* @__PURE__ */ _("div", {
157
+ children: /* @__PURE__ */ b(r, { children: W && c ? /* @__PURE__ */ b("div", {
158
158
  className: "select-table__empty",
159
159
  children: c
160
160
  }) : a })
@@ -163,7 +163,7 @@ var S = u(0), C = d(function({ columns: t, children: a, empty: c, footer: u, tit
163
163
  })]
164
164
  })
165
165
  }),
166
- u && /* @__PURE__ */ _("div", {
166
+ u && /* @__PURE__ */ b("div", {
167
167
  className: "select-table__footer",
168
168
  children: u
169
169
  })
@@ -171,77 +171,86 @@ var S = u(0), C = d(function({ columns: t, children: a, empty: c, footer: u, tit
171
171
  })]
172
172
  });
173
173
  });
174
- function w({ enabled: e, open: t, id: n, children: r }) {
175
- return e ? /* @__PURE__ */ _("div", {
174
+ function ne({ enabled: e, open: t, id: n, children: r }) {
175
+ return e ? /* @__PURE__ */ b("div", {
176
176
  className: "select-table__collapse",
177
177
  id: n,
178
178
  "data-open": t,
179
179
  "aria-hidden": !t,
180
- children: /* @__PURE__ */ _("div", {
180
+ children: /* @__PURE__ */ b("div", {
181
181
  className: "select-table__collapsewrap",
182
182
  children: r
183
183
  })
184
- }) : /* @__PURE__ */ _(g, { children: r });
184
+ }) : /* @__PURE__ */ b(y, { children: r });
185
185
  }
186
- var T = d(function({ name: e, secondary: t, src: n, badge: r, className: i, ...o }, s) {
187
- return /* @__PURE__ */ v("span", {
186
+ var O = p(function({ name: e, secondary: t, src: n, badge: r, className: i, ...o }, s) {
187
+ return /* @__PURE__ */ x("span", {
188
188
  ref: s,
189
189
  ...o,
190
190
  className: `select-usercell${i ? " " + i : ""}`,
191
- children: [/* @__PURE__ */ _(a, {
191
+ children: [/* @__PURE__ */ b(a, {
192
192
  name: typeof e == "string" ? e : void 0,
193
193
  src: n
194
- }), /* @__PURE__ */ v("span", {
194
+ }), /* @__PURE__ */ x("span", {
195
195
  className: "select-usercell__text",
196
- children: [r ? /* @__PURE__ */ v("span", {
196
+ children: [r ? /* @__PURE__ */ x("span", {
197
197
  className: "select-usercell__line",
198
- children: [/* @__PURE__ */ _("span", {
198
+ children: [/* @__PURE__ */ b("span", {
199
199
  className: "select-usercell__name",
200
200
  children: e
201
201
  }), r]
202
- }) : /* @__PURE__ */ _("span", {
202
+ }) : /* @__PURE__ */ b("span", {
203
203
  className: "select-usercell__name",
204
204
  children: e
205
- }), t && /* @__PURE__ */ _("span", {
205
+ }), t && /* @__PURE__ */ b("span", {
206
206
  className: "select-usercell__secondary",
207
207
  children: t
208
208
  })]
209
209
  })]
210
210
  });
211
211
  });
212
- function E({ children: e, onClick: t, expanded: n, nested: r = !1, current: i = !1, section: a = !1, muted: o = !1, className: s, ...c }) {
213
- let l = `select-table__row${t ? " select-table__row--clickable" : ""}${r ? " select-table__row--nested" : ""}${a ? " select-table__row--section" : ""}${o ? " select-table__row--muted" : ""}${n ? " is-expanded" : ""}${i ? " is-current" : ""}${s ? " " + s : ""}`;
214
- return t ? /* @__PURE__ */ _("div", {
215
- ...c,
216
- className: l,
212
+ function k(e, t) {
213
+ let n = l.toArray(e), r = (e) => m(e) && e.type !== u, i = n.findIndex((e) => r(e) && e.props.header === !0), a = i >= 0 ? i : n.findIndex(r);
214
+ if (a < 0) return e;
215
+ let o = n[a];
216
+ return n[a] = d(o, void 0, /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b("span", {
217
+ className: "select-visually-hidden",
218
+ children: `${t}: `
219
+ }), o.props.children] })), n;
220
+ }
221
+ function A({ children: e, onClick: t, expanded: n, nested: r = !1, current: i = !1, section: a = !1, muted: o = !1, tone: s, toneLabel: c, className: l, ...u }) {
222
+ let d = c ? k(e, c) : e, f = `select-table__row${t ? " select-table__row--clickable" : ""}${r ? " select-table__row--nested" : ""}${a ? " select-table__row--section" : ""}${o ? " select-table__row--muted" : ""}${s ? ` select-table__row--tone select-table__row--tone-${s}` : ""}${n ? " is-expanded" : ""}${i ? " is-current" : ""}${l ? " " + l : ""}`;
223
+ return t ? /* @__PURE__ */ b("div", {
224
+ ...u,
225
+ className: f,
217
226
  role: "row",
218
227
  tabIndex: 0,
219
228
  "aria-expanded": n,
220
229
  "aria-current": i || void 0,
221
230
  onClick: (e) => {
222
- O(e.target, e.currentTarget) || t();
231
+ M(e.target, e.currentTarget) || t();
223
232
  },
224
233
  onKeyDown: (e) => {
225
234
  e.target !== e.currentTarget || e.key !== "Enter" && e.key !== " " || (e.preventDefault(), t());
226
235
  },
227
- children: e
228
- }) : /* @__PURE__ */ _("div", {
229
- ...c,
230
- className: l,
236
+ children: d
237
+ }) : /* @__PURE__ */ b("div", {
238
+ ...u,
239
+ className: f,
231
240
  role: "row",
232
241
  "aria-current": i || void 0,
233
- children: e
242
+ children: d
234
243
  });
235
244
  }
236
- var D = "button, a[href], input, select, textarea, label, summary, [role=\"button\"], [role=\"menuitem\"], [role=\"checkbox\"], [role=\"switch\"], [data-row-click=\"ignore\"]";
237
- function O(e, t) {
245
+ var j = "button, a[href], input, select, textarea, label, summary, [role=\"button\"], [role=\"menuitem\"], [role=\"checkbox\"], [role=\"switch\"], [data-row-click=\"ignore\"]";
246
+ function M(e, t) {
238
247
  if (!(e instanceof Element) || !t.contains(e)) return !0;
239
- let n = e.closest(D);
248
+ let n = e.closest(j);
240
249
  return n !== null && n !== t && t.contains(n);
241
250
  }
242
- var k = d(function({ children: e, align: n = "start", disclosure: r, header: i = !1, span: a, wrap: o = !1, className: s, style: c, ...l }, u) {
243
- let d = p(S), f = a === "all" ? d || void 0 : a;
244
- return /* @__PURE__ */ v("div", {
251
+ var N = p(function({ children: e, align: n = "start", disclosure: r, header: i = !1, span: a, wrap: o = !1, className: s, style: c, ...l }, u) {
252
+ let d = g(E), f = a === "all" ? d || void 0 : a;
253
+ return /* @__PURE__ */ x("div", {
245
254
  ref: u,
246
255
  ...l,
247
256
  role: i ? "rowheader" : "cell",
@@ -251,14 +260,14 @@ var k = d(function({ children: e, align: n = "start", disclosure: r, header: i =
251
260
  ...c
252
261
  } : c,
253
262
  className: `select-table__td select-table__cell--${n}${o ? " select-table__td--wrap" : ""}${s ? " " + s : ""}`,
254
- children: [r ? /* @__PURE__ */ _("span", {
263
+ children: [r ? /* @__PURE__ */ b("span", {
255
264
  className: `select-table__disclosure${r === "open" ? " is-open" : ""}`,
256
265
  "aria-hidden": "true",
257
- children: r !== "none" && /* @__PURE__ */ _(t, {})
266
+ children: r !== "none" && /* @__PURE__ */ b(t, {})
258
267
  }) : null, e]
259
268
  });
260
269
  });
261
270
  //#endregion
262
- export { C as SelectTable, k as SelectTableCell, c as SelectTableEmpty, E as SelectTableRow, T as SelectUserCell };
271
+ export { D as SelectTable, N as SelectTableCell, c as SelectTableEmpty, A as SelectTableRow, O as SelectUserCell };
263
272
 
264
273
  //# sourceMappingURL=SelectTable.js.map
@@ -18,5 +18,15 @@ type SelectTabsOwnProps = {
18
18
  panelId?: string;
19
19
  };
20
20
  export type SelectTabsProps = SelectTabsOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectTabsOwnProps>;
21
+ /**
22
+ * 0.1.259: as pontas da barra que escondem abas — `start` (há abas à esquerda), `end` (à direita), `both` ou `null`
23
+ * (tudo cabe). Um pixel de folga contra o arredondamento da rolagem. PURA.
24
+ */
25
+ export declare function selectTabsOverflow(scrollLeft: number, scrollWidth: number, clientWidth: number): 'start' | 'end' | 'both' | null;
26
+ /**
27
+ * 0.1.259: até onde rolar para a aba [left, right) ficar à vista com um pedaço do vizinho; `null` quando ela já está à
28
+ * vista (ou tudo cabe). PURA.
29
+ */
30
+ export declare function selectTabScrollTarget(left: number, right: number, scrollLeft: number, clientWidth: number, scrollWidth: number): number | null;
21
31
  export declare function SelectTabs({ tabs, value, onChange, end, panelId, className, onKeyDown, ...rest }: SelectTabsProps): import("react").JSX.Element;
22
32
  export {};
@@ -2,68 +2,106 @@ import { formatSelectNumber as e, useSelectLocale as t } from "./SelectLocale.js
2
2
  import { useLayoutEffect as n, useRef as r, useState as i } from "react";
3
3
  import { jsx as a, jsxs as o } from "react/jsx-runtime";
4
4
  //#region src/SelectTabs.tsx
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({
5
+ var s = 24;
6
+ function c(e, t, n) {
7
+ if (t - n <= 1) return null;
8
+ let r = e > 1, i = e + n < t - 1;
9
+ return r && i ? "both" : r ? "start" : i ? "end" : null;
10
+ }
11
+ function l(e, t, n, r, i) {
12
+ if (i - r <= 1) return null;
13
+ let a = i - r;
14
+ return e < n + s && n > 0 ? Math.max(0, Math.min(a, e - s)) : t > n + r - s && n < a ? Math.max(0, Math.min(a, t + s - r)) : null;
15
+ }
16
+ function u(e, t) {
17
+ var n, r;
18
+ let i = e.querySelector(".select-tab--active");
19
+ if (!i) return;
20
+ let a = i.offsetLeft, o = l(a, a + i.offsetWidth, e.scrollLeft, e.clientWidth, e.scrollWidth);
21
+ if (o === null) return;
22
+ let s = typeof window < "u" && ((n = (r = window).matchMedia) == null ? void 0 : n.call(r, "(prefers-reduced-motion: reduce)").matches);
23
+ t && !s && typeof e.scrollTo == "function" ? e.scrollTo({
24
+ left: o,
25
+ behavior: "smooth"
26
+ }) : e.scrollLeft = o;
27
+ }
28
+ function d({ tabs: s, value: l, onChange: d, end: f, panelId: p, className: m, onKeyDown: h, ...g }) {
29
+ let _ = t(), v = r(null), y = r([]), [b, x] = i({
7
30
  left: 0,
8
31
  width: 0
9
- }), b = s.findIndex((e) => e.id === c), x = s.map((e) => e.id).join("\0");
32
+ }), S = s.findIndex((e) => e.id === l), C = s.map((e) => e.id).join("\0"), w = r(!1);
10
33
  n(() => {
11
- let e = g.current;
34
+ let e = v.current;
35
+ e && (u(e, w.current), w.current = !0);
36
+ }, [l, C]), n(() => {
37
+ let e = v.current;
38
+ if (!e) return;
39
+ let t = () => {
40
+ let t = c(e.scrollLeft, e.scrollWidth, e.clientWidth);
41
+ t ? e.setAttribute("data-overflow", t) : e.removeAttribute("data-overflow");
42
+ };
43
+ t(), e.addEventListener("scroll", t, { passive: !0 });
44
+ let n = typeof ResizeObserver < "u" ? new ResizeObserver(t) : null;
45
+ return n == null || n.observe(e), e.querySelectorAll(".select-tab").forEach((e) => n == null ? void 0 : n.observe(e)), () => {
46
+ e.removeEventListener("scroll", t), n == null || n.disconnect();
47
+ };
48
+ }, [s.length, C]), n(() => {
49
+ let e = v.current;
12
50
  if (!e) return;
13
51
  let t = () => {
14
52
  let t = e.querySelector(".select-tab--active");
15
53
  if (!t) {
16
- y((e) => e.width === 0 ? e : {
54
+ x((e) => e.width === 0 ? e : {
17
55
  left: e.left,
18
56
  width: 0
19
57
  });
20
58
  return;
21
59
  }
22
60
  let n = t.offsetLeft, r = t.offsetWidth;
23
- y((e) => e.left === n && e.width === r ? e : {
61
+ x((e) => e.left === n && e.width === r ? e : {
24
62
  left: n,
25
63
  width: r
26
64
  });
27
65
  };
28
66
  t();
29
67
  let n = typeof ResizeObserver < "u" ? new ResizeObserver(t) : null;
30
- return n == null || n.observe(e), _.current.forEach((e) => e && (n == null ? void 0 : n.observe(e))), () => n == null ? void 0 : n.disconnect();
68
+ return n == null || n.observe(e), y.current.forEach((e) => e && (n == null ? void 0 : n.observe(e))), () => n == null ? void 0 : n.disconnect();
31
69
  }, [
32
- c,
70
+ l,
33
71
  s.length,
34
- x
72
+ C
35
73
  ]);
36
- let S = (e) => {
74
+ let T = (e) => {
37
75
  var t;
38
- if (p == null || p(e), e.defaultPrevented || !s.length) return;
39
- let n = _.current.findIndex((t) => t === e.target);
76
+ if (h == null || h(e), e.defaultPrevented || !s.length) return;
77
+ let n = y.current.findIndex((t) => t === e.target);
40
78
  if (n < 0) return;
41
79
  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`
80
+ i < 0 || (e.preventDefault(), (t = y.current[i]) == null || t.focus(), s[i].id !== l && d(s[i].id));
81
+ }, E = {
82
+ "--tab-ind-left": `${b.left}px`,
83
+ "--tab-ind-width": `${b.width}px`
46
84
  };
47
85
  return /* @__PURE__ */ o("div", {
48
- ...m,
49
- className: `select-tabs${f ? " " + f : ""}`,
86
+ ...g,
87
+ className: `select-tabs${m ? " " + m : ""}`,
50
88
  role: "tablist",
51
- ref: g,
52
- style: C,
53
- onKeyDown: S,
89
+ ref: v,
90
+ style: E,
91
+ onKeyDown: T,
54
92
  children: [s.map((t, n) => {
55
- let r = t.id === c;
93
+ let r = t.id === l;
56
94
  return /* @__PURE__ */ o("button", {
57
95
  ref: (e) => {
58
- _.current[n] = e;
96
+ y.current[n] = e;
59
97
  },
60
98
  type: "button",
61
99
  role: "tab",
62
100
  "aria-selected": r,
63
- "aria-controls": d,
64
- tabIndex: r || b < 0 && n === 0 ? 0 : -1,
101
+ "aria-controls": p,
102
+ tabIndex: r || S < 0 && n === 0 ? 0 : -1,
65
103
  className: `select-tab${r ? " select-tab--active" : ""}`,
66
- onClick: () => l(t.id),
104
+ onClick: () => d(t.id),
67
105
  children: [
68
106
  t.dot && /* @__PURE__ */ a("span", {
69
107
  className: `select-tab__dot select-tab__dot--${t.dot}`,
@@ -72,17 +110,17 @@ function s({ tabs: s, value: c, onChange: l, end: u, panelId: d, className: f, o
72
110
  t.label,
73
111
  t.count !== void 0 && /* @__PURE__ */ a("span", {
74
112
  className: "select-tab__count",
75
- children: e(t.count, h)
113
+ children: e(t.count, _)
76
114
  })
77
115
  ]
78
116
  }, t.id);
79
- }), u != null && /* @__PURE__ */ a("div", {
117
+ }), f != null && /* @__PURE__ */ a("div", {
80
118
  className: "select-tabs__end",
81
- children: u
119
+ children: f
82
120
  })]
83
121
  });
84
122
  }
85
123
  //#endregion
86
- export { s as SelectTabs };
124
+ export { d as SelectTabs, l as selectTabScrollTarget, c as selectTabsOverflow };
87
125
 
88
126
  //# sourceMappingURL=SelectTabs.js.map