@inspirecn/react 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/dist/components/accordion/Accordion.d.ts +19 -0
- package/dist/components/accordion/Accordion.d.ts.map +1 -0
- package/dist/components/accordion/Accordion.js +90 -0
- package/dist/components/alert/Alert.d.ts +13 -0
- package/dist/components/alert/Alert.d.ts.map +1 -0
- package/dist/components/alert/Alert.js +100 -0
- package/dist/components/alert-dialog/AlertDialog.d.ts +44 -0
- package/dist/components/alert-dialog/AlertDialog.d.ts.map +1 -0
- package/dist/components/alert-dialog/AlertDialog.js +174 -0
- package/dist/components/aspect-ratio/AspectRatio.d.ts +4 -0
- package/dist/components/aspect-ratio/AspectRatio.d.ts.map +1 -0
- package/dist/components/aspect-ratio/AspectRatio.js +13 -0
- package/dist/components/avatar/Avatar.d.ts +19 -0
- package/dist/components/avatar/Avatar.d.ts.map +1 -0
- package/dist/components/avatar/Avatar.js +86 -0
- package/dist/components/badge/Badge.d.ts +16 -0
- package/dist/components/badge/Badge.d.ts.map +1 -0
- package/dist/components/badge/Badge.js +46 -0
- package/dist/components/body-text/BodyText.d.ts +17 -0
- package/dist/components/body-text/BodyText.d.ts.map +1 -0
- package/dist/components/body-text/BodyText.js +51 -0
- package/dist/components/breadcrumb/Breadcrumb.d.ts +30 -0
- package/dist/components/breadcrumb/Breadcrumb.d.ts.map +1 -0
- package/dist/components/breadcrumb/Breadcrumb.js +220 -0
- package/dist/components/button/Button.d.ts +24 -0
- package/dist/components/button/Button.d.ts.map +1 -0
- package/dist/components/button/Button.js +95 -0
- package/dist/components/button-group/ButtonGroup.d.ts +12 -0
- package/dist/components/button-group/ButtonGroup.d.ts.map +1 -0
- package/dist/components/button-group/ButtonGroup.js +59 -0
- package/dist/components/calendar/Calendar.d.ts +10 -0
- package/dist/components/calendar/Calendar.d.ts.map +1 -0
- package/dist/components/calendar/Calendar.js +147 -0
- package/dist/components/card/Card.d.ts +10 -0
- package/dist/components/card/Card.d.ts.map +1 -0
- package/dist/components/card/Card.js +81 -0
- package/dist/components/carousel/Carousel.d.ts +20 -0
- package/dist/components/carousel/Carousel.d.ts.map +1 -0
- package/dist/components/carousel/Carousel.js +153 -0
- package/dist/components/chart/Chart.d.ts +43 -0
- package/dist/components/chart/Chart.d.ts.map +1 -0
- package/dist/components/chart/Chart.js +175 -0
- package/dist/components/checkbox/Checkbox.d.ts +11 -0
- package/dist/components/checkbox/Checkbox.d.ts.map +1 -0
- package/dist/components/checkbox/Checkbox.js +43 -0
- package/dist/components/code-box/Codebox.d.ts +11 -0
- package/dist/components/code-box/Codebox.d.ts.map +1 -0
- package/dist/components/code-box/Codebox.js +251 -0
- package/dist/components/collapsible/Collapsible.d.ts +6 -0
- package/dist/components/collapsible/Collapsible.d.ts.map +1 -0
- package/dist/components/collapsible/Collapsible.js +31 -0
- package/dist/components/combobox/Combobox.d.ts +161 -0
- package/dist/components/combobox/Combobox.d.ts.map +1 -0
- package/dist/components/combobox/Combobox.js +330 -0
- package/dist/components/command/Command.d.ts +19 -0
- package/dist/components/command/Command.d.ts.map +1 -0
- package/dist/components/command/Command.js +128 -0
- package/dist/components/container/Container.d.ts +14 -0
- package/dist/components/container/Container.d.ts.map +1 -0
- package/dist/components/container/Container.js +27 -0
- package/dist/components/context-menu/ContextMenu.d.ts +26 -0
- package/dist/components/context-menu/ContextMenu.d.ts.map +1 -0
- package/dist/components/context-menu/ContextMenu.js +193 -0
- package/dist/components/count-animation/CountAnimation.d.ts +5 -0
- package/dist/components/count-animation/CountAnimation.d.ts.map +1 -0
- package/dist/components/count-animation/CountAnimation.js +19 -0
- package/dist/components/date-time-picker/DateTimePicker.d.ts +38 -0
- package/dist/components/date-time-picker/DateTimePicker.d.ts.map +1 -0
- package/dist/components/date-time-picker/DateTimePicker.js +287 -0
- package/dist/components/dialog/Dialog.d.ts +18 -0
- package/dist/components/dialog/Dialog.d.ts.map +1 -0
- package/dist/components/dialog/Dialog.js +138 -0
- package/dist/components/dialog/FilterDropdown.d.ts +7 -0
- package/dist/components/dialog/FilterDropdown.d.ts.map +1 -0
- package/dist/components/dialog/FilterDropdown.js +38 -0
- package/dist/components/display-error/DisplayError.d.ts +11 -0
- package/dist/components/display-error/DisplayError.d.ts.map +1 -0
- package/dist/components/display-error/DisplayError.js +34 -0
- package/dist/components/drawer/Drawer.d.ts +14 -0
- package/dist/components/drawer/Drawer.d.ts.map +1 -0
- package/dist/components/drawer/Drawer.js +114 -0
- package/dist/components/dropdown-menu/DropdownMenu.d.ts +41 -0
- package/dist/components/dropdown-menu/DropdownMenu.d.ts.map +1 -0
- package/dist/components/dropdown-menu/DropdownMenu.js +282 -0
- package/dist/components/empty/Empty.d.ts +12 -0
- package/dist/components/empty/Empty.d.ts.map +1 -0
- package/dist/components/empty/Empty.js +87 -0
- package/dist/components/empty-state/EmptyState.d.ts +12 -0
- package/dist/components/empty-state/EmptyState.d.ts.map +1 -0
- package/dist/components/empty-state/EmptyState.js +43 -0
- package/dist/components/field/Field.d.ts +25 -0
- package/dist/components/field/Field.d.ts.map +1 -0
- package/dist/components/field/Field.js +164 -0
- package/dist/components/file-uploader/FileUploader.d.ts +34 -0
- package/dist/components/file-uploader/FileUploader.d.ts.map +1 -0
- package/dist/components/file-uploader/FileUploader.js +124 -0
- package/dist/components/file-uploader/types.d.ts +32 -0
- package/dist/components/file-uploader/types.d.ts.map +1 -0
- package/dist/components/file-uploader/types.js +1 -0
- package/dist/components/file-uploader/useFileUploader.d.ts +22 -0
- package/dist/components/file-uploader/useFileUploader.d.ts.map +1 -0
- package/dist/components/file-uploader/useFileUploader.js +115 -0
- package/dist/components/form/FieldArray.d.ts +26 -0
- package/dist/components/form/FieldArray.d.ts.map +1 -0
- package/dist/components/form/FieldArray.js +16 -0
- package/dist/components/form/Form.d.ts +25 -0
- package/dist/components/form/Form.d.ts.map +1 -0
- package/dist/components/form/Form.js +124 -0
- package/dist/components/form/GenericForm.d.ts +42 -0
- package/dist/components/form/GenericForm.d.ts.map +1 -0
- package/dist/components/form/GenericForm.js +55 -0
- package/dist/components/form/fields/CheckboxField.d.ts +33 -0
- package/dist/components/form/fields/CheckboxField.d.ts.map +1 -0
- package/dist/components/form/fields/CheckboxField.js +66 -0
- package/dist/components/form/fields/CheckboxGroupField.d.ts +50 -0
- package/dist/components/form/fields/CheckboxGroupField.d.ts.map +1 -0
- package/dist/components/form/fields/CheckboxGroupField.js +64 -0
- package/dist/components/form/fields/ColorPickerField.d.ts +12 -0
- package/dist/components/form/fields/ColorPickerField.d.ts.map +1 -0
- package/dist/components/form/fields/ColorPickerField.js +140 -0
- package/dist/components/form/fields/ComboboxField.d.ts +32 -0
- package/dist/components/form/fields/ComboboxField.d.ts.map +1 -0
- package/dist/components/form/fields/ComboboxField.js +93 -0
- package/dist/components/form/fields/DateTimeField.d.ts +77 -0
- package/dist/components/form/fields/DateTimeField.d.ts.map +1 -0
- package/dist/components/form/fields/DateTimeField.js +99 -0
- package/dist/components/form/fields/FieldDescription.d.ts +10 -0
- package/dist/components/form/fields/FieldDescription.d.ts.map +1 -0
- package/dist/components/form/fields/FieldDescription.js +30 -0
- package/dist/components/form/fields/FileField.d.ts +16 -0
- package/dist/components/form/fields/FileField.d.ts.map +1 -0
- package/dist/components/form/fields/FileField.js +79 -0
- package/dist/components/form/fields/FileUploaderField.d.ts +72 -0
- package/dist/components/form/fields/FileUploaderField.d.ts.map +1 -0
- package/dist/components/form/fields/FileUploaderField.js +79 -0
- package/dist/components/form/fields/InputPhoneField.d.ts +40 -0
- package/dist/components/form/fields/InputPhoneField.d.ts.map +1 -0
- package/dist/components/form/fields/InputPhoneField.js +48 -0
- package/dist/components/form/fields/InputTagsField.d.ts +32 -0
- package/dist/components/form/fields/InputTagsField.d.ts.map +1 -0
- package/dist/components/form/fields/InputTagsField.js +50 -0
- package/dist/components/form/fields/RadioGroupField.d.ts +40 -0
- package/dist/components/form/fields/RadioGroupField.d.ts.map +1 -0
- package/dist/components/form/fields/RadioGroupField.js +61 -0
- package/dist/components/form/fields/ResetButton.d.ts +19 -0
- package/dist/components/form/fields/ResetButton.d.ts.map +1 -0
- package/dist/components/form/fields/ResetButton.js +25 -0
- package/dist/components/form/fields/SelectField.d.ts +44 -0
- package/dist/components/form/fields/SelectField.d.ts.map +1 -0
- package/dist/components/form/fields/SelectField.js +59 -0
- package/dist/components/form/fields/SubmitButton.d.ts +27 -0
- package/dist/components/form/fields/SubmitButton.d.ts.map +1 -0
- package/dist/components/form/fields/SubmitButton.js +36 -0
- package/dist/components/form/fields/SwitchField.d.ts +40 -0
- package/dist/components/form/fields/SwitchField.d.ts.map +1 -0
- package/dist/components/form/fields/SwitchField.js +77 -0
- package/dist/components/form/fields/TextField.d.ts +25 -0
- package/dist/components/form/fields/TextField.d.ts.map +1 -0
- package/dist/components/form/fields/TextField.js +98 -0
- package/dist/components/form/fields/TextareaField.d.ts +44 -0
- package/dist/components/form/fields/TextareaField.d.ts.map +1 -0
- package/dist/components/form/fields/TextareaField.js +71 -0
- package/dist/components/form/fields/UniqueTextField.d.ts +38 -0
- package/dist/components/form/fields/UniqueTextField.d.ts.map +1 -0
- package/dist/components/form/fields/UniqueTextField.js +171 -0
- package/dist/components/form/index.d.ts +20 -0
- package/dist/components/form/index.d.ts.map +1 -0
- package/dist/components/form/index.js +40 -0
- package/dist/components/form/useTriggerForm.d.ts +11 -0
- package/dist/components/form/useTriggerForm.d.ts.map +1 -0
- package/dist/components/form/useTriggerForm.js +14 -0
- package/dist/components/heading/Heading.d.ts +18 -0
- package/dist/components/heading/Heading.d.ts.map +1 -0
- package/dist/components/heading/Heading.js +71 -0
- package/dist/components/hover-card/HoverCard.d.ts +7 -0
- package/dist/components/hover-card/HoverCard.d.ts.map +1 -0
- package/dist/components/hover-card/HoverCard.js +41 -0
- package/dist/components/icon/Icon.d.ts +22 -0
- package/dist/components/icon/Icon.d.ts.map +1 -0
- package/dist/components/icon/Icon.js +71 -0
- package/dist/components/index.d.ts +76 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +426 -0
- package/dist/components/input/Input.d.ts +11 -0
- package/dist/components/input/Input.d.ts.map +1 -0
- package/dist/components/input/Input.js +66 -0
- package/dist/components/input-group/InputGroup.d.ts +17 -0
- package/dist/components/input-group/InputGroup.d.ts.map +1 -0
- package/dist/components/input-group/InputGroup.js +129 -0
- package/dist/components/input-otp/input-otp.d.ts +16 -0
- package/dist/components/input-otp/input-otp.d.ts.map +1 -0
- package/dist/components/input-otp/input-otp.js +72 -0
- package/dist/components/input-phone/InputPhone.d.ts +13 -0
- package/dist/components/input-phone/InputPhone.d.ts.map +1 -0
- package/dist/components/input-phone/InputPhone.js +116 -0
- package/dist/components/input-tags/InputTags.d.ts +28 -0
- package/dist/components/input-tags/InputTags.d.ts.map +1 -0
- package/dist/components/input-tags/InputTags.js +88 -0
- package/dist/components/item/Item.d.ts +24 -0
- package/dist/components/item/Item.d.ts.map +1 -0
- package/dist/components/item/Item.js +162 -0
- package/dist/components/kbd/Kbd.d.ts +4 -0
- package/dist/components/kbd/Kbd.d.ts.map +1 -0
- package/dist/components/kbd/Kbd.js +26 -0
- package/dist/components/label/Label.d.ts +11 -0
- package/dist/components/label/Label.d.ts.map +1 -0
- package/dist/components/label/Label.js +26 -0
- package/dist/components/menubar/Menubar.d.ts +27 -0
- package/dist/components/menubar/Menubar.d.ts.map +1 -0
- package/dist/components/menubar/Menubar.js +212 -0
- package/dist/components/native-select/NativeSelect.d.ts +6 -0
- package/dist/components/native-select/NativeSelect.d.ts.map +1 -0
- package/dist/components/native-select/NativeSelect.js +44 -0
- package/dist/components/navbar/Navbar.d.ts +3 -0
- package/dist/components/navbar/Navbar.d.ts.map +1 -0
- package/dist/components/navbar/Navbar.js +69 -0
- package/dist/components/navigation-menu/NavigationMenu.d.ts +15 -0
- package/dist/components/navigation-menu/NavigationMenu.d.ts.map +1 -0
- package/dist/components/navigation-menu/NavigationMenu.js +112 -0
- package/dist/components/open-dialog/OpenDialog.d.ts +9 -0
- package/dist/components/open-dialog/OpenDialog.d.ts.map +1 -0
- package/dist/components/open-dialog/OpenDialog.js +35 -0
- package/dist/components/pagination/Pagination.d.ts +31 -0
- package/dist/components/pagination/Pagination.d.ts.map +1 -0
- package/dist/components/pagination/Pagination.js +216 -0
- package/dist/components/pagination/PaginationProvider.d.ts +33 -0
- package/dist/components/pagination/PaginationProvider.d.ts.map +1 -0
- package/dist/components/pagination/PaginationProvider.js +65 -0
- package/dist/components/pagination/types.d.ts +22 -0
- package/dist/components/pagination/types.d.ts.map +1 -0
- package/dist/components/pagination/types.js +1 -0
- package/dist/components/popover/Popover.d.ts +8 -0
- package/dist/components/popover/Popover.d.ts.map +1 -0
- package/dist/components/popover/Popover.js +49 -0
- package/dist/components/profile-pic-uploader/ProfilePicUploader.d.ts +12 -0
- package/dist/components/profile-pic-uploader/ProfilePicUploader.d.ts.map +1 -0
- package/dist/components/profile-pic-uploader/ProfilePicUploader.js +233 -0
- package/dist/components/profile-pic-uploader/index.d.ts +3 -0
- package/dist/components/profile-pic-uploader/index.d.ts.map +1 -0
- package/dist/components/profile-pic-uploader/index.js +4 -0
- package/dist/components/progress/Progress.d.ts +189 -0
- package/dist/components/progress/Progress.d.ts.map +1 -0
- package/dist/components/progress/Progress.js +283 -0
- package/dist/components/radio-group/RadioGroup.d.ts +16 -0
- package/dist/components/radio-group/RadioGroup.d.ts.map +1 -0
- package/dist/components/radio-group/RadioGroup.js +50 -0
- package/dist/components/resizable-panel/ResizablePanel.d.ts +9 -0
- package/dist/components/resizable-panel/ResizablePanel.d.ts.map +1 -0
- package/dist/components/resizable-panel/ResizablePanel.js +44 -0
- package/dist/components/scroll-area/ScrollArea.d.ts +6 -0
- package/dist/components/scroll-area/ScrollArea.d.ts.map +1 -0
- package/dist/components/scroll-area/ScrollArea.js +39 -0
- package/dist/components/section/Section.d.ts +12 -0
- package/dist/components/section/Section.d.ts.map +1 -0
- package/dist/components/section/Section.js +84 -0
- package/dist/components/select/Select.d.ts +16 -0
- package/dist/components/select/Select.d.ts.map +1 -0
- package/dist/components/select/Select.js +148 -0
- package/dist/components/separator/Separator.d.ts +5 -0
- package/dist/components/separator/Separator.d.ts.map +1 -0
- package/dist/components/separator/Separator.js +20 -0
- package/dist/components/sheet/Sheet.d.ts +16 -0
- package/dist/components/sheet/Sheet.d.ts.map +1 -0
- package/dist/components/sheet/Sheet.js +127 -0
- package/dist/components/sidebar/HeaderDropDown.d.ts +3 -0
- package/dist/components/sidebar/HeaderDropDown.d.ts.map +1 -0
- package/dist/components/sidebar/HeaderDropDown.js +39 -0
- package/dist/components/sidebar/Sidebar.d.ts +70 -0
- package/dist/components/sidebar/Sidebar.d.ts.map +1 -0
- package/dist/components/sidebar/Sidebar.js +514 -0
- package/dist/components/sidebar/SidebarFooterContent.d.ts +3 -0
- package/dist/components/sidebar/SidebarFooterContent.d.ts.map +1 -0
- package/dist/components/sidebar/SidebarFooterContent.js +66 -0
- package/dist/components/sidebar/SidebarHeaderLogo.d.ts +2 -0
- package/dist/components/sidebar/SidebarHeaderLogo.d.ts.map +1 -0
- package/dist/components/sidebar/SidebarHeaderLogo.js +34 -0
- package/dist/components/skeleton/Skeleton.d.ts +3 -0
- package/dist/components/skeleton/Skeleton.d.ts.map +1 -0
- package/dist/components/skeleton/Skeleton.js +15 -0
- package/dist/components/slider/Slider.d.ts +6 -0
- package/dist/components/slider/Slider.d.ts.map +1 -0
- package/dist/components/slider/Slider.js +39 -0
- package/dist/components/sonner/Sonner.d.ts +4 -0
- package/dist/components/sonner/Sonner.d.ts.map +1 -0
- package/dist/components/sonner/Sonner.js +55 -0
- package/dist/components/spinner/Spinner.d.ts +11 -0
- package/dist/components/spinner/Spinner.d.ts.map +1 -0
- package/dist/components/spinner/Spinner.js +49 -0
- package/dist/components/stack/Stack.d.ts +14 -0
- package/dist/components/stack/Stack.d.ts.map +1 -0
- package/dist/components/stack/Stack.js +29 -0
- package/dist/components/subText/SubText.d.ts +13 -0
- package/dist/components/subText/SubText.d.ts.map +1 -0
- package/dist/components/subText/SubText.js +50 -0
- package/dist/components/switch/Switch.d.ts +5 -0
- package/dist/components/switch/Switch.d.ts.map +1 -0
- package/dist/components/switch/Switch.js +41 -0
- package/dist/components/table/Table.d.ts +32 -0
- package/dist/components/table/Table.d.ts.map +1 -0
- package/dist/components/table/Table.js +243 -0
- package/dist/components/table-empty-state/TableEmptyState.d.ts +11 -0
- package/dist/components/table-empty-state/TableEmptyState.d.ts.map +1 -0
- package/dist/components/table-empty-state/TableEmptyState.js +52 -0
- package/dist/components/tabs/Tabs.d.ts +12 -0
- package/dist/components/tabs/Tabs.d.ts.map +1 -0
- package/dist/components/tabs/Tabs.js +84 -0
- package/dist/components/text-link/LinkText.d.ts +14 -0
- package/dist/components/text-link/LinkText.d.ts.map +1 -0
- package/dist/components/text-link/LinkText.js +42 -0
- package/dist/components/textarea/Textarea.d.ts +7 -0
- package/dist/components/textarea/Textarea.d.ts.map +1 -0
- package/dist/components/textarea/Textarea.js +28 -0
- package/dist/components/toggle/Toggle.d.ts +10 -0
- package/dist/components/toggle/Toggle.d.ts.map +1 -0
- package/dist/components/toggle/Toggle.js +41 -0
- package/dist/components/toggle-group/ToggleGroup.d.ts +10 -0
- package/dist/components/toggle-group/ToggleGroup.d.ts.map +1 -0
- package/dist/components/toggle-group/ToggleGroup.js +78 -0
- package/dist/components/tooltip/Tooltip.d.ts +18 -0
- package/dist/components/tooltip/Tooltip.d.ts.map +1 -0
- package/dist/components/tooltip/Tooltip.js +83 -0
- package/dist/fonts/index.css +49 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +12 -0
- package/dist/hooks/use-countdown.d.ts +20 -0
- package/dist/hooks/use-countdown.d.ts.map +1 -0
- package/dist/hooks/use-countdown.js +21 -0
- package/dist/hooks/use-debounce.d.ts +20 -0
- package/dist/hooks/use-debounce.d.ts.map +1 -0
- package/dist/hooks/use-debounce.js +15 -0
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +14 -0
- package/dist/hooks/useDragScroll.d.ts +6 -0
- package/dist/hooks/useDragScroll.d.ts.map +1 -0
- package/dist/hooks/useDragScroll.js +26 -0
- package/dist/hooks/useImageCrop.d.ts +41 -0
- package/dist/hooks/useImageCrop.d.ts.map +1 -0
- package/dist/hooks/useImageCrop.js +84 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +456 -0
- package/dist/lib/datetime.d.ts +8 -0
- package/dist/lib/datetime.d.ts.map +1 -0
- package/dist/lib/datetime.js +44 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +15 -0
- package/dist/lib/string.d.ts +4 -0
- package/dist/lib/string.d.ts.map +1 -0
- package/dist/lib/string.js +12 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +8 -0
- package/dist/styles/globals.css +60 -0
- package/dist/styles/tokens.css +249 -0
- package/dist/theme/ThemeProvider.d.ts +5 -0
- package/dist/theme/ThemeProvider.d.ts.map +1 -0
- package/dist/theme/ThemeProvider.js +17 -0
- package/dist/theme/ToggleTheme.d.ts +2 -0
- package/dist/theme/ToggleTheme.d.ts.map +1 -0
- package/dist/theme/ToggleTheme.js +29 -0
- package/dist/theme/index.d.ts +4 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +9 -0
- package/dist/theme/theme.d.ts +8 -0
- package/dist/theme/theme.d.ts.map +1 -0
- package/dist/theme/theme.js +15 -0
- package/dist/vite.svg +1 -0
- package/package.json +156 -0
- package/postcss.config.mjs +6 -0
- package/src/styles/globals.css +60 -0
- package/src/styles/tokens.css +249 -0
- package/src/styles/tokens.json +253 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUploader.d.ts","sourceRoot":"","sources":["../../../src/components/file-uploader/FileUploader.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAqB,iBAAiB,EAAgB,MAAM,SAAS,CAAC;AAS7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAwIlE,CAAC;AA4BF,YAAY,EACV,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAClD,YAAY,EACb,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { CloudUpload as P, BadgeX as U } from "lucide-react";
|
|
2
|
+
import { cn as a } from "../../lib/utils.js";
|
|
3
|
+
import { Button as x } from "../button/Button.js";
|
|
4
|
+
import { Progress as j } from "../progress/Progress.js";
|
|
5
|
+
import { useFileUploader as G } from "./useFileUploader.js";
|
|
6
|
+
import { jsx as e, jsxs as n } from "react/jsx-runtime";
|
|
7
|
+
const M = {
|
|
8
|
+
maxFiles: 4,
|
|
9
|
+
maxSize: 1e6,
|
|
10
|
+
// 1MB
|
|
11
|
+
resourceType: "IMAGE"
|
|
12
|
+
}, E = ({
|
|
13
|
+
config: s,
|
|
14
|
+
onUpload: p,
|
|
15
|
+
onFilesChange: h,
|
|
16
|
+
disabled: c = !1,
|
|
17
|
+
className: b
|
|
18
|
+
}) => {
|
|
19
|
+
var d, u;
|
|
20
|
+
const o = {
|
|
21
|
+
...M,
|
|
22
|
+
...s
|
|
23
|
+
}, {
|
|
24
|
+
files: i,
|
|
25
|
+
onRemoveFile: v,
|
|
26
|
+
dropzone: r,
|
|
27
|
+
isUploading: l,
|
|
28
|
+
uploadProgress: y,
|
|
29
|
+
handleUpload: N,
|
|
30
|
+
isUploadComplete: w
|
|
31
|
+
} = G({
|
|
32
|
+
configuration: o,
|
|
33
|
+
onUpload: p,
|
|
34
|
+
onFilesChange: h
|
|
35
|
+
});
|
|
36
|
+
return /* @__PURE__ */ e("div", {
|
|
37
|
+
className: a("flex flex-col gap-4", b),
|
|
38
|
+
children: /* @__PURE__ */ n("div", {
|
|
39
|
+
className: a("relative flex h-full max-h-96 w-full flex-col items-center justify-center gap-y-2 rounded border-2 border-dashed p-5 shadow transition-colors", r.isDragActive && "border-primary bg-primary/5", c && "cursor-not-allowed opacity-50", i.length > 0 && "justify-start"),
|
|
40
|
+
...r.getRootProps(),
|
|
41
|
+
children: [/* @__PURE__ */ e("input", {
|
|
42
|
+
...r.getInputProps(),
|
|
43
|
+
disabled: c
|
|
44
|
+
}), !i.length && /* @__PURE__ */ n("div", {
|
|
45
|
+
className: "flex flex-col items-center justify-center",
|
|
46
|
+
children: [/* @__PURE__ */ e(P, {
|
|
47
|
+
size: 50,
|
|
48
|
+
className: "text-foreground cursor-pointer"
|
|
49
|
+
}), /* @__PURE__ */ e("p", {
|
|
50
|
+
className: "text-md",
|
|
51
|
+
children: r.isDragActive ? "Drop here." : "Drag and Drop"
|
|
52
|
+
}), /* @__PURE__ */ n("em", {
|
|
53
|
+
className: "text-muted-foreground text-center text-sm leading-6",
|
|
54
|
+
children: ["Max Size: ", o.maxSize / 1e6, "MB, Maximum upload:", " ", o.maxFiles, " ", /* @__PURE__ */ e("br", {}), "Supported formats:", " ", z(o.resourceType)]
|
|
55
|
+
})]
|
|
56
|
+
}), /* @__PURE__ */ e("div", {
|
|
57
|
+
className: "flex w-full flex-wrap justify-center gap-2",
|
|
58
|
+
children: i.length > 0 && i.map((t, m) => {
|
|
59
|
+
const f = y[m] || 0, g = l && f < 100;
|
|
60
|
+
return /* @__PURE__ */ n("div", {
|
|
61
|
+
className: "group relative h-16 w-16",
|
|
62
|
+
children: [o.resourceType === "IMAGE" ? /* @__PURE__ */ e("img", {
|
|
63
|
+
src: t.preview,
|
|
64
|
+
className: a("h-12 w-12 rounded object-cover", g && "opacity-50"),
|
|
65
|
+
alt: t.name
|
|
66
|
+
}) : /* @__PURE__ */ e("div", {
|
|
67
|
+
className: "bg-muted flex h-12 w-12 items-center justify-center rounded",
|
|
68
|
+
children: /* @__PURE__ */ e("span", {
|
|
69
|
+
className: "text-xs font-medium",
|
|
70
|
+
children: A(t.file.name).toUpperCase()
|
|
71
|
+
})
|
|
72
|
+
}), /* @__PURE__ */ e(j, {
|
|
73
|
+
value: f,
|
|
74
|
+
className: a("invisible absolute inset-0 mx-auto my-auto w-[60%]", g && "visible")
|
|
75
|
+
}), /* @__PURE__ */ e(x, {
|
|
76
|
+
className: a("bg-primary/10 text-primary-foreground invisible absolute inset-0 mx-auto my-auto h-10 w-10 rounded-full", !l && "group-hover:visible"),
|
|
77
|
+
size: "sm",
|
|
78
|
+
onClick: (F) => {
|
|
79
|
+
F.stopPropagation(), v(m);
|
|
80
|
+
},
|
|
81
|
+
disabled: l,
|
|
82
|
+
children: /* @__PURE__ */ e(U, {
|
|
83
|
+
size: 30
|
|
84
|
+
})
|
|
85
|
+
}), /* @__PURE__ */ e("p", {
|
|
86
|
+
className: "text-primary-foreground absolute -bottom-4 left-0 right-0 w-full truncate text-center text-[10px] font-semibold",
|
|
87
|
+
children: t.name
|
|
88
|
+
})]
|
|
89
|
+
}, `file-${m}`);
|
|
90
|
+
})
|
|
91
|
+
}), i.length > 0 && p && !w && /* @__PURE__ */ e(x, {
|
|
92
|
+
onClick: (t) => {
|
|
93
|
+
t.stopPropagation(), N();
|
|
94
|
+
},
|
|
95
|
+
size: "sm",
|
|
96
|
+
disabled: l || c,
|
|
97
|
+
className: "absolute bottom-2 right-2",
|
|
98
|
+
children: l ? "Uploading..." : "Upload"
|
|
99
|
+
}), (r == null ? void 0 : r.fileRejections.length) > 0 && /* @__PURE__ */ e("p", {
|
|
100
|
+
className: "text-destructive text-sm",
|
|
101
|
+
children: (u = (d = r.fileRejections[0]) == null ? void 0 : d.errors[0]) == null ? void 0 : u.message
|
|
102
|
+
})]
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
function z(s) {
|
|
107
|
+
switch (s) {
|
|
108
|
+
case "IMAGE":
|
|
109
|
+
return "PNG, JPEG, JPG, WebP";
|
|
110
|
+
case "PDF":
|
|
111
|
+
return "PDF";
|
|
112
|
+
case "VIDEO":
|
|
113
|
+
return "MP4, WebM, OGG";
|
|
114
|
+
default:
|
|
115
|
+
return "Various formats";
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function A(s) {
|
|
119
|
+
return s.split(".").pop() || "";
|
|
120
|
+
}
|
|
121
|
+
E.displayName = "FileUploader";
|
|
122
|
+
export {
|
|
123
|
+
E as FileUploader
|
|
124
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type ResourceType = "IMAGE" | "PDF" | "VIDEO";
|
|
2
|
+
export type UploadMode = "manual" | "on-change";
|
|
3
|
+
export interface FileConfiguration {
|
|
4
|
+
maxFiles?: number;
|
|
5
|
+
maxSize?: number;
|
|
6
|
+
resourceType?: ResourceType;
|
|
7
|
+
}
|
|
8
|
+
export interface UploadedFile {
|
|
9
|
+
file: File;
|
|
10
|
+
preview: string;
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
export interface UploadResult {
|
|
14
|
+
success: boolean;
|
|
15
|
+
url?: string;
|
|
16
|
+
error?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface FileUploaderProps {
|
|
19
|
+
config?: FileConfiguration;
|
|
20
|
+
mode?: UploadMode;
|
|
21
|
+
onUpload?: (files: UploadedFile[]) => Promise<UploadResult[]> | UploadResult[] | Promise<void> | void;
|
|
22
|
+
onFilesChange?: (files: UploadedFile[]) => void;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface UseFileUploaderProps {
|
|
27
|
+
configuration: Required<FileConfiguration>;
|
|
28
|
+
mode?: UploadMode;
|
|
29
|
+
onUpload?: (files: UploadedFile[]) => Promise<UploadResult[]> | UploadResult[] | Promise<void> | void;
|
|
30
|
+
onFilesChange?: (files: UploadedFile[]) => void;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/file-uploader/types.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,CAAC;AAErD,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEhD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,QAAQ,CAAC,EAAE,CACT,KAAK,EAAE,YAAY,EAAE,KAClB,OAAO,CAAC,YAAY,EAAE,CAAC,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACrE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;IAChD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAGD,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC3C,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,QAAQ,CAAC,EAAE,CACT,KAAK,EAAE,YAAY,EAAE,KAClB,OAAO,CAAC,YAAY,EAAE,CAAC,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACrE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;CACjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UploadedFile, UseFileUploaderProps } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Provider-agnostic file uploader hook
|
|
4
|
+
*
|
|
5
|
+
* @param configuration - File uploader configuration
|
|
6
|
+
* @param onUpload - Callback function that receives files to upload
|
|
7
|
+
* @param onFilesChange - Callback function that receives current files when they change
|
|
8
|
+
*
|
|
9
|
+
* @returns File uploader state and handlers
|
|
10
|
+
*/
|
|
11
|
+
export declare const useFileUploader: ({ configuration, onUpload, onFilesChange, }: UseFileUploaderProps) => {
|
|
12
|
+
files: UploadedFile[];
|
|
13
|
+
onRemoveFile: (index: number) => void;
|
|
14
|
+
dropzone: import("react-dropzone").DropzoneState;
|
|
15
|
+
isUploading: boolean;
|
|
16
|
+
uploadProgress: Record<number, number>;
|
|
17
|
+
handleUpload: () => Promise<void>;
|
|
18
|
+
updateProgress: (fileIndex: number, percentage: number) => void;
|
|
19
|
+
resetFiles: () => void;
|
|
20
|
+
isUploadComplete: boolean;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=useFileUploader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFileUploader.d.ts","sourceRoot":"","sources":["../../../src/components/file-uploader/useFileUploader.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAgB,YAAY,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAkC3E;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,6CAI7B,oBAAoB;;0BA0BX,MAAM;;;;;gCAwDF,MAAM,cAAc,MAAM;;;CA8FzC,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { useState as m, useRef as D, useEffect as w, useCallback as a } from "react";
|
|
2
|
+
import { useDropzone as L } from "react-dropzone";
|
|
3
|
+
const M = (c) => {
|
|
4
|
+
switch (c) {
|
|
5
|
+
case "IMAGE":
|
|
6
|
+
return {
|
|
7
|
+
"image/png": [".png"],
|
|
8
|
+
"image/jpeg": [".jpg", ".jpeg"],
|
|
9
|
+
"image/webp": [".webp"]
|
|
10
|
+
};
|
|
11
|
+
case "PDF":
|
|
12
|
+
return {
|
|
13
|
+
"application/pdf": [".pdf"]
|
|
14
|
+
};
|
|
15
|
+
case "VIDEO":
|
|
16
|
+
return {
|
|
17
|
+
"video/mp4": [".mp4"],
|
|
18
|
+
"video/webm": [".webm"],
|
|
19
|
+
"video/ogg": [".ogg"]
|
|
20
|
+
};
|
|
21
|
+
default:
|
|
22
|
+
return console.error("Invalid resource type"), {};
|
|
23
|
+
}
|
|
24
|
+
}, N = ({
|
|
25
|
+
configuration: c,
|
|
26
|
+
onUpload: d,
|
|
27
|
+
onFilesChange: r
|
|
28
|
+
}) => {
|
|
29
|
+
const [t, i] = m([]), [f, b] = m(!1), [x, u] = m({}), [y, n] = m(!1), U = D(!0);
|
|
30
|
+
w(() => {
|
|
31
|
+
t.length === 0 && n(!1);
|
|
32
|
+
}, [t]);
|
|
33
|
+
const E = a(() => {
|
|
34
|
+
i([]), u({}), n(!1), r == null || r([]);
|
|
35
|
+
}, [r]), j = a((s) => {
|
|
36
|
+
f || (i((o) => {
|
|
37
|
+
const e = [...o];
|
|
38
|
+
e.splice(s, 1);
|
|
39
|
+
const l = e.slice(0, c.maxFiles);
|
|
40
|
+
return r == null || r(l), l;
|
|
41
|
+
}), u((o) => {
|
|
42
|
+
const e = {
|
|
43
|
+
...o
|
|
44
|
+
};
|
|
45
|
+
return delete e[s], e;
|
|
46
|
+
}));
|
|
47
|
+
}, [c.maxFiles, r]), R = a(async () => {
|
|
48
|
+
if (!(!t.length || !d || f)) {
|
|
49
|
+
b(!0), u({});
|
|
50
|
+
try {
|
|
51
|
+
const s = await d(t);
|
|
52
|
+
if (s && Array.isArray(s) && (console.log("Upload results:", s), s.some((e) => typeof e == "object" && "success" in e && !e.success)))
|
|
53
|
+
throw console.error("Some uploads failed:", s.filter((e) => typeof e == "object" && "success" in e && !e.success)), new Error("Some files failed to upload");
|
|
54
|
+
n(!0);
|
|
55
|
+
} catch (s) {
|
|
56
|
+
console.error("Upload failed:", s);
|
|
57
|
+
} finally {
|
|
58
|
+
b(!1);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, [d, t]), z = a((s, o) => {
|
|
62
|
+
u((e) => ({
|
|
63
|
+
...e,
|
|
64
|
+
[s]: o
|
|
65
|
+
}));
|
|
66
|
+
}, []), I = a((s, o) => {
|
|
67
|
+
if (o.length > 0 || t.length >= c.maxFiles)
|
|
68
|
+
return;
|
|
69
|
+
const e = [];
|
|
70
|
+
s.forEach((l) => {
|
|
71
|
+
const p = l.name, v = p.split(".")[0];
|
|
72
|
+
if (!v || t.find((A) => A.file.name === p))
|
|
73
|
+
return;
|
|
74
|
+
const S = URL.createObjectURL(l);
|
|
75
|
+
e.push({
|
|
76
|
+
file: l,
|
|
77
|
+
preview: S,
|
|
78
|
+
name: v
|
|
79
|
+
});
|
|
80
|
+
}), e.length > 0 && i((l) => {
|
|
81
|
+
const p = [...l, ...e].slice(0, c.maxFiles);
|
|
82
|
+
return r == null || r(p), p;
|
|
83
|
+
});
|
|
84
|
+
}, [t, c.maxFiles, r]), P = L({
|
|
85
|
+
accept: M(c.resourceType),
|
|
86
|
+
maxFiles: c.maxFiles,
|
|
87
|
+
onDrop: I,
|
|
88
|
+
validator: (s) => s.size > c.maxSize ? {
|
|
89
|
+
code: "file-too-large",
|
|
90
|
+
message: `File size must be less than ${c.maxSize / 1e6}MB`
|
|
91
|
+
} : null
|
|
92
|
+
});
|
|
93
|
+
return w(() => {
|
|
94
|
+
if (U.current) {
|
|
95
|
+
U.current = !1;
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
r == null || r(t);
|
|
99
|
+
}, [t, r]), w(() => () => {
|
|
100
|
+
t.forEach((s) => URL.revokeObjectURL(s.preview));
|
|
101
|
+
}, [t]), {
|
|
102
|
+
files: t,
|
|
103
|
+
onRemoveFile: j,
|
|
104
|
+
dropzone: P,
|
|
105
|
+
isUploading: f,
|
|
106
|
+
uploadProgress: x,
|
|
107
|
+
handleUpload: R,
|
|
108
|
+
updateProgress: z,
|
|
109
|
+
resetFiles: E,
|
|
110
|
+
isUploadComplete: y
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export {
|
|
114
|
+
N as useFileUploader
|
|
115
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ArrayPath, FieldValues, UseFieldArrayReturn } from 'react-hook-form';
|
|
3
|
+
export type FieldArrayProps<T extends FieldValues> = {
|
|
4
|
+
children: (field: UseFieldArrayReturn<T, ArrayPath<T>>) => ReactNode;
|
|
5
|
+
name: ArrayPath<T>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A field array component.
|
|
9
|
+
* @param children The children of the field array.
|
|
10
|
+
* @param name The name of the field array.
|
|
11
|
+
*
|
|
12
|
+
* @returns The field array component.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <FieldArray name="items">
|
|
17
|
+
* {({ fields }) =>
|
|
18
|
+
* fields.map((field, index) => (
|
|
19
|
+
* <TextField key={field.id} name={`items.${index}.name`} />
|
|
20
|
+
* ))
|
|
21
|
+
* }
|
|
22
|
+
* </FieldArray>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const FieldArray: <T extends FieldValues>({ children, name, }: FieldArrayProps<T>) => ReactNode;
|
|
26
|
+
//# sourceMappingURL=FieldArray.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldArray.d.ts","sourceRoot":"","sources":["../../../src/components/form/FieldArray.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EACL,SAAS,EACT,WAAW,EAEX,mBAAmB,EAEpB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,WAAW,IAAI;IACnD,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IACrE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AAEH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,WAAW,EAAE,qBAG/C,eAAe,CAAC,CAAC,CAAC,cAKpB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useFormContext as n, useFieldArray as s } from "react-hook-form";
|
|
2
|
+
const i = ({
|
|
3
|
+
children: r,
|
|
4
|
+
name: o
|
|
5
|
+
}) => {
|
|
6
|
+
const {
|
|
7
|
+
control: t
|
|
8
|
+
} = n(), e = s({
|
|
9
|
+
control: t,
|
|
10
|
+
name: o
|
|
11
|
+
});
|
|
12
|
+
return r(e);
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
i as FieldArray
|
|
16
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
3
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
+
import { type ControllerProps, type FieldPath, type FieldValues } from 'react-hook-form';
|
|
5
|
+
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: import("react-hook-form").FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
6
|
+
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare const useFormField: () => {
|
|
8
|
+
invalid: boolean;
|
|
9
|
+
isDirty: boolean;
|
|
10
|
+
isTouched: boolean;
|
|
11
|
+
isValidating: boolean;
|
|
12
|
+
error?: import("react-hook-form").FieldError;
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
formItemId: string;
|
|
16
|
+
formDescriptionId: string;
|
|
17
|
+
formMessageId: string;
|
|
18
|
+
};
|
|
19
|
+
declare function FormItem({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
declare function FormLabel({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
declare function FormControl({ ...props }: React.ComponentProps<typeof Slot>): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
declare function FormDescription({ className, ...props }: React.ComponentProps<'p'>): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
declare function FormMessage({ className, ...props }: React.ComponentProps<'p'>): import("react/jsx-runtime").JSX.Element | null;
|
|
24
|
+
export { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, };
|
|
25
|
+
//# sourceMappingURL=Form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/form/Form.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,cAAc,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAKzB,QAAA,MAAM,IAAI,4MAAe,CAAC;AAa1B,QAAA,MAAM,SAAS,GACb,YAAY,SAAS,WAAW,GAAG,WAAW,EAC9C,KAAK,SAAS,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC,YAAY,CAAC,EAC/D,cAEC,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,4CAMtC,CAAC;AAEF,QAAA,MAAM,YAAY;;;;;;;;;;;CAqBjB,CAAC;AAUF,iBAAS,QAAQ,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,2CAYrE;AAED,iBAAS,SAAS,CAAC,EACjB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,2CAYlD;AAED,iBAAS,WAAW,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,2CAiBnE;AAED,iBAAS,eAAe,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,2CAW1E;AAED,iBAAS,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,kDAkBtE;AAED,OAAO,EACL,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,eAAe,EACf,WAAW,EACX,SAAS,GACV,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import * as s from "react";
|
|
2
|
+
import { Slot as f } from "@radix-ui/react-slot";
|
|
3
|
+
import { FormProvider as u, Controller as F, useFormContext as x, useFormState as I } from "react-hook-form";
|
|
4
|
+
import { cn as a } from "@inspirecn/ui/lib/utils";
|
|
5
|
+
import { Label as g } from "../label/Label.js";
|
|
6
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
7
|
+
const S = u, c = s.createContext({}), $ = ({
|
|
8
|
+
...e
|
|
9
|
+
}) => /* @__PURE__ */ m(c.Provider, {
|
|
10
|
+
value: {
|
|
11
|
+
name: e.name
|
|
12
|
+
},
|
|
13
|
+
children: /* @__PURE__ */ m(F, {
|
|
14
|
+
...e
|
|
15
|
+
})
|
|
16
|
+
}), d = () => {
|
|
17
|
+
const e = s.useContext(c), o = s.useContext(l), {
|
|
18
|
+
getFieldState: t
|
|
19
|
+
} = x(), r = I({
|
|
20
|
+
name: e.name
|
|
21
|
+
}), n = t(e.name, r);
|
|
22
|
+
if (!e)
|
|
23
|
+
throw new Error("useFormField should be used within <FormField>");
|
|
24
|
+
const {
|
|
25
|
+
id: i
|
|
26
|
+
} = o;
|
|
27
|
+
return {
|
|
28
|
+
id: i,
|
|
29
|
+
name: e.name,
|
|
30
|
+
formItemId: `${i}-form-item`,
|
|
31
|
+
formDescriptionId: `${i}-form-item-description`,
|
|
32
|
+
formMessageId: `${i}-form-item-message`,
|
|
33
|
+
...n
|
|
34
|
+
};
|
|
35
|
+
}, l = s.createContext({});
|
|
36
|
+
function D({
|
|
37
|
+
className: e,
|
|
38
|
+
...o
|
|
39
|
+
}) {
|
|
40
|
+
const t = s.useId();
|
|
41
|
+
return /* @__PURE__ */ m(l.Provider, {
|
|
42
|
+
value: {
|
|
43
|
+
id: t
|
|
44
|
+
},
|
|
45
|
+
children: /* @__PURE__ */ m("div", {
|
|
46
|
+
"data-slot": "form-item",
|
|
47
|
+
className: a("grid gap-2", e),
|
|
48
|
+
...o
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function M({
|
|
53
|
+
className: e,
|
|
54
|
+
...o
|
|
55
|
+
}) {
|
|
56
|
+
const {
|
|
57
|
+
error: t,
|
|
58
|
+
formItemId: r
|
|
59
|
+
} = d();
|
|
60
|
+
return /* @__PURE__ */ m(g, {
|
|
61
|
+
"data-slot": "form-label",
|
|
62
|
+
"data-error": !!t,
|
|
63
|
+
className: a("data-[error=true]:text-destructive", e),
|
|
64
|
+
htmlFor: r,
|
|
65
|
+
...o
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function N({
|
|
69
|
+
...e
|
|
70
|
+
}) {
|
|
71
|
+
const {
|
|
72
|
+
error: o,
|
|
73
|
+
formItemId: t,
|
|
74
|
+
formDescriptionId: r,
|
|
75
|
+
formMessageId: n
|
|
76
|
+
} = d();
|
|
77
|
+
return /* @__PURE__ */ m(f, {
|
|
78
|
+
"data-slot": "form-control",
|
|
79
|
+
id: t,
|
|
80
|
+
"aria-describedby": o ? `${r} ${n}` : `${r}`,
|
|
81
|
+
"aria-invalid": !!o,
|
|
82
|
+
...e
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function w({
|
|
86
|
+
className: e,
|
|
87
|
+
...o
|
|
88
|
+
}) {
|
|
89
|
+
const {
|
|
90
|
+
formDescriptionId: t
|
|
91
|
+
} = d();
|
|
92
|
+
return /* @__PURE__ */ m("p", {
|
|
93
|
+
"data-slot": "form-description",
|
|
94
|
+
id: t,
|
|
95
|
+
className: a("text-muted-foreground text-sm", e),
|
|
96
|
+
...o
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function P({
|
|
100
|
+
className: e,
|
|
101
|
+
...o
|
|
102
|
+
}) {
|
|
103
|
+
const {
|
|
104
|
+
error: t,
|
|
105
|
+
formMessageId: r
|
|
106
|
+
} = d(), n = t ? String((t == null ? void 0 : t.message) ?? "") : o.children;
|
|
107
|
+
return n ? /* @__PURE__ */ m("p", {
|
|
108
|
+
"data-slot": "form-message",
|
|
109
|
+
id: r,
|
|
110
|
+
className: a("text-delete text-sm", e),
|
|
111
|
+
...o,
|
|
112
|
+
children: n
|
|
113
|
+
}) : null;
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
S as Form,
|
|
117
|
+
N as FormControl,
|
|
118
|
+
w as FormDescription,
|
|
119
|
+
$ as FormField,
|
|
120
|
+
D as FormItem,
|
|
121
|
+
M as FormLabel,
|
|
122
|
+
P as FormMessage,
|
|
123
|
+
d as useFormField
|
|
124
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { PropsWithChildren, Ref } from 'react';
|
|
2
|
+
import { Control, FieldValues, FormState, UseFormReset, UseFormReturn, UseFormSetValue } from 'react-hook-form';
|
|
3
|
+
import * as z from 'zod/v4';
|
|
4
|
+
export type GenericFormRef<T extends FieldValues> = {
|
|
5
|
+
form: UseFormReturn<T>;
|
|
6
|
+
control: Control<T>;
|
|
7
|
+
formState: FormState<T>;
|
|
8
|
+
getValues: () => T;
|
|
9
|
+
setValue: UseFormSetValue<T>;
|
|
10
|
+
watch: (name: keyof T) => T[keyof T];
|
|
11
|
+
reset: UseFormReset<T>;
|
|
12
|
+
handleSubmit: (onSubmit: (data: T) => void) => (e?: React.BaseSyntheticEvent) => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
export type FormProps<TSchema extends z.ZodType<any, any, any>> = PropsWithChildren<{
|
|
15
|
+
schema: TSchema;
|
|
16
|
+
initialValues?: z.infer<TSchema>;
|
|
17
|
+
ref?: Ref<GenericFormRef<z.infer<TSchema>>>;
|
|
18
|
+
mode?: 'onChange' | 'onBlur' | 'onSubmit' | 'all';
|
|
19
|
+
onSubmit: (data: z.infer<TSchema>, form: UseFormReturn<z.infer<TSchema>, any, undefined>) => void;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* A generic form component.
|
|
23
|
+
* @param schema The schema of the form.
|
|
24
|
+
* @param initialValues The initial values of the form.
|
|
25
|
+
* @param onSubmit The submit handler of the form.
|
|
26
|
+
* @param children The children of the form.
|
|
27
|
+
* @param ref The reference of the form.
|
|
28
|
+
*
|
|
29
|
+
* @returns The generic form component.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* <GenericForm
|
|
33
|
+
* schema={schema}
|
|
34
|
+
* initialValues={initialValues}
|
|
35
|
+
* onSubmit={onSubmit}
|
|
36
|
+
* >
|
|
37
|
+
* <TextField name="name" label="Name" />
|
|
38
|
+
* <SubmitButton />
|
|
39
|
+
* </GenericForm>
|
|
40
|
+
*/
|
|
41
|
+
export declare const GenericForm: <TSchema extends z.ZodType<any, any, any>>({ children, ...props }: FormProps<TSchema>) => import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
//# sourceMappingURL=GenericForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenericForm.d.ts","sourceRoot":"","sources":["../../../src/components/form/GenericForm.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,GAAG,EAAkC,MAAM,OAAO,CAAC;AAC/E,OAAO,EACL,OAAO,EACP,WAAW,EACX,SAAS,EAET,YAAY,EACZ,aAAa,EACb,eAAe,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAI5B,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,WAAW,IAAI;IAClD,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC,CAAC;IACnB,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAC7B,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACrC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACvB,YAAY,EAAE,CACZ,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,KACxB,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,OAAO,SAAS,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAC5D,iBAAiB,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5C,IAAI,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,KAAK,CAAC;IAClD,QAAQ,EAAE,CACR,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EACtB,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,KAClD,IAAI,CAAC;CACX,CAAC,CAAC;AAkDL;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,WAAW,GAAI,OAAO,SAAS,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,wBAGnE,SAAS,CAAC,OAAO,CAAC,4CAiBpB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useEffect as f, useImperativeHandle as a } from "react";
|
|
2
|
+
import { useForm as i } from "react-hook-form";
|
|
3
|
+
import { zodResolver as c } from "@hookform/resolvers/zod";
|
|
4
|
+
import { Form as l } from "./Form.js";
|
|
5
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
6
|
+
const S = ({
|
|
7
|
+
schema: m,
|
|
8
|
+
initialValues: t,
|
|
9
|
+
mode: r,
|
|
10
|
+
ref: s,
|
|
11
|
+
onSubmit: o
|
|
12
|
+
}) => {
|
|
13
|
+
const e = i({
|
|
14
|
+
resolver: c(m),
|
|
15
|
+
defaultValues: t,
|
|
16
|
+
mode: r
|
|
17
|
+
});
|
|
18
|
+
return f(() => {
|
|
19
|
+
!e.formState.isDirty && JSON.stringify(e.getValues()) !== JSON.stringify(t) && e.reset(t);
|
|
20
|
+
}, [e, t]), a(s, () => ({
|
|
21
|
+
form: e,
|
|
22
|
+
control: e.control,
|
|
23
|
+
formState: e.formState,
|
|
24
|
+
getValues: e.getValues,
|
|
25
|
+
setValue: e.setValue,
|
|
26
|
+
watch: e.watch,
|
|
27
|
+
reset: e.reset,
|
|
28
|
+
handleSubmit: e.handleSubmit
|
|
29
|
+
}), [e]), {
|
|
30
|
+
form: e,
|
|
31
|
+
handleSubmit: (u) => {
|
|
32
|
+
o(u, e);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}, v = ({
|
|
36
|
+
children: m,
|
|
37
|
+
...t
|
|
38
|
+
}) => {
|
|
39
|
+
const {
|
|
40
|
+
form: r,
|
|
41
|
+
handleSubmit: s
|
|
42
|
+
} = S({
|
|
43
|
+
...t
|
|
44
|
+
});
|
|
45
|
+
return /* @__PURE__ */ n(l, {
|
|
46
|
+
...r,
|
|
47
|
+
children: /* @__PURE__ */ n("form", {
|
|
48
|
+
onSubmit: (o) => (o.stopPropagation(), r.handleSubmit(s)(o)),
|
|
49
|
+
children: m
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
v as GenericForm
|
|
55
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { FieldValues, Path } from 'react-hook-form';
|
|
2
|
+
type Props<T extends FieldValues> = {
|
|
3
|
+
name: Path<T>;
|
|
4
|
+
label?: string;
|
|
5
|
+
required?: boolean;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
labelInfo?: string;
|
|
9
|
+
labelOptional?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* CheckboxField. A checkbox field component.
|
|
13
|
+
*
|
|
14
|
+
* @param name - The name of the field.
|
|
15
|
+
* @param label - The label of the field.
|
|
16
|
+
* @param required - The required flag of the field.
|
|
17
|
+
* @param disabled - The disabled flag of the field.
|
|
18
|
+
* @param className - The class name of the field.
|
|
19
|
+
* @param labelInfo - Additional information for the label (shown in tooltip).
|
|
20
|
+
* @param labelOptional - Mark the label as optional.
|
|
21
|
+
* @returns A checkbox field component.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <CheckboxField name="isActive" label="Is Active" />
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const CheckboxField: {
|
|
29
|
+
<T extends FieldValues>({ name, label, disabled, required, className, labelInfo, labelOptional, }: Props<T>): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
displayName: string;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=CheckboxField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxField.d.ts","sourceRoot":"","sources":["../../../../src/components/form/fields/CheckboxField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAkB,MAAM,iBAAiB,CAAC;AAOpE,KAAK,KAAK,CAAC,CAAC,SAAS,WAAW,IAAI;IAClC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AAEH,eAAO,MAAM,aAAa;KAAI,CAAC,SAAS,WAAW,6EAQhD,KAAK,CAAC,CAAC,CAAC;;CAoDV,CAAC"}
|