@kapiuara/ui 0.3.1 → 0.4.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/dist/components/inputs/KapiAutocomplete.js +1 -1
- package/dist/components/inputs/KapiField.d.ts +10 -2
- package/dist/components/inputs/KapiField.js +39 -32
- package/dist/components/inputs/fieldLogic.d.ts +6 -0
- package/dist/components/inputs/fieldLogic.js +5 -2
- package/dist/components/navigation/KapiWizard.d.ts +9 -2
- package/dist/components/navigation/KapiWizard.js +75 -58
- package/dist/components/navigation/wizardLogic.d.ts +13 -3
- package/dist/components/navigation/wizardLogic.js +2 -5
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/package.json +1 -1
|
@@ -129,10 +129,10 @@ var u = {
|
|
|
129
129
|
"aria-expanded": $,
|
|
130
130
|
"aria-controls": N,
|
|
131
131
|
"aria-activedescendant": $ && Q >= 0 ? F(Q) : void 0,
|
|
132
|
-
"aria-busy": X || void 0,
|
|
133
132
|
...t(A ? null : je, {
|
|
134
133
|
id: M,
|
|
135
134
|
describedBy: n(P, O["aria-describedby"]),
|
|
135
|
+
busy: X || void 0,
|
|
136
136
|
invalid: x ? x === "err" : void 0
|
|
137
137
|
}),
|
|
138
138
|
required: C,
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from "react";
|
|
2
2
|
import { type KapiFieldContextValue } from "./fieldLogic";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* `pending` es para mientras una validación asíncrona resuelve: el campo se marca ocupado pero NO
|
|
5
|
+
* inválido, porque pintarlo en rojo antes de saber el resultado le miente a quien lo está usando.
|
|
6
|
+
*/
|
|
7
|
+
export type KapiFieldStatus = "ok" | "err" | "pending";
|
|
4
8
|
export type { KapiFieldContextValue };
|
|
5
9
|
/** Atributos nativos (`id`, `style`, `data-*`…) van al contenedor; el `id` del control es `htmlFor`. */
|
|
6
10
|
export type KapiFieldProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
@@ -14,7 +18,11 @@ export type KapiFieldProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> &
|
|
|
14
18
|
help?: ReactNode | undefined;
|
|
15
19
|
/** `id` del texto de ayuda. Opcional: sin él se deriva del id del control. */
|
|
16
20
|
helpId?: string | undefined;
|
|
17
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Estado de validación: pinta la ayuda y le pone ícono. Con `err` el control queda `aria-invalid`
|
|
23
|
+
* y la ayuda interrumpe (`role="alert"`); con `pending` queda `aria-busy` y la ayuda se anuncia
|
|
24
|
+
* sin interrumpir (`aria-live="polite"`), que es lo que corresponde cuando todavía no pasó nada.
|
|
25
|
+
*/
|
|
18
26
|
status?: KapiFieldStatus | undefined;
|
|
19
27
|
/** El control del campo (input, select…); recibe `id`, `aria-describedby` y estado del contexto. */
|
|
20
28
|
children: ReactNode;
|
|
@@ -2,54 +2,61 @@
|
|
|
2
2
|
import { fieldIds as e } from "./fieldLogic.js";
|
|
3
3
|
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
4
4
|
import { createContext as r, useContext as i, useId as a, useMemo as o } from "react";
|
|
5
|
-
import { AlertTriangle as s, CheckCircle2 as c } from "lucide-react";
|
|
5
|
+
import { AlertTriangle as s, CheckCircle2 as c, LoaderCircle as l } from "lucide-react";
|
|
6
6
|
//#region src/components/inputs/KapiField.tsx
|
|
7
|
-
var
|
|
8
|
-
let
|
|
7
|
+
var u = r(null), d = () => i(u), f = (e = "") => ["kapi-field", e].filter(Boolean).join(" "), p = (e) => ["kapi-help", e && `kapi-help--${e}`].filter(Boolean).join(" "), m = ({ label: r, htmlFor: i, required: d = !1, help: m, helpId: h, status: g, className: _, children: v, ...y }) => {
|
|
8
|
+
let b = a(), x = !!m, { controlId: S, labelId: C, helpId: w } = e({
|
|
9
9
|
htmlFor: i,
|
|
10
|
-
autoId:
|
|
11
|
-
helpId:
|
|
12
|
-
hasHelp:
|
|
13
|
-
}),
|
|
14
|
-
controlId:
|
|
15
|
-
labelId: r == null ? void 0 :
|
|
16
|
-
helpId:
|
|
17
|
-
required:
|
|
18
|
-
invalid:
|
|
10
|
+
autoId: b,
|
|
11
|
+
helpId: h,
|
|
12
|
+
hasHelp: x
|
|
13
|
+
}), T = o(() => ({
|
|
14
|
+
controlId: S,
|
|
15
|
+
labelId: r == null ? void 0 : C,
|
|
16
|
+
helpId: w,
|
|
17
|
+
required: d,
|
|
18
|
+
invalid: g === "err",
|
|
19
|
+
busy: g === "pending"
|
|
19
20
|
}), [
|
|
20
|
-
x,
|
|
21
21
|
S,
|
|
22
|
-
r,
|
|
23
22
|
C,
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
r,
|
|
24
|
+
w,
|
|
25
|
+
d,
|
|
26
|
+
g
|
|
26
27
|
]);
|
|
27
|
-
return /* @__PURE__ */ t(
|
|
28
|
-
value:
|
|
28
|
+
return /* @__PURE__ */ t(u.Provider, {
|
|
29
|
+
value: T,
|
|
29
30
|
children: /* @__PURE__ */ n("div", {
|
|
30
|
-
...
|
|
31
|
-
className:
|
|
31
|
+
...y,
|
|
32
|
+
className: f(_),
|
|
32
33
|
children: [
|
|
33
34
|
r != null && /* @__PURE__ */ n("label", {
|
|
34
|
-
id: S,
|
|
35
|
-
htmlFor: x,
|
|
36
|
-
children: [r, u && " *"]
|
|
37
|
-
}),
|
|
38
|
-
_,
|
|
39
|
-
b ? /* @__PURE__ */ n("span", {
|
|
40
35
|
id: C,
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
htmlFor: S,
|
|
37
|
+
children: [r, d && " *"]
|
|
38
|
+
}),
|
|
39
|
+
v,
|
|
40
|
+
x ? /* @__PURE__ */ n("span", {
|
|
41
|
+
id: w,
|
|
42
|
+
className: p(g),
|
|
43
|
+
role: g === "err" ? "alert" : void 0,
|
|
44
|
+
"aria-live": g === "pending" ? "polite" : void 0,
|
|
43
45
|
children: [
|
|
44
|
-
|
|
46
|
+
g === "ok" && /* @__PURE__ */ t(c, {
|
|
45
47
|
size: 13,
|
|
46
48
|
strokeWidth: 2.2
|
|
47
49
|
}),
|
|
48
|
-
|
|
50
|
+
g === "err" && /* @__PURE__ */ t(s, {
|
|
49
51
|
size: 13,
|
|
50
52
|
strokeWidth: 2.2
|
|
51
53
|
}),
|
|
52
|
-
|
|
54
|
+
g === "pending" && /* @__PURE__ */ t(l, {
|
|
55
|
+
size: 13,
|
|
56
|
+
strokeWidth: 2.2,
|
|
57
|
+
className: "kapi-spinner"
|
|
58
|
+
}),
|
|
59
|
+
m
|
|
53
60
|
]
|
|
54
61
|
}) : null
|
|
55
62
|
]
|
|
@@ -57,4 +64,4 @@ var l = r(null), u = () => i(l), d = (e = "") => ["kapi-field", e].filter(Boolea
|
|
|
57
64
|
});
|
|
58
65
|
};
|
|
59
66
|
//#endregion
|
|
60
|
-
export {
|
|
67
|
+
export { m as KapiField, f as fieldClasses, p as helpClasses, d as useKapiField };
|
|
@@ -6,6 +6,8 @@ export type KapiFieldContextValue = {
|
|
|
6
6
|
helpId?: string | undefined;
|
|
7
7
|
required: boolean;
|
|
8
8
|
invalid: boolean;
|
|
9
|
+
/** El campo está esperando una validación asíncrona: ocupado, pero todavía no inválido. */
|
|
10
|
+
busy: boolean;
|
|
9
11
|
};
|
|
10
12
|
/** Suma ids para `aria-describedby`/`aria-labelledby`: sin vacíos ni repetidos; `undefined` si no queda ninguno. */
|
|
11
13
|
export declare const joinIds: (...ids: (string | undefined | null | false)[]) => string | undefined;
|
|
@@ -30,6 +32,7 @@ export declare const fieldControlProps: (ctx: KapiFieldContextValue | null, own:
|
|
|
30
32
|
describedBy?: string | undefined;
|
|
31
33
|
invalid?: boolean | undefined;
|
|
32
34
|
required?: boolean | undefined;
|
|
35
|
+
busy?: boolean | undefined;
|
|
33
36
|
labelable?: boolean | undefined;
|
|
34
37
|
ariaLabel?: string | undefined;
|
|
35
38
|
}) => {
|
|
@@ -37,6 +40,7 @@ export declare const fieldControlProps: (ctx: KapiFieldContextValue | null, own:
|
|
|
37
40
|
"aria-describedby": string | undefined;
|
|
38
41
|
"aria-invalid": true | undefined;
|
|
39
42
|
"aria-required": true | undefined;
|
|
43
|
+
"aria-busy": true | undefined;
|
|
40
44
|
"aria-labelledby": string | undefined;
|
|
41
45
|
};
|
|
42
46
|
/**
|
|
@@ -49,6 +53,7 @@ export declare const nativeFieldProps: (ctx: KapiFieldContextValue | null, own:
|
|
|
49
53
|
describedBy?: string | undefined;
|
|
50
54
|
invalid?: boolean | undefined;
|
|
51
55
|
required?: boolean | undefined;
|
|
56
|
+
busy?: boolean | undefined;
|
|
52
57
|
ariaInvalid?: AriaAttributes["aria-invalid"] | undefined;
|
|
53
58
|
ariaRequired?: AriaAttributes["aria-required"] | undefined;
|
|
54
59
|
takeId?: boolean | undefined;
|
|
@@ -57,6 +62,7 @@ export declare const nativeFieldProps: (ctx: KapiFieldContextValue | null, own:
|
|
|
57
62
|
"aria-describedby": string | undefined;
|
|
58
63
|
"aria-invalid": boolean | "true" | "false" | "grammar" | "spelling" | undefined;
|
|
59
64
|
"aria-required": (boolean | "true" | "false") | undefined;
|
|
65
|
+
"aria-busy": true | undefined;
|
|
60
66
|
};
|
|
61
67
|
/**
|
|
62
68
|
* ¿El foco sale del control? `next` es el `relatedTarget` del blur; `containers` son las partes del
|
|
@@ -14,19 +14,22 @@ var e = (...e) => {
|
|
|
14
14
|
"aria-describedby": e(t?.helpId, n.describedBy),
|
|
15
15
|
"aria-invalid": n.invalid ?? t?.invalid ? !0 : void 0,
|
|
16
16
|
"aria-required": n.required ?? t?.required ? !0 : void 0,
|
|
17
|
+
"aria-busy": n.busy ?? t?.busy ? !0 : void 0,
|
|
17
18
|
"aria-labelledby": n.labelable === !1 && !n.ariaLabel ? t?.labelId : void 0
|
|
18
19
|
}), r = (e, t) => {
|
|
19
20
|
let r = n(e, {
|
|
20
21
|
id: t.id,
|
|
21
22
|
describedBy: t.describedBy,
|
|
22
23
|
invalid: t.invalid,
|
|
23
|
-
required: t.required
|
|
24
|
+
required: t.required,
|
|
25
|
+
busy: t.busy
|
|
24
26
|
});
|
|
25
27
|
return {
|
|
26
28
|
id: t.takeId === !1 ? t.id : r.id,
|
|
27
29
|
"aria-describedby": r["aria-describedby"],
|
|
28
30
|
"aria-invalid": t.ariaInvalid ?? r["aria-invalid"],
|
|
29
|
-
"aria-required": t.ariaRequired ?? r["aria-required"]
|
|
31
|
+
"aria-required": t.ariaRequired ?? r["aria-required"],
|
|
32
|
+
"aria-busy": r["aria-busy"]
|
|
30
33
|
};
|
|
31
34
|
}, i = (e, ...t) => !(e instanceof Node && t.some((t) => t?.contains(e))), a = (e, t) => {
|
|
32
35
|
typeof e == "function" ? e(t) : e && (e.current = t);
|
|
@@ -4,8 +4,13 @@ export type KapiWizardStep = {
|
|
|
4
4
|
title: string;
|
|
5
5
|
desc?: ReactNode | undefined;
|
|
6
6
|
content: ReactNode;
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Si devuelve `false`, "Siguiente"/"Finalizar" NO avanza. Puede devolver una promesa: mientras
|
|
9
|
+
* resuelve, el wizard marca los botones como ocupados y no deja volver a apretar. Cada paso
|
|
10
|
+
* decide por su cuenta, así que un wizard puede mezclar pasos sincrónicos con otros que
|
|
11
|
+
* consultan al servidor. Una promesa rechazada se trata como `false`: no avanza.
|
|
12
|
+
*/
|
|
13
|
+
validate?: (() => boolean | Promise<boolean>) | undefined;
|
|
9
14
|
};
|
|
10
15
|
export type KapiWizardOrientation = "horizontal" | "vertical";
|
|
11
16
|
export type KapiWizardLabels = {
|
|
@@ -13,6 +18,8 @@ export type KapiWizardLabels = {
|
|
|
13
18
|
cancel: string;
|
|
14
19
|
back: string;
|
|
15
20
|
next: string;
|
|
21
|
+
/** Reemplaza al texto de avanzar mientras un `validate` asíncrono está resolviendo. */
|
|
22
|
+
validating: string;
|
|
16
23
|
};
|
|
17
24
|
export declare const DEFAULT_WIZARD_LABELS: KapiWizardLabels;
|
|
18
25
|
/** Atributos nativos (`id`, `style`, `data-*`…) van al contenedor del wizard. */
|
|
@@ -2,103 +2,120 @@
|
|
|
2
2
|
import { KapiButton as e } from "../inputs/KapiButton.js";
|
|
3
3
|
import { useLabels as t } from "../locale/KapiLocaleProvider.js";
|
|
4
4
|
import { joinClasses as n } from "../rootProps.js";
|
|
5
|
-
import { canJumpTo as r, clampStep as i,
|
|
6
|
-
import { Fragment as
|
|
7
|
-
import { useState as
|
|
8
|
-
import { Check as
|
|
5
|
+
import { canJumpTo as r, clampStep as i, isThenable as a, resolveAdvance as o } from "./wizardLogic.js";
|
|
6
|
+
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
|
+
import { useRef as u, useState as d } from "react";
|
|
8
|
+
import { Check as f, ChevronLeft as p, ChevronRight as m } from "lucide-react";
|
|
9
9
|
//#region src/components/navigation/KapiWizard.tsx
|
|
10
|
-
var
|
|
10
|
+
var h = {
|
|
11
11
|
finish: "Finalizar",
|
|
12
12
|
cancel: "Cancelar",
|
|
13
13
|
back: "Atrás",
|
|
14
|
-
next: "Siguiente"
|
|
15
|
-
|
|
14
|
+
next: "Siguiente",
|
|
15
|
+
validating: "Validando…"
|
|
16
|
+
}, g = {
|
|
16
17
|
size: 15,
|
|
17
18
|
strokeWidth: 2.2
|
|
18
|
-
},
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
let
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
}, _ = (e, t) => e === void 0 ? t : e, v = ({ steps: v, orientation: y = "horizontal", onFinish: b, onCancel: x, finishLabel: S, cancelLabel: C, backLabel: w, nextLabel: T, labels: E, step: D, defaultStep: O = 0, onStepChange: k, className: A, ...j }) => {
|
|
20
|
+
let M = t("wizard", h, E), [N, P] = d(O), [F, I] = d(!1), L = u(0), R = u(0), z = i(D ?? N, v.length);
|
|
21
|
+
R.current = z;
|
|
22
|
+
let B = v[z];
|
|
23
|
+
if (!B) return null;
|
|
24
|
+
let V = z === v.length - 1, H = (e) => {
|
|
25
|
+
let t = i(e, v.length);
|
|
26
|
+
t !== z && (D === void 0 && P(t), k?.(t));
|
|
27
|
+
}, U = (e) => {
|
|
28
|
+
r(e, z) && H(e);
|
|
29
|
+
}, W = (e, t) => {
|
|
30
|
+
let n = o(v, e, t);
|
|
31
|
+
n === "next" ? H(e + 1) : n === "finish" && b?.();
|
|
32
|
+
}, G = (e, t, n) => {
|
|
33
|
+
e === L.current && (I(!1), t === R.current && W(t, n));
|
|
34
|
+
}, K = () => {
|
|
35
|
+
if (F) return;
|
|
36
|
+
let e = !B.validate || B.validate();
|
|
37
|
+
if (!a(e)) {
|
|
38
|
+
W(z, !!e);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
let t = L.current += 1, n = z;
|
|
42
|
+
I(!0), e.then((e) => G(t, n, !!e), () => G(t, n, !1));
|
|
43
|
+
}, q = /* @__PURE__ */ l("div", {
|
|
30
44
|
className: "kapi-wz__nav",
|
|
31
|
-
children: [/* @__PURE__ */
|
|
32
|
-
onClick:
|
|
33
|
-
|
|
34
|
-
|
|
45
|
+
children: [/* @__PURE__ */ c(e, {
|
|
46
|
+
onClick: z === 0 ? x : () => H(z - 1),
|
|
47
|
+
disabled: F,
|
|
48
|
+
children: z === 0 ? _(C, M.cancel) : /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(p, { ...g }), _(w, M.back)] })
|
|
49
|
+
}), /* @__PURE__ */ c(e, {
|
|
35
50
|
variant: "primary",
|
|
36
|
-
onClick:
|
|
37
|
-
|
|
51
|
+
onClick: K,
|
|
52
|
+
disabled: F,
|
|
53
|
+
"aria-busy": F || void 0,
|
|
54
|
+
children: F ? M.validating : V ? _(S, M.finish) : /* @__PURE__ */ l(s, { children: [_(T, M.next), /* @__PURE__ */ c(m, { ...g })] })
|
|
38
55
|
})]
|
|
39
|
-
}),
|
|
56
|
+
}), J = /* @__PURE__ */ c("div", {
|
|
40
57
|
className: "kapi-wz__pane",
|
|
41
|
-
children:
|
|
42
|
-
},
|
|
43
|
-
return
|
|
44
|
-
...
|
|
45
|
-
className: n("kapi-wz kapi-wz--v",
|
|
46
|
-
children: [/* @__PURE__ */
|
|
58
|
+
children: B.content
|
|
59
|
+
}, z);
|
|
60
|
+
return y === "vertical" ? /* @__PURE__ */ l("div", {
|
|
61
|
+
...j,
|
|
62
|
+
className: n("kapi-wz kapi-wz--v", A),
|
|
63
|
+
children: [/* @__PURE__ */ c("div", {
|
|
47
64
|
className: "kapi-wz__rail",
|
|
48
|
-
children:
|
|
65
|
+
children: v.map((e, t) => /* @__PURE__ */ l("button", {
|
|
49
66
|
type: "button",
|
|
50
|
-
className: `kapi-wz__vstep${t ===
|
|
51
|
-
"aria-current": t ===
|
|
52
|
-
onClick: () =>
|
|
53
|
-
children: [/* @__PURE__ */
|
|
54
|
-
className: `kapi-step__dot${t <
|
|
55
|
-
children: t <
|
|
67
|
+
className: `kapi-wz__vstep${t === z ? " is-on" : ""}`,
|
|
68
|
+
"aria-current": t === z ? "step" : void 0,
|
|
69
|
+
onClick: () => U(t),
|
|
70
|
+
children: [/* @__PURE__ */ c("span", {
|
|
71
|
+
className: `kapi-step__dot${t < z ? " kapi-step__dot--done" : ""}${t === z ? " kapi-step__dot--on" : ""}`,
|
|
72
|
+
children: t < z ? /* @__PURE__ */ c(f, {
|
|
56
73
|
size: 13,
|
|
57
74
|
strokeWidth: 3
|
|
58
75
|
}) : t + 1
|
|
59
|
-
}), /* @__PURE__ */
|
|
76
|
+
}), /* @__PURE__ */ l("span", {
|
|
60
77
|
className: "kapi-wz__vlabel",
|
|
61
|
-
children: [/* @__PURE__ */
|
|
78
|
+
children: [/* @__PURE__ */ c("b", { children: e.title }), e.desc && /* @__PURE__ */ c("span", { children: e.desc })]
|
|
62
79
|
})]
|
|
63
80
|
}, `${t}-${e.title}`))
|
|
64
|
-
}), /* @__PURE__ */
|
|
81
|
+
}), /* @__PURE__ */ l("div", {
|
|
65
82
|
className: "kapi-wz__main",
|
|
66
|
-
children: [
|
|
83
|
+
children: [J, q]
|
|
67
84
|
})]
|
|
68
|
-
}) : /* @__PURE__ */
|
|
69
|
-
...
|
|
70
|
-
className: n("kapi-wz",
|
|
85
|
+
}) : /* @__PURE__ */ l("div", {
|
|
86
|
+
...j,
|
|
87
|
+
className: n("kapi-wz", A),
|
|
71
88
|
children: [
|
|
72
|
-
/* @__PURE__ */
|
|
89
|
+
/* @__PURE__ */ c("div", {
|
|
73
90
|
className: "kapi-wz__steps",
|
|
74
|
-
children:
|
|
91
|
+
children: v.map((e, t) => /* @__PURE__ */ l("button", {
|
|
75
92
|
type: "button",
|
|
76
|
-
className: `kapi-wz__step${t ===
|
|
77
|
-
"aria-current": t ===
|
|
78
|
-
onClick: () =>
|
|
93
|
+
className: `kapi-wz__step${t === z ? " is-on" : ""}${t < z ? " is-done" : ""}`,
|
|
94
|
+
"aria-current": t === z ? "step" : void 0,
|
|
95
|
+
onClick: () => U(t),
|
|
79
96
|
children: [
|
|
80
|
-
/* @__PURE__ */
|
|
97
|
+
/* @__PURE__ */ c("span", {
|
|
81
98
|
className: "kapi-wz__num",
|
|
82
|
-
children: t <
|
|
99
|
+
children: t < z ? /* @__PURE__ */ c(f, {
|
|
83
100
|
size: 16,
|
|
84
101
|
strokeWidth: 3
|
|
85
102
|
}) : t + 1
|
|
86
103
|
}),
|
|
87
|
-
/* @__PURE__ */
|
|
104
|
+
/* @__PURE__ */ c("span", {
|
|
88
105
|
className: "kapi-wz__st",
|
|
89
106
|
children: e.title
|
|
90
107
|
}),
|
|
91
|
-
e.desc && /* @__PURE__ */
|
|
108
|
+
e.desc && /* @__PURE__ */ c("span", {
|
|
92
109
|
className: "kapi-wz__ss",
|
|
93
110
|
children: e.desc
|
|
94
111
|
})
|
|
95
112
|
]
|
|
96
113
|
}, `${t}-${e.title}`))
|
|
97
114
|
}),
|
|
98
|
-
|
|
99
|
-
|
|
115
|
+
J,
|
|
116
|
+
q
|
|
100
117
|
]
|
|
101
118
|
});
|
|
102
119
|
};
|
|
103
120
|
//#endregion
|
|
104
|
-
export {
|
|
121
|
+
export { h as DEFAULT_WIZARD_LABELS, v as KapiWizard };
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
/** Lo mínimo que la lógica necesita de un paso. */
|
|
2
2
|
export type WizardStepLike = {
|
|
3
|
-
validate?: (() => boolean) | undefined;
|
|
3
|
+
validate?: (() => boolean | Promise<boolean>) | undefined;
|
|
4
4
|
};
|
|
5
5
|
export type WizardAdvance = "blocked" | "next" | "finish";
|
|
6
6
|
/** Mantiene el índice dentro de [0, total-1]. Con 0 pasos devuelve 0. */
|
|
7
7
|
export declare const clampStep: (index: number, total: number) => number;
|
|
8
8
|
/** Sólo se puede saltar hacia atrás por click (nunca adelante). */
|
|
9
9
|
export declare const canJumpTo: (target: number, current: number) => boolean;
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Un `validate` que devuelve una promesa. Se mira el `then` y no `instanceof Promise`: un
|
|
12
|
+
* consumidor puede devolver la promesa de otra realm o de una librería, y seguiría siendo
|
|
13
|
+
* esperable.
|
|
14
|
+
*/
|
|
15
|
+
export declare const isThenable: (value: unknown) => value is Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Qué pasa al apretar "Siguiente", una vez que YA se sabe si el paso dio por válido. No llama a
|
|
18
|
+
* `validate`: quien la llama decide si esperó una promesa o no, y así esta función queda pura y
|
|
19
|
+
* sirve igual para el camino sincrónico y para el asíncrono.
|
|
20
|
+
*/
|
|
21
|
+
export declare const resolveAdvance: (steps: readonly WizardStepLike[], current: number, valid: boolean) => WizardAdvance;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
//#region src/components/navigation/wizardLogic.ts
|
|
2
|
-
var e = (e, t) => t <= 0 ? 0 : Math.min(Math.max(Math.trunc(e) || 0, 0), t - 1), t = (e, t) => e < t, n = (e, t) =>
|
|
3
|
-
let n = e[t];
|
|
4
|
-
return !n || n.validate && !n.validate() ? "blocked" : t >= e.length - 1 ? "finish" : "next";
|
|
5
|
-
};
|
|
2
|
+
var e = (e, t) => t <= 0 ? 0 : Math.min(Math.max(Math.trunc(e) || 0, 0), t - 1), t = (e, t) => e < t, n = (e) => typeof e?.then == "function", r = (e, t, n) => !e[t] || !n ? "blocked" : t >= e.length - 1 ? "finish" : "next";
|
|
6
3
|
//#endregion
|
|
7
|
-
export { t as canJumpTo, e as clampStep, n as resolveAdvance };
|
|
4
|
+
export { t as canJumpTo, e as clampStep, n as isThenable, r as resolveAdvance };
|