@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.
Files changed (288) hide show
  1. package/LICENSE +19 -15
  2. package/README.md +505 -13
  3. package/dist/components/chat/KapiChatThread.js +4 -4
  4. package/dist/components/chat/KapiComposer.js +8 -8
  5. package/dist/components/data/KapiDataTable.d.ts +1 -1
  6. package/dist/components/data/KapiDataTable.js +25 -25
  7. package/dist/components/data/KapiPaginationFooter.js +1 -1
  8. package/dist/components/data/KapiSheet.d.ts +105 -0
  9. package/dist/components/data/KapiSheet.js +75 -0
  10. package/dist/components/data/KapiSparkline.d.ts +2 -1
  11. package/dist/components/data/KapiSparkline.js +29 -26
  12. package/dist/components/data/KapiTable.d.ts +2 -2
  13. package/dist/components/data/KapiTable.js +347 -329
  14. package/dist/components/data/KapiTableFilter.js +6 -6
  15. package/dist/components/data/KapiTableFooter.d.ts +22 -0
  16. package/dist/components/data/KapiTableFooter.js +55 -0
  17. package/dist/components/data/KapiTableRow.js +53 -52
  18. package/dist/components/data/KapiTableToolbar.d.ts +4 -2
  19. package/dist/components/data/KapiTableToolbar.js +71 -69
  20. package/dist/components/data/index.d.ts +3 -1
  21. package/dist/components/data/tableCells.d.ts +17 -5
  22. package/dist/components/data/tableCells.js +52 -53
  23. package/dist/components/data/tableLogic.d.ts +2 -0
  24. package/dist/components/data/tableLogic.js +66 -66
  25. package/dist/components/data/tableSlots.d.ts +9 -0
  26. package/dist/components/data/tableSlots.js +12 -0
  27. package/dist/components/data/tableSpanLogic.d.ts +35 -0
  28. package/dist/components/data/tableSpanLogic.js +47 -0
  29. package/dist/components/data/tableTypes.d.ts +54 -1
  30. package/dist/components/data/useTableSelection.d.ts +4 -2
  31. package/dist/components/data/useTableSelection.js +29 -25
  32. package/dist/components/display/KapiAnchor.d.ts +36 -0
  33. package/dist/components/display/KapiAnchor.js +36 -0
  34. package/dist/components/display/KapiAnnotation.js +68 -63
  35. package/dist/components/display/KapiAvatar.d.ts +6 -4
  36. package/dist/components/display/KapiAvatar.js +33 -28
  37. package/dist/components/display/KapiBadge.d.ts +6 -5
  38. package/dist/components/display/KapiBadge.js +25 -19
  39. package/dist/components/display/KapiCodeBlock.d.ts +48 -0
  40. package/dist/components/display/KapiCodeBlock.js +44 -0
  41. package/dist/components/display/KapiCommentComposer.js +6 -6
  42. package/dist/components/display/KapiDiff.d.ts +62 -0
  43. package/dist/components/display/KapiDiff.js +118 -0
  44. package/dist/components/display/KapiHighlight.d.ts +27 -0
  45. package/dist/components/display/KapiHighlight.js +21 -0
  46. package/dist/components/display/KapiIconTile.d.ts +2 -1
  47. package/dist/components/display/KapiIconTile.js +23 -21
  48. package/dist/components/display/KapiStat.d.ts +3 -2
  49. package/dist/components/display/KapiStat.js +32 -26
  50. package/dist/components/display/KapiTag.d.ts +4 -3
  51. package/dist/components/display/KapiTag.js +29 -24
  52. package/dist/components/display/KapiText.d.ts +43 -0
  53. package/dist/components/display/KapiText.js +33 -0
  54. package/dist/components/display/KapiTimeline.d.ts +5 -2
  55. package/dist/components/display/KapiTimeline.js +31 -23
  56. package/dist/components/display/KapiTitle.d.ts +33 -0
  57. package/dist/components/display/KapiTitle.js +29 -0
  58. package/dist/components/display/annotationLogic.d.ts +2 -1
  59. package/dist/components/display/annotationLogic.js +7 -6
  60. package/dist/components/display/codeBlockSlots.d.ts +10 -0
  61. package/dist/components/display/codeBlockSlots.js +13 -0
  62. package/dist/components/display/diffLogic.d.ts +58 -0
  63. package/dist/components/display/diffLogic.js +96 -0
  64. package/dist/components/display/diffSlots.d.ts +14 -0
  65. package/dist/components/display/diffSlots.js +17 -0
  66. package/dist/components/display/highlightLogic.d.ts +18 -0
  67. package/dist/components/display/highlightLogic.js +26 -0
  68. package/dist/components/display/highlightSlots.d.ts +5 -0
  69. package/dist/components/display/highlightSlots.js +8 -0
  70. package/dist/components/display/iconTileLogic.d.ts +2 -2
  71. package/dist/components/display/iconTileLogic.js +7 -6
  72. package/dist/components/display/index.d.ts +15 -0
  73. package/dist/components/display/statLogic.d.ts +2 -1
  74. package/dist/components/display/statLogic.js +7 -6
  75. package/dist/components/display/tagLogic.d.ts +2 -1
  76. package/dist/components/display/tagLogic.js +7 -6
  77. package/dist/components/display/textLogic.d.ts +32 -0
  78. package/dist/components/display/textLogic.js +19 -0
  79. package/dist/components/display/timelineLogic.d.ts +20 -2
  80. package/dist/components/display/timelineLogic.js +10 -2
  81. package/dist/components/feedback/KapiAlert.d.ts +8 -4
  82. package/dist/components/feedback/KapiAlert.js +39 -34
  83. package/dist/components/feedback/KapiFab.js +108 -108
  84. package/dist/components/feedback/KapiProgress.js +63 -54
  85. package/dist/components/feedback/KapiToastContainer.js +9 -9
  86. package/dist/components/feedback/KapiTour.js +12 -12
  87. package/dist/components/feedback/progressLogic.d.ts +2 -1
  88. package/dist/components/feedback/progressLogic.js +9 -8
  89. package/dist/components/inputs/KapiAutocomplete.d.ts +6 -0
  90. package/dist/components/inputs/KapiAutocomplete.js +86 -85
  91. package/dist/components/inputs/KapiButton.d.ts +7 -4
  92. package/dist/components/inputs/KapiButton.js +47 -42
  93. package/dist/components/inputs/KapiChecklist.d.ts +7 -1
  94. package/dist/components/inputs/KapiChecklist.js +53 -52
  95. package/dist/components/inputs/KapiCopyButton.d.ts +40 -0
  96. package/dist/components/inputs/KapiCopyButton.js +35 -0
  97. package/dist/components/inputs/KapiDatePicker.d.ts +7 -1
  98. package/dist/components/inputs/KapiDatePicker.js +118 -116
  99. package/dist/components/inputs/KapiDateRangePicker.d.ts +7 -1
  100. package/dist/components/inputs/KapiDateRangePicker.js +136 -135
  101. package/dist/components/inputs/KapiFacetedSearch.js +5 -5
  102. package/dist/components/inputs/KapiField.d.ts +9 -1
  103. package/dist/components/inputs/KapiField.js +43 -42
  104. package/dist/components/inputs/KapiFileUpload.js +6 -6
  105. package/dist/components/inputs/KapiInput.d.ts +29 -1
  106. package/dist/components/inputs/KapiInput.js +74 -51
  107. package/dist/components/inputs/KapiMaskedInput.js +26 -26
  108. package/dist/components/inputs/KapiNumberStepper.d.ts +7 -1
  109. package/dist/components/inputs/KapiNumberStepper.js +24 -23
  110. package/dist/components/inputs/KapiPinInput.d.ts +72 -0
  111. package/dist/components/inputs/KapiPinInput.js +75 -0
  112. package/dist/components/inputs/KapiPropsForm.d.ts +34 -0
  113. package/dist/components/inputs/KapiPropsForm.js +78 -0
  114. package/dist/components/inputs/KapiRating.d.ts +7 -1
  115. package/dist/components/inputs/KapiRating.js +39 -38
  116. package/dist/components/inputs/KapiSearchChip.js +5 -5
  117. package/dist/components/inputs/KapiSegmented.d.ts +13 -5
  118. package/dist/components/inputs/KapiSegmented.js +81 -77
  119. package/dist/components/inputs/KapiSelect.d.ts +21 -1
  120. package/dist/components/inputs/KapiSelect.js +251 -245
  121. package/dist/components/inputs/KapiSelectMenu.d.ts +4 -2
  122. package/dist/components/inputs/KapiSelectMenu.js +131 -133
  123. package/dist/components/inputs/KapiSlider.d.ts +10 -3
  124. package/dist/components/inputs/KapiSlider.js +67 -63
  125. package/dist/components/inputs/KapiTagInput.d.ts +7 -1
  126. package/dist/components/inputs/KapiTagInput.js +70 -69
  127. package/dist/components/inputs/KapiTextarea.d.ts +7 -1
  128. package/dist/components/inputs/KapiTextarea.js +51 -50
  129. package/dist/components/inputs/copyLogic.d.ts +1 -0
  130. package/dist/components/inputs/copyLogic.js +12 -0
  131. package/dist/components/inputs/fieldLogic.d.ts +21 -1
  132. package/dist/components/inputs/fieldLogic.js +18 -11
  133. package/dist/components/inputs/index.d.ts +9 -1
  134. package/dist/components/inputs/inputLogic.d.ts +16 -1
  135. package/dist/components/inputs/inputLogic.js +3 -3
  136. package/dist/components/inputs/ownField.d.ts +3 -1
  137. package/dist/components/inputs/ownField.js +28 -27
  138. package/dist/components/inputs/pinInputLogic.d.ts +34 -0
  139. package/dist/components/inputs/pinInputLogic.js +37 -0
  140. package/dist/components/inputs/propsFormLogic.d.ts +53 -0
  141. package/dist/components/inputs/propsFormLogic.js +11 -0
  142. package/dist/components/inputs/segmentedLogic.d.ts +7 -0
  143. package/dist/components/inputs/segmentedLogic.js +2 -2
  144. package/dist/components/inputs/selectSlots.d.ts +24 -0
  145. package/dist/components/inputs/selectSlots.js +27 -0
  146. package/dist/components/layout/KapiAccessCard.d.ts +5 -1
  147. package/dist/components/layout/KapiAccessCard.js +43 -39
  148. package/dist/components/layout/KapiAccountMenu.js +7 -7
  149. package/dist/components/layout/KapiBox.d.ts +31 -0
  150. package/dist/components/layout/KapiBox.js +26 -0
  151. package/dist/components/layout/KapiCard.d.ts +16 -4
  152. package/dist/components/layout/KapiCard.js +46 -34
  153. package/dist/components/layout/KapiCenter.d.ts +13 -0
  154. package/dist/components/layout/KapiCenter.js +23 -0
  155. package/dist/components/layout/KapiCol.d.ts +22 -0
  156. package/dist/components/layout/KapiCol.js +23 -0
  157. package/dist/components/layout/KapiCollapse.d.ts +39 -0
  158. package/dist/components/layout/KapiCollapse.js +20 -0
  159. package/dist/components/layout/KapiContextSlot.js +4 -4
  160. package/dist/components/layout/KapiDivider.d.ts +11 -2
  161. package/dist/components/layout/KapiDivider.js +30 -24
  162. package/dist/components/layout/KapiGrid.d.ts +29 -3
  163. package/dist/components/layout/KapiGrid.js +39 -17
  164. package/dist/components/layout/KapiNotificationBell.js +10 -10
  165. package/dist/components/layout/KapiPageHeader.d.ts +10 -1
  166. package/dist/components/layout/KapiPageHeader.js +94 -92
  167. package/dist/components/layout/KapiPanelParts.d.ts +11 -2
  168. package/dist/components/layout/KapiPanelParts.js +73 -56
  169. package/dist/components/layout/KapiRail.d.ts +10 -1
  170. package/dist/components/layout/KapiRail.js +125 -122
  171. package/dist/components/layout/KapiRoot.d.ts +55 -5
  172. package/dist/components/layout/KapiRoot.js +57 -38
  173. package/dist/components/layout/KapiShell.d.ts +44 -3
  174. package/dist/components/layout/KapiShell.js +54 -50
  175. package/dist/components/layout/accessCardLogic.d.ts +8 -1
  176. package/dist/components/layout/accessCardLogic.js +11 -7
  177. package/dist/components/layout/cardSlots.d.ts +9 -0
  178. package/dist/components/layout/cardSlots.js +12 -0
  179. package/dist/components/layout/gridSpanLogic.d.ts +46 -0
  180. package/dist/components/layout/gridSpanLogic.js +39 -0
  181. package/dist/components/layout/index.d.ts +13 -4
  182. package/dist/components/layout/layoutPrimitives.d.ts +11 -0
  183. package/dist/components/layout/layoutPrimitives.js +12 -1
  184. package/dist/components/layout/pageHeaderSlots.d.ts +12 -0
  185. package/dist/components/layout/pageHeaderSlots.js +15 -0
  186. package/dist/components/layout/railLogic.d.ts +16 -3
  187. package/dist/components/layout/railSlots.d.ts +12 -0
  188. package/dist/components/layout/railSlots.js +15 -0
  189. package/dist/components/layout/shellSlots.d.ts +6 -0
  190. package/dist/components/layout/shellSlots.js +9 -0
  191. package/dist/components/layout/useGridBreakpoint.d.ts +12 -0
  192. package/dist/components/layout/useGridBreakpoint.js +35 -0
  193. package/dist/components/locale/labelRegistry.d.ts +10 -0
  194. package/dist/components/navigation/KapiAccordion.js +9 -9
  195. package/dist/components/navigation/KapiBreadcrumb.d.ts +18 -2
  196. package/dist/components/navigation/KapiBreadcrumb.js +23 -16
  197. package/dist/components/navigation/KapiContextPanel.d.ts +17 -4
  198. package/dist/components/navigation/KapiContextPanel.js +152 -136
  199. package/dist/components/navigation/KapiNavBadge.d.ts +6 -3
  200. package/dist/components/navigation/KapiNavBadge.js +26 -22
  201. package/dist/components/navigation/KapiPanelGroup.d.ts +16 -4
  202. package/dist/components/navigation/KapiPanelGroup.js +66 -65
  203. package/dist/components/navigation/KapiTabs.d.ts +12 -0
  204. package/dist/components/navigation/KapiTabs.js +87 -71
  205. package/dist/components/navigation/KapiToc.d.ts +48 -0
  206. package/dist/components/navigation/KapiToc.js +66 -0
  207. package/dist/components/navigation/KapiTree.js +10 -10
  208. package/dist/components/navigation/MiniNavItem.d.ts +7 -2
  209. package/dist/components/navigation/MiniNavItem.js +41 -36
  210. package/dist/components/navigation/breadcrumbLogic.d.ts +4 -2
  211. package/dist/components/navigation/breadcrumbLogic.js +1 -1
  212. package/dist/components/navigation/index.d.ts +3 -0
  213. package/dist/components/navigation/navLink.d.ts +21 -0
  214. package/dist/components/navigation/navLink.js +26 -0
  215. package/dist/components/navigation/navLinkLogic.d.ts +18 -0
  216. package/dist/components/navigation/navLinkLogic.js +22 -0
  217. package/dist/components/navigation/tocLogic.d.ts +35 -0
  218. package/dist/components/navigation/tocLogic.js +11 -0
  219. package/dist/components/navigation/tocSlots.d.ts +8 -0
  220. package/dist/components/navigation/tocSlots.js +11 -0
  221. package/dist/components/overlays/KapiCommandPalette.js +6 -6
  222. package/dist/components/overlays/KapiContextMenu.d.ts +8 -0
  223. package/dist/components/overlays/KapiContextMenu.js +5 -5
  224. package/dist/components/overlays/KapiMenuButton.js +7 -7
  225. package/dist/components/overlays/KapiModal.d.ts +9 -0
  226. package/dist/components/overlays/KapiModal.js +79 -77
  227. package/dist/components/overlays/KapiOffcanvas.js +24 -24
  228. package/dist/components/overlays/KapiPhotoView.js +10 -10
  229. package/dist/components/overlays/KapiPopover.js +6 -6
  230. package/dist/components/overlays/KapiShapeSheet.js +4 -4
  231. package/dist/components/overlays/KapiTooltip.js +18 -18
  232. package/dist/components/overlays/index.d.ts +1 -1
  233. package/dist/components/overlays/menuList.js +127 -117
  234. package/dist/components/overlays/modalSlots.d.ts +11 -0
  235. package/dist/components/overlays/modalSlots.js +14 -0
  236. package/dist/components/slotCatalog.d.ts +123 -0
  237. package/dist/components/slotCatalog.js +27 -0
  238. package/dist/components/slotsLogic.d.ts +34 -0
  239. package/dist/components/slotsLogic.js +18 -0
  240. package/dist/components/tone.d.ts +26 -0
  241. package/dist/components/tone.js +15 -14
  242. package/dist/css/base.css +1 -1
  243. package/dist/css/components/data/KapiEventCalendar.css +1 -1
  244. package/dist/css/components/data/KapiTable.css +1 -1
  245. package/dist/css/components/display/KapiAnnotation.css +1 -1
  246. package/dist/css/components/display/KapiCodeBlock.css +1 -0
  247. package/dist/css/components/display/KapiDiff.css +1 -0
  248. package/dist/css/components/display/display.css +1 -1
  249. package/dist/css/components/display/typography.css +1 -0
  250. package/dist/css/components/feedback/feedback.css +1 -1
  251. package/dist/css/components/inputs/KapiButton.css +1 -1
  252. package/dist/css/components/inputs/KapiDatePicker.css +1 -1
  253. package/dist/css/components/inputs/KapiPinInput.css +1 -0
  254. package/dist/css/components/inputs/KapiSelect.css +1 -1
  255. package/dist/css/components/inputs/inputsExtra.css +1 -1
  256. package/dist/css/components/layout/KapiAccessCard.css +1 -1
  257. package/dist/css/components/layout/KapiBox.css +1 -0
  258. package/dist/css/components/layout/KapiCollapse.css +1 -0
  259. package/dist/css/components/layout/KapiDivider.css +1 -1
  260. package/dist/css/components/layout/KapiRail.css +1 -1
  261. package/dist/css/components/layout/gridSpan.css +1 -0
  262. package/dist/css/components/navigation/KapiToc.css +1 -0
  263. package/dist/css/components/navigation/navigation.css +1 -1
  264. package/dist/hooks/asyncResourceLogic.d.ts +11 -0
  265. package/dist/hooks/asyncResourceLogic.js +4 -0
  266. package/dist/hooks/densityLogic.d.ts +15 -0
  267. package/dist/hooks/densityLogic.js +4 -0
  268. package/dist/hooks/index.d.ts +7 -0
  269. package/dist/hooks/themeColorsLogic.d.ts +19 -0
  270. package/dist/hooks/themeColorsLogic.js +4 -2
  271. package/dist/hooks/themeDeriveLogic.d.ts +16 -0
  272. package/dist/hooks/themeDeriveLogic.js +27 -17
  273. package/dist/hooks/toneFamilyLogic.d.ts +146 -0
  274. package/dist/hooks/toneFamilyLogic.js +164 -0
  275. package/dist/hooks/useAsyncResource.d.ts +45 -0
  276. package/dist/hooks/useAsyncResource.js +24 -0
  277. package/dist/hooks/useKapiTheme.d.ts +16 -3
  278. package/dist/hooks/useKapiTheme.js +130 -117
  279. package/dist/hooks/useToneFamilies.d.ts +40 -0
  280. package/dist/hooks/useToneFamilies.js +50 -0
  281. package/dist/index.d.ts +3 -1
  282. package/dist/index.js +227 -204
  283. package/dist/kapi.css +1 -1
  284. package/dist/kapi.layered.css +1 -1
  285. package/dist/logic.d.ts +41 -0
  286. package/dist/logic.js +42 -0
  287. package/dist/styles/rawHeights.d.ts +8 -0
  288. 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
