@boxcustodia/library 2.0.0-alpha.19 → 2.0.0-alpha.20
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/components/button/button.cjs.js +1 -1
- package/dist/components/button/button.es.js +19 -18
- package/dist/components/button/components/base-button.cjs.js +1 -1
- package/dist/components/button/components/base-button.es.js +20 -20
- package/dist/components/calendar/calendar.cjs.js +1 -1
- package/dist/components/calendar/calendar.es.js +1 -0
- package/dist/components/date-picker/date-input.cjs.js +1 -1
- package/dist/components/date-picker/date-input.es.js +92 -75
- package/dist/components/date-picker/date-picker.cjs.js +1 -1
- package/dist/components/date-picker/date-picker.es.js +104 -95
- package/dist/components/date-picker/date-picker.utils.cjs.js +1 -1
- package/dist/components/date-picker/date-picker.utils.es.js +51 -43
- package/dist/components/date-picker/use-hidden-field-value.cjs.js +1 -0
- package/dist/components/date-picker/use-hidden-field-value.es.js +11 -0
- package/dist/components/menu/menu.es.js +1 -9
- package/dist/components/otp/otp.cjs.js +2 -0
- package/dist/components/otp/otp.es.js +93 -0
- package/dist/components/password/password.cjs.js +1 -1
- package/dist/components/password/password.es.js +2 -2
- package/dist/components/select/select.cjs.js +1 -1
- package/dist/components/select/select.es.js +68 -60
- package/dist/hooks/internal/is-apple-device.cjs.js +1 -0
- package/dist/hooks/internal/is-apple-device.es.js +9 -0
- package/dist/hooks/internal/use-latest-ref.cjs.js +1 -0
- package/dist/hooks/internal/use-latest-ref.es.js +11 -0
- package/dist/hooks/use-array/use-array.cjs.js +1 -1
- package/dist/hooks/use-array/use-array.es.js +54 -42
- package/dist/hooks/use-async/use-async.cjs.js +1 -1
- package/dist/hooks/use-async/use-async.es.js +53 -20
- package/dist/hooks/use-boolean/use-boolean.cjs.js +1 -0
- package/dist/hooks/use-boolean/use-boolean.es.js +25 -0
- package/dist/hooks/use-click-outside/use-click-outside.cjs.js +1 -1
- package/dist/hooks/use-click-outside/use-click-outside.es.js +26 -12
- package/dist/hooks/use-debounce-callback/use-debounced-callback.cjs.js +1 -1
- package/dist/hooks/use-debounce-callback/use-debounced-callback.es.js +27 -10
- package/dist/hooks/use-debounce-value/use-debounced-value.cjs.js +1 -1
- package/dist/hooks/use-debounce-value/use-debounced-value.es.js +7 -9
- package/dist/hooks/use-disclosure/use-disclosure.cjs.js +1 -1
- package/dist/hooks/use-disclosure/use-disclosure.es.js +21 -11
- package/dist/hooks/use-document-title/use-document-title.cjs.js +1 -1
- package/dist/hooks/use-document-title/use-document-title.es.js +14 -12
- package/dist/hooks/use-event-listener/use-event-listener.cjs.js +1 -1
- package/dist/hooks/use-event-listener/use-event-listener.es.js +17 -9
- package/dist/hooks/use-hotkey/use-hotkey.cjs.js +1 -1
- package/dist/hooks/use-hotkey/use-hotkey.es.js +30 -14
- package/dist/hooks/use-hotkey/utils/is-input-field.cjs.js +1 -1
- package/dist/hooks/use-hotkey/utils/is-input-field.es.js +4 -2
- package/dist/hooks/use-hotkey/utils/match-and-run.cjs.js +1 -0
- package/dist/hooks/use-hotkey/utils/match-and-run.es.js +12 -0
- package/dist/hooks/use-hotkey/utils/match-key-modifiers.cjs.js +1 -1
- package/dist/hooks/use-hotkey/utils/match-key-modifiers.es.js +13 -12
- package/dist/hooks/use-hover/use-hover.cjs.js +1 -1
- package/dist/hooks/use-hover/use-hover.es.js +32 -17
- package/dist/hooks/use-is-visible/use-is-visible.cjs.js +1 -1
- package/dist/hooks/use-is-visible/use-is-visible.es.js +31 -27
- package/dist/hooks/use-local-storage/use-local-storage.cjs.js +1 -1
- package/dist/hooks/use-local-storage/use-local-storage.es.js +52 -20
- package/dist/hooks/use-media-query/use-media-query.cjs.js +1 -1
- package/dist/hooks/use-media-query/use-media-query.es.js +21 -11
- package/dist/hooks/use-mutation/use-mutation.cjs.js +1 -1
- package/dist/hooks/use-mutation/use-mutation.es.js +36 -22
- package/dist/hooks/use-object/use-object.cjs.js +1 -1
- package/dist/hooks/use-object/use-object.es.js +26 -22
- package/dist/hooks/use-prevent-page-close/use-prevent-page-close.cjs.js +1 -0
- package/dist/hooks/use-prevent-page-close/use-prevent-page-close.es.js +14 -0
- package/dist/hooks/use-step/use-step.cjs.js +1 -1
- package/dist/hooks/use-step/use-step.es.js +25 -24
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +308 -300
- package/dist/src/components/date-picker/date-picker.utils.d.ts +17 -0
- package/dist/src/components/date-picker/use-hidden-field-value.d.ts +12 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/hooks/index.d.ts +2 -2
- package/dist/src/hooks/internal/index.d.ts +2 -0
- package/dist/src/hooks/internal/is-apple-device.d.ts +12 -0
- package/dist/src/hooks/internal/use-latest-ref.d.ts +12 -0
- package/dist/src/hooks/use-array/use-array.d.ts +24 -11
- package/dist/src/hooks/use-async/use-async.d.ts +16 -13
- package/dist/src/hooks/use-boolean/index.d.ts +1 -0
- package/dist/src/hooks/use-boolean/use-boolean.d.ts +15 -0
- package/dist/src/hooks/use-boolean/use-boolean.test.d.ts +1 -0
- package/dist/src/hooks/use-click-outside/use-click-outside.d.ts +23 -1
- package/dist/src/hooks/use-debounce-callback/use-debounced-callback.d.ts +19 -1
- package/dist/src/hooks/use-debounce-value/use-debounced-value.d.ts +10 -1
- package/dist/src/hooks/use-disclosure/use-disclosure.d.ts +17 -8
- package/dist/src/hooks/use-document-title/use-document-title.d.ts +11 -0
- package/dist/src/hooks/use-event-listener/use-event-listener.d.ts +18 -1
- package/dist/src/hooks/use-hotkey/index.d.ts +2 -1
- package/dist/src/hooks/use-hotkey/use-hotkey.d.ts +62 -5
- package/dist/src/hooks/use-hotkey/utils/index.d.ts +4 -3
- package/dist/src/hooks/use-hotkey/utils/is-input-field.d.ts +12 -2
- package/dist/src/hooks/use-hotkey/utils/is-input-field.test.d.ts +1 -0
- package/dist/src/hooks/use-hotkey/utils/match-and-run.d.ts +36 -0
- package/dist/src/hooks/use-hotkey/utils/match-and-run.test.d.ts +1 -0
- package/dist/src/hooks/use-hotkey/utils/match-key-modifiers.d.ts +20 -6
- package/dist/src/hooks/use-hotkey/utils/match-key-modifiers.test.d.ts +1 -0
- package/dist/src/hooks/use-hover/use-hover.d.ts +8 -4
- package/dist/src/hooks/use-is-visible/use-is-visible.d.ts +28 -4
- package/dist/src/hooks/use-local-storage/use-local-storage.d.ts +13 -2
- package/dist/src/hooks/use-media-query/use-media-query.d.ts +10 -1
- package/dist/src/hooks/use-media-query/use-media-query.test.d.ts +1 -0
- package/dist/src/hooks/use-mutation/use-mutation.d.ts +18 -11
- package/dist/src/hooks/use-object/use-object.d.ts +15 -6
- package/dist/src/hooks/use-prevent-page-close/index.d.ts +1 -0
- package/dist/src/hooks/use-prevent-page-close/use-prevent-page-close.d.ts +10 -0
- package/dist/src/hooks/use-prevent-page-close/use-prevent-page-close.test.d.ts +1 -0
- package/dist/src/hooks/use-step/use-step.d.ts +18 -11
- package/dist/src/utils/form.d.ts +10 -0
- package/package.json +1 -1
- package/src/components/alert-dialog/alert-dialog.test.tsx +13 -9
- package/src/components/auto-complete/auto-complete.test.tsx +4 -14
- package/src/components/avatar/avatar.test.tsx +7 -12
- package/src/components/button/button.test.tsx +10 -15
- package/src/components/button/button.tsx +14 -9
- package/src/components/button/components/base-button.tsx +2 -4
- package/src/components/calendar/calendar.test.tsx +12 -19
- package/src/components/calendar/calendar.tsx +4 -0
- package/src/components/card/card.test.tsx +4 -6
- package/src/components/checkbox/checkbox.test.tsx +12 -8
- package/src/components/checkbox-group/checkbox-group.test.tsx +7 -8
- package/src/components/combobox/combobox.test.tsx +24 -21
- package/src/components/date-picker/date-input-form.test.tsx +77 -0
- package/src/components/date-picker/date-input.stories.tsx +30 -18
- package/src/components/date-picker/date-input.tsx +77 -44
- package/src/components/date-picker/date-picker.stories.tsx +31 -1
- package/src/components/date-picker/date-picker.test.tsx +3 -13
- package/src/components/date-picker/date-picker.tsx +35 -16
- package/src/components/date-picker/date-picker.utils.test.ts +32 -14
- package/src/components/date-picker/date-picker.utils.ts +33 -0
- package/src/components/date-picker/use-date-input-popover.test.ts +3 -1
- package/src/components/date-picker/use-hidden-field-value.ts +23 -0
- package/src/components/dialog/dialog.test.tsx +10 -8
- package/src/components/dropzone/dropzone.test.tsx +11 -13
- package/src/components/empty/empty.test.tsx +4 -3
- package/src/components/field/field.test.tsx +12 -13
- package/src/components/form/form.stories.tsx +16 -1
- package/src/components/index.ts +1 -0
- package/src/components/label/label.test.tsx +3 -3
- package/src/components/menu/menu.tsx +1 -5
- package/src/components/number-input/number-input.test.tsx +6 -2
- package/src/components/password/password.test.tsx +20 -6
- package/src/components/password/password.tsx +2 -2
- package/src/components/popover/popover.test.tsx +4 -4
- package/src/components/progress/progress.test.tsx +7 -8
- package/src/components/radio-group/radio-group.test.tsx +17 -11
- package/src/components/select/select.test.tsx +10 -10
- package/src/components/select/select.tsx +9 -1
- package/src/components/stepper/stepper.stories.tsx +11 -15
- package/src/components/stepper/stepper.test.tsx +6 -4
- package/src/components/switch/switch.test.tsx +3 -3
- package/src/components/table/table.test.tsx +9 -3
- package/src/components/tabs/tabs.test.tsx +6 -2
- package/src/components/tag/tag.test.tsx +1 -3
- package/src/components/textarea/textarea.test.tsx +4 -1
- package/src/components/timeline/timeline.test.tsx +10 -5
- package/src/components/toast/toast.test.tsx +11 -14
- package/src/components/tooltip/tooltip.test.tsx +1 -5
- package/src/components/tree/tree.test.tsx +3 -1
- package/src/hooks/index.ts +2 -2
- package/src/hooks/internal/index.ts +2 -0
- package/src/hooks/internal/is-apple-device.test.ts +41 -0
- package/src/hooks/internal/is-apple-device.ts +33 -0
- package/src/hooks/internal/use-isomorphic-layout-effect.ts +3 -1
- package/src/hooks/internal/use-latest-ref.ts +21 -0
- package/src/hooks/use-array/use-array.stories.tsx +435 -64
- package/src/hooks/use-array/use-array.test.tsx +398 -15
- package/src/hooks/use-array/use-array.ts +105 -66
- package/src/hooks/use-async/use-async.stories.tsx +255 -131
- package/src/hooks/use-async/use-async.test.ts +397 -0
- package/src/hooks/use-async/use-async.ts +117 -39
- package/src/hooks/use-boolean/index.ts +1 -0
- package/src/hooks/use-boolean/use-boolean.stories.tsx +377 -0
- package/src/hooks/use-boolean/use-boolean.test.tsx +177 -0
- package/src/hooks/use-boolean/use-boolean.ts +50 -0
- package/src/hooks/use-click-outside/use-click-outside.stories.tsx +188 -18
- package/src/hooks/use-click-outside/use-click-outside.test.tsx +89 -10
- package/src/hooks/use-click-outside/use-click-outside.ts +62 -16
- package/src/hooks/use-debounce-callback/use-debounced-callback.stories.tsx +141 -41
- package/src/hooks/use-debounce-callback/use-debounced-callback.test.ts +217 -9
- package/src/hooks/use-debounce-callback/use-debounced-callback.ts +71 -11
- package/src/hooks/use-debounce-value/use-debounced-value.stories.tsx +247 -47
- package/src/hooks/use-debounce-value/use-debounced-value.test.ts +105 -10
- package/src/hooks/use-debounce-value/use-debounced-value.ts +19 -10
- package/src/hooks/use-disclosure/use-disclosure.stories.tsx +305 -14
- package/src/hooks/use-disclosure/use-disclosure.test.ts +198 -50
- package/src/hooks/use-disclosure/use-disclosure.ts +49 -29
- package/src/hooks/use-document-title/use-document-title.stories.tsx +54 -0
- package/src/hooks/use-document-title/use-document-title.test.tsx +26 -0
- package/src/hooks/use-document-title/{use-document-title.tsx → use-document-title.ts} +17 -3
- package/src/hooks/use-event-listener/use-event-listener.stories.tsx +105 -9
- package/src/hooks/use-event-listener/use-event-listener.test.tsx +77 -10
- package/src/hooks/use-event-listener/use-event-listener.ts +71 -11
- package/src/hooks/use-focus-trap/use-focus-trap.test.ts +31 -6
- package/src/hooks/use-focus-trap/use-focus-trap.ts +3 -2
- package/src/hooks/use-hotkey/index.ts +9 -1
- package/src/hooks/use-hotkey/use-hotkey.stories.tsx +279 -74
- package/src/hooks/use-hotkey/use-hotkey.test.tsx +286 -34
- package/src/hooks/use-hotkey/use-hotkey.ts +141 -17
- package/src/hooks/use-hotkey/utils/index.ts +8 -3
- package/src/hooks/use-hotkey/utils/is-input-field.test.ts +78 -0
- package/src/hooks/use-hotkey/utils/is-input-field.ts +31 -10
- package/src/hooks/use-hotkey/utils/match-and-run.test.ts +203 -0
- package/src/hooks/use-hotkey/utils/match-and-run.ts +62 -0
- package/src/hooks/use-hotkey/utils/match-key-modifiers.test.ts +65 -0
- package/src/hooks/use-hotkey/utils/match-key-modifiers.ts +39 -12
- package/src/hooks/use-hover/use-hover.stories.tsx +258 -80
- package/src/hooks/use-hover/use-hover.test.tsx +266 -26
- package/src/hooks/use-hover/use-hover.tsx +93 -28
- package/src/hooks/use-is-visible/use-is-visible.stories.tsx +193 -46
- package/src/hooks/use-is-visible/use-is-visible.test.tsx +235 -7
- package/src/hooks/use-is-visible/use-is-visible.ts +114 -0
- package/src/hooks/use-local-storage/use-local-storage.stories.tsx +129 -29
- package/src/hooks/use-local-storage/use-local-storage.test.ts +106 -41
- package/src/hooks/use-local-storage/use-local-storage.ts +100 -31
- package/src/hooks/use-media-query/use-media-query.stories.tsx +86 -26
- package/src/hooks/use-media-query/use-media-query.test.ts +132 -0
- package/src/hooks/use-media-query/use-media-query.ts +39 -14
- package/src/hooks/use-memoized-fn/use-memoized-fn.ts +0 -1
- package/src/hooks/use-mutation/use-mutation.stories.tsx +260 -94
- package/src/hooks/use-mutation/use-mutation.test.ts +359 -0
- package/src/hooks/use-mutation/use-mutation.ts +97 -0
- package/src/hooks/use-object/use-object.stories.tsx +310 -79
- package/src/hooks/use-object/use-object.test.tsx +235 -56
- package/src/hooks/use-object/use-object.ts +59 -0
- package/src/hooks/use-pagination/use-pagination.tsx +0 -1
- package/src/hooks/use-prevent-page-close/index.ts +1 -0
- package/src/hooks/use-prevent-page-close/use-prevent-page-close.stories.tsx +39 -0
- package/src/hooks/use-prevent-page-close/use-prevent-page-close.test.ts +89 -0
- package/src/hooks/use-prevent-page-close/use-prevent-page-close.ts +27 -0
- package/src/hooks/use-range-pagination/use-range-pagination.test.tsx +1 -1
- package/src/hooks/use-range-pagination/use-range-pagination.tsx +1 -1
- package/src/hooks/use-selection/use-selection.ts +0 -1
- package/src/hooks/use-step/use-step.stories.tsx +178 -65
- package/src/hooks/use-step/use-step.test.ts +178 -53
- package/src/hooks/use-step/use-step.ts +57 -49
- package/src/utils/form.test.tsx +13 -8
- package/src/utils/form.tsx +10 -0
- package/src/utils/functions/getFormData.test.ts +1 -1
- package/dist/hooks/use-hotkey/utils/create-hotkey-listener.cjs.js +0 -1
- package/dist/hooks/use-hotkey/utils/create-hotkey-listener.es.js +0 -10
- package/dist/hooks/use-prevent-close-window/use-prevent-close-window.cjs.js +0 -1
- package/dist/hooks/use-prevent-close-window/use-prevent-close-window.es.js +0 -15
- package/dist/hooks/use-toggle/use-toggle.cjs.js +0 -1
- package/dist/hooks/use-toggle/use-toggle.es.js +0 -10
- package/dist/src/hooks/use-hotkey/utils/create-hotkey-listener.d.ts +0 -1
- package/dist/src/hooks/use-prevent-close-window/index.d.ts +0 -1
- package/dist/src/hooks/use-prevent-close-window/use-prevent-close-window.d.ts +0 -13
- package/dist/src/hooks/use-toggle/index.d.ts +0 -1
- package/dist/src/hooks/use-toggle/use-toggle.d.ts +0 -3
- package/src/hooks/use-async/use-async.test.tsx +0 -68
- package/src/hooks/use-hotkey/utils/create-hotkey-listener.ts +0 -25
- package/src/hooks/use-is-visible/use-is-visible.tsx +0 -49
- package/src/hooks/use-mutation/use-mutation.test.tsx +0 -83
- package/src/hooks/use-mutation/use-mutation.tsx +0 -59
- package/src/hooks/use-object/use-object.tsx +0 -46
- package/src/hooks/use-prevent-close-window/index.ts +0 -1
- package/src/hooks/use-prevent-close-window/use-prevent-close-window.stories.tsx +0 -32
- package/src/hooks/use-prevent-close-window/use-prevent-close-window.test.ts +0 -79
- package/src/hooks/use-prevent-close-window/use-prevent-close-window.ts +0 -33
- package/src/hooks/use-toggle/index.ts +0 -1
- package/src/hooks/use-toggle/use-toggle.stories.tsx +0 -25
- package/src/hooks/use-toggle/use-toggle.test.tsx +0 -64
- package/src/hooks/use-toggle/use-toggle.ts +0 -14
- /package/dist/src/{hooks/use-prevent-close-window/use-prevent-close-window.test.d.ts → components/date-picker/date-input-form.test.d.ts} +0 -0
- /package/dist/src/hooks/{use-toggle/use-toggle.test.d.ts → internal/is-apple-device.test.d.ts} +0 -0
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useControllableState as
|
|
4
|
-
import { CalendarIcon as
|
|
5
|
-
import { useState as
|
|
6
|
-
import { formatRangeDate as y, formatMultipleDates as
|
|
2
|
+
import { jsx as o, jsxs as V } from "react/jsx-runtime";
|
|
3
|
+
import { useControllableState as S } from "@radix-ui/react-use-controllable-state";
|
|
4
|
+
import { CalendarIcon as N } from "lucide-react";
|
|
5
|
+
import { useState as C, useRef as O } from "react";
|
|
6
|
+
import { formatRangeDate as y, formatMultipleDates as R, formatISODate as T, formatSingleDate as F } from "./date-picker.utils.es.js";
|
|
7
|
+
import { useHiddenFieldValue as I } from "./use-hidden-field-value.es.js";
|
|
7
8
|
import { Calendar as k } from "../calendar/calendar.es.js";
|
|
8
|
-
import { cn as
|
|
9
|
-
import { PopoverRoot as w, PopoverTrigger as
|
|
10
|
-
import { inputBaseClasses as
|
|
11
|
-
import { FieldControl as E } from "../field/field.es.js";
|
|
12
|
-
function
|
|
13
|
-
return
|
|
9
|
+
import { cn as b } from "../../lib/cn.es.js";
|
|
10
|
+
import { PopoverRoot as w, PopoverTrigger as D, PopoverPopup as M } from "../popover/popover.es.js";
|
|
11
|
+
import { inputBaseClasses as j } from "../input/input.es.js";
|
|
12
|
+
import { FieldControl as E, FieldRoot as $ } from "../field/field.es.js";
|
|
13
|
+
function X(a) {
|
|
14
|
+
return a.mode === "range" ? /* @__PURE__ */ o(B, { ...a }) : a.mode === "multiple" ? /* @__PURE__ */ o(G, { ...a }) : /* @__PURE__ */ o(A, { ...a });
|
|
14
15
|
}
|
|
15
16
|
const x = ({
|
|
16
|
-
open:
|
|
17
|
+
open: a,
|
|
17
18
|
onOpenChange: u,
|
|
18
|
-
displayText:
|
|
19
|
-
hasValue:
|
|
19
|
+
displayText: f,
|
|
20
|
+
hasValue: p,
|
|
20
21
|
disabled: m,
|
|
21
22
|
className: i,
|
|
22
23
|
classNames: d,
|
|
@@ -26,78 +27,86 @@ const x = ({
|
|
|
26
27
|
formValue: v,
|
|
27
28
|
required: c
|
|
28
29
|
}) => {
|
|
29
|
-
const r =
|
|
30
|
-
return /* @__PURE__ */
|
|
31
|
-
/* @__PURE__ */
|
|
32
|
-
|
|
30
|
+
const r = O(null), n = I(v);
|
|
31
|
+
return /* @__PURE__ */ V(w, { "data-slot": s, open: a, onOpenChange: u, children: [
|
|
32
|
+
/* @__PURE__ */ V(
|
|
33
|
+
D,
|
|
33
34
|
{
|
|
34
|
-
render: /* @__PURE__ */
|
|
35
|
+
render: /* @__PURE__ */ o(
|
|
35
36
|
"button",
|
|
36
37
|
{
|
|
37
38
|
ref: r,
|
|
38
39
|
disabled: m,
|
|
39
|
-
className:
|
|
40
|
-
|
|
40
|
+
className: b(
|
|
41
|
+
j,
|
|
41
42
|
"inline-flex items-center gap-2 h-8 cursor-pointer text-left",
|
|
42
43
|
"focus-visible:border-ring",
|
|
43
44
|
"aria-invalid:border-error focus-visible:aria-invalid:ring-error/20",
|
|
44
|
-
|
|
45
|
+
// Attribute selector (specificity 0,2,0) beats `border-input`;
|
|
46
|
+
// `group-data-[invalid]` ties and loses. Matches the OTP convention.
|
|
47
|
+
// The `focus-visible` variant re-asserts the error border so it is
|
|
48
|
+
// not washed out by `focus-visible:border-ring` while focused.
|
|
49
|
+
"in-[[data-slot=field][data-invalid]]:border-error focus-visible:in-[[data-slot=field][data-invalid]]:border-error focus-visible:in-[[data-slot=field][data-invalid]]:ring-error/20",
|
|
45
50
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
46
|
-
!
|
|
51
|
+
!p && "text-muted-foreground",
|
|
47
52
|
i
|
|
48
53
|
)
|
|
49
54
|
}
|
|
50
55
|
),
|
|
51
56
|
children: [
|
|
52
|
-
/* @__PURE__ */
|
|
53
|
-
/* @__PURE__ */
|
|
57
|
+
/* @__PURE__ */ o("span", { className: "flex-1 truncate", children: f }),
|
|
58
|
+
/* @__PURE__ */ o(
|
|
59
|
+
N,
|
|
60
|
+
{
|
|
61
|
+
"data-slot": "date-picker-icon",
|
|
62
|
+
className: "shrink-0 text-muted-foreground"
|
|
63
|
+
}
|
|
64
|
+
)
|
|
54
65
|
]
|
|
55
66
|
}
|
|
56
67
|
),
|
|
57
|
-
/* @__PURE__ */
|
|
68
|
+
/* @__PURE__ */ o(
|
|
58
69
|
E,
|
|
59
70
|
{
|
|
60
|
-
render: /* @__PURE__ */
|
|
71
|
+
render: /* @__PURE__ */ o(
|
|
61
72
|
"input",
|
|
62
73
|
{
|
|
74
|
+
ref: n,
|
|
63
75
|
type: "text",
|
|
64
76
|
tabIndex: -1,
|
|
65
77
|
"aria-hidden": "true",
|
|
66
78
|
className: "sr-only",
|
|
67
|
-
value: v,
|
|
68
|
-
onChange: () => {
|
|
69
|
-
},
|
|
70
79
|
required: c,
|
|
71
80
|
onFocus: () => r.current?.focus()
|
|
72
81
|
}
|
|
73
82
|
)
|
|
74
83
|
}
|
|
75
84
|
),
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
|
|
85
|
+
/* @__PURE__ */ o(
|
|
86
|
+
M,
|
|
78
87
|
{
|
|
79
|
-
className:
|
|
88
|
+
className: b("w-auto p-0", d?.popup),
|
|
80
89
|
align: "start",
|
|
81
90
|
"data-slot": `${s}-content`,
|
|
82
|
-
children: [
|
|
91
|
+
children: /* @__PURE__ */ V($, { className: "contents", children: [
|
|
83
92
|
g,
|
|
84
|
-
l && /* @__PURE__ */
|
|
93
|
+
l && /* @__PURE__ */ o(
|
|
85
94
|
"div",
|
|
86
95
|
{
|
|
87
|
-
className:
|
|
96
|
+
className: b("p-2", d?.footer),
|
|
88
97
|
"data-slot": `${s}-footer`,
|
|
89
98
|
children: l
|
|
90
99
|
}
|
|
91
100
|
)
|
|
92
|
-
]
|
|
101
|
+
] })
|
|
93
102
|
}
|
|
94
103
|
)
|
|
95
104
|
] });
|
|
96
|
-
},
|
|
97
|
-
value:
|
|
105
|
+
}, A = ({
|
|
106
|
+
value: a,
|
|
98
107
|
defaultValue: u,
|
|
99
|
-
onValueChange:
|
|
100
|
-
placeholder:
|
|
108
|
+
onValueChange: f,
|
|
109
|
+
placeholder: p = "Seleccionar fecha",
|
|
101
110
|
disabled: m,
|
|
102
111
|
disabledDate: i,
|
|
103
112
|
renderFooter: d,
|
|
@@ -105,53 +114,53 @@ const x = ({
|
|
|
105
114
|
classNames: l,
|
|
106
115
|
required: s
|
|
107
116
|
}) => {
|
|
108
|
-
const [v, c] =
|
|
109
|
-
prop:
|
|
110
|
-
onChange: (e) =>
|
|
117
|
+
const [v, c] = C(!1), [r, n] = S({
|
|
118
|
+
prop: a,
|
|
119
|
+
onChange: (e) => f?.(e ?? null),
|
|
111
120
|
defaultProp: u ?? null
|
|
112
|
-
}),
|
|
121
|
+
}), t = {
|
|
113
122
|
mode: "single",
|
|
114
123
|
value: r ?? null,
|
|
115
|
-
clear: () =>
|
|
124
|
+
clear: () => n(null),
|
|
116
125
|
selectToday: () => {
|
|
117
126
|
const e = /* @__PURE__ */ new Date();
|
|
118
|
-
i?.(e) ||
|
|
127
|
+
i?.(e) || n(e);
|
|
119
128
|
},
|
|
120
|
-
setValue: (e) =>
|
|
129
|
+
setValue: (e) => n(e)
|
|
121
130
|
};
|
|
122
|
-
return /* @__PURE__ */
|
|
131
|
+
return /* @__PURE__ */ o(
|
|
123
132
|
x,
|
|
124
133
|
{
|
|
125
134
|
slot: "date-picker",
|
|
126
135
|
open: v,
|
|
127
136
|
onOpenChange: c,
|
|
128
|
-
displayText:
|
|
137
|
+
displayText: F(r, p),
|
|
129
138
|
hasValue: !!r,
|
|
130
139
|
disabled: m,
|
|
131
140
|
className: g,
|
|
132
141
|
classNames: l,
|
|
133
|
-
footer: d?.(
|
|
134
|
-
formValue:
|
|
142
|
+
footer: d?.(t),
|
|
143
|
+
formValue: T(r),
|
|
135
144
|
required: s,
|
|
136
|
-
children: /* @__PURE__ */
|
|
145
|
+
children: /* @__PURE__ */ o(
|
|
137
146
|
k,
|
|
138
147
|
{
|
|
139
|
-
className:
|
|
148
|
+
className: b("border-none", l?.calendar),
|
|
140
149
|
mode: "single",
|
|
141
150
|
selected: r ?? void 0,
|
|
142
151
|
onSelect: (e) => {
|
|
143
|
-
i && e && i(e) || (
|
|
152
|
+
i && e && i(e) || (n(e ?? null), c(!1));
|
|
144
153
|
},
|
|
145
154
|
disabled: i
|
|
146
155
|
}
|
|
147
156
|
)
|
|
148
157
|
}
|
|
149
158
|
);
|
|
150
|
-
},
|
|
151
|
-
value:
|
|
159
|
+
}, P = { start: null, end: null }, B = ({
|
|
160
|
+
value: a,
|
|
152
161
|
defaultValue: u,
|
|
153
|
-
onValueChange:
|
|
154
|
-
placeholder:
|
|
162
|
+
onValueChange: f,
|
|
163
|
+
placeholder: p = "Seleccionar rango",
|
|
155
164
|
disabled: m,
|
|
156
165
|
disabledDate: i,
|
|
157
166
|
renderFooter: d,
|
|
@@ -159,58 +168,58 @@ const x = ({
|
|
|
159
168
|
classNames: l,
|
|
160
169
|
required: s
|
|
161
170
|
}) => {
|
|
162
|
-
const [v, c] =
|
|
163
|
-
prop:
|
|
164
|
-
onChange: (h) =>
|
|
165
|
-
defaultProp: u ??
|
|
166
|
-
}),
|
|
171
|
+
const [v, c] = C(!1), [r, n] = S({
|
|
172
|
+
prop: a,
|
|
173
|
+
onChange: (h) => f?.(h ?? P),
|
|
174
|
+
defaultProp: u ?? P
|
|
175
|
+
}), t = r ?? P, e = {
|
|
167
176
|
mode: "range",
|
|
168
|
-
value:
|
|
169
|
-
clear: () =>
|
|
170
|
-
setValue: (h) =>
|
|
177
|
+
value: t,
|
|
178
|
+
clear: () => n(P),
|
|
179
|
+
setValue: (h) => n(h)
|
|
171
180
|
};
|
|
172
|
-
return /* @__PURE__ */
|
|
181
|
+
return /* @__PURE__ */ o(
|
|
173
182
|
x,
|
|
174
183
|
{
|
|
175
184
|
slot: "date-picker",
|
|
176
185
|
open: v,
|
|
177
186
|
onOpenChange: c,
|
|
178
187
|
displayText: y(
|
|
179
|
-
|
|
180
|
-
|
|
188
|
+
t.start || t.end ? t : void 0,
|
|
189
|
+
p
|
|
181
190
|
),
|
|
182
|
-
hasValue: !!(
|
|
191
|
+
hasValue: !!(t.start || t.end),
|
|
183
192
|
disabled: m,
|
|
184
193
|
className: g,
|
|
185
194
|
classNames: l,
|
|
186
195
|
footer: d?.(e),
|
|
187
196
|
formValue: y(
|
|
188
|
-
|
|
197
|
+
t.start || t.end ? t : void 0,
|
|
189
198
|
""
|
|
190
199
|
),
|
|
191
200
|
required: s,
|
|
192
|
-
children: /* @__PURE__ */
|
|
201
|
+
children: /* @__PURE__ */ o(
|
|
193
202
|
k,
|
|
194
203
|
{
|
|
195
|
-
className:
|
|
204
|
+
className: b("border-none", l?.calendar),
|
|
196
205
|
mode: "range",
|
|
197
206
|
selected: {
|
|
198
|
-
from:
|
|
199
|
-
to:
|
|
207
|
+
from: t.start ?? void 0,
|
|
208
|
+
to: t.end ?? void 0
|
|
200
209
|
},
|
|
201
210
|
onSelect: (h) => {
|
|
202
|
-
|
|
211
|
+
n({ start: h?.from ?? null, end: h?.to ?? null });
|
|
203
212
|
},
|
|
204
213
|
disabled: i
|
|
205
214
|
}
|
|
206
215
|
)
|
|
207
216
|
}
|
|
208
217
|
);
|
|
209
|
-
},
|
|
210
|
-
value:
|
|
218
|
+
}, G = ({
|
|
219
|
+
value: a,
|
|
211
220
|
defaultValue: u,
|
|
212
|
-
onValueChange:
|
|
213
|
-
placeholder:
|
|
221
|
+
onValueChange: f,
|
|
222
|
+
placeholder: p = "Seleccionar fechas",
|
|
214
223
|
disabled: m,
|
|
215
224
|
disabledDate: i,
|
|
216
225
|
renderFooter: d,
|
|
@@ -218,38 +227,38 @@ const x = ({
|
|
|
218
227
|
classNames: l,
|
|
219
228
|
required: s
|
|
220
229
|
}) => {
|
|
221
|
-
const [v, c] =
|
|
222
|
-
prop:
|
|
223
|
-
onChange: (e) =>
|
|
230
|
+
const [v, c] = C(!1), [r, n] = S({
|
|
231
|
+
prop: a,
|
|
232
|
+
onChange: (e) => f?.(e ?? []),
|
|
224
233
|
defaultProp: u ?? []
|
|
225
|
-
}),
|
|
234
|
+
}), t = {
|
|
226
235
|
mode: "multiple",
|
|
227
236
|
value: r ?? [],
|
|
228
|
-
clear: () =>
|
|
229
|
-
setValue: (e) =>
|
|
237
|
+
clear: () => n([]),
|
|
238
|
+
setValue: (e) => n(e)
|
|
230
239
|
};
|
|
231
|
-
return /* @__PURE__ */
|
|
240
|
+
return /* @__PURE__ */ o(
|
|
232
241
|
x,
|
|
233
242
|
{
|
|
234
243
|
slot: "date-picker",
|
|
235
244
|
open: v,
|
|
236
245
|
onOpenChange: c,
|
|
237
|
-
displayText:
|
|
246
|
+
displayText: R(r, p),
|
|
238
247
|
hasValue: (r?.length ?? 0) > 0,
|
|
239
248
|
disabled: m,
|
|
240
249
|
className: g,
|
|
241
250
|
classNames: l,
|
|
242
|
-
footer: d?.(
|
|
243
|
-
formValue:
|
|
251
|
+
footer: d?.(t),
|
|
252
|
+
formValue: R(r, ""),
|
|
244
253
|
required: s,
|
|
245
|
-
children: /* @__PURE__ */
|
|
254
|
+
children: /* @__PURE__ */ o(
|
|
246
255
|
k,
|
|
247
256
|
{
|
|
248
|
-
className:
|
|
257
|
+
className: b("border-none", l?.calendar),
|
|
249
258
|
mode: "multiple",
|
|
250
259
|
selected: r ?? [],
|
|
251
260
|
onSelect: (e) => {
|
|
252
|
-
|
|
261
|
+
n(e ?? []);
|
|
253
262
|
},
|
|
254
263
|
disabled: i
|
|
255
264
|
}
|
|
@@ -258,5 +267,5 @@ const x = ({
|
|
|
258
267
|
);
|
|
259
268
|
};
|
|
260
269
|
export {
|
|
261
|
-
|
|
270
|
+
X as DatePicker
|
|
262
271
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("date-fns"),g="dd/MM/yyyy",S=(e,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("date-fns"),g="dd/MM/yyyy",S=(e,n)=>!e||!o.isDate(e)?n:o.format(e,g),M=e=>!e||!o.isDate(e)?"":o.format(e,"yyyy-MM-dd"),$=(e,n)=>{if(!e)return n;const{start:i,end:u}=e;if(!i&&!u)return n;const N=i&&o.isDate(i)?o.format(i,g):"...",h=u&&o.isDate(u)?o.format(u,g):"...";return`${N} → ${h}`},I=(e,n)=>!e||e.length===0?n:e.length===1?o.format(e[0],g):`${e.length} fechas seleccionadas`,T=e=>o.isDate(e)?o.format(e,g):"",P=(e,n)=>{if(!e)return;Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value")?.set?.call(e,n),e.dispatchEvent(new Event("input",{bubbles:!0}))},v=e=>{const n=e.trim();if(!n)return null;const i=/^(\d{1,2})\/(\d{1,2})\/(\d{1,4})$/.exec(n);if(!i)return null;const[,u,N,h]=i,s=Number(u),m=Number(N),l=h;let c=Number(l);if(Number.isNaN(s)||Number.isNaN(m)||Number.isNaN(c)||(l.length<=2&&(c=2e3+c),s<1||s>31||m<1||m>12))return null;const a=new Date(c,m-1,s);return a.getFullYear()!==c||a.getMonth()!==m-1||a.getDate()!==s?null:a},A=(e,n)=>{const i=(n.lastKey==="Backspace"||n.lastKey==="Delete")&&e.length<n.previousValue.length,u=e.includes("/"),N=e.trim().endsWith("/");if((e.match(/\//g)??[]).length>=2){const r=e.split("/"),t=(r[0]??"").replace(/\D/g,"").slice(0,2),b=(r[1]??"").replace(/\D/g,"").slice(0,2),p=(r[2]??"").replace(/\D/g,"").slice(0,4);return!t&&!b&&!p?"":`${t}/${b}/${p}`}const s=e.replace(/\D/g,"").slice(0,8);if(!s)return"";if(s.length<=2){let r=s;if(s.length===1&&(u||N)&&!i){let t=Number(r);Number.isNaN(t)&&(t=1),t<1&&(t=1),t>31&&(t=31),r=t.toString().padStart(2,"0"),r+="/"}else if(s.length===2&&!i){let t=Number(r);Number.isNaN(t)&&(t=1),t<1&&(t=1),t>31&&(t=31),r=t.toString().padStart(2,"0"),r+="/"}return r}const m=s.slice(0,2);let l=Number(m);Number.isNaN(l)&&(l=1),l<1&&(l=1),l>31&&(l=31);const c=l.toString().padStart(2,"0"),a=s.slice(2,4),D=s.slice(4);let f="";if(a.length===0)f="";else if(a.length===1&&D.length===0){const r=N&&!i&&a.length===1;if(a==="0"||a==="1")if(r){let t=Number(a);Number.isNaN(t)&&(t=1),t<1&&(t=1),t>12&&(t=12),f=t.toString().padStart(2,"0")}else f=a;else{let t=Number(a);Number.isNaN(t)&&(t=1),t<1&&(t=1),t>12&&(t=12),f=t.toString().padStart(2,"0")}}else{let r=Number(a);Number.isNaN(r)&&(r=1),r<1&&(r=1),r>12&&(r=12),f=r.toString().padStart(2,"0")}const d=`${c}/${f}`,y=!D&&f.length===2&&!i;return D?`${d}/${D}`:y?`${d}/`:d};exports.DISPLAY_DATE_FORMAT=g;exports.emitNativeInputChange=P;exports.formatDate=T;exports.formatISODate=M;exports.formatMultipleDates=I;exports.formatRangeDate=$;exports.formatSingleDate=S;exports.maskDateInput=A;exports.parseInputToDate=v;
|
|
@@ -1,73 +1,81 @@
|
|
|
1
|
-
import { isDate as
|
|
2
|
-
const
|
|
3
|
-
if (!e) return
|
|
1
|
+
import { isDate as g, format as N } from "date-fns";
|
|
2
|
+
const h = "dd/MM/yyyy", I = (e, n) => !e || !g(e) ? n : N(e, h), P = (e) => !e || !g(e) ? "" : N(e, "yyyy-MM-dd"), k = (e, n) => {
|
|
3
|
+
if (!e) return n;
|
|
4
4
|
const { start: a, end: o } = e;
|
|
5
|
-
if (!a && !o) return
|
|
6
|
-
const f = a &&
|
|
7
|
-
return `${f} → ${
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
if (!a && !o) return n;
|
|
6
|
+
const f = a && g(a) ? N(a, h) : "...", d = o && g(o) ? N(o, h) : "...";
|
|
7
|
+
return `${f} → ${d}`;
|
|
8
|
+
}, v = (e, n) => !e || e.length === 0 ? n : e.length === 1 ? N(e[0], h) : `${e.length} fechas seleccionadas`, T = (e) => g(e) ? N(e, h) : "", A = (e, n) => {
|
|
9
|
+
if (!e) return;
|
|
10
|
+
Object.getOwnPropertyDescriptor(
|
|
11
|
+
HTMLInputElement.prototype,
|
|
12
|
+
"value"
|
|
13
|
+
)?.set?.call(e, n), e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
14
|
+
}, E = (e) => {
|
|
15
|
+
const n = e.trim();
|
|
16
|
+
if (!n) return null;
|
|
17
|
+
const a = /^(\d{1,2})\/(\d{1,2})\/(\d{1,4})$/.exec(n);
|
|
12
18
|
if (!a) return null;
|
|
13
|
-
const [, o, f,
|
|
19
|
+
const [, o, f, d] = a, s = Number(o), u = Number(f), l = d;
|
|
14
20
|
let c = Number(l);
|
|
15
|
-
if (Number.isNaN(
|
|
21
|
+
if (Number.isNaN(s) || Number.isNaN(u) || Number.isNaN(c) || (l.length <= 2 && (c = 2e3 + c), s < 1 || s > 31 || u < 1 || u > 12))
|
|
16
22
|
return null;
|
|
17
|
-
const
|
|
18
|
-
return
|
|
19
|
-
},
|
|
20
|
-
const a = (
|
|
23
|
+
const i = new Date(c, u - 1, s);
|
|
24
|
+
return i.getFullYear() !== c || i.getMonth() !== u - 1 || i.getDate() !== s ? null : i;
|
|
25
|
+
}, O = (e, n) => {
|
|
26
|
+
const a = (n.lastKey === "Backspace" || n.lastKey === "Delete") && e.length < n.previousValue.length, o = e.includes("/"), f = e.trim().endsWith("/");
|
|
21
27
|
if ((e.match(/\//g) ?? []).length >= 2) {
|
|
22
|
-
const r = e.split("/"), t = (r[0] ?? "").replace(/\D/g, "").slice(0, 2),
|
|
23
|
-
return !t && !
|
|
28
|
+
const r = e.split("/"), t = (r[0] ?? "").replace(/\D/g, "").slice(0, 2), p = (r[1] ?? "").replace(/\D/g, "").slice(0, 2), D = (r[2] ?? "").replace(/\D/g, "").slice(0, 4);
|
|
29
|
+
return !t && !p && !D ? "" : `${t}/${p}/${D}`;
|
|
24
30
|
}
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
31
|
+
const s = e.replace(/\D/g, "").slice(0, 8);
|
|
32
|
+
if (!s)
|
|
27
33
|
return "";
|
|
28
|
-
if (
|
|
29
|
-
let r =
|
|
30
|
-
if (
|
|
34
|
+
if (s.length <= 2) {
|
|
35
|
+
let r = s;
|
|
36
|
+
if (s.length === 1 && (o || f) && !a) {
|
|
31
37
|
let t = Number(r);
|
|
32
38
|
Number.isNaN(t) && (t = 1), t < 1 && (t = 1), t > 31 && (t = 31), r = t.toString().padStart(2, "0"), r += "/";
|
|
33
|
-
} else if (
|
|
39
|
+
} else if (s.length === 2 && !a) {
|
|
34
40
|
let t = Number(r);
|
|
35
41
|
Number.isNaN(t) && (t = 1), t < 1 && (t = 1), t > 31 && (t = 31), r = t.toString().padStart(2, "0"), r += "/";
|
|
36
42
|
}
|
|
37
43
|
return r;
|
|
38
44
|
}
|
|
39
|
-
const u =
|
|
45
|
+
const u = s.slice(0, 2);
|
|
40
46
|
let l = Number(u);
|
|
41
47
|
Number.isNaN(l) && (l = 1), l < 1 && (l = 1), l > 31 && (l = 31);
|
|
42
|
-
const c = l.toString().padStart(2, "0"),
|
|
48
|
+
const c = l.toString().padStart(2, "0"), i = s.slice(2, 4), b = s.slice(4);
|
|
43
49
|
let m = "";
|
|
44
|
-
if (
|
|
50
|
+
if (i.length === 0)
|
|
45
51
|
m = "";
|
|
46
|
-
else if (
|
|
47
|
-
const r = f && !a &&
|
|
48
|
-
if (
|
|
52
|
+
else if (i.length === 1 && b.length === 0) {
|
|
53
|
+
const r = f && !a && i.length === 1;
|
|
54
|
+
if (i === "0" || i === "1")
|
|
49
55
|
if (r) {
|
|
50
|
-
let t = Number(
|
|
56
|
+
let t = Number(i);
|
|
51
57
|
Number.isNaN(t) && (t = 1), t < 1 && (t = 1), t > 12 && (t = 12), m = t.toString().padStart(2, "0");
|
|
52
58
|
} else
|
|
53
|
-
m =
|
|
59
|
+
m = i;
|
|
54
60
|
else {
|
|
55
|
-
let t = Number(
|
|
61
|
+
let t = Number(i);
|
|
56
62
|
Number.isNaN(t) && (t = 1), t < 1 && (t = 1), t > 12 && (t = 12), m = t.toString().padStart(2, "0");
|
|
57
63
|
}
|
|
58
64
|
} else {
|
|
59
|
-
let r = Number(
|
|
65
|
+
let r = Number(i);
|
|
60
66
|
Number.isNaN(r) && (r = 1), r < 1 && (r = 1), r > 12 && (r = 12), m = r.toString().padStart(2, "0");
|
|
61
67
|
}
|
|
62
|
-
const y = `${c}/${m}`, S = !
|
|
63
|
-
return
|
|
68
|
+
const y = `${c}/${m}`, S = !b && m.length === 2 && !a;
|
|
69
|
+
return b ? `${y}/${b}` : S ? `${y}/` : y;
|
|
64
70
|
};
|
|
65
71
|
export {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
P as
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
h as DISPLAY_DATE_FORMAT,
|
|
73
|
+
A as emitNativeInputChange,
|
|
74
|
+
T as formatDate,
|
|
75
|
+
P as formatISODate,
|
|
76
|
+
v as formatMultipleDates,
|
|
77
|
+
k as formatRangeDate,
|
|
78
|
+
I as formatSingleDate,
|
|
79
|
+
O as maskDateInput,
|
|
80
|
+
E as parseInputToDate
|
|
73
81
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),i=require("./date-picker.utils.cjs.js");function n(e){const t=u.useRef(null);return u.useEffect(()=>{i.emitNativeInputChange(t.current,e)},[e]),t}exports.useHiddenFieldValue=n;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useRef as r, useEffect as n } from "react";
|
|
2
|
+
import { emitNativeInputChange as u } from "./date-picker.utils.es.js";
|
|
3
|
+
function o(e) {
|
|
4
|
+
const t = r(null);
|
|
5
|
+
return n(() => {
|
|
6
|
+
u(t.current, e);
|
|
7
|
+
}, [e]), t;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
o as useHiddenFieldValue
|
|
11
|
+
};
|
|
@@ -27,15 +27,7 @@ function l(o, c) {
|
|
|
27
27
|
}
|
|
28
28
|
case "radio-group": {
|
|
29
29
|
const { type: u, value: e, onValueChange: r, items: n } = o;
|
|
30
|
-
return /* @__PURE__ */ t(
|
|
31
|
-
C,
|
|
32
|
-
{
|
|
33
|
-
value: e,
|
|
34
|
-
onValueChange: r,
|
|
35
|
-
children: n.map((p, a) => l(p, a))
|
|
36
|
-
},
|
|
37
|
-
c
|
|
38
|
-
);
|
|
30
|
+
return /* @__PURE__ */ t(C, { value: e, onValueChange: r, children: n.map((p, a) => l(p, a)) }, c);
|
|
39
31
|
}
|
|
40
32
|
case "label": {
|
|
41
33
|
const { type: u, label: e, ...r } = o;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("@base-ui/react/otp-field"),f=require("react"),g=require("../divider/divider.cjs.js"),s=require("../../lib/cn.cjs.js");function l({className:t,size:a="default",...r}){return e.jsx(i.OTPFieldPreview.Root,{className:s.cn("flex items-center gap-2 has-disabled:opacity-64 has-disabled:**:data-[slot=otp-input]:shadow-none has-disabled:**:data-[slot=otp-input]:before:shadow-none!",t),"data-size":a,"data-slot":"otp",...r})}function u({className:t,...a}){return e.jsx(i.OTPFieldPreview.Input,{className:s.cn("in-[[data-slot=otp][data-size=lg]]:size-10 size-9 min-w-0 rounded-lg border border-input bg-background text-center in-[[data-slot=otp][data-size=lg]]:text-lg text-base text-foreground in-[[data-slot=otp][data-size=lg]]:leading-10 leading-9 outline-none transition-shadow focus-visible:z-10 focus-visible:border-ring aria-invalid:border-error focus-visible:aria-invalid:border-error focus-visible:aria-invalid:ring-error/20 in-[[data-slot=field][data-invalid]]:border-error in-[[data-slot=field][data-invalid]]:focus-visible:border-error in-[[data-slot=field][data-invalid]]:focus-visible:ring-error/20 sm:in-[[data-slot=otp][data-size=lg]]:size-9 sm:size-8 sm:in-[[data-slot=otp][data-size=lg]]:text-base sm:text-sm sm:in-[[data-slot=otp][data-size=lg]]:leading-9 sm:leading-8",t),"data-slot":"otp-input",spellCheck:!1,...a})}function c({className:t,...a}){return e.jsx(i.OTPFieldPreview.Separator,{render:e.jsx(g.Divider,{className:s.cn("rounded-full bg-input data-[orientation=horizontal]:h-0.5 data-[orientation=horizontal]:w-3",t),orientation:"horizontal",...a})})}function v({split:t,inputProps:a,size:r,length:o,"aria-invalid":d,...p}){const b={...d?{"aria-invalid":!0}:{},...a};return e.jsx(l,{size:r,length:o,"aria-invalid":d,...p,children:Array.from({length:o},(P,n)=>e.jsxs(f.Fragment,{children:[e.jsx(u,{"aria-label":`Character ${n+1} of ${o}`,...b}),t===n+1&&e.jsx(c,{})]},n))})}Object.defineProperty(exports,"OTPPrimitive",{enumerable:!0,get:()=>i.OTPFieldPreview});exports.OTP=v;exports.OTPInput=u;exports.OTPRoot=l;exports.OTPSeparator=c;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as i, jsxs as u } from "react/jsx-runtime";
|
|
3
|
+
import { OTPFieldPreview as n } from "@base-ui/react/otp-field";
|
|
4
|
+
import { OTPFieldPreview as N } from "@base-ui/react/otp-field";
|
|
5
|
+
import { Fragment as f } from "react";
|
|
6
|
+
import { Divider as m } from "../divider/divider.es.js";
|
|
7
|
+
import { cn as s } from "../../lib/cn.es.js";
|
|
8
|
+
function b({
|
|
9
|
+
className: a,
|
|
10
|
+
size: t = "default",
|
|
11
|
+
...o
|
|
12
|
+
}) {
|
|
13
|
+
return /* @__PURE__ */ i(
|
|
14
|
+
n.Root,
|
|
15
|
+
{
|
|
16
|
+
className: s(
|
|
17
|
+
"flex items-center gap-2 has-disabled:opacity-64 has-disabled:**:data-[slot=otp-input]:shadow-none has-disabled:**:data-[slot=otp-input]:before:shadow-none!",
|
|
18
|
+
a
|
|
19
|
+
),
|
|
20
|
+
"data-size": t,
|
|
21
|
+
"data-slot": "otp",
|
|
22
|
+
...o
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
function c({
|
|
27
|
+
className: a,
|
|
28
|
+
...t
|
|
29
|
+
}) {
|
|
30
|
+
return /* @__PURE__ */ i(
|
|
31
|
+
n.Input,
|
|
32
|
+
{
|
|
33
|
+
className: s(
|
|
34
|
+
"in-[[data-slot=otp][data-size=lg]]:size-10 size-9 min-w-0 rounded-lg border border-input bg-background text-center in-[[data-slot=otp][data-size=lg]]:text-lg text-base text-foreground in-[[data-slot=otp][data-size=lg]]:leading-10 leading-9 outline-none transition-shadow focus-visible:z-10 focus-visible:border-ring aria-invalid:border-error focus-visible:aria-invalid:border-error focus-visible:aria-invalid:ring-error/20 in-[[data-slot=field][data-invalid]]:border-error in-[[data-slot=field][data-invalid]]:focus-visible:border-error in-[[data-slot=field][data-invalid]]:focus-visible:ring-error/20 sm:in-[[data-slot=otp][data-size=lg]]:size-9 sm:size-8 sm:in-[[data-slot=otp][data-size=lg]]:text-base sm:text-sm sm:in-[[data-slot=otp][data-size=lg]]:leading-9 sm:leading-8",
|
|
35
|
+
a
|
|
36
|
+
),
|
|
37
|
+
"data-slot": "otp-input",
|
|
38
|
+
spellCheck: !1,
|
|
39
|
+
...t
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
function g({
|
|
44
|
+
className: a,
|
|
45
|
+
...t
|
|
46
|
+
}) {
|
|
47
|
+
return /* @__PURE__ */ i(
|
|
48
|
+
n.Separator,
|
|
49
|
+
{
|
|
50
|
+
render: /* @__PURE__ */ i(
|
|
51
|
+
m,
|
|
52
|
+
{
|
|
53
|
+
className: s(
|
|
54
|
+
"rounded-full bg-input data-[orientation=horizontal]:h-0.5 data-[orientation=horizontal]:w-3",
|
|
55
|
+
a
|
|
56
|
+
),
|
|
57
|
+
orientation: "horizontal",
|
|
58
|
+
...t
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
function O({
|
|
65
|
+
split: a,
|
|
66
|
+
inputProps: t,
|
|
67
|
+
size: o,
|
|
68
|
+
length: r,
|
|
69
|
+
"aria-invalid": d,
|
|
70
|
+
...l
|
|
71
|
+
}) {
|
|
72
|
+
const p = {
|
|
73
|
+
...d ? { "aria-invalid": !0 } : {},
|
|
74
|
+
...t
|
|
75
|
+
};
|
|
76
|
+
return /* @__PURE__ */ i(b, { size: o, length: r, "aria-invalid": d, ...l, children: Array.from({ length: r }, (v, e) => /* @__PURE__ */ u(f, { children: [
|
|
77
|
+
/* @__PURE__ */ i(
|
|
78
|
+
c,
|
|
79
|
+
{
|
|
80
|
+
"aria-label": `Character ${e + 1} of ${r}`,
|
|
81
|
+
...p
|
|
82
|
+
}
|
|
83
|
+
),
|
|
84
|
+
a === e + 1 && /* @__PURE__ */ i(g, {})
|
|
85
|
+
] }, e)) });
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
O as OTP,
|
|
89
|
+
c as OTPInput,
|
|
90
|
+
N as OTPPrimitive,
|
|
91
|
+
b as OTPRoot,
|
|
92
|
+
g as OTPSeparator
|
|
93
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("lucide-react"),m=require("@base-ui/react/input"),x=require("../../hooks/use-
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("lucide-react"),m=require("@base-ui/react/input"),x=require("../../hooks/use-boolean/use-boolean.cjs.js"),o=require("../../lib/cn.cjs.js");function i({className:d,showIcon:l=e.jsx(n.Eye,{className:"h-4 w-4"}),hideIcon:c=e.jsx(n.EyeOff,{className:"h-4 w-4"}),onShow:u,onHide:g,toggleable:h=!0,onValueChange:s,classNames:t,...w}){const[r,{toggle:b}]=x.useBoolean(!1),p=()=>{b(),r?g?.():u?.()},f=s?a=>s(a.target.value,a):void 0;return e.jsxs("div",{className:o.cn("relative inline-flex h-8 w-full items-center text-sm","rounded-md border border-input bg-background transition-shadow","focus-within:border-ring","aria-invalid:border-error focus-within:aria-invalid:ring-error/20","has-aria-invalid:border-error focus-within:has-aria-invalid:ring-error/20","has-disabled:cursor-not-allowed has-disabled:opacity-50","[&::-ms-clear]:hidden [&::-ms-reveal]:hidden",d),"data-slot":"password",children:[e.jsx(m.Input,{...w,onChange:f,type:r?"text":"password",className:o.cn("min-w-0 flex-1 bg-transparent pl-3 outline-none","placeholder:text-muted-foreground","disabled:cursor-not-allowed",t?.input)}),e.jsx("button",{"data-slot":"password-toggle",type:"button",onClick:p,disabled:!h,className:o.cn("flex shrink-0 items-center px-2 text-muted-foreground transition-colors","hover:text-foreground","disabled:cursor-not-allowed disabled:opacity-50",t?.toggle),children:r?c:l})]})}exports.Password=i;exports.PasswordRoot=i;
|