@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.
- package/LICENSE +19 -15
- package/README.md +338 -6
- package/dist/components/data/KapiDataTable.d.ts +1 -1
- package/dist/components/data/KapiDataTable.js +22 -22
- 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/KapiTable.d.ts +2 -2
- package/dist/components/data/KapiTable.js +347 -329
- 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 +5 -4
- package/dist/components/data/tableCells.js +48 -43
- 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 +66 -1
- package/dist/components/data/useTableSelection.d.ts +4 -2
- package/dist/components/data/useTableSelection.js +27 -23
- package/dist/components/display/KapiAnchor.d.ts +36 -0
- package/dist/components/display/KapiAnchor.js +36 -0
- package/dist/components/display/KapiBadge.d.ts +6 -5
- package/dist/components/display/KapiBadge.js +25 -19
- package/dist/components/display/KapiText.d.ts +43 -0
- package/dist/components/display/KapiText.js +33 -0
- package/dist/components/display/KapiTitle.d.ts +33 -0
- package/dist/components/display/KapiTitle.js +29 -0
- package/dist/components/display/index.d.ts +7 -0
- package/dist/components/display/textLogic.d.ts +32 -0
- package/dist/components/display/textLogic.js +19 -0
- package/dist/components/feedback/KapiAlert.d.ts +8 -4
- package/dist/components/feedback/KapiAlert.js +39 -34
- package/dist/components/inputs/KapiButton.d.ts +7 -4
- package/dist/components/inputs/KapiButton.js +47 -42
- package/dist/components/inputs/KapiSelect.d.ts +12 -0
- package/dist/components/inputs/KapiSelect.js +215 -212
- package/dist/components/inputs/KapiSelectMenu.d.ts +4 -2
- package/dist/components/inputs/KapiSelectMenu.js +131 -133
- package/dist/components/inputs/fieldLogic.d.ts +2 -2
- package/dist/components/inputs/index.d.ts +1 -1
- package/dist/components/inputs/selectSlots.d.ts +24 -0
- package/dist/components/inputs/selectSlots.js +27 -0
- 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/KapiGrid.d.ts +29 -3
- package/dist/components/layout/KapiGrid.js +39 -17
- package/dist/components/layout/KapiPageHeader.d.ts +10 -1
- package/dist/components/layout/KapiPageHeader.js +82 -80
- 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 +123 -120
- package/dist/components/layout/KapiRoot.d.ts +35 -5
- package/dist/components/layout/KapiRoot.js +54 -39
- package/dist/components/layout/KapiShell.d.ts +36 -3
- package/dist/components/layout/KapiShell.js +53 -50
- 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 +11 -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/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 +151 -135
- 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/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/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/overlays/KapiContextMenu.d.ts +8 -0
- package/dist/components/overlays/KapiModal.d.ts +9 -0
- package/dist/components/overlays/KapiModal.js +77 -75
- package/dist/components/overlays/index.d.ts +1 -1
- package/dist/components/overlays/menuList.js +123 -113
- package/dist/components/overlays/modalSlots.d.ts +11 -0
- package/dist/components/overlays/modalSlots.js +14 -0
- package/dist/components/slotCatalog.d.ts +90 -0
- package/dist/components/slotCatalog.js +19 -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/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/layout/KapiBox.css +1 -0
- package/dist/css/components/layout/KapiRail.css +1 -1
- package/dist/css/components/layout/gridSpan.css +1 -0
- package/dist/css/components/navigation/navigation.css +1 -1
- package/dist/hooks/densityLogic.d.ts +15 -0
- package/dist/hooks/densityLogic.js +4 -0
- package/dist/hooks/index.d.ts +4 -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 +122 -0
- package/dist/hooks/toneFamilyLogic.js +151 -0
- package/dist/hooks/useKapiTheme.d.ts +8 -2
- package/dist/hooks/useKapiTheme.js +116 -103
- package/dist/hooks/useToneFamilies.d.ts +30 -0
- package/dist/hooks/useToneFamilies.js +46 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +213 -204
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/dist/styles/rawHeights.d.ts +8 -0
- 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
|
|
5
|
-
import { resolveGroupSize as
|
|
6
|
-
import { useKapiInputGroup as
|
|
7
|
-
import { useLabels as
|
|
8
|
-
import { useRangeSelect as
|
|
9
|
-
import { SELECT_MENU_PLACEMENT as
|
|
10
|
-
import { useControllableState as
|
|
11
|
-
import { resolveKapiRoot as
|
|
12
|
-
import { isCreateRow as
|
|
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
|
|
15
|
-
import { useDuplicateValueWarning as
|
|
16
|
-
import { useFormReset as
|
|
17
|
-
import { useMergedRefs as
|
|
18
|
-
import { useOutsidePress as
|
|
19
|
-
import { useTypeahead as
|
|
20
|
-
import { selectKeyAction as
|
|
21
|
-
import { useSelectSource as
|
|
22
|
-
import { useSelectCreate as
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
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
|
|
29
|
-
...
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
].filter(Boolean).join(" "),
|
|
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 =
|
|
47
|
-
value:
|
|
48
|
-
label:
|
|
49
|
-
}), [
|
|
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
|
-
|
|
53
|
+
We,
|
|
52
54
|
h,
|
|
53
55
|
E
|
|
54
|
-
]),
|
|
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:
|
|
57
|
-
label:
|
|
58
|
-
}),
|
|
59
|
-
id:
|
|
60
|
-
label:
|
|
61
|
-
help:
|
|
62
|
-
required:
|
|
63
|
-
invalid:
|
|
64
|
-
readOnly:
|
|
65
|
-
fieldClassName:
|
|
66
|
-
}), D =
|
|
67
|
-
id:
|
|
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:
|
|
70
|
-
inGroup:
|
|
71
|
-
}),
|
|
72
|
-
|
|
73
|
-
controlled:
|
|
74
|
-
hasOnChange: !!
|
|
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) =>
|
|
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]),
|
|
81
|
-
|
|
82
|
-
}, [b]), V =
|
|
83
|
-
options:
|
|
84
|
-
loadOptions:
|
|
85
|
-
loadDelay:
|
|
86
|
-
reloadKey:
|
|
87
|
-
creatable:
|
|
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:
|
|
92
|
+
open: H,
|
|
91
93
|
current: j,
|
|
92
|
-
onLoaded: (e, t) => R(
|
|
93
|
-
}), { isAsync:
|
|
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
|
-
|
|
98
|
+
U.selected,
|
|
97
99
|
v,
|
|
98
100
|
j
|
|
99
|
-
]), q =
|
|
100
|
-
onCreate:
|
|
101
|
-
open:
|
|
101
|
+
]), q = je({
|
|
102
|
+
onCreate: qe,
|
|
103
|
+
open: H,
|
|
102
104
|
onSettled: (e, t) => {
|
|
103
|
-
e && (
|
|
105
|
+
e && (U.remember([e]), A(xe(j, e.value, g))), I.trim() === t && cn(e ? e.value : null);
|
|
104
106
|
}
|
|
105
|
-
}),
|
|
106
|
-
|
|
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
|
-
|
|
111
|
+
G,
|
|
110
112
|
C.create
|
|
111
|
-
]),
|
|
112
|
-
|
|
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 =
|
|
117
|
+
let Q = Ne(() => {
|
|
116
118
|
F(!1), L(""), R(-1);
|
|
117
|
-
}, []),
|
|
118
|
-
_ || O || (F(!0), R(
|
|
119
|
-
},
|
|
120
|
-
g ? (L(""), R(e === null ? -1 :
|
|
121
|
-
},
|
|
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 (
|
|
124
|
-
q.create(
|
|
125
|
+
if (be(e)) {
|
|
126
|
+
q.create(Xt);
|
|
125
127
|
return;
|
|
126
128
|
}
|
|
127
129
|
if (g) {
|
|
128
|
-
let n = Y.filter((e) => !
|
|
129
|
-
selected: new Set(
|
|
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) =>
|
|
135
|
+
isSelectable: (e) => ee.has(e)
|
|
134
136
|
});
|
|
135
|
-
A([...N.filter((e) =>
|
|
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 =
|
|
139
|
-
n === j ? Q() : (A(n),
|
|
140
|
-
},
|
|
141
|
-
A(g ? [] : null), L(""),
|
|
142
|
-
}, { placement:
|
|
143
|
-
open:
|
|
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
|
-
...
|
|
147
|
-
offset:
|
|
148
|
+
...ae,
|
|
149
|
+
offset: ze
|
|
148
150
|
});
|
|
149
|
-
|
|
150
|
-
|
|
151
|
+
Ie(() => {
|
|
152
|
+
H && mn();
|
|
151
153
|
}, [
|
|
152
|
-
|
|
154
|
+
H,
|
|
153
155
|
Y.length,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
]),
|
|
157
|
-
if (!
|
|
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
|
-
}, [
|
|
161
|
-
let
|
|
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 ||
|
|
165
|
-
},
|
|
166
|
-
L(e), F(!0), q.resetError(), R(
|
|
167
|
-
},
|
|
168
|
-
let t =
|
|
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
|
-
},
|
|
172
|
+
}, vn = (e) => {
|
|
171
173
|
if (_ || O) return;
|
|
172
|
-
let t =
|
|
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
|
-
|
|
186
|
+
sn(n.edge);
|
|
185
187
|
break;
|
|
186
188
|
case "move":
|
|
187
|
-
R(
|
|
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 &&
|
|
193
|
+
e && ln(e);
|
|
192
194
|
break;
|
|
193
195
|
}
|
|
194
196
|
case "close":
|
|
195
197
|
Q();
|
|
196
198
|
break;
|
|
197
199
|
case "removeLast":
|
|
198
|
-
|
|
200
|
+
un(N[N.length - 1]);
|
|
199
201
|
break;
|
|
200
|
-
case "typeahead":
|
|
202
|
+
case "typeahead": _n(n.key);
|
|
201
203
|
}
|
|
202
|
-
},
|
|
203
|
-
n(e.relatedTarget, z.current, V.current) && (P && Q(),
|
|
204
|
-
},
|
|
205
|
-
virtual:
|
|
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:
|
|
208
|
-
customRows:
|
|
209
|
-
}),
|
|
209
|
+
contentSized: xn,
|
|
210
|
+
customRows: ct !== void 0
|
|
211
|
+
}), Cn = {
|
|
210
212
|
role: "combobox",
|
|
211
213
|
...t(D, {
|
|
212
214
|
id: k,
|
|
213
|
-
describedBy:
|
|
214
|
-
invalid:
|
|
215
|
-
required:
|
|
215
|
+
describedBy: Ft,
|
|
216
|
+
invalid: rt,
|
|
217
|
+
required: it,
|
|
216
218
|
labelable: S,
|
|
217
|
-
ariaLabel:
|
|
219
|
+
ariaLabel: Mt
|
|
218
220
|
}),
|
|
219
221
|
"aria-haspopup": "listbox",
|
|
220
|
-
"aria-expanded":
|
|
221
|
-
"aria-controls":
|
|
222
|
-
"aria-activedescendant":
|
|
223
|
-
"aria-label":
|
|
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":
|
|
227
|
-
}, $ =
|
|
228
|
-
|
|
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:
|
|
232
|
+
children: St
|
|
231
233
|
});
|
|
232
|
-
return
|
|
233
|
-
ref:
|
|
234
|
-
|
|
235
|
-
size:
|
|
236
|
-
open:
|
|
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:
|
|
242
|
-
}),
|
|
243
|
-
style:
|
|
244
|
-
onMouseDown:
|
|
243
|
+
className: gt
|
|
244
|
+
})),
|
|
245
|
+
style: _t,
|
|
246
|
+
onMouseDown: hn,
|
|
245
247
|
children: [
|
|
246
|
-
x &&
|
|
247
|
-
|
|
248
|
-
children:
|
|
248
|
+
x && Ze ? /* @__PURE__ */ d("span", {
|
|
249
|
+
...o(s, "icon", y),
|
|
250
|
+
children: Ze
|
|
249
251
|
}) : null,
|
|
250
|
-
x &&
|
|
251
|
-
|
|
252
|
+
x && kt && /* @__PURE__ */ f("span", {
|
|
253
|
+
...o(s, "label", y),
|
|
252
254
|
"aria-hidden": "true",
|
|
253
|
-
children: [
|
|
255
|
+
children: [kt, ":"]
|
|
254
256
|
}),
|
|
255
|
-
/* @__PURE__ */
|
|
256
|
-
|
|
257
|
+
/* @__PURE__ */ f("div", {
|
|
258
|
+
...o(s, "values", y),
|
|
257
259
|
children: [
|
|
258
|
-
g && $ !== null && /* @__PURE__ */
|
|
259
|
-
|
|
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__ */
|
|
264
|
-
|
|
265
|
-
children: [/* @__PURE__ */
|
|
266
|
-
|
|
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__ */
|
|
270
|
+
}), /* @__PURE__ */ d("button", {
|
|
269
271
|
type: "button",
|
|
270
272
|
tabIndex: -1,
|
|
271
273
|
"data-kapisel-action": !0,
|
|
272
|
-
|
|
274
|
+
...o(s, "tagRemove", y),
|
|
273
275
|
"aria-label": `${C.remove} ${e.label}`,
|
|
274
276
|
disabled: _,
|
|
275
277
|
hidden: O || void 0,
|
|
276
|
-
onClick: () =>
|
|
277
|
-
children: /* @__PURE__ */
|
|
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__ */
|
|
286
|
+
S ? /* @__PURE__ */ f("div", {
|
|
285
287
|
className: "kapisel__inputwrap",
|
|
286
288
|
children: [
|
|
287
|
-
!g && Z && !
|
|
288
|
-
|
|
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
|
-
|
|
293
|
-
/* @__PURE__ */
|
|
294
|
-
...
|
|
295
|
-
ref:
|
|
294
|
+
wn,
|
|
295
|
+
/* @__PURE__ */ d("input", {
|
|
296
|
+
...Cn,
|
|
297
|
+
ref: Gt,
|
|
296
298
|
type: "text",
|
|
297
|
-
|
|
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) =>
|
|
304
|
-
onKeyDown:
|
|
305
|
-
onBlur:
|
|
305
|
+
onChange: (e) => gn(e.target.value),
|
|
306
|
+
onKeyDown: vn,
|
|
307
|
+
onBlur: yn
|
|
306
308
|
})
|
|
307
309
|
]
|
|
308
|
-
}) : /* @__PURE__ */
|
|
309
|
-
...
|
|
310
|
-
ref:
|
|
311
|
-
|
|
310
|
+
}) : /* @__PURE__ */ f("div", {
|
|
311
|
+
...Cn,
|
|
312
|
+
ref: Kt,
|
|
313
|
+
...o(s, "combo", y),
|
|
312
314
|
tabIndex: _ ? -1 : 0,
|
|
313
|
-
onKeyDown:
|
|
314
|
-
onBlur:
|
|
315
|
-
children: [!g && Z && /* @__PURE__ */
|
|
316
|
-
|
|
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
|
-
}),
|
|
321
|
+
}), wn]
|
|
320
322
|
})
|
|
321
323
|
]
|
|
322
324
|
}),
|
|
323
|
-
/* @__PURE__ */
|
|
324
|
-
id:
|
|
325
|
+
/* @__PURE__ */ d("span", {
|
|
326
|
+
id: Ft,
|
|
325
327
|
className: "kapisel__sr",
|
|
326
|
-
children:
|
|
328
|
+
children: oe(K, St)
|
|
327
329
|
}),
|
|
328
|
-
|
|
329
|
-
|
|
330
|
+
en && /* @__PURE__ */ d("span", {
|
|
331
|
+
...o(s, "spinner", y, "kapi-spinner kapi-spinner--sm"),
|
|
330
332
|
"aria-hidden": "true"
|
|
331
333
|
}),
|
|
332
|
-
|
|
334
|
+
nt && Z && !M && !_ && !O && /* @__PURE__ */ d("button", {
|
|
333
335
|
type: "button",
|
|
334
336
|
tabIndex: -1,
|
|
335
337
|
"data-kapisel-action": !0,
|
|
336
|
-
|
|
338
|
+
...o(s, "clear", y),
|
|
337
339
|
"aria-label": C.clear,
|
|
338
|
-
onClick:
|
|
339
|
-
children: /* @__PURE__ */
|
|
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__ */
|
|
346
|
-
|
|
347
|
+
/* @__PURE__ */ d("span", {
|
|
348
|
+
...o(s, "caret", y),
|
|
347
349
|
"aria-hidden": "true",
|
|
348
|
-
children: /* @__PURE__ */
|
|
350
|
+
children: /* @__PURE__ */ d(Le, {
|
|
349
351
|
size: x ? 14 : 17,
|
|
350
352
|
strokeWidth: 2.2
|
|
351
353
|
})
|
|
352
354
|
}),
|
|
353
|
-
|
|
355
|
+
mt && (g ? N.map((e) => /* @__PURE__ */ d("input", {
|
|
354
356
|
type: "hidden",
|
|
355
|
-
name:
|
|
357
|
+
name: mt,
|
|
356
358
|
value: e
|
|
357
|
-
}, e)) : /* @__PURE__ */
|
|
359
|
+
}, e)) : /* @__PURE__ */ d("input", {
|
|
358
360
|
type: "hidden",
|
|
359
|
-
name:
|
|
361
|
+
name: mt,
|
|
360
362
|
value: M ? "" : j ?? ""
|
|
361
363
|
})),
|
|
362
|
-
|
|
363
|
-
root:
|
|
364
|
+
bn && /* @__PURE__ */ d(Me, {
|
|
365
|
+
root: bn,
|
|
366
|
+
classNames: y,
|
|
364
367
|
ref: V,
|
|
365
|
-
side:
|
|
366
|
-
hug:
|
|
367
|
-
style:
|
|
368
|
-
listboxId:
|
|
369
|
-
optionId:
|
|
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":
|
|
372
|
-
rows:
|
|
373
|
-
createRow:
|
|
374
|
+
"aria-label": Mt,
|
|
375
|
+
rows: tn,
|
|
376
|
+
createRow: nn,
|
|
374
377
|
createIndex: Y.length - 1,
|
|
375
|
-
loading:
|
|
378
|
+
loading: $t,
|
|
376
379
|
empty: Y.length === 0,
|
|
377
|
-
message:
|
|
380
|
+
message: an,
|
|
378
381
|
active: X,
|
|
379
382
|
values: N,
|
|
380
|
-
renderOption:
|
|
383
|
+
renderOption: ct,
|
|
381
384
|
query: I,
|
|
382
|
-
virtual:
|
|
385
|
+
virtual: Sn,
|
|
383
386
|
onHover: R,
|
|
384
|
-
onChoose:
|
|
387
|
+
onChoose: ln
|
|
385
388
|
})
|
|
386
389
|
]
|
|
387
390
|
}));
|
|
388
391
|
};
|
|
389
392
|
//#endregion
|
|
390
|
-
export {
|
|
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;
|