@g4rcez/components 5.0.2 → 5.0.3
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/dist/AnimatePresence-j36AYeOQ.js +181 -0
- package/dist/AnimatePresence-j36AYeOQ.js.map +1 -0
- package/dist/Calendar.es-xICmgvjq.js +23 -0
- package/dist/Calendar.es-xICmgvjq.js.map +1 -0
- package/dist/Funnel.es-DjKVl8Nj.js +23 -0
- package/dist/Funnel.es-DjKVl8Nj.js.map +1 -0
- package/dist/{MotionConfig-DKKYqBH2.js → MotionConfig-CXHoPGbK.js} +2 -2
- package/dist/{MotionConfig-DKKYqBH2.js.map → MotionConfig-CXHoPGbK.js.map} +1 -1
- package/dist/Plus.es-DbyRkEE2.js +23 -0
- package/dist/Plus.es-DbyRkEE2.js.map +1 -0
- package/dist/Trash.es-BFAc8PMf.js +23 -0
- package/dist/Trash.es-BFAc8PMf.js.map +1 -0
- package/dist/{calendar-PCCZDUIL.js → calendar-DEPkz8sw.js} +364 -502
- package/dist/calendar-DEPkz8sw.js.map +1 -0
- package/dist/calendar-header-Dfr-CwkY.js +174 -0
- package/dist/calendar-header-Dfr-CwkY.js.map +1 -0
- package/dist/chunk-jwUa06l-.js +23 -0
- package/dist/components/core/button.js +1 -1
- package/dist/components/core/heading.js +11 -0
- package/dist/components/core/heading.js.map +1 -0
- package/dist/{polymorph-BLXhrn9n.js → components/core/polymorph.js} +2 -2
- package/dist/components/core/polymorph.js.map +1 -0
- package/dist/components/core/render-on-view.js +29 -0
- package/dist/components/core/render-on-view.js.map +1 -0
- package/dist/components/core/resizable.d.ts +7 -1
- package/dist/components/core/resizable.d.ts.map +1 -1
- package/dist/components/core/resizable.js +60 -0
- package/dist/components/core/resizable.js.map +1 -0
- package/dist/components/core/resizable.jsx +46 -40
- package/dist/{slot-pC8kH9De.js → components/core/slot.js} +2 -2
- package/dist/components/core/slot.js.map +1 -0
- package/dist/components/core/tag.js +1 -1
- package/dist/components/core/typography.js +40 -0
- package/dist/components/core/typography.js.map +1 -0
- package/dist/components/display/alert.d.ts.map +1 -1
- package/dist/components/display/alert.js +83 -102
- package/dist/components/display/alert.js.map +1 -1
- package/dist/components/display/alert.jsx +26 -29
- package/dist/components/display/calendar.d.ts.map +1 -1
- package/dist/components/display/calendar.js +1 -1
- package/dist/components/display/calendar.jsx +15 -10
- package/dist/components/display/card.js +2 -2
- package/dist/components/display/empty.d.ts.map +1 -1
- package/dist/components/display/empty.js +25 -0
- package/dist/components/display/empty.js.map +1 -0
- package/dist/components/display/empty.jsx +3 -1
- package/dist/components/display/list.d.ts.map +1 -1
- package/dist/components/display/list.js +132 -122
- package/dist/components/display/list.js.map +1 -1
- package/dist/components/display/list.jsx +30 -25
- package/dist/components/display/notifications.d.ts.map +1 -1
- package/dist/components/display/notifications.js +1 -1
- package/dist/components/display/notifications.jsx +8 -6
- package/dist/components/display/progress.d.ts.map +1 -1
- package/dist/components/display/progress.js +3 -0
- package/dist/components/display/progress.jsx +6 -8
- package/dist/components/display/shortcut.js +2 -0
- package/dist/components/display/skeleton.js +41 -0
- package/dist/components/display/skeleton.js.map +1 -0
- package/dist/components/display/spinner.js +17 -0
- package/dist/components/display/spinner.js.map +1 -0
- package/dist/components/display/step.d.ts.map +1 -1
- package/dist/components/display/step.js +3 -0
- package/dist/components/display/step.jsx +5 -5
- package/dist/components/display/tabs.js +1 -1
- package/dist/components/display/timeline.js +1 -1
- package/dist/components/floating/command-palette.d.ts.map +1 -1
- package/dist/components/floating/command-palette.js +255 -0
- package/dist/components/floating/command-palette.js.map +1 -0
- package/dist/components/floating/command-palette.jsx +34 -25
- package/dist/components/floating/dropdown.js +1 -1
- package/dist/components/floating/dropdown.js.map +1 -1
- package/dist/components/floating/dropdown.jsx +1 -1
- package/dist/components/floating/expand.js +15 -14
- package/dist/components/floating/expand.js.map +1 -1
- package/dist/components/floating/menu.js +1 -1
- package/dist/components/floating/modal.d.ts +14 -11
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.js +1 -1
- package/dist/components/floating/modal.jsx +56 -17
- package/dist/components/floating/toolbar.d.ts +3 -3
- package/dist/components/floating/toolbar.d.ts.map +1 -1
- package/dist/components/floating/toolbar.js +20 -0
- package/dist/components/floating/toolbar.js.map +1 -0
- package/dist/components/floating/toolbar.jsx +7 -3
- package/dist/components/floating/tooltip.js +2 -2
- package/dist/components/floating/tooltip.js.map +1 -1
- package/dist/components/floating/tooltip.jsx +1 -1
- package/dist/components/floating/wizard.js +3 -0
- package/dist/components/form/autocomplete.d.ts.map +1 -1
- package/dist/components/form/autocomplete.js +344 -2
- package/dist/components/form/autocomplete.js.map +1 -0
- package/dist/components/form/autocomplete.jsx +27 -18
- package/dist/components/form/checkbox.d.ts.map +1 -1
- package/dist/components/form/checkbox.js +29 -27
- package/dist/components/form/checkbox.js.map +1 -1
- package/dist/components/form/checkbox.jsx +21 -6
- package/dist/components/form/date-picker.js +1 -1
- package/dist/components/form/date-picker.jsx +1 -1
- package/dist/components/form/file-upload.d.ts +6 -1
- package/dist/components/form/file-upload.d.ts.map +1 -1
- package/dist/components/form/file-upload.js +1 -1
- package/dist/components/form/file-upload.jsx +34 -12
- package/dist/components/form/formReset.js +10 -0
- package/dist/components/form/formReset.js.map +1 -0
- package/dist/components/form/free-text.js +70 -0
- package/dist/components/form/free-text.js.map +1 -0
- package/dist/components/form/free-text.jsx +1 -1
- package/dist/components/form/input-field.d.ts.map +1 -1
- package/dist/components/form/input-field.js +3 -0
- package/dist/components/form/input-field.jsx +14 -8
- package/dist/components/form/input.js +1 -1
- package/dist/components/form/multi-select.d.ts.map +1 -1
- package/dist/components/form/multi-select.js +420 -0
- package/dist/components/form/multi-select.js.map +1 -0
- package/dist/components/form/multi-select.jsx +41 -33
- package/dist/components/form/select.d.ts.map +1 -1
- package/dist/components/form/select.js +55 -51
- package/dist/components/form/select.js.map +1 -1
- package/dist/components/form/select.jsx +8 -5
- package/dist/components/form/slider.js +3 -0
- package/dist/components/form/switch.d.ts +2 -1
- package/dist/components/form/switch.d.ts.map +1 -1
- package/dist/components/form/switch.js +32 -26
- package/dist/components/form/switch.js.map +1 -1
- package/dist/components/form/switch.jsx +26 -13
- package/dist/components/form/textarea.js +19 -0
- package/dist/components/form/textarea.js.map +1 -0
- package/dist/components/page-calendar/calendar-header.d.ts.map +1 -1
- package/dist/components/page-calendar/calendar-header.js +2 -0
- package/dist/components/page-calendar/calendar-header.jsx +6 -4
- package/dist/components/page-calendar/day-view.js +124 -0
- package/dist/components/page-calendar/day-view.js.map +1 -0
- package/dist/components/page-calendar/event-pill.js +44 -0
- package/dist/components/page-calendar/event-pill.js.map +1 -0
- package/dist/components/page-calendar/month-view.d.ts.map +1 -1
- package/dist/components/page-calendar/month-view.js +109 -0
- package/dist/components/page-calendar/month-view.js.map +1 -0
- package/dist/components/page-calendar/month-view.jsx +78 -31
- package/dist/components/page-calendar/page-calendar.d.ts.map +1 -1
- package/dist/components/page-calendar/page-calendar.js +75 -0
- package/dist/components/page-calendar/page-calendar.js.map +1 -0
- package/dist/components/page-calendar/page-calendar.jsx +2 -2
- package/dist/components/page-calendar/week-view.js +88 -0
- package/dist/components/page-calendar/week-view.js.map +1 -0
- package/dist/components/table/filter.d.ts.map +1 -1
- package/dist/components/table/filter.js +239 -0
- package/dist/components/table/filter.js.map +1 -0
- package/dist/components/table/filter.jsx +9 -4
- package/dist/components/table/group.d.ts.map +1 -1
- package/dist/components/table/group.js +3 -0
- package/dist/components/table/group.jsx +5 -3
- package/dist/components/table/index.js +102 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/table/inner-table.js +2 -0
- package/dist/components/table/inner-table.jsx +1 -1
- package/dist/components/table/metadata.js +73 -0
- package/dist/components/table/metadata.js.map +1 -0
- package/dist/components/table/metadata.jsx +1 -1
- package/dist/components/table/pagination.js +70 -0
- package/dist/components/table/pagination.js.map +1 -0
- package/dist/components/table/row.js +58 -0
- package/dist/components/table/row.js.map +1 -0
- package/dist/components/table/sort.d.ts.map +1 -1
- package/dist/components/table/sort.js +3 -0
- package/dist/components/table/sort.jsx +3 -1
- package/dist/components/table/thead.js +3 -0
- package/dist/config/default-translations.d.ts +18 -0
- package/dist/config/default-translations.d.ts.map +1 -1
- package/dist/config/default-translations.jsx +18 -0
- package/dist/{use-translations-DTLfPE3_.js → context-CsnUsfeP.js} +55 -40
- package/dist/context-CsnUsfeP.js.map +1 -0
- package/dist/{date-picker-BhKEFZew.js → date-picker-DNzupG8R.js} +301 -317
- package/dist/date-picker-DNzupG8R.js.map +1 -0
- package/dist/dict-CisoYSMO.js +28 -0
- package/dist/dict-CisoYSMO.js.map +1 -0
- package/dist/dist-ChfJ5LO9.js +498 -0
- package/dist/dist-ChfJ5LO9.js.map +1 -0
- package/dist/{dist-BrGpYRaj.js → dist-DIjUECx9.js} +56 -56
- package/dist/{dist-BrGpYRaj.js.map → dist-DIjUECx9.js.map} +1 -1
- package/dist/dom-Bn4wY_Zx.js.map +1 -1
- package/dist/{file-upload-DWbZfeG5.js → file-upload-C2zNnv9n.js} +501 -481
- package/dist/{file-upload-DWbZfeG5.js.map → file-upload-C2zNnv9n.js.map} +1 -1
- package/dist/fzf-CPGDDCoU.js +64 -0
- package/dist/fzf-CPGDDCoU.js.map +1 -0
- package/dist/getISOWeek-EcB4Ebqp.js +72 -0
- package/dist/getISOWeek-EcB4Ebqp.js.map +1 -0
- package/dist/group-Dl14TJXO.js +222 -0
- package/dist/group-Dl14TJXO.js.map +1 -0
- package/dist/hooks/use-translations.d.ts +18 -0
- package/dist/hooks/use-translations.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js.map +1 -1
- package/dist/inner-table-CeDX60cL.js +151 -0
- package/dist/inner-table-CeDX60cL.js.map +1 -0
- package/dist/input-Cmyuea4Y.js +412 -0
- package/dist/input-Cmyuea4Y.js.map +1 -0
- package/dist/{input-field-B_whI66Q.js → input-field-ffx1MbHo.js} +29 -16
- package/dist/input-field-ffx1MbHo.js.map +1 -0
- package/dist/isSameMonth-C3lsSwcg.js +10 -0
- package/dist/isSameMonth-C3lsSwcg.js.map +1 -0
- package/dist/isToday-COXfxFui.js +32 -0
- package/dist/isToday-COXfxFui.js.map +1 -0
- package/dist/lib/dom.d.ts.map +1 -1
- package/dist/modal-Df8-6i-o.js +408 -0
- package/dist/modal-Df8-6i-o.js.map +1 -0
- package/dist/notifications-NhCESJUV.js +1697 -0
- package/dist/notifications-NhCESJUV.js.map +1 -0
- package/dist/page-calendar.utils-Bd0PHktL.js +102 -0
- package/dist/page-calendar.utils-Bd0PHktL.js.map +1 -0
- package/dist/preset/preset.tailwind.d.ts.map +1 -1
- package/dist/preset/preset.tailwind.js +6 -7
- package/dist/preset/src/styles/dark.js +1 -1
- package/dist/progress-8LO5gWLp.js +104 -0
- package/dist/progress-8LO5gWLp.js.map +1 -0
- package/dist/{proxy-BcJ_5Dwq.js → proxy-fP2NxmhM.js} +658 -844
- package/dist/proxy-fP2NxmhM.js.map +1 -0
- package/dist/shim-Czv-YhKR.js +93 -0
- package/dist/shim-Czv-YhKR.js.map +1 -0
- package/dist/shortcut-CQCmgmlU.js +100 -0
- package/dist/shortcut-CQCmgmlU.js.map +1 -0
- package/dist/slider-TX9hiHO-.js +1196 -0
- package/dist/slider-TX9hiHO-.js.map +1 -0
- package/dist/sort-DGmiselV.js +195 -0
- package/dist/sort-DGmiselV.js.map +1 -0
- package/dist/step-DFpJ7zCG.js +185 -0
- package/dist/step-DFpJ7zCG.js.map +1 -0
- package/dist/styles/dark.js +1 -1
- package/dist/subMonths-QcCnE3Yh.js +43 -0
- package/dist/subMonths-QcCnE3Yh.js.map +1 -0
- package/dist/table-lib-1bkYSklk.js +174 -0
- package/dist/table-lib-1bkYSklk.js.map +1 -0
- package/dist/{tabs-Ciy0l9OF.js → tabs-Brc963EW.js} +2 -2
- package/dist/{tabs-Ciy0l9OF.js.map → tabs-Brc963EW.js.map} +1 -1
- package/dist/thead-B6WELJZ-.js +211 -0
- package/dist/thead-B6WELJZ-.js.map +1 -0
- package/dist/use-locale-DPM_sg4s.js +12 -0
- package/dist/use-locale-DPM_sg4s.js.map +1 -0
- package/dist/use-remove-scroll-pAgC09Sq.js +38 -0
- package/dist/use-remove-scroll-pAgC09Sq.js.map +1 -0
- package/dist/use-translations-BE4PuhLm.js +11 -0
- package/dist/use-translations-BE4PuhLm.js.map +1 -0
- package/dist/useAnimationFrame-DnKbaXfi.js +223 -0
- package/dist/useAnimationFrame-DnKbaXfi.js.map +1 -0
- package/dist/valueToPercent-DZc_m1tm.js +43 -0
- package/dist/valueToPercent-DZc_m1tm.js.map +1 -0
- package/dist/visuallyHidden-B7wI86yi.js +303 -0
- package/dist/visuallyHidden-B7wI86yi.js.map +1 -0
- package/dist/with-selector-BFW5n-pb.js +102 -0
- package/dist/with-selector-BFW5n-pb.js.map +1 -0
- package/dist/wizard-7u_qZ-78.js +218 -0
- package/dist/wizard-7u_qZ-78.js.map +1 -0
- package/package.json +19 -11
- package/dist/autocomplete-D3VOTihi.js +0 -415
- package/dist/autocomplete-D3VOTihi.js.map +0 -1
- package/dist/calendar-PCCZDUIL.js.map +0 -1
- package/dist/components/table/table.js +0 -3
- package/dist/date-picker-BhKEFZew.js.map +0 -1
- package/dist/input-B7jqwPG4.js +0 -473
- package/dist/input-B7jqwPG4.js.map +0 -1
- package/dist/input-field-B_whI66Q.js.map +0 -1
- package/dist/modal-Bz-61ays.js +0 -373
- package/dist/modal-Bz-61ays.js.map +0 -1
- package/dist/notifications-MT4XkLov.js +0 -2203
- package/dist/notifications-MT4XkLov.js.map +0 -1
- package/dist/polymorph-BLXhrn9n.js.map +0 -1
- package/dist/proxy-BcJ_5Dwq.js.map +0 -1
- package/dist/skeleton-CBYEq3lM.js +0 -26
- package/dist/skeleton-CBYEq3lM.js.map +0 -1
- package/dist/slot-pC8kH9De.js.map +0 -1
- package/dist/table-CUFbAI2k.js +0 -1914
- package/dist/table-CUFbAI2k.js.map +0 -1
- package/dist/use-translations-DTLfPE3_.js.map +0 -1
|
@@ -1,3 +1,345 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { d as e, i as t, n, o as r, p as i, t as a } from "../../dom-Bn4wY_Zx.js";
|
|
3
|
+
import { t as o } from "../../CaretDown.es-BXl0Ixp3.js";
|
|
4
|
+
import { n as ee } from "../../input-field-ffx1MbHo.js";
|
|
5
|
+
import { t as te } from "../../use-translations-BE4PuhLm.js";
|
|
6
|
+
import { A as ne, D as re, S as ie, T as ae, b as oe, d as se, f as ce, k as le, n as ue, o as de, v as fe } from "../../floating-ui.react-CwXtBJ_y.js";
|
|
7
|
+
import { o as s } from "../../fns-KbsWlOTG.js";
|
|
8
|
+
import { t as c } from "../../proxy-fP2NxmhM.js";
|
|
9
|
+
import { t as l } from "../../AnimatePresence-j36AYeOQ.js";
|
|
10
|
+
import { t as pe } from "../../dist-BHFtgf5x.js";
|
|
11
|
+
import { t as me } from "../../use-remove-scroll-pAgC09Sq.js";
|
|
12
|
+
import { t as he } from "../../fzf-CPGDDCoU.js";
|
|
13
|
+
import { Fragment as u, forwardRef as d, useEffect as f, useId as ge, useMemo as p, useRef as m, useState as h } from "react";
|
|
14
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
15
|
+
import { flushSync as v } from "react-dom";
|
|
16
|
+
//#region src/components/form/autocomplete.tsx
|
|
17
|
+
var _e = (e) => /* @__PURE__ */ g(u, { children: e.children }), ve = {
|
|
18
|
+
duration: 200,
|
|
19
|
+
open: {
|
|
20
|
+
transform: "scaleY(1)",
|
|
21
|
+
opacity: 1
|
|
22
|
+
},
|
|
23
|
+
close: {
|
|
24
|
+
transform: "scaleY(0)",
|
|
25
|
+
opacity: 0
|
|
26
|
+
},
|
|
27
|
+
initial: {
|
|
28
|
+
transform: "scaleY(0)",
|
|
29
|
+
opacity: .2
|
|
30
|
+
}
|
|
31
|
+
}, ye = {
|
|
32
|
+
List: d(function({ context: e, ...t }, n) {
|
|
33
|
+
return /* @__PURE__ */ g(c.div, {
|
|
34
|
+
...t,
|
|
35
|
+
ref: n,
|
|
36
|
+
role: "select",
|
|
37
|
+
id: e?.listboxId,
|
|
38
|
+
className: "max-h-dropdown-max-h w-full overscroll-contain rounded-dropdown-radius",
|
|
39
|
+
children: /* @__PURE__ */ g(l, { children: t.children })
|
|
40
|
+
});
|
|
41
|
+
}),
|
|
42
|
+
Item: d(function({ item: e, context: t, ...n }, r) {
|
|
43
|
+
return /* @__PURE__ */ g(c.div, {
|
|
44
|
+
...n,
|
|
45
|
+
ref: r,
|
|
46
|
+
role: "presentation",
|
|
47
|
+
className: "first:rounded-t-dropdown-radius last:rounded-t-dropdown-radius"
|
|
48
|
+
});
|
|
49
|
+
})
|
|
50
|
+
}, be = [], y = 40, b = d(({ left: l, error: u, right: d, loading: b, options: x, container: xe, rightLabel: Se, interactive: Ce, emptyMessage: we, optionalText: Te, labelClassName: Ee, feedback: De = null, hideLeft: Oe = !1, required: S = !1, dynamicOption: C = !1, ...w }, ke) => {
|
|
51
|
+
let Ae = m(null), T = m(null), E = m(null), D = w.value ?? w.defaultValue ?? "", O = te(), je = ge(), [k, A] = h(!1), [j, M] = h(""), [N, P] = h(D), [Me, F] = h(() => x.find((e) => e.value === D)?.label ?? D), [I, L] = h(null), R = m(be), [, Ne] = h(0), Pe = me(k, "block-only"), z = p(() => C && j !== "" ? [{
|
|
52
|
+
value: j,
|
|
53
|
+
label: j,
|
|
54
|
+
"data-dynamic": "true"
|
|
55
|
+
}, ...x] : x, [
|
|
56
|
+
C,
|
|
57
|
+
j,
|
|
58
|
+
x
|
|
59
|
+
]), B = () => v(() => A(!0)), V = p(() => j ? he(z, "value", [{
|
|
60
|
+
key: "value",
|
|
61
|
+
value: j
|
|
62
|
+
}, {
|
|
63
|
+
key: "label",
|
|
64
|
+
value: j
|
|
65
|
+
}]) : z, [z, j]), [H, U] = h(() => Math.min(320, y * x.length)), W = () => {
|
|
66
|
+
A(!1), U(0);
|
|
67
|
+
}, G = p(() => V.filter((e) => e.hidden !== !0), [V]), Fe = p(() => C ? void 0 : `^(${x.map((e) => `${s(e.value)}${e.label ? "|" + s(e.label) : ""}`).join("|")})$`, [C, x]), { x: Ie, y: Le, strategy: Re, refs: K, context: q, placement: J } = ce({
|
|
68
|
+
open: k,
|
|
69
|
+
transform: !0,
|
|
70
|
+
onOpenChange: A,
|
|
71
|
+
placement: "bottom-start",
|
|
72
|
+
whileElementsMounted: ne,
|
|
73
|
+
middleware: [
|
|
74
|
+
re(4),
|
|
75
|
+
ae({
|
|
76
|
+
allowedPlacements: ["top-start", "bottom-start"],
|
|
77
|
+
alignment: "start"
|
|
78
|
+
}),
|
|
79
|
+
le({
|
|
80
|
+
padding: 10,
|
|
81
|
+
elementContext: "reference",
|
|
82
|
+
apply(e) {
|
|
83
|
+
let n = t(K.reference.current, window.innerHeight), r = `${T.current?.getBoundingClientRect().width || n}px`;
|
|
84
|
+
Object.assign(e.elements.floating.style, {
|
|
85
|
+
width: r,
|
|
86
|
+
maxWidth: r
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
}), ze = ie(q, ve), { getReferenceProps: Be, getFloatingProps: Ve, getItemProps: He } = fe([se(q), oe(q, {
|
|
92
|
+
cols: 0,
|
|
93
|
+
listRef: R,
|
|
94
|
+
loop: !0,
|
|
95
|
+
virtual: !0,
|
|
96
|
+
allowEscape: !0,
|
|
97
|
+
activeIndex: I,
|
|
98
|
+
selectedIndex: I,
|
|
99
|
+
focusItemOnOpen: "auto",
|
|
100
|
+
openOnArrowKeyDown: !0,
|
|
101
|
+
scrollItemIntoView: !0
|
|
102
|
+
})]);
|
|
103
|
+
f(() => {
|
|
104
|
+
if (w.value) {
|
|
105
|
+
let e = x.find((e) => e.value === w.value);
|
|
106
|
+
e && (F(e.label ?? e.value), P(w.value));
|
|
107
|
+
}
|
|
108
|
+
}, [w.value, x]), f(() => {
|
|
109
|
+
let e = K.reference.current;
|
|
110
|
+
if (e) return r(e);
|
|
111
|
+
}, [K.reference]), f(() => {
|
|
112
|
+
if (!k) return;
|
|
113
|
+
let e = requestAnimationFrame(() => Ne((e) => e + 1));
|
|
114
|
+
return () => cancelAnimationFrame(e);
|
|
115
|
+
}, [k]), f(() => {
|
|
116
|
+
if (!k) {
|
|
117
|
+
U(0);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
let e = setTimeout(() => U(Math.min(320, G.length * y)), 100);
|
|
121
|
+
return () => clearTimeout(e);
|
|
122
|
+
}, [k, G.length]);
|
|
123
|
+
let Y = (t, n) => {
|
|
124
|
+
P(t.value);
|
|
125
|
+
let r = K.reference.current;
|
|
126
|
+
if (!r) return;
|
|
127
|
+
r?.setAttribute("data-value", t.value), r.value = t.value;
|
|
128
|
+
let i = new Event("change", {
|
|
129
|
+
bubbles: !1,
|
|
130
|
+
cancelable: !0
|
|
131
|
+
});
|
|
132
|
+
r.dispatchEvent(i), w.onChange && w.onChange(e(r)), F(t.label ?? ""), W(), M(""), L(n), r.focus();
|
|
133
|
+
}, Ue = (e) => {
|
|
134
|
+
let t = e.target.value;
|
|
135
|
+
return M(t), !k && t === "" ? A(!0) : (e.target.name = w.name || "", t ? A(!0) : w.onChange?.(e));
|
|
136
|
+
}, We = () => {
|
|
137
|
+
B(), M(""), K.reference.current?.focus();
|
|
138
|
+
}, Ge = () => {
|
|
139
|
+
L((e) => e === null ? 0 : e), B(), M("");
|
|
140
|
+
}, Ke = () => {
|
|
141
|
+
K.reference.current?.setAttribute("data-value", ""), M(""), P(""), F(""), n(K.reference.current), W();
|
|
142
|
+
}, X = w.id || w.name || je, Z = `${X}-shadow`, Q = `${Z}-listbox`, $ = G.length === 0, qe = J === "top" || J === "top-start", Je = k && I !== null && G[I] ? `${Z}-option-${I}` : void 0;
|
|
143
|
+
return /* @__PURE__ */ _(ee, {
|
|
144
|
+
...w,
|
|
145
|
+
left: l,
|
|
146
|
+
error: u,
|
|
147
|
+
id: Z,
|
|
148
|
+
form: w.form,
|
|
149
|
+
loading: b,
|
|
150
|
+
name: w.name,
|
|
151
|
+
hideLeft: Oe,
|
|
152
|
+
required: S,
|
|
153
|
+
title: w.title,
|
|
154
|
+
container: xe,
|
|
155
|
+
rightLabel: Se,
|
|
156
|
+
interactive: Ce,
|
|
157
|
+
optionalText: Te,
|
|
158
|
+
componentName: "autocomplete",
|
|
159
|
+
labelClassName: Ee,
|
|
160
|
+
placeholder: w.placeholder,
|
|
161
|
+
ref: T,
|
|
162
|
+
feedback: k && qe ? w.title : De,
|
|
163
|
+
right: /* @__PURE__ */ _("span", {
|
|
164
|
+
className: "flex items-center gap-0.5",
|
|
165
|
+
children: [
|
|
166
|
+
d,
|
|
167
|
+
/* @__PURE__ */ _("button", {
|
|
168
|
+
type: "button",
|
|
169
|
+
className: "p-input-gap transition-colors link:text-primary md:p-1",
|
|
170
|
+
onClick: We,
|
|
171
|
+
children: [/* @__PURE__ */ g(o, { size: 20 }), /* @__PURE__ */ g("span", {
|
|
172
|
+
className: "sr-only",
|
|
173
|
+
children: O.inputCaretDown
|
|
174
|
+
})]
|
|
175
|
+
}),
|
|
176
|
+
N ? /* @__PURE__ */ g("button", {
|
|
177
|
+
type: "button",
|
|
178
|
+
onClick: Ke,
|
|
179
|
+
"aria-label": O.inputCloseValue,
|
|
180
|
+
className: "p-input-gap transition-colors link:text-danger md:p-1",
|
|
181
|
+
children: /* @__PURE__ */ g("svg", {
|
|
182
|
+
width: "15",
|
|
183
|
+
height: "15",
|
|
184
|
+
viewBox: "0 0 15 15",
|
|
185
|
+
fill: "none",
|
|
186
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
187
|
+
children: /* @__PURE__ */ g("path", {
|
|
188
|
+
d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",
|
|
189
|
+
fill: "currentColor",
|
|
190
|
+
fillRule: "evenodd",
|
|
191
|
+
clipRule: "evenodd"
|
|
192
|
+
})
|
|
193
|
+
})
|
|
194
|
+
}) : null
|
|
195
|
+
]
|
|
196
|
+
}),
|
|
197
|
+
children: [
|
|
198
|
+
/* @__PURE__ */ g("input", {
|
|
199
|
+
"data-shadow": "true",
|
|
200
|
+
...Be({
|
|
201
|
+
...w,
|
|
202
|
+
onFocus: Ge,
|
|
203
|
+
pattern: Fe,
|
|
204
|
+
onChange: Ue,
|
|
205
|
+
id: Z,
|
|
206
|
+
name: Z,
|
|
207
|
+
ref: K.setReference,
|
|
208
|
+
onClick: (e) => e.currentTarget.focus(),
|
|
209
|
+
onKeyDown(e) {
|
|
210
|
+
if (w.onKeyDown?.(e), !e.defaultPrevented) {
|
|
211
|
+
if (e.key === "Escape") return e.preventDefault(), W();
|
|
212
|
+
if (k) {
|
|
213
|
+
if (e.key === "ArrowDown") {
|
|
214
|
+
e.preventDefault();
|
|
215
|
+
let t = i.number(I) ? I + 1 : 0;
|
|
216
|
+
return t > G.length - 1 && (t = 0), E.current?.scrollIntoView({ index: t }), L(t);
|
|
217
|
+
}
|
|
218
|
+
if (e.key === "ArrowUp") {
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
let t = i.number(I) ? I - 1 : G.length - 1;
|
|
221
|
+
return t < 0 && (t = G.length - 1), E.current?.scrollIntoView({ index: t }), L(t);
|
|
222
|
+
}
|
|
223
|
+
if (e.key === "Enter") {
|
|
224
|
+
if (I !== null && G[I]) return e.preventDefault(), Y(G[I], I);
|
|
225
|
+
if (G.length === 1) return e.preventDefault(), Y(G[0], 0);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}),
|
|
231
|
+
"data-value": N,
|
|
232
|
+
"data-error": !!u,
|
|
233
|
+
"data-name": X,
|
|
234
|
+
"data-target": X,
|
|
235
|
+
required: S,
|
|
236
|
+
value: k ? j : x.length === 0 ? "" : Me || N,
|
|
237
|
+
role: "combobox",
|
|
238
|
+
"aria-autocomplete": "list",
|
|
239
|
+
"aria-expanded": k,
|
|
240
|
+
"aria-haspopup": "listbox",
|
|
241
|
+
"aria-controls": Q,
|
|
242
|
+
"aria-activedescendant": Je,
|
|
243
|
+
"aria-labelledby": `${Z}-label`,
|
|
244
|
+
autoComplete: "off",
|
|
245
|
+
className: a("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-input-radius bg-transparent px-input-padding-x py-input-padding-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "text-input-text group-focus-within:border-primary group-hover:border-primary", w.className)
|
|
246
|
+
}),
|
|
247
|
+
/* @__PURE__ */ g("input", {
|
|
248
|
+
id: X,
|
|
249
|
+
name: X,
|
|
250
|
+
type: "hidden",
|
|
251
|
+
"data-origin": X,
|
|
252
|
+
ref: ke,
|
|
253
|
+
required: S,
|
|
254
|
+
defaultValue: w.value || N || void 0
|
|
255
|
+
}),
|
|
256
|
+
/* @__PURE__ */ g(de, {
|
|
257
|
+
preserveTabOrder: !0,
|
|
258
|
+
children: k ? /* @__PURE__ */ g(ue, {
|
|
259
|
+
modal: !0,
|
|
260
|
+
guards: !0,
|
|
261
|
+
returnFocus: !1,
|
|
262
|
+
context: q,
|
|
263
|
+
initialFocus: -1,
|
|
264
|
+
visuallyHiddenDismiss: !0,
|
|
265
|
+
children: /* @__PURE__ */ _(c.div, {
|
|
266
|
+
...Ve({
|
|
267
|
+
ref: K.setFloating,
|
|
268
|
+
style: {
|
|
269
|
+
...ze.styles,
|
|
270
|
+
left: Ie,
|
|
271
|
+
top: Le ?? 0,
|
|
272
|
+
position: Re,
|
|
273
|
+
height: "auto"
|
|
274
|
+
}
|
|
275
|
+
}),
|
|
276
|
+
initial: !1,
|
|
277
|
+
"data-floating": "true",
|
|
278
|
+
animate: { height: $ ? "auto" : H },
|
|
279
|
+
onAnimationComplete: () => {
|
|
280
|
+
if (!k) {
|
|
281
|
+
U(0);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
let e = ((K.floating.current?.querySelector("li"))?.getBoundingClientRect().height ?? y) * G.length;
|
|
285
|
+
v(() => U(Math.min(320, e + 2)));
|
|
286
|
+
},
|
|
287
|
+
className: a("shadow-floating isolate z-floating m-0 max-h-80 origin-[top_center] list-none overscroll-contain rounded-dropdown-radius border border-floating-border bg-floating-background p-0 text-foreground ease-in-out", qe ? "origin-[bottom_center]" : "origin-[top_center]"),
|
|
288
|
+
children: [$ ? /* @__PURE__ */ g("div", {
|
|
289
|
+
className: "w-full border-b border-tooltip-border",
|
|
290
|
+
children: /* @__PURE__ */ g("span", {
|
|
291
|
+
className: "flex w-full justify-between p-menu-item-p text-left text-disabled",
|
|
292
|
+
children: we || O.autocompleteEmpty
|
|
293
|
+
})
|
|
294
|
+
}) : null, /* @__PURE__ */ g(pe, {
|
|
295
|
+
overscan: 40,
|
|
296
|
+
ref: E,
|
|
297
|
+
hidden: $,
|
|
298
|
+
data: G,
|
|
299
|
+
context: { listboxId: Q },
|
|
300
|
+
style: { height: H },
|
|
301
|
+
initialItemCount: G.length,
|
|
302
|
+
defaultItemHeight: y,
|
|
303
|
+
components: ye,
|
|
304
|
+
scrollerRef: (e) => {
|
|
305
|
+
Ae.current = e, Pe.current = e;
|
|
306
|
+
},
|
|
307
|
+
className: "border-floating max-h-full overscroll-contain rounded-dropdown-radius bg-floating-background p-0 text-foreground",
|
|
308
|
+
itemContent: (e, t) => {
|
|
309
|
+
let n = t.Render ?? _e, r = N === t.value || N === t.label, i = I === e, o = t.label ?? t.value;
|
|
310
|
+
return /* @__PURE__ */ g("div", {
|
|
311
|
+
id: `${Z}-option-${e}`,
|
|
312
|
+
"data-value": t.value,
|
|
313
|
+
...He({
|
|
314
|
+
ref: (t) => {
|
|
315
|
+
R.current[e] = t;
|
|
316
|
+
},
|
|
317
|
+
role: "option",
|
|
318
|
+
"aria-selected": r,
|
|
319
|
+
"aria-disabled": t.disabled,
|
|
320
|
+
tabIndex: -1,
|
|
321
|
+
onClick: () => {
|
|
322
|
+
t.disabled || Y(t, e);
|
|
323
|
+
},
|
|
324
|
+
className: a("min-h-10 w-full cursor-pointer p-menu-item-p text-left hover:bg-floating-hover", r ? "bg-primary-hover text-primary-foreground" : "", i ? "bg-floating-hover text-floating-foreground" : "")
|
|
325
|
+
}),
|
|
326
|
+
children: /* @__PURE__ */ g(n, {
|
|
327
|
+
...t,
|
|
328
|
+
ref: void 0,
|
|
329
|
+
label: t.label,
|
|
330
|
+
value: t.value,
|
|
331
|
+
children: o
|
|
332
|
+
})
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
})]
|
|
336
|
+
})
|
|
337
|
+
}) : null
|
|
338
|
+
})
|
|
339
|
+
]
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
//#endregion
|
|
343
|
+
export { b as Autocomplete };
|
|
344
|
+
|
|
345
|
+
//# sourceMappingURL=autocomplete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autocomplete.js","names":[],"sources":["../../../src/components/form/autocomplete.tsx"],"sourcesContent":["\"use client\";\nimport {\n autoPlacement,\n autoUpdate,\n FloatingFocusManager,\n FloatingPortal,\n offset,\n size,\n useDismiss,\n useFloating,\n useInteractions,\n useListNavigation,\n useTransitionStyles,\n} from \"@floating-ui/react\";\nimport { CaretDownIcon } from \"@phosphor-icons/react\";\nimport { AnimatePresence, motion } from \"motion/react\";\nimport React, { forwardRef, Fragment, type PropsWithChildren, Ref, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { type ContextProp, type ItemProps, type ListProps, Virtuoso, type VirtuosoHandle } from \"react-virtuoso\";\nimport { Is } from \"sidekicker\";\nimport { useRemoveScroll } from \"../../hooks/use-remove-scroll\";\nimport { useTranslations } from \"../../hooks/use-translations\";\nimport { css, dispatchInput, getRemainingSize, initializeInputDataset, synthesizeChangeEvent } from \"../../lib/dom\";\nimport { safeRegex } from \"../../lib/fns\";\nimport { fzf } from \"../../lib/fzf\";\nimport { Label } from \"../../types\";\nimport { InputField, InputFieldProps } from \"./input-field\";\nimport { type OptionProps } from \"./select\";\n\nexport type AutocompleteItemProps = OptionProps & {\n Render?: React.FC<OptionProps>;\n};\n\nexport type AutocompleteProps = Omit<InputFieldProps<\"input\">, \"value\"> & {\n title?: string;\n value?: string;\n emptyMessage?: Label;\n dynamicOption?: boolean;\n options: AutocompleteItemProps[];\n};\n\nconst Frag = (props: PropsWithChildren) => <Fragment>{props.children}</Fragment>;\n\nconst transitionStyles = {\n duration: 200,\n open: { transform: \"scaleY(1)\", opacity: 1 },\n close: { transform: \"scaleY(0)\", opacity: 0 },\n initial: { transform: \"scaleY(0)\", opacity: 0.2 },\n} as const;\n\nconst List = forwardRef<HTMLDivElement, ListProps & ContextProp<{ listboxId?: string }>>(function VirtualList({ context, ...props }, ref) {\n return (\n <motion.div\n {...props}\n ref={ref}\n role=\"select\"\n id={context?.listboxId}\n className=\"max-h-dropdown-max-h w-full overscroll-contain rounded-dropdown-radius\"\n >\n <AnimatePresence>{props.children}</AnimatePresence>\n </motion.div>\n );\n});\n\nconst Item = forwardRef<HTMLDivElement, ItemProps<AutocompleteItemProps> & ContextProp<unknown>>(function VirtualItem(\n { item: _item, context: _context, ...props },\n ref\n) {\n return <motion.div {...props} ref={ref} role=\"presentation\" className=\"first:rounded-t-dropdown-radius last:rounded-t-dropdown-radius\" />;\n});\n\nconst components = { List, Item };\n\nconst EMPTY_NODES: Array<HTMLElement | null> = [];\n\nconst MIN_SIZE = 40;\n\nexport const Autocomplete = forwardRef<HTMLInputElement, AutocompleteProps>(\n (\n {\n left,\n error,\n right,\n loading,\n options,\n container,\n rightLabel,\n interactive,\n emptyMessage,\n optionalText,\n labelClassName,\n feedback = null,\n hideLeft = false,\n required = false,\n dynamicOption = false,\n ...props\n }: AutocompleteProps,\n externalRef\n ) => {\n const scroller = useRef<HTMLElement | null>(null);\n const fieldset = useRef<HTMLFieldSetElement>(null);\n const virtuoso = useRef<VirtuosoHandle | null>(null);\n const defaults = props.value ?? props.defaultValue ?? \"\";\n const translation = useTranslations();\n const generatedId = useId();\n const [open, setOpen] = useState(false);\n const [shadow, setShadow] = useState(\"\");\n const [value, setValue] = useState(defaults);\n const [label, setLabel] = useState(() => options.find((x) => x.value === defaults)?.label ?? defaults);\n const [index, setIndex] = useState<number | null>(null);\n const listRef = useRef<Array<HTMLElement | null>>(EMPTY_NODES);\n const [, tick] = useState(0);\n const removeScrollRef = useRemoveScroll(open, \"block-only\");\n\n const innerOptions = useMemo<AutocompleteItemProps[]>(\n () => (dynamicOption && shadow !== \"\" ? [{ value: shadow, label: shadow, \"data-dynamic\": \"true\" }, ...options] : options),\n [dynamicOption, shadow, options]\n );\n\n const openDropdown = () => flushSync(() => setOpen(true));\n\n const list = useMemo(\n () =>\n shadow\n ? fzf(innerOptions, \"value\", [\n { key: \"value\", value: shadow },\n { key: \"label\", value: shadow },\n ])\n : innerOptions,\n [innerOptions, shadow]\n );\n\n const [h, setH] = useState(() => Math.min(320, MIN_SIZE * options.length));\n\n const setClosed = () => {\n setOpen(false);\n setH(0);\n };\n\n const displayList = useMemo(() => list.filter((x) => x.hidden !== true), [list]);\n\n const pattern = useMemo(\n () =>\n dynamicOption ? undefined : `^(${options.map((x) => `${safeRegex(x.value)}${x.label ? \"|\" + safeRegex(x.label) : \"\"}`).join(\"|\")})$`,\n [dynamicOption, options]\n );\n\n const { x, y, strategy, refs, context, placement } = useFloating<HTMLInputElement>({\n open,\n transform: true,\n onOpenChange: setOpen,\n placement: \"bottom-start\",\n whileElementsMounted: autoUpdate,\n middleware: [\n offset(4),\n autoPlacement({\n allowedPlacements: [\"top-start\", \"bottom-start\"],\n alignment: \"start\",\n }),\n size({\n padding: 10,\n elementContext: \"reference\",\n apply(args) {\n const DEFAULT_SIZE = getRemainingSize(refs.reference!.current as HTMLElement, window.innerHeight);\n const mw = `${fieldset.current?.getBoundingClientRect().width || DEFAULT_SIZE}px`;\n Object.assign(args.elements.floating.style, {\n width: mw,\n maxWidth: mw,\n });\n },\n }),\n ],\n });\n const transitions = useTransitionStyles(context, transitionStyles);\n const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([\n useDismiss(context),\n useListNavigation(context, {\n cols: 0,\n listRef,\n loop: true,\n virtual: true,\n allowEscape: true,\n activeIndex: index,\n selectedIndex: index,\n focusItemOnOpen: \"auto\",\n openOnArrowKeyDown: true,\n scrollItemIntoView: true,\n }),\n ]);\n\n useEffect(() => {\n if (props.value) {\n const item = options.find((x) => x.value === props.value);\n if (item) {\n setLabel(item.label ?? item.value);\n setValue(props.value);\n }\n }\n }, [props.value, options]);\n\n useEffect(() => {\n const input = refs.reference.current as HTMLInputElement;\n if (!input) return;\n return initializeInputDataset(input);\n }, [refs.reference]);\n\n useEffect(() => {\n if (!open) return;\n const id = requestAnimationFrame(() => tick((n) => n + 1));\n return () => cancelAnimationFrame(id);\n }, [open]);\n\n useEffect(() => {\n if (!open) {\n setH(0);\n return;\n }\n const id = setTimeout(() => setH(Math.min(320, displayList.length * MIN_SIZE)), 100);\n return () => clearTimeout(id);\n }, [open, displayList.length]);\n\n const onSelect = (opt: AutocompleteItemProps, i: number) => {\n setValue(opt.value);\n const input = refs.reference.current as HTMLInputElement;\n if (!input) return;\n input?.setAttribute(\"data-value\", opt.value);\n input.value = opt.value;\n const event = new Event(\"change\", { bubbles: false, cancelable: true });\n input.dispatchEvent(event);\n if (props.onChange) props.onChange(synthesizeChangeEvent(input));\n setLabel(opt.label ?? \"\");\n setClosed();\n setShadow(\"\");\n setIndex(i);\n input.focus();\n };\n\n const onChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const value = event.target.value;\n setShadow(value);\n if (!open && value === \"\") return setOpen(true);\n event.target.name = props.name || \"\";\n return value ? setOpen(true) : props.onChange?.(event);\n };\n\n const onCaretDownClick = () => {\n openDropdown();\n setShadow(\"\");\n (refs.reference.current as HTMLInputElement)?.focus();\n };\n\n const onFocus = () => {\n setIndex((prev) => (prev === null ? 0 : prev));\n openDropdown();\n setShadow(\"\");\n };\n\n const onClose = () => {\n (refs.reference.current as HTMLInputElement)?.setAttribute(\"data-value\", \"\");\n setShadow(\"\");\n setValue(\"\");\n setLabel(\"\");\n dispatchInput(refs.reference.current as HTMLInputElement);\n setClosed();\n };\n\n const id = props.id || props.name || generatedId;\n\n const shadowId = `${id}-shadow`;\n const listboxId = `${shadowId}-listbox`;\n\n const isEmpty = displayList.length === 0;\n\n const isTopPlacement = placement === \"top\" || placement === \"top-start\";\n\n const activeOptionId = open && index !== null && displayList[index] ? `${shadowId}-option-${index}` : undefined;\n\n return (\n <InputField\n {...props}\n left={left}\n error={error}\n id={shadowId}\n form={props.form}\n loading={loading}\n name={props.name}\n hideLeft={hideLeft}\n required={required}\n title={props.title}\n container={container}\n rightLabel={rightLabel}\n interactive={interactive}\n optionalText={optionalText}\n componentName=\"autocomplete\"\n labelClassName={labelClassName}\n placeholder={props.placeholder}\n ref={fieldset as unknown as Ref<HTMLInputElement>}\n feedback={open && isTopPlacement ? props.title : feedback}\n right={\n <span className=\"flex items-center gap-0.5\">\n {right}\n <button type=\"button\" className=\"p-input-gap transition-colors link:text-primary md:p-1\" onClick={onCaretDownClick}>\n <CaretDownIcon size={20} />\n <span className=\"sr-only\">{translation.inputCaretDown}</span>\n </button>\n {value ? (\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={translation.inputCloseValue}\n className=\"p-input-gap transition-colors link:text-danger md:p-1\"\n >\n <svg width=\"15\" height=\"15\" viewBox=\"0 0 15 15\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z\"\n fill=\"currentColor\"\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n ) : null}\n </span>\n }\n >\n <input\n data-shadow=\"true\"\n {...getReferenceProps({\n ...props,\n onFocus,\n pattern,\n onChange,\n id: shadowId,\n name: shadowId,\n ref: refs.setReference,\n onClick: (e: React.MouseEvent<HTMLInputElement>) => e.currentTarget.focus(),\n onKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {\n props.onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (event.key === \"Escape\") {\n event.preventDefault();\n return setClosed();\n }\n if (!open) return;\n if (event.key === \"ArrowDown\") {\n event.preventDefault();\n let next = Is.number(index) ? index + 1 : 0;\n if (next > displayList.length - 1) next = 0;\n virtuoso.current?.scrollIntoView({ index: next });\n return setIndex(next);\n }\n if (event.key === \"ArrowUp\") {\n event.preventDefault();\n let next = Is.number(index) ? index! - 1 : displayList.length - 1;\n if (next < 0) next = displayList.length - 1;\n virtuoso.current?.scrollIntoView({ index: next });\n return setIndex(next);\n }\n if (event.key === \"Enter\") {\n if (index !== null && displayList[index]) {\n event.preventDefault();\n return onSelect(displayList[index], index);\n }\n if (displayList.length === 1) {\n event.preventDefault();\n return onSelect(displayList[0], 0);\n }\n }\n },\n } as React.HTMLProps<HTMLInputElement>)}\n data-value={value}\n data-error={!!error}\n data-name={id}\n data-target={id}\n required={required}\n value={open ? shadow : options.length === 0 ? \"\" : label || value}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={open}\n aria-haspopup=\"listbox\"\n aria-controls={listboxId}\n aria-activedescendant={activeOptionId}\n aria-labelledby={`${shadowId}-label`}\n autoComplete=\"off\"\n className={css(\n \"input placeholder-input-mask group h-input-height w-full flex-1\",\n \"rounded-input-radius bg-transparent px-input-padding-x py-input-padding-y text-foreground\",\n \"outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary\",\n \"group-error:text-danger group-error:placeholder-input-mask-error\",\n \"text-input-text group-focus-within:border-primary group-hover:border-primary\",\n props.className\n )}\n />\n <input\n id={id}\n name={id}\n type=\"hidden\"\n data-origin={id}\n ref={externalRef}\n required={required}\n defaultValue={props.value || value || undefined}\n />\n <FloatingPortal preserveTabOrder>\n {open ? (\n <FloatingFocusManager modal guards returnFocus={false} context={context} initialFocus={-1} visuallyHiddenDismiss>\n <motion.div\n {...getFloatingProps({\n ref: refs.setFloating,\n style: {\n ...transitions.styles,\n left: x,\n top: y ?? 0,\n position: strategy,\n height: \"auto\",\n },\n })}\n initial={false}\n data-floating=\"true\"\n animate={{ height: isEmpty ? \"auto\" : h }}\n onAnimationComplete={() => {\n if (!open) {\n setH(0);\n return;\n }\n const li = refs.floating.current?.querySelector(\"li\");\n const sum = (li?.getBoundingClientRect().height ?? MIN_SIZE) * displayList.length;\n flushSync(() => setH(Math.min(320, sum + 2)));\n }}\n className={css(\n \"shadow-floating isolate z-floating m-0 max-h-80 origin-[top_center] list-none overscroll-contain rounded-dropdown-radius border border-floating-border bg-floating-background p-0 text-foreground ease-in-out\",\n isTopPlacement ? \"origin-[bottom_center]\" : \"origin-[top_center]\"\n )}\n >\n {isEmpty ? (\n <div className=\"w-full border-b border-tooltip-border\">\n <span className=\"flex w-full justify-between p-menu-item-p text-left text-disabled\">\n {emptyMessage || translation.autocompleteEmpty}\n </span>\n </div>\n ) : null}\n <Virtuoso\n overscan={40}\n ref={virtuoso}\n hidden={isEmpty}\n data={displayList}\n context={{ listboxId }}\n style={{ height: h }}\n initialItemCount={displayList.length}\n defaultItemHeight={MIN_SIZE}\n components={components as never}\n scrollerRef={(e) => {\n scroller.current = e as HTMLElement;\n removeScrollRef.current = e as HTMLElement;\n }}\n className=\"border-floating max-h-full overscroll-contain rounded-dropdown-radius bg-floating-background p-0 text-foreground\"\n itemContent={(i, option) => {\n const Label = option.Render ?? Frag;\n const active = value === option.value || value === option.label;\n const selected = index === i;\n const children = option.label ?? option.value;\n return (\n <div\n id={`${shadowId}-option-${i}`}\n data-value={option.value}\n {...getItemProps({\n ref: (node: HTMLElement | null) => {\n listRef.current[i] = node;\n },\n role: \"option\",\n \"aria-selected\": active,\n \"aria-disabled\": option.disabled,\n tabIndex: -1,\n onClick: () => {\n if (!option.disabled) onSelect(option, i);\n },\n className: css(\n \"min-h-10 w-full cursor-pointer p-menu-item-p text-left hover:bg-floating-hover\",\n active ? \"bg-primary-hover text-primary-foreground\" : \"\",\n selected ? \"bg-floating-hover text-floating-foreground\" : \"\"\n ),\n })}\n >\n <Label {...option} ref={undefined} label={option.label} value={option.value}>\n {children}\n </Label>\n </div>\n );\n }}\n />\n </motion.div>\n </FloatingFocusManager>\n ) : null}\n </FloatingPortal>\n </InputField>\n );\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;AAyCA,IAAM,MAAQ,MAA6B,kBAAC,GAAD,EAAA,UAAW,EAAM,SAAmB,CAAA,GAEzE,KAAmB;CACrB,UAAU;CACV,MAAM;EAAE,WAAW;EAAa,SAAS;CAAE;CAC3C,OAAO;EAAE,WAAW;EAAa,SAAS;CAAE;CAC5C,SAAS;EAAE,WAAW;EAAa,SAAS;CAAI;AACpD,GAuBM,KAAa;CAAE,MArBR,EAA4E,SAAqB,EAAE,YAAS,GAAG,KAAS,GAAK;EACtI,OACI,kBAAC,EAAO,KAAR;GACI,GAAI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;OACZ,cAAc,MAAM;QAEhB,AADA,GAAS,UAAU,GACnB,GAAgB,UAAU;OAC9B;OACA,WAAU;OACV,cAAc,GAAG,MAAW;QACxB,IAAM,IAAQ,EAAO,UAAU,IACzB,IAAS,MAAU,EAAO,SAAS,MAAU,EAAO,OACpD,IAAW,MAAU,GACrB,IAAW,EAAO,SAAS,EAAO;QACxC,OACI,kBAAC,OAAD;SACI,IAAI,GAAG,EAAS,UAAU;SAC1B,cAAY,EAAO;SACnB,GAAI,GAAa;UACb,MAAM,MAA6B;WAC/B,EAAQ,QAAQ,KAAK;UACzB;UACA,MAAM;UACN,iBAAiB;UACjB,iBAAiB,EAAO;UACxB,UAAU;UACV,eAAe;WACX,AAAK,EAAO,YAAU,EAAS,GAAQ,CAAC;UAC5C;UACA,WAAW,EACP,kFACA,IAAS,6CAA6C,IACtD,IAAW,+CAA+C,EAC9D;SACJ,CAAC;mBAED,kBAAC,GAAD;UAAO,GAAI;UAAQ,KAAK,KAAA;UAAW,OAAO,EAAO;UAAO,OAAO,EAAO;UACjE;SACE,CAAA;QACN,CAAA;OAEb;MACH,CAAA,CACO;;IACM,CAAA,IACtB;GACQ,CAAA;EACR;;AAEpB,CACJ"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { autoPlacement, autoUpdate, FloatingFocusManager, FloatingPortal, offset, size, useDismiss, useFloating, useInteractions, useListNavigation,
|
|
2
|
+
import { autoPlacement, autoUpdate, FloatingFocusManager, FloatingPortal, offset, size, useDismiss, useFloating, useInteractions, useListNavigation, useTransitionStyles, } from "@floating-ui/react";
|
|
3
3
|
import { CaretDownIcon } from "@phosphor-icons/react";
|
|
4
4
|
import { AnimatePresence, motion } from "motion/react";
|
|
5
|
-
import React, { forwardRef, Fragment, useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import React, { forwardRef, Fragment, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { flushSync } from "react-dom";
|
|
7
7
|
import { Virtuoso } from "react-virtuoso";
|
|
8
8
|
import { Is } from "sidekicker";
|
|
@@ -19,13 +19,13 @@ const transitionStyles = {
|
|
|
19
19
|
close: { transform: "scaleY(0)", opacity: 0 },
|
|
20
20
|
initial: { transform: "scaleY(0)", opacity: 0.2 },
|
|
21
21
|
};
|
|
22
|
-
const List = forwardRef(function VirtualList({ context
|
|
23
|
-
return (<motion.
|
|
22
|
+
const List = forwardRef(function VirtualList({ context, ...props }, ref) {
|
|
23
|
+
return (<motion.div {...props} ref={ref} role="select" id={context?.listboxId} className="max-h-dropdown-max-h w-full overscroll-contain rounded-dropdown-radius">
|
|
24
24
|
<AnimatePresence>{props.children}</AnimatePresence>
|
|
25
|
-
</motion.
|
|
25
|
+
</motion.div>);
|
|
26
26
|
});
|
|
27
27
|
const Item = forwardRef(function VirtualItem({ item: _item, context: _context, ...props }, ref) {
|
|
28
|
-
return <motion.
|
|
28
|
+
return <motion.div {...props} ref={ref} role="presentation" className="first:rounded-t-dropdown-radius last:rounded-t-dropdown-radius"/>;
|
|
29
29
|
});
|
|
30
30
|
const components = { List, Item };
|
|
31
31
|
const EMPTY_NODES = [];
|
|
@@ -36,6 +36,7 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
36
36
|
const virtuoso = useRef(null);
|
|
37
37
|
const defaults = props.value ?? props.defaultValue ?? "";
|
|
38
38
|
const translation = useTranslations();
|
|
39
|
+
const generatedId = useId();
|
|
39
40
|
const [open, setOpen] = useState(false);
|
|
40
41
|
const [shadow, setShadow] = useState("");
|
|
41
42
|
const [value, setValue] = useState(defaults);
|
|
@@ -87,7 +88,6 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
87
88
|
});
|
|
88
89
|
const transitions = useTransitionStyles(context, transitionStyles);
|
|
89
90
|
const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([
|
|
90
|
-
useRole(context, { role: "listbox" }),
|
|
91
91
|
useDismiss(context),
|
|
92
92
|
useListNavigation(context, {
|
|
93
93
|
cols: 0,
|
|
@@ -146,6 +146,7 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
146
146
|
setClosed();
|
|
147
147
|
setShadow("");
|
|
148
148
|
setIndex(i);
|
|
149
|
+
input.focus();
|
|
149
150
|
};
|
|
150
151
|
const onChange = (event) => {
|
|
151
152
|
const value = event.target.value;
|
|
@@ -173,10 +174,12 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
173
174
|
dispatchInput(refs.reference.current);
|
|
174
175
|
setClosed();
|
|
175
176
|
};
|
|
176
|
-
const id = props.id || props.name;
|
|
177
|
+
const id = props.id || props.name || generatedId;
|
|
177
178
|
const shadowId = `${id}-shadow`;
|
|
179
|
+
const listboxId = `${shadowId}-listbox`;
|
|
178
180
|
const isEmpty = displayList.length === 0;
|
|
179
181
|
const isTopPlacement = placement === "top" || placement === "top-start";
|
|
182
|
+
const activeOptionId = open && index !== null && displayList[index] ? `${shadowId}-option-${index}` : undefined;
|
|
180
183
|
return (<InputField {...props} left={left} error={error} id={shadowId} form={props.form} loading={loading} name={props.name} hideLeft={hideLeft} required={required} title={props.title} container={container} rightLabel={rightLabel} interactive={interactive} optionalText={optionalText} componentName="autocomplete" labelClassName={labelClassName} placeholder={props.placeholder} ref={fieldset} feedback={open && isTopPlacement ? props.title : feedback} right={<span className="flex items-center gap-0.5">
|
|
181
184
|
{right}
|
|
182
185
|
<button type="button" className="p-input-gap transition-colors link:text-primary md:p-1" onClick={onCaretDownClick}>
|
|
@@ -199,13 +202,17 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
199
202
|
ref: refs.setReference,
|
|
200
203
|
onClick: (e) => e.currentTarget.focus(),
|
|
201
204
|
onKeyDown(event) {
|
|
205
|
+
props.onKeyDown?.(event);
|
|
206
|
+
if (event.defaultPrevented)
|
|
207
|
+
return;
|
|
202
208
|
if (event.key === "Escape") {
|
|
203
|
-
event.
|
|
209
|
+
event.preventDefault();
|
|
204
210
|
return setClosed();
|
|
205
211
|
}
|
|
206
212
|
if (!open)
|
|
207
213
|
return;
|
|
208
214
|
if (event.key === "ArrowDown") {
|
|
215
|
+
event.preventDefault();
|
|
209
216
|
let next = Is.number(index) ? index + 1 : 0;
|
|
210
217
|
if (next > displayList.length - 1)
|
|
211
218
|
next = 0;
|
|
@@ -213,6 +220,7 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
213
220
|
return setIndex(next);
|
|
214
221
|
}
|
|
215
222
|
if (event.key === "ArrowUp") {
|
|
223
|
+
event.preventDefault();
|
|
216
224
|
let next = Is.number(index) ? index - 1 : displayList.length - 1;
|
|
217
225
|
if (next < 0)
|
|
218
226
|
next = displayList.length - 1;
|
|
@@ -230,7 +238,7 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
230
238
|
}
|
|
231
239
|
}
|
|
232
240
|
},
|
|
233
|
-
})} data-value={value} data-error={!!error} data-name={id} data-target={id} required={required} value={open ? shadow : options.length === 0 ? "" : label || value} aria-autocomplete="list" autoComplete="off" className={css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-input-radius bg-transparent px-input-padding-x py-input-padding-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "text-input-text group-focus-within:border-primary group-hover:border-primary", props.className)}/>
|
|
241
|
+
})} data-value={value} data-error={!!error} data-name={id} data-target={id} required={required} value={open ? shadow : options.length === 0 ? "" : label || value} role="combobox" aria-autocomplete="list" aria-expanded={open} aria-haspopup="listbox" aria-controls={listboxId} aria-activedescendant={activeOptionId} aria-labelledby={`${shadowId}-label`} autoComplete="off" className={css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-input-radius bg-transparent px-input-padding-x py-input-padding-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "text-input-text group-focus-within:border-primary group-hover:border-primary", props.className)}/>
|
|
234
242
|
<input id={id} name={id} type="hidden" data-origin={id} ref={externalRef} required={required} defaultValue={props.value || value || undefined}/>
|
|
235
243
|
<FloatingPortal preserveTabOrder>
|
|
236
244
|
{open ? (<FloatingFocusManager modal guards returnFocus={false} context={context} initialFocus={-1} visuallyHiddenDismiss>
|
|
@@ -257,7 +265,7 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
257
265
|
{emptyMessage || translation.autocompleteEmpty}
|
|
258
266
|
</span>
|
|
259
267
|
</div>) : null}
|
|
260
|
-
<Virtuoso overscan={40} ref={virtuoso} hidden={isEmpty} data={displayList} style={{ height: h }} defaultItemHeight={MIN_SIZE} components={components} scrollerRef={(e) => {
|
|
268
|
+
<Virtuoso overscan={40} ref={virtuoso} hidden={isEmpty} data={displayList} context={{ listboxId }} style={{ height: h }} initialItemCount={displayList.length} defaultItemHeight={MIN_SIZE} components={components} scrollerRef={(e) => {
|
|
261
269
|
scroller.current = e;
|
|
262
270
|
removeScrollRef.current = e;
|
|
263
271
|
}} className="border-floating max-h-full overscroll-contain rounded-dropdown-radius bg-floating-background p-0 text-foreground" itemContent={(i, option) => {
|
|
@@ -265,23 +273,24 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
265
273
|
const active = value === option.value || value === option.label;
|
|
266
274
|
const selected = index === i;
|
|
267
275
|
const children = option.label ?? option.value;
|
|
268
|
-
return (<
|
|
276
|
+
return (<div id={`${shadowId}-option-${i}`} data-value={option.value} {...getItemProps({
|
|
269
277
|
ref: (node) => {
|
|
270
278
|
listRef.current[i] = node;
|
|
271
279
|
},
|
|
272
280
|
role: "option",
|
|
273
|
-
type: "button",
|
|
274
|
-
"aria-checked": active,
|
|
275
|
-
"aria-current": active,
|
|
276
281
|
"aria-selected": active,
|
|
277
282
|
"aria-disabled": option.disabled,
|
|
278
|
-
|
|
279
|
-
|
|
283
|
+
tabIndex: -1,
|
|
284
|
+
onClick: () => {
|
|
285
|
+
if (!option.disabled)
|
|
286
|
+
onSelect(option, i);
|
|
287
|
+
},
|
|
288
|
+
className: css("min-h-10 w-full cursor-pointer p-menu-item-p text-left hover:bg-floating-hover", active ? "bg-primary-hover text-primary-foreground" : "", selected ? "bg-floating-hover text-floating-foreground" : ""),
|
|
280
289
|
})}>
|
|
281
290
|
<Label {...option} ref={undefined} label={option.label} value={option.value}>
|
|
282
291
|
{children}
|
|
283
292
|
</Label>
|
|
284
|
-
</
|
|
293
|
+
</div>);
|
|
285
294
|
}}/>
|
|
286
295
|
</motion.div>
|
|
287
296
|
</FloatingFocusManager>) : null}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/form/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/form/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,MAAM,aAAa,GAAG,QAAQ,CAChC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EACtD;IACI,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC7B,CACJ,CAAC;AAEF,eAAO,MAAM,QAAQ,qGAuDpB,CAAC"}
|
|
@@ -1,34 +1,36 @@
|
|
|
1
1
|
import { t as e } from "../../dom-Bn4wY_Zx.js";
|
|
2
|
-
import { forwardRef as t } from "react";
|
|
3
|
-
import { jsx as
|
|
2
|
+
import { forwardRef as t, useId as n } from "react";
|
|
3
|
+
import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/form/checkbox.tsx
|
|
5
|
-
var
|
|
6
|
-
let
|
|
7
|
-
return /* @__PURE__ */ r("label", {
|
|
8
|
-
"aria-disabled":
|
|
9
|
-
"data-disabled":
|
|
10
|
-
"data-task":
|
|
5
|
+
var o = t(({ children: t, asTask: o = !1, labelClassName: s, loading: c, error: l, className: u = "", size: d, container: f, ...p }, m) => {
|
|
6
|
+
let h = p.disabled || c, g = n(), _ = p.id ?? p.name ?? g, v = l ? `${_}-error` : void 0, y = [p["aria-describedby"], v].filter(Boolean).join(" ") || void 0, b = l ? !0 : p["aria-invalid"];
|
|
7
|
+
return /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ a("label", {
|
|
8
|
+
"aria-disabled": h,
|
|
9
|
+
"data-disabled": h,
|
|
10
|
+
"data-task": o,
|
|
11
11
|
"data-component": "checkbox",
|
|
12
|
-
className: e("group flex w-fit flex-wrap items-center font-normal data-[disabled=true]:cursor-not-allowed",
|
|
13
|
-
children: [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
12
|
+
className: e("group flex w-fit flex-wrap items-center font-normal data-[disabled=true]:cursor-not-allowed", o ? "group-checkbox-checked:line-through" : "", f),
|
|
13
|
+
children: [/* @__PURE__ */ i("input", {
|
|
14
|
+
...p,
|
|
15
|
+
ref: m,
|
|
16
|
+
disabled: h,
|
|
17
|
+
type: "checkbox",
|
|
18
|
+
"data-task": o,
|
|
19
|
+
"aria-invalid": b,
|
|
20
|
+
"aria-describedby": y,
|
|
21
|
+
onKeyDown: (e) => {
|
|
22
|
+
p.onKeyDown?.(e), !e.defaultPrevented && (e.key === " " || e.key === "Space" || e.code === "Space" || e.key === "Enter") && (e.preventDefault(), e.currentTarget.click());
|
|
23
|
+
},
|
|
24
|
+
className: e("form-checkbox mr-checkbox-gap inline-block size-checkbox-size appearance-none rounded-checkbox-radius border-card-border bg-origin-border text-primary focus:ring-primary disabled:opacity-70 group-aria-disabled:cursor-not-allowed", u)
|
|
25
|
+
}), t]
|
|
26
|
+
}), /* @__PURE__ */ i("span", {
|
|
27
|
+
id: v,
|
|
28
|
+
"data-name": "checkbox-label",
|
|
29
|
+
className: e("min-w-full flex-1 text-checkbox-hint-text text-danger empty:mt-0 empty:hidden", s),
|
|
30
|
+
children: l
|
|
31
|
+
})] });
|
|
30
32
|
});
|
|
31
33
|
//#endregion
|
|
32
|
-
export {
|
|
34
|
+
export { o as Checkbox };
|
|
33
35
|
|
|
34
36
|
//# sourceMappingURL=checkbox.js.map
|