pixel-react 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.prettierrc.js +13 -0
- package/.storybook/main.ts +26 -0
- package/.storybook/preview.ts +26 -0
- package/.yarn/install-state.gz +0 -0
- package/.yarnrc.yml +1 -0
- package/README.md +25 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/index.scss +0 -0
- package/lib/StyleGuide/ColorPalette/ColorPalette.d.ts +3 -0
- package/lib/StyleGuide/ColorPalette/ColorPalette.stories.d.ts +6 -0
- package/lib/StyleGuide/ColorPalette/colorPaletteList.d.ts +3 -0
- package/lib/StyleGuide/ColorPalette/index.d.ts +1 -0
- package/lib/StyleGuide/ColorPalette/types.d.ts +15 -0
- package/lib/StyleGuide/Typography/Typography.d.ts +3 -0
- package/lib/StyleGuide/Typography/Typography.stories.d.ts +6 -0
- package/lib/StyleGuide/Typography/TypographyList.d.ts +5 -0
- package/lib/StyleGuide/Typography/types.d.ts +8 -0
- package/lib/assets/utils/functionUtils.d.ts +1 -0
- package/lib/components/Accordion/Accordion.d.ts +8 -0
- package/lib/components/Accordion/Accordion.stories.d.ts +6 -0
- package/lib/components/Accordion/index.d.ts +1 -0
- package/lib/components/Accordion/types.d.ts +27 -0
- package/lib/components/AddResourceButton/AddButton.d.ts +4 -0
- package/lib/components/AddResourceButton/AddButton.stories.d.ts +8 -0
- package/lib/components/AddResourceButton/ArrowsButton/ArrowsButton.d.ts +6 -0
- package/lib/components/AddResourceButton/index.d.ts +1 -0
- package/lib/components/AddResourceButton/type.d.ts +65 -0
- package/lib/components/Button/Button.d.ts +5 -0
- package/lib/components/Button/Button.stories.d.ts +12 -0
- package/lib/components/Button/index.d.ts +1 -0
- package/lib/components/Button/types.d.ts +61 -0
- package/lib/components/Charts/DonutChart/DonutChart.d.ts +5 -0
- package/lib/components/Charts/DonutChart/DonutChart.stories.d.ts +6 -0
- package/lib/components/Charts/DonutChart/index.d.ts +1 -0
- package/lib/components/Charts/DonutChart/type.d.ts +13 -0
- package/lib/components/Charts/RadialChart/RadialChart.d.ts +5 -0
- package/lib/components/Charts/RadialChart/RadialChart.stories.d.ts +6 -0
- package/lib/components/Charts/RadialChart/index.d.ts +1 -0
- package/lib/components/Charts/RadialChart/types.d.ts +25 -0
- package/lib/components/Checkbox/Checkbox.d.ts +6 -0
- package/lib/components/Checkbox/Checkbox.stories.d.ts +8 -0
- package/lib/components/Checkbox/index.d.ts +1 -0
- package/lib/components/Checkbox/types.d.ts +30 -0
- package/lib/components/Chip/Chip.d.ts +4 -0
- package/lib/components/Chip/Chip.stories.d.ts +14 -0
- package/lib/components/Chip/index.d.ts +1 -0
- package/lib/components/Chip/types.d.ts +18 -0
- package/lib/components/Drawer/Drawer.d.ts +4 -0
- package/lib/components/Drawer/Drawer.stories.d.ts +7 -0
- package/lib/components/Drawer/Types.d.ts +85 -0
- package/lib/components/Drawer/index.d.ts +1 -0
- package/lib/components/ExpandableMenu/ExpandableMenu.d.ts +5 -0
- package/lib/components/ExpandableMenu/ExpandableMenu.stories.d.ts +7 -0
- package/lib/components/ExpandableMenu/index.d.ts +1 -0
- package/lib/components/ExpandableMenu/types.d.ts +34 -0
- package/lib/components/FileDropzone/Dropzone.d.ts +5 -0
- package/lib/components/FileDropzone/FileDropzone.d.ts +4 -0
- package/lib/components/FileDropzone/FileDropzone.stories.d.ts +8 -0
- package/lib/components/FileDropzone/FilePreview.d.ts +4 -0
- package/lib/components/FileDropzone/index.d.ts +1 -0
- package/lib/components/FileDropzone/types.d.ts +103 -0
- package/lib/components/Form/Form.d.ts +16 -0
- package/lib/components/Form/Form.stories.d.ts +6 -0
- package/lib/components/Form/index.d.ts +1 -0
- package/lib/components/Form/types.d.ts +1 -0
- package/lib/components/GridLayout/GridLayout.d.ts +6 -0
- package/lib/components/GridLayout/GridLayout.stories.d.ts +8 -0
- package/lib/components/GridLayout/index.d.ts +2 -0
- package/lib/components/GridLayout/types.d.ts +57 -0
- package/lib/components/HighlightText/HighlightText.d.ts +4 -0
- package/lib/components/HighlightText/HighlightText.stories.d.ts +6 -0
- package/lib/components/HighlightText/index.d.ts +1 -0
- package/lib/components/HighlightText/types.d.ts +4 -0
- package/lib/components/Icon/Icon.d.ts +4 -0
- package/lib/components/Icon/Icon.stories.d.ts +7 -0
- package/lib/components/Icon/iconList.d.ts +2 -0
- package/lib/components/Icon/index.d.ts +1 -0
- package/lib/components/Icon/types.d.ts +10 -0
- package/lib/components/Input/Input.d.ts +4 -0
- package/lib/components/Input/Input.stories.d.ts +9 -0
- package/lib/components/Input/index.d.ts +1 -0
- package/lib/components/Input/types.d.ts +74 -0
- package/lib/components/InputWithDropdown/InputWithDropdown.d.ts +4 -0
- package/lib/components/InputWithDropdown/InputWithDropdown.stories.d.ts +8 -0
- package/lib/components/InputWithDropdown/index.d.ts +1 -0
- package/lib/components/InputWithDropdown/types.d.ts +88 -0
- package/lib/components/LazyLoad/LazyLoad.d.ts +2 -0
- package/lib/components/LazyLoad/LazyLoad.stories.d.ts +6 -0
- package/lib/components/LazyLoad/LazyLoading.d.ts +2 -0
- package/lib/components/LazyLoad/index.d.ts +1 -0
- package/lib/components/MenuOption/MenuOption.d.ts +4 -0
- package/lib/components/MenuOption/MenuOption.stories.d.ts +15 -0
- package/lib/components/MenuOption/index.d.ts +1 -0
- package/lib/components/MenuOption/types.d.ts +134 -0
- package/lib/components/MiniModal/MiniModal.d.ts +4 -0
- package/lib/components/MiniModal/MiniModal.stories.d.ts +9 -0
- package/lib/components/MiniModal/index.d.ts +1 -0
- package/lib/components/MiniModal/types.d.ts +89 -0
- package/lib/components/MultiSelect/Dropdown.d.ts +4 -0
- package/lib/components/MultiSelect/MultiSelect.d.ts +4 -0
- package/lib/components/MultiSelect/MultiSelect.stories.d.ts +9 -0
- package/lib/components/MultiSelect/MultiSelectTypes.d.ts +18 -0
- package/lib/components/MultiSelect/dropdownTypes.d.ts +15 -0
- package/lib/components/MultiSelect/index.d.ts +1 -0
- package/lib/components/RadioButton/RadioButton.d.ts +4 -0
- package/lib/components/RadioButton/RadioButton.stories.d.ts +10 -0
- package/lib/components/RadioButton/index.d.ts +1 -0
- package/lib/components/RadioButton/radioButtonTypes.d.ts +35 -0
- package/lib/components/RadioGroup/RadioGroup.d.ts +4 -0
- package/lib/components/RadioGroup/RadioGroup.stories.d.ts +8 -0
- package/lib/components/RadioGroup/index.d.ts +1 -0
- package/lib/components/RadioGroup/radioGroupTypes.d.ts +47 -0
- package/lib/components/Search/Search.d.ts +4 -0
- package/lib/components/Search/Search.stories.d.ts +6 -0
- package/lib/components/Search/index.d.ts +1 -0
- package/lib/components/Search/types.d.ts +15 -0
- package/lib/components/Select/Select.d.ts +4 -0
- package/lib/components/Select/Select.stories.d.ts +13 -0
- package/lib/components/Select/components/Dropdown/Dropdown.d.ts +4 -0
- package/lib/components/Select/components/Dropdown/dropdownTypes.d.ts +15 -0
- package/lib/components/Select/index.d.ts +1 -0
- package/lib/components/Select/types.d.ts +68 -0
- package/lib/components/Table/Table.d.ts +4 -0
- package/lib/components/Table/Table.stories.d.ts +11 -0
- package/lib/components/Table/Types.d.ts +98 -0
- package/lib/components/Table/index.d.ts +1 -0
- package/lib/components/TableTree/TableTree.d.ts +21 -0
- package/lib/components/TableTree/TableTree.stories.d.ts +7 -0
- package/lib/components/TableTree/data.d.ts +313 -0
- package/lib/components/TableTree/index.d.ts +1 -0
- package/lib/components/Tabs/Tabs.d.ts +5 -0
- package/lib/components/Tabs/Tabs.stories.d.ts +8 -0
- package/lib/components/Tabs/index.d.ts +1 -0
- package/lib/components/Tabs/types.d.ts +40 -0
- package/lib/components/TextArea/Textarea.d.ts +4 -0
- package/lib/components/TextArea/Textarea.stories.d.ts +9 -0
- package/lib/components/TextArea/Types.d.ts +78 -0
- package/lib/components/TextArea/index.d.ts +1 -0
- package/lib/components/ThemeProvider/ThemeProvider.d.ts +7 -0
- package/lib/components/ThemeProvider/index.d.ts +1 -0
- package/lib/components/ThemeProvider/types.d.ts +11 -0
- package/lib/components/Toast/Toast.d.ts +5 -0
- package/lib/components/Toast/Toast.stories.d.ts +6 -0
- package/lib/components/Toast/index.d.ts +1 -0
- package/lib/components/Toast/types.d.ts +20 -0
- package/lib/components/Toggle/Toggle.d.ts +5 -0
- package/lib/components/Toggle/Toggle.stories.d.ts +12 -0
- package/lib/components/Toggle/index.d.ts +1 -0
- package/lib/components/Toggle/types.d.ts +50 -0
- package/lib/components/Tooltip/Tooltip.d.ts +5 -0
- package/lib/components/Tooltip/Tooltip.stories.d.ts +15 -0
- package/lib/components/Tooltip/index.d.ts +1 -0
- package/lib/components/Tooltip/types.d.ts +37 -0
- package/lib/components/Typography/Typography.d.ts +5 -0
- package/lib/components/Typography/Typography.stories.d.ts +10 -0
- package/lib/components/Typography/index.d.ts +1 -0
- package/lib/components/Typography/types.d.ts +47 -0
- package/lib/hooks/keyboardevents/useEscKeyEvent.d.ts +2 -0
- package/lib/hooks/useClickOutside.d.ts +2 -0
- package/lib/hooks/useFileDropzone.d.ts +3 -0
- package/lib/hooks/usePortalPosition.d.ts +9 -0
- package/lib/hooks/useTheme.d.ts +3 -0
- package/lib/index.css +404 -0
- package/lib/index.d.ts +1286 -0
- package/lib/index.esm.css +404 -0
- package/lib/index.esm.js +9317 -0
- package/lib/index.esm.js.map +1 -0
- package/lib/index.js +9376 -0
- package/lib/index.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/utils/TableCell/TableCell.d.ts +1 -0
- package/lib/utils/checkEmpty/checkEmpty.d.ts +3 -0
- package/lib/utils/checkEmpty/checkEmpty.stories.d.ts +6 -0
- package/lib/utils/ffID/ffID.stories.d.ts +6 -0
- package/lib/utils/ffID/ffid.d.ts +2 -0
- package/lib/utils/getExtension/getExtension.d.ts +4 -0
- package/lib/utils/getExtension/getExtension.stories.d.ts +6 -0
- package/lib/utils/truncateText/truncateText.d.ts +1 -0
- package/lib/utils/truncateText/truncateText.stories.d.ts +6 -0
- package/package.json +62 -0
- package/rollup.config.mjs +57 -0
- package/src/StyleGuide/ColorPalette/ColorPalette.scss +58 -0
- package/src/StyleGuide/ColorPalette/ColorPalette.stories.tsx +16 -0
- package/src/StyleGuide/ColorPalette/ColorPalette.tsx +61 -0
- package/src/StyleGuide/ColorPalette/colorPaletteList.ts +97 -0
- package/src/StyleGuide/ColorPalette/index.ts +1 -0
- package/src/StyleGuide/ColorPalette/types.ts +17 -0
- package/src/StyleGuide/Typography/Typography.scss +100 -0
- package/src/StyleGuide/Typography/Typography.stories.tsx +16 -0
- package/src/StyleGuide/Typography/Typography.tsx +60 -0
- package/src/StyleGuide/Typography/TypographyList.ts +3 -0
- package/src/StyleGuide/Typography/types.ts +9 -0
- package/src/assets/Themes/BaseTheme.scss +130 -0
- package/src/assets/Themes/DarkTheme.scss +131 -0
- package/src/assets/Themes/Theme.scss +200 -0
- package/src/assets/icons/Arrow.svg +5 -0
- package/src/assets/icons/accordion_header_icon.svg +10 -0
- package/src/assets/icons/arrow_down.svg +3 -0
- package/src/assets/icons/arrow_right.svg +5 -0
- package/src/assets/icons/arrow_up.svg +3 -0
- package/src/assets/icons/arrows_down_icon.svg +3 -0
- package/src/assets/icons/arrows_right_icon.svg +10 -0
- package/src/assets/icons/arrows_top_icon.svg +3 -0
- package/src/assets/icons/check_mark.svg +3 -0
- package/src/assets/icons/close_pill.svg +3 -0
- package/src/assets/icons/delete.svg +17 -0
- package/src/assets/icons/dropzone_icon.svg +18 -0
- package/src/assets/icons/error.svg +17 -0
- package/src/assets/icons/file.svg +12 -0
- package/src/assets/icons/info.svg +17 -0
- package/src/assets/icons/logo.svg +18 -0
- package/src/assets/icons/manage_apps.svg +3 -0
- package/src/assets/icons/moon_stars.svg +10 -0
- package/src/assets/icons/more.svg +11 -0
- package/src/assets/icons/plus_icon.svg +11 -0
- package/src/assets/icons/remove.svg +12 -0
- package/src/assets/icons/replace.svg +12 -0
- package/src/assets/icons/search.svg +3 -0
- package/src/assets/icons/success.svg +13 -0
- package/src/assets/icons/sun_icon.svg +10 -0
- package/src/assets/icons/tick_icon.svg +5 -0
- package/src/assets/icons/toast_close.svg +3 -0
- package/src/assets/icons/warning.svg +17 -0
- package/src/assets/icons/wrong_mark.svg +3 -0
- package/src/assets/styles/_colors.scss +145 -0
- package/src/assets/styles/_fonts.scss +68 -0
- package/src/assets/styles/_mixins.scss +20 -0
- package/src/assets/utils/functionUtils.ts +5 -0
- package/src/components/Accordion/Accordion.scss +45 -0
- package/src/components/Accordion/Accordion.stories.tsx +31 -0
- package/src/components/Accordion/Accordion.tsx +62 -0
- package/src/components/Accordion/index.ts +1 -0
- package/src/components/Accordion/types.ts +28 -0
- package/src/components/AddResourceButton/AddButton.scss +36 -0
- package/src/components/AddResourceButton/AddButton.stories.tsx +126 -0
- package/src/components/AddResourceButton/AddButton.tsx +121 -0
- package/src/components/AddResourceButton/ArrowsButton/ArrowsButton.scss +160 -0
- package/src/components/AddResourceButton/ArrowsButton/ArrowsButton.tsx +38 -0
- package/src/components/AddResourceButton/index.ts +1 -0
- package/src/components/AddResourceButton/type.ts +60 -0
- package/src/components/Button/Button.scss +148 -0
- package/src/components/Button/Button.stories.tsx +74 -0
- package/src/components/Button/Button.tsx +66 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Button/types.ts +65 -0
- package/src/components/Charts/DonutChart/DonutChart.scss +76 -0
- package/src/components/Charts/DonutChart/DonutChart.stories.tsx +30 -0
- package/src/components/Charts/DonutChart/DonutChart.tsx +241 -0
- package/src/components/Charts/DonutChart/index.ts +1 -0
- package/src/components/Charts/DonutChart/type.ts +23 -0
- package/src/components/Charts/RadialChart/RadialChart.scss +12 -0
- package/src/components/Charts/RadialChart/RadialChart.stories.tsx +36 -0
- package/src/components/Charts/RadialChart/RadialChart.tsx +174 -0
- package/src/components/Charts/RadialChart/index.ts +1 -0
- package/src/components/Charts/RadialChart/types.ts +32 -0
- package/src/components/Checkbox/Checkbox.scss +89 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +47 -0
- package/src/components/Checkbox/Checkbox.tsx +61 -0
- package/src/components/Checkbox/index.ts +1 -0
- package/src/components/Checkbox/types.ts +30 -0
- package/src/components/Chip/Chip.scss +70 -0
- package/src/components/Chip/Chip.stories.tsx +88 -0
- package/src/components/Chip/Chip.tsx +35 -0
- package/src/components/Chip/index.ts +1 -0
- package/src/components/Chip/types.ts +19 -0
- package/src/components/Drawer/Drawer.scss +121 -0
- package/src/components/Drawer/Drawer.stories.tsx +88 -0
- package/src/components/Drawer/Drawer.tsx +179 -0
- package/src/components/Drawer/Types.ts +88 -0
- package/src/components/Drawer/index.ts +1 -0
- package/src/components/ExpandableMenu/ExpandableMenu.scss +110 -0
- package/src/components/ExpandableMenu/ExpandableMenu.stories.tsx +67 -0
- package/src/components/ExpandableMenu/ExpandableMenu.tsx +101 -0
- package/src/components/ExpandableMenu/index.ts +1 -0
- package/src/components/ExpandableMenu/types.ts +34 -0
- package/src/components/FileDropzone/Dropzone.tsx +55 -0
- package/src/components/FileDropzone/FileDropzone.scss +134 -0
- package/src/components/FileDropzone/FileDropzone.stories.tsx +83 -0
- package/src/components/FileDropzone/FileDropzone.tsx +98 -0
- package/src/components/FileDropzone/FilePreview.tsx +75 -0
- package/src/components/FileDropzone/index.ts +1 -0
- package/src/components/FileDropzone/types.ts +113 -0
- package/src/components/Form/Form.scss +98 -0
- package/src/components/Form/Form.stories.tsx +177 -0
- package/src/components/Form/Form.tsx +57 -0
- package/src/components/Form/index.ts +1 -0
- package/src/components/Form/types.ts +1 -0
- package/src/components/Form/validation.json +29 -0
- package/src/components/GridLayout/GridLayout.scss +71 -0
- package/src/components/GridLayout/GridLayout.stories.tsx +128 -0
- package/src/components/GridLayout/GridLayout.tsx +30 -0
- package/src/components/GridLayout/GridLayoutStory.scss +25 -0
- package/src/components/GridLayout/index.ts +1 -0
- package/src/components/GridLayout/types.ts +64 -0
- package/src/components/HighlightText/HighlightText.scss +3 -0
- package/src/components/HighlightText/HighlightText.stories.tsx +22 -0
- package/src/components/HighlightText/HighlightText.tsx +33 -0
- package/src/components/HighlightText/index.ts +1 -0
- package/src/components/HighlightText/types.ts +4 -0
- package/src/components/Icon/Icon.stories.tsx +37 -0
- package/src/components/Icon/Icon.tsx +43 -0
- package/src/components/Icon/Icons.scss +34 -0
- package/src/components/Icon/iconList.ts +62 -0
- package/src/components/Icon/index.ts +1 -0
- package/src/components/Icon/types.ts +10 -0
- package/src/components/Input/Input.scss +150 -0
- package/src/components/Input/Input.stories.tsx +96 -0
- package/src/components/Input/Input.tsx +93 -0
- package/src/components/Input/index.ts +1 -0
- package/src/components/Input/types.ts +77 -0
- package/src/components/InputWithDropdown/InputWithDropdown.scss +185 -0
- package/src/components/InputWithDropdown/InputWithDropdown.stories.tsx +114 -0
- package/src/components/InputWithDropdown/InputWithDropdown.tsx +85 -0
- package/src/components/InputWithDropdown/index.ts +1 -0
- package/src/components/InputWithDropdown/types.ts +110 -0
- package/src/components/LazyLoad/LazyLoad.d.ts +3 -0
- package/src/components/LazyLoad/LazyLoad.stories.tsx +33 -0
- package/src/components/LazyLoad/LazyLoad.ts +2 -0
- package/src/components/LazyLoad/LazyLoading.tsx +19 -0
- package/src/components/LazyLoad/index.ts +1 -0
- package/src/components/MenuOption/MenuOption.scss +69 -0
- package/src/components/MenuOption/MenuOption.stories.tsx +259 -0
- package/src/components/MenuOption/MenuOption.tsx +126 -0
- package/src/components/MenuOption/index.ts +1 -0
- package/src/components/MenuOption/types.ts +161 -0
- package/src/components/MiniModal/MiniModal.scss +139 -0
- package/src/components/MiniModal/MiniModal.stories.tsx +475 -0
- package/src/components/MiniModal/MiniModal.tsx +218 -0
- package/src/components/MiniModal/index.ts +1 -0
- package/src/components/MiniModal/types.ts +88 -0
- package/src/components/MultiSelect/Dropdown.scss +66 -0
- package/src/components/MultiSelect/Dropdown.tsx +77 -0
- package/src/components/MultiSelect/MultiSelect.scss +190 -0
- package/src/components/MultiSelect/MultiSelect.stories.tsx +85 -0
- package/src/components/MultiSelect/MultiSelect.tsx +260 -0
- package/src/components/MultiSelect/MultiSelectTypes.ts +19 -0
- package/src/components/MultiSelect/dropdownTypes.ts +15 -0
- package/src/components/MultiSelect/index.ts +1 -0
- package/src/components/RadioButton/RadioButton.scss +99 -0
- package/src/components/RadioButton/RadioButton.stories.tsx +43 -0
- package/src/components/RadioButton/RadioButton.tsx +32 -0
- package/src/components/RadioButton/index.ts +1 -0
- package/src/components/RadioButton/radioButtonTypes.tsx +40 -0
- package/src/components/RadioGroup/RadioGroup.scss +5 -0
- package/src/components/RadioGroup/RadioGroup.stories.tsx +81 -0
- package/src/components/RadioGroup/RadioGroup.tsx +30 -0
- package/src/components/RadioGroup/index.ts +1 -0
- package/src/components/RadioGroup/radioGroupTypes.tsx +54 -0
- package/src/components/Search/Search.scss +87 -0
- package/src/components/Search/Search.stories.tsx +26 -0
- package/src/components/Search/Search.tsx +103 -0
- package/src/components/Search/index.ts +1 -0
- package/src/components/Search/types.ts +15 -0
- package/src/components/Select/Select.scss +247 -0
- package/src/components/Select/Select.stories.tsx +156 -0
- package/src/components/Select/Select.tsx +368 -0
- package/src/components/Select/components/Dropdown/Dropdown.scss +70 -0
- package/src/components/Select/components/Dropdown/Dropdown.tsx +89 -0
- package/src/components/Select/components/Dropdown/dropdownTypes.ts +19 -0
- package/src/components/Select/index.ts +1 -0
- package/src/components/Select/types.ts +122 -0
- package/src/components/Table/Table.scss +101 -0
- package/src/components/Table/Table.stories.tsx +345 -0
- package/src/components/Table/Table.tsx +128 -0
- package/src/components/Table/Types.ts +100 -0
- package/src/components/Table/index.ts +1 -0
- package/src/components/TableTree/TableTree.scss +142 -0
- package/src/components/TableTree/TableTree.stories.tsx +121 -0
- package/src/components/TableTree/TableTree.tsx +216 -0
- package/src/components/TableTree/TableTreeStories.scss +22 -0
- package/src/components/TableTree/data.ts +573 -0
- package/src/components/TableTree/index.ts +1 -0
- package/src/components/Tabs/Tabs.scss +76 -0
- package/src/components/Tabs/Tabs.stories.tsx +104 -0
- package/src/components/Tabs/Tabs.tsx +64 -0
- package/src/components/Tabs/index.ts +1 -0
- package/src/components/Tabs/types.ts +38 -0
- package/src/components/TextArea/Textarea.scss +145 -0
- package/src/components/TextArea/Textarea.stories.tsx +92 -0
- package/src/components/TextArea/Textarea.tsx +84 -0
- package/src/components/TextArea/Types.ts +82 -0
- package/src/components/TextArea/index.tsx +1 -0
- package/src/components/ThemeProvider/ThemeProvider.tsx +24 -0
- package/src/components/ThemeProvider/index.ts +1 -0
- package/src/components/ThemeProvider/types.ts +14 -0
- package/src/components/Toast/Toast.scss +121 -0
- package/src/components/Toast/Toast.stories.tsx +180 -0
- package/src/components/Toast/Toast.tsx +116 -0
- package/src/components/Toast/index.ts +1 -0
- package/src/components/Toast/types.ts +27 -0
- package/src/components/Toggle/Toggle.scss +132 -0
- package/src/components/Toggle/Toggle.stories.tsx +132 -0
- package/src/components/Toggle/Toggle.tsx +96 -0
- package/src/components/Toggle/index.ts +1 -0
- package/src/components/Toggle/types.ts +43 -0
- package/src/components/Tooltip/Tooltip.scss +27 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +97 -0
- package/src/components/Tooltip/Tooltip.tsx +194 -0
- package/src/components/Tooltip/index.ts +1 -0
- package/src/components/Tooltip/types.ts +60 -0
- package/src/components/Typography/Typography.scss +49 -0
- package/src/components/Typography/Typography.stories.tsx +57 -0
- package/src/components/Typography/Typography.tsx +39 -0
- package/src/components/Typography/index.ts +1 -0
- package/src/components/Typography/types.ts +56 -0
- package/src/fonts/Montserrat/Montserrat-Medium.ttf +0 -0
- package/src/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/src/fonts/Montserrat/Montserrat-SemiBold.ttf +0 -0
- package/src/fonts/Poppins/Poppins-Black.ttf +0 -0
- package/src/fonts/Poppins/Poppins-BlackItalic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-Bold.ttf +0 -0
- package/src/fonts/Poppins/Poppins-BoldItalic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-ExtraBold.ttf +0 -0
- package/src/fonts/Poppins/Poppins-ExtraBoldItalic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-ExtraLight.ttf +0 -0
- package/src/fonts/Poppins/Poppins-ExtraLightItalic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-Italic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-Light.ttf +0 -0
- package/src/fonts/Poppins/Poppins-LightItalic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-Medium.ttf +0 -0
- package/src/fonts/Poppins/Poppins-MediumItalic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-Regular.ttf +0 -0
- package/src/fonts/Poppins/Poppins-SemiBold.ttf +0 -0
- package/src/fonts/Poppins/Poppins-SemiBoldItalic.ttf +0 -0
- package/src/fonts/Poppins/Poppins-Thin.ttf +0 -0
- package/src/fonts/Poppins/Poppins-ThinItalic.ttf +0 -0
- package/src/hooks/keyboardevents/useEscKeyEvent.tsx +31 -0
- package/src/hooks/useClickOutside.tsx +30 -0
- package/src/hooks/useFileDropzone.tsx +273 -0
- package/src/hooks/usePortalPosition.tsx +53 -0
- package/src/hooks/useTheme.tsx +13 -0
- package/src/index.ts +91 -0
- package/src/utils/TableCell/TableCell.ts +16 -0
- package/src/utils/checkEmpty/checkEmpty.stories.tsx +34 -0
- package/src/utils/checkEmpty/checkEmpty.ts +10 -0
- package/src/utils/ffID/ffID.stories.tsx +35 -0
- package/src/utils/ffID/ffid.ts +9 -0
- package/src/utils/getExtension/getExtension.stories.tsx +23 -0
- package/src/utils/getExtension/getExtension.ts +28 -0
- package/src/utils/truncateText/truncateText.stories.tsx +37 -0
- package/src/utils/truncateText/truncateText.ts +4 -0
- package/tsconfig.json +55 -0
- package/ui-library.zip +0 -0
- package/vite.config.js +30 -0
@@ -0,0 +1,98 @@
|
|
1
|
+
import useFileDropzone from '../../hooks/useFileDropzone';
|
2
|
+
import { FileDropzoneProps } from './types';
|
3
|
+
import './FileDropzone.scss';
|
4
|
+
import Icon from '../Icon';
|
5
|
+
import { checkEmpty } from '../../utils/checkEmpty/checkEmpty';
|
6
|
+
import { useMemo } from 'react';
|
7
|
+
import Dropzone from './Dropzone';
|
8
|
+
import FilePreview from './FilePreview';
|
9
|
+
|
10
|
+
const FileDropzone: React.FC<FileDropzoneProps> = ({
|
11
|
+
icon = <Icon name="dropzone_icon" height={80} width={80} />,
|
12
|
+
primaryLabel = 'Drag & drop your file to upload',
|
13
|
+
secondaryLabel = 'Or',
|
14
|
+
buttonLabel = 'Choose File to upload',
|
15
|
+
accept = [],
|
16
|
+
multiple = false,
|
17
|
+
maxFiles,
|
18
|
+
maxSize,
|
19
|
+
onMaxFilesError,
|
20
|
+
maxSizeErrorMessage = '',
|
21
|
+
invalidFileMessage = '',
|
22
|
+
fileExistMessage = '',
|
23
|
+
validateMIMEType = false,
|
24
|
+
}) => {
|
25
|
+
const {
|
26
|
+
getRootProps,
|
27
|
+
getInputProps,
|
28
|
+
acceptedFiles,
|
29
|
+
rejectedFiles,
|
30
|
+
isDragActive,
|
31
|
+
handleRemoveClick,
|
32
|
+
handleReplaceClick,
|
33
|
+
} = useFileDropzone({
|
34
|
+
accept,
|
35
|
+
multiple,
|
36
|
+
maxFiles,
|
37
|
+
maxSize,
|
38
|
+
onMaxFilesError,
|
39
|
+
maxSizeErrorMessage,
|
40
|
+
invalidFileMessage,
|
41
|
+
fileExistMessage,
|
42
|
+
validateMIMEType,
|
43
|
+
// onDrop: (accepted, rejected, event) => {}, //onDrop function to handle dropped or selected files explicitly.
|
44
|
+
});
|
45
|
+
|
46
|
+
const acceptedFilesList = useMemo(
|
47
|
+
() =>
|
48
|
+
acceptedFiles.map((file) => (
|
49
|
+
<FilePreview
|
50
|
+
key={file.name}
|
51
|
+
file={file}
|
52
|
+
onRemoveClick={handleRemoveClick}
|
53
|
+
onReplaceClick={handleReplaceClick}
|
54
|
+
/>
|
55
|
+
)),
|
56
|
+
[acceptedFiles, handleRemoveClick, handleReplaceClick]
|
57
|
+
);
|
58
|
+
|
59
|
+
const rejectedFilesList = useMemo(
|
60
|
+
() =>
|
61
|
+
rejectedFiles.map((rejectedFile) => (
|
62
|
+
<FilePreview
|
63
|
+
key={rejectedFile.file.name}
|
64
|
+
file={rejectedFile.file}
|
65
|
+
error={rejectedFile.errors[0]?.message}
|
66
|
+
onRemoveClick={handleRemoveClick}
|
67
|
+
onReplaceClick={handleReplaceClick}
|
68
|
+
/>
|
69
|
+
)),
|
70
|
+
[rejectedFiles, handleRemoveClick, handleReplaceClick]
|
71
|
+
);
|
72
|
+
|
73
|
+
return (
|
74
|
+
<div className="ff-file-dropzone-wrapper">
|
75
|
+
<Dropzone
|
76
|
+
icon={icon}
|
77
|
+
primaryLabel={primaryLabel}
|
78
|
+
secondaryLabel={secondaryLabel}
|
79
|
+
buttonLabel={buttonLabel}
|
80
|
+
getRootProps={getRootProps}
|
81
|
+
getInputProps={getInputProps}
|
82
|
+
isDragActive={isDragActive}
|
83
|
+
/>
|
84
|
+
|
85
|
+
<div className={'ff-file-details-wrapper'}>
|
86
|
+
{!checkEmpty(acceptedFiles) && (
|
87
|
+
<div className="ff-file-details">{acceptedFilesList}</div>
|
88
|
+
)}
|
89
|
+
|
90
|
+
{!checkEmpty(rejectedFiles) && (
|
91
|
+
<div className="ff-file-details">{rejectedFilesList}</div>
|
92
|
+
)}
|
93
|
+
</div>
|
94
|
+
</div>
|
95
|
+
);
|
96
|
+
};
|
97
|
+
|
98
|
+
export default FileDropzone;
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import './FileDropzone.scss';
|
2
|
+
import Icon from '../Icon';
|
3
|
+
import Tooltip from '../Tooltip';
|
4
|
+
import { FilePreviewProps } from './types';
|
5
|
+
import Typography from '../Typography';
|
6
|
+
|
7
|
+
const FilePreview: React.FC<FilePreviewProps> = ({
|
8
|
+
file,
|
9
|
+
error,
|
10
|
+
onRemoveClick,
|
11
|
+
onReplaceClick,
|
12
|
+
}) => {
|
13
|
+
return (
|
14
|
+
<div key={file.name} className="ff-file-details__item">
|
15
|
+
<div className="ff-file-info">
|
16
|
+
<div className="ff-file-info__icon">
|
17
|
+
<Icon
|
18
|
+
name="file"
|
19
|
+
color={'var(--icons-default-color)'}
|
20
|
+
height={16}
|
21
|
+
width={16}
|
22
|
+
/>
|
23
|
+
</div>
|
24
|
+
<div className="ff-file-info__name-wrapper">
|
25
|
+
<Tooltip title={file?.name}>
|
26
|
+
<Typography
|
27
|
+
lineHeight="18px"
|
28
|
+
fontWeight="semi-bold"
|
29
|
+
color={'var(--text-color)'}
|
30
|
+
className="ff-file-info__name-wrapper__name"
|
31
|
+
>
|
32
|
+
{file?.name}
|
33
|
+
</Typography>
|
34
|
+
</Tooltip>
|
35
|
+
{error && (
|
36
|
+
<Typography
|
37
|
+
fontSize={8}
|
38
|
+
color={'var(--error-light)'}
|
39
|
+
lineHeight="12px"
|
40
|
+
letterSpacing="0.5px"
|
41
|
+
>
|
42
|
+
{error}
|
43
|
+
</Typography>
|
44
|
+
)}
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
<div className="ff-file-actions">
|
48
|
+
<div className="ff-file-actions__icon-replace">
|
49
|
+
<Tooltip title="Replace">
|
50
|
+
<Icon
|
51
|
+
name="replace"
|
52
|
+
color={'var(--icons-default-color)'}
|
53
|
+
height={16}
|
54
|
+
width={16}
|
55
|
+
onClick={() => onReplaceClick(file)}
|
56
|
+
/>
|
57
|
+
</Tooltip>
|
58
|
+
</div>
|
59
|
+
<div className="ff-file-actions__icon-remove">
|
60
|
+
<Tooltip title="Remove">
|
61
|
+
<Icon
|
62
|
+
name="remove"
|
63
|
+
height={16}
|
64
|
+
width={16}
|
65
|
+
color={'var(--default-icon-color)'}
|
66
|
+
onClick={() => onRemoveClick(file)}
|
67
|
+
/>
|
68
|
+
</Tooltip>
|
69
|
+
</div>
|
70
|
+
</div>
|
71
|
+
</div>
|
72
|
+
);
|
73
|
+
};
|
74
|
+
|
75
|
+
export default FilePreview;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './FileDropzone';
|
@@ -0,0 +1,113 @@
|
|
1
|
+
import { ReactNode } from 'react';
|
2
|
+
|
3
|
+
export interface FileDropzoneProps {
|
4
|
+
/**
|
5
|
+
* Icon to be displayed in the dropzone.
|
6
|
+
**/
|
7
|
+
icon?: ReactNode;
|
8
|
+
/**
|
9
|
+
* Primary label to be shown in dropzone area
|
10
|
+
**/
|
11
|
+
primaryLabel?: string;
|
12
|
+
/**
|
13
|
+
* Secondary label to be shown
|
14
|
+
**/
|
15
|
+
secondaryLabel?: string;
|
16
|
+
/**
|
17
|
+
* Label to be shown in choose file/input button.
|
18
|
+
**/
|
19
|
+
buttonLabel?: string;
|
20
|
+
/**
|
21
|
+
* . extension needs to be passed to allow the type of file to add or MIME type to be validate MIME type
|
22
|
+
**/
|
23
|
+
accept: string[];
|
24
|
+
/**
|
25
|
+
* To allow multiple selection or drop of files.
|
26
|
+
**/
|
27
|
+
multiple?: boolean;
|
28
|
+
/**
|
29
|
+
* Maximum files to be dropped or selected at once.
|
30
|
+
**/
|
31
|
+
maxFiles?: number;
|
32
|
+
/**
|
33
|
+
* Maximum size of the file in numbers.
|
34
|
+
**/
|
35
|
+
maxSize?: number;
|
36
|
+
/**
|
37
|
+
* Function with state to get the boolean value when the maxFiles is less than dropped files.
|
38
|
+
**/
|
39
|
+
onMaxFilesError?: () => void;
|
40
|
+
/**
|
41
|
+
* To show error message if file size exceeds the max size
|
42
|
+
**/
|
43
|
+
maxSizeErrorMessage?: string;
|
44
|
+
/**
|
45
|
+
* To show error message if file is not of accepted file type
|
46
|
+
**/
|
47
|
+
invalidFileMessage?: string;
|
48
|
+
/**
|
49
|
+
* To show error message if file already exist with same name and type
|
50
|
+
**/
|
51
|
+
fileExistMessage?: string;
|
52
|
+
/**
|
53
|
+
* To validate file type based on MIME type but mandatorily need to pass MIME type in accept props
|
54
|
+
**/
|
55
|
+
validateMIMEType?: boolean;
|
56
|
+
}
|
57
|
+
export interface FileState {
|
58
|
+
accepted: File[];
|
59
|
+
rejected: FileRejection[];
|
60
|
+
}
|
61
|
+
export interface FileError {
|
62
|
+
message: string;
|
63
|
+
code: string;
|
64
|
+
}
|
65
|
+
|
66
|
+
export interface FileRejection {
|
67
|
+
file: File;
|
68
|
+
errors: FileError[];
|
69
|
+
}
|
70
|
+
|
71
|
+
export interface DropzoneOptions {
|
72
|
+
accept: string[];
|
73
|
+
multiple?: boolean;
|
74
|
+
maxSize?: number;
|
75
|
+
maxFiles?: number | undefined;
|
76
|
+
onDrop?: (
|
77
|
+
acceptedFiles: File[],
|
78
|
+
rejectedFiles: FileRejection[],
|
79
|
+
event: React.DragEvent<HTMLElement> | React.ChangeEvent<HTMLInputElement>
|
80
|
+
) => void;
|
81
|
+
onMaxFilesError?: () => void;
|
82
|
+
maxSizeErrorMessage?: string;
|
83
|
+
invalidFileMessage?: string;
|
84
|
+
fileExistMessage?: string;
|
85
|
+
validateMIMEType?: boolean;
|
86
|
+
}
|
87
|
+
|
88
|
+
export interface DropzoneState {
|
89
|
+
getRootProps: () => React.HTMLAttributes<HTMLElement>;
|
90
|
+
getInputProps: () => React.InputHTMLAttributes<HTMLInputElement>;
|
91
|
+
acceptedFiles: File[];
|
92
|
+
rejectedFiles: FileRejection[];
|
93
|
+
isDragActive: boolean;
|
94
|
+
handleRemoveClick: (file: File) => void;
|
95
|
+
handleReplaceClick: (file: File) => void;
|
96
|
+
}
|
97
|
+
|
98
|
+
export interface DroppableProps {
|
99
|
+
icon: React.ReactNode;
|
100
|
+
primaryLabel: string;
|
101
|
+
secondaryLabel: string;
|
102
|
+
buttonLabel: string;
|
103
|
+
getRootProps: () => any;
|
104
|
+
getInputProps: () => any;
|
105
|
+
isDragActive: boolean;
|
106
|
+
}
|
107
|
+
|
108
|
+
export interface FilePreviewProps {
|
109
|
+
file: File;
|
110
|
+
error?: string;
|
111
|
+
onRemoveClick: (file: File) => void;
|
112
|
+
onReplaceClick: (file: File) => void;
|
113
|
+
}
|
@@ -0,0 +1,98 @@
|
|
1
|
+
@use '../../assets/styles/fonts';
|
2
|
+
|
3
|
+
.ff-form-container {
|
4
|
+
@extend .fontSm;
|
5
|
+
background-color: var(--hover-color);
|
6
|
+
border: 1px solid var(--arrows-button-border-color);
|
7
|
+
border-radius: 8px;
|
8
|
+
padding: 20px;
|
9
|
+
width: 400px;
|
10
|
+
margin: 0 auto;
|
11
|
+
|
12
|
+
.ff-form-group {
|
13
|
+
margin-bottom: 16px;
|
14
|
+
|
15
|
+
.ff-label {
|
16
|
+
display: block;
|
17
|
+
margin-bottom: 4px;
|
18
|
+
font-weight: bold;
|
19
|
+
}
|
20
|
+
|
21
|
+
input {
|
22
|
+
width: 94%;
|
23
|
+
padding: 10px;
|
24
|
+
border: 1px solid var(--arrows-button-border-color);
|
25
|
+
border-radius: 8px;
|
26
|
+
&:focus {
|
27
|
+
border-color: var(--brand-color);
|
28
|
+
}
|
29
|
+
&.ff-error {
|
30
|
+
border-color: var(--ff-error-light);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
.ff-error {
|
34
|
+
color: var(--error-light);
|
35
|
+
margin-top: 4px;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
.ff-form-group {
|
39
|
+
margin-bottom: 16px;
|
40
|
+
.ff-label {
|
41
|
+
display: block;
|
42
|
+
margin-bottom: 4px;
|
43
|
+
font-weight: bold;
|
44
|
+
}
|
45
|
+
input,
|
46
|
+
select {
|
47
|
+
width: 94%;
|
48
|
+
padding: 10px;
|
49
|
+
border: 1px solid var(--arrows-button-border-color);
|
50
|
+
border-radius: 8px;
|
51
|
+
&:focus {
|
52
|
+
border-color: var(--brand-color);
|
53
|
+
}
|
54
|
+
&.ff-error {
|
55
|
+
border-color: var(--ff-error-light); // Ensure red border color
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
.ff-form-radio-group {
|
61
|
+
display: flex;
|
62
|
+
flex-direction: column;
|
63
|
+
gap: 1rem;
|
64
|
+
margin-bottom: 16px;
|
65
|
+
.ff-radio-group-wrapper{
|
66
|
+
display: flex;
|
67
|
+
}
|
68
|
+
.ff-radio-gender {
|
69
|
+
display: flex;
|
70
|
+
flex-direction: column;
|
71
|
+
align-items: center;
|
72
|
+
|
73
|
+
input[type="radio"] {
|
74
|
+
margin-right: 0.5rem;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
.ff-error {
|
78
|
+
padding-left: 12px;
|
79
|
+
color: var(--error-light);
|
80
|
+
margin-top: 4px;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
.ff-button-layout {
|
84
|
+
width: 99%;
|
85
|
+
display: flex;
|
86
|
+
gap: 12px;
|
87
|
+
margin-top: 24px;
|
88
|
+
button {
|
89
|
+
width: 50%;
|
90
|
+
background-color: var(--brand-color);
|
91
|
+
color: var(--primary-button-text-color);
|
92
|
+
border: none;
|
93
|
+
border-radius: 8px;
|
94
|
+
padding: 10px;
|
95
|
+
cursor: pointer;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
@@ -0,0 +1,177 @@
|
|
1
|
+
import { useState } from 'react';
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
3
|
+
import Form from './Form';
|
4
|
+
import validationRules from './validation.json';
|
5
|
+
import { FormValues } from './types';
|
6
|
+
import Typography from '../Typography';
|
7
|
+
|
8
|
+
const meta: Meta<typeof Form> = {
|
9
|
+
title: 'Components/Form',
|
10
|
+
component: Form,
|
11
|
+
parameters: {
|
12
|
+
layout: 'centered',
|
13
|
+
},
|
14
|
+
tags: ['autodocs'],
|
15
|
+
};
|
16
|
+
|
17
|
+
type Story = StoryObj<typeof Form>;
|
18
|
+
|
19
|
+
export const WithControlledState: Story = {
|
20
|
+
render: () => {
|
21
|
+
const initialFormState: FormValues = {
|
22
|
+
username: '',
|
23
|
+
email: '',
|
24
|
+
password: '',
|
25
|
+
gender: '',
|
26
|
+
language: '',
|
27
|
+
};
|
28
|
+
|
29
|
+
const [formData, setFormData] = useState<FormValues>(initialFormState);
|
30
|
+
|
31
|
+
const handleSubmit = (data: FormValues) => {
|
32
|
+
setFormData(data);
|
33
|
+
alert('Form submitted with: ' + JSON.stringify(data));
|
34
|
+
};
|
35
|
+
|
36
|
+
const handleReset = (
|
37
|
+
setValue: (field: keyof FormValues, value: any) => void
|
38
|
+
) => {
|
39
|
+
Object.keys(initialFormState).forEach((field) => {
|
40
|
+
setValue(
|
41
|
+
field as keyof FormValues,
|
42
|
+
initialFormState[field as keyof FormValues]
|
43
|
+
);
|
44
|
+
});
|
45
|
+
setFormData(initialFormState);
|
46
|
+
};
|
47
|
+
|
48
|
+
return (
|
49
|
+
<div className="ff-form-container">
|
50
|
+
<Form<FormValues> onSubmit={handleSubmit}>
|
51
|
+
{(
|
52
|
+
{ register, errors, handleBlur, setValue } // Include setValue here
|
53
|
+
) => (
|
54
|
+
<>
|
55
|
+
{['username', 'email', 'password'].map((field) => (
|
56
|
+
<div className="ff-form-group" key={field}>
|
57
|
+
<Typography as="label">
|
58
|
+
{field.charAt(0).toUpperCase() + field.slice(1)}
|
59
|
+
</Typography>
|
60
|
+
<input
|
61
|
+
id={field}
|
62
|
+
type={
|
63
|
+
field === 'email'
|
64
|
+
? 'email'
|
65
|
+
: field === 'password'
|
66
|
+
? 'password'
|
67
|
+
: 'text'
|
68
|
+
}
|
69
|
+
{...register(field as keyof FormValues, {
|
70
|
+
...validationRules[field as keyof typeof validationRules],
|
71
|
+
onChange: (e: any) => {
|
72
|
+
const value = e.target.value;
|
73
|
+
setFormData((prev) => ({
|
74
|
+
...prev,
|
75
|
+
[field]: value,
|
76
|
+
}));
|
77
|
+
if (errors[field as keyof FormValues]?.message) {
|
78
|
+
handleBlur(field as keyof FormValues);
|
79
|
+
}
|
80
|
+
},
|
81
|
+
})}
|
82
|
+
className={
|
83
|
+
errors[field as keyof FormValues] ? 'ff-error' : ''
|
84
|
+
}
|
85
|
+
onBlur={() => handleBlur(field as keyof FormValues)}
|
86
|
+
/>
|
87
|
+
{errors[field as keyof FormValues]?.message && (
|
88
|
+
<span className="ff-error">
|
89
|
+
{String(errors[field as keyof FormValues]?.message)}
|
90
|
+
</span>
|
91
|
+
)}
|
92
|
+
</div>
|
93
|
+
))}
|
94
|
+
|
95
|
+
{/* Gender Radio Input */}
|
96
|
+
<div className="ff-form-radio-group">
|
97
|
+
<Typography as="label"> Gender </Typography>
|
98
|
+
<div className='ff-radio-group-wrapper'>
|
99
|
+
{['Male', 'Female', 'Other'].map((gender) => (
|
100
|
+
<div className="ff-radio-gender" key={gender}>
|
101
|
+
<Typography as="label">
|
102
|
+
<input
|
103
|
+
type="radio"
|
104
|
+
value={gender}
|
105
|
+
{...register('gender', validationRules.gender)}
|
106
|
+
checked={formData.gender === gender}
|
107
|
+
onChange={() =>
|
108
|
+
setFormData((prev) => ({ ...prev, gender }))
|
109
|
+
}
|
110
|
+
onBlur={() => handleBlur('gender')}
|
111
|
+
/>
|
112
|
+
{gender}
|
113
|
+
</Typography>
|
114
|
+
</div>
|
115
|
+
))}
|
116
|
+
{errors.gender?.message && (
|
117
|
+
<span className="ff-error">
|
118
|
+
{String(errors.gender.message)}
|
119
|
+
</span>
|
120
|
+
)}
|
121
|
+
</div>
|
122
|
+
</div>
|
123
|
+
|
124
|
+
{/* Language Select Dropdown */}
|
125
|
+
<div className="ff-form-group">
|
126
|
+
<Typography as='label'>Programming Language</Typography>
|
127
|
+
<select
|
128
|
+
id="language"
|
129
|
+
{...register('language', validationRules.language)}
|
130
|
+
onBlur={() => handleBlur('language')}
|
131
|
+
className={errors.language ? 'ff-error' : ''}
|
132
|
+
value={formData.language}
|
133
|
+
onChange={(e) => {
|
134
|
+
const value = e.target.value;
|
135
|
+
setFormData((prev) => ({
|
136
|
+
...prev,
|
137
|
+
language: value,
|
138
|
+
}));
|
139
|
+
if (value) {
|
140
|
+
setValue('language', value);
|
141
|
+
}
|
142
|
+
}}
|
143
|
+
>
|
144
|
+
<option value="">Select a language</option>
|
145
|
+
{['Java', 'Rust', 'Dart'].map((lang) => (
|
146
|
+
<option key={lang} value={lang}>
|
147
|
+
{lang}
|
148
|
+
</option>
|
149
|
+
))}
|
150
|
+
</select>
|
151
|
+
{errors.language?.message && (
|
152
|
+
<span className="ff-error">
|
153
|
+
{String(errors.language.message)}
|
154
|
+
</span>
|
155
|
+
)}
|
156
|
+
</div>
|
157
|
+
|
158
|
+
<div className="ff-button-layout">
|
159
|
+
<button type="submit">Submit</button>
|
160
|
+
<button type="button" onClick={() => handleReset(setValue)}>
|
161
|
+
Reset
|
162
|
+
</button>
|
163
|
+
</div>
|
164
|
+
</>
|
165
|
+
)}
|
166
|
+
</Form>
|
167
|
+
|
168
|
+
<pre>
|
169
|
+
<span>Payload Data:</span>
|
170
|
+
</pre>
|
171
|
+
<pre>{JSON.stringify(formData, null, 2)}</pre>
|
172
|
+
</div>
|
173
|
+
);
|
174
|
+
},
|
175
|
+
};
|
176
|
+
|
177
|
+
export default meta;
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import {
|
3
|
+
useForm,
|
4
|
+
UseFormProps,
|
5
|
+
SubmitHandler,
|
6
|
+
FieldValues,
|
7
|
+
FieldPath,
|
8
|
+
FieldErrors,
|
9
|
+
} from 'react-hook-form';
|
10
|
+
import './Form.scss';
|
11
|
+
|
12
|
+
interface FormProps<T extends FieldValues> extends UseFormProps<T> {
|
13
|
+
onSubmit: SubmitHandler<T>;
|
14
|
+
children: (props: {
|
15
|
+
register: (name: FieldPath<T>, options?: any) => any;
|
16
|
+
errors: FieldErrors<T>;
|
17
|
+
handleBlur: (field: FieldPath<T>) => void;
|
18
|
+
getValues: () => T;
|
19
|
+
watch: (field?: FieldPath<T>) => any;
|
20
|
+
setValue: (field: FieldPath<T>, value: any, options?: object) => void;
|
21
|
+
}) => React.ReactNode;
|
22
|
+
}
|
23
|
+
|
24
|
+
const Form = <T extends FieldValues>({
|
25
|
+
onSubmit,
|
26
|
+
children,
|
27
|
+
...rest
|
28
|
+
}: FormProps<T>) => {
|
29
|
+
const {
|
30
|
+
register,
|
31
|
+
handleSubmit,
|
32
|
+
formState: { errors },
|
33
|
+
trigger,
|
34
|
+
getValues,
|
35
|
+
watch,
|
36
|
+
setValue
|
37
|
+
} = useForm<T>(rest);
|
38
|
+
|
39
|
+
const handleBlur = async (field: FieldPath<T>) => {
|
40
|
+
await trigger(field);
|
41
|
+
};
|
42
|
+
|
43
|
+
return (
|
44
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
45
|
+
{children({
|
46
|
+
register,
|
47
|
+
errors,
|
48
|
+
handleBlur,
|
49
|
+
getValues,
|
50
|
+
watch,
|
51
|
+
setValue,
|
52
|
+
})}
|
53
|
+
</form>
|
54
|
+
);
|
55
|
+
};
|
56
|
+
|
57
|
+
export default Form;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {default} from './Form';
|
@@ -0,0 +1 @@
|
|
1
|
+
export type FormValues = Record<string, any>;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"username": {
|
3
|
+
"required": "Username is required",
|
4
|
+
"minLength": {
|
5
|
+
"value": 3,
|
6
|
+
"message": "Username must be at least 3 characters"
|
7
|
+
}
|
8
|
+
},
|
9
|
+
"email": {
|
10
|
+
"required": "Email is required",
|
11
|
+
"pattern": {
|
12
|
+
"value": "^\\S+@\\S+\\.\\S+$",
|
13
|
+
"message": "Please enter a valid email"
|
14
|
+
}
|
15
|
+
},
|
16
|
+
"password": {
|
17
|
+
"required": "Password is required",
|
18
|
+
"minLength": {
|
19
|
+
"value": 6,
|
20
|
+
"message": "Password must be at least 6 characters"
|
21
|
+
}
|
22
|
+
},
|
23
|
+
"gender": {
|
24
|
+
"required": "Gender is required"
|
25
|
+
},
|
26
|
+
"language": {
|
27
|
+
"required": "Language is required"
|
28
|
+
}
|
29
|
+
}
|