@zayne-labs/ui-react 0.9.18 → 0.9.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/css/theme.css +7 -1
  2. package/dist/esm/card-BBTJxmWt.js +95 -0
  3. package/dist/esm/card-BBTJxmWt.js.map +1 -0
  4. package/dist/esm/{carousel-Dznupnx8.js → carousel-Dvp-qURP.js} +2 -2
  5. package/dist/esm/{carousel-Dznupnx8.js.map → carousel-Dvp-qURP.js.map} +1 -1
  6. package/dist/esm/components/common/await/index.d.ts +5 -5
  7. package/dist/esm/components/common/await/index.js +1 -1
  8. package/dist/esm/components/common/error-boundary/index.d.ts +1 -1
  9. package/dist/esm/components/common/for/index.d.ts +1 -1
  10. package/dist/esm/components/common/index.d.ts +10 -10
  11. package/dist/esm/components/common/index.js +3 -3
  12. package/dist/esm/components/common/show/index.d.ts +1 -1
  13. package/dist/esm/components/common/show/index.js +2 -2
  14. package/dist/esm/components/common/slot/index.d.ts +1 -1
  15. package/dist/esm/components/common/suspense-with-boundary/index.d.ts +2 -2
  16. package/dist/esm/components/common/switch/index.d.ts +1 -1
  17. package/dist/esm/components/common/switch/index.js +2 -2
  18. package/dist/esm/components/common/teleport/index.d.ts +1 -1
  19. package/dist/esm/components/ui/card/index.d.ts +2 -2
  20. package/dist/esm/components/ui/card/index.js +2 -2
  21. package/dist/esm/components/ui/carousel/index.d.ts +1 -1
  22. package/dist/esm/components/ui/carousel/index.js +4 -4
  23. package/dist/esm/components/ui/drag-scroll/index.d.ts +1 -1
  24. package/dist/esm/components/ui/drop-zone/index.d.ts +2 -2
  25. package/dist/esm/components/ui/drop-zone/index.js +4 -4
  26. package/dist/esm/components/ui/form/index.d.ts +1 -1
  27. package/dist/esm/components/ui/form/index.js +2 -2
  28. package/dist/esm/components/ui/index.d.ts +6 -6
  29. package/dist/esm/components/ui/index.js +7 -7
  30. package/dist/esm/{drop-zone-_YK9C3Xj.js → drop-zone-Beip1k4x.js} +2 -2
  31. package/dist/esm/{drop-zone-_YK9C3Xj.js.map → drop-zone-Beip1k4x.js.map} +1 -1
  32. package/dist/esm/{form-DytCfL6R.js → form-6RV0u4YT.js} +4 -4
  33. package/dist/esm/form-6RV0u4YT.js.map +1 -0
  34. package/dist/esm/{getSlot-BIcGgBwN.js → getSlot-D1_uG-Ym.js} +2 -2
  35. package/dist/esm/{getSlot-BIcGgBwN.js.map → getSlot-D1_uG-Ym.js.map} +1 -1
  36. package/dist/esm/{getSlotMap-DA_uhXqU.d.ts → getSlotMap-DZlQN8--.d.ts} +2 -3
  37. package/dist/esm/{index-DnaUCh8d.d.ts → index-B3N6YbN8.d.ts} +2 -3
  38. package/dist/esm/{index-ASoFjmZ6.d.ts → index-BilTdK_M.d.ts} +7 -10
  39. package/dist/esm/{index-BSJ30pGj.d.ts → index-BsjcsNQh.d.ts} +4 -5
  40. package/dist/esm/{index-1UCPJf7B.d.ts → index-BwnMUHzm.d.ts} +2 -5
  41. package/dist/esm/{index-CqlM1M0j.d.ts → index-CFNg1R-m.d.ts} +5 -6
  42. package/dist/esm/{index-C0XZoIZD.d.ts → index-CGI7EVlK.d.ts} +2 -5
  43. package/dist/esm/{index-DQ1yFGd2.d.ts → index-CIM4YPg5.d.ts} +4 -6
  44. package/dist/esm/{index-BhpBx8dH.d.ts → index-CNE9Cime.d.ts} +2 -4
  45. package/dist/esm/{index-D-j2Cn1J.d.ts → index-DRiwJkJC.d.ts} +4 -5
  46. package/dist/esm/{index-BC0r1cBF.d.ts → index-DT8F8QKc.d.ts} +4 -7
  47. package/dist/esm/{index--1COprHP.d.ts → index-UX3DaMVe.d.ts} +2 -5
  48. package/dist/esm/{index-BuSQsDCX.d.ts → index-XYFc-mmy.d.ts} +4 -6
  49. package/dist/esm/{index-TBkPiipk.d.ts → index-YFi-sIuR.d.ts} +5 -9
  50. package/dist/esm/{index-CTZr4PTO.d.ts → index-gT9tVHv1.d.ts} +2 -3
  51. package/dist/esm/lib/utils/index.d.ts +2 -2
  52. package/dist/esm/lib/utils/index.js +1 -1
  53. package/dist/esm/{show-BgYrfIxJ.js → show-DNPzdLi-.js} +2 -2
  54. package/dist/esm/{show-BgYrfIxJ.js.map → show-DNPzdLi-.js.map} +1 -1
  55. package/dist/esm/{switch-PF5xTJfr.js → switch-B2gKl94R.js} +2 -2
  56. package/dist/esm/{switch-PF5xTJfr.js.map → switch-B2gKl94R.js.map} +1 -1
  57. package/dist/style.css +160 -8
  58. package/package.json +10 -10
  59. package/dist/esm/card-DRjs-vtv.js +0 -54
  60. package/dist/esm/card-DRjs-vtv.js.map +0 -1
  61. package/dist/esm/form-DytCfL6R.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"drop-zone-_YK9C3Xj.js","names":["file: File | FileMeta","file: File","disallowPreviewForNonImageFiles: boolean","fileWithPreview: FileWithPreview | undefined","props?: UseDropZoneProps","value: boolean","addFiles: DropZoneActions[\"addFiles\"]","filesWithPreview: FileWithPreview[]","clearFiles: DropZoneActions[\"clearFiles\"]","removeFile: DropZoneActions[\"removeFile\"]","clearErrors: DropZoneActions[\"clearErrors\"]","handleFileUpload: DropZoneActions[\"handleFileUpload\"]","handleDragEnter: DropZoneActions[\"handleDragEnter\"]","handleDragOver: DropZoneActions[\"handleDragOver\"]","handleDragLeave: DropZoneActions[\"handleDragLeave\"]","openFilePicker: DropZoneActions[\"openFilePicker\"]","getContainerProps: UseDropZoneResult[\"getContainerProps\"]","getInputProps: UseDropZoneResult[\"getInputProps\"]","props: DropZoneRootProps","ReactFragment","props: DropZoneInputProps","Component","props: PolymorphicProps<TElement, DropZoneContainerProps>","props: { children: RenderPropFn }"],"sources":["../../src/components/ui/drop-zone/drop-context.ts","../../src/components/ui/drop-zone/utils.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 type { UseDropZoneResult } from \"./use-drop-zone\";\n\nconst [DropZoneContextProvider, useDropZoneContext] = createCustomContext<UseDropZoneResult>({\n\thookName: \"useDropZoneContext\",\n\tname: \"DropZoneContext\",\n\tproviderName: \"DropZoneRoot\",\n});\n\nexport { DropZoneContextProvider, useDropZoneContext };\n","import { type FileMeta, createImagePreview } from \"@zayne-labs/toolkit-core\";\nimport { isFile } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { FileWithPreview } from \"./use-drop-zone\";\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) => {\n\tif (disallowPreviewForNonImageFiles && !file.type.startsWith(\"image/\")) return;\n\n\treturn createImagePreview(file);\n};\n\nexport const clearObjectURL = (\n\tfileWithPreview: FileWithPreview | undefined,\n\tdisallowPreviewForNonImageFiles: boolean\n) => {\n\tif (!isFile(fileWithPreview?.file)) return;\n\n\tif (disallowPreviewForNonImageFiles && !fileWithPreview.file.type.startsWith(\"image/\")) return;\n\n\tif (!fileWithPreview.preview) return;\n\n\tURL.revokeObjectURL(fileWithPreview.preview);\n};\n","import { cnMerge } from \"@/lib/utils/cn\";\nimport { dataAttr } from \"@zayne-labs/toolkit-core\";\nimport {\n\ttype FileMeta,\n\ttype FileValidationErrorContext,\n\ttype FileValidationOptions,\n\thandleFileValidation,\n\ttoArray,\n} from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport {\n\ttype InferProps,\n\tcomposeRefs,\n\tcomposeTwoEventHandlers,\n\tmergeTwoProps,\n} from \"@zayne-labs/toolkit-react/utils\";\nimport { type Prettify, isString } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport { clearObjectURL, createObjectURL, generateUniqueId } from \"./utils\";\n\nexport type ContainerProps = InferProps<HTMLElement> & {\n\tclassNames?: {\n\t\tbase?: string;\n\t\tisDragging?: string;\n\t};\n};\n\nexport type InputProps = InferProps<\"input\">;\n\nexport type FileWithPreview = {\n\t/**\n\t * File object or file metadata\n\t */\n\tfile: File | FileMeta;\n\t/**\n\t * Unique ID for the file\n\t */\n\tid: string;\n\t/**\n\t * Preview URL for the file\n\t * - Will be undefined if `disallowPreviewForNonImageFiles` is set to `true` and the file is not an image\n\t * - Can also be undefined if `URL.createObjectURL` fails\n\t */\n\tpreview: string | undefined;\n};\n\nexport type DropZoneState = {\n\t/**\n\t * List of validation errors\n\t */\n\terrors: FileValidationErrorContext[];\n\t/**\n\t * List of files with their preview URLs and unique IDs\n\t */\n\tfilesWithPreview: FileWithPreview[];\n\t/**\n\t * Whether or not a file is currently being dragged over the drop zone\n\t */\n\tisDragging: boolean;\n};\n\ntype ChangeOrDragEvent = React.ChangeEvent<HTMLInputElement> | React.DragEvent<HTMLElement>;\n\nexport type DropZoneActions = {\n\taddFiles: (fileList: File[] | FileList | null, event?: ChangeOrDragEvent) => void;\n\tclearErrors: () => void;\n\tclearFiles: () => void;\n\thandleDragEnter: (event: React.DragEvent<HTMLElement>) => void;\n\thandleDragLeave: (event: React.DragEvent<HTMLElement>) => void;\n\thandleDragOver: (event: React.DragEvent<HTMLElement>) => void;\n\thandleFileUpload: (event: ChangeOrDragEvent) => void;\n\topenFilePicker: () => void;\n\tremoveFile: (fileToRemoveOrId: string | FileWithPreview) => void;\n};\n\nexport type UseDropZoneResult = {\n\tdropZoneActions: DropZoneActions;\n\tdropZoneState: DropZoneState;\n\tgetContainerProps: (containerProps?: ContainerProps) => ContainerProps;\n\tgetInputProps: (inputProps?: InputProps) => InputProps;\n\tinputRef: React.RefObject<HTMLInputElement | null>;\n};\n\nexport type UseDropZoneProps = {\n\t/**\n\t * Allowed file types to be uploaded.\n\t */\n\tallowedFileTypes?: string[];\n\n\t/**\n\t * CSS classes to apply to the various parts of the drop zone\n\t */\n\tclassNames?: Prettify<ContainerProps[\"classNames\"] & { input?: string }>;\n\n\t/**\n\t * Whether to disallow duplicate files\n\t * @default true\n\t */\n\tdisallowDuplicates?: boolean;\n\n\t/**\n\t * Whether to disallow preview for non-image files\n\t * @default true\n\t */\n\tdisallowPreviewForNonImageFiles?: boolean;\n\n\t/**\n\t * Extra props to pass to the container element\n\t */\n\textraContainerProps?: ContainerProps;\n\n\t/**\n\t * Extra props to pass to the input element\n\t */\n\textraInputProps?: InputProps;\n\n\t/**\n\t * Initial files to populate the drop zone\n\t */\n\tinitialFiles?: FileMeta | FileMeta[] | null;\n\n\t/**\n\t * Maximum number of files that can be uploaded.\n\t */\n\tmaxFileCount?: number;\n\n\t/**\n\t * Maximum file size in MB\n\t */\n\tmaxFileSize?: number;\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: { filesWithPreview: FileWithPreview[] }) => void;\n\n\t/**\n\t * Callback function to be called when the render props change\n\t */\n\tonRenderPropsChange?: (props: UseDropZoneResult) => void;\n\n\t/**\n\t * Callback function to be called when new files are uploaded\n\t */\n\tonUpload?: (context: { event: ChangeOrDragEvent; filesWithPreview: FileWithPreview[] }) => void;\n\n\t/**\n\t * Callback function to be called on each file upload as they occur\n\t */\n\tonUploadError?: FileValidationOptions[\"onError\"];\n\n\t/**\n\t * Callback function to be called once after all file upload errors have occurred\n\t */\n\tonUploadErrors?: FileValidationOptions[\"onErrors\"];\n\n\t/**\n\t * Callback function to be called on file upload success\n\t */\n\tonUploadSuccess?: FileValidationOptions[\"onSuccess\"];\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\tvalidator?: NonNullable<FileValidationOptions[\"validationSettings\"]>[\"validator\"];\n\n\t/**\n\t * Custom validation function that runs after all file validation has occurred\n\t */\n\tvalidatorForAllFiles?: FileValidationOptions[\"validatorForAllFiles\"];\n\n\t/**\n\t * Whether to allow the default file picker via the file input element\n\t * @default true\n\t */\n\twithDefaultFilePicker?: boolean;\n};\n\nexport const useDropZone = (props?: UseDropZoneProps): UseDropZoneResult => {\n\tconst {\n\t\tallowedFileTypes,\n\t\tclassNames,\n\t\tdisallowDuplicates = true,\n\t\tdisallowPreviewForNonImageFiles = true,\n\t\textraContainerProps,\n\t\textraInputProps,\n\t\tinitialFiles,\n\t\tmaxFileCount,\n\t\tmaxFileSize,\n\t\tmultiple,\n\t\tonFilesChange,\n\t\tonRenderPropsChange,\n\t\tonUpload,\n\t\tonUploadError,\n\t\tonUploadErrors,\n\t\tonUploadSuccess,\n\t\tvalidator,\n\t\tvalidatorForAllFiles,\n\t\twithDefaultFilePicker = true,\n\t} = props ?? {};\n\n\tconst inputRef = useRef<HTMLInputElement>(null);\n\n\tconst initialFileArray = toArray(initialFiles).filter(Boolean);\n\n\tconst [dropZoneState, setDropZoneState] = useState<DropZoneState>({\n\t\terrors: [],\n\t\tfilesWithPreview: 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\tisDragging: false,\n\t});\n\n\tconst toggleIsDragging = (value: boolean) => {\n\t\tsetDropZoneState((prevState) => ({ ...prevState, isDragging: value }));\n\t};\n\n\tconst addFiles: DropZoneActions[\"addFiles\"] = useCallbackRef((fileList, event) => {\n\t\tif (!fileList || fileList.length === 0) {\n\t\t\tconsole.warn(\"No file selected!\");\n\t\t\treturn;\n\t\t}\n\n\t\t// Clear existing errors when new files are uploaded\n\t\tclearErrors();\n\n\t\t// In single file mode, clear existing files first\n\t\tif (!multiple) {\n\t\t\tclearFiles();\n\t\t}\n\n\t\tconst { errors, validFiles } = handleFileValidation({\n\t\t\texistingFiles: dropZoneState.filesWithPreview.map((fileWithPreview) => fileWithPreview.file),\n\t\t\tnewFiles: fileList,\n\t\t\tonError: onUploadError,\n\t\t\tonErrors: onUploadErrors,\n\t\t\tonSuccess: onUploadSuccess,\n\t\t\tvalidationSettings: {\n\t\t\t\tallowedFileTypes,\n\t\t\t\tdisallowDuplicates,\n\t\t\t\tmaxFileCount,\n\t\t\t\tmaxFileSize,\n\t\t\t\tvalidator,\n\t\t\t},\n\t\t\tvalidatorForAllFiles,\n\t\t});\n\n\t\tif (validFiles.length === 0) {\n\t\t\tsetDropZoneState((prevState) => ({ ...prevState, errors }));\n\t\t\treturn;\n\t\t}\n\n\t\tconst filesWithPreview: FileWithPreview[] = validFiles.map((file) => ({\n\t\t\tfile,\n\t\t\tid: generateUniqueId(file),\n\t\t\tpreview: createObjectURL(file, disallowPreviewForNonImageFiles),\n\t\t}));\n\n\t\t// == Only call onUpload callback if event is provided, which indicates that new files were uploaded from an event handler\n\n\t\tif (event) {\n\t\t\tonUpload?.({ event, filesWithPreview });\n\t\t}\n\n\t\tconst newFileUploadState = {\n\t\t\t...dropZoneState,\n\t\t\terrors,\n\t\t\t...(event?.type === \"drop\" && { isDragging: false }),\n\t\t\tfilesWithPreview: multiple\n\t\t\t\t? [...dropZoneState.filesWithPreview, ...filesWithPreview]\n\t\t\t\t: filesWithPreview,\n\t\t} satisfies DropZoneState;\n\n\t\tonFilesChange?.({ filesWithPreview: newFileUploadState.filesWithPreview });\n\n\t\tsetDropZoneState(newFileUploadState);\n\n\t\t// == Reset input value after adding files\n\t\tinputRef.current && (inputRef.current.value = \"\");\n\t});\n\n\tconst clearFiles: DropZoneActions[\"clearFiles\"] = useCallbackRef(() => {\n\t\t// == Clean up object URLs if any\n\t\tdropZoneState.filesWithPreview.forEach((fileWithPreview) =>\n\t\t\tclearObjectURL(fileWithPreview, disallowPreviewForNonImageFiles)\n\t\t);\n\n\t\tconst newFileUploadState = {\n\t\t\t...dropZoneState,\n\t\t\terrors: [],\n\t\t\tfilesWithPreview: [],\n\t\t} satisfies DropZoneState;\n\n\t\tonFilesChange?.({ filesWithPreview: newFileUploadState.filesWithPreview });\n\n\t\tsetDropZoneState(newFileUploadState);\n\n\t\t// == Reset input value after clearing files\n\t\tinputRef.current && (inputRef.current.value = \"\");\n\t});\n\n\tconst removeFile: DropZoneActions[\"removeFile\"] = useCallbackRef((fileToRemoveOrId) => {\n\t\tconst actualFileToRemove = isString(fileToRemoveOrId)\n\t\t\t? dropZoneState.filesWithPreview.find((file) => file.id === fileToRemoveOrId)\n\t\t\t: fileToRemoveOrId;\n\n\t\tif (!actualFileToRemove) return;\n\n\t\tclearObjectURL(actualFileToRemove, disallowPreviewForNonImageFiles);\n\n\t\tconst newFilesWithPreview = dropZoneState.filesWithPreview.filter(\n\t\t\t(file) => file.id !== actualFileToRemove.id\n\t\t);\n\n\t\tonFilesChange?.({ filesWithPreview: newFilesWithPreview });\n\n\t\tsetDropZoneState({\n\t\t\t...dropZoneState,\n\t\t\terrors: [],\n\t\t\tfilesWithPreview: newFilesWithPreview,\n\t\t});\n\t});\n\n\tconst clearErrors: DropZoneActions[\"clearErrors\"] = useCallbackRef(() => {\n\t\tsetDropZoneState((prevState) => ({ ...prevState, errors: [] }));\n\t});\n\n\tconst handleFileUpload: DropZoneActions[\"handleFileUpload\"] = useCallbackRef((event) => {\n\t\tif (inputRef.current?.disabled) return;\n\n\t\tif (event.type === \"drop\") {\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t}\n\n\t\tconst fileList =\n\t\t\tevent.type === \"drop\"\n\t\t\t\t? (event as React.DragEvent).dataTransfer.files\n\t\t\t\t: (event as React.ChangeEvent<HTMLInputElement>).target.files;\n\n\t\t// == In single file mode, only use the first file\n\t\tif (!multiple) {\n\t\t\tconst firstFile = fileList?.[0];\n\n\t\t\tfirstFile && addFiles([firstFile], event);\n\n\t\t\treturn;\n\t\t}\n\n\t\taddFiles(fileList, event);\n\t});\n\n\tconst handleDragEnter: DropZoneActions[\"handleDragEnter\"] = useCallbackRef((event) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\t\ttoggleIsDragging(true);\n\t});\n\n\tconst handleDragOver: DropZoneActions[\"handleDragOver\"] = useCallbackRef((event) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\t\ttoggleIsDragging(true);\n\t});\n\n\tconst handleDragLeave: DropZoneActions[\"handleDragLeave\"] = useCallbackRef((event) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\t\ttoggleIsDragging(false);\n\t});\n\n\tconst openFilePicker: DropZoneActions[\"openFilePicker\"] = useCallbackRef(() => {\n\t\tinputRef.current?.click();\n\t});\n\n\tconst getContainerProps: UseDropZoneResult[\"getContainerProps\"] = useCallback(\n\t\t(containerProps) => {\n\t\t\tconst mergedContainerProps = mergeTwoProps(extraContainerProps, 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\tmergedContainerProps.className,\n\t\t\t\t\tclassNames?.base,\n\t\t\t\t\tdropZoneState.isDragging && [\n\t\t\t\t\t\t\"opacity-60\",\n\t\t\t\t\t\tclassNames?.isDragging,\n\t\t\t\t\t\tcontainerProps?.classNames?.isDragging,\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\t\"data-dragging\": dataAttr(dropZoneState.isDragging),\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(handleDragEnter, mergedContainerProps.onDragEnter),\n\t\t\t\tonDragLeave: composeTwoEventHandlers(handleDragLeave, mergedContainerProps.onDragLeave),\n\t\t\t\tonDragOver: composeTwoEventHandlers(handleDragOver, mergedContainerProps.onDragOver),\n\t\t\t\tonDrop: composeTwoEventHandlers(handleFileUpload, mergedContainerProps.onDrop),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tclassNames?.base,\n\t\t\tclassNames?.isDragging,\n\t\t\textraContainerProps,\n\t\t\tdropZoneState.isDragging,\n\t\t\thandleDragEnter,\n\t\t\thandleDragLeave,\n\t\t\thandleDragOver,\n\t\t\thandleFileUpload,\n\t\t]\n\t);\n\n\tconst getInputProps: UseDropZoneResult[\"getInputProps\"] = useCallback(\n\t\t(inputProps) => {\n\t\t\tconst mergedInputProps = mergeTwoProps(extraInputProps, 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\twithDefaultFilePicker ? \"absolute inset-0 z-[100] cursor-pointer opacity-0\" : \"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-dragging\": dataAttr(dropZoneState.isDragging),\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(handleFileUpload, 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\tallowedFileTypes,\n\t\t\tclassNames?.input,\n\t\t\textraInputProps,\n\t\t\tdropZoneState.isDragging,\n\t\t\thandleFileUpload,\n\t\t\tmultiple,\n\t\t\twithDefaultFilePicker,\n\t\t]\n\t);\n\n\tconst savedOnRenderPropsChange = useCallbackRef(onRenderPropsChange);\n\n\tconst dropZoneResult = useMemo(() => {\n\t\tconst propsForRenderFn = {\n\t\t\tdropZoneActions: {\n\t\t\t\taddFiles,\n\t\t\t\tclearErrors,\n\t\t\t\tclearFiles,\n\t\t\t\thandleDragEnter,\n\t\t\t\thandleDragLeave,\n\t\t\t\thandleDragOver,\n\t\t\t\thandleFileUpload,\n\t\t\t\topenFilePicker,\n\t\t\t\tremoveFile,\n\t\t\t},\n\t\t\tdropZoneState,\n\t\t\tgetContainerProps,\n\t\t\tgetInputProps,\n\t\t\tinputRef,\n\t\t} satisfies UseDropZoneResult;\n\n\t\tsavedOnRenderPropsChange(propsForRenderFn);\n\n\t\treturn propsForRenderFn;\n\t}, [\n\t\tsavedOnRenderPropsChange,\n\t\taddFiles,\n\t\tclearErrors,\n\t\tclearFiles,\n\t\tdropZoneState,\n\t\tgetInputProps,\n\t\tgetContainerProps,\n\t\thandleDragEnter,\n\t\thandleDragLeave,\n\t\thandleDragOver,\n\t\thandleFileUpload,\n\t\topenFilePicker,\n\t\tremoveFile,\n\t]);\n\n\treturn dropZoneResult;\n};\n","\"use client\";\n\nimport * as React from \"react\";\n\nimport { Show, Slot } from \"@/components/common\";\nimport { type GetSlotComponentProps, getSlotMap, withSlotNameAndSymbol } from \"@/lib/utils/getSlotMap\";\nimport type { DiscriminatedRenderProps, PolymorphicProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { isArray, isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Fragment as ReactFragment, isValidElement } from \"react\";\nimport { DropZoneContextProvider, useDropZoneContext } from \"./drop-context\";\nimport {\n\ttype ContainerProps,\n\ttype InputProps,\n\ttype UseDropZoneProps,\n\ttype UseDropZoneResult,\n\tuseDropZone,\n} from \"./use-drop-zone\";\n\nexport type DropZoneRenderPropType = DiscriminatedRenderProps<\n\tReact.ReactNode | ((props: UseDropZoneResult) => React.ReactNode)\n>;\n\nexport type DropZoneRootProps = DropZoneRenderPropType\n\t& UseDropZoneProps & {\n\t\t/**\n\t\t * Controls whether to include internal elements (root and input) or not.\n\t\t */\n\t\twithInternalElements?: boolean;\n\t};\n\nexport function DropZoneRoot(props: DropZoneRootProps) {\n\tconst { children, render, withInternalElements = true, ...restOfProps } = props;\n\n\tconst dropZone = useDropZone(restOfProps);\n\n\tconst ContainerComponent = withInternalElements ? DropZoneContainer : ReactFragment;\n\tconst InputComponent = withInternalElements ? DropZoneInput : ReactFragment;\n\n\tconst selectedChildren = children ?? render;\n\n\tconst resolvedChildren = isFunction(selectedChildren) ? selectedChildren(dropZone) : selectedChildren;\n\n\tconst couldChildrenContainSlots =\n\t\tisArray(resolvedChildren)\n\t\t|| (isValidElement(resolvedChildren) && resolvedChildren.type === ReactFragment);\n\n\tconst slots =\n\t\twithInternalElements && couldChildrenContainSlots\n\t\t\t? getSlotMap<SlotComponentProps>(resolvedChildren)\n\t\t\t: ({ default: resolvedChildren } as ReturnType<typeof getSlotMap<SlotComponentProps>>);\n\n\treturn (\n\t\t<DropZoneContextProvider value={dropZone}>\n\t\t\t<ContainerComponent>\n\t\t\t\t<InputComponent />\n\n\t\t\t\t{slots.default}\n\t\t\t</ContainerComponent>\n\n\t\t\t{slots.preview}\n\t\t</DropZoneContextProvider>\n\t);\n}\n\ntype DropZoneInputProps = InputProps & { asChild?: boolean };\n\nexport function DropZoneInput(props: DropZoneInputProps) {\n\tconst { asChild, ...restOfProps } = props;\n\n\tconst dropZoneContext = useDropZoneContext();\n\n\tconst Component = asChild ? Slot.Root : \"input\";\n\n\treturn <Component {...dropZoneContext.getInputProps(restOfProps)} />;\n}\n\ntype DropZoneContainerProps = ContainerProps & { 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 dropZoneContext = useDropZoneContext();\n\n\tconst Component = asChild ? Slot.Root : Element;\n\n\treturn <Component {...dropZoneContext.getContainerProps(restOfProps)} />;\n}\n\ntype RenderPropFn = (props: UseDropZoneResult) => React.ReactNode;\n\ntype SlotComponentProps = GetSlotComponentProps<\"preview\", React.ReactNode | RenderPropFn>;\n\nexport function DropZoneContext(props: { children: RenderPropFn }) {\n\tconst { children } = props;\n\n\tconst dropZoneContext = useDropZoneContext();\n\n\treturn children(dropZoneContext);\n}\n\nexport const DropZoneImagePreview = withSlotNameAndSymbol<SlotComponentProps>(\"preview\", (props) => {\n\tconst { children } = props;\n\n\tif (isFunction(children)) {\n\t\treturn (\n\t\t\t<DropZoneContext>\n\t\t\t\t{(dropZoneCtx) => (\n\t\t\t\t\t<Show.Root when={dropZoneCtx.dropZoneState.filesWithPreview.length > 0}>\n\t\t\t\t\t\t{children(dropZoneCtx)}\n\t\t\t\t\t</Show.Root>\n\t\t\t\t)}\n\t\t\t</DropZoneContext>\n\t\t);\n\t}\n\n\treturn children;\n});\n","export {\n\tDropZoneRoot as Root,\n\tDropZoneImagePreview as ImagePreview,\n\tDropZoneContext as Context,\n\tDropZoneInput as Input,\n\tDropZoneContainer as Container,\n} from \"./drop-zone\";\n"],"mappings":";;;;;;;;;;;;;AAGA,MAAM,CAAC,yBAAyB,mBAAmB,GAAG,oBAAuC;CAC5F,UAAU;CACV,MAAM;CACN,cAAc;AACd,EAAC;;;;ACHF,MAAa,mBAAmB,CAACA,SAAkC;AAClE,MAAK,OAAO,KAAK,CAChB,QAAO,KAAK;AAGb,SAAQ,EAAE,KAAK,KAAK,IAAI,KAAK,MAAM,YAAY,KAAK,CAAC,CAAC,IAAI,OAAO,YAAY,CAAC,MAAM,GAAG,EAAE,CAAC;AAC1F;AAED,MAAa,kBAAkB,CAACC,MAAYC,oCAA6C;AACxF,KAAI,oCAAoC,KAAK,KAAK,WAAW,SAAS,CAAE;AAExE,QAAO,mBAAmB,KAAK;AAC/B;AAED,MAAa,iBAAiB,CAC7BC,iBACAD,oCACI;AACJ,MAAK,OAAO,iBAAiB,KAAK,CAAE;AAEpC,KAAI,oCAAoC,gBAAgB,KAAK,KAAK,WAAW,SAAS,CAAE;AAExF,MAAK,gBAAgB,QAAS;AAE9B,KAAI,gBAAgB,gBAAgB,QAAQ;AAC5C;;;;AC4JD,MAAa,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M,WACa,EAEpB,MAAM;GACkB;AAE3B;AAID,SAAgB,cAAcC,OAA2B;CACxD,MAAM,EAAE,QAAS,GAAG,aAAa,GAAG;CAEpC,MAAM,kBAAkB,oBAAoB;CAE5C,MAAMC,cAAY,qBAAsB;AAExC,wBAAO,IAACA,eAAU,GAAI,gBAAgB,cAAc,YAAY,GAAI;AACpE;AAID,SAAgB,kBACfC,OACC;CACD,MAAM,EAAE,IAAI,UAAU,OAAO,QAAS,GAAG,aAAa,GAAG;CAEzD,MAAM,kBAAkB,oBAAoB;CAE5C,MAAMD,cAAY,qBAAsB;AAExC,wBAAO,IAACA,eAAU,GAAI,gBAAgB,kBAAkB,YAAY,GAAI;AACxE;AAMD,SAAgB,gBAAgBE,OAAmC;CAClE,MAAM,EAAE,UAAU,GAAG;CAErB,MAAM,kBAAkB,oBAAoB;AAE5C,QAAO,SAAS,gBAAgB;AAChC;AAED,MAAa,uBAAuB,sBAA0C,WAAW,CAAC,UAAU;CACnG,MAAM,EAAE,UAAU,GAAG;AAErB,KAAI,WAAW,SAAS,CACvB,wBACC,IAAC,6BACC,CAAC,gCACD;EAAW,MAAM,YAAY,cAAc,iBAAiB,SAAS;YACnE,SAAS,YAAY;GACX,GAEI;AAIpB,QAAO;AACP,EAAC"}
