@kapiuara/ui 0.17.0 → 0.18.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/KapiScatterChart.d.ts +56 -0
- package/dist/components/data/KapiScatterChart.js +90 -0
- package/dist/components/data/chartFrame.d.ts +20 -2
- package/dist/components/data/chartFrame.js +33 -24
- package/dist/components/data/index.d.ts +4 -0
- package/dist/components/data/scatterLogic.d.ts +56 -0
- package/dist/components/data/scatterLogic.js +43 -0
- 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/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 +1 -1
|
@@ -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
|
|
39
|
-
*
|
|
40
|
-
*
|
|
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 {
|
|
8
|
-
import {
|
|
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
|
|
11
|
+
var u = {
|
|
11
12
|
complete: "Completado",
|
|
12
13
|
current: "En curso",
|
|
13
14
|
upcoming: "Pendiente",
|
|
14
15
|
error: "Con error"
|
|
15
|
-
},
|
|
16
|
+
}, d = {
|
|
16
17
|
size: 14,
|
|
17
18
|
strokeWidth: 3,
|
|
18
19
|
"aria-hidden": !0
|
|
19
20
|
};
|
|
20
|
-
function
|
|
21
|
-
let
|
|
22
|
-
return /* @__PURE__ */
|
|
23
|
-
...
|
|
24
|
-
ref:
|
|
25
|
-
className: e(r(
|
|
26
|
-
children:
|
|
27
|
-
let n =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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 {
|
|
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;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "#kapi-css/components/overlays/KapiViewport.css";
|
|
3
|
+
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
+
import { useLabels as t } from "../locale/KapiLocaleProvider.js";
|
|
5
|
+
import { KapiIconButton as n } from "../inputs/KapiIconButton.js";
|
|
6
|
+
import { useControllableState as r } from "../../hooks/useControllableState.js";
|
|
7
|
+
import { useDismiss as i } from "../../hooks/useDismiss.js";
|
|
8
|
+
/* empty css */
|
|
9
|
+
import { KapiViewport as a } from "./KapiViewport.js";
|
|
10
|
+
import { useCallback as o, useId as s, useRef as c, useState as l } from "react";
|
|
11
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
12
|
+
import { ChevronLeft as p, ChevronRight as m, X as h } from "lucide-react";
|
|
13
|
+
//#region src/components/overlays/KapiImageViewer.tsx
|
|
14
|
+
var g = {
|
|
15
|
+
close: "Cerrar el visor",
|
|
16
|
+
previous: "Imagen anterior",
|
|
17
|
+
next: "Imagen siguiente",
|
|
18
|
+
counter: "{i} de {n}"
|
|
19
|
+
}, _ = ({ ref: _, open: v, onClose: y, images: b, index: x, defaultIndex: S = 0, onIndexChange: C, className: w, style: T, id: E, labels: D }) => {
|
|
20
|
+
let O = t("imageViewer", g, D), k = c(null), A = s(), [j, M] = r(x, S, C), [N, P] = l(null), F = b.length, I = F === 0 ? 0 : Math.min(Math.max(j, 0), F - 1), L = b[I], R = o((e) => {
|
|
21
|
+
F !== 0 && M((I + e + F) % F);
|
|
22
|
+
}, [
|
|
23
|
+
I,
|
|
24
|
+
F,
|
|
25
|
+
M
|
|
26
|
+
]), z = c(L?.src);
|
|
27
|
+
if (z.current !== L?.src && (z.current = L?.src, P(null)), i(v, {
|
|
28
|
+
zones: [k],
|
|
29
|
+
onDismiss: (e) => y(e)
|
|
30
|
+
}), !v || !L) return null;
|
|
31
|
+
let B = L.width ?? N?.width ?? 0, V = L.height ?? N?.height ?? 0, H = O.counter.replace("{i}", String(I + 1)).replace("{n}", String(F));
|
|
32
|
+
return /* @__PURE__ */ f("div", {
|
|
33
|
+
ref: (e) => {
|
|
34
|
+
k.current = e, typeof _ == "function" ? _(e) : _ && (_.current = e);
|
|
35
|
+
},
|
|
36
|
+
id: E,
|
|
37
|
+
className: e("kapi-imgviewer", w),
|
|
38
|
+
style: T,
|
|
39
|
+
role: "dialog",
|
|
40
|
+
"aria-modal": "true",
|
|
41
|
+
"aria-labelledby": A,
|
|
42
|
+
children: [
|
|
43
|
+
/* @__PURE__ */ f("div", {
|
|
44
|
+
className: "kapi-imgviewer__bar",
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ d("span", {
|
|
47
|
+
id: A,
|
|
48
|
+
className: "kapi-imgviewer__title",
|
|
49
|
+
children: L.alt
|
|
50
|
+
}),
|
|
51
|
+
F > 1 && /* @__PURE__ */ d("span", {
|
|
52
|
+
className: "kapi-imgviewer__count",
|
|
53
|
+
children: H
|
|
54
|
+
}),
|
|
55
|
+
/* @__PURE__ */ d(n, {
|
|
56
|
+
"aria-label": O.close,
|
|
57
|
+
icon: /* @__PURE__ */ d(h, {
|
|
58
|
+
size: 18,
|
|
59
|
+
strokeWidth: 2.2
|
|
60
|
+
}),
|
|
61
|
+
onClick: () => y("close-button")
|
|
62
|
+
})
|
|
63
|
+
]
|
|
64
|
+
}),
|
|
65
|
+
/* @__PURE__ */ d(a, {
|
|
66
|
+
className: "kapi-imgviewer__stage",
|
|
67
|
+
contentWidth: B,
|
|
68
|
+
contentHeight: V,
|
|
69
|
+
hideFullscreen: !0,
|
|
70
|
+
children: /* @__PURE__ */ d("img", {
|
|
71
|
+
className: "kapi-imgviewer__img",
|
|
72
|
+
src: L.src,
|
|
73
|
+
alt: L.alt,
|
|
74
|
+
draggable: !1,
|
|
75
|
+
onLoad: (e) => P({
|
|
76
|
+
width: e.currentTarget.naturalWidth,
|
|
77
|
+
height: e.currentTarget.naturalHeight
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
}, L.src),
|
|
81
|
+
F > 1 && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(n, {
|
|
82
|
+
className: "kapi-imgviewer__prev",
|
|
83
|
+
"aria-label": O.previous,
|
|
84
|
+
icon: /* @__PURE__ */ d(p, {
|
|
85
|
+
size: 20,
|
|
86
|
+
strokeWidth: 2.2
|
|
87
|
+
}),
|
|
88
|
+
onClick: () => R(-1)
|
|
89
|
+
}), /* @__PURE__ */ d(n, {
|
|
90
|
+
className: "kapi-imgviewer__next",
|
|
91
|
+
"aria-label": O.next,
|
|
92
|
+
icon: /* @__PURE__ */ d(m, {
|
|
93
|
+
size: 20,
|
|
94
|
+
strokeWidth: 2.2
|
|
95
|
+
}),
|
|
96
|
+
onClick: () => R(1)
|
|
97
|
+
})] }),
|
|
98
|
+
L.caption != null && /* @__PURE__ */ d("div", {
|
|
99
|
+
className: "kapi-imgviewer__caption",
|
|
100
|
+
children: L.caption
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
//#endregion
|
|
106
|
+
export { g as DEFAULT_IMAGE_VIEWER_LABELS, _ as KapiImageViewer };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode, type Ref } from "react";
|
|
2
|
+
import type { KapiCloseReason } from "../closeReason.js";
|
|
3
|
+
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
4
|
+
import type { KapiClassNames } from "../slotCatalog.js";
|
|
5
|
+
/** Partes de `KapiShortcutsHelp` que acepta `classNames` (`group`, `groupTitle`, `list`, `row`, `keys`, `description`). */
|
|
6
|
+
export type KapiShortcutsHelpClassNames = KapiClassNames<"shortcutsHelp">;
|
|
7
|
+
/** Textos de `KapiShortcutsHelp`. */
|
|
8
|
+
export type KapiShortcutsHelpLabels = {
|
|
9
|
+
/** Título del diálogo. */
|
|
10
|
+
title: string;
|
|
11
|
+
/** Encabezado de los atajos que no declararon grupo. */
|
|
12
|
+
general: string;
|
|
13
|
+
/** Qué se ve cuando no hay ningún atajo con descripción. */
|
|
14
|
+
empty: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const DEFAULT_SHORTCUTS_HELP_LABELS: KapiShortcutsHelpLabels;
|
|
17
|
+
/** `className`/`style`/`id` van al diálogo. */
|
|
18
|
+
export type KapiShortcutsHelpProps = {
|
|
19
|
+
/** Ref al `<div>` del diálogo. */
|
|
20
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
21
|
+
/** Abre el diálogo. */
|
|
22
|
+
open: boolean;
|
|
23
|
+
/** Se llama al cerrar (Escape, fondo, X). */
|
|
24
|
+
onClose: (reason: KapiCloseReason) => void;
|
|
25
|
+
/** Título propio. Sin él, el del locale. */
|
|
26
|
+
title?: ReactNode | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Fuerza el dibujo de las teclas al estilo de macOS (`⌘`, `⌥`, `⇧`). Sin la prop se deduce de la
|
|
29
|
+
* plataforma, que es lo que corresponde: el mismo `"mod+k"` se escribe distinto en cada una.
|
|
30
|
+
*/
|
|
31
|
+
mac?: boolean | undefined;
|
|
32
|
+
/** Clase del diálogo. */
|
|
33
|
+
className?: string | undefined;
|
|
34
|
+
/** Estilo del diálogo. */
|
|
35
|
+
style?: CSSProperties | undefined;
|
|
36
|
+
/** `id` del diálogo. */
|
|
37
|
+
id?: string | undefined;
|
|
38
|
+
/** Clases por parte (`group`, `groupTitle`, `list`, `row`, `keys`, `description`). Se suman a las propias. */
|
|
39
|
+
classNames?: KapiShortcutsHelpClassNames | undefined;
|
|
40
|
+
/** Textos fijos. */
|
|
41
|
+
labels?: KapiLabelsOverride<KapiShortcutsHelpLabels> | undefined;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* La ayuda «?» que lista los atajos que registró `useHotkey`.
|
|
45
|
+
*
|
|
46
|
+
* Sólo aparecen los que pasaron `description`: un atajo sin explicación sería una tecla suelta en
|
|
47
|
+
* una lista, que no ayuda a nadie. La lista se arma sola y **sigue al estado**: un atajo que está
|
|
48
|
+
* apagado (`enabled: false`) no se lista, porque prometería una tecla que no hace nada.
|
|
49
|
+
*
|
|
50
|
+
* El diálogo no registra ningún atajo propio para abrirse: quién abre la ayuda lo decide la app,
|
|
51
|
+
* normalmente con `useHotkey("?", …)`, y así la ayuda no se mete en el teclado de nadie.
|
|
52
|
+
*/
|
|
53
|
+
export declare const KapiShortcutsHelp: ({ ref, open, onClose, title, mac, className, style, id, classNames, labels }: KapiShortcutsHelpProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "#kapi-css/components/overlays/overlays.css";
|
|
3
|
+
import { useLabels as e } from "../locale/KapiLocaleProvider.js";
|
|
4
|
+
import { slot as t } from "../slotsLogic.js";
|
|
5
|
+
/* empty css */
|
|
6
|
+
import { KapiModal as n } from "./KapiModal.js";
|
|
7
|
+
import { groupHotkeys as r, hotkeyKeys as i, hotkeyRegistry as a } from "../../hooks/hotkeyRegistry.js";
|
|
8
|
+
import { SHORTCUTS_HELP_SLOTS as o } from "./shortcutsHelpSlots.js";
|
|
9
|
+
import { useSyncExternalStore as s } from "react";
|
|
10
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
11
|
+
//#region src/components/overlays/KapiShortcutsHelp.tsx
|
|
12
|
+
var u = {
|
|
13
|
+
title: "Atajos de teclado",
|
|
14
|
+
general: "General",
|
|
15
|
+
empty: "No hay atajos disponibles en esta pantalla."
|
|
16
|
+
}, d = () => typeof navigator < "u" && /mac/i.test(navigator.platform || navigator.userAgent), f = ({ ref: f, open: p, onClose: m, title: h, mac: g, className: _, style: v, id: y, classNames: b, labels: x }) => {
|
|
17
|
+
let S = e("shortcutsHelp", u, x), C = s(a.subscribe, a.getSnapshot, a.getSnapshot), w = r(C, S.general), T = g ?? d();
|
|
18
|
+
return /* @__PURE__ */ c(n, {
|
|
19
|
+
open: p,
|
|
20
|
+
onClose: m,
|
|
21
|
+
title: h === void 0 ? S.title : h,
|
|
22
|
+
size: "sm",
|
|
23
|
+
...f === void 0 ? {} : { ref: f },
|
|
24
|
+
..._ === void 0 ? {} : { className: _ },
|
|
25
|
+
...v === void 0 ? {} : { style: v },
|
|
26
|
+
...y === void 0 ? {} : { id: y },
|
|
27
|
+
children: w.length === 0 ? /* @__PURE__ */ c("p", {
|
|
28
|
+
className: "kapi-muted",
|
|
29
|
+
children: S.empty
|
|
30
|
+
}) : w.map(({ group: e, items: n }) => /* @__PURE__ */ l("section", {
|
|
31
|
+
...t(o, "group", b),
|
|
32
|
+
children: [/* @__PURE__ */ c("h3", {
|
|
33
|
+
...t(o, "groupTitle", b),
|
|
34
|
+
children: e
|
|
35
|
+
}), /* @__PURE__ */ c("dl", {
|
|
36
|
+
...t(o, "list", b),
|
|
37
|
+
children: n.map((e, n) => /* @__PURE__ */ l("div", {
|
|
38
|
+
...t(o, "row", b),
|
|
39
|
+
children: [/* @__PURE__ */ c("dt", {
|
|
40
|
+
...t(o, "keys", b),
|
|
41
|
+
children: i(e.combo, T).map((e, t) => /* @__PURE__ */ c("kbd", {
|
|
42
|
+
className: "kapi-kbd",
|
|
43
|
+
children: e
|
|
44
|
+
}, t))
|
|
45
|
+
}), /* @__PURE__ */ c("dd", {
|
|
46
|
+
...t(o, "description", b),
|
|
47
|
+
children: e.description
|
|
48
|
+
})]
|
|
49
|
+
}, `${e.combo}-${n}`))
|
|
50
|
+
})]
|
|
51
|
+
}, e))
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { u as DEFAULT_SHORTCUTS_HELP_LABELS, f as KapiShortcutsHelp };
|
|
@@ -8,25 +8,61 @@ type TooltipPhysicalSide = "right" | "left" | "top" | "bottom";
|
|
|
8
8
|
* sigue la dirección del texto: `end` es la derecha en LTR y la izquierda en RTL).
|
|
9
9
|
*/
|
|
10
10
|
export type KapiTooltipSide = TooltipPhysicalSide | "start" | "end";
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
label:
|
|
15
|
-
/** Disparador: el elemento que muestra el tooltip al pasar el mouse o enfocarlo. */
|
|
16
|
-
children: ReactNode;
|
|
11
|
+
/** Lo común a las dos formas de usarlo (envolviendo al disparador o apuntándolo por id). */
|
|
12
|
+
type KapiTooltipBase = KapiRootProps<HTMLSpanElement> & {
|
|
13
|
+
/** Contenido del tooltip. Puede ser texto o nodos (`<strong>`, varias partes). */
|
|
14
|
+
label: ReactNode;
|
|
17
15
|
/** Lado preferido: se respeta si entra; si no, va al opuesto. @default "end" */
|
|
18
16
|
prefer?: KapiTooltipSide | undefined;
|
|
17
|
+
/** Apagado: no se abre y no describe al disparador (no deja un `aria-describedby` a una burbuja que no se ve). */
|
|
18
|
+
disabled?: boolean | undefined;
|
|
19
|
+
/** Deja que el texto corte en varias líneas (tope 280px). Sin esto va en una sola, que es lo que conviene a un ícono. */
|
|
20
|
+
multiline?: boolean | undefined;
|
|
21
|
+
/** Milisegundos de espera antes de abrir con el mouse. Salir antes cancela. El foco de teclado NO espera. @default 0 */
|
|
22
|
+
openDelay?: number | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Abre y cierra desde afuera. Con la prop definida el estado es del consumidor: el hover y el foco
|
|
25
|
+
* dejan de abrirlo y cerrarlo. Sin ella, lo maneja el componente.
|
|
26
|
+
*/
|
|
27
|
+
opened?: boolean | undefined;
|
|
19
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* `className`/`style`/`id` van al envoltorio `<span class="kapi-tip">`.
|
|
31
|
+
*
|
|
32
|
+
* Dos formas, y el tipo obliga a elegir una: **envolviendo** al disparador (`children`) o
|
|
33
|
+
* **apuntándolo por id** (`target`), que no agrega ningún nodo alrededor.
|
|
34
|
+
*/
|
|
35
|
+
export type KapiTooltipProps = (KapiTooltipBase & {
|
|
36
|
+
/** Disparador: el elemento que muestra el tooltip al pasar el mouse o enfocarlo. */
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
/** No aplica envolviendo al disparador. */
|
|
39
|
+
target?: undefined;
|
|
40
|
+
}) | (KapiTooltipBase & {
|
|
41
|
+
/**
|
|
42
|
+
* `id` del elemento que dispara el tooltip. El componente no lo envuelve: le cuelga los
|
|
43
|
+
* eventos y le pone `aria-describedby`, así el layout del disparador no cambia. Es la forma
|
|
44
|
+
* que necesita `UncontrolledTooltip target={id}` al migrar.
|
|
45
|
+
*/
|
|
46
|
+
target: string;
|
|
47
|
+
/** No aplica apuntando por id: el disparador es el elemento del `target`. */
|
|
48
|
+
children?: undefined;
|
|
49
|
+
});
|
|
20
50
|
/** Lado físico de `side` para la dirección del texto: `start`/`end` se resuelven; el resto pasa tal cual. */
|
|
21
51
|
export declare const physicalTooltipSide: (side: KapiTooltipSide, dir: KapiDir) => TooltipPhysicalSide;
|
|
22
|
-
/**
|
|
23
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Ancho estimado de la burbuja (sin medirla), con tope.
|
|
54
|
+
*
|
|
55
|
+
* Un `label` que no es texto no se puede medir contando caracteres, así que se asume el tope: el
|
|
56
|
+
* efecto es que el lado se da vuelta un poco antes de lo necesario, que es el error barato. Al
|
|
57
|
+
* revés —asumir angosto— la burbuja se saldría de la ventana.
|
|
58
|
+
*/
|
|
59
|
+
export declare const estimateTooltipWidth: (label: ReactNode) => number;
|
|
24
60
|
/**
|
|
25
61
|
* Lado final del tooltip (auto-flip) con el motor `placePopover`: se respeta el lado pedido salvo que
|
|
26
62
|
* la burbuja (tamaño estimado) no entre; entonces va al opuesto. Pura: recibe el rect del disparador y
|
|
27
63
|
* el viewport (sin `bottom`/`left` se toman `top`/`right`; sin alto de viewport, abajo siempre entra).
|
|
28
64
|
*/
|
|
29
|
-
export declare const resolveTooltipSide: (prefer: TooltipPhysicalSide, rect: Pick<DOMRect, "top" | "right"> & Partial<Pick<DOMRect, "bottom" | "left">>, label:
|
|
65
|
+
export declare const resolveTooltipSide: (prefer: TooltipPhysicalSide, rect: Pick<DOMRect, "top" | "right"> & Partial<Pick<DOMRect, "bottom" | "left">>, label: ReactNode, viewportWidth: number, viewportHeight?: number) => TooltipPhysicalSide;
|
|
30
66
|
/**
|
|
31
67
|
* Punto de la burbuja en coordenadas de viewport según el lado (la burbuja es `position: fixed`, así no la
|
|
32
68
|
* recorta un contenedor con overflow, como el panel plegado o la zona que scrollea del rail). El CSS la
|
|
@@ -43,6 +79,9 @@ export declare const tooltipDescribedBy: (existing: unknown, tipId: string) => s
|
|
|
43
79
|
* Tooltip para íconos sueltos. Se muestra con hover y con foco de teclado (`:focus-visible`), se
|
|
44
80
|
* descarta con Escape (WCAG 1.4.13) y el disparador lo referencia por `aria-describedby`. Al abrir mide
|
|
45
81
|
* el disparador y abre del lado con espacio.
|
|
82
|
+
*
|
|
83
|
+
* Dos formas: **envolviendo** al disparador (`children`) o **apuntándolo por id** (`target`), que no
|
|
84
|
+
* agrega ningún nodo alrededor y es la que necesita la migración de `UncontrolledTooltip`.
|
|
46
85
|
*/
|
|
47
|
-
export declare const KapiTooltip: ({ label, children, prefer, className, style, id, ref: refProp }: KapiTooltipProps) => import("react").JSX.Element;
|
|
86
|
+
export declare const KapiTooltip: ({ label, children, target, prefer, disabled, multiline, openDelay, opened, className, style, id, ref: refProp }: KapiTooltipProps) => import("react").JSX.Element;
|
|
48
87
|
export {};
|