@kapiuara/ui 0.15.2 → 0.16.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 (145) hide show
  1. package/LICENSE +19 -15
  2. package/README.md +338 -6
  3. package/dist/components/data/KapiDataTable.d.ts +1 -1
  4. package/dist/components/data/KapiDataTable.js +22 -22
  5. package/dist/components/data/KapiPaginationFooter.js +1 -1
  6. package/dist/components/data/KapiSheet.d.ts +105 -0
  7. package/dist/components/data/KapiSheet.js +75 -0
  8. package/dist/components/data/KapiTable.d.ts +2 -2
  9. package/dist/components/data/KapiTable.js +347 -329
  10. package/dist/components/data/KapiTableFooter.d.ts +22 -0
  11. package/dist/components/data/KapiTableFooter.js +55 -0
  12. package/dist/components/data/KapiTableRow.js +53 -52
  13. package/dist/components/data/KapiTableToolbar.d.ts +4 -2
  14. package/dist/components/data/KapiTableToolbar.js +71 -69
  15. package/dist/components/data/index.d.ts +3 -1
  16. package/dist/components/data/tableCells.d.ts +5 -4
  17. package/dist/components/data/tableCells.js +48 -43
  18. package/dist/components/data/tableLogic.d.ts +2 -0
  19. package/dist/components/data/tableLogic.js +66 -66
  20. package/dist/components/data/tableSlots.d.ts +9 -0
  21. package/dist/components/data/tableSlots.js +12 -0
  22. package/dist/components/data/tableSpanLogic.d.ts +35 -0
  23. package/dist/components/data/tableSpanLogic.js +47 -0
  24. package/dist/components/data/tableTypes.d.ts +66 -1
  25. package/dist/components/data/useTableSelection.d.ts +4 -2
  26. package/dist/components/data/useTableSelection.js +27 -23
  27. package/dist/components/display/KapiAnchor.d.ts +36 -0
  28. package/dist/components/display/KapiAnchor.js +36 -0
  29. package/dist/components/display/KapiBadge.d.ts +6 -5
  30. package/dist/components/display/KapiBadge.js +25 -19
  31. package/dist/components/display/KapiText.d.ts +43 -0
  32. package/dist/components/display/KapiText.js +33 -0
  33. package/dist/components/display/KapiTitle.d.ts +33 -0
  34. package/dist/components/display/KapiTitle.js +29 -0
  35. package/dist/components/display/index.d.ts +7 -0
  36. package/dist/components/display/textLogic.d.ts +32 -0
  37. package/dist/components/display/textLogic.js +19 -0
  38. package/dist/components/feedback/KapiAlert.d.ts +8 -4
  39. package/dist/components/feedback/KapiAlert.js +39 -34
  40. package/dist/components/inputs/KapiButton.d.ts +7 -4
  41. package/dist/components/inputs/KapiButton.js +47 -42
  42. package/dist/components/inputs/KapiSelect.d.ts +12 -0
  43. package/dist/components/inputs/KapiSelect.js +215 -212
  44. package/dist/components/inputs/KapiSelectMenu.d.ts +4 -2
  45. package/dist/components/inputs/KapiSelectMenu.js +131 -133
  46. package/dist/components/inputs/fieldLogic.d.ts +2 -2
  47. package/dist/components/inputs/index.d.ts +1 -1
  48. package/dist/components/inputs/selectSlots.d.ts +24 -0
  49. package/dist/components/inputs/selectSlots.js +27 -0
  50. package/dist/components/layout/KapiBox.d.ts +31 -0
  51. package/dist/components/layout/KapiBox.js +26 -0
  52. package/dist/components/layout/KapiCard.d.ts +16 -4
  53. package/dist/components/layout/KapiCard.js +46 -34
  54. package/dist/components/layout/KapiCenter.d.ts +13 -0
  55. package/dist/components/layout/KapiCenter.js +23 -0
  56. package/dist/components/layout/KapiCol.d.ts +22 -0
  57. package/dist/components/layout/KapiCol.js +23 -0
  58. package/dist/components/layout/KapiGrid.d.ts +29 -3
  59. package/dist/components/layout/KapiGrid.js +39 -17
  60. package/dist/components/layout/KapiPageHeader.d.ts +10 -1
  61. package/dist/components/layout/KapiPageHeader.js +82 -80
  62. package/dist/components/layout/KapiPanelParts.d.ts +11 -2
  63. package/dist/components/layout/KapiPanelParts.js +73 -56
  64. package/dist/components/layout/KapiRail.d.ts +10 -1
  65. package/dist/components/layout/KapiRail.js +123 -120
  66. package/dist/components/layout/KapiRoot.d.ts +35 -5
  67. package/dist/components/layout/KapiRoot.js +54 -39
  68. package/dist/components/layout/KapiShell.d.ts +36 -3
  69. package/dist/components/layout/KapiShell.js +53 -50
  70. package/dist/components/layout/cardSlots.d.ts +9 -0
  71. package/dist/components/layout/cardSlots.js +12 -0
  72. package/dist/components/layout/gridSpanLogic.d.ts +46 -0
  73. package/dist/components/layout/gridSpanLogic.js +39 -0
  74. package/dist/components/layout/index.d.ts +11 -4
  75. package/dist/components/layout/layoutPrimitives.d.ts +11 -0
  76. package/dist/components/layout/layoutPrimitives.js +12 -1
  77. package/dist/components/layout/pageHeaderSlots.d.ts +12 -0
  78. package/dist/components/layout/pageHeaderSlots.js +15 -0
  79. package/dist/components/layout/railLogic.d.ts +16 -3
  80. package/dist/components/layout/railSlots.d.ts +12 -0
  81. package/dist/components/layout/railSlots.js +15 -0
  82. package/dist/components/layout/shellSlots.d.ts +6 -0
  83. package/dist/components/layout/shellSlots.js +9 -0
  84. package/dist/components/layout/useGridBreakpoint.d.ts +12 -0
  85. package/dist/components/layout/useGridBreakpoint.js +35 -0
  86. package/dist/components/navigation/KapiBreadcrumb.d.ts +18 -2
  87. package/dist/components/navigation/KapiBreadcrumb.js +23 -16
  88. package/dist/components/navigation/KapiContextPanel.d.ts +17 -4
  89. package/dist/components/navigation/KapiContextPanel.js +151 -135
  90. package/dist/components/navigation/KapiPanelGroup.d.ts +16 -4
  91. package/dist/components/navigation/KapiPanelGroup.js +66 -65
  92. package/dist/components/navigation/KapiTabs.d.ts +12 -0
  93. package/dist/components/navigation/KapiTabs.js +87 -71
  94. package/dist/components/navigation/MiniNavItem.d.ts +7 -2
  95. package/dist/components/navigation/MiniNavItem.js +41 -36
  96. package/dist/components/navigation/breadcrumbLogic.d.ts +4 -2
  97. package/dist/components/navigation/breadcrumbLogic.js +1 -1
  98. package/dist/components/navigation/navLink.d.ts +21 -0
  99. package/dist/components/navigation/navLink.js +26 -0
  100. package/dist/components/navigation/navLinkLogic.d.ts +18 -0
  101. package/dist/components/navigation/navLinkLogic.js +22 -0
  102. package/dist/components/overlays/KapiContextMenu.d.ts +8 -0
  103. package/dist/components/overlays/KapiModal.d.ts +9 -0
  104. package/dist/components/overlays/KapiModal.js +77 -75
  105. package/dist/components/overlays/index.d.ts +1 -1
  106. package/dist/components/overlays/menuList.js +123 -113
  107. package/dist/components/overlays/modalSlots.d.ts +11 -0
  108. package/dist/components/overlays/modalSlots.js +14 -0
  109. package/dist/components/slotCatalog.d.ts +90 -0
  110. package/dist/components/slotCatalog.js +19 -0
  111. package/dist/components/slotsLogic.d.ts +34 -0
  112. package/dist/components/slotsLogic.js +18 -0
  113. package/dist/components/tone.d.ts +26 -0
  114. package/dist/components/tone.js +15 -14
  115. package/dist/css/base.css +1 -1
  116. package/dist/css/components/data/KapiEventCalendar.css +1 -1
  117. package/dist/css/components/data/KapiTable.css +1 -1
  118. package/dist/css/components/display/display.css +1 -1
  119. package/dist/css/components/display/typography.css +1 -0
  120. package/dist/css/components/feedback/feedback.css +1 -1
  121. package/dist/css/components/inputs/KapiButton.css +1 -1
  122. package/dist/css/components/inputs/KapiDatePicker.css +1 -1
  123. package/dist/css/components/layout/KapiBox.css +1 -0
  124. package/dist/css/components/layout/KapiRail.css +1 -1
  125. package/dist/css/components/layout/gridSpan.css +1 -0
  126. package/dist/css/components/navigation/navigation.css +1 -1
  127. package/dist/hooks/densityLogic.d.ts +15 -0
  128. package/dist/hooks/densityLogic.js +4 -0
  129. package/dist/hooks/index.d.ts +4 -0
  130. package/dist/hooks/themeColorsLogic.d.ts +19 -0
  131. package/dist/hooks/themeColorsLogic.js +4 -2
  132. package/dist/hooks/themeDeriveLogic.d.ts +16 -0
  133. package/dist/hooks/themeDeriveLogic.js +27 -17
  134. package/dist/hooks/toneFamilyLogic.d.ts +122 -0
  135. package/dist/hooks/toneFamilyLogic.js +151 -0
  136. package/dist/hooks/useKapiTheme.d.ts +8 -2
  137. package/dist/hooks/useKapiTheme.js +116 -103
  138. package/dist/hooks/useToneFamilies.d.ts +30 -0
  139. package/dist/hooks/useToneFamilies.js +46 -0
  140. package/dist/index.d.ts +3 -1
  141. package/dist/index.js +213 -204
  142. package/dist/kapi.css +1 -1
  143. package/dist/kapi.layered.css +1 -1
  144. package/dist/styles/rawHeights.d.ts +8 -0
  145. package/package.json +4 -4
