@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.
Files changed (94) hide show
  1. package/README.md +259 -9
  2. package/dist/components/data/KapiDataTable.d.ts +12 -2
  3. package/dist/components/data/KapiDataTable.js +78 -76
  4. package/dist/components/data/KapiScatterChart.d.ts +56 -0
  5. package/dist/components/data/KapiScatterChart.js +90 -0
  6. package/dist/components/data/KapiTable.d.ts +2 -2
  7. package/dist/components/data/KapiTable.js +229 -227
  8. package/dist/components/data/chartFrame.d.ts +20 -2
  9. package/dist/components/data/chartFrame.js +33 -24
  10. package/dist/components/data/index.d.ts +5 -1
  11. package/dist/components/data/scatterLogic.d.ts +56 -0
  12. package/dist/components/data/scatterLogic.js +43 -0
  13. package/dist/components/data/tableTypes.d.ts +37 -0
  14. package/dist/components/data/useRowKeyWarning.d.ts +9 -3
  15. package/dist/components/data/useRowKeyWarning.js +7 -7
  16. package/dist/components/data/useTableSelection.d.ts +3 -2
  17. package/dist/components/data/useTableSelection.js +3 -3
  18. package/dist/components/display/KapiAvatarGroup.d.ts +14 -2
  19. package/dist/components/display/KapiAvatarGroup.js +25 -23
  20. package/dist/components/display/KapiTimeline.d.ts +14 -0
  21. package/dist/components/display/KapiTimeline.js +28 -21
  22. package/dist/components/display/avatarGroupSlots.d.ts +6 -0
  23. package/dist/components/display/avatarGroupSlots.js +9 -0
  24. package/dist/components/display/index.d.ts +1 -1
  25. package/dist/components/feedback/KapiAlert.d.ts +6 -1
  26. package/dist/components/feedback/KapiAlert.js +45 -44
  27. package/dist/components/feedback/KapiCountdown.d.ts +12 -1
  28. package/dist/components/feedback/KapiCountdown.js +34 -31
  29. package/dist/components/feedback/KapiEmpty.d.ts +6 -1
  30. package/dist/components/feedback/KapiEmpty.js +20 -18
  31. package/dist/components/feedback/KapiProgress.js +1 -1
  32. package/dist/components/feedback/KapiSpinner.d.ts +48 -0
  33. package/dist/components/feedback/KapiSpinner.js +27 -0
  34. package/dist/components/feedback/KapiToastContainer.js +1 -1
  35. package/dist/components/feedback/KapiTour.js +1 -1
  36. package/dist/components/feedback/alertSlots.d.ts +9 -0
  37. package/dist/components/feedback/alertSlots.js +12 -0
  38. package/dist/components/feedback/countdownSlots.d.ts +6 -0
  39. package/dist/components/feedback/countdownSlots.js +9 -0
  40. package/dist/components/feedback/emptySlots.d.ts +8 -0
  41. package/dist/components/feedback/emptySlots.js +11 -0
  42. package/dist/components/feedback/index.d.ts +5 -3
  43. package/dist/components/inputs/KapiFileUpload.d.ts +14 -1
  44. package/dist/components/inputs/KapiFileUpload.js +80 -67
  45. package/dist/components/inputs/formBridgeLogic.d.ts +104 -0
  46. package/dist/components/inputs/formBridgeLogic.js +25 -0
  47. package/dist/components/inputs/index.d.ts +2 -0
  48. package/dist/components/locale/labelRegistry.d.ts +8 -0
  49. package/dist/components/navigation/KapiSteps.d.ts +26 -5
  50. package/dist/components/navigation/KapiSteps.js +55 -43
  51. package/dist/components/overlays/KapiImageViewer.d.ts +63 -0
  52. package/dist/components/overlays/KapiImageViewer.js +106 -0
  53. package/dist/components/overlays/KapiShortcutsHelp.d.ts +53 -0
  54. package/dist/components/overlays/KapiShortcutsHelp.js +55 -0
  55. package/dist/components/overlays/KapiTooltip.d.ts +49 -10
  56. package/dist/components/overlays/KapiTooltip.js +110 -58
  57. package/dist/components/overlays/KapiViewport.d.ts +63 -0
  58. package/dist/components/overlays/KapiViewport.js +195 -0
  59. package/dist/components/overlays/index.d.ts +8 -0
  60. package/dist/components/overlays/shortcutsHelpSlots.d.ts +9 -0
  61. package/dist/components/overlays/shortcutsHelpSlots.js +12 -0
  62. package/dist/components/overlays/viewportLogic.d.ts +73 -0
  63. package/dist/components/overlays/viewportLogic.js +54 -0
  64. package/dist/components/slotCatalog.d.ts +33 -0
  65. package/dist/components/slotCatalog.js +30 -20
  66. package/dist/css/base.css +1 -1
  67. package/dist/css/components/data/KapiScatterChart.css +1 -0
  68. package/dist/css/components/display/display.css +1 -1
  69. package/dist/css/components/inputs/KapiFileUpload.css +1 -1
  70. package/dist/css/components/navigation/KapiSteps.css +1 -1
  71. package/dist/css/components/overlays/KapiViewport.css +1 -0
  72. package/dist/css/components/overlays/overlays.css +1 -1
  73. package/dist/hooks/elementSizeLogic.d.ts +15 -0
  74. package/dist/hooks/elementSizeLogic.js +7 -0
  75. package/dist/hooks/hotkeyLogic.d.ts +9 -0
  76. package/dist/hooks/hotkeyLogic.js +16 -15
  77. package/dist/hooks/hotkeyRegistry.d.ts +44 -0
  78. package/dist/hooks/hotkeyRegistry.js +32 -0
  79. package/dist/hooks/index.d.ts +10 -0
  80. package/dist/hooks/themeDeriveLogic.js +2 -2
  81. package/dist/hooks/useDebouncedValue.d.ts +30 -0
  82. package/dist/hooks/useDebouncedValue.js +26 -0
  83. package/dist/hooks/useDisclosure.d.ts +39 -0
  84. package/dist/hooks/useDisclosure.js +35 -0
  85. package/dist/hooks/useElementSize.d.ts +27 -0
  86. package/dist/hooks/useElementSize.js +29 -0
  87. package/dist/hooks/useHotkey.d.ts +8 -0
  88. package/dist/hooks/useHotkey.js +27 -15
  89. package/dist/index.js +201 -188
  90. package/dist/kapi.css +1 -1
  91. package/dist/kapi.layered.css +1 -1
  92. package/dist/logic.d.ts +4 -0
  93. package/dist/logic.js +33 -29
  94. package/package.json +2 -2
