@kapiuara/ui 0.13.0 → 0.14.0

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 +5 -0
  2. package/dist/components/chat/KapiChatDivider.d.ts +7 -3
  3. package/dist/components/chat/KapiChatDivider.js +6 -6
  4. package/dist/components/chat/index.d.ts +1 -1
  5. package/dist/components/display/KapiAnnotation.js +4 -4
  6. package/dist/components/feedback/KapiFab.js +4 -4
  7. package/dist/components/feedback/KapiToastContainer.js +5 -5
  8. package/dist/components/feedback/KapiTour.js +4 -4
  9. package/dist/components/inputs/KapiDatePicker.js +124 -122
  10. package/dist/components/inputs/KapiDateRangePicker.js +138 -136
  11. package/dist/components/inputs/KapiFacetedSearch.js +8 -8
  12. package/dist/components/inputs/KapiMaskedInput.d.ts +8 -3
  13. package/dist/components/inputs/KapiMaskedInput.js +66 -53
  14. package/dist/components/inputs/KapiNumberStepper.js +29 -29
  15. package/dist/components/inputs/KapiRating.js +61 -59
  16. package/dist/components/inputs/KapiSegmented.js +68 -58
  17. package/dist/components/inputs/KapiSelect.js +204 -194
  18. package/dist/components/inputs/KapiTagInput.js +82 -80
  19. package/dist/components/inputs/misuseWarnings.d.ts +37 -0
  20. package/dist/components/inputs/misuseWarnings.js +36 -0
  21. package/dist/components/inputs/numberStepLogic.d.ts +10 -0
  22. package/dist/components/inputs/numberStepLogic.js +16 -7
  23. package/dist/components/layout/KapiAccountMenu.js +4 -4
  24. package/dist/components/navigation/CtxSlidingList.js +4 -4
  25. package/dist/components/navigation/KapiTabs.js +58 -51
  26. package/dist/components/navigation/KapiTree.js +5 -5
  27. package/dist/components/overlays/KapiContextMenu.js +4 -4
  28. package/dist/components/overlays/KapiMenuButton.js +4 -4
  29. package/dist/components/overlays/KapiPhotoView.js +1 -1
  30. package/dist/components/overlays/KapiPopover.js +4 -4
  31. package/dist/components/overlays/KapiShapeSheet.js +4 -4
  32. package/dist/components/overlays/KapiTooltip.js +1 -1
  33. package/dist/css/components/chat/chat.css +1 -1
  34. package/dist/hooks/useControllableState.d.ts +6 -2
  35. package/dist/hooks/useControllableState.js +14 -11
  36. package/dist/hooks/useFormReset.d.ts +22 -0
  37. package/dist/hooks/useFormReset.js +17 -0
  38. package/dist/kapi.css +1 -1
  39. package/dist/kapi.layered.css +1 -1
  40. package/package.json +5 -2
@@ -1,122 +1,124 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/inputs/KapiTagInput.css";
3
3
  import { assignRef as e, fieldControlProps as t, focusLeaves as n, joinIds as r, resolveReadOnly as i } from "./fieldLogic.js";
4
- import { useOwnField as ee } from "./ownField.js";
5
- import { useLabels as te } from "../locale/KapiLocaleProvider.js";
6
- import { joinClasses as a } from "../rootProps.js";
7
- import { useControllableState as o } from "../../hooks/useControllableState.js";
4
+ import { useOwnField as a } from "./ownField.js";
5
+ import { useLabels as o } from "../locale/KapiLocaleProvider.js";
6
+ import { joinClasses as s } from "../rootProps.js";
7
+ import { useControllableState as ee } from "../../hooks/useControllableState.js";
8
+ import { useFormReset as te } from "../../hooks/useFormReset.js";
9
+ import { useMergedRefs as ne } from "../../hooks/mergeRefs.js";
8
10
  /* empty css */
9
- import { addTags as s, hasSeparator as c, removeTagAt as l, spliceText as ne, splitDraft as re, splitTags as u } from "./tagInputLogic.js";
11
+ import { addTags as re, hasSeparator as c, removeTagAt as l, spliceText as u, splitDraft as d, splitTags as f } from "./tagInputLogic.js";
10
12
  import { KapiTag as ie } from "../display/KapiTag.js";
11
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
12
- import { useCallback as p, useId as m, useRef as h, useState as g } from "react";
13
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
14
+ import { useCallback as ae, useId as oe, useRef as h, useState as g } from "react";
13
15
  //#region src/components/inputs/KapiTagInput.tsx