1
+ {"version":3,"file":"drop-zone-Beip1k4x.js","names":["file: File | FileMeta","file: File","disallowPreviewForNonImageFiles: boolean","fileWithPreview: FileWithPreview | undefined","props?: UseDropZoneProps","value: boolean","addFiles: DropZoneActions[\"addFiles\"]","filesWithPreview: FileWithPreview[]","clearFiles: DropZoneActions[\"clearFiles\"]","removeFile: DropZoneActions[\"removeFile\"]","clearErrors: DropZoneActions[\"clearErrors\"]","handleFileUpload: DropZoneActions[\"handleFileUpload\"]","handleDragEnter: DropZoneActions[\"handleDragEnter\"]","handleDragOver: DropZoneActions[\"handleDragOver\"]","handleDragLeave: DropZoneActions[\"handleDragLeave\"]","openFilePicker: DropZoneActions[\"openFilePicker\"]","getContainerProps: UseDropZoneResult[\"getContainerProps\"]","getInputProps: UseDropZoneResult[\"getInputProps\"]","props: DropZoneRootProps","ReactFragment","props: DropZoneInputProps","Component","props: PolymorphicProps<TElement, DropZoneContainerProps>","props: { children: RenderPropFn }"],"sources":["../../src/components/ui/drop-zone/drop-context.ts","../../src/components/ui/drop-zone/utils.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 type { UseDropZoneResult } from \"./use-drop-zone\";\n\nconst [DropZoneContextProvider, useDropZoneContext] = createCustomContext<UseDropZoneResult>({\n\thookName: \"useDropZoneContext\",\n\tname: \"DropZoneContext\",\n\tproviderName: \"DropZoneRoot\",\n});\n\nexport { DropZoneContextProvider, useDropZoneContext };\n","import { type FileMeta, createImagePreview } from \"@zayne-labs/toolkit-core\";\nimport { isFile } from \"@zayne-labs/toolkit-type-helpers\";\nimport type { FileWithPreview } from \"./use-drop-zone\";\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) => {\n\tif (disallowPreviewForNonImageFiles && !file.type.startsWith(\"image/\")) return;\n\n\treturn createImagePreview(file);\n};\n\nexport const clearObjectURL = (\n\tfileWithPreview: FileWithPreview | undefined,\n\tdisallowPreviewForNonImageFiles: boolean\n) => {\n\tif (!isFile(fileWithPreview?.file)) return;\n\n\tif (disallowPreviewForNonImageFiles && !fileWithPreview.file.type.startsWith(\"image/\")) return;\n\n\tif (!fileWithPreview.preview) return;\n\n\tURL.revokeObjectURL(fileWithPreview.preview);\n};\n","import { cnMerge } from \"@/lib/utils/cn\";\nimport { dataAttr } from \"@zayne-labs/toolkit-core\";\nimport {\n\ttype FileMeta,\n\ttype FileValidationErrorContext,\n\ttype FileValidationOptions,\n\thandleFileValidation,\n\ttoArray,\n} from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport {\n\ttype InferProps,\n\tcomposeRefs,\n\tcomposeTwoEventHandlers,\n\tmergeTwoProps,\n} from \"@zayne-labs/toolkit-react/utils\";\nimport { type Prettify, isString } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport { clearObjectURL, createObjectURL, generateUniqueId } from \"./utils\";\n\nexport type ContainerProps = InferProps<HTMLElement> & {\n\tclassNames?: {\n\t\tbase?: string;\n\t\tisDragging?: string;\n\t};\n};\n\nexport type InputProps = InferProps<\"input\">;\n\nexport type FileWithPreview = {\n\t/**\n\t * File object or file metadata\n\t */\n\tfile: File | FileMeta;\n\t/**\n\t * Unique ID for the file\n\t */\n\tid: string;\n\t/**\n\t * Preview URL for the file\n\t * - Will be undefined if `disallowPreviewForNonImageFiles` is set to `true` and the file is not an image\n\t * - Can also be undefined if `URL.createObjectURL` fails\n\t */\n\tpreview: string | undefined;\n};\n\nexport type DropZoneState = {\n\t/**\n\t * List of validation errors\n\t */\n\terrors: FileValidationErrorContext[];\n\t/**\n\t * List of files with their preview URLs and unique IDs\n\t */\n\tfilesWithPreview: FileWithPreview[];\n\t/**\n\t * Whether or not a file is currently being dragged over the drop zone\n\t */\n\tisDragging: boolean;\n};\n\ntype ChangeOrDragEvent = React.ChangeEvent<HTMLInputElement> | React.DragEvent<HTMLElement>;\n\nexport type DropZoneActions = {\n\taddFiles: (fileList: File[] | FileList | null, event?: ChangeOrDragEvent) => void;\n\tclearErrors: () => void;\n\tclearFiles: () => void;\n\thandleDragEnter: (event: React.DragEvent<HTMLElement>) => void;\n\thandleDragLeave: (event: React.DragEvent<HTMLElement>) => void;\n\thandleDragOver: (event: React.DragEvent<HTMLElement>) => void;\n\thandleFileUpload: (event: ChangeOrDragEvent) => void;\n\topenFilePicker: () => void;\n\tremoveFile: (fileToRemoveOrId: string | FileWithPreview) => void;\n};\n\nexport type UseDropZoneResult = {\n\tdropZoneActions: DropZoneActions;\n\tdropZoneState: DropZoneState;\n\tgetContainerProps: (containerProps?: ContainerProps) => ContainerProps;\n\tgetInputProps: (inputProps?: InputProps) => InputProps;\n\tinputRef: React.RefObject<HTMLInputElement | null>;\n};\n\nexport type UseDropZoneProps = {\n\t/**\n\t * Allowed file types to be uploaded.\n\t */\n\tallowedFileTypes?: string[];\n\n\t/**\n\t * CSS classes to apply to the various parts of the drop zone\n\t */\n\tclassNames?: Prettify<ContainerProps[\"classNames\"] & { input?: string }>;\n\n\t/**\n\t * Whether to disallow duplicate files\n\t * @default true\n\t */\n\tdisallowDuplicates?: boolean;\n\n\t/**\n\t * Whether to disallow preview for non-image files\n\t * @default true\n\t */\n\tdisallowPreviewForNonImageFiles?: boolean;\n\n\t/**\n\t * Extra props to pass to the container element\n\t */\n\textraContainerProps?: ContainerProps;\n\n\t/**\n\t * Extra props to pass to the input element\n\t */\n\textraInputProps?: InputProps;\n\n\t/**\n\t * Initial files to populate the drop zone\n\t */\n\tinitialFiles?: FileMeta | FileMeta[] | null;\n\n\t/**\n\t * Maximum number of files that can be uploaded.\n\t */\n\tmaxFileCount?: number;\n\n\t/**\n\t * Maximum file size in MB\n\t */\n\tmaxFileSize?: number;\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: { filesWithPreview: FileWithPreview[] }) => void;\n\n\t/**\n\t * Callback function to be called when the render props change\n\t */\n\tonRenderPropsChange?: (props: UseDropZoneResult) => void;\n\n\t/**\n\t * Callback function to be called when new files are uploaded\n\t */\n\tonUpload?: (context: { event: ChangeOrDragEvent; filesWithPreview: FileWithPreview[] }) => void;\n\n\t/**\n\t * Callback function to be called on each file upload as they occur\n\t */\n\tonUploadError?: FileValidationOptions[\"onError\"];\n\n\t/**\n\t * Callback function to be called once after all file upload errors have occurred\n\t */\n\tonUploadErrors?: FileValidationOptions[\"onErrors\"];\n\n\t/**\n\t * Callback function to be called on file upload success\n\t */\n\tonUploadSuccess?: FileValidationOptions[\"onSuccess\"];\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\tvalidator?: NonNullable<FileValidationOptions[\"validationSettings\"]>[\"validator\"];\n\n\t/**\n\t * Custom validation function that runs after all file validation has occurred\n\t */\n\tvalidatorForAllFiles?: FileValidationOptions[\"validatorForAllFiles\"];\n\n\t/**\n\t * Whether to allow the default file picker via the file input element\n\t * @default true\n\t */\n\twithDefaultFilePicker?: boolean;\n};\n\nexport const useDropZone = (props?: UseDropZoneProps): UseDropZoneResult => {\n\tconst {\n\t\tallowedFileTypes,\n\t\tclassNames,\n\t\tdisallowDuplicates = true,\n\t\tdisallowPreviewForNonImageFiles = true,\n\t\textraContainerProps,\n\t\textraInputProps,\n\t\tinitialFiles,\n\t\tmaxFileCount,\n\t\tmaxFileSize,\n\t\tmultiple,\n\t\tonFilesChange,\n\t\tonRenderPropsChange,\n\t\tonUpload,\n\t\tonUploadError,\n\t\tonUploadErrors,\n\t\tonUploadSuccess,\n\t\tvalidator,\n\t\tvalidatorForAllFiles,\n\t\twithDefaultFilePicker = true,\n\t} = props ?? {};\n\n\tconst inputRef = useRef<HTMLInputElement>(null);\n\n\tconst initialFileArray = toArray(initialFiles).filter(Boolean);\n\n\tconst [dropZoneState, setDropZoneState] = useState<DropZoneState>({\n\t\terrors: [],\n\t\tfilesWithPreview: 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\tisDragging: false,\n\t});\n\n\tconst toggleIsDragging = (value: boolean) => {\n\t\tsetDropZoneState((prevState) => ({ ...prevState, isDragging: value }));\n\t};\n\n\tconst addFiles: DropZoneActions[\"addFiles\"] = useCallbackRef((fileList, event) => {\n\t\tif (!fileList || fileList.length === 0) {\n\t\t\tconsole.warn(\"No file selected!\");\n\t\t\treturn;\n\t\t}\n\n\t\t// Clear existing errors when new files are uploaded\n\t\tclearErrors();\n\n\t\t// In single file mode, clear existing files first\n\t\tif (!multiple) {\n\t\t\tclearFiles();\n\t\t}\n\n\t\tconst { errors, validFiles } = handleFileValidation({\n\t\t\texistingFiles: dropZoneState.filesWithPreview.map((fileWithPreview) => fileWithPreview.file),\n\t\t\tnewFiles: fileList,\n\t\t\tonError: onUploadError,\n\t\t\tonErrors: onUploadErrors,\n\t\t\tonSuccess: onUploadSuccess,\n\t\t\tvalidationSettings: {\n\t\t\t\tallowedFileTypes,\n\t\t\t\tdisallowDuplicates,\n\t\t\t\tmaxFileCount,\n\t\t\t\tmaxFileSize,\n\t\t\t\tvalidator,\n\t\t\t},\n\t\t\tvalidatorForAllFiles,\n\t\t});\n\n\t\tif (validFiles.length === 0) {\n\t\t\tsetDropZoneState((prevState) => ({ ...prevState, errors }));\n\t\t\treturn;\n\t\t}\n\n\t\tconst filesWithPreview: FileWithPreview[] = validFiles.map((file) => ({\n\t\t\tfile,\n\t\t\tid: generateUniqueId(file),\n\t\t\tpreview: createObjectURL(file, disallowPreviewForNonImageFiles),\n\t\t}));\n\n\t\t// == Only call onUpload callback if event is provided, which indicates that new files were uploaded from an event handler\n\n\t\tif (event) {\n\t\t\tonUpload?.({ event, filesWithPreview });\n\t\t}\n\n\t\tconst newFileUploadState = {\n\t\t\t...dropZoneState,\n\t\t\terrors,\n\t\t\t...(event?.type === \"drop\" && { isDragging: false }),\n\t\t\tfilesWithPreview: multiple\n\t\t\t\t? [...dropZoneState.filesWithPreview, ...filesWithPreview]\n\t\t\t\t: filesWithPreview,\n\t\t} satisfies DropZoneState;\n\n\t\tonFilesChange?.({ filesWithPreview: newFileUploadState.filesWithPreview });\n\n\t\tsetDropZoneState(newFileUploadState);\n\n\t\t// == Reset input value after adding files\n\t\tinputRef.current && (inputRef.current.value = \"\");\n\t});\n\n\tconst clearFiles: DropZoneActions[\"clearFiles\"] = useCallbackRef(() => {\n\t\t// == Clean up object URLs if any\n\t\tdropZoneState.filesWithPreview.forEach((fileWithPreview) =>\n\t\t\tclearObjectURL(fileWithPreview, disallowPreviewForNonImageFiles)\n\t\t);\n\n\t\tconst newFileUploadState = {\n\t\t\t...dropZoneState,\n\t\t\terrors: [],\n\t\t\tfilesWithPreview: [],\n\t\t} satisfies DropZoneState;\n\n\t\tonFilesChange?.({ filesWithPreview: newFileUploadState.filesWithPreview });\n\n\t\tsetDropZoneState(newFileUploadState);\n\n\t\t// == Reset input value after clearing files\n\t\tinputRef.current && (inputRef.current.value = \"\");\n\t});\n\n\tconst removeFile: DropZoneActions[\"removeFile\"] = useCallbackRef((fileToRemoveOrId) => {\n\t\tconst actualFileToRemove = isString(fileToRemoveOrId)\n\t\t\t? dropZoneState.filesWithPreview.find((file) => file.id === fileToRemoveOrId)\n\t\t\t: fileToRemoveOrId;\n\n\t\tif (!actualFileToRemove) return;\n\n\t\tclearObjectURL(actualFileToRemove, disallowPreviewForNonImageFiles);\n\n\t\tconst newFilesWithPreview = dropZoneState.filesWithPreview.filter(\n\t\t\t(file) => file.id !== actualFileToRemove.id\n\t\t);\n\n\t\tonFilesChange?.({ filesWithPreview: newFilesWithPreview });\n\n\t\tsetDropZoneState({\n\t\t\t...dropZoneState,\n\t\t\terrors: [],\n\t\t\tfilesWithPreview: newFilesWithPreview,\n\t\t});\n\t});\n\n\tconst clearErrors: DropZoneActions[\"clearErrors\"] = useCallbackRef(() => {\n\t\tsetDropZoneState((prevState) => ({ ...prevState, errors: [] }));\n\t});\n\n\tconst handleFileUpload: DropZoneActions[\"handleFileUpload\"] = useCallbackRef((event) => {\n\t\tif (inputRef.current?.disabled) return;\n\n\t\tif (event.type === \"drop\") {\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t}\n\n\t\tconst fileList =\n\t\t\tevent.type === \"drop\"\n\t\t\t\t? (event as React.DragEvent).dataTransfer.files\n\t\t\t\t: (event as React.ChangeEvent<HTMLInputElement>).target.files;\n\n\t\t// == In single file mode, only use the first file\n\t\tif (!multiple) {\n\t\t\tconst firstFile = fileList?.[0];\n\n\t\t\tfirstFile && addFiles([firstFile], event);\n\n\t\t\treturn;\n\t\t}\n\n\t\taddFiles(fileList, event);\n\t});\n\n\tconst handleDragEnter: DropZoneActions[\"handleDragEnter\"] = useCallbackRef((event) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\t\ttoggleIsDragging(true);\n\t});\n\n\tconst handleDragOver: DropZoneActions[\"handleDragOver\"] = useCallbackRef((event) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\t\ttoggleIsDragging(true);\n\t});\n\n\tconst handleDragLeave: DropZoneActions[\"handleDragLeave\"] = useCallbackRef((event) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\t\ttoggleIsDragging(false);\n\t});\n\n\tconst openFilePicker: DropZoneActions[\"openFilePicker\"] = useCallbackRef(() => {\n\t\tinputRef.current?.click();\n\t});\n\n\tconst getContainerProps: UseDropZoneResult[\"getContainerProps\"] = useCallback(\n\t\t(containerProps) => {\n\t\t\tconst mergedContainerProps = mergeTwoProps(extraContainerProps, 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\tmergedContainerProps.className,\n\t\t\t\t\tclassNames?.base,\n\t\t\t\t\tdropZoneState.isDragging && [\n\t\t\t\t\t\t\"opacity-60\",\n\t\t\t\t\t\tclassNames?.isDragging,\n\t\t\t\t\t\tcontainerProps?.classNames?.isDragging,\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\t\"data-dragging\": dataAttr(dropZoneState.isDragging),\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(handleDragEnter, mergedContainerProps.onDragEnter),\n\t\t\t\tonDragLeave: composeTwoEventHandlers(handleDragLeave, mergedContainerProps.onDragLeave),\n\t\t\t\tonDragOver: composeTwoEventHandlers(handleDragOver, mergedContainerProps.onDragOver),\n\t\t\t\tonDrop: composeTwoEventHandlers(handleFileUpload, mergedContainerProps.onDrop),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tclassNames?.base,\n\t\t\tclassNames?.isDragging,\n\t\t\textraContainerProps,\n\t\t\tdropZoneState.isDragging,\n\t\t\thandleDragEnter,\n\t\t\thandleDragLeave,\n\t\t\thandleDragOver,\n\t\t\thandleFileUpload,\n\t\t]\n\t);\n\n\tconst getInputProps: UseDropZoneResult[\"getInputProps\"] = useCallback(\n\t\t(inputProps) => {\n\t\t\tconst mergedInputProps = mergeTwoProps(extraInputProps, 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\twithDefaultFilePicker ? \"absolute inset-0 z-[100] cursor-pointer opacity-0\" : \"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-dragging\": dataAttr(dropZoneState.isDragging),\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(handleFileUpload, 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\tallowedFileTypes,\n\t\t\tclassNames?.input,\n\t\t\textraInputProps,\n\t\t\tdropZoneState.isDragging,\n\t\t\thandleFileUpload,\n\t\t\tmultiple,\n\t\t\twithDefaultFilePicker,\n\t\t]\n\t);\n\n\tconst savedOnRenderPropsChange = useCallbackRef(onRenderPropsChange);\n\n\tconst dropZoneResult = useMemo(() => {\n\t\tconst propsForRenderFn = {\n\t\t\tdropZoneActions: {\n\t\t\t\taddFiles,\n\t\t\t\tclearErrors,\n\t\t\t\tclearFiles,\n\t\t\t\thandleDragEnter,\n\t\t\t\thandleDragLeave,\n\t\t\t\thandleDragOver,\n\t\t\t\thandleFileUpload,\n\t\t\t\topenFilePicker,\n\t\t\t\tremoveFile,\n\t\t\t},\n\t\t\tdropZoneState,\n\t\t\tgetContainerProps,\n\t\t\tgetInputProps,\n\t\t\tinputRef,\n\t\t} satisfies UseDropZoneResult;\n\n\t\tsavedOnRenderPropsChange(propsForRenderFn);\n\n\t\treturn propsForRenderFn;\n\t}, [\n\t\tsavedOnRenderPropsChange,\n\t\taddFiles,\n\t\tclearErrors,\n\t\tclearFiles,\n\t\tdropZoneState,\n\t\tgetInputProps,\n\t\tgetContainerProps,\n\t\thandleDragEnter,\n\t\thandleDragLeave,\n\t\thandleDragOver,\n\t\thandleFileUpload,\n\t\topenFilePicker,\n\t\tremoveFile,\n\t]);\n\n\treturn dropZoneResult;\n};\n","\"use client\";\n\nimport * as React from \"react\";\n\nimport { Show, Slot } from \"@/components/common\";\nimport { type GetSlotComponentProps, getSlotMap, withSlotNameAndSymbol } from \"@/lib/utils/getSlotMap\";\nimport type { DiscriminatedRenderProps, PolymorphicProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { isArray, isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Fragment as ReactFragment, isValidElement } from \"react\";\nimport { DropZoneContextProvider, useDropZoneContext } from \"./drop-context\";\nimport {\n\ttype ContainerProps,\n\ttype InputProps,\n\ttype UseDropZoneProps,\n\ttype UseDropZoneResult,\n\tuseDropZone,\n} from \"./use-drop-zone\";\n\nexport type DropZoneRenderPropType = DiscriminatedRenderProps<\n\tReact.ReactNode | ((props: UseDropZoneResult) => React.ReactNode)\n>;\n\nexport type DropZoneRootProps = DropZoneRenderPropType\n\t& UseDropZoneProps & {\n\t\t/**\n\t\t * Controls whether to include internal elements (root and input) or not.\n\t\t */\n\t\twithInternalElements?: boolean;\n\t};\n\nexport function DropZoneRoot(props: DropZoneRootProps) {\n\tconst { children, render, withInternalElements = true, ...restOfProps } = props;\n\n\tconst dropZone = useDropZone(restOfProps);\n\n\tconst ContainerComponent = withInternalElements ? DropZoneContainer : ReactFragment;\n\tconst InputComponent = withInternalElements ? DropZoneInput : ReactFragment;\n\n\tconst selectedChildren = children ?? render;\n\n\tconst resolvedChildren = isFunction(selectedChildren) ? selectedChildren(dropZone) : selectedChildren;\n\n\tconst couldChildrenContainSlots =\n\t\tisArray(resolvedChildren)\n\t\t|| (isValidElement(resolvedChildren) && resolvedChildren.type === ReactFragment);\n\n\tconst slots =\n\t\twithInternalElements && couldChildrenContainSlots\n\t\t\t? getSlotMap<SlotComponentProps>(resolvedChildren)\n\t\t\t: ({ default: resolvedChildren } as ReturnType<typeof getSlotMap<SlotComponentProps>>);\n\n\treturn (\n\t\t<DropZoneContextProvider value={dropZone}>\n\t\t\t<ContainerComponent>\n\t\t\t\t<InputComponent />\n\n\t\t\t\t{slots.default}\n\t\t\t</ContainerComponent>\n\n\t\t\t{slots.preview}\n\t\t</DropZoneContextProvider>\n\t);\n}\n\ntype DropZoneInputProps = InputProps & { asChild?: boolean };\n\nexport function DropZoneInput(props: DropZoneInputProps) {\n\tconst { asChild, ...restOfProps } = props;\n\n\tconst dropZoneContext = useDropZoneContext();\n\n\tconst Component = asChild ? Slot.Root : \"input\";\n\n\treturn <Component {...dropZoneContext.getInputProps(restOfProps)} />;\n}\n\ntype DropZoneContainerProps = ContainerProps & { 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 dropZoneContext = useDropZoneContext();\n\n\tconst Component = asChild ? Slot.Root : Element;\n\n\treturn <Component {...dropZoneContext.getContainerProps(restOfProps)} />;\n}\n\ntype RenderPropFn = (props: UseDropZoneResult) => React.ReactNode;\n\ntype SlotComponentProps = GetSlotComponentProps<\"preview\", React.ReactNode | RenderPropFn>;\n\nexport function DropZoneContext(props: { children: RenderPropFn }) {\n\tconst { children } = props;\n\n\tconst dropZoneContext = useDropZoneContext();\n\n\treturn children(dropZoneContext);\n}\n\nexport const DropZoneImagePreview = withSlotNameAndSymbol<SlotComponentProps>(\"preview\", (props) => {\n\tconst { children } = props;\n\n\tif (isFunction(children)) {\n\t\treturn (\n\t\t\t<DropZoneContext>\n\t\t\t\t{(dropZoneCtx) => (\n\t\t\t\t\t<Show.Root when={dropZoneCtx.dropZoneState.filesWithPreview.length > 0}>\n\t\t\t\t\t\t{children(dropZoneCtx)}\n\t\t\t\t\t</Show.Root>\n\t\t\t\t)}\n\t\t\t</DropZoneContext>\n\t\t);\n\t}\n\n\treturn children;\n});\n","export {\n\tDropZoneRoot as Root,\n\tDropZoneImagePreview as ImagePreview,\n\tDropZoneContext as Context,\n\tDropZoneInput as Input,\n\tDropZoneContainer as Container,\n} from \"./drop-zone\";\n"],"mappings":";;;;;;;;;;;;;AAGA,MAAM,CAAC,yBAAyB,mBAAmB,GAAG,oBAAuC;CAC5F,UAAU;CACV,MAAM;CACN,cAAc;AACd,EAAC;;;;ACHF,MAAa,mBAAmB,CAACA,SAAkC;AAClE,MAAK,OAAO,KAAK,CAChB,QAAO,KAAK;AAGb,SAAQ,EAAE,KAAK,KAAK,IAAI,KAAK,MAAM,YAAY,KAAK,CAAC,CAAC,IAAI,OAAO,YAAY,CAAC,MAAM,GAAG,EAAE,CAAC;AAC1F;A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-BIcGgBwN.js";
2
+ import { getMultipleSlots } from "./getSlot-D1_uG-Ym.js";
3
3
  import { SlotRoot } from "./slot-RXTKo4L7.js";
4
4
  import { getElementList } from "./for-aTw1TgJo.js";
5
5
  import { cnMerge } from "./cn-_FbtIrlZ.js";
@@ -147,7 +147,7 @@ function FormField(props) {
147
147
  }), [name, uniqueId]);
