@kapiuara/ui 0.17.0 → 0.19.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 +259 -9
- package/dist/components/data/KapiDataTable.d.ts +12 -2
- package/dist/components/data/KapiDataTable.js +78 -76
- package/dist/components/data/KapiScatterChart.d.ts +56 -0
- package/dist/components/data/KapiScatterChart.js +90 -0
- package/dist/components/data/KapiTable.d.ts +2 -2
- package/dist/components/data/KapiTable.js +229 -227
- package/dist/components/data/chartFrame.d.ts +20 -2
- package/dist/components/data/chartFrame.js +33 -24
- package/dist/components/data/index.d.ts +5 -1
- package/dist/components/data/scatterLogic.d.ts +56 -0
- package/dist/components/data/scatterLogic.js +43 -0
- package/dist/components/data/tableTypes.d.ts +37 -0
- package/dist/components/data/useRowKeyWarning.d.ts +9 -3
- package/dist/components/data/useRowKeyWarning.js +7 -7
- package/dist/components/data/useTableSelection.d.ts +3 -2
- package/dist/components/data/useTableSelection.js +3 -3
- package/dist/components/display/KapiAvatarGroup.d.ts +14 -2
- package/dist/components/display/KapiAvatarGroup.js +25 -23
- package/dist/components/display/KapiTimeline.d.ts +14 -0
- package/dist/components/display/KapiTimeline.js +28 -21
- package/dist/components/display/avatarGroupSlots.d.ts +6 -0
- package/dist/components/display/avatarGroupSlots.js +9 -0
- package/dist/components/display/index.d.ts +1 -1
- package/dist/components/feedback/KapiAlert.d.ts +6 -1
- package/dist/components/feedback/KapiAlert.js +45 -44
- package/dist/components/feedback/KapiCountdown.d.ts +12 -1
- package/dist/components/feedback/KapiCountdown.js +34 -31
- package/dist/components/feedback/KapiEmpty.d.ts +6 -1
- package/dist/components/feedback/KapiEmpty.js +20 -18
- package/dist/components/feedback/KapiProgress.js +1 -1
- package/dist/components/feedback/KapiSpinner.d.ts +48 -0
- package/dist/components/feedback/KapiSpinner.js +27 -0
- package/dist/components/feedback/KapiToastContainer.js +1 -1
- package/dist/components/feedback/KapiTour.js +1 -1
- package/dist/components/feedback/alertSlots.d.ts +9 -0
- package/dist/components/feedback/alertSlots.js +12 -0
- package/dist/components/feedback/countdownSlots.d.ts +6 -0
- package/dist/components/feedback/countdownSlots.js +9 -0
- package/dist/components/feedback/emptySlots.d.ts +8 -0
- package/dist/components/feedback/emptySlots.js +11 -0
- package/dist/components/feedback/index.d.ts +5 -3
- package/dist/components/inputs/KapiFileUpload.d.ts +14 -1
- package/dist/components/inputs/KapiFileUpload.js +80 -67
- package/dist/components/inputs/formBridgeLogic.d.ts +104 -0
- package/dist/components/inputs/formBridgeLogic.js +25 -0
- package/dist/components/inputs/index.d.ts +2 -0
- package/dist/components/locale/labelRegistry.d.ts +8 -0
- package/dist/components/navigation/KapiSteps.d.ts +26 -5
- package/dist/components/navigation/KapiSteps.js +55 -43
- package/dist/components/overlays/KapiImageViewer.d.ts +63 -0
- package/dist/components/overlays/KapiImageViewer.js +106 -0
- package/dist/components/overlays/KapiShortcutsHelp.d.ts +53 -0
- package/dist/components/overlays/KapiShortcutsHelp.js +55 -0
- package/dist/components/overlays/KapiTooltip.d.ts +49 -10
- package/dist/components/overlays/KapiTooltip.js +110 -58
- package/dist/components/overlays/KapiViewport.d.ts +63 -0
- package/dist/components/overlays/KapiViewport.js +195 -0
- package/dist/components/overlays/index.d.ts +8 -0
- package/dist/components/overlays/shortcutsHelpSlots.d.ts +9 -0
- package/dist/components/overlays/shortcutsHelpSlots.js +12 -0
- package/dist/components/overlays/viewportLogic.d.ts +73 -0
- package/dist/components/overlays/viewportLogic.js +54 -0
- package/dist/components/slotCatalog.d.ts +33 -0
- package/dist/components/slotCatalog.js +30 -20
- package/dist/css/base.css +1 -1
- package/dist/css/components/data/KapiScatterChart.css +1 -0
- package/dist/css/components/display/display.css +1 -1
- package/dist/css/components/inputs/KapiFileUpload.css +1 -1
- package/dist/css/components/navigation/KapiSteps.css +1 -1
- package/dist/css/components/overlays/KapiViewport.css +1 -0
- package/dist/css/components/overlays/overlays.css +1 -1
- package/dist/hooks/elementSizeLogic.d.ts +15 -0
- package/dist/hooks/elementSizeLogic.js +7 -0
- package/dist/hooks/hotkeyLogic.d.ts +9 -0
- package/dist/hooks/hotkeyLogic.js +16 -15
- package/dist/hooks/hotkeyRegistry.d.ts +44 -0
- package/dist/hooks/hotkeyRegistry.js +32 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/themeDeriveLogic.js +2 -2
- package/dist/hooks/useDebouncedValue.d.ts +30 -0
- package/dist/hooks/useDebouncedValue.js +26 -0
- package/dist/hooks/useDisclosure.d.ts +39 -0
- package/dist/hooks/useDisclosure.js +35 -0
- package/dist/hooks/useElementSize.d.ts +27 -0
- package/dist/hooks/useElementSize.js +29 -0
- package/dist/hooks/useHotkey.d.ts +8 -0
- package/dist/hooks/useHotkey.js +27 -15
- package/dist/index.js +201 -188
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/dist/logic.d.ts +4 -0
- package/dist/logic.js +33 -29
- package/package.json +2 -2
|
@@ -2,6 +2,9 @@ import type { HTMLAttributes, ReactNode, Ref } from "react";
|
|
|
2
2
|
import type { KapiCloseReason } from "../closeReason.js";
|
|
3
3
|
import { type KapiFamilyTone, type KapiTone } from "../tone.js";
|
|
4
4
|
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
5
|
+
import type { KapiClassNames } from "../slotCatalog.js";
|
|
6
|
+
/** Partes de `KapiAlert` que acepta `classNames` (`root`, `icon`, `body`, `title`, `message`, `close`). */
|
|
7
|
+
export type KapiAlertClassNames = KapiClassNames<"alert">;
|
|
5
8
|
export type KapiAlertLabels = {
|
|
6
9
|
/** Nombre accesible del botón de cierre (con `onClose`). */
|
|
7
10
|
close: string;
|
|
@@ -15,6 +18,8 @@ export type KapiAlertVariant = KapiAlertTone;
|
|
|
15
18
|
export type KapiAlertProps = Omit<HTMLAttributes<HTMLDivElement>, "title" | "role" | "children"> & {
|
|
16
19
|
/** Ref al `<div>` raíz del aviso. */
|
|
17
20
|
ref?: Ref<HTMLDivElement> | undefined;
|
|
21
|
+
/** Clases por parte (`root`, `icon`, `body`, `title`, `message`, `close`). Se suman a las propias. */
|
|
22
|
+
classNames?: KapiAlertClassNames | undefined;
|
|
18
23
|
/**
|
|
19
24
|
* Rol semántico: define color, ícono y si se anuncia como `alert` o `status`. Una familia propia
|
|
20
25
|
* de la app (`toneFamilies`) pinta el color y usa el ícono y el anuncio de `info`.
|
|
@@ -53,4 +58,4 @@ export declare const alertRole: (tone: KapiAlertTone, override?: KapiAlertRole)
|
|
|
53
58
|
* Banner inline (info / success / warning / danger) para formularios, modales y pantallas.
|
|
54
59
|
* `danger` se anuncia como `role="alert"`; el resto como `role="status"` (ver `role`).
|
|
55
60
|
*/
|
|
56
|
-
export declare const KapiAlert: ({ tone: toneProp, variant, title, children, action, icon, onClose, labels, className, role, style, ...rest }: KapiAlertProps) => import("react").JSX.Element;
|
|
61
|
+
export declare const KapiAlert: ({ tone: toneProp, variant, title, children, action, icon, onClose, labels, className, classNames, role, style, ...rest }: KapiAlertProps) => import("react").JSX.Element;
|
|
@@ -1,82 +1,83 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/feedback/feedback.css";
|
|
3
3
|
import { useToneLook as e } from "../../hooks/useToneFamilies.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { resolveTone as t } from "../tone.js";
|
|
5
|
+
import { KapiButton as n } from "../inputs/KapiButton.js";
|
|
6
|
+
import { useLabels as r } from "../locale/KapiLocaleProvider.js";
|
|
7
|
+
import { slot as i } from "../slotsLogic.js";
|
|
8
8
|
/* empty css */
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { ALERT_SLOTS as a } from "./alertSlots.js";
|
|
10
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
11
|
+
import { AlertTriangle as c, CheckCircle2 as l, Info as u, X as d, XCircle as f } from "lucide-react";
|
|
11
12
|
//#region src/components/feedback/KapiAlert.tsx
|
|
12
|
-
var
|
|
13
|
+
var p = { close: "Cerrar aviso" }, m = (e, t) => {
|
|
13
14
|
let n = t ?? (e === "danger" ? "alert" : "status");
|
|
14
15
|
return n === "none" ? void 0 : n;
|
|
15
|
-
},
|
|
16
|
+
}, h = {
|
|
16
17
|
info: {
|
|
17
|
-
Icon:
|
|
18
|
+
Icon: u,
|
|
18
19
|
color: "var(--kapi-info)"
|
|
19
20
|
},
|
|
20
21
|
success: {
|
|
21
|
-
Icon:
|
|
22
|
+
Icon: l,
|
|
22
23
|
color: "var(--kapi-success)"
|
|
23
24
|
},
|
|
24
25
|
warning: {
|
|
25
|
-
Icon:
|
|
26
|
+
Icon: c,
|
|
26
27
|
color: "var(--kapi-warning)"
|
|
27
28
|
},
|
|
28
29
|
danger: {
|
|
29
|
-
Icon:
|
|
30
|
+
Icon: f,
|
|
30
31
|
color: "var(--kapi-danger)"
|
|
31
32
|
}
|
|
32
|
-
},
|
|
33
|
-
let
|
|
34
|
-
return /* @__PURE__ */
|
|
35
|
-
...
|
|
36
|
-
style:
|
|
37
|
-
...
|
|
38
|
-
...
|
|
39
|
-
} :
|
|
40
|
-
|
|
41
|
-
role:
|
|
33
|
+
}, g = ({ tone: c, variant: l, title: u, children: f, action: g, icon: _, onClose: v, labels: y, className: b, classNames: x, role: S, style: C, ...w }) => {
|
|
34
|
+
let T = r("alert", p, y), E = e("KapiAlert", c), D = t(E.tone, l, "info"), O = D in h ? D : "info", { Icon: k } = h[O], A = E.style ? "var(--kapi-tone)" : h[O].color;
|
|
35
|
+
return /* @__PURE__ */ s("div", {
|
|
36
|
+
...w,
|
|
37
|
+
style: E.style ? {
|
|
38
|
+
...E.style,
|
|
39
|
+
...C
|
|
40
|
+
} : C,
|
|
41
|
+
...i(a, "root", x, E.style ? "kapi-alert--family" : `kapi-alert--${O}`, b),
|
|
42
|
+
role: m(O, S),
|
|
42
43
|
children: [
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
_ === void 0 ? /* @__PURE__ */ o(k, {
|
|
45
|
+
...i(a, "icon", x),
|
|
45
46
|
size: 19,
|
|
46
47
|
strokeWidth: 2,
|
|
47
|
-
color:
|
|
48
|
-
}) :
|
|
49
|
-
|
|
50
|
-
style: { color:
|
|
48
|
+
color: A
|
|
49
|
+
}) : _ === !1 || _ === null ? null : /* @__PURE__ */ o("span", {
|
|
50
|
+
...i(a, "icon", x, "kapi-alert__ico--custom"),
|
|
51
|
+
style: { color: A },
|
|
51
52
|
"aria-hidden": "true",
|
|
52
|
-
children:
|
|
53
|
+
children: _
|
|
53
54
|
}),
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
|
|
56
|
-
children: [
|
|
57
|
-
|
|
58
|
-
children:
|
|
59
|
-
}),
|
|
60
|
-
|
|
61
|
-
children:
|
|
55
|
+
/* @__PURE__ */ s("div", {
|
|
56
|
+
...i(a, "body", x),
|
|
57
|
+
children: [u && /* @__PURE__ */ o("div", {
|
|
58
|
+
...i(a, "title", x),
|
|
59
|
+
children: u
|
|
60
|
+
}), f && /* @__PURE__ */ o("div", {
|
|
61
|
+
...i(a, "message", x),
|
|
62
|
+
children: f
|
|
62
63
|
})]
|
|
63
64
|
}),
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
g,
|
|
66
|
+
v && /* @__PURE__ */ o(n, {
|
|
67
|
+
...i(a, "close", x),
|
|
67
68
|
variant: "ghost",
|
|
68
69
|
size: "sm",
|
|
69
70
|
iconOnly: !0,
|
|
70
|
-
icon: /* @__PURE__ */
|
|
71
|
+
icon: /* @__PURE__ */ o(d, {
|
|
71
72
|
size: 16,
|
|
72
73
|
strokeWidth: 2.2,
|
|
73
74
|
"aria-hidden": "true"
|
|
74
75
|
}),
|
|
75
|
-
"aria-label":
|
|
76
|
-
onClick: () =>
|
|
76
|
+
"aria-label": T.close,
|
|
77
|
+
onClick: () => v?.("close-button")
|
|
77
78
|
})
|
|
78
79
|
]
|
|
79
80
|
});
|
|
80
81
|
};
|
|
81
82
|
//#endregion
|
|
82
|
-
export {
|
|
83
|
+
export { p as DEFAULT_ALERT_LABELS, g as KapiAlert, m as alertRole };
|
|
@@ -2,10 +2,15 @@ import { type HTMLAttributes, type ReactNode, type Ref } from "react";
|
|
|
2
2
|
import { type KapiBadgeAppearance, type KapiBadgeSize } from "../display/KapiBadge.js";
|
|
3
3
|
import { type KapiCountdownLabels, type KapiCountdownTarget, type KapiCountdownToneMap } from "./countdownLogic.js";
|
|
4
4
|
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
5
|
+
import type { KapiClassNames } from "../slotCatalog.js";
|
|
6
|
+
/** Partes de `KapiCountdown` que acepta `classNames` (`root`, `prefix`, `time`). */
|
|
7
|
+
export type KapiCountdownClassNames = KapiClassNames<"countdown">;
|
|
5
8
|
/** Native attributes (`id`, `style`, `data-*`…) go to the chip; `role="timer"` and its label (from `detail`) are owned. */
|
|
6
9
|
export type KapiCountdownProps = Omit<HTMLAttributes<HTMLSpanElement>, "prefix" | "children" | "role" | "aria-label"> & {
|
|
7
10
|
/** Ref al `<span>` raíz de la cuenta regresiva. */
|
|
8
11
|
ref?: Ref<HTMLSpanElement> | undefined;
|
|
12
|
+
/** Clases por parte (`root`, `prefix`, `time`). Se suman a las propias. */
|
|
13
|
+
classNames?: KapiCountdownClassNames | undefined;
|
|
9
14
|
/** Deadline: Date, ISO string or epoch milliseconds. */
|
|
10
15
|
to: KapiCountdownTarget;
|
|
11
16
|
/** Text before the clock while running (e.g. "Cierra en"). Hidden once overdue. */
|
|
@@ -16,6 +21,12 @@ export type KapiCountdownProps = Omit<HTMLAttributes<HTMLSpanElement>, "prefix"
|
|
|
16
21
|
nearThresholdMs?: number | undefined;
|
|
17
22
|
/** Tooltip text. Defaults to a sentence like "Faltan 2 horas". */
|
|
18
23
|
detail?: string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Fija el "ahora" en lugar de leer el reloj, y **apaga el tick**. Es la misma convención que el
|
|
26
|
+
* resto de lo que muestra tiempo relativo en el sistema: sin esto, un test y una captura miden
|
|
27
|
+
* algo distinto en cada corrida y la baseline se mueve sola.
|
|
28
|
+
*/
|
|
29
|
+
now?: number | undefined;
|
|
19
30
|
/** Override the Spanish copy (unit words keyed by `Intl.PluralRules` category). */
|
|
20
31
|
labels?: KapiLabelsOverride<KapiCountdownLabels> | undefined;
|
|
21
32
|
/** Tamaño del badge: `sm` · `md`. */
|
|
@@ -26,4 +37,4 @@ export type KapiCountdownProps = Omit<HTMLAttributes<HTMLSpanElement>, "prefix"
|
|
|
26
37
|
badgeTone?: KapiBadgeAppearance | undefined;
|
|
27
38
|
};
|
|
28
39
|
/** Live countdown chip: ticks every second and changes color as the deadline approaches. */
|
|
29
|
-
export declare function KapiCountdown({ to, prefix, tones, nearThresholdMs, detail, labels, size, badgeVariant, badgeTone, className, ...rest }: KapiCountdownProps): import("react").JSX.Element | null;
|
|
40
|
+
export declare function KapiCountdown({ to, prefix, tones, nearThresholdMs, detail, now: nowProp, labels, size, badgeVariant, badgeTone, className, classNames, ...rest }: KapiCountdownProps): import("react").JSX.Element | null;
|
|
@@ -1,44 +1,47 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/feedback/feedback.css";
|
|
3
3
|
import { useKapiLocale as e, useLabels as t } from "../locale/KapiLocaleProvider.js";
|
|
4
|
-
import {
|
|
5
|
-
import { KapiBadge as r } from "../display/KapiBadge.js";
|
|
4
|
+
import { slot as n } from "../slotsLogic.js";
|
|
6
5
|
/* empty css */
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { KapiTooltip as r } from "../overlays/KapiTooltip.js";
|
|
7
|
+
import { KapiBadge as i } from "../display/KapiBadge.js";
|
|
8
|
+
import { DEFAULT_COUNTDOWN_LABELS as a, DEFAULT_NEAR_MS as o, bucketFor as s, chipText as c, describe as l, parseTarget as u, resolveTones as d } from "./countdownLogic.js";
|
|
9
|
+
import { COUNTDOWN_SLOTS as f } from "./countdownSlots.js";
|
|
10
|
+
import { useEffect as p, useState as m } from "react";
|
|
11
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
10
12
|
//#region src/components/feedback/KapiCountdown.tsx
|
|
11
|
-
function
|
|
12
|
-
let [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
function _({ to: _, prefix: v, tones: y, nearThresholdMs: b = o, detail: x, now: S, labels: C, size: w = "md", badgeVariant: T, badgeTone: E, className: D, classNames: O, ...k }) {
|
|
14
|
+
let [A, j] = m(() => Date.now()), M = S ?? A, N = t("countdown", a, C), P = e() ?? "es";
|
|
15
|
+
p(() => {
|
|
16
|
+
if (S !== void 0) return;
|
|
17
|
+
j(Date.now());
|
|
18
|
+
let e = setInterval(() => j(Date.now()), 1e3);
|
|
16
19
|
return () => clearInterval(e);
|
|
17
|
-
}, [
|
|
18
|
-
let
|
|
19
|
-
if (!Number.isFinite(
|
|
20
|
-
let
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
-
label:
|
|
23
|
-
children: /* @__PURE__ */
|
|
24
|
-
...
|
|
25
|
-
tone:
|
|
26
|
-
variant:
|
|
27
|
-
size:
|
|
28
|
-
|
|
29
|
-
"data-state":
|
|
20
|
+
}, [_, S]);
|
|
21
|
+
let F = u(_);
|
|
22
|
+
if (!Number.isFinite(F)) return null;
|
|
23
|
+
let I = F - M, L = s(I, b), R = d(y)[L], z = x ?? l(I, N, P), B = v && L !== "overdue";
|
|
24
|
+
return /* @__PURE__ */ h(r, {
|
|
25
|
+
label: z,
|
|
26
|
+
children: /* @__PURE__ */ g(i, {
|
|
27
|
+
...k,
|
|
28
|
+
tone: R,
|
|
29
|
+
variant: T ?? E ?? "subtle",
|
|
30
|
+
size: w,
|
|
31
|
+
...n(f, "root", O, D),
|
|
32
|
+
"data-state": L,
|
|
30
33
|
role: "timer",
|
|
31
|
-
"aria-label":
|
|
34
|
+
"aria-label": z,
|
|
32
35
|
suppressHydrationWarning: !0,
|
|
33
|
-
children: [
|
|
34
|
-
|
|
35
|
-
children:
|
|
36
|
-
}), /* @__PURE__ */
|
|
37
|
-
|
|
38
|
-
children:
|
|
36
|
+
children: [B && /* @__PURE__ */ h("span", {
|
|
37
|
+
...n(f, "prefix", O),
|
|
38
|
+
children: v
|
|
39
|
+
}), /* @__PURE__ */ h("span", {
|
|
40
|
+
...n(f, "time", O),
|
|
41
|
+
children: c(I, N)
|
|
39
42
|
})]
|
|
40
43
|
})
|
|
41
44
|
});
|
|
42
45
|
}
|
|
43
46
|
//#endregion
|
|
44
|
-
export {
|
|
47
|
+
export { _ as KapiCountdown };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { HTMLAttributes, ReactNode, Ref } from "react";
|
|
2
|
+
import type { KapiClassNames } from "../slotCatalog.js";
|
|
3
|
+
/** Partes de `KapiEmpty` que acepta `classNames` (`root`, `icon`, `title`, `description`, `action`). */
|
|
4
|
+
export type KapiEmptyClassNames = KapiClassNames<"empty">;
|
|
2
5
|
export type KapiEmptyProps = Omit<HTMLAttributes<HTMLDivElement>, "title"> & {
|
|
3
6
|
/** Ref al `<div>` raíz del estado vacío. */
|
|
4
7
|
ref?: Ref<HTMLDivElement> | undefined;
|
|
@@ -10,6 +13,8 @@ export type KapiEmptyProps = Omit<HTMLAttributes<HTMLDivElement>, "title"> & {
|
|
|
10
13
|
description?: ReactNode;
|
|
11
14
|
/** Acción principal (típicamente un `KapiButton`). */
|
|
12
15
|
action?: ReactNode;
|
|
16
|
+
/** Clases por parte (`root`, `icon`, `title`, `description`, `action`). Se suman a las propias. */
|
|
17
|
+
classNames?: KapiEmptyClassNames | undefined;
|
|
13
18
|
};
|
|
14
19
|
/** Estado vacío: ícono, título, descripción y acción opcionales, centrados. */
|
|
15
|
-
export declare function KapiEmpty({ icon, title, description, action, className, ...rest }: KapiEmptyProps): import("react").JSX.Element;
|
|
20
|
+
export declare function KapiEmpty({ icon, title, description, action, className, classNames, ...rest }: KapiEmptyProps): import("react").JSX.Element;
|
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/feedback/feedback.css";
|
|
3
|
+
import { slot as e } from "../slotsLogic.js";
|
|
3
4
|
/* empty css */
|
|
4
|
-
import {
|
|
5
|
+
import { EMPTY_SLOTS as t } from "./emptySlots.js";
|
|
6
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
7
|
//#region src/components/feedback/KapiEmpty.tsx
|
|
6
|
-
function
|
|
7
|
-
return /* @__PURE__ */
|
|
8
|
-
|
|
9
|
-
...
|
|
8
|
+
function i({ icon: i, title: a, description: o, action: s, className: c, classNames: l, ...u }) {
|
|
9
|
+
return /* @__PURE__ */ r("div", {
|
|
10
|
+
...u,
|
|
11
|
+
...e(t, "root", l, c),
|
|
10
12
|
children: [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
i != null && /* @__PURE__ */ n("div", {
|
|
14
|
+
...e(t, "icon", l),
|
|
13
15
|
"aria-hidden": !0,
|
|
14
|
-
children: n
|
|
15
|
-
}),
|
|
16
|
-
/* @__PURE__ */ e("div", {
|
|
17
|
-
className: "kapi-empty__title",
|
|
18
|
-
children: r
|
|
19
|
-
}),
|
|
20
|
-
i != null && /* @__PURE__ */ e("div", {
|
|
21
|
-
className: "kapi-empty__desc",
|
|
22
16
|
children: i
|
|
23
17
|
}),
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
/* @__PURE__ */ n("div", {
|
|
19
|
+
...e(t, "title", l),
|
|
26
20
|
children: a
|
|
21
|
+
}),
|
|
22
|
+
o != null && /* @__PURE__ */ n("div", {
|
|
23
|
+
...e(t, "description", l),
|
|
24
|
+
children: o
|
|
25
|
+
}),
|
|
26
|
+
s != null && /* @__PURE__ */ n("div", {
|
|
27
|
+
...e(t, "action", l),
|
|
28
|
+
children: s
|
|
27
29
|
})
|
|
28
30
|
]
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
//#endregion
|
|
32
|
-
export {
|
|
34
|
+
export { i as KapiEmpty };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/feedback/feedback.css";
|
|
3
3
|
import { useToneLook as e } from "../../hooks/useToneFamilies.js";
|
|
4
|
-
/* empty css */
|
|
5
4
|
import { circleDash as t, clampPercent as n, formatPercent as r, progressClasses as i } from "./progressLogic.js";
|
|
5
|
+
/* empty css */
|
|
6
6
|
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/feedback/KapiProgress.tsx
|
|
8
8
|
var s = {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { HTMLAttributes, Ref } from "react";
|
|
2
|
+
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
3
|
+
/** Textos de `KapiSpinner`. */
|
|
4
|
+
export type KapiSpinnerLabels = {
|
|
5
|
+
/** Nombre accesible (y texto visible con `labelVisible`). */
|
|
6
|
+
loading: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const DEFAULT_SPINNER_LABELS: KapiSpinnerLabels;
|
|
9
|
+
/** Tamaños de `KapiSpinner`: los dos que dibuja la hoja base. */
|
|
10
|
+
export type KapiSpinnerSize = "sm" | "md";
|
|
11
|
+
/** Atributos nativos (`id`, `style`, `data-*`…) van al contenedor. */
|
|
12
|
+
export type KapiSpinnerProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
13
|
+
/** Ref al `<div>` raíz. */
|
|
14
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* `sm` mide 20px y entra al lado de un texto; `md` mide 46px y es el de una zona que carga entera.
|
|
17
|
+
* @default "md"
|
|
18
|
+
*/
|
|
19
|
+
size?: KapiSpinnerSize | undefined;
|
|
20
|
+
/** Nombre accesible propio. Sin él, el del locale (`Cargando`). */
|
|
21
|
+
label?: string | undefined;
|
|
22
|
+
/** Además de nombrarlo, muestra el texto debajo del disco. */
|
|
23
|
+
labelVisible?: boolean | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Lo saca del árbol de accesibilidad. Para cuando el estado de carga **ya lo anuncia otra cosa**
|
|
26
|
+
* (un `KapiButton loading`, una tabla con `aria-busy`): dos anuncios del mismo hecho son ruido
|
|
27
|
+
* para quien usa un lector de pantalla.
|
|
28
|
+
*/
|
|
29
|
+
decorative?: boolean | undefined;
|
|
30
|
+
/** Textos fijos (el nombre accesible). */
|
|
31
|
+
labels?: KapiLabelsOverride<KapiSpinnerLabels> | undefined;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Indicador de carga en línea.
|
|
35
|
+
*
|
|
36
|
+
* Existe porque hasta ahora había dos extremos y nada en el medio: `.kapi-spinner` es **sólo una
|
|
37
|
+
* clase** —cada pantalla escribía el `<span>` a mano y casi siempre sin anunciar nada— y
|
|
38
|
+
* `KapiLoading` es un **overlay** que tapa la pantalla entera. Esto es el disco solo, con el
|
|
39
|
+
* anuncio hecho bien: `role="status"` y un nombre accesible, o nada en absoluto con `decorative`.
|
|
40
|
+
* **No lleva `aria-busy`**, y es a propósito: sobre una región viva le diría al lector que espere y
|
|
41
|
+
* se perdería el anuncio, que es justo lo que este componente existe para hacer. El motivo completo
|
|
42
|
+
* está en el comentario de la raíz, al lado del `role`.
|
|
43
|
+
*
|
|
44
|
+
* No trae CSS propio: usa las clases que la hoja base ya dibuja, así que el gate de movimiento lo
|
|
45
|
+
* sigue tratando como loop de carga (gira lento en vez de congelarse con `data-motion="reduced"`,
|
|
46
|
+
* porque un spinner congelado parece colgado).
|
|
47
|
+
*/
|
|
48
|
+
export declare const KapiSpinner: ({ size, label, labelVisible, decorative, labels, className, ...rest }: KapiSpinnerProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { joinClasses as e } from "../rootProps.js";
|
|
3
|
+
import { useLabels as t } from "../locale/KapiLocaleProvider.js";
|
|
4
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/feedback/KapiSpinner.tsx
|
|
6
|
+
var i = { loading: "Cargando" }, a = ({ size: a = "md", label: o, labelVisible: s, decorative: c, labels: l, className: u, ...d }) => {
|
|
7
|
+
let f = t("spinner", i, l), p = o ?? f.loading, m = /* @__PURE__ */ n("div", {
|
|
8
|
+
className: e("kapi-spinner", a === "sm" && "kapi-spinner--sm"),
|
|
9
|
+
"aria-hidden": "true"
|
|
10
|
+
});
|
|
11
|
+
return c ? /* @__PURE__ */ n("div", {
|
|
12
|
+
...d,
|
|
13
|
+
className: u,
|
|
14
|
+
"aria-hidden": "true",
|
|
15
|
+
children: m
|
|
16
|
+
}) : /* @__PURE__ */ r("div", {
|
|
17
|
+
...d,
|
|
18
|
+
className: u,
|
|
19
|
+
role: "status",
|
|
20
|
+
children: [m, /* @__PURE__ */ n("span", {
|
|
21
|
+
className: s ? void 0 : "kapi-sr-only",
|
|
22
|
+
children: p
|
|
23
|
+
})]
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { i as DEFAULT_SPINNER_LABELS, a as KapiSpinner };
|
|
@@ -6,8 +6,8 @@ import { useLabels as n } from "../locale/KapiLocaleProvider.js";
|
|
|
6
6
|
import { activeElementOf as r, docOf as i } from "../../hooks/ownerDocument.js";
|
|
7
7
|
import { usePortalRootOverride as a } from "../../hooks/portalRoot.js";
|
|
8
8
|
import { modalStack as o } from "../overlays/modalStack.js";
|
|
9
|
-
import { getPortalRoot as s } from "../overlays/useNativeDialog.js";
|
|
10
9
|
/* empty css */
|
|
10
|
+
import { getPortalRoot as s } from "../overlays/useNativeDialog.js";
|
|
11
11
|
import { moveNode as c, raisePopover as l } from "./toastLayer.js";
|
|
12
12
|
import { toastStore as u } from "./toastStore.js";
|
|
13
13
|
import { useEffect as d, useLayoutEffect as f, useRef as p, useState as m, useSyncExternalStore as h } from "react";
|
|
@@ -9,8 +9,8 @@ import { useKapiRoot as s } from "../../hooks/kapiRoot.js";
|
|
|
9
9
|
import { onViewportChange as c } from "../../hooks/rafThrottle.js";
|
|
10
10
|
import { usePlacement as l } from "../../hooks/usePlacement.js";
|
|
11
11
|
import { useDismiss as u } from "../../hooks/useDismiss.js";
|
|
12
|
-
import { trapTabKey as d } from "../../hooks/focusLogic.js";
|
|
13
12
|
/* empty css */
|
|
13
|
+
import { trapTabKey as d } from "../../hooks/focusLogic.js";
|
|
14
14
|
import { TOUR_PLACEMENT as f, filterAvailableSteps as p, highlightBox as m, markTourSeen as h } from "./tourLogic.js";
|
|
15
15
|
import { useCallback as g, useEffect as _, useId as v, useLayoutEffect as y, useRef as b, useState as x } from "react";
|
|
16
16
|
import { jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Partes de `alert` (ver `slotCatalog.ts` para el contrato). Vive junto al componente para que su CSS lo siga. */
|
|
2
|
+
export declare const ALERT_SLOTS: import("../slotsLogic.js").SlotTable<"alert", {
|
|
3
|
+
readonly root: "kapi-alert";
|
|
4
|
+
readonly icon: "kapi-alert__ico";
|
|
5
|
+
readonly body: "kapi-alert__body";
|
|
6
|
+
readonly title: "kapi-alert__title";
|
|
7
|
+
readonly message: "kapi-alert__msg";
|
|
8
|
+
readonly close: "kapi-alert__close";
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineSlots as e } from "../slotsLogic.js";
|
|
2
|
+
//#region src/components/feedback/alertSlots.ts
|
|
3
|
+
var t = e("alert", {
|
|
4
|
+
root: "kapi-alert",
|
|
5
|
+
icon: "kapi-alert__ico",
|
|
6
|
+
body: "kapi-alert__body",
|
|
7
|
+
title: "kapi-alert__title",
|
|
8
|
+
message: "kapi-alert__msg",
|
|
9
|
+
close: "kapi-alert__close"
|
|
10
|
+
});
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as ALERT_SLOTS };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Partes de `countdown` (ver `slotCatalog.ts` para el contrato). Vive junto al componente para que su CSS lo siga. */
|
|
2
|
+
export declare const COUNTDOWN_SLOTS: import("../slotsLogic.js").SlotTable<"countdown", {
|
|
3
|
+
readonly root: "kapi-countdown";
|
|
4
|
+
readonly prefix: "kapi-countdown__prefix";
|
|
5
|
+
readonly time: "kapi-countdown__time";
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineSlots as e } from "../slotsLogic.js";
|
|
2
|
+
//#region src/components/feedback/countdownSlots.ts
|
|
3
|
+
var t = e("countdown", {
|
|
4
|
+
root: "kapi-countdown",
|
|
5
|
+
prefix: "kapi-countdown__prefix",
|
|
6
|
+
time: "kapi-countdown__time"
|
|
7
|
+
});
|
|
8
|
+
//#endregion
|
|
9
|
+
export { t as COUNTDOWN_SLOTS };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Partes de `empty` (ver `slotCatalog.ts` para el contrato). Vive junto al componente para que su CSS lo siga. */
|
|
2
|
+
export declare const EMPTY_SLOTS: import("../slotsLogic.js").SlotTable<"empty", {
|
|
3
|
+
readonly root: "kapi-empty";
|
|
4
|
+
readonly icon: "kapi-empty__icon";
|
|
5
|
+
readonly title: "kapi-empty__title";
|
|
6
|
+
readonly description: "kapi-empty__desc";
|
|
7
|
+
readonly action: "kapi-empty__action";
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineSlots as e } from "../slotsLogic.js";
|
|
2
|
+
//#region src/components/feedback/emptySlots.ts
|
|
3
|
+
var t = e("empty", {
|
|
4
|
+
root: "kapi-empty",
|
|
5
|
+
icon: "kapi-empty__icon",
|
|
6
|
+
title: "kapi-empty__title",
|
|
7
|
+
description: "kapi-empty__desc",
|
|
8
|
+
action: "kapi-empty__action"
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as EMPTY_SLOTS };
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export { KapiAlert,
|
|
2
2
|
/** @deprecated Interno, se quita en 1.0. */
|
|
3
3
|
alertRole, DEFAULT_ALERT_LABELS } from "./KapiAlert.js";
|
|
4
|
-
export type { KapiAlertLabels, KapiAlertProps, KapiAlertRole, KapiAlertTone, KapiAlertVariant } from "./KapiAlert.js";
|
|
4
|
+
export type { KapiAlertLabels, KapiAlertClassNames, KapiAlertProps, KapiAlertRole, KapiAlertTone, KapiAlertVariant } from "./KapiAlert.js";
|
|
5
5
|
export { KapiToastContainer, DEFAULT_TOAST_LABELS } from "./KapiToastContainer.js";
|
|
6
6
|
export type { KapiToastContainerProps, KapiToastLabels } from "./KapiToastContainer.js";
|
|
7
7
|
export { kapiToast, toastStore,
|
|
8
8
|
/** @deprecated Interno, se quita en 1.0. */
|
|
9
9
|
createToastStore, TOAST_ACTION_DURATION, TOAST_DEFAULT_DURATION } from "./toastStore.js";
|
|
10
10
|
export type { KapiToastAction, KapiToastItem, KapiToastMessage, KapiToastOptions, KapiToastPromiseMessages, KapiToastShowOptions, KapiToastStore, KapiToastStoreOptions, KapiToastTone, KapiToastUpdate, KapiToastVariant } from "./toastStore.js";
|
|
11
|
+
export { KapiSpinner, DEFAULT_SPINNER_LABELS } from "./KapiSpinner.js";
|
|
12
|
+
export type { KapiSpinnerProps, KapiSpinnerLabels, KapiSpinnerSize } from "./KapiSpinner.js";
|
|
11
13
|
export { KapiSkeleton } from "./KapiSkeleton.js";
|
|
12
14
|
export type { KapiSkeletonProps } from "./KapiSkeleton.js";
|
|
13
15
|
export { KapiFab, DEFAULT_FAB_LABELS } from "./KapiFab.js";
|
|
@@ -27,9 +29,9 @@ clampPercent, formatPercent,
|
|
|
27
29
|
progressClasses } from "./progressLogic.js";
|
|
28
30
|
export type { KapiProgressTone } from "./progressLogic.js";
|
|
29
31
|
export { KapiEmpty } from "./KapiEmpty.js";
|
|
30
|
-
export type { KapiEmptyProps } from "./KapiEmpty.js";
|
|
32
|
+
export type { KapiEmptyClassNames, KapiEmptyProps } from "./KapiEmpty.js";
|
|
31
33
|
export { KapiCountdown } from "./KapiCountdown.js";
|
|
32
|
-
export type { KapiCountdownProps } from "./KapiCountdown.js";
|
|
34
|
+
export type { KapiCountdownClassNames, KapiCountdownProps } from "./KapiCountdown.js";
|
|
33
35
|
export { KapiUnsavedBar, DEFAULT_UNSAVED_BAR_LABELS } from "./KapiUnsavedBar.js";
|
|
34
36
|
export type { KapiUnsavedBarProps, KapiUnsavedBarLabels } from "./KapiUnsavedBar.js";
|
|
35
37
|
export { KapiBulkBar, DEFAULT_BULK_BAR_LABELS } from "./KapiBulkBar.js";
|
|
@@ -32,6 +32,17 @@ export type KapiFileUploadProps = {
|
|
|
32
32
|
onBlur?: ((event: FocusEvent<HTMLDivElement>) => void) | undefined;
|
|
33
33
|
/** Marca la zona como inválida (`aria-invalid`). Sin la prop, lo toma del `KapiField` (`invalid`). */
|
|
34
34
|
invalid?: boolean | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Progreso de subida de cada archivo, 0–100. Devolver `undefined` para un archivo es no mostrarle
|
|
37
|
+
* barra (todavía no empezó, o ya terminó). Es una **función y no un mapa por nombre** porque la
|
|
38
|
+
* lista admite dos archivos con el mismo nombre y un mapa se los pisaría entre sí.
|
|
39
|
+
*/
|
|
40
|
+
progress?: ((file: File, index: number) => number | undefined) | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Permite pegar archivos del portapapeles con Ctrl/Cmd+V cuando la zona tiene el foco (una captura
|
|
43
|
+
* de pantalla, por ejemplo). Respeta `accept` y `multiple`, igual que arrastrar.
|
|
44
|
+
*/
|
|
45
|
+
paste?: boolean | undefined;
|
|
35
46
|
/** `id`s extra para `aria-describedby` (se suman a la ayuda del campo y al hint). */
|
|
36
47
|
"aria-describedby"?: string | undefined;
|
|
37
48
|
/** Ref a la zona (el elemento enfocable, `role="button"`). */
|
|
@@ -46,6 +57,8 @@ export type KapiFileUploadLabels = {
|
|
|
46
57
|
remove: string;
|
|
47
58
|
/** Ayuda bajo el título (sin `hint`). */
|
|
48
59
|
hint: string;
|
|
60
|
+
/** Prefijo del nombre accesible de la barra de progreso ("Subiendo informe.pdf"). */
|
|
61
|
+
uploading: string;
|
|
49
62
|
};
|
|
50
63
|
export declare const DEFAULT_FILE_UPLOAD_LABELS: KapiFileUploadLabels;
|
|
51
64
|
/**
|
|
@@ -54,4 +67,4 @@ export declare const DEFAULT_FILE_UPLOAD_LABELS: KapiFileUploadLabels;
|
|
|
54
67
|
* Dentro de un `KapiField` la zona toma id, nombre (label del campo + texto de la zona), ayuda y `aria-invalid`.
|
|
55
68
|
* No lleva `aria-required` (no es válido en `role="button"`): el obligatorio se ve en el asterisco del label.
|
|
56
69
|
*/
|
|
57
|
-
export declare const KapiFileUpload: ({ multiple, accept, hint: hintProp, onChange, disabled, className, style, labels, name, id, onBlur, invalid, "aria-describedby": describedBy, ref }: KapiFileUploadProps) => import("react").JSX.Element;
|
|
70
|
+
export declare const KapiFileUpload: ({ multiple, accept, hint: hintProp, onChange, disabled, className, style, labels, name, id, onBlur, invalid, progress, paste, "aria-describedby": describedBy, ref }: KapiFileUploadProps) => import("react").JSX.Element;
|