@@ -1,38 +1,40 @@
1
1
  "use client";
2
2
  import "#kapi-css/components/inputs/KapiSelect.css";
3
3
  import { assignRef as e, fieldControlProps as t, focusLeaves as n, resolveReadOnly as r } from "./fieldLogic.js";
4
- import { useOwnField as i } from "./ownField.js";
5
- import { resolveGroupSize as a, selectControlId as ee } from "./inputGroupLogic.js";
6
- import { useKapiInputGroup as te } from "./KapiInputGroup.js";
7
- import { useLabels as ne } from "../locale/KapiLocaleProvider.js";
8
- import { useRangeSelect as re } from "../../hooks/useRangeSelect.js";
9
- import { SELECT_MENU_PLACEMENT as ie, displayLabel as ae, filterOptions as oe, findTypeaheadIndex as se, flattenOptions as ce, indexEntries as le, initialActiveIndex as ue, nextActiveIndex as o, normalizeValue as de, resolveChipLabel as fe, resolveVirtualMenu as pe, toggleValue as me, withUnknownValues as he } from "./selectLogic.js";
10
- import { useControllableState as ge } from "../../hooks/useControllableState.js";
11
- import { resolveKapiRoot as _e } from "../../hooks/kapiRoot.js";
12
- import { isCreateRow as ve, menuItems as ye, withCreated as be } from "./asyncSelectLogic.js";
4
+ import { useOwnField as ee } from "./ownField.js";
5
+ import { resolveGroupSize as i, selectControlId as te } from "./inputGroupLogic.js";
6
+ import { useKapiInputGroup as ne } from "./KapiInputGroup.js";
7
+ import { useLabels as re } from "../locale/KapiLocaleProvider.js";
8
+ import { useRangeSelect as ie } from "../../hooks/useRangeSelect.js";
9
+ import { SELECT_MENU_PLACEMENT as ae, displayLabel as oe, filterOptions as se, findTypeaheadIndex as ce, flattenOptions as le, indexEntries as ue, initialActiveIndex as de, nextActiveIndex as fe, normalizeValue as pe, resolveChipLabel as me, resolveVirtualMenu as he, toggleValue as ge, withUnknownValues as _e } from "./selectLogic.js";
10
+ import { useControllableState as ve } from "../../hooks/useControllableState.js";
11
+ import { resolveKapiRoot as ye } from "../../hooks/kapiRoot.js";
12
+ import { isCreateRow as be, menuItems as a, withCreated as xe } from "./asyncSelectLogic.js";
13
13
  /* empty css */
