@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
|
@@ -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 };
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import "#kapi-css/components/navigation/navigation.css";
|
|
3
3
|
import { joinClasses as e } from "../rootProps.js";
|
|
4
4
|
import { renderSlot as t } from "../renderSlot.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
5
|
+
import { useMergedRefs as n } from "../../hooks/mergeRefs.js";
|
|
6
|
+
import { useKapiFormatLocale as r } from "../locale/KapiLocaleProvider.js";
|
|
7
|
+
import { useControllableState as i } from "../../hooks/useControllableState.js";
|
|
8
|
+
import { logicalKeyOf as a } from "../../hooks/directionLogic.js";
|
|
9
|
+
import { useDuplicateValueWarning as o, useMutedControlWarning as s } from "../inputs/misuseWarnings.js";
|
|
10
10
|
import { useSlidingIndicator as c } from "../../hooks/useSlidingIndicator.js";
|
|
11
11
|
import { formatCount as l } from "../../hooks/numberFormatLogic.js";
|
|
12
12
|
import { useScrollEdges as u } from "../../hooks/useScrollEdges.js";
|
|
@@ -17,8 +17,8 @@ import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
|
17
17
|
//#region src/components/navigation/KapiTabs.tsx
|
|
18
18
|
var w = [];
|
|
19
19
|
function T({ items: T, tabs: E, value: D, defaultValue: O, onChange: k, className: A, idBase: j, disabled: M = !1, size: N = "md", onKeyDown: P, ref: F, ...I }) {
|
|
20
|
-
let L =
|
|
21
|
-
|
|
20
|
+
let L = r(), R = T ?? E ?? w, z = _(), B = j ?? z, V = b({}), [H, U] = i(D, () => O ?? R[0]?.id, k), W = y(() => R.map((e) => e.id), [R]);
|
|
21
|
+
o("KapiTabs", W), s("KapiTabs", {
|
|
22
22
|
controlled: D !== void 0,
|
|
23
23
|
hasOnChange: !!k,
|
|
24
24
|
disabled: M
|
|
@@ -29,7 +29,7 @@ function T({ items: T, tabs: E, value: D, defaultValue: O, onChange: k, classNam
|
|
|
29
29
|
findActive: (e) => e.querySelector("[role=\"tab\"][aria-selected=\"true\"]")
|
|
30
30
|
}), { ref: q, edges: J, reveal: Y } = u({ axis: "x" }), X = g((e) => {
|
|
31
31
|
G.current = e, q.current = e;
|
|
32
|
-
}, [G, q]), Z =
|
|
32
|
+
}, [G, q]), Z = n(X, F), Q = b(!1);
|
|
33
33
|
v(() => {
|
|
34
34
|
let e = G.current?.querySelector("[role=\"tab\"][aria-selected=\"true\"]");
|
|
35
35
|
e && Y(e, { instant: !Q.current }), Q.current = !0;
|
|
@@ -40,7 +40,7 @@ function T({ items: T, tabs: E, value: D, defaultValue: O, onChange: k, classNam
|
|
|
40
40
|
]);
|
|
41
41
|
let $ = (e) => M || R.some((t) => t.id === e && t.disabled === !0), ee = H !== void 0 && R.some((e) => e.id === H) && !$(H) ? H : R.find((e) => !$(e.id))?.id, te = (e) => {
|
|
42
42
|
if (P?.(e), e.defaultPrevented || H === void 0) return;
|
|
43
|
-
let t = d(R.map((e) => e.id), H,
|
|
43
|
+
let t = d(R.map((e) => e.id), H, a(e), $);
|
|
44
44
|
t !== void 0 && (e.preventDefault(), U(t), V.current[t]?.focus());
|
|
45
45
|
};
|
|
46
46
|
return /* @__PURE__ */ C("div", {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { HTMLAttributes, Ref } from "react";
|
|
2
|
+
import type { KapiLabelsOverride } from "../labelsLogic.js";
|
|
3
|
+
import type { KapiClassNames } from "../slotCatalog.js";
|
|
4
|
+
import { type KapiTocItem } from "./tocLogic.js";
|
|
5
|
+
export type { KapiTocItem, KapiTocPosition } from "./tocLogic.js";
|
|
6
|
+
/** Textos de `KapiToc`; se pisan con `labels` o el `KapiLocaleProvider`. */
|
|
7
|
+
export type KapiTocLabels = {
|
|
8
|
+
/** Nombre accesible de la navegación. */
|
|
9
|
+
region: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const DEFAULT_TOC_LABELS: KapiTocLabels;
|
|
12
|
+
/** Atributos nativos (`id`, `style`, `data-*`…) van al `<nav>` raíz. */
|
|
13
|
+
export type KapiTocProps = Omit<HTMLAttributes<HTMLElement>, "children" | "onChange"> & {
|
|
14
|
+
/** Ref al `<nav>` raíz. */
|
|
15
|
+
ref?: Ref<HTMLElement> | undefined;
|
|
16
|
+
/** Los títulos, en el orden en que aparecen en la página. */
|
|
17
|
+
items: readonly KapiTocItem[];
|
|
18
|
+
/** Id del título activo. Con esto manda la app (el router, normalmente) y el scroll no decide. */
|
|
19
|
+
activeId?: string | null | undefined;
|
|
20
|
+
/** Avisa cuándo cambia el título activo, lo decida el scroll o un clic. */
|
|
21
|
+
onActiveIdChange?: ((id: string) => void) | undefined;
|
|
22
|
+
/** Alto del header pegajoso, en px: el título se activa ese tanto antes. @default 0 */
|
|
23
|
+
offset?: number | undefined;
|
|
24
|
+
/** Nivel máximo de encabezado que entra (2 = sólo `<h2>`). @default 3 */
|
|
25
|
+
maxLevel?: number | undefined;
|
|
26
|
+
/** Título visible sobre la lista. Sin esto, el nombre va sólo al lector de pantalla. */
|
|
27
|
+
heading?: string | undefined;
|
|
28
|
+
/** Textos propios; pisan los del `KapiLocaleProvider` y los defaults. */
|
|
29
|
+
labels?: KapiLabelsOverride<KapiTocLabels> | undefined;
|
|
30
|
+
/** Clases por parte (`root`, `heading`, `list`, `item`, `link`). Se suman a las propias. */
|
|
31
|
+
classNames?: KapiClassNames<"toc"> | undefined;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Índice de la página con seguimiento del scroll (scrollspy).
|
|
35
|
+
*
|
|
36
|
+
* **Un solo juego de listeners, no un observer por título.** Se mide con `onViewportChange`, que
|
|
37
|
+
* agrupa a todos los suscriptores de la ventana en un recálculo por frame; con un
|
|
38
|
+
* `IntersectionObserver` por ítem, una página de cuarenta títulos crea cuarenta observers, y aun
|
|
39
|
+
* así hay que resolver a mano cuál gana cuando dos entran en el mismo frame.
|
|
40
|
+
*
|
|
41
|
+
* **La decisión de cuál está activo es pura** (`activeTocId`) y ahí viven los tres bordes que se
|
|
42
|
+
* sienten rotos cuando faltan: arriba de todo gana el primero, al fondo gana el último aunque no
|
|
43
|
+
* haya llegado al tope, y un scroll exacto sobre un título lo marca a él.
|
|
44
|
+
*
|
|
45
|
+
* Pasando `activeId` el componente queda controlado y el scroll deja de decidir: es lo que hace
|
|
46
|
+
* falta cuando el id activo lo manda el router.
|
|
47
|
+
*/
|
|
48
|
+
export declare function KapiToc({ items, activeId, onActiveIdChange, offset, maxLevel, heading, labels, classNames, className, ref, ...rest }: KapiTocProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "#kapi-css/components/navigation/KapiToc.css";
|
|
3
|
+
import { useMergedRefs as e } from "../../hooks/mergeRefs.js";
|
|
4
|
+
import { useLabels as t } from "../locale/KapiLocaleProvider.js";
|
|
5
|
+
import { docOf as n, winOf as r } from "../../hooks/ownerDocument.js";
|
|
6
|
+
import { useControllableState as i } from "../../hooks/useControllableState.js";
|
|
7
|
+
import { onViewportChange as a } from "../../hooks/rafThrottle.js";
|
|
8
|
+
import { slot as o } from "../slotsLogic.js";
|
|
9
|
+
import { TOC_SLOTS as s } from "./tocSlots.js";
|
|
10
|
+
import { activeTocId as c, isAtBottom as l, visibleTocItems as u } from "./tocLogic.js";
|
|
11
|
+
/* empty css */
|
|
12
|
+
import { useCallback as d, useEffect as f, useRef as p, useState as m } from "react";
|
|
13
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
14
|
+
//#region src/components/navigation/KapiToc.tsx
|
|
15
|
+
var _ = { region: "En esta página" };
|
|
16
|
+
function v({ items: v, activeId: y, onActiveIdChange: b, offset: x = 0, maxLevel: S = 3, heading: C, labels: w, classNames: T, className: E, ref: D, ...O }) {
|
|
17
|
+
let k = t("toc", _, w), A = u(v, S), j = p(null), M = e(D, j), [N, P] = m(null), [F, I] = i(y, null, b), L = y === void 0 ? N ?? A[0]?.id ?? null : F, R = A.map((e) => e.id).join("\0"), z = d(() => {
|
|
18
|
+
let e = n(j.current), t = r(j.current);
|
|
19
|
+
if (!e || !t) return;
|
|
20
|
+
let i = R.split("\0").filter(Boolean).map((n) => {
|
|
21
|
+
let r = e.getElementById(n);
|
|
22
|
+
return r ? {
|
|
23
|
+
id: n,
|
|
24
|
+
top: r.getBoundingClientRect().top + t.scrollY
|
|
25
|
+
} : null;
|
|
26
|
+
}).filter((e) => e !== null), a = l(t.scrollY, t.innerHeight, e.documentElement.scrollHeight);
|
|
27
|
+
P(c(i, t.scrollY, x, a));
|
|
28
|
+
}, [R, x]);
|
|
29
|
+
f(() => (z(), a(z, { target: r(j.current) ?? void 0 })), [z]);
|
|
30
|
+
let B = p(null);
|
|
31
|
+
f(() => {
|
|
32
|
+
y === void 0 && L !== null && B.current !== L && (B.current = L, b?.(L));
|
|
33
|
+
}, [
|
|
34
|
+
L,
|
|
35
|
+
y,
|
|
36
|
+
b
|
|
37
|
+
]);
|
|
38
|
+
let V = (e, t) => {
|
|
39
|
+
e.defaultPrevented || (y === void 0 ? P(t) : I(t));
|
|
40
|
+
};
|
|
41
|
+
return A.length === 0 ? null : /* @__PURE__ */ g("nav", {
|
|
42
|
+
...O,
|
|
43
|
+
ref: M,
|
|
44
|
+
...o(s, "root", T, E),
|
|
45
|
+
"aria-label": C ?? k.region,
|
|
46
|
+
children: [C !== void 0 && /* @__PURE__ */ h("p", {
|
|
47
|
+
...o(s, "heading", T),
|
|
48
|
+
children: C
|
|
49
|
+
}), /* @__PURE__ */ h("ol", {
|
|
50
|
+
...o(s, "list", T),
|
|
51
|
+
children: A.map((e) => /* @__PURE__ */ h("li", {
|
|
52
|
+
...o(s, "item", T),
|
|
53
|
+
"data-level": e.level ?? 2,
|
|
54
|
+
children: /* @__PURE__ */ h("a", {
|
|
55
|
+
href: `#${e.id}`,
|
|
56
|
+
...o(s, "link", T, L === e.id && "is-on"),
|
|
57
|
+
"aria-current": L === e.id ? "location" : void 0,
|
|
58
|
+
onClick: (t) => V(t, e.id),
|
|
59
|
+
children: e.label
|
|
60
|
+
})
|
|
61
|
+
}, e.id))
|
|
62
|
+
})]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { _ as DEFAULT_TOC_LABELS, v as KapiToc };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/navigation/navigation.css";
|
|
3
3
|
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { useMergedRefs as t } from "../../hooks/mergeRefs.js";
|
|
5
|
+
import { useLabels as n } from "../locale/KapiLocaleProvider.js";
|
|
6
6
|
import { useControllableState as r } from "../../hooks/useControllableState.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { isTypeaheadKey as i } from "../overlays/menuKeyboardLogic.js";
|
|
8
|
+
import { logicalKeyOf as a } from "../../hooks/directionLogic.js";
|
|
9
9
|
import { useTypeahead as o } from "../../hooks/useTypeahead.js";
|
|
10
10
|
import { useVirtualList as s } from "../../hooks/useVirtualList.js";
|
|
11
11
|
/* empty css */
|
|
@@ -16,7 +16,7 @@ import { ChevronRight as _ } from "lucide-react";
|
|
|
16
16
|
//#region src/components/navigation/KapiTree.tsx
|
|
17
17
|
var v = { loading: "Cargando…" }, se = 37, y = 400;
|
|
18
18
|
function b({ nodes: b, expandedIds: ce, defaultExpandedIds: le, onExpandedIdsChange: x, expanded: S, defaultExpanded: C, onExpandedChange: ue, onExpand: de, selectedIds: fe, defaultSelectedIds: pe, onSelectedIdsChange: me, selected: he, defaultSelected: ge, onSelectedChange: _e, multiple: w = !1, renderLabel: T, labels: ve, virtual: E = !1, maxHeight: D = y, className: O, style: k, ref: A, onKeyDown: j, onFocus: M, ...N }) {
|
|
19
|
-
let P =
|
|
19
|
+
let P = n("tree", v, ve), F = ie(), [I, ye] = r(ce ?? S, () => le ?? C ?? [], x ?? ue), [L, be] = r(fe ?? he, () => pe ?? ge ?? []), xe = me ?? _e, [Se, R] = oe(null), z = p(/* @__PURE__ */ new Map()), Ce = o(500), B = f(() => l(b, I), [b, I]), V = ne(b, B, Se, L), H = f(() => new Map(B.map((e, t) => [e.node.id, {
|
|
20
20
|
...e,
|
|
21
21
|
node: e.node,
|
|
22
22
|
index: t
|
|
@@ -32,7 +32,7 @@ function b({ nodes: b, expandedIds: ce, defaultExpandedIds: le, onExpandedIdsCha
|
|
|
32
32
|
if (e.disabled) return;
|
|
33
33
|
let t = re(L, e.id, w);
|
|
34
34
|
be(t), xe?.(t, e);
|
|
35
|
-
}, J = p(null), Te =
|
|
35
|
+
}, J = p(null), Te = t(A, J), Ee = f(() => E ? B.map((e) => e.node.id) : void 0, [E, B]), Y = s({
|
|
36
36
|
enabled: E,
|
|
37
37
|
count: B.length,
|
|
38
38
|
scrollRef: J,
|
|
@@ -57,12 +57,12 @@ function b({ nodes: b, expandedIds: ce, defaultExpandedIds: le, onExpandedIdsCha
|
|
|
57
57
|
if (j?.(e), e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
58
58
|
let t = V;
|
|
59
59
|
if (t === null) return;
|
|
60
|
-
let
|
|
61
|
-
if (!
|
|
60
|
+
let n = e.target.getAttribute("role") === "treeitem", r = e.key === "Enter" || e.key === " ";
|
|
61
|
+
if (!n && (r || i(e.key))) return;
|
|
62
62
|
if (c.has(e.key)) {
|
|
63
63
|
e.preventDefault();
|
|
64
64
|
let n = d({
|
|
65
|
-
key:
|
|
65
|
+
key: a(e),
|
|
66
66
|
nodes: b,
|
|
67
67
|
visible: B,
|
|
68
68
|
focusId: t,
|
|
@@ -96,7 +96,7 @@ function b({ nodes: b, expandedIds: ce, defaultExpandedIds: le, onExpandedIdsCha
|
|
|
96
96
|
}
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
|
-
if (!
|
|
99
|
+
if (!i(e.key)) return;
|
|
100
100
|
let o = H.get(t)?.index;
|
|
101
101
|
if (o === void 0) return;
|
|
102
102
|
let s = ee(B, o, Ce(e.key));
|
|
@@ -73,3 +73,6 @@ canCollapse,
|
|
|
73
73
|
/** @deprecated Interno; usa `KapiContextPanel` en su lugar. Se quita en 1.0. */
|
|
74
74
|
ctxPanelClasses, resolveCollapsed } from "./contextPanelLogic.js";
|
|
75
75
|
export type { KapiContextPanelSide } from "./contextPanelLogic.js";
|
|
76
|
+
export { KapiToc, DEFAULT_TOC_LABELS } from "./KapiToc.js";
|
|
77
|
+
export type { KapiTocItem, KapiTocLabels, KapiTocPosition, KapiTocProps } from "./KapiToc.js";
|
|
78
|
+
export { activeTocId, isAtBottom, visibleTocItems } from "./tocLogic.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Un título del contenido, con su nivel de encabezado. */
|
|
2
|
+
export type KapiTocItem = {
|
|
3
|
+
/** El `id` del elemento en la página. Es a lo que apunta el enlace. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Lo que se lee en el índice. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Nivel del encabezado: 2 para `<h2>`, 3 para `<h3>`… @default 2 */
|
|
8
|
+
level?: number | undefined;
|
|
9
|
+
};
|
|
10
|
+
/** Dónde está un título, medido desde el tope del documento. */
|
|
11
|
+
export type KapiTocPosition = {
|
|
12
|
+
/** El `id` del título. */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Su distancia al tope del documento, en píxeles. */
|
|
15
|
+
top: number;
|
|
16
|
+
};
|
|
17
|
+
/** Los títulos que entran en el índice: los de nivel `maxLevel` o menos. */
|
|
18
|
+
export declare const visibleTocItems: (items: readonly KapiTocItem[], maxLevel: number) => KapiTocItem[];
|
|
19
|
+
/**
|
|
20
|
+
* Cuál título está activo para un scroll dado.
|
|
21
|
+
*
|
|
22
|
+
* La regla es "el último que ya pasó el tope", con `offset` descontado para que un header pegajoso
|
|
23
|
+
* no tape el título que acaba de activarse. Tres bordes que hay que decidir y conviene tener acá y
|
|
24
|
+
* no repartidos en un efecto:
|
|
25
|
+
*
|
|
26
|
+
* - **Arriba de todo**: ninguno pasó todavía, pero el índice sin nada marcado se ve roto, así que
|
|
27
|
+
* gana el primero.
|
|
28
|
+
* - **Abajo de todo**: los últimos títulos de una página pueden no llegar nunca al tope si el
|
|
29
|
+
* documento se termina antes, y entonces el índice se queda clavado en el penúltimo mientras la
|
|
30
|
+
* persona mira el último. Con `atBottom`, gana el último.
|
|
31
|
+
* - **Sin títulos**: `null`, y el componente no dibuja nada.
|
|
32
|
+
*/
|
|
33
|
+
export declare const activeTocId: (positions: readonly KapiTocPosition[], scrollTop: number, offset?: number, atBottom?: boolean) => string | null;
|
|
34
|
+
/** `true` si ya no queda nada para scrollear (con un margen, que el scroll suele caer decimal). */
|
|
35
|
+
export declare const isAtBottom: (scrollTop: number, viewport: number, total: number, margen?: number) => boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/components/navigation/tocLogic.ts
|
|
2
|
+
var e = (e, t) => e.filter((e) => (e.level ?? 2) <= t), t = (e, t, n = 0, r = !1) => {
|
|
3
|
+
if (e.length === 0) return null;
|
|
4
|
+
if (r) return e[e.length - 1]?.id ?? null;
|
|
5
|
+
let i = t + n, a = e[0]?.id ?? null;
|
|
6
|
+
for (let t of e) if (t.top <= i) a = t.id;
|
|
7
|
+
else break;
|
|
8
|
+
return a;
|
|
9
|
+
}, n = (e, t, n, r = 2) => e + t >= n - r;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as activeTocId, n as isAtBottom, e as visibleTocItems };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Partes de `toc` (ver `slotCatalog.ts` para el contrato). Vive junto al componente. */
|
|
2
|
+
export declare const TOC_SLOTS: import("../slotsLogic.js").SlotTable<"toc", {
|
|
3
|
+
readonly root: null;
|
|
4
|
+
readonly heading: "kapi-toc__heading";
|
|
5
|
+
readonly list: "kapi-toc__list";
|
|
6
|
+
readonly item: "kapi-toc__item";
|
|
7
|
+
readonly link: "kapi-toc__link";
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineSlots as e } from "../slotsLogic.js";
|
|
2
|
+
//#region src/components/navigation/tocSlots.ts
|
|
3
|
+
var t = e("toc", {
|
|
4
|
+
root: null,
|
|
5
|
+
heading: "kapi-toc__heading",
|
|
6
|
+
list: "kapi-toc__list",
|
|
7
|
+
item: "kapi-toc__item",
|
|
8
|
+
link: "kapi-toc__link"
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as TOC_SLOTS };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/overlays/KapiCommandPalette.css";
|
|
3
3
|
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { useMergedRefs as t } from "../../hooks/mergeRefs.js";
|
|
5
|
+
import { useLabels as n } from "../locale/KapiLocaleProvider.js";
|
|
6
|
+
import { enabledIndexes as r, nextEnabledIndex as i } from "./menuKeyboardLogic.js";
|
|
7
7
|
import { useBackdropClose as a, useNativeDialog as o, usePortalRoot as s } from "./useNativeDialog.js";
|
|
8
8
|
import { clampActiveIndex as c, filterGroups as ee, flattenNavigable as l, nodeText as u } from "./commandPaletteLogic.js";
|
|
9
9
|
/* empty css */
|
|
@@ -17,7 +17,7 @@ var b = "↑↓ para moverte · Enter para ir · Esc para cerrar", x = {
|
|
|
17
17
|
empty: "Sin resultados",
|
|
18
18
|
footerHint: b
|
|
19
19
|
}, S = ({ onClose: b, groups: S, placeholder: C, emptyMessage: w, emptyLabel: T, footerHint: E, labels: D, className: O, style: k, id: A, ref: j }) => {
|
|
20
|
-
let M =
|
|
20
|
+
let M = n("commandPalette", x, D), N = C ?? M.placeholder, P = w ?? T ?? M.empty, F = E === void 0 ? M.footerHint : E, I = f(), L = `${I}-listbox`, R = (e) => `${I}-opt-${e}`, z = m(null), [B, V] = h(""), [H, U] = h(0), { ref: W, dialogProps: G } = o({ onRequestClose: () => b("escape") }), K = t(W, j), q = a(() => b("backdrop")), J = p(() => {
|
|
21
21
|
let e = S.map((e) => ({
|
|
22
22
|
...e,
|
|
23
23
|
commands: e.commands.map((e) => ({
|
|
@@ -38,11 +38,11 @@ var b = "↑↓ para moverte · Enter para ir · Esc para cerrar", x = {
|
|
|
38
38
|
switch (e.key) {
|
|
39
39
|
case "ArrowDown":
|
|
40
40
|
case "ArrowUp":
|
|
41
|
-
e.preventDefault(), U(
|
|
41
|
+
e.preventDefault(), U(i(X, e.key === "ArrowDown" ? "next" : "prev", r(Y.length)));
|
|
42
42
|
break;
|
|
43
43
|
case "Home":
|
|
44
44
|
case "End":
|
|
45
|
-
Y.length > 0 && (e.preventDefault(), U(
|
|
45
|
+
Y.length > 0 && (e.preventDefault(), U(i(X, e.key === "Home" ? "first" : "last", r(Y.length))));
|
|
46
46
|
break;
|
|
47
47
|
case "Enter": Z && !e.nativeEvent.isComposing && (e.preventDefault(), Q(Z));
|
|
48
48
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/overlays/overlays.css";
|
|
3
3
|
import { joinClasses as e } from "../rootProps.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { useMergedRefs as t } from "../../hooks/mergeRefs.js";
|
|
5
|
+
import { useLabels as n } from "../locale/KapiLocaleProvider.js";
|
|
6
|
+
import { usePlacement as r } from "../../hooks/usePlacement.js";
|
|
7
7
|
import { useDismiss as i } from "../../hooks/useDismiss.js";
|
|
8
8
|
/* empty css */
|
|
9
9
|
import { POINT_MENU_PLACEMENT as a } from "../../hooks/rightClick.js";
|
|
@@ -14,7 +14,7 @@ import { useLayoutEffect as l, useRef as u } from "react";
|
|
|
14
14
|
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
15
15
|
//#region src/components/overlays/KapiContextMenu.tsx
|
|
16
16
|
var m = { menu: "Menú contextual" }, h = 210, g = ({ open: e, ...t }) => e ? /* @__PURE__ */ f(_, { ...t }) : null, _ = ({ x: g, y: _, items: v, onClose: y, className: b, style: x, id: S, ref: C, labels: w, "aria-label": T }) => {
|
|
17
|
-
let E =
|
|
17
|
+
let E = n("contextMenu", m, w), D = u(null), O = t(D, C);
|
|
18
18
|
c(!0, {
|
|
19
19
|
container: D,
|
|
20
20
|
restoreOnDeactivate: "if-lost"
|
|
@@ -23,7 +23,7 @@ var m = { menu: "Menú contextual" }, h = 210, g = ({ open: e, ...t }) => e ? /*
|
|
|
23
23
|
zones: [D],
|
|
24
24
|
outside: !1,
|
|
25
25
|
onDismiss: (e) => y(e)
|
|
26
|
-
}), { placement: A, update: j } =
|
|
26
|
+
}), { placement: A, update: j } = r({
|
|
27
27
|
open: !0,
|
|
28
28
|
anchor: () => ({
|
|
29
29
|
x: g,
|
|
@@ -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;
|