148
148
  const WrapperElement = withWrapper ? "div" : Fragment;
149
149
  const wrapperElementProps = withWrapper && {
150
- className: cnMerge("flex flex-col", className),
150
+ className: cnMerge("flex flex-col gap-2", className),
151
151
  "data-part": "field",
152
152
  "data-scope": "form",
153
153
  "data-slot": "form-field",
@@ -517,7 +517,7 @@ function FormErrorMessage(props) {
517
517
  type,
518
518
  render: ({ props: renderProps, state }) => /* @__PURE__ */ jsx("p", {
519
519
  ...renderProps,
520
- className: cnMerge("text-[13px] text-red-600", "data-[index=0]:mt-1", renderProps.className, className),
520
+ className: cnMerge("text-shadcn-destructive text-[13px]", "data-[index=0]:mt-1", renderProps.className, className),
521
521
  children: state.errorMessage
522
522
  }, state.errorMessage)
523
523
  });
@@ -587,4 +587,4 @@ __export(form_parts_exports, {
587
587
 
588
588
  //#endregion
589
589
  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-DytCfL6R.js.map
590
+ //# sourceMappingURL=form-6RV0u4YT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-6RV0u4YT.js","names":["props: React.SVGProps<SVGSVGElement>","options: {\n\terrors: FieldErrors | undefined;\n\tfieldName: string | undefined;\n\ttype: FormErrorMessagePrimitiveProps<FieldValues>[\"type\"];\n}","errorMessage","options: {\n\tclassNames: FormInputProps[\"classNames\"];\n\ticonType: \"closed\" | \"open\";\n\trenderIconProps: RenderIconProps;\n\twithEyeIcon: FormRootContext[\"withEyeIcon\"];\n}","options: { strict?: TStrict }","options?: FieldStateOptions","props: FormRootProps<TValues>","HookFormProvider","props: FormFieldProps<TControl, TFieldValues>","ReactFragment","props: FormFieldControllerProps","props: ControllerProps<TFieldValues>","props: FormFieldContextProps","props: InferProps<\"label\">","props: InferProps<\"div\">","props: PolymorphicProps<TElement, FormSideItemProps>","props: FormInputPrimitiveProps<TFieldValues> & { rules?: RegisterOptions }","props: FormTextAreaPrimitiveProps<TFieldValues> & { rules?: RegisterOptions }","props: FormSelectPrimitiveProps<TFieldValues> & { rules?: RegisterOptions }","props: CombinedFormInputProps & { rules?: RegisterOptions }","props: FormTextAreaProps","props: FormSelectProps","props: InferProps<\"p\">","FormErrorMessagePrimitive: FormErrorMessagePrimitiveType","options: { index: number }","options: { errorMessage: string; index: number }","props: FormErrorMessageProps<TControl, TFieldValues>","props: PolymorphicProps<TElement, FormSubmitProps>","Component","props: FormSubscribeToFieldValueProps<TFieldValues, TFieldPathOrPaths>","props: FormSubscribeToFormStateProps<TFieldValues>"],"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\nimport * as React from \"react\";\n\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 { dataAttr, on, toArray } from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef, useToggle } from \"@zayne-labs/toolkit-react\";\nimport {\n\ttype DiscriminatedRenderProps,\n\ttype InferProps,\n\ttype PolymorphicProps,\n\tcomposeRefs,\n\tcomposeTwoEventHandlers,\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 {\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\nexport type FieldValues = Record<string, unknown>;\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 Control<infer TValues>\n\t? {\n\t\t\tcontrol?: never;\n\t\t\tname: FieldPath<TValues>;\n\t\t}\n\t: {\n\t\t\tcontrol?: Control<TFieldValues>;\n\t\t\tname: FieldPath<TFieldValues>;\n\t\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\t? fieldContextValues?.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\t? fieldContextValues?.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\t? fieldContextValues?.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\t? InputTypeMap[type as Exclude<typeof type, AnyString>]\n\t\t\t: FormInputPrimitive;\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\tDiscriminatedRenderProps<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\trender,\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 : render;\n\n\treturn (\n\t\t<WrapperComponent {...wrapperComponentProps}>\n\t\t\t<ErrorMessageList\n\t\t\t\teach={errorMessageArray}\n\t\t\t\trender={(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\t\tclassName?: string;\n\t\t\t\t\tcontrol?: never;\n\t\t\t\t\terrorField?: FieldPath<TValues>;\n\t\t\t\t\ttype?: \"regular\";\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tclassName?: string;\n\t\t\t\t\tcontrol?: Control<TFieldValues>; // == Here for type inference of errorField prop\n\t\t\t\t\terrorField?: FieldPath<TFieldValues>;\n\t\t\t\t\ttype?: \"regular\";\n\t\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\trender={({ 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\t? FieldPathValues<TFieldValues, TFieldPathOrPaths>\n\t\t: TFieldPathOrPaths extends FieldPath<TFieldValues>\n\t\t\t? FieldPathValue<TFieldValues, TFieldPathOrPaths>\n\t\t\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 });\n\n\tconst fieldProps = { value: formValue };\n\n\tconst selectedChildren = typeof children === \"function\" ? children : render;\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,gBAAgB,CAACA,0BAC7B,IAAC;CAAI,OAAM;CAA6B,OAAM;CAAM,QAAO;CAAM,SAAQ;CAAY,GAAI;2BACxF,IAAC;EACA,MAAK;EACL,GAAE;GACD;EACG;AAGP,MAAa,cAAc,CAACA,0BAC3B,IAAC;CAAI,OAAM;CAA6B,OAAM;CAAM,QAAO;CAAM,SAAQ;CAAY,GAAI;2BACxF,IAAC;EACA,MAAK;EACL,GAAE;GACD;EACG;;;;ACTP,MAAa,uBAAuB,CAACC,YAIO;CAC3C,MAAM,EAAE,QAAQ,WAAW,MAAM,GAAG;AAEpC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C,OACC;CACD,MAAM,EAAE,IAAI,UAAU,UAAU,SAAS,UAAU,OAAO,SAAU,GAAG,aAAa,GAAG;CAEvF,MAAMC,cAAY,qBAAsB;AAExC,wBACC,IAACA;EAAU,aAAU;EAAS,cAAW;EAAO,aAAU;EAAoB;EAAM,GAAI;EACtF;GACU;AAEb;AAqBD,SAAgB,0BAGdC,OAAwE;CACzE,MAAM,qBAAqB,wBAAwB;CAEnD,MAAM,EAAE,UAAU,OAAO,oBAAoB,MAAM,QAAQ,GAAG;CAE9D,MAAM,EAAE,SAAS,GAAG,uBAAuB;CAE3C,MAAM,YAAY,SAAS;EAAE;EAAe;CAAgB,EAAC;CAE7D,MAAM,aAAa,EAAE,OAAO,UAAW;CAEvC,MAAM,0BAA0B,aAAa,aAAa,WAAW;CAErE,MAAM,mBAAmB,iBAAiB,WAAoB;AAE9D,QAAO;AACP;AAaD,SAAgB,yBACfC,OACC;CACD,MAAM,qBAAqB,wBAAwB;CAEnD,MAAM,EAAE,UAAU,SAAS,OAAO,oBAAoB,MAAM,QAAQ,GAAG;CAEvE,MAAM,YAAY,aAAa;EAAE;EAAe;CAAiC,EAAC;CAElF,MAAM,0BAA0B,aAAa,aAAa,WAAW;CAErE,MAAM,mBAAmB,iBAAiB,UAAmB;AAE7D,QAAO;AACP"}
@@ -81,5 +81,5 @@ const getRegularChildren = (children, SlotComponentOrComponents) => {
81
81
  };
82
82
 
83
83
  //#endregion
84
- export { getMultipleSlots as getMultipleSlots$1, getRegularChildren as getRegularChildren$1, getSingleSlot as getSingleSlot$1, matchesAnySlotComponent as matchesAnySlotComponent$1, matchesSlotComponent as matchesSlotComponent$1 };
85
- //# sourceMappingURL=getSlot-BIcGgBwN.js.map
84
+ export { getMultipleSlots, getRegularChildren, getSingleSlot, matchesAnySlotComponent, matchesSlotComponent };
85
+ //# sourceMappingURL=getSlot-D1_uG-Ym.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getSlot-BIcGgBwN.js","names":["component: TFunction","child: React.ReactNode","SlotComponent: FunctionalComponent","SlotComponents: FunctionalComponent[]","childrenArray: React.ReactNode[]","children: React.ReactNode","options: SlotOptions","ReactFragment","SlotComponents: TSlotComponents","options?: MultipleSlotsOptions","SlotComponentOrComponents: FunctionalComponent | FunctionalComponent[]"],"sources":["../../src/lib/utils/getSlot/getSlot.ts"],"sourcesContent":["import { toArray } from \"@zayne-labs/toolkit-core\";\nimport type { InferProps } from \"@zayne-labs/toolkit-react/utils\";\nimport {\n\ttype AnyFunction,\n\tAssertionError,\n\ttype Prettify,\n\ttype UnknownObject,\n\tisArray,\n\tisFunction,\n} from \"@zayne-labs/toolkit-type-helpers\";\nimport { Fragment as ReactFragment, isValidElement } from \"react\";\n\nexport type FunctionalComponent<TProps extends UnknownObject = never> = React.FunctionComponent<TProps>;\n\nconst isWithSlotSymbol = <TFunction extends AnyFunction>(\n\tcomponent: TFunction\n): component is Record<\"slotSymbol\", unknown> & TFunction => {\n\treturn \"slotSymbol\" in component && Boolean(component.slotSymbol);\n};\n\nconst isWithSlotReference = <TFunction extends AnyFunction>(\n\tcomponent: TFunction\n): component is Record<\"slotReference\", unknown> & TFunction => {\n\treturn \"slotReference\" in component && Boolean(component.slotReference);\n};\n/**\n * @description Checks if a react child (within the children array) matches the provided SlotComponent using multiple matching strategies:\n * 1. Matches by slot symbol property\n * 2. Matches by component name\n */\n\nexport const matchesSlotComponent = (child: React.ReactNode, SlotComponent: FunctionalComponent) => {\n\tif (!isValidElement(child) || !isFunction(child.type)) {\n\t\treturn false;\n\t}\n\n\tconst resolvedChildType = isWithSlotReference(child.type)\n\t\t? (child.type.slotReference as FunctionalComponent)\n\t\t: child.type;\n\n\tconst hasMatchingSlotSymbol =\n\t\tisWithSlotSymbol(resolvedChildType)\n\t\t&& isWithSlotSymbol(SlotComponent)\n\t\t&& resolvedChildType.slotSymbol === SlotComponent.slotSymbol;\n\n\tif (hasMatchingSlotSymbol) {\n\t\treturn true;\n\t}\n\n\tif (child.type.name === SlotComponent.name) {\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\n/**\n * @description Checks if a react child (within the children array) matches any of the provided SlotComponents.\n */\nexport const matchesAnySlotComponent = (child: React.ReactNode, SlotComponents: FunctionalComponent[]) => {\n\tconst matchesSlot = SlotComponents.some((SlotComponent) => matchesSlotComponent(child, SlotComponent));\n\n\treturn matchesSlot;\n};\n\ntype SlotOptions = {\n\t/**\n\t * @description The error message to throw when multiple slots are found for a given slot component\n\t */\n\terrorMessage?: string;\n\t/**\n\t * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component\n\t */\n\tthrowOnMultipleSlotMatch?: boolean;\n};\n\n/**\n * @description Counts how many times a given slot component appears in an array of children\n * @internal\n */\nconst calculateSlotOccurrences = (\n\tchildrenArray: React.ReactNode[],\n\tSlotComponent: FunctionalComponent\n) => {\n\tlet count = 0;\n\n\tfor (const child of childrenArray) {\n\t\tif (!matchesSlotComponent(child, SlotComponent)) continue;\n\n\t\tcount += 1;\n\t}\n\n\treturn count;\n};\n\n/**\n * @description Retrieves a single slot element from a collection of React children that matches the provided SlotComponent component.\n *\n * @throws { AssertionError } when throwOnMultipleSlotMatch is true and multiple slots are found\n */\nexport const getSingleSlot = (\n\tchildren: React.ReactNode,\n\tSlotComponent: FunctionalComponent,\n\toptions: SlotOptions = {}\n) => {\n\tconst {\n\t\terrorMessage = \"Only one instance of the SlotComponent is allowed\",\n\t\tthrowOnMultipleSlotMatch = false,\n\t} = options;\n\n\tconst actualChildren =\n\t\tisValidElement<InferProps<typeof ReactFragment>>(children) && children.type === ReactFragment\n\t\t\t? children.props.children\n\t\t\t: children;\n\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\n\n\tconst shouldThrow =\n\t\tthrowOnMultipleSlotMatch && calculateSlotOccurrences(childrenArray, SlotComponent) > 1;\n\n\tif (shouldThrow) {\n\t\tthrow new AssertionError(errorMessage);\n\t}\n\n\tconst slotElement = childrenArray.find((child) => matchesSlotComponent(child, SlotComponent));\n\n\treturn slotElement;\n};\n\n// NOTE - You can imitate const type parameter by extending readonly[] | []\n\ntype MultipleSlotsOptions = {\n\t/**\n\t * @description The error message to throw when multiple slots are found for a given slot component\n\t * If a string is provided, the same message will be used for all slot components\n\t * If an array is provided, each string in the array will be used as the errorMessage for the corresponding slot component\n\t */\n\terrorMessage?: string | string[];\n\t/**\n\t * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component\n\t * If a boolean is provided, the same value will be used for all slot components\n\t * If an array is provided, each boolean in the array will be used as the throwOnMultipleSlotMatch value for the corresponding slot component\n\t */\n\tthrowOnMultipleSlotMatch?: boolean | boolean[];\n};\n\ntype GetMultipleSlotsResult<TSlotComponents extends FunctionalComponent[]> = {\n\tregularChildren: React.ReactNode[];\n\tslots: { [Key in keyof TSlotComponents]: ReturnType<TSlotComponents[Key]> };\n};\n\n/**\n * @description The same as getSingleSlot, but for multiple slot components\n */\nexport const getMultipleSlots = <const TSlotComponents extends FunctionalComponent[]>(\n\tchildren: React.ReactNode,\n\tSlotComponents: TSlotComponents,\n\toptions?: MultipleSlotsOptions\n): Prettify<GetMultipleSlotsResult<TSlotComponents>> => {\n\tconst { errorMessage, throwOnMultipleSlotMatch } = options ?? {};\n\n\tconst slots = SlotComponents.map((SlotComponent, index) =>\n\t\tgetSingleSlot(children, SlotComponent, {\n\t\t\terrorMessage: isArray(errorMessage) ? errorMessage[index] : errorMessage,\n\t\t\tthrowOnMultipleSlotMatch: isArray(throwOnMultipleSlotMatch)\n\t\t\t\t? throwOnMultipleSlotMatch[index]\n\t\t\t\t: throwOnMultipleSlotMatch,\n\t\t})\n\t);\n\n\tconst regularChildren = getRegularChildren(children, SlotComponents);\n\n\treturn { regularChildren, slots } as GetMultipleSlotsResult<TSlotComponents>;\n};\n\n/**\n * @description Returns all children that are not slot elements (i.e., don't match any of the provided slot components)\n */\nexport const getRegularChildren = (\n\tchildren: React.ReactNode,\n\tSlotComponentOrComponents: FunctionalComponent | FunctionalComponent[]\n) => {\n\tconst actualChildren =\n\t\tisValidElement<InferProps<typeof ReactFragment>>(children) && children.type === ReactFragment\n\t\t\t? children.props.children\n\t\t\t: children;\n\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\n\n\tconst regularChildren = childrenArray.filter(\n\t\t(child) => !matchesAnySlotComponent(child, toArray(SlotComponentOrComponents))\n\t);\n\n\treturn regularChildren;\n};\n"],"mappings":";;;;;AAcA,MAAM,mBAAmB,CACxBA,cAC4D;AAC5D,QAAO,gBAAgB,aAAa,QAAQ,UAAU,WAAW;AACjE;AAED,MAAM,sBAAsB,CAC3BA,cAC+D;AAC/D,QAAO,mBAAmB,aAAa,QAAQ,UAAU,cAAc;AACvE;;;;;;AAOD,MAAa,uBAAuB,CAACC,OAAwBC,kBAAuC;AACnG,MAAK,eAAe,MAAM,KAAK,WAAW,MAAM,KAAK,CACpD,QAAO;CAGR,MAAM,oBAAoB,oBAAoB,MAAM,KAAK,GACrD,MAAM,KAAK,gBACZ,MAAM;CAET,MAAM,wBACL,iBAAiB,kBAAkB,IAChC,iBAAiB,cAAc,IAC/B,kBAAkB,eAAe,cAAc;AAEnD,KAAI,sBACH,QAAO;AAGR,KAAI,MAAM,KAAK,SAAS,cAAc,KACrC,QAAO;AAGR,QAAO;AACP;;;;AAKD,MAAa,0BAA0B,CAACD,OAAwBE,mBAA0C;CACzG,MAAM,cAAc,eAAe,KAAK,CAAC,kBAAkB,qBAAqB,OAAO,cAAc,CAAC;AAEtG,QAAO;AACP;;;;;AAiBD,MAAM,2BAA2B,CAChCC,eACAF,kBACI;CACJ,IAAI,QAAQ;AAEZ,MAAK,MAAM,SAAS,eAAe;AAClC,OAAK,qBAAqB,OAAO,cAAc,CAAE;AAEjD,WAAS;CACT;AAED,QAAO;AACP;;;;;;AAOD,MAAa,gBAAgB,CAC5BG,UACAH,eACAI,UAAuB,CAAE,MACrB;CACJ,MAAM,EACL,eAAe,qDACf,2BAA2B,OAC3B,GAAG;CAEJ,MAAM,iBACL,eAAiD,SAAS,IAAI,SAAS,SAASC,WAC7E,SAAS,MAAM,WACf;CAEJ,MAAM,gBAAgB,QAAyB,eAAe;CAE9D,MAAM,cACL,4BAA4B,yBAAyB,eAAe,cAAc,GAAG;AAEtF,KAAI,YACH,OAAM,IAAI,eAAe;CAG1B,MAAM,cAAc,cAAc,KAAK,CAAC,UAAU,qBAAqB,OAAO,cAAc,CAAC;AAE7F,QAAO;AACP;;;;AA2BD,MAAa,mBAAmB,CAC/BF,UACAG,gBACAC,YACuD;CACvD,MAAM,EAAE,cAAc,0BAA0B,GAAG,WAAW,CAAE;CAEhE,MAAM,QAAQ,eAAe,IAAI,CAAC,eAAe,UAChD,cAAc,UAAU,eAAe;EACtC,cAAc,QAAQ,aAAa,GAAG,aAAa,SAAS;EAC5D,0BAA0B,QAAQ,yBAAyB,GACxD,yBAAyB,SACzB;CACH,EAAC,CACF;CAED,MAAM,kBAAkB,mBAAmB,UAAU,eAAe;AAEpE,QAAO;EAAE;EAAiB;CAAO;AACjC;;;;AAKD,MAAa,qBAAqB,CACjCJ,UACAK,8BACI;CACJ,MAAM,iBACL,eAAiD,SAAS,IAAI,SAAS,SAASH,WAC7E,SAAS,MAAM,WACf;CAEJ,MAAM,gBAAgB,QAAyB,eAAe;CAE9D,MAAM,kBAAkB,cAAc,OACrC,CAAC,WAAW,wBAAwB,OAAO,QAAQ,0BAA0B,CAAC,CAC9E;AAED,QAAO;AACP"}
1
+ {"version":3,"file":"getSlot-D1_uG-Ym.js","names":["component: TFunction","child: React.ReactNode","SlotComponent: FunctionalComponent","SlotComponents: FunctionalComponent[]","childrenArray: React.ReactNode[]","children: React.ReactNode","options: SlotOptions","ReactFragment","SlotComponents: TSlotComponents","options?: MultipleSlotsOptions","SlotComponentOrComponents: FunctionalComponent | FunctionalComponent[]"],"sources":["../../src/lib/utils/getSlot/getSlot.ts"],"sourcesContent":["import { toArray } from \"@zayne-labs/toolkit-core\";\nimport type { InferProps } from \"@zayne-labs/toolkit-react/utils\";\nimport {\n\ttype AnyFunction,\n\tAssertionError,\n\ttype Prettify,\n\ttype UnknownObject,\n\tisArray,\n\tisFunction,\n} from \"@zayne-labs/toolkit-type-helpers\";\nimport { Fragment as ReactFragment, isValidElement } from \"react\";\n\nexport type FunctionalComponent<TProps extends UnknownObject = never> = React.FunctionComponent<TProps>;\n\nconst isWithSlotSymbol = <TFunction extends AnyFunction>(\n\tcomponent: TFunction\n): component is Record<\"slotSymbol\", unknown> & TFunction => {\n\treturn \"slotSymbol\" in component && Boolean(component.slotSymbol);\n};\n\nconst isWithSlotReference = <TFunction extends AnyFunction>(\n\tcomponent: TFunction\n): component is Record<\"slotReference\", unknown> & TFunction => {\n\treturn \"slotReference\" in component && Boolean(component.slotReference);\n};\n/**\n * @description Checks if a react child (within the children array) matches the provided SlotComponent using multiple matching strategies:\n * 1. Matches by slot symbol property\n * 2. Matches by component name\n */\n\nexport const matchesSlotComponent = (child: React.ReactNode, SlotComponent: FunctionalComponent) => {\n\tif (!isValidElement(child) || !isFunction(child.type)) {\n\t\treturn false;\n\t}\n\n\tconst resolvedChildType = isWithSlotReference(child.type)\n\t\t? (child.type.slotReference as FunctionalComponent)\n\t\t: child.type;\n\n\tconst hasMatchingSlotSymbol =\n\t\tisWithSlotSymbol(resolvedChildType)\n\t\t&& isWithSlotSymbol(SlotComponent)\n\t\t&& resolvedChildType.slotSymbol === SlotComponent.slotSymbol;\n\n\tif (hasMatchingSlotSymbol) {\n\t\treturn true;\n\t}\n\n\tif (child.type.name === SlotComponent.name) {\n\t\treturn true;\n\t}\n\n\treturn false;\n};\n\n/**\n * @description Checks if a react child (within the children array) matches any of the provided SlotComponents.\n */\nexport const matchesAnySlotComponent = (child: React.ReactNode, SlotComponents: FunctionalComponent[]) => {\n\tconst matchesSlot = SlotComponents.some((SlotComponent) => matchesSlotComponent(child, SlotComponent));\n\n\treturn matchesSlot;\n};\n\ntype SlotOptions = {\n\t/**\n\t * @description The error message to throw when multiple slots are found for a given slot component\n\t */\n\terrorMessage?: string;\n\t/**\n\t * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component\n\t */\n\tthrowOnMultipleSlotMatch?: boolean;\n};\n\n/**\n * @description Counts how many times a given slot component appears in an array of children\n * @internal\n */\nconst calculateSlotOccurrences = (\n\tchildrenArray: React.ReactNode[],\n\tSlotComponent: FunctionalComponent\n) => {\n\tlet count = 0;\n\n\tfor (const child of childrenArray) {\n\t\tif (!matchesSlotComponent(child, SlotComponent)) continue;\n\n\t\tcount += 1;\n\t}\n\n\treturn count;\n};\n\n/**\n * @description Retrieves a single slot element from a collection of React children that matches the provided SlotComponent component.\n *\n * @throws { AssertionError } when throwOnMultipleSlotMatch is true and multiple slots are found\n */\nexport const getSingleSlot = (\n\tchildren: React.ReactNode,\n\tSlotComponent: FunctionalComponent,\n\toptions: SlotOptions = {}\n) => {\n\tconst {\n\t\terrorMessage = \"Only one instance of the SlotComponent is allowed\",\n\t\tthrowOnMultipleSlotMatch = false,\n\t} = options;\n\n\tconst actualChildren =\n\t\tisValidElement<InferProps<typeof ReactFragment>>(children) && children.type === ReactFragment\n\t\t\t? children.props.children\n\t\t\t: children;\n\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\n\n\tconst shouldThrow =\n\t\tthrowOnMultipleSlotMatch && calculateSlotOccurrences(childrenArray, SlotComponent) > 1;\n\n\tif (shouldThrow) {\n\t\tthrow new AssertionError(errorMessage);\n\t}\n\n\tconst slotElement = childrenArray.find((child) => matchesSlotComponent(child, SlotComponent));\n\n\treturn slotElement;\n};\n\n// NOTE - You can imitate const type parameter by extending readonly[] | []\n\ntype MultipleSlotsOptions = {\n\t/**\n\t * @description The error message to throw when multiple slots are found for a given slot component\n\t * If a string is provided, the same message will be used for all slot components\n\t * If an array is provided, each string in the array will be used as the errorMessage for the corresponding slot component\n\t */\n\terrorMessage?: string | string[];\n\t/**\n\t * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component\n\t * If a boolean is provided, the same value will be used for all slot components\n\t * If an array is provided, each boolean in the array will be used as the throwOnMultipleSlotMatch value for the corresponding slot component\n\t */\n\tthrowOnMultipleSlotMatch?: boolean | boolean[];\n};\n\ntype GetMultipleSlotsResult<TSlotComponents extends FunctionalComponent[]> = {\n\tregularChildren: React.ReactNode[];\n\tslots: { [Key in keyof TSlotComponents]: ReturnType<TSlotComponents[Key]> };\n};\n\n/**\n * @description The same as getSingleSlot, but for multiple slot components\n */\nexport const getMultipleSlots = <const TSlotComponents extends FunctionalComponent[]>(\n\tchildren: React.ReactNode,\n\tSlotComponents: TSlotComponents,\n\toptions?: MultipleSlotsOptions\n): Prettify<GetMultipleSlotsResult<TSlotComponents>> => {\n\tconst { errorMessage, throwOnMultipleSlotMatch } = options ?? {};\n\n\tconst slots = SlotComponents.map((SlotComponent, index) =>\n\t\tgetSingleSlot(children, SlotComponent, {\n\t\t\terrorMessage: isArray(errorMessage) ? errorMessage[index] : errorMessage,\n\t\t\tthrowOnMultipleSlotMatch: isArray(throwOnMultipleSlotMatch)\n\t\t\t\t? throwOnMultipleSlotMatch[index]\n\t\t\t\t: throwOnMultipleSlotMatch,\n\t\t})\n\t);\n\n\tconst regularChildren = getRegularChildren(children, SlotComponents);\n\n\treturn { regularChildren, slots } as GetMultipleSlotsResult<TSlotComponents>;\n};\n\n/**\n * @description Returns all children that are not slot elements (i.e., don't match any of the provided slot components)\n */\nexport const getRegularChildren = (\n\tchildren: React.ReactNode,\n\tSlotComponentOrComponents: FunctionalComponent | FunctionalComponent[]\n) => {\n\tconst actualChildren =\n\t\tisValidElement<InferProps<typeof ReactFragment>>(children) && children.type === ReactFragment\n\t\t\t? children.props.children\n\t\t\t: children;\n\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\n\n\tconst regularChildren = childrenArray.filter(\n\t\t(child) => !matchesAnySlotComponent(child, toArray(SlotComponentOrComponents))\n\t);\n\n\treturn regularChildren;\n};\n"],"mappings":";;;;;AAcA,MAAM,mBAAmB,CACxBA,cAC4D;AAC5D,QAAO,gBAAgB,aAAa,QAAQ,UAAU,WAAW;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0BAA0B,GAAG,WAAW,CAAE;CAEhE,MAAM,QAAQ,eAAe,IAAI,CAAC,eAAe,UAChD,cAAc,UAAU,eAAe;EACtC,cAAc,QAAQ,aAAa,GAAG,aAAa,SAAS;EAC5D,0BAA0B,QAAQ,yBAAyB,GACxD,yBAAyB,SACzB;CACH,EAAC,CACF;CAED,MAAM,kBAAkB,mBAAmB,UAAU,eAAe;AAEpE,QAAO;EAAE;EAAiB;CAAO;AACjC;;;;AAKD,MAAa,qBAAqB,CACjCJ,UACAK,8BACI;CACJ,MAAM,iBACL,eAAiD,SAAS,IAAI,SAAS,SAASH,WAC7E,SAAS,MAAM,WACf;CAEJ,MAAM,gBAAgB,QAAyB,eAAe;CAE9D,MAAM,kBAAkB,cAAc,OACrC,CAAC,WAAW,wBAAwB,OAAO,QAAQ,0BAA0B,CAAC,CAC9E;AAED,QAAO;AACP"}
@@ -81,7 +81,6 @@ type SlotWithNameAndSymbol<TSlotComponentProps extends GetSlotComponentProps = G
81
81
  * @description Adds a slot symbol and name to a slot component passed in
82
82
  */
83
83
  declare const withSlotNameAndSymbol: <TSlotComponentProps extends GetSlotComponentProps, TOtherProps extends UnknownObject = EmptyObject>(name: TSlotComponentProps["name"], SlotComponent?: SlotWithNameAndSymbol<TSlotComponentProps, TOtherProps>) => SlotWithNameAndSymbol<TSlotComponentProps, TOtherProps>;
84
-
85
84
  //#endregion
86
- export { GetSlotComponentProps, GetSlotMapResult, createSlotComponent as createSlotComponent$1, getSlotMap as getSlotMap$1, slotComponentSymbol as slotComponentSymbol$1, withSlotNameAndSymbol as withSlotNameAndSymbol$1 };
87
- //# sourceMappingURL=getSlotMap-DA_uhXqU.d.ts.map
85
+ export { GetSlotComponentProps, GetSlotMapResult, createSlotComponent, getSlotMap, slotComponentSymbol, withSlotNameAndSymbol };
86
+ //# sourceMappingURL=getSlotMap-DZlQN8--.d.ts.map
@@ -9,7 +9,6 @@ type PortalProps = {
9
9
  to: AnyString | HTMLElement | ValidHtmlTags | null;
10
10
  };
11
11
  declare function Teleport(props: PortalProps): React.ReactPortal | null;
12
-
13
12
  //#endregion
14
- export { Teleport as Teleport$1 };
15
- //# sourceMappingURL=index-DnaUCh8d.d.ts.map
13
+ export { Teleport };
14
+ //# sourceMappingURL=index-B3N6YbN8.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { __export } from "./chunk-Cl8Af3a2.js";
2
- import { GetSlotComponentProps } from "./getSlotMap-DA_uhXqU.js";
2
+ import { GetSlotComponentProps } from "./getSlotMap-DZlQN8--.js";
3
3
  import * as React$1 from "react";
4
- import * as react3 from "react";
4
+ import * as react6 from "react";
5
5
  import { FileMeta, FileValidationErrorContext, FileValidationOptions } from "@zayne-labs/toolkit-core";
6
6
  import { Prettify } from "@zayne-labs/toolkit-type-helpers";
7
7
  import { DiscriminatedRenderProps, InferProps, PolymorphicProps } from "@zayne-labs/toolkit-react/utils";
@@ -153,7 +153,8 @@ type UseDropZoneProps = {
153
153
  */
154
154
  withDefaultFilePicker?: boolean;
155
155
  };
156
- declare const useDropZone: (props?: UseDropZoneProps) => UseDropZoneResult; //#endregion
156
+ declare const useDropZone: (props?: UseDropZoneProps) => UseDropZoneResult;
157
+ //#endregion
157
158
  //#region src/components/ui/drop-zone/drop-zone.d.ts
158
159
  type DropZoneRenderPropType = DiscriminatedRenderProps<React$1.ReactNode | ((props: UseDropZoneResult) => React$1.ReactNode)>;
159
160
  type DropZoneRootProps = DropZoneRenderPropType & UseDropZoneProps & {
@@ -181,16 +182,12 @@ declare const DropZoneImagePreview: {
181
182
  readonly slotName?: "preview" | undefined;
182
183
  readonly slotSymbol?: symbol;
183
184
  };
184
-
185
- //#endregion
186
- //#region src/components/ui/drop-zone/drop-zone-parts.d.ts
187
185
  declare namespace drop_zone_parts_d_exports {
188
186
  export { DropZoneContainer as Container, DropZoneContext as Context, DropZoneImagePreview as ImagePreview, DropZoneInput as Input, DropZoneRoot as Root };
189
187
  }
190
188
  //#endregion
191
189
  //#region src/components/ui/drop-zone/drop-context.d.ts
192
- declare const DropZoneContextProvider: react3.Context<UseDropZoneResult | null>, useDropZoneContext: () => UseDropZoneResult;
193
-
190
+ declare const DropZoneContextProvider: react6.Context<UseDropZoneResult | null>, useDropZoneContext: () => UseDropZoneResult;
194
191
  //#endregion
195
- export { ContainerProps, DropZoneActions, DropZoneContainer as DropZoneContainer$1, DropZoneContext as DropZoneContext$1, DropZoneImagePreview as DropZoneImagePreview$1, DropZoneInput as DropZoneInput$1, DropZoneRenderPropType, DropZoneRoot as DropZoneRoot$1, DropZoneRootProps, DropZoneState, FileWithPreview, InputProps, UseDropZoneProps, UseDropZoneResult, drop_zone_parts_d_exports, useDropZone as useDropZone$1, useDropZoneContext as useDropZoneContext$1 };
196
- //# sourceMappingURL=index-ASoFjmZ6.d.ts.map
192
+ export { ContainerProps, DropZoneActions, DropZoneContainer, DropZoneContext, DropZoneImagePreview, DropZoneInput, DropZoneRenderPropType, DropZoneRoot, DropZoneRootProps, DropZoneState, FileWithPreview, InputProps, UseDropZoneProps, UseDropZoneResult, drop_zone_parts_d_exports, useDropZone, useDropZoneContext };
193
+ //# sourceMappingURL=index-BilTdK_M.d.ts.map
@@ -24,7 +24,8 @@ type ErrorBoundaryProps = {
24
24
  reason: "keys";
25
25
  }) => void;
26
26
  resetKeys?: unknown[];
27
- }; //#endregion
27
+ };
28
+ //#endregion
28
29
  //#region src/components/common/error-boundary/error-boundary.d.ts
