@kapiuara/ui 0.15.3 → 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/LICENSE +19 -15
- package/README.md +505 -13
- package/dist/components/chat/KapiChatThread.js +4 -4
- package/dist/components/chat/KapiComposer.js +8 -8
- package/dist/components/data/KapiDataTable.d.ts +1 -1
- package/dist/components/data/KapiDataTable.js +25 -25
- package/dist/components/data/KapiPaginationFooter.js +1 -1
- package/dist/components/data/KapiSheet.d.ts +105 -0
- package/dist/components/data/KapiSheet.js +75 -0
- package/dist/components/data/KapiSparkline.d.ts +2 -1
- package/dist/components/data/KapiSparkline.js +29 -26
- package/dist/components/data/KapiTable.d.ts +2 -2
- package/dist/components/data/KapiTable.js +347 -329
- package/dist/components/data/KapiTableFilter.js +6 -6
- package/dist/components/data/KapiTableFooter.d.ts +22 -0
- package/dist/components/data/KapiTableFooter.js +55 -0
- package/dist/components/data/KapiTableRow.js +53 -52
- package/dist/components/data/KapiTableToolbar.d.ts +4 -2
- package/dist/components/data/KapiTableToolbar.js +71 -69
- package/dist/components/data/index.d.ts +3 -1
- package/dist/components/data/tableCells.d.ts +17 -5
- package/dist/components/data/tableCells.js +52 -53
- package/dist/components/data/tableLogic.d.ts +2 -0
- package/dist/components/data/tableLogic.js +66 -66
- package/dist/components/data/tableSlots.d.ts +9 -0
- package/dist/components/data/tableSlots.js +12 -0
- package/dist/components/data/tableSpanLogic.d.ts +35 -0
- package/dist/components/data/tableSpanLogic.js +47 -0
- package/dist/components/data/tableTypes.d.ts +54 -1
- package/dist/components/data/useTableSelection.d.ts +4 -2
- package/dist/components/data/useTableSelection.js +29 -25
- package/dist/components/display/KapiAnchor.d.ts +36 -0
- package/dist/components/display/KapiAnchor.js +36 -0
- 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/KapiBadge.d.ts +6 -5
- package/dist/components/display/KapiBadge.js +25 -19
- 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/KapiText.d.ts +43 -0
- package/dist/components/display/KapiText.js +33 -0
- package/dist/components/display/KapiTimeline.d.ts +5 -2
- package/dist/components/display/KapiTimeline.js +31 -23
- package/dist/components/display/KapiTitle.d.ts +33 -0
- package/dist/components/display/KapiTitle.js +29 -0
- 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 +15 -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/textLogic.d.ts +32 -0
- package/dist/components/display/textLogic.js +19 -0
- package/dist/components/display/timelineLogic.d.ts +20 -2
- package/dist/components/display/timelineLogic.js +10 -2
- package/dist/components/feedback/KapiAlert.d.ts +8 -4
- package/dist/components/feedback/KapiAlert.js +39 -34
- 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/KapiButton.d.ts +7 -4
- package/dist/components/inputs/KapiButton.js +47 -42
- 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 +21 -1
- package/dist/components/inputs/KapiSelect.js +251 -245
- package/dist/components/inputs/KapiSelectMenu.d.ts +4 -2
- package/dist/components/inputs/KapiSelectMenu.js +131 -133
- 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 +21 -1
- package/dist/components/inputs/fieldLogic.js +18 -11
- package/dist/components/inputs/index.d.ts +9 -1
- 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/inputs/selectSlots.d.ts +24 -0
- package/dist/components/inputs/selectSlots.js +27 -0
- 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/KapiBox.d.ts +31 -0
- package/dist/components/layout/KapiBox.js +26 -0
- package/dist/components/layout/KapiCard.d.ts +16 -4
- package/dist/components/layout/KapiCard.js +46 -34
- package/dist/components/layout/KapiCenter.d.ts +13 -0
- package/dist/components/layout/KapiCenter.js +23 -0
- package/dist/components/layout/KapiCol.d.ts +22 -0
- package/dist/components/layout/KapiCol.js +23 -0
- 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.d.ts +29 -3
- package/dist/components/layout/KapiGrid.js +39 -17
- package/dist/components/layout/KapiNotificationBell.js +10 -10
- package/dist/components/layout/KapiPageHeader.d.ts +10 -1
- package/dist/components/layout/KapiPageHeader.js +94 -92
- package/dist/components/layout/KapiPanelParts.d.ts +11 -2
- package/dist/components/layout/KapiPanelParts.js +73 -56
- package/dist/components/layout/KapiRail.d.ts +10 -1
- package/dist/components/layout/KapiRail.js +125 -122
- package/dist/components/layout/KapiRoot.d.ts +55 -5
- package/dist/components/layout/KapiRoot.js +57 -38
- package/dist/components/layout/KapiShell.d.ts +44 -3
- package/dist/components/layout/KapiShell.js +54 -50
- package/dist/components/layout/accessCardLogic.d.ts +8 -1
- package/dist/components/layout/accessCardLogic.js +11 -7
- package/dist/components/layout/cardSlots.d.ts +9 -0
- package/dist/components/layout/cardSlots.js +12 -0
- package/dist/components/layout/gridSpanLogic.d.ts +46 -0
- package/dist/components/layout/gridSpanLogic.js +39 -0
- package/dist/components/layout/index.d.ts +13 -4
- package/dist/components/layout/layoutPrimitives.d.ts +11 -0
- package/dist/components/layout/layoutPrimitives.js +12 -1
- package/dist/components/layout/pageHeaderSlots.d.ts +12 -0
- package/dist/components/layout/pageHeaderSlots.js +15 -0
- package/dist/components/layout/railLogic.d.ts +16 -3
- package/dist/components/layout/railSlots.d.ts +12 -0
- package/dist/components/layout/railSlots.js +15 -0
- package/dist/components/layout/shellSlots.d.ts +6 -0
- package/dist/components/layout/shellSlots.js +9 -0
- package/dist/components/layout/useGridBreakpoint.d.ts +12 -0
- package/dist/components/layout/useGridBreakpoint.js +35 -0
- package/dist/components/locale/labelRegistry.d.ts +10 -0
- package/dist/components/navigation/KapiAccordion.js +9 -9
- package/dist/components/navigation/KapiBreadcrumb.d.ts +18 -2
- package/dist/components/navigation/KapiBreadcrumb.js +23 -16
- package/dist/components/navigation/KapiContextPanel.d.ts +17 -4
- package/dist/components/navigation/KapiContextPanel.js +152 -136
- package/dist/components/navigation/KapiNavBadge.d.ts +6 -3
- package/dist/components/navigation/KapiNavBadge.js +26 -22
- package/dist/components/navigation/KapiPanelGroup.d.ts +16 -4
- package/dist/components/navigation/KapiPanelGroup.js +66 -65
- package/dist/components/navigation/KapiTabs.d.ts +12 -0
- package/dist/components/navigation/KapiTabs.js +87 -71
- 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/MiniNavItem.d.ts +7 -2
- package/dist/components/navigation/MiniNavItem.js +41 -36
- package/dist/components/navigation/breadcrumbLogic.d.ts +4 -2
- package/dist/components/navigation/breadcrumbLogic.js +1 -1
- package/dist/components/navigation/index.d.ts +3 -0
- package/dist/components/navigation/navLink.d.ts +21 -0
- package/dist/components/navigation/navLink.js +26 -0
- package/dist/components/navigation/navLinkLogic.d.ts +18 -0
- package/dist/components/navigation/navLinkLogic.js +22 -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.d.ts +8 -0
- package/dist/components/overlays/KapiContextMenu.js +5 -5
- package/dist/components/overlays/KapiMenuButton.js +7 -7
- package/dist/components/overlays/KapiModal.d.ts +9 -0
- package/dist/components/overlays/KapiModal.js +79 -77
- 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/index.d.ts +1 -1
- package/dist/components/overlays/menuList.js +127 -117
- package/dist/components/overlays/modalSlots.d.ts +11 -0
- package/dist/components/overlays/modalSlots.js +14 -0
- package/dist/components/slotCatalog.d.ts +123 -0
- package/dist/components/slotCatalog.js +27 -0
- package/dist/components/slotsLogic.d.ts +34 -0
- package/dist/components/slotsLogic.js +18 -0
- package/dist/components/tone.d.ts +26 -0
- package/dist/components/tone.js +15 -14
- package/dist/css/base.css +1 -1
- package/dist/css/components/data/KapiEventCalendar.css +1 -1
- package/dist/css/components/data/KapiTable.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/display/typography.css +1 -0
- package/dist/css/components/feedback/feedback.css +1 -1
- package/dist/css/components/inputs/KapiButton.css +1 -1
- package/dist/css/components/inputs/KapiDatePicker.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/KapiBox.css +1 -0
- package/dist/css/components/layout/KapiCollapse.css +1 -0
- package/dist/css/components/layout/KapiDivider.css +1 -1
- package/dist/css/components/layout/KapiRail.css +1 -1
- package/dist/css/components/layout/gridSpan.css +1 -0
- package/dist/css/components/navigation/KapiToc.css +1 -0
- package/dist/css/components/navigation/navigation.css +1 -1
- package/dist/hooks/asyncResourceLogic.d.ts +11 -0
- package/dist/hooks/asyncResourceLogic.js +4 -0
- package/dist/hooks/densityLogic.d.ts +15 -0
- package/dist/hooks/densityLogic.js +4 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/themeColorsLogic.d.ts +19 -0
- package/dist/hooks/themeColorsLogic.js +4 -2
- package/dist/hooks/themeDeriveLogic.d.ts +16 -0
- package/dist/hooks/themeDeriveLogic.js +27 -17
- package/dist/hooks/toneFamilyLogic.d.ts +146 -0
- package/dist/hooks/toneFamilyLogic.js +164 -0
- package/dist/hooks/useAsyncResource.d.ts +45 -0
- package/dist/hooks/useAsyncResource.js +24 -0
- package/dist/hooks/useKapiTheme.d.ts +16 -3
- package/dist/hooks/useKapiTheme.js +130 -117
- package/dist/hooks/useToneFamilies.d.ts +40 -0
- package/dist/hooks/useToneFamilies.js +50 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +227 -204
- 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/dist/styles/rawHeights.d.ts +8 -0
- package/package.json +14 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type KapiLinkLabels } from "../locale/linkLabels.js";
|
|
3
|
+
import type { KapiRender } from "../renderSlot.js";
|
|
3
4
|
import { type KapiNavBadgeValue } from "./navBadgeLogic.js";
|
|
4
5
|
import type { KapiTone } from "../tone.js";
|
|
5
6
|
import type { KapiRootProps } from "../rootProps.js";
|
|
@@ -20,11 +21,22 @@ export type KapiPanelGroupItem<Id extends string = string> = {
|
|
|
20
21
|
icon?: ReactNode;
|
|
21
22
|
/** No se puede elegir (botón deshabilitado o enlace `aria-disabled`). */
|
|
22
23
|
disabled?: boolean | undefined;
|
|
23
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Si se pasa, se dibuja un enlace real `<a>` en vez de un botón. Es un enlace NATIVO: navega con carga
|
|
26
|
+
* completa de página. Para navegar dentro de una SPA sin recargar, usa `render`.
|
|
27
|
+
*/
|
|
24
28
|
href?: string | undefined;
|
|
25
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* El elemento que dibuja el subítem: el `<Link>` de tu router. Navega sin recargar la página. Las clases
|
|
31
|
+
* se unen, los estilos se funden y los handlers corren los dos (primero el tuyo); la librería no le pone
|
|
32
|
+
* `href` y `href` se ignora. `onSelect(id)` NO se llama: un enlace navega solo (igual que con `href`), así que no hay doble navegación si tu `onSelect` ya navega para los ítems que son botones.
|
|
33
|
+
*
|
|
34
|
+
* { id: "abiertos", label: "Abiertos", render: <Link to="/abiertos" /> }
|
|
35
|
+
*/
|
|
36
|
+
render?: KapiRender | undefined;
|
|
37
|
+
/** Destino en otro sistema: agrega el ícono ↗ (sólo con `href` o `render`). */
|
|
26
38
|
external?: boolean | undefined;
|
|
27
|
-
/** Abrir el enlace en una pestaña nueva (sólo con `href`). */
|
|
39
|
+
/** Abrir el enlace en una pestaña nueva (sólo con `href` o `render`). */
|
|
28
40
|
newTab?: boolean | undefined;
|
|
29
41
|
};
|
|
30
42
|
/**
|
|
@@ -48,7 +60,7 @@ export type KapiPanelGroupProps<Id extends string = string> = KapiRootProps<HTML
|
|
|
48
60
|
items: readonly KapiPanelGroupItem<Id>[];
|
|
49
61
|
/** Id del subítem activo (`aria-current="page"`); lo decide la app, normalmente desde el router. */
|
|
50
62
|
activeId?: Id | undefined;
|
|
51
|
-
/** Se llama con el `id` del subítem clickeado (no aplica a los enlaces con `href`). */
|
|
63
|
+
/** Se llama con el `id` del subítem clickeado (no aplica a los enlaces: ni con `href` ni con `render`). */
|
|
52
64
|
onSelect?: ((id: Id) => void) | undefined;
|
|
53
65
|
/** Controlado. */
|
|
54
66
|
open?: boolean | undefined;
|
|
@@ -7,99 +7,100 @@ import "./navBadgeLogic.js";
|
|
|
7
7
|
import { KapiNavBadge as r } from "./KapiNavBadge.js";
|
|
8
8
|
import { CtxSlidingList as i } from "./CtxSlidingList.js";
|
|
9
9
|
/* empty css */
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
10
|
+
import { renderNavLink as a } from "./navLink.js";
|
|
11
|
+
import { useKapiPanelMini as o } from "./panelMini.js";
|
|
12
|
+
import { MiniNavItem as s } from "./MiniNavItem.js";
|
|
13
|
+
import { activeIdIn as c } from "./activeItemLogic.js";
|
|
14
|
+
import { formatCount as l, panelGroupClasses as u } from "./panelGroupLogic.js";
|
|
15
|
+
import { useId as d } from "react";
|
|
16
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
17
|
+
import { ChevronRight as h, ExternalLink as g } from "lucide-react";
|
|
17
18
|
//#region src/components/navigation/KapiPanelGroup.tsx
|
|
18
|
-
var
|
|
19
|
-
let t =
|
|
20
|
-
return t === null ? null : /* @__PURE__ */
|
|
19
|
+
var _ = ({ value: e }) => {
|
|
20
|
+
let t = l(e);
|
|
21
|
+
return t === null ? null : /* @__PURE__ */ p("span", {
|
|
21
22
|
className: "kapi-panelgroup__count",
|
|
22
23
|
children: t
|
|
23
24
|
});
|
|
24
|
-
},
|
|
25
|
-
let
|
|
25
|
+
}, v = ({ item: e, active: t, onSelect: n, newTabLabel: i }) => {
|
|
26
|
+
let o = `kapi-ctxitem${t ? " kapi-ctxitem--on" : ""}`, s = /* @__PURE__ */ m("span", {
|
|
26
27
|
className: "kapi-ctxitem__main",
|
|
27
28
|
children: [e.icon, e.label]
|
|
28
29
|
});
|
|
29
|
-
return e.href
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
return e.href !== void 0 || e.render !== void 0 ? a({
|
|
31
|
+
render: e.render,
|
|
32
|
+
href: e.href,
|
|
33
|
+
newTab: e.newTab,
|
|
33
34
|
disabled: e.disabled,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
tone: e.badgeTone,
|
|
40
|
-
label: e.badgeLabel,
|
|
41
|
-
max: 999
|
|
42
|
-
}),
|
|
43
|
-
/* @__PURE__ */ d(h, { value: e.count })
|
|
44
|
-
]
|
|
45
|
-
}) : /* @__PURE__ */ f("a", {
|
|
46
|
-
className: `${a} kapi-ctxitem--link`,
|
|
47
|
-
href: e.disabled ? void 0 : e.href,
|
|
48
|
-
rel: "noopener noreferrer",
|
|
49
|
-
target: e.newTab ? "_blank" : void 0,
|
|
50
|
-
"aria-current": t ? "page" : void 0,
|
|
51
|
-
"aria-disabled": e.disabled || void 0,
|
|
52
|
-
children: [
|
|
53
|
-
o,
|
|
54
|
-
/* @__PURE__ */ d(r, {
|
|
35
|
+
active: t,
|
|
36
|
+
className: `${o} kapi-ctxitem--link`,
|
|
37
|
+
children: /* @__PURE__ */ m(f, { children: [
|
|
38
|
+
s,
|
|
39
|
+
/* @__PURE__ */ p(r, {
|
|
55
40
|
value: e.badge,
|
|
56
41
|
tone: e.badgeTone,
|
|
57
42
|
label: e.badgeLabel,
|
|
58
43
|
max: 999
|
|
59
44
|
}),
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
e.external && /* @__PURE__ */
|
|
45
|
+
/* @__PURE__ */ p(_, { value: e.count }),
|
|
46
|
+
e.external && /* @__PURE__ */ p(g, {
|
|
62
47
|
className: "kapi-ctxitem__ext",
|
|
63
48
|
size: 14,
|
|
64
49
|
"aria-hidden": "true"
|
|
65
50
|
}),
|
|
66
|
-
e.newTab && /* @__PURE__ */
|
|
51
|
+
e.newTab && /* @__PURE__ */ p("span", {
|
|
67
52
|
className: "kapi-ctxitem__sr",
|
|
68
53
|
children: i
|
|
69
54
|
})
|
|
55
|
+
] })
|
|
56
|
+
}) : /* @__PURE__ */ m("button", {
|
|
57
|
+
type: "button",
|
|
58
|
+
className: o,
|
|
59
|
+
"aria-current": t ? "page" : void 0,
|
|
60
|
+
disabled: e.disabled,
|
|
61
|
+
onClick: () => n?.(e.id),
|
|
62
|
+
children: [
|
|
63
|
+
s,
|
|
64
|
+
/* @__PURE__ */ p(r, {
|
|
65
|
+
value: e.badge,
|
|
66
|
+
tone: e.badgeTone,
|
|
67
|
+
label: e.badgeLabel,
|
|
68
|
+
max: 999
|
|
69
|
+
}),
|
|
70
|
+
/* @__PURE__ */ p(_, { value: e.count })
|
|
70
71
|
]
|
|
71
72
|
});
|
|
72
73
|
};
|
|
73
|
-
function
|
|
74
|
-
let N = e("link", n, M), P =
|
|
75
|
-
return B ? /* @__PURE__ */
|
|
74
|
+
function y({ label: a, count: l, badge: f, badgeTone: g, badgeLabel: y, icon: b, items: x, activeId: S, onSelect: C, open: w, defaultOpen: T = !1, onOpenChange: E, className: D, style: O, id: k, ref: A, "aria-label": j, labels: M }) {
|
|
75
|
+
let N = e("link", n, M), P = d(), F = `${P}-body`, I = `${P}-head`, [L, R] = t(w, T, E), z = () => R(!L), { mini: B, expand: V } = o();
|
|
76
|
+
return B ? /* @__PURE__ */ p("div", {
|
|
76
77
|
ref: A,
|
|
77
|
-
className:
|
|
78
|
+
className: u({
|
|
78
79
|
open: !1,
|
|
79
80
|
className: D
|
|
80
81
|
}),
|
|
81
82
|
style: O,
|
|
82
83
|
id: k,
|
|
83
|
-
children: /* @__PURE__ */
|
|
84
|
-
label:
|
|
84
|
+
children: /* @__PURE__ */ p(s, {
|
|
85
|
+
label: a,
|
|
85
86
|
icon: b,
|
|
86
|
-
active:
|
|
87
|
-
badge:
|
|
88
|
-
badgeTone:
|
|
87
|
+
active: c(x, S) !== null,
|
|
88
|
+
badge: f,
|
|
89
|
+
badgeTone: g,
|
|
89
90
|
badgeLabel: y,
|
|
90
91
|
onClick: () => {
|
|
91
92
|
V(), L || R(!0);
|
|
92
93
|
}
|
|
93
94
|
})
|
|
94
|
-
}) : /* @__PURE__ */
|
|
95
|
+
}) : /* @__PURE__ */ m("div", {
|
|
95
96
|
ref: A,
|
|
96
|
-
className:
|
|
97
|
+
className: u({
|
|
97
98
|
open: L,
|
|
98
99
|
className: D
|
|
99
100
|
}),
|
|
100
101
|
style: O,
|
|
101
102
|
id: k,
|
|
102
|
-
children: [/* @__PURE__ */
|
|
103
|
+
children: [/* @__PURE__ */ m("button", {
|
|
103
104
|
type: "button",
|
|
104
105
|
id: I,
|
|
105
106
|
className: "kapi-panelgroup__head",
|
|
@@ -107,36 +108,36 @@ function _({ label: c, count: m, badge: _, badgeTone: v, badgeLabel: y, icon: b,
|
|
|
107
108
|
"aria-controls": F,
|
|
108
109
|
onClick: z,
|
|
109
110
|
children: [
|
|
110
|
-
/* @__PURE__ */
|
|
111
|
+
/* @__PURE__ */ m("span", {
|
|
111
112
|
className: "kapi-panelgroup__label",
|
|
112
|
-
children: [b,
|
|
113
|
+
children: [b, a]
|
|
113
114
|
}),
|
|
114
|
-
/* @__PURE__ */
|
|
115
|
-
value:
|
|
116
|
-
tone:
|
|
115
|
+
/* @__PURE__ */ p(r, {
|
|
116
|
+
value: f,
|
|
117
|
+
tone: g,
|
|
117
118
|
label: y,
|
|
118
119
|
max: 999
|
|
119
120
|
}),
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
/* @__PURE__ */
|
|
121
|
+
/* @__PURE__ */ p(_, { value: l }),
|
|
122
|
+
/* @__PURE__ */ p(h, {
|
|
122
123
|
className: "kapi-panelgroup__chevron kapi-flip-rtl",
|
|
123
124
|
size: 16,
|
|
124
125
|
strokeWidth: 2,
|
|
125
126
|
"aria-hidden": "true"
|
|
126
127
|
})
|
|
127
128
|
]
|
|
128
|
-
}), /* @__PURE__ */
|
|
129
|
+
}), /* @__PURE__ */ p("div", {
|
|
129
130
|
id: F,
|
|
130
131
|
role: "region",
|
|
131
132
|
"aria-label": j,
|
|
132
133
|
"aria-labelledby": j ? void 0 : I,
|
|
133
134
|
className: "kapi-panelgroup__body",
|
|
134
135
|
inert: !L,
|
|
135
|
-
children: /* @__PURE__ */
|
|
136
|
+
children: /* @__PURE__ */ p("div", {
|
|
136
137
|
className: "kapi-panelgroup__clip",
|
|
137
|
-
children: /* @__PURE__ */
|
|
138
|
-
active:
|
|
139
|
-
children: x.map((e) => /* @__PURE__ */
|
|
138
|
+
children: /* @__PURE__ */ p(i, {
|
|
139
|
+
active: c(x, S),
|
|
140
|
+
children: x.map((e) => /* @__PURE__ */ p(v, {
|
|
140
141
|
item: e,
|
|
141
142
|
active: e.id === S,
|
|
142
143
|
onSelect: C,
|
|
@@ -148,4 +149,4 @@ function _({ label: c, count: m, badge: _, badgeTone: v, badgeLabel: y, icon: b,
|
|
|
148
149
|
});
|
|
149
150
|
}
|
|
150
151
|
//#endregion
|
|
151
|
-
export {
|
|
152
|
+
export { y as KapiPanelGroup };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CSSProperties } from "react";
|
|
2
2
|
import { type HTMLAttributes, type ReactNode, type Ref } from "react";
|
|
3
|
+
import { type KapiRender } from "../renderSlot.js";
|
|
3
4
|
/** Pestaña de `KapiTabs`. `Id` acota los ids (p. ej. una unión de literales). */
|
|
4
5
|
export type KapiTabItem<Id extends string = string> = {
|
|
5
6
|
/** Id único de la pestaña (es el `value` cuando está activa). */
|
|
@@ -14,6 +15,17 @@ export type KapiTabItem<Id extends string = string> = {
|
|
|
14
15
|
count?: number | undefined;
|
|
15
16
|
/** Pestaña no elegible: se ve atenuada y el teclado la saltea. */
|
|
16
17
|
disabled?: boolean | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* El elemento que dibuja la pestaña: el `<Link>` de tu router, para pestañas que son rutas y navegan
|
|
20
|
+
* sin recargar la página. Conserva `role="tab"`, `aria-selected`, el id y el roving tabindex (no se
|
|
21
|
+
* negocian); las clases se unen, los estilos se funden y los handlers corren los dos (primero el tuyo).
|
|
22
|
+
* Con `value` (controlado) el clic NO llama a `onChange`: el enlace navega solo y la ruta decide la
|
|
23
|
+
* pestaña activa. Las flechas sí lo llaman (no hay clic que navegue): ahí navega tú. Apagada, va por
|
|
24
|
+
* `aria-disabled` y el clic se frena.
|
|
25
|
+
*
|
|
26
|
+
* { id: "altas", label: "Altas", render: <Link to="/altas" /> }
|
|
27
|
+
*/
|
|
28
|
+
render?: KapiRender | undefined;
|
|
17
29
|
};
|
|
18
30
|
/** Escala de las pestañas: `sm` para barras compactas, `md` la de siempre (mismo vocabulario que `KapiSegmentedSize`). */
|
|
19
31
|
export type KapiTabsSize = "sm" | "md";
|
|
@@ -1,94 +1,110 @@
|
|
|
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 {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
4
|
+
import { renderSlot as t } from "../renderSlot.js";
|
|
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
|
+
import { useSlidingIndicator as c } from "../../hooks/useSlidingIndicator.js";
|
|
11
|
+
import { formatCount as l } from "../../hooks/numberFormatLogic.js";
|
|
12
|
+
import { useScrollEdges as u } from "../../hooks/useScrollEdges.js";
|
|
12
13
|
/* empty css */
|
|
13
|
-
import { nextTabId as
|
|
14
|
-
import { useCallback as
|
|
15
|
-
import { Fragment as
|
|
14
|
+
import { nextTabId as d, tabClasses as f, tabId as p, tabPanelId as m } from "./tabsLogic.js";
|
|
15
|
+
import { Fragment as h, useCallback as g, useId as _, useLayoutEffect as v, useMemo as y, useRef as b } from "react";
|
|
16
|
+
import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
16
17
|
//#region src/components/navigation/KapiTabs.tsx
|
|
17
|
-
var
|
|
18
|
-
function
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
controlled:
|
|
22
|
-
hasOnChange: !!
|
|
23
|
-
disabled:
|
|
18
|
+
var w = [];
|
|
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 = 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
|
+
controlled: D !== void 0,
|
|
23
|
+
hasOnChange: !!k,
|
|
24
|
+
disabled: M
|
|
24
25
|
});
|
|
25
|
-
let { containerRef:
|
|
26
|
-
active:
|
|
27
|
-
deps: [
|
|
26
|
+
let { containerRef: G, indicatorRef: K } = c({
|
|
27
|
+
active: H ?? null,
|
|
28
|
+
deps: [R],
|
|
28
29
|
findActive: (e) => e.querySelector("[role=\"tab\"][aria-selected=\"true\"]")
|
|
29
|
-
}), { ref:
|
|
30
|
-
|
|
31
|
-
}, [
|
|
32
|
-
|
|
33
|
-
let e =
|
|
34
|
-
e &&
|
|
30
|
+
}), { ref: q, edges: J, reveal: Y } = u({ axis: "x" }), X = g((e) => {
|
|
31
|
+
G.current = e, q.current = e;
|
|
32
|
+
}, [G, q]), Z = n(X, F), Q = b(!1);
|
|
33
|
+
v(() => {
|
|
34
|
+
let e = G.current?.querySelector("[role=\"tab\"][aria-selected=\"true\"]");
|
|
35
|
+
e && Y(e, { instant: !Q.current }), Q.current = !0;
|
|
35
36
|
}, [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
H,
|
|
38
|
+
G,
|
|
39
|
+
Y
|
|
39
40
|
]);
|
|
40
|
-
let
|
|
41
|
-
if (
|
|
42
|
-
let t =
|
|
43
|
-
t !== void 0 && (e.preventDefault(),
|
|
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
|
+
if (P?.(e), e.defaultPrevented || H === void 0) return;
|
|
43
|
+
let t = d(R.map((e) => e.id), H, a(e), $);
|
|
44
|
+
t !== void 0 && (e.preventDefault(), U(t), V.current[t]?.focus());
|
|
44
45
|
};
|
|
45
|
-
return /* @__PURE__ */
|
|
46
|
-
...
|
|
47
|
-
ref:
|
|
48
|
-
className: e("kapi-tabs", "kapi-fade-x",
|
|
49
|
-
"data-edge-start":
|
|
50
|
-
"data-edge-end":
|
|
46
|
+
return /* @__PURE__ */ C("div", {
|
|
47
|
+
...I,
|
|
48
|
+
ref: Z,
|
|
49
|
+
className: e("kapi-tabs", "kapi-fade-x", N === "sm" && "kapi-tabs--sm", A),
|
|
50
|
+
"data-edge-start": J.start ? "" : void 0,
|
|
51
|
+
"data-edge-end": J.end ? "" : void 0,
|
|
51
52
|
role: "tablist",
|
|
52
|
-
"aria-disabled":
|
|
53
|
-
onKeyDown:
|
|
54
|
-
children: [/* @__PURE__ */
|
|
55
|
-
ref:
|
|
53
|
+
"aria-disabled": M || void 0,
|
|
54
|
+
onKeyDown: te,
|
|
55
|
+
children: [/* @__PURE__ */ S("span", {
|
|
56
|
+
ref: K,
|
|
56
57
|
className: "kapi-tabs__indicator",
|
|
57
58
|
"aria-hidden": "true"
|
|
58
|
-
}),
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
}), R.map((e) => {
|
|
60
|
+
let n = e.id === H, r = /* @__PURE__ */ C(x, { children: [
|
|
61
|
+
e.icon,
|
|
62
|
+
e.label,
|
|
63
|
+
e.count !== void 0 && /* @__PURE__ */ C(x, { children: [" ", /* @__PURE__ */ S("span", {
|
|
64
|
+
className: "kapi-tabs__count",
|
|
65
|
+
children: l(e.count, L)
|
|
66
|
+
})] })
|
|
67
|
+
] }), i = (t) => {
|
|
68
|
+
V.current[e.id] = t;
|
|
69
|
+
}, a = {
|
|
70
|
+
id: p(B, e.id),
|
|
66
71
|
role: "tab",
|
|
67
|
-
"aria-controls":
|
|
68
|
-
"aria-selected":
|
|
69
|
-
tabIndex: e.id ===
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
children:
|
|
74
|
-
|
|
75
|
-
e.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
"aria-controls": j ? m(j, e.id) : void 0,
|
|
73
|
+
"aria-selected": n,
|
|
74
|
+
tabIndex: e.id === ee ? 0 : -1
|
|
75
|
+
};
|
|
76
|
+
if (e.render !== void 0) {
|
|
77
|
+
let o = $(e.id);
|
|
78
|
+
return /* @__PURE__ */ S(h, { children: t(e.render, {
|
|
79
|
+
className: f(n),
|
|
80
|
+
...D === void 0 ? { onClick: () => U(e.id) } : {}
|
|
81
|
+
}, {
|
|
82
|
+
...a,
|
|
83
|
+
"aria-disabled": o || void 0,
|
|
84
|
+
...o ? { onClick: (e) => e.preventDefault() } : {},
|
|
85
|
+
ref: i,
|
|
86
|
+
children: r
|
|
87
|
+
}, (e) => /* @__PURE__ */ S("a", { ...e })) }, e.id);
|
|
88
|
+
}
|
|
89
|
+
return /* @__PURE__ */ S("button", {
|
|
90
|
+
ref: i,
|
|
91
|
+
type: "button",
|
|
92
|
+
...a,
|
|
93
|
+
disabled: $(e.id) || void 0,
|
|
94
|
+
className: f(n),
|
|
95
|
+
onClick: () => U(e.id),
|
|
96
|
+
children: r
|
|
81
97
|
}, e.id);
|
|
82
98
|
})]
|
|
83
99
|
});
|
|
84
100
|
}
|
|
85
|
-
function
|
|
86
|
-
return /* @__PURE__ */
|
|
101
|
+
function E({ idBase: e, tabId: t, active: n, keepMounted: r = !1, className: i, style: a, children: o, ref: s }) {
|
|
102
|
+
return /* @__PURE__ */ S("div", {
|
|
87
103
|
ref: s,
|
|
88
104
|
style: a,
|
|
89
|
-
id:
|
|
105
|
+
id: m(e, t),
|
|
90
106
|
role: "tabpanel",
|
|
91
|
-
"aria-labelledby":
|
|
107
|
+
"aria-labelledby": p(e, t),
|
|
92
108
|
tabIndex: 0,
|
|
93
109
|
hidden: !n,
|
|
94
110
|
className: i,
|
|
@@ -96,4 +112,4 @@ function w({ idBase: e, tabId: t, active: n, keepMounted: r = !1, className: i,
|
|
|
96
112
|
});
|
|
97
113
|
}
|
|
98
114
|
//#endregion
|
|
99
|
-
export {
|
|
115
|
+
export { E as KapiTabPanel, T as KapiTabs };
|
|
@@ -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));
|