@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.
- package/README.md +5 -0
- package/dist/components/chat/KapiChatDivider.d.ts +7 -3
- package/dist/components/chat/KapiChatDivider.js +6 -6
- package/dist/components/chat/index.d.ts +1 -1
- package/dist/components/display/KapiAnnotation.js +4 -4
- package/dist/components/feedback/KapiFab.js +4 -4
- package/dist/components/feedback/KapiToastContainer.js +5 -5
- package/dist/components/feedback/KapiTour.js +4 -4
- package/dist/components/inputs/KapiDatePicker.js +124 -122
- package/dist/components/inputs/KapiDateRangePicker.js +138 -136
- package/dist/components/inputs/KapiFacetedSearch.js +8 -8
- package/dist/components/inputs/KapiMaskedInput.d.ts +8 -3
- package/dist/components/inputs/KapiMaskedInput.js +66 -53
- package/dist/components/inputs/KapiNumberStepper.js +29 -29
- package/dist/components/inputs/KapiRating.js +61 -59
- package/dist/components/inputs/KapiSegmented.js +68 -58
- package/dist/components/inputs/KapiSelect.js +204 -194
- package/dist/components/inputs/KapiTagInput.js +82 -80
- package/dist/components/inputs/misuseWarnings.d.ts +37 -0
- package/dist/components/inputs/misuseWarnings.js +36 -0
- package/dist/components/inputs/numberStepLogic.d.ts +10 -0
- package/dist/components/inputs/numberStepLogic.js +16 -7
- package/dist/components/layout/KapiAccountMenu.js +4 -4
- package/dist/components/navigation/CtxSlidingList.js +4 -4
- package/dist/components/navigation/KapiTabs.js +58 -51
- package/dist/components/navigation/KapiTree.js +5 -5
- package/dist/components/overlays/KapiContextMenu.js +4 -4
- package/dist/components/overlays/KapiMenuButton.js +4 -4
- package/dist/components/overlays/KapiPhotoView.js +1 -1
- package/dist/components/overlays/KapiPopover.js +4 -4
- package/dist/components/overlays/KapiShapeSheet.js +4 -4
- package/dist/components/overlays/KapiTooltip.js +1 -1
- package/dist/css/components/chat/chat.css +1 -1
- package/dist/hooks/useControllableState.d.ts +6 -2
- package/dist/hooks/useControllableState.js +14 -11
- package/dist/hooks/useFormReset.d.ts +22 -0
- package/dist/hooks/useFormReset.js +17 -0
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- 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
|
|
5
|
-
import { useLabels as
|
|
6
|
-
import { joinClasses as
|
|
7
|
-
import { useControllableState as
|
|
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
|
|
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
|
|
12
|
-
import { useCallback as
|
|
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 }) =>
|
|
19
|
-
function y({ value:
|
|
20
|
-
let
|
|
21
|
-
id:
|
|
22
|
-
label:
|
|
23
|
-
help:
|
|
24
|
-
required:
|
|
25
|
-
invalid:
|
|
26
|
-
readOnly:
|
|
27
|
-
fieldClassName:
|
|
28
|
-
}),
|
|
29
|
-
|
|
30
|
-
}, [
|
|
31
|
-
let { values: n, rejected: r } =
|
|
32
|
-
validate:
|
|
33
|
-
maxTags:
|
|
34
|
-
allowDuplicates:
|
|
35
|
-
caseSensitive:
|
|
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 !==
|
|
38
|
-
},
|
|
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 (
|
|
41
|
-
|
|
42
|
+
if (J(null), !c(t)) {
|
|
43
|
+
K(t);
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
44
|
-
let { complete: n, tail: r } =
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
if (
|
|
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 =
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
n(e.relatedTarget,
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
}, $ =
|
|
62
|
-
return
|
|
63
|
-
...
|
|
64
|
-
ref:
|
|
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:
|
|
68
|
+
size: C,
|
|
67
69
|
invalid: $,
|
|
68
|
-
disabled:
|
|
69
|
-
readOnly:
|
|
70
|
-
className:
|
|
70
|
+
disabled: S,
|
|
71
|
+
readOnly: V,
|
|
72
|
+
className: F
|
|
71
73
|
}),
|
|
72
|
-
onClick:
|
|
73
|
-
onBlur:
|
|
74
|
+
onClick: xe,
|
|
75
|
+
onBlur: be,
|
|
74
76
|
children: [
|
|
75
|
-
/* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ m("div", {
|
|
76
78
|
className: "kapi-taginput__box",
|
|
77
|
-
children: [
|
|
79
|
+
children: [U.length > 0 && /* @__PURE__ */ p("ul", {
|
|
78
80
|
className: "kapi-taginput__tags",
|
|
79
|
-
children:
|
|
81
|
+
children: U.map((e, t) => /* @__PURE__ */ p("li", {
|
|
80
82
|
className: "kapi-taginput__item",
|
|
81
|
-
children: /* @__PURE__ */
|
|
83
|
+
children: /* @__PURE__ */ p(ie, {
|
|
82
84
|
tone: "primary",
|
|
83
|
-
size:
|
|
84
|
-
onRemove:
|
|
85
|
-
removeLabel: `${
|
|
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__ */
|
|
90
|
-
ref:
|
|
91
|
+
}), /* @__PURE__ */ p("input", {
|
|
92
|
+
ref: ge,
|
|
91
93
|
type: "text",
|
|
92
94
|
className: "kapi-taginput__input",
|
|
93
|
-
...t(
|
|
94
|
-
id:
|
|
95
|
-
describedBy: r(
|
|
95
|
+
...t(B, {
|
|
96
|
+
id: T,
|
|
97
|
+
describedBy: r(q !== null && H, j),
|
|
96
98
|
invalid: $,
|
|
97
|
-
required:
|
|
99
|
+
required: D
|
|
98
100
|
}),
|
|
99
|
-
"aria-label":
|
|
100
|
-
"aria-labelledby":
|
|
101
|
-
placeholder:
|
|
102
|
-
value:
|
|
103
|
-
disabled:
|
|
104
|
-
readOnly:
|
|
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:
|
|
107
|
-
onKeyDown:
|
|
108
|
-
onPaste:
|
|
108
|
+
onChange: Q,
|
|
109
|
+
onKeyDown: ve,
|
|
110
|
+
onPaste: ye
|
|
109
111
|
})]
|
|
110
112
|
}),
|
|
111
|
-
|
|
112
|
-
id:
|
|
113
|
+
q !== null && /* @__PURE__ */ p("span", {
|
|
114
|
+
id: H,
|
|
113
115
|
className: "kapi-taginput__error",
|
|
114
116
|
role: "alert",
|
|
115
|
-
children:
|
|
117
|
+
children: q
|
|
116
118
|
}),
|
|
117
|
-
|
|
119
|
+
w && U.map((e, t) => /* @__PURE__ */ p("input", {
|
|
118
120
|
type: "hidden",
|
|
119
|
-
name:
|
|
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 = (
|
|
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
|
-
},
|
|
14
|
-
let s = Number.isFinite(
|
|
15
|
-
return
|
|
16
|
-
min:
|
|
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
|
-
},
|
|
28
|
+
}, o = (e, { min: t } = {}) => t === void 0 || e > t, s = (e, { max: t } = {}) => t === void 0 || e < t;
|
|
20
29
|
//#endregion
|
|
21
|
-
export {
|
|
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 {
|
|
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 =
|
|
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 =
|
|
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 {
|
|
4
|
-
import {
|
|
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 } =
|
|
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 =
|
|
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 {
|
|
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 {
|
|
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
|
|
13
|
-
import { Fragment as
|
|
14
|
-
import { useCallback as
|
|
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
|
|
17
|
-
function
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
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:
|
|
23
|
-
|
|
24
|
-
}, [
|
|
25
|
-
|
|
26
|
-
let e =
|
|
27
|
-
e &&
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
B,
|
|
37
|
+
U,
|
|
38
|
+
q
|
|
32
39
|
]);
|
|
33
|
-
let
|
|
34
|
-
if (
|
|
35
|
-
let t =
|
|
36
|
-
t !== void 0 && (e.preventDefault(),
|
|
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__ */
|
|
39
|
-
...
|
|
40
|
-
ref:
|
|
41
|
-
className: t("kapi-tabs", "kapi-fade-x",
|
|
42
|
-
"data-edge-start":
|
|
43
|
-
"data-edge-end":
|
|
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":
|
|
46
|
-
onKeyDown:
|
|
47
|
-
children: [/* @__PURE__ */
|
|
48
|
-
ref:
|
|
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
|
-
}),
|
|
52
|
-
let t = e.id ===
|
|
53
|
-
return /* @__PURE__ */
|
|
58
|
+
}), I.map((e) => {
|
|
59
|
+
let t = e.id === B;
|
|
60
|
+
return /* @__PURE__ */ g("button", {
|
|
54
61
|
ref: (t) => {
|
|
55
|
-
|
|
62
|
+
z.current[e.id] = t;
|
|
56
63
|
},
|
|
57
64
|
type: "button",
|
|
58
|
-
id:
|
|
65
|
+
id: f(R, e.id),
|
|
59
66
|
role: "tab",
|
|
60
|
-
"aria-controls":
|
|
67
|
+
"aria-controls": k ? p(k, e.id) : void 0,
|
|
61
68
|
"aria-selected": t,
|
|
62
|
-
tabIndex: e.id ===
|
|
63
|
-
disabled:
|
|
64
|
-
className:
|
|
65
|
-
onClick: () =>
|
|
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
|
|
76
|
+
e.count !== void 0 && /* @__PURE__ */ g(m, { children: [" ", /* @__PURE__ */ h("span", {
|
|
70
77
|
className: "kapi-tabs__count",
|
|
71
|
-
children:
|
|
78
|
+
children: c(e.count, F)
|
|
72
79
|
})] })
|
|
73
80
|
]
|
|
74
81
|
}, e.id);
|
|
75
82
|
})]
|
|
76
83
|
});
|
|
77
84
|
}
|
|
78
|
-
function
|
|
79
|
-
return /* @__PURE__ */
|
|
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:
|
|
88
|
+
id: p(e, t),
|
|
82
89
|
role: "tabpanel",
|
|
83
|
-
"aria-labelledby":
|
|
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 {
|
|
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 {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
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 =
|
|
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 =
|
|
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 {
|
|
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 =
|
|
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 =
|
|
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 {
|
|
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 =
|
|
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 =
|
|
41
|
+
let Z = o(z, {
|
|
42
42
|
zones: [H, G],
|
|
43
43
|
onDismiss: (e) => q(e === "escape")
|
|
44
44
|
}), Q = (e) => {
|