14
- import { usePlacement as xe } from "../../hooks/usePlacement.js";
15
- import { useDuplicateValueWarning as Se, useMutedControlWarning as Ce } from "./misuseWarnings.js";
16
- import { useFormReset as we } from "../../hooks/useFormReset.js";
17
- import { useMergedRefs as Te } from "../../hooks/mergeRefs.js";
18
- import { useOutsidePress as Ee } from "../../hooks/useOutsidePress.js";
19
- import { useTypeahead as De } from "../../hooks/useTypeahead.js";
20
- import { selectKeyAction as Oe } from "./selectKeyLogic.js";
21
- import { useSelectSource as ke } from "./useSelectSource.js";
22
- import { useSelectCreate as Ae } from "./useSelectCreate.js";
23
- import { KapiSelectMenu as je } from "./KapiSelectMenu.js";
24
- import { useCallback as Me, useEffect as Ne, useId as Pe, useLayoutEffect as Fe, useMemo as s, useRef as c, useState as l } from "react";
25
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
26
- import { ChevronDown as Ie, X as Le } from "lucide-react";
14
+ import { usePlacement as Se } from "../../hooks/usePlacement.js";
15
+ import { useDuplicateValueWarning as Ce, useMutedControlWarning as we } from "./misuseWarnings.js";
16
+ import { useFormReset as Te } from "../../hooks/useFormReset.js";
17
+ import { useMergedRefs as Ee } from "../../hooks/mergeRefs.js";
18
+ import { useOutsidePress as De } from "../../hooks/useOutsidePress.js";
19
+ import { useTypeahead as Oe } from "../../hooks/useTypeahead.js";
20
+ import { selectKeyAction as ke } from "./selectKeyLogic.js";
21
+ import { useSelectSource as Ae } from "./useSelectSource.js";
22
+ import { useSelectCreate as je } from "./useSelectCreate.js";
23
+ import { slot as o } from "../slotsLogic.js";
24
+ import { SELECT_SLOTS as s } from "./selectSlots.js";
25
+ import { KapiSelectMenu as Me } from "./KapiSelectMenu.js";
26
+ import { useCallback as Ne, useEffect as Pe, useId as Fe, useLayoutEffect as Ie, useMemo as c, useRef as l, useState as u } from "react";
27
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
28
+ import { ChevronDown as Le, X as Re } from "lucide-react";
27
29
  //#region src/components/inputs/KapiSelect.tsx
