@kapiuara/ui 0.16.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 +430 -20
- package/dist/components/chat/KapiChatThread.js +4 -4
- package/dist/components/chat/KapiComposer.js +8 -8
- package/dist/components/data/KapiDataTable.js +4 -4
- package/dist/components/data/KapiScatterChart.d.ts +56 -0
- package/dist/components/data/KapiScatterChart.js +90 -0
- package/dist/components/data/KapiSparkline.d.ts +2 -1
- package/dist/components/data/KapiSparkline.js +29 -26
- package/dist/components/data/KapiTableFilter.js +6 -6
- 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/data/tableCells.d.ts +12 -1
- package/dist/components/data/tableCells.js +49 -51
- package/dist/components/data/useTableSelection.js +3 -3
- package/dist/components/display/KapiAnnotation.js +68 -63
- package/dist/components/display/KapiAvatar.d.ts +6 -4
- package/dist/components/display/KapiAvatar.js +33 -28
- package/dist/components/display/KapiAvatarGroup.d.ts +14 -2
- package/dist/components/display/KapiAvatarGroup.js +25 -23
- package/dist/components/display/KapiCodeBlock.d.ts +48 -0
- package/dist/components/display/KapiCodeBlock.js +44 -0
- package/dist/components/display/KapiCommentComposer.js +6 -6
- package/dist/components/display/KapiDiff.d.ts +62 -0
- package/dist/components/display/KapiDiff.js +118 -0
- package/dist/components/display/KapiHighlight.d.ts +27 -0
- package/dist/components/display/KapiHighlight.js +21 -0
- package/dist/components/display/KapiIconTile.d.ts +2 -1
- package/dist/components/display/KapiIconTile.js +23 -21
- package/dist/components/display/KapiStat.d.ts +3 -2
- package/dist/components/display/KapiStat.js +32 -26
- package/dist/components/display/KapiTag.d.ts +4 -3
- package/dist/components/display/KapiTag.js +29 -24
- package/dist/components/display/KapiTimeline.d.ts +19 -2
- package/dist/components/display/KapiTimeline.js +38 -23
- package/dist/components/display/annotationLogic.d.ts +2 -1
- package/dist/components/display/annotationLogic.js +7 -6
- package/dist/components/display/avatarGroupSlots.d.ts +6 -0
- package/dist/components/display/avatarGroupSlots.js +9 -0
- package/dist/components/display/codeBlockSlots.d.ts +10 -0
- package/dist/components/display/codeBlockSlots.js +13 -0
- package/dist/components/display/diffLogic.d.ts +58 -0
- package/dist/components/display/diffLogic.js +96 -0
- package/dist/components/display/diffSlots.d.ts +14 -0
- package/dist/components/display/diffSlots.js +17 -0
- package/dist/components/display/highlightLogic.d.ts +18 -0
- package/dist/components/display/highlightLogic.js +26 -0
- package/dist/components/display/highlightSlots.d.ts +5 -0
- package/dist/components/display/highlightSlots.js +8 -0
- package/dist/components/display/iconTileLogic.d.ts +2 -2
- package/dist/components/display/iconTileLogic.js +7 -6
- package/dist/components/display/index.d.ts +9 -1
- package/dist/components/display/statLogic.d.ts +2 -1
- package/dist/components/display/statLogic.js +7 -6
- package/dist/components/display/tagLogic.d.ts +2 -1
- package/dist/components/display/tagLogic.js +7 -6
- package/dist/components/display/timelineLogic.d.ts +20 -2
- package/dist/components/display/timelineLogic.js +10 -2
- 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/KapiFab.js +108 -108
- package/dist/components/feedback/KapiProgress.js +63 -54
- package/dist/components/feedback/KapiSpinner.d.ts +48 -0
- package/dist/components/feedback/KapiSpinner.js +27 -0
- package/dist/components/feedback/KapiToastContainer.js +10 -10
- package/dist/components/feedback/KapiTour.js +13 -13
- 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/feedback/progressLogic.d.ts +2 -1
- package/dist/components/feedback/progressLogic.js +9 -8
- package/dist/components/inputs/KapiAutocomplete.d.ts +6 -0
- package/dist/components/inputs/KapiAutocomplete.js +86 -85
- package/dist/components/inputs/KapiChecklist.d.ts +7 -1
- package/dist/components/inputs/KapiChecklist.js +53 -52
- package/dist/components/inputs/KapiCopyButton.d.ts +40 -0
- package/dist/components/inputs/KapiCopyButton.js +35 -0
- package/dist/components/inputs/KapiDatePicker.d.ts +7 -1
- package/dist/components/inputs/KapiDatePicker.js +118 -116
- package/dist/components/inputs/KapiDateRangePicker.d.ts +7 -1
- package/dist/components/inputs/KapiDateRangePicker.js +136 -135
- package/dist/components/inputs/KapiFacetedSearch.js +5 -5
- package/dist/components/inputs/KapiField.d.ts +9 -1
- package/dist/components/inputs/KapiField.js +43 -42
- package/dist/components/inputs/KapiFileUpload.d.ts +14 -1
- package/dist/components/inputs/KapiFileUpload.js +83 -70
- package/dist/components/inputs/KapiInput.d.ts +29 -1
- package/dist/components/inputs/KapiInput.js +74 -51
- package/dist/components/inputs/KapiMaskedInput.js +26 -26
- package/dist/components/inputs/KapiNumberStepper.d.ts +7 -1
- package/dist/components/inputs/KapiNumberStepper.js +24 -23
- package/dist/components/inputs/KapiPinInput.d.ts +72 -0
- package/dist/components/inputs/KapiPinInput.js +75 -0
- package/dist/components/inputs/KapiPropsForm.d.ts +34 -0
- package/dist/components/inputs/KapiPropsForm.js +78 -0
- package/dist/components/inputs/KapiRating.d.ts +7 -1
- package/dist/components/inputs/KapiRating.js +39 -38
- package/dist/components/inputs/KapiSearchChip.js +5 -5
- package/dist/components/inputs/KapiSegmented.d.ts +13 -5
- package/dist/components/inputs/KapiSegmented.js +81 -77
- package/dist/components/inputs/KapiSelect.d.ts +9 -1
- package/dist/components/inputs/KapiSelect.js +236 -233
- package/dist/components/inputs/KapiSlider.d.ts +10 -3
- package/dist/components/inputs/KapiSlider.js +67 -63
- package/dist/components/inputs/KapiTagInput.d.ts +7 -1
- package/dist/components/inputs/KapiTagInput.js +70 -69
- package/dist/components/inputs/KapiTextarea.d.ts +7 -1
- package/dist/components/inputs/KapiTextarea.js +51 -50
- package/dist/components/inputs/copyLogic.d.ts +1 -0
- package/dist/components/inputs/copyLogic.js +12 -0
- package/dist/components/inputs/fieldLogic.d.ts +23 -3
- package/dist/components/inputs/fieldLogic.js +18 -11
- package/dist/components/inputs/formBridgeLogic.d.ts +104 -0
- package/dist/components/inputs/formBridgeLogic.js +25 -0
- package/dist/components/inputs/index.d.ts +10 -0
- package/dist/components/inputs/inputLogic.d.ts +16 -1
- package/dist/components/inputs/inputLogic.js +3 -3
- package/dist/components/inputs/ownField.d.ts +3 -1
- package/dist/components/inputs/ownField.js +28 -27
- package/dist/components/inputs/pinInputLogic.d.ts +34 -0
- package/dist/components/inputs/pinInputLogic.js +37 -0
- package/dist/components/inputs/propsFormLogic.d.ts +53 -0
- package/dist/components/inputs/propsFormLogic.js +11 -0
- package/dist/components/inputs/segmentedLogic.d.ts +7 -0
- package/dist/components/inputs/segmentedLogic.js +2 -2
- package/dist/components/layout/KapiAccessCard.d.ts +5 -1
- package/dist/components/layout/KapiAccessCard.js +43 -39
- package/dist/components/layout/KapiAccountMenu.js +7 -7
- package/dist/components/layout/KapiCollapse.d.ts +39 -0
- package/dist/components/layout/KapiCollapse.js +20 -0
- package/dist/components/layout/KapiContextSlot.js +4 -4
- package/dist/components/layout/KapiDivider.d.ts +11 -2
- package/dist/components/layout/KapiDivider.js +30 -24
- package/dist/components/layout/KapiGrid.js +2 -2
- package/dist/components/layout/KapiNotificationBell.js +10 -10
- package/dist/components/layout/KapiPageHeader.js +22 -22
- package/dist/components/layout/KapiRail.js +4 -4
- package/dist/components/layout/KapiRoot.d.ts +22 -2
- package/dist/components/layout/KapiRoot.js +33 -29
- package/dist/components/layout/KapiShell.d.ts +9 -1
- package/dist/components/layout/KapiShell.js +28 -27
- package/dist/components/layout/accessCardLogic.d.ts +8 -1
- package/dist/components/layout/accessCardLogic.js +11 -7
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/locale/labelRegistry.d.ts +18 -0
- package/dist/components/navigation/KapiAccordion.js +9 -9
- package/dist/components/navigation/KapiContextPanel.js +12 -12
- package/dist/components/navigation/KapiNavBadge.d.ts +6 -3
- package/dist/components/navigation/KapiNavBadge.js +26 -22
- package/dist/components/navigation/KapiSteps.d.ts +26 -5
- package/dist/components/navigation/KapiSteps.js +55 -43
- package/dist/components/navigation/KapiTabs.js +9 -9
- package/dist/components/navigation/KapiToc.d.ts +48 -0
- package/dist/components/navigation/KapiToc.js +66 -0
- package/dist/components/navigation/KapiTree.js +10 -10
- package/dist/components/navigation/index.d.ts +3 -0
- package/dist/components/navigation/tocLogic.d.ts +35 -0
- package/dist/components/navigation/tocLogic.js +11 -0
- package/dist/components/navigation/tocSlots.d.ts +8 -0
- package/dist/components/navigation/tocSlots.js +11 -0
- package/dist/components/overlays/KapiCommandPalette.js +6 -6
- package/dist/components/overlays/KapiContextMenu.js +5 -5
- package/dist/components/overlays/KapiImageViewer.d.ts +63 -0
- package/dist/components/overlays/KapiImageViewer.js +106 -0
- package/dist/components/overlays/KapiMenuButton.js +7 -7
- package/dist/components/overlays/KapiModal.js +3 -3
- package/dist/components/overlays/KapiOffcanvas.js +24 -24
- package/dist/components/overlays/KapiPhotoView.js +10 -10
- package/dist/components/overlays/KapiPopover.js +6 -6
- package/dist/components/overlays/KapiShapeSheet.js +4 -4
- 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 +120 -68
- 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/menuList.js +22 -22
- 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 +66 -0
- package/dist/components/slotCatalog.js +30 -12
- package/dist/css/base.css +1 -1
- package/dist/css/components/data/KapiScatterChart.css +1 -0
- package/dist/css/components/display/KapiAnnotation.css +1 -1
- package/dist/css/components/display/KapiCodeBlock.css +1 -0
- package/dist/css/components/display/KapiDiff.css +1 -0
- package/dist/css/components/display/display.css +1 -1
- package/dist/css/components/feedback/feedback.css +1 -1
- package/dist/css/components/inputs/KapiFileUpload.css +1 -1
- package/dist/css/components/inputs/KapiPinInput.css +1 -0
- package/dist/css/components/inputs/KapiSelect.css +1 -1
- package/dist/css/components/inputs/inputsExtra.css +1 -1
- package/dist/css/components/layout/KapiAccessCard.css +1 -1
- package/dist/css/components/layout/KapiCollapse.css +1 -0
- package/dist/css/components/layout/KapiDivider.css +1 -1
- package/dist/css/components/navigation/KapiSteps.css +1 -1
- package/dist/css/components/navigation/KapiToc.css +1 -0
- package/dist/css/components/overlays/KapiViewport.css +1 -0
- package/dist/css/components/overlays/overlays.css +1 -1
- package/dist/hooks/asyncResourceLogic.d.ts +11 -0
- package/dist/hooks/asyncResourceLogic.js +4 -0
- 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 +13 -0
- package/dist/hooks/toneFamilyLogic.d.ts +26 -2
- package/dist/hooks/toneFamilyLogic.js +19 -6
- package/dist/hooks/useAsyncResource.d.ts +45 -0
- package/dist/hooks/useAsyncResource.js +24 -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/hooks/useKapiTheme.d.ts +8 -1
- package/dist/hooks/useKapiTheme.js +57 -57
- package/dist/hooks/useToneFamilies.d.ts +14 -4
- package/dist/hooks/useToneFamilies.js +27 -23
- package/dist/index.js +234 -207
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/dist/logic.d.ts +45 -0
- package/dist/logic.js +46 -0
- package/package.json +13 -2
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/overlays/overlays.css";
|
|
3
3
|
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
-
import {
|
|
4
|
+
import { useMergedRefs as t } from "../../hooks/mergeRefs.js";
|
|
5
5
|
import { useKapiDir as n } from "../locale/KapiLocaleProvider.js";
|
|
6
6
|
import { winOf as r } from "../../hooks/ownerDocument.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
7
|
+
import { joinIds as i } from "../inputs/fieldLogic.js";
|
|
8
|
+
import { placePopover as a } from "./popoverLogic.js";
|
|
9
|
+
import { onViewportChange as o } from "../../hooks/rafThrottle.js";
|
|
10
|
+
import { placementViewport as s } from "../../hooks/viewportInsetLogic.js";
|
|
11
|
+
import { resolveDirection as c } from "../../hooks/directionLogic.js";
|
|
12
12
|
/* empty css */
|
|
13
|
-
import { cloneElement as l, isValidElement as
|
|
14
|
-
import { jsx as
|
|
13
|
+
import { cloneElement as l, isValidElement as ee, useEffect as u, useId as te, useLayoutEffect as d, useRef as f, useState as p } from "react";
|
|
14
|
+
import { jsx as m, jsxs as ne } from "react/jsx-runtime";
|
|
15
15
|
//#region src/components/overlays/KapiTooltip.tsx
|
|
16
|
-
var
|
|
16
|
+
var h = 280, g = 7, _ = 28, v = 12, y = 44, b = (e, t) => e === "end" ? t === "rtl" ? "left" : "right" : e === "start" ? t === "rtl" ? "right" : "left" : e, x = (e) => typeof e == "string" || typeof e == "number" ? Math.min(h, String(e).length * g + _) : h, S = (e, t, n, r, i = Infinity) => {
|
|
17
17
|
let o = t.bottom ?? t.top, s = t.left ?? t.right, c = {
|
|
18
18
|
top: t.top,
|
|
19
19
|
bottom: o,
|
|
@@ -22,25 +22,25 @@ var v = 280, y = 7, b = 28, x = 12, S = 44, C = (e, t) => e === "end" ? t === "r
|
|
|
22
22
|
width: t.right - s,
|
|
23
23
|
height: o - t.top
|
|
24
24
|
}, l = e === "top" || e === "bottom";
|
|
25
|
-
return
|
|
26
|
-
width:
|
|
27
|
-
height:
|
|
25
|
+
return a(c, {
|
|
26
|
+
width: x(n),
|
|
27
|
+
height: y
|
|
28
28
|
}, {
|
|
29
29
|
width: r,
|
|
30
|
-
height:
|
|
30
|
+
height: i
|
|
31
31
|
}, {
|
|
32
32
|
side: e,
|
|
33
|
-
offset: l ? 0 :
|
|
33
|
+
offset: l ? 0 : v,
|
|
34
34
|
flip: "if-overflow",
|
|
35
35
|
shift: !1
|
|
36
36
|
}).side;
|
|
37
|
-
},
|
|
37
|
+
}, C = 10, w = 8, T = {
|
|
38
38
|
align: "center",
|
|
39
39
|
flip: !1,
|
|
40
40
|
shift: !1,
|
|
41
41
|
mainMin: -Infinity
|
|
42
|
-
},
|
|
43
|
-
let n = e === "top" || e === "bottom", { top: r, left:
|
|
42
|
+
}, E = (e, t) => {
|
|
43
|
+
let n = e === "top" || e === "bottom", { top: r, left: i } = a({
|
|
44
44
|
top: t.top,
|
|
45
45
|
bottom: t.bottom,
|
|
46
46
|
left: t.left,
|
|
@@ -54,75 +54,127 @@ var v = 280, y = 7, b = 28, x = 12, S = 44, C = (e, t) => e === "end" ? t === "r
|
|
|
54
54
|
width: Infinity,
|
|
55
55
|
height: Infinity
|
|
56
56
|
}, {
|
|
57
|
-
...
|
|
57
|
+
...T,
|
|
58
58
|
side: e,
|
|
59
|
-
offset: n ?
|
|
59
|
+
offset: n ? w : C
|
|
60
60
|
});
|
|
61
61
|
return {
|
|
62
|
-
x:
|
|
62
|
+
x: i,
|
|
63
63
|
y: r
|
|
64
64
|
};
|
|
65
|
-
},
|
|
65
|
+
}, D = (e, t) => {
|
|
66
66
|
try {
|
|
67
67
|
return e.matches(t);
|
|
68
68
|
} catch {
|
|
69
69
|
return null;
|
|
70
70
|
}
|
|
71
|
-
},
|
|
72
|
-
let
|
|
71
|
+
}, O = (e, t) => i(typeof e == "string" ? e : void 0, t), k = ({ label: i, children: a, target: h, prefer: g = "end", disabled: _, multiline: v, openDelay: y = 0, opened: x, className: C, style: w, id: T, ref: k }) => {
|
|
72
|
+
let A = te(), j = f(null), M = t(j, k), N = n(), [P, re] = p(() => b(g, c(null, N))), [F, I] = p(!1), [ie, L] = p(!1), R = f(!1), z = x !== void 0, B = _ ? !1 : x ?? ie, V = f({
|
|
73
73
|
hover: !1,
|
|
74
74
|
focus: !1
|
|
75
|
-
}),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
let
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
}), H = f(null), U = () => {
|
|
76
|
+
H.current !== null && clearTimeout(H.current), H.current = null;
|
|
77
|
+
}, W = f(null), ae = () => W.current ?? j.current, G = () => {
|
|
78
|
+
let e = ae(), t = j.current;
|
|
79
|
+
if (!e || !t) return;
|
|
80
|
+
let n = e.getBoundingClientRect(), r = s(e), a = S(b(g, c(e, N)), n, i, r.width, r.height), { x: o, y: l } = E(a, n);
|
|
81
|
+
t.style.setProperty("--kapi-tip-x", `${Math.round(o)}px`), t.style.setProperty("--kapi-tip-y", `${Math.round(l)}px`), re(a);
|
|
82
|
+
}, K = f(G);
|
|
83
|
+
d(() => {
|
|
84
|
+
K.current = G;
|
|
83
85
|
});
|
|
84
|
-
let
|
|
85
|
-
let t =
|
|
86
|
+
let q = f(null), J = f(!1), Y = (e) => {
|
|
87
|
+
let t = q.current;
|
|
86
88
|
if (!t || typeof t.showPopover != "function") return;
|
|
87
|
-
let n =
|
|
88
|
-
e && !n && t.showPopover(), !e && n && t.hidePopover(),
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
},
|
|
92
|
-
|
|
89
|
+
let n = D(t, ":popover-open") ?? J.current;
|
|
90
|
+
e && !n && t.showPopover(), !e && n && t.hidePopover(), J.current = e;
|
|
91
|
+
}, X = () => {
|
|
92
|
+
I(!1), L(!0), K.current(), Y(!0);
|
|
93
|
+
}, Z = (e) => {
|
|
94
|
+
_ || z || (V.current[e] = !0, e === "focus" || y <= 0 ? (U(), X()) : (U(), H.current = setTimeout(() => {
|
|
95
|
+
H.current = null, (V.current.hover || V.current.focus) && X();
|
|
96
|
+
}, y)));
|
|
97
|
+
}, Q = (e) => {
|
|
98
|
+
_ || z || (V.current[e] = !1, !(V.current.hover || V.current.focus) && (U(), I(!1), L(!1), Y(!1)));
|
|
93
99
|
};
|
|
94
100
|
d(() => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
"
|
|
110
|
-
|
|
101
|
+
z && (B ? (R.current || I(!1), G(), Y(!0)) : Y(!1), R.current = B);
|
|
102
|
+
}, [
|
|
103
|
+
z,
|
|
104
|
+
B,
|
|
105
|
+
i,
|
|
106
|
+
g
|
|
107
|
+
]), u(() => {
|
|
108
|
+
_ && (U(), V.current.hover = !1, V.current.focus = !1, L(!1), Y(!1));
|
|
109
|
+
}, [_]), u(() => U, []), u(() => {
|
|
110
|
+
if (!B) return;
|
|
111
|
+
let e = r(j.current);
|
|
112
|
+
return o(() => K.current(), e ? { target: e } : {});
|
|
113
|
+
}, [B]);
|
|
114
|
+
let oe = () => I(!0), se = (e) => {
|
|
115
|
+
e.key === "Escape" && !F && oe();
|
|
116
|
+
};
|
|
117
|
+
u(() => {
|
|
118
|
+
if (h === void 0) return;
|
|
119
|
+
let e = (j.current?.ownerDocument ?? (typeof document > "u" ? null : document))?.getElementById(h) ?? null;
|
|
120
|
+
if (W.current = e, !e || _) return;
|
|
121
|
+
let t = e.getAttribute("aria-describedby"), n = O(t, A);
|
|
122
|
+
n !== void 0 && e.setAttribute("aria-describedby", n);
|
|
123
|
+
let r = () => Z("hover"), i = () => Q("hover"), a = () => {
|
|
124
|
+
(D(e, ":focus-visible") ?? !0) && Z("focus");
|
|
125
|
+
}, o = () => Q("focus"), s = (e) => {
|
|
126
|
+
e.key === "Escape" && oe();
|
|
127
|
+
};
|
|
128
|
+
return e.addEventListener("mouseenter", r), e.addEventListener("mouseleave", i), e.addEventListener("focus", a), e.addEventListener("blur", o), e.addEventListener("keydown", s), () => {
|
|
129
|
+
e.removeEventListener("mouseenter", r), e.removeEventListener("mouseleave", i), e.removeEventListener("focus", a), e.removeEventListener("blur", o), e.removeEventListener("keydown", s), t === null ? e.removeAttribute("aria-describedby") : e.setAttribute("aria-describedby", t), W.current = null, V.current = {
|
|
130
|
+
hover: !1,
|
|
131
|
+
focus: !1
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
}, [
|
|
135
|
+
h,
|
|
136
|
+
A,
|
|
137
|
+
_,
|
|
138
|
+
y,
|
|
139
|
+
z
|
|
140
|
+
]);
|
|
141
|
+
let ce = /* @__PURE__ */ m("span", {
|
|
142
|
+
ref: q,
|
|
143
|
+
className: e("kapi-tip__bubble", v && "kapi-tip__bubble--multiline"),
|
|
144
|
+
role: "tooltip",
|
|
145
|
+
id: A,
|
|
146
|
+
popover: "manual",
|
|
147
|
+
children: i
|
|
148
|
+
});
|
|
149
|
+
if (h !== void 0) return /* @__PURE__ */ m("span", {
|
|
150
|
+
id: T,
|
|
151
|
+
className: e("kapi-tip", C),
|
|
152
|
+
style: w,
|
|
153
|
+
ref: M,
|
|
154
|
+
"data-side": P,
|
|
155
|
+
"data-open": B && !F ? "" : void 0,
|
|
156
|
+
"data-dismissed": F || void 0,
|
|
157
|
+
children: ce
|
|
158
|
+
});
|
|
159
|
+
let $ = ee(a) ? a : null, le = $ && !_ ? l($, { "aria-describedby": O($.props["aria-describedby"], A) }) : a;
|
|
160
|
+
return /* @__PURE__ */ ne("span", {
|
|
161
|
+
id: T,
|
|
162
|
+
className: e("kapi-tip", C),
|
|
163
|
+
style: w,
|
|
164
|
+
ref: M,
|
|
165
|
+
"data-side": P,
|
|
166
|
+
"data-open": B && !F ? "" : void 0,
|
|
167
|
+
"data-dismissed": F || void 0,
|
|
168
|
+
"aria-describedby": $ || _ ? void 0 : A,
|
|
169
|
+
onMouseEnter: () => Z("hover"),
|
|
111
170
|
onFocus: (e) => {
|
|
112
|
-
(
|
|
171
|
+
(D(e.target, ":focus-visible") ?? !0) && Z("focus");
|
|
113
172
|
},
|
|
114
|
-
onMouseLeave: () =>
|
|
115
|
-
onBlur: () =>
|
|
116
|
-
onKeyDown:
|
|
117
|
-
children: [
|
|
118
|
-
ref: V,
|
|
119
|
-
className: "kapi-tip__bubble",
|
|
120
|
-
role: "tooltip",
|
|
121
|
-
id: w,
|
|
122
|
-
popover: "manual",
|
|
123
|
-
children: t
|
|
124
|
-
})]
|
|
173
|
+
onMouseLeave: () => Q("hover"),
|
|
174
|
+
onBlur: () => Q("focus"),
|
|
175
|
+
onKeyDown: se,
|
|
176
|
+
children: [le, ce]
|
|
125
177
|
});
|
|
126
178
|
};
|
|
127
179
|
//#endregion
|
|
128
|
-
export {
|
|
180
|
+
export { k as KapiTooltip, x as estimateTooltipWidth, b as physicalTooltipSide, S as resolveTooltipSide, E as tooltipAnchor, O as tooltipDescribedBy };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode, type Ref } from "react";
|
|
2
|
+
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
3
|
+
import { type KapiViewportState } from "./viewportLogic.js";
|
|
4
|
+
export type { KapiViewportState };
|
|
5
|
+
/** Textos de `KapiViewport`. */
|
|
6
|
+
export type KapiViewportLabels = {
|
|
7
|
+
/** Botón de acercar. */
|
|
8
|
+
zoomIn: string;
|
|
9
|
+
/** Botón de alejar. */
|
|
10
|
+
zoomOut: string;
|
|
11
|
+
/** Botón de ajustar a la pantalla. */
|
|
12
|
+
fit: string;
|
|
13
|
+
/** Botón de pantalla completa. */
|
|
14
|
+
fullscreen: string;
|
|
15
|
+
/** Botón de salir de pantalla completa. */
|
|
16
|
+
exitFullscreen: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const DEFAULT_VIEWPORT_LABELS: KapiViewportLabels;
|
|
19
|
+
/** Atributos nativos (`id`, `style`, `data-*`…) van al marco. */
|
|
20
|
+
export type KapiViewportProps = Omit<HTMLAttributes<HTMLDivElement>, "children" | "onScroll"> & {
|
|
21
|
+
/** Ref al `<div>` del marco. */
|
|
22
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
23
|
+
/** Lo que se mira: una imagen, un SVG, un plano. */
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
/** Ancho natural del contenido, en píxeles. De acá sale el ajuste y el acotado del arrastre. */
|
|
26
|
+
contentWidth: number;
|
|
27
|
+
/** Alto natural del contenido. */
|
|
28
|
+
contentHeight: number;
|
|
29
|
+
/** Escala mínima. @default 0.25 */
|
|
30
|
+
minScale?: number | undefined;
|
|
31
|
+
/** Escala máxima. @default 8 */
|
|
32
|
+
maxScale?: number | undefined;
|
|
33
|
+
/** Cuánto cambia la escala por paso de rueda o por botón. Los dos usan el mismo. @default 0.25 */
|
|
34
|
+
scaleStep?: number | undefined;
|
|
35
|
+
/** Estado controlado (escala y desplazamiento). */
|
|
36
|
+
state?: KapiViewportState | undefined;
|
|
37
|
+
/** Estado inicial. Sin él, el contenido arranca ajustado al marco. */
|
|
38
|
+
defaultState?: KapiViewportState | undefined;
|
|
39
|
+
/** Avisa cada cambio de escala o de posición. */
|
|
40
|
+
onStateChange?: ((state: KapiViewportState) => void) | undefined;
|
|
41
|
+
/** Oculta la barra de botones (acercar, alejar, ajustar, pantalla completa). */
|
|
42
|
+
hideControls?: boolean | undefined;
|
|
43
|
+
/** Saca el botón de pantalla completa sin sacar los demás. */
|
|
44
|
+
hideFullscreen?: boolean | undefined;
|
|
45
|
+
/** Textos fijos de los botones. */
|
|
46
|
+
labels?: KapiLabelsOverride<KapiViewportLabels> | undefined;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Marco con zoom y arrastre: rueda, doble clic, pellizco, arrastre, ajustar y pantalla completa.
|
|
50
|
+
*
|
|
51
|
+
* Toda la matemática vive en `viewportLogic.ts`, pura y testeada; acá sólo se escuchan eventos. Dos
|
|
52
|
+
* decisiones que no se ven en el código:
|
|
53
|
+
*
|
|
54
|
+
* - **La rueda usa el mismo motor de pasos que los botones** (`nextWheelZoom`), no un factor
|
|
55
|
+
* continuo propio: si no, un gesto de trackpad y tres clics en `+` dejarían escalas distintas y
|
|
56
|
+
* el `Ajustar` volvería a un lugar que no coincide con ninguna.
|
|
57
|
+
* - **Acercar deja quieto el punto bajo el cursor.** Sin eso el contenido crece desde el centro y
|
|
58
|
+
* lo que la persona estaba mirando se le va de la pantalla.
|
|
59
|
+
*
|
|
60
|
+
* El contenido más chico que el marco **no se arrastra**: queda centrado, para que una imagen chica
|
|
61
|
+
* no se pueda sacar de la vista.
|
|
62
|
+
*/
|
|
63
|
+
export declare const KapiViewport: ({ children, contentWidth, contentHeight, minScale, maxScale, scaleStep, state, defaultState, onStateChange, hideControls, hideFullscreen, labels, className, ref, ...rest }: KapiViewportProps) => import("react").JSX.Element;
|
|
@@ -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";
|
|
@@ -3,8 +3,8 @@ import { joinClasses as e } from "../rootProps.js";
|
|
|
3
3
|
import { renderSlot as t } from "../renderSlot.js";
|
|
4
4
|
import { resolveMenuItemTone as n } from "../tone.js";
|
|
5
5
|
import { useLabels as r } from "../locale/KapiLocaleProvider.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { activeElementOf as i } from "../../hooks/ownerDocument.js";
|
|
7
|
+
import { initialMenuFocus as a, isTypeaheadKey as o, menuKeyIntent as s, nextEnabledIndex as c } from "./menuKeyboardLogic.js";
|
|
8
8
|
import { logicalKeyOf as l } from "../../hooks/directionLogic.js";
|
|
9
9
|
import { usePlacement as u } from "../../hooks/usePlacement.js";
|
|
10
10
|
import { useTypeahead as d } from "../../hooks/useTypeahead.js";
|
|
@@ -20,38 +20,38 @@ var O = {
|
|
|
20
20
|
flip: "auto",
|
|
21
21
|
shift: !0
|
|
22
22
|
}, k = (t) => e("kapi-ctxmenu__item", n(t.tone, t.danger) === "danger" && "is-danger", t.disabled && "is-disabled", t.current && "is-current"), A = (e) => {
|
|
23
|
-
let t = b([]), n = b(null), r = b(void 0), [
|
|
23
|
+
let t = b([]), n = b(null), r = b(void 0), [a, o] = x(null);
|
|
24
24
|
v(() => () => clearTimeout(r.current), []);
|
|
25
|
-
let
|
|
25
|
+
let s = (e) => t.current[e]?.focus(), c = (e, t) => o((n) => ({
|
|
26
26
|
index: e,
|
|
27
27
|
focus: t ? (n?.focus ?? 0) + 1 : n?.index === e ? n.focus : 0
|
|
28
28
|
})), l = () => {
|
|
29
|
-
|
|
29
|
+
a !== null && (n.current?.contains(i(n.current)) && s(a.index), o(null));
|
|
30
30
|
}, u = (t) => {
|
|
31
31
|
let n = e[t];
|
|
32
32
|
return n !== void 0 && p(n) && !n.disabled && (n.items?.length ?? 0) > 0;
|
|
33
33
|
}, d = (e) => {
|
|
34
|
-
clearTimeout(r.current),
|
|
35
|
-
u(e) ?
|
|
34
|
+
clearTimeout(r.current), a?.index !== e && (r.current = setTimeout(() => {
|
|
35
|
+
u(e) ? c(e, !1) : l();
|
|
36
36
|
}, 200));
|
|
37
37
|
}, f = () => clearTimeout(r.current);
|
|
38
38
|
return {
|
|
39
39
|
itemEls: t,
|
|
40
|
-
focusItem:
|
|
41
|
-
sub:
|
|
42
|
-
openSub:
|
|
40
|
+
focusItem: s,
|
|
41
|
+
sub: a,
|
|
42
|
+
openSub: c,
|
|
43
43
|
closeSub: l,
|
|
44
44
|
hasSubmenu: u,
|
|
45
45
|
entryProps: (e) => ({
|
|
46
46
|
itemRef: (n) => {
|
|
47
47
|
t.current[e] = n;
|
|
48
48
|
},
|
|
49
|
-
subOpen:
|
|
50
|
-
subFocus:
|
|
49
|
+
subOpen: a?.index === e && u(e),
|
|
50
|
+
subFocus: a?.index === e ? a.focus : 0,
|
|
51
51
|
subRef: n,
|
|
52
|
-
onToggleSub: () =>
|
|
52
|
+
onToggleSub: () => a?.index === e ? l() : c(e, !0),
|
|
53
53
|
onBackFromSub: () => {
|
|
54
|
-
|
|
54
|
+
o(null), s(e);
|
|
55
55
|
},
|
|
56
56
|
onEnter: () => d(e),
|
|
57
57
|
onLeave: f
|
|
@@ -60,7 +60,7 @@ var O = {
|
|
|
60
60
|
}, j = ({ items: e, onActivate: t, onClose: n, focusRequest: u, onBack: p, onKeyDown: h, ref: y, id: b, className: x, style: S, "aria-label": w, "aria-labelledby": T }) => {
|
|
61
61
|
let E = r("link", _), D = d(500), O = A(e), { itemEls: k, focusItem: j, openSub: N, hasSubmenu: P } = O, F = f(e), I = p !== void 0;
|
|
62
62
|
return v(() => {
|
|
63
|
-
u > 0 && j(
|
|
63
|
+
u > 0 && j(a(F));
|
|
64
64
|
}, [u]), /* @__PURE__ */ C("div", {
|
|
65
65
|
ref: y,
|
|
66
66
|
id: b,
|
|
@@ -70,25 +70,25 @@ var O = {
|
|
|
70
70
|
"aria-label": w,
|
|
71
71
|
"aria-labelledby": T,
|
|
72
72
|
onKeyDown: (t) => {
|
|
73
|
-
let r =
|
|
73
|
+
let r = i(t.currentTarget), a = k.current.findIndex((e) => e !== null && e === r), u = () => {
|
|
74
74
|
t.preventDefault(), I && t.stopPropagation();
|
|
75
|
-
}, d =
|
|
75
|
+
}, d = s(t.key);
|
|
76
76
|
if (d.kind === "move") {
|
|
77
|
-
u(), j(
|
|
77
|
+
u(), j(c(a, d.dir, F));
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
let f = g(l(t), {
|
|
81
|
-
hasSubmenu:
|
|
81
|
+
hasSubmenu: a >= 0 && P(a),
|
|
82
82
|
nested: I
|
|
83
83
|
});
|
|
84
|
-
if (f === "open") u(), N(
|
|
84
|
+
if (f === "open") u(), N(a, !0);
|
|
85
85
|
else if (f === "back") u(), p?.();
|
|
86
86
|
else if (d.kind === "close") {
|
|
87
87
|
if (I) return;
|
|
88
88
|
if (d.returnFocus) return h?.(t);
|
|
89
89
|
n(!1);
|
|
90
|
-
} else if (
|
|
91
|
-
let n = m(e,
|
|
90
|
+
} else if (o(t.key) && !t.ctrlKey && !t.metaKey && !t.altKey) {
|
|
91
|
+
let n = m(e, a, D(t.key));
|
|
92
92
|
n >= 0 && (u(), j(n));
|
|
93
93
|
}
|
|
94
94
|
},
|
|
@@ -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 };
|