@zayne-labs/ui-react 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/{chunk-PW4AIAWC.js → chunk-2YCUMTC7.js} +13 -10
- package/dist/esm/chunk-2YCUMTC7.js.map +1 -0
- package/dist/esm/{chunk-RJQIINNX.js → chunk-DW3FXTFL.js} +2 -2
- package/dist/esm/chunk-DW3FXTFL.js.map +1 -0
- package/dist/esm/chunk-ENDWJXPF.js +2 -2
- package/dist/esm/chunk-ENDWJXPF.js.map +1 -1
- package/dist/esm/{chunk-VMJ2L3VC.js → chunk-GVL6BLX5.js} +9 -9
- package/dist/esm/{chunk-VMJ2L3VC.js.map → chunk-GVL6BLX5.js.map} +1 -1
- package/dist/esm/{chunk-PKN52DWQ.js → chunk-NEAL4P57.js} +48 -18
- package/dist/esm/chunk-NEAL4P57.js.map +1 -0
- package/dist/esm/{chunk-E3UC4AGS.js → chunk-Y7TF3SRM.js} +3 -4
- package/dist/esm/chunk-Y7TF3SRM.js.map +1 -0
- package/dist/esm/common/for/index.d.ts +4 -4
- package/dist/esm/common/for/index.js +1 -1
- package/dist/esm/common/index.js +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +5 -5
- package/dist/esm/ui/carousel/index.d.ts +4 -4
- package/dist/esm/ui/carousel/index.js +2 -2
- package/dist/esm/ui/drag-scroll/index.js +1 -1
- package/dist/esm/ui/drop-zone/index.d.ts +5 -4
- package/dist/esm/ui/drop-zone/index.js +1 -1
- package/dist/esm/ui/form/index.d.ts +56 -43
- package/dist/esm/ui/form/index.js +2 -2
- package/dist/esm/ui/index.d.ts +2 -2
- package/dist/esm/ui/index.js +5 -5
- package/package.json +21 -21
- package/dist/esm/chunk-E3UC4AGS.js.map +0 -1
- package/dist/esm/chunk-PKN52DWQ.js.map +0 -1
- package/dist/esm/chunk-PW4AIAWC.js.map +0 -1
- package/dist/esm/chunk-RJQIINNX.js.map +0 -1
|
@@ -12,13 +12,13 @@ var useDropZone = (props) => {
|
|
|
12
12
|
allowedFileTypes,
|
|
13
13
|
children,
|
|
14
14
|
classNames,
|
|
15
|
-
disableInbuiltValidation,
|
|
16
15
|
existingFiles,
|
|
17
16
|
extraInputProps,
|
|
18
17
|
extraRootProps,
|
|
19
18
|
onUpload,
|
|
20
19
|
onUploadError,
|
|
21
20
|
onUploadSuccess,
|
|
21
|
+
render,
|
|
22
22
|
validationSettings,
|
|
23
23
|
validator
|
|
24
24
|
// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- Can be undefined
|
|
@@ -37,15 +37,15 @@ var useDropZone = (props) => {
|
|
|
37
37
|
console.warn("No file selected");
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
const
|
|
40
|
+
const resolvedValidationSettings = isObject(validationSettings) ? { ...validationSettings, allowedFileTypes } : {};
|
|
41
|
+
const validFilesArray = handleFileValidation({
|
|
41
42
|
existingFileArray: existingFiles,
|
|
42
43
|
newFileList: fileList,
|
|
43
44
|
onError: onUploadError,
|
|
44
45
|
onSuccess: onUploadSuccess,
|
|
45
|
-
validationSettings:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const validFilesArray = [...inbuiltValidatedFilesArray, ...validatorFnFileArray];
|
|
46
|
+
validationSettings: resolvedValidationSettings,
|
|
47
|
+
validator
|
|
48
|
+
});
|
|
49
49
|
if (validFilesArray.length === 0) return;
|
|
50
50
|
setAcceptedFiles(validFilesArray);
|
|
51
51
|
onUpload?.({ acceptedFiles: validFilesArray, event });
|
|
@@ -60,7 +60,8 @@ var useDropZone = (props) => {
|
|
|
60
60
|
toggleIsDragging(false);
|
|
61
61
|
};
|
|
62
62
|
const getRenderProps = () => ({ acceptedFiles, inputRef, isDragging });
|
|
63
|
-
const
|
|
63
|
+
const computedChildren = children ?? render;
|
|
64
|
+
const getChildren = () => isFunction(computedChildren) ? computedChildren(getRenderProps()) : computedChildren;
|
|
64
65
|
const getRootProps = (rootProps) => {
|
|
65
66
|
const mergedRootProps = mergeTwoProps(extraRootProps, rootProps);
|
|
66
67
|
return {
|
|
@@ -94,14 +95,16 @@ var useDropZone = (props) => {
|
|
|
94
95
|
"data-part": "input",
|
|
95
96
|
"data-scope": "dropzone",
|
|
96
97
|
onChange: (event) => {
|
|
97
|
-
handleFileUpload(event);
|
|
98
98
|
mergedInputProps.onChange?.(event);
|
|
99
|
+
handleFileUpload(event);
|
|
99
100
|
},
|
|
100
101
|
ref: composeRefs([inputRef, mergedInputProps.ref]),
|
|
101
102
|
type: "file"
|
|
102
103
|
};
|
|
103
104
|
};
|
|
104
105
|
return {
|
|
106
|
+
acceptedFiles,
|
|
107
|
+
computedChildren,
|
|
105
108
|
getChildren,
|
|
106
109
|
getInputProps,
|
|
107
110
|
getRenderProps,
|
|
@@ -121,5 +124,5 @@ function DropZone(props) {
|
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
export { DropZone, useDropZone };
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
125
|
-
//# sourceMappingURL=chunk-
|
|
127
|
+
//# sourceMappingURL=chunk-2YCUMTC7.js.map
|
|
128
|
+
//# sourceMappingURL=chunk-2YCUMTC7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/ui/drop-zone/use-drop-zone.ts","../../src/components/ui/drop-zone/drop-zone.tsx"],"names":[],"mappings":";;;;;;;;AA0Da,IAAA,WAAA,GAAc,CAAC,KAA4B,KAAA;AACvD,EAAM,MAAA,QAAA,GAAW,OAAyB,IAAI,CAAA;AAE9C,EAAM,MAAA;AAAA,IACL,gBAAA;AAAA,IACA,QAAA;AAAA,IACA,UAAA;AAAA,IACA,aAAA;AAAA,IACA,eAAA;AAAA,IACA,cAAA;AAAA,IACA,QAAA;AAAA,IACA,aAAA;AAAA,IACA,eAAA;AAAA,IACA,MAAA;AAAA,IACA,kBAAA;AAAA,IACA;AAAA;AAAA,GAED,GAAI,SAAS,EAAC;AAEd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AAA,MAAA;AAAA,MAC1E,SAAW,EAAA,OAAA;AAAA,QACV,mDAAA;AAAA,QACA,UAAY,EAAA,KAAA;AAAA,QACZ,gBAAiB,CAAA;AAAA,OAClB;AAAA,MACA,kBAAoB,EAAA,UAAA;AAAA,MACpB,WAAa,EAAA,OAAA;AAAA,MACb,YAAc,EAAA,UAAA;AAAA,MACd,QAAA,EAAU,CAAC,KAA+C,KAAA;AACzD,QAAA,gBAAA,CAAiB,WAAW,KAAK,CAAA;AACjC,QAAA,gBAAA,CAAiB,KAAK,CAAA;AAAA,OACvB;AAAA,MACA,KAAK,WAAY,CAAA,CAAC,QAAU,EAAA,gBAAA,CAAiB,GAAG,CAAC,CAAA;AAAA,MACjD,IAAM,EAAA;AAAA,KACP;AAAA,GACD;AAEA,EAAO,OAAA;AAAA,IACN,aAAA;AAAA,IACA,gBAAA;AAAA,IACA,WAAA;AAAA,IACA,aAAA;AAAA,IACA,cAAA;AAAA,IACA,YAAA;AAAA,IACA,eAAA;AAAA,IACA,cAAA;AAAA,IACA,gBAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,GACD;AACD;;;AChMA,SAAS,SAAS,KAAyB,EAAA;AAC1C,EAAM,MAAA,GAAA,GAAM,YAAY,KAAK,CAAA;AAE7B,EAAA,uBACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,GAAG,GAAA,CAAI,cACZ,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,OAAO,EAAA,EAAA,GAAG,IAAI,aAAc,EAAA,EAAG,CAE/B,EAAA,GAAA,CAAI,aACN,CAAA;AAEF","file":"chunk-2YCUMTC7.js","sourcesContent":["\"use client\";\n\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport { type FileValidationOptions, handleFileValidation } from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef, useToggle } from \"@zayne-labs/toolkit-react\";\nimport {\n\ttype DiscriminatedRenderProps,\n\ttype InferProps,\n\tcomposeRefs,\n\tmergeTwoProps,\n} from \"@zayne-labs/toolkit-react/utils\";\nimport { isFunction, isObject } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useRef, useState } from \"react\";\n\ntype RenderProps = {\n\tacceptedFiles: File[];\n\tinputRef: React.RefObject<HTMLInputElement | null>;\n\tisDragging: boolean;\n};\n\nexport type RootProps = InferProps<\"div\"> & {\n\tclassNames?: { activeDrag?: string; base?: string };\n};\n\nexport type InputProps = InferProps<\"input\">;\n\ntype DropZoneRenderProps = DiscriminatedRenderProps<\n\tReact.ReactNode | ((props: RenderProps) => React.ReactNode)\n>;\n\nexport type UseDropZoneProps = DropZoneRenderProps & {\n\tallowedFileTypes?: string[];\n\n\tclassNames?: { activeDrag?: string; base?: string; input?: string };\n\n\texistingFiles?: File[];\n\n\textraInputProps?: InputProps;\n\n\textraRootProps?: RootProps;\n\n\tonUpload?: (details: {\n\t\tacceptedFiles: File[];\n\t\tevent: React.ChangeEvent<HTMLInputElement> | React.DragEvent<HTMLDivElement>;\n\t}) => void;\n\n\tonUploadError?: FileValidationOptions[\"onError\"];\n\n\tonUploadSuccess?: FileValidationOptions[\"onSuccess\"];\n\n\tvalidationSettings?: {\n\t\tdisallowDuplicates?: boolean;\n\t\tfileLimit?: number;\n\t\tmaxFileSize?: number;\n\t};\n\tvalidator?: (context: { existingFileArray: File[] | undefined; newFileList: FileList }) => File[];\n};\n\nexport const useDropZone = (props: UseDropZoneProps) => {\n\tconst inputRef = useRef<HTMLInputElement>(null);\n\n\tconst {\n\t\tallowedFileTypes,\n\t\tchildren,\n\t\tclassNames,\n\t\texistingFiles,\n\t\textraInputProps,\n\t\textraRootProps,\n\t\tonUpload,\n\t\tonUploadError,\n\t\tonUploadSuccess,\n\t\trender,\n\t\tvalidationSettings,\n\t\tvalidator,\n\t\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- Can be undefined\n\t} = props ?? {};\n\n\tconst [isDragging, toggleIsDragging] = useToggle(false);\n\n\tconst [acceptedFiles, setAcceptedFiles] = useState<File[]>([]);\n\n\tconst handleFileUpload = useCallbackRef(\n\t\t(event: React.ChangeEvent<HTMLInputElement> | React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (event.defaultPrevented) return;\n\n\t\t\tif (event.type === \"drop\") {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttoggleIsDragging(false);\n\t\t\t}\n\n\t\t\tconst fileList =\n\t\t\t\tevent.type === \"drop\"\n\t\t\t\t\t? (event as React.DragEvent).dataTransfer.files\n\t\t\t\t\t: (event as React.ChangeEvent<HTMLInputElement>).target.files;\n\n\t\t\tif (fileList === null) {\n\t\t\t\tconsole.warn(\"No file selected\");\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst resolvedValidationSettings = isObject(validationSettings)\n\t\t\t\t? { ...validationSettings, allowedFileTypes }\n\t\t\t\t: {};\n\n\t\t\tconst validFilesArray = handleFileValidation({\n\t\t\t\texistingFileArray: existingFiles,\n\t\t\t\tnewFileList: fileList,\n\t\t\t\tonError: onUploadError,\n\t\t\t\tonSuccess: onUploadSuccess,\n\t\t\t\tvalidationSettings: resolvedValidationSettings,\n\t\t\t\tvalidator,\n\t\t\t});\n\n\t\t\tif (validFilesArray.length === 0) return;\n\n\t\t\tsetAcceptedFiles(validFilesArray);\n\n\t\t\tonUpload?.({ acceptedFiles: validFilesArray, event });\n\t\t}\n\t);\n\n\tconst handleDragOver = (event: React.DragEvent<HTMLDivElement>) => {\n\t\tevent.preventDefault();\n\t\ttoggleIsDragging(true);\n\t};\n\n\tconst handleDragLeave = (event: React.DragEvent<HTMLDivElement>) => {\n\t\tevent.preventDefault();\n\t\ttoggleIsDragging(false);\n\t};\n\n\tconst getRenderProps = () => ({ acceptedFiles, inputRef, isDragging }) satisfies RenderProps;\n\n\tconst computedChildren = children ?? render;\n\n\tconst getChildren = () =>\n\t\tisFunction(computedChildren) ? computedChildren(getRenderProps()) : computedChildren;\n\n\tconst getRootProps = (rootProps?: RootProps) => {\n\t\tconst mergedRootProps = mergeTwoProps(extraRootProps, rootProps);\n\n\t\treturn {\n\t\t\t...mergedRootProps,\n\t\t\tclassName: cnMerge(\n\t\t\t\t\"relative isolate flex flex-col\",\n\t\t\t\tmergedRootProps.className,\n\t\t\t\tclassNames?.base,\n\t\t\t\tisDragging && [\"opacity-60\", classNames?.activeDrag, rootProps?.classNames?.activeDrag]\n\t\t\t),\n\t\t\t\"data-active-drag\": isDragging,\n\t\t\t\"data-part\": \"root\",\n\t\t\t\"data-scope\": \"dropzone\",\n\t\t\tonDragEnter: handleDragOver,\n\t\t\tonDragLeave: handleDragLeave,\n\t\t\tonDragOver: handleDragOver,\n\t\t\tonDrop: handleFileUpload,\n\t\t};\n\t};\n\n\tconst getInputProps = (inputProps?: InputProps) => {\n\t\tconst mergedInputProps = mergeTwoProps(extraInputProps, inputProps);\n\n\t\treturn {\n\t\t\t...mergedInputProps,\n\t\t\taccept: allowedFileTypes ? allowedFileTypes.join(\", \") : mergedInputProps.accept,\n\t\t\tclassName: cnMerge(\n\t\t\t\t\"absolute inset-0 z-[100] cursor-pointer opacity-0\",\n\t\t\t\tclassNames?.input,\n\t\t\t\tmergedInputProps.className\n\t\t\t),\n\t\t\t\"data-active-drag\": isDragging,\n\t\t\t\"data-part\": \"input\",\n\t\t\t\"data-scope\": \"dropzone\",\n\t\t\tonChange: (event: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\t\tmergedInputProps.onChange?.(event);\n\t\t\t\thandleFileUpload(event);\n\t\t\t},\n\t\t\tref: composeRefs([inputRef, mergedInputProps.ref]),\n\t\t\ttype: \"file\",\n\t\t};\n\t};\n\n\treturn {\n\t\tacceptedFiles,\n\t\tcomputedChildren,\n\t\tgetChildren,\n\t\tgetInputProps,\n\t\tgetRenderProps,\n\t\tgetRootProps,\n\t\thandleDragLeave,\n\t\thandleDragOver,\n\t\thandleFileUpload,\n\t\tinputRef,\n\t\tisDragging,\n\t};\n};\n","import * as React from \"react\";\n\nimport { type UseDropZoneProps, useDropZone } from \"./use-drop-zone\";\n\nfunction DropZone(props: UseDropZoneProps) {\n\tconst api = useDropZone(props);\n\n\treturn (\n\t\t<div {...api.getRootProps()}>\n\t\t\t<input {...api.getInputProps()} />\n\n\t\t\t{api.getChildren()}\n\t\t</div>\n\t);\n}\n\nexport { DropZone };\n"]}
|
|
@@ -40,5 +40,5 @@ var getElementList = (variant) => {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export { ForBase, ForList, getElementList };
|
|
43
|
-
//# sourceMappingURL=chunk-
|
|
44
|
-
//# sourceMappingURL=chunk-
|
|
43
|
+
//# sourceMappingURL=chunk-DW3FXTFL.js.map
|
|
44
|
+
//# sourceMappingURL=chunk-DW3FXTFL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/common/for/for.tsx","../../src/components/common/for/getElementList.ts"],"names":[],"mappings":";;;;AA+BO,SAAS,QAAoB,KAA8D,EAAA;AACjG,EAAA,MAAM,EAAE,QAAA,EAAU,IAAM,EAAA,QAAA,EAAU,QAAW,GAAA,KAAA;AAE7C,EAAA,IAAI,IAAQ,IAAA,IAAA,IAAS,QAAS,CAAA,IAAI,CAAK,IAAA,IAAA,KAAS,CAAO,IAAA,OAAA,CAAQ,IAAI,CAAA,IAAK,IAAK,CAAA,MAAA,KAAW,CAAI,EAAA;AAC3F,IAAO,OAAA,QAAA;AAAA;AAGR,EAAM,MAAA,aAAA,GAAgB,QAAS,CAAA,IAAI,CAC/B,GAAA,CAAC,GAAG,KAAA,CAAM,IAAI,CAAA,CAAE,IAAK,EAAC,CACtB,GAAA,IAAA;AAEJ,EAAI,IAAA,aAAA,CAAc,WAAW,CAAG,EAAA;AAC/B,IAAO,OAAA,QAAA;AAAA;AAGR,EAAA,MAAM,cAAiB,GAAA,aAAA,CAAc,GAAI,CAAA,CAAA,GAAI,MAAiD,KAAA;AAC7F,IAAI,IAAA,OAAO,aAAa,UAAY,EAAA;AACnC,MAAO,OAAA,QAAA,CAAS,GAAG,MAAM,CAAA;AAAA;AAG1B,IAAO,OAAA,MAAA,CAAO,GAAG,MAAM,CAAA;AAAA,GACvB,CAAA;AAED,EAAO,OAAA,cAAA;AACR;AAMO,SAAS,QACf,KACC,EAAA;AACD,EAAM,MAAA,EAAE,EAAI,EAAA,aAAA,GAAgB,IAAM,EAAA,QAAA,EAAU,SAAW,EAAA,IAAA,EAAM,GAAK,EAAA,MAAA,EAAQ,GAAG,eAAA,EAAoB,GAAA,KAAA;AAEjG,EAAA,uBACE,KAAA,CAAA,aAAA,CAAA,aAAA,EAAA,EAAc,GAAU,EAAA,SAAA,EAAuB,GAAG,eAClD,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,OAAS,EAAA,EAAA,GAAI,EAAE,QAAA,EAAU,IAAM,EAAA,MAAA,IAAmC,CACpE,CAAA;AAEF;;;ACjEM,IAAA,cAAA,GAAiB,CACtB,OACoC,KAAA;AACpC,EAAA,QAAQ,OAAS;AAAA,IAChB,KAAK,MAAQ,EAAA;AACZ,MAAA,OAAO,CAAC,OAAO,CAAA;AAAA;AAChB,IACA,KAAK,aAAe,EAAA;AACnB,MAAA,OAAO,CAAC,OAAO,CAAA;AAAA;AAChB,IACA,SAAS;AACR,MAAA,OAAO,CAAC,OAAO,CAAA;AAAA;AAChB;AAEF","file":"chunk-DW3FXTFL.js","sourcesContent":["import * as React from \"react\";\n\nimport type { DiscriminatedRenderProps, PolymorphicProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { type Prettify, isArray, isNumber } from \"@zayne-labs/toolkit-type-helpers\";\n\n// prettier-ignore\ntype RenderPropFn<TArrayItem> = (\n\titem: TArrayItem,\n\tindex: number,\n\tarray: TArrayItem[]\n) => React.ReactNode;\n\nexport type ForRenderProps<TArrayItem> = DiscriminatedRenderProps<RenderPropFn<TArrayItem>>;\n\n/* eslint-disable perfectionist/sort-intersection-types -- Prefer the object to come first before the render props */\ntype ForProps<TArrayItem> = Prettify<\n\t{\n\t\teach: TArrayItem[];\n\t\tfallback?: React.ReactNode;\n\t} & ForRenderProps<TArrayItem>\n>;\n\ntype ForPropsWithNumber<TNumber> = Prettify<\n\t{\n\t\teach: TNumber;\n\t\tfallback?: React.ReactNode;\n\t} & ForRenderProps<TNumber>\n>;\n\n/* eslint-enable perfectionist/sort-intersection-types -- Prefer the object to come first before the render props */\n\nexport function ForBase<TArrayItem>(props: ForProps<TArrayItem> | ForPropsWithNumber<TArrayItem>) {\n\tconst { children, each, fallback, render } = props;\n\n\tif (each == null || (isNumber(each) && each === 0) || (isArray(each) && each.length === 0)) {\n\t\treturn fallback;\n\t}\n\n\tconst resolvedArray = isNumber(each)\n\t\t? ([...Array(each).keys()] as TArrayItem[])\n\t\t: (each as TArrayItem[]);\n\n\tif (resolvedArray.length === 0) {\n\t\treturn fallback;\n\t}\n\n\tconst JSXElementList = resolvedArray.map((...params: Parameters<RenderPropFn<TArrayItem>>) => {\n\t\tif (typeof children === \"function\") {\n\t\t\treturn children(...params);\n\t\t}\n\n\t\treturn render(...params);\n\t});\n\n\treturn JSXElementList;\n}\n\ntype ForListProps<TArrayItem> = {\n\tclassName?: string;\n} & (ForProps<TArrayItem> | ForPropsWithNumber<TArrayItem>);\n\nexport function ForList<TArrayItem, TElement extends React.ElementType = \"ul\">(\n\tprops: PolymorphicProps<TElement, ForListProps<TArrayItem>>\n) {\n\tconst { as: ListContainer = \"ul\", children, className, each, ref, render, ...restOfListProps } = props;\n\n\treturn (\n\t\t<ListContainer ref={ref} className={className} {...restOfListProps}>\n\t\t\t<ForBase {...({ children, each, render } as ForProps<TArrayItem>)} />\n\t\t</ListContainer>\n\t);\n}\n","import { ForBase, ForList } from \"./for\";\n\ntype GetElementListResult<TVariant extends \"base\" | \"withWrapper\"> = TVariant extends \"base\"\n\t? [typeof ForBase]\n\t: [typeof ForList];\n\nconst getElementList = <TVariant extends \"base\" | \"withWrapper\" = \"withWrapper\">(\n\tvariant?: TVariant\n): GetElementListResult<TVariant> => {\n\tswitch (variant) {\n\t\tcase \"base\": {\n\t\t\treturn [ForBase] as never;\n\t\t}\n\t\tcase \"withWrapper\": {\n\t\t\treturn [ForList] as never;\n\t\t}\n\t\tdefault: {\n\t\t\treturn [ForList] as never;\n\t\t}\n\t}\n};\n\nexport { getElementList };\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Children, isValidElement, cloneElement } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { composeRefs, mergeProps } from '@zayne-labs/toolkit-react/utils';
|
|
4
4
|
import { isArray } from '@zayne-labs/toolkit-type-helpers';
|
|
5
5
|
|
|
6
6
|
// src/components/common/slot/slot.tsx
|
|
@@ -25,7 +25,7 @@ function Slot(props) {
|
|
|
25
25
|
}
|
|
26
26
|
return child;
|
|
27
27
|
});
|
|
28
|
-
return /* @__PURE__ */ React.createElement(SlotClone, { ...restOfSlotProps }, isValidElement(newElement) && cloneElement(newElement,
|
|
28
|
+
return /* @__PURE__ */ React.createElement(SlotClone, { ...restOfSlotProps }, isValidElement(newElement) && cloneElement(newElement, void 0, newElementChildren));
|
|
29
29
|
}
|
|
30
30
|
return /* @__PURE__ */ React.createElement(SlotClone, { ...restOfSlotProps }, children);
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/common/slot/slot.tsx"],"names":[],"mappings":";;;;;;AAYO,SAAS,SAAA,CAAU,EAAE,QAAA,EAAyC,EAAA;AACpE,EAAO,OAAA,QAAA;AACR;AAEA,IAAM,WAAA,GAAc,CAAC,KAAwD,KAAA;AAC5E,EAAA,OAAO,cAAe,CAAA,KAAK,CAAK,IAAA,KAAA,CAAM,IAAS,KAAA,SAAA;AAChD,CAAA;AAMO,SAAS,KAAK,KAAkB,EAAA;AACtC,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,eAAA,EAAoB,GAAA,KAAA;AAEzC,EAAA,MAAM,gBAAgB,OAAyB,CAAA,QAAQ,CAAI,GAAA,QAAA,GAAW,CAAC,QAAQ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AK,CAAA;AAAA,IAC7C,KAAK,YAAe,GAAA,WAAA,CAAY,CAAC,YAAc,EAAA,QAA8B,CAAC,CAAI,GAAA;AAAA,GACnF;AAEA,EAAO,OAAA,YAAA,CAAa,UAAU,WAAW,CAAA;AAC1C","file":"chunk-ENDWJXPF.js","sourcesContent":["import * as React from \"react\";\n\nimport { type InferProps, composeRefs, mergeProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { isArray } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Children, cloneElement, isValidElement } from \"react\";\n\ntype SlotProps = InferProps<HTMLElement>;\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * ----------------------------------------------------------------------------------------------- */\n\nexport function Slottable({ children }: Pick<SlotProps, \"children\">) {\n\treturn children;\n}\n\nconst isSlottable = (child: React.ReactNode): child is React.ReactElement => {\n\treturn isValidElement(child) && child.type === Slottable;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * ----------------------------------------------------------------------------------------------- */\n\nexport function Slot(props: SlotProps) {\n\tconst { children, ...restOfSlotProps } = props;\n\n\tconst childrenArray = isArray<React.ReactNode>(children) ? children : [children];\n\tconst slottable = childrenArray.find((element) => isSlottable(element));\n\n\tif (slottable) {\n\t\t// == The new element to render is the one passed as a child of `Slottable`\n\t\tconst newElement = (slottable.props as SlotProps).children;\n\n\t\tif (Children.count(newElement) > 1) {\n\t\t\treturn Children.only(null);\n\t\t}\n\n\t\tconst newElementChildren = childrenArray.map((child) => {\n\t\t\tif (child === slottable) {\n\t\t\t\t// == Because the new element will be the one rendered, we are only interested in grabbing its children (`newElement.props.children`)\n\t\t\t\treturn isValidElement<SlotProps>(newElement) && newElement.props.children;\n\t\t\t}\n\n\t\t\treturn child;\n\t\t});\n\n\t\treturn (\n\t\t\t<SlotClone {...restOfSlotProps}>\n\t\t\t\t{isValidElement(newElement) && cloneElement(newElement, undefined, newElementChildren)}\n\t\t\t</SlotClone>\n\t\t);\n\t}\n\n\treturn <SlotClone {...restOfSlotProps}>{children}</SlotClone>;\n}\n\ntype SlotCloneProps = {\n\tchildren: React.ReactNode;\n\tref?: React.RefObject<HTMLElement>;\n};\n\ntype UnknownProps = Record<string, unknown>;\n\nfunction SlotClone(props: SlotCloneProps) {\n\tconst { children, ref: forwardedRef, ...restOfSlotProps } = props;\n\n\tif (!isValidElement<UnknownProps>(children)) {\n\t\treturn Children.count(children) > 1 ? Children.only(null) : null;\n\t}\n\n\tconst childRef = children.props.ref ?? (children as unknown as UnknownProps).ref;\n\n\tconst clonedProps = {\n\t\t...mergeProps(restOfSlotProps, children.props),\n\t\tref: forwardedRef ? composeRefs([forwardedRef, childRef as React.Ref<unknown>]) : childRef,\n\t};\n\n\treturn cloneElement(children, clonedProps);\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cnMerge } from './chunk-OHG7GB7O.js';
|
|
2
|
-
import { getElementList } from './chunk-
|
|
2
|
+
import { getElementList } from './chunk-DW3FXTFL.js';
|
|
3
3
|
import { __export } from './chunk-PZ5AY32C.js';
|
|
4
4
|
import * as React3 from 'react';
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
@@ -183,7 +183,7 @@ function CarouselControls(props) {
|
|
|
183
183
|
}
|
|
184
184
|
)));
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function CarouselItemGroup(props) {
|
|
187
187
|
const { children, className, each, render } = props;
|
|
188
188
|
const [ItemList] = getElementList("base");
|
|
189
189
|
const currentSlide = useCarouselStoreContext((state) => state.currentSlide);
|
|
@@ -193,7 +193,7 @@ function CarouselItemWrapper(props) {
|
|
|
193
193
|
{
|
|
194
194
|
"data-id": "Carousel Image Wrapper",
|
|
195
195
|
className: cnMerge(
|
|
196
|
-
`flex w-full shrink-0
|
|
196
|
+
`flex w-full shrink-0 [transform:translate3d(var(--translate-distance),0,0)] snap-center
|
|
197
197
|
[transition:transform_800ms_ease]`,
|
|
198
198
|
className
|
|
199
199
|
),
|
|
@@ -218,7 +218,7 @@ function CarouselCaption(props) {
|
|
|
218
218
|
const { as: HtmlElement = "div", children, className } = props;
|
|
219
219
|
return /* @__PURE__ */ React3.createElement(HtmlElement, { "data-id": "Carousel Caption", className: cnMerge("absolute z-10", className) }, children);
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function CarouselIndicatorGroup(props) {
|
|
222
222
|
const { children, className, each, render } = props;
|
|
223
223
|
const images = useCarouselStoreContext((state) => each ?? state.images);
|
|
224
224
|
const [IndicatorList] = getElementList("base");
|
|
@@ -263,12 +263,12 @@ __export(carousel_parts_exports, {
|
|
|
263
263
|
Content: () => CarouselContent,
|
|
264
264
|
Controls: () => CarouselControls,
|
|
265
265
|
Indicator: () => CarouselIndicator,
|
|
266
|
-
IndicatorWrapper: () =>
|
|
266
|
+
IndicatorWrapper: () => CarouselIndicatorGroup,
|
|
267
267
|
Item: () => CarouselItem,
|
|
268
|
-
ItemWrapper: () =>
|
|
268
|
+
ItemWrapper: () => CarouselItemGroup,
|
|
269
269
|
Root: () => CarouselContextProvider
|
|
270
270
|
});
|
|
271
271
|
|
|
272
|
-
export { CarouselButton, CarouselCaption, CarouselContent, CarouselControls, CarouselIndicator,
|
|
273
|
-
//# sourceMappingURL=chunk-
|
|
274
|
-
//# sourceMappingURL=chunk-
|
|
272
|
+
export { CarouselButton, CarouselCaption, CarouselContent, CarouselControls, CarouselIndicator, CarouselIndicatorGroup, CarouselItem, CarouselItemGroup, carousel_parts_exports };
|
|
273
|
+
//# sourceMappingURL=chunk-GVL6BLX5.js.map
|
|
274
|
+
//# sourceMappingURL=chunk-GVL6BLX5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/icons/ChevronLeftIcon.tsx","../../src/components/ui/carousel/carousel-store-context.tsx","../../src/components/ui/carousel/useCarouselOptions.ts","../../src/components/ui/carousel/carousel.tsx","../../src/components/ui/carousel/carousel-parts.ts"],"names":["React","React2"],"mappings":";;;;;;;;;AAEA,IAAM,kBAAkB,CA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AAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACA,eAAa,YAAiB,KAAA,YAAA;AAAA,MAC9B,IAAK,EAAA,QAAA;AAAA,MACL,OAAA,EAAS,MAAM,SAAA,CAAU,YAAY,CAAA;AAAA,MACrC,SAAW,EAAA,OAAA;AAAA,QACV,0BAAA;AAAA,QACA,UAAY,EAAA,MAAA;AAAA,QACZ,YAAiB,KAAA,YAAA,IAAgB,CAAC,iBAAA,EAAmB,YAAY,SAAS;AAAA;AAC3E;AAAA,GAEF,CAAA;AAEF;;;AC7OA,IAAA,sBAAA,GAAA;AAAA,QAAA,CAAA,sBAAA,EAAA;AAAA,EAAA,MAAA,EAAA,MAAA,cAAA;AAAA,EAAA,OAAA,EAAA,MAAA,eAAA;AAAA,EAAA,OAAA,EAAA,MAAA,eAAA;AAAA,EAAA,QAAA,EAAA,MAAA,gBAAA;AAAA,EAAA,SAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,gBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,IAAA,EAAA,MAAA,YAAA;AAAA,EAAA,WAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,IAAA,EAAA,MAAA;AAAA,CAAA,CAAA","file":"chunk-VMJ2L3VC.js","sourcesContent":["import * as React from \"react\";\n\nconst ChevronLeftIcon = (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<g fill=\"none\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\">\n\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\" />\n\t\t\t<path d=\"m14 16l-4-4l4-4\" />\n\t\t</g>\n\t</svg>\n);\n\nexport { ChevronLeftIcon };\n","import * as React from \"react\";\n\nimport { useConstant } from \"@zayne-labs/toolkit-react\";\nimport { createZustandContext } from \"@zayne-labs/toolkit-react/zustand\";\nimport type { PrettyOmit } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useEffect } from \"react\";\nimport { create } from \"zustand\";\nimport type { CarouselProviderProps, CarouselStore, ImagesType } from \"./types\";\n\nconst [Provider, useCarouselStoreContext] = createZustandContext<CarouselStore>({\n\thookName: \"useCarouselStore\",\n\tname: \"CarouselStoreContext\",\n\tproviderName: \"CarouselContextProvider\",\n});\n\n// CarouselStore Creation\nconst createCarouselStore = <TImages extends ImagesType>(\n\tstoreValues: PrettyOmit<CarouselProviderProps<TImages>, \"children\">\n) => {\n\tconst { images, onSlideBtnClick } = storeValues;\n\n\tconst useInitCarouselStore = create<CarouselStore<TImages>>()((set, get) => ({\n\t\tcurrentSlide: 0,\n\t\timages,\n\t\tmaxSlide: images.length - 1,\n\n\t\t/* eslint-disable perfectionist/sort-objects -- actions should be last */\n\t\tactions: {\n\t\t\t/* eslint-enable perfectionist/sort-objects -- actions should be last */\n\n\t\t\tgoToNextSlide: () => {\n\t\t\t\tconst { currentSlide, maxSlide } = get();\n\t\t\t\tconst { goToSlide } = get().actions;\n\n\t\t\t\tif (currentSlide === maxSlide) {\n\t\t\t\t\tgoToSlide(0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tgoToSlide(currentSlide + 1);\n\t\t\t},\n\n\t\t\tgoToPreviousSlide: () => {\n\t\t\t\tconst { currentSlide, maxSlide } = get();\n\t\t\t\tconst { goToSlide } = get().actions;\n\n\t\t\t\tif (currentSlide === 0) {\n\t\t\t\t\tgoToSlide(maxSlide);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tgoToSlide(currentSlide - 1);\n\t\t\t},\n\n\t\t\tgoToSlide: (newValue) => {\n\t\t\t\tonSlideBtnClick?.();\n\n\t\t\t\tset({ currentSlide: newValue });\n\t\t\t},\n\t\t},\n\t}));\n\n\treturn useInitCarouselStore;\n};\n\nconst useCarousel = <TImages extends ImagesType>(\n\tprops: Omit<CarouselProviderProps<TImages>, \"children\">\n) => {\n\tconst { images, onSlideBtnClick } = props;\n\n\tconst useInitCarouselStore = useConstant(() => createCarouselStore({ images, onSlideBtnClick }));\n\n\t// == To set images again when a page is mounted, preventing stale images from previous page\n\tuseEffect(() => {\n\t\tuseInitCarouselStore.setState({ images });\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- useInitCarouselStore is stable\n\t}, [images]);\n\n\treturn useInitCarouselStore;\n};\n\n// == Provider Component\nfunction CarouselContextProvider<TImages extends ImagesType>(props: CarouselProviderProps<TImages>) {\n\tconst { children, images, onSlideBtnClick } = props;\n\n\tconst useInitCarouselStore = useCarousel({ images, onSlideBtnClick });\n\n\treturn <Provider value={useInitCarouselStore}>{children}</Provider>;\n}\n\n// eslint-disable-next-line react-refresh/only-export-components -- It's fine\nexport { useCarouselStoreContext, CarouselContextProvider };\n","import { useAnimationInterval, useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport { useState } from \"react\";\nimport { useCarouselStoreContext } from \"./carousel-store-context\";\n\ntype CarouselOptions = {\n\tautoSlideInterval?: number;\n\thasAutoSlide?: boolean;\n\tshouldPauseOnHover?: boolean;\n};\n\nconst useCarouselOptions = (options: CarouselOptions = {}) => {\n\tconst { autoSlideInterval = 5000, hasAutoSlide = false, shouldPauseOnHover = false } = options;\n\n\tconst { goToNextSlide } = useCarouselStoreContext((state) => state.actions);\n\n\tconst [isPaused, setIsPaused] = useState(false);\n\n\tconst shouldAutoSlide = hasAutoSlide && !isPaused;\n\n\tuseAnimationInterval({\n\t\tintervalDuration: shouldAutoSlide ? autoSlideInterval : null,\n\t\tonAnimation: goToNextSlide,\n\t});\n\n\tconst pauseAutoSlide = useCallbackRef(() => shouldPauseOnHover && setIsPaused(true));\n\n\tconst resumeAutoSlide = useCallbackRef(() => shouldPauseOnHover && setIsPaused(false));\n\n\treturn { pauseAutoSlide, resumeAutoSlide };\n};\n\nexport { useCarouselOptions };\n","\"use client\";\n\nimport * as React from \"react\";\n\nimport { getElementList } from \"@/components/common/for\";\nimport { ChevronLeftIcon } from \"@/components/icons\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport type { MyCustomCss, PolymorphicProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { useCarouselStoreContext } from \"./carousel-store-context\";\nimport type {\n\tCarouselButtonsProps,\n\tCarouselContentProps,\n\tCarouselControlProps,\n\tCarouselIndicatorProps,\n\tCarouselWrapperProps,\n\tOtherCarouselProps,\n} from \"./types\";\nimport { useCarouselOptions } from \"./useCarouselOptions\";\n\n// TODO - Add dragging and swiping support\nexport function CarouselContent<TElement extends React.ElementType = \"article\">(\n\tprops: PolymorphicProps<TElement, CarouselContentProps>\n) {\n\tconst {\n\t\tas: HtmlElement = \"article\",\n\t\tautoSlideInterval,\n\t\tchildren,\n\t\tclassNames,\n\t\thasAutoSlide,\n\t\tshouldPauseOnHover,\n\t} = props;\n\n\tconst { pauseAutoSlide, resumeAutoSlide } = useCarouselOptions({\n\t\tautoSlideInterval,\n\t\thasAutoSlide,\n\t\tshouldPauseOnHover,\n\t});\n\n\t// FIXME - Prevent touch swipe on mobile using a cover element or allow swipe but it must update the state appriopriately\n\treturn (\n\t\t<HtmlElement\n\t\t\tdata-id=\"Carousel\"\n\t\t\tclassName={cnMerge(\"relative select-none\", classNames?.base)}\n\t\t\tonMouseEnter={pauseAutoSlide}\n\t\t\tonMouseLeave={resumeAutoSlide}\n\t\t>\n\t\t\t<div\n\t\t\t\tdata-id=\"Scroll Container\"\n\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t\"flex size-full overflow-x-scroll [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\",\n\t\t\t\t\tclassNames?.scrollContainer\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</HtmlElement>\n\t);\n}\n\nexport function CarouselButton(props: CarouselButtonsProps) {\n\tconst { classNames, icon, variant } = props;\n\n\tconst { goToNextSlide, goToPreviousSlide } = useCarouselStoreContext((state) => state.actions);\n\n\treturn (\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t\"z-30 flex h-full w-[15%] items-center\",\n\t\t\t\tvariant === \"prev\" ? \"justify-start\" : \"justify-end\",\n\t\t\t\tclassNames?.base\n\t\t\t)}\n\t\t\tonClick={variant === \"prev\" ? goToPreviousSlide : goToNextSlide}\n\t\t>\n\t\t\t<span className={cnMerge(\"transition-transform active:scale-[1.06]\", classNames?.iconContainer)}>\n\t\t\t\t{icon ?? (\n\t\t\t\t\t<ChevronLeftIcon\n\t\t\t\t\t\tclassName={cnMerge(variant === \"next\" && \"rotate-180\", classNames?.defaultIcon)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</span>\n\t\t</button>\n\t);\n}\n\nexport function CarouselControls(props: CarouselControlProps) {\n\tconst { classNames, icon } = props;\n\n\treturn (\n\t\t<div className={cnMerge(\"absolute inset-0 flex justify-between\", classNames?.base)}>\n\t\t\t{icon?.iconType ? (\n\t\t\t\t<>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"prev\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: cnMerge(\n\t\t\t\t\t\t\t\ticon.iconType === \"nextIcon\" && \"rotate-180\",\n\t\t\t\t\t\t\t\tclassNames?.iconContainer\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon.icon}\n\t\t\t\t\t/>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"next\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: cnMerge(\n\t\t\t\t\t\t\t\ticon.iconType === \"prevIcon\" && \"rotate-180\",\n\t\t\t\t\t\t\t\tclassNames?.iconContainer\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon.icon}\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"prev\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: classNames?.iconContainer,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon?.prev}\n\t\t\t\t\t/>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"next\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: classNames?.iconContainer,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon?.next}\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n\nexport function CarouselItemWrapper<TArrayItem>(props: CarouselWrapperProps<TArrayItem>) {\n\tconst { children, className, each, render } = props;\n\n\tconst [ItemList] = getElementList(\"base\");\n\tconst currentSlide = useCarouselStoreContext((state) => state.currentSlide);\n\tconst images = useCarouselStoreContext((state) => each ?? (state.images as TArrayItem[]));\n\n\treturn (\n\t\t<ul\n\t\t\tdata-id=\"Carousel Image Wrapper\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t`flex w-full shrink-0 snap-center [transform:translate3d(var(--translate-distance),0,0)]\n\t\t\t\t[transition:transform_800ms_ease]`,\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tstyle={\n\t\t\t\t{\n\t\t\t\t\t\"--translate-distance\": `-${currentSlide * 100}%`,\n\t\t\t\t} satisfies MyCustomCss as MyCustomCss\n\t\t\t}\n\t\t>\n\t\t\t{typeof render === \"function\" ? (\n\t\t\t\t<ItemList each={images} render={render} />\n\t\t\t) : (\n\t\t\t\t<ItemList each={images}>{children}</ItemList>\n\t\t\t)}\n\t\t</ul>\n\t);\n}\n\nexport function CarouselItem({ children, className, ...restOfProps }: OtherCarouselProps) {\n\treturn (\n\t\t<li\n\t\t\tclassName={cnMerge(\"flex w-full shrink-0 snap-center justify-center\", className)}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{children}\n\t\t</li>\n\t);\n}\n\nexport function CarouselCaption<TElement extends React.ElementType = \"div\">(\n\tprops: PolymorphicProps<TElement, OtherCarouselProps>\n) {\n\tconst { as: HtmlElement = \"div\", children, className } = props;\n\n\treturn (\n\t\t<HtmlElement data-id=\"Carousel Caption\" className={cnMerge(\"absolute z-10\", className)}>\n\t\t\t{children}\n\t\t</HtmlElement>\n\t);\n}\n\nexport function CarouselIndicatorWrapper<TArrayItem>(props: CarouselWrapperProps<TArrayItem>) {\n\tconst { children, className, each, render } = props;\n\n\tconst images = useCarouselStoreContext((state) => each ?? (state.images as TArrayItem[]));\n\tconst [IndicatorList] = getElementList(\"base\");\n\n\treturn (\n\t\t<ul\n\t\t\tdata-id=\"Carousel Indicators\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t\"absolute bottom-10 z-[2] flex w-full items-center justify-center gap-6\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t>\n\t\t\t{typeof render === \"function\" ? (\n\t\t\t\t<IndicatorList each={images} render={render} />\n\t\t\t) : (\n\t\t\t\t<IndicatorList each={images}>{children}</IndicatorList>\n\t\t\t)}\n\t\t</ul>\n\t);\n}\n\nexport function CarouselIndicator(props: CarouselIndicatorProps) {\n\tconst { classNames, currentIndex } = props;\n\n\tconst {\n\t\tactions: { goToSlide },\n\t\tcurrentSlide,\n\t} = useCarouselStoreContext((state) => state);\n\n\treturn (\n\t\t<li className={cnMerge(\"inline-flex\", classNames?.base)}>\n\t\t\t<button\n\t\t\t\tdata-active={currentIndex === currentSlide}\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={() => goToSlide(currentIndex)}\n\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t\"size-[6px] rounded-[50%]\",\n\t\t\t\t\tclassNames?.button,\n\t\t\t\t\tcurrentIndex === currentSlide && [\"w-14 rounded-lg\", classNames?.activeBtn]\n\t\t\t\t)}\n\t\t\t/>\n\t\t</li>\n\t);\n}\n","export { CarouselContextProvider as Root } from \"./carousel-store-context\";\nexport {\n\tCarouselContent as Content,\n\tCarouselControls as Controls,\n\tCarouselButton as Button,\n\tCarouselItem as Item,\n\tCarouselItemWrapper as ItemWrapper,\n\tCarouselCaption as Caption,\n\tCarouselIndicator as Indicator,\n\tCarouselIndicatorWrapper as IndicatorWrapper,\n} from \"./carousel\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/icons/ChevronLeftIcon.tsx","../../src/components/ui/carousel/carousel-store-context.tsx","../../src/components/ui/carousel/useCarouselOptions.ts","../../src/components/ui/carousel/carousel.tsx","../../src/components/ui/carousel/carousel-parts.ts"],"names":["React","React2"],"mappings":";;;;;;;;;AAEA,IAAM,kBAAkB,CAAC,KAAA,0CACvB,KAAI,EAAA,EAAA,KAAA,EAAM,8BAA6B,KAAM,EAAA,KAAA,EAAM,MAAO,EAAA,KAAA,EAAM,SAAQ,WAAa,EAAA,GAAG,yBACvFA,MAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAE,MAAK,MAAO,EAAA,MAAA,EAAO,cAAe,EAAA,aAAA,EAAc,SAAQ,cAAe,EAAA,OAAA,EAAQ,aAAY,GAC7F,EAAA,kBAAAA,MAAA,CAAA,aAAA,CAAC,YAAO,EAAG,EAAA,IAAA,EAAK,IAAG,IAAK,EAAA,CAAA,EAAE,MAAK,CAC/B,kBAAAA,MAAA,CAAA,aAAA,CAAC,UAAK,CAAE,EAAA,iBAAA,EAAkB,CAC3B,CACD,CAAA;ACCD,IAAM,CAAC,QAAA,EAAU,uBAAuB,CAAA,GAAI,oBAAoC,CAAA;AAAA,EAC/E,QAAU,EAAA,kBAAA;AAAA,EACV,IAAM,EAAA,sBAAA;AAAA,EACN,YAAc,EAAA;AACf,CAAC,CAAA;AAGD,IAAM,mBAAA,GAAsB,CAC3B,WACI,KA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iBAAA;AAAA,EAAA,IAAA,EAAA,MAAA;AAAA,CAAA,CAAA","file":"chunk-GVL6BLX5.js","sourcesContent":["import * as React from \"react\";\n\nconst ChevronLeftIcon = (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<g fill=\"none\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\">\n\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\" />\n\t\t\t<path d=\"m14 16l-4-4l4-4\" />\n\t\t</g>\n\t</svg>\n);\n\nexport { ChevronLeftIcon };\n","import * as React from \"react\";\n\nimport { useConstant } from \"@zayne-labs/toolkit-react\";\nimport { createZustandContext } from \"@zayne-labs/toolkit-react/zustand\";\nimport type { PrettyOmit } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useEffect } from \"react\";\nimport { create } from \"zustand\";\nimport type { CarouselProviderProps, CarouselStore, ImagesType } from \"./types\";\n\nconst [Provider, useCarouselStoreContext] = createZustandContext<CarouselStore>({\n\thookName: \"useCarouselStore\",\n\tname: \"CarouselStoreContext\",\n\tproviderName: \"CarouselContextProvider\",\n});\n\n// CarouselStore Creation\nconst createCarouselStore = <TImages extends ImagesType>(\n\tstoreValues: PrettyOmit<CarouselProviderProps<TImages>, \"children\">\n) => {\n\tconst { images, onSlideBtnClick } = storeValues;\n\n\tconst useInitCarouselStore = create<CarouselStore<TImages>>()((set, get) => ({\n\t\tcurrentSlide: 0,\n\t\timages,\n\t\tmaxSlide: images.length - 1,\n\n\t\t/* eslint-disable perfectionist/sort-objects -- actions should be last */\n\t\tactions: {\n\t\t\t/* eslint-enable perfectionist/sort-objects -- actions should be last */\n\n\t\t\tgoToNextSlide: () => {\n\t\t\t\tconst { currentSlide, maxSlide } = get();\n\t\t\t\tconst { goToSlide } = get().actions;\n\n\t\t\t\tif (currentSlide === maxSlide) {\n\t\t\t\t\tgoToSlide(0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tgoToSlide(currentSlide + 1);\n\t\t\t},\n\n\t\t\tgoToPreviousSlide: () => {\n\t\t\t\tconst { currentSlide, maxSlide } = get();\n\t\t\t\tconst { goToSlide } = get().actions;\n\n\t\t\t\tif (currentSlide === 0) {\n\t\t\t\t\tgoToSlide(maxSlide);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tgoToSlide(currentSlide - 1);\n\t\t\t},\n\n\t\t\tgoToSlide: (newValue) => {\n\t\t\t\tonSlideBtnClick?.();\n\n\t\t\t\tset({ currentSlide: newValue });\n\t\t\t},\n\t\t},\n\t}));\n\n\treturn useInitCarouselStore;\n};\n\nconst useCarousel = <TImages extends ImagesType>(\n\tprops: Omit<CarouselProviderProps<TImages>, \"children\">\n) => {\n\tconst { images, onSlideBtnClick } = props;\n\n\tconst useInitCarouselStore = useConstant(() => createCarouselStore({ images, onSlideBtnClick }));\n\n\t// == To set images again when a page is mounted, preventing stale images from previous page\n\tuseEffect(() => {\n\t\tuseInitCarouselStore.setState({ images });\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- useInitCarouselStore is stable\n\t}, [images]);\n\n\treturn useInitCarouselStore;\n};\n\n// == Provider Component\nfunction CarouselContextProvider<TImages extends ImagesType>(props: CarouselProviderProps<TImages>) {\n\tconst { children, images, onSlideBtnClick } = props;\n\n\tconst useInitCarouselStore = useCarousel({ images, onSlideBtnClick });\n\n\treturn <Provider value={useInitCarouselStore}>{children}</Provider>;\n}\n\n// eslint-disable-next-line react-refresh/only-export-components -- It's fine\nexport { useCarouselStoreContext, CarouselContextProvider };\n","import { useAnimationInterval, useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport { useState } from \"react\";\nimport { useCarouselStoreContext } from \"./carousel-store-context\";\n\ntype CarouselOptions = {\n\tautoSlideInterval?: number;\n\thasAutoSlide?: boolean;\n\tshouldPauseOnHover?: boolean;\n};\n\nconst useCarouselOptions = (options: CarouselOptions = {}) => {\n\tconst { autoSlideInterval = 5000, hasAutoSlide = false, shouldPauseOnHover = false } = options;\n\n\tconst { goToNextSlide } = useCarouselStoreContext((state) => state.actions);\n\n\tconst [isPaused, setIsPaused] = useState(false);\n\n\tconst shouldAutoSlide = hasAutoSlide && !isPaused;\n\n\tuseAnimationInterval({\n\t\tintervalDuration: shouldAutoSlide ? autoSlideInterval : null,\n\t\tonAnimation: goToNextSlide,\n\t});\n\n\tconst pauseAutoSlide = useCallbackRef(() => shouldPauseOnHover && setIsPaused(true));\n\n\tconst resumeAutoSlide = useCallbackRef(() => shouldPauseOnHover && setIsPaused(false));\n\n\treturn { pauseAutoSlide, resumeAutoSlide };\n};\n\nexport { useCarouselOptions };\n","\"use client\";\n\nimport * as React from \"react\";\n\nimport { getElementList } from \"@/components/common/for\";\nimport { ChevronLeftIcon } from \"@/components/icons\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport type { MyCustomCss, PolymorphicProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { useCarouselStoreContext } from \"./carousel-store-context\";\nimport type {\n\tCarouselButtonsProps,\n\tCarouselContentProps,\n\tCarouselControlProps,\n\tCarouselIndicatorProps,\n\tCarouselWrapperProps,\n\tOtherCarouselProps,\n} from \"./types\";\nimport { useCarouselOptions } from \"./useCarouselOptions\";\n\n// TODO - Add dragging and swiping support\nexport function CarouselContent<TElement extends React.ElementType = \"article\">(\n\tprops: PolymorphicProps<TElement, CarouselContentProps>\n) {\n\tconst {\n\t\tas: HtmlElement = \"article\",\n\t\tautoSlideInterval,\n\t\tchildren,\n\t\tclassNames,\n\t\thasAutoSlide,\n\t\tshouldPauseOnHover,\n\t} = props;\n\n\tconst { pauseAutoSlide, resumeAutoSlide } = useCarouselOptions({\n\t\tautoSlideInterval,\n\t\thasAutoSlide,\n\t\tshouldPauseOnHover,\n\t});\n\n\t// FIXME - Prevent touch swipe on mobile using a cover element or allow swipe but it must update the state appriopriately\n\treturn (\n\t\t<HtmlElement\n\t\t\tdata-id=\"Carousel\"\n\t\t\tclassName={cnMerge(\"relative select-none\", classNames?.base)}\n\t\t\tonMouseEnter={pauseAutoSlide}\n\t\t\tonMouseLeave={resumeAutoSlide}\n\t\t>\n\t\t\t<div\n\t\t\t\tdata-id=\"Scroll Container\"\n\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t\"flex size-full overflow-x-scroll [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\",\n\t\t\t\t\tclassNames?.scrollContainer\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</HtmlElement>\n\t);\n}\n\nexport function CarouselButton(props: CarouselButtonsProps) {\n\tconst { classNames, icon, variant } = props;\n\n\tconst { goToNextSlide, goToPreviousSlide } = useCarouselStoreContext((state) => state.actions);\n\n\treturn (\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t\"z-30 flex h-full w-[15%] items-center\",\n\t\t\t\tvariant === \"prev\" ? \"justify-start\" : \"justify-end\",\n\t\t\t\tclassNames?.base\n\t\t\t)}\n\t\t\tonClick={variant === \"prev\" ? goToPreviousSlide : goToNextSlide}\n\t\t>\n\t\t\t<span className={cnMerge(\"transition-transform active:scale-[1.06]\", classNames?.iconContainer)}>\n\t\t\t\t{icon ?? (\n\t\t\t\t\t<ChevronLeftIcon\n\t\t\t\t\t\tclassName={cnMerge(variant === \"next\" && \"rotate-180\", classNames?.defaultIcon)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</span>\n\t\t</button>\n\t);\n}\n\nexport function CarouselControls(props: CarouselControlProps) {\n\tconst { classNames, icon } = props;\n\n\treturn (\n\t\t<div className={cnMerge(\"absolute inset-0 flex justify-between\", classNames?.base)}>\n\t\t\t{icon?.iconType ? (\n\t\t\t\t<>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"prev\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: cnMerge(\n\t\t\t\t\t\t\t\ticon.iconType === \"nextIcon\" && \"rotate-180\",\n\t\t\t\t\t\t\t\tclassNames?.iconContainer\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon.icon}\n\t\t\t\t\t/>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"next\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: cnMerge(\n\t\t\t\t\t\t\t\ticon.iconType === \"prevIcon\" && \"rotate-180\",\n\t\t\t\t\t\t\t\tclassNames?.iconContainer\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon.icon}\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"prev\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: classNames?.iconContainer,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon?.prev}\n\t\t\t\t\t/>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"next\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: classNames?.iconContainer,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon?.next}\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n\nexport function CarouselItemGroup<TArrayItem>(props: CarouselWrapperProps<TArrayItem>) {\n\tconst { children, className, each, render } = props;\n\n\tconst [ItemList] = getElementList(\"base\");\n\tconst currentSlide = useCarouselStoreContext((state) => state.currentSlide);\n\tconst images = useCarouselStoreContext((state) => each ?? (state.images as TArrayItem[]));\n\n\treturn (\n\t\t<ul\n\t\t\tdata-id=\"Carousel Image Wrapper\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t`flex w-full shrink-0 [transform:translate3d(var(--translate-distance),0,0)] snap-center\n\t\t\t\t[transition:transform_800ms_ease]`,\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tstyle={\n\t\t\t\t{\n\t\t\t\t\t\"--translate-distance\": `-${currentSlide * 100}%`,\n\t\t\t\t} satisfies MyCustomCss as MyCustomCss\n\t\t\t}\n\t\t>\n\t\t\t{typeof render === \"function\" ? (\n\t\t\t\t<ItemList each={images} render={render} />\n\t\t\t) : (\n\t\t\t\t<ItemList each={images}>{children}</ItemList>\n\t\t\t)}\n\t\t</ul>\n\t);\n}\n\nexport function CarouselItem({ children, className, ...restOfProps }: OtherCarouselProps) {\n\treturn (\n\t\t<li\n\t\t\tclassName={cnMerge(\"flex w-full shrink-0 snap-center justify-center\", className)}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{children}\n\t\t</li>\n\t);\n}\n\nexport function CarouselCaption<TElement extends React.ElementType = \"div\">(\n\tprops: PolymorphicProps<TElement, OtherCarouselProps>\n) {\n\tconst { as: HtmlElement = \"div\", children, className } = props;\n\n\treturn (\n\t\t<HtmlElement data-id=\"Carousel Caption\" className={cnMerge(\"absolute z-10\", className)}>\n\t\t\t{children}\n\t\t</HtmlElement>\n\t);\n}\n\nexport function CarouselIndicatorGroup<TArrayItem>(props: CarouselWrapperProps<TArrayItem>) {\n\tconst { children, className, each, render } = props;\n\n\tconst images = useCarouselStoreContext((state) => each ?? (state.images as TArrayItem[]));\n\tconst [IndicatorList] = getElementList(\"base\");\n\n\treturn (\n\t\t<ul\n\t\t\tdata-id=\"Carousel Indicators\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t\"absolute bottom-10 z-[2] flex w-full items-center justify-center gap-6\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t>\n\t\t\t{typeof render === \"function\" ? (\n\t\t\t\t<IndicatorList each={images} render={render} />\n\t\t\t) : (\n\t\t\t\t<IndicatorList each={images}>{children}</IndicatorList>\n\t\t\t)}\n\t\t</ul>\n\t);\n}\n\nexport function CarouselIndicator(props: CarouselIndicatorProps) {\n\tconst { classNames, currentIndex } = props;\n\n\tconst {\n\t\tactions: { goToSlide },\n\t\tcurrentSlide,\n\t} = useCarouselStoreContext((state) => state);\n\n\treturn (\n\t\t<li className={cnMerge(\"inline-flex\", classNames?.base)}>\n\t\t\t<button\n\t\t\t\tdata-active={currentIndex === currentSlide}\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={() => goToSlide(currentIndex)}\n\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t\"size-[6px] rounded-[50%]\",\n\t\t\t\t\tclassNames?.button,\n\t\t\t\t\tcurrentIndex === currentSlide && [\"w-14 rounded-lg\", classNames?.activeBtn]\n\t\t\t\t)}\n\t\t\t/>\n\t\t</li>\n\t);\n}\n","export { CarouselContextProvider as Root } from \"./carousel-store-context\";\nexport {\n\tCarouselContent as Content,\n\tCarouselControls as Controls,\n\tCarouselButton as Button,\n\tCarouselItem as Item,\n\tCarouselItemGroup as ItemWrapper,\n\tCarouselCaption as Caption,\n\tCarouselIndicator as Indicator,\n\tCarouselIndicatorGroup as IndicatorWrapper,\n} from \"./carousel\";\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { cnMerge } from './chunk-OHG7GB7O.js';
|
|
2
|
-
import { getElementList } from './chunk-
|
|
2
|
+
import { getElementList } from './chunk-DW3FXTFL.js';
|
|
3
3
|
import { __export } from './chunk-PZ5AY32C.js';
|
|
4
4
|
import * as React2 from 'react';
|
|
5
|
-
import { useId, useMemo, useRef, useEffect
|
|
5
|
+
import { useId, useMemo, Fragment, useRef, useEffect } from 'react';
|
|
6
6
|
import { toArray } from '@zayne-labs/toolkit-core';
|
|
7
7
|
import { createCustomContext, useToggle, ContextError } from '@zayne-labs/toolkit-react';
|
|
8
8
|
import { getSlotElement, getOtherChildren } from '@zayne-labs/toolkit-react/utils';
|
|
9
|
-
import {
|
|
9
|
+
import { useFormState, FormProvider, useWatch, Controller, useFormContext } from 'react-hook-form';
|
|
10
10
|
|
|
11
11
|
var EyeIconInvisible = (props) => /* @__PURE__ */ React2.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React2.createElement(
|
|
12
12
|
"path",
|
|
@@ -22,11 +22,11 @@ var EyeIconVisible = (props) => /* @__PURE__ */ React2.createElement("svg", { xm
|
|
|
22
22
|
d: "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"
|
|
23
23
|
}
|
|
24
24
|
));
|
|
25
|
-
var
|
|
25
|
+
var useFormRootContext = () => {
|
|
26
26
|
const formContext = useFormContext();
|
|
27
27
|
if (!formContext) {
|
|
28
28
|
throw new ContextError(
|
|
29
|
-
`
|
|
29
|
+
`useFormRootContext returned "null". Did you forget to wrap the necessary components within FormRoot?`
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
return formContext;
|
|
@@ -144,7 +144,7 @@ function FormInputPrimitive(props) {
|
|
|
144
144
|
...restOfProps
|
|
145
145
|
} = props;
|
|
146
146
|
const getFormState = control ? useFormState : () => formState;
|
|
147
|
-
const { errors } = getFormState({ control }) ?? {};
|
|
147
|
+
const { errors } = getFormState({ control, name }) ?? {};
|
|
148
148
|
const [isPasswordVisible, toggleVisibility] = useToggle(false);
|
|
149
149
|
const shouldHaveEyeIcon = withEyeIcon && type === "password";
|
|
150
150
|
const WrapperElement = shouldHaveEyeIcon ? FormInputGroup : Fragment;
|
|
@@ -184,7 +184,8 @@ function FormInputPrimitive(props) {
|
|
|
184
184
|
function FormInput(props) {
|
|
185
185
|
const { rules, ...restOfProps } = props;
|
|
186
186
|
const { name } = useStrictFormItemContext();
|
|
187
|
-
const {
|
|
187
|
+
const { control, register } = useFormRootContext();
|
|
188
|
+
const formState = useFormState({ control, name });
|
|
188
189
|
return /* @__PURE__ */ React2.createElement(
|
|
189
190
|
FormInputPrimitive,
|
|
190
191
|
{
|
|
@@ -207,7 +208,7 @@ function FormTextAreaPrimitive(props) {
|
|
|
207
208
|
...restOfProps
|
|
208
209
|
} = props;
|
|
209
210
|
const getFormState = control ? useFormState : () => formState;
|
|
210
|
-
const { errors } = getFormState({ control }) ?? {};
|
|
211
|
+
const { errors } = getFormState({ control, name }) ?? {};
|
|
211
212
|
return /* @__PURE__ */ React2.createElement(
|
|
212
213
|
"textarea",
|
|
213
214
|
{
|
|
@@ -228,7 +229,8 @@ function FormTextAreaPrimitive(props) {
|
|
|
228
229
|
function FormTextArea(props) {
|
|
229
230
|
const { rules, ...restOfProps } = props;
|
|
230
231
|
const { name } = useStrictFormItemContext();
|
|
231
|
-
const {
|
|
232
|
+
const { control, register } = useFormRootContext();
|
|
233
|
+
const formState = useFormState({ control, name });
|
|
232
234
|
return /* @__PURE__ */ React2.createElement(
|
|
233
235
|
FormTextAreaPrimitive,
|
|
234
236
|
{
|
|
@@ -239,10 +241,14 @@ function FormTextArea(props) {
|
|
|
239
241
|
}
|
|
240
242
|
);
|
|
241
243
|
}
|
|
244
|
+
var FormControllerPrimitive = (props) => {
|
|
245
|
+
return /* @__PURE__ */ React2.createElement(Controller, { ...props });
|
|
246
|
+
};
|
|
242
247
|
function FormController(props) {
|
|
243
|
-
const { control } =
|
|
248
|
+
const { control } = useFormRootContext();
|
|
244
249
|
const { name } = useStrictFormItemContext();
|
|
245
|
-
|
|
250
|
+
const { render, ...restOfProps } = props;
|
|
251
|
+
return /* @__PURE__ */ React2.createElement(FormControllerPrimitive, { name, control, render, ...restOfProps });
|
|
246
252
|
}
|
|
247
253
|
function FormDescription(props) {
|
|
248
254
|
const { className, ...restOfProps } = props;
|
|
@@ -250,6 +256,7 @@ function FormDescription(props) {
|
|
|
250
256
|
}
|
|
251
257
|
var FormErrorMessagePrimitive = (props) => {
|
|
252
258
|
const {
|
|
259
|
+
children,
|
|
253
260
|
className,
|
|
254
261
|
classNames,
|
|
255
262
|
control,
|
|
@@ -286,7 +293,7 @@ var FormErrorMessagePrimitive = (props) => {
|
|
|
286
293
|
}
|
|
287
294
|
const errorMessageArray = toArray(message);
|
|
288
295
|
const [ErrorMessageList] = getElementList();
|
|
289
|
-
const onAnimationEnd = withAnimationOnInvalid ? (event) => event.currentTarget.classList.remove(errorAnimationClass) :
|
|
296
|
+
const onAnimationEnd = withAnimationOnInvalid ? (event) => event.currentTarget.classList.remove(errorAnimationClass) : void 0;
|
|
290
297
|
const getRenderProps = ({ index }) => ({
|
|
291
298
|
className: cnMerge(errorAnimationClass, className, classNames?.errorMessage),
|
|
292
299
|
"data-index": index,
|
|
@@ -299,6 +306,7 @@ var FormErrorMessagePrimitive = (props) => {
|
|
|
299
306
|
errorMessageArray,
|
|
300
307
|
index
|
|
301
308
|
});
|
|
309
|
+
const renderFn = typeof children === "function" ? children : render;
|
|
302
310
|
return /* @__PURE__ */ React2.createElement(
|
|
303
311
|
ErrorMessageList,
|
|
304
312
|
{
|
|
@@ -306,7 +314,7 @@ var FormErrorMessagePrimitive = (props) => {
|
|
|
306
314
|
each: errorMessageArray,
|
|
307
315
|
className: cnMerge("flex flex-col", classNames?.container),
|
|
308
316
|
render: (errorMessage, index) => {
|
|
309
|
-
return
|
|
317
|
+
return renderFn({
|
|
310
318
|
props: getRenderProps({ index }),
|
|
311
319
|
state: getRenderState({ errorMessage, index })
|
|
312
320
|
});
|
|
@@ -317,7 +325,7 @@ var FormErrorMessagePrimitive = (props) => {
|
|
|
317
325
|
function FormErrorMessage(props) {
|
|
318
326
|
const contextValues = useLaxFormItemContext();
|
|
319
327
|
const { className, errorField = contextValues?.name, type = "regular" } = props;
|
|
320
|
-
const { control } =
|
|
328
|
+
const { control } = useFormRootContext();
|
|
321
329
|
return /* @__PURE__ */ React2.createElement(
|
|
322
330
|
FormErrorMessagePrimitive,
|
|
323
331
|
{
|
|
@@ -336,15 +344,36 @@ function FormErrorMessage(props) {
|
|
|
336
344
|
}
|
|
337
345
|
);
|
|
338
346
|
}
|
|
347
|
+
function FormFieldSubscribe(props) {
|
|
348
|
+
const contextValues = useLaxFormItemContext();
|
|
349
|
+
const { children, name = contextValues?.name, render } = props;
|
|
350
|
+
const { control } = useFormRootContext();
|
|
351
|
+
const formValue = useWatch({ control, name });
|
|
352
|
+
const fieldProps = { value: formValue };
|
|
353
|
+
if (typeof children === "function") {
|
|
354
|
+
return children(fieldProps);
|
|
355
|
+
}
|
|
356
|
+
return render(fieldProps);
|
|
357
|
+
}
|
|
358
|
+
function FormStateSubscribe(props) {
|
|
359
|
+
const contextValues = useLaxFormItemContext();
|
|
360
|
+
const { children, control, name = contextValues?.name, render } = props;
|
|
361
|
+
const formState = useFormState({ control, name });
|
|
362
|
+
if (typeof children === "function") {
|
|
363
|
+
return children(formState);
|
|
364
|
+
}
|
|
365
|
+
return render(formState);
|
|
366
|
+
}
|
|
339
367
|
|
|
340
368
|
// src/components/ui/form/form-parts.ts
|
|
341
369
|
var form_parts_exports = {};
|
|
342
370
|
__export(form_parts_exports, {
|
|
343
371
|
Controller: () => FormController,
|
|
344
|
-
ControllerPrimitive: () =>
|
|
372
|
+
ControllerPrimitive: () => FormControllerPrimitive,
|
|
345
373
|
Description: () => FormDescription,
|
|
346
374
|
ErrorMessage: () => FormErrorMessage,
|
|
347
375
|
ErrorMessagePrimitive: () => FormErrorMessagePrimitive,
|
|
376
|
+
FieldSubscribe: () => FormFieldSubscribe,
|
|
348
377
|
Input: () => FormInput,
|
|
349
378
|
InputGroup: () => FormInputGroup,
|
|
350
379
|
InputLeftItem: () => FormInputLeftItem,
|
|
@@ -354,10 +383,11 @@ __export(form_parts_exports, {
|
|
|
354
383
|
ItemContext: () => FormItemContext,
|
|
355
384
|
Label: () => FormLabel,
|
|
356
385
|
Root: () => FormRoot,
|
|
386
|
+
StateSubscribe: () => FormStateSubscribe,
|
|
357
387
|
TextArea: () => FormTextArea,
|
|
358
388
|
TextAreaPrimitive: () => FormTextAreaPrimitive
|
|
359
389
|
});
|
|
360
390
|
|
|
361
|
-
export { FormController, FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputRightItem, FormItem, FormItemContext, FormLabel, FormRoot, FormTextArea, FormTextAreaPrimitive, form_parts_exports, useStrictFormItemContext };
|
|
362
|
-
//# sourceMappingURL=chunk-
|
|
363
|
-
//# sourceMappingURL=chunk-
|
|
391
|
+
export { FormController, FormControllerPrimitive, FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormFieldSubscribe, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputRightItem, FormItem, FormItemContext, FormLabel, FormRoot, FormStateSubscribe, FormTextArea, FormTextAreaPrimitive, form_parts_exports, useStrictFormItemContext };
|
|
392
|
+
//# sourceMappingURL=chunk-NEAL4P57.js.map
|
|
393
|
+
//# sourceMappingURL=chunk-NEAL4P57.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/icons/EyeIcon.tsx","../../src/components/ui/form/form-context.ts","../../src/components/ui/form/form.tsx","../../src/components/ui/form/form-parts.ts"],"names":["React","HookFormProvider","ReactFragment"],"mappings":";;;;;;;;;;AAEO,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,MAAA,kBAAA;AAAA,EAAA,KAAA,EAAA,MAAA,SAAA;AAAA,EAAA,UAAA,EAAA,MAAA,cAAA;AAAA,EAAA,aAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,cAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,cAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,IAAA,EAAA,MAAA,QAAA;AAAA,EAAA,WAAA,EAAA,MAAA,eAAA;AAAA,EAAA,KAAA,EAAA,MAAA,SAAA;AAAA,EAAA,IAAA,EAAA,MAAA,QAAA;AAAA,EAAA,cAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,QAAA,EAAA,MAAA,YAAA;AAAA,EAAA,iBAAA,EAAA,MAAA;AAAA,CAAA,CAAA","file":"chunk-NEAL4P57.js","sourcesContent":["import * as React from \"react\";\n\nexport const EyeIconInvisible = (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 EyeIconVisible = (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 { ContextError, createCustomContext } from \"@zayne-labs/toolkit-react\";\nimport type { DiscriminatedRenderProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { type UseFormReturn, useFormContext } from \"react-hook-form\";\nimport type { FieldValues } from \"./form\";\n\nexport type FormRootContextValue<TFieldValues extends FieldValues = FieldValues> =\n\tUseFormReturn<TFieldValues>;\n\nexport const useFormRootContext = () => {\n\tconst formContext = useFormContext() as FormRootContextValue | null;\n\n\tif (!formContext) {\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 ItemContextValue = {\n\tname: string;\n\tuniqueId: string;\n};\n\nexport type FormItemContextProps = DiscriminatedRenderProps<\n\t(contextValue: ItemContextValue) => React.ReactNode\n>;\n\nexport const [StrictFormItemProvider, useStrictFormItemContext] = createCustomContext<ItemContextValue>({\n\thookName: \"useFormItemContext\",\n\tproviderName: \"FormItem\",\n});\n\nexport const [LaxFormItemProvider, useLaxFormItemContext] = createCustomContext<ItemContextValue, false>({\n\thookName: \"useLaxFormItemContext\",\n\tproviderName: \"FormItem\",\n\tstrict: false,\n});\n","\"use client\";\n\nimport * as React from \"react\";\n\nimport { getElementList } from \"@/components/common/for\";\nimport { EyeIconInvisible, EyeIconVisible } from \"@/components/icons\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport { toArray } from \"@zayne-labs/toolkit-core\";\nimport { useToggle } from \"@zayne-labs/toolkit-react\";\nimport {\n\ttype DiscriminatedRenderProps,\n\ttype InferProps,\n\ttype PolymorphicProps,\n\tgetOtherChildren,\n\tgetSlotElement,\n} from \"@zayne-labs/toolkit-react/utils\";\nimport type { UnionDiscriminator } 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\ttype FormState,\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 FormItemContextProps,\n\tLaxFormItemProvider,\n\tStrictFormItemProvider,\n\tuseFormRootContext,\n\tuseLaxFormItemContext,\n\tuseStrictFormItemContext,\n} from \"./form-context\";\n\nexport type FieldValues = Record<string, unknown>;\n\ntype FormRootProps<TFieldValues extends FieldValues> = React.ComponentPropsWithoutRef<\"form\"> & {\n\tchildren: React.ReactNode;\n\tmethods: UseFormReturn<TFieldValues>;\n};\n\nexport function FormRoot<TValues extends FieldValues>(props: FormRootProps<TValues>) {\n\tconst { children, className, methods, ...restOfProps } = props;\n\n\treturn (\n\t\t<HookFormProvider {...methods}>\n\t\t\t<form\n\t\t\t\tclassName={cnMerge(\"flex flex-col\", className)}\n\t\t\t\t{...restOfProps}\n\t\t\t\tdata-scope=\"form\"\n\t\t\t\tdata-part=\"root\"\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</form>\n\t\t</HookFormProvider>\n\t);\n}\n\ntype FormItemProps<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\tchildren: React.ReactNode;\n\tclassName?: string;\n\twithWrapper?: boolean;\n};\n\nexport function FormItem<TControl, TFieldValues extends FieldValues = FieldValues>(\n\tprops: FormItemProps<TControl, TFieldValues>\n) {\n\tconst { children, className, name, withWrapper = true } = props;\n\n\tconst uniqueId = useId();\n\n\tconst value = useMemo(\n\t\t() => ({ name: String(name), uniqueId: `${String(name)}-(${uniqueId})` }),\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\", className),\n\t\t\"data-part\": \"item\",\n\t\t\"data-scope\": \"form\",\n\t};\n\n\treturn (\n\t\t<StrictFormItemProvider value={value}>\n\t\t\t<LaxFormItemProvider value={value}>\n\t\t\t\t<WrapperElement {...wrapperElementProps}>{children}</WrapperElement>\n\t\t\t</LaxFormItemProvider>\n\t\t</StrictFormItemProvider>\n\t);\n}\n\nexport function FormItemContext(props: FormItemContextProps) {\n\tconst { children, render } = props;\n\tconst contextValues = useStrictFormItemContext();\n\n\tif (typeof children === \"function\") {\n\t\treturn children(contextValues);\n\t}\n\n\treturn render(contextValues);\n}\n\nexport function FormLabel(props: InferProps<\"label\">) {\n\tconst { uniqueId } = useStrictFormItemContext();\n\tconst { children, className, ...restOfProps } = props;\n\n\treturn (\n\t\t<label data-scope=\"form\" data-part=\"label\" htmlFor={uniqueId} className={className} {...restOfProps}>\n\t\t\t{children}\n\t\t</label>\n\t);\n}\n\nexport function FormInputGroup(props: React.ComponentPropsWithRef<\"div\">) {\n\tconst { children, className, ...restOfProps } = props;\n\tconst LeftItemSlot = getSlotElement(children, FormInputLeftItem);\n\tconst RightItemSlot = getSlotElement(children, FormInputRightItem);\n\n\tconst otherChildren = getOtherChildren(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\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{otherChildren}\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\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.slot = Symbol.for(\"leftItem\");\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\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.slot = Symbol.for(\"rightItem\");\n\ntype FormInputPrimitiveProps<TFieldValues extends FieldValues = FieldValues> = Omit<\n\tReact.ComponentPropsWithRef<\"input\">,\n\t\"children\"\n>\n\t& UnionDiscriminator<[{ control: Control<TFieldValues> }, { formState?: FormState<TFieldValues> }]> & {\n\t\tclassNames?: { error?: string; eyeIcon?: string; input?: string; inputGroup?: string };\n\t\tname?: FieldPath<TFieldValues>;\n\t\twithEyeIcon?: boolean;\n\t};\n\nconst inputTypesWithoutFullWith = new Set<React.HTMLInputTypeAttribute>([\"checkbox\", \"radio\"]);\n\nexport function FormInputPrimitive<TFieldValues extends FieldValues>(\n\tprops: FormInputPrimitiveProps<TFieldValues>\n) {\n\tconst contextValues = useLaxFormItemContext();\n\n\tconst {\n\t\tclassName,\n\t\tclassNames,\n\t\tcontrol,\n\t\tformState,\n\t\tid = contextValues?.uniqueId,\n\t\tname = contextValues?.name,\n\t\ttype = \"text\",\n\t\twithEyeIcon = true,\n\t\t...restOfProps\n\t} = props;\n\n\tconst getFormState = (control ? useFormState : () => formState) as typeof useFormState;\n\n\tconst { errors } =\n\t\t(getFormState({ control, name: name as never }) as UseFormStateReturn<TFieldValues> | undefined)\n\t\t?? {};\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, name && errors?.[name] && classNames?.error),\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\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`bg-transparent text-sm file:border-0 file:bg-transparent\n\t\t\t\t\tplaceholder:text-shadcn-muted-foreground focus-visible:outline-none\n\t\t\t\t\tdisabled: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\" && name && errors?.[name] && classNames?.error\n\t\t\t\t)}\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{isPasswordVisible ? (\n\t\t\t\t\t\t<EyeIconInvisible className={cnMerge(\"size-full\", classNames?.eyeIcon)} />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<EyeIconVisible className={cnMerge(\"size-full\", classNames?.eyeIcon)} />\n\t\t\t\t\t)}\n\t\t\t\t</FormInputRightItem>\n\t\t\t)}\n\t\t</WrapperElement>\n\t);\n}\n\nexport function FormInput(\n\tprops: Omit<FormInputPrimitiveProps, \"control\" | \"formState\" | \"name\" | \"ref\"> & {\n\t\trules?: RegisterOptions;\n\t}\n) {\n\tconst { rules, ...restOfProps } = props;\n\n\tconst { name } = useStrictFormItemContext();\n\tconst { control, register } = useFormRootContext();\n\n\tconst formState = useFormState({ control, name });\n\n\treturn (\n\t\t<FormInputPrimitive\n\t\t\tname={name}\n\t\t\tformState={formState}\n\t\t\t{...(Boolean(name) && register(name, rules))}\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\n\ntype FormTextAreaPrimitiveProps<TFieldValues extends FieldValues = FieldValues> =\n\tReact.ComponentPropsWithRef<\"textarea\"> & {\n\t\terrorClassName?: string;\n\t\tname?: FieldPath<TFieldValues>;\n\t\t// eslint-disable-next-line perfectionist/sort-intersection-types -- Prefer the object to come first before the discriminator props\n\t} & UnionDiscriminator<[{ control: Control<TFieldValues> }, { formState?: FormState<TFieldValues> }]>;\n\nexport function FormTextAreaPrimitive<TFieldValues extends FieldValues>(\n\tprops: FormTextAreaPrimitiveProps<TFieldValues>\n) {\n\tconst contextValues = useLaxFormItemContext();\n\n\tconst {\n\t\tclassName,\n\t\tcontrol,\n\t\terrorClassName,\n\t\tformState,\n\t\tid = contextValues?.uniqueId,\n\t\tname = contextValues?.name,\n\t\t...restOfProps\n\t} = props;\n\n\tconst getFormState = (control ? useFormState : () => formState) as typeof useFormState;\n\n\tconst { errors } =\n\t\t(getFormState({ control, name: name as never }) as UseFormStateReturn<TFieldValues> | undefined)\n\t\t?? {};\n\n\treturn (\n\t\t<textarea\n\t\t\tdata-scope=\"form\"\n\t\t\tdata-part=\"textarea\"\n\t\t\tid={id}\n\t\t\tname={name}\n\t\t\tclassName={cnMerge(\n\t\t\t\t`w-full bg-transparent text-sm placeholder:text-shadcn-muted-foreground\n\t\t\t\tfocus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50`,\n\t\t\t\tclassName,\n\t\t\t\tname && errors?.[name] && errorClassName\n\t\t\t)}\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\n\nexport function FormTextArea(\n\tprops: Omit<FormTextAreaPrimitiveProps, \"control\" | \"formState\" | \"id\" | \"name\" | \"ref\"> & {\n\t\trules?: RegisterOptions;\n\t}\n) {\n\tconst { rules, ...restOfProps } = props;\n\n\tconst { name } = useStrictFormItemContext();\n\tconst { control, register } = useFormRootContext();\n\tconst formState = useFormState({ control, name });\n\n\treturn (\n\t\t<FormTextAreaPrimitive\n\t\t\tname={name}\n\t\t\tformState={formState}\n\t\t\t{...(Boolean(name) && register(name, rules))}\n\t\t\t{...restOfProps}\n\t\t/>\n\t);\n}\n\ntype FormControllerRenderFn = (props: {\n\tfield: Omit<ControllerRenderProps, \"value\"> & {\n\t\tvalue: never;\n\t};\n\tfieldState: ControllerFieldState;\n\tformState: UseFormStateReturn<never>;\n}) => React.ReactElement;\n\ntype FormControllerProps = Omit<\n\tControllerProps<FieldValues, FieldPath<FieldValues>>,\n\t\"control\" | \"name\" | \"render\"\n> & {\n\trender: FormControllerRenderFn;\n};\n\nexport const FormControllerPrimitive: typeof Controller = (props) => {\n\treturn <Controller {...props} />;\n};\n\nexport function FormController(props: FormControllerProps) {\n\tconst { control } = useFormRootContext();\n\tconst { name } = useStrictFormItemContext();\n\tconst { render, ...restOfProps } = props;\n\n\treturn (\n\t\t<FormControllerPrimitive name={name} control={control} render={render as never} {...restOfProps} />\n\t);\n}\n\nexport function FormDescription(props: InferProps<\"p\">) {\n\tconst { className, ...restOfProps } = props;\n\n\treturn <p className={cnMerge(\"text-[12px]\", className)} {...restOfProps} />;\n}\n\ntype ErrorMessageRenderProps = {\n\tclassName: string;\n\t\"data-index\": number;\n\t\"data-part\": string;\n\t\"data-scope\": string;\n\tonAnimationEnd?: React.ReactEventHandler<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\ntype 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\twithAnimationOnInvalid?: boolean;\n\t} & (\n\t\t\t| {\n\t\t\t\t\terrorField: FieldPath<TFieldValues>;\n\t\t\t\t\ttype?: \"regular\";\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\terrorField: 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 {\n\t\tchildren,\n\t\tclassName,\n\t\tclassNames,\n\t\tcontrol,\n\t\terrorField,\n\t\trender,\n\t\ttype = \"regular\",\n\t\twithAnimationOnInvalid = true,\n\t} = props;\n\n\tconst formState = useFormState({ control });\n\n\tconst wrapperRef = useRef<HTMLUListElement>(null);\n\n\tconst errorAnimationClass = classNames?.errorMessageAnimation ?? \"animate-shake\";\n\n\tuseEffect(() => {\n\t\tif (!withAnimationOnInvalid) return;\n\n\t\tconst errorMessageElements = wrapperRef.current?.children;\n\n\t\tif (!errorMessageElements) return;\n\n\t\tfor (const element of errorMessageElements) {\n\t\t\telement.classList.add(errorAnimationClass);\n\t\t}\n\t}, [errorAnimationClass, withAnimationOnInvalid]);\n\n\tuseEffect(() => {\n\t\tconst errorMessageElements = wrapperRef.current?.children;\n\n\t\tif (!errorMessageElements) return;\n\n\t\t// == Scroll to first error message\n\t\tif (Object.keys(formState.errors).indexOf(errorField as string) === 0) {\n\t\t\terrorMessageElements[0]?.scrollIntoView({\n\t\t\t\tbehavior: \"smooth\",\n\t\t\t\tblock: \"center\",\n\t\t\t});\n\n\t\t\twindow.scrollBy({ behavior: \"smooth\", top: -100 });\n\t\t}\n\t}, [errorField, formState.errors]);\n\n\tconst message = (\n\t\ttype === \"root\"\n\t\t\t? formState.errors.root?.[errorField as string]?.message\n\t\t\t: formState.errors[errorField]?.message\n\t) as string | string[];\n\n\tif (!message) {\n\t\treturn null;\n\t}\n\n\tconst errorMessageArray = toArray(message);\n\n\tconst [ErrorMessageList] = getElementList();\n\n\tconst onAnimationEnd: React.AnimationEventHandler<HTMLElement> | undefined = withAnimationOnInvalid\n\t\t? (event) => event.currentTarget.classList.remove(errorAnimationClass)\n\t\t: undefined;\n\n\tconst getRenderProps = ({ index }: { index: number }) =>\n\t\t({\n\t\t\tclassName: cnMerge(errorAnimationClass, 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\tonAnimationEnd,\n\t\t}) satisfies ErrorMessageRenderProps;\n\n\tconst getRenderState = ({ errorMessage, index }: { errorMessage: string; index: number }) =>\n\t\t({\n\t\t\terrorMessage,\n\t\t\terrorMessageArray,\n\t\t\tindex,\n\t\t}) satisfies ErrorMessageRenderState;\n\n\tconst renderFn = typeof children === \"function\" ? children : render;\n\n\treturn (\n\t\t<ErrorMessageList\n\t\t\tref={wrapperRef}\n\t\t\teach={errorMessageArray}\n\t\t\tclassName={cnMerge(\"flex flex-col\", classNames?.container)}\n\t\t\trender={(errorMessage, index) => {\n\t\t\t\treturn renderFn({\n\t\t\t\t\tprops: getRenderProps({ index }),\n\t\t\t\t\tstate: getRenderState({ errorMessage, index }),\n\t\t\t\t});\n\t\t\t}}\n\t\t/>\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 contextValues = useLaxFormItemContext();\n\n\tconst { className, errorField = contextValues?.name, type = \"regular\" } = props;\n\n\tconst { control } = useFormRootContext();\n\n\treturn (\n\t\t<FormErrorMessagePrimitive\n\t\t\tcontrol={control}\n\t\t\terrorField={errorField as NonNullable<typeof errorField>}\n\t\t\ttype={type as \"root\"}\n\t\t\trender={({ props: renderProps, state: { errorMessage } }) => (\n\t\t\t\t<p\n\t\t\t\t\t{...renderProps}\n\t\t\t\t\tkey={errorMessage}\n\t\t\t\t\tclassName={cnMerge(\"text-[13px]\", \"data-[index=0]:mt-1\", renderProps.className, className)}\n\t\t\t\t>\n\t\t\t\t\t{errorMessage}\n\t\t\t\t</p>\n\t\t\t)}\n\t\t/>\n\t);\n}\n\ntype FieldSubscribeRenderFn<TFieldValues extends FieldValues, TFieldPathOrPaths> = (props: {\n\tvalue: TFieldPathOrPaths 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}) => React.ReactNode;\n\ntype FormFieldSubscribeProps<\n\tTFieldValues extends FieldValues,\n\tTFieldPathOrPaths,\n> = DiscriminatedRenderProps<FieldSubscribeRenderFn<TFieldValues, TFieldPathOrPaths>> & {\n\tcontrol: Control<TFieldValues>;\n\tname?: TFieldPathOrPaths;\n};\n\nexport function FormFieldSubscribe<\n\tTFieldValues extends FieldValues,\n\tconst TFieldPathOrPaths extends Array<FieldPath<TFieldValues>> | FieldPath<TFieldValues>,\n>(props: FormFieldSubscribeProps<TFieldValues, TFieldPathOrPaths>) {\n\tconst contextValues = useLaxFormItemContext();\n\n\tconst { children, name = contextValues?.name, render } = props;\n\n\tconst { control } = useFormRootContext();\n\n\tconst formValue = useWatch({ control, name: name as string });\n\n\tconst fieldProps = { value: formValue };\n\n\tif (typeof children === \"function\") {\n\t\treturn children(fieldProps as never);\n\t}\n\n\treturn render(fieldProps as never);\n}\n\ntype FormStateSubscribeRenderFn<TFieldValues extends FieldValues> = (\n\tprops: UseFormStateReturn<TFieldValues>\n) => React.ReactNode;\n\ntype FormStateSubscribeProps<TFieldValues extends FieldValues> = DiscriminatedRenderProps<\n\tFormStateSubscribeRenderFn<TFieldValues>\n> & {\n\tcontrol?: Control<TFieldValues>;\n\tname?: Array<FieldPath<TFieldValues>> | FieldPath<TFieldValues>;\n};\n\nexport function FormStateSubscribe<TFieldValues extends FieldValues = FieldValues>(\n\tprops: FormStateSubscribeProps<TFieldValues>\n) {\n\tconst contextValues = useLaxFormItemContext();\n\n\tconst { children, control, name = contextValues?.name, render } = props;\n\n\tconst formState = useFormState({ control, name: name as FieldPath<TFieldValues> });\n\n\tif (typeof children === \"function\") {\n\t\treturn children(formState as never);\n\t}\n\n\treturn render(formState as never);\n}\n","export {\n\tFormController as Controller,\n\tFormControllerPrimitive as ControllerPrimitive,\n\tFormDescription as Description,\n\tFormErrorMessage as ErrorMessage,\n\tFormErrorMessagePrimitive as ErrorMessagePrimitive,\n\tFormInput as Input,\n\tFormInputGroup as InputGroup,\n\tFormInputLeftItem as InputLeftItem,\n\tFormInputPrimitive as InputPrimitive,\n\tFormInputRightItem as InputRightItem,\n\tFormItem as Item,\n\tFormItemContext as ItemContext,\n\tFormLabel as Label,\n\tFormRoot as Root,\n\tFormStateSubscribe as StateSubscribe,\n\tFormFieldSubscribe as FieldSubscribe,\n\tFormTextArea as TextArea,\n\tFormTextAreaPrimitive as TextAreaPrimitive,\n} from \"./form\";\n"]}
|
|
@@ -85,8 +85,7 @@ var useDragScroll = (props = {}) => {
|
|
|
85
85
|
return {
|
|
86
86
|
...mergedRootProps,
|
|
87
87
|
className: cnMerge(
|
|
88
|
-
`flex w-full cursor-grab snap-x snap-mandatory overflow-y-clip overflow-
|
|
89
|
-
[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,
|
|
88
|
+
`flex w-full cursor-grab snap-x snap-mandatory overflow-x-scroll overflow-y-clip [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,
|
|
90
89
|
orientation === "horizontal" && "flex-row",
|
|
91
90
|
orientation === "vertical" && "flex-col",
|
|
92
91
|
usage === "mobileAndTabletOnly" && "md:cursor-default md:flex-col",
|
|
@@ -115,5 +114,5 @@ var useDragScroll = (props = {}) => {
|
|
|
115
114
|
};
|
|
116
115
|
|
|
117
116
|
export { useDragScroll };
|
|
118
|
-
//# sourceMappingURL=chunk-
|
|
119
|
-
//# sourceMappingURL=chunk-
|
|
117
|
+
//# sourceMappingURL=chunk-Y7TF3SRM.js.map
|
|
118
|
+
//# sourceMappingURL=chunk-Y7TF3SRM.js.map
|