@zayne-labs/ui-react 0.10.0 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/common/await/index.d.ts +2 -2
- package/dist/esm/components/common/index.d.ts +2 -2
- package/dist/esm/components/common/suspense-with-boundary/index.d.ts +1 -1
- package/dist/esm/components/ui/drop-zone/index.d.ts +1 -1
- package/dist/esm/components/ui/form/index.js +1 -1
- package/dist/esm/components/ui/index.d.ts +1 -1
- package/dist/esm/components/ui/index.js +1 -1
- package/dist/esm/drop-zone-BPfSu99L.js.map +1 -1
- package/dist/esm/{form-Bkj1QWwb.js → form-BnSpmc4f.js} +5 -9
- package/dist/esm/form-BnSpmc4f.js.map +1 -0
- package/dist/esm/{index-BBGuBbI_.d.ts → index-BEv8nXKb.d.ts} +16 -16
- package/dist/esm/{index-Ci8USVIW.d.ts → index-BaONHZq0.d.ts} +2 -2
- package/dist/esm/{index-DM-Rbcq2.d.ts → index-eCX5RJ41.d.ts} +3 -3
- package/package.json +1 -1
- package/dist/esm/form-Bkj1QWwb.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../../../index-BNrCAe9Y.js";
|
|
2
2
|
import "../../../index-lKxE9WPi.js";
|
|
3
|
-
import "../../../index-
|
|
4
|
-
import { AwaitError, AwaitPending, AwaitRoot, AwaitSuccess, await_parts_d_exports, useAwaitContext } from "../../../index-
|
|
3
|
+
import "../../../index-eCX5RJ41.js";
|
|
4
|
+
import { AwaitError, AwaitPending, AwaitRoot, AwaitSuccess, await_parts_d_exports, useAwaitContext } from "../../../index-BaONHZq0.js";
|
|
5
5
|
export { await_parts_d_exports as Await, AwaitError, AwaitPending, AwaitRoot, AwaitSuccess, useAwaitContext };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../../index-BNrCAe9Y.js";
|
|
2
2
|
import { ErrorBoundary } from "../../index-lKxE9WPi.js";
|
|
3
|
-
import { SuspenseWithBoundary } from "../../index-
|
|
4
|
-
import { await_parts_d_exports } from "../../index-
|
|
3
|
+
import { SuspenseWithBoundary } from "../../index-eCX5RJ41.js";
|
|
4
|
+
import { await_parts_d_exports } from "../../index-BaONHZq0.js";
|
|
5
5
|
import { For, ForWithWrapper } from "../../index-CnvH74ea.js";
|
|
6
6
|
import { show_parts_d_exports } from "../../index-DVr1tbxh.js";
|
|
7
7
|
import { slot_parts_d_exports } from "../../index-BBJzo-WC.js";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import "../../../index-lKxE9WPi.js";
|
|
2
|
-
import { SuspenseWithBoundary, SuspenseWithBoundaryProps } from "../../../index-
|
|
2
|
+
import { SuspenseWithBoundary, SuspenseWithBoundaryProps } from "../../../index-eCX5RJ41.js";
|
|
3
3
|
export { SuspenseWithBoundary, SuspenseWithBoundaryProps };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ClassNames, DropZoneArea, DropZoneContainer, DropZoneContext, DropZoneContextProps, DropZoneErrorPreview, DropZoneFilePreview, DropZoneInput, DropZoneRoot, DropZoneRootProps, DropZoneTrigger, ExtraProps, UseDropZoneProps, UseDropZoneResult, drop_zone_parts_d_exports, useDropZone, useDropZoneStoreContext } from "../../../index-
|
|
1
|
+
import { ClassNames, DropZoneArea, DropZoneContainer, DropZoneContext, DropZoneContextProps, DropZoneErrorPreview, DropZoneFilePreview, DropZoneInput, DropZoneRoot, DropZoneRootProps, DropZoneTrigger, ExtraProps, UseDropZoneProps, UseDropZoneResult, drop_zone_parts_d_exports, useDropZone, useDropZoneStoreContext } from "../../../index-BEv8nXKb.js";
|
|
2
2
|
export { ClassNames, drop_zone_parts_d_exports as DropZone, DropZoneArea, DropZoneContainer, DropZoneContext, DropZoneContextProps, DropZoneErrorPreview, DropZoneFilePreview, DropZoneInput, DropZoneRoot, DropZoneRootProps, DropZoneTrigger, ExtraProps, UseDropZoneProps, UseDropZoneResult, useDropZone, useDropZoneStoreContext };
|
|
@@ -5,6 +5,6 @@ import "../../../getSlot-Cf5ON6lE.js";
|
|
|
5
5
|
import "../../../slot-D1062oA5.js";
|
|
6
6
|
import "../../../for-DGs2XZ21.js";
|
|
7
7
|
import "../../../cn-_FbtIrlZ.js";
|
|
8
|
-
import { FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormField, FormFieldContext, FormFieldControlledField, FormFieldController, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputRightItem, FormLabel, FormRoot, FormSelect, FormSelectPrimitive, FormSubmit, FormSubscribeToFieldValue, FormSubscribeToFormState, FormTextArea, FormTextAreaPrimitive, form_parts_exports, useFormRootContext, useStrictFormFieldContext } from "../../../form-
|
|
8
|
+
import { FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormField, FormFieldContext, FormFieldControlledField, FormFieldController, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputRightItem, FormLabel, FormRoot, FormSelect, FormSelectPrimitive, FormSubmit, FormSubscribeToFieldValue, FormSubscribeToFormState, FormTextArea, FormTextAreaPrimitive, form_parts_exports, useFormRootContext, useStrictFormFieldContext } from "../../../form-BnSpmc4f.js";
|
|
9
9
|
|
|
10
10
|
export { form_parts_exports as Form, FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormField, FormFieldContext, FormFieldControlledField, FormFieldController, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputRightItem, FormLabel, FormRoot, FormSelect, FormSelectPrimitive, FormSubmit, FormSubscribeToFieldValue, FormSubscribeToFormState, FormTextArea, FormTextAreaPrimitive, useStrictFormFieldContext as useFormFieldContext, useFormRootContext };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { card_parts_d_exports } from "../../index-BeDmH7lX.js";
|
|
2
2
|
import { carousel_parts_d_exports } from "../../index-DqutTJQB.js";
|
|
3
3
|
import { useDragScroll } from "../../index-BYhH4Fm0.js";
|
|
4
|
-
import { drop_zone_parts_d_exports, useDropZone } from "../../index-
|
|
4
|
+
import { drop_zone_parts_d_exports, useDropZone } from "../../index-BEv8nXKb.js";
|
|
5
5
|
import { form_parts_d_exports } from "../../index-CMwCQ8qR.js";
|
|
6
6
|
export { card_parts_d_exports as Card, carousel_parts_d_exports as Carousel, drop_zone_parts_d_exports as DropZone, form_parts_d_exports as Form, useDragScroll, useDropZone };
|
|
@@ -14,6 +14,6 @@ import { card_parts_exports } from "../../card-TD60Xux0.js";
|
|
|
14
14
|
import { carousel_parts_exports } from "../../carousel-YXXtZ85s.js";
|
|
15
15
|
import { useDragScroll } from "../../drag-scroll-De6-soln.js";
|
|
16
16
|
import { drop_zone_parts_exports, useDropZone } from "../../drop-zone-BPfSu99L.js";
|
|
17
|
-
import { form_parts_exports } from "../../form-
|
|
17
|
+
import { form_parts_exports } from "../../form-BnSpmc4f.js";
|
|
18
18
|
|
|
19
19
|
export { card_parts_exports as Card, carousel_parts_exports as Carousel, drop_zone_parts_exports as DropZone, form_parts_exports as Form, useDragScroll, useDropZone };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drop-zone-BPfSu99L.js","names":["useDropZoneStore: UseDropZoneResult[\"useDropZoneStore\"]","getContainerProps: UseDropZoneResult[\"propGetters\"][\"getContainerProps\"]","getInputProps: UseDropZoneResult[\"propGetters\"][\"getInputProps\"]","getTriggerProps: UseDropZoneResult[\"propGetters\"][\"getTriggerProps\"]","Component"],"sources":["../../src/components/ui/drop-zone/drop-zone-context.ts","../../src/components/ui/drop-zone/utils.ts","../../src/components/ui/drop-zone/drop-zone-store.ts","../../src/components/ui/drop-zone/use-drop-zone.ts","../../src/components/ui/drop-zone/drop-zone.tsx","../../src/components/ui/drop-zone/drop-zone-parts.ts"],"sourcesContent":["import { createCustomContext } from \"@zayne-labs/toolkit-react\";\nimport { createZustandContext } from \"@zayne-labs/toolkit-react/zustand\";\nimport type { DropZoneStore } from \"./drop-zone-store\";\nimport type { DropZonePropGetters } from \"./types\";\n\nconst [DropZoneStoreContextProvider, useDropZoneStoreContext] = createZustandContext<DropZoneStore>({\n\thookName: \"useDropZoneStoreContext\",\n\tname: \"DropZoneStoreContext\",\n\tproviderName: \"DropZoneRoot\",\n});\n\nconst [DropZonePropGettersContextProvider, usePropGettersContext] =\n\tcreateCustomContext<DropZonePropGetters>({\n\t\thookName: \"usePropGettersContext\",\n\t\tname: \"PropGettersContext\",\n\t\tproviderName: \"DropZoneRoot\",\n\t});\n\nexport {\n\tDropZoneStoreContextProvider,\n\tuseDropZoneStoreContext,\n\tDropZonePropGettersContextProvider,\n\tusePropGettersContext,\n};\n","import { createImagePreview, type FileMeta } from \"@zayne-labs/toolkit-core\";\nimport { isFile } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { FileState } from \"./types\";\n\nexport const generateUniqueId = (file: File | FileMeta): string => {\n\tif (!isFile(file)) {\n\t\treturn file.id;\n\t}\n\n\treturn `${file.name}-(${Math.round(performance.now())})-${crypto.randomUUID().slice(0, 8)}`;\n};\n\nexport const createObjectURL = (file: File, disallowPreviewForNonImageFiles: boolean | undefined) => {\n\tif (disallowPreviewForNonImageFiles && !file.type.startsWith(\"image/\")) return;\n\n\treturn createImagePreview(file);\n};\n\nexport const clearObjectURL = (\n\tfileState: FileState | undefined,\n\tdisallowPreviewForNonImageFiles: boolean | undefined\n) => {\n\tif (!isFile(fileState?.file)) return;\n\n\tif (disallowPreviewForNonImageFiles && !fileState.file.type.startsWith(\"image/\")) return;\n\n\tif (!fileState.preview) return;\n\n\tURL.revokeObjectURL(fileState.preview);\n};\n","import { createStore, handleFileValidationAsync, toArray } from \"@zayne-labs/toolkit-core\";\nimport { isString } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { DropZoneActions, DropZoneState } from \"./types\";\nimport type { UseDropZoneProps } from \"./use-drop-zone\";\nimport { clearObjectURL, createObjectURL, generateUniqueId } from \"./utils\";\n\nexport type DropZoneStore = DropZoneState & { actions: DropZoneActions };\n\nexport const createDropZoneStore = (\n\tinitStoreValues: Pick<\n\t\tUseDropZoneProps,\n\t\t| \"allowedFileTypes\"\n\t\t| \"disablePreviewForNonImageFiles\"\n\t\t| \"initialFiles\"\n\t\t| \"maxFileCount\"\n\t\t| \"maxFileSize\"\n\t\t| \"multiple\"\n\t\t| \"onFilesChange\"\n\t\t| \"onUpload\"\n\t\t| \"onUploadError\"\n\t\t| \"onUploadErrorCollection\"\n\t\t| \"onUploadSuccess\"\n\t\t| \"rejectDuplicateFiles\"\n\t\t| \"validator\"\n\t> & {\n\t\tinputRef: React.RefObject<HTMLInputElement | null>;\n\t}\n) => {\n\tconst {\n\t\tallowedFileTypes,\n\t\tdisablePreviewForNonImageFiles,\n\t\tinitialFiles,\n\t\tinputRef,\n\t\tmaxFileCount,\n\t\tmaxFileSize,\n\t\tmultiple,\n\t\tonFilesChange,\n\t\tonUpload,\n\t\tonUploadError,\n\t\tonUploadErrorCollection,\n\t\tonUploadSuccess,\n\t\trejectDuplicateFiles,\n\t\tvalidator,\n\t} = initStoreValues;\n\n\tconst initialFileArray = toArray(initialFiles).filter(Boolean);\n\n\tconst clearInputValue = () => {\n\t\tif (!inputRef.current) return;\n\n\t\tinputRef.current.value = \"\";\n\t};\n\n\tconst store = createStore<DropZoneStore>((set, get) => ({\n\t\terrors: [],\n\t\tfileStateArray: initialFileArray.map((fileMeta) => ({\n\t\t\tfile: fileMeta,\n\t\t\tid: fileMeta.id,\n\t\t\tpreview: fileMeta.url,\n\t\t})),\n\t\tisDraggingOver: false,\n\n\t\t// eslint-disable-next-line perfectionist/sort-objects -- Ignore\n\t\tactions: {\n\t\t\t// registerEventListeners: () => {\n\t\t\t// \tconst containerElement = {}\n\t\t\t// \tconst inputElement = {}\n\n\t\t\t// \tinputRef.current.addEventListener(\"change\", get().actions.handleChange);\n\t\t\t// \tinputRef.current.addEventListener(\"dragenter\", get().actions.handleDragEnter);\n\t\t\t// \tinputRef.current.addEventListener(\"dragleave\", get().actions.handleDragLeave);\n\t\t\t// \tinputRef.current.addEventListener(\"dragover\", get().actions.handleDragOver);\n\t\t\t// \tinputRef.current.addEventListener(\"drop\", get().actions.handleDrop);\n\t\t\t// },\n\t\t\taddFiles: async (files) => {\n\t\t\t\tif (!files || files.length === 0) {\n\t\t\t\t\tconsole.warn(\"No file selected!\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { fileStateArray } = get();\n\n\t\t\t\t// == In single file mode, only use the first file\n\t\t\t\tconst newFiles = !multiple ? [files[0]] : files;\n\n\t\t\t\tconst { errors, validFiles } = await handleFileValidationAsync({\n\t\t\t\t\texistingFiles: fileStateArray.map((fileWithPreview) => fileWithPreview.file),\n\t\t\t\t\thooks: {\n\t\t\t\t\t\tonError: onUploadError,\n\t\t\t\t\t\tonErrorCollection: onUploadErrorCollection,\n\t\t\t\t\t\tonSuccess: onUploadSuccess,\n\t\t\t\t\t},\n\t\t\t\t\tnewFiles,\n\t\t\t\t\tsettings: {\n\t\t\t\t\t\tallowedFileTypes,\n\t\t\t\t\t\tmaxFileCount,\n\t\t\t\t\t\tmaxFileSize,\n\t\t\t\t\t\trejectDuplicateFiles,\n\t\t\t\t\t\tvalidator,\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tif (validFiles.length === 0) {\n\t\t\t\t\tset({ errors, isDraggingOver: false });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst newFileStateArray = validFiles.map((file) => ({\n\t\t\t\t\tfile,\n\t\t\t\t\tid: generateUniqueId(file),\n\t\t\t\t\tpreview: createObjectURL(file, disablePreviewForNonImageFiles),\n\t\t\t\t}));\n\n\t\t\t\tset({\n\t\t\t\t\terrors,\n\t\t\t\t\tfileStateArray: multiple ? [...fileStateArray, ...newFileStateArray] : newFileStateArray,\n\t\t\t\t\tisDraggingOver: false,\n\t\t\t\t});\n\n\t\t\t\tawait onUpload?.({ fileStateArray: newFileStateArray });\n\t\t\t},\n\t\t\tclearErrors: () => {\n\t\t\t\tset({ errors: [] });\n\t\t\t},\n\t\t\tclearFiles: () => {\n\t\t\t\tconst { fileStateArray } = get();\n\n\t\t\t\tfor (const fileState of fileStateArray) {\n\t\t\t\t\tclearObjectURL(fileState, disablePreviewForNonImageFiles);\n\t\t\t\t}\n\n\t\t\t\tset({ fileStateArray: [] });\n\t\t\t},\n\t\t\thandleChange: async (event) => {\n\t\t\t\tconst fileList = event.target.files;\n\n\t\t\t\tconst { actions } = get();\n\n\t\t\t\tawait actions.addFiles(fileList);\n\n\t\t\t\tclearInputValue();\n\t\t\t},\n\t\t\thandleDragEnter: (event) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\n\t\t\t\tset({ isDraggingOver: true });\n\t\t\t},\n\t\t\thandleDragLeave: (event) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\n\t\t\t\tset({ isDraggingOver: false });\n\t\t\t},\n\t\t\thandleDragOver: (event) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t},\n\t\t\thandleDrop: async (event) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\n\t\t\t\tif (inputRef.current?.disabled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst fileList = event.dataTransfer.files;\n\n\t\t\t\tconst { actions } = get();\n\n\t\t\t\tawait actions.addFiles(fileList);\n\t\t\t},\n\t\t\topenFilePicker: () => {\n\t\t\t\tinputRef.current?.click();\n\t\t\t},\n\t\t\tremoveFile: (fileToRemoveOrFileId) => {\n\t\t\t\tconst { fileStateArray } = get();\n\n\t\t\t\tconst actualFileToRemove =\n\t\t\t\t\tisString(fileToRemoveOrFileId) ?\n\t\t\t\t\t\tfileStateArray.find((file) => file.id === fileToRemoveOrFileId)\n\t\t\t\t\t:\tfileToRemoveOrFileId;\n\n\t\t\t\tif (!actualFileToRemove) return;\n\n\t\t\t\tclearObjectURL(actualFileToRemove, disablePreviewForNonImageFiles);\n\n\t\t\t\tconst updatedFileStateArray = fileStateArray.filter(\n\t\t\t\t\t(file) => file.id !== actualFileToRemove.id\n\t\t\t\t);\n\n\t\t\t\tset({ errors: [], fileStateArray: updatedFileStateArray });\n\t\t\t},\n\t\t},\n\t}));\n\n\tstore.subscribe.withSelector(\n\t\t(state) => state.fileStateArray,\n\t\t(fileStateArray) => {\n\t\t\tonFilesChange?.({ fileStateArray });\n\t\t}\n\t);\n\n\treturn store;\n};\n","import type {\n\tFileMeta,\n\tFileValidationHooksAsync,\n\tFileValidationSettingsAsync,\n} from \"@zayne-labs/toolkit-core\";\nimport { dataAttr } from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef, useConstant, useShallowComparedValue, useStore } from \"@zayne-labs/toolkit-react\";\nimport type { InferProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { composeRefs, composeTwoEventHandlers, mergeTwoProps } from \"@zayne-labs/toolkit-react/utils\";\nimport type { Awaitable } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport type { useDropZoneStoreContext } from \"./drop-zone-context\";\nimport { createDropZoneStore } from \"./drop-zone-store\";\nimport type { DropZonePropGetters, DropZoneState } from \"./types\";\n\nexport type ExtraProps = {\n\tcontainer?: InferProps<HTMLElement>;\n\tinput?: InferProps<\"input\">;\n\ttrigger?: InferProps<\"button\">;\n};\n\nexport type ClassNames = {\n\t[key in keyof ExtraProps]: string;\n};\n\nexport type UseDropZoneResult = {\n\tinputRef: React.RefObject<HTMLInputElement | null>;\n\tpropGetters: DropZonePropGetters;\n\tstoreApi: ReturnType<typeof createDropZoneStore>;\n\tuseDropZoneStore: typeof useDropZoneStoreContext;\n};\n\nexport type UseDropZoneProps = FileValidationSettingsAsync & {\n\t/**\n\t * CSS classes to apply to the various parts of the drop zone\n\t */\n\tclassNames?: ClassNames;\n\n\t/**\n\t * Whether to disallow preview for non-image files\n\t * @default true\n\t */\n\tdisablePreviewForNonImageFiles?: boolean;\n\n\t/**\n\t * Extra props to pass to various parts of the dropzone\n\t */\n\textraProps?: ExtraProps;\n\n\t/**\n\t * Initial files to populate the drop zone\n\t */\n\tinitialFiles?: FileMeta | FileMeta[] | null;\n\n\t/**\n\t * Whether to allow multiple files to be uploaded\n\t */\n\tmultiple?: boolean;\n\n\t/**\n\t * Callback function to be called when internal files state changes\n\t */\n\tonFilesChange?: (context: Pick<DropZoneState, \"fileStateArray\">) => void;\n\n\t/**\n\t * Callback function to be called when new files are uploaded\n\t */\n\tonUpload?: (context: Pick<DropZoneState, \"fileStateArray\">) => Awaitable<void>;\n\n\t/**\n\t * Callback function to be called on each file upload as they occur\n\t */\n\tonUploadError?: FileValidationHooksAsync[\"onError\"];\n\n\t/**\n\t * Callback function to be called once after all file upload errors have occurred\n\t */\n\tonUploadErrorCollection?: FileValidationHooksAsync[\"onErrorCollection\"];\n\n\t/**\n\t * Callback function to be called on file upload success\n\t */\n\tonUploadSuccess?: FileValidationHooksAsync[\"onSuccess\"];\n\n\t/**\n\t * Whether clicking the drop zone area will open the default file picker or not\n\t *\n\t * @default true\n\t */\n\tshouldOpenFilePickerOnAreaClick?: boolean;\n\n\t/**\n\t * Custom validation function.\n\t *\n\t * If the function returns false, the file will be rejected\n\t *\n\t */\n\tvalidator?: FileValidationSettingsAsync[\"validator\"];\n};\n\nexport const useDropZone = (props?: UseDropZoneProps): UseDropZoneResult => {\n\tconst {\n\t\tallowedFileTypes,\n\t\tclassNames,\n\t\tdisablePreviewForNonImageFiles = true,\n\t\textraProps,\n\t\tinitialFiles,\n\t\tmaxFileCount,\n\t\tmaxFileSize,\n\t\tmultiple,\n\t\tonFilesChange,\n\t\tonUpload,\n\t\tonUploadError,\n\t\tonUploadErrorCollection,\n\t\tonUploadSuccess,\n\t\trejectDuplicateFiles = true,\n\t\tshouldOpenFilePickerOnAreaClick = true,\n\t\tvalidator,\n\t} = props ?? {};\n\n\tconst inputRef = useRef<HTMLInputElement>(null);\n\n\tconst savedOnFilesChange = useCallbackRef(onFilesChange);\n\tconst savedOnUpload = useCallbackRef(onUpload);\n\tconst savedOnUploadError = useCallbackRef(onUploadError);\n\tconst savedOnUploadErrorCollection = useCallbackRef(onUploadErrorCollection);\n\tconst savedOnUploadSuccess = useCallbackRef(onUploadSuccess);\n\tconst savedValidator = useCallbackRef(validator);\n\n\tconst constantInitialFiles = useConstant(() => initialFiles);\n\tconst shallowComparedMaxFileSize = useShallowComparedValue(maxFileSize);\n\tconst shallowComparedAllowedFileTypes = useShallowComparedValue(allowedFileTypes);\n\n\tconst storeApi = useMemo(() => {\n\t\treturn createDropZoneStore({\n\t\t\tallowedFileTypes: shallowComparedAllowedFileTypes,\n\t\t\tdisablePreviewForNonImageFiles,\n\t\t\tinitialFiles: constantInitialFiles,\n\t\t\tinputRef,\n\t\t\tmaxFileCount,\n\t\t\tmaxFileSize: shallowComparedMaxFileSize,\n\t\t\tmultiple,\n\t\t\tonFilesChange: savedOnFilesChange,\n\t\t\tonUpload: savedOnUpload,\n\t\t\tonUploadError: savedOnUploadError,\n\t\t\tonUploadErrorCollection: savedOnUploadErrorCollection,\n\t\t\tonUploadSuccess: savedOnUploadSuccess,\n\t\t\trejectDuplicateFiles,\n\t\t\tvalidator: savedValidator,\n\t\t});\n\t}, [\n\t\tshallowComparedAllowedFileTypes,\n\t\tdisablePreviewForNonImageFiles,\n\t\tconstantInitialFiles,\n\t\tmaxFileCount,\n\t\tshallowComparedMaxFileSize,\n\t\tmultiple,\n\t\tsavedOnFilesChange,\n\t\tsavedOnUpload,\n\t\tsavedOnUploadError,\n\t\tsavedOnUploadErrorCollection,\n\t\tsavedOnUploadSuccess,\n\t\trejectDuplicateFiles,\n\t\tsavedValidator,\n\t]);\n\n\tconst useDropZoneStore: UseDropZoneResult[\"useDropZoneStore\"] = (selector) => {\n\t\treturn useStore(storeApi, selector);\n\t};\n\n\tconst isDraggingOver = useDropZoneStore((store) => store.isDraggingOver);\n\tconst actions = useDropZoneStore((store) => store.actions);\n\n\tconst getContainerProps: UseDropZoneResult[\"propGetters\"][\"getContainerProps\"] = useCallback(\n\t\t(containerProps) => {\n\t\t\tconst mergedContainerProps = mergeTwoProps(extraProps?.container, containerProps);\n\n\t\t\treturn {\n\t\t\t\t...mergedContainerProps,\n\t\t\t\tclassName: cnMerge(\n\t\t\t\t\t\"relative isolate flex flex-col\",\n\t\t\t\t\tisDraggingOver && \"opacity-60\",\n\t\t\t\t\tclassNames?.container,\n\t\t\t\t\tmergedContainerProps.className\n\t\t\t\t),\n\t\t\t\t\"data-drag-over\": dataAttr(isDraggingOver),\n\t\t\t\t\"data-scope\": \"dropzone\",\n\t\t\t\t// eslint-disable-next-line perfectionist/sort-objects -- I need data-scope to be first\n\t\t\t\t\"data-part\": \"container\",\n\t\t\t\t\"data-slot\": \"dropzone-container\",\n\t\t\t\tonDragEnter: composeTwoEventHandlers(\n\t\t\t\t\tactions.handleDragEnter,\n\t\t\t\t\tmergedContainerProps.onDragEnter\n\t\t\t\t),\n\t\t\t\tonDragLeave: composeTwoEventHandlers(\n\t\t\t\t\tactions.handleDragLeave,\n\t\t\t\t\tmergedContainerProps.onDragLeave\n\t\t\t\t),\n\t\t\t\tonDragOver: composeTwoEventHandlers(actions.handleDragOver, mergedContainerProps.onDragOver),\n\t\t\t\tonDrop: composeTwoEventHandlers(actions.handleDrop, mergedContainerProps.onDrop),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tactions.handleDragEnter,\n\t\t\tactions.handleDragLeave,\n\t\t\tactions.handleDragOver,\n\t\t\tactions.handleDrop,\n\t\t\tclassNames?.container,\n\t\t\textraProps?.container,\n\t\t\tisDraggingOver,\n\t\t]\n\t);\n\n\tconst getInputProps: UseDropZoneResult[\"propGetters\"][\"getInputProps\"] = useCallback(\n\t\t(inputProps) => {\n\t\t\tconst mergedInputProps = mergeTwoProps(extraProps?.input, inputProps);\n\n\t\t\treturn {\n\t\t\t\t...mergedInputProps,\n\t\t\t\taccept: allowedFileTypes ? allowedFileTypes.join(\", \") : mergedInputProps.accept,\n\t\t\t\tclassName: cnMerge(\n\t\t\t\t\tshouldOpenFilePickerOnAreaClick ?\n\t\t\t\t\t\t\"absolute inset-0 z-[100] cursor-pointer opacity-0\"\n\t\t\t\t\t:\t\"hidden\",\n\t\t\t\t\tclassNames?.input,\n\t\t\t\t\tmergedInputProps.className\n\t\t\t\t),\n\t\t\t\t\"data-drag-over\": dataAttr(isDraggingOver),\n\t\t\t\t\"data-scope\": \"dropzone\",\n\t\t\t\t// eslint-disable-next-line perfectionist/sort-objects -- I need data-scope to be first\n\t\t\t\t\"data-part\": \"input\",\n\t\t\t\t\"data-slot\": \"dropzone-input\",\n\t\t\t\tmultiple: multiple ?? mergedInputProps.multiple,\n\t\t\t\tonChange: composeTwoEventHandlers(actions.handleChange, mergedInputProps.onChange),\n\t\t\t\tref: composeRefs(inputRef, mergedInputProps.ref),\n\t\t\t\ttype: \"file\",\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tactions.handleChange,\n\t\t\tallowedFileTypes,\n\t\t\tclassNames?.input,\n\t\t\textraProps?.input,\n\t\t\tisDraggingOver,\n\t\t\tmultiple,\n\t\t\tshouldOpenFilePickerOnAreaClick,\n\t\t]\n\t);\n\n\tconst getTriggerProps: UseDropZoneResult[\"propGetters\"][\"getTriggerProps\"] = useCallback(\n\t\t(triggerProps) => {\n\t\t\tconst mergedTriggerProps = mergeTwoProps(extraProps?.trigger, triggerProps);\n\n\t\t\treturn {\n\t\t\t\t...mergedTriggerProps,\n\t\t\t\tclassName: cnMerge(classNames?.trigger, mergedTriggerProps.className),\n\t\t\t\t\"data-scope\": \"dropzone\",\n\t\t\t\t// eslint-disable-next-line perfectionist/sort-objects -- I need data-scope to be first\n\t\t\t\t\"data-part\": \"trigger\",\n\t\t\t\t\"data-slot\": \"dropzone-trigger\",\n\t\t\t\tonClick: composeTwoEventHandlers(actions.openFilePicker, mergedTriggerProps.onClick),\n\t\t\t};\n\t\t},\n\t\t[actions.openFilePicker, classNames?.trigger, extraProps?.trigger]\n\t);\n\n\t// const getDeleteProps: UseDropZoneResult[\"propGetters\"][\"getTriggerProps\"] = useCallback(\n\t// \t(triggerProps) => {\n\t// \t\tconst mergedTriggerProps = mergeTwoProps(extraProps?.trigger, triggerProps);\n\n\t// \t\treturn {\n\t// \t\t\t...mergedTriggerProps,\n\t// \t\t\tclassName: cnMerge(classNames?.trigger, mergedTriggerProps.className),\n\t// \t\t\t\"data-scope\": \"dropzone\",\n\t// \t\t\t// eslint-disable-next-line perfectionist/sort-objects -- I need data-scope to be first\n\t// \t\t\t\"data-part\": \"trigger\",\n\t// \t\t\t\"data-slot\": \"dropzone-trigger\",\n\t// \t\t\tonClick: composeTwoEventHandlers(actions.openFilePicker, mergedTriggerProps.onClick),\n\t// \t\t};\n\t// \t},\n\t// \t[actions.openFilePicker, classNames?.trigger, extraProps?.trigger]\n\t// );\n\n\tconst propGetters = useMemo(\n\t\t() => ({ getContainerProps, getInputProps, getTriggerProps }),\n\t\t[getContainerProps, getInputProps, getTriggerProps]\n\t);\n\n\tconst savedUseDropZoneStore = useCallbackRef(useDropZoneStore);\n\n\tconst result = useMemo<UseDropZoneResult>(\n\t\t() =>\n\t\t\t({\n\t\t\t\tinputRef,\n\t\t\t\tpropGetters,\n\t\t\t\tstoreApi,\n\t\t\t\tuseDropZoneStore: savedUseDropZoneStore,\n\t\t\t}) satisfies UseDropZoneResult,\n\t\t[propGetters, storeApi, savedUseDropZoneStore]\n\t);\n\n\treturn result;\n};\n","\"use client\";\n\nimport type { PolymorphicProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { isFunction, type SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport * as React from \"react\";\nimport { Slot } from \"@/components/common\";\nimport {\n\tDropZonePropGettersContextProvider,\n\tDropZoneStoreContextProvider,\n\tuseDropZoneStoreContext,\n\tusePropGettersContext,\n} from \"./drop-zone-context\";\nimport type { DropZoneStore } from \"./drop-zone-store\";\nimport { type ExtraProps, type UseDropZoneProps, useDropZone } from \"./use-drop-zone\";\n\nexport type DropZoneRootProps = UseDropZoneProps & { children: React.ReactNode };\n\nexport function DropZoneRoot(props: DropZoneRootProps) {\n\tconst { children, ...restOfProps } = props;\n\n\tconst dropZone = useDropZone(restOfProps);\n\n\treturn (\n\t\t<DropZoneStoreContextProvider store={dropZone.storeApi}>\n\t\t\t<DropZonePropGettersContextProvider value={dropZone.propGetters}>\n\t\t\t\t{children}\n\t\t\t</DropZonePropGettersContextProvider>\n\t\t</DropZoneStoreContextProvider>\n\t);\n}\n\nexport type DropZoneContextProps<TSlice> = {\n\tchildren: React.ReactNode | ((props: TSlice) => React.ReactNode);\n\tselector?: SelectorFn<DropZoneStore, TSlice>;\n};\n\nexport function DropZoneContext<TSlice = DropZoneStore>(props: DropZoneContextProps<TSlice>) {\n\tconst { children, selector } = props;\n\n\tconst dropZoneCtx = useDropZoneStoreContext(selector);\n\n\tconst resolvedChildren = isFunction(children) ? children(dropZoneCtx) : children;\n\n\treturn resolvedChildren;\n}\n\ntype DropZoneContainerProps = ExtraProps[\"container\"] & { asChild?: boolean };\n\nexport function DropZoneContainer<TElement extends React.ElementType = \"div\">(\n\tprops: PolymorphicProps<TElement, DropZoneContainerProps>\n) {\n\tconst { as: Element = \"div\", asChild, ...restOfProps } = props;\n\n\tconst propGetters = usePropGettersContext();\n\n\tconst Component = asChild ? Slot.Root : Element;\n\n\treturn <Component {...propGetters.getContainerProps(restOfProps)} />;\n}\n\ntype DropZoneInputProps = ExtraProps[\"input\"] & { asChild?: boolean };\n\nexport function DropZoneInput(props: DropZoneInputProps) {\n\tconst { asChild, ...restOfProps } = props;\n\n\tconst propGetters = usePropGettersContext();\n\n\tconst Component = asChild ? Slot.Root : \"input\";\n\n\treturn <Component {...propGetters.getInputProps(restOfProps)} />;\n}\n\ntype DropZoneAreaProps<TSlice> = {\n\tchildren: React.ReactNode | ((props: TSlice) => React.ReactNode);\n\textraProps?: Pick<ExtraProps, \"container\" | \"input\">;\n\tselector?: SelectorFn<DropZoneStore, TSlice>;\n};\n\nexport function DropZoneArea<TSlice = DropZoneStore>(props: DropZoneAreaProps<TSlice>) {\n\tconst { children, extraProps, selector } = props;\n\n\treturn (\n\t\t<DropZoneContainer {...extraProps?.container}>\n\t\t\t<DropZoneInput {...extraProps?.input} />\n\n\t\t\t<DropZoneContext selector={selector}>{children}</DropZoneContext>\n\t\t</DropZoneContainer>\n\t);\n}\n\ntype DropZoneTriggerProps = ExtraProps[\"trigger\"] & { asChild?: boolean };\n\nexport function DropZoneTrigger(props: DropZoneTriggerProps) {\n\tconst { asChild, ...restOfProps } = props;\n\n\tconst propGetters = usePropGettersContext();\n\n\tconst Component = asChild ? Slot.Root : \"button\";\n\n\treturn <Component {...propGetters.getTriggerProps(restOfProps)} />;\n}\n\ntype DropZoneFilePreviewProps = {\n\tchildren:\n\t\t| React.ReactNode\n\t\t| ((props: Pick<DropZoneStore, \"actions\" | \"fileStateArray\">) => React.ReactNode);\n};\n\nexport function DropZoneFilePreview(props: DropZoneFilePreviewProps) {\n\tconst { children } = props;\n\n\tconst fileStateArray = useDropZoneStoreContext((store) => store.fileStateArray);\n\tconst actions = useDropZoneStoreContext((store) => store.actions);\n\n\tif (fileStateArray.length === 0) return;\n\n\tconst resolvedChildren = isFunction(children) ? children({ actions, fileStateArray }) : children;\n\n\treturn resolvedChildren;\n}\n\ntype DropZoneErrorPreviewProps = {\n\tchildren: React.ReactNode | ((props: Pick<DropZoneStore, \"actions\" | \"errors\">) => React.ReactNode);\n};\n\nexport function DropZoneErrorPreview(props: DropZoneErrorPreviewProps) {\n\tconst { children } = props;\n\n\tconst errors = useDropZoneStoreContext((store) => store.errors);\n\tconst actions = useDropZoneStoreContext((store) => store.actions);\n\n\tif (errors.length === 0) return;\n\n\tconst resolvedChildren = isFunction(children) ? children({ actions, errors }) : children;\n\n\treturn resolvedChildren;\n}\n","export {\n\tDropZoneArea as Area,\n\tDropZoneContainer as Container,\n\tDropZoneContext as Context,\n\tDropZoneErrorPreview as ErrorPreview,\n\tDropZoneFilePreview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;;AAGxC;AAID,SAAgB,gBAAgB,OAA6B;CAC5D,MAAM,EAAE,QAAS,GAAG,aAAa,GAAG;CAEpC,MAAM,cAAc;CAEpB,MAAMA,cAAY,qBAAsB;AAExC,QAAO,oBAACA,eAAU,GAAI,YAAY,gBAAgB;AAClD;AAQD,SAAgB,oBAAoB,OAAiC;CACpE,MAAM,EAAE,UAAU,GAAG;CAErB,MAAM,iBAAiB,yBAAyB,UAAU,MAAM;CAChE,MAAM,UAAU,yBAAyB,UAAU,MAAM;AAEzD,KAAI,eAAe,WAAW,EAAG;CAEjC,MAAM,mBAAmB,WAAW,YAAY,SAAS;EAAE;EAAS;EAAgB,IAAI;AAExF,QAAO;AACP;AAMD,SAAgB,qBAAqB,OAAkC;CACtE,MAAM,EAAE,UAAU,GAAG;CAErB,MAAM,SAAS,yBAAyB,UAAU,MAAM;CACxD,MAAM,UAAU,yBAAyB,UAAU,MAAM;AAEzD,KAAI,OAAO,WAAW,EAAG;CAEzB,MAAM,mBAAmB,WAAW,YAAY,SAAS;EAAE;EAAS;EAAQ,IAAI;AAEhF,QAAO;AACP"}
|
|
1
|
+
{"version":3,"file":"drop-zone-BPfSu99L.js","names":["useDropZoneStore: UseDropZoneResult[\"useDropZoneStore\"]","getContainerProps: UseDropZoneResult[\"propGetters\"][\"getContainerProps\"]","getInputProps: UseDropZoneResult[\"propGetters\"][\"getInputProps\"]","getTriggerProps: UseDropZoneResult[\"propGetters\"][\"getTriggerProps\"]","Component"],"sources":["../../src/components/ui/drop-zone/drop-zone-context.ts","../../src/components/ui/drop-zone/utils.ts","../../src/components/ui/drop-zone/drop-zone-store.ts","../../src/components/ui/drop-zone/use-drop-zone.ts","../../src/components/ui/drop-zone/drop-zone.tsx","../../src/components/ui/drop-zone/drop-zone-parts.ts"],"sourcesContent":["import { createCustomContext } from \"@zayne-labs/toolkit-react\";\nimport { createZustandContext } from \"@zayne-labs/toolkit-react/zustand\";\nimport type { DropZoneStore } from \"./drop-zone-store\";\nimport type { DropZonePropGetters } from \"./types\";\n\nconst [DropZoneStoreContextProvider, useDropZoneStoreContext] = createZustandContext<DropZoneStore>({\n\thookName: \"useDropZoneStoreContext\",\n\tname: \"DropZoneStoreContext\",\n\tproviderName: \"DropZoneRoot\",\n});\n\nconst [DropZonePropGettersContextProvider, usePropGettersContext] =\n\tcreateCustomContext<DropZonePropGetters>({\n\t\thookName: \"usePropGettersContext\",\n\t\tname: \"PropGettersContext\",\n\t\tproviderName: \"DropZoneRoot\",\n\t});\n\nexport {\n\tDropZoneStoreContextProvider,\n\tuseDropZoneStoreContext,\n\tDropZonePropGettersContextProvider,\n\tusePropGettersContext,\n};\n","import { createImagePreview, type FileMeta } from \"@zayne-labs/toolkit-core\";\nimport { isFile } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { FileState } from \"./types\";\n\nexport const generateUniqueId = (file: File | FileMeta): string => {\n\tif (!isFile(file)) {\n\t\treturn file.id;\n\t}\n\n\treturn `${file.name}-(${Math.round(performance.now())})-${crypto.randomUUID().slice(0, 8)}`;\n};\n\nexport const createObjectURL = (file: File, disallowPreviewForNonImageFiles: boolean | undefined) => {\n\tif (disallowPreviewForNonImageFiles && !file.type.startsWith(\"image/\")) return;\n\n\treturn createImagePreview(file);\n};\n\nexport const clearObjectURL = (\n\tfileState: FileState | undefined,\n\tdisallowPreviewForNonImageFiles: boolean | undefined\n) => {\n\tif (!isFile(fileState?.file)) return;\n\n\tif (disallowPreviewForNonImageFiles && !fileState.file.type.startsWith(\"image/\")) return;\n\n\tif (!fileState.preview) return;\n\n\tURL.revokeObjectURL(fileState.preview);\n};\n","import { createStore, handleFileValidationAsync, toArray } from \"@zayne-labs/toolkit-core\";\nimport { isString } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { DropZoneActions, DropZoneState } from \"./types\";\nimport type { UseDropZoneProps } from \"./use-drop-zone\";\nimport { clearObjectURL, createObjectURL, generateUniqueId } from \"./utils\";\n\nexport type DropZoneStore = DropZoneState & { actions: DropZoneActions };\n\nexport const createDropZoneStore = (\n\tinitStoreValues: Pick<\n\t\tUseDropZoneProps,\n\t\t| \"allowedFileTypes\"\n\t\t| \"disablePreviewForNonImageFiles\"\n\t\t| \"initialFiles\"\n\t\t| \"maxFileCount\"\n\t\t| \"maxFileSize\"\n\t\t| \"multiple\"\n\t\t| \"onFilesChange\"\n\t\t| \"onUpload\"\n\t\t| \"onUploadError\"\n\t\t| \"onUploadErrorCollection\"\n\t\t| \"onUploadSuccess\"\n\t\t| \"rejectDuplicateFiles\"\n\t\t| \"validator\"\n\t> & {\n\t\tinputRef: React.RefObject<HTMLInputElement | null>;\n\t}\n) => {\n\tconst {\n\t\tallowedFileTypes,\n\t\tdisablePreviewForNonImageFiles,\n\t\tinitialFiles,\n\t\tinputRef,\n\t\tmaxFileCount,\n\t\tmaxFileSize,\n\t\tmultiple,\n\t\tonFilesChange,\n\t\tonUpload,\n\t\tonUploadError,\n\t\tonUploadErrorCollection,\n\t\tonUploadSuccess,\n\t\trejectDuplicateFiles,\n\t\tvalidator,\n\t} = initStoreValues;\n\n\tconst initialFileArray = toArray(initialFiles).filter(Boolean);\n\n\tconst clearInputValue = () => {\n\t\tif (!inputRef.current) return;\n\n\t\tinputRef.current.value = \"\";\n\t};\n\n\tconst store = createStore<DropZoneStore>((set, get) => ({\n\t\terrors: [],\n\t\tfileStateArray: initialFileArray.map((fileMeta) => ({\n\t\t\tfile: fileMeta,\n\t\t\tid: fileMeta.id,\n\t\t\tpreview: fileMeta.url,\n\t\t})),\n\t\tisDraggingOver: false,\n\n\t\t// eslint-disable-next-line perfectionist/sort-objects -- Ignore\n\t\tactions: {\n\t\t\t// registerEventListeners: () => {\n\t\t\t// \tconst containerElement = {}\n\t\t\t// \tconst inputElement = {}\n\n\t\t\t// \tinputRef.current.addEventListener(\"change\", get().actions.handleChange);\n\t\t\t// \tinputRef.current.addEventListener(\"dragenter\", get().actions.handleDragEnter);\n\t\t\t// \tinputRef.current.addEventListener(\"dragleave\", get().actions.handleDragLeave);\n\t\t\t// \tinputRef.current.addEventListener(\"dragover\", get().actions.handleDragOver);\n\t\t\t// \tinputRef.current.addEventListener(\"drop\", get().actions.handleDrop);\n\t\t\t// },\n\t\t\taddFiles: async (files) => {\n\t\t\t\tif (!files || files.length === 0) {\n\t\t\t\t\tconsole.warn(\"No file selected!\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { fileStateArray } = get();\n\n\t\t\t\t// == In single file mode, only use the first file\n\t\t\t\tconst newFiles = !multiple ? [files[0]] : files;\n\n\t\t\t\tconst { errors, validFiles } = await handleFileValidationAsync({\n\t\t\t\t\texistingFiles: fileStateArray.map((fileWithPreview) => fileWithPreview.file),\n\t\t\t\t\thooks: {\n\t\t\t\t\t\tonError: onUploadError,\n\t\t\t\t\t\tonErrorCollection: onUploadErrorCollection,\n\t\t\t\t\t\tonSuccess: onUploadSuccess,\n\t\t\t\t\t},\n\t\t\t\t\tnewFiles,\n\t\t\t\t\tsettings: {\n\t\t\t\t\t\tallowedFileTypes,\n\t\t\t\t\t\tmaxFileCount,\n\t\t\t\t\t\tmaxFileSize,\n\t\t\t\t\t\trejectDuplicateFiles,\n\t\t\t\t\t\tvalidator,\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tif (validFiles.length === 0) {\n\t\t\t\t\tset({ errors, isDraggingOver: false });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst newFileStateArray = validFiles.map((file) => ({\n\t\t\t\t\tfile,\n\t\t\t\t\tid: generateUniqueId(file),\n\t\t\t\t\tpreview: createObjectURL(file, disablePreviewForNonImageFiles),\n\t\t\t\t}));\n\n\t\t\t\tset({\n\t\t\t\t\terrors,\n\t\t\t\t\tfileStateArray: multiple ? [...fileStateArray, ...newFileStateArray] : newFileStateArray,\n\t\t\t\t\tisDraggingOver: false,\n\t\t\t\t});\n\n\t\t\t\tawait onUpload?.({ fileStateArray: newFileStateArray });\n\t\t\t},\n\t\t\tclearErrors: () => {\n\t\t\t\tset({ errors: [] });\n\t\t\t},\n\t\t\tclearFiles: () => {\n\t\t\t\tconst { fileStateArray } = get();\n\n\t\t\t\tfor (const fileState of fileStateArray) {\n\t\t\t\t\tclearObjectURL(fileState, disablePreviewForNonImageFiles);\n\t\t\t\t}\n\n\t\t\t\tset({ fileStateArray: [] });\n\t\t\t},\n\t\t\thandleChange: async (event) => {\n\t\t\t\tconst fileList = event.target.files;\n\n\t\t\t\tconst { actions } = get();\n\n\t\t\t\tawait actions.addFiles(fileList);\n\n\t\t\t\tclearInputValue();\n\t\t\t},\n\t\t\thandleDragEnter: (event) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\n\t\t\t\tset({ isDraggingOver: true });\n\t\t\t},\n\t\t\thandleDragLeave: (event) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\n\t\t\t\tset({ isDraggingOver: false });\n\t\t\t},\n\t\t\thandleDragOver: (event) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\t\t\t},\n\t\t\thandleDrop: async (event) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\n\t\t\t\tif (inputRef.current?.disabled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst fileList = event.dataTransfer.files;\n\n\t\t\t\tconst { actions } = get();\n\n\t\t\t\tawait actions.addFiles(fileList);\n\t\t\t},\n\t\t\topenFilePicker: () => {\n\t\t\t\tinputRef.current?.click();\n\t\t\t},\n\t\t\tremoveFile: (fileToRemoveOrFileId) => {\n\t\t\t\tconst { fileStateArray } = get();\n\n\t\t\t\tconst actualFileToRemove =\n\t\t\t\t\tisString(fileToRemoveOrFileId) ?\n\t\t\t\t\t\tfileStateArray.find((file) => file.id === fileToRemoveOrFileId)\n\t\t\t\t\t:\tfileToRemoveOrFileId;\n\n\t\t\t\tif (!actualFileToRemove) return;\n\n\t\t\t\tclearObjectURL(actualFileToRemove, disablePreviewForNonImageFiles);\n\n\t\t\t\tconst updatedFileStateArray = fileStateArray.filter(\n\t\t\t\t\t(file) => file.id !== actualFileToRemove.id\n\t\t\t\t);\n\n\t\t\t\tset({ errors: [], fileStateArray: updatedFileStateArray });\n\t\t\t},\n\t\t},\n\t}));\n\n\tstore.subscribe.withSelector(\n\t\t(state) => state.fileStateArray,\n\t\t(fileStateArray) => {\n\t\t\tonFilesChange?.({ fileStateArray });\n\t\t}\n\t);\n\n\treturn store;\n};\n","import {\n\tdataAttr,\n\ttype FileMeta,\n\ttype FileValidationHooksAsync,\n\ttype FileValidationSettingsAsync,\n} from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef, useConstant, useShallowComparedValue, useStore } from \"@zayne-labs/toolkit-react\";\nimport type { InferProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { composeRefs, composeTwoEventHandlers, mergeTwoProps } from \"@zayne-labs/toolkit-react/utils\";\nimport type { Awaitable } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport type { useDropZoneStoreContext } from \"./drop-zone-context\";\nimport { createDropZoneStore } from \"./drop-zone-store\";\nimport type { DropZonePropGetters, DropZoneState } from \"./types\";\n\nexport type ExtraProps = {\n\tcontainer?: InferProps<HTMLElement>;\n\tinput?: InferProps<\"input\">;\n\ttrigger?: InferProps<\"button\">;\n};\n\nexport type ClassNames = {\n\t[key in keyof ExtraProps]: string;\n};\n\nexport type UseDropZoneResult = {\n\tinputRef: React.RefObject<HTMLInputElement | null>;\n\tpropGetters: DropZonePropGetters;\n\tstoreApi: ReturnType<typeof createDropZoneStore>;\n\tuseDropZoneStore: typeof useDropZoneStoreContext;\n};\n\nexport type UseDropZoneProps = FileValidationSettingsAsync & {\n\t/**\n\t * CSS classes to apply to the various parts of the drop zone\n\t */\n\tclassNames?: ClassNames;\n\n\t/**\n\t * Whether to disallow preview for non-image files\n\t * @default true\n\t */\n\tdisablePreviewForNonImageFiles?: boolean;\n\n\t/**\n\t * Extra props to pass to various parts of the dropzone\n\t */\n\textraProps?: ExtraProps;\n\n\t/**\n\t * Initial files to populate the drop zone\n\t */\n\tinitialFiles?: FileMeta | FileMeta[] | null;\n\n\t/**\n\t * Whether to allow multiple files to be uploaded\n\t */\n\tmultiple?: boolean;\n\n\t/**\n\t * Callback function to be called when internal files state changes\n\t */\n\tonFilesChange?: (context: Pick<DropZoneState, \"fileStateArray\">) => void;\n\n\t/**\n\t * Callback function to be called when new files are uploaded\n\t */\n\tonUpload?: (context: Pick<DropZoneState, \"fileStateArray\">) => Awaitable<void>;\n\n\t/**\n\t * Callback function to be called on each file upload as they occur\n\t */\n\tonUploadError?: FileValidationHooksAsync[\"onError\"];\n\n\t/**\n\t * Callback function to be called once after all file upload errors have occurred\n\t */\n\tonUploadErrorCollection?: FileValidationHooksAsync[\"onErrorCollection\"];\n\n\t/**\n\t * Callback function to be called on file upload success\n\t */\n\tonUploadSuccess?: FileValidationHooksAsync[\"onSuccess\"];\n\n\t/**\n\t * Whether clicking the drop zone area will open the default file picker or not\n\t *\n\t * @default true\n\t */\n\tshouldOpenFilePickerOnAreaClick?: boolean;\n\n\t/**\n\t * Custom validation function.\n\t *\n\t * If the function returns false, the file will be rejected\n\t *\n\t */\n\tvalidator?: FileValidationSettingsAsync[\"validator\"];\n};\n\nexport const useDropZone = (props?: UseDropZoneProps): UseDropZoneResult => {\n\tconst {\n\t\tallowedFileTypes,\n\t\tclassNames,\n\t\tdisablePreviewForNonImageFiles = true,\n\t\textraProps,\n\t\tinitialFiles,\n\t\tmaxFileCount,\n\t\tmaxFileSize,\n\t\tmultiple,\n\t\tonFilesChange,\n\t\tonUpload,\n\t\tonUploadError,\n\t\tonUploadErrorCollection,\n\t\tonUploadSuccess,\n\t\trejectDuplicateFiles = true,\n\t\tshouldOpenFilePickerOnAreaClick = true,\n\t\tvalidator,\n\t} = props ?? {};\n\n\tconst inputRef = useRef<HTMLInputElement>(null);\n\n\tconst savedOnFilesChange = useCallbackRef(onFilesChange);\n\tconst savedOnUpload = useCallbackRef(onUpload);\n\tconst savedOnUploadError = useCallbackRef(onUploadError);\n\tconst savedOnUploadErrorCollection = useCallbackRef(onUploadErrorCollection);\n\tconst savedOnUploadSuccess = useCallbackRef(onUploadSuccess);\n\tconst savedValidator = useCallbackRef(validator);\n\n\tconst constantInitialFiles = useConstant(() => initialFiles);\n\tconst shallowComparedMaxFileSize = useShallowComparedValue(maxFileSize);\n\tconst shallowComparedAllowedFileTypes = useShallowComparedValue(allowedFileTypes);\n\n\tconst storeApi = useMemo(() => {\n\t\treturn createDropZoneStore({\n\t\t\tallowedFileTypes: shallowComparedAllowedFileTypes,\n\t\t\tdisablePreviewForNonImageFiles,\n\t\t\tinitialFiles: constantInitialFiles,\n\t\t\tinputRef,\n\t\t\tmaxFileCount,\n\t\t\tmaxFileSize: shallowComparedMaxFileSize,\n\t\t\tmultiple,\n\t\t\tonFilesChange: savedOnFilesChange,\n\t\t\tonUpload: savedOnUpload,\n\t\t\tonUploadError: savedOnUploadError,\n\t\t\tonUploadErrorCollection: savedOnUploadErrorCollection,\n\t\t\tonUploadSuccess: savedOnUploadSuccess,\n\t\t\trejectDuplicateFiles,\n\t\t\tvalidator: savedValidator,\n\t\t});\n\t}, [\n\t\tshallowComparedAllowedFileTypes,\n\t\tdisablePreviewForNonImageFiles,\n\t\tconstantInitialFiles,\n\t\tmaxFileCount,\n\t\tshallowComparedMaxFileSize,\n\t\tmultiple,\n\t\tsavedOnFilesChange,\n\t\tsavedOnUpload,\n\t\tsavedOnUploadError,\n\t\tsavedOnUploadErrorCollection,\n\t\tsavedOnUploadSuccess,\n\t\trejectDuplicateFiles,\n\t\tsavedValidator,\n\t]);\n\n\tconst useDropZoneStore: UseDropZoneResult[\"useDropZoneStore\"] = (selector) => {\n\t\treturn useStore(storeApi, selector);\n\t};\n\n\tconst isDraggingOver = useDropZoneStore((store) => store.isDraggingOver);\n\tconst actions = useDropZoneStore((store) => store.actions);\n\n\tconst getContainerProps: UseDropZoneResult[\"propGetters\"][\"getContainerProps\"] = useCallback(\n\t\t(containerProps) => {\n\t\t\tconst mergedContainerProps = mergeTwoProps(extraProps?.container, containerProps);\n\n\t\t\treturn {\n\t\t\t\t...mergedContainerProps,\n\t\t\t\tclassName: cnMerge(\n\t\t\t\t\t\"relative isolate flex flex-col\",\n\t\t\t\t\tisDraggingOver && \"opacity-60\",\n\t\t\t\t\tclassNames?.container,\n\t\t\t\t\tmergedContainerProps.className\n\t\t\t\t),\n\t\t\t\t\"data-drag-over\": dataAttr(isDraggingOver),\n\t\t\t\t\"data-scope\": \"dropzone\",\n\t\t\t\t// eslint-disable-next-line perfectionist/sort-objects -- I need data-scope to be first\n\t\t\t\t\"data-part\": \"container\",\n\t\t\t\t\"data-slot\": \"dropzone-container\",\n\t\t\t\tonDragEnter: composeTwoEventHandlers(\n\t\t\t\t\tactions.handleDragEnter,\n\t\t\t\t\tmergedContainerProps.onDragEnter\n\t\t\t\t),\n\t\t\t\tonDragLeave: composeTwoEventHandlers(\n\t\t\t\t\tactions.handleDragLeave,\n\t\t\t\t\tmergedContainerProps.onDragLeave\n\t\t\t\t),\n\t\t\t\tonDragOver: composeTwoEventHandlers(actions.handleDragOver, mergedContainerProps.onDragOver),\n\t\t\t\tonDrop: composeTwoEventHandlers(actions.handleDrop, mergedContainerProps.onDrop),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tactions.handleDragEnter,\n\t\t\tactions.handleDragLeave,\n\t\t\tactions.handleDragOver,\n\t\t\tactions.handleDrop,\n\t\t\tclassNames?.container,\n\t\t\textraProps?.container,\n\t\t\tisDraggingOver,\n\t\t]\n\t);\n\n\tconst getInputProps: UseDropZoneResult[\"propGetters\"][\"getInputProps\"] = useCallback(\n\t\t(inputProps) => {\n\t\t\tconst mergedInputProps = mergeTwoProps(extraProps?.input, inputProps);\n\n\t\t\treturn {\n\t\t\t\t...mergedInputProps,\n\t\t\t\taccept: allowedFileTypes ? allowedFileTypes.join(\", \") : mergedInputProps.accept,\n\t\t\t\tclassName: cnMerge(\n\t\t\t\t\tshouldOpenFilePickerOnAreaClick ?\n\t\t\t\t\t\t\"absolute inset-0 z-[100] cursor-pointer opacity-0\"\n\t\t\t\t\t:\t\"hidden\",\n\t\t\t\t\tclassNames?.input,\n\t\t\t\t\tmergedInputProps.className\n\t\t\t\t),\n\t\t\t\t\"data-drag-over\": dataAttr(isDraggingOver),\n\t\t\t\t\"data-scope\": \"dropzone\",\n\t\t\t\t// eslint-disable-next-line perfectionist/sort-objects -- I need data-scope to be first\n\t\t\t\t\"data-part\": \"input\",\n\t\t\t\t\"data-slot\": \"dropzone-input\",\n\t\t\t\tmultiple: multiple ?? mergedInputProps.multiple,\n\t\t\t\tonChange: composeTwoEventHandlers(actions.handleChange, mergedInputProps.onChange),\n\t\t\t\tref: composeRefs(inputRef, mergedInputProps.ref),\n\t\t\t\ttype: \"file\",\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tactions.handleChange,\n\t\t\tallowedFileTypes,\n\t\t\tclassNames?.input,\n\t\t\textraProps?.input,\n\t\t\tisDraggingOver,\n\t\t\tmultiple,\n\t\t\tshouldOpenFilePickerOnAreaClick,\n\t\t]\n\t);\n\n\tconst getTriggerProps: UseDropZoneResult[\"propGetters\"][\"getTriggerProps\"] = useCallback(\n\t\t(triggerProps) => {\n\t\t\tconst mergedTriggerProps = mergeTwoProps(extraProps?.trigger, triggerProps);\n\n\t\t\treturn {\n\t\t\t\t...mergedTriggerProps,\n\t\t\t\tclassName: cnMerge(classNames?.trigger, mergedTriggerProps.className),\n\t\t\t\t\"data-scope\": \"dropzone\",\n\t\t\t\t// eslint-disable-next-line perfectionist/sort-objects -- I need data-scope to be first\n\t\t\t\t\"data-part\": \"trigger\",\n\t\t\t\t\"data-slot\": \"dropzone-trigger\",\n\t\t\t\tonClick: composeTwoEventHandlers(actions.openFilePicker, mergedTriggerProps.onClick),\n\t\t\t};\n\t\t},\n\t\t[actions.openFilePicker, classNames?.trigger, extraProps?.trigger]\n\t);\n\n\t// const getDeleteProps: UseDropZoneResult[\"propGetters\"][\"getTriggerProps\"] = useCallback(\n\t// \t(triggerProps) => {\n\t// \t\tconst mergedTriggerProps = mergeTwoProps(extraProps?.trigger, triggerProps);\n\n\t// \t\treturn {\n\t// \t\t\t...mergedTriggerProps,\n\t// \t\t\tclassName: cnMerge(classNames?.trigger, mergedTriggerProps.className),\n\t// \t\t\t\"data-scope\": \"dropzone\",\n\t// \t\t\t// eslint-disable-next-line perfectionist/sort-objects -- I need data-scope to be first\n\t// \t\t\t\"data-part\": \"trigger\",\n\t// \t\t\t\"data-slot\": \"dropzone-trigger\",\n\t// \t\t\tonClick: composeTwoEventHandlers(actions.openFilePicker, mergedTriggerProps.onClick),\n\t// \t\t};\n\t// \t},\n\t// \t[actions.openFilePicker, classNames?.trigger, extraProps?.trigger]\n\t// );\n\n\tconst propGetters = useMemo(\n\t\t() => ({ getContainerProps, getInputProps, getTriggerProps }),\n\t\t[getContainerProps, getInputProps, getTriggerProps]\n\t);\n\n\tconst savedUseDropZoneStore = useCallbackRef(useDropZoneStore);\n\n\tconst result = useMemo<UseDropZoneResult>(\n\t\t() =>\n\t\t\t({\n\t\t\t\tinputRef,\n\t\t\t\tpropGetters,\n\t\t\t\tstoreApi,\n\t\t\t\tuseDropZoneStore: savedUseDropZoneStore,\n\t\t\t}) satisfies UseDropZoneResult,\n\t\t[propGetters, storeApi, savedUseDropZoneStore]\n\t);\n\n\treturn result;\n};\n","\"use client\";\n\nimport type { PolymorphicProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { isFunction, type SelectorFn } from \"@zayne-labs/toolkit-type-helpers\";\nimport * as React from \"react\";\nimport { Slot } from \"@/components/common\";\nimport {\n\tDropZonePropGettersContextProvider,\n\tDropZoneStoreContextProvider,\n\tuseDropZoneStoreContext,\n\tusePropGettersContext,\n} from \"./drop-zone-context\";\nimport type { DropZoneStore } from \"./drop-zone-store\";\nimport { type ExtraProps, type UseDropZoneProps, useDropZone } from \"./use-drop-zone\";\n\nexport type DropZoneRootProps = UseDropZoneProps & { children: React.ReactNode };\n\nexport function DropZoneRoot(props: DropZoneRootProps) {\n\tconst { children, ...restOfProps } = props;\n\n\tconst dropZone = useDropZone(restOfProps);\n\n\treturn (\n\t\t<DropZoneStoreContextProvider store={dropZone.storeApi}>\n\t\t\t<DropZonePropGettersContextProvider value={dropZone.propGetters}>\n\t\t\t\t{children}\n\t\t\t</DropZonePropGettersContextProvider>\n\t\t</DropZoneStoreContextProvider>\n\t);\n}\n\nexport type DropZoneContextProps<TSlice> = {\n\tchildren: React.ReactNode | ((props: TSlice) => React.ReactNode);\n\tselector?: SelectorFn<DropZoneStore, TSlice>;\n};\n\nexport function DropZoneContext<TSlice = DropZoneStore>(props: DropZoneContextProps<TSlice>) {\n\tconst { children, selector } = props;\n\n\tconst dropZoneCtx = useDropZoneStoreContext(selector);\n\n\tconst resolvedChildren = isFunction(children) ? children(dropZoneCtx) : children;\n\n\treturn resolvedChildren;\n}\n\ntype DropZoneContainerProps = ExtraProps[\"container\"] & { asChild?: boolean };\n\nexport function DropZoneContainer<TElement extends React.ElementType = \"div\">(\n\tprops: PolymorphicProps<TElement, DropZoneContainerProps>\n) {\n\tconst { as: Element = \"div\", asChild, ...restOfProps } = props;\n\n\tconst propGetters = usePropGettersContext();\n\n\tconst Component = asChild ? Slot.Root : Element;\n\n\treturn <Component {...propGetters.getContainerProps(restOfProps)} />;\n}\n\ntype DropZoneInputProps = ExtraProps[\"input\"] & { asChild?: boolean };\n\nexport function DropZoneInput(props: DropZoneInputProps) {\n\tconst { asChild, ...restOfProps } = props;\n\n\tconst propGetters = usePropGettersContext();\n\n\tconst Component = asChild ? Slot.Root : \"input\";\n\n\treturn <Component {...propGetters.getInputProps(restOfProps)} />;\n}\n\ntype DropZoneAreaProps<TSlice> = {\n\tchildren: React.ReactNode | ((props: TSlice) => React.ReactNode);\n\textraProps?: Pick<ExtraProps, \"container\" | \"input\">;\n\tselector?: SelectorFn<DropZoneStore, TSlice>;\n};\n\nexport function DropZoneArea<TSlice = DropZoneStore>(props: DropZoneAreaProps<TSlice>) {\n\tconst { children, extraProps, selector } = props;\n\n\treturn (\n\t\t<DropZoneContainer {...extraProps?.container}>\n\t\t\t<DropZoneInput {...extraProps?.input} />\n\n\t\t\t<DropZoneContext selector={selector}>{children}</DropZoneContext>\n\t\t</DropZoneContainer>\n\t);\n}\n\ntype DropZoneTriggerProps = ExtraProps[\"trigger\"] & { asChild?: boolean };\n\nexport function DropZoneTrigger(props: DropZoneTriggerProps) {\n\tconst { asChild, ...restOfProps } = props;\n\n\tconst propGetters = usePropGettersContext();\n\n\tconst Component = asChild ? Slot.Root : \"button\";\n\n\treturn <Component {...propGetters.getTriggerProps(restOfProps)} />;\n}\n\ntype DropZoneFilePreviewProps = {\n\tchildren:\n\t\t| React.ReactNode\n\t\t| ((props: Pick<DropZoneStore, \"actions\" | \"fileStateArray\">) => React.ReactNode);\n};\n\nexport function DropZoneFilePreview(props: DropZoneFilePreviewProps) {\n\tconst { children } = props;\n\n\tconst fileStateArray = useDropZoneStoreContext((store) => store.fileStateArray);\n\tconst actions = useDropZoneStoreContext((store) => store.actions);\n\n\tif (fileStateArray.length === 0) return;\n\n\tconst resolvedChildren = isFunction(children) ? children({ actions, fileStateArray }) : children;\n\n\treturn resolvedChildren;\n}\n\ntype DropZoneErrorPreviewProps = {\n\tchildren: React.ReactNode | ((props: Pick<DropZoneStore, \"actions\" | \"errors\">) => React.ReactNode);\n};\n\nexport function DropZoneErrorPreview(props: DropZoneErrorPreviewProps) {\n\tconst { children } = props;\n\n\tconst errors = useDropZoneStoreContext((store) => store.errors);\n\tconst actions = useDropZoneStoreContext((store) => store.actions);\n\n\tif (errors.length === 0) return;\n\n\tconst resolvedChildren = isFunction(children) ? children({ actions, errors }) : children;\n\n\treturn resolvedChildren;\n}\n","export {\n\tDropZoneArea as Area,\n\tDropZoneContainer as Container,\n\tDropZoneContext as Context,\n\tDropZoneErrorPreview as ErrorPreview,\n\tDropZoneFilePreview as FilePreview,\n\tDropZoneInput as Input,\n\tDropZoneRoot as Root,\n\tDropZoneTrigger as Trigger,\n} from \"./drop-zone\";\n"],"mappings":";;;;;;;;;;;;AAKA,MAAM,CAAC,8BAA8B,wBAAwB,GAAG,qBAAoC;CACnG,UAAU;CACV,MAAM;CACN,cAAc;CACd;AAED,MAAM,CAAC,oCAAoC,sBAAsB,GAChE,oBAAyC;CACxC,UAAU;CACV,MAAM;CACN,cAAc;CACd;;;;ACZF,MAAa,oBAAoB,SAAkC;AAClE,KAAI,CAAC,OAAO,MACX,QAAO,KAAK;AAGb,QAAO,GAAG,KAAK,KAAK,IAAI,KAAK,MAAM,YAAY,OAAO,IAAI,OAAO,aAAa,MAAM,GAAG;AACvF;AAED,MAAa,mBAAmB,MAAY,oCAAyD;AACpG,KAAI,mCAAmC,CAAC,KAAK,KAAK,WAAW,UAAW;AAExE,QAAO,mBAAmB;AAC1B;AAED,MAAa,kBACZ,WACA,oCACI;AACJ,KAAI,CAAC,OAAO,WAAW,MAAO;AAE9B,KAAI,mCAAmC,CAAC,UAAU,KAAK,KAAK,WAAW,UAAW;AAElF,KAAI,CAAC,UAAU,QAAS;AAExB,KAAI,gBAAgB,UAAU;AAC9B;;;;ACrBD,MAAa,uBACZ,oBAkBI;CACJ,MAAM,EACL,kBACA,gCACA,cACA,UACA,cACA,aACA,UACA,eACA,UACA,eACA,yBACA,iBACA,sBACA,WACA,GAAG;CAEJ,MAAM,mBAAmB,QAAQ,cAAc,OAAO;CAEtD,MAAM,wBAAwB;AAC7B,MAAI,CAAC,SAAS,QAAS;AAEvB,WAAS,QAAQ,QAAQ;CACzB;CAED,MAAM,QAAQ,aAA4B,KAAK,SAAS;EACvD,QAAQ,EAAE;EACV,gBAAgB,iBAAiB,KAAK,cAAc;GACnD,MAAM;GACN,IAAI,SAAS;GACb,SAAS,SAAS;GAClB;EACD,gBAAgB;EAGhB,SAAS;GAWR,UAAU,OAAO,U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I,YAAY,UAE/B,oBAAC;GAA0B;GAAW;;;AAGxC;AAID,SAAgB,gBAAgB,OAA6B;CAC5D,MAAM,EAAE,QAAS,GAAG,aAAa,GAAG;CAEpC,MAAM,cAAc;CAEpB,MAAMA,cAAY,qBAAsB;AAExC,QAAO,oBAACA,eAAU,GAAI,YAAY,gBAAgB;AAClD;AAQD,SAAgB,oBAAoB,OAAiC;CACpE,MAAM,EAAE,UAAU,GAAG;CAErB,MAAM,iBAAiB,yBAAyB,UAAU,MAAM;CAChE,MAAM,UAAU,yBAAyB,UAAU,MAAM;AAEzD,KAAI,eAAe,WAAW,EAAG;CAEjC,MAAM,mBAAmB,WAAW,YAAY,SAAS;EAAE;EAAS;EAAgB,IAAI;AAExF,QAAO;AACP;AAMD,SAAgB,qBAAqB,OAAkC;CACtE,MAAM,EAAE,UAAU,GAAG;CAErB,MAAM,SAAS,yBAAyB,UAAU,MAAM;CACxD,MAAM,UAAU,yBAAyB,UAAU,MAAM;AAEzD,KAAI,OAAO,WAAW,EAAG;CAEzB,MAAM,mBAAmB,WAAW,YAAY,SAAS;EAAE;EAAS;EAAQ,IAAI;AAEhF,QAAO;AACP"}
|
|
@@ -200,17 +200,16 @@ function FormFieldContext(props) {
|
|
|
200
200
|
return render(fieldContextValues);
|
|
201
201
|
}
|
|
202
202
|
function FormLabel(props) {
|
|
203
|
-
const
|
|
204
|
-
const { children,
|
|
205
|
-
const { isDisabled, isInvalid } = useLaxFormFieldState({ name });
|
|
203
|
+
const fieldContextValues = useLaxFormFieldContext();
|
|
204
|
+
const { children, htmlFor = fieldContextValues?.formItemId,...restOfProps } = props;
|
|
205
|
+
const { isDisabled, isInvalid } = useLaxFormFieldState({ name: fieldContextValues?.name });
|
|
206
206
|
return /* @__PURE__ */ jsx("label", {
|
|
207
207
|
"data-scope": "form",
|
|
208
208
|
"data-part": "label",
|
|
209
209
|
"data-slot": "form-label",
|
|
210
210
|
"data-disabled": dataAttr(isDisabled),
|
|
211
211
|
"data-invalid": dataAttr(isInvalid),
|
|
212
|
-
htmlFor
|
|
213
|
-
className,
|
|
212
|
+
htmlFor,
|
|
214
213
|
...restOfProps,
|
|
215
214
|
children
|
|
216
215
|
});
|
|
@@ -433,9 +432,6 @@ const FormErrorMessagePrimitive = (props) => {
|
|
|
433
432
|
const errorMessageElements = getErrorElements();
|
|
434
433
|
const firstErrorElement = errorMessageElements[0];
|
|
435
434
|
if (!firstErrorElement) return;
|
|
436
|
-
const inputField = document.querySelector(`[name='${fieldName}']`);
|
|
437
|
-
const isFocusableInput = inputField?.matches(":is(input, select, textarea, [contenteditable='true'])");
|
|
438
|
-
if (isFocusableInput) return;
|
|
439
435
|
requestAnimationFrame(() => {
|
|
440
436
|
const rect = firstErrorElement.getBoundingClientRect();
|
|
441
437
|
const topWithOffset = rect.top - 100;
|
|
@@ -587,4 +583,4 @@ __export(form_parts_exports, {
|
|
|
587
583
|
|
|
588
584
|
//#endregion
|
|
589
585
|
export { FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormField, FormFieldContext, FormFieldControlledField, FormFieldController, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputRightItem, FormLabel, FormRoot, FormSelect, FormSelectPrimitive, FormSubmit, FormSubscribeToFieldValue, FormSubscribeToFormState, FormTextArea, FormTextAreaPrimitive, form_parts_exports, useFormRootContext, useStrictFormFieldContext };
|
|
590
|
-
//# sourceMappingURL=form-
|
|
586
|
+
//# sourceMappingURL=form-BnSpmc4f.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-BnSpmc4f.js","names":["errorMessage","useHookFormContext","HookFormProvider","ReactFragment","FormErrorMessagePrimitive: FormErrorMessagePrimitiveType","Component"],"sources":["../../src/components/ui/form/icons.tsx","../../src/components/ui/form/utils.ts","../../src/components/ui/form/form-context.ts","../../src/components/ui/form/form.tsx","../../src/components/ui/form/form-parts.ts"],"sourcesContent":["import * as React from \"react\";\n\nexport const EyeIconClosed = (props: React.SVGProps<SVGSVGElement>) => (\n\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1em\" height=\"1em\" viewBox=\"0 0 24 24\" {...props}>\n\t\t<path\n\t\t\tfill=\"currentColor\"\n\t\t\td=\"M15.175 8.325q.725.725 1.063 1.65t.237 1.9q0 .375-.275.638t-.65.262t-.638-.262t-.262-.638q.125-.65-.075-1.25T13.95 9.6t-1.025-.65t-1.275-.1q-.375 0-.638-.275t-.262-.65t.263-.637t.637-.263q.95-.1 1.875.238t1.65 1.062M12 6q-.475 0-.925.037t-.9.138q-.425.075-.763-.125t-.462-.6t.088-.775t.612-.45q.575-.125 1.163-.175T12 4q3.425 0 6.263 1.8t4.337 4.85q.1.2.15.413t.05.437t-.038.438t-.137.412q-.45 1-1.112 1.875t-1.463 1.6q-.3.275-.7.225t-.65-.4t-.212-.763t.337-.687q.6-.575 1.1-1.25t.875-1.45q-1.25-2.525-3.613-4.012T12 6m0 13q-3.35 0-6.125-1.812T1.5 12.425q-.125-.2-.187-.437T1.25 11.5t.05-.475t.175-.45q.5-1 1.163-1.912T4.15 7L2.075 4.9q-.275-.3-.262-.712T2.1 3.5t.7-.275t.7.275l17 17q.275.275.288.688t-.288.712q-.275.275-.7.275t-.7-.275l-3.5-3.45q-.875.275-1.775.413T12 19M5.55 8.4q-.725.65-1.325 1.425T3.2 11.5q1.25 2.525 3.613 4.013T12 17q.5 0 .975-.062t.975-.138l-.9-.95q-.275.075-.525.113T12 16q-1.875 0-3.188-1.312T7.5 11.5q0-.275.038-.525t.112-.525zm4.2 4.2\"\n\t\t/>\n\t</svg>\n);\n\nexport const EyeIconOpen = (props: React.SVGProps<SVGSVGElement>) => (\n\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1em\" height=\"1em\" viewBox=\"0 0 24 24\" {...props}>\n\t\t<path\n\t\t\tfill=\"currentColor\"\n\t\t\td=\"M12 16q1.875 0 3.188-1.312T16.5 11.5t-1.312-3.187T12 7T8.813 8.313T7.5 11.5t1.313 3.188T12 16m0-1.8q-1.125 0-1.912-.788T9.3 11.5t.788-1.912T12 8.8t1.913.788t.787 1.912t-.787 1.913T12 14.2m0 4.8q-3.35 0-6.113-1.8t-4.362-4.75q-.125-.225-.187-.462t-.063-.488t.063-.488t.187-.462q1.6-2.95 4.363-4.75T12 4t6.113 1.8t4.362 4.75q.125.225.188.463t.062.487t-.062.488t-.188.462q-1.6 2.95-4.362 4.75T12 19m0-2q2.825 0 5.188-1.487T20.8 11.5q-1.25-2.525-3.613-4.012T12 6T6.813 7.488T3.2 11.5q1.25 2.525 3.613 4.013T12 17\"\n\t\t/>\n\t</svg>\n);\n","import { cnMerge } from \"@/lib/utils/cn\";\nimport { isObject } from \"@zayne-labs/toolkit-type-helpers\";\nimport { createElement } from \"react\";\nimport type { FieldErrors, FieldValues } from \"react-hook-form\";\nimport type { FormErrorMessagePrimitiveProps, FormInputProps } from \"./form\";\nimport type { FormRootContext, RenderIconProps } from \"./form-context\";\nimport { EyeIconClosed, EyeIconOpen } from \"./icons\";\n\nexport const getFieldErrorMessage = (options: {\n\terrors: FieldErrors | undefined;\n\tfieldName: string | undefined;\n\ttype: FormErrorMessagePrimitiveProps<FieldValues>[\"type\"];\n}): string | string[] | null | undefined => {\n\tconst { errors, fieldName, type } = options;\n\n\tif (!fieldName || !errors || Object.keys(errors).length === 0) return;\n\n\tif (type === \"root\") {\n\t\treturn errors.root?.[fieldName]?.message;\n\t}\n\n\t// == Handle nested paths like `notifications.0`\n\tconst pathParts = fieldName.includes(\".\") ? fieldName.split(\".\") : null;\n\n\t// == If there are no path parts, return the error message\n\tif (!pathParts) {\n\t\tconst errorMessage = errors[fieldName]?.message;\n\n\t\treturn errorMessage as string | string[];\n\t}\n\n\tlet extractedError = errors;\n\n\tfor (const part of pathParts) {\n\t\tconst currentError = extractedError[part];\n\n\t\tif (!isObject(currentError)) break;\n\n\t\textractedError = currentError as never;\n\t}\n\n\tconst errorMessage = extractedError.message as unknown as string | string[];\n\n\treturn errorMessage;\n};\n\nexport const getEyeIcon = (options: {\n\tclassNames: FormInputProps[\"classNames\"];\n\ticonType: \"closed\" | \"open\";\n\trenderIconProps: RenderIconProps;\n\twithEyeIcon: FormRootContext[\"withEyeIcon\"];\n}) => {\n\tconst { classNames, iconType, renderIconProps, withEyeIcon } = options;\n\n\tif (!withEyeIcon) {\n\t\treturn null;\n\t}\n\n\tif (withEyeIcon === true) {\n\t\tconst defaultIconMap = {\n\t\t\tclosed: createElement(EyeIconClosed, {\n\t\t\t\tclassName: cnMerge(\"size-full\", classNames?.eyeIcon),\n\t\t\t}),\n\n\t\t\topen: createElement(EyeIconOpen, {\n\t\t\t\tclassName: cnMerge(\"size-full\", classNames?.eyeIcon),\n\t\t\t}),\n\t\t};\n\n\t\treturn defaultIconMap[iconType];\n\t}\n\n\tif (withEyeIcon.renderIcon) {\n\t\treturn withEyeIcon.renderIcon(renderIconProps);\n\t}\n\n\tif (withEyeIcon[iconType]) {\n\t\treturn withEyeIcon[iconType];\n\t}\n\n\treturn null;\n};\n","import { ContextError, createCustomContext } from \"@zayne-labs/toolkit-react\";\nimport type { DiscriminatedRenderProps } from \"@zayne-labs/toolkit-react/utils\";\nimport type { UnionDiscriminator } from \"@zayne-labs/toolkit-type-helpers\";\nimport {\n\ttype Control,\n\ttype UseFormReturn,\n\ttype UseFormStateReturn,\n\tuseFormState,\n\tuseFormContext as useHookFormContext,\n} from \"react-hook-form\";\nimport type { FieldValues, FormInputProps } from \"./form\";\nimport { getFieldErrorMessage } from \"./utils\";\n\ntype UseFormRootContextResult<TStrict extends boolean = true> = TStrict extends true\n\t? UseFormReturn<FieldValues> & { withEyeIcon?: FormInputProps[\"withEyeIcon\"] }\n\t: (UseFormReturn<FieldValues> & { withEyeIcon?: FormInputProps[\"withEyeIcon\"] }) | null;\n\nexport const useFormMethodsContext = <TStrict extends boolean = true>(\n\toptions: { strict?: TStrict } = {}\n): UseFormRootContextResult<TStrict> => {\n\tconst { strict = true } = options;\n\tconst formContext = useHookFormContext();\n\n\tif (strict && !(formContext as unknown)) {\n\t\tthrow new ContextError(\n\t\t\t`useFormRootContext returned \"null\". Did you forget to wrap the necessary components within FormRoot?`\n\t\t);\n\t}\n\n\treturn formContext;\n};\n\nexport type RenderIconProps = {\n\tisPasswordVisible: boolean;\n};\n\ntype EyeIconObject = UnionDiscriminator<\n\t[\n\t\t{ closed: React.ReactNode; open: React.ReactNode },\n\t\t{ renderIcon: (props: RenderIconProps) => React.ReactNode },\n\t]\n>;\n\nexport type FormRootContext = {\n\twithEyeIcon: boolean | EyeIconObject | undefined;\n};\n\nexport const [LaxFormRootProvider, useLaxFormRootContext] = createCustomContext<FormRootContext, false>({\n\thookName: \"useLaxFormRootContext\",\n\tname: \"LaxFormRootContext\",\n\tproviderName: \"FormRoot\",\n\tstrict: false,\n});\n\n// export const useStrictGetFieldState = () => {\n// \tconst { name } = useStrictFormFieldContext();\n\n// \tconst { getFieldState } = useFormRootContext();\n\n// \tconst fieldState = getFieldState(name);\n\n// \treturn fieldState;\n// };\n\nexport type FieldContextValue = {\n\tformDescriptionId: `${string}-(${string})-form-item-description`;\n\tformItemId: `${string}-(${string})-form-item`;\n\tformMessageId: `${string}-(${string})-form-item-message`;\n\tname: string;\n};\n\nexport type FormFieldContextProps = DiscriminatedRenderProps<\n\t(contextValue: FieldContextValue) => React.ReactNode\n>;\n\nexport const [StrictFormFieldProvider, useStrictFormFieldContext] = createCustomContext<FieldContextValue>(\n\t{\n\t\thookName: \"useFormFieldContext\",\n\t\tname: \"StrictFormFieldContext\",\n\t\tproviderName: \"FormField\",\n\t}\n);\n\nexport const [LaxFormFieldProvider, useLaxFormFieldContext] = createCustomContext<\n\tFieldContextValue,\n\tfalse\n>({\n\thookName: \"useLaxFormFieldContext\",\n\tname: \"LaxFormFieldContext\",\n\tproviderName: \"FormField\",\n\tstrict: false,\n});\n\nexport type FieldState = {\n\terrors?: UseFormStateReturn<FieldValues>[\"errors\"];\n\tisDisabled?: boolean;\n\tisInvalid?: boolean;\n};\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- any is used here for type compatibility\nexport type AnyControl = Control<any>;\n\ntype FieldStateOptions =\n\t| {\n\t\t\tcontrol: AnyControl | undefined;\n\t\t\tname?: string;\n\t }\n\t| {\n\t\t\tcontrol?: AnyControl;\n\t\t\tname: string | undefined;\n\t };\n\nexport const useLaxFormFieldState = (options?: FieldStateOptions): FieldState => {\n\tconst { control = options?.control } = useFormMethodsContext({ strict: false }) ?? {};\n\tconst { name = options?.name } = useLaxFormFieldContext() ?? {};\n\n\tconst getFormState = control ? useFormState : () => ({}) as Partial<ReturnType<typeof useFormState>>;\n\n\tconst { disabled, errors } = getFormState({ control, name });\n\n\tconst errorMessage = getFieldErrorMessage({ errors, fieldName: name, type: \"regular\" });\n\n\treturn {\n\t\terrors,\n\t\tisDisabled: disabled,\n\t\tisInvalid: Boolean(errorMessage),\n\t};\n};\n","\"use client\";\n\n// biome-ignore assist/source/organizeImports: needs to be on top\nimport * as React from \"react\";\n\nimport { dataAttr, on, toArray } from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef, useToggle } from \"@zayne-labs/toolkit-react\";\nimport {\n\tcomposeRefs,\n\tcomposeTwoEventHandlers,\n\ttype DiscriminatedRenderItemProps,\n\ttype DiscriminatedRenderProps,\n\ttype InferProps,\n\ttype PolymorphicProps,\n} from \"@zayne-labs/toolkit-react/utils\";\nimport { type AnyString, defineEnum } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Fragment as ReactFragment, useEffect, useId, useMemo, useRef } from \"react\";\nimport {\n\ttype Control,\n\tController,\n\ttype ControllerFieldState,\n\ttype ControllerProps,\n\ttype ControllerRenderProps,\n\ttype FieldPath,\n\ttype FieldPathValue,\n\ttype FieldPathValues,\n\tFormProvider as HookFormProvider,\n\ttype RegisterOptions,\n\ttype UseFormReturn,\n\ttype UseFormStateReturn,\n\tuseFormState,\n\tuseWatch,\n} from \"react-hook-form\";\nimport { getElementList } from \"@/components/common/for\";\nimport { Slot } from \"@/components/common/slot\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport { getMultipleSlots } from \"@/lib/utils/getSlot\";\nimport {\n\ttype FieldContextValue,\n\ttype FieldState,\n\ttype FormFieldContextProps,\n\ttype FormRootContext,\n\tLaxFormFieldProvider,\n\tLaxFormRootProvider,\n\tStrictFormFieldProvider,\n\tuseFormMethodsContext,\n\tuseLaxFormFieldContext,\n\tuseLaxFormFieldState,\n\tuseLaxFormRootContext,\n\tuseStrictFormFieldContext,\n} from \"./form-context\";\nimport { getEyeIcon, getFieldErrorMessage } from \"./utils\";\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Necessary so that arrays can also be accepted\nexport type FieldValues = Record<string, any>;\n\ntype FormRootProps<TFieldValues extends FieldValues> = Partial<FormRootContext>\n\t& React.ComponentPropsWithoutRef<\"form\"> & {\n\t\tchildren: React.ReactNode;\n\t\tmethods: UseFormReturn<TFieldValues>;\n\t};\n\nexport function FormRoot<TValues extends FieldValues>(props: FormRootProps<TValues>) {\n\tconst { children, className, methods, withEyeIcon, ...restOfProps } = props;\n\n\tconst formContextValue = useMemo(() => ({ withEyeIcon }), [withEyeIcon]);\n\n\treturn (\n\t\t<HookFormProvider {...methods}>\n\t\t\t<LaxFormRootProvider value={formContextValue}>\n\t\t\t\t<form\n\t\t\t\t\tclassName={cnMerge(\"flex flex-col\", className)}\n\t\t\t\t\t{...restOfProps}\n\t\t\t\t\tdata-scope=\"form\"\n\t\t\t\t\tdata-part=\"root\"\n\t\t\t\t\tdata-slot=\"form-root\"\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</form>\n\t\t\t</LaxFormRootProvider>\n\t\t</HookFormProvider>\n\t);\n}\n\ntype FormFieldProps<TControl, TFieldValues extends FieldValues> = (TControl extends (\n\tControl<infer TValues>\n) ?\n\t{\n\t\tcontrol?: never;\n\t\tname: FieldPath<TValues>;\n\t}\n:\t{\n\t\tcontrol?: Control<TFieldValues>;\n\t\tname: FieldPath<TFieldValues>;\n\t})\n\t& (\n\t\t| (InferProps<\"div\"> & {\n\t\t\t\twithWrapper?: true;\n\t\t })\n\t\t| { children: React.ReactNode; className?: never; withWrapper: false }\n\t);\n\nexport function FormField<TControl, TFieldValues extends FieldValues = FieldValues>(\n\tprops: FormFieldProps<TControl, TFieldValues>\n) {\n\tconst { children, className, name, withWrapper = true } = props;\n\n\tconst { isDisabled, isInvalid } = useLaxFormFieldState({ name });\n\n\tconst uniqueId = useId();\n\n\tconst fieldContextValue = useMemo(\n\t\t() =>\n\t\t\t({\n\t\t\t\tformDescriptionId: `${name}-(${uniqueId})-form-item-description`,\n\t\t\t\tformItemId: `${name}-(${uniqueId})-form-item`,\n\t\t\t\tformMessageId: `${name}-(${uniqueId})-form-item-message`,\n\t\t\t\tname,\n\t\t\t}) satisfies FieldContextValue,\n\t\t[name, uniqueId]\n\t);\n\n\tconst WrapperElement = withWrapper ? \"div\" : ReactFragment;\n\n\tconst wrapperElementProps = withWrapper && {\n\t\tclassName: cnMerge(\"flex flex-col gap-2\", className),\n\t\t\"data-part\": \"field\",\n\t\t\"data-scope\": \"form\",\n\t\t\"data-slot\": \"form-field\",\n\t\t/* eslint-disable perfectionist/sort-objects -- order of attributes does not matter */\n\t\t\"data-disabled\": dataAttr(isDisabled),\n\t\t\"data-invalid\": dataAttr(isInvalid),\n\t\t/* eslint-enable perfectionist/sort-objects -- order of attributes does not matter */\n\t};\n\treturn (\n\t\t<StrictFormFieldProvider value={fieldContextValue}>\n\t\t\t<LaxFormFieldProvider value={fieldContextValue}>\n\t\t\t\t<WrapperElement {...wrapperElementProps}>{children}</WrapperElement>\n\t\t\t</LaxFormFieldProvider>\n\t\t</StrictFormFieldProvider>\n\t);\n}\n\ntype FormFieldControllerRenderFn = (props: {\n\tfield: Omit<ControllerRenderProps, \"value\"> & {\n\t\tvalue: never;\n\t};\n\tfieldState: ControllerFieldState;\n\tformState: UseFormStateReturn<never>;\n}) => React.ReactElement;\n\ntype FormFieldControllerProps = Omit<\n\tControllerProps<FieldValues, FieldPath<FieldValues>>,\n\t\"control\" | \"name\" | \"render\"\n> & {\n\trender: FormFieldControllerRenderFn;\n};\n\nexport function FormFieldController(props: FormFieldControllerProps) {\n\tconst { control } = useFormMethodsContext();\n\tconst { name } = useStrictFormFieldContext();\n\tconst { render, ...restOfProps } = props;\n\n\treturn <Controller name={name} control={control} render={render as never} {...restOfProps} />;\n}\n\nexport function FormFieldControlledField<TFieldValues extends FieldValues>(\n\tprops: ControllerProps<TFieldValues>\n) {\n\tconst { name } = props;\n\n\tconst uniqueId = useId();\n\n\tconst fieldContextValue = useMemo(\n\t\t() =>\n\t\t\t({\n\t\t\t\tformDescriptionId: `${name}-(${uniqueId})-form-item-description`,\n\t\t\t\tformItemId: `${name}-(${uniqueId})-form-item`,\n\t\t\t\tformMessageId: `${name}-(${uniqueId})-form-item-message`,\n\t\t\t\tname,\n\t\t\t}) satisfies FieldContextValue,\n\t\t[name, uniqueId]\n\t);\n\n\treturn (\n\t\t<StrictFormFieldProvider value={fieldContextValue}>\n\t\t\t<LaxFormFieldProvider value={fieldContextValue}>\n\t\t\t\t<Controller {...props} />\n\t\t\t</LaxFormFieldProvider>\n\t\t</StrictFormFieldProvider>\n\t);\n}\n\nexport function FormFieldContext(props: FormFieldContextProps) {\n\tconst { children, render } = props;\n\tconst fieldContextValues = useStrictFormFieldContext();\n\n\tif (typeof children === \"function\") {\n\t\treturn children(fieldContextValues);\n\t}\n\n\treturn render(fieldContextValues);\n}\n\nexport function FormLabel(props: InferProps<\"label\">) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst { children, htmlFor = fieldContextValues?.formItemId, ...restOfProps } = props;\n\n\tconst { isDisabled, isInvalid } = useLaxFormFieldState({ name: fieldContextValues?.name });\n\n\treturn (\n\t\t<label\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"label\"\n\t\t\tdata-slot=\"form-label\"\n\t\t\tdata-disabled={dataAttr(isDisabled)}\n\t\t\tdata-invalid={dataAttr(isInvalid)}\n\t\t\thtmlFor={htmlFor}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{children}\n\t\t</label>\n\t);\n}\n\nexport function FormInputGroup(props: InferProps<\"div\">) {\n\tconst { children, className, ...restOfProps } = props;\n\n\tconst { isDisabled, isInvalid } = useLaxFormFieldState();\n\n\tconst {\n\t\tregularChildren,\n\t\tslots: [leftItemSlot, rightItemSlot],\n\t} = getMultipleSlots(children, [FormInputLeftItem, FormInputRightItem]);\n\n\treturn (\n\t\t<div\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"input-group\"\n\t\t\tdata-slot=\"form-input-group\"\n\t\t\tdata-invalid={dataAttr(isInvalid)}\n\t\t\tdata-disabled={dataAttr(isDisabled)}\n\t\t\tclassName={cnMerge(\"flex items-center justify-between gap-2\", className)}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{leftItemSlot}\n\t\t\t{regularChildren}\n\t\t\t{rightItemSlot}\n\t\t</div>\n\t);\n}\n\ntype FormSideItemProps = {\n\tchildren?: React.ReactNode;\n\tclassName?: string;\n};\n\nexport function FormInputLeftItem<TElement extends React.ElementType = \"span\">(\n\tprops: PolymorphicProps<TElement, FormSideItemProps>\n) {\n\tconst { as: Element = \"span\", children, className, ...restOfProps } = props;\n\n\treturn (\n\t\t<Element\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"left-item\"\n\t\t\tdata-slot=\"form-left-item\"\n\t\t\tclassName={cnMerge(\"inline-flex items-center justify-center\", className)}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{children}\n\t\t</Element>\n\t);\n}\nFormInputLeftItem.slotSymbol = Symbol(\"input-left-item\");\n\nexport function FormInputRightItem<TElement extends React.ElementType = \"span\">(\n\tprops: PolymorphicProps<TElement, FormSideItemProps>\n) {\n\tconst { as: Element = \"span\", children, className, ...restOfProps } = props;\n\n\treturn (\n\t\t<Element\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"right-item\"\n\t\t\tdata-slot=\"form-right-item\"\n\t\t\tclassName={cnMerge(\"inline-flex items-center justify-center\", className)}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{children}\n\t\t</Element>\n\t);\n}\nFormInputRightItem.slotSymbol = Symbol(\"input-right-item\");\n\ntype FormInputPrimitiveProps<TFieldValues extends FieldValues = FieldValues> = Omit<\n\tReact.ComponentPropsWithRef<\"input\">,\n\t\"children\"\n> & {\n\tclassNames?: { error?: string; eyeIcon?: string; input?: string; inputGroup?: string };\n\tcontrol?: Control<TFieldValues>;\n\tfieldState?: FieldState;\n\tname?: FieldPath<TFieldValues>;\n\twithEyeIcon?: FormRootContext[\"withEyeIcon\"];\n};\n\ntype FormTextAreaPrimitiveProps<TFieldValues extends FieldValues = FieldValues> =\n\tReact.ComponentPropsWithRef<\"textarea\"> & {\n\t\tclassNames?: { base?: string; error?: string };\n\t\tcontrol?: Control<TFieldValues>;\n\t\tfieldState?: FieldState;\n\t\tname?: FieldPath<TFieldValues>;\n\t};\n\ntype FormSelectPrimitiveProps<TFieldValues extends FieldValues = FieldValues> =\n\tReact.ComponentPropsWithRef<\"select\"> & {\n\t\tclassNames?: { base?: string; error?: string };\n\t\tcontrol?: Control<TFieldValues>;\n\t\tfieldState?: FieldState;\n\t\tname?: FieldPath<TFieldValues>;\n\t};\n\nconst inputTypesWithoutFullWith = new Set<React.HTMLInputTypeAttribute>([\"checkbox\", \"radio\"]);\n\nexport function FormInputPrimitive<TFieldValues extends FieldValues>(\n\tprops: FormInputPrimitiveProps<TFieldValues> & { rules?: RegisterOptions }\n) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst formRootContextValues = useLaxFormRootContext();\n\n\tconst {\n\t\tclassName,\n\t\tclassNames,\n\t\tcontrol,\n\t\tfieldState,\n\t\tid = fieldContextValues?.formItemId,\n\t\tname = fieldContextValues?.name,\n\t\trules,\n\t\ttype = \"text\",\n\t\twithEyeIcon = formRootContextValues?.withEyeIcon ?? true,\n\t\t...restOfProps\n\t} = props;\n\n\tconst fieldStateFromLaxFormField = useLaxFormFieldState({ control, name });\n\n\tconst { isDisabled, isInvalid } = fieldState ?? fieldStateFromLaxFormField;\n\n\tconst [isPasswordVisible, toggleVisibility] = useToggle(false);\n\n\tconst shouldHaveEyeIcon = withEyeIcon && type === \"password\";\n\n\tconst WrapperElement = shouldHaveEyeIcon ? FormInputGroup : ReactFragment;\n\n\tconst wrapperElementProps = shouldHaveEyeIcon && {\n\t\tclassName: cnMerge(\"w-full\", classNames?.inputGroup, isInvalid && classNames?.error),\n\t};\n\n\tconst { register } = useFormMethodsContext({ strict: false }) ?? {};\n\n\tconst eyeIcon = getEyeIcon({\n\t\tclassNames,\n\t\ticonType: isPasswordVisible ? \"closed\" : \"open\",\n\t\trenderIconProps: { isPasswordVisible },\n\t\twithEyeIcon,\n\t});\n\n\treturn (\n\t\t<WrapperElement {...wrapperElementProps}>\n\t\t\t<input\n\t\t\t\tdata-scope=\"form\"\n\t\t\t\tdata-part=\"input\"\n\t\t\t\tdata-slot=\"form-input\"\n\t\t\t\taria-describedby={\n\t\t\t\t\t!isInvalid ?\n\t\t\t\t\t\tfieldContextValues?.formDescriptionId\n\t\t\t\t\t:\t`${fieldContextValues?.formDescriptionId} ${fieldContextValues?.formMessageId}`\n\t\t\t\t}\n\t\t\t\taria-invalid={dataAttr(isInvalid)}\n\t\t\t\tdata-invalid={dataAttr(isInvalid)}\n\t\t\t\tdata-disabled={dataAttr(isDisabled)}\n\t\t\t\tid={id}\n\t\t\t\tname={name}\n\t\t\t\ttype={type === \"password\" && isPasswordVisible ? \"text\" : type}\n\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t!inputTypesWithoutFullWith.has(type) && \"flex w-full\",\n\t\t\t\t\t`focus-visible:outline-hidden placeholder:text-shadcn-muted-foreground bg-transparent\n\t\t\t\t\ttext-sm file:border-0 file:bg-transparent disabled:cursor-not-allowed disabled:opacity-50`,\n\t\t\t\t\tclassName,\n\t\t\t\t\tclassNames?.input,\n\t\t\t\t\ttype !== \"password\" && isInvalid && classNames?.error\n\t\t\t\t)}\n\t\t\t\t{...(Boolean(name) && register?.(name, rules))}\n\t\t\t\t{...restOfProps}\n\t\t\t/>\n\n\t\t\t{shouldHaveEyeIcon && (\n\t\t\t\t<FormInputRightItem\n\t\t\t\t\tas=\"button\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonClick={toggleVisibility}\n\t\t\t\t\tclassName=\"size-5 shrink-0 lg:size-6\"\n\t\t\t\t>\n\t\t\t\t\t{eyeIcon}\n\t\t\t\t</FormInputRightItem>\n\t\t\t)}\n\t\t</WrapperElement>\n\t);\n}\n\nexport function FormTextAreaPrimitive<TFieldValues extends FieldValues>(\n\tprops: FormTextAreaPrimitiveProps<TFieldValues> & { rules?: RegisterOptions }\n) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst {\n\t\tclassName,\n\t\tclassNames,\n\t\tcontrol,\n\t\tfieldState,\n\t\tid = fieldContextValues?.formItemId,\n\t\tname = fieldContextValues?.name,\n\t\trules,\n\t\t...restOfProps\n\t} = props;\n\n\tconst fieldStateFromLaxFormField = useLaxFormFieldState({ control, name });\n\n\tconst { isDisabled, isInvalid } = fieldState ?? fieldStateFromLaxFormField;\n\n\tconst { register } = useFormMethodsContext({ strict: false }) ?? {};\n\n\treturn (\n\t\t<textarea\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"textarea\"\n\t\t\tdata-slot=\"form-textarea\"\n\t\t\taria-describedby={\n\t\t\t\t!isInvalid ?\n\t\t\t\t\tfieldContextValues?.formDescriptionId\n\t\t\t\t:\t`${fieldContextValues?.formDescriptionId} ${fieldContextValues?.formMessageId}`\n\t\t\t}\n\t\t\taria-invalid={dataAttr(isInvalid)}\n\t\t\tdata-disabled={dataAttr(isDisabled)}\n\t\t\tdata-invalid={dataAttr(isInvalid)}\n\t\t\tid={id}\n\t\t\tname={name}\n\t\t\tclassName={cnMerge(\n\t\t\t\t`placeholder:text-shadcn-muted-foreground focus-visible:outline-hidden w-full bg-transparent\n\t\t\t\ttext-sm disabled:cursor-not-allowed disabled:opacity-50`,\n\t\t\t\tclassName,\n\t\t\t\tclassNames?.base,\n\t\t\t\tisInvalid && classNames?.error\n\t\t\t)}\n\t\t\t{...(Boolean(name) && register?.(name, rules))}\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\nexport function FormSelectPrimitive<TFieldValues extends FieldValues>(\n\tprops: FormSelectPrimitiveProps<TFieldValues> & { rules?: RegisterOptions }\n) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst {\n\t\tclassName,\n\t\tclassNames,\n\t\tcontrol,\n\t\tfieldState,\n\t\tid = fieldContextValues?.formItemId,\n\t\tname = fieldContextValues?.name,\n\t\trules,\n\t\t...restOfProps\n\t} = props;\n\n\tconst fieldStateFromLaxFormField = useLaxFormFieldState({ control, name });\n\n\tconst { isDisabled, isInvalid } = fieldState ?? fieldStateFromLaxFormField;\n\n\tconst { register } = useFormMethodsContext({ strict: false }) ?? {};\n\n\treturn (\n\t\t<select\n\t\t\tdefaultValue=\"\"\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"select\"\n\t\t\tdata-slot=\"form-select\"\n\t\t\taria-describedby={\n\t\t\t\t!isInvalid ?\n\t\t\t\t\tfieldContextValues?.formDescriptionId\n\t\t\t\t:\t`${fieldContextValues?.formDescriptionId} ${fieldContextValues?.formMessageId}`\n\t\t\t}\n\t\t\taria-invalid={dataAttr(isInvalid)}\n\t\t\tdata-disabled={dataAttr(isDisabled)}\n\t\t\tdata-invalid={dataAttr(isInvalid)}\n\t\t\tid={id}\n\t\t\tname={name}\n\t\t\tclassName={cnMerge(\n\t\t\t\t`placeholder:text-shadcn-muted-foreground focus-visible:outline-hidden w-full bg-transparent\n\t\t\t\ttext-sm disabled:cursor-not-allowed disabled:opacity-50`,\n\t\t\t\tclassName,\n\t\t\t\tclassNames?.base,\n\t\t\t\tisInvalid && classNames?.error\n\t\t\t)}\n\t\t\t{...(Boolean(name) && register?.(name, rules))}\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\n\ntype PrimitivePropsToOmit = \"control\" | \"formState\" | \"name\";\n\nexport type FormInputProps = Omit<FormInputPrimitiveProps, PrimitivePropsToOmit> & {\n\trules?: RegisterOptions;\n};\n\nexport type FormTextAreaProps = Omit<FormTextAreaPrimitiveProps, PrimitivePropsToOmit> & {\n\trules?: RegisterOptions;\n};\n\nexport type FormSelectProps = Omit<FormSelectPrimitiveProps, PrimitivePropsToOmit> & {\n\trules?: RegisterOptions;\n};\n\ntype CombinedFormInputProps =\n\t| (FormSelectProps & { type: \"select\" })\n\t| (FormTextAreaProps & { type: \"textarea\" })\n\t| FormInputProps;\n\nconst InputTypeMap = defineEnum({\n\tselect: FormSelectPrimitive,\n\ttextarea: FormTextAreaPrimitive,\n});\n\nexport function FormInput(props: CombinedFormInputProps & { rules?: RegisterOptions }) {\n\tconst { onBlur, onChange, ref, rules, type, ...restOfProps } = props;\n\n\tconst { name } = useStrictFormFieldContext();\n\tconst { register } = useFormMethodsContext();\n\n\tconst SelectedInput =\n\t\ttype === \"textarea\" || type === \"select\" ?\n\t\t\tInputTypeMap[type as Exclude<typeof type, AnyString>]\n\t\t:\tFormInputPrimitive;\n\n\tconst registerProps = name ? register(name, rules) : null;\n\n\treturn (\n\t\t<SelectedInput\n\t\t\ttype={type as never}\n\t\t\tname={name}\n\t\t\t{...registerProps}\n\t\t\t{...(restOfProps as NonNullable<unknown>)}\n\t\t\tref={composeRefs(registerProps?.ref, ref)}\n\t\t\tonChange={composeTwoEventHandlers(registerProps?.onChange, onChange)}\n\t\t\tonBlur={composeTwoEventHandlers(registerProps?.onBlur, onBlur)}\n\t\t/>\n\t);\n}\n\nexport function FormTextArea(props: FormTextAreaProps) {\n\treturn <FormInput {...props} type=\"textarea\" />;\n}\n\nexport function FormSelect(props: FormSelectProps) {\n\treturn <FormInput {...props} type=\"select\" />;\n}\n\nexport function FormDescription(props: InferProps<\"p\">) {\n\tconst { className, ...restOfProps } = props;\n\n\tconst { formDescriptionId } = useLaxFormFieldContext() ?? {};\n\n\treturn <p id={formDescriptionId} className={cnMerge(\"text-[12px]\", className)} {...restOfProps} />;\n}\n\ntype ErrorMessageRenderProps = {\n\tclassName: string;\n\t\"data-index\": number;\n\t\"data-part\": \"error-message\";\n\t\"data-scope\": \"form\";\n\t\"data-slot\": \"form-error-message\";\n\tid: string | undefined;\n\tref: React.RefCallback<HTMLElement>;\n};\n\ntype ErrorMessageRenderState = { errorMessage: string; errorMessageArray: string[]; index: number };\n\ntype ErrorMessageRenderFn = (context: {\n\tprops: ErrorMessageRenderProps;\n\tstate: ErrorMessageRenderState;\n}) => React.ReactNode;\n\nexport type FormErrorMessagePrimitiveProps<TFieldValues extends FieldValues> =\n\tDiscriminatedRenderItemProps<ErrorMessageRenderFn> & {\n\t\tclassName?: string;\n\t\tclassNames?: {\n\t\t\tcontainer?: string;\n\t\t\terrorMessage?: string;\n\t\t\terrorMessageAnimation?: string;\n\t\t};\n\t\tcontrol?: Control<TFieldValues>; // == Here for type inference of errorField prop\n\t\tdisableErrorAnimation?: boolean;\n\t\tdisableScrollToErrorField?: boolean;\n\t} & (\n\t\t\t| {\n\t\t\t\t\tfieldName: FieldPath<TFieldValues>;\n\t\t\t\t\ttype?: \"regular\";\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tfieldName: string;\n\t\t\t\t\ttype: \"root\";\n\t\t\t }\n\t\t);\n\ntype FormErrorMessagePrimitiveType = {\n\t<TFieldValues extends FieldValues>(\n\t\tprops: Extract<FormErrorMessagePrimitiveProps<TFieldValues>, { type?: \"regular\" }>\n\t): React.ReactNode;\n\t<TFieldValues extends FieldValues>(\n\t\t// eslint-disable-next-line ts-eslint/unified-signatures -- Using overloads are better because it gives better error messages\n\t\tprops: Extract<FormErrorMessagePrimitiveProps<TFieldValues>, { type: \"root\" }>\n\t): React.ReactNode;\n};\n\nexport const FormErrorMessagePrimitive: FormErrorMessagePrimitiveType = (props) => {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\tconst rootContextValues = useFormMethodsContext({ strict: false });\n\n\tconst {\n\t\tchildren,\n\t\tclassName,\n\t\tclassNames,\n\t\tcontrol = rootContextValues?.control,\n\t\tdisableErrorAnimation = false,\n\t\tdisableScrollToErrorField = false,\n\t\tfieldName = fieldContextValues?.name,\n\t\trenderItem,\n\t\ttype = \"regular\",\n\t} = props;\n\n\tconst { errors } = useLaxFormFieldState({ control, name: fieldName });\n\n\tconst { formMessageId } = useLaxFormFieldContext() ?? {};\n\n\tconst errorParagraphRef = useRef<HTMLElement>(null);\n\n\tconst wrapperRef = useRef<HTMLDivElement>(null);\n\n\tconst errorAnimationClass = classNames?.errorMessageAnimation ?? \"animate-shake\";\n\n\tconst getErrorElements = useCallbackRef(\n\t\t() => wrapperRef.current?.children ?? [errorParagraphRef.current]\n\t);\n\n\tuseEffect(() => {\n\t\tif (disableErrorAnimation) return;\n\n\t\tif (!errors || Object.keys(errors).length === 0) return;\n\n\t\tconst errorMessageElements = getErrorElements();\n\n\t\tif (errorMessageElements.length === 0) return;\n\n\t\tfor (const element of errorMessageElements) {\n\t\t\tif (!element) continue;\n\n\t\t\telement.classList.add(errorAnimationClass);\n\n\t\t\tconst onAnimationEnd = () => element.classList.remove(errorAnimationClass);\n\n\t\t\ton(\"animationend\", element, onAnimationEnd, { once: true });\n\t\t}\n\t}, [disableErrorAnimation, errorAnimationClass, errors, getErrorElements]);\n\n\tuseEffect(() => {\n\t\tif (disableScrollToErrorField) return;\n\n\t\tif (!errors || Object.keys(errors).length === 0) return;\n\n\t\tconst errorMessageElements = getErrorElements();\n\n\t\tconst firstErrorElement = errorMessageElements[0];\n\n\t\tif (!firstErrorElement) return;\n\n\t\t// // == Find the input field associated with this error\n\t\t// const inputField = document.querySelector(`[name='${fieldName}']`);\n\t\t// const isFocusableInput = inputField?.matches(\n\t\t// \t\":is(input, select, textarea, [contenteditable='true'])\"\n\t\t// );\n\n\t\t// // == Return early if the input field is focusable (Only scrollIntoView for non-focusable fields)\n\t\t// if (isFocusableInput) return;\n\n\t\t// == Schedule the scroll to next frame to ensure DOM is ready\n\t\trequestAnimationFrame(() => {\n\t\t\t// == Get the element's position and scroll in one frame\n\t\t\tconst rect = firstErrorElement.getBoundingClientRect();\n\t\t\tconst topWithOffset = rect.top - 100;\n\n\t\t\twindow.scrollTo({\n\t\t\t\tbehavior: \"smooth\",\n\t\t\t\ttop: window.scrollY + topWithOffset,\n\t\t\t});\n\t\t});\n\t}, [disableScrollToErrorField, fieldName, errors, getErrorElements]);\n\n\tconst fieldErrorMessage = getFieldErrorMessage({ errors, fieldName, type });\n\n\tif (!fieldErrorMessage) {\n\t\treturn null;\n\t}\n\n\tconst errorMessageArray = toArray(fieldErrorMessage);\n\n\tif (errorMessageArray.length === 0) {\n\t\treturn null;\n\t}\n\n\tconst getRenderProps = (options: { index: number }): ErrorMessageRenderProps => {\n\t\tconst { index } = options;\n\n\t\treturn {\n\t\t\tclassName: cnMerge(className, classNames?.errorMessage),\n\t\t\t\"data-index\": index,\n\t\t\t\"data-part\": \"error-message\",\n\t\t\t\"data-scope\": \"form\",\n\t\t\t\"data-slot\": \"form-error-message\",\n\t\t\tid: formMessageId,\n\t\t\tref: (node) => {\n\t\t\t\tif (!node || errorParagraphRef.current) return;\n\n\t\t\t\terrorParagraphRef.current = node;\n\t\t\t},\n\t\t};\n\t};\n\n\tconst getRenderState = (options: { errorMessage: string; index: number }): ErrorMessageRenderState => {\n\t\tconst { errorMessage, index } = options;\n\n\t\treturn {\n\t\t\terrorMessage,\n\t\t\terrorMessageArray,\n\t\t\tindex,\n\t\t};\n\t};\n\n\tconst [ErrorMessageList] = getElementList(\"base\");\n\n\tconst WrapperComponent = \"div\";\n\n\tconst wrapperComponentProps = errorMessageArray.length > 1 && {\n\t\tclassName: cnMerge(\"flex flex-col\", classNames?.container),\n\t\t\"data-part\": \"error-message-container\",\n\t\t\"data-scope\": \"form\",\n\t\t\"data-slot\": \"form-error-message-container\",\n\t\tref: wrapperRef,\n\t};\n\n\tconst selectedChildren = typeof children === \"function\" ? children : renderItem;\n\n\treturn (\n\t\t<WrapperComponent {...wrapperComponentProps}>\n\t\t\t<ErrorMessageList\n\t\t\t\teach={errorMessageArray}\n\t\t\t\trenderItem={(errorMessage, index) => {\n\t\t\t\t\treturn selectedChildren({\n\t\t\t\t\t\tprops: getRenderProps({ index }),\n\t\t\t\t\t\tstate: getRenderState({ errorMessage, index }),\n\t\t\t\t\t});\n\t\t\t\t}}\n\t\t\t/>\n\t\t</WrapperComponent>\n\t);\n};\n\ntype FormErrorMessageProps<TControl, TFieldValues extends FieldValues> =\n\t| (TControl extends Control<infer TValues> ?\n\t\t\t{\n\t\t\t\tclassName?: string;\n\t\t\t\tcontrol?: never;\n\t\t\t\terrorField?: FieldPath<TValues>;\n\t\t\t\ttype?: \"regular\";\n\t\t\t}\n\t :\t{\n\t\t\t\tclassName?: string;\n\t\t\t\tcontrol?: Control<TFieldValues>; // == Here for type inference of errorField prop\n\t\t\t\terrorField?: FieldPath<TFieldValues>;\n\t\t\t\ttype?: \"regular\";\n\t\t\t})\n\t| {\n\t\t\tclassName?: string;\n\t\t\tcontrol?: never;\n\t\t\terrorField: string;\n\t\t\ttype: \"root\";\n\t };\n\nexport function FormErrorMessage<TControl, TFieldValues extends FieldValues = FieldValues>(\n\tprops: FormErrorMessageProps<TControl, TFieldValues>\n) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst { className, errorField = fieldContextValues?.name, type = \"regular\" } = props;\n\n\tconst { control } = useFormMethodsContext();\n\n\treturn (\n\t\t<FormErrorMessagePrimitive\n\t\t\tcontrol={control}\n\t\t\tfieldName={errorField as NonNullable<typeof errorField>}\n\t\t\ttype={type as \"root\"}\n\t\t\trenderItem={({ props: renderProps, state }) => (\n\t\t\t\t<p\n\t\t\t\t\tkey={state.errorMessage}\n\t\t\t\t\t{...renderProps}\n\t\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t\t\"text-shadcn-destructive text-[13px]\",\n\t\t\t\t\t\t\"data-[index=0]:mt-1\",\n\t\t\t\t\t\trenderProps.className,\n\t\t\t\t\t\tclassName\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t{state.errorMessage}\n\t\t\t\t</p>\n\t\t\t)}\n\t\t/>\n\t);\n}\n\ntype FormSubmitProps = InferProps<\"button\"> & { asChild?: boolean };\n\nexport function FormSubmit<TElement extends React.ElementType = \"button\">(\n\tprops: PolymorphicProps<TElement, FormSubmitProps>\n) {\n\tconst { as: Element = \"button\", asChild, children, type = \"submit\", ...restOfProps } = props;\n\n\tconst Component = asChild ? Slot.Root : Element;\n\n\treturn (\n\t\t<Component data-part=\"submit\" data-scope=\"form\" data-slot=\"form-submit\" type={type} {...restOfProps}>\n\t\t\t{children}\n\t\t</Component>\n\t);\n}\n\ntype GetFieldValue<TFieldPathOrPaths, TFieldValues extends FieldValues> =\n\tTFieldPathOrPaths extends Array<FieldPath<TFieldValues>> ?\n\t\tFieldPathValues<TFieldValues, TFieldPathOrPaths>\n\t: TFieldPathOrPaths extends FieldPath<TFieldValues> ? FieldPathValue<TFieldValues, TFieldPathOrPaths>\n\t: unknown;\n\ntype FormSubscribeToFieldValueRenderFn<TFieldValues extends FieldValues, TFieldPathOrPaths> = (props: {\n\tvalue: GetFieldValue<TFieldPathOrPaths, TFieldValues>;\n}) => React.ReactNode;\n\ntype FormSubscribeToFieldValueProps<\n\tTFieldValues extends FieldValues,\n\tTFieldPathOrPaths,\n> = DiscriminatedRenderProps<FormSubscribeToFieldValueRenderFn<TFieldValues, TFieldPathOrPaths>> & {\n\tcontrol: Control<TFieldValues>;\n\tname?: TFieldPathOrPaths;\n};\n\nexport function FormSubscribeToFieldValue<\n\tTFieldValues extends FieldValues,\n\tconst TFieldPathOrPaths extends Array<FieldPath<TFieldValues>> | FieldPath<TFieldValues>,\n>(props: FormSubscribeToFieldValueProps<TFieldValues, TFieldPathOrPaths>) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst { children, name = fieldContextValues?.name, render } = props;\n\n\tconst { control } = useFormMethodsContext();\n\n\tconst formValue = useWatch({ control, name: name as string }) as unknown;\n\n\tconst selectedChildren = typeof children === \"function\" ? children : render;\n\n\tconst fieldProps = { value: formValue };\n\n\tconst resolvedChildren = selectedChildren(fieldProps as never);\n\n\treturn resolvedChildren;\n}\n\ntype FormSubscribeToFormStateRenderFn<TFieldValues extends FieldValues> = (\n\tprops: UseFormStateReturn<TFieldValues>\n) => React.ReactNode;\n\ntype FormSubscribeToFormStateProps<TFieldValues extends FieldValues> = DiscriminatedRenderProps<\n\tFormSubscribeToFormStateRenderFn<TFieldValues>\n> & {\n\tcontrol?: Control<TFieldValues>;\n\tname?: Array<FieldPath<TFieldValues>> | FieldPath<TFieldValues>;\n};\n\nexport function FormSubscribeToFormState<TFieldValues extends FieldValues = FieldValues>(\n\tprops: FormSubscribeToFormStateProps<TFieldValues>\n) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst { children, control, name = fieldContextValues?.name, render } = props;\n\n\tconst formState = useFormState({ control, name: name as FieldPath<TFieldValues> });\n\n\tconst selectedChildren = typeof children === \"function\" ? children : render;\n\n\tconst resolvedChildren = selectedChildren(formState as never);\n\n\treturn resolvedChildren;\n}\n","export {\n\tFormDescription as Description,\n\tFormErrorMessage as ErrorMessage,\n\tFormErrorMessagePrimitive as ErrorMessagePrimitive,\n\tFormField as Field,\n\tFormFieldContext as FieldContext,\n\tFormFieldController as FieldController,\n\tFormFieldControlledField as ControlledField,\n\tFormInput as Input,\n\tFormInputGroup as InputGroup,\n\tFormInputLeftItem as InputLeftItem,\n\tFormInputPrimitive as InputPrimitive,\n\tFormInputRightItem as InputRightItem,\n\tFormLabel as Label,\n\tFormRoot as Root,\n\tFormSelect as Select,\n\tFormSubmit as Submit,\n\tFormSubscribeToFieldValue as SubscribeToFieldValue,\n\tFormSubscribeToFormState as SubscribeToFormState,\n\tFormTextArea as TextArea,\n\tFormTextAreaPrimitive as TextArea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AAQ,GAAG;CAEvE,MAAM,YAAY,aAAa;EAAE;EAAe;EAAiC;CAEjF,MAAM,mBAAmB,OAAO,aAAa,aAAa,WAAW;CAErE,MAAM,mBAAmB,iBAAiB;AAE1C,QAAO;AACP"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _zayne_labs_toolkit_type_helpers0 from "@zayne-labs/toolkit-type-helpers";
|
|
2
2
|
import { Awaitable, SelectorFn } from "@zayne-labs/toolkit-type-helpers";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react2 from "react";
|
|
4
4
|
import * as _zayne_labs_toolkit_core0 from "@zayne-labs/toolkit-core";
|
|
5
5
|
import { FileMeta, FileValidationErrorContext, FileValidationHooksAsync, FileValidationSettingsAsync } from "@zayne-labs/toolkit-core";
|
|
6
6
|
import { InferProps, PolymorphicProps } from "@zayne-labs/toolkit-react/utils";
|
|
@@ -9,7 +9,7 @@ import { InferProps, PolymorphicProps } from "@zayne-labs/toolkit-react/utils";
|
|
|
9
9
|
declare const DropZoneStoreContextProvider: (props: {
|
|
10
10
|
children: React.ReactNode;
|
|
11
11
|
store: _zayne_labs_toolkit_core0.StoreApi<DropZoneStore>;
|
|
12
|
-
}) =>
|
|
12
|
+
}) => react2.FunctionComponentElement<react2.ProviderProps<_zayne_labs_toolkit_core0.StoreApi<DropZoneStore> | null>>, useDropZoneStoreContext: <TResult = DropZoneStore>(selector?: _zayne_labs_toolkit_type_helpers0.SelectorFn<DropZoneStore, TResult> | undefined) => TResult;
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/components/ui/drop-zone/use-drop-zone.d.ts
|
|
15
15
|
type ExtraProps = {
|
|
@@ -141,43 +141,43 @@ declare const createDropZoneStore: (initStoreValues: Pick<UseDropZoneProps, "all
|
|
|
141
141
|
//#endregion
|
|
142
142
|
//#region src/components/ui/drop-zone/drop-zone.d.ts
|
|
143
143
|
type DropZoneRootProps = UseDropZoneProps & {
|
|
144
|
-
children:
|
|
144
|
+
children: react2.ReactNode;
|
|
145
145
|
};
|
|
146
|
-
declare function DropZoneRoot(props: DropZoneRootProps):
|
|
146
|
+
declare function DropZoneRoot(props: DropZoneRootProps): react2.JSX.Element;
|
|
147
147
|
type DropZoneContextProps<TSlice> = {
|
|
148
|
-
children:
|
|
148
|
+
children: react2.ReactNode | ((props: TSlice) => react2.ReactNode);
|
|
149
149
|
selector?: SelectorFn<DropZoneStore, TSlice>;
|
|
150
150
|
};
|
|
151
|
-
declare function DropZoneContext<TSlice = DropZoneStore>(props: DropZoneContextProps<TSlice>):
|
|
151
|
+
declare function DropZoneContext<TSlice = DropZoneStore>(props: DropZoneContextProps<TSlice>): react2.ReactNode;
|
|
152
152
|
type DropZoneContainerProps = ExtraProps["container"] & {
|
|
153
153
|
asChild?: boolean;
|
|
154
154
|
};
|
|
155
|
-
declare function DropZoneContainer<TElement extends
|
|
155
|
+
declare function DropZoneContainer<TElement extends react2.ElementType = "div">(props: PolymorphicProps<TElement, DropZoneContainerProps>): react2.JSX.Element;
|
|
156
156
|
type DropZoneInputProps = ExtraProps["input"] & {
|
|
157
157
|
asChild?: boolean;
|
|
158
158
|
};
|
|
159
|
-
declare function DropZoneInput(props: DropZoneInputProps):
|
|
159
|
+
declare function DropZoneInput(props: DropZoneInputProps): react2.JSX.Element;
|
|
160
160
|
type DropZoneAreaProps<TSlice> = {
|
|
161
|
-
children:
|
|
161
|
+
children: react2.ReactNode | ((props: TSlice) => react2.ReactNode);
|
|
162
162
|
extraProps?: Pick<ExtraProps, "container" | "input">;
|
|
163
163
|
selector?: SelectorFn<DropZoneStore, TSlice>;
|
|
164
164
|
};
|
|
165
|
-
declare function DropZoneArea<TSlice = DropZoneStore>(props: DropZoneAreaProps<TSlice>):
|
|
165
|
+
declare function DropZoneArea<TSlice = DropZoneStore>(props: DropZoneAreaProps<TSlice>): react2.JSX.Element;
|
|
166
166
|
type DropZoneTriggerProps = ExtraProps["trigger"] & {
|
|
167
167
|
asChild?: boolean;
|
|
168
168
|
};
|
|
169
|
-
declare function DropZoneTrigger(props: DropZoneTriggerProps):
|
|
169
|
+
declare function DropZoneTrigger(props: DropZoneTriggerProps): react2.JSX.Element;
|
|
170
170
|
type DropZoneFilePreviewProps = {
|
|
171
|
-
children:
|
|
171
|
+
children: react2.ReactNode | ((props: Pick<DropZoneStore, "actions" | "fileStateArray">) => react2.ReactNode);
|
|
172
172
|
};
|
|
173
|
-
declare function DropZoneFilePreview(props: DropZoneFilePreviewProps):
|
|
173
|
+
declare function DropZoneFilePreview(props: DropZoneFilePreviewProps): react2.ReactNode;
|
|
174
174
|
type DropZoneErrorPreviewProps = {
|
|
175
|
-
children:
|
|
175
|
+
children: react2.ReactNode | ((props: Pick<DropZoneStore, "actions" | "errors">) => react2.ReactNode);
|
|
176
176
|
};
|
|
177
|
-
declare function DropZoneErrorPreview(props: DropZoneErrorPreviewProps):
|
|
177
|
+
declare function DropZoneErrorPreview(props: DropZoneErrorPreviewProps): react2.ReactNode;
|
|
178
178
|
declare namespace drop_zone_parts_d_exports {
|
|
179
179
|
export { DropZoneArea as Area, DropZoneContainer as Container, DropZoneContext as Context, DropZoneErrorPreview as ErrorPreview, DropZoneFilePreview as FilePreview, DropZoneInput as Input, DropZoneRoot as Root, DropZoneTrigger as Trigger };
|
|
180
180
|
}
|
|
181
181
|
//#endregion
|
|
182
182
|
export { ClassNames, DropZoneArea, DropZoneContainer, DropZoneContext, DropZoneContextProps, DropZoneErrorPreview, DropZoneFilePreview, DropZoneInput, DropZoneRoot, DropZoneRootProps, DropZoneTrigger, ExtraProps, UseDropZoneProps, UseDropZoneResult, drop_zone_parts_d_exports, useDropZone, useDropZoneStoreContext };
|
|
183
|
-
//# sourceMappingURL=index-
|
|
183
|
+
//# sourceMappingURL=index-BEv8nXKb.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetSlotComponentProps } from "./index-BNrCAe9Y.js";
|
|
2
2
|
import { ErrorBoundaryProps } from "./index-lKxE9WPi.js";
|
|
3
|
-
import { SuspenseWithBoundaryProps } from "./index-
|
|
3
|
+
import { SuspenseWithBoundaryProps } from "./index-eCX5RJ41.js";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/components/common/await/await.d.ts
|
|
@@ -42,4 +42,4 @@ type AwaitContextType<TValue = unknown> = {
|
|
|
42
42
|
declare const useAwaitContext: <TValue>() => AwaitContextType<TValue>;
|
|
43
43
|
//#endregion
|
|
44
44
|
export { AwaitError, AwaitPending, AwaitRoot, AwaitSuccess, await_parts_d_exports, useAwaitContext };
|
|
45
|
-
//# sourceMappingURL=index-
|
|
45
|
+
//# sourceMappingURL=index-BaONHZq0.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorBoundaryProps } from "./index-lKxE9WPi.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react0 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/components/common/suspense-with-boundary/suspense-with-boundary.d.ts
|
|
5
5
|
type SuspenseWithBoundaryProps = {
|
|
@@ -7,7 +7,7 @@ type SuspenseWithBoundaryProps = {
|
|
|
7
7
|
errorFallback?: ErrorBoundaryProps["fallback"];
|
|
8
8
|
fallback?: React.ReactNode;
|
|
9
9
|
};
|
|
10
|
-
declare function SuspenseWithBoundary(props: SuspenseWithBoundaryProps):
|
|
10
|
+
declare function SuspenseWithBoundary(props: SuspenseWithBoundaryProps): react0.JSX.Element;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { SuspenseWithBoundary, SuspenseWithBoundaryProps };
|
|
13
|
-
//# sourceMappingURL=index-
|
|
13
|
+
//# sourceMappingURL=index-eCX5RJ41.d.ts.map
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"form-Bkj1QWwb.js","names":["errorMessage","useHookFormContext","HookFormProvider","ReactFragment","FormErrorMessagePrimitive: FormErrorMessagePrimitiveType","Component"],"sources":["../../src/components/ui/form/icons.tsx","../../src/components/ui/form/utils.ts","../../src/components/ui/form/form-context.ts","../../src/components/ui/form/form.tsx","../../src/components/ui/form/form-parts.ts"],"sourcesContent":["import * as React from \"react\";\n\nexport const EyeIconClosed = (props: React.SVGProps<SVGSVGElement>) => (\n\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1em\" height=\"1em\" viewBox=\"0 0 24 24\" {...props}>\n\t\t<path\n\t\t\tfill=\"currentColor\"\n\t\t\td=\"M15.175 8.325q.725.725 1.063 1.65t.237 1.9q0 .375-.275.638t-.65.262t-.638-.262t-.262-.638q.125-.65-.075-1.25T13.95 9.6t-1.025-.65t-1.275-.1q-.375 0-.638-.275t-.262-.65t.263-.637t.637-.263q.95-.1 1.875.238t1.65 1.062M12 6q-.475 0-.925.037t-.9.138q-.425.075-.763-.125t-.462-.6t.088-.775t.612-.45q.575-.125 1.163-.175T12 4q3.425 0 6.263 1.8t4.337 4.85q.1.2.15.413t.05.437t-.038.438t-.137.412q-.45 1-1.112 1.875t-1.463 1.6q-.3.275-.7.225t-.65-.4t-.212-.763t.337-.687q.6-.575 1.1-1.25t.875-1.45q-1.25-2.525-3.613-4.012T12 6m0 13q-3.35 0-6.125-1.812T1.5 12.425q-.125-.2-.187-.437T1.25 11.5t.05-.475t.175-.45q.5-1 1.163-1.912T4.15 7L2.075 4.9q-.275-.3-.262-.712T2.1 3.5t.7-.275t.7.275l17 17q.275.275.288.688t-.288.712q-.275.275-.7.275t-.7-.275l-3.5-3.45q-.875.275-1.775.413T12 19M5.55 8.4q-.725.65-1.325 1.425T3.2 11.5q1.25 2.525 3.613 4.013T12 17q.5 0 .975-.062t.975-.138l-.9-.95q-.275.075-.525.113T12 16q-1.875 0-3.188-1.312T7.5 11.5q0-.275.038-.525t.112-.525zm4.2 4.2\"\n\t\t/>\n\t</svg>\n);\n\nexport const EyeIconOpen = (props: React.SVGProps<SVGSVGElement>) => (\n\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1em\" height=\"1em\" viewBox=\"0 0 24 24\" {...props}>\n\t\t<path\n\t\t\tfill=\"currentColor\"\n\t\t\td=\"M12 16q1.875 0 3.188-1.312T16.5 11.5t-1.312-3.187T12 7T8.813 8.313T7.5 11.5t1.313 3.188T12 16m0-1.8q-1.125 0-1.912-.788T9.3 11.5t.788-1.912T12 8.8t1.913.788t.787 1.912t-.787 1.913T12 14.2m0 4.8q-3.35 0-6.113-1.8t-4.362-4.75q-.125-.225-.187-.462t-.063-.488t.063-.488t.187-.462q1.6-2.95 4.363-4.75T12 4t6.113 1.8t4.362 4.75q.125.225.188.463t.062.487t-.062.488t-.188.462q-1.6 2.95-4.362 4.75T12 19m0-2q2.825 0 5.188-1.487T20.8 11.5q-1.25-2.525-3.613-4.012T12 6T6.813 7.488T3.2 11.5q1.25 2.525 3.613 4.013T12 17\"\n\t\t/>\n\t</svg>\n);\n","import { cnMerge } from \"@/lib/utils/cn\";\nimport { isObject } from \"@zayne-labs/toolkit-type-helpers\";\nimport { createElement } from \"react\";\nimport type { FieldErrors, FieldValues } from \"react-hook-form\";\nimport type { FormErrorMessagePrimitiveProps, FormInputProps } from \"./form\";\nimport type { FormRootContext, RenderIconProps } from \"./form-context\";\nimport { EyeIconClosed, EyeIconOpen } from \"./icons\";\n\nexport const getFieldErrorMessage = (options: {\n\terrors: FieldErrors | undefined;\n\tfieldName: string | undefined;\n\ttype: FormErrorMessagePrimitiveProps<FieldValues>[\"type\"];\n}): string | string[] | null | undefined => {\n\tconst { errors, fieldName, type } = options;\n\n\tif (!fieldName || !errors || Object.keys(errors).length === 0) return;\n\n\tif (type === \"root\") {\n\t\treturn errors.root?.[fieldName]?.message;\n\t}\n\n\t// == Handle nested paths like `notifications.0`\n\tconst pathParts = fieldName.includes(\".\") ? fieldName.split(\".\") : null;\n\n\t// == If there are no path parts, return the error message\n\tif (!pathParts) {\n\t\tconst errorMessage = errors[fieldName]?.message;\n\n\t\treturn errorMessage as string | string[];\n\t}\n\n\tlet extractedError = errors;\n\n\tfor (const part of pathParts) {\n\t\tconst currentError = extractedError[part];\n\n\t\tif (!isObject(currentError)) break;\n\n\t\textractedError = currentError as never;\n\t}\n\n\tconst errorMessage = extractedError.message as unknown as string | string[];\n\n\treturn errorMessage;\n};\n\nexport const getEyeIcon = (options: {\n\tclassNames: FormInputProps[\"classNames\"];\n\ticonType: \"closed\" | \"open\";\n\trenderIconProps: RenderIconProps;\n\twithEyeIcon: FormRootContext[\"withEyeIcon\"];\n}) => {\n\tconst { classNames, iconType, renderIconProps, withEyeIcon } = options;\n\n\tif (!withEyeIcon) {\n\t\treturn null;\n\t}\n\n\tif (withEyeIcon === true) {\n\t\tconst defaultIconMap = {\n\t\t\tclosed: createElement(EyeIconClosed, {\n\t\t\t\tclassName: cnMerge(\"size-full\", classNames?.eyeIcon),\n\t\t\t}),\n\n\t\t\topen: createElement(EyeIconOpen, {\n\t\t\t\tclassName: cnMerge(\"size-full\", classNames?.eyeIcon),\n\t\t\t}),\n\t\t};\n\n\t\treturn defaultIconMap[iconType];\n\t}\n\n\tif (withEyeIcon.renderIcon) {\n\t\treturn withEyeIcon.renderIcon(renderIconProps);\n\t}\n\n\tif (withEyeIcon[iconType]) {\n\t\treturn withEyeIcon[iconType];\n\t}\n\n\treturn null;\n};\n","import { ContextError, createCustomContext } from \"@zayne-labs/toolkit-react\";\nimport type { DiscriminatedRenderProps } from \"@zayne-labs/toolkit-react/utils\";\nimport type { UnionDiscriminator } from \"@zayne-labs/toolkit-type-helpers\";\nimport {\n\ttype Control,\n\ttype UseFormReturn,\n\ttype UseFormStateReturn,\n\tuseFormState,\n\tuseFormContext as useHookFormContext,\n} from \"react-hook-form\";\nimport type { FieldValues, FormInputProps } from \"./form\";\nimport { getFieldErrorMessage } from \"./utils\";\n\ntype UseFormRootContextResult<TStrict extends boolean = true> = TStrict extends true\n\t? UseFormReturn<FieldValues> & { withEyeIcon?: FormInputProps[\"withEyeIcon\"] }\n\t: (UseFormReturn<FieldValues> & { withEyeIcon?: FormInputProps[\"withEyeIcon\"] }) | null;\n\nexport const useFormMethodsContext = <TStrict extends boolean = true>(\n\toptions: { strict?: TStrict } = {}\n): UseFormRootContextResult<TStrict> => {\n\tconst { strict = true } = options;\n\tconst formContext = useHookFormContext();\n\n\tif (strict && !(formContext as unknown)) {\n\t\tthrow new ContextError(\n\t\t\t`useFormRootContext returned \"null\". Did you forget to wrap the necessary components within FormRoot?`\n\t\t);\n\t}\n\n\treturn formContext;\n};\n\nexport type RenderIconProps = {\n\tisPasswordVisible: boolean;\n};\n\ntype EyeIconObject = UnionDiscriminator<\n\t[\n\t\t{ closed: React.ReactNode; open: React.ReactNode },\n\t\t{ renderIcon: (props: RenderIconProps) => React.ReactNode },\n\t]\n>;\n\nexport type FormRootContext = {\n\twithEyeIcon: boolean | EyeIconObject | undefined;\n};\n\nexport const [LaxFormRootProvider, useLaxFormRootContext] = createCustomContext<FormRootContext, false>({\n\thookName: \"useLaxFormRootContext\",\n\tname: \"LaxFormRootContext\",\n\tproviderName: \"FormRoot\",\n\tstrict: false,\n});\n\n// export const useStrictGetFieldState = () => {\n// \tconst { name } = useStrictFormFieldContext();\n\n// \tconst { getFieldState } = useFormRootContext();\n\n// \tconst fieldState = getFieldState(name);\n\n// \treturn fieldState;\n// };\n\nexport type FieldContextValue = {\n\tformDescriptionId: `${string}-(${string})-form-item-description`;\n\tformItemId: `${string}-(${string})-form-item`;\n\tformMessageId: `${string}-(${string})-form-item-message`;\n\tname: string;\n};\n\nexport type FormFieldContextProps = DiscriminatedRenderProps<\n\t(contextValue: FieldContextValue) => React.ReactNode\n>;\n\nexport const [StrictFormFieldProvider, useStrictFormFieldContext] = createCustomContext<FieldContextValue>(\n\t{\n\t\thookName: \"useFormFieldContext\",\n\t\tname: \"StrictFormFieldContext\",\n\t\tproviderName: \"FormField\",\n\t}\n);\n\nexport const [LaxFormFieldProvider, useLaxFormFieldContext] = createCustomContext<\n\tFieldContextValue,\n\tfalse\n>({\n\thookName: \"useLaxFormFieldContext\",\n\tname: \"LaxFormFieldContext\",\n\tproviderName: \"FormField\",\n\tstrict: false,\n});\n\nexport type FieldState = {\n\terrors?: UseFormStateReturn<FieldValues>[\"errors\"];\n\tisDisabled?: boolean;\n\tisInvalid?: boolean;\n};\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- any is used here for type compatibility\nexport type AnyControl = Control<any>;\n\ntype FieldStateOptions =\n\t| {\n\t\t\tcontrol: AnyControl | undefined;\n\t\t\tname?: string;\n\t }\n\t| {\n\t\t\tcontrol?: AnyControl;\n\t\t\tname: string | undefined;\n\t };\n\nexport const useLaxFormFieldState = (options?: FieldStateOptions): FieldState => {\n\tconst { control = options?.control } = useFormMethodsContext({ strict: false }) ?? {};\n\tconst { name = options?.name } = useLaxFormFieldContext() ?? {};\n\n\tconst getFormState = control ? useFormState : () => ({}) as Partial<ReturnType<typeof useFormState>>;\n\n\tconst { disabled, errors } = getFormState({ control, name });\n\n\tconst errorMessage = getFieldErrorMessage({ errors, fieldName: name, type: \"regular\" });\n\n\treturn {\n\t\terrors,\n\t\tisDisabled: disabled,\n\t\tisInvalid: Boolean(errorMessage),\n\t};\n};\n","\"use client\";\n\n// biome-ignore assist/source/organizeImports: needs to be on top\nimport * as React from \"react\";\n\nimport { dataAttr, on, toArray } from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef, useToggle } from \"@zayne-labs/toolkit-react\";\nimport {\n\tcomposeRefs,\n\tcomposeTwoEventHandlers,\n\ttype DiscriminatedRenderItemProps,\n\ttype DiscriminatedRenderProps,\n\ttype InferProps,\n\ttype PolymorphicProps,\n} from \"@zayne-labs/toolkit-react/utils\";\nimport { type AnyString, defineEnum } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Fragment as ReactFragment, useEffect, useId, useMemo, useRef } from \"react\";\nimport {\n\ttype Control,\n\tController,\n\ttype ControllerFieldState,\n\ttype ControllerProps,\n\ttype ControllerRenderProps,\n\ttype FieldPath,\n\ttype FieldPathValue,\n\ttype FieldPathValues,\n\tFormProvider as HookFormProvider,\n\ttype RegisterOptions,\n\ttype UseFormReturn,\n\ttype UseFormStateReturn,\n\tuseFormState,\n\tuseWatch,\n} from \"react-hook-form\";\nimport { getElementList } from \"@/components/common/for\";\nimport { Slot } from \"@/components/common/slot\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport { getMultipleSlots } from \"@/lib/utils/getSlot\";\nimport {\n\ttype FieldContextValue,\n\ttype FieldState,\n\ttype FormFieldContextProps,\n\ttype FormRootContext,\n\tLaxFormFieldProvider,\n\tLaxFormRootProvider,\n\tStrictFormFieldProvider,\n\tuseFormMethodsContext,\n\tuseLaxFormFieldContext,\n\tuseLaxFormFieldState,\n\tuseLaxFormRootContext,\n\tuseStrictFormFieldContext,\n} from \"./form-context\";\nimport { getEyeIcon, getFieldErrorMessage } from \"./utils\";\n\n// eslint-disable-next-line ts-eslint/no-explicit-any -- Necessary so that arrays can also be accepted\nexport type FieldValues = Record<string, any>;\n\ntype FormRootProps<TFieldValues extends FieldValues> = Partial<FormRootContext>\n\t& React.ComponentPropsWithoutRef<\"form\"> & {\n\t\tchildren: React.ReactNode;\n\t\tmethods: UseFormReturn<TFieldValues>;\n\t};\n\nexport function FormRoot<TValues extends FieldValues>(props: FormRootProps<TValues>) {\n\tconst { children, className, methods, withEyeIcon, ...restOfProps } = props;\n\n\tconst formContextValue = useMemo(() => ({ withEyeIcon }), [withEyeIcon]);\n\n\treturn (\n\t\t<HookFormProvider {...methods}>\n\t\t\t<LaxFormRootProvider value={formContextValue}>\n\t\t\t\t<form\n\t\t\t\t\tclassName={cnMerge(\"flex flex-col\", className)}\n\t\t\t\t\t{...restOfProps}\n\t\t\t\t\tdata-scope=\"form\"\n\t\t\t\t\tdata-part=\"root\"\n\t\t\t\t\tdata-slot=\"form-root\"\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</form>\n\t\t\t</LaxFormRootProvider>\n\t\t</HookFormProvider>\n\t);\n}\n\ntype FormFieldProps<TControl, TFieldValues extends FieldValues> = (TControl extends (\n\tControl<infer TValues>\n) ?\n\t{\n\t\tcontrol?: never;\n\t\tname: FieldPath<TValues>;\n\t}\n:\t{\n\t\tcontrol?: Control<TFieldValues>;\n\t\tname: FieldPath<TFieldValues>;\n\t})\n\t& (\n\t\t| (InferProps<\"div\"> & {\n\t\t\t\twithWrapper?: true;\n\t\t })\n\t\t| { children: React.ReactNode; className?: never; withWrapper: false }\n\t);\n\nexport function FormField<TControl, TFieldValues extends FieldValues = FieldValues>(\n\tprops: FormFieldProps<TControl, TFieldValues>\n) {\n\tconst { children, className, name, withWrapper = true } = props;\n\n\tconst { isDisabled, isInvalid } = useLaxFormFieldState({ name });\n\n\tconst uniqueId = useId();\n\n\tconst fieldContextValue = useMemo(\n\t\t() =>\n\t\t\t({\n\t\t\t\tformDescriptionId: `${name}-(${uniqueId})-form-item-description`,\n\t\t\t\tformItemId: `${name}-(${uniqueId})-form-item`,\n\t\t\t\tformMessageId: `${name}-(${uniqueId})-form-item-message`,\n\t\t\t\tname,\n\t\t\t}) satisfies FieldContextValue,\n\t\t[name, uniqueId]\n\t);\n\n\tconst WrapperElement = withWrapper ? \"div\" : ReactFragment;\n\n\tconst wrapperElementProps = withWrapper && {\n\t\tclassName: cnMerge(\"flex flex-col gap-2\", className),\n\t\t\"data-part\": \"field\",\n\t\t\"data-scope\": \"form\",\n\t\t\"data-slot\": \"form-field\",\n\t\t/* eslint-disable perfectionist/sort-objects -- order of attributes does not matter */\n\t\t\"data-disabled\": dataAttr(isDisabled),\n\t\t\"data-invalid\": dataAttr(isInvalid),\n\t\t/* eslint-enable perfectionist/sort-objects -- order of attributes does not matter */\n\t};\n\treturn (\n\t\t<StrictFormFieldProvider value={fieldContextValue}>\n\t\t\t<LaxFormFieldProvider value={fieldContextValue}>\n\t\t\t\t<WrapperElement {...wrapperElementProps}>{children}</WrapperElement>\n\t\t\t</LaxFormFieldProvider>\n\t\t</StrictFormFieldProvider>\n\t);\n}\n\ntype FormFieldControllerRenderFn = (props: {\n\tfield: Omit<ControllerRenderProps, \"value\"> & {\n\t\tvalue: never;\n\t};\n\tfieldState: ControllerFieldState;\n\tformState: UseFormStateReturn<never>;\n}) => React.ReactElement;\n\ntype FormFieldControllerProps = Omit<\n\tControllerProps<FieldValues, FieldPath<FieldValues>>,\n\t\"control\" | \"name\" | \"render\"\n> & {\n\trender: FormFieldControllerRenderFn;\n};\n\nexport function FormFieldController(props: FormFieldControllerProps) {\n\tconst { control } = useFormMethodsContext();\n\tconst { name } = useStrictFormFieldContext();\n\tconst { render, ...restOfProps } = props;\n\n\treturn <Controller name={name} control={control} render={render as never} {...restOfProps} />;\n}\n\nexport function FormFieldControlledField<TFieldValues extends FieldValues>(\n\tprops: ControllerProps<TFieldValues>\n) {\n\tconst { name } = props;\n\n\tconst uniqueId = useId();\n\n\tconst fieldContextValue = useMemo(\n\t\t() =>\n\t\t\t({\n\t\t\t\tformDescriptionId: `${name}-(${uniqueId})-form-item-description`,\n\t\t\t\tformItemId: `${name}-(${uniqueId})-form-item`,\n\t\t\t\tformMessageId: `${name}-(${uniqueId})-form-item-message`,\n\t\t\t\tname,\n\t\t\t}) satisfies FieldContextValue,\n\t\t[name, uniqueId]\n\t);\n\n\treturn (\n\t\t<StrictFormFieldProvider value={fieldContextValue}>\n\t\t\t<LaxFormFieldProvider value={fieldContextValue}>\n\t\t\t\t<Controller {...props} />\n\t\t\t</LaxFormFieldProvider>\n\t\t</StrictFormFieldProvider>\n\t);\n}\n\nexport function FormFieldContext(props: FormFieldContextProps) {\n\tconst { children, render } = props;\n\tconst fieldContextValues = useStrictFormFieldContext();\n\n\tif (typeof children === \"function\") {\n\t\treturn children(fieldContextValues);\n\t}\n\n\treturn render(fieldContextValues);\n}\n\nexport function FormLabel(props: InferProps<\"label\">) {\n\tconst { formItemId, name } = useStrictFormFieldContext();\n\tconst { children, className, ...restOfProps } = props;\n\n\tconst { isDisabled, isInvalid } = useLaxFormFieldState({ name });\n\n\treturn (\n\t\t<label\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"label\"\n\t\t\tdata-slot=\"form-label\"\n\t\t\tdata-disabled={dataAttr(isDisabled)}\n\t\t\tdata-invalid={dataAttr(isInvalid)}\n\t\t\thtmlFor={formItemId}\n\t\t\tclassName={className}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{children}\n\t\t</label>\n\t);\n}\n\nexport function FormInputGroup(props: InferProps<\"div\">) {\n\tconst { children, className, ...restOfProps } = props;\n\n\tconst { isDisabled, isInvalid } = useLaxFormFieldState();\n\n\tconst {\n\t\tregularChildren,\n\t\tslots: [leftItemSlot, rightItemSlot],\n\t} = getMultipleSlots(children, [FormInputLeftItem, FormInputRightItem]);\n\n\treturn (\n\t\t<div\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"input-group\"\n\t\t\tdata-slot=\"form-input-group\"\n\t\t\tdata-invalid={dataAttr(isInvalid)}\n\t\t\tdata-disabled={dataAttr(isDisabled)}\n\t\t\tclassName={cnMerge(\"flex items-center justify-between gap-2\", className)}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{leftItemSlot}\n\t\t\t{regularChildren}\n\t\t\t{rightItemSlot}\n\t\t</div>\n\t);\n}\n\ntype FormSideItemProps = {\n\tchildren?: React.ReactNode;\n\tclassName?: string;\n};\n\nexport function FormInputLeftItem<TElement extends React.ElementType = \"span\">(\n\tprops: PolymorphicProps<TElement, FormSideItemProps>\n) {\n\tconst { as: Element = \"span\", children, className, ...restOfProps } = props;\n\n\treturn (\n\t\t<Element\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"left-item\"\n\t\t\tdata-slot=\"form-left-item\"\n\t\t\tclassName={cnMerge(\"inline-flex items-center justify-center\", className)}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{children}\n\t\t</Element>\n\t);\n}\nFormInputLeftItem.slotSymbol = Symbol(\"input-left-item\");\n\nexport function FormInputRightItem<TElement extends React.ElementType = \"span\">(\n\tprops: PolymorphicProps<TElement, FormSideItemProps>\n) {\n\tconst { as: Element = \"span\", children, className, ...restOfProps } = props;\n\n\treturn (\n\t\t<Element\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"right-item\"\n\t\t\tdata-slot=\"form-right-item\"\n\t\t\tclassName={cnMerge(\"inline-flex items-center justify-center\", className)}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{children}\n\t\t</Element>\n\t);\n}\nFormInputRightItem.slotSymbol = Symbol(\"input-right-item\");\n\ntype FormInputPrimitiveProps<TFieldValues extends FieldValues = FieldValues> = Omit<\n\tReact.ComponentPropsWithRef<\"input\">,\n\t\"children\"\n> & {\n\tclassNames?: { error?: string; eyeIcon?: string; input?: string; inputGroup?: string };\n\tcontrol?: Control<TFieldValues>;\n\tfieldState?: FieldState;\n\tname?: FieldPath<TFieldValues>;\n\twithEyeIcon?: FormRootContext[\"withEyeIcon\"];\n};\n\ntype FormTextAreaPrimitiveProps<TFieldValues extends FieldValues = FieldValues> =\n\tReact.ComponentPropsWithRef<\"textarea\"> & {\n\t\tclassNames?: { base?: string; error?: string };\n\t\tcontrol?: Control<TFieldValues>;\n\t\tfieldState?: FieldState;\n\t\tname?: FieldPath<TFieldValues>;\n\t};\n\ntype FormSelectPrimitiveProps<TFieldValues extends FieldValues = FieldValues> =\n\tReact.ComponentPropsWithRef<\"select\"> & {\n\t\tclassNames?: { base?: string; error?: string };\n\t\tcontrol?: Control<TFieldValues>;\n\t\tfieldState?: FieldState;\n\t\tname?: FieldPath<TFieldValues>;\n\t};\n\nconst inputTypesWithoutFullWith = new Set<React.HTMLInputTypeAttribute>([\"checkbox\", \"radio\"]);\n\nexport function FormInputPrimitive<TFieldValues extends FieldValues>(\n\tprops: FormInputPrimitiveProps<TFieldValues> & { rules?: RegisterOptions }\n) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst formRootContextValues = useLaxFormRootContext();\n\n\tconst {\n\t\tclassName,\n\t\tclassNames,\n\t\tcontrol,\n\t\tfieldState,\n\t\tid = fieldContextValues?.formItemId,\n\t\tname = fieldContextValues?.name,\n\t\trules,\n\t\ttype = \"text\",\n\t\twithEyeIcon = formRootContextValues?.withEyeIcon ?? true,\n\t\t...restOfProps\n\t} = props;\n\n\tconst fieldStateFromLaxFormField = useLaxFormFieldState({ control, name });\n\n\tconst { isDisabled, isInvalid } = fieldState ?? fieldStateFromLaxFormField;\n\n\tconst [isPasswordVisible, toggleVisibility] = useToggle(false);\n\n\tconst shouldHaveEyeIcon = withEyeIcon && type === \"password\";\n\n\tconst WrapperElement = shouldHaveEyeIcon ? FormInputGroup : ReactFragment;\n\n\tconst wrapperElementProps = shouldHaveEyeIcon && {\n\t\tclassName: cnMerge(\"w-full\", classNames?.inputGroup, isInvalid && classNames?.error),\n\t};\n\n\tconst { register } = useFormMethodsContext({ strict: false }) ?? {};\n\n\tconst eyeIcon = getEyeIcon({\n\t\tclassNames,\n\t\ticonType: isPasswordVisible ? \"closed\" : \"open\",\n\t\trenderIconProps: { isPasswordVisible },\n\t\twithEyeIcon,\n\t});\n\n\treturn (\n\t\t<WrapperElement {...wrapperElementProps}>\n\t\t\t<input\n\t\t\t\tdata-scope=\"form\"\n\t\t\t\tdata-part=\"input\"\n\t\t\t\tdata-slot=\"form-input\"\n\t\t\t\taria-describedby={\n\t\t\t\t\t!isInvalid ?\n\t\t\t\t\t\tfieldContextValues?.formDescriptionId\n\t\t\t\t\t:\t`${fieldContextValues?.formDescriptionId} ${fieldContextValues?.formMessageId}`\n\t\t\t\t}\n\t\t\t\taria-invalid={dataAttr(isInvalid)}\n\t\t\t\tdata-invalid={dataAttr(isInvalid)}\n\t\t\t\tdata-disabled={dataAttr(isDisabled)}\n\t\t\t\tid={id}\n\t\t\t\tname={name}\n\t\t\t\ttype={type === \"password\" && isPasswordVisible ? \"text\" : type}\n\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t!inputTypesWithoutFullWith.has(type) && \"flex w-full\",\n\t\t\t\t\t`focus-visible:outline-hidden placeholder:text-shadcn-muted-foreground bg-transparent\n\t\t\t\t\ttext-sm file:border-0 file:bg-transparent disabled:cursor-not-allowed disabled:opacity-50`,\n\t\t\t\t\tclassName,\n\t\t\t\t\tclassNames?.input,\n\t\t\t\t\ttype !== \"password\" && isInvalid && classNames?.error\n\t\t\t\t)}\n\t\t\t\t{...(Boolean(name) && register?.(name, rules))}\n\t\t\t\t{...restOfProps}\n\t\t\t/>\n\n\t\t\t{shouldHaveEyeIcon && (\n\t\t\t\t<FormInputRightItem\n\t\t\t\t\tas=\"button\"\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tonClick={toggleVisibility}\n\t\t\t\t\tclassName=\"size-5 shrink-0 lg:size-6\"\n\t\t\t\t>\n\t\t\t\t\t{eyeIcon}\n\t\t\t\t</FormInputRightItem>\n\t\t\t)}\n\t\t</WrapperElement>\n\t);\n}\n\nexport function FormTextAreaPrimitive<TFieldValues extends FieldValues>(\n\tprops: FormTextAreaPrimitiveProps<TFieldValues> & { rules?: RegisterOptions }\n) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst {\n\t\tclassName,\n\t\tclassNames,\n\t\tcontrol,\n\t\tfieldState,\n\t\tid = fieldContextValues?.formItemId,\n\t\tname = fieldContextValues?.name,\n\t\trules,\n\t\t...restOfProps\n\t} = props;\n\n\tconst fieldStateFromLaxFormField = useLaxFormFieldState({ control, name });\n\n\tconst { isDisabled, isInvalid } = fieldState ?? fieldStateFromLaxFormField;\n\n\tconst { register } = useFormMethodsContext({ strict: false }) ?? {};\n\n\treturn (\n\t\t<textarea\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"textarea\"\n\t\t\tdata-slot=\"form-textarea\"\n\t\t\taria-describedby={\n\t\t\t\t!isInvalid ?\n\t\t\t\t\tfieldContextValues?.formDescriptionId\n\t\t\t\t:\t`${fieldContextValues?.formDescriptionId} ${fieldContextValues?.formMessageId}`\n\t\t\t}\n\t\t\taria-invalid={dataAttr(isInvalid)}\n\t\t\tdata-disabled={dataAttr(isDisabled)}\n\t\t\tdata-invalid={dataAttr(isInvalid)}\n\t\t\tid={id}\n\t\t\tname={name}\n\t\t\tclassName={cnMerge(\n\t\t\t\t`placeholder:text-shadcn-muted-foreground focus-visible:outline-hidden w-full bg-transparent\n\t\t\t\ttext-sm disabled:cursor-not-allowed disabled:opacity-50`,\n\t\t\t\tclassName,\n\t\t\t\tclassNames?.base,\n\t\t\t\tisInvalid && classNames?.error\n\t\t\t)}\n\t\t\t{...(Boolean(name) && register?.(name, rules))}\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\nexport function FormSelectPrimitive<TFieldValues extends FieldValues>(\n\tprops: FormSelectPrimitiveProps<TFieldValues> & { rules?: RegisterOptions }\n) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst {\n\t\tclassName,\n\t\tclassNames,\n\t\tcontrol,\n\t\tfieldState,\n\t\tid = fieldContextValues?.formItemId,\n\t\tname = fieldContextValues?.name,\n\t\trules,\n\t\t...restOfProps\n\t} = props;\n\n\tconst fieldStateFromLaxFormField = useLaxFormFieldState({ control, name });\n\n\tconst { isDisabled, isInvalid } = fieldState ?? fieldStateFromLaxFormField;\n\n\tconst { register } = useFormMethodsContext({ strict: false }) ?? {};\n\n\treturn (\n\t\t<select\n\t\t\tdefaultValue=\"\"\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"select\"\n\t\t\tdata-slot=\"form-select\"\n\t\t\taria-describedby={\n\t\t\t\t!isInvalid ?\n\t\t\t\t\tfieldContextValues?.formDescriptionId\n\t\t\t\t:\t`${fieldContextValues?.formDescriptionId} ${fieldContextValues?.formMessageId}`\n\t\t\t}\n\t\t\taria-invalid={dataAttr(isInvalid)}\n\t\t\tdata-disabled={dataAttr(isDisabled)}\n\t\t\tdata-invalid={dataAttr(isInvalid)}\n\t\t\tid={id}\n\t\t\tname={name}\n\t\t\tclassName={cnMerge(\n\t\t\t\t`placeholder:text-shadcn-muted-foreground focus-visible:outline-hidden w-full bg-transparent\n\t\t\t\ttext-sm disabled:cursor-not-allowed disabled:opacity-50`,\n\t\t\t\tclassName,\n\t\t\t\tclassNames?.base,\n\t\t\t\tisInvalid && classNames?.error\n\t\t\t)}\n\t\t\t{...(Boolean(name) && register?.(name, rules))}\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\n\ntype PrimitivePropsToOmit = \"control\" | \"formState\" | \"name\";\n\nexport type FormInputProps = Omit<FormInputPrimitiveProps, PrimitivePropsToOmit> & {\n\trules?: RegisterOptions;\n};\n\nexport type FormTextAreaProps = Omit<FormTextAreaPrimitiveProps, PrimitivePropsToOmit> & {\n\trules?: RegisterOptions;\n};\n\nexport type FormSelectProps = Omit<FormSelectPrimitiveProps, PrimitivePropsToOmit> & {\n\trules?: RegisterOptions;\n};\n\ntype CombinedFormInputProps =\n\t| (FormSelectProps & { type: \"select\" })\n\t| (FormTextAreaProps & { type: \"textarea\" })\n\t| FormInputProps;\n\nconst InputTypeMap = defineEnum({\n\tselect: FormSelectPrimitive,\n\ttextarea: FormTextAreaPrimitive,\n});\n\nexport function FormInput(props: CombinedFormInputProps & { rules?: RegisterOptions }) {\n\tconst { onBlur, onChange, ref, rules, type, ...restOfProps } = props;\n\n\tconst { name } = useStrictFormFieldContext();\n\tconst { register } = useFormMethodsContext();\n\n\tconst SelectedInput =\n\t\ttype === \"textarea\" || type === \"select\" ?\n\t\t\tInputTypeMap[type as Exclude<typeof type, AnyString>]\n\t\t:\tFormInputPrimitive;\n\n\tconst registerProps = name ? register(name, rules) : null;\n\n\treturn (\n\t\t<SelectedInput\n\t\t\ttype={type as never}\n\t\t\tname={name}\n\t\t\t{...registerProps}\n\t\t\t{...(restOfProps as NonNullable<unknown>)}\n\t\t\tref={composeRefs(registerProps?.ref, ref)}\n\t\t\tonChange={composeTwoEventHandlers(registerProps?.onChange, onChange)}\n\t\t\tonBlur={composeTwoEventHandlers(registerProps?.onBlur, onBlur)}\n\t\t/>\n\t);\n}\n\nexport function FormTextArea(props: FormTextAreaProps) {\n\treturn <FormInput {...props} type=\"textarea\" />;\n}\n\nexport function FormSelect(props: FormSelectProps) {\n\treturn <FormInput {...props} type=\"select\" />;\n}\n\nexport function FormDescription(props: InferProps<\"p\">) {\n\tconst { className, ...restOfProps } = props;\n\n\tconst { formDescriptionId } = useLaxFormFieldContext() ?? {};\n\n\treturn <p id={formDescriptionId} className={cnMerge(\"text-[12px]\", className)} {...restOfProps} />;\n}\n\ntype ErrorMessageRenderProps = {\n\tclassName: string;\n\t\"data-index\": number;\n\t\"data-part\": \"error-message\";\n\t\"data-scope\": \"form\";\n\t\"data-slot\": \"form-error-message\";\n\tid: string | undefined;\n\tref: React.RefCallback<HTMLElement>;\n};\n\ntype ErrorMessageRenderState = { errorMessage: string; errorMessageArray: string[]; index: number };\n\ntype ErrorMessageRenderFn = (context: {\n\tprops: ErrorMessageRenderProps;\n\tstate: ErrorMessageRenderState;\n}) => React.ReactNode;\n\nexport type FormErrorMessagePrimitiveProps<TFieldValues extends FieldValues> =\n\tDiscriminatedRenderItemProps<ErrorMessageRenderFn> & {\n\t\tclassName?: string;\n\t\tclassNames?: {\n\t\t\tcontainer?: string;\n\t\t\terrorMessage?: string;\n\t\t\terrorMessageAnimation?: string;\n\t\t};\n\t\tcontrol?: Control<TFieldValues>; // == Here for type inference of errorField prop\n\t\tdisableErrorAnimation?: boolean;\n\t\tdisableScrollToErrorField?: boolean;\n\t} & (\n\t\t\t| {\n\t\t\t\t\tfieldName: FieldPath<TFieldValues>;\n\t\t\t\t\ttype?: \"regular\";\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tfieldName: string;\n\t\t\t\t\ttype: \"root\";\n\t\t\t }\n\t\t);\n\ntype FormErrorMessagePrimitiveType = {\n\t<TFieldValues extends FieldValues>(\n\t\tprops: Extract<FormErrorMessagePrimitiveProps<TFieldValues>, { type?: \"regular\" }>\n\t): React.ReactNode;\n\t<TFieldValues extends FieldValues>(\n\t\t// eslint-disable-next-line ts-eslint/unified-signatures -- Using overloads are better because it gives better error messages\n\t\tprops: Extract<FormErrorMessagePrimitiveProps<TFieldValues>, { type: \"root\" }>\n\t): React.ReactNode;\n};\n\nexport const FormErrorMessagePrimitive: FormErrorMessagePrimitiveType = (props) => {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\tconst rootContextValues = useFormMethodsContext({ strict: false });\n\n\tconst {\n\t\tchildren,\n\t\tclassName,\n\t\tclassNames,\n\t\tcontrol = rootContextValues?.control,\n\t\tdisableErrorAnimation = false,\n\t\tdisableScrollToErrorField = false,\n\t\tfieldName = fieldContextValues?.name,\n\t\trenderItem,\n\t\ttype = \"regular\",\n\t} = props;\n\n\tconst { errors } = useLaxFormFieldState({ control, name: fieldName });\n\n\tconst { formMessageId } = useLaxFormFieldContext() ?? {};\n\n\tconst errorParagraphRef = useRef<HTMLElement>(null);\n\n\tconst wrapperRef = useRef<HTMLDivElement>(null);\n\n\tconst errorAnimationClass = classNames?.errorMessageAnimation ?? \"animate-shake\";\n\n\tconst getErrorElements = useCallbackRef(\n\t\t() => wrapperRef.current?.children ?? [errorParagraphRef.current]\n\t);\n\n\tuseEffect(() => {\n\t\tif (disableErrorAnimation) return;\n\n\t\tif (!errors || Object.keys(errors).length === 0) return;\n\n\t\tconst errorMessageElements = getErrorElements();\n\n\t\tif (errorMessageElements.length === 0) return;\n\n\t\tfor (const element of errorMessageElements) {\n\t\t\tif (!element) continue;\n\n\t\t\telement.classList.add(errorAnimationClass);\n\n\t\t\tconst onAnimationEnd = () => element.classList.remove(errorAnimationClass);\n\n\t\t\ton(\"animationend\", element, onAnimationEnd, { once: true });\n\t\t}\n\t}, [disableErrorAnimation, errorAnimationClass, errors, getErrorElements]);\n\n\tuseEffect(() => {\n\t\tif (disableScrollToErrorField) return;\n\n\t\tif (!errors || Object.keys(errors).length === 0) return;\n\n\t\tconst errorMessageElements = getErrorElements();\n\n\t\tconst firstErrorElement = errorMessageElements[0];\n\n\t\tif (!firstErrorElement) return;\n\n\t\t// == Find the input field associated with this error\n\t\tconst inputField = document.querySelector(`[name='${fieldName}']`);\n\t\tconst isFocusableInput = inputField?.matches(\n\t\t\t\":is(input, select, textarea, [contenteditable='true'])\"\n\t\t);\n\n\t\t// == Return early if the input field is focusable (Only scrollIntoView for non-focusable fields)\n\t\tif (isFocusableInput) return;\n\n\t\t// == Schedule the scroll to next frame to ensure DOM is ready\n\t\trequestAnimationFrame(() => {\n\t\t\t// == Get the element's position and scroll in one frame\n\t\t\tconst rect = firstErrorElement.getBoundingClientRect();\n\t\t\tconst topWithOffset = rect.top - 100;\n\n\t\t\twindow.scrollTo({\n\t\t\t\tbehavior: \"smooth\",\n\t\t\t\ttop: window.scrollY + topWithOffset,\n\t\t\t});\n\t\t});\n\t}, [disableScrollToErrorField, fieldName, errors, getErrorElements]);\n\n\tconst fieldErrorMessage = getFieldErrorMessage({ errors, fieldName, type });\n\n\tif (!fieldErrorMessage) {\n\t\treturn null;\n\t}\n\n\tconst errorMessageArray = toArray(fieldErrorMessage);\n\n\tif (errorMessageArray.length === 0) {\n\t\treturn null;\n\t}\n\n\tconst getRenderProps = (options: { index: number }): ErrorMessageRenderProps => {\n\t\tconst { index } = options;\n\n\t\treturn {\n\t\t\tclassName: cnMerge(className, classNames?.errorMessage),\n\t\t\t\"data-index\": index,\n\t\t\t\"data-part\": \"error-message\",\n\t\t\t\"data-scope\": \"form\",\n\t\t\t\"data-slot\": \"form-error-message\",\n\t\t\tid: formMessageId,\n\t\t\tref: (node) => {\n\t\t\t\tif (!node || errorParagraphRef.current) return;\n\n\t\t\t\terrorParagraphRef.current = node;\n\t\t\t},\n\t\t};\n\t};\n\n\tconst getRenderState = (options: { errorMessage: string; index: number }): ErrorMessageRenderState => {\n\t\tconst { errorMessage, index } = options;\n\n\t\treturn {\n\t\t\terrorMessage,\n\t\t\terrorMessageArray,\n\t\t\tindex,\n\t\t};\n\t};\n\n\tconst [ErrorMessageList] = getElementList(\"base\");\n\n\tconst WrapperComponent = \"div\";\n\n\tconst wrapperComponentProps = errorMessageArray.length > 1 && {\n\t\tclassName: cnMerge(\"flex flex-col\", classNames?.container),\n\t\t\"data-part\": \"error-message-container\",\n\t\t\"data-scope\": \"form\",\n\t\t\"data-slot\": \"form-error-message-container\",\n\t\tref: wrapperRef,\n\t};\n\n\tconst selectedChildren = typeof children === \"function\" ? children : renderItem;\n\n\treturn (\n\t\t<WrapperComponent {...wrapperComponentProps}>\n\t\t\t<ErrorMessageList\n\t\t\t\teach={errorMessageArray}\n\t\t\t\trenderItem={(errorMessage, index) => {\n\t\t\t\t\treturn selectedChildren({\n\t\t\t\t\t\tprops: getRenderProps({ index }),\n\t\t\t\t\t\tstate: getRenderState({ errorMessage, index }),\n\t\t\t\t\t});\n\t\t\t\t}}\n\t\t\t/>\n\t\t</WrapperComponent>\n\t);\n};\n\ntype FormErrorMessageProps<TControl, TFieldValues extends FieldValues> =\n\t| (TControl extends Control<infer TValues> ?\n\t\t\t{\n\t\t\t\tclassName?: string;\n\t\t\t\tcontrol?: never;\n\t\t\t\terrorField?: FieldPath<TValues>;\n\t\t\t\ttype?: \"regular\";\n\t\t\t}\n\t :\t{\n\t\t\t\tclassName?: string;\n\t\t\t\tcontrol?: Control<TFieldValues>; // == Here for type inference of errorField prop\n\t\t\t\terrorField?: FieldPath<TFieldValues>;\n\t\t\t\ttype?: \"regular\";\n\t\t\t})\n\t| {\n\t\t\tclassName?: string;\n\t\t\tcontrol?: never;\n\t\t\terrorField: string;\n\t\t\ttype: \"root\";\n\t };\n\nexport function FormErrorMessage<TControl, TFieldValues extends FieldValues = FieldValues>(\n\tprops: FormErrorMessageProps<TControl, TFieldValues>\n) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst { className, errorField = fieldContextValues?.name, type = \"regular\" } = props;\n\n\tconst { control } = useFormMethodsContext();\n\n\treturn (\n\t\t<FormErrorMessagePrimitive\n\t\t\tcontrol={control}\n\t\t\tfieldName={errorField as NonNullable<typeof errorField>}\n\t\t\ttype={type as \"root\"}\n\t\t\trenderItem={({ props: renderProps, state }) => (\n\t\t\t\t<p\n\t\t\t\t\tkey={state.errorMessage}\n\t\t\t\t\t{...renderProps}\n\t\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t\t\"text-shadcn-destructive text-[13px]\",\n\t\t\t\t\t\t\"data-[index=0]:mt-1\",\n\t\t\t\t\t\trenderProps.className,\n\t\t\t\t\t\tclassName\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t{state.errorMessage}\n\t\t\t\t</p>\n\t\t\t)}\n\t\t/>\n\t);\n}\n\ntype FormSubmitProps = InferProps<\"button\"> & { asChild?: boolean };\n\nexport function FormSubmit<TElement extends React.ElementType = \"button\">(\n\tprops: PolymorphicProps<TElement, FormSubmitProps>\n) {\n\tconst { as: Element = \"button\", asChild, children, type = \"submit\", ...restOfProps } = props;\n\n\tconst Component = asChild ? Slot.Root : Element;\n\n\treturn (\n\t\t<Component data-part=\"submit\" data-scope=\"form\" data-slot=\"form-submit\" type={type} {...restOfProps}>\n\t\t\t{children}\n\t\t</Component>\n\t);\n}\n\ntype GetFieldValue<TFieldPathOrPaths, TFieldValues extends FieldValues> =\n\tTFieldPathOrPaths extends Array<FieldPath<TFieldValues>> ?\n\t\tFieldPathValues<TFieldValues, TFieldPathOrPaths>\n\t: TFieldPathOrPaths extends FieldPath<TFieldValues> ? FieldPathValue<TFieldValues, TFieldPathOrPaths>\n\t: unknown;\n\ntype FormSubscribeToFieldValueRenderFn<TFieldValues extends FieldValues, TFieldPathOrPaths> = (props: {\n\tvalue: GetFieldValue<TFieldPathOrPaths, TFieldValues>;\n}) => React.ReactNode;\n\ntype FormSubscribeToFieldValueProps<\n\tTFieldValues extends FieldValues,\n\tTFieldPathOrPaths,\n> = DiscriminatedRenderProps<FormSubscribeToFieldValueRenderFn<TFieldValues, TFieldPathOrPaths>> & {\n\tcontrol: Control<TFieldValues>;\n\tname?: TFieldPathOrPaths;\n};\n\nexport function FormSubscribeToFieldValue<\n\tTFieldValues extends FieldValues,\n\tconst TFieldPathOrPaths extends Array<FieldPath<TFieldValues>> | FieldPath<TFieldValues>,\n>(props: FormSubscribeToFieldValueProps<TFieldValues, TFieldPathOrPaths>) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst { children, name = fieldContextValues?.name, render } = props;\n\n\tconst { control } = useFormMethodsContext();\n\n\tconst formValue = useWatch({ control, name: name as string }) as unknown;\n\n\tconst selectedChildren = typeof children === \"function\" ? children : render;\n\n\tconst fieldProps = { value: formValue };\n\n\tconst resolvedChildren = selectedChildren(fieldProps as never);\n\n\treturn resolvedChildren;\n}\n\ntype FormSubscribeToFormStateRenderFn<TFieldValues extends FieldValues> = (\n\tprops: UseFormStateReturn<TFieldValues>\n) => React.ReactNode;\n\ntype FormSubscribeToFormStateProps<TFieldValues extends FieldValues> = DiscriminatedRenderProps<\n\tFormSubscribeToFormStateRenderFn<TFieldValues>\n> & {\n\tcontrol?: Control<TFieldValues>;\n\tname?: Array<FieldPath<TFieldValues>> | FieldPath<TFieldValues>;\n};\n\nexport function FormSubscribeToFormState<TFieldValues extends FieldValues = FieldValues>(\n\tprops: FormSubscribeToFormStateProps<TFieldValues>\n) {\n\tconst fieldContextValues = useLaxFormFieldContext();\n\n\tconst { children, control, name = fieldContextValues?.name, render } = props;\n\n\tconst formState = useFormState({ control, name: name as FieldPath<TFieldValues> });\n\n\tconst selectedChildren = typeof children === \"function\" ? children : render;\n\n\tconst resolvedChildren = selectedChildren(formState as never);\n\n\treturn resolvedChildren;\n}\n","export {\n\tFormDescription as Description,\n\tFormErrorMessage as ErrorMessage,\n\tFormErrorMessagePrimitive as ErrorMessagePrimitive,\n\tFormField as Field,\n\tFormFieldContext as FieldContext,\n\tFormFieldController as FieldController,\n\tFormFieldControlledField as ControlledField,\n\tFormInput as Input,\n\tFormInputGroup as InputGroup,\n\tFormInputLeftItem as InputLeftItem,\n\tFormInputPrimitive as InputPrimitive,\n\tFormInputRightItem as InputRightItem,\n\tFormLabel as Label,\n\tFormRoot as Root,\n\tFormSelect as Select,\n\tFormSubmit as Submit,\n\tFormSubscribeToFieldValue as SubscribeToFieldValue,\n\tFormSubscribeToFormState as SubscribeToFormState,\n\tFormTextArea as TextArea,\n\tFormTextAreaPrimitive as TextAreaPrimitive,\n} from \"./form\";\n"],"mappings":";;;;;;;;;;;;;;AAEA,MAAa,iBAAiB,UAC7B,oBAAC;CAAI,OAAM;CAA6B,OAAM;CAAM,QAAO;CAAM,SAAQ;CAAY,GAAI;WACxF,oBAAC;EACA,MAAK;EACL,GAAE;;;AAKL,MAAa,eAAe,UAC3B,oBAAC;CAAI,OAAM;CAA6B,OAAM;CAAM,QAAO;CAAM,SAAQ;CAAY,GAAI;WACxF,oBAAC;EACA,MAAK;EACL,GAAE;;;;;;ACPL,MAAa,wBAAwB,YAIO;CAC3C,MAAM,EAAE,QAAQ,WAAW,MAAM,GAAG;AAEpC,KAAI,CAAC,aAAa,CAAC,UAAU,OAAO,KAAK,QAAQ,WAAW,EAAG;AAE/D,KAAI,SAAS,OACZ,QAAO,OAAO,OAAO,YAAY;CAIlC,MAAM,YAAY,UAAU,SAAS,OAAO,UAAU,MAAM,OAAO;AAGnE,KAAI,CAAC,WAAW;EACf,MAAMA,iBAAe,OAAO,YAAY;AAExC,SAAOA;CACP;CAED,IAAI,iBAAiB;AAErB,MAAK,MAAM,QAAQ,WAAW;EAC7B,MAAM,eAAe,eAAe;AAEpC,MAAI,CAAC,SAAS,cAAe;AAE7B,mBAAiB;CACjB;CAED,MAAM,eAAe,eAAe;AAEpC,QAAO;AACP;AAED,MAAa,cAAc,YAKrB;CACL,MAAM,EAAE,YAAY,UAAU,iBAAiB,aAAa,GAAG;AAE/D,KAAI,CAAC,YACJ,QAAO;AAGR,KAAI,gBAAgB,MAAM;EACzB,MAAM,iBAAiB;GACtB,QAAQ,cAAc,eAAe,EACpC,WAAW,QAAQ,aAAa,YAAY,UAC5C;GAED,MAAM,cAAc,aAAa,EAChC,WAAW,QAAQ,aAAa,YAAY,UAC5C;GACD;AAED,SAAO,eAAe;CACtB;AAED,KAAI,YAAY,WACf,QA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