@oneplatformdev/ui 0.1.99-beta.263 → 0.1.99-beta.266
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/.storybook/Wrappers.js.map +1 -1
- package/Accordion/Accordion.js.map +1 -1
- package/Alert/Alert.js.map +1 -1
- package/Alert/alertVariants.js.map +1 -1
- package/AlertDialog/AlertDialog.js.map +1 -1
- package/AlertDialog/AlertDialog.stories.js +2 -4
- package/AlertDialog/AlertDialog.stories.js.map +1 -1
- package/AlertDialog/AlertDialogRoot.js +18 -20
- package/AlertDialog/AlertDialogRoot.js.map +1 -1
- package/AreaChart/AreaChart.js.map +1 -1
- package/Aside/Aside.js.map +1 -1
- package/Aside/AsideSidebar.js.map +1 -1
- package/AspectRatio/AspectRatio.js.map +1 -1
- package/Avatar/Avatar.js.map +1 -1
- package/Badge/Badge.js.map +1 -1
- package/Badge/badgeVariants.js.map +1 -1
- package/Breadcrumb/Breadcrumb.js.map +1 -1
- package/Button/Button.js +10 -11
- package/Button/Button.js.map +1 -1
- package/Button/Button.stories.js.map +1 -1
- package/Button/Button.utils.js.map +1 -1
- package/Button/ButtonCounterBadge.js.map +1 -1
- package/Button/buttonVariants.js.map +1 -1
- package/ButtonIcon/ButtonIcon.js +19 -22
- package/ButtonIcon/ButtonIcon.js.map +1 -1
- package/ButtonIcon/ButtonIcon.stories.js.map +1 -1
- package/ButtonIcon/buttonIconVariants.js.map +1 -1
- package/CHANGELOG.md +3401 -3393
- package/Calendar/Calendar.js +4 -6
- package/Calendar/Calendar.js.map +1 -1
- package/Card/Card.js.map +1 -1
- package/Carousel/Carousel.js +6 -7
- package/Carousel/Carousel.js.map +1 -1
- package/Chart/Chart.js.map +1 -1
- package/Checkbox/Checkbox.js +0 -1
- package/Checkbox/Checkbox.js.map +1 -1
- package/Checkbox/Checkbox.stories.js.map +1 -1
- package/Collapsible/Collapsible.js.map +1 -1
- package/Combobox/Combobox.js +10 -10
- package/Combobox/Combobox.js.map +1 -1
- package/Combobox/Combobox.stories.js.map +1 -1
- package/Combobox/Combobox.types.js.map +1 -1
- package/Combobox/ComboboxOptionItem.js +18 -19
- package/Combobox/ComboboxOptionItem.js.map +1 -1
- package/Combobox/ComboboxRenderContent.js +26 -27
- package/Combobox/ComboboxRenderContent.js.map +1 -1
- package/Combobox/ComboboxRenderOptions.js +5 -5
- package/Combobox/ComboboxRenderOptions.js.map +1 -1
- package/Combobox/ComboboxRenderTrigger.js +28 -30
- package/Combobox/ComboboxRenderTrigger.js.map +1 -1
- package/Command/Command.js +21 -22
- package/Command/Command.js.map +1 -1
- package/ContextPopover/ContextDropdownMenu.js.map +1 -1
- package/ContextPopover/ContextPopover.js.map +1 -1
- package/ContextPopover/useContextPopoverHandler.js.map +1 -1
- package/DataTable/DataTable.js +24 -26
- package/DataTable/DataTable.js.map +1 -1
- package/DataTable/DataTableColumnFilter.js +6 -7
- package/DataTable/DataTableColumnFilter.js.map +1 -1
- package/DataTable/useDataTable.js.map +1 -1
- package/DatePicker/DatePicker.js +12 -13
- package/DatePicker/DatePicker.js.map +1 -1
- package/Dialog/Dialog.js +20 -21
- package/Dialog/Dialog.js.map +1 -1
- package/Dialog/Dialog.stories.js +14 -15
- package/Dialog/Dialog.stories.js.map +1 -1
- package/Dialog/DialogOverlayScope.js.map +1 -1
- package/Dialog/useDialogClosePosition.js.map +1 -1
- package/Drawer/Drawer.js.map +1 -1
- package/DropdownMenu/DropdownMenu.js.map +1 -1
- package/Dropzone/Dropzone.d.ts.map +1 -1
- package/Dropzone/Dropzone.js +321 -159
- package/Dropzone/Dropzone.js.map +1 -1
- package/Dropzone/Dropzone.stories.js +257 -63
- package/Dropzone/Dropzone.stories.js.map +1 -1
- package/Dropzone/Dropzone.types.d.ts +17 -1
- package/Dropzone/Dropzone.types.d.ts.map +1 -1
- package/Dropzone/Dropzone.types.js +18 -7
- package/Dropzone/Dropzone.types.js.map +1 -1
- package/Dropzone/DropzoneFilePreview.d.ts.map +1 -1
- package/Dropzone/DropzoneFilePreview.js +46 -26
- package/Dropzone/DropzoneFilePreview.js.map +1 -1
- package/Dropzone/DropzoneSinglePickPreview.d.ts +5 -2
- package/Dropzone/DropzoneSinglePickPreview.d.ts.map +1 -1
- package/Dropzone/DropzoneSinglePickPreview.js +119 -22
- package/Dropzone/DropzoneSinglePickPreview.js.map +1 -1
- package/Dropzone/DropzoneUtils.js.map +1 -1
- package/Dropzone/index.js +7 -5
- package/Form/Form.js +14 -15
- package/Form/Form.js.map +1 -1
- package/Form/FormRenderControl.js +6 -7
- package/Form/FormRenderControl.js.map +1 -1
- package/Form/Form_old.js +4 -5
- package/Form/Form_old.js.map +1 -1
- package/FormCheckbox/FormCheckbox.js +4 -4
- package/FormCheckbox/FormCheckbox.js.map +1 -1
- package/FormCombobox/FormCombobox.js +4 -4
- package/FormCombobox/FormCombobox.js.map +1 -1
- package/FormDatePicker/FormDatePicker.js +4 -4
- package/FormDatePicker/FormDatePicker.js.map +1 -1
- package/FormDropzone/FormDropzone.js +3 -3
- package/FormDropzone/FormDropzone.js.map +1 -1
- package/FormInput/FormInput.js +6 -6
- package/FormInput/FormInput.js.map +1 -1
- package/FormInput/FormInput.stories.js.map +1 -1
- package/FormRadio/FormRadio.js.map +1 -1
- package/FormSelect/FormSelect.js +6 -9
- package/FormSelect/FormSelect.js.map +1 -1
- package/FormTextarea/FormTextarea.js +4 -4
- package/FormTextarea/FormTextarea.js.map +1 -1
- package/Header/Header.js.map +1 -1
- package/HoverCard/HoverCard.js.map +1 -1
- package/InfoBlock/InfoBlock.js.map +1 -1
- package/InfoBlock/InfoBlock.stories.js.map +1 -1
- package/InfoBlock/infoBlockVariants.js.map +1 -1
- package/Input/Input.js.map +1 -1
- package/Input/Input.stories.js.map +1 -1
- package/Input/inputVariants.js.map +1 -1
- package/InputOTP/InputOTP.d.ts.map +1 -1
- package/InputOTP/InputOTP.js.map +1 -1
- package/LICENSE +21 -21
- package/Label/Label.js.map +1 -1
- package/Label/labelVariants.js.map +1 -1
- package/LazyLoader/LazyLoader.js +4 -5
- package/LazyLoader/LazyLoader.js.map +1 -1
- package/LoadedIcon/LoadedIcon.js.map +1 -1
- package/LoadingMask/LoadingMask.js.map +1 -1
- package/LoadingMask/RenderLoadingMask.js.map +1 -1
- package/LoadingProgress/LoadingProgress.js.map +1 -1
- package/LoadingProgress/loadingProgressVariants.js.map +1 -1
- package/Menubar/Menubar.js.map +1 -1
- package/NavigationMenu/NavigationMenu.js.map +1 -1
- package/NavigationMenu/navigationMenuVariants.js.map +1 -1
- package/Pagination/Pagination.js +0 -1
- package/Pagination/Pagination.js.map +1 -1
- package/Popover/Popover.js.map +1 -1
- package/Progress/Progress.js.map +1 -1
- package/README.md +7 -7
- package/Radio/Radio.js.map +1 -1
- package/RadioGroup/RadioGroup.js.map +1 -1
- package/Resizable/Resizable.js.map +1 -1
- package/Resizable/Resizable.stories.js.map +1 -1
- package/ScrollArea/ScrollArea.js.map +1 -1
- package/Search/Search.js +9 -9
- package/Search/Search.js.map +1 -1
- package/Search/Search.stories.js.map +1 -1
- package/Select/Select.js +6 -7
- package/Select/Select.js.map +1 -1
- package/Select/Select.stories.js.map +1 -1
- package/Select/SelectRoot.js.map +1 -1
- package/Separator/Separator.js.map +1 -1
- package/Sheet/Sheet.js.map +1 -1
- package/Sidebar/Sidebar.js +20 -21
- package/Sidebar/Sidebar.js.map +1 -1
- package/Skeleton/Skeleton.js.map +1 -1
- package/Slider/Slider.js.map +1 -1
- package/Sonner/Sonner.js.map +1 -1
- package/Switch/Switch.js.map +1 -1
- package/Switch/Switch.stories.js.map +1 -1
- package/Table/Table.js.map +1 -1
- package/TablePagination/TablePagination.js +21 -26
- package/TablePagination/TablePagination.js.map +1 -1
- package/Tabs/Tabs.js.map +1 -1
- package/Tabs/TabsRoot.js.map +1 -1
- package/Textarea/Textarea.js.map +1 -1
- package/Textarea/Textarea.stories.js.map +1 -1
- package/Textarea/useAutosizeTextArea.js.map +1 -1
- package/Theme/ThemeModeToggle.js +3 -4
- package/Theme/ThemeModeToggle.js.map +1 -1
- package/Theme/ThemeProvider.js.map +1 -1
- package/Toast/Toast.js.map +1 -1
- package/Toast/toast.constants.js.map +1 -1
- package/Toast/toastVariants.js.map +1 -1
- package/Toast/useToast.js.map +1 -1
- package/Toaster/Toaster.js.map +1 -1
- package/Toggle/Toggle.js.map +1 -1
- package/ToggleGroup/ToggleGroup.js.map +1 -1
- package/Tooltip/Tooltip.js.map +1 -1
- package/Tooltip/TooltipRoot.js.map +1 -1
- package/Tooltip/tooltipVariants.js.map +1 -1
- package/index.js +298 -296
- package/package.json +7 -5
- package/styles.css +1 -0
- package/vite-env.d.ts +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropzoneFilePreview.js","sources":["../../src/Dropzone/DropzoneFilePreview.tsx"],"sourcesContent":["import { FC, useEffect, useState } from 'react';\nimport { File as FileIcon } from 'lucide-react';\nimport { DEFAULT_IMAGES_TYPES, FilePreviewProps } from './Dropzone.types';\nimport { isFile } from './DropzoneUtils';\nimport { cn } from '@oneplatformdev/utils';\n\nexport const FilePreview: FC<FilePreviewProps> = ({ item, styles }) => {\n const [preview, setPreview] = useState<string | null>(null);\n\n const isFileTypeImage =\n isFile(item) && DEFAULT_IMAGES_TYPES.includes(item.type);\n\n useEffect(() => {\n let img: HTMLImageElement | null = null;\n\n if (isFile(item) && isFileTypeImage) {\n const reader = new FileReader();\n reader.onloadend = () => setPreview(reader.result as string);\n reader.readAsDataURL(item);\n\n return () => setPreview(null);\n } else if (typeof item === 'string') {\n img = new Image();\n img.src = item;\n img.onload = () => setPreview(item);\n img.onerror = () => setPreview(null);\n\n return () => {\n img!.onload = null;\n img!.onerror = null;\n };\n } else {\n setPreview(null);\n }\n\n return () => setPreview(null);\n }, [item, isFileTypeImage]);\n\n return (\n <div\n className={cn(\n 'w-32 h-32 border border-gray-300 rounded-md overflow-hidden flex items-center justify-center',\n styles?.previewWraper\n )}\n >\n {preview ? (\n <img\n src={preview}\n alt={isFile(item) ? item.name : 'external-image'}\n className={cn('w-full h-full object-cover', styles?.previewImage)}\n />\n ) : (\n <div\n className={cn(\n 'flex flex-col items-center justify-center text-gray-500 text-sm p-2 text-center',\n styles?.previewFile\n )}\n >\n <FileIcon className=\"w-6 h-6\" />\n {!isFile(item) ? (\n <span className=\"text-xs break-all\">{item}</span>\n ) : (\n <span className=\"text-xs break-all\">{item.name}</span>\n )}\n </div>\n )}\n </div>\n );\n};\n"],"names":["FilePreview","item","styles","preview","setPreview","useState","isFileTypeImage","isFile","DEFAULT_IMAGES_TYPES","useEffect","img","reader","jsx","cn","jsxs","FileIcon"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DropzoneFilePreview.js","sources":["../../src/Dropzone/DropzoneFilePreview.tsx"],"sourcesContent":["import { FC, useEffect, useState } from 'react';\r\nimport { File as FileIcon } from 'lucide-react';\r\nimport { DEFAULT_IMAGES_TYPES, FilePreviewProps } from './Dropzone.types';\r\nimport { isFile } from './DropzoneUtils';\r\nimport { cn } from '@oneplatformdev/utils';\r\nimport { MediaPlayer, MediaProvider } from '@vidstack/react';\r\nimport { defaultLayoutIcons, DefaultVideoLayout } from '@vidstack/react/player/layouts/default';\r\n\r\nimport '@vidstack/react/player/styles/base.css';\r\nimport '@vidstack/react/player/styles/default/theme.css';\r\nimport '@vidstack/react/player/styles/default/layouts/video.css';\r\n\r\nexport const FilePreview: FC<FilePreviewProps> = ({ item, styles }) => {\r\n const [preview, setPreview] = useState<string | null>(null);\r\n\r\n const isFileTypeImage =\r\n isFile(item) && DEFAULT_IMAGES_TYPES.includes(item.type);\r\n const isFileTypeVideo = isFile(item) && item.type.includes('video');\r\n\r\n useEffect(() => {\r\n let img: HTMLImageElement | null = null;\r\n\r\n if (isFile(item) && isFileTypeImage) {\r\n const reader = new FileReader();\r\n reader.onloadend = () => setPreview(reader.result as string);\r\n reader.readAsDataURL(item);\r\n\r\n return () => setPreview(null);\r\n } else if (typeof item === 'string') {\r\n img = new Image();\r\n img.src = item;\r\n img.onload = () => setPreview(item);\r\n img.onerror = () => setPreview(null);\r\n\r\n return () => {\r\n img!.onload = null;\r\n img!.onerror = null;\r\n };\r\n } else if (isFile(item) && isFileTypeVideo) {\r\n const objectUrl = URL.createObjectURL(item);\r\n setPreview(objectUrl);\r\n return () => URL.revokeObjectURL(objectUrl);\r\n } else {\r\n setPreview(null);\r\n }\r\n\r\n return () => setPreview(null);\r\n }, [item, isFileTypeImage, isFileTypeVideo]);\r\n\r\n return (\r\n <div\r\n className={cn(\r\n 'w-32 h-32 border border-gray-300 rounded-md overflow-hidden flex items-center justify-center',\r\n styles?.previewWraper\r\n )}\r\n >\r\n {preview && isFileTypeVideo ? (\r\n <div className=\"w-full h-full bg-black\" onClick={(event) => event.stopPropagation()}>\r\n <MediaPlayer\r\n src={isFile(item) ? { src: preview, type: item.type } : preview}\r\n className=\"h-full w-full bg-black text-white\"\r\n playsInline\r\n >\r\n <MediaProvider />\r\n <DefaultVideoLayout icons={defaultLayoutIcons} />\r\n </MediaPlayer>\r\n </div>\r\n ) : preview ? (\r\n <img\r\n src={preview}\r\n alt={isFile(item) ? item.name : 'external-image'}\r\n className={cn('w-full h-full object-cover', styles?.previewImage)}\r\n />\r\n ) : (\r\n <div\r\n className={cn(\r\n 'flex flex-col items-center justify-center text-gray-500 text-sm p-2 text-center',\r\n styles?.previewFile\r\n )}\r\n >\r\n <FileIcon className=\"w-6 h-6\" />\r\n {!isFile(item) ? (\r\n <span className=\"text-xs break-all\">{item}</span>\r\n ) : (\r\n <span className=\"text-xs break-all\">{item.name}</span>\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n};\r\n"],"names":["FilePreview","item","styles","preview","setPreview","useState","isFileTypeImage","isFile","DEFAULT_IMAGES_TYPES","isFileTypeVideo","useEffect","img","reader","objectUrl","jsx","cn","event","jsxs","MediaPlayer","MediaProvider","DefaultVideoLayout","defaultLayoutIcons","FileIcon"],"mappings":";;;;;;;;;;;AAYO,MAAMA,IAAoC,CAAC,EAAE,MAAAC,GAAM,QAAAC,QAAa;AACrE,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAwB,IAAI,GAEpDC,IACJC,EAAON,CAAI,KAAKO,EAAqB,SAASP,EAAK,IAAI,GACnDQ,IAAkBF,EAAON,CAAI,KAAKA,EAAK,KAAK,SAAS,OAAO;AAElE,SAAAS,EAAU,MAAM;AACd,QAAIC,IAA+B;AAEnC,QAAIJ,EAAON,CAAI,KAAKK,GAAiB;AACnC,YAAMM,IAAS,IAAI,WAAA;AACnB,aAAAA,EAAO,YAAY,MAAMR,EAAWQ,EAAO,MAAgB,GAC3DA,EAAO,cAAcX,CAAI,GAElB,MAAMG,EAAW,IAAI;AAAA,IAC9B,OAAA;AAAA,UAAW,OAAOH,KAAS;AACzB,eAAAU,IAAM,IAAI,MAAA,GACVA,EAAI,MAAMV,GACVU,EAAI,SAAS,MAAMP,EAAWH,CAAI,GAClCU,EAAI,UAAU,MAAMP,EAAW,IAAI,GAE5B,MAAM;AACX,UAAAO,EAAK,SAAS,MACdA,EAAK,UAAU;AAAA,QACjB;AACF,UAAWJ,EAAON,CAAI,KAAKQ,GAAiB;AAC1C,cAAMI,IAAY,IAAI,gBAAgBZ,CAAI;AAC1C,eAAAG,EAAWS,CAAS,GACb,MAAM,IAAI,gBAAgBA,CAAS;AAAA,MAC5C;AACE,QAAAT,EAAW,IAAI;AAAA;AAGjB,WAAO,MAAMA,EAAW,IAAI;AAAA,EAC9B,GAAG,CAACH,GAAMK,GAAiBG,CAAe,CAAC,GAGzC,gBAAAK;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC;AAAA,QACT;AAAA,QACAb,GAAQ;AAAA,MAAA;AAAA,MAGT,UAAAC,KAAWM,IACV,gBAAAK,EAAC,OAAA,EAAI,WAAU,0BAAyB,SAAS,CAACE,MAAUA,EAAM,gBAAA,GAChE,UAAA,gBAAAC;AAAA,QAACC;AAAA,QAAA;AAAA,UACC,KAAKX,EAAON,CAAI,IAAI,EAAE,KAAKE,GAAS,MAAMF,EAAK,KAAA,IAASE;AAAA,UACxD,WAAU;AAAA,UACV,aAAW;AAAA,UAEX,UAAA;AAAA,YAAA,gBAAAW,EAACK,GAAA,EAAc;AAAA,YACf,gBAAAL,EAACM,GAAA,EAAmB,OAAOC,EAAA,CAAoB;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA,EACjD,CACF,IACElB,IACF,gBAAAW;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,KAAKX;AAAA,UACL,KAAKI,EAAON,CAAI,IAAIA,EAAK,OAAO;AAAA,UAChC,WAAWc,EAAG,8BAA8Bb,GAAQ,YAAY;AAAA,QAAA;AAAA,MAAA,IAGlE,gBAAAe;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWF;AAAA,YACT;AAAA,YACAb,GAAQ;AAAA,UAAA;AAAA,UAGV,UAAA;AAAA,YAAA,gBAAAY,EAACQ,GAAA,EAAS,WAAU,UAAA,CAAU;AAAA,YAC5Bf,EAAON,CAAI,IAGX,gBAAAa,EAAC,QAAA,EAAK,WAAU,qBAAqB,YAAK,KAAA,CAAK,sBAF9C,QAAA,EAAK,WAAU,qBAAqB,UAAAb,EAAA,CAAK;AAAA,UAEK;AAAA,QAAA;AAAA,MAAA;AAAA,IAEnD;AAAA,EAAA;AAIR;"}
|
|
@@ -3,8 +3,11 @@ export declare const transformImageToSrc: (preview?: string | File | null) => st
|
|
|
3
3
|
interface SinglePickPreviewProps {
|
|
4
4
|
item: DropzoneValueItem;
|
|
5
5
|
disabled?: boolean;
|
|
6
|
-
onRemoveClick: (e: React.MouseEvent<
|
|
6
|
+
onRemoveClick: (e: React.MouseEvent<HTMLElement>) => void;
|
|
7
|
+
onReplaceClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
8
|
+
labelUploaded?: string;
|
|
9
|
+
labelReplace?: string;
|
|
7
10
|
}
|
|
8
|
-
export declare const DropzoneSinglePickPreview: ({ item, disabled, onRemoveClick, }: SinglePickPreviewProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const DropzoneSinglePickPreview: ({ item, disabled, onRemoveClick, onReplaceClick, labelReplace, }: SinglePickPreviewProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
12
|
export {};
|
|
10
13
|
//# sourceMappingURL=DropzoneSinglePickPreview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropzoneSinglePickPreview.d.ts","sourceRoot":"","sources":["../../src/Dropzone/DropzoneSinglePickPreview.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"DropzoneSinglePickPreview.d.ts","sourceRoot":"","sources":["../../src/Dropzone/DropzoneSinglePickPreview.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAOrD,OAAO,wCAAwC,CAAC;AAChD,OAAO,iDAAiD,CAAC;AACzD,OAAO,yDAAyD,CAAC;AACjE,OAAO,iCAAiC,CAAC;AAGzC,eAAO,MAAM,mBAAmB,GAAI,UAAU,MAAM,GAAG,IAAI,GAAG,IAAI,KAAG,MAYpE,CAAC;AAqCF,UAAU,sBAAsB;IAC9B,IAAI,EAAE,iBAAiB,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAC1D,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,yBAAyB,GAAI,kEAMvC,sBAAsB,4CAyIxB,CAAC"}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { isFile as
|
|
4
|
-
import { X as
|
|
5
|
-
|
|
1
|
+
import { jsxs as c, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as y, useMemo as d, useEffect as w } from "react";
|
|
3
|
+
import { isFile as N } from "./DropzoneUtils.js";
|
|
4
|
+
import { X as x, FileIcon as v, Video as k, PencilIcon as L, Trash2 as F } from "lucide-react";
|
|
5
|
+
import { MediaPlayer as P, MediaProvider as z } from "@vidstack/react";
|
|
6
|
+
import { DefaultVideoLayout as E, defaultLayoutIcons as I } from "@vidstack/react/player/layouts/default";
|
|
7
|
+
import { Button as U } from "../Button/Button.js";
|
|
8
|
+
import "@vidstack/react/player/styles/base.css";
|
|
9
|
+
import "@vidstack/react/player/styles/default/theme.css";
|
|
10
|
+
import "@vidstack/react/player/styles/default/layouts/video.css";
|
|
11
|
+
/* empty css */
|
|
12
|
+
import { ButtonIcon as j } from "../ButtonIcon/ButtonIcon.js";
|
|
13
|
+
const C = (e) => {
|
|
6
14
|
if (!e) return "";
|
|
7
15
|
switch (!0) {
|
|
8
16
|
case (typeof e == "string" && !!e.trim() && e !== "null"):
|
|
@@ -14,29 +22,118 @@ const m = (e) => {
|
|
|
14
22
|
default:
|
|
15
23
|
return "";
|
|
16
24
|
}
|
|
17
|
-
},
|
|
25
|
+
}, S = (e) => {
|
|
26
|
+
if (!e) return !1;
|
|
27
|
+
try {
|
|
28
|
+
const i = new URL(e).hostname.toLowerCase();
|
|
29
|
+
return i.includes("youtube.com") || i.includes("youtu.be");
|
|
30
|
+
} catch {
|
|
31
|
+
return !1;
|
|
32
|
+
}
|
|
33
|
+
}, B = (e) => {
|
|
34
|
+
try {
|
|
35
|
+
const o = new URL(e);
|
|
36
|
+
if (o.hostname.toLowerCase().includes("youtu.be"))
|
|
37
|
+
return o.pathname.replace("/", "").trim();
|
|
38
|
+
const f = o.searchParams.get("v");
|
|
39
|
+
if (f) return f.trim();
|
|
40
|
+
const u = o.pathname.split("/").filter(Boolean), l = u.findIndex((h) => h === "embed");
|
|
41
|
+
return l >= 0 && u[l + 1] ? u[l + 1].trim() : "";
|
|
42
|
+
} catch {
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
}, G = ({
|
|
18
46
|
item: e,
|
|
19
|
-
disabled:
|
|
20
|
-
onRemoveClick:
|
|
47
|
+
disabled: o,
|
|
48
|
+
onRemoveClick: i,
|
|
49
|
+
onReplaceClick: f,
|
|
50
|
+
labelReplace: u = "Замінити"
|
|
21
51
|
}) => {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
52
|
+
const [l, h] = y(""), n = N(e), m = n ? e.name : e, s = d(
|
|
53
|
+
() => typeof e == "string" && S(e),
|
|
54
|
+
[e]
|
|
55
|
+
), g = d(() => {
|
|
56
|
+
if (!s || typeof e != "string") return "";
|
|
57
|
+
const r = B(e);
|
|
58
|
+
return r ? `youtube/${r}` : e;
|
|
59
|
+
}, [s, e]), p = d(() => n && e.type?.includes("image") || typeof e == "string" && !s, [e, n, s]), a = d(() => n && e.type?.includes("video") || s, [e, n, s]), b = d(() => n ? `${(e.size / (1024 * 1024)).toFixed(0)} MB` : "", [e, n]);
|
|
60
|
+
return w(() => {
|
|
61
|
+
if (p || a) {
|
|
62
|
+
const r = C(e);
|
|
63
|
+
if (h(r), n && r)
|
|
64
|
+
return () => URL.revokeObjectURL(r);
|
|
65
|
+
} else
|
|
66
|
+
h("");
|
|
67
|
+
}, [e, n, p, a]), /* @__PURE__ */ c("div", { className: "relative w-full overflow-hidden", children: [
|
|
68
|
+
a && l ? /* @__PURE__ */ t("div", { className: "w-full h-64 sm:h-80 md:h-96 rounded-lg overflow-hidden bg-black", onClick: (r) => r.stopPropagation(), children: /* @__PURE__ */ c(
|
|
69
|
+
P,
|
|
70
|
+
{
|
|
71
|
+
src: s ? g : { src: l, type: n ? e.type : void 0 },
|
|
72
|
+
className: `h-full w-full bg-black text-white ${s ? "dropzone-youtube-player" : ""}`,
|
|
73
|
+
playsInline: !0,
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ t(z, {}),
|
|
76
|
+
/* @__PURE__ */ t(E, { icons: I })
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
) }) : !a && l ? /* @__PURE__ */ c("div", { className: "relative w-full h-64 sm:h-80 md:h-96 overflow-hidden outline-[#E4E4E7] outline-2 outline-dashed -outline-offset-1 rounded-lg", children: [
|
|
80
|
+
!o && /* @__PURE__ */ t("div", { className: "absolute top-2 right-2 cursor-pointer bg-white/70 rounded-[4px] p-1 shadow-sm", onClick: i, children: /* @__PURE__ */ t(x, { size: 16, strokeWidth: 2, color: "black" }) }),
|
|
81
|
+
/* @__PURE__ */ t(
|
|
82
|
+
"img",
|
|
83
|
+
{
|
|
84
|
+
src: l,
|
|
85
|
+
alt: m?.toString(),
|
|
86
|
+
className: "w-full h-full object-cover rounded-lg "
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
] }) : a ? null : /* @__PURE__ */ c("div", { className: "relative w-full h-64 sm:h-80 md:h-96 overflow-hidden outline-[#E4E4E7] outline-2 outline-dashed -outline-offset-1 rounded-lg", children: [
|
|
90
|
+
!o && /* @__PURE__ */ t("div", { className: "absolute top-2 right-2 cursor-pointer bg-white/70 rounded-[4px] p-1 shadow-sm", onClick: i, children: /* @__PURE__ */ t(x, { size: 16, strokeWidth: 2, color: "black" }) }),
|
|
91
|
+
/* @__PURE__ */ c("div", { className: "w-full h-full flex flex-col items-center justify-center text-gray-600", children: [
|
|
92
|
+
/* @__PURE__ */ t(v, { size: 28 }),
|
|
93
|
+
/* @__PURE__ */ t("span", { className: "text-sm mt-2 break-all px-2 text-center", children: m?.toString() })
|
|
94
|
+
] })
|
|
95
|
+
] }),
|
|
96
|
+
a && !s && /* @__PURE__ */ c(
|
|
97
|
+
"div",
|
|
27
98
|
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
99
|
+
className: "mt-2 w-full h-auto min-h-14 rounded-[8px] border border-[#E8E9EB] bg-[#FCFCFC] p-2 flex items-center gap-4",
|
|
100
|
+
onClick: (r) => r.stopPropagation(),
|
|
101
|
+
children: [
|
|
102
|
+
/* @__PURE__ */ t("div", { className: "size-10 rounded-[8px] bg-[#9368FF1F] flex items-center justify-center shrink-0", children: /* @__PURE__ */ t(k, { className: "size-6 text-[#06080D]" }) }),
|
|
103
|
+
/* @__PURE__ */ c("div", { className: "flex flex-col items-start text-left gap-1 min-w-0 flex-1 justify-start", children: [
|
|
104
|
+
/* @__PURE__ */ t("span", { className: "w-full text-[14px] font-semibold leading-[125%] text-[#06080D] truncate text-left", children: m?.toString() }),
|
|
105
|
+
/* @__PURE__ */ t("span", { className: "w-full text-[12px] font-medium leading-[120%] text-[#363B4E] text-left", children: b })
|
|
106
|
+
] }),
|
|
107
|
+
!o && /* @__PURE__ */ t(
|
|
108
|
+
U,
|
|
109
|
+
{
|
|
110
|
+
type: "button",
|
|
111
|
+
color: "secondary",
|
|
112
|
+
startAdornment: L,
|
|
113
|
+
size: "md",
|
|
114
|
+
onClick: (r) => {
|
|
115
|
+
r.stopPropagation(), f?.(r);
|
|
116
|
+
},
|
|
117
|
+
children: u
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
!o && /* @__PURE__ */ t(
|
|
121
|
+
j,
|
|
122
|
+
{
|
|
123
|
+
icon: F,
|
|
124
|
+
variant: "outlined",
|
|
125
|
+
size: "md",
|
|
126
|
+
color: "secondary",
|
|
127
|
+
onClick: i
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
]
|
|
31
131
|
}
|
|
32
|
-
)
|
|
33
|
-
/* @__PURE__ */ t(d, { size: 28 }),
|
|
34
|
-
/* @__PURE__ */ t("span", { className: "text-sm mt-2 break-all px-2 text-center", children: r?.toString() })
|
|
35
|
-
] })
|
|
132
|
+
)
|
|
36
133
|
] });
|
|
37
134
|
};
|
|
38
135
|
export {
|
|
39
|
-
|
|
40
|
-
|
|
136
|
+
G as DropzoneSinglePickPreview,
|
|
137
|
+
C as transformImageToSrc
|
|
41
138
|
};
|
|
42
139
|
//# sourceMappingURL=DropzoneSinglePickPreview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropzoneSinglePickPreview.js","sources":["../../src/Dropzone/DropzoneSinglePickPreview.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { DropzoneValueItem } from './Dropzone.types';\nimport { isFile } from './DropzoneUtils';\nimport { FileIcon, X } from 'lucide-react';\n\nexport const transformImageToSrc = (preview?: string | File | null): string => {\n if (!preview) return '';\n switch (true) {\n case typeof preview === 'string' && !!preview.trim() && preview !== 'null':\n return preview;\n case preview instanceof File:\n return URL.createObjectURL(preview);\n case preview instanceof FileList:\n return preview[0] ? URL.createObjectURL(preview[0]) : '';\n default:\n return '';\n }\n};\n\ninterface SinglePickPreviewProps {\n item: DropzoneValueItem;\n disabled?: boolean;\n onRemoveClick: (e: React.MouseEvent<HTMLDivElement>) => void;\n}\n\nexport const DropzoneSinglePickPreview = ({\n item,\n disabled,\n onRemoveClick,\n}: SinglePickPreviewProps) => {\n const isFileType = isFile(item);\n const fileName = isFileType ? item.name : item;\n\n const showImage = useMemo(() => {\n return (isFileType && (item as File)?.type?.includes('image')) || typeof item === 'string';\n }, [item, isFileType]);\n\n const preview = useMemo(() => (showImage ? transformImageToSrc(item) : ''), [item, showImage]);\n\n return (\n <div className=\"relative w-full h-64 sm:h-80 md:h-96 overflow-hidden outline-[#E4E4E7] outline-2 outline-dashed -outline-offset-1 rounded-lg\">\n {!disabled && (\n <div className=\"absolute top-2 right-2 cursor-pointer bg-white/70 rounded-[4px] p-1 shadow-sm\" onClick={onRemoveClick} >\n <X size={16} strokeWidth={2} color=\"black\" />\n </div>\n )}\n\n {preview ? (\n <img\n src={preview}\n alt={fileName?.toString()}\n className=\"w-full h-full object-cover rounded-lg \"\n />\n ) : (\n <div className=\"w-full h-full flex flex-col items-center justify-center text-gray-600\">\n <FileIcon size={28} />\n <span className=\"text-sm mt-2 break-all px-2 text-center\">\n {fileName?.toString()}\n </span>\n </div>\n )}\n </div>\n );\n};\n"],"names":["transformImageToSrc","preview","DropzoneSinglePickPreview","item","disabled","onRemoveClick","isFileType","isFile","fileName","showImage","useMemo","jsxs","jsx","X","FileIcon"],"mappings":";;;;AAKO,MAAMA,IAAsB,CAACC,MAA2C;AAC7E,MAAI,CAACA,EAAS,QAAO;AACrB,UAAQ,IAAA;AAAA,IACN,MAAK,OAAOA,KAAY,YAAY,CAAC,CAACA,EAAQ,KAAA,KAAUA,MAAY;AAClE,aAAOA;AAAA,IACT,KAAKA,aAAmB;AACtB,aAAO,IAAI,gBAAgBA,CAAO;AAAA,IACpC,KAAKA,aAAmB;AACtB,aAAOA,EAAQ,CAAC,IAAI,IAAI,gBAAgBA,EAAQ,CAAC,CAAC,IAAI;AAAA,IACxD;AACE,aAAO;AAAA,EAAA;AAEb,GAQaC,IAA4B,CAAC;AAAA,EACxC,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,eAAAC;AACF,MAA8B;AAC5B,QAAMC,IAAaC,EAAOJ,CAAI,GACxBK,IAAWF,IAAaH,EAAK,OAAOA,GAEpCM,IAAYC,EAAQ,MAChBJ,KAAeH,GAAe,MAAM,SAAS,OAAO,KAAM,OAAOA,KAAS,UACjF,CAACA,GAAMG,CAAU,CAAC,GAEfL,IAAUS,EAAQ,MAAOD,IAAYT,EAAoBG,CAAI,IAAI,IAAK,CAACA,GAAMM,CAAS,CAAC;AAE7F,SACE,gBAAAE,EAAC,OAAA,EAAI,WAAU,iIACZ,UAAA;AAAA,IAAA,CAACP,KACA,gBAAAQ,EAAC,OAAA,EAAI,WAAU,iFAAgF,SAASP,GACtG,UAAA,gBAAAO,EAACC,GAAA,EAAE,MAAM,IAAI,aAAa,GAAG,OAAM,SAAQ,GAC7C;AAAA,IAGDZ,IACC,gBAAAW;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAKX;AAAA,QACL,KAAKO,GAAU,SAAA;AAAA,QACf,WAAU;AAAA,MAAA;AAAA,IAAA,IAGZ,gBAAAG,EAAC,OAAA,EAAI,WAAU,yEACb,UAAA;AAAA,MAAA,gBAAAC,EAACE,GAAA,EAAS,MAAM,GAAA,CAAI;AAAA,wBACnB,QAAA,EAAK,WAAU,2CACb,UAAAN,GAAU,WAAS,CACtB;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"DropzoneSinglePickPreview.js","sources":["../../src/Dropzone/DropzoneSinglePickPreview.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react';\r\nimport { DropzoneValueItem } from './Dropzone.types';\r\nimport { isFile } from './DropzoneUtils';\r\nimport { FileIcon, PencilIcon, Trash2, Video, X } from 'lucide-react';\r\nimport { MediaPlayer, MediaProvider } from '@vidstack/react';\r\nimport { defaultLayoutIcons, DefaultVideoLayout } from '@vidstack/react/player/layouts/default';\r\nimport { Button } from '../Button/Button';\r\n\r\nimport '@vidstack/react/player/styles/base.css';\r\nimport '@vidstack/react/player/styles/default/theme.css';\r\nimport '@vidstack/react/player/styles/default/layouts/video.css';\r\nimport './DropzoneSinglePickPreview.css';\r\nimport { ButtonIcon } from \"../ButtonIcon\";\r\n\r\nexport const transformImageToSrc = (preview?: string | File | null): string => {\r\n if (!preview) return '';\r\n switch (true) {\r\n case typeof preview === 'string' && !!preview.trim() && preview !== 'null':\r\n return preview;\r\n case preview instanceof File:\r\n return URL.createObjectURL(preview);\r\n case preview instanceof FileList:\r\n return preview[0] ? URL.createObjectURL(preview[0]) : '';\r\n default:\r\n return '';\r\n }\r\n};\r\n\r\nconst isYoutubeUrl = (value?: string | null) => {\r\n if (!value) return false;\r\n try {\r\n const url = new URL(value);\r\n const hostname = url.hostname.toLowerCase();\r\n return hostname.includes('youtube.com') || hostname.includes('youtu.be');\r\n } catch {\r\n return false;\r\n }\r\n};\r\n\r\nconst extractYoutubeId = (value: string) => {\r\n try {\r\n const url = new URL(value);\r\n const hostname = url.hostname.toLowerCase();\r\n\r\n if (hostname.includes('youtu.be')) {\r\n return url.pathname.replace('/', '').trim();\r\n }\r\n\r\n const searchId = url.searchParams.get('v');\r\n if (searchId) return searchId.trim();\r\n\r\n const pathParts = url.pathname.split('/').filter(Boolean);\r\n const embedIndex = pathParts.findIndex((part) => part === 'embed');\r\n if (embedIndex >= 0 && pathParts[embedIndex + 1]) {\r\n return pathParts[embedIndex + 1].trim();\r\n }\r\n\r\n return '';\r\n } catch {\r\n return '';\r\n }\r\n};\r\n\r\ninterface SinglePickPreviewProps {\r\n item: DropzoneValueItem;\r\n disabled?: boolean;\r\n onRemoveClick: (e: React.MouseEvent<HTMLElement>) => void;\r\n onReplaceClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;\r\n labelUploaded?: string;\r\n labelReplace?: string;\r\n}\r\n\r\nexport const DropzoneSinglePickPreview = ({\r\n item,\r\n disabled,\r\n onRemoveClick,\r\n onReplaceClick,\r\n labelReplace = 'Замінити',\r\n}: SinglePickPreviewProps) => {\r\n const [previewUrl, setPreviewUrl] = useState('');\r\n const isFileType = isFile(item);\r\n const fileName = isFileType ? item.name : item;\r\n\r\n const isYoutubeVideo = useMemo(\r\n () => typeof item === 'string' && isYoutubeUrl(item),\r\n [item]\r\n );\r\n const youtubeSource = useMemo(() => {\r\n if (!isYoutubeVideo || typeof item !== 'string') return '';\r\n const id = extractYoutubeId(item);\r\n return id ? `youtube/${id}` : item;\r\n }, [isYoutubeVideo, item]);\r\n\r\n const showImage = useMemo(() => {\r\n return (isFileType && item.type?.includes('image')) || (typeof item === 'string' && !isYoutubeVideo);\r\n }, [item, isFileType, isYoutubeVideo]);\r\n\r\n const showVideo = useMemo(() => {\r\n return (isFileType && item.type?.includes('video')) || isYoutubeVideo;\r\n }, [item, isFileType, isYoutubeVideo]);\r\n\r\n const fileSize = useMemo(() => {\r\n if (!isFileType) return '';\r\n return `${(item.size / (1024 * 1024)).toFixed(0)} MB`;\r\n }, [item, isFileType]);\r\n\r\n useEffect(() => {\r\n if (showImage || showVideo) {\r\n const nextPreview = transformImageToSrc(item);\r\n setPreviewUrl(nextPreview);\r\n\r\n if (isFileType && nextPreview) {\r\n return () => URL.revokeObjectURL(nextPreview);\r\n }\r\n } else {\r\n setPreviewUrl('');\r\n }\r\n\r\n return undefined;\r\n }, [item, isFileType, showImage, showVideo]);\r\n\r\n return (\r\n <div className=\"relative w-full overflow-hidden\">\r\n {showVideo && previewUrl ? (\r\n <div className=\"w-full h-64 sm:h-80 md:h-96 rounded-lg overflow-hidden bg-black\" onClick={(event) => event.stopPropagation()}>\r\n <MediaPlayer\r\n src={\r\n isYoutubeVideo\r\n ? youtubeSource\r\n : { src: previewUrl, type: isFileType ? item.type : undefined }\r\n }\r\n className={`h-full w-full bg-black text-white ${\r\n isYoutubeVideo ? 'dropzone-youtube-player' : ''\r\n }`}\r\n playsInline\r\n >\r\n <MediaProvider />\r\n <DefaultVideoLayout icons={defaultLayoutIcons} />\r\n </MediaPlayer>\r\n </div>\r\n ) : !showVideo && previewUrl ? (\r\n <div className=\"relative w-full h-64 sm:h-80 md:h-96 overflow-hidden outline-[#E4E4E7] outline-2 outline-dashed -outline-offset-1 rounded-lg\">\r\n {!disabled && (\r\n <div className=\"absolute top-2 right-2 cursor-pointer bg-white/70 rounded-[4px] p-1 shadow-sm\" onClick={onRemoveClick} >\r\n <X size={16} strokeWidth={2} color=\"black\" />\r\n </div>\r\n )}\r\n <img\r\n src={previewUrl}\r\n alt={fileName?.toString()}\r\n className=\"w-full h-full object-cover rounded-lg \"\r\n />\r\n </div>\r\n ) : !showVideo ? (\r\n <div className=\"relative w-full h-64 sm:h-80 md:h-96 overflow-hidden outline-[#E4E4E7] outline-2 outline-dashed -outline-offset-1 rounded-lg\">\r\n {!disabled && (\r\n <div className=\"absolute top-2 right-2 cursor-pointer bg-white/70 rounded-[4px] p-1 shadow-sm\" onClick={onRemoveClick} >\r\n <X size={16} strokeWidth={2} color=\"black\" />\r\n </div>\r\n )}\r\n <div className=\"w-full h-full flex flex-col items-center justify-center text-gray-600\">\r\n <FileIcon size={28} />\r\n <span className=\"text-sm mt-2 break-all px-2 text-center\">\r\n {fileName?.toString()}\r\n </span>\r\n </div>\r\n </div>\r\n ) : null}\r\n\r\n {showVideo && !isYoutubeVideo && (\r\n <div\r\n className=\"mt-2 w-full h-auto min-h-14 rounded-[8px] border border-[#E8E9EB] bg-[#FCFCFC] p-2 flex items-center gap-4\"\r\n onClick={(event) => event.stopPropagation()}\r\n >\r\n <div className=\"size-10 rounded-[8px] bg-[#9368FF1F] flex items-center justify-center shrink-0\">\r\n <Video className=\"size-6 text-[#06080D]\" />\r\n </div>\r\n\r\n <div className=\"flex flex-col items-start text-left gap-1 min-w-0 flex-1 justify-start\">\r\n <span className=\"w-full text-[14px] font-semibold leading-[125%] text-[#06080D] truncate text-left\">\r\n {fileName?.toString()}\r\n </span>\r\n <span className=\"w-full text-[12px] font-medium leading-[120%] text-[#363B4E] text-left\">\r\n {fileSize}\r\n </span>\r\n </div>\r\n\r\n {!disabled && (\r\n <Button\r\n type=\"button\"\r\n color=\"secondary\"\r\n startAdornment={PencilIcon}\r\n size=\"md\"\r\n onClick={(event) => {\r\n event.stopPropagation();\r\n onReplaceClick?.(event);\r\n }}\r\n >\r\n {labelReplace}\r\n </Button>\r\n )}\r\n\r\n {!disabled && (\r\n <ButtonIcon\r\n icon={Trash2}\r\n variant=\"outlined\"\r\n size=\"md\"\r\n color=\"secondary\"\r\n onClick={onRemoveClick}\r\n />\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n};\r\n"],"names":["transformImageToSrc","preview","isYoutubeUrl","value","hostname","extractYoutubeId","url","searchId","pathParts","embedIndex","part","DropzoneSinglePickPreview","item","disabled","onRemoveClick","onReplaceClick","labelReplace","previewUrl","setPreviewUrl","useState","isFileType","isFile","fileName","isYoutubeVideo","useMemo","youtubeSource","id","showImage","showVideo","fileSize","useEffect","nextPreview","jsxs","jsx","event","MediaPlayer","MediaProvider","DefaultVideoLayout","defaultLayoutIcons","X","FileIcon","Video","Button","PencilIcon","ButtonIcon","Trash2"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropzoneUtils.js","sources":["../../src/Dropzone/DropzoneUtils.tsx"],"sourcesContent":["import { DropzoneValueItem } from './Dropzone.types';\n\nexport function isFile(item: DropzoneValueItem): item is File {\n return item instanceof File;\n}\n\nexport function extractName(url: string) {\n try {\n const parts = url.split('?')[0].split('#')[0].split('/');\n return parts[parts.length - 1] || url;\n } catch {\n return url;\n }\n}\n\nexport const DefaultFileIcon = () => {\n return (\n <svg width=\"55\" height=\"55\" viewBox=\"0 0 55 55\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <mask id=\"mask0_2430_114601\" maskUnits=\"userSpaceOnUse\" x=\"7\" y=\"4\" width=\"39\" height=\"46\">\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M7.25 4.68359H45.6174V49.354H7.25V4.68359Z\" fill=\"white\"/>\n </mask>\n <g mask=\"url(#mask0_2430_114601)\">\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M17.5386 8.05859C13.8103 8.05859 10.7143 11.0781 10.6266 14.8018V38.9196C10.5456 42.7468 13.5606 45.8968 17.3518 45.9801H35.5386C39.2938 45.8451 42.2661 42.7468 42.2413 38.9308V18.9216L31.8148 8.05859H17.5656H17.5386ZM17.5664 49.3551H17.2829C11.6309 49.2336 7.1309 44.5356 7.2524 38.8836V14.7613C7.38515 9.17909 11.9932 4.68359 17.5327 4.68359H17.5732H32.5334C32.9924 4.68359 33.4312 4.87034 33.7507 5.20109L45.1492 17.0743C45.4484 17.3871 45.6172 17.8078 45.6172 18.2421V38.9196C45.6532 44.5648 41.2522 49.1526 35.5979 49.3551H17.5664Z\" fill=\"#0D0E2B\" fill-opacity=\"0.7\"/>\n </g>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M43.9198 20.3703H37.7233C33.6036 20.359 30.2578 17.002 30.2578 12.889V6.34375C30.2578 5.41225 31.0138 4.65625 31.9453 4.65625C32.8768 4.65625 33.6328 5.41225 33.6328 6.34375V12.889C33.6328 15.148 35.4688 16.9885 37.7278 16.9953H43.9198C44.8513 16.9953 45.6073 17.7513 45.6073 18.6828C45.6073 19.6143 44.8513 20.3703 43.9198 20.3703Z\" fill=\"#0D0E2B\" fill-opacity=\"0.7\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M25.5708 37.729C24.6393 37.729 23.8833 36.973 23.8833 36.0415V22.4492C23.8833 21.5177 24.6393 20.7617 25.5708 20.7617C26.5023 20.7617 27.2583 21.5177 27.2583 22.4492V36.0415C27.2583 36.973 26.5023 37.729 25.5708 37.729Z\" fill=\"#0D0E2B\" fill-opacity=\"0.7\"/>\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M25.5678 37.7279C25.1201 37.7279 24.6881 37.5501 24.3731 37.2306L19.0968 31.9341C18.4398 31.2726 18.4421 30.2039 19.1013 29.5469C19.7628 28.8899 20.8316 28.8899 21.4886 29.5514L25.5678 33.6509L29.6471 29.5514C30.3041 28.8899 31.3728 28.8899 32.0343 29.5469C32.6936 30.2039 32.6958 31.2726 32.0388 31.9341L26.7626 37.2306C26.4476 37.5501 26.0156 37.7279 25.5678 37.7279Z\" fill=\"#0D0E2B\" fill-opacity=\"0.7\"/>\n </svg>\n \n );\n};\n"],"names":["isFile","item","extractName","url","parts","DefaultFileIcon","jsxs","jsx"],"mappings":";AAEO,SAASA,EAAOC,GAAuC;AAC5D,SAAOA,aAAgB;AACzB;AAEO,SAASC,EAAYC,GAAa;AACvC,MAAI;AACF,UAAMC,IAAQD,EAAI,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG;AACvD,WAAOC,EAAMA,EAAM,SAAS,CAAC,KAAKD;AAAA,EACpC,QAAQ;AACN,WAAOA;AAAA,EACT;AACF;AAEO,MAAME,IAAkB,MAE3B,gBAAAC,EAAC,OAAA,EAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,OAAM,8BAClE,UAAA;AAAA,EAAA,gBAAAC,EAAC,QAAA,EAAK,IAAG,qBAAoB,WAAU,kBAAiB,GAAE,KAAI,GAAE,KAAI,OAAM,MAAK,QAAO,MACtF,UAAA,gBAAAA,EAAC,QAAA,EAAK,aAAU,WAAU,aAAU,WAAU,GAAE,8CAA6C,MAAK,QAAA,CAAO,EAAA,CACzG;AAAA,oBACC,KAAA,EAAE,MAAK,2BACR,UAAA,gBAAAA,EAAC,UAAK,aAAU,WAAU,aAAU,WAAU,GAAE,4hBAA2hB,MAAK,WAAU,gBAAa,OAAK,GAC5mB;AAAA,EACA,gBAAAA,EAAC,QAAA,EAAK,aAAU,WAAU,aAAU,WAAU,GAAE,gVAA+U,MAAK,WAAU,gBAAa,MAAA,CAAK;AAAA,EACha,gBAAAA,EAAC,QAAA,EAAK,aAAU,WAAU,aAAU,WAAU,GAAE,+NAA8N,MAAK,WAAU,gBAAa,MAAA,CAAK;AAAA,EAC/S,gBAAAA,EAAC,QAAA,EAAK,aAAU,WAAU,aAAU,WAAU,GAAE,qXAAoX,MAAK,WAAU,gBAAa,MAAA,CAAK;AAAA,GACrc;"}
|
|
1
|
+
{"version":3,"file":"DropzoneUtils.js","sources":["../../src/Dropzone/DropzoneUtils.tsx"],"sourcesContent":["import { DropzoneValueItem } from './Dropzone.types';\r\n\r\nexport function isFile(item: DropzoneValueItem): item is File {\r\n return item instanceof File;\r\n}\r\n\r\nexport function extractName(url: string) {\r\n try {\r\n const parts = url.split('?')[0].split('#')[0].split('/');\r\n return parts[parts.length - 1] || url;\r\n } catch {\r\n return url;\r\n }\r\n}\r\n\r\nexport const DefaultFileIcon = () => {\r\n return (\r\n <svg width=\"55\" height=\"55\" viewBox=\"0 0 55 55\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <mask id=\"mask0_2430_114601\" maskUnits=\"userSpaceOnUse\" x=\"7\" y=\"4\" width=\"39\" height=\"46\">\r\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M7.25 4.68359H45.6174V49.354H7.25V4.68359Z\" fill=\"white\"/>\r\n </mask>\r\n <g mask=\"url(#mask0_2430_114601)\">\r\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M17.5386 8.05859C13.8103 8.05859 10.7143 11.0781 10.6266 14.8018V38.9196C10.5456 42.7468 13.5606 45.8968 17.3518 45.9801H35.5386C39.2938 45.8451 42.2661 42.7468 42.2413 38.9308V18.9216L31.8148 8.05859H17.5656H17.5386ZM17.5664 49.3551H17.2829C11.6309 49.2336 7.1309 44.5356 7.2524 38.8836V14.7613C7.38515 9.17909 11.9932 4.68359 17.5327 4.68359H17.5732H32.5334C32.9924 4.68359 33.4312 4.87034 33.7507 5.20109L45.1492 17.0743C45.4484 17.3871 45.6172 17.8078 45.6172 18.2421V38.9196C45.6532 44.5648 41.2522 49.1526 35.5979 49.3551H17.5664Z\" fill=\"#0D0E2B\" fill-opacity=\"0.7\"/>\r\n </g>\r\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M43.9198 20.3703H37.7233C33.6036 20.359 30.2578 17.002 30.2578 12.889V6.34375C30.2578 5.41225 31.0138 4.65625 31.9453 4.65625C32.8768 4.65625 33.6328 5.41225 33.6328 6.34375V12.889C33.6328 15.148 35.4688 16.9885 37.7278 16.9953H43.9198C44.8513 16.9953 45.6073 17.7513 45.6073 18.6828C45.6073 19.6143 44.8513 20.3703 43.9198 20.3703Z\" fill=\"#0D0E2B\" fill-opacity=\"0.7\"/>\r\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M25.5708 37.729C24.6393 37.729 23.8833 36.973 23.8833 36.0415V22.4492C23.8833 21.5177 24.6393 20.7617 25.5708 20.7617C26.5023 20.7617 27.2583 21.5177 27.2583 22.4492V36.0415C27.2583 36.973 26.5023 37.729 25.5708 37.729Z\" fill=\"#0D0E2B\" fill-opacity=\"0.7\"/>\r\n <path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M25.5678 37.7279C25.1201 37.7279 24.6881 37.5501 24.3731 37.2306L19.0968 31.9341C18.4398 31.2726 18.4421 30.2039 19.1013 29.5469C19.7628 28.8899 20.8316 28.8899 21.4886 29.5514L25.5678 33.6509L29.6471 29.5514C30.3041 28.8899 31.3728 28.8899 32.0343 29.5469C32.6936 30.2039 32.6958 31.2726 32.0388 31.9341L26.7626 37.2306C26.4476 37.5501 26.0156 37.7279 25.5678 37.7279Z\" fill=\"#0D0E2B\" fill-opacity=\"0.7\"/>\r\n </svg>\r\n \r\n );\r\n};\r\n"],"names":["isFile","item","extractName","url","parts","DefaultFileIcon","jsxs","jsx"],"mappings":";AAEO,SAASA,EAAOC,GAAuC;AAC5D,SAAOA,aAAgB;AACzB;AAEO,SAASC,EAAYC,GAAa;AACvC,MAAI;AACF,UAAMC,IAAQD,EAAI,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG;AACvD,WAAOC,EAAMA,EAAM,SAAS,CAAC,KAAKD;AAAA,EACpC,QAAQ;AACN,WAAOA;AAAA,EACT;AACF;AAEO,MAAME,IAAkB,MAE3B,gBAAAC,EAAC,OAAA,EAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,OAAM,8BAClE,UAAA;AAAA,EAAA,gBAAAC,EAAC,QAAA,EAAK,IAAG,qBAAoB,WAAU,kBAAiB,GAAE,KAAI,GAAE,KAAI,OAAM,MAAK,QAAO,MACtF,UAAA,gBAAAA,EAAC,QAAA,EAAK,aAAU,WAAU,aAAU,WAAU,GAAE,8CAA6C,MAAK,QAAA,CAAO,EAAA,CACzG;AAAA,oBACC,KAAA,EAAE,MAAK,2BACR,UAAA,gBAAAA,EAAC,UAAK,aAAU,WAAU,aAAU,WAAU,GAAE,4hBAA2hB,MAAK,WAAU,gBAAa,OAAK,GAC5mB;AAAA,EACA,gBAAAA,EAAC,QAAA,EAAK,aAAU,WAAU,aAAU,WAAU,GAAE,gVAA+U,MAAK,WAAU,gBAAa,MAAA,CAAK;AAAA,EACha,gBAAAA,EAAC,QAAA,EAAK,aAAU,WAAU,aAAU,WAAU,GAAE,+NAA8N,MAAK,WAAU,gBAAa,MAAA,CAAK;AAAA,EAC/S,gBAAAA,EAAC,QAAA,EAAK,aAAU,WAAU,aAAU,WAAU,GAAE,qXAAoX,MAAK,WAAU,gBAAa,MAAA,CAAK;AAAA,GACrc;"}
|
package/Dropzone/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Dropzone as
|
|
2
|
-
import { DEFAULT_FILE_TYPES as
|
|
1
|
+
import { Dropzone as _ } from "./Dropzone.js";
|
|
2
|
+
import { DEFAULT_DOCUMENT_TYPES as o, DEFAULT_FILE_TYPES as r, DEFAULT_IMAGES_TYPES as A, DEFAULT_VIDEO_TYPES as F } from "./Dropzone.types.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
o as DEFAULT_DOCUMENT_TYPES,
|
|
5
|
+
r as DEFAULT_FILE_TYPES,
|
|
6
|
+
A as DEFAULT_IMAGES_TYPES,
|
|
7
|
+
F as DEFAULT_VIDEO_TYPES,
|
|
8
|
+
_ as Dropzone
|
|
7
9
|
};
|
|
8
10
|
//# sourceMappingURL=index.js.map
|
package/Form/Form.js
CHANGED
|
@@ -4,10 +4,9 @@ import { Slot as f } from "@radix-ui/react-slot";
|
|
|
4
4
|
import { Controller as u, useFormContext as F, useFormState as x, FormProvider as I } from "react-hook-form";
|
|
5
5
|
import { cn as a } from "@oneplatformdev/utils";
|
|
6
6
|
import { Label as p } from "../Label/Label.js";
|
|
7
|
-
|
|
8
|
-
const $ = I, c = s.createContext(
|
|
7
|
+
const S = I, c = s.createContext(
|
|
9
8
|
{}
|
|
10
|
-
),
|
|
9
|
+
), $ = ({
|
|
11
10
|
...e
|
|
12
11
|
}) => /* @__PURE__ */ m(c.Provider, { value: { name: e.name }, children: /* @__PURE__ */ m(u, { ...e }) }), d = () => {
|
|
13
12
|
const e = s.useContext(c), t = s.useContext(l), { getFieldState: r } = F(), o = x({ name: e.name }), n = r(e.name, o);
|
|
@@ -25,7 +24,7 @@ const $ = I, c = s.createContext(
|
|
|
25
24
|
}, l = s.createContext(
|
|
26
25
|
{}
|
|
27
26
|
);
|
|
28
|
-
function
|
|
27
|
+
function D({ className: e, ...t }) {
|
|
29
28
|
const r = s.useId();
|
|
30
29
|
return /* @__PURE__ */ m(l.Provider, { value: { id: r }, children: /* @__PURE__ */ m(
|
|
31
30
|
"div",
|
|
@@ -36,7 +35,7 @@ function M({ className: e, ...t }) {
|
|
|
36
35
|
}
|
|
37
36
|
) });
|
|
38
37
|
}
|
|
39
|
-
function
|
|
38
|
+
function M({
|
|
40
39
|
className: e,
|
|
41
40
|
...t
|
|
42
41
|
}) {
|
|
@@ -52,7 +51,7 @@ function N({
|
|
|
52
51
|
}
|
|
53
52
|
);
|
|
54
53
|
}
|
|
55
|
-
function
|
|
54
|
+
function N({ ...e }) {
|
|
56
55
|
const { error: t, formItemId: r, formDescriptionId: o, formMessageId: n } = d();
|
|
57
56
|
return /* @__PURE__ */ m(
|
|
58
57
|
f,
|
|
@@ -65,7 +64,7 @@ function w({ ...e }) {
|
|
|
65
64
|
}
|
|
66
65
|
);
|
|
67
66
|
}
|
|
68
|
-
function
|
|
67
|
+
function w({ className: e, ...t }) {
|
|
69
68
|
const { formDescriptionId: r } = d();
|
|
70
69
|
return /* @__PURE__ */ m(
|
|
71
70
|
"p",
|
|
@@ -77,7 +76,7 @@ function P({ className: e, ...t }) {
|
|
|
77
76
|
}
|
|
78
77
|
);
|
|
79
78
|
}
|
|
80
|
-
function
|
|
79
|
+
function P({ className: e, ...t }) {
|
|
81
80
|
const { error: r, formMessageId: o } = d(), n = r ? String(r?.message ?? "") : t.children;
|
|
82
81
|
return n ? /* @__PURE__ */ m(
|
|
83
82
|
"p",
|
|
@@ -91,13 +90,13 @@ function y({ className: e, ...t }) {
|
|
|
91
90
|
) : null;
|
|
92
91
|
}
|
|
93
92
|
export {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
S as Form,
|
|
94
|
+
N as FormControl,
|
|
95
|
+
w as FormDescription,
|
|
96
|
+
$ as FormField,
|
|
97
|
+
D as FormItem,
|
|
98
|
+
M as FormLabel,
|
|
99
|
+
P as FormMessage,
|
|
101
100
|
d as useFormField
|
|
102
101
|
};
|
|
103
102
|
//# sourceMappingURL=Form.js.map
|
package/Form/Form.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sources":["../../src/Form/Form.tsx"],"sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport * as LabelPrimitive from \"@radix-ui/react-label\"\nimport { Slot } from \"@radix-ui/react-slot\"\nimport {\n Controller,\n FormProvider,\n useFormContext,\n useFormState,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n} from \"react-hook-form\"\n\nimport { cn } from \"@oneplatformdev/utils\"\nimport { Label } from \"../Label\"\n\nconst Form = FormProvider\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue\n)\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n }: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n )\n}\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext)\n const itemContext = React.useContext(FormItemContext)\n const { getFieldState } = useFormContext()\n const formState = useFormState({ name: fieldContext.name })\n const fieldState = getFieldState(fieldContext.name, formState)\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\")\n }\n\n const { id } = itemContext\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n }\n}\n\ntype FormItemContextValue = {\n id: string\n}\n\nconst FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue\n)\n\nfunction FormItem({ className, ...props }: React.ComponentProps<\"div\">) {\n const id = React.useId()\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div\n data-slot=\"form-item\"\n className={cn(\"flex flex-col gap-2\", className)}\n {...props}\n />\n </FormItemContext.Provider>\n )\n}\n\nfunction FormLabel({\n className,\n ...props\n }: React.ComponentProps<typeof LabelPrimitive.Root>) {\n const { error, formItemId } = useFormField()\n\n return (\n <Label\n data-slot=\"form-label\"\n data-error={!!error}\n className={cn(\"data-[error=true]:text-destructive\", className)}\n htmlFor={formItemId}\n {...props}\n />\n )\n}\n\nfunction FormControl({ ...props }: React.ComponentProps<typeof Slot>) {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField()\n\n return (\n <Slot\n data-slot=\"form-control\"\n id={formItemId}\n aria-describedby={\n !error\n ? `${formDescriptionId}`\n : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n {...props}\n />\n )\n}\n\nfunction FormDescription({ className, ...props }: React.ComponentProps<\"p\">) {\n const { formDescriptionId } = useFormField()\n\n return (\n <p\n data-slot=\"form-description\"\n id={formDescriptionId}\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...props}\n />\n )\n}\n\nfunction FormMessage({ className, ...props }: React.ComponentProps<\"p\">) {\n const { error, formMessageId } = useFormField()\n const body = error ? String(error?.message ?? \"\") : props.children\n\n if (!body) {\n return null\n }\n\n return (\n <p\n data-slot=\"form-message\"\n id={formMessageId}\n className={cn(\"text-destructive text-sm\", className)}\n {...props}\n >\n {body}\n </p>\n )\n}\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\n}\n"],"names":["Form","FormProvider","FormFieldContext","React","FormField","props","jsx","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","useFormContext","formState","useFormState","fieldState","id","FormItem","className","cn","FormLabel","error","formItemId","Label","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","body"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Form.js","sources":["../../src/Form/Form.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\nimport * as LabelPrimitive from \"@radix-ui/react-label\"\r\nimport { Slot } from \"@radix-ui/react-slot\"\r\nimport {\r\n Controller,\r\n FormProvider,\r\n useFormContext,\r\n useFormState,\r\n type ControllerProps,\r\n type FieldPath,\r\n type FieldValues,\r\n} from \"react-hook-form\"\r\n\r\nimport { cn } from \"@oneplatformdev/utils\"\r\nimport { Label } from \"../Label\"\r\n\r\nconst Form = FormProvider\r\n\r\ntype FormFieldContextValue<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\r\n> = {\r\n name: TName\r\n}\r\n\r\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\r\n {} as FormFieldContextValue\r\n)\r\n\r\nconst FormField = <\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\r\n>({\r\n ...props\r\n }: ControllerProps<TFieldValues, TName>) => {\r\n return (\r\n <FormFieldContext.Provider value={{ name: props.name }}>\r\n <Controller {...props} />\r\n </FormFieldContext.Provider>\r\n )\r\n}\r\n\r\nconst useFormField = () => {\r\n const fieldContext = React.useContext(FormFieldContext)\r\n const itemContext = React.useContext(FormItemContext)\r\n const { getFieldState } = useFormContext()\r\n const formState = useFormState({ name: fieldContext.name })\r\n const fieldState = getFieldState(fieldContext.name, formState)\r\n\r\n if (!fieldContext) {\r\n throw new Error(\"useFormField should be used within <FormField>\")\r\n }\r\n\r\n const { id } = itemContext\r\n\r\n return {\r\n id,\r\n name: fieldContext.name,\r\n formItemId: `${id}-form-item`,\r\n formDescriptionId: `${id}-form-item-description`,\r\n formMessageId: `${id}-form-item-message`,\r\n ...fieldState,\r\n }\r\n}\r\n\r\ntype FormItemContextValue = {\r\n id: string\r\n}\r\n\r\nconst FormItemContext = React.createContext<FormItemContextValue>(\r\n {} as FormItemContextValue\r\n)\r\n\r\nfunction FormItem({ className, ...props }: React.ComponentProps<\"div\">) {\r\n const id = React.useId()\r\n\r\n return (\r\n <FormItemContext.Provider value={{ id }}>\r\n <div\r\n data-slot=\"form-item\"\r\n className={cn(\"flex flex-col gap-2\", className)}\r\n {...props}\r\n />\r\n </FormItemContext.Provider>\r\n )\r\n}\r\n\r\nfunction FormLabel({\r\n className,\r\n ...props\r\n }: React.ComponentProps<typeof LabelPrimitive.Root>) {\r\n const { error, formItemId } = useFormField()\r\n\r\n return (\r\n <Label\r\n data-slot=\"form-label\"\r\n data-error={!!error}\r\n className={cn(\"data-[error=true]:text-destructive\", className)}\r\n htmlFor={formItemId}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\nfunction FormControl({ ...props }: React.ComponentProps<typeof Slot>) {\r\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField()\r\n\r\n return (\r\n <Slot\r\n data-slot=\"form-control\"\r\n id={formItemId}\r\n aria-describedby={\r\n !error\r\n ? `${formDescriptionId}`\r\n : `${formDescriptionId} ${formMessageId}`\r\n }\r\n aria-invalid={!!error}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\nfunction FormDescription({ className, ...props }: React.ComponentProps<\"p\">) {\r\n const { formDescriptionId } = useFormField()\r\n\r\n return (\r\n <p\r\n data-slot=\"form-description\"\r\n id={formDescriptionId}\r\n className={cn(\"text-muted-foreground text-sm\", className)}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\nfunction FormMessage({ className, ...props }: React.ComponentProps<\"p\">) {\r\n const { error, formMessageId } = useFormField()\r\n const body = error ? String(error?.message ?? \"\") : props.children\r\n\r\n if (!body) {\r\n return null\r\n }\r\n\r\n return (\r\n <p\r\n data-slot=\"form-message\"\r\n id={formMessageId}\r\n className={cn(\"text-destructive text-sm\", className)}\r\n {...props}\r\n >\r\n {body}\r\n </p>\r\n )\r\n}\r\n\r\nexport {\r\n useFormField,\r\n Form,\r\n FormItem,\r\n FormLabel,\r\n FormControl,\r\n FormDescription,\r\n FormMessage,\r\n FormField,\r\n}\r\n"],"names":["Form","FormProvider","FormFieldContext","React","FormField","props","jsx","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","useFormContext","formState","useFormState","fieldState","id","FormItem","className","cn","FormLabel","error","formItemId","Label","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","body"],"mappings":";;;;;;AAkBA,MAAMA,IAAOC,GASPC,IAAmBC,EAAM;AAAA,EAC7B,CAAA;AACF,GAEMC,IAAY,CAGhB;AAAA,EACE,GAAGC;AACL,MAEE,gBAAAC,EAACJ,EAAiB,UAAjB,EAA0B,OAAO,EAAE,MAAMG,EAAM,KAAA,GAC9C,UAAA,gBAAAC,EAACC,GAAA,EAAY,GAAGF,GAAO,GACzB,GAIEG,IAAe,MAAM;AACzB,QAAMC,IAAeN,EAAM,WAAWD,CAAgB,GAChDQ,IAAcP,EAAM,WAAWQ,CAAe,GAC9C,EAAE,eAAAC,EAAA,IAAkBC,EAAA,GACpBC,IAAYC,EAAa,EAAE,MAAMN,EAAa,MAAM,GACpDO,IAAaJ,EAAcH,EAAa,MAAMK,CAAS;AAE7D,MAAI,CAACL;AACH,UAAM,IAAI,MAAM,gDAAgD;AAGlE,QAAM,EAAE,IAAAQ,MAAOP;AAEf,SAAO;AAAA,IACL,IAAAO;AAAA,IACA,MAAMR,EAAa;AAAA,IACnB,YAAY,GAAGQ,CAAE;AAAA,IACjB,mBAAmB,GAAGA,CAAE;AAAA,IACxB,eAAe,GAAGA,CAAE;AAAA,IACpB,GAAGD;AAAA,EAAA;AAEP,GAMML,IAAkBR,EAAM;AAAA,EAC5B,CAAA;AACF;AAEA,SAASe,EAAS,EAAE,WAAAC,GAAW,GAAGd,KAAsC;AACtE,QAAMY,IAAKd,EAAM,MAAA;AAEjB,2BACGQ,EAAgB,UAAhB,EAAyB,OAAO,EAAE,IAAAM,KACjC,UAAA,gBAAAX;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAWc,EAAG,uBAAuBD,CAAS;AAAA,MAC7C,GAAGd;AAAA,IAAA;AAAA,EAAA,GAER;AAEJ;AAEA,SAASgB,EAAU;AAAA,EACE,WAAAF;AAAA,EACA,GAAGd;AACL,GAAqD;AACtE,QAAM,EAAE,OAAAiB,GAAO,YAAAC,EAAA,IAAef,EAAA;AAE9B,SACE,gBAAAF;AAAA,IAACkB;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,cAAY,CAAC,CAACF;AAAA,MACd,WAAWF,EAAG,sCAAsCD,CAAS;AAAA,MAC7D,SAASI;AAAA,MACR,GAAGlB;AAAA,IAAA;AAAA,EAAA;AAGV;AAEA,SAASoB,EAAY,EAAE,GAAGpB,KAA4C;AACpE,QAAM,EAAE,OAAAiB,GAAO,YAAAC,GAAY,mBAAAG,GAAmB,eAAAC,EAAA,IAAkBnB,EAAA;AAEhE,SACE,gBAAAF;AAAA,IAACsB;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,IAAIL;AAAA,MACJ,oBACGD,IAEG,GAAGI,CAAiB,IAAIC,CAAa,KADrC,GAAGD,CAAiB;AAAA,MAG1B,gBAAc,CAAC,CAACJ;AAAA,MACf,GAAGjB;AAAA,IAAA;AAAA,EAAA;AAGV;AAEA,SAASwB,EAAgB,EAAE,WAAAV,GAAW,GAAGd,KAAoC;AAC3E,QAAM,EAAE,mBAAAqB,EAAA,IAAsBlB,EAAA;AAE9B,SACE,gBAAAF;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,IAAIoB;AAAA,MACJ,WAAWN,EAAG,iCAAiCD,CAAS;AAAA,MACvD,GAAGd;AAAA,IAAA;AAAA,EAAA;AAGV;AAEA,SAASyB,EAAY,EAAE,WAAAX,GAAW,GAAGd,KAAoC;AACvE,QAAM,EAAE,OAAAiB,GAAO,eAAAK,EAAA,IAAkBnB,EAAA,GAC3BuB,IAAOT,IAAQ,OAAOA,GAAO,WAAW,EAAE,IAAIjB,EAAM;AAE1D,SAAK0B,IAKH,gBAAAzB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAU;AAAA,MACV,IAAIqB;AAAA,MACJ,WAAWP,EAAG,4BAA4BD,CAAS;AAAA,MAClD,GAAGd;AAAA,MAEH,UAAA0B;AAAA,IAAA;AAAA,EAAA,IAVI;AAaX;"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { jsx as e, jsxs as u } from "react/jsx-runtime";
|
|
2
2
|
import { FormField as h, FormItem as d, FormMessage as f, FormLabel as F } from "./Form.js";
|
|
3
|
-
import "
|
|
3
|
+
import { cloneElement as P } from "react";
|
|
4
4
|
import { cn as l } from "@oneplatformdev/utils";
|
|
5
|
-
import { Tooltip as
|
|
6
|
-
import { cloneElement as b } from "react";
|
|
5
|
+
import { Tooltip as b } from "../Tooltip/Tooltip.js";
|
|
7
6
|
const N = (n) => {
|
|
8
7
|
const { label: t, tooltip: s, tooltipProps: r } = n, o = /* @__PURE__ */ e(F, { children: t });
|
|
9
8
|
return t ? s ? /* @__PURE__ */ e(
|
|
10
|
-
|
|
9
|
+
b,
|
|
11
10
|
{
|
|
12
11
|
message: s,
|
|
13
12
|
showQuestionMark: !0,
|
|
@@ -21,10 +20,10 @@ const N = (n) => {
|
|
|
21
20
|
...r?.triggerProps,
|
|
22
21
|
className: l("cursor-help", r?.triggerProps?.className)
|
|
23
22
|
},
|
|
24
|
-
children:
|
|
23
|
+
children: P(o, { className: l("cursor-help", o.props.classNames) })
|
|
25
24
|
}
|
|
26
25
|
) : o : null;
|
|
27
|
-
},
|
|
26
|
+
}, I = (n) => {
|
|
28
27
|
const {
|
|
29
28
|
form: t,
|
|
30
29
|
name: s,
|
|
@@ -58,6 +57,6 @@ const N = (n) => {
|
|
|
58
57
|
);
|
|
59
58
|
};
|
|
60
59
|
export {
|
|
61
|
-
|
|
60
|
+
I as FormRenderControl
|
|
62
61
|
};
|
|
63
62
|
//# sourceMappingURL=FormRenderControl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormRenderControl.js","sources":["../../src/Form/FormRenderControl.tsx"],"sourcesContent":["import { FieldValues } from \"react-hook-form\";\n\nimport { FormField, FormItem, FormLabel, FormMessage } from \"./Form\";\nimport { FormRenderControlProps } from \"./FormRenderControl.types\";\nimport { Tooltip } from \"../Tooltip\";\nimport { cloneElement } from \"react\";\nimport { cn } from \"@oneplatformdev/utils\";\n\ninterface IFormLabelWithTooltipProps<\n Data extends FieldValues = FieldValues,\n> extends Pick<FormRenderControlProps<Data>, 'label' | 'tooltip' | 'tooltipProps'> {\n}\n\nconst FormLabelWithTooltip = <\n Data extends FieldValues = FieldValues,\n>(props: IFormLabelWithTooltipProps<Data>) => {\n const { label, tooltip, tooltipProps } = props;\n const cmp = <FormLabel>{label}</FormLabel>;\n if (!label) return null;\n if (!tooltip) return cmp;\n return (\n <Tooltip\n message={tooltip}\n showQuestionMark\n questionIconSize=\"sm\"\n contentProps={{\n side: \"right\",\n align: \"center\"\n }}\n {...tooltipProps}\n triggerProps={{\n ...tooltipProps?.triggerProps,\n className: cn('cursor-help', tooltipProps?.triggerProps?.className),\n }}\n >\n {cloneElement(cmp, { className: cn('cursor-help', cmp.props.classNames) })}\n </Tooltip>\n )\n}\n\nexport const FormRenderControl = <\n Data extends FieldValues = FieldValues,\n>(\n props: FormRenderControlProps<Data>\n) => {\n const {\n form,\n name,\n label,\n tooltip,\n tooltipProps,\n render,\n containerProps = {},\n showErrorMessages = true,\n ...rest\n } = props;\n return (\n <FormField\n control={form.control}\n name={name}\n render={(params) => (\n <FormItem {...containerProps}>\n <FormLabelWithTooltip\n label={label}\n tooltip={tooltip}\n tooltipProps={tooltipProps}\n />\n {/*{(label || tooltip) && (*/}\n {/* <FormLabel className={cn(\"flex items-center gap-1\")}>*/}\n {/* {label && <span>{label}</span>}*/}\n {/* {tooltip && (*/}\n {/* <Tooltip*/}\n {/* message={tooltip}*/}\n {/* showQuestionMark*/}\n {/* questionIconSize=\"xs\"*/}\n {/* contentProps={{*/}\n {/* side: \"right\",*/}\n {/* align: \"center\"*/}\n {/* }}*/}\n {/* {...props.tooltipProps}*/}\n {/* />*/}\n {/* )}*/}\n {/* </FormLabel>*/}\n {/*)}*/}\n {render(params)}\n {showErrorMessages && <FormMessage/>}\n </FormItem>\n )}\n {...rest}\n />\n );\n};\n"],"names":["FormLabelWithTooltip","props","label","tooltip","tooltipProps","cmp","jsx","FormLabel","Tooltip","cn","cloneElement","FormRenderControl","form","name","render","containerProps","showErrorMessages","rest","FormField","params","jsxs","FormItem","FormMessage"],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormRenderControl.js","sources":["../../src/Form/FormRenderControl.tsx"],"sourcesContent":["import { FieldValues } from \"react-hook-form\";\r\n\r\nimport { FormField, FormItem, FormLabel, FormMessage } from \"./Form\";\r\nimport { FormRenderControlProps } from \"./FormRenderControl.types\";\r\nimport { Tooltip } from \"../Tooltip\";\r\nimport { cloneElement } from \"react\";\r\nimport { cn } from \"@oneplatformdev/utils\";\r\n\r\ninterface IFormLabelWithTooltipProps<\r\n Data extends FieldValues = FieldValues,\r\n> extends Pick<FormRenderControlProps<Data>, 'label' | 'tooltip' | 'tooltipProps'> {\r\n}\r\n\r\nconst FormLabelWithTooltip = <\r\n Data extends FieldValues = FieldValues,\r\n>(props: IFormLabelWithTooltipProps<Data>) => {\r\n const { label, tooltip, tooltipProps } = props;\r\n const cmp = <FormLabel>{label}</FormLabel>;\r\n if (!label) return null;\r\n if (!tooltip) return cmp;\r\n return (\r\n <Tooltip\r\n message={tooltip}\r\n showQuestionMark\r\n questionIconSize=\"sm\"\r\n contentProps={{\r\n side: \"right\",\r\n align: \"center\"\r\n }}\r\n {...tooltipProps}\r\n triggerProps={{\r\n ...tooltipProps?.triggerProps,\r\n className: cn('cursor-help', tooltipProps?.triggerProps?.className),\r\n }}\r\n >\r\n {cloneElement(cmp, { className: cn('cursor-help', cmp.props.classNames) })}\r\n </Tooltip>\r\n )\r\n}\r\n\r\nexport const FormRenderControl = <\r\n Data extends FieldValues = FieldValues,\r\n>(\r\n props: FormRenderControlProps<Data>\r\n) => {\r\n const {\r\n form,\r\n name,\r\n label,\r\n tooltip,\r\n tooltipProps,\r\n render,\r\n containerProps = {},\r\n showErrorMessages = true,\r\n ...rest\r\n } = props;\r\n return (\r\n <FormField\r\n control={form.control}\r\n name={name}\r\n render={(params) => (\r\n <FormItem {...containerProps}>\r\n <FormLabelWithTooltip\r\n label={label}\r\n tooltip={tooltip}\r\n tooltipProps={tooltipProps}\r\n />\r\n {/*{(label || tooltip) && (*/}\r\n {/* <FormLabel className={cn(\"flex items-center gap-1\")}>*/}\r\n {/* {label && <span>{label}</span>}*/}\r\n {/* {tooltip && (*/}\r\n {/* <Tooltip*/}\r\n {/* message={tooltip}*/}\r\n {/* showQuestionMark*/}\r\n {/* questionIconSize=\"xs\"*/}\r\n {/* contentProps={{*/}\r\n {/* side: \"right\",*/}\r\n {/* align: \"center\"*/}\r\n {/* }}*/}\r\n {/* {...props.tooltipProps}*/}\r\n {/* />*/}\r\n {/* )}*/}\r\n {/* </FormLabel>*/}\r\n {/*)}*/}\r\n {render(params)}\r\n {showErrorMessages && <FormMessage/>}\r\n </FormItem>\r\n )}\r\n {...rest}\r\n />\r\n );\r\n};\r\n"],"names":["FormLabelWithTooltip","props","label","tooltip","tooltipProps","cmp","jsx","FormLabel","Tooltip","cn","cloneElement","FormRenderControl","form","name","render","containerProps","showErrorMessages","rest","FormField","params","jsxs","FormItem","FormMessage"],"mappings":";;;;;AAaA,MAAMA,IAAuB,CAE3BC,MAA4C;AAC5C,QAAM,EAAE,OAAAC,GAAO,SAAAC,GAAS,cAAAC,EAAA,IAAiBH,GACnCI,IAAM,gBAAAC,EAACC,GAAA,EAAW,UAAAL,EAAA,CAAM;AAC9B,SAAKA,IACAC,IAEH,gBAAAG;AAAA,IAACE;AAAA,IAAA;AAAA,MACC,SAASL;AAAA,MACT,kBAAgB;AAAA,MAChB,kBAAiB;AAAA,MACjB,cAAc;AAAA,QACZ,MAAM;AAAA,QACN,OAAO;AAAA,MAAA;AAAA,MAER,GAAGC;AAAA,MACJ,cAAc;AAAA,QACZ,GAAGA,GAAc;AAAA,QACjB,WAAWK,EAAG,eAAeL,GAAc,cAAc,SAAS;AAAA,MAAA;AAAA,MAGnE,UAAAM,EAAaL,GAAK,EAAE,WAAWI,EAAG,eAAeJ,EAAI,MAAM,UAAU,EAAA,CAAG;AAAA,IAAA;AAAA,EAAA,IAhBxDA,IADF;AAoBrB,GAEaM,IAAoB,CAG/BV,MACG;AACH,QAAM;AAAA,IACJ,MAAAW;AAAA,IACA,MAAAC;AAAA,IACA,OAAAX;AAAA,IACA,SAAAC;AAAA,IACA,cAAAC;AAAA,IACA,QAAAU;AAAA,IACA,gBAAAC,IAAiB,CAAA;AAAA,IACjB,mBAAAC,IAAoB;AAAA,IACpB,GAAGC;AAAA,EAAA,IACDhB;AACJ,SACE,gBAAAK;AAAA,IAACY;AAAA,IAAA;AAAA,MACC,SAASN,EAAK;AAAA,MACd,MAAAC;AAAA,MACA,QAAQ,CAACM,MACP,gBAAAC,EAACC,GAAA,EAAU,GAAGN,GACZ,UAAA;AAAA,QAAA,gBAAAT;AAAA,UAACN;AAAA,UAAA;AAAA,YACC,OAAAE;AAAA,YACA,SAAAC;AAAA,YACA,cAAAC;AAAA,UAAA;AAAA,QAAA;AAAA,QAmBDU,EAAOK,CAAM;AAAA,QACbH,uBAAsBM,GAAA,CAAA,CAAW;AAAA,MAAA,GACpC;AAAA,MAED,GAAGL;AAAA,IAAA;AAAA,EAAA;AAGV;"}
|
package/Form/Form_old.js
CHANGED
|
@@ -4,10 +4,9 @@ import { Slot as F } from "@radix-ui/react-slot";
|
|
|
4
4
|
import { useFormContext as u, FormProvider as p, Controller as x } from "react-hook-form";
|
|
5
5
|
import { cn as a } from "@oneplatformdev/utils";
|
|
6
6
|
import { Label as I } from "../Label/Label.js";
|
|
7
|
-
|
|
8
|
-
const M = p, l = m.createContext(
|
|
7
|
+
const D = p, l = m.createContext(
|
|
9
8
|
{}
|
|
10
|
-
),
|
|
9
|
+
), M = ({
|
|
11
10
|
...e
|
|
12
11
|
}) => /* @__PURE__ */ n(l.Provider, { value: { name: e.name }, children: /* @__PURE__ */ n(x, { ...e }) }), c = () => {
|
|
13
12
|
const e = m.useContext(l), t = m.useContext(f), { getFieldState: o, formState: r } = u(), i = o(e.name, r);
|
|
@@ -87,10 +86,10 @@ const w = m.forwardRef(({ className: e, children: t, ...o }, r) => {
|
|
|
87
86
|
});
|
|
88
87
|
w.displayName = "FormMessage";
|
|
89
88
|
export {
|
|
90
|
-
|
|
89
|
+
D as Form,
|
|
91
90
|
g as FormControl,
|
|
92
91
|
N as FormDescription,
|
|
93
|
-
|
|
92
|
+
M as FormField,
|
|
94
93
|
v as FormItem,
|
|
95
94
|
C as FormLabel,
|
|
96
95
|
w as FormMessage,
|
package/Form/Form_old.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form_old.js","sources":["../../src/Form/Form_old.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport * as LabelPrimitive from '@radix-ui/react-label';\nimport { Slot } from '@radix-ui/react-slot';\nimport {\n Controller,\n ControllerProps,\n FieldPath,\n FieldValues,\n FormProvider,\n useFormContext,\n} from 'react-hook-form';\n\nimport { cn } from '@oneplatformdev/utils';\nimport { Label } from '../Label';\n\nconst Form = FormProvider;\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> = {\n name: TName\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue\n)\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n )\n}\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext)\n const itemContext = React.useContext(FormItemContext)\n const { getFieldState, formState } = useFormContext()\n\n const fieldState = getFieldState(fieldContext.name, formState)\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\")\n }\n\n const { id } = itemContext\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n }\n}\n\ntype FormItemContextValue = {\n id: string\n}\n\nconst FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue\n)\n\nconst FormItem = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => {\n const id = React.useId()\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={cn(\"space-y-1\", className)} {...props} />\n </FormItemContext.Provider>\n )\n})\nFormItem.displayName = \"FormItem\"\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField()\n\n return (\n <Label\n ref={ref}\n data-state={error ? \"invalid\" : \"valid\"}\n className={cn(error && \"text-destructive\", className)}\n htmlFor={formItemId}\n {...props}\n />\n )\n})\nFormLabel.displayName = \"FormLabel\"\n\nconst FormControl = React.forwardRef<\n React.ElementRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ className, ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField()\n\n return (\n <Slot\n ref={ref}\n id={formItemId}\n data-state={error ? \"invalid\" : \"valid\"}\n aria-describedby={\n !error\n ? `${formDescriptionId}`\n : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n className={cn('group/form-control', className)}\n {...props}\n />\n )\n})\nFormControl.displayName = \"FormControl\"\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField()\n\n return (\n <p\n ref={ref}\n id={formDescriptionId}\n className={cn(\"text-[0.8rem] text-muted-foreground\", className)}\n {...props}\n />\n )\n})\nFormDescription.displayName = \"FormDescription\"\n\nconst FormMessage = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, children, ...props }, ref) => {\n const { error, formMessageId } = useFormField()\n const body = error ? String(error?.message) : children\n\n if (!body) {\n return null\n }\n\n return (\n <p\n ref={ref}\n id={formMessageId}\n className={cn(\"text-[0.8rem] font-medium text-destructive\", className)}\n {...props}\n >\n {body}\n </p>\n )\n})\nFormMessage.displayName = \"FormMessage\"\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\n}\n"],"names":["Form","FormProvider","FormFieldContext","React","FormField","props","jsx","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","formState","useFormContext","fieldState","id","FormItem","className","ref","cn","FormLabel","error","formItemId","Label","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","children","body"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Form_old.js","sources":["../../src/Form/Form_old.tsx"],"sourcesContent":["'use client';\r\n\r\nimport * as React from 'react';\r\nimport * as LabelPrimitive from '@radix-ui/react-label';\r\nimport { Slot } from '@radix-ui/react-slot';\r\nimport {\r\n Controller,\r\n ControllerProps,\r\n FieldPath,\r\n FieldValues,\r\n FormProvider,\r\n useFormContext,\r\n} from 'react-hook-form';\r\n\r\nimport { cn } from '@oneplatformdev/utils';\r\nimport { Label } from '../Label';\r\n\r\nconst Form = FormProvider;\r\n\r\ntype FormFieldContextValue<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n> = {\r\n name: TName\r\n}\r\n\r\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\r\n {} as FormFieldContextValue\r\n)\r\n\r\nconst FormField = <\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>({\r\n ...props\r\n}: ControllerProps<TFieldValues, TName>) => {\r\n return (\r\n <FormFieldContext.Provider value={{ name: props.name }}>\r\n <Controller {...props} />\r\n </FormFieldContext.Provider>\r\n )\r\n}\r\n\r\nconst useFormField = () => {\r\n const fieldContext = React.useContext(FormFieldContext)\r\n const itemContext = React.useContext(FormItemContext)\r\n const { getFieldState, formState } = useFormContext()\r\n\r\n const fieldState = getFieldState(fieldContext.name, formState)\r\n\r\n if (!fieldContext) {\r\n throw new Error(\"useFormField should be used within <FormField>\")\r\n }\r\n\r\n const { id } = itemContext\r\n\r\n return {\r\n id,\r\n name: fieldContext.name,\r\n formItemId: `${id}-form-item`,\r\n formDescriptionId: `${id}-form-item-description`,\r\n formMessageId: `${id}-form-item-message`,\r\n ...fieldState,\r\n }\r\n}\r\n\r\ntype FormItemContextValue = {\r\n id: string\r\n}\r\n\r\nconst FormItemContext = React.createContext<FormItemContextValue>(\r\n {} as FormItemContextValue\r\n)\r\n\r\nconst FormItem = React.forwardRef<\r\n HTMLDivElement,\r\n React.HTMLAttributes<HTMLDivElement>\r\n>(({ className, ...props }, ref) => {\r\n const id = React.useId()\r\n\r\n return (\r\n <FormItemContext.Provider value={{ id }}>\r\n <div ref={ref} className={cn(\"space-y-1\", className)} {...props} />\r\n </FormItemContext.Provider>\r\n )\r\n})\r\nFormItem.displayName = \"FormItem\"\r\n\r\nconst FormLabel = React.forwardRef<\r\n React.ElementRef<typeof LabelPrimitive.Root>,\r\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>\r\n>(({ className, ...props }, ref) => {\r\n const { error, formItemId } = useFormField()\r\n\r\n return (\r\n <Label\r\n ref={ref}\r\n data-state={error ? \"invalid\" : \"valid\"}\r\n className={cn(error && \"text-destructive\", className)}\r\n htmlFor={formItemId}\r\n {...props}\r\n />\r\n )\r\n})\r\nFormLabel.displayName = \"FormLabel\"\r\n\r\nconst FormControl = React.forwardRef<\r\n React.ElementRef<typeof Slot>,\r\n React.ComponentPropsWithoutRef<typeof Slot>\r\n>(({ className, ...props }, ref) => {\r\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField()\r\n\r\n return (\r\n <Slot\r\n ref={ref}\r\n id={formItemId}\r\n data-state={error ? \"invalid\" : \"valid\"}\r\n aria-describedby={\r\n !error\r\n ? `${formDescriptionId}`\r\n : `${formDescriptionId} ${formMessageId}`\r\n }\r\n aria-invalid={!!error}\r\n className={cn('group/form-control', className)}\r\n {...props}\r\n />\r\n )\r\n})\r\nFormControl.displayName = \"FormControl\"\r\n\r\nconst FormDescription = React.forwardRef<\r\n HTMLParagraphElement,\r\n React.HTMLAttributes<HTMLParagraphElement>\r\n>(({ className, ...props }, ref) => {\r\n const { formDescriptionId } = useFormField()\r\n\r\n return (\r\n <p\r\n ref={ref}\r\n id={formDescriptionId}\r\n className={cn(\"text-[0.8rem] text-muted-foreground\", className)}\r\n {...props}\r\n />\r\n )\r\n})\r\nFormDescription.displayName = \"FormDescription\"\r\n\r\nconst FormMessage = React.forwardRef<\r\n HTMLParagraphElement,\r\n React.HTMLAttributes<HTMLParagraphElement>\r\n>(({ className, children, ...props }, ref) => {\r\n const { error, formMessageId } = useFormField()\r\n const body = error ? String(error?.message) : children\r\n\r\n if (!body) {\r\n return null\r\n }\r\n\r\n return (\r\n <p\r\n ref={ref}\r\n id={formMessageId}\r\n className={cn(\"text-[0.8rem] font-medium text-destructive\", className)}\r\n {...props}\r\n >\r\n {body}\r\n </p>\r\n )\r\n})\r\nFormMessage.displayName = \"FormMessage\"\r\n\r\nexport {\r\n useFormField,\r\n Form,\r\n FormItem,\r\n FormLabel,\r\n FormControl,\r\n FormDescription,\r\n FormMessage,\r\n FormField,\r\n}\r\n"],"names":["Form","FormProvider","FormFieldContext","React","FormField","props","jsx","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","formState","useFormContext","fieldState","id","FormItem","className","ref","cn","FormLabel","error","formItemId","Label","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","children","body"],"mappings":"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"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { FormRenderControl as a } from "../Form/FormRenderControl.js";
|
|
3
|
+
import { FormControl as l } from "../Form/Form.js";
|
|
4
4
|
import { CheckboxLabel as k } from "../Checkbox/Checkbox.js";
|
|
5
5
|
const f = (m) => {
|
|
6
6
|
const { form: t, label: c, name: h, onCheckedChange: C, ...r } = m;
|
|
7
7
|
return /* @__PURE__ */ e(
|
|
8
|
-
|
|
8
|
+
a,
|
|
9
9
|
{
|
|
10
10
|
form: t,
|
|
11
11
|
name: h,
|
|
12
|
-
render: ({ field: o }) => /* @__PURE__ */ e(
|
|
12
|
+
render: ({ field: o }) => /* @__PURE__ */ e(l, { children: /* @__PURE__ */ e(
|
|
13
13
|
k,
|
|
14
14
|
{
|
|
15
15
|
...o,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormCheckbox.js","sources":["../../src/FormCheckbox/FormCheckbox.tsx"],"sourcesContent":["import { FieldValues } from 'react-hook-form';\n\nimport { FormControl, FormRenderControl } from '../Form';\n\nimport { FormCheckboxProps } from './FormCheckbox.types';\nimport { CheckboxLabel } from '../Checkbox';\n\n// TODO: move to @oneplatformdev/ui/FormCheckbox\nexport const FormCheckbox = <Data extends FieldValues>(\n\tprops: FormCheckboxProps<Data>\n) => {\n\tconst { form, label, name, onCheckedChange, ...rest } = props;\n\treturn (\n\t\t<FormRenderControl\n\t\t\tform={form}\n\t\t\tname={name}\n\t\t\trender={({ field }) => (\n\t\t\t\t<FormControl>\n\t\t\t\t\t<CheckboxLabel\n\t\t\t\t\t\t{...field}\n\t\t\t\t\t\t{...rest}\n\t\t\t\t\t\tlabel={label}\n\t\t\t\t\t\tchecked={field.value || false}\n\t\t\t\t\t\tonCheckedChange={(v) => {\n\t\t\t\t\t\t\tfield.onChange(v);\n\t\t\t\t\t\t\tonCheckedChange?.(v);\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</FormControl>\n\t\t\t)}\n\t\t\t{...rest}\n\t\t/>\n\t);\n};\n"],"names":["FormCheckbox","props","form","label","name","onCheckedChange","rest","jsx","FormRenderControl","field","FormControl","CheckboxLabel","v"],"mappings":";;;;AAQO,MAAMA,IAAe,CAC3BC,MACI;AACJ,QAAM,EAAE,MAAAC,GAAM,OAAAC,GAAO,MAAAC,GAAM,iBAAAC,GAAiB,GAAGC,MAASL;AACxD,SACC,gBAAAM;AAAA,IAACC;AAAA,IAAA;AAAA,MACA,MAAAN;AAAA,MACA,MAAAE;AAAA,MACA,QAAQ,CAAC,EAAE,OAAAK,EAAA,wBACTC,GAAA,EACA,UAAA,gBAAAH;AAAA,QAACI;AAAA,QAAA;AAAA,UACC,GAAGF;AAAA,UACH,GAAGH;AAAA,UACJ,OAAAH;AAAA,UACA,SAASM,EAAM,SAAS;AAAA,UACxB,iBAAiB,CAACG,MAAM;AACvB,YAAAH,EAAM,SAASG,CAAC,GAChBP,IAAkBO,CAAC;AAAA,UACpB;AAAA,QAAA;AAAA,MAAA,GAEF;AAAA,MAEA,GAAGN;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
1
|
+
{"version":3,"file":"FormCheckbox.js","sources":["../../src/FormCheckbox/FormCheckbox.tsx"],"sourcesContent":["import { FieldValues } from 'react-hook-form';\r\n\r\nimport { FormControl, FormRenderControl } from '../Form';\r\n\r\nimport { FormCheckboxProps } from './FormCheckbox.types';\r\nimport { CheckboxLabel } from '../Checkbox';\r\n\r\n// TODO: move to @oneplatformdev/ui/FormCheckbox\r\nexport const FormCheckbox = <Data extends FieldValues>(\r\n\tprops: FormCheckboxProps<Data>\r\n) => {\r\n\tconst { form, label, name, onCheckedChange, ...rest } = props;\r\n\treturn (\r\n\t\t<FormRenderControl\r\n\t\t\tform={form}\r\n\t\t\tname={name}\r\n\t\t\trender={({ field }) => (\r\n\t\t\t\t<FormControl>\r\n\t\t\t\t\t<CheckboxLabel\r\n\t\t\t\t\t\t{...field}\r\n\t\t\t\t\t\t{...rest}\r\n\t\t\t\t\t\tlabel={label}\r\n\t\t\t\t\t\tchecked={field.value || false}\r\n\t\t\t\t\t\tonCheckedChange={(v) => {\r\n\t\t\t\t\t\t\tfield.onChange(v);\r\n\t\t\t\t\t\t\tonCheckedChange?.(v);\r\n\t\t\t\t\t\t}}\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FormControl>\r\n\t\t\t)}\r\n\t\t\t{...rest}\r\n\t\t/>\r\n\t);\r\n};\r\n"],"names":["FormCheckbox","props","form","label","name","onCheckedChange","rest","jsx","FormRenderControl","field","FormControl","CheckboxLabel","v"],"mappings":";;;;AAQO,MAAMA,IAAe,CAC3BC,MACI;AACJ,QAAM,EAAE,MAAAC,GAAM,OAAAC,GAAO,MAAAC,GAAM,iBAAAC,GAAiB,GAAGC,MAASL;AACxD,SACC,gBAAAM;AAAA,IAACC;AAAA,IAAA;AAAA,MACA,MAAAN;AAAA,MACA,MAAAE;AAAA,MACA,QAAQ,CAAC,EAAE,OAAAK,EAAA,wBACTC,GAAA,EACA,UAAA,gBAAAH;AAAA,QAACI;AAAA,QAAA;AAAA,UACC,GAAGF;AAAA,UACH,GAAGH;AAAA,UACJ,OAAAH;AAAA,UACA,SAASM,EAAM,SAAS;AAAA,UACxB,iBAAiB,CAACG,MAAM;AACvB,YAAAH,EAAM,SAASG,CAAC,GAChBP,IAAkBO,CAAC;AAAA,UACpB;AAAA,QAAA;AAAA,MAAA,GAEF;AAAA,MAEA,GAAGN;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { FormControl as s } from "../Form/Form.js";
|
|
3
|
-
import { FormRenderControl as b } from "../Form/FormRenderControl.js";
|
|
4
2
|
import { Combobox as m } from "../Combobox/Combobox.js";
|
|
3
|
+
import { FormRenderControl as s } from "../Form/FormRenderControl.js";
|
|
4
|
+
import { FormControl as b } from "../Form/Form.js";
|
|
5
5
|
function x(t) {
|
|
6
6
|
const { form: i, label: p, tooltip: l, tooltipProps: C, name: a, imperativeRef: n, ...e } = t, g = t.type ?? "single";
|
|
7
7
|
return /* @__PURE__ */ r(
|
|
8
|
-
|
|
8
|
+
s,
|
|
9
9
|
{
|
|
10
10
|
form: i,
|
|
11
11
|
label: p,
|
|
12
12
|
tooltip: l,
|
|
13
13
|
tooltipProps: C,
|
|
14
14
|
name: a,
|
|
15
|
-
render: ({ field: o }) => /* @__PURE__ */ r(
|
|
15
|
+
render: ({ field: o }) => /* @__PURE__ */ r(b, { children: g === "multi" ? /* @__PURE__ */ r(
|
|
16
16
|
m,
|
|
17
17
|
{
|
|
18
18
|
...e,
|