- /** Si se pasa, se dibuja un enlace real `<a>` en vez de un botón. */
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
- /** Destino en otro sistema: agrega el ícono ↗ (sólo con `href`). */
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 { useKapiPanelMini as a } from "./panelMini.js";
11
- import { MiniNavItem as o } from "./MiniNavItem.js";
12
- import { activeIdIn as s } from "./activeItemLogic.js";
13
- import { formatCount as c, panelGroupClasses as l } from "./panelGroupLogic.js";
14
- import { useId as u } from "react";
15
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
16
- import { ChevronRight as p, ExternalLink as m } from "lucide-react";
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 h = ({ value: e }) => {
19
- let t = c(e);
20
- return t === null ? null : /* @__PURE__ */ d("span", {
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
- }, g = ({ item: e, active: t, onSelect: n, newTabLabel: i }) => {
25
- let a = `kapi-ctxitem${t ? " kapi-ctxitem--on" : ""}`, o = /* @__PURE__ */ f("span", {
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 === void 0 ? /* @__PURE__ */ f("button", {
30
- type: "button",
31
- className: a,
32
- "aria-current": t ? "page" : void 0,
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
- onClick: () => n?.(e.id),
35
- children: [
36
- o,
37
- /* @__PURE__ */ d(r, {
38
- value: e.badge,
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__ */ d(h, { value: e.count }),
61
- e.external && /* @__PURE__ */ d(m, {
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__ */ d("span", {
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 _({ label: c, count: m, badge: _, badgeTone: v, 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 }) {
74
- let N = e("link", n, M), P = u(), F = `${P}-body`, I = `${P}-head`, [L, R] = t(w, T, E), z = () => R(!L), { mini: B, expand: V } = a();
75
- return B ? /* @__PURE__ */ d("div", {
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: l({
78
+ className: u({
78
79
  open: !1,
79
80
  className: D
80
81
  }),
81
82
  style: O,
82
83
  id: k,
83
- children: /* @__PURE__ */ d(o, {
84
- label: c,
84
+ children: /* @__PURE__ */ p(s, {
85
+ label: a,
85
86
  icon: b,
86
- active: s(x, S) !== null,
87
- badge: _,
88
- badgeTone: v,
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__ */ f("div", {
95
+ }) : /* @__PURE__ */ m("div", {
95
96
  ref: A,
96
- className: l({
97
+ className: u({
97
98
  open: L,
98
99
  className: D
99
100
  }),
100
101
  style: O,
101
102
  id: k,
102
- children: [/* @__PURE__ */ f("button", {
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__ */ f("span", {
111
+ /* @__PURE__ */ m("span", {
111
112
  className: "kapi-panelgroup__label",
112
- children: [b, c]
113
+ children: [b, a]
113
114
  }),
114
- /* @__PURE__ */ d(r, {
115
- value: _,
116
- tone: v,
115
+ /* @__PURE__ */ p(r, {
116
+ value: f,
117
+ tone: g,
117
118
  label: y,
118
119
  max: 999
119
120
  }),
120
- /* @__PURE__ */ d(h, { value: m }),
121
- /* @__PURE__ */ d(p, {
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__ */ d("div", {
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__ */ d("div", {
136
+ children: /* @__PURE__ */ p("div", {
136
137
  className: "kapi-panelgroup__clip",
137
- children: /* @__PURE__ */ d(i, {
138
- active: s(x, S),
139
- children: x.map((e) => /* @__PURE__ */ d(g, {
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 { _ as KapiPanelGroup };
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 { useKapiFormatLocale as t } from "../locale/KapiLocaleProvider.js";
5
- import { useControllableState as n } from "../../hooks/useControllableState.js";
6
- import { logicalKeyOf as r } from "../../hooks/directionLogic.js";
7
- import { useDuplicateValueWarning as i, useMutedControlWarning as a } from "../inputs/misuseWarnings.js";
8
- import { useMergedRefs as o } from "../../hooks/mergeRefs.js";
9
- import { useSlidingIndicator as s } from "../../hooks/useSlidingIndicator.js";
10
- import { formatCount as c } from "../../hooks/numberFormatLogic.js";
11
- import { useScrollEdges as l } from "../../hooks/useScrollEdges.js";
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 u, tabClasses as d, tabId as f, tabPanelId as p } from "./tabsLogic.js";
14
- import { useCallback as m, useId as h, useLayoutEffect as g, useMemo as _, useRef as v } from "react";
15
- import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
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 S = [];
18
- function C({ items: C, tabs: w, value: T, defaultValue: E, onChange: D, className: O, idBase: k, disabled: A = !1, size: j = "md", onKeyDown: M, ref: N, ...P }) {
19
- let F = t(), I = C ?? w ?? S, L = h(), R = k ?? L, z = v({}), [B, V] = n(T, () => E ?? I[0]?.id, D), H = _(() => I.map((e) => e.id), [I]);
20
- i("KapiTabs", H), a("KapiTabs", {
21
- controlled: T !== void 0,
22
- hasOnChange: !!D,
23
- disabled: A
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: U, indicatorRef: W } = s({
26
- active: B ?? null,
27
- deps: [I],
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: G, edges: K, reveal: q } = l({ axis: "x" }), J = m((e) => {
30
- U.current = e, G.current = e;
31
- }, [U, G]), Y = o(J, N), X = v(!1);
32
- g(() => {
33
- let e = U.current?.querySelector("[role=\"tab\"][aria-selected=\"true\"]");
34
- e && q(e, { instant: !X.current }), X.current = !0;
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
- B,
37
- U,
38
- q
37
+ H,
38
+ G,
39
+ Y
39
40
  ]);
40
- let Z = (e) => A || I.some((t) => t.id === e && t.disabled === !0), Q = B !== void 0 && I.some((e) => e.id === B) && !Z(B) ? B : I.find((e) => !Z(e.id))?.id, $ = (e) => {
41
- if (M?.(e), e.defaultPrevented || B === void 0) return;
42
- let t = u(I.map((e) => e.id), B, r(e), Z);
43
- t !== void 0 && (e.preventDefault(), V(t), z.current[t]?.focus());
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__ */ x("div", {
46
- ...P,
47
- ref: Y,
48
- className: e("kapi-tabs", "kapi-fade-x", j === "sm" && "kapi-tabs--sm", O),
49
- "data-edge-start": K.start ? "" : void 0,
50
- "data-edge-end": K.end ? "" : void 0,
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": A || void 0,
53
- onKeyDown: $,
54
- children: [/* @__PURE__ */ b("span", {
55
- ref: W,
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
- }), I.map((e) => {
59
- let t = e.id === B;
60
- return /* @__PURE__ */ x("button", {
61
- ref: (t) => {
62
- z.current[e.id] = t;
63
- },
64
- type: "button",
65
- id: f(R, e.id),
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": k ? p(k, e.id) : void 0,
68
- "aria-selected": t,
69
- tabIndex: e.id === Q ? 0 : -1,
70
- disabled: Z(e.id) || void 0,
71
- className: d(t),
72
- onClick: () => V(e.id),
73
- children: [
74
- e.icon,
75
- e.label,
76
- e.count !== void 0 && /* @__PURE__ */ x(y, { children: [" ", /* @__PURE__ */ b("span", {
77
- className: "kapi-tabs__count",
78
- children: c(e.count, F)
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 w({ idBase: e, tabId: t, active: n, keepMounted: r = !1, className: i, style: a, children: o, ref: s }) {
86
- return /* @__PURE__ */ b("div", {
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: p(e, t),
105
+ id: m(e, t),
90
106
  role: "tabpanel",
91
- "aria-labelledby": f(e, t),
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 { w as KapiTabPanel, C as KapiTabs };
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 { useLabels as t } from "../locale/KapiLocaleProvider.js";
5
- import { isTypeaheadKey as n } from "../overlays/menuKeyboardLogic.js";
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 { logicalKeyOf as i } from "../../hooks/directionLogic.js";
8
- import { useMergedRefs as a } from "../../hooks/mergeRefs.js";
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 = t("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, {
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 = a(A, J), Ee = f(() => E ? B.map((e) => e.node.id) : void 0, [E, B]), Y = s({
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 r = e.target.getAttribute("role") === "treeitem", a = e.key === "Enter" || e.key === " ";
61
- if (!r && (a || n(e.key))) return;
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: i(e),
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 (!n(e.key)) return;
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));