@selectwin/kit 0.1.259 → 0.1.260

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.
@@ -1,113 +1,132 @@
1
- import { forwardRef as e, useId as t, useLayoutEffect as n, useRef as r, useState as i } from "react";
2
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
1
+ import { revealInTrack as e, watchTrackOverflow as t } from "./internal/scrollReveal.js";
2
+ import { forwardRef as n, useCallback as r, useId as i, useLayoutEffect as a, useRef as o, useState as s } from "react";
3
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
3
4
  //#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, variant: h = "track", semantics: g = h === "chips" ? "radio" : "tabs", size: _ = "md", className: v, ...y }, b) {
5
- let x = t(), S = Math.max(0, c.findIndex((t) => t.value === e)), C = r([]), [w, T] = i(null), E = g === "radio", D = c.map((e) => e.count ?? "").join(",");
6
- n(() => {
5
+ var u = n(function({ value: n, onChange: u, options: d, ariaLabel: f, fullWidth: p = !1, label: m, hint: h, disabled: g = !1, error: _, variant: v = "track", semantics: y = v === "chips" ? "radio" : "tabs", size: b = "md", scroll: x = !1, selected: S = "outline", className: C, ...w }, T) {
6
+ let E = i(), D = Math.max(0, d.findIndex((e) => e.value === n)), O = o([]), [k, A] = s(null), j = y === "radio", M = d.map((e) => e.count ?? "").join(",");
7
+ a(() => {
7
8
  let e = () => {
8
- let e = C.current[S];
9
+ let e = O.current[D];
9
10
  if (!e) return;
10
11
  let t = {
11
12
  left: e.offsetLeft,
12
13
  width: e.offsetWidth
13
14
  };
14
- T((e) => e && e.left === t.left && e.width === t.width ? e : t);
15
+ A((e) => e && e.left === t.left && e.width === t.width ? e : t);
15
16
  };
16
17
  e();
17
18
  let t = typeof ResizeObserver < "u" ? new ResizeObserver(e) : null;
18
- return C.current.forEach((e) => e && (t == null ? void 0 : t.observe(e))), () => t == null ? void 0 : t.disconnect();
19
+ return O.current.forEach((e) => e && (t == null ? void 0 : t.observe(e))), () => t == null ? void 0 : t.disconnect();
19
20
  }, [
20
- S,
21
- c.length,
22
- D
21
+ D,
22
+ d.length,
23
+ M
23
24
  ]);
24
- let O = w ? {
25
- left: w.left,
26
- width: w.width,
25
+ let N = x && v === "chips", P = o(null), F = o(!1);
26
+ a(() => {
27
+ let t = P.current;
28
+ N && t && (e(t, O.current[D] ?? null, F.current), F.current = !0);
29
+ }, [
30
+ N,
31
+ D,
32
+ d.length
33
+ ]), a(() => {
34
+ let e = P.current;
35
+ if (N && e) return t(e, O.current.filter((e) => e !== null));
36
+ }, [
37
+ N,
38
+ d.length,
39
+ M
40
+ ]);
41
+ let I = m != null, L = r((e) => {
42
+ P.current = e, !I && (typeof T == "function" ? T(e) : T && (T.current = e));
43
+ }, [T, I]), R = k ? {
44
+ left: k.left,
45
+ width: k.width,
27
46
  opacity: 1
28
- } : { opacity: 0 }, k = d == null ? y : {}, A = (t) => {
29
- var n, r;
30
- if ((n = k.onKeyDown) == null || n.call(k, t), t.defaultPrevented || p || !c.length) return;
31
- let i = C.current.findIndex((e) => e === t.target);
47
+ } : { opacity: 0 }, z = m == null ? w : {}, B = (e) => {
48
+ var t, r;
49
+ if ((t = z.onKeyDown) == null || t.call(z, e), e.defaultPrevented || g || !d.length) return;
50
+ let i = O.current.findIndex((t) => t === e.target);
32
51
  if (i < 0) return;
33
- let a = t.key === "ArrowRight" || E && t.key === "ArrowDown", o = t.key === "ArrowLeft" || E && 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 = C.current[l]) == null || r.focus(), c[l].value !== e && s(c[l].value));
35
- }, j = /* @__PURE__ */ o("div", {
36
- ref: d == null ? b : void 0,
37
- ...k,
38
- className: `select-segmented${h === "chips" ? " select-segmented--chips" : ""}${u ? " select-segmented--full" : ""}${_ === "sm" ? " select-segmented--sm" : ""}${p ? " select-segmented--disabled" : ""}${m != null && m !== !1 ? " select-segmented--error" : ""}${d == null && v ? " " + v : ""}`,
39
- role: E ? "radiogroup" : "tablist",
40
- "aria-label": l,
41
- "aria-labelledby": d != null && !l ? x : void 0,
42
- "aria-disabled": p || void 0,
43
- onKeyDown: A,
44
- children: [h === "chips" ? null : /* @__PURE__ */ a("span", {
52
+ let a = e.key === "ArrowRight" || j && e.key === "ArrowDown", o = e.key === "ArrowLeft" || j && e.key === "ArrowUp", s = a ? (i + 1) % d.length : o ? (i - 1 + d.length) % d.length : e.key === "Home" ? 0 : e.key === "End" ? d.length - 1 : -1;
53
+ s < 0 || (e.preventDefault(), (r = O.current[s]) == null || r.focus(), d[s].value !== n && u(d[s].value));
54
+ }, V = /* @__PURE__ */ l("div", {
55
+ ref: L,
56
+ ...z,
57
+ className: `select-segmented${v === "chips" ? " select-segmented--chips" : ""}${N ? " select-segmented--scroll" : ""}${v === "chips" && S === "solid" ? " select-segmented--solid" : ""}${p ? " select-segmented--full" : ""}${b === "sm" ? " select-segmented--sm" : ""}${g ? " select-segmented--disabled" : ""}${_ != null && _ !== !1 ? " select-segmented--error" : ""}${m == null && C ? " " + C : ""}`,
58
+ role: j ? "radiogroup" : "tablist",
59
+ "aria-label": f,
60
+ "aria-labelledby": m != null && !f ? E : void 0,
61
+ "aria-disabled": g || void 0,
62
+ onKeyDown: B,
63
+ children: [v === "chips" ? null : /* @__PURE__ */ c("span", {
45
64
  className: "select-segmented__pill",
46
65
  "aria-hidden": "true",
47
- style: O
48
- }), c.map((t, n) => {
49
- let r = t.value === e, i = !!t.count && t.count > 0, c = t.title && i ? `${t.title}, ${t.countLabel ?? t.count}` : t.title;
50
- return /* @__PURE__ */ o("button", {
66
+ style: R
67
+ }), d.map((e, t) => {
68
+ let r = e.value === n, i = !!e.count && e.count > 0, a = e.title && i ? `${e.title}, ${e.countLabel ?? e.count}` : e.title;
69
+ return /* @__PURE__ */ l("button", {
51
70
  ref: (e) => {
52
- C.current[n] = e;
71
+ O.current[t] = e;
53
72
  },
54
73
  type: "button",
55
- role: E ? "radio" : "tab",
56
- "aria-selected": E ? void 0 : r,
57
- "aria-checked": E ? r : void 0,
58
- tabIndex: n === S ? 0 : -1,
74
+ role: j ? "radio" : "tab",
75
+ "aria-selected": j ? void 0 : r,
76
+ "aria-checked": j ? r : void 0,
77
+ tabIndex: t === D ? 0 : -1,
59
78
  className: `select-segmented__item${r ? " select-segmented__item--active" : ""}`,
60
- title: t.title,
61
- "aria-label": c,
62
- disabled: p,
63
- onClick: () => s(t.value),
79
+ title: e.title,
80
+ "aria-label": a,
81
+ disabled: g,
82
+ onClick: () => u(e.value),
64
83
  children: [
65
- t.icon != null && t.icon !== !1 ? /* @__PURE__ */ a("span", {
84
+ e.icon != null && e.icon !== !1 ? /* @__PURE__ */ c("span", {
66
85
  className: "select-segmented__icon",
67
86
  "aria-hidden": "true",
68
- children: t.icon
87
+ children: e.icon
69
88
  }) : null,
70
- t.label,
71
- i ? /* @__PURE__ */ a("span", {
89
+ e.label,
90
+ i ? /* @__PURE__ */ c("span", {
72
91
  className: "select-segmented__count",
73
- "aria-hidden": t.title ? !0 : void 0,
74
- children: t.count
92
+ "aria-hidden": e.title ? !0 : void 0,
93
+ children: e.count
75
94
  }) : null
76
95
  ]
77
- }, t.value);
96
+ }, e.value);
78
97
  })]
79
- }), M = m != null && m !== !1 && m !== "";
80
- return d == null && !M ? j : d == null ? /* @__PURE__ */ o("div", {
98
+ }), H = _ != null && _ !== !1 && _ !== "";
99
+ return m == null && !H ? V : m == null ? /* @__PURE__ */ l("div", {
81
100
  className: "select-field",
82
- children: [j, /* @__PURE__ */ a("p", {
101
+ children: [V, /* @__PURE__ */ c("p", {
83
102
  className: "select-field__error",
84
- children: m
103
+ children: _
85
104
  })]
86
- }) : /* @__PURE__ */ o("div", {
87
- ref: b,
88
- ...y,
89
- className: `select-field${v ? " " + v : ""}`,
105
+ }) : /* @__PURE__ */ l("div", {
106
+ ref: T,
107
+ ...w,
108
+ className: `select-field${C ? " " + C : ""}`,
90
109
  children: [
91
- /* @__PURE__ */ a("div", {
110
+ /* @__PURE__ */ c("div", {
92
111
  className: "select-field__labelrow",
93
- children: /* @__PURE__ */ a("span", {
112
+ children: /* @__PURE__ */ c("span", {
94
113
  className: "select-field__label",
95
- id: x,
96
- children: d
114
+ id: E,
115
+ children: m
97
116
  })
98
117
  }),
99
- j,
100
- M ? /* @__PURE__ */ a("p", {
118
+ V,
119
+ H ? /* @__PURE__ */ c("p", {
101
120
  className: "select-field__error",
102
- children: m
103
- }) : f != null && /* @__PURE__ */ a("p", {
121
+ children: _
122
+ }) : h != null && /* @__PURE__ */ c("p", {
104
123
  className: "select-field__hint",
105
- children: f
124
+ children: h
106
125
  })
107
126
  ]
108
127
  });
109
128
  });
110
129
  //#endregion
111
- export { s as SelectSegmented };
130
+ export { u as SelectSegmented };
112
131
 
113
132
  //# sourceMappingURL=SelectSegmented.js.map
@@ -1,4 +1,5 @@
1
1
  import { ReactNode, ComponentPropsWithoutRef } from 'react';
2
+ import { selectScrollOverflow, selectScrollTarget } from './internal/scrollReveal';
2
3
  export interface SelectTab {
3
4
  id: string;
4
5
  label: ReactNode;
@@ -19,14 +20,10 @@ type SelectTabsOwnProps = {
19
20
  };
20
21
  export type SelectTabsProps = SelectTabsOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectTabsOwnProps>;
21
22
  /**
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.
23
+ * 0.1.259: as pontas da barra que escondem abas e até onde rolar para a aba ficar à vista — as contas moram em
24
+ * `internal/scrollReveal` desde a 0.1.260 (as fichas que rolam usam as mesmas); os nomes daqui seguem. PURAS.
24
25
  */
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;
26
+ export declare const selectTabsOverflow: typeof selectScrollOverflow;
27
+ export declare const selectTabScrollTarget: typeof selectScrollTarget;
31
28
  export declare function SelectTabs({ tabs, value, onChange, end, panelId, className, onKeyDown, ...rest }: SelectTabsProps): import("react").JSX.Element;
32
29
  export {};
@@ -1,51 +1,20 @@
1
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";
2
+ import { revealInTrack as n, watchTrackOverflow as r } from "./internal/scrollReveal.js";
3
+ import { useLayoutEffect as i, useRef as a, useState as o } from "react";
4
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
4
5
  //#region src/SelectTabs.tsx
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({
6
+ function l({ tabs: l, value: u, onChange: d, end: f, panelId: p, className: m, onKeyDown: h, ...g }) {
7
+ let _ = t(), v = a(null), y = a([]), [b, x] = o({
30
8
  left: 0,
31
9
  width: 0
32
- }), S = s.findIndex((e) => e.id === l), C = s.map((e) => e.id).join("\0"), w = r(!1);
33
- n(() => {
10
+ }), S = l.findIndex((e) => e.id === u), C = l.map((e) => e.id).join("\0"), w = a(!1);
11
+ i(() => {
34
12
  let e = v.current;
35
- e && (u(e, w.current), w.current = !0);
36
- }, [l, C]), n(() => {
13
+ e && (n(e, e.querySelector(".select-tab--active"), w.current), w.current = !0);
14
+ }, [u, C]), i(() => {
37
15
  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(() => {
16
+ if (e) return r(e, e.querySelectorAll(".select-tab"));
17
+ }, [l.length, C]), i(() => {
49
18
  let e = v.current;
50
19
  if (!e) return;
51
20
  let t = () => {
@@ -67,31 +36,31 @@ function d({ tabs: s, value: l, onChange: d, end: f, panelId: p, className: m, o
67
36
  let n = typeof ResizeObserver < "u" ? new ResizeObserver(t) : null;
68
37
  return n == null || n.observe(e), y.current.forEach((e) => e && (n == null ? void 0 : n.observe(e))), () => n == null ? void 0 : n.disconnect();
69
38
  }, [
70
- l,
71
- s.length,
39
+ u,
40
+ l.length,
72
41
  C
73
42
  ]);
74
43
  let T = (e) => {
75
44
  var t;
76
- if (h == null || h(e), e.defaultPrevented || !s.length) return;
45
+ if (h == null || h(e), e.defaultPrevented || !l.length) return;
77
46
  let n = y.current.findIndex((t) => t === e.target);
78
47
  if (n < 0) return;
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;
80
- i < 0 || (e.preventDefault(), (t = y.current[i]) == null || t.focus(), s[i].id !== l && d(s[i].id));
48
+ let r = l.length - 1, i = e.key === "ArrowRight" ? (n + 1) % l.length : e.key === "ArrowLeft" ? (n - 1 + l.length) % l.length : e.key === "Home" ? 0 : e.key === "End" ? r : -1;
49
+ i < 0 || (e.preventDefault(), (t = y.current[i]) == null || t.focus(), l[i].id !== u && d(l[i].id));
81
50
  }, E = {
82
51
  "--tab-ind-left": `${b.left}px`,
83
52
  "--tab-ind-width": `${b.width}px`
84
53
  };
85
- return /* @__PURE__ */ o("div", {
54
+ return /* @__PURE__ */ c("div", {
86
55
  ...g,
87
56
  className: `select-tabs${m ? " " + m : ""}`,
88
57
  role: "tablist",
89
58
  ref: v,
90
59
  style: E,
91
60
  onKeyDown: T,
92
- children: [s.map((t, n) => {
93
- let r = t.id === l;
94
- return /* @__PURE__ */ o("button", {
61
+ children: [l.map((t, n) => {
62
+ let r = t.id === u;
63
+ return /* @__PURE__ */ c("button", {
95
64
  ref: (e) => {
96
65
  y.current[n] = e;
97
66
  },
@@ -103,24 +72,24 @@ function d({ tabs: s, value: l, onChange: d, end: f, panelId: p, className: m, o
103
72
  className: `select-tab${r ? " select-tab--active" : ""}`,
104
73
  onClick: () => d(t.id),
105
74
  children: [
106
- t.dot && /* @__PURE__ */ a("span", {
75
+ t.dot && /* @__PURE__ */ s("span", {
107
76
  className: `select-tab__dot select-tab__dot--${t.dot}`,
108
77
  "aria-hidden": "true"
109
78
  }),
110
79
  t.label,
111
- t.count !== void 0 && /* @__PURE__ */ a("span", {
80
+ t.count !== void 0 && /* @__PURE__ */ s("span", {
112
81
  className: "select-tab__count",
113
82
  children: e(t.count, _)
114
83
  })
115
84
  ]
116
85
  }, t.id);
117
- }), f != null && /* @__PURE__ */ a("div", {
86
+ }), f != null && /* @__PURE__ */ s("div", {
118
87
  className: "select-tabs__end",
119
88
  children: f
120
89
  })]
121
90
  });
122
91
  }
123
92
  //#endregion
124
- export { d as SelectTabs, l as selectTabScrollTarget, c as selectTabsOverflow };
93
+ export { l as SelectTabs };
125
94
 
126
95
  //# sourceMappingURL=SelectTabs.js.map
package/dist/index.d.ts CHANGED
@@ -74,6 +74,8 @@ export { SelectDeadlineBadge, selectDeadlineText, selectDurationText } from './S
74
74
  export type { SelectDeadlineBadgeProps, SelectDeadlineState } from './SelectDeadlineBadge';
75
75
  export { SelectBulkBar } from './SelectBulkBar';
76
76
  export type { SelectBulkBarProps } from './SelectBulkBar';
77
+ export { SelectComposerNotice } from './SelectComposerNotice';
78
+ export type { SelectComposerNoticeProps } from './SelectComposerNotice';
77
79
  export { SelectPage, SelectPageBackProvider, SelectPageHeader } from './SelectPage';
78
80
  export { SelectFormLayout } from './SelectFormLayout';
79
81
  export { SelectSkeleton } from './SelectSkeleton';