29
30
  type ErrorBoundaryState = {
30
31
  error: Error;
@@ -48,7 +49,6 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryS
48
49
  componentDidUpdate(prevProps: ErrorBoundaryProps, prevState: ErrorBoundaryState): void;
49
50
  render(): React$1.JSX.Element;
50
51
  }
51
-
52
52
  //#endregion
53
53
  //#region src/components/common/error-boundary/error-boundary-context.d.ts
54
54
  type ErrorBoundaryContextType = {
@@ -62,7 +62,6 @@ declare const useErrorBoundary: <TError extends Error>() => {
62
62
  resetBoundary: () => void;
63
63
  showBoundary: (error: TError) => void;
64
64
  };
65
-
66
65
  //#endregion
67
- export { ErrorBoundary as ErrorBoundary$1, ErrorBoundaryContextType, ErrorBoundaryProps, FallbackProps, useErrorBoundary as useErrorBoundary$1, useErrorBoundaryContext as useErrorBoundaryContext$1 };
68
- //# sourceMappingURL=index-BSJ30pGj.d.ts.map
66
+ export { ErrorBoundary, ErrorBoundaryContextType, ErrorBoundaryProps, FallbackProps, useErrorBoundary, useErrorBoundaryContext };
67
+ //# sourceMappingURL=index-BsjcsNQh.d.ts.map
@@ -8,12 +8,9 @@ declare function SlotSlottable({
8
8
  children
9
9
  }: Pick<SlotProps, "children">): React.ReactNode;
10
10
  declare function SlotRoot(props: SlotProps): React.JSX.Element | null;
11
-
12
- //#endregion
13
- //#region src/components/common/slot/slot-parts.d.ts
14
11
  declare namespace slot_parts_d_exports {
15
12
  export { SlotRoot as Root, SlotSlottable as Slottable };
16
13
  }
17
14
  //#endregion
18
- export { SlotRoot as SlotRoot$1, SlotSlottable as SlotSlottable$1, slot_parts_d_exports };
19
- //# sourceMappingURL=index-1UCPJf7B.d.ts.map
15
+ export { SlotRoot, SlotSlottable, slot_parts_d_exports };
16
+ //# sourceMappingURL=index-BwnMUHzm.d.ts.map
@@ -1,5 +1,5 @@
1
- import { ErrorBoundaryProps } from "./index-BSJ30pGj.js";
2
- import * as react1 from "react";
1
+ import { ErrorBoundaryProps } from "./index-BsjcsNQh.js";
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,8 +7,7 @@ type SuspenseWithBoundaryProps = {
7
7
  errorFallback?: ErrorBoundaryProps["fallback"];
8
8
  fallback?: React.ReactNode;
9
9
  };
10
- declare function SuspenseWithBoundary(props: SuspenseWithBoundaryProps): react1.JSX.Element;
11
-
10
+ declare function SuspenseWithBoundary(props: SuspenseWithBoundaryProps): react0.JSX.Element;
12
11
  //#endregion
13
- export { SuspenseWithBoundary as SuspenseWithBoundary$1, SuspenseWithBoundaryProps };
14
- //# sourceMappingURL=index-CqlM1M0j.d.ts.map
12
+ export { SuspenseWithBoundary, SuspenseWithBoundaryProps };
13
+ //# sourceMappingURL=index-CFNg1R-m.d.ts.map
@@ -24,12 +24,9 @@ declare function ShowFallback({
24
24
  declare namespace ShowFallback {
25
25
  var slotSymbol: symbol;
26
26
  }
27
-
28
- //#endregion
29
- //#region src/components/common/show/show-parts.d.ts
30
27
  declare namespace show_parts_d_exports {
31
28
  export { ShowContent as Content, ShowFallback as Fallback, ShowFallback as Otherwise, ShowRoot as Root };
32
29
  }
33
30
  //#endregion
34
- export { ShowContent as ShowContent$1, ShowFallback as ShowFallback$1, ShowRoot as ShowRoot$1, show_parts_d_exports };
35
- //# sourceMappingURL=index-C0XZoIZD.d.ts.map
31
+ export { ShowContent, ShowFallback, ShowRoot, show_parts_d_exports };
32
+ //# sourceMappingURL=index-CGI7EVlK.d.ts.map
@@ -29,7 +29,8 @@ type FieldState = {
29
29
  errors?: UseFormStateReturn<FieldValues>["errors"];
30
30
  isDisabled?: boolean;
31
31
  isInvalid?: boolean;
32
- }; //#endregion
32
+ };
33
+ //#endregion
33
34
  //#region src/components/ui/form/form.d.ts
34
35
  type FieldValues = Record<string, unknown>;
35
36
  type FormRootProps<TFieldValues extends FieldValues> = Partial<FormRootContext> & React$1.ComponentPropsWithoutRef<"form"> & {
@@ -218,12 +219,9 @@ type FormSubscribeToFormStateProps<TFieldValues extends FieldValues> = Discrimin
218
219
  name?: Array<FieldPath<TFieldValues>> | FieldPath<TFieldValues>;
219
220
  };
220
221
  declare function FormSubscribeToFormState<TFieldValues extends FieldValues = FieldValues>(props: FormSubscribeToFormStateProps<TFieldValues>): React$1.ReactNode;
221
-
222
- //#endregion
223
- //#region src/components/ui/form/form-parts.d.ts
224
222
  declare namespace form_parts_d_exports {
225
223
  export { FormFieldControlledField as ControlledField, FormDescription as Description, FormErrorMessage as ErrorMessage, FormErrorMessagePrimitive as ErrorMessagePrimitive, FormField as Field, FormFieldContext as FieldContext, FormFieldController as FieldController, FormInput as Input, FormInputGroup as InputGroup, FormInputLeftItem as InputLeftItem, FormInputPrimitive as InputPrimitive, FormInputRightItem as InputRightItem, FormLabel as Label, FormRoot as Root, FormSelect as Select, FormSubmit as Submit, FormSubscribeToFieldValue as SubscribeToFieldValue, FormSubscribeToFormState as SubscribeToFormState, FormTextArea as TextArea, FormTextAreaPrimitive as TextAreaPrimitive };
226
224
  }
227
225
  //#endregion
228
- export { FieldValues, FormDescription as FormDescription$1, FormErrorMessage as FormErrorMessage$1, FormErrorMessagePrimitive as FormErrorMessagePrimitive$1, FormErrorMessagePrimitiveProps, FormField as FormField$1, FormFieldContext as FormFieldContext$1, FormFieldControlledField as FormFieldControlledField$1, FormFieldController as FormFieldController$1, FormInput as FormInput$1, FormInputGroup as FormInputGroup$1, FormInputLeftItem as FormInputLeftItem$1, FormInputPrimitive as FormInputPrimitive$1, FormInputProps, FormInputRightItem as FormInputRightItem$1, FormLabel as FormLabel$1, FormRoot as FormRoot$1, FormSelect as FormSelect$1, FormSelectPrimitive as FormSelectPrimitive$1, FormSelectProps, FormSubmit as FormSubmit$1, FormSubscribeToFieldValue as FormSubscribeToFieldValue$1, FormSubscribeToFormState as FormSubscribeToFormState$1, FormTextArea as FormTextArea$1, FormTextAreaPrimitive as FormTextAreaPrimitive$1, FormTextAreaProps, form_parts_d_exports, useFormRootContext as useFormRootContext$1, useStrictFormFieldContext as useStrictFormFieldContext$1 };
229
- //# sourceMappingURL=index-DQ1yFGd2.d.ts.map
226
+ export { FieldValues, FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormErrorMessagePrimitiveProps, FormField, FormFieldContext, FormFieldControlledField, FormFieldController, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputProps, FormInputRightItem, FormLabel, FormRoot, FormSelect, FormSelectPrimitive, FormSelectProps, FormSubmit, FormSubscribeToFieldValue, FormSubscribeToFormState, FormTextArea, FormTextAreaPrimitive, FormTextAreaProps, form_parts_d_exports, useFormRootContext, useStrictFormFieldContext };
227
+ //# sourceMappingURL=index-CIM4YPg5.d.ts.map
@@ -11,12 +11,10 @@ type ForProps<TArray> = Prettify<{
11
11
  } & ForRenderProps<TArray>>;
12
12
  declare function For<const TArray>(props: ForProps<TArray>): string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null;
13
13
  declare function ForWithWrapper<TArrayItem, TElement extends React.ElementType = "ul">(props: PolymorphicProps<TElement, ForProps<TArrayItem>>): React.JSX.Element;
14
-
15
14
  //#endregion
16
15
  //#region src/components/common/for/getElementList.d.ts
17
16
  type GetElementListResult<TVariant extends "base" | "withWrapper"> = TVariant extends "base" ? [typeof For] : [typeof ForWithWrapper];
18
17
  declare const getElementList: <TVariant extends "base" | "withWrapper" = "withWrapper">(variant?: TVariant) => GetElementListResult<TVariant>;
19
-
20
18
  //#endregion
21
- export { For as For$1, ForRenderProps, ForWithWrapper as ForWithWrapper$1, getElementList as getElementList$1 };
22
- //# sourceMappingURL=index-BhpBx8dH.d.ts.map
19
+ export { For, ForRenderProps, ForWithWrapper, getElementList };
20
+ //# sourceMappingURL=index-CNE9Cime.d.ts.map
@@ -1,4 +1,4 @@
1
- import * as react8 from "react";
1
+ import * as react7 from "react";
2
2
  import { Prettify, UnknownObject } from "@zayne-labs/toolkit-type-helpers";
3
3
 
4
4
  //#region src/lib/utils/getSlot/getSlot.d.ts
@@ -28,7 +28,7 @@ type SlotOptions = {
28
28
  *
29
29
  * @throws { AssertionError } when throwOnMultipleSlotMatch is true and multiple slots are found
30
30
  */
31
- declare const getSingleSlot: (children: React.ReactNode, SlotComponent: FunctionalComponent, options?: SlotOptions) => react8.ReactNode;
31
+ declare const getSingleSlot: (children: React.ReactNode, SlotComponent: FunctionalComponent, options?: SlotOptions) => react7.ReactNode;
32
32
  type MultipleSlotsOptions = {
33
33
  /**
34
34
  * @description The error message to throw when multiple slots are found for a given slot component
@@ -54,8 +54,7 @@ declare const getMultipleSlots: <const TSlotComponents extends FunctionalCompone
54
54
  /**
55
55
  * @description Returns all children that are not slot elements (i.e., don't match any of the provided slot components)
56
56
  */
57
- declare const getRegularChildren: (children: React.ReactNode, SlotComponentOrComponents: FunctionalComponent | FunctionalComponent[]) => react8.ReactNode[];
58
-
57
+ declare const getRegularChildren: (children: React.ReactNode, SlotComponentOrComponents: FunctionalComponent | FunctionalComponent[]) => react7.ReactNode[];
59
58
  //#endregion
60
59
  export { FunctionalComponent, getMultipleSlots, getRegularChildren, getSingleSlot, matchesAnySlotComponent, matchesSlotComponent };
61
- //# sourceMappingURL=index-D-j2Cn1J.d.ts.map
60
+ //# sourceMappingURL=index-DRiwJkJC.d.ts.map
@@ -75,7 +75,8 @@ type OtherCarouselProps = {
75
75
  children?: React.ReactNode;
76
76
  className?: string;
77
77
  style?: React.CSSProperties;
78
- }; //#endregion
78
+ };
79
+ //#endregion
79
80
  //#region src/components/ui/carousel/carousel.d.ts
80
81
  declare function CarouselContent<TElement extends React$2.ElementType = "article">(props: PolymorphicProps<TElement, CarouselContentProps>): React$2.JSX.Element;
81
82
  declare function CarouselButton(props: CarouselButtonsProps): React$2.JSX.Element;
@@ -89,16 +90,12 @@ declare function CarouselItem({
89
90
  declare function CarouselCaption<TElement extends React$2.ElementType = "div">(props: PolymorphicProps<TElement, OtherCarouselProps>): React$2.JSX.Element;
90
91
  declare function CarouselIndicatorGroup<TArrayItem>(props: CarouselWrapperProps<TArrayItem>): React$2.JSX.Element;
91
92
  declare function CarouselIndicator(props: CarouselIndicatorProps): React$2.JSX.Element;
92
-
93
93
  //#endregion
94
94
  //#region src/components/ui/carousel/carousel-store-context.d.ts
95
95
  declare function CarouselContextProvider<TImages extends ImagesType>(props: CarouselProviderProps<TImages>): React$1.JSX.Element;
96
-
97
- //#endregion
98
- //#region src/components/ui/carousel/carousel-parts.d.ts
99
96
  declare namespace carousel_parts_d_exports {
100
97
  export { CarouselButton as Button, CarouselCaption as Caption, CarouselContent as Content, CarouselControls as Controls, CarouselIndicator as Indicator, CarouselIndicatorGroup as IndicatorGroup, CarouselItem as Item, CarouselItemGroup as ItemGroup, CarouselContextProvider as Root };
101
98
  }
102
99
  //#endregion
103
- export { CarouselButton as CarouselButton$1, CarouselButtonsProps, CarouselCaption as CarouselCaption$1, CarouselContent as CarouselContent$1, CarouselContentProps, CarouselControlProps, CarouselControls as CarouselControls$1, CarouselIndicator as CarouselIndicator$1, CarouselIndicatorGroup as CarouselIndicatorGroup$1, CarouselIndicatorProps, CarouselItem as CarouselItem$1, CarouselItemGroup as CarouselItemGroup$1, CarouselProviderProps, CarouselStore, CarouselStoreApi, CarouselWrapperProps, ImagesType, OtherCarouselProps, carousel_parts_d_exports };
104
- //# sourceMappingURL=index-BC0r1cBF.d.ts.map
100
+ export { CarouselButton, CarouselButtonsProps, CarouselCaption, CarouselContent, CarouselContentProps, CarouselControlProps, CarouselControls, CarouselIndicator, CarouselIndicatorGroup, CarouselIndicatorProps, CarouselItem, CarouselItemGroup, CarouselProviderProps, CarouselStore, CarouselStoreApi, CarouselWrapperProps, ImagesType, OtherCarouselProps, carousel_parts_d_exports };
101
+ //# sourceMappingURL=index-DT8F8QKc.d.ts.map