@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
|
@@ -0,0 +1,195 @@
|
|
|
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 { docOf as n } from "../../hooks/ownerDocument.js";
|
|
6
|
+
import { KapiIconButton as r } from "../inputs/KapiIconButton.js";
|
|
7
|
+
import { useControllableState as ee } from "../../hooks/useControllableState.js";
|
|
8
|
+
import { useElementSize as i } from "../../hooks/useElementSize.js";
|
|
9
|
+
import { nextWheelZoom as a } from "../../hooks/wheelZoomLogic.js";
|
|
10
|
+
import { VIEWPORT_IDENTITY as te, clampViewport as o, doubleTapScale as ne, fitScale as re, fitViewport as s, pinchCenter as c, pinchDistance as l, zoomAt as u } from "./viewportLogic.js";
|
|
11
|
+
/* empty css */
|
|
12
|
+
import { useCallback as ie, useEffect as d, useRef as f, useState as ae } from "react";
|
|
13
|
+
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
14
|
+
import { Maximize2 as oe, Minimize2 as se, Minus as h, Plus as g, Scan as _ } from "lucide-react";
|
|
15
|
+
//#region src/components/overlays/KapiViewport.tsx
|
|
16
|
+
var v = {
|
|
17
|
+
zoomIn: "Acercar",
|
|
18
|
+
zoomOut: "Alejar",
|
|
19
|
+
fit: "Ajustar a la pantalla",
|
|
20
|
+
fullscreen: "Pantalla completa",
|
|
21
|
+
exitFullscreen: "Salir de pantalla completa"
|
|
22
|
+
}, y = ({ children: y, contentWidth: b, contentHeight: x, minScale: S = .25, maxScale: C = 8, scaleStep: ce = .25, state: w, defaultState: T, onStateChange: le, hideControls: ue, hideFullscreen: de, labels: fe, className: pe, ref: E, ...me }) => {
|
|
23
|
+
let D = t("viewport", v, fe), { ref: O, width: k, height: A } = i(), j = f(null), M = f(null), [N, P] = ae(!1), F = {
|
|
24
|
+
width: b,
|
|
25
|
+
height: x
|
|
26
|
+
}, I = {
|
|
27
|
+
width: k,
|
|
28
|
+
height: A
|
|
29
|
+
}, L = {
|
|
30
|
+
min: S,
|
|
31
|
+
max: C
|
|
32
|
+
}, R = re(F, I), [z, B] = ee(w, T ?? te, le), V = k > 0 && A > 0, H = V ? o(z, F, I, L) : z, U = b > 0 && x > 0, W = f(T !== void 0 || w !== void 0);
|
|
33
|
+
d(() => {
|
|
34
|
+
!W.current && V && U && (W.current = !0, B(s(F, I, L)));
|
|
35
|
+
}, [
|
|
36
|
+
V,
|
|
37
|
+
U,
|
|
38
|
+
B,
|
|
39
|
+
b,
|
|
40
|
+
x,
|
|
41
|
+
k,
|
|
42
|
+
A,
|
|
43
|
+
S,
|
|
44
|
+
C
|
|
45
|
+
]);
|
|
46
|
+
let G = ie((e) => B(o(e, F, I, L)), [
|
|
47
|
+
B,
|
|
48
|
+
b,
|
|
49
|
+
x,
|
|
50
|
+
k,
|
|
51
|
+
A,
|
|
52
|
+
S,
|
|
53
|
+
C
|
|
54
|
+
]), K = (e, t) => {
|
|
55
|
+
let n = j.current?.getBoundingClientRect();
|
|
56
|
+
return n ? {
|
|
57
|
+
x: e - (n.left + n.width / 2),
|
|
58
|
+
y: t - (n.top + n.height / 2)
|
|
59
|
+
} : {
|
|
60
|
+
x: 0,
|
|
61
|
+
y: 0
|
|
62
|
+
};
|
|
63
|
+
}, q = (e, t) => {
|
|
64
|
+
let n = u(H, e, t, F, I, L);
|
|
65
|
+
(n.scale !== H.scale || n.x !== H.x || n.y !== H.y) && B(n);
|
|
66
|
+
}, J = (e, t) => q(a(H.scale, e, {
|
|
67
|
+
min: S,
|
|
68
|
+
max: C,
|
|
69
|
+
step: ce
|
|
70
|
+
}), t), Y = f(() => void 0);
|
|
71
|
+
Y.current = (e) => {
|
|
72
|
+
e.preventDefault(), J(e.deltaY, K(e.clientX, e.clientY));
|
|
73
|
+
}, d(() => {
|
|
74
|
+
let e = M.current;
|
|
75
|
+
if (!e) return;
|
|
76
|
+
let t = (e) => Y.current(e);
|
|
77
|
+
return e.addEventListener("wheel", t, { passive: !1 }), () => e.removeEventListener("wheel", t);
|
|
78
|
+
}, []);
|
|
79
|
+
let X = f(/* @__PURE__ */ new Map()), Z = f(null), Q = f(null), he = (e) => {
|
|
80
|
+
if (X.current.set(e.pointerId, {
|
|
81
|
+
x: e.clientX,
|
|
82
|
+
y: e.clientY
|
|
83
|
+
}), X.current.size === 2) {
|
|
84
|
+
let e = [...X.current.values()];
|
|
85
|
+
Z.current = {
|
|
86
|
+
dist: l(e),
|
|
87
|
+
scale: H.scale
|
|
88
|
+
}, Q.current = null;
|
|
89
|
+
} else X.current.size === 1 && (e.currentTarget.setPointerCapture(e.pointerId), Q.current = {
|
|
90
|
+
x: e.clientX,
|
|
91
|
+
y: e.clientY,
|
|
92
|
+
ox: H.x,
|
|
93
|
+
oy: H.y
|
|
94
|
+
});
|
|
95
|
+
}, ge = (e) => {
|
|
96
|
+
if (!X.current.has(e.pointerId)) return;
|
|
97
|
+
if (X.current.set(e.pointerId, {
|
|
98
|
+
x: e.clientX,
|
|
99
|
+
y: e.clientY
|
|
100
|
+
}), Z.current && X.current.size >= 2) {
|
|
101
|
+
let e = [...X.current.values()], t = l(e);
|
|
102
|
+
if (Z.current.dist > 0 && t > 0) {
|
|
103
|
+
let n = c(e);
|
|
104
|
+
q(Z.current.scale * (t / Z.current.dist), K(n.x, n.y));
|
|
105
|
+
}
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
let t = Q.current;
|
|
109
|
+
t && G({
|
|
110
|
+
scale: H.scale,
|
|
111
|
+
x: t.ox + (e.clientX - t.x),
|
|
112
|
+
y: t.oy + (e.clientY - t.y)
|
|
113
|
+
});
|
|
114
|
+
}, $ = (e) => {
|
|
115
|
+
X.current.delete(e.pointerId), X.current.size < 2 && (Z.current = null), X.current.size === 0 && (Q.current = null);
|
|
116
|
+
};
|
|
117
|
+
d(() => {
|
|
118
|
+
let e = n(j.current);
|
|
119
|
+
if (!e) return;
|
|
120
|
+
let t = () => P(e.fullscreenElement === j.current);
|
|
121
|
+
return e.addEventListener("fullscreenchange", t), t(), () => e.removeEventListener("fullscreenchange", t);
|
|
122
|
+
}, []);
|
|
123
|
+
let _e = () => {
|
|
124
|
+
let e = j.current, t = n(e);
|
|
125
|
+
e && t && (t.fullscreenElement ? t.exitFullscreen?.() : e.requestFullscreen?.())?.catch(() => void 0);
|
|
126
|
+
}, ve = V && (b * H.scale > k || x * H.scale > A);
|
|
127
|
+
return /* @__PURE__ */ m("div", {
|
|
128
|
+
...me,
|
|
129
|
+
ref: (e) => {
|
|
130
|
+
j.current = e, O(e), typeof E == "function" ? E(e) : E && (E.current = e);
|
|
131
|
+
},
|
|
132
|
+
className: e("kapi-viewport", ve && "is-pannable", pe),
|
|
133
|
+
children: [/* @__PURE__ */ p("div", {
|
|
134
|
+
ref: M,
|
|
135
|
+
className: "kapi-viewport__stage",
|
|
136
|
+
style: {
|
|
137
|
+
transform: `translate(${H.x}px, ${H.y}px) scale(${H.scale})`,
|
|
138
|
+
width: b,
|
|
139
|
+
height: x
|
|
140
|
+
},
|
|
141
|
+
onPointerDown: he,
|
|
142
|
+
onPointerMove: ge,
|
|
143
|
+
onPointerUp: $,
|
|
144
|
+
onPointerCancel: $,
|
|
145
|
+
onDoubleClick: (e) => q(ne(H.scale, R, L), K(e.clientX, e.clientY)),
|
|
146
|
+
children: y
|
|
147
|
+
}), !ue && /* @__PURE__ */ m("div", {
|
|
148
|
+
className: "kapi-viewport__controls",
|
|
149
|
+
children: [
|
|
150
|
+
/* @__PURE__ */ p(r, {
|
|
151
|
+
"aria-label": D.zoomOut,
|
|
152
|
+
icon: /* @__PURE__ */ p(h, {
|
|
153
|
+
size: 16,
|
|
154
|
+
strokeWidth: 2.2
|
|
155
|
+
}),
|
|
156
|
+
onClick: () => J(1, {
|
|
157
|
+
x: 0,
|
|
158
|
+
y: 0
|
|
159
|
+
}),
|
|
160
|
+
disabled: H.scale <= S
|
|
161
|
+
}),
|
|
162
|
+
/* @__PURE__ */ p(r, {
|
|
163
|
+
"aria-label": D.zoomIn,
|
|
164
|
+
icon: /* @__PURE__ */ p(g, {
|
|
165
|
+
size: 16,
|
|
166
|
+
strokeWidth: 2.2
|
|
167
|
+
}),
|
|
168
|
+
onClick: () => J(-1, {
|
|
169
|
+
x: 0,
|
|
170
|
+
y: 0
|
|
171
|
+
}),
|
|
172
|
+
disabled: H.scale >= C
|
|
173
|
+
}),
|
|
174
|
+
/* @__PURE__ */ p(r, {
|
|
175
|
+
"aria-label": D.fit,
|
|
176
|
+
icon: /* @__PURE__ */ p(_, {
|
|
177
|
+
size: 16,
|
|
178
|
+
strokeWidth: 2
|
|
179
|
+
}),
|
|
180
|
+
onClick: () => G(s(F, I, L))
|
|
181
|
+
}),
|
|
182
|
+
!de && /* @__PURE__ */ p(r, {
|
|
183
|
+
"aria-label": N ? D.exitFullscreen : D.fullscreen,
|
|
184
|
+
icon: p(N ? se : oe, {
|
|
185
|
+
size: 16,
|
|
186
|
+
strokeWidth: 2
|
|
187
|
+
}),
|
|
188
|
+
onClick: _e
|
|
189
|
+
})
|
|
190
|
+
]
|
|
191
|
+
})]
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
//#endregion
|
|
195
|
+
export { v as DEFAULT_VIEWPORT_LABELS, y as KapiViewport };
|
|
@@ -46,3 +46,11 @@ samePlacement,
|
|
|
46
46
|
/** @deprecated Interno, se quita en 1.0. */
|
|
47
47
|
shiftIntoView } from "./popoverLogic.js";
|
|
48
48
|
export type { KapiPlacePopoverOptions, KapiPopoverAlign, KapiPopoverAnchor, KapiPopoverFlip, KapiPopoverPlacement, KapiPopoverPoint, KapiPopoverRect, KapiPopoverSide, KapiPopoverSize, KapiPopoverWidth } from "./popoverLogic.js";
|
|
49
|
+
export { KapiShortcutsHelp, DEFAULT_SHORTCUTS_HELP_LABELS } from "./KapiShortcutsHelp.js";
|
|
50
|
+
export type { KapiShortcutsHelpProps, KapiShortcutsHelpLabels, KapiShortcutsHelpClassNames } from "./KapiShortcutsHelp.js";
|
|
51
|
+
export { KapiViewport, DEFAULT_VIEWPORT_LABELS } from "./KapiViewport.js";
|
|
52
|
+
export type { KapiViewportProps, KapiViewportLabels, KapiViewportState } from "./KapiViewport.js";
|
|
53
|
+
export { KapiImageViewer, DEFAULT_IMAGE_VIEWER_LABELS } from "./KapiImageViewer.js";
|
|
54
|
+
export type { KapiImageViewerProps, KapiImageViewerLabels, KapiImageViewerItem } from "./KapiImageViewer.js";
|
|
55
|
+
export { VIEWPORT_IDENTITY, clampViewport, doubleTapScale, fitScale, fitViewport, panBounds, pinchCenter, pinchDistance, zoomAt } from "./viewportLogic.js";
|
|
56
|
+
export type { KapiViewportLimits, KapiViewportSize } from "./viewportLogic.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Partes de `shortcutsHelp` (ver `slotCatalog.ts` para el contrato). Vive junto al componente para que su CSS lo siga. */
|
|
2
|
+
export declare const SHORTCUTS_HELP_SLOTS: import("../slotsLogic.js").SlotTable<"shortcutsHelp", {
|
|
3
|
+
readonly group: "kapi-shortcuts__group";
|
|
4
|
+
readonly groupTitle: "kapi-shortcuts__title";
|
|
5
|
+
readonly list: "kapi-shortcuts__list";
|
|
6
|
+
readonly row: "kapi-shortcuts__row";
|
|
7
|
+
readonly keys: "kapi-shortcuts__keys";
|
|
8
|
+
readonly description: "kapi-shortcuts__what";
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineSlots as e } from "../slotsLogic.js";
|
|
2
|
+
//#region src/components/overlays/shortcutsHelpSlots.ts
|
|
3
|
+
var t = e("shortcutsHelp", {
|
|
4
|
+
group: "kapi-shortcuts__group",
|
|
5
|
+
groupTitle: "kapi-shortcuts__title",
|
|
6
|
+
list: "kapi-shortcuts__list",
|
|
7
|
+
row: "kapi-shortcuts__row",
|
|
8
|
+
keys: "kapi-shortcuts__keys",
|
|
9
|
+
description: "kapi-shortcuts__what"
|
|
10
|
+
});
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as SHORTCUTS_HELP_SLOTS };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** Estado del visor: cuánto se acercó y cuánto se corrió el contenido, en píxeles de pantalla. */
|
|
2
|
+
export type KapiViewportState = {
|
|
3
|
+
/** Factor de escala. 1 es el tamaño natural del contenido. */
|
|
4
|
+
scale: number;
|
|
5
|
+
/** Desplazamiento horizontal del contenido respecto del centro del marco. */
|
|
6
|
+
x: number;
|
|
7
|
+
/** Desplazamiento vertical. */
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
/** Un tamaño en píxeles. */
|
|
11
|
+
export type KapiViewportSize = {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
/** Hasta dónde se puede acercar y alejar. */
|
|
16
|
+
export type KapiViewportLimits = {
|
|
17
|
+
/** Escala mínima. */
|
|
18
|
+
min: number;
|
|
19
|
+
/** Escala máxima. */
|
|
20
|
+
max: number;
|
|
21
|
+
};
|
|
22
|
+
/** El estado de arranque: tamaño natural, centrado. */
|
|
23
|
+
export declare const VIEWPORT_IDENTITY: KapiViewportState;
|
|
24
|
+
/**
|
|
25
|
+
* Escala a la que el contenido entra entero en el marco, sin deformarse (la menor de las dos
|
|
26
|
+
* razones). Un contenido o un marco de lado cero devuelve 1: no hay nada que ajustar y dividir
|
|
27
|
+
* daría infinito.
|
|
28
|
+
*/
|
|
29
|
+
export declare const fitScale: (content: KapiViewportSize, frame: KapiViewportSize) => number;
|
|
30
|
+
/**
|
|
31
|
+
* Cuánto puede correrse el contenido en cada eje sin dejar un borde adentro del marco.
|
|
32
|
+
*
|
|
33
|
+
* Cuando el contenido escalado es MÁS CHICO que el marco el margen es cero, o sea que queda
|
|
34
|
+
* centrado y no se puede arrastrar: dejarlo moverse haría que una foto chica se vaya de la
|
|
35
|
+
* pantalla y haya que buscarla.
|
|
36
|
+
*/
|
|
37
|
+
export declare const panBounds: (content: KapiViewportSize, frame: KapiViewportSize, scale: number) => KapiViewportSize;
|
|
38
|
+
/** Acota un estado: la escala a sus límites y el desplazamiento a lo que el contenido permite. */
|
|
39
|
+
export declare const clampViewport: (state: KapiViewportState, content: KapiViewportSize, frame: KapiViewportSize, limits: KapiViewportLimits) => KapiViewportState;
|
|
40
|
+
/**
|
|
41
|
+
* Cambia la escala dejando quieto el punto que está bajo el cursor.
|
|
42
|
+
*
|
|
43
|
+
* Es lo que hace que acercar con la rueda se sienta bien: sin esto el contenido se agranda desde el
|
|
44
|
+
* centro y lo que la persona estaba mirando se le escapa de la pantalla. `point` va en coordenadas
|
|
45
|
+
* **relativas al centro del marco**, que es el mismo origen del desplazamiento.
|
|
46
|
+
*/
|
|
47
|
+
export declare const zoomAt: (state: KapiViewportState, nextScale: number, point: {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
}, content: KapiViewportSize, frame: KapiViewportSize, limits: KapiViewportLimits) => KapiViewportState;
|
|
51
|
+
/** Estado que ajusta el contenido al marco y lo centra. */
|
|
52
|
+
export declare const fitViewport: (content: KapiViewportSize, frame: KapiViewportSize, limits: KapiViewportLimits) => KapiViewportState;
|
|
53
|
+
/**
|
|
54
|
+
* ¿El doble clic acerca o vuelve a ajustar? Acerca mientras esté cerca del ajuste; una vez
|
|
55
|
+
* acercado, el segundo doble clic devuelve al ajuste. Un solo gesto para ir y volver.
|
|
56
|
+
*/
|
|
57
|
+
export declare const doubleTapScale: (current: number, fitted: number, limits: KapiViewportLimits) => number;
|
|
58
|
+
/**
|
|
59
|
+
* Distancia entre dos dedos, para el pellizco. Devuelve 0 con menos de dos puntos, que es lo que
|
|
60
|
+
* deja al llamador distinguir "no hay gesto" sin mirar la longitud.
|
|
61
|
+
*/
|
|
62
|
+
export declare const pinchDistance: (points: readonly {
|
|
63
|
+
x: number;
|
|
64
|
+
y: number;
|
|
65
|
+
}[]) => number;
|
|
66
|
+
/** Punto medio entre dos dedos: el foco del pellizco. Con menos de dos puntos, el origen. */
|
|
67
|
+
export declare const pinchCenter: (points: readonly {
|
|
68
|
+
x: number;
|
|
69
|
+
y: number;
|
|
70
|
+
}[]) => {
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//#region src/components/overlays/viewportLogic.ts
|
|
2
|
+
var e = (e, t, n) => Math.min(n, Math.max(t, e)), t = (e, t) => Number.isFinite(e) ? e : t, n = {
|
|
3
|
+
scale: 1,
|
|
4
|
+
x: 0,
|
|
5
|
+
y: 0
|
|
6
|
+
}, r = (e, n) => {
|
|
7
|
+
let r = t(e.width, 0), i = t(e.height, 0), a = t(n.width, 0), o = t(n.height, 0);
|
|
8
|
+
return r <= 0 || i <= 0 || a <= 0 || o <= 0 ? 1 : Math.min(a / r, o / i);
|
|
9
|
+
}, i = (e, n, r) => {
|
|
10
|
+
let i = t(r, 1), a = t(e.width, 0) * i, o = t(e.height, 0) * i;
|
|
11
|
+
return {
|
|
12
|
+
width: Math.max(0, (a - t(n.width, 0)) / 2),
|
|
13
|
+
height: Math.max(0, (o - t(n.height, 0)) / 2)
|
|
14
|
+
};
|
|
15
|
+
}, a = (n, r, a, o) => {
|
|
16
|
+
let s = t(o.min, 1), c = Math.max(s, t(o.max, s)), l = e(t(n.scale, 1), s, c), u = i(r, a, l);
|
|
17
|
+
return {
|
|
18
|
+
scale: l,
|
|
19
|
+
x: e(t(n.x, 0), -u.width, u.width),
|
|
20
|
+
y: e(t(n.y, 0), -u.height, u.height)
|
|
21
|
+
};
|
|
22
|
+
}, o = (n, r, i, o, s, c) => {
|
|
23
|
+
let l = t(c.min, 1), u = Math.max(l, t(c.max, l)), d = t(n.scale, 1), f = e(t(r, d), l, u);
|
|
24
|
+
if (f === d) return a(n, o, s, c);
|
|
25
|
+
let p = f / d, m = t(i.x, 0), h = t(i.y, 0);
|
|
26
|
+
return a({
|
|
27
|
+
scale: f,
|
|
28
|
+
x: m - (m - t(n.x, 0)) * p,
|
|
29
|
+
y: h - (h - t(n.y, 0)) * p
|
|
30
|
+
}, o, s, c);
|
|
31
|
+
}, s = (e, t, n) => a({
|
|
32
|
+
scale: r(e, t),
|
|
33
|
+
x: 0,
|
|
34
|
+
y: 0
|
|
35
|
+
}, e, t, n), c = (n, r, i) => {
|
|
36
|
+
let a = t(i.min, 1), o = Math.max(a, t(i.max, a));
|
|
37
|
+
return Math.abs(t(n, 1) - t(r, 1)) < .01 ? e(Math.max(r * 2, 1), a, o) : e(r, a, o);
|
|
38
|
+
}, l = (e) => {
|
|
39
|
+
if (e.length < 2) return 0;
|
|
40
|
+
let [n, r] = e;
|
|
41
|
+
return Math.hypot(t(r.x, 0) - t(n.x, 0), t(r.y, 0) - t(n.y, 0));
|
|
42
|
+
}, u = (e) => {
|
|
43
|
+
if (e.length < 2) return {
|
|
44
|
+
x: 0,
|
|
45
|
+
y: 0
|
|
46
|
+
};
|
|
47
|
+
let [n, r] = e;
|
|
48
|
+
return {
|
|
49
|
+
x: (t(n.x, 0) + t(r.x, 0)) / 2,
|
|
50
|
+
y: (t(n.y, 0) + t(r.y, 0)) / 2
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
54
|
+
export { n as VIEWPORT_IDENTITY, a as clampViewport, c as doubleTapScale, r as fitScale, s as fitViewport, i as panBounds, u as pinchCenter, l as pinchDistance, o as zoomAt };
|
|
@@ -109,6 +109,39 @@ export declare const KAPI_SLOTS: {
|
|
|
109
109
|
readonly meta: "kapi-pageheader__meta";
|
|
110
110
|
readonly actions: "kapi-pageheader__actions";
|
|
111
111
|
};
|
|
112
|
+
alert: {
|
|
113
|
+
readonly root: "kapi-alert";
|
|
114
|
+
readonly icon: "kapi-alert__ico";
|
|
115
|
+
readonly body: "kapi-alert__body";
|
|
116
|
+
readonly title: "kapi-alert__title";
|
|
117
|
+
readonly message: "kapi-alert__msg";
|
|
118
|
+
readonly close: "kapi-alert__close";
|
|
119
|
+
};
|
|
120
|
+
countdown: {
|
|
121
|
+
readonly root: "kapi-countdown";
|
|
122
|
+
readonly prefix: "kapi-countdown__prefix";
|
|
123
|
+
readonly time: "kapi-countdown__time";
|
|
124
|
+
};
|
|
125
|
+
empty: {
|
|
126
|
+
readonly root: "kapi-empty";
|
|
127
|
+
readonly icon: "kapi-empty__icon";
|
|
128
|
+
readonly title: "kapi-empty__title";
|
|
129
|
+
readonly description: "kapi-empty__desc";
|
|
130
|
+
readonly action: "kapi-empty__action";
|
|
131
|
+
};
|
|
132
|
+
shortcutsHelp: {
|
|
133
|
+
readonly group: "kapi-shortcuts__group";
|
|
134
|
+
readonly groupTitle: "kapi-shortcuts__title";
|
|
135
|
+
readonly list: "kapi-shortcuts__list";
|
|
136
|
+
readonly row: "kapi-shortcuts__row";
|
|
137
|
+
readonly keys: "kapi-shortcuts__keys";
|
|
138
|
+
readonly description: "kapi-shortcuts__what";
|
|
139
|
+
};
|
|
140
|
+
avatarGroup: {
|
|
141
|
+
readonly root: "kapi-avatargroup";
|
|
142
|
+
readonly item: "kapi-avatargroup__item";
|
|
143
|
+
readonly more: null;
|
|
144
|
+
};
|
|
112
145
|
};
|
|
113
146
|
/** Nombre de un componente con partes declaradas (el que va en `data-slot` y en `KAPI_SLOTS`). */
|
|
114
147
|
export type KapiSlotComponent = keyof typeof KAPI_SLOTS;
|
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
import { SELECT_SLOTS as e } from "./inputs/selectSlots.js";
|
|
2
2
|
import { MODAL_SLOTS as t } from "./overlays/modalSlots.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
3
|
+
import { SHORTCUTS_HELP_SLOTS as n } from "./overlays/shortcutsHelpSlots.js";
|
|
4
|
+
import { TABLE_SLOTS as r } from "./data/tableSlots.js";
|
|
5
|
+
import { AVATAR_GROUP_SLOTS as i } from "./display/avatarGroupSlots.js";
|
|
6
|
+
import { HIGHLIGHT_SLOTS as a } from "./display/highlightSlots.js";
|
|
7
|
+
import { CODE_BLOCK_SLOTS as o } from "./display/codeBlockSlots.js";
|
|
8
|
+
import { DIFF_SLOTS as s } from "./display/diffSlots.js";
|
|
9
|
+
import { EMPTY_SLOTS as c } from "./feedback/emptySlots.js";
|
|
10
|
+
import { ALERT_SLOTS as l } from "./feedback/alertSlots.js";
|
|
11
|
+
import { COUNTDOWN_SLOTS as u } from "./feedback/countdownSlots.js";
|
|
12
|
+
import { TOC_SLOTS as d } from "./navigation/tocSlots.js";
|
|
13
|
+
import { SHELL_SLOTS as f } from "./layout/shellSlots.js";
|
|
14
|
+
import { RAIL_SLOTS as p } from "./layout/railSlots.js";
|
|
15
|
+
import { CARD_SLOTS as m } from "./layout/cardSlots.js";
|
|
16
|
+
import { PAGEHEADER_SLOTS as h } from "./layout/pageHeaderSlots.js";
|
|
12
17
|
//#region src/components/slotCatalog.ts
|
|
13
|
-
var
|
|
14
|
-
card:
|
|
15
|
-
codeBlock:
|
|
16
|
-
diff:
|
|
17
|
-
highlight:
|
|
18
|
-
toc:
|
|
18
|
+
var g = {
|
|
19
|
+
card: m.parts,
|
|
20
|
+
codeBlock: o.parts,
|
|
21
|
+
diff: s.parts,
|
|
22
|
+
highlight: a.parts,
|
|
23
|
+
toc: d.parts,
|
|
19
24
|
modal: t.parts,
|
|
20
|
-
table:
|
|
25
|
+
table: r.parts,
|
|
21
26
|
select: e.parts,
|
|
22
|
-
shell:
|
|
23
|
-
rail:
|
|
24
|
-
pageheader:
|
|
27
|
+
shell: f.parts,
|
|
28
|
+
rail: p.parts,
|
|
29
|
+
pageheader: h.parts,
|
|
30
|
+
alert: l.parts,
|
|
31
|
+
countdown: u.parts,
|
|
32
|
+
empty: c.parts,
|
|
33
|
+
shortcutsHelp: n.parts,
|
|
34
|
+
avatarGroup: i.parts
|
|
25
35
|
};
|
|
26
36
|
//#endregion
|
|
27
|
-
export {
|
|
37
|
+
export { g as KAPI_SLOTS };
|