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,260 @@
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
2
|
+
import { createPortal } from 'react-dom';
|
3
|
+
import classNames from 'classnames';
|
4
|
+
import './MultiSelect.scss';
|
5
|
+
import Dropdown from './Dropdown';
|
6
|
+
import Icon from '../Icon';
|
7
|
+
import { MultiSelectProps, Option } from './MultiSelectTypes';
|
8
|
+
|
9
|
+
const ChipElement = ({
|
10
|
+
label,
|
11
|
+
onChipCloseClick,
|
12
|
+
}: {
|
13
|
+
label: string;
|
14
|
+
onChipCloseClick: (e: React.MouseEvent<HTMLDivElement>) => void;
|
15
|
+
}) => {
|
16
|
+
if (label) {
|
17
|
+
return (
|
18
|
+
<div className="ff-multiselect-chip">
|
19
|
+
<span className="ff-multiselect-chip-label"> {label}</span>
|
20
|
+
<Icon
|
21
|
+
color="#71347b"
|
22
|
+
className="ff-multiselect-chip-close-icon"
|
23
|
+
onClick={onChipCloseClick}
|
24
|
+
name="close_pill"
|
25
|
+
/>
|
26
|
+
</div>
|
27
|
+
);
|
28
|
+
}
|
29
|
+
return null;
|
30
|
+
};
|
31
|
+
const MultiSelect = ({
|
32
|
+
options,
|
33
|
+
selectedOptions = [],
|
34
|
+
onChange = () => {},
|
35
|
+
zIndex = 100,
|
36
|
+
label = '',
|
37
|
+
onSearch = () => {},
|
38
|
+
required = false,
|
39
|
+
disabled = false,
|
40
|
+
errorMessage = 'Fill this field',
|
41
|
+
}: MultiSelectProps) => {
|
42
|
+
const [isOpen, setIsOpen] = useState<boolean>(false);
|
43
|
+
const [allOptions, setAllOptions] = useState(options);
|
44
|
+
|
45
|
+
const [searchedKeyword, setSearchedKeyword] = useState('');
|
46
|
+
const [isSelectFocusedOnce, setIsSelectFocusedOnce] =
|
47
|
+
useState<boolean>(false);
|
48
|
+
|
49
|
+
const [dropdownPosition, setDropdownPosition] = useState<{
|
50
|
+
top: number;
|
51
|
+
left: number;
|
52
|
+
width: number;
|
53
|
+
fromBottom: number;
|
54
|
+
selectHeight: number;
|
55
|
+
}>({
|
56
|
+
top: 0,
|
57
|
+
left: 0,
|
58
|
+
width: 0,
|
59
|
+
fromBottom: 0,
|
60
|
+
selectHeight: 0,
|
61
|
+
});
|
62
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
63
|
+
const dropdownWrapper = useRef<HTMLInputElement>(null);
|
64
|
+
const dropdownRef = useRef<HTMLInputElement>(null);
|
65
|
+
const selectWrapper = useRef<HTMLInputElement>(null);
|
66
|
+
let isFieldSkipped = isSelectFocusedOnce && selectedOptions.length === 0;
|
67
|
+
|
68
|
+
const handleClick = () => {
|
69
|
+
if (!isOpen) {
|
70
|
+
setIsOpen(true);
|
71
|
+
}
|
72
|
+
};
|
73
|
+
|
74
|
+
const toggleDropdown = () => {
|
75
|
+
inputRef.current?.focus();
|
76
|
+
setIsOpen((prev) => !prev);
|
77
|
+
if (!isSelectFocusedOnce && isOpen) {
|
78
|
+
setIsSelectFocusedOnce(true);
|
79
|
+
}
|
80
|
+
};
|
81
|
+
const handleOptionChange = (selectedOption: Option, isChecked: boolean) => {
|
82
|
+
inputRef.current?.focus();
|
83
|
+
const updatedOptions = allOptions.map((option) =>
|
84
|
+
option.value === selectedOption.value ? { ...option, isChecked } : option
|
85
|
+
);
|
86
|
+
|
87
|
+
setAllOptions(updatedOptions);
|
88
|
+
const tempCheckedOptions = updatedOptions
|
89
|
+
.filter((option) => option.isChecked)
|
90
|
+
.map(({ isChecked, ...rest }) => rest);
|
91
|
+
if (!isSelectFocusedOnce) {
|
92
|
+
setIsSelectFocusedOnce(true);
|
93
|
+
}
|
94
|
+
onChange && onChange(tempCheckedOptions);
|
95
|
+
};
|
96
|
+
const handleChipCloseClick = (
|
97
|
+
option: Option,
|
98
|
+
e: React.MouseEvent<HTMLDivElement>
|
99
|
+
) => {
|
100
|
+
e.stopPropagation();
|
101
|
+
handleOptionChange(option, false);
|
102
|
+
};
|
103
|
+
const calculatePosition = () => {
|
104
|
+
if (dropdownWrapper.current && selectWrapper.current) {
|
105
|
+
const rect = dropdownWrapper.current?.getBoundingClientRect();
|
106
|
+
const rect2 = selectWrapper.current?.getBoundingClientRect();
|
107
|
+
setDropdownPosition({
|
108
|
+
top: rect.bottom + window.scrollY,
|
109
|
+
left: rect.left + window.scrollX,
|
110
|
+
width: rect.width,
|
111
|
+
fromBottom: document.documentElement.clientHeight - (rect.bottom - 4),
|
112
|
+
selectHeight: rect2.height,
|
113
|
+
});
|
114
|
+
}
|
115
|
+
};
|
116
|
+
useEffect(() => {
|
117
|
+
if (isOpen) {
|
118
|
+
calculatePosition();
|
119
|
+
}
|
120
|
+
}, [isOpen, allOptions]);
|
121
|
+
const onSelectToggleScroll = (isEnabled: boolean) => {
|
122
|
+
const bodyScrollWidth = window.innerWidth - document.body.clientWidth;
|
123
|
+
document.body.style.paddingRight = isEnabled ? '' : `${bodyScrollWidth}px`;
|
124
|
+
document.body.style.overflow = isEnabled ? '' : 'hidden';
|
125
|
+
};
|
126
|
+
|
127
|
+
useEffect(() => {
|
128
|
+
if (isOpen) {
|
129
|
+
onSelectToggleScroll(!isOpen);
|
130
|
+
}
|
131
|
+
|
132
|
+
if (dropdownRef?.current) {
|
133
|
+
inputRef?.current?.focus();
|
134
|
+
}
|
135
|
+
return () => {
|
136
|
+
onSelectToggleScroll(true);
|
137
|
+
};
|
138
|
+
}, [isOpen]);
|
139
|
+
|
140
|
+
useEffect(() => {
|
141
|
+
if (options?.length > 0) {
|
142
|
+
const initializeOptions = options.map((option) => ({
|
143
|
+
...option,
|
144
|
+
isChecked: selectedOptions.some(
|
145
|
+
(selectedOption) => selectedOption.value === option.value
|
146
|
+
),
|
147
|
+
}));
|
148
|
+
setAllOptions(initializeOptions);
|
149
|
+
}
|
150
|
+
const handleClickAnywhere = (event: MouseEvent) => {
|
151
|
+
if (
|
152
|
+
dropdownWrapper.current &&
|
153
|
+
inputRef.current &&
|
154
|
+
selectWrapper.current &&
|
155
|
+
dropdownRef.current &&
|
156
|
+
!inputRef.current.contains(event?.target as Node) &&
|
157
|
+
!dropdownRef.current.contains(event?.target as Node) &&
|
158
|
+
!selectWrapper.current.contains(event?.target as Node)
|
159
|
+
) {
|
160
|
+
setIsOpen(false);
|
161
|
+
if (!isSelectFocusedOnce) {
|
162
|
+
setIsSelectFocusedOnce(true);
|
163
|
+
}
|
164
|
+
}
|
165
|
+
};
|
166
|
+
window.addEventListener('resize', calculatePosition);
|
167
|
+
window.addEventListener('click', handleClickAnywhere);
|
168
|
+
return () => {
|
169
|
+
window.removeEventListener('resize', calculatePosition);
|
170
|
+
window.removeEventListener('click', handleClickAnywhere);
|
171
|
+
document.body.style.overflow = 'auto';
|
172
|
+
};
|
173
|
+
}, []);
|
174
|
+
return (
|
175
|
+
<div
|
176
|
+
ref={selectWrapper}
|
177
|
+
className={classNames('ff-multiselect-wrapper', {
|
178
|
+
'ff-multiselect-wrapper--with-options': selectedOptions?.length,
|
179
|
+
'ff-multiselect-wrapper--opened-dropdown': isOpen,
|
180
|
+
'ff-multiselect-wrapper--error': isFieldSkipped && required,
|
181
|
+
'ff-multiselect-wrapper--disabled': disabled,
|
182
|
+
})}
|
183
|
+
>
|
184
|
+
<div className="ff-multiselect" onClick={handleClick}>
|
185
|
+
<div className="ff-multiselect__main">
|
186
|
+
<span
|
187
|
+
className={classNames({
|
188
|
+
'active-default-label':
|
189
|
+
isOpen ||
|
190
|
+
selectedOptions?.length ||
|
191
|
+
(isFieldSkipped && required),
|
192
|
+
'default-label': !isOpen && !selectedOptions?.length,
|
193
|
+
})}
|
194
|
+
>
|
195
|
+
{label}
|
196
|
+
</span>
|
197
|
+
<div className="ff-multiselect-chip-container">
|
198
|
+
{selectedOptions.map((option) => (
|
199
|
+
<ChipElement
|
200
|
+
key={option?.label}
|
201
|
+
label={option?.label || ''}
|
202
|
+
onChipCloseClick={(e) => handleChipCloseClick(option, e)}
|
203
|
+
/>
|
204
|
+
))}
|
205
|
+
<div className="ff-multiselect-input-container">
|
206
|
+
<input
|
207
|
+
autoComplete="off"
|
208
|
+
placeholder="search..."
|
209
|
+
ref={inputRef}
|
210
|
+
onChange={(e) => {
|
211
|
+
if (!isOpen) {
|
212
|
+
setIsOpen(true);
|
213
|
+
}
|
214
|
+
setSearchedKeyword(e.target.value);
|
215
|
+
onSearch?.(e.target.value);
|
216
|
+
}}
|
217
|
+
id="input-ele"
|
218
|
+
className="ff-select-input"
|
219
|
+
style={{
|
220
|
+
display:
|
221
|
+
isOpen || selectedOptions.length ? 'inherit' : 'none',
|
222
|
+
}}
|
223
|
+
/>
|
224
|
+
</div>
|
225
|
+
</div>
|
226
|
+
</div>
|
227
|
+
<div onClick={toggleDropdown} className="ff-multiselect__toggle">
|
228
|
+
<Icon
|
229
|
+
name="arrow_down"
|
230
|
+
className={classNames({
|
231
|
+
'ff-select-arrow--opened-dropdown': isOpen,
|
232
|
+
'ff-select-arrow': !isOpen,
|
233
|
+
})}
|
234
|
+
color={isOpen ? '#71347b' : '#a3a3a3'}
|
235
|
+
/>
|
236
|
+
</div>
|
237
|
+
</div>
|
238
|
+
<div ref={dropdownWrapper}>
|
239
|
+
{isFieldSkipped && required && errorMessage && (
|
240
|
+
<div className="error-text">{errorMessage}</div>
|
241
|
+
)}
|
242
|
+
{isOpen &&
|
243
|
+
createPortal(
|
244
|
+
<Dropdown
|
245
|
+
ref={dropdownRef}
|
246
|
+
searchedKeyword={searchedKeyword}
|
247
|
+
checkedOptions={selectedOptions}
|
248
|
+
handleOptionChange={handleOptionChange}
|
249
|
+
options={allOptions}
|
250
|
+
dropdownPosition={dropdownPosition}
|
251
|
+
zIndex={zIndex}
|
252
|
+
/>,
|
253
|
+
document.body
|
254
|
+
)}
|
255
|
+
</div>
|
256
|
+
</div>
|
257
|
+
);
|
258
|
+
};
|
259
|
+
|
260
|
+
export default MultiSelect;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
interface Option {
|
2
|
+
label?: string;
|
3
|
+
value?: string;
|
4
|
+
accessor?: string;
|
5
|
+
isChecked?: boolean;
|
6
|
+
}
|
7
|
+
interface MultiSelectProps {
|
8
|
+
options: Option[];
|
9
|
+
label: string;
|
10
|
+
selectedOptions?: Option[];
|
11
|
+
disabled?: boolean;
|
12
|
+
onSearch?: (searchedKeyword: string) => void;
|
13
|
+
onChange?: (selectedOptions: Option[]) => void;
|
14
|
+
zIndex?: number;
|
15
|
+
required?: boolean;
|
16
|
+
errorMessage?: string;
|
17
|
+
}
|
18
|
+
|
19
|
+
export { Option, MultiSelectProps };
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { Option } from './MultiSelectTypes';
|
2
|
+
export const dropdownDefaultCSSData = {
|
3
|
+
verticalMargin: 4,
|
4
|
+
optionHeight: 32,
|
5
|
+
maxDropdownHeight: 160,
|
6
|
+
};
|
7
|
+
export interface DropdownProps {
|
8
|
+
options: Option[];
|
9
|
+
style?: React.CSSProperties;
|
10
|
+
handleOptionChange: (option: Option, isChecked: boolean) => void;
|
11
|
+
checkedOptions: Option[];
|
12
|
+
searchedKeyword: undefined | string;
|
13
|
+
dropdownPosition: any;
|
14
|
+
zIndex: number;
|
15
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './MultiSelect';
|
@@ -0,0 +1,99 @@
|
|
1
|
+
@import '../../assets/styles/_colors';
|
2
|
+
@import '../../assets/styles/_fonts';
|
3
|
+
|
4
|
+
@mixin circle($size, $border: none) {
|
5
|
+
width: $size;
|
6
|
+
height: $size;
|
7
|
+
border-radius: 50%;
|
8
|
+
@if $border != none {
|
9
|
+
border: $border;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
@mixin transition($properties, $duration: 0.3s) {
|
13
|
+
transition: $properties $duration;
|
14
|
+
}
|
15
|
+
|
16
|
+
.ff-radio {
|
17
|
+
@extend .fontSm;
|
18
|
+
position: relative;
|
19
|
+
color: $text-color;
|
20
|
+
display: flex;
|
21
|
+
align-items: center;
|
22
|
+
cursor: pointer;
|
23
|
+
.ff-radio-input {
|
24
|
+
display: none;
|
25
|
+
}
|
26
|
+
.ff-radio-custom {
|
27
|
+
box-sizing: border-box;
|
28
|
+
@include circle(16px, 1px solid var(--radio-button-border)); //todo
|
29
|
+
position: relative;
|
30
|
+
margin-right: 8px;
|
31
|
+
@include transition(border-color, background-color);
|
32
|
+
|
33
|
+
&::before {
|
34
|
+
content: '';
|
35
|
+
@include circle(14px);
|
36
|
+
background: #fbfdff; //todo
|
37
|
+
position: absolute;
|
38
|
+
top: 50%;
|
39
|
+
left: 50%;
|
40
|
+
transform: translate(-50%, -50%);
|
41
|
+
@include transition(background-color);
|
42
|
+
}
|
43
|
+
|
44
|
+
&::after {
|
45
|
+
content: '';
|
46
|
+
@include circle(16px, 4px solid #f7edff); //todo
|
47
|
+
position: absolute;
|
48
|
+
top: 50%;
|
49
|
+
left: 50%;
|
50
|
+
transform: translate(-50%, -50%);
|
51
|
+
opacity: 0;
|
52
|
+
@include transition(opacity);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
&:hover .ff-radio-custom {
|
57
|
+
border: 1px solid var(--brand-color);
|
58
|
+
&::before {
|
59
|
+
background-color: var(--drawer-footer-bg);
|
60
|
+
}
|
61
|
+
&::after {
|
62
|
+
opacity: 1;
|
63
|
+
@include transition(opacity);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
.ff-radio-input:checked + .ff-radio-custom {
|
67
|
+
border-color: var(--brand-color);
|
68
|
+
|
69
|
+
&::before {
|
70
|
+
background: var(--brand-color);
|
71
|
+
height: 12px;
|
72
|
+
width: 12px;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
.ff-radio-input:disabled + .ff-radio-custom {
|
76
|
+
border: 1px solid var(--radio-button-border);
|
77
|
+
&::before {
|
78
|
+
background: var(--drawer-footer-bg);
|
79
|
+
}
|
80
|
+
|
81
|
+
&::after {
|
82
|
+
border: 4px solid var(--radio-button-hover);
|
83
|
+
opacity: 0;
|
84
|
+
@include transition(opacity);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
.ff-radio-input:checked:disabled + .ff-radio-custom {
|
89
|
+
border-color: var(--brand-color);
|
90
|
+
background-color: var(--drawer-footer-bg);
|
91
|
+
&::before {
|
92
|
+
background: var(--brand-color);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
&--disabled {
|
96
|
+
cursor: default;
|
97
|
+
opacity: 0.5;
|
98
|
+
}
|
99
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
2
|
+
import RadioButton from './RadioButton';
|
3
|
+
|
4
|
+
const meta: Meta<typeof RadioButton> = {
|
5
|
+
title: 'Components/RadioButton',
|
6
|
+
component: RadioButton,
|
7
|
+
parameters: {
|
8
|
+
layout: 'centered',
|
9
|
+
},
|
10
|
+
tags: ['autodocs'],
|
11
|
+
};
|
12
|
+
|
13
|
+
type Story = StoryObj<typeof RadioButton>;
|
14
|
+
|
15
|
+
export const Default: Story = {
|
16
|
+
args: {
|
17
|
+
label: 'men',
|
18
|
+
},
|
19
|
+
};
|
20
|
+
|
21
|
+
export const Checked: Story = {
|
22
|
+
args: {
|
23
|
+
label: 'women',
|
24
|
+
checked: true,
|
25
|
+
},
|
26
|
+
};
|
27
|
+
export const UncheckedDisabled: Story = {
|
28
|
+
args: {
|
29
|
+
label: 'women',
|
30
|
+
disabled: true,
|
31
|
+
},
|
32
|
+
};
|
33
|
+
export const CheckedDisabled: Story = {
|
34
|
+
args: {
|
35
|
+
label: 'women',
|
36
|
+
disabled: true,
|
37
|
+
checked: true,
|
38
|
+
},
|
39
|
+
};
|
40
|
+
|
41
|
+
export const WithoutLabel: Story = {};
|
42
|
+
|
43
|
+
export default meta;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import './RadioButton.scss';
|
3
|
+
import classNames from 'classnames';
|
4
|
+
|
5
|
+
const RadioButton: React.FC<RadioButtonProps> = ({
|
6
|
+
label,
|
7
|
+
name,
|
8
|
+
checked,
|
9
|
+
onChange,
|
10
|
+
value,
|
11
|
+
disabled = false,
|
12
|
+
}) => {
|
13
|
+
return (
|
14
|
+
<label
|
15
|
+
className={classNames('ff-radio', { 'ff-radio--disabled': disabled })}
|
16
|
+
>
|
17
|
+
<input
|
18
|
+
disabled={disabled}
|
19
|
+
type="radio"
|
20
|
+
name={name}
|
21
|
+
value={value}
|
22
|
+
checked={checked}
|
23
|
+
onChange={onChange}
|
24
|
+
className="ff-radio-input"
|
25
|
+
/>
|
26
|
+
<span className="ff-radio-custom" />
|
27
|
+
{label}
|
28
|
+
</label>
|
29
|
+
);
|
30
|
+
};
|
31
|
+
|
32
|
+
export default RadioButton;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './RadioButton';
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/**
|
2
|
+
* Props for the RadioButton component.
|
3
|
+
*/
|
4
|
+
interface RadioButtonProps {
|
5
|
+
/**
|
6
|
+
* The display label for the radio button.
|
7
|
+
* Optional.
|
8
|
+
*/
|
9
|
+
label?: string;
|
10
|
+
|
11
|
+
/**
|
12
|
+
* The name attribute for the radio button, used for grouping.
|
13
|
+
*/
|
14
|
+
name: string;
|
15
|
+
|
16
|
+
/**
|
17
|
+
* The unique value of the radio button.
|
18
|
+
* Optional.
|
19
|
+
*/
|
20
|
+
value?: string;
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Indicates whether the radio button is checked.
|
24
|
+
* Optional.
|
25
|
+
*/
|
26
|
+
checked?: boolean;
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Callback function that is called when the radio button's value changes.
|
30
|
+
* Receives the change event as an argument.
|
31
|
+
* Optional.
|
32
|
+
*/
|
33
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Indicates whether the radio button is disabled.
|
37
|
+
* Optional.
|
38
|
+
*/
|
39
|
+
disabled?: boolean;
|
40
|
+
}
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
2
|
+
import RadioGroup from './RadioGroup';
|
3
|
+
import { useState } from 'react';
|
4
|
+
|
5
|
+
const meta: Meta<typeof RadioGroup> = {
|
6
|
+
title: 'Components/RadioGroup',
|
7
|
+
component: RadioGroup,
|
8
|
+
parameters: {
|
9
|
+
layout: 'centered',
|
10
|
+
},
|
11
|
+
tags: ['autodocs'],
|
12
|
+
};
|
13
|
+
|
14
|
+
type Story = StoryObj<typeof RadioGroup>;
|
15
|
+
|
16
|
+
export const Controlled: Story = {
|
17
|
+
render: () => {
|
18
|
+
const radioOptions = [
|
19
|
+
{ value: 'men', label: 'Men' },
|
20
|
+
{ value: 'women', label: 'Women' }, // Disabled option
|
21
|
+
{ value: 'other', label: 'Other' },
|
22
|
+
];
|
23
|
+
const [selectedOption, setSelectedOption] = useState('option2');
|
24
|
+
const handleOptionChange = (option: Option) => {
|
25
|
+
setSelectedOption(option.value);
|
26
|
+
};
|
27
|
+
return (
|
28
|
+
<RadioGroup
|
29
|
+
options={radioOptions}
|
30
|
+
onChange={handleOptionChange}
|
31
|
+
name="option"
|
32
|
+
selectedValue={selectedOption}
|
33
|
+
/>
|
34
|
+
);
|
35
|
+
},
|
36
|
+
};
|
37
|
+
|
38
|
+
export const WithDisabledOption: Story = {
|
39
|
+
render: () => {
|
40
|
+
const radioOptions = [
|
41
|
+
{ value: 'men', label: 'Men', disabled: true },
|
42
|
+
{ value: 'women', label: 'Women' }, // Disabled option
|
43
|
+
{ value: 'other', label: 'Other' },
|
44
|
+
];
|
45
|
+
const [selectedOption, setSelectedOption] = useState('');
|
46
|
+
const handleOptionChange = (option: Option) => {
|
47
|
+
setSelectedOption(option.value);
|
48
|
+
};
|
49
|
+
return (
|
50
|
+
<RadioGroup
|
51
|
+
options={radioOptions}
|
52
|
+
onChange={handleOptionChange}
|
53
|
+
name="option"
|
54
|
+
selectedValue={selectedOption}
|
55
|
+
/>
|
56
|
+
);
|
57
|
+
},
|
58
|
+
};
|
59
|
+
|
60
|
+
export const DisabledSelcted: Story = {
|
61
|
+
render: () => {
|
62
|
+
const radioOptions = [
|
63
|
+
{ value: 'men', label: 'Men' },
|
64
|
+
{ value: 'women', label: 'Women', disabled: true }, // Disabled option
|
65
|
+
{ value: 'other', label: 'Other' },
|
66
|
+
];
|
67
|
+
const [selectedOption, setSelectedOption] = useState('women');
|
68
|
+
const handleOptionChange = (option: Option) => {
|
69
|
+
setSelectedOption(option.value);
|
70
|
+
};
|
71
|
+
return (
|
72
|
+
<RadioGroup
|
73
|
+
options={radioOptions}
|
74
|
+
onChange={handleOptionChange}
|
75
|
+
name="gender"
|
76
|
+
selectedValue={selectedOption}
|
77
|
+
/>
|
78
|
+
);
|
79
|
+
},
|
80
|
+
};
|
81
|
+
export default meta;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import RadioButton from '../RadioButton/RadioButton'; // Adjust the import path as necessary
|
3
|
+
import './RadioGroup.scss';
|
4
|
+
import classNames from 'classnames';
|
5
|
+
|
6
|
+
const RadioGroup: React.FC<RadioGroupProps> = ({
|
7
|
+
options,
|
8
|
+
name,
|
9
|
+
selectedValue,
|
10
|
+
onChange,
|
11
|
+
className,
|
12
|
+
}) => {
|
13
|
+
return (
|
14
|
+
<div className={classNames('ff-radio-group', className)}>
|
15
|
+
{options.map((option) => (
|
16
|
+
<RadioButton
|
17
|
+
key={option.value}
|
18
|
+
label={option.label}
|
19
|
+
name={name}
|
20
|
+
value={option.value}
|
21
|
+
checked={selectedValue === option.value}
|
22
|
+
onChange={() => onChange?.(option)}
|
23
|
+
disabled={option.disabled}
|
24
|
+
/>
|
25
|
+
))}
|
26
|
+
</div>
|
27
|
+
);
|
28
|
+
};
|
29
|
+
|
30
|
+
export default RadioGroup;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './RadioGroup';
|
@@ -0,0 +1,54 @@
|
|
1
|
+
/**
|
2
|
+
* Represents a single option in the radio group.
|
3
|
+
*/
|
4
|
+
interface Option {
|
5
|
+
/**
|
6
|
+
* The unique value of the option.
|
7
|
+
*/
|
8
|
+
value: string;
|
9
|
+
|
10
|
+
/**
|
11
|
+
* The display label for the option.
|
12
|
+
*/
|
13
|
+
label: string;
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Indicates whether the option is disabled.
|
17
|
+
* Optional.
|
18
|
+
*/
|
19
|
+
disabled?: boolean;
|
20
|
+
}
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Props for the RadioGroup component.
|
24
|
+
*/
|
25
|
+
interface RadioGroupProps {
|
26
|
+
/**
|
27
|
+
* An array of options to be rendered in the radio group.
|
28
|
+
*/
|
29
|
+
options: Option[];
|
30
|
+
|
31
|
+
/**
|
32
|
+
* The name attribute for the radio inputs, used for grouping.
|
33
|
+
*/
|
34
|
+
name: string;
|
35
|
+
|
36
|
+
/**
|
37
|
+
* The currently selected value.
|
38
|
+
* Optional.
|
39
|
+
*/
|
40
|
+
selectedValue?: string;
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Callback function that is called when the selected option changes.
|
44
|
+
* It receives the selected option as an argument.
|
45
|
+
* Optional.
|
46
|
+
*/
|
47
|
+
onChange?: (option: Option) => void;
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Additional class names to apply to the radio group for custom styling.
|
51
|
+
* Optional.
|
52
|
+
*/
|
53
|
+
className?: string;
|
54
|
+
}
|