@kapiuara/ui 0.16.0 → 0.17.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 +171 -11
- 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/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/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/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 +5 -2
- package/dist/components/display/KapiTimeline.js +31 -23
- package/dist/components/display/annotationLogic.d.ts +2 -1
- package/dist/components/display/annotationLogic.js +7 -6
- 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 +8 -0
- 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/KapiFab.js +108 -108
- package/dist/components/feedback/KapiProgress.js +63 -54
- package/dist/components/feedback/KapiToastContainer.js +9 -9
- package/dist/components/feedback/KapiTour.js +12 -12
- 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.js +6 -6
- 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/index.d.ts +8 -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 +10 -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/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/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/KapiTooltip.js +18 -18
- package/dist/components/overlays/menuList.js +22 -22
- package/dist/components/slotCatalog.d.ts +33 -0
- package/dist/components/slotCatalog.js +18 -10
- package/dist/css/base.css +1 -1
- 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/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/KapiToc.css +1 -0
- package/dist/hooks/asyncResourceLogic.d.ts +11 -0
- package/dist/hooks/asyncResourceLogic.js +4 -0
- package/dist/hooks/index.d.ts +3 -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/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 +221 -207
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/dist/logic.d.ts +41 -0
- package/dist/logic.js +42 -0
- package/package.json +13 -2
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import { isFamilyTone as e } from "../tone.js";
|
|
1
2
|
//#region src/components/layout/accessCardLogic.ts
|
|
2
|
-
var
|
|
3
|
+
var t = (e) => e ? "external" : "chevron", n = (e) => {
|
|
3
4
|
let t = {};
|
|
4
5
|
return e.newTab && (t.target = "_blank"), (e.newTab || e.external) && (t.rel = "noopener noreferrer"), t;
|
|
5
|
-
},
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
}, r = (t = {}) => {
|
|
7
|
+
let n = t.tone ?? "primary";
|
|
8
|
+
return [
|
|
9
|
+
"kapi-accesscard",
|
|
10
|
+
`kapi-accesscard--${e(n) ? "family" : n}`,
|
|
11
|
+
t.className
|
|
12
|
+
].filter(Boolean).join(" ");
|
|
13
|
+
}, i = (e) => e === "Enter" || e === " ";
|
|
10
14
|
//#endregion
|
|
11
|
-
export {
|
|
15
|
+
export { t as accessCardAffordance, r as accessCardClasses, i as isActivationKey, n as linkAttrs };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { KapiShell } from "./KapiShell.js";
|
|
2
2
|
export type { KapiShellClassNames, KapiShellProps } from "./KapiShell.js";
|
|
3
|
+
export { KapiCollapse } from "./KapiCollapse.js";
|
|
4
|
+
export type { KapiCollapseProps } from "./KapiCollapse.js";
|
|
3
5
|
export { KapiRoot } from "./KapiRoot.js";
|
|
4
6
|
export type { KapiRootProps } from "./KapiRoot.js";
|
|
5
7
|
export { KapiThemeScript } from "./KapiThemeScript.js";
|
|
@@ -18,7 +18,12 @@ import type { KapiSearchChipLabels } from "../inputs/KapiSearchChip.js";
|
|
|
18
18
|
import type { KapiSelectLabels } from "../inputs/KapiSelect.js";
|
|
19
19
|
import type { KapiChecklistLabels } from "../inputs/KapiChecklist.js";
|
|
20
20
|
import type { KapiNumberStepperLabels } from "../inputs/KapiNumberStepper.js";
|
|
21
|
+
import type { KapiPinInputLabels } from "../inputs/KapiPinInput.js";
|
|
22
|
+
import type { KapiCodeBlockLabels } from "../display/KapiCodeBlock.js";
|
|
23
|
+
import type { KapiDiffLabels } from "../display/KapiDiff.js";
|
|
24
|
+
import type { KapiTocLabels } from "../navigation/KapiToc.js";
|
|
21
25
|
import type { KapiFileUploadLabels } from "../inputs/KapiFileUpload.js";
|
|
26
|
+
import type { KapiCopyButtonLabels } from "../inputs/KapiCopyButton.js";
|
|
22
27
|
import type { KapiInputLabels } from "../inputs/KapiInput.js";
|
|
23
28
|
import type { KapiTagInputLabels } from "../inputs/KapiTagInput.js";
|
|
24
29
|
import type { KapiContextSlotLabels } from "../layout/KapiContextSlot.js";
|
|
@@ -100,14 +105,18 @@ export interface KapiLabelRegistry {
|
|
|
100
105
|
fileViewer: KapiFileViewerLabels;
|
|
101
106
|
filterChips: KapiFilterChipsLabels;
|
|
102
107
|
heatmap: KapiHeatmapLabels;
|
|
108
|
+
copyButton: KapiCopyButtonLabels;
|
|
103
109
|
eventCalendar: KapiEventCalendarLabels;
|
|
104
110
|
input: KapiInputLabels;
|
|
111
|
+
codeBlock: KapiCodeBlockLabels;
|
|
112
|
+
diff: KapiDiffLabels;
|
|
105
113
|
link: KapiLinkLabels;
|
|
106
114
|
loading: KapiLoadingLabels;
|
|
107
115
|
messageBubble: KapiMessageBubbleLabels;
|
|
108
116
|
modal: KapiModalLabels;
|
|
109
117
|
notificationBell: KapiNotificationBellLabels;
|
|
110
118
|
numberStepper: KapiNumberStepperLabels;
|
|
119
|
+
pinInput: KapiPinInputLabels;
|
|
111
120
|
offcanvas: KapiOffcanvasLabels;
|
|
112
121
|
offlineBanner: KapiOfflineBannerLabels;
|
|
113
122
|
pagination: KapiPaginationLabels;
|
|
@@ -117,6 +126,7 @@ export interface KapiLabelRegistry {
|
|
|
117
126
|
scrollArea: KapiScrollAreaLabels;
|
|
118
127
|
searchChip: KapiSearchChipLabels;
|
|
119
128
|
select: KapiSelectLabels;
|
|
129
|
+
toc: KapiTocLabels;
|
|
120
130
|
shapeSheet: KapiShapeSheetLabels;
|
|
121
131
|
sparkline: KapiSparklineLabels;
|
|
122
132
|
splitModal: KapiSplitModalLabels;
|
|
@@ -1,8 +1,8 @@
|
|
|
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 { useControllableState as t } from "../../hooks/useControllableState.js";
|
|
5
|
+
import { enabledIndexes as n, navKeyOf as r, nextEnabledIndex as i } from "../overlays/menuKeyboardLogic.js";
|
|
6
6
|
/* empty css */
|
|
7
7
|
import { normalizeOpenIds as a, toggleOpenId as o } from "./accordionLogic.js";
|
|
8
8
|
import { useId as s } from "react";
|
|
@@ -11,17 +11,17 @@ import { ChevronDown as u } from "lucide-react";
|
|
|
11
11
|
//#region src/components/navigation/KapiAccordion.tsx
|
|
12
12
|
var d = ":scope > .kapi-accordion__item > .kapi-accordion__heading > .kapi-accordion__trigger:not(:disabled)", f = (e) => {
|
|
13
13
|
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
|
|
14
|
-
let
|
|
15
|
-
if (!
|
|
16
|
-
let a = Array.from(
|
|
17
|
-
!s || o < 0 || (e.preventDefault(), a[
|
|
14
|
+
let t = e.currentTarget.closest(".kapi-accordion");
|
|
15
|
+
if (!t) return;
|
|
16
|
+
let a = Array.from(t.querySelectorAll(d)), o = a.indexOf(e.currentTarget), s = r(e.key, "vertical");
|
|
17
|
+
!s || o < 0 || (e.preventDefault(), a[i(o, s, n(a.length))]?.focus());
|
|
18
18
|
};
|
|
19
|
-
function p({ items:
|
|
20
|
-
let g = s(), [_, v] = i
|
|
19
|
+
function p({ items: n, single: r = !0, openIds: i, defaultOpenIds: d = [], onOpenIdsChange: p, className: m, ...h }) {
|
|
20
|
+
let g = s(), [_, v] = t(i, () => a(d, r), p), y = a(_, r), b = (e) => v(o(y, e, r));
|
|
21
21
|
return /* @__PURE__ */ c("div", {
|
|
22
22
|
...h,
|
|
23
23
|
className: e("kapi-accordion", m),
|
|
24
|
-
children:
|
|
24
|
+
children: n.map((e) => {
|
|
25
25
|
let t = y.includes(e.id), n = `${g}-b-${e.id}`, r = `${g}-p-${e.id}`;
|
|
26
26
|
return /* @__PURE__ */ l("div", {
|
|
27
27
|
className: t ? "kapi-accordion__item kapi-accordion__item--open" : "kapi-accordion__item",
|
|
@@ -2,10 +2,10 @@
|
|
|
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 {
|
|
5
|
+
import { useMergedRefs as n } from "../../hooks/mergeRefs.js";
|
|
6
|
+
import { useLabels as r } from "../locale/KapiLocaleProvider.js";
|
|
7
|
+
import { useControllableState as i } from "../../hooks/useControllableState.js";
|
|
8
|
+
import { directionOf as a, physicalSide as o } from "../../hooks/directionLogic.js";
|
|
9
9
|
import { DEFAULT_LINK_LABELS as s } from "../locale/linkLabels.js";
|
|
10
10
|
import "./navBadgeLogic.js";
|
|
11
11
|
import { KapiNavBadge as c } from "./KapiNavBadge.js";
|
|
@@ -129,8 +129,8 @@ var O = ({ item: e, active: n, onSelect: r, newTabLabel: i }) => {
|
|
|
129
129
|
e.trailing
|
|
130
130
|
]
|
|
131
131
|
});
|
|
132
|
-
}, k = ({ sections: e, activeId: t, onSelect:
|
|
133
|
-
let c =
|
|
132
|
+
}, k = ({ sections: e, activeId: t, onSelect: n, search: i, hint: a, labels: o }) => {
|
|
133
|
+
let c = r("link", s, o);
|
|
134
134
|
return /* @__PURE__ */ w(S, { children: [
|
|
135
135
|
i && /* @__PURE__ */ C(p, {
|
|
136
136
|
placeholder: i.placeholder,
|
|
@@ -138,10 +138,10 @@ var O = ({ item: e, active: n, onSelect: r, newTabLabel: i }) => {
|
|
|
138
138
|
...i["aria-label"] === void 0 ? {} : { "aria-label": i["aria-label"] },
|
|
139
139
|
onChange: (e) => i.onChange?.(e.target.value)
|
|
140
140
|
}),
|
|
141
|
-
e.map((e,
|
|
141
|
+
e.map((e, r) => /* @__PURE__ */ w("div", {
|
|
142
142
|
className: "kapi-ctxsection",
|
|
143
143
|
children: [
|
|
144
|
-
|
|
144
|
+
r > 0 && /* @__PURE__ */ C("div", { className: "kapi-ctxdivider" }),
|
|
145
145
|
e.label && /* @__PURE__ */ C("div", {
|
|
146
146
|
className: "kapi-ct",
|
|
147
147
|
children: e.label
|
|
@@ -151,7 +151,7 @@ var O = ({ item: e, active: n, onSelect: r, newTabLabel: i }) => {
|
|
|
151
151
|
children: e.items.map((e) => /* @__PURE__ */ C(O, {
|
|
152
152
|
item: e,
|
|
153
153
|
active: e.id === t,
|
|
154
|
-
onSelect:
|
|
154
|
+
onSelect: n,
|
|
155
155
|
newTabLabel: c.newTab
|
|
156
156
|
}, e.id))
|
|
157
157
|
})
|
|
@@ -168,7 +168,7 @@ var O = ({ item: e, active: n, onSelect: r, newTabLabel: i }) => {
|
|
|
168
168
|
expand: "Desplegar panel",
|
|
169
169
|
region: "Panel contextual"
|
|
170
170
|
}, j = ({ title: t, actions: s, collapsed: c, defaultCollapsed: l, onCollapsedChange: u, collapseLabel: d, expandLabel: f, side: p = "left", collapsedMode: v = "hidden", resizable: S = !1, minWidth: D = 200, maxWidth: O = 420, "aria-label": j, labels: M, className: N, style: P, id: F, ref: I, ...L }) => {
|
|
171
|
-
let R =
|
|
171
|
+
let R = r("contextPanel", A, M), re = d ?? R.collapse, ie = f ?? R.expand, z = j ?? R.region, [B, ae] = i(c, l ?? !1, u), [V, H] = x(null), [oe, U] = x(!1), W = b(null), G = b(null), K = n(G, I), q = b(null), [J, Y] = x(null);
|
|
172
172
|
y(() => {
|
|
173
173
|
J && (B === J.next && q.current?.focus(), Y(null));
|
|
174
174
|
}, [J, B]);
|
|
@@ -189,11 +189,11 @@ var O = ({ item: e, active: n, onSelect: r, newTabLabel: i }) => {
|
|
|
189
189
|
}, e.currentTarget.setPointerCapture(e.pointerId), U(!0), e.preventDefault());
|
|
190
190
|
}, de = (e) => {
|
|
191
191
|
let t = W.current;
|
|
192
|
-
t && H(g(
|
|
192
|
+
t && H(g(o(p, a(e.currentTarget)), t.startWidth, t.startX, e.clientX, D, O));
|
|
193
193
|
}, $ = (e) => {
|
|
194
194
|
W.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), U(!1);
|
|
195
195
|
}, fe = (e) => {
|
|
196
|
-
let t = _(
|
|
196
|
+
let t = _(o(p, a(e.currentTarget)), Q(), e.key, D, O);
|
|
197
197
|
t !== null && (e.preventDefault(), H(t));
|
|
198
198
|
};
|
|
199
199
|
if (B) {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { CSSProperties, Ref } from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { KapiToneName } from "../tone.js";
|
|
3
3
|
import { type KapiNavBadgeValue } from "./navBadgeLogic.js";
|
|
4
4
|
export type KapiNavBadgeProps = {
|
|
5
5
|
/** Contador o `"dot"` (aviso sin número). Sin valor o 0 no dibuja nada. */
|
|
6
6
|
value?: KapiNavBadgeValue | undefined;
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Color por rol, igual que `KapiBadge` (`danger` para vencidos, `warning` para por vencer…), o
|
|
9
|
+
* una familia propia de la app (`toneFamilies`). @default "primary"
|
|
10
|
+
*/
|
|
11
|
+
tone?: KapiToneName | undefined;
|
|
9
12
|
/** Texto accesible (p. ej. "3 trámites vencidos"); sin él se lee el número. */
|
|
10
13
|
label?: string | undefined;
|
|
11
14
|
/** `inline`: al final de un ítem de lista. `corner`: burbuja sobre la esquina del ícono (rail). @default "inline" */
|
|
@@ -1,36 +1,40 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "#kapi-css/components/navigation/KapiNavBadge.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { useToneLook as e } from "../../hooks/useToneFamilies.js";
|
|
4
|
+
import { joinClasses as t } from "../rootProps.js";
|
|
5
|
+
import { badgeClasses as n } from "../display/KapiBadge.js";
|
|
6
|
+
import { navBadgeA11yText as r, navBadgeView as i } from "./navBadgeLogic.js";
|
|
6
7
|
/* empty css */
|
|
7
|
-
import { Fragment as
|
|
8
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
9
|
//#region src/components/navigation/KapiNavBadge.tsx
|
|
9
|
-
var
|
|
10
|
-
let
|
|
11
|
-
max:
|
|
12
|
-
showZero:
|
|
10
|
+
var c = ({ value: c, tone: l = "primary", label: u, placement: d = "inline", max: f, showZero: p, announce: m = !0, className: h, style: g, ref: _ }) => {
|
|
11
|
+
let v = e("KapiNavBadge", l), y = i(c, {
|
|
12
|
+
max: f,
|
|
13
|
+
showZero: p
|
|
13
14
|
});
|
|
14
|
-
if (
|
|
15
|
-
let
|
|
16
|
-
return /* @__PURE__ */
|
|
17
|
-
ref:
|
|
18
|
-
style:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
if (y === null) return null;
|
|
16
|
+
let b = m ? r(c, u, { showZero: p }) : null, x = y.kind === "dot";
|
|
17
|
+
return /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o("span", {
|
|
18
|
+
ref: _,
|
|
19
|
+
style: v.style ? {
|
|
20
|
+
...v.style,
|
|
21
|
+
...g
|
|
22
|
+
} : g,
|
|
23
|
+
className: t(n({
|
|
24
|
+
tone: v.tone,
|
|
25
|
+
variant: d === "corner" || x ? "solid" : "subtle",
|
|
22
26
|
size: "sm"
|
|
23
|
-
}), "kapi-navbadge", `kapi-navbadge--${
|
|
27
|
+
}), "kapi-navbadge", `kapi-navbadge--${d}`, x && "kapi-navbadge--dot", h),
|
|
24
28
|
"aria-hidden": "true",
|
|
25
|
-
children:
|
|
26
|
-
}),
|
|
29
|
+
children: x ? null : y.text
|
|
30
|
+
}), b !== null && /* @__PURE__ */ s(a, { children: [
|
|
27
31
|
" ",
|
|
28
|
-
/* @__PURE__ */
|
|
32
|
+
/* @__PURE__ */ o("span", {
|
|
29
33
|
className: "kapi-navbadge__sr",
|
|
30
|
-
children:
|
|
34
|
+
children: b
|
|
31
35
|
}),
|
|
32
36
|
" "
|
|
33
37
|
] })] });
|
|
34
38
|
};
|
|
35
39
|
//#endregion
|
|
36
|
-
export {
|
|
40
|
+
export { c as KapiNavBadge };
|
|
@@ -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
|
}
|