@@ -6,124 +6,137 @@ import { fieldControlProps as n, joinIds as r } from "./fieldLogic.js";
6
6
  import { useKapiField as i } from "./KapiField.js";
7
7
  import { formatFileSize as a, isActivationKey as o, matchesAccept as s, mergeFiles as c, removeFileAt as l } from "./fileUploadLogic.js";
8
8
  /* empty css */
9
- import { useEffect as u, useId as d, useRef as f, useState as p } from "react";
10
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
11
- import { FileText as g, UploadCloud as _, X as v } from "lucide-react";
9
+ import { KapiProgress as u } from "../feedback/KapiProgress.js";
10
+ import { useEffect as d, useId as f, useRef as p, useState as m } from "react";
11
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
12
+ import { FileText as _, UploadCloud as v, X as y } from "lucide-react";
12
13
  //#region src/components/inputs/KapiFileUpload.tsx
13
- var y = {
14
+ var b = {
14
15
  drop: "Arrastra archivos o",
15
16
  choose: "elige",
16
17
  remove: "Quitar",
17
- hint: "PDF, JPG, PNG · hasta 10MB"
18
- }, b = ({ multiple: b = !0, accept: x, hint: S, onChange: C, disabled: w = !1, className: T, style: E, labels: D, name: O, id: k, onBlur: A, invalid: j, "aria-describedby": M, ref: N }) => {
19
- let P = t("fileUpload", y, D), F = S ?? P.hint, I = i(), [L, R] = p([]), [z, B] = p(!1), V = f(null), H = d(), U = `${H}-title`, W = `${H}-hint`, G = !!I?.labelId, K = n(I, {
20
- id: k,
21
- describedBy: r(G && W, M),
22
- invalid: j
18
+ hint: "PDF, JPG, PNG · hasta 10MB",
19
+ uploading: "Subiendo"
20
+ }, x = ({ multiple: x = !0, accept: S, hint: C, onChange: w, disabled: T = !1, className: E, style: D, labels: O, name: k, id: A, onBlur: j, invalid: M, progress: N, paste: P = !1, "aria-describedby": F, ref: I }) => {
21
+ let L = t("fileUpload", b, O), R = C ?? L.hint, z = i(), [B, V] = m([]), [H, U] = m(!1), W = p(null), G = f(), K = `${G}-title`, q = `${G}-hint`, J = !!z?.labelId, Y = n(z, {
22
+ id: A,
23
+ describedBy: r(J && q, F),
24
+ invalid: M
23
25
  });
24
- u(() => {
25
- let e = V.current;
26
- if (!O || !e || typeof DataTransfer > "u" || L.length === 0 && !e.files?.length) return;
26
+ d(() => {
27
+ let e = W.current;
28
+ if (!k || !e || typeof DataTransfer > "u" || B.length === 0 && !e.files?.length) return;
27
29
  let t = new DataTransfer();
28
- L.forEach((e) => t.items.add(e)), e.files = t.files;
29
- }, [L, O]);
30
- let q = (e) => {
31
- R(e), C?.(e);
32
- }, J = (e) => {
30
+ B.forEach((e) => t.items.add(e)), e.files = t.files;
31
+ }, [B, k]);
32
+ let X = (e) => {
33
+ V(e), w?.(e);
34
+ }, Z = (e) => {
33
35
  let t = Array.from(e ?? []);
34
- t.length !== 0 && q(c(L, t, b));
35
- }, Y = () => V.current?.click();
36
- return /* @__PURE__ */ h("div", {
37
- className: e("kapi-upload-wrap", T),
38
- style: E,
36
+ t.length !== 0 && X(c(B, t, x));
37
+ }, Q = () => W.current?.click();
38
+ return /* @__PURE__ */ g("div", {
39
+ className: e("kapi-upload-wrap", E),
40
+ style: D,
39
41
  children: [
40
- /* @__PURE__ */ h("div", {
41
- ref: N,
42
- id: K.id,
43
- "aria-describedby": K["aria-describedby"],
44
- "aria-invalid": K["aria-invalid"],
45
- "aria-labelledby": G ? r(I?.labelId, U) : void 0,
46
- onBlur: A,
47
- className: `kapi-upload${z ? " is-over" : ""}`,
48
- onClick: Y,
42
+ /* @__PURE__ */ g("div", {
43
+ ref: I,
44
+ id: Y.id,
45
+ "aria-describedby": Y["aria-describedby"],
46
+ "aria-invalid": Y["aria-invalid"],
47
+ "aria-labelledby": J ? r(z?.labelId, K) : void 0,
48
+ onBlur: j,
49
+ className: `kapi-upload${H ? " is-over" : ""}`,
50
+ onClick: Q,
49
51
  onKeyDown: (e) => {
50
- o(e.key) && (e.preventDefault(), Y());
52
+ o(e.key) && (e.preventDefault(), Q());
51
53
  },
52
54
  onDragOver: (e) => {
53
- e.preventDefault(), w || B(!0);
55
+ e.preventDefault(), T || U(!0);
54
56
  },
55
- onDragLeave: () => B(!1),
57
+ onDragLeave: () => U(!1),
56
58
  onDrop: (e) => {
57
- if (e.preventDefault(), B(!1), w) return;
58
- let t = Array.from(e.dataTransfer.files).filter((e) => s(e, x));
59
- t.length !== 0 && q(c(L, t, b));
59
+ if (e.preventDefault(), U(!1), T) return;
60
+ let t = Array.from(e.dataTransfer.files).filter((e) => s(e, S));
61
+ t.length !== 0 && X(c(B, t, x));
62
+ },
63
+ onPaste: (e) => {
64
+ if (!P || T) return;
65
+ let t = Array.from(e.clipboardData?.files ?? []).filter((e) => s(e, S));
66
+ t.length !== 0 && (e.preventDefault(), X(c(B, t, x)));
60
67
  },
61
68
  role: "button",
62
- tabIndex: w ? -1 : 0,
63
- "aria-disabled": w || void 0,
64
- children: [/* @__PURE__ */ m("span", {
69
+ tabIndex: T ? -1 : 0,
70
+ "aria-disabled": T || void 0,
71
+ children: [/* @__PURE__ */ h("span", {
65
72
  className: "kapi-upload__ico",
66
- children: /* @__PURE__ */ m(_, {
73
+ children: /* @__PURE__ */ h(v, {
67
74
  size: 22,
68
75
  strokeWidth: 1.9
69
76
  })
70
- }), /* @__PURE__ */ h("div", {
77
+ }), /* @__PURE__ */ g("div", {
71
78
  className: "kapi-upload__body",
72
- children: [/* @__PURE__ */ h("div", {
73
- id: U,
79
+ children: [/* @__PURE__ */ g("div", {
80
+ id: K,
74
81
  className: "kapi-upload__t",
75
82
  children: [
76
- P.drop,
83
+ L.drop,
77
84
  " ",
78
- /* @__PURE__ */ m("b", { children: P.choose })
85
+ /* @__PURE__ */ h("b", { children: L.choose })
79
86
  ]
80
- }), /* @__PURE__ */ m("div", {
81
- id: W,
87
+ }), /* @__PURE__ */ h("div", {
88
+ id: q,
82
89
  className: "kapi-upload__s",
83
- children: F
90
+ children: R
84
91
  })]
85
92
  })]
86
93
  }),
87
- /* @__PURE__ */ m("input", {
88
- ref: V,
94
+ /* @__PURE__ */ h("input", {
95
+ ref: W,
89
96
  className: "kapi-upload__input",
90
97
  type: "file",
91
98
  hidden: !0,
92
- name: O,
93
- multiple: b,
94
- accept: x,
95
- disabled: w,
99
+ name: k,
100
+ multiple: x,
101
+ accept: S,
102
+ disabled: T,
96
103
  tabIndex: -1,
97
104
  onChange: (e) => {
98
- J(e.target.files), e.target.value = "";
105
+ Z(e.target.files), e.target.value = "";
99
106
  }
100
107
  }),
101
- L.length > 0 && /* @__PURE__ */ m("div", {
108
+ B.length > 0 && /* @__PURE__ */ h("div", {
102
109
  className: "kapi-upload__list",
103
- children: L.map((e, t) => /* @__PURE__ */ h("div", {
110
+ children: B.map((e, t) => /* @__PURE__ */ g("div", {
104
111
  className: "kapi-upload__file",
105
112
  children: [
106
- /* @__PURE__ */ m(g, {
113
+ /* @__PURE__ */ h(_, {
107
114
  className: "kapi-upload__fileico",
108
115
  size: 16,
109
116
  strokeWidth: 1.9
110
117
  }),
111
- /* @__PURE__ */ m("span", {
118
+ /* @__PURE__ */ h("span", {
112
119
  className: "kapi-upload__name",
113
120
  children: e.name
114
121
  }),
115
- /* @__PURE__ */ m("span", {
122
+ /* @__PURE__ */ h("span", {
116
123
  className: "kapi-upload__size",
117
124
  children: a(e.size)
118
125
  }),
119
- /* @__PURE__ */ m("button", {
126
+ /* @__PURE__ */ h("button", {
120
127
  type: "button",
121
- "aria-label": `${P.remove} ${e.name}`,
122
- onClick: () => q(l(L, t)),
123
- children: /* @__PURE__ */ m(v, {
128
+ "aria-label": `${L.remove} ${e.name}`,
129
+ onClick: () => X(l(B, t)),
130
+ children: /* @__PURE__ */ h(y, {
124
131
  size: 15,
125
132
  strokeWidth: 2.2
126
133
  })
134
+ }),
135
+ N?.(e, t) !== void 0 && /* @__PURE__ */ h(u, {
136
+ className: "kapi-upload__progress",
137
+ value: N(e, t) ?? 0,
138
+ size: "sm",
139
+ label: `${L.uploading} ${e.name}`
127
140
  })
128
141
  ]
129
142
  }, `${e.name}-${t}`))
@@ -132,4 +145,4 @@ var y = {
132
145
  });
133
146
  };
134
147
  //#endregion
135
- export { y as DEFAULT_FILE_UPLOAD_LABELS, b as KapiFileUpload };
148
+ export { b as DEFAULT_FILE_UPLOAD_LABELS, x as KapiFileUpload };
@@ -0,0 +1,104 @@
1
+ import type { ChangeEvent, FocusEvent, ReactNode } from "react";
2
+ /**
3
+ * Lo que entrega el `getInputProps(path)` de una librería de formularios (`@mantine/form`,
4
+ * `react-hook-form` vía `register`, Formik…). Se describe por su FORMA, no importando la librería:
5
+ * el paquete no tiene dependencias de runtime y el contrato que importa es público.
6
+ *
7
+ * El `onChange` se escribe `(payload: never) => void` **a propósito, y es lo único raro del tipo**.
8
+ * Es el único tipo de parámetro que acepta un handler de cualquier aridad de un argumento: por
9
+ * contravarianza, el parámetro del destino tiene que ser asignable al del origen, y `never` lo es a
10
+ * todo. Con `unknown` no compilaría un `(e: ChangeEvent) => void`, y con `any` se apagaría el
11
+ * chequeo en vez de resolverlo.
12
+ */
13
+ export type KapiFieldSource<V = unknown> = {
14
+ /** Valor actual del campo (modo controlado). */
15
+ value?: V | undefined;
16
+ /** Valor inicial (modo no controlado de la librería). Se reenvía sólo si no vino `value`. */
17
+ defaultValue?: V | undefined;
18
+ /** Estado del campo cuando la librería lo pidió con `type: "checkbox"`. */
19
+ checked?: boolean | undefined;
20
+ /** Estado inicial de la marca (modo no controlado de la librería). Se reenvía sólo si no vino `checked`. */
21
+ defaultChecked?: boolean | undefined;
22
+ /** Handler de la librería; acepta un evento del DOM o un valor pelado. */
23
+ onChange?: ((payload: never) => void) | undefined;
24
+ /** Handler de salida de foco, para marcar el campo como tocado. */
25
+ onBlur?: ((event: never) => void) | undefined;
26
+ /** Handler de entrada de foco, para marcar el campo como tocado. */
27
+ onFocus?: ((event: never) => void) | undefined;
28
+ /** Motivo por el que el campo está mal, tal como lo entrega la librería. */
29
+ error?: ReactNode;
30
+ /** Nombre del campo, si la librería lo entrega. */
31
+ name?: string | undefined;
32
+ };
33
+ /**
34
+ * Qué clase de control recibe el resultado, porque de eso depende la firma de su `onChange`:
35
+ * `event` para los wrappers de un control nativo (`KapiInput`, `KapiTextarea`), `value` para los
36
+ * que eligen un valor (`KapiSelect`, `KapiDatePicker`, `KapiRating`…) y `checked` para los que son
37
+ * una casilla (`KapiCheckbox`, `KapiSwitch`).
38
+ */
39
+ export type KapiFieldMode = "event" | "value" | "checked";
40
+ /** Props para un control que avisa con el evento del DOM (`KapiInput`, `KapiTextarea`). */
41
+ export type KapiEventFieldProps<V = string> = {
42
+ name?: string | undefined;
43
+ value?: V | undefined;
44
+ defaultValue?: V | undefined;
45
+ onChange?: ((event: ChangeEvent<HTMLInputElement & HTMLTextAreaElement>) => void) | undefined;
46
+ onBlur?: ((event: FocusEvent<HTMLElement>) => void) | undefined;
47
+ onFocus?: ((event: FocusEvent<HTMLElement>) => void) | undefined;
48
+ error?: ReactNode;
49
+ };
50
+ /** Props para un control que avisa con el valor ya tipado (`KapiSelect`, `KapiDatePicker`). */
51
+ export type KapiValueFieldProps<V> = {
52
+ name?: string | undefined;
53
+ value?: V | undefined;
54
+ defaultValue?: V | undefined;
55
+ onChange?: ((value: V) => void) | undefined;
56
+ onBlur?: ((event: FocusEvent<HTMLElement>) => void) | undefined;
57
+ onFocus?: ((event: FocusEvent<HTMLElement>) => void) | undefined;
58
+ error?: ReactNode;
59
+ };
60
+ /**
61
+ * Props para una casilla (`KapiCheckbox`, `KapiSwitch`). Lleva `invalid` y **no** `error`: esos dos
62
+ * controles no dibujan mensaje, así que mandarles el texto lo perdería en silencio. El mensaje va
63
+ * al `KapiField` que los envuelve.
64
+ */
65
+ export type KapiCheckedFieldProps = {
66
+ name?: string | undefined;
67
+ checked?: boolean | undefined;
68
+ defaultChecked?: boolean | undefined;
69
+ onChange?: ((event: ChangeEvent<HTMLInputElement>) => void) | undefined;
70
+ onBlur?: ((event: FocusEvent<HTMLElement>) => void) | undefined;
71
+ onFocus?: ((event: FocusEvent<HTMLElement>) => void) | undefined;
72
+ invalid: boolean;
73
+ };
74
+ /**
75
+ * Ata un campo de una librería de formularios a un control de Kapi.
76
+ *
77
+ * **Para la mayoría de los campos no hace falta**, y conviene decirlo antes que venderlo: el
78
+ * `onChange` que devuelve `getInputProps` ya absorbe tanto un evento del DOM como un valor pelado
79
+ * —por eso el mismo spread anda en el `TextInput` y en el `Select` de la propia Mantine—, así que
80
+ * un `{...form.getInputProps("x")}` sobre un `KapiInput` funciona en runtime. Lo que esta función
81
+ * resuelve son las tres cosas que ese spread sí rompe:
82
+ *
83
+ * 1. **Los tipos.** El `onChange` de la librería no tiene la firma del control de destino, y el
84
+ * `mode` obliga a declarar qué clase de control lo recibe, así que `tsc` caza el cruce (un
85
+ * `"value"` spreadeado sobre un `KapiInput` no compila).
86
+ * 2. **`value` + `defaultValue` juntos.** El modo no controlado devuelve los dos y React avisa que
87
+ * el control pasó de no controlado a controlado. Acá se reenvía uno solo.
88
+ * 3. **Las props de más.** `enhanceGetInputProps` deja claves que el control de Kapi no declara y
89
+ * que ponen `tsc` en rojo al spreadearlas; se descartan.
90
+ *
91
+ * Más `error` → `invalid` en las casillas, que no dibujan mensaje.
92
+ *
93
+ * @example
94
+ * ```tsx
95
+ * <KapiInput label="Correo" {...bindField(form.getInputProps("correo"))} />
96
+ * <KapiSelect label="Área" options={areas} {...bindField<string | null>(form.getInputProps("area"), "value")} />
97
+ * <KapiField label="Términos" error={form.errors.ok}>
98
+ * <KapiCheckbox {...bindField(form.getInputProps("ok", { type: "checkbox" }), "checked")} />
99
+ * </KapiField>
100
+ * ```
101
+ */
102
+ export declare function bindField<V = string>(source: KapiFieldSource<V>, mode?: "event"): KapiEventFieldProps<V>;
103
+ export declare function bindField<V>(source: KapiFieldSource<V>, mode: "value"): KapiValueFieldProps<V>;
104
+ export declare function bindField<V = unknown>(source: KapiFieldSource<V>, mode: "checked"): KapiCheckedFieldProps;
@@ -0,0 +1,25 @@
1
+ import { present as e } from "./inputLogic.js";
2
+ //#region src/components/inputs/formBridgeLogic.ts
3
+ var t = (e, t) => t === void 0 ? {} : { [e]: t };
4
+ function n(n, r = "event") {
5
+ let i = n.onChange, a = {
6
+ ...t("onBlur", n.onBlur),
7
+ ...t("onFocus", n.onFocus),
8
+ ...t("name", n.name)
9
+ };
10
+ if (r === "checked") return {
11
+ ...a,
12
+ ...n.checked === void 0 ? t("defaultChecked", n.defaultChecked) : t("checked", n.checked),
13
+ ...t("onChange", i),
14
+ invalid: e(n.error)
15
+ };
16
+ let o = n.value === void 0 ? t("defaultValue", n.defaultValue) : t("value", n.value);
17
+ return {
18
+ ...a,
19
+ ...o,
20
+ ...t("onChange", i),
21
+ ...t("error", n.error)
22
+ };
23
+ }
24
+ //#endregion
25
+ export { n as bindField };
@@ -124,3 +124,5 @@ export type { KapiFacet, KapiFacetChip, KapiFacetKind, KapiFacetOption, KapiFace
124
124
  export { KapiPropsForm } from "./KapiPropsForm.js";
125
125
  export type { KapiPropsFormField, KapiPropsFormProps, KapiPropsFormValue, KapiPropsFormValues } from "./KapiPropsForm.js";
126
126
  export { initialPropsFormValues, isPropsFormFieldEmpty, missingPropsFormFields, reconcilePropsFormValues } from "./propsFormLogic.js";
127
+ export { bindField } from "./formBridgeLogic.js";
128
+ export type { KapiCheckedFieldProps, KapiEventFieldProps, KapiFieldMode, KapiFieldSource, KapiValueFieldProps } from "./formBridgeLogic.js";
@@ -7,6 +7,10 @@ import type { KapiTableLabels } from "../data/KapiTable.js";
7
7
  import type { KapiTableFilterLabels } from "../data/KapiTableFilter.js";
8
8
  import type { KapiPaginationLabels } from "../data/KapiPagination.js";
9
9
  import type { KapiAlertLabels } from "../feedback/KapiAlert.js";
10
+ import type { KapiSpinnerLabels } from "../feedback/KapiSpinner.js";
11
+ import type { KapiShortcutsHelpLabels } from "../overlays/KapiShortcutsHelp.js";
12
+ import type { KapiViewportLabels } from "../overlays/KapiViewport.js";
13
+ import type { KapiImageViewerLabels } from "../overlays/KapiImageViewer.js";
10
14
  import type { KapiBulkBarLabels } from "../feedback/KapiBulkBar.js";
11
15
  import type { KapiUnsavedBarLabels } from "../feedback/KapiUnsavedBar.js";
12
16
  import type { KapiOfflineBannerLabels } from "../feedback/KapiOfflineBanner.js";
@@ -78,6 +82,10 @@ import type { UnsavedGuardLabels } from "../../hooks/useUnsavedGuard.js";
78
82
  export interface KapiLabelRegistry {
79
83
  accountMenu: KapiAccountMenuLabels;
80
84
  alert: KapiAlertLabels;
85
+ spinner: KapiSpinnerLabels;
86
+ shortcutsHelp: KapiShortcutsHelpLabels;
87
+ viewport: KapiViewportLabels;
88
+ imageViewer: KapiImageViewerLabels;
81
89
  autocomplete: KapiAutocompleteLabels;
82
90
  avatarGroup: KapiAvatarGroupLabels;
83
91
  breadcrumb: KapiBreadcrumbLabels;
@@ -12,6 +12,12 @@ export type KapiStep<Id extends string = string> = {
12
12
  description?: ReactNode | undefined;
13
13
  /** Estado explícito; gana sobre el derivado de `current`. */
14
14
  status?: KapiStepStatus | undefined;
15
+ /**
16
+ * Con `onSelect`, deja el paso sin apretar: es un `<button disabled>`, así que el teclado lo
17
+ * saltea solo. Sin `onSelect` no hace nada. Sirve para un paso al que todavía no se puede saltar.
18
+ * @default false
19
+ */
20
+ disabled?: boolean | undefined;
15
21
  };
16
22
  /** Texto oculto que anuncia el estado de cada paso a lectores de pantalla. */
17
23
  export type KapiStepsLabels = Record<KapiStepStatus, string>;
@@ -19,8 +25,13 @@ export declare const DEFAULT_STEPS_LABELS: KapiStepsLabels;
19
25
  /**
20
26
  * Atributos nativos (`id`, `style`, `aria-label`, `data-*`…) van al `<ol>`. `Id` se infiere de `steps`,
21
27
  * sin escribir el argumento de tipo.
28
+ *
29
+ * `onSelect` se omite del tipo nativo porque choca: React ya declara un `onSelect` para el evento
30
+ * `select` del DOM, y sin omitirlo el parámetro de nuestro handler llega como
31
+ * `string | SyntheticEvent` y el consumidor no puede usar el id sin castear. Un evento `select`
32
+ * sobre un `<ol>` no significa nada, así que no se pierde nada.
22
33
  */
23
- export type KapiStepsProps<Id extends string = string> = Omit<OlHTMLAttributes<HTMLOListElement>, "children"> & {
34
+ export type KapiStepsProps<Id extends string = string> = Omit<OlHTMLAttributes<HTMLOListElement>, "children" | "onSelect"> & {
24
35
  /** Pasos del circuito, en orden. */
25
36
  steps: readonly KapiStep<Id>[];
26
37
  /** Id del paso actual: los anteriores quedan completos y los siguientes pendientes (salvo `status` explícito). */
@@ -31,12 +42,22 @@ export type KapiStepsProps<Id extends string = string> = Omit<OlHTMLAttributes<H
31
42
  size?: KapiStepsSize | undefined;
32
43
  /** Textos de estado para lectores de pantalla (clave `steps`). */
33
44
  labels?: KapiLabelsOverride<KapiStepsLabels> | undefined;
45
+ /**
46
+ * Avisa con el id del paso apretado. **Pasarla vuelve cada paso un `<button>`**; sin ella el
47
+ * componente queda de solo lectura y su markup no cambia. `NoInfer` para que un literal suelto
48
+ * acá no ancle `Id`: los ids salen de `steps`.
49
+ */
50
+ onSelect?: ((id: NoInfer<Id>) => void) | undefined;
34
51
  /** Ref al `<ol>`. */
35
52
  ref?: Ref<HTMLOListElement> | undefined;
36
53
  };
37
54
  /**
38
- * Pasos de un circuito, de solo lectura (p. ej. los estados de un trámite). No navega: para un
39
- * formulario por pasos usar `KapiWizard`. Es un `<ol>` con `aria-current="step"` en el paso actual y
40
- * el estado de cada paso como texto oculto.
55
+ * Pasos de un circuito (p. ej. los estados de un trámite). Es un `<ol>` con `aria-current="step"`
56
+ * en el paso actual y el estado de cada paso como texto oculto.
57
+ *
58
+ * **De solo lectura por defecto, e interactivo sólo con `onSelect`**, que envuelve cada paso en un
59
+ * `<button>`. Es el indicador, no el flujo: un formulario por pasos —que dibuja el contenido de
60
+ * cada uno y controla el avance— sigue siendo `KapiWizard`. Acá los pasos se muestran y, si el
61
+ * consumidor quiere, se saltan.
41
62
  */
42
- export declare function KapiSteps<Id extends string = string>({ steps, current, orientation, size, labels, className, ref, ...rest }: KapiStepsProps<Id>): import("react").JSX.Element;
63
+ export declare function KapiSteps<Id extends string = string>({ steps, current, orientation, size, labels, onSelect, className, ref, ...rest }: KapiStepsProps<Id>): import("react").JSX.Element;
@@ -4,61 +4,73 @@ import { joinClasses as e } from "../rootProps.js";
4
4
  import { useLabels as t } from "../locale/KapiLocaleProvider.js";
5
5
  /* empty css */
6
6
  import { resolveSteps as n, stepsClasses as r } from "./stepsLogic.js";
7
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
8
- import { Check as o, X as s } from "lucide-react";
7
+ import { useId as i } from "react";
8
+ import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
9
+ import { Check as c, X as l } from "lucide-react";
9
10
  //#region src/components/navigation/KapiSteps.tsx
10
- var c = {
11
+ var u = {
11
12
  complete: "Completado",
12
13
  current: "En curso",
13
14
  upcoming: "Pendiente",
14
15
  error: "Con error"
15
- }, l = {
16
+ }, d = {
16
17
  size: 14,
17
18
  strokeWidth: 3,
18
19
  "aria-hidden": !0
19
20
  };
20
- function u({ steps: u, current: d, orientation: f = "vertical", size: p = "md", labels: m, className: h, ref: g, ..._ }) {
21
- let v = t("steps", c, m), { statuses: y, currentIndex: b } = n(u, d);
22
- return /* @__PURE__ */ i("ol", {
23
- ..._,
24
- ref: g,
25
- className: e(r(f, p), h),
26
- children: u.map((e, t) => {
27
- let n = y[t] ?? "upcoming";
28
- return /* @__PURE__ */ a("li", {
29
- className: `kapi-steps__item is-${n}`,
30
- "aria-current": t === b ? "step" : void 0,
31
- children: [/* @__PURE__ */ i("span", {
32
- className: "kapi-steps__head",
33
- children: /* @__PURE__ */ i("span", {
34
- className: "kapi-steps__marker",
35
- "aria-hidden": "true",
36
- children: n === "complete" ? /* @__PURE__ */ i(o, { ...l }) : n === "error" ? /* @__PURE__ */ i(s, { ...l }) : t + 1
21
+ function f({ steps: f, current: p, orientation: m = "vertical", size: h = "md", labels: g, onSelect: _, className: v, ref: y, ...b }) {
22
+ let x = t("steps", u, g), S = i(), { statuses: C, currentIndex: w } = n(f, p);
23
+ return /* @__PURE__ */ o("ol", {
24
+ ...b,
25
+ ref: y,
26
+ className: e(r(m, h), v),
27
+ children: f.map((e, t) => {
28
+ let n = C[t] ?? "upcoming", r = `${S}-${t}-l`, i = `${S}-${t}-s`, u = `${S}-${t}-d`, f = /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o("span", {
29
+ className: "kapi-steps__head",
30
+ children: /* @__PURE__ */ o("span", {
31
+ className: "kapi-steps__marker",
32
+ "aria-hidden": "true",
33
+ children: n === "complete" ? /* @__PURE__ */ o(c, { ...d }) : n === "error" ? /* @__PURE__ */ o(l, { ...d }) : t + 1
34
+ })
35
+ }), /* @__PURE__ */ s("span", {
36
+ className: "kapi-steps__body",
37
+ children: [
38
+ /* @__PURE__ */ o("span", {
39
+ id: r,
40
+ className: "kapi-steps__label",
41
+ children: e.label
42
+ }),
43
+ /* @__PURE__ */ s("span", {
44
+ id: i,
45
+ className: "kapi-steps__sr",
46
+ children: [
47
+ " ",
48
+ "(",
49
+ x[n],
50
+ ")"
51
+ ]
52
+ }),
53
+ e.description != null && /* @__PURE__ */ o("span", {
54
+ id: u,
55
+ className: "kapi-steps__desc",
56
+ children: e.description
37
57
  })
38
- }), /* @__PURE__ */ a("span", {
39
- className: "kapi-steps__body",
40
- children: [
41
- /* @__PURE__ */ i("span", {
42
- className: "kapi-steps__label",
43
- children: e.label
44
- }),
45
- /* @__PURE__ */ a("span", {
46
- className: "kapi-steps__sr",
47
- children: [
48
- " (",
49
- v[n],
50
- ")"
51
- ]
52
- }),
53
- e.description != null && /* @__PURE__ */ i("span", {
54
- className: "kapi-steps__desc",
55
- children: e.description
56
- })
57
- ]
58
- })]
58
+ ]
59
+ })] });
60
+ return /* @__PURE__ */ o("li", {
61
+ className: `kapi-steps__item is-${n}`,
62
+ "aria-current": t === w ? "step" : void 0,
63
+ children: _ ? /* @__PURE__ */ o("button", {
64
+ type: "button",
65
+ className: "kapi-steps__btn",
66
+ disabled: e.disabled,
67
+ "aria-labelledby": `${r} ${i}${e.description == null ? "" : ` ${u}`}`,
68
+ onClick: () => _(e.id),
69
+ children: f
70
+ }) : f
59
71
  }, e.id);
60
72
  })
61
73
  });
62
74
  }
63
75
  //#endregion
64
- export { c as DEFAULT_STEPS_LABELS, u as KapiSteps };
76
+ export { u as DEFAULT_STEPS_LABELS, f as KapiSteps };
@@ -0,0 +1,63 @@
1
+ import { type CSSProperties, type ReactNode, type Ref } from "react";
2
+ import type { KapiLabelsOverride } from "../labelsLogic.js";
3
+ import type { KapiCloseReason } from "../closeReason.js";
4
+ /** Una imagen de la galería. */
5
+ export type KapiImageViewerItem = {
6
+ /** URL de la imagen. */
7
+ src: string;
8
+ /** Texto alternativo. Obligatorio: una imagen sin nombre no existe para un lector de pantalla. */
9
+ alt: string;
10
+ /** Pie que se muestra abajo. */
11
+ caption?: ReactNode;
12
+ /** Ancho natural, si se conoce; si no, se lee del `<img>` al cargar. */
13
+ width?: number | undefined;
14
+ /** Alto natural. */
15
+ height?: number | undefined;
16
+ };
17
+ /** Textos de `KapiImageViewer`. */
18
+ export type KapiImageViewerLabels = {
19
+ /** Botón de cerrar. */
20
+ close: string;
21
+ /** Botón de imagen anterior. */
22
+ previous: string;
23
+ /** Botón de imagen siguiente. */
24
+ next: string;
25
+ /** Contador: `{i}` es la posición y `{n}` el total. */
26
+ counter: string;
27
+ };
28
+ export declare const DEFAULT_IMAGE_VIEWER_LABELS: KapiImageViewerLabels;
29
+ export type KapiImageViewerProps = {
30
+ /** Ref al `<div>` del visor. */
31
+ ref?: Ref<HTMLDivElement> | undefined;
32
+ /** Abre el visor. */
33
+ open: boolean;
34
+ /** Se llama al cerrar (Escape, fondo, X). */
35
+ onClose: (reason: KapiCloseReason) => void;
36
+ /** Las imágenes de la galería, en orden. */
37
+ images: readonly KapiImageViewerItem[];
38
+ /** Imagen mostrada (controlado). */
39
+ index?: number | undefined;
40
+ /** Imagen inicial. @default 0 */
41
+ defaultIndex?: number | undefined;
42
+ /** Avisa el cambio de imagen. */
43
+ onIndexChange?: ((index: number) => void) | undefined;
44
+ /** Clase del visor. */
45
+ className?: string | undefined;
46
+ /** Estilo del visor. */
47
+ style?: CSSProperties | undefined;
48
+ /** `id` del visor. */
49
+ id?: string | undefined;
50
+ /** Textos fijos. */
51
+ labels?: KapiLabelsOverride<KapiImageViewerLabels> | undefined;
52
+ };
53
+ /**
54
+ * Visor de imágenes a pantalla completa, con zoom y arrastre.
55
+ *
56
+ * El motor es `KapiViewport`: acá sólo se agrega la galería (navegar, contador, pie) y el cierre.
57
+ * No hay una segunda implementación del zoom, que es lo que pasaba antes con `KapiPhotoView` y
58
+ * `useWheelZoom` resolviendo pedazos distintos del mismo problema.
59
+ *
60
+ * **Cada imagen vuelve a arrancar ajustada**: conservar la escala al pasar a la siguiente deja a la
61
+ * persona mirando una esquina de una foto que todavía no vio.
62
+ */
63
+ export declare const KapiImageViewer: ({ ref, open, onClose, images, index, defaultIndex, onIndexChange, className, style, id, labels }: KapiImageViewerProps) => import("react").JSX.Element | null;