@datum-cloud/datum-ui 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapter-context-NyGTDZYq.mjs → adapter-context-DemTWhel.mjs} +3 -3
- package/dist/alert/index.mjs +1 -1
- package/dist/{alert-BDj6od5I.mjs → alert-Cz56SqdN.mjs} +2 -2
- package/dist/app-navigation/index.mjs +2 -2
- package/dist/{app-navigation-rSOfo1KV.mjs → app-navigation-CnGkJvwF.mjs} +1 -1
- package/dist/autocomplete/index.mjs +1 -1
- package/dist/{autocomplete-DdbTQe6u.mjs → autocomplete-ChuPNldi.mjs} +6 -6
- package/dist/autosearch/index.mjs +12 -12
- package/dist/avatar-stack/index.mjs +1 -1
- package/dist/{avatar-stack-CDhlA1Nm.mjs → avatar-stack-WqoQ3l06.mjs} +1 -1
- package/dist/{button-D3RrsMfQ.mjs → button-Rw1xI-k9.mjs} +2 -2
- package/dist/calendar/index.mjs +1 -1
- package/dist/calendar-D_DriVHT.mjs +77 -0
- package/dist/{calendar-C-Hbf74r.mjs → calendar-Dwvq3Vu_.mjs} +6 -6
- package/dist/calendar-date-picker-CchHKodM.mjs +52 -0
- package/dist/chart/index.mjs +1 -1
- package/dist/{chart-CUa21ynK.mjs → chart-DgcOwkOh.mjs} +5 -5
- package/dist/code-editor/index.mjs +1 -1
- package/dist/{col-DISdGlqY.mjs → col-Q6yazFwL.mjs} +2 -1
- package/dist/components/base/button/button.d.ts.map +1 -1
- package/dist/components/features/calendar-date-picker/calendar-date-picker.d.ts +6 -5
- package/dist/components/features/calendar-date-picker/calendar-date-picker.d.ts.map +1 -1
- package/dist/components/features/calendar-date-picker/types.d.ts +19 -0
- package/dist/components/features/calendar-date-picker/types.d.ts.map +1 -1
- package/dist/components/features/code-editor/code-editor.d.ts +1 -1
- package/dist/components/features/code-editor/code-editor.d.ts.map +1 -1
- package/dist/components/features/code-editor/index.d.ts +1 -1
- package/dist/components/features/code-editor/index.d.ts.map +1 -1
- package/dist/components/features/code-editor/types.d.ts +25 -2
- package/dist/components/features/code-editor/types.d.ts.map +1 -1
- package/dist/components/features/data-table/core/client-provider.d.ts.map +1 -1
- package/dist/components/features/date-time-picker/date-time-picker.d.ts +12 -4
- package/dist/components/features/date-time-picker/date-time-picker.d.ts.map +1 -1
- package/dist/components/features/date-time-picker/types.d.ts +9 -0
- package/dist/components/features/date-time-picker/types.d.ts.map +1 -1
- package/dist/components/features/grid/components/col.d.ts +1 -1
- package/dist/components/features/grid/components/col.d.ts.map +1 -1
- package/dist/components/features/grid/components/row.d.ts +1 -1
- package/dist/components/features/grid/components/row.d.ts.map +1 -1
- package/dist/components/features/picker/components/calendar.d.ts +14 -0
- package/dist/components/features/picker/components/calendar.d.ts.map +1 -0
- package/dist/components/features/picker/components/content.d.ts +18 -0
- package/dist/components/features/picker/components/content.d.ts.map +1 -0
- package/dist/components/features/picker/components/context.d.ts +57 -0
- package/dist/components/features/picker/components/context.d.ts.map +1 -0
- package/dist/components/features/picker/components/footer.d.ts +35 -0
- package/dist/components/features/picker/components/footer.d.ts.map +1 -0
- package/dist/components/features/picker/components/index.d.ts +36 -0
- package/dist/components/features/picker/components/index.d.ts.map +1 -0
- package/dist/components/features/picker/components/presets.d.ts +9 -0
- package/dist/components/features/picker/components/presets.d.ts.map +1 -0
- package/dist/components/features/picker/components/root.d.ts +40 -0
- package/dist/components/features/picker/components/root.d.ts.map +1 -0
- package/dist/components/features/picker/components/time-input-field.d.ts +13 -0
- package/dist/components/features/picker/components/time-input-field.d.ts.map +1 -0
- package/dist/components/features/picker/components/time-input.d.ts +13 -0
- package/dist/components/features/picker/components/time-input.d.ts.map +1 -0
- package/dist/components/features/picker/components/timezone-indicator.d.ts +14 -0
- package/dist/components/features/picker/components/timezone-indicator.d.ts.map +1 -0
- package/dist/components/features/picker/components/timezone-select.d.ts +16 -0
- package/dist/components/features/picker/components/timezone-select.d.ts.map +1 -0
- package/dist/components/features/picker/components/trigger.d.ts +23 -0
- package/dist/components/features/picker/components/trigger.d.ts.map +1 -0
- package/dist/components/features/picker/hooks/index.d.ts +5 -0
- package/dist/components/features/picker/hooks/index.d.ts.map +1 -0
- package/dist/components/features/picker/hooks/use-keyboard-shortcuts.d.ts +25 -0
- package/dist/components/features/picker/hooks/use-keyboard-shortcuts.d.ts.map +1 -0
- package/dist/components/features/picker/hooks/use-picker-state.d.ts +51 -0
- package/dist/components/features/picker/hooks/use-picker-state.d.ts.map +1 -0
- package/dist/components/features/picker/hooks/use-presets.d.ts +24 -0
- package/dist/components/features/picker/hooks/use-presets.d.ts.map +1 -0
- package/dist/components/features/picker/hooks/use-time-slots.d.ts +21 -0
- package/dist/components/features/picker/hooks/use-time-slots.d.ts.map +1 -0
- package/dist/components/features/picker/index.d.ts +8 -0
- package/dist/components/features/picker/index.d.ts.map +1 -0
- package/dist/components/features/picker/internal/use-deprecation-warning.d.ts +9 -0
- package/dist/components/features/picker/internal/use-deprecation-warning.d.ts.map +1 -0
- package/dist/components/features/picker/presets/defaults.d.ts +16 -0
- package/dist/components/features/picker/presets/defaults.d.ts.map +1 -0
- package/dist/components/features/picker/presets/index.d.ts +2 -0
- package/dist/components/features/picker/presets/index.d.ts.map +1 -0
- package/dist/components/features/picker/types.d.ts +70 -0
- package/dist/components/features/picker/types.d.ts.map +1 -0
- package/dist/components/features/picker/utils/commit.d.ts +16 -0
- package/dist/components/features/picker/utils/commit.d.ts.map +1 -0
- package/dist/components/features/picker/utils/compare.d.ts +12 -0
- package/dist/components/features/picker/utils/compare.d.ts.map +1 -0
- package/dist/components/features/picker/utils/format-value.d.ts +25 -0
- package/dist/components/features/picker/utils/format-value.d.ts.map +1 -0
- package/dist/components/features/picker/utils/format.d.ts +38 -0
- package/dist/components/features/picker/utils/format.d.ts.map +1 -0
- package/dist/components/features/picker/utils/index.d.ts +7 -0
- package/dist/components/features/picker/utils/index.d.ts.map +1 -0
- package/dist/components/features/picker/utils/range.d.ts +26 -0
- package/dist/components/features/picker/utils/range.d.ts.map +1 -0
- package/dist/components/features/picker/utils/timezone.d.ts +38 -0
- package/dist/components/features/picker/utils/timezone.d.ts.map +1 -0
- package/dist/components/features/picker/wrappers/date-picker.d.ts +10 -0
- package/dist/components/features/picker/wrappers/date-picker.d.ts.map +1 -0
- package/dist/components/features/picker/wrappers/date-range-picker.d.ts +16 -0
- package/dist/components/features/picker/wrappers/date-range-picker.d.ts.map +1 -0
- package/dist/components/features/picker/wrappers/date-range-time-picker.d.ts +16 -0
- package/dist/components/features/picker/wrappers/date-range-time-picker.d.ts.map +1 -0
- package/dist/components/features/picker/wrappers/date-time-picker.d.ts +20 -0
- package/dist/components/features/picker/wrappers/date-time-picker.d.ts.map +1 -0
- package/dist/components/features/picker/wrappers/date-time-range-picker.d.ts +16 -0
- package/dist/components/features/picker/wrappers/date-time-range-picker.d.ts.map +1 -0
- package/dist/components/features/picker/wrappers/index.d.ts +16 -0
- package/dist/components/features/picker/wrappers/index.d.ts.map +1 -0
- package/dist/components/features/picker/wrappers/internal/default-footer.d.ts +7 -0
- package/dist/components/features/picker/wrappers/internal/default-footer.d.ts.map +1 -0
- package/dist/components/features/picker/wrappers/time-picker.d.ts +14 -0
- package/dist/components/features/picker/wrappers/time-picker.d.ts.map +1 -0
- package/dist/components/features/picker/wrappers/time-range-picker.d.ts +16 -0
- package/dist/components/features/picker/wrappers/time-range-picker.d.ts.map +1 -0
- package/dist/components/features/picker/wrappers/types.d.ts +118 -0
- package/dist/components/features/picker/wrappers/types.d.ts.map +1 -0
- package/dist/components/features/tag-input/tag-input.d.ts +1 -1
- package/dist/components/features/tag-input/tag-input.d.ts.map +1 -1
- package/dist/components/features/time-picker/time-picker.d.ts +5 -0
- package/dist/components/features/time-picker/time-picker.d.ts.map +1 -1
- package/dist/components/features/time-picker/types.d.ts +5 -0
- package/dist/components/features/time-picker/types.d.ts.map +1 -1
- package/dist/components/features/time-range-picker/index.d.ts +5 -0
- package/dist/components/features/time-range-picker/index.d.ts.map +1 -1
- package/dist/components/features/time-range-picker/time-range-picker.d.ts +19 -14
- package/dist/components/features/time-range-picker/time-range-picker.d.ts.map +1 -1
- package/dist/components/features/time-range-picker/types.d.ts +20 -0
- package/dist/components/features/time-range-picker/types.d.ts.map +1 -1
- package/dist/data-table/index.mjs +22 -15
- package/dist/date-picker/index.mjs +2 -2
- package/dist/date-range-picker-DNZh06zo.mjs +77 -0
- package/dist/date-time-picker/index.mjs +1 -1
- package/dist/date-time-picker-BiobghTJ.mjs +43 -0
- package/dist/date-time-picker-C0fF7s_e.mjs +109 -0
- package/dist/date-time-range-picker-cW4rbuFn.mjs +82 -0
- package/dist/default-footer-DbpemJVl.mjs +1037 -0
- package/dist/dropzone/index.mjs +1 -1
- package/dist/{dropzone-Bt0plEuw.mjs → dropzone-DXH0xHso.mjs} +1 -1
- package/dist/empty-content/index.mjs +1 -1
- package/dist/form/adapters/conform/index.mjs +19 -19
- package/dist/form/adapters/rhf/index.mjs +18 -18
- package/dist/form/index.mjs +2 -2
- package/dist/form/stepper/index.mjs +23 -23
- package/dist/{form-CCNN9VtJ.mjs → form-DvgKb4s4.mjs} +49 -42
- package/dist/{form-context-CeKyvO-A.mjs → form-context-0usxTumz.mjs} +3 -3
- package/dist/grid/index.mjs +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/index.mjs +41 -41
- package/dist/input-group/index.mjs +1 -1
- package/dist/{input-group-DDtz-RT7.mjs → input-group-CeMsDhOk.mjs} +1 -1
- package/dist/input-number/index.mjs +1 -1
- package/dist/{input-number-Diu-C6d5.mjs → input-number-BU4nno8J.mjs} +1 -1
- package/dist/loader-overlay/index.mjs +1 -1
- package/dist/map/index.mjs +1 -1
- package/dist/{map-qo7bY_g_.mjs → map-l7iwhEwM.mjs} +24 -27
- package/dist/more-actions/index.mjs +2 -2
- package/dist/{more-actions-Ca5qqd0H.mjs → more-actions-Baqor0yr.mjs} +2 -2
- package/dist/multi-select/index.mjs +1 -1
- package/dist/{multi-select-DM_dxnSV.mjs → multi-select-BHmtkQIi.mjs} +6 -6
- package/dist/page-title/index.mjs +1 -1
- package/dist/picker/index.mjs +273 -0
- package/dist/rich-text-editor/index.mjs +1 -1
- package/dist/{rich-text-editor-CQH_U4T5.mjs → rich-text-editor-aWuLRaj9.mjs} +1 -1
- package/dist/select/index.mjs +1 -1
- package/dist/select-By1ZqPgr.mjs +94 -0
- package/dist/select-Ck0szhAH.mjs +73 -0
- package/dist/sidebar/index.mjs +1 -1
- package/dist/{sidebar-B8LQJiNI.mjs → sidebar-CUnFkH7o.mjs} +32 -32
- package/dist/skeleton/index.mjs +1 -1
- package/dist/{skeleton-D4HOEiOZ.mjs → skeleton-CxAhQT6T.mjs} +1 -1
- package/dist/stepper/index.mjs +1 -1
- package/dist/{stepper-Beb-zbdL.mjs → stepper-adDdiJMx.mjs} +7 -7
- package/dist/styles/root.css +4 -2
- package/dist/styles/shadcn/shadcn.css +212 -213
- package/dist/switch/index.mjs +1 -1
- package/dist/table/index.mjs +1 -1
- package/dist/tag-input/index.mjs +1 -1
- package/dist/{tag-input-Bf4GMptp.mjs → tag-input-D3NYy9-_.mjs} +1 -1
- package/dist/task-queue/index.mjs +1 -1
- package/dist/{task-queue-dropdown-D-LncEWm.mjs → task-queue-dropdown-t9KKIL6j.mjs} +3 -3
- package/dist/textarea/index.mjs +1 -1
- package/dist/theme/index.mjs +1 -1
- package/dist/{themes-CAiN4b6G.mjs → themes-08-znmBI.mjs} +16 -16
- package/dist/time-input-9LdNL0Us.mjs +196 -0
- package/dist/time-picker/index.mjs +1 -1
- package/dist/time-picker-B-vpUClR.mjs +45 -0
- package/dist/time-picker-C840fLl6.mjs +49 -0
- package/dist/timezone-indicator-COoeMKKs.mjs +27 -0
- package/dist/{to-api-format-CgKcC9SK.mjs → to-api-format-CNqrcrz7.mjs} +58 -243
- package/dist/toast/index.mjs +2 -2
- package/dist/{toast-DDdLgY53.mjs → toast-Bd5Kk7BB.mjs} +1 -1
- package/dist/tooltip/index.mjs +1 -1
- package/dist/transfer/index.mjs +1 -1
- package/dist/{transfer-CoGPwOc6.mjs → transfer-CuJGL420.mjs} +6 -6
- package/dist/{types-CKIe2WlV.mjs → types-DvMIxilw.mjs} +9 -3
- package/dist/typography/index.mjs +1 -1
- package/dist/{typography-TRKP_CLT.mjs → typography-CBwfg-vz.mjs} +5 -5
- package/dist/{use-copy-to-clipboard-D7KyLIAt.mjs → use-copy-to-clipboard-ZHDvfV3W.mjs} +1 -1
- package/dist/use-deprecation-warning-Dy_DOyLu.mjs +20 -0
- package/dist/{use-display-touched-C-afz17j.mjs → use-display-touched-DpX3fsOl.mjs} +5 -5
- package/dist/{use-option-picker-BXQOfyrK.mjs → use-option-picker-DV5O68eV.mjs} +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/visually-hidden/index.mjs +1 -1
- package/package.json +28 -23
- package/dist/calendar-date-picker-BaykEs6j.mjs +0 -749
- package/dist/date-time-picker-DKOxrhmc.mjs +0 -193
- package/dist/select-zxwykvQn.mjs +0 -163
- package/dist/time-picker-BZF5jbF6.mjs +0 -99
- package/dist/use-date-constraints-R3H4lIoT.mjs +0 -41
- /package/dist/{action-row-DnhBhMtt.mjs → action-row-ZaMsJ8cP.mjs} +0 -0
- /package/dist/{empty-content-CBh5bbtJ.mjs → empty-content-DTk_lwnh.mjs} +0 -0
- /package/dist/{hooks-DQXVwbrs.mjs → hooks-CnphNpwz.mjs} +0 -0
- /package/dist/{loader-overlay-C2WDla6V.mjs → loader-overlay-B3YEoOFJ.mjs} +0 -0
- /package/dist/{map-leaflet-imports-yWwH4CHB.mjs → map-leaflet-imports-Ix8F7E8j.mjs} +0 -0
- /package/dist/{page-title-ChLiv6gB.mjs → page-title-D5JhOpxV.mjs} +0 -0
- /package/dist/{skeleton-D2xuJdE1.mjs → skeleton-B1NOdZGM.mjs} +0 -0
- /package/dist/{switch-DcSF42Kc.mjs → switch-BcQaR1Bp.mjs} +0 -0
- /package/dist/{table-DWGT4cqh.mjs → table-ouGk4Vxe.mjs} +0 -0
- /package/dist/{textarea-BoChBcFz.mjs → textarea-q-k7DYwi.mjs} +0 -0
- /package/dist/{toast-D5XD7goD.mjs → toast-BWol1pyV.mjs} +0 -0
- /package/dist/{tooltip-a7NTDCWw.mjs → tooltip-CHuzXR_O.mjs} +0 -0
- /package/dist/{utils-BwB1mIdZ.mjs → utils-bUueJ2r9.mjs} +0 -0
- /package/dist/{visuallyhidden-BHOPczmW.mjs → visuallyhidden-CoIJOJ9z.mjs} +0 -0
package/dist/dropzone/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as FileInputButton, n as DropzoneContent, r as DropzoneEmptyState, t as Dropzone } from "../dropzone-
|
|
1
|
+
import { i as FileInputButton, n as DropzoneContent, r as DropzoneEmptyState, t as Dropzone } from "../dropzone-DXH0xHso.mjs";
|
|
2
2
|
export { Dropzone, DropzoneContent, DropzoneEmptyState, FileInputButton };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as cn } from "./cn-D2KYQ917.mjs";
|
|
2
2
|
import { t as Button } from "./button-BllvE9Lm.mjs";
|
|
3
|
-
import { t as Button$1 } from "./button-
|
|
3
|
+
import { t as Button$1 } from "./button-Rw1xI-k9.mjs";
|
|
4
4
|
import { t as Icon } from "./icon-wrapper-DuLp3RM1.mjs";
|
|
5
5
|
import { UploadIcon } from "lucide-react";
|
|
6
6
|
import { createContext, use, useRef } from "react";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as EmptyContent } from "../empty-content-
|
|
1
|
+
import { t as EmptyContent } from "../empty-content-DTk_lwnh.mjs";
|
|
2
2
|
export { EmptyContent };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as FormAdapterProvider } from "../../../adapter-context-
|
|
2
|
-
import { n as getFieldConstraints, t as useDisplayTouched } from "../../../use-display-touched-
|
|
3
|
-
import * as React
|
|
1
|
+
import { t as FormAdapterProvider } from "../../../adapter-context-DemTWhel.mjs";
|
|
2
|
+
import { n as getFieldConstraints, t as useDisplayTouched } from "../../../use-display-touched-DpX3fsOl.mjs";
|
|
3
|
+
import * as React from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { FormProvider, getFormProps, getInputProps, useForm, useFormMetadata, useInputControl } from "@conform-to/react";
|
|
6
6
|
import { isDirty, useFormData } from "@conform-to/react/future";
|
|
@@ -10,7 +10,7 @@ import { getZodConstraint, parseWithZod } from "@conform-to/zod/v4";
|
|
|
10
10
|
* Shared context for the touched fields set.
|
|
11
11
|
* Created in useConformCreateForm and consumed by useConformField.
|
|
12
12
|
*/
|
|
13
|
-
const TouchedFieldsContext = React
|
|
13
|
+
const TouchedFieldsContext = React.createContext({ current: /* @__PURE__ */ new Set() });
|
|
14
14
|
/**
|
|
15
15
|
* Resolve a Conform field metadata object by dot-notation path.
|
|
16
16
|
*
|
|
@@ -75,7 +75,7 @@ function useConformCreateForm(props) {
|
|
|
75
75
|
if (submission?.status === "success") onSubmit(submission.value);
|
|
76
76
|
} : void 0
|
|
77
77
|
});
|
|
78
|
-
const constraints = React
|
|
78
|
+
const constraints = React.useMemo(() => getFieldConstraints(schema), [schema]);
|
|
79
79
|
const formIsDirty = useFormData(formRef, (formData) => isDirty(formData, { defaultValue: defaultValues }) ?? false) ?? false;
|
|
80
80
|
const dirtyFields = useFormData(formRef, (formData) => {
|
|
81
81
|
const result = {};
|
|
@@ -96,9 +96,9 @@ function useConformCreateForm(props) {
|
|
|
96
96
|
const isValid = useFormData(formRef, (formData) => {
|
|
97
97
|
return parseWithZod(formData, { schema })?.status === "success";
|
|
98
98
|
}) ?? false;
|
|
99
|
-
const touchedFieldsRef = React
|
|
100
|
-
const [touchedFields, setTouchedFields] = React
|
|
101
|
-
React
|
|
99
|
+
const touchedFieldsRef = React.useRef(/* @__PURE__ */ new Set());
|
|
100
|
+
const [touchedFields, setTouchedFields] = React.useState({});
|
|
101
|
+
React.useEffect(() => {
|
|
102
102
|
const formEl = formRef?.current;
|
|
103
103
|
if (!formEl) return;
|
|
104
104
|
const handleFocusOut = (event) => {
|
|
@@ -117,7 +117,7 @@ function useConformCreateForm(props) {
|
|
|
117
117
|
formEl.addEventListener("focusout", handleFocusOut);
|
|
118
118
|
return () => formEl.removeEventListener("focusout", handleFocusOut);
|
|
119
119
|
}, [formRef]);
|
|
120
|
-
const formState = React
|
|
120
|
+
const formState = React.useMemo(() => ({
|
|
121
121
|
isDirty: formIsDirty,
|
|
122
122
|
isValid,
|
|
123
123
|
isSubmitted: false,
|
|
@@ -130,7 +130,7 @@ function useConformCreateForm(props) {
|
|
|
130
130
|
dirtyFields,
|
|
131
131
|
touchedFields
|
|
132
132
|
]);
|
|
133
|
-
const normalizedFields = React
|
|
133
|
+
const normalizedFields = React.useMemo(() => {
|
|
134
134
|
const result = {};
|
|
135
135
|
for (const [key, fieldMeta] of Object.entries(fields)) result[key] = {
|
|
136
136
|
id: fieldMeta.id ?? `${id ?? form.id}-${key}`,
|
|
@@ -148,9 +148,9 @@ function useConformCreateForm(props) {
|
|
|
148
148
|
dirtyFields,
|
|
149
149
|
touchedFields
|
|
150
150
|
]);
|
|
151
|
-
const conformFormProps = React
|
|
151
|
+
const conformFormProps = React.useMemo(() => getFormProps(form), [form]);
|
|
152
152
|
const { displayTouchedFields, markFieldTouched, markAllFieldsTouched } = useDisplayTouched(schema);
|
|
153
|
-
return React
|
|
153
|
+
return React.useMemo(() => ({
|
|
154
154
|
id: form.id,
|
|
155
155
|
fields: normalizedFields,
|
|
156
156
|
formProps: conformFormProps,
|
|
@@ -187,7 +187,7 @@ function useConformCreateForm(props) {
|
|
|
187
187
|
/** Resolve a field by dot-notation path and return its normalized state. */
|
|
188
188
|
function useConformField(name) {
|
|
189
189
|
const fieldMeta = resolveConformField(useFormMetadata().getFieldset(), name);
|
|
190
|
-
const touchedFieldsRef = React
|
|
190
|
+
const touchedFieldsRef = React.use(TouchedFieldsContext);
|
|
191
191
|
const control = useInputControl(fieldMeta ?? {
|
|
192
192
|
name,
|
|
193
193
|
key: void 0,
|
|
@@ -198,7 +198,7 @@ function useConformField(name) {
|
|
|
198
198
|
const defaultValue = convertFromString(fieldMeta.initialValue);
|
|
199
199
|
const fieldIsDirty = currentValue !== (defaultValue === void 0 ? "" : defaultValue);
|
|
200
200
|
const fieldIsTouched = touchedFieldsRef.current.has(name);
|
|
201
|
-
return React
|
|
201
|
+
return React.useMemo(() => ({
|
|
202
202
|
name: fieldMeta.name,
|
|
203
203
|
id: fieldMeta.id,
|
|
204
204
|
errors: fieldMeta.errors ?? [],
|
|
@@ -228,7 +228,7 @@ function useConformWatch(name) {
|
|
|
228
228
|
function useConformWatchAll(names) {
|
|
229
229
|
const allFields = useFormMetadata().getFieldset();
|
|
230
230
|
const namesKey = names.join(",");
|
|
231
|
-
return React
|
|
231
|
+
return React.useMemo(() => {
|
|
232
232
|
const result = {};
|
|
233
233
|
for (const name of names) {
|
|
234
234
|
const fieldMeta = resolveConformField(allFields, name);
|
|
@@ -241,7 +241,7 @@ function useConformWatchAll(names) {
|
|
|
241
241
|
function useConformFieldArray(name) {
|
|
242
242
|
const formMeta = useFormMetadata();
|
|
243
243
|
const arrayField = resolveConformField(formMeta.getFieldset(), name);
|
|
244
|
-
const items = React
|
|
244
|
+
const items = React.useMemo(() => {
|
|
245
245
|
if (!arrayField?.getFieldList) return [];
|
|
246
246
|
return arrayField.getFieldList().map((item, index) => ({
|
|
247
247
|
id: item.id ?? `${name}-${index}`,
|
|
@@ -252,21 +252,21 @@ function useConformFieldArray(name) {
|
|
|
252
252
|
const arrayFieldName = arrayField?.name;
|
|
253
253
|
return {
|
|
254
254
|
items,
|
|
255
|
-
append: React
|
|
255
|
+
append: React.useCallback((defaultValue) => {
|
|
256
256
|
if (!arrayFieldName) return;
|
|
257
257
|
formMeta.insert({
|
|
258
258
|
name: arrayFieldName,
|
|
259
259
|
defaultValue
|
|
260
260
|
});
|
|
261
261
|
}, [formMeta, arrayFieldName]),
|
|
262
|
-
remove: React
|
|
262
|
+
remove: React.useCallback((index) => {
|
|
263
263
|
if (!arrayFieldName) return;
|
|
264
264
|
formMeta.remove({
|
|
265
265
|
name: arrayFieldName,
|
|
266
266
|
index
|
|
267
267
|
});
|
|
268
268
|
}, [formMeta, arrayFieldName]),
|
|
269
|
-
move: React
|
|
269
|
+
move: React.useCallback((from, to) => {
|
|
270
270
|
if (!arrayFieldName) return;
|
|
271
271
|
formMeta.reorder({
|
|
272
272
|
name: arrayFieldName,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as FormAdapterProvider } from "../../../adapter-context-
|
|
2
|
-
import { n as getFieldConstraints, r as getObjectShape, t as useDisplayTouched } from "../../../use-display-touched-
|
|
3
|
-
import * as React
|
|
1
|
+
import { t as FormAdapterProvider } from "../../../adapter-context-DemTWhel.mjs";
|
|
2
|
+
import { n as getFieldConstraints, r as getObjectShape, t as useDisplayTouched } from "../../../use-display-touched-DpX3fsOl.mjs";
|
|
3
|
+
import * as React from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
6
6
|
import { FormProvider, useController, useFieldArray, useForm, useFormContext, useWatch } from "react-hook-form";
|
|
@@ -59,12 +59,12 @@ function getFieldDefault(schema) {
|
|
|
59
59
|
}
|
|
60
60
|
//#endregion
|
|
61
61
|
//#region src/components/features/form/adapters/rhf/rhf-adapter.tsx
|
|
62
|
-
const RHFFormIdContext = React
|
|
62
|
+
const RHFFormIdContext = React.createContext("form");
|
|
63
63
|
/** Create a React Hook Form instance and normalize it to the adapter interface. */
|
|
64
64
|
function useRHFCreateForm(props) {
|
|
65
65
|
const { schema, defaultValues, mode, id, onSubmit, formRef } = props;
|
|
66
|
-
const schemaDefaults = React
|
|
67
|
-
const mergedDefaults = React
|
|
66
|
+
const schemaDefaults = React.useMemo(() => getSchemaDefaults(schema), [schema]);
|
|
67
|
+
const mergedDefaults = React.useMemo(() => ({
|
|
68
68
|
...schemaDefaults,
|
|
69
69
|
...defaultValues
|
|
70
70
|
}), [schemaDefaults, defaultValues]);
|
|
@@ -75,10 +75,10 @@ function useRHFCreateForm(props) {
|
|
|
75
75
|
reValidateMode: "onChange"
|
|
76
76
|
});
|
|
77
77
|
const { errors, isDirty, isValid, dirtyFields, touchedFields } = form.formState;
|
|
78
|
-
const constraints = React
|
|
79
|
-
const onSubmitRef = React
|
|
78
|
+
const constraints = React.useMemo(() => getFieldConstraints(schema), [schema]);
|
|
79
|
+
const onSubmitRef = React.useRef(onSubmit);
|
|
80
80
|
onSubmitRef.current = onSubmit;
|
|
81
|
-
const normalizedFields = React
|
|
81
|
+
const normalizedFields = React.useMemo(() => {
|
|
82
82
|
const result = {};
|
|
83
83
|
for (const [key, constraint] of Object.entries(constraints)) {
|
|
84
84
|
const fieldError = errors[key];
|
|
@@ -98,7 +98,7 @@ function useRHFCreateForm(props) {
|
|
|
98
98
|
dirtyFields,
|
|
99
99
|
touchedFields
|
|
100
100
|
]);
|
|
101
|
-
const formState = React
|
|
101
|
+
const formState = React.useMemo(() => ({
|
|
102
102
|
isDirty,
|
|
103
103
|
isValid,
|
|
104
104
|
isSubmitted: false,
|
|
@@ -111,16 +111,16 @@ function useRHFCreateForm(props) {
|
|
|
111
111
|
dirtyFields,
|
|
112
112
|
touchedFields
|
|
113
113
|
]);
|
|
114
|
-
const handleSubmit = React
|
|
114
|
+
const handleSubmit = React.useMemo(() => form.handleSubmit((data) => {
|
|
115
115
|
onSubmitRef.current?.(data);
|
|
116
116
|
}), [form]);
|
|
117
|
-
const formProps = React
|
|
117
|
+
const formProps = React.useMemo(() => ({
|
|
118
118
|
id,
|
|
119
119
|
onSubmit: handleSubmit,
|
|
120
120
|
noValidate: true
|
|
121
121
|
}), [id, handleSubmit]);
|
|
122
122
|
const { displayTouchedFields, markFieldTouched, markAllFieldsTouched } = useDisplayTouched(schema);
|
|
123
|
-
return React
|
|
123
|
+
return React.useMemo(() => ({
|
|
124
124
|
id: id ?? "form",
|
|
125
125
|
fields: normalizedFields,
|
|
126
126
|
formProps,
|
|
@@ -147,12 +147,12 @@ function useRHFCreateForm(props) {
|
|
|
147
147
|
/** Resolve a field by name and return its normalized state. */
|
|
148
148
|
function useRHFField(name) {
|
|
149
149
|
const form = useFormContext();
|
|
150
|
-
const formId = React
|
|
150
|
+
const formId = React.use(RHFFormIdContext);
|
|
151
151
|
const { field, fieldState } = useController({
|
|
152
152
|
name,
|
|
153
153
|
control: form.control
|
|
154
154
|
});
|
|
155
|
-
return React
|
|
155
|
+
return React.useMemo(() => ({
|
|
156
156
|
name: field.name,
|
|
157
157
|
id: `${formId}-${name}`,
|
|
158
158
|
errors: fieldState.error?.message ? [String(fieldState.error.message)] : [],
|
|
@@ -185,7 +185,7 @@ function useRHFWatchAllHook(names) {
|
|
|
185
185
|
control: useFormContext().control
|
|
186
186
|
});
|
|
187
187
|
const namesKey = names.join(",");
|
|
188
|
-
return React
|
|
188
|
+
return React.useMemo(() => {
|
|
189
189
|
const result = {};
|
|
190
190
|
names.forEach((n, index) => {
|
|
191
191
|
result[n] = values[index];
|
|
@@ -200,12 +200,12 @@ function useRHFFieldArrayHook(name) {
|
|
|
200
200
|
control: useFormContext().control
|
|
201
201
|
});
|
|
202
202
|
return {
|
|
203
|
-
items: React
|
|
203
|
+
items: React.useMemo(() => fields.map((field, index) => ({
|
|
204
204
|
id: field.id,
|
|
205
205
|
key: field.id,
|
|
206
206
|
name: `${name}.${index}`
|
|
207
207
|
})), [fields, name]),
|
|
208
|
-
append: React
|
|
208
|
+
append: React.useCallback((defaultValue) => {
|
|
209
209
|
append(defaultValue ?? {});
|
|
210
210
|
}, [append]),
|
|
211
211
|
remove,
|
package/dist/form/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as FormCheckbox, C as FormDialog, D as FormCustom, E as FormDatePicker, M as FormAutosearch, N as FormAutocomplete, O as FormCopyBox, S as FormError, T as FormDateTimePicker, _ as FormRadioGroup, a as useField, b as FormFieldArray, c as useWatchAll, d as FormTextarea, f as FormSwitch, g as FormRoot, h as FormSelectItem, i as useFieldContext, j as FormButton, k as FormCombobox, l as FormTransfer, m as FormSelect, n as useFormState, o as FormWhen, p as FormSubmit, r as useFormContext, s as useWatch, t as Form, u as FormTimePicker, v as FormRadioItem, w as FormDescription, x as FormField, y as FormInput } from "../form-
|
|
2
|
-
import { n as useAdapter, t as FormAdapterProvider } from "../adapter-context-
|
|
1
|
+
import { A as FormCheckbox, C as FormDialog, D as FormCustom, E as FormDatePicker, M as FormAutosearch, N as FormAutocomplete, O as FormCopyBox, S as FormError, T as FormDateTimePicker, _ as FormRadioGroup, a as useField, b as FormFieldArray, c as useWatchAll, d as FormTextarea, f as FormSwitch, g as FormRoot, h as FormSelectItem, i as useFieldContext, j as FormButton, k as FormCombobox, l as FormTransfer, m as FormSelect, n as useFormState, o as FormWhen, p as FormSubmit, r as useFormContext, s as useWatch, t as Form, u as FormTimePicker, v as FormRadioItem, w as FormDescription, x as FormField, y as FormInput } from "../form-DvgKb4s4.mjs";
|
|
2
|
+
import { n as useAdapter, t as FormAdapterProvider } from "../adapter-context-DemTWhel.mjs";
|
|
3
3
|
export { Form, FormAdapterProvider, FormAutocomplete, FormAutosearch, FormButton, FormCheckbox, FormCombobox, FormCopyBox, FormCustom, FormDatePicker, FormDateTimePicker, FormDescription, FormDialog, FormError, FormField, FormFieldArray, FormInput, FormRadioGroup, FormRadioItem, FormRoot, FormSelect, FormSelectItem, FormSubmit, FormSwitch, FormTextarea, FormTimePicker, FormTransfer, FormWhen, useAdapter, useField, useFieldContext, useFormContext, useFormState, useWatch, useWatchAll };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { t as cn } from "../../cn-D2KYQ917.mjs";
|
|
2
2
|
import { t as Button } from "../../button-BllvE9Lm.mjs";
|
|
3
|
-
import { n as useFormContext, t as FormProvider } from "../../form-context-
|
|
4
|
-
import { n as useAdapter } from "../../adapter-context-
|
|
5
|
-
import { t as defineStepper } from "../../stepper-
|
|
3
|
+
import { n as useFormContext, t as FormProvider } from "../../form-context-0usxTumz.mjs";
|
|
4
|
+
import { n as useAdapter } from "../../adapter-context-DemTWhel.mjs";
|
|
5
|
+
import { t as defineStepper } from "../../stepper-adDdiJMx.mjs";
|
|
6
6
|
import { CheckIcon } from "lucide-react";
|
|
7
|
-
import * as React
|
|
7
|
+
import * as React from "react";
|
|
8
8
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
//#region src/components/features/form/components/stepper/form-stepper.tsx
|
|
10
|
-
const FormStepperContext = React
|
|
10
|
+
const FormStepperContext = React.createContext(null);
|
|
11
11
|
function useFormStepperContext() {
|
|
12
|
-
const context = React
|
|
12
|
+
const context = React.use(FormStepperContext);
|
|
13
13
|
if (!context) throw new Error("useFormStepperContext must be used within a Form.Stepper component");
|
|
14
14
|
return context;
|
|
15
15
|
}
|
|
@@ -56,10 +56,10 @@ function toStepperizeSteps(steps) {
|
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
58
|
function FormStepper({ steps, children, onComplete, onStepChange, initialStep, className, defaultValues, id, formComponent, mode = "onSubmit" }) {
|
|
59
|
-
const stepperDef = React
|
|
59
|
+
const stepperDef = React.useMemo(() => {
|
|
60
60
|
return defineStepper(...toStepperizeSteps(steps));
|
|
61
61
|
}, [steps]);
|
|
62
|
-
const initialStepIndex = React
|
|
62
|
+
const initialStepIndex = React.useMemo(() => {
|
|
63
63
|
if (!initialStep) return void 0;
|
|
64
64
|
const index = steps.findIndex((s) => s.id === initialStep);
|
|
65
65
|
return index >= 0 ? steps[index].id : void 0;
|
|
@@ -89,8 +89,8 @@ function FormStepperContent({ steps, stepperDef, children, onComplete, onStepCha
|
|
|
89
89
|
return /* @__PURE__ */ jsx(StepForm, {
|
|
90
90
|
steps,
|
|
91
91
|
stepper,
|
|
92
|
-
currentStepConfig: React
|
|
93
|
-
storedValues: React
|
|
92
|
+
currentStepConfig: React.useMemo(() => steps.find((s) => s.id === stepper.state.current.data.id) ?? steps[0], [steps, stepper.state.current.data.id]),
|
|
93
|
+
storedValues: React.useMemo(() => {
|
|
94
94
|
const allMetadata = steps.reduce((acc, step) => ({
|
|
95
95
|
...acc,
|
|
96
96
|
...stepper.metadata.get(step.id) || {}
|
|
@@ -116,12 +116,12 @@ function FormStepperContent({ steps, stepperDef, children, onComplete, onStepCha
|
|
|
116
116
|
}
|
|
117
117
|
function StepForm({ steps, stepper, currentStepConfig, storedValues, children, onComplete, onStepChange, className, id, formComponent: FormComp = "form", mode }) {
|
|
118
118
|
const adapter = useAdapter();
|
|
119
|
-
const [isSubmitting, setIsSubmitting] = React
|
|
120
|
-
const [isSubmitted, setIsSubmitted] = React
|
|
121
|
-
const [submitCount, setSubmitCount] = React
|
|
122
|
-
const formRef = React
|
|
119
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
120
|
+
const [isSubmitted, setIsSubmitted] = React.useState(false);
|
|
121
|
+
const [submitCount, setSubmitCount] = React.useState(0);
|
|
122
|
+
const formRef = React.useRef(null);
|
|
123
123
|
const currentIndex = stepper.lookup.getIndex(stepper.state.current.data.id);
|
|
124
|
-
const handleStepSubmit = React
|
|
124
|
+
const handleStepSubmit = React.useCallback(async (data) => {
|
|
125
125
|
setIsSubmitted(true);
|
|
126
126
|
setSubmitCount((prev) => prev + 1);
|
|
127
127
|
stepper.metadata.set(stepper.state.current.data.id, data);
|
|
@@ -159,10 +159,10 @@ function StepForm({ steps, stepper, currentStepConfig, storedValues, children, o
|
|
|
159
159
|
onSubmit: handleStepSubmit,
|
|
160
160
|
formRef
|
|
161
161
|
});
|
|
162
|
-
const next = React
|
|
162
|
+
const next = React.useCallback(() => {
|
|
163
163
|
formRef.current?.requestSubmit();
|
|
164
164
|
}, []);
|
|
165
|
-
const prev = React
|
|
165
|
+
const prev = React.useCallback(() => {
|
|
166
166
|
const currentValues = instance.getValues();
|
|
167
167
|
if (Object.keys(currentValues).length > 0) stepper.metadata.set(stepper.state.current.data.id, currentValues);
|
|
168
168
|
const prevStepId = stepper.lookup.getPrev(stepper.state.current.data.id)?.id;
|
|
@@ -175,7 +175,7 @@ function StepForm({ steps, stepper, currentStepConfig, storedValues, children, o
|
|
|
175
175
|
stepper,
|
|
176
176
|
onStepChange
|
|
177
177
|
]);
|
|
178
|
-
const goTo = React
|
|
178
|
+
const goTo = React.useCallback((stepId) => {
|
|
179
179
|
if (stepper.lookup.getIndex(stepId) < currentIndex) {
|
|
180
180
|
const currentValues = instance.getValues();
|
|
181
181
|
if (Object.keys(currentValues).length > 0) stepper.metadata.set(stepper.state.current.data.id, currentValues);
|
|
@@ -188,14 +188,14 @@ function StepForm({ steps, stepper, currentStepConfig, storedValues, children, o
|
|
|
188
188
|
currentIndex,
|
|
189
189
|
onStepChange
|
|
190
190
|
]);
|
|
191
|
-
const getStepData = React
|
|
192
|
-
const getAllStepData = React
|
|
191
|
+
const getStepData = React.useCallback((stepId) => stepper.metadata.get(stepId), [stepper]);
|
|
192
|
+
const getAllStepData = React.useCallback(() => {
|
|
193
193
|
return steps.reduce((acc, step) => ({
|
|
194
194
|
...acc,
|
|
195
195
|
...stepper.metadata.get(step.id) || {}
|
|
196
196
|
}), {});
|
|
197
197
|
}, [steps, stepper]);
|
|
198
|
-
const stepperContextValue = React
|
|
198
|
+
const stepperContextValue = React.useMemo(() => ({
|
|
199
199
|
steps,
|
|
200
200
|
current: currentStepConfig,
|
|
201
201
|
currentIndex,
|
|
@@ -218,7 +218,7 @@ function StepForm({ steps, stepper, currentStepConfig, storedValues, children, o
|
|
|
218
218
|
getStepData,
|
|
219
219
|
getAllStepData
|
|
220
220
|
]);
|
|
221
|
-
const contextValue = React
|
|
221
|
+
const contextValue = React.useMemo(() => ({
|
|
222
222
|
form: instance,
|
|
223
223
|
fields: instance.fields,
|
|
224
224
|
isSubmitting,
|
|
@@ -423,7 +423,7 @@ function StepperNavigation({ variant = "horizontal", labelOrientation = "vertica
|
|
|
423
423
|
const isActive = index === currentIndex;
|
|
424
424
|
const isCompleted = index < currentIndex;
|
|
425
425
|
const isLast = index === steps.length - 1;
|
|
426
|
-
return /* @__PURE__ */ jsxs(React
|
|
426
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
427
427
|
className: "flex items-center",
|
|
428
428
|
children: [/* @__PURE__ */ jsx("div", {
|
|
429
429
|
className: cn("flex h-8 w-8 items-center justify-center rounded-full border text-sm font-medium transition-colors", isActive && "border-primary bg-primary text-primary-foreground", isCompleted && "border-tertiary-foreground bg-tertiary-foreground text-tertiary", !isActive && !isCompleted && "border-stepper-label text-stepper-label"),
|
|
@@ -6,26 +6,26 @@ import { t as Dialog } from "./dialog-Bm2H9lrx.mjs";
|
|
|
6
6
|
import { t as Input } from "./input-FKGqZypx.mjs";
|
|
7
7
|
import { t as Label } from "./label-cnAhY-ej.mjs";
|
|
8
8
|
import { n as RadioGroupItem, t as RadioGroup } from "./radio-group-70UjJBb5.mjs";
|
|
9
|
-
import { i as SelectItem, l as SelectTrigger, n as SelectContent, t as Select, u as SelectValue } from "./select-
|
|
10
|
-
import { t as Tooltip } from "./tooltip-
|
|
11
|
-
import { t as Switch } from "./switch-
|
|
12
|
-
import { t as Textarea } from "./textarea-
|
|
13
|
-
import { t as Autocomplete } from "./autocomplete-
|
|
14
|
-
import { t as CalendarDatePicker } from "./calendar-date-picker-
|
|
15
|
-
import { t as toast } from "./toast-
|
|
9
|
+
import { i as SelectItem, l as SelectTrigger, n as SelectContent, t as Select, u as SelectValue } from "./select-Ck0szhAH.mjs";
|
|
10
|
+
import { t as Tooltip } from "./tooltip-CHuzXR_O.mjs";
|
|
11
|
+
import { t as Switch } from "./switch-BcQaR1Bp.mjs";
|
|
12
|
+
import { t as Textarea } from "./textarea-q-k7DYwi.mjs";
|
|
13
|
+
import { t as Autocomplete } from "./autocomplete-ChuPNldi.mjs";
|
|
14
|
+
import { t as CalendarDatePicker } from "./calendar-date-picker-CchHKodM.mjs";
|
|
15
|
+
import { t as toast } from "./toast-BWol1pyV.mjs";
|
|
16
16
|
import { Autosearch } from "./autosearch/index.mjs";
|
|
17
|
-
import { n as useFormContext$1, t as FormProvider } from "./form-context-
|
|
18
|
-
import { t as useCopyToClipboard } from "./use-copy-to-clipboard-
|
|
19
|
-
import { t as DateTimePicker } from "./date-time-picker-
|
|
20
|
-
import { n as useAdapter } from "./adapter-context-
|
|
17
|
+
import { n as useFormContext$1, t as FormProvider } from "./form-context-0usxTumz.mjs";
|
|
18
|
+
import { t as useCopyToClipboard } from "./use-copy-to-clipboard-ZHDvfV3W.mjs";
|
|
19
|
+
import { t as DateTimePicker } from "./date-time-picker-BiobghTJ.mjs";
|
|
20
|
+
import { n as useAdapter } from "./adapter-context-DemTWhel.mjs";
|
|
21
21
|
import { InputWithAddons } from "./input-with-addons/index.mjs";
|
|
22
|
-
import { t as TimePicker } from "./time-picker-
|
|
23
|
-
import { t as Transfer } from "./transfer-
|
|
22
|
+
import { t as TimePicker } from "./time-picker-C840fLl6.mjs";
|
|
23
|
+
import { t as Transfer } from "./transfer-CuJGL420.mjs";
|
|
24
24
|
import { CheckIcon, CircleHelp, CopyIcon } from "lucide-react";
|
|
25
|
-
import * as React
|
|
25
|
+
import * as React from "react";
|
|
26
26
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
27
27
|
//#region src/components/features/form/context/field-context.tsx
|
|
28
|
-
const FieldContext = React
|
|
28
|
+
const FieldContext = React.createContext(null);
|
|
29
29
|
function FieldProvider({ children, value }) {
|
|
30
30
|
return /* @__PURE__ */ jsx(FieldContext, {
|
|
31
31
|
value,
|
|
@@ -33,7 +33,7 @@ function FieldProvider({ children, value }) {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
function useFieldContext$1() {
|
|
36
|
-
const context = React
|
|
36
|
+
const context = React.use(FieldContext);
|
|
37
37
|
if (!context) throw new Error("useFieldContext must be used within a Form.Field component. Make sure your input component is wrapped with Form.Field.");
|
|
38
38
|
return context;
|
|
39
39
|
}
|
|
@@ -42,7 +42,7 @@ function useFieldContext$1() {
|
|
|
42
42
|
* Useful for components that can work both inside and outside Form.Field
|
|
43
43
|
*/
|
|
44
44
|
function useOptionalFieldContext() {
|
|
45
|
-
return React
|
|
45
|
+
return React.use(FieldContext);
|
|
46
46
|
}
|
|
47
47
|
//#endregion
|
|
48
48
|
//#region src/components/features/form/components/form-autocomplete.tsx
|
|
@@ -235,7 +235,7 @@ function FormCombobox({ options, placeholder, searchPlaceholder, emptyMessage, d
|
|
|
235
235
|
const { id, errors, disabled: fieldDisabled, fieldState } = useFieldContext$1();
|
|
236
236
|
const isDisabled = disabled ?? fieldDisabled;
|
|
237
237
|
const hasErrors = errors && errors.length > 0;
|
|
238
|
-
const handleChange = React
|
|
238
|
+
const handleChange = React.useCallback((value) => {
|
|
239
239
|
fieldState?.change(value ?? "");
|
|
240
240
|
fieldState?.blur();
|
|
241
241
|
}, [fieldState]);
|
|
@@ -369,7 +369,7 @@ function FormDatePicker({ placeholder, disabled, className, triggerClassName, nu
|
|
|
369
369
|
const { id, errors, disabled: fieldDisabled, fieldState } = useFieldContext$1();
|
|
370
370
|
const isDisabled = disabled ?? fieldDisabled;
|
|
371
371
|
const hasErrors = errors && errors.length > 0;
|
|
372
|
-
const currentValue = React
|
|
372
|
+
const currentValue = React.useMemo(() => {
|
|
373
373
|
const val = fieldState?.value;
|
|
374
374
|
if (!val) return {
|
|
375
375
|
from: void 0,
|
|
@@ -397,7 +397,7 @@ function FormDatePicker({ placeholder, disabled, className, triggerClassName, nu
|
|
|
397
397
|
return /* @__PURE__ */ jsx(CalendarDatePicker, {
|
|
398
398
|
id,
|
|
399
399
|
date: currentValue,
|
|
400
|
-
onDateSelect: React
|
|
400
|
+
onDateSelect: React.useCallback((range) => {
|
|
401
401
|
if (!range) {
|
|
402
402
|
fieldState?.change(void 0);
|
|
403
403
|
fieldState?.blur();
|
|
@@ -432,7 +432,7 @@ function FormDateTimePicker({ minDate: minDateProp, maxDate: maxDateProp, disabl
|
|
|
432
432
|
const { id, errors, disabled: fieldDisabled, fieldState } = useFieldContext$1();
|
|
433
433
|
const isDisabled = disabled ?? fieldDisabled;
|
|
434
434
|
const hasErrors = errors && errors.length > 0;
|
|
435
|
-
const currentValue = React
|
|
435
|
+
const currentValue = React.useMemo(() => {
|
|
436
436
|
const val = fieldState?.value;
|
|
437
437
|
if (!val) return void 0;
|
|
438
438
|
if (typeof val === "string") return val;
|
|
@@ -441,7 +441,7 @@ function FormDateTimePicker({ minDate: minDateProp, maxDate: maxDateProp, disabl
|
|
|
441
441
|
const maxDate = maxDateProp;
|
|
442
442
|
return /* @__PURE__ */ jsx(DateTimePicker, {
|
|
443
443
|
value: currentValue,
|
|
444
|
-
onChange: React
|
|
444
|
+
onChange: React.useCallback((value) => {
|
|
445
445
|
fieldState?.change(value);
|
|
446
446
|
fieldState?.blur();
|
|
447
447
|
}, [fieldState]),
|
|
@@ -538,12 +538,12 @@ FormDescription.displayName = "Form.Description";
|
|
|
538
538
|
* ```
|
|
539
539
|
*/
|
|
540
540
|
function FormDialog({ open, onOpenChange, defaultOpen, title, description, trigger, schema, defaultValues, onSubmit, onSuccess, onError, submitText = "Submit", submitTextLoading = "Submitting...", cancelText = "Cancel", showCancel = true, submitType = "primary", loading, formComponent, telemetry, className, formClassName, showHeaderClose = true, children }) {
|
|
541
|
-
const [internalOpen, setInternalOpen] = React
|
|
542
|
-
const [internalIsSubmitting, setInternalIsSubmitting] = React
|
|
541
|
+
const [internalOpen, setInternalOpen] = React.useState(defaultOpen ?? false);
|
|
542
|
+
const [internalIsSubmitting, setInternalIsSubmitting] = React.useState(false);
|
|
543
543
|
const isSubmitting = loading ?? internalIsSubmitting;
|
|
544
544
|
const isControlled = open !== void 0;
|
|
545
545
|
const isOpen = isControlled ? open : internalOpen;
|
|
546
|
-
const handleOpenChange = React
|
|
546
|
+
const handleOpenChange = React.useCallback((value) => {
|
|
547
547
|
if (!value && isSubmitting) return;
|
|
548
548
|
if (!isControlled) setInternalOpen(value);
|
|
549
549
|
onOpenChange?.(value);
|
|
@@ -552,7 +552,7 @@ function FormDialog({ open, onOpenChange, defaultOpen, title, description, trigg
|
|
|
552
552
|
isSubmitting,
|
|
553
553
|
onOpenChange
|
|
554
554
|
]);
|
|
555
|
-
const handleSubmit = React
|
|
555
|
+
const handleSubmit = React.useCallback(async (data) => {
|
|
556
556
|
if (loading === void 0) setInternalIsSubmitting(true);
|
|
557
557
|
try {
|
|
558
558
|
await onSubmit?.(data);
|
|
@@ -565,7 +565,7 @@ function FormDialog({ open, onOpenChange, defaultOpen, title, description, trigg
|
|
|
565
565
|
onSuccess,
|
|
566
566
|
loading
|
|
567
567
|
]);
|
|
568
|
-
const handleCancel = React
|
|
568
|
+
const handleCancel = React.useCallback(() => {
|
|
569
569
|
handleOpenChange(false);
|
|
570
570
|
}, [handleOpenChange]);
|
|
571
571
|
return /* @__PURE__ */ jsxs(Dialog, {
|
|
@@ -657,7 +657,7 @@ FormError.displayName = "Form.Error";
|
|
|
657
657
|
//#endregion
|
|
658
658
|
//#region src/components/features/form/components/form-field.tsx
|
|
659
659
|
function FieldLabel({ htmlFor, label, hasErrors, required, tooltip, className }) {
|
|
660
|
-
const [isTooltipVisible, setIsTooltipVisible] = React
|
|
660
|
+
const [isTooltipVisible, setIsTooltipVisible] = React.useState(false);
|
|
661
661
|
return /* @__PURE__ */ jsxs("div", {
|
|
662
662
|
className: "relative flex w-fit items-start space-x-2",
|
|
663
663
|
children: [/* @__PURE__ */ jsxs(Label, {
|
|
@@ -709,21 +709,21 @@ function FormField({ name, children, label, description, tooltip, required = fal
|
|
|
709
709
|
const rawErrors = fieldState.errors;
|
|
710
710
|
const errors = isDisplayTouched ? rawErrors : [];
|
|
711
711
|
const hasErrors = errors.length > 0;
|
|
712
|
-
const hasFocusedRef = React
|
|
713
|
-
React
|
|
712
|
+
const hasFocusedRef = React.useRef(false);
|
|
713
|
+
React.useEffect(() => {
|
|
714
714
|
hasFocusedRef.current = false;
|
|
715
715
|
}, [name]);
|
|
716
|
-
const handleFocus = React
|
|
716
|
+
const handleFocus = React.useCallback((e) => {
|
|
717
717
|
if (e.target.type !== "hidden") hasFocusedRef.current = true;
|
|
718
718
|
}, []);
|
|
719
|
-
const handleChange = React
|
|
719
|
+
const handleChange = React.useCallback(() => {
|
|
720
720
|
if (mode === "onChange" && hasFocusedRef.current) markFieldTouched(name);
|
|
721
721
|
}, [
|
|
722
722
|
mode,
|
|
723
723
|
name,
|
|
724
724
|
markFieldTouched
|
|
725
725
|
]);
|
|
726
|
-
const handleBlur = React
|
|
726
|
+
const handleBlur = React.useCallback(() => {
|
|
727
727
|
if ((mode === "onChange" || mode === "onBlur") && hasFocusedRef.current) markFieldTouched(name);
|
|
728
728
|
}, [
|
|
729
729
|
mode,
|
|
@@ -734,7 +734,7 @@ function FormField({ name, children, label, description, tooltip, required = fal
|
|
|
734
734
|
const descriptionId = description ? `${fieldId}-description` : void 0;
|
|
735
735
|
const errorId = hasErrors ? `${fieldId}-error` : void 0;
|
|
736
736
|
const fieldRequired = required || fieldState.required;
|
|
737
|
-
const contextValue = React
|
|
737
|
+
const contextValue = React.useMemo(() => ({
|
|
738
738
|
name,
|
|
739
739
|
id: fieldId,
|
|
740
740
|
errors,
|
|
@@ -1004,12 +1004,12 @@ FormRadioItem.displayName = "Form.RadioItem";
|
|
|
1004
1004
|
*/
|
|
1005
1005
|
function FormRoot({ schema, children, onSubmit, action, method = "POST", formComponent: FormComp = "form", id, name, defaultValues, mode = "onChange", isSubmitting: externalIsSubmitting, onError, onSuccess, telemetry, className }) {
|
|
1006
1006
|
const adapter = useAdapter();
|
|
1007
|
-
const [internalIsSubmitting, setInternalIsSubmitting] = React
|
|
1007
|
+
const [internalIsSubmitting, setInternalIsSubmitting] = React.useState(false);
|
|
1008
1008
|
const isSubmitting = externalIsSubmitting ?? internalIsSubmitting;
|
|
1009
|
-
const [isSubmitted, setIsSubmitted] = React
|
|
1010
|
-
const [submitCount, setSubmitCount] = React
|
|
1011
|
-
const formRef = React
|
|
1012
|
-
const wrappedOnSubmit = React
|
|
1009
|
+
const [isSubmitted, setIsSubmitted] = React.useState(false);
|
|
1010
|
+
const [submitCount, setSubmitCount] = React.useState(0);
|
|
1011
|
+
const formRef = React.useRef(null);
|
|
1012
|
+
const wrappedOnSubmit = React.useCallback(async (data) => {
|
|
1013
1013
|
setInternalIsSubmitting(true);
|
|
1014
1014
|
setIsSubmitted(true);
|
|
1015
1015
|
setSubmitCount((prev) => prev + 1);
|
|
@@ -1052,7 +1052,7 @@ function FormRoot({ schema, children, onSubmit, action, method = "POST", formCom
|
|
|
1052
1052
|
formRef
|
|
1053
1053
|
});
|
|
1054
1054
|
const { formState } = instance;
|
|
1055
|
-
const contextValue = React
|
|
1055
|
+
const contextValue = React.useMemo(() => ({
|
|
1056
1056
|
form: instance,
|
|
1057
1057
|
fields: instance.fields,
|
|
1058
1058
|
isSubmitting,
|
|
@@ -1283,7 +1283,7 @@ function FormTimePicker({ min, max, step, placeholder, disabled, className }) {
|
|
|
1283
1283
|
return /* @__PURE__ */ jsx(TimePicker, {
|
|
1284
1284
|
id,
|
|
1285
1285
|
value: fieldState?.value ?? "",
|
|
1286
|
-
onChange: React
|
|
1286
|
+
onChange: React.useCallback((value) => {
|
|
1287
1287
|
fieldState?.change(value || void 0);
|
|
1288
1288
|
fieldState?.blur();
|
|
1289
1289
|
}, [fieldState]),
|
|
@@ -1324,7 +1324,7 @@ function FormTransfer({ disabled, minItems, maxItems, ...props }) {
|
|
|
1324
1324
|
const isDisabled = disabled ?? fieldDisabled;
|
|
1325
1325
|
const hasErrors = errors && errors.length > 0;
|
|
1326
1326
|
const value = Array.isArray(fieldState?.value) ? fieldState.value : [];
|
|
1327
|
-
const handleChange = React
|
|
1327
|
+
const handleChange = React.useCallback((newValue) => {
|
|
1328
1328
|
fieldState?.change(newValue);
|
|
1329
1329
|
fieldState?.blur();
|
|
1330
1330
|
}, [fieldState]);
|
|
@@ -1537,12 +1537,19 @@ function useFormContext() {
|
|
|
1537
1537
|
function useFormState() {
|
|
1538
1538
|
const ctx = useFormContext$1();
|
|
1539
1539
|
return {
|
|
1540
|
+
/** Whether any field value differs from its default value */
|
|
1540
1541
|
isDirty: ctx.isDirty,
|
|
1542
|
+
/** Whether the form currently passes validation */
|
|
1541
1543
|
isValid: ctx.isValid,
|
|
1544
|
+
/** Whether the form is currently submitting */
|
|
1542
1545
|
isSubmitting: ctx.isSubmitting,
|
|
1546
|
+
/** Whether the form has been submitted at least once */
|
|
1543
1547
|
isSubmitted: ctx.isSubmitted,
|
|
1548
|
+
/** Number of times the form has been submitted */
|
|
1544
1549
|
submitCount: ctx.submitCount,
|
|
1550
|
+
/** Record of which fields have been modified from defaults */
|
|
1545
1551
|
dirtyFields: ctx.dirtyFields,
|
|
1552
|
+
/** Record of which fields have been focused and blurred */
|
|
1546
1553
|
touchedFields: ctx.touchedFields
|
|
1547
1554
|
};
|
|
1548
1555
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as React
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
//#region src/components/features/form/context/form-context.tsx
|
|
4
|
-
const FormContext = React
|
|
4
|
+
const FormContext = React.createContext(null);
|
|
5
5
|
function FormProvider({ children, value }) {
|
|
6
6
|
return /* @__PURE__ */ jsx(FormContext, {
|
|
7
7
|
value,
|
|
@@ -9,7 +9,7 @@ function FormProvider({ children, value }) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
function useFormContext() {
|
|
12
|
-
const context = React
|
|
12
|
+
const context = React.use(FormContext);
|
|
13
13
|
if (!context) throw new Error("useFormContext must be used within a Form.Root component");
|
|
14
14
|
return context;
|
|
15
15
|
}
|
package/dist/grid/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as getResponsiveValue, c as GRID_COLUMNS, d as RESPONSIVE_MAP, i as getGutter, l as GRID_PREFIX, n as Row, o as registerMediaQuery, r as RowContext, s as GRID_BREAKPOINTS, t as Col, u as RESPONSIVE_ARRAY } from "../col-
|
|
1
|
+
import { a as getResponsiveValue, c as GRID_COLUMNS, d as RESPONSIVE_MAP, i as getGutter, l as GRID_PREFIX, n as Row, o as registerMediaQuery, r as RowContext, s as GRID_BREAKPOINTS, t as Col, u as RESPONSIVE_ARRAY } from "../col-Q6yazFwL.mjs";
|
|
2
2
|
export { Col, GRID_BREAKPOINTS, GRID_COLUMNS, GRID_PREFIX, RESPONSIVE_ARRAY, RESPONSIVE_MAP, Row, RowContext, getGutter, getResponsiveValue, registerMediaQuery };
|