28
- var Re = 6, ze = [], f = "\0kapisel-all", p = (e, t) => `${e} “${t.trim()}”`, Be = ({ size: e = "md", open: t, disabled: n, readOnly: r, multi: i, chip: a, className: ee }) => [
29
- ...a ? ["kapi-filterchip", "kapisel--chip"] : ["kapisel", `kapisel--${e}`],
30
+ var ze = 6, Be = [], p = "\0kapisel-all", Ve = (e, t) => `${e} “${t.trim()}”`, He = ({ size: e = "md", open: t, disabled: n, readOnly: r, multi: ee, chip: i, className: te }) => [
31
+ ...i ? ["kapi-filterchip", "kapisel--chip"] : ["kapisel", `kapisel--${e}`],
30
32
  t && "kapisel--open",
31
33
  n && "kapisel--disabled",
32
34
  r && "kapisel--readonly",
33
- i && "kapisel--multi",
34
- ee
35
- ].filter(Boolean).join(" "), Ve = {
35
+ ee && "kapisel--multi",
36
+ te
37
+ ].filter(Boolean).join(" "), Ue = {
36
38
  clear: "Limpiar selección",
37
39
  remove: "Quitar",
38
40
  placeholder: "Seleccionar…",
@@ -43,133 +45,133 @@ var Re = 6, ze = [], f = "\0kapisel-all", p = (e, t) => `${e} “${t.trim()}”`
43
45
  create: "Crear",
44
46
  all: "Todas"
45
47
  }, m = (m) => {
46
- let { options: h = ze, loadOptions: He, loadDelay: Ue = 300, reloadKey: We, onCreate: Ge, value: Ke, defaultValue: qe, multiple: g = !1, variant: Je = "field", icon: Ye, label: Xe, chipLabel: Ze, help: Qe, fieldClassName: $e, clearable: et = !1, disabled: _ = !1, invalid: tt, required: nt, readOnly: rt, loading: v = !1, placeholder: it, size: at, renderOption: ot, renderValue: st, virtual: ct, emptyMessage: lt, noOptionsMessage: ut, loadingMessage: dt, name: y, id: ft, className: pt, style: mt, "aria-label": ht, labels: gt, ref: b, onBlur: _t } = m, x = Je === "chip", S = m.searchable ?? !x, vt = m.onChange, C = ne("select", Ve, gt), yt = it ?? C.placeholder, w = g ? void 0 : m.allOption, T = w !== void 0 && w !== !1, bt = typeof w == "string" ? w : C.all, E = s(() => ({
47
- value: f,
48
- label: bt
49
- }), [bt]), xt = s(() => T && !(He && h.length === 0) ? [E, ...h] : h, [
48
+ let { options: h = Be, loadOptions: We, loadDelay: Ge = 300, reloadKey: Ke, onCreate: qe, value: Je, defaultValue: Ye, multiple: g = !1, variant: Xe = "field", icon: Ze, label: Qe, chipLabel: $e, help: et, fieldClassName: tt, clearable: nt = !1, disabled: _ = !1, invalid: rt, required: it, readOnly: at, loading: v = !1, placeholder: ot, size: st, renderOption: ct, renderValue: lt, virtual: ut, emptyMessage: dt, noOptionsMessage: ft, loadingMessage: pt, name: mt, id: ht, className: gt, classNames: y, style: _t, "aria-label": vt, labels: yt, ref: b, onBlur: bt } = m, x = Xe === "chip", S = m.searchable ?? !x, xt = m.onChange, C = re("select", Ue, yt), St = ot ?? C.placeholder, w = g ? void 0 : m.allOption, T = w !== void 0 && w !== !1, Ct = typeof w == "string" ? w : C.all, E = c(() => ({
49
+ value: p,
50
+ label: Ct
51
+ }), [Ct]), wt = c(() => T && !(We && h.length === 0) ? [E, ...h] : h, [
50
52
  T,
51
- He,
53
+ We,
52
54
  h,
53
55
  E
54
- ]), St = lt ?? ut ?? C.noOptions, Ct = dt ?? C.loading, wt = te(), Tt = a(at, wt?.size) ?? "md", { chipLabel: Et, fieldLabel: Dt } = fe({
56
+ ]), Tt = dt ?? ft ?? C.noOptions, Et = pt ?? C.loading, Dt = ne(), Ot = i(st, Dt?.size) ?? "md", { chipLabel: kt, fieldLabel: At } = me({
55
57
  chip: x,
56
- chipLabel: Ze,
57
- label: Xe
58
- }), Ot = i({
59
- id: ft,
60
- label: Dt,
61
- help: Qe,
62
- required: nt,
63
- invalid: tt,
64
- readOnly: rt,
65
- fieldClassName: $e
66
- }), D = Ot.field, O = r(rt, D), kt = ht ?? (x && !D ? Et : void 0), At = Pe(), k = ee({
67
- id: ft,
58
+ chipLabel: $e,
59
+ label: Qe
60
+ }), jt = ee({
61
+ id: ht,
62
+ label: At,
63
+ help: et,
64
+ required: it,
65
+ invalid: rt,
66
+ readOnly: at,
67
+ fieldClassName: tt
68
+ }), D = jt.field, O = r(at, D), Mt = vt ?? (x && !D ? kt : void 0), Nt = Fe(), k = te({
69
+ id: ht,
68
70
  fieldControlId: D?.controlId,
69
- autoId: At,
70
- inGroup: wt !== null
71
- }), jt = `${k}-listbox`, Mt = `${k}-value`, Nt = (e) => `${k}-opt-${e}`, [Pt, Ft, , It] = ge(Ke, () => de(qe, g), vt), Lt = s(() => ce(h).map((e) => e.value), [h]);
72
- Se("KapiSelect", Lt), Ce("KapiSelect", {
73
- controlled: Ke !== void 0,
74
- hasOnChange: !!vt,
71
+ autoId: Nt,
72
+ inGroup: Dt !== null
73
+ }), Pt = `${k}-listbox`, Ft = `${k}-value`, It = (e) => `${k}-opt-${e}`, [Lt, Rt, , zt] = ve(Je, () => pe(Ye, g), xt), Bt = c(() => le(h).map((e) => e.value), [h]);
74
+ Ce("KapiSelect", Bt), we("KapiSelect", {
75
+ controlled: Je !== void 0,
76
+ hasOnChange: !!xt,
75
77
  readOnly: O,
76
78
  disabled: _
77
79
  });
78
- let A = (e) => Ft(T && e === f ? null : e), Rt = de(Pt, g), j = T && Rt === null ? f : Rt, M = j === f, N = s(() => de(j, !0), [j]), [P, F] = l(!1), [I, L] = l(""), [zt, R] = l(-1), z = c(null), Bt = Te(z, we(It)), B = c(null), Vt = c(null), Ht = Me((t) => {
80
+ let A = (e) => Rt(T && e === p ? null : e), Vt = pe(Lt, g), j = T && Vt === null ? p : Vt, M = j === p, N = c(() => pe(j, !0), [j]), [P, F] = u(!1), [I, L] = u(""), [Ht, R] = u(-1), z = l(null), Ut = Ee(z, Te(zt)), B = l(null), Wt = l(null), Gt = Ne((t) => {
79
81
  B.current = t, e(b, t);
80
- }, [b]), Ut = Me((t) => {
81
- Vt.current = t, e(b, t);
82
- }, [b]), V = c(null), Wt = De(500), H = s(() => new Set(N), [N]), Gt = re(), Kt = I.trim(), U = P && !_ && !O, W = ke({
83
- options: xt,
84
- loadOptions: He,
85
- loadDelay: Ue,
86
- reloadKey: We,
87
- creatable: Ge !== void 0,
82
+ }, [b]), Kt = Ne((t) => {
83
+ Wt.current = t, e(b, t);
84
+ }, [b]), V = l(null), qt = Oe(500), Jt = c(() => new Set(N), [N]), Yt = ie(), Xt = I.trim(), H = P && !_ && !O, U = Ae({
85
+ options: wt,
86
+ loadOptions: We,
87
+ loadDelay: Ge,
88
+ reloadKey: Ke,
89
+ creatable: qe !== void 0,
88
90
  searchable: S,
89
91
  query: I,
90
- open: U,
92
+ open: H,
91
93
  current: j,
92
- onLoaded: (e, t) => R(o(-1, "first", ye(e, t, J, p(C.create, t))))
93
- }), { isAsync: qt, filtered: G, asyncLoading: Jt, loadError: Yt } = W, K = s(() => M ? [E] : v ? W.selected : he(W.selected, j), [
94
+ onLoaded: (e, t) => R(fe(-1, "first", a(e, t, J, Ve(C.create, t))))
95
+ }), { isAsync: Zt, filtered: W, asyncLoading: G, loadError: Qt } = U, K = c(() => M ? [E] : v ? U.selected : _e(U.selected, j), [
94
96
  M,
95
97
  E,
96
- W.selected,
98
+ U.selected,
97
99
  v,
98
100
  j
99
- ]), q = Ae({
100
- onCreate: Ge,
101
- open: U,
101
+ ]), q = je({
102
+ onCreate: qe,
103
+ open: H,
102
104
  onSettled: (e, t) => {
103
- e && (W.remember([e]), A(be(j, e.value, g))), I.trim() === t && an(e ? e.value : null);
105
+ e && (U.remember([e]), A(xe(j, e.value, g))), I.trim() === t && cn(e ? e.value : null);
104
106
  }
105
- }), Xt = v || Jt, Zt = Xt || q.creating, J = Ge !== void 0 && S && !v && !q.creating, Y = s(() => ye(G, I, J && !Jt, p(C.create, I)), [
106
- G,
107
+ }), $t = v || G, en = $t || q.creating, J = qe !== void 0 && S && !v && !q.creating, Y = c(() => a(W, I, J && !G, Ve(C.create, I)), [
108
+ W,
107
109
  I,
108
110
  J,
109
- Jt,
111
+ G,
110
112
  C.create
111
- ]), Qt = s(() => le(G), [G]), $t = Y.length > 0 && ve(Y[Y.length - 1]) ? Y[Y.length - 1] : null, X = zt >= 0 && zt < Y.length ? zt : -1, Z = K.length > 0, en = S && I !== "", tn = Xt ? Ct : q.failed ? C.createError : Yt ? C.loadError : Y.length === 0 ? St : null, nn = () => (S ? B.current : Vt.current)?.focus();
112
- Ne(() => {
113
+ ]), tn = c(() => ue(W), [W]), nn = Y.length > 0 && be(Y[Y.length - 1]) ? Y[Y.length - 1] : null, X = Ht >= 0 && Ht < Y.length ? Ht : -1, Z = K.length > 0, rn = S && I !== "", an = $t ? Et : q.failed ? C.createError : Qt ? C.loadError : Y.length === 0 ? Tt : null, on = () => (S ? B.current : Wt.current)?.focus();
114
+ Pe(() => {
113
115
  _ && (F(!1), L(""));
114
116
  }, [_]);
115
- let Q = Me(() => {
117
+ let Q = Ne(() => {
116
118
  F(!1), L(""), R(-1);
117
- }, []), rn = (e = "selected") => {
118
- _ || O || (F(!0), R(ue(Y, N, e)));
119
- }, an = (e) => {
120
- g ? (L(""), R(e === null ? -1 : ue(ce(h), [e], "selected")), B.current?.focus()) : Q();
121
- }, on = (e, t = !1) => {
119
+ }, []), sn = (e = "selected") => {
120
+ _ || O || (F(!0), R(de(Y, N, e)));
121
+ }, cn = (e) => {
122
+ g ? (L(""), R(e === null ? -1 : de(le(h), [e], "selected")), B.current?.focus()) : Q();
123
+ }, ln = (e, t = !1) => {
122
124
  if (e.disabled) return;
123
- if (ve(e)) {
124
- q.create(Kt);
125
+ if (be(e)) {
126
+ q.create(Xt);
125
127
  return;
126
128
  }
127
129
  if (g) {
128
- let n = Y.filter((e) => !ve(e)), r = n.map((e) => e.value), i = new Set(n.filter((e) => !e.disabled).map((e) => e.value)), a = Gt.toggle({
129
- selected: new Set(H),
130
+ let n = Y.filter((e) => !be(e)), r = n.map((e) => e.value), ee = new Set(n.filter((e) => !e.disabled).map((e) => e.value)), i = Yt.toggle({
131
+ selected: new Set(Jt),
130
132
  ids: r,
131
133
  target: e.value,
132
134
  shift: t,
133
- isSelectable: (e) => i.has(e)
135
+ isSelectable: (e) => ee.has(e)
134
136
  });
135
- A([...N.filter((e) => a.has(e)), ...r.filter((e) => a.has(e) && !H.has(e))]), an(e.value);
137
+ A([...N.filter((e) => i.has(e)), ...r.filter((e) => i.has(e) && !Jt.has(e))]), cn(e.value);
136
138
  return;
137
139
  }
138
- let n = me(j, e.value, g);
139
- n === j ? Q() : (A(n), an(e.value));
140
- }, sn = (e) => A(N.filter((t) => t !== e)), cn = () => {
141
- A(g ? [] : null), L(""), nn();
142
- }, { placement: ln, style: un, update: dn } = xe({
143
- open: U,
140
+ let n = ge(j, e.value, g);
141
+ n === j ? Q() : (A(n), cn(e.value));
142
+ }, un = (e) => A(N.filter((t) => t !== e)), dn = () => {
143
+ A(g ? [] : null), L(""), on();
144
+ }, { placement: fn, style: pn, update: mn } = Se({
145
+ open: H,
144
146
  anchor: z,
145
147
  floatingRef: V,
146
- ...ie,
147
- offset: Re
148
+ ...ae,
149
+ offset: ze
148
150
  });
149
- Fe(() => {
150
- U && dn();
151
+ Ie(() => {
152
+ H && mn();
151
153
  }, [
152
- U,
154
+ H,
153
155
  Y.length,
154
- tn,
155
- dn
156
- ]), Ee(U, [z, V], Q), Ne(() => {
157
- if (!U || X < 0) return;
156
+ an,
157
+ mn
158
+ ]), De(H, [z, V], Q), Pe(() => {
159
+ if (!H || X < 0) return;
158
160
  let e = V.current?.querySelector(`[data-kapisel-index="${X}"]`);
159
161
  e && typeof e.scrollIntoView == "function" && e.scrollIntoView({ block: "nearest" });
160
- }, [U, X]);
161
- let fn = (e) => {
162
+ }, [H, X]);
163
+ let hn = (e) => {
162
164
  if (_) return;
163
165
  let t = e.target;
164
- V.current?.contains(t) || (t.closest("[data-kapisel-action]") ? e.preventDefault() : t === B.current ? P || rn() : (e.preventDefault(), nn(), P ? Q() : rn()));
165
- }, pn = (e) => {
166
- L(e), F(!0), q.resetError(), R(qt ? -1 : o(-1, "first", ye(oe(xt, e), e, J, p(C.create, e))));
167
- }, mn = (e) => {
168
- let t = se(Y, Wt(e), P ? X : Y.findIndex((e) => H.has(e.value)));
166
+ V.current?.contains(t) || (t.closest("[data-kapisel-action]") ? e.preventDefault() : t === B.current ? P || sn() : (e.preventDefault(), on(), P ? Q() : sn()));
167
+ }, gn = (e) => {
168
+ L(e), F(!0), q.resetError(), R(Zt ? -1 : fe(-1, "first", a(se(wt, e), e, J, Ve(C.create, e))));
169
+ }, _n = (e) => {
170
+ let t = ce(Y, qt(e), P ? X : Y.findIndex((e) => Jt.has(e.value)));
169
171
  t < 0 || (P || F(!0), R(t));
170
- }, hn = (e) => {
172
+ }, vn = (e) => {
171
173
  if (_ || O) return;
172
- let t = Oe(e, {
174
+ let t = ke(e, {
173
175
  open: P,
174
176
  searchable: S,
175
177
  multiple: g,
@@ -181,210 +183,211 @@ var Re = 6, ze = [], f = "\0kapisel-all", p = (e, t) => `${e} “${t.trim()}”`
181
183
  let { intent: n } = t;
182
184
  switch (n.type) {
183
185
  case "open":
184
- rn(n.edge);
186
+ sn(n.edge);
185
187
  break;
186
188
  case "move":
187
- R(o(X, n.to, Y));
189
+ R(fe(X, n.to, Y));
188
190
  break;
189
191
  case "choose": {
190
192
  let e = X >= 0 ? Y[X] : void 0;
191
- e && on(e);
193
+ e && ln(e);
192
194
  break;
193
195
  }
194
196
  case "close":
195
197
  Q();
196
198
  break;
197
199
  case "removeLast":
198
- sn(N[N.length - 1]);
200
+ un(N[N.length - 1]);
199
201
  break;
200
- case "typeahead": mn(n.key);
202
+ case "typeahead": _n(n.key);
201
203
  }
202
- }, gn = (e) => {
203
- n(e.relatedTarget, z.current, V.current) && (P && Q(), _t?.(e));
204
- }, _n = U ? _e(z.current) : null, vn = wt !== null || x, yn = pe({
205
- virtual: ct,
204
+ }, yn = (e) => {
205
+ n(e.relatedTarget, z.current, V.current) && (P && Q(), bt?.(e));
206
+ }, bn = H ? ye(z.current) : null, xn = Dt !== null || x, Sn = he({
207
+ virtual: ut,
206
208
  count: Y.length,
207
- contentSized: vn,
208
- customRows: ot !== void 0
209
- }), bn = {
209
+ contentSized: xn,
210
+ customRows: ct !== void 0
211
+ }), Cn = {
210
212
  role: "combobox",
211
213
  ...t(D, {
212
214
  id: k,
213
- describedBy: Mt,
214
- invalid: tt,
215
- required: nt,
215
+ describedBy: Ft,
216
+ invalid: rt,
217
+ required: it,
216
218
  labelable: S,
217
- ariaLabel: kt
219
+ ariaLabel: Mt
218
220
  }),
219
221
  "aria-haspopup": "listbox",
220
- "aria-expanded": U,
221
- "aria-controls": U ? jt : void 0,
222
- "aria-activedescendant": U && X >= 0 ? Nt(X) : void 0,
223
- "aria-label": kt,
222
+ "aria-expanded": H,
223
+ "aria-controls": H ? Pt : void 0,
224
+ "aria-activedescendant": H && X >= 0 ? It(X) : void 0,
225
+ "aria-label": Mt,
224
226
  "aria-disabled": _ || void 0,
225
227
  "aria-readonly": O || void 0,
226
- "aria-busy": Zt || void 0
227
- }, $ = st && Z && !M ? st(K) : null, xn = !Z && !en && /* @__PURE__ */ u("span", {
228
- className: "kapisel__placeholder",
228
+ "aria-busy": en || void 0
229
+ }, $ = lt && Z && !M ? lt(K) : null, wn = !Z && !rn && /* @__PURE__ */ d("span", {
230
+ ...o(s, "placeholder", y),
229
231
  "aria-hidden": "true",
230
- children: yt
232
+ children: St
231
233
  });
232
- return Ot.wrap(/* @__PURE__ */ d("div", {
233
- ref: Bt,
234
- className: Be({
235
- size: Tt,
236
- open: U,
234
+ return jt.wrap(/* @__PURE__ */ f("div", {
235
+ ref: Ut,
236
+ ...o(s, "root", y, He({
237
+ size: Ot,
238
+ open: H,
237
239
  disabled: _,
238
240
  readOnly: O,
239
241
  multi: g,
240
242
  chip: x,
241
- className: pt
242
- }),
243
- style: mt,
244
- onMouseDown: fn,
243
+ className: gt
244
+ })),
245
+ style: _t,
246
+ onMouseDown: hn,
245
247
  children: [
246
- x && Ye ? /* @__PURE__ */ u("span", {
247
- className: "kapisel__icon",
248
- children: Ye
248
+ x && Ze ? /* @__PURE__ */ d("span", {
249
+ ...o(s, "icon", y),
250
+ children: Ze
249
251
  }) : null,
250
- x && Et && /* @__PURE__ */ d("span", {
251
- className: "kapisel__chiplabel",
252
+ x && kt && /* @__PURE__ */ f("span", {
253
+ ...o(s, "label", y),
252
254
  "aria-hidden": "true",
253
- children: [Et, ":"]
255
+ children: [kt, ":"]
254
256
  }),
255
- /* @__PURE__ */ d("div", {
256
- className: "kapisel__values",
257
+ /* @__PURE__ */ f("div", {
258
+ ...o(s, "values", y),
257
259
  children: [
258
- g && $ !== null && /* @__PURE__ */ u("span", {
259
- className: "kapisel__single",
260
+ g && $ !== null && /* @__PURE__ */ d("span", {
261
+ ...o(s, "single", y),
260
262
  "aria-hidden": "true",
261
263
  children: $
262
264
  }),
263
- g && $ === null && K.map((e) => /* @__PURE__ */ d("span", {
264
- className: "kapisel__chip",
265
- children: [/* @__PURE__ */ u("span", {
266
- className: "kapisel__chip-label",
265
+ g && $ === null && K.map((e) => /* @__PURE__ */ f("span", {
266
+ ...o(s, "tag", y),
267
+ children: [/* @__PURE__ */ d("span", {
268
+ ...o(s, "tagLabel", y),
267
269
  children: e.label
268
- }), /* @__PURE__ */ u("button", {
270
+ }), /* @__PURE__ */ d("button", {
269
271
  type: "button",
270
272
  tabIndex: -1,
271
273
  "data-kapisel-action": !0,
272
- className: "kapisel__chip-x",
274
+ ...o(s, "tagRemove", y),
273
275
  "aria-label": `${C.remove} ${e.label}`,
274
276
  disabled: _,
275
277
  hidden: O || void 0,
276
- onClick: () => sn(e.value),
277
- children: /* @__PURE__ */ u(Le, {
278
+ onClick: () => un(e.value),
279
+ children: /* @__PURE__ */ d(Re, {
278
280
  size: 12,
279
281
  strokeWidth: 2.6,
280
282
  "aria-hidden": "true"
281
283
  })
282
284
  })]
283
285
  }, e.value)),
284
- S ? /* @__PURE__ */ d("div", {
286
+ S ? /* @__PURE__ */ f("div", {
285
287
  className: "kapisel__inputwrap",
286
288
  children: [
287
- !g && Z && !en && /* @__PURE__ */ u("span", {
288
- className: "kapisel__single",
289
+ !g && Z && !rn && /* @__PURE__ */ d("span", {
290
+ ...o(s, "single", y),
289
291
  "aria-hidden": "true",
290
292
  children: $ ?? K[0]?.label
291
293
  }),
292
- xn,
293
- /* @__PURE__ */ u("input", {
294
- ...bn,
295
- ref: Ht,
294
+ wn,
295
+ /* @__PURE__ */ d("input", {
296
+ ...Cn,
297
+ ref: Gt,
296
298
  type: "text",
297
- className: "kapisel__input",
299
+ ...o(s, "input", y),
298
300
  autoComplete: "off",
299
301
  "aria-autocomplete": "list",
300
302
  disabled: _,
301
303
  readOnly: O || void 0,
302
304
  value: I,
303
- onChange: (e) => pn(e.target.value),
304
- onKeyDown: hn,
305
- onBlur: gn
305
+ onChange: (e) => gn(e.target.value),
306
+ onKeyDown: vn,
307
+ onBlur: yn
306
308
  })
307
309
  ]
308
- }) : /* @__PURE__ */ d("div", {
309
- ...bn,
310
- ref: Ut,
311
- className: "kapisel__combo",
310
+ }) : /* @__PURE__ */ f("div", {
311
+ ...Cn,
312
+ ref: Kt,
313
+ ...o(s, "combo", y),
312
314
  tabIndex: _ ? -1 : 0,
313
- onKeyDown: hn,
314
- onBlur: gn,
315
- children: [!g && Z && /* @__PURE__ */ u("span", {
316
- className: "kapisel__single",
315
+ onKeyDown: vn,
316
+ onBlur: yn,
317
+ children: [!g && Z && /* @__PURE__ */ d("span", {
318
+ ...o(s, "single", y),
317
319
  "aria-hidden": "true",
318
320
  children: $ ?? K[0]?.label
319
- }), xn]
321
+ }), wn]
320
322
  })
321
323
  ]
322
324
  }),
323
- /* @__PURE__ */ u("span", {
324
- id: Mt,
325
+ /* @__PURE__ */ d("span", {
326
+ id: Ft,
325
327
  className: "kapisel__sr",
326
- children: ae(K, yt)
328
+ children: oe(K, St)
327
329
  }),
328
- Zt && /* @__PURE__ */ u("span", {
329
- className: "kapisel__spinner kapi-spinner kapi-spinner--sm",
330
+ en && /* @__PURE__ */ d("span", {
331
+ ...o(s, "spinner", y, "kapi-spinner kapi-spinner--sm"),
330
332
  "aria-hidden": "true"
331
333
  }),
332
- et && Z && !M && !_ && !O && /* @__PURE__ */ u("button", {
334
+ nt && Z && !M && !_ && !O && /* @__PURE__ */ d("button", {
333
335
  type: "button",
334
336
  tabIndex: -1,
335
337
  "data-kapisel-action": !0,
336
- className: "kapisel__clear",
338
+ ...o(s, "clear", y),
337
339
  "aria-label": C.clear,
338
- onClick: cn,
339
- children: /* @__PURE__ */ u(Le, {
340
+ onClick: dn,
341
+ children: /* @__PURE__ */ d(Re, {
340
342
  size: 15,
341
343
  strokeWidth: 2.4,
342
344
  "aria-hidden": "true"
343
345
  })
344
346
  }),
345
- /* @__PURE__ */ u("span", {
346
- className: "kapisel__caret",
347
+ /* @__PURE__ */ d("span", {
348
+ ...o(s, "caret", y),
347
349
  "aria-hidden": "true",
348
- children: /* @__PURE__ */ u(Ie, {
350
+ children: /* @__PURE__ */ d(Le, {
349
351
  size: x ? 14 : 17,
350
352
  strokeWidth: 2.2
351
353
  })
352
354
  }),
353
- y && (g ? N.map((e) => /* @__PURE__ */ u("input", {
355
+ mt && (g ? N.map((e) => /* @__PURE__ */ d("input", {
354
356
  type: "hidden",
355
- name: y,
357
+ name: mt,
356
358
  value: e
357
- }, e)) : /* @__PURE__ */ u("input", {
359
+ }, e)) : /* @__PURE__ */ d("input", {
358
360
  type: "hidden",
359
- name: y,
361
+ name: mt,
360
362
  value: M ? "" : j ?? ""
361
363
  })),
362
- _n && /* @__PURE__ */ u(je, {
363
- root: _n,
364
+ bn && /* @__PURE__ */ d(Me, {
365
+ root: bn,
366
+ classNames: y,
364
367
  ref: V,
365
- side: ln?.side === "top" ? "top" : "bottom",
366
- hug: vn,
367
- style: un,
368
- listboxId: jt,
369
- optionId: Nt,
368
+ side: fn?.side === "top" ? "top" : "bottom",
369
+ hug: xn,
370
+ style: pn,
371
+ listboxId: Pt,
372
+ optionId: It,
370
373
  multiple: g,
371
- "aria-label": kt,
372
- rows: Qt,
373
- createRow: $t,
374
+ "aria-label": Mt,
375
+ rows: tn,
376
+ createRow: nn,
374
377
  createIndex: Y.length - 1,
375
- loading: Xt,
378
+ loading: $t,
376
379
  empty: Y.length === 0,
377
- message: tn,
380
+ message: an,
378
381
  active: X,
379
382
  values: N,
380
- renderOption: ot,
383
+ renderOption: ct,
381
384
  query: I,
382
- virtual: yn,
385
+ virtual: Sn,
383
386
  onHover: R,
384
- onChoose: on
387
+ onChoose: ln
385
388
  })
386
389
  ]
387
390
  }));
388
391
  };
389
392
  //#endregion
390
- export { Ve as DEFAULT_SELECT_LABELS, m as KapiSelect, Be as selectClasses };
393
+ export { Ue as DEFAULT_SELECT_LABELS, m as KapiSelect, He as selectClasses };
@@ -1,7 +1,9 @@
1
1
  import { type CSSProperties, type ReactNode, type Ref } from "react";
2
2
  import { type IndexedRow, type KapiSelectOption } from "./selectLogic.js";
3
- import type { KapiSelectRenderContext } from "./KapiSelect.js";
3
+ import type { KapiSelectClassNames, KapiSelectRenderContext } from "./KapiSelect.js";
4
4
  export type KapiSelectMenuProps<T> = {
5
+ /** `classNames` del select: acá cuentan las partes del menú. */
6
+ classNames?: KapiSelectClassNames | undefined;
5
7
  /** `.kapi` donde se portalea (escapa tablas y overflow). */
6
8
  root: Element;
7
9
  ref: Ref<HTMLDivElement>;
@@ -35,4 +37,4 @@ export type KapiSelectMenuProps<T> = {
35
37
  onChoose: (option: KapiSelectOption<T>, shift: boolean) => void;
36
38
  };
37
39
  /** Listbox portaleado de `KapiSelect`: grupos, fila de crear y mensaje de estado. Solo dibuja. */
38
- export declare const KapiSelectMenu: <T>({ root, ref, side, hug, style, listboxId, optionId, multiple, "aria-label": ariaLabel, rows, createRow, createIndex, loading, empty, message, active, values, renderOption, query, virtual, onHover, onChoose }: KapiSelectMenuProps<T>) => import("react").ReactPortal;
40
+ export declare const KapiSelectMenu: <T>({ classNames, root, ref, side, hug, style, listboxId, optionId, multiple, "aria-label": ariaLabel, rows, createRow, createIndex, loading, empty, message, active, values, renderOption, query, virtual, onHover, onChoose }: KapiSelectMenuProps<T>) => import("react").ReactPortal;