14
16
  var _ = {
15
17
  remove: "Quitar",
16
18
  duplicate: "Ya está en la lista:",
17
19
  max: "Llegaste al máximo de"
18
- }, v = ({ size: e = "md", invalid: t, disabled: n, readOnly: r, className: i }) => a("kapi-taginput", e !== "md" && `kapi-taginput--${e}`, t && "kapi-taginput--err", n && "kapi-taginput--disabled", r && "kapi-taginput--readonly", i);
19
- function y({ value: a, defaultValue: y = [], onChange: ae, validate: oe, maxTags: b, allowDuplicates: x, caseSensitive: S, placeholder: C, disabled: w = !1, size: T = "md", name: E, id: D, invalid: O, required: k, label: se, help: ce, fieldClassName: le, readOnly: A, "aria-label": ue, "aria-labelledby": j, "aria-describedby": M, onBlur: N, ref: P, labels: F, className: I, onClick: L, ...R }) {
20
- let z = te("tagInput", _, F), B = ee({
21
- id: D,
22
- label: se,
23
- help: ce,
24
- required: k,
25
- invalid: O,
26
- readOnly: A,
27
- fieldClassName: le
28
- }), V = B.field, H = i(A, V), U = m(), [W, G] = o(a, y, ae), [K, q] = g(""), [J, Y] = g(null), X = h(null), Z = h(null), de = p((t) => {
29
- Z.current = t, e(P, t);
30
- }, [P]), fe = (e) => e.reason === "invalid" ? e.message : e.reason === "duplicate" ? `${z.duplicate} ${e.tag}` : `${z.max} ${b}`, Q = (e, t = "") => {
31
- let { values: n, rejected: r } = s(W, e, {
32
- validate: oe,
33
- maxTags: b,
34
- allowDuplicates: x,
35
- caseSensitive: S
20
+ }, v = ({ size: e = "md", invalid: t, disabled: n, readOnly: r, className: i }) => s("kapi-taginput", e !== "md" && `kapi-taginput--${e}`, t && "kapi-taginput--err", n && "kapi-taginput--disabled", r && "kapi-taginput--readonly", i);
21
+ function y({ value: s, defaultValue: y = [], onChange: b, validate: se, maxTags: x, allowDuplicates: ce, caseSensitive: le, placeholder: ue, disabled: S = !1, size: C = "md", name: w, id: T, invalid: E, required: D, label: de, help: fe, fieldClassName: pe, readOnly: O, "aria-label": k, "aria-labelledby": A, "aria-describedby": j, onBlur: M, ref: N, labels: P, className: F, onClick: I, ...L }) {
22
+ let R = o("tagInput", _, P), z = a({
23
+ id: T,
24
+ label: de,
25
+ help: fe,
26
+ required: D,
27
+ invalid: E,
28
+ readOnly: O,
29
+ fieldClassName: pe
30
+ }), B = z.field, V = i(O, B), H = oe(), [U, W, , me] = ee(s, y, b), [G, K] = g(""), [q, J] = g(null), Y = h(null), he = ne(Y, te(me)), X = h(null), ge = ae((t) => {
31
+ X.current = t, e(N, t);
32
+ }, [N]), _e = (e) => e.reason === "invalid" ? e.message : e.reason === "duplicate" ? `${R.duplicate} ${e.tag}` : `${R.max} ${x}`, Z = (e, t = "") => {
33
+ let { values: n, rejected: r } = re(U, e, {
34
+ validate: se,
35
+ maxTags: x,
36
+ allowDuplicates: ce,
37
+ caseSensitive: le
36
38
  });
37
- n.length !== W.length && G(n), Y(r[0] ? fe(r[0]) : null), q([...r.map((e) => e.tag), t].filter(Boolean).join(", "));
38
- }, pe = (e) => {
39
+ n.length !== U.length && W(n), J(r[0] ? _e(r[0]) : null), K([...r.map((e) => e.tag), t].filter(Boolean).join(", "));
40
+ }, Q = (e) => {
39
41
  let t = e.target.value;
40
- if (Y(null), !c(t)) {
41
- q(t);
42
+ if (J(null), !c(t)) {
43
+ K(t);
42
44
  return;
43
45
  }
44
- let { complete: n, tail: r } = re(t);
45
- Q(n, r);
46
- }, me = (e) => {
47
- w || H || (e.key === "Enter" && K.trim() ? (e.preventDefault(), Q(u(K))) : e.key === "Backspace" && K === "" && W.length > 0 && (e.preventDefault(), Y(null), G(l(W, W.length - 1))));
48
- }, he = (e) => {
49
- if (H) return;
46
+ let { complete: n, tail: r } = d(t);
47
+ Z(n, r);
48
+ }, ve = (e) => {
49
+ S || V || (e.key === "Enter" && G.trim() ? (e.preventDefault(), Z(f(G))) : e.key === "Backspace" && G === "" && U.length > 0 && (e.preventDefault(), J(null), W(l(U, U.length - 1))));
50
+ }, ye = (e) => {
51
+ if (V) return;
50
52
  let t = e.clipboardData.getData("text");
51
53
  if (!c(t)) return;
52
54
  e.preventDefault();
53
- let n = e.currentTarget, r = ne(K, n.selectionStart ?? K.length, n.selectionEnd ?? K.length, t);
54
- Q(u(r));
55
- }, ge = (e) => {
56
- n(e.relatedTarget, X.current) && (K.trim() && !H && Q(u(K)), N?.(e));
57
- }, _e = (e) => {
58
- L?.(e), !(e.defaultPrevented || w) && (e.target.closest("button, input") || Z.current?.focus());
59
- }, ve = (e) => {
60
- Y(null), G(l(W, e)), Z.current?.focus();
61
- }, $ = J !== null || (O ?? V?.invalid ?? !1);
62
- return B.wrap(/* @__PURE__ */ f("div", {
63
- ...R,
64
- ref: X,
55
+ let n = e.currentTarget, r = u(G, n.selectionStart ?? G.length, n.selectionEnd ?? G.length, t);
56
+ Z(f(r));
57
+ }, be = (e) => {
58
+ n(e.relatedTarget, Y.current) && (G.trim() && !V && Z(f(G)), M?.(e));
59
+ }, xe = (e) => {
60
+ I?.(e), !(e.defaultPrevented || S) && (e.target.closest("button, input") || X.current?.focus());
61
+ }, Se = (e) => {
62
+ J(null), W(l(U, e)), X.current?.focus();
63
+ }, $ = q !== null || (E ?? B?.invalid ?? !1);
64
+ return z.wrap(/* @__PURE__ */ m("div", {
65
+ ...L,
66
+ ref: he,
65
67
  className: v({
66
- size: T,
68
+ size: C,
67
69
  invalid: $,
68
- disabled: w,
69
- readOnly: H,
70
- className: I
70
+ disabled: S,
71
+ readOnly: V,
72
+ className: F
71
73
  }),
72
- onClick: _e,
73
- onBlur: ge,
74
+ onClick: xe,
75
+ onBlur: be,
74
76
  children: [
75
- /* @__PURE__ */ f("div", {
77
+ /* @__PURE__ */ m("div", {
76
78
  className: "kapi-taginput__box",
77
- children: [W.length > 0 && /* @__PURE__ */ d("ul", {
79
+ children: [U.length > 0 && /* @__PURE__ */ p("ul", {
78
80
  className: "kapi-taginput__tags",
79
- children: W.map((e, t) => /* @__PURE__ */ d("li", {
81
+ children: U.map((e, t) => /* @__PURE__ */ p("li", {
80
82
  className: "kapi-taginput__item",
81
- children: /* @__PURE__ */ d(ie, {
83
+ children: /* @__PURE__ */ p(ie, {
82
84
  tone: "primary",
83
- size: T === "sm" ? "sm" : "md",
84
- onRemove: w || H ? void 0 : () => ve(t),
85
- removeLabel: `${z.remove} ${e}`,
85
+ size: C === "sm" ? "sm" : "md",
86
+ onRemove: S || V ? void 0 : () => Se(t),
87
+ removeLabel: `${R.remove} ${e}`,
86
88
  children: e
87
89
  })
88
90
  }, `${t}-${e}`))
89
- }), /* @__PURE__ */ d("input", {
90
- ref: de,
91
+ }), /* @__PURE__ */ p("input", {
92
+ ref: ge,
91
93
  type: "text",
92
94
  className: "kapi-taginput__input",
93
- ...t(V, {
94
- id: D,
95
- describedBy: r(J !== null && U, M),
95
+ ...t(B, {
96
+ id: T,
97
+ describedBy: r(q !== null && H, j),
96
98
  invalid: $,
97
- required: k
99
+ required: D
98
100
  }),
99
- "aria-label": ue,
100
- "aria-labelledby": j,
101
- placeholder: W.length ? void 0 : C,
102
- value: K,
103
- disabled: w,
104
- readOnly: H || void 0,
101
+ "aria-label": k,
102
+ "aria-labelledby": A,
103
+ placeholder: U.length ? void 0 : ue,
104
+ value: G,
105
+ disabled: S,
106
+ readOnly: V || void 0,
105
107
  enterKeyHint: "enter",
106
- onChange: pe,
107
- onKeyDown: me,
108
- onPaste: he
108
+ onChange: Q,
109
+ onKeyDown: ve,
110
+ onPaste: ye
109
111
  })]
110
112
  }),
111
- J !== null && /* @__PURE__ */ d("span", {
112
- id: U,
113
+ q !== null && /* @__PURE__ */ p("span", {
114
+ id: H,
113
115
  className: "kapi-taginput__error",
114
116
  role: "alert",
115
- children: J
117
+ children: q
116
118
  }),
117
- E && W.map((e, t) => /* @__PURE__ */ d("input", {
119
+ w && U.map((e, t) => /* @__PURE__ */ p("input", {
118
120
  type: "hidden",
119
- name: E,
121
+ name: w,
120
122
  value: e
121
123
  }, `${t}-${e}`))
122
124
  ]
@@ -0,0 +1,37 @@
1
+ /** El primer valor repetido de la lista, envuelto para distinguirlo de «no hay». */
2
+ export declare const firstDuplicate: (values: readonly unknown[]) => {
3
+ value: unknown;
4
+ } | null;
5
+ /**
6
+ * Aviso: dos opciones con el mismo valor.
7
+ *
8
+ * Medido en `KapiSelect` con dos opciones de valor `"x"`: las DOS quedan con `aria-selected="true"`,
9
+ * así que un lector de pantalla anuncia dos opciones elegidas a la vez y elegir una no distingue
10
+ * cuál. Nada más lo señalaba.
11
+ *
12
+ * Recibe los valores ya calculados (y memoizados por el componente) en vez de la lista y un
13
+ * `valueOf`: así la dependencia del efecto es estable y no hay que desactivar `exhaustive-deps`.
14
+ */
15
+ export declare const useDuplicateValueWarning: (name: string, values: readonly unknown[]) => void;
16
+ /** Lo que mira el aviso de control mudo. */
17
+ export type MutedControl = {
18
+ /** `value` llegó definido: el estado es del consumidor. */
19
+ controlled: boolean;
20
+ /** Llegó un `onChange` (o el `onXChange` que corresponda). */
21
+ hasOnChange: boolean;
22
+ /** Pedir sólo lectura es explícito: ahí no se avisa. */
23
+ readOnly?: boolean | undefined;
24
+ /** Deshabilitado también es explícito. */
25
+ disabled?: boolean | undefined;
26
+ };
27
+ /** `true` si el control quedó mudo sin que nadie lo haya pedido. */
28
+ export declare const isMuted: ({ controlled, hasOnChange, readOnly, disabled }: MutedControl) => boolean;
29
+ /**
30
+ * Aviso: `value` sin `onChange` deja el control mudo.
31
+ *
32
+ * Con `value` el estado es del consumidor, así que el componente no guarda nada: sin `onChange`
33
+ * nadie se entera de lo que la persona elige y el control parece roto. Es la forma más común de
34
+ * escribir mal un componente controlado, y no decía nada. `readOnly` y `disabled` son maneras
35
+ * explícitas de pedir justamente eso, así que ahí no avisa.
36
+ */
37
+ export declare const useMutedControlWarning: (name: string, control: MutedControl) => void;
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ import { useEffect as e, useRef as t } from "react";
3
+ //#region src/components/inputs/misuseWarnings.ts
4
+ var n = (e) => {
5
+ let t = /* @__PURE__ */ new Set();
6
+ for (let n of e) {
7
+ if (t.has(n)) return { value: n };
8
+ t.add(n);
9
+ }
10
+ return null;
11
+ }, r = (r, i) => {
12
+ let a = t(!1);
13
+ e(() => {
14
+ if (process.env.NODE_ENV === "production" || a.current) return;
15
+ let e = n(i);
16
+ e && (a.current = !0, console.warn(`${r}: hay dos opciones con el mismo valor (${JSON.stringify(e.value)}). Las dos quedan marcadas como elegidas y no se puede distinguir cuál se eligió. Dales un valor propio.`));
17
+ }, [r, i]);
18
+ }, i = ({ controlled: e, hasOnChange: t, readOnly: n, disabled: r }) => e && !t && !n && !r, a = (n, r) => {
19
+ let a = t(!1), { controlled: o, hasOnChange: s, readOnly: c, disabled: l } = r;
20
+ e(() => {
21
+ process.env.NODE_ENV === "production" || a.current || i({
22
+ controlled: o,
23
+ hasOnChange: s,
24
+ readOnly: c,
25
+ disabled: l
26
+ }) && (a.current = !0, console.warn(`${n}: tiene \`value\` pero no \`onChange\`, así que no responde a lo que la persona elige. Pasa \`onChange\` para quedarte con el valor, \`defaultValue\` para que lo guarde el componente, o \`readOnly\` si de verdad querés que no se pueda cambiar.`));
27
+ }, [
28
+ n,
29
+ o,
30
+ s,
31
+ c,
32
+ l
33
+ ]);
34
+ };
35
+ //#endregion
36
+ export { n as firstDuplicate, i as isMuted, r as useDuplicateValueWarning, a as useMutedControlWarning };
@@ -3,6 +3,16 @@ export type StepBounds = {
3
3
  max?: number | undefined;
4
4
  step?: number | undefined;
5
5
  };
6
+ /** El texto como número decimal finito, o `null` si no lo es. La coma vale como separador. */
7
+ export declare const parseTypedNumber: (text: string) => number | null;
8
+ /**
9
+ * Ajusta al escalón más cercano, contando desde `min` (o desde 0 si no hay).
10
+ *
11
+ * Los botones y las flechas siempre caen en la grilla; lo tipeado no caía, así que con `step={1}`
12
+ * un `2.5` escrito a mano se quedaba en 2.5 y el contador mostraba un valor que sus propios
13
+ * botones no podían producir. Un `step` que no sea un número finito positivo no ajusta nada.
14
+ */
15
+ export declare const snapToStep: (value: number, { min, step }?: StepBounds) => number;
6
16
  /** Clamp to optional bounds. */
7
17
  export declare const clampNumber: (value: number, { min, max }?: StepBounds) => number;
8
18
  /**
@@ -7,15 +7,24 @@ var e = (e) => {
7
7
  }
8
8
  let r = t.indexOf(".");
9
9
  return r === -1 ? 0 : t.length - r - 1;
10
- }, t = (e, { min: t, max: n } = {}) => {
10
+ }, t = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/, n = (e) => {
11
+ let n = e.trim().replace(",", ".");
12
+ if (!t.test(n)) return null;
13
+ let r = Number(n);
14
+ return Number.isFinite(r) ? r : null;
15
+ }, r = (t, { min: n, step: r = 1 } = {}) => {
16
+ if (!Number.isFinite(r) || r <= 0) return t;
17
+ let i = n ?? 0, a = Math.max(e(r), e(i)), o = Math.round(Number(((t - i) / r).toFixed(10)));
18
+ return Number((i + o * r).toFixed(a));
19
+ }, i = (e, { min: t, max: n } = {}) => {
11
20
  let r = e;
12
21
  return t !== void 0 && r < t && (r = t), n !== void 0 && r > n && (r = n), r;
13
- }, n = (n, r, { min: i, max: a, step: o = 1 } = {}) => {
14
- let s = Number.isFinite(n) ? n : i ?? 0, c = s + r * o, l = Math.max(e(o), e(s));
15
- return t(Number(c.toFixed(l)), {
16
- min: i,
22
+ }, a = (t, n, { min: r, max: a, step: o = 1 } = {}) => {
23
+ let s = Number.isFinite(t) ? t : r ?? 0, c = s + n * o, l = Math.max(e(o), e(s));
24
+ return i(Number(c.toFixed(l)), {
25
+ min: r,
17
26
  max: a
18
27
  });
19
- }, r = (e, { min: t } = {}) => t === void 0 || e > t, i = (e, { max: t } = {}) => t === void 0 || e < t;
28
+ }, o = (e, { min: t } = {}) => t === void 0 || e > t, s = (e, { max: t } = {}) => t === void 0 || e < t;
20
29
  //#endregion
21
- export { r as canDecrement, i as canIncrement, t as clampNumber, n as stepValue };
30
+ export { o as canDecrement, s as canIncrement, i as clampNumber, n as parseTypedNumber, r as snapToStep, a as stepValue };
@@ -5,9 +5,9 @@ import { useLabels as e } from "../locale/KapiLocaleProvider.js";
5
5
  import { joinClasses as t } from "../rootProps.js";
6
6
  import { enabledIndexes as n, focusedMenuIndex as ee, menuKeyIntent as te, nextEnabledIndex as ne } from "../overlays/menuKeyboardLogic.js";
7
7
  import { activeElementOf as r } from "../../hooks/ownerDocument.js";
8
- import { useDismiss as i } from "../../hooks/useDismiss.js";
8
+ import { useMergedRefs as i } from "../../hooks/mergeRefs.js";
9
+ import { useDismiss as a } from "../../hooks/useDismiss.js";
9
10
  /* empty css */
10
- import { useMergedRefs as a } from "../../hooks/mergeRefs.js";
11
11
  import { useExitPresence as o } from "../overlays/useExitPresence.js";
12
12
  import { isActionMenuItem as s, submenuKeyAction as c } from "../overlays/menuButtonLogic.js";
13
13
  import { DEFAULT_LINK_LABELS as l } from "../locale/linkLabels.js";
@@ -63,7 +63,7 @@ function C({ open: g, onClose: C, user: w, notificationsCount: T = 0, onNotifica
63
63
  key: "system",
64
64
  label: z.themeSystem
65
65
  }
66
- ], W = oe(null), pe = a(W, P), { present: me, closing: G } = o(g, W), K = () => Array.from(W.current?.querySelectorAll(b) ?? []).filter((e) => e.closest("[role=\"menu\"]") === W.current), q = (e) => n(e.length, (t) => e[t].getAttribute("aria-disabled") === "true"), { restore: J } = f(g, {
66
+ ], W = oe(null), pe = i(W, P), { present: me, closing: G } = o(g, W), K = () => Array.from(W.current?.querySelectorAll(b) ?? []).filter((e) => e.closest("[role=\"menu\"]") === W.current), q = (e) => n(e.length, (t) => e[t].getAttribute("aria-disabled") === "true"), { restore: J } = f(g, {
67
67
  container: W,
68
68
  target: F
69
69
  }), Y = () => {
@@ -74,7 +74,7 @@ function C({ open: g, onClose: C, user: w, notificationsCount: T = 0, onNotifica
74
74
  let e = K();
75
75
  e[q(e)[0] ?? -1]?.focus();
76
76
  }, [g]);
77
- let he = i(g, {
77
+ let he = a(g, {
78
78
  zones: [W],
79
79
  outside: !1,
80
80
  onDismiss: Y
@@ -1,15 +1,15 @@
1
1
  "use client";
2
2
  import { joinClasses as e } from "../rootProps.js";
3
- import { useSlidingIndicator as t } from "../../hooks/useSlidingIndicator.js";
4
- import { useMergedRefs as n } from "../../hooks/mergeRefs.js";
3
+ import { useMergedRefs as t } from "../../hooks/mergeRefs.js";
4
+ import { useSlidingIndicator as n } from "../../hooks/useSlidingIndicator.js";
5
5
  import { jsx as r, jsxs as i } from "react/jsx-runtime";
6
6
  //#region src/components/navigation/CtxSlidingList.tsx
7
7
  var a = ({ active: a = null, children: o, className: s, ref: c, ...l }) => {
8
- let { containerRef: u, indicatorRef: d } = t({
8
+ let { containerRef: u, indicatorRef: d } = n({
9
9
  active: a,
10
10
  deps: [a, o],
11
11
  findActive: (e) => e.querySelector("[aria-current=\"page\"]")
12
- }), f = n(u, c);
12
+ }), f = t(u, c);
13
13
  return /* @__PURE__ */ i("div", {
14
14
  ...l,
15
15
  ref: f,
@@ -4,83 +4,90 @@ import { useKapiFormatLocale as e } from "../locale/KapiLocaleProvider.js";
4
4
  import { joinClasses as t } from "../rootProps.js";
5
5
  import { useControllableState as n } from "../../hooks/useControllableState.js";
6
6
  import { logicalKeyOf as r } from "../../hooks/directionLogic.js";
7
- import { useSlidingIndicator as i } from "../../hooks/useSlidingIndicator.js";
8
- import { formatCount as a } from "../../hooks/numberFormatLogic.js";
7
+ import { useDuplicateValueWarning as i, useMutedControlWarning as a } from "../inputs/misuseWarnings.js";
9
8
  import { useMergedRefs as o } from "../../hooks/mergeRefs.js";
10
- import { useScrollEdges as s } from "../../hooks/useScrollEdges.js";
9
+ import { useSlidingIndicator as s } from "../../hooks/useSlidingIndicator.js";
10
+ import { formatCount as c } from "../../hooks/numberFormatLogic.js";
11
+ import { useScrollEdges as l } from "../../hooks/useScrollEdges.js";
11
12
  /* empty css */
12
- import { nextTabId as c, tabClasses as l, tabId as u, tabPanelId as d } from "./tabsLogic.js";
13
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
14
- import { useCallback as h, useId as g, useLayoutEffect as _, useRef as v } from "react";
13
+ import { nextTabId as u, tabClasses as d, tabId as f, tabPanelId as p } from "./tabsLogic.js";
14
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
15
+ import { useCallback as _, useId as v, useLayoutEffect as y, useMemo as b, useRef as x } from "react";
15
16
  //#region src/components/navigation/KapiTabs.tsx
16
- var y = [];
17
- function b({ items: b, tabs: x, value: S, defaultValue: C, onChange: w, className: T, idBase: E, disabled: D = !1, size: O = "md", onKeyDown: k, ref: A, ...j }) {
18
- let M = e(), N = b ?? x ?? y, P = g(), F = E ?? P, I = v({}), [L, R] = n(S, () => C ?? N[0]?.id, w), { containerRef: z, indicatorRef: B } = i({
19
- active: L ?? null,
20
- deps: [N],
17
+ var S = [];
18
+ function C({ items: C, tabs: w, value: T, defaultValue: E, onChange: D, className: O, idBase: k, disabled: A = !1, size: j = "md", onKeyDown: M, ref: N, ...P }) {
19
+ let F = e(), I = C ?? w ?? S, L = v(), R = k ?? L, z = x({}), [B, V] = n(T, () => E ?? I[0]?.id, D), H = b(() => I.map((e) => e.id), [I]);
20
+ i("KapiTabs", H), a("KapiTabs", {
21
+ controlled: T !== void 0,
22
+ hasOnChange: !!D,
23
+ disabled: A
24
+ });
25
+ let { containerRef: U, indicatorRef: W } = s({
26
+ active: B ?? null,
27
+ deps: [I],
21
28
  findActive: (e) => e.querySelector("[role=\"tab\"][aria-selected=\"true\"]")
22
- }), { ref: V, edges: H, reveal: U } = s({ axis: "x" }), W = h((e) => {
23
- z.current = e, V.current = e;
24
- }, [z, V]), G = o(W, A), K = v(!1);
25
- _(() => {
26
- let e = z.current?.querySelector("[role=\"tab\"][aria-selected=\"true\"]");
27
- e && U(e, { instant: !K.current }), K.current = !0;
29
+ }), { ref: G, edges: K, reveal: q } = l({ axis: "x" }), J = _((e) => {
30
+ U.current = e, G.current = e;
31
+ }, [U, G]), Y = o(J, N), X = x(!1);
32
+ y(() => {
33
+ let e = U.current?.querySelector("[role=\"tab\"][aria-selected=\"true\"]");
34
+ e && q(e, { instant: !X.current }), X.current = !0;
28
35
  }, [
29
- L,
30
- z,
31
- U
36
+ B,
37
+ U,
38
+ q
32
39
  ]);
33
- let q = (e) => D || N.some((t) => t.id === e && t.disabled === !0), J = L !== void 0 && N.some((e) => e.id === L) && !q(L) ? L : N.find((e) => !q(e.id))?.id, Y = (e) => {
34
- if (k?.(e), e.defaultPrevented || L === void 0) return;
35
- let t = c(N.map((e) => e.id), L, r(e), q);
36
- t !== void 0 && (e.preventDefault(), R(t), I.current[t]?.focus());
40
+ let Z = (e) => A || I.some((t) => t.id === e && t.disabled === !0), Q = B !== void 0 && I.some((e) => e.id === B) && !Z(B) ? B : I.find((e) => !Z(e.id))?.id, $ = (e) => {
41
+ if (M?.(e), e.defaultPrevented || B === void 0) return;
42
+ let t = u(I.map((e) => e.id), B, r(e), Z);
43
+ t !== void 0 && (e.preventDefault(), V(t), z.current[t]?.focus());
37
44
  };
38
- return /* @__PURE__ */ m("div", {
39
- ...j,
40
- ref: G,
41
- className: t("kapi-tabs", "kapi-fade-x", O === "sm" && "kapi-tabs--sm", T),
42
- "data-edge-start": H.start ? "" : void 0,
43
- "data-edge-end": H.end ? "" : void 0,
45
+ return /* @__PURE__ */ g("div", {
46
+ ...P,
47
+ ref: Y,
48
+ className: t("kapi-tabs", "kapi-fade-x", j === "sm" && "kapi-tabs--sm", O),
49
+ "data-edge-start": K.start ? "" : void 0,
50
+ "data-edge-end": K.end ? "" : void 0,
44
51
  role: "tablist",
45
- "aria-disabled": D || void 0,
46
- onKeyDown: Y,
47
- children: [/* @__PURE__ */ p("span", {
48
- ref: B,
52
+ "aria-disabled": A || void 0,
53
+ onKeyDown: $,
54
+ children: [/* @__PURE__ */ h("span", {
55
+ ref: W,
49
56
  className: "kapi-tabs__indicator",
50
57
  "aria-hidden": "true"
51
- }), N.map((e) => {
52
- let t = e.id === L;
53
- return /* @__PURE__ */ m("button", {
58
+ }), I.map((e) => {
59
+ let t = e.id === B;
60
+ return /* @__PURE__ */ g("button", {
54
61
  ref: (t) => {
55
- I.current[e.id] = t;
62
+ z.current[e.id] = t;
56
63
  },
57
64
  type: "button",
58
- id: u(F, e.id),
65
+ id: f(R, e.id),
59
66
  role: "tab",
60
- "aria-controls": E ? d(E, e.id) : void 0,
67
+ "aria-controls": k ? p(k, e.id) : void 0,
61
68
  "aria-selected": t,
62
- tabIndex: e.id === J ? 0 : -1,
63
- disabled: q(e.id) || void 0,
64
- className: l(t),
65
- onClick: () => R(e.id),
69
+ tabIndex: e.id === Q ? 0 : -1,
70
+ disabled: Z(e.id) || void 0,
71
+ className: d(t),
72
+ onClick: () => V(e.id),
66
73
  children: [
67
74
  e.icon,
68
75
  e.label,
69
- e.count !== void 0 && /* @__PURE__ */ m(f, { children: [" ", /* @__PURE__ */ p("span", {
76
+ e.count !== void 0 && /* @__PURE__ */ g(m, { children: [" ", /* @__PURE__ */ h("span", {
70
77
  className: "kapi-tabs__count",
71
- children: a(e.count, M)
78
+ children: c(e.count, F)
72
79
  })] })
73
80
  ]
74
81
  }, e.id);
75
82
  })]
76
83
  });
77
84
  }
78
- function x({ idBase: e, tabId: t, active: n, keepMounted: r = !1, className: i, children: a, ref: o }) {
79
- return /* @__PURE__ */ p("div", {
85
+ function w({ idBase: e, tabId: t, active: n, keepMounted: r = !1, className: i, children: a, ref: o }) {
86
+ return /* @__PURE__ */ h("div", {
80
87
  ref: o,
81
- id: d(e, t),
88
+ id: p(e, t),
82
89
  role: "tabpanel",
83
- "aria-labelledby": u(e, t),
90
+ "aria-labelledby": f(e, t),
84
91
  tabIndex: 0,
85
92
  hidden: !n,
86
93
  className: i,
@@ -88,4 +95,4 @@ function x({ idBase: e, tabId: t, active: n, keepMounted: r = !1, className: i,
88
95
  });
89
96
  }
90
97
  //#endregion
91
- export { x as KapiTabPanel, b as KapiTabs };
98
+ export { w as KapiTabPanel, C as KapiTabs };
@@ -5,9 +5,9 @@ import { joinClasses as t } from "../rootProps.js";
5
5
  import { isTypeaheadKey as n } from "../overlays/menuKeyboardLogic.js";
6
6
  import { useControllableState as r } from "../../hooks/useControllableState.js";
7
7
  import { logicalKeyOf as i } from "../../hooks/directionLogic.js";
8
- import { useTypeahead as a } from "../../hooks/useTypeahead.js";
9
- import { useVirtualList as o } from "../../hooks/useVirtualList.js";
10
- import { useMergedRefs as s } from "../../hooks/mergeRefs.js";
8
+ import { useMergedRefs as a } from "../../hooks/mergeRefs.js";
9
+ import { useTypeahead as o } from "../../hooks/useTypeahead.js";
10
+ import { useVirtualList as s } from "../../hooks/useVirtualList.js";
11
11
  /* empty css */
12
12
  import { TREE_KEYS as c, flattenVisible as l, isExpandable as u, matchTypeahead as ee, needsChildren as te, resolveTabStop as ne, toggleSelectedId as re, treeKeyAction as d } from "./treeLogic.js";
13
13
  import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
@@ -16,7 +16,7 @@ import { ChevronRight as se } from "lucide-react";
16
16
  //#region src/components/navigation/KapiTree.tsx
17
17
  var _ = { loading: "Cargando…" }, ce = 37, v = 400;
18
18
  function y({ nodes: y, expandedIds: le, defaultExpandedIds: ue, onExpandedIdsChange: b, expanded: x, defaultExpanded: S, onExpandedChange: de, onExpand: fe, selectedIds: pe, defaultSelectedIds: me, onSelectedIdsChange: he, selected: ge, defaultSelected: _e, onSelectedChange: ve, multiple: C = !1, renderLabel: w, labels: ye, virtual: T = !1, maxHeight: E = v, className: D, style: O, ref: k, onKeyDown: A, onFocus: j, ...M }) {
19
- let N = e("tree", _, ye), P = ie(), [F, be] = r(le ?? x, () => ue ?? S ?? [], b ?? de), [I, xe] = r(pe ?? ge, () => me ?? _e ?? []), Se = he ?? ve, [Ce, L] = oe(null), R = g(/* @__PURE__ */ new Map()), z = a(500), B = h(() => l(y, F), [y, F]), V = ne(y, B, Ce, I), H = h(() => new Map(B.map((e, t) => [e.node.id, {
19
+ let N = e("tree", _, ye), P = ie(), [F, be] = r(le ?? x, () => ue ?? S ?? [], b ?? de), [I, xe] = r(pe ?? ge, () => me ?? _e ?? []), Se = he ?? ve, [Ce, L] = oe(null), R = g(/* @__PURE__ */ new Map()), z = o(500), B = h(() => l(y, F), [y, F]), V = ne(y, B, Ce, I), H = h(() => new Map(B.map((e, t) => [e.node.id, {
20
20
  ...e,
21
21
  node: e.node,
22
22
  index: t
@@ -32,7 +32,7 @@ function y({ nodes: y, expandedIds: le, defaultExpandedIds: ue, onExpandedIdsCha
32
32
  if (e.disabled) return;
33
33
  let t = re(I, e.id, C);
34
34
  xe(t), Se?.(t, e);
35
- }, J = g(null), Te = s(k, J), Ee = h(() => T ? B.map((e) => e.node.id) : void 0, [T, B]), Y = o({
35
+ }, J = g(null), Te = a(k, J), Ee = h(() => T ? B.map((e) => e.node.id) : void 0, [T, B]), Y = s({
36
36
  enabled: T,
37
37
  count: B.length,
38
38
  scrollRef: J,
@@ -3,9 +3,9 @@ import "#kapi-css/components/overlays/overlays.css";
3
3
  import { useLabels as e } from "../locale/KapiLocaleProvider.js";
4
4
  import { joinClasses as t } from "../rootProps.js";
5
5
  import { usePlacement as n } from "../../hooks/usePlacement.js";
6
- import { useDismiss as r } from "../../hooks/useDismiss.js";
6
+ import { useMergedRefs as r } from "../../hooks/mergeRefs.js";
7
+ import { useDismiss as i } from "../../hooks/useDismiss.js";
7
8
  /* empty css */
8
- import { useMergedRefs as i } from "../../hooks/mergeRefs.js";
9
9
  import { POINT_MENU_PLACEMENT as a } from "../../hooks/rightClick.js";
10
10
  import { estimateMenuHeight as o } from "./menuButtonLogic.js";
11
11
  import { MenuList as s } from "./menuList.js";
@@ -14,12 +14,12 @@ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
14
14
  import { useLayoutEffect as f, useRef as p } from "react";
15
15
  //#region src/components/overlays/KapiContextMenu.tsx
16
16
  var m = { menu: "Menú contextual" }, h = 210, g = ({ open: e, ...t }) => e ? /* @__PURE__ */ u(_, { ...t }) : null, _ = ({ x: g, y: _, items: v, onClose: y, className: b, style: x, id: S, ref: C, labels: w, "aria-label": T }) => {
17
- let E = e("contextMenu", m, w), D = p(null), O = i(D, C);
17
+ let E = e("contextMenu", m, w), D = p(null), O = r(D, C);
18
18
  c(!0, {
19
19
  container: D,
20
20
  restoreOnDeactivate: "if-lost"
21
21
  });
22
- let k = r(!0, {
22
+ let k = i(!0, {
23
23
  zones: [D],
24
24
  outside: !1,
25
25
  onDismiss: () => y()
@@ -5,9 +5,9 @@ import { joinClasses as t } from "../rootProps.js";
5
5
  import { useControllableState as n } from "../../hooks/useControllableState.js";
6
6
  import { resolveKapiRoot as r } from "../../hooks/kapiRoot.js";
7
7
  import { usePlacement as i } from "../../hooks/usePlacement.js";
8
- import { useDismiss as a } from "../../hooks/useDismiss.js";
8
+ import { useMergedRefs as a } from "../../hooks/mergeRefs.js";
9
+ import { useDismiss as o } from "../../hooks/useDismiss.js";
9
10
  /* empty css */
10
- import { useMergedRefs as o } from "../../hooks/mergeRefs.js";
11
11
  import { ACTION_MENU_PLACEMENT as s } from "./menuButtonLogic.js";
12
12
  import { MenuList as c } from "./menuList.js";
13
13
  import { useFocusReturn as l } from "../../hooks/useFocusReturn.js";
@@ -17,7 +17,7 @@ import { ChevronDown as g } from "lucide-react";
17
17
  import { createPortal as _ } from "react-dom";
18
18
  //#region src/components/overlays/KapiMenuButton.tsx
19
19
  var v = 6, y = ({ label: y, items: b, icon: x, tone: S, variant: C, size: w, disabled: T = !1, open: E, defaultOpen: D = !1, onOpenChange: O, chevron: k, "aria-label": A, drop: j = "down", className: M, style: N, id: P, ref: F }) => {
20
- let I = p(), [L, R] = n(E, D, O), z = L && !T, B = y === void 0 && x != null, V = k ?? !B, H = h(null), U = o(H, F), W = h(null), G = h(null), { restore: K } = l(z, {
20
+ let I = p(), [L, R] = n(E, D, O), z = L && !T, B = y === void 0 && x != null, V = k ?? !B, H = h(null), U = a(H, F), W = h(null), G = h(null), { restore: K } = l(z, {
21
21
  container: G,
22
22
  target: W
23
23
  }), q = f((e) => {
@@ -38,7 +38,7 @@ var v = 6, y = ({ label: y, items: b, icon: x, tone: S, variant: C, size: w, dis
38
38
  b.length,
39
39
  X
40
40
  ]);
41
- let Z = a(z, {
41
+ let Z = o(z, {
42
42
  zones: [H, G],
43
43
  onDismiss: (e) => q(e === "escape")
44
44
  }), Q = (e) => {