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,368 @@
|
|
1
|
+
import { useReducer, useRef, useEffect, useMemo } from 'react';
|
2
|
+
import { Option, SelectAction, SelectProps, SelectState } from './types';
|
3
|
+
import { checkEmpty } from '../../utils/checkEmpty/checkEmpty';
|
4
|
+
import { createPortal } from 'react-dom';
|
5
|
+
import classNames from 'classnames';
|
6
|
+
import Dropdown from './components/Dropdown/Dropdown';
|
7
|
+
import Icon from '../Icon';
|
8
|
+
import './Select.scss';
|
9
|
+
import usePortalPosition from '../../hooks/usePortalPosition';
|
10
|
+
import Typography from '../Typography';
|
11
|
+
|
12
|
+
const selectReducer = (
|
13
|
+
state: SelectState,
|
14
|
+
action: SelectAction
|
15
|
+
): SelectState => {
|
16
|
+
switch (action.type) {
|
17
|
+
case 'FOCUS_INPUT':
|
18
|
+
return {
|
19
|
+
...state,
|
20
|
+
isInputFocused: true,
|
21
|
+
iconColor: 'var(--ff-select-brand-color)',
|
22
|
+
isIconClick: true,
|
23
|
+
showOptions: true,
|
24
|
+
};
|
25
|
+
case 'BLUR_INPUT':
|
26
|
+
return {
|
27
|
+
...state,
|
28
|
+
isInputFocused: false,
|
29
|
+
options: action.payload.optionsList,
|
30
|
+
option: action.payload.option,
|
31
|
+
|
32
|
+
// todo color need to be add in style guide
|
33
|
+
iconColor: 'var(--ff-select-default-color)',
|
34
|
+
isIconClick: false,
|
35
|
+
showOptions: false,
|
36
|
+
dropdownPosition: {
|
37
|
+
positionX: 0,
|
38
|
+
positionY: 0,
|
39
|
+
width: 0,
|
40
|
+
fromBottom: 0,
|
41
|
+
},
|
42
|
+
};
|
43
|
+
case 'MOUSE_ENTER':
|
44
|
+
return state.isInputFocused
|
45
|
+
? state
|
46
|
+
: { ...state, iconColor: 'var(--ff-select-text-hover-color)' };
|
47
|
+
case 'MOUSE_LEAVE':
|
48
|
+
return state.isInputFocused
|
49
|
+
? state
|
50
|
+
: // todo color need to be add in style guide
|
51
|
+
{
|
52
|
+
...state,
|
53
|
+
iconColor: 'var(--ff-select-default-color)',
|
54
|
+
isIconClick: false,
|
55
|
+
};
|
56
|
+
|
57
|
+
case 'UPDATE_DROPDOWN_POSITION':
|
58
|
+
const { positionX, positionY, width, fromBottom } = action.payload || {};
|
59
|
+
return {
|
60
|
+
...state,
|
61
|
+
dropdownPosition: {
|
62
|
+
positionX,
|
63
|
+
positionY,
|
64
|
+
width,
|
65
|
+
fromBottom,
|
66
|
+
},
|
67
|
+
};
|
68
|
+
|
69
|
+
case 'UPDATE_OPTION':
|
70
|
+
return {
|
71
|
+
...state,
|
72
|
+
option: action.payload,
|
73
|
+
};
|
74
|
+
|
75
|
+
case 'UPDATE_OPTION_LIST':
|
76
|
+
return {
|
77
|
+
...state,
|
78
|
+
options: action.payload,
|
79
|
+
};
|
80
|
+
case 'SHOW_ERROR':
|
81
|
+
return {
|
82
|
+
...state,
|
83
|
+
isInputFocused: true,
|
84
|
+
isIconClick: false,
|
85
|
+
showOptions: false,
|
86
|
+
options: action.payload.optionsList,
|
87
|
+
option: action.payload.option,
|
88
|
+
|
89
|
+
// todo color need to be add in style guide
|
90
|
+
iconColor: 'var(--ff-select-default-color)',
|
91
|
+
dropdownPosition: {
|
92
|
+
positionX: 0,
|
93
|
+
positionY: 0,
|
94
|
+
width: 0,
|
95
|
+
fromBottom: 0,
|
96
|
+
},
|
97
|
+
};
|
98
|
+
|
99
|
+
default:
|
100
|
+
return state;
|
101
|
+
}
|
102
|
+
};
|
103
|
+
|
104
|
+
const Select = ({
|
105
|
+
label = '',
|
106
|
+
showLabel = true,
|
107
|
+
optionsList = [],
|
108
|
+
selectedOption = { label: '', value: '' },
|
109
|
+
onChange = () => {},
|
110
|
+
errorMsg = '',
|
111
|
+
className = '',
|
112
|
+
optionZIndex = 100,
|
113
|
+
disabled = false,
|
114
|
+
borderRadius = true,
|
115
|
+
showBorder = true,
|
116
|
+
required = false,
|
117
|
+
}: SelectProps) => {
|
118
|
+
const initialState: SelectState = useMemo(
|
119
|
+
() => ({
|
120
|
+
isInputFocused: false,
|
121
|
+
|
122
|
+
// todo color need to be added in style guide
|
123
|
+
iconColor: 'var(--ff-select-default-color)',
|
124
|
+
isIconClick: false,
|
125
|
+
showOptions: false,
|
126
|
+
options: optionsList,
|
127
|
+
option: checkEmpty(selectedOption) ? '' : selectedOption?.value,
|
128
|
+
dropdownPosition: { positionX: 0, positionY: 0, width: 0, fromBottom: 0 },
|
129
|
+
}),
|
130
|
+
[optionsList, selectedOption]
|
131
|
+
);
|
132
|
+
|
133
|
+
const [selectControlState, dispatch] = useReducer(
|
134
|
+
selectReducer,
|
135
|
+
initialState
|
136
|
+
);
|
137
|
+
|
138
|
+
const DropDownRef = useRef<HTMLDivElement>(null);
|
139
|
+
const InputRef = useRef<HTMLInputElement>(null);
|
140
|
+
|
141
|
+
const {
|
142
|
+
isInputFocused,
|
143
|
+
iconColor,
|
144
|
+
isIconClick,
|
145
|
+
showOptions,
|
146
|
+
dropdownPosition,
|
147
|
+
options,
|
148
|
+
option,
|
149
|
+
} = selectControlState;
|
150
|
+
|
151
|
+
const calculatePosition = usePortalPosition(DropDownRef, showOptions);
|
152
|
+
|
153
|
+
const handleSelectAction = (
|
154
|
+
actionType:
|
155
|
+
| 'FOCUS_INPUT'
|
156
|
+
| 'MOUSE_ENTER'
|
157
|
+
| 'MOUSE_LEAVE'
|
158
|
+
| 'SHOW_ERROR'
|
159
|
+
| 'BLUR_INPUT'
|
160
|
+
) => {
|
161
|
+
if (!disabled) {
|
162
|
+
if (actionType === 'SHOW_ERROR' || actionType === 'BLUR_INPUT') {
|
163
|
+
dispatch({
|
164
|
+
type: actionType,
|
165
|
+
payload: { optionsList, option: selectedOption.value },
|
166
|
+
});
|
167
|
+
} else {
|
168
|
+
dispatch({ type: actionType });
|
169
|
+
}
|
170
|
+
}
|
171
|
+
};
|
172
|
+
|
173
|
+
const onSelectInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
174
|
+
if (disabled) return;
|
175
|
+
const { value } = e.target;
|
176
|
+
const filteredOptions = optionsList.filter((option) => {
|
177
|
+
return typeof option.value === 'string'
|
178
|
+
? option.value.toLowerCase().includes(value.toLowerCase().trim())
|
179
|
+
: option.value === Number(value);
|
180
|
+
});
|
181
|
+
dispatch({ type: 'UPDATE_OPTION_LIST', payload: filteredOptions });
|
182
|
+
dispatch({ type: 'UPDATE_OPTION', payload: value });
|
183
|
+
};
|
184
|
+
|
185
|
+
const onSelectBlur = () => {
|
186
|
+
if (disabled) return;
|
187
|
+
|
188
|
+
if (errorMsg) {
|
189
|
+
handleSelectAction('SHOW_ERROR');
|
190
|
+
} else {
|
191
|
+
handleSelectAction('BLUR_INPUT');
|
192
|
+
}
|
193
|
+
};
|
194
|
+
|
195
|
+
const onSelectOptionSelector = (option: Option) => {
|
196
|
+
if (!disabled) {
|
197
|
+
onSelectBlur();
|
198
|
+
dispatch({ type: 'UPDATE_OPTION', payload: option.value });
|
199
|
+
if (onChange) {
|
200
|
+
onChange(option);
|
201
|
+
}
|
202
|
+
}
|
203
|
+
};
|
204
|
+
|
205
|
+
const onSelectUpdatePosition = () => {
|
206
|
+
if (!showOptions || !DropDownRef?.current || disabled) return;
|
207
|
+
const { positionX, positionY, width, fromBottom } =
|
208
|
+
calculatePosition(DropDownRef);
|
209
|
+
dispatch({
|
210
|
+
type: 'UPDATE_DROPDOWN_POSITION',
|
211
|
+
payload: { positionX, positionY, width, fromBottom },
|
212
|
+
});
|
213
|
+
};
|
214
|
+
|
215
|
+
const onSelectToggleScroll = (isEnabled: boolean) => {
|
216
|
+
const bodyScrollWidth = window.innerWidth - document.body.clientWidth;
|
217
|
+
document.body.style.paddingRight = isEnabled ? '' : `${bodyScrollWidth}px`;
|
218
|
+
document.body.style.overflow = isEnabled ? '' : 'hidden';
|
219
|
+
};
|
220
|
+
|
221
|
+
useEffect(() => {
|
222
|
+
if (disabled) return;
|
223
|
+
if (showOptions) {
|
224
|
+
onSelectToggleScroll(!showOptions);
|
225
|
+
}
|
226
|
+
onSelectUpdatePosition();
|
227
|
+
|
228
|
+
const handleResizeOrScroll = () => onSelectUpdatePosition();
|
229
|
+
|
230
|
+
window.addEventListener('resize', handleResizeOrScroll);
|
231
|
+
window.addEventListener('scroll', handleResizeOrScroll);
|
232
|
+
return () => {
|
233
|
+
onSelectToggleScroll(true);
|
234
|
+
window.removeEventListener('resize', handleResizeOrScroll);
|
235
|
+
window.removeEventListener('scroll', handleResizeOrScroll);
|
236
|
+
};
|
237
|
+
}, [showOptions]);
|
238
|
+
|
239
|
+
useEffect(() => {
|
240
|
+
if (errorMsg) {
|
241
|
+
handleSelectAction('SHOW_ERROR');
|
242
|
+
}
|
243
|
+
}, []);
|
244
|
+
|
245
|
+
const applyActiveOptionClasses = !isInputFocused && Boolean(option);
|
246
|
+
|
247
|
+
return (
|
248
|
+
<div className={classNames(`ff-select-wrapper ${className}`)}>
|
249
|
+
<div className="ff-select">
|
250
|
+
<input
|
251
|
+
type="text"
|
252
|
+
className={classNames('ff-select-input', {
|
253
|
+
'ff-select-input--default': !isInputFocused,
|
254
|
+
'ff-select-input--active': applyActiveOptionClasses,
|
255
|
+
'ff-select-input--no-label': !showLabel,
|
256
|
+
'ff-select-input--error':
|
257
|
+
errorMsg && !isInputFocused && !Boolean(option),
|
258
|
+
'ff-select-input--border-radius': !borderRadius,
|
259
|
+
'ff-select-input--disable': disabled,
|
260
|
+
'ff-select-input--no-border': !showBorder,
|
261
|
+
})}
|
262
|
+
// inline css required due to multiple overlay scenarios are present
|
263
|
+
style={{ zIndex: optionZIndex }}
|
264
|
+
onFocus={() => handleSelectAction('FOCUS_INPUT')}
|
265
|
+
onMouseEnter={() => handleSelectAction('MOUSE_ENTER')}
|
266
|
+
onMouseLeave={() => handleSelectAction('MOUSE_LEAVE')}
|
267
|
+
onChange={onSelectInputChange}
|
268
|
+
value={option}
|
269
|
+
disabled={disabled}
|
270
|
+
autoComplete="off"
|
271
|
+
spellCheck="false"
|
272
|
+
ref={InputRef}
|
273
|
+
/>
|
274
|
+
|
275
|
+
{showLabel && (
|
276
|
+
<div
|
277
|
+
className={classNames('ff-select-label', {
|
278
|
+
'ff-select-label--default': !isInputFocused,
|
279
|
+
'ff-select-label--active': isInputFocused || Boolean(option),
|
280
|
+
'ff-select-label--error': errorMsg,
|
281
|
+
})}
|
282
|
+
>
|
283
|
+
{required && (
|
284
|
+
<Typography
|
285
|
+
color="var(--$error-light)"
|
286
|
+
className="ff-select-label--required"
|
287
|
+
>
|
288
|
+
*
|
289
|
+
</Typography>
|
290
|
+
)}
|
291
|
+
{label}
|
292
|
+
</div>
|
293
|
+
)}
|
294
|
+
|
295
|
+
<Icon
|
296
|
+
name="arrow_up"
|
297
|
+
height={7}
|
298
|
+
width={12}
|
299
|
+
className={classNames('ff-select-arrow', {
|
300
|
+
'ff-select-arrow--down': isIconClick,
|
301
|
+
'ff-select-arrow--no-label': !showLabel,
|
302
|
+
})}
|
303
|
+
color={iconColor}
|
304
|
+
/>
|
305
|
+
<fieldset
|
306
|
+
className={classNames('ff-select-fieldset', {
|
307
|
+
'ff-select-fieldset--no-label': !showLabel,
|
308
|
+
'ff-select-fieldset--default': !isInputFocused,
|
309
|
+
'ff-select-fieldset--active': isInputFocused,
|
310
|
+
'ff-select-fieldset--option': applyActiveOptionClasses,
|
311
|
+
'ff-select-fieldset--error': errorMsg,
|
312
|
+
'ff-select-fieldset--border-radius': !borderRadius,
|
313
|
+
'ff-select-fieldset--no-border': !showBorder,
|
314
|
+
})}
|
315
|
+
>
|
316
|
+
{showLabel && (
|
317
|
+
<legend
|
318
|
+
className={classNames('ff-select-legend', {
|
319
|
+
'ff-select-legend--default': !isInputFocused,
|
320
|
+
'ff-select-legend--active': isInputFocused,
|
321
|
+
'ff-select-legend--option': applyActiveOptionClasses,
|
322
|
+
'ff-select-legend--error': errorMsg,
|
323
|
+
})}
|
324
|
+
>
|
325
|
+
{required && (
|
326
|
+
<Typography
|
327
|
+
fontSize={8}
|
328
|
+
color={'var(--$error-light)'}
|
329
|
+
className="ff-select-legend--required"
|
330
|
+
>
|
331
|
+
*
|
332
|
+
</Typography>
|
333
|
+
)}
|
334
|
+
{label}
|
335
|
+
</legend>
|
336
|
+
)}
|
337
|
+
</fieldset>
|
338
|
+
</div>
|
339
|
+
|
340
|
+
{errorMsg && (
|
341
|
+
<Typography
|
342
|
+
className="ff-select-wrapper-error-text"
|
343
|
+
fontSize={8}
|
344
|
+
color={'var(--error-light)'}
|
345
|
+
>
|
346
|
+
{errorMsg}
|
347
|
+
</Typography>
|
348
|
+
)}
|
349
|
+
|
350
|
+
<div ref={DropDownRef}>
|
351
|
+
{showOptions &&
|
352
|
+
createPortal(
|
353
|
+
<Dropdown
|
354
|
+
onSelectBlur={onSelectBlur}
|
355
|
+
onSelectOptionSelector={onSelectOptionSelector}
|
356
|
+
dropdownPosition={dropdownPosition}
|
357
|
+
options={options}
|
358
|
+
optionZIndex={optionZIndex}
|
359
|
+
inputRef={InputRef}
|
360
|
+
/>,
|
361
|
+
document.body
|
362
|
+
)}
|
363
|
+
</div>
|
364
|
+
</div>
|
365
|
+
);
|
366
|
+
};
|
367
|
+
|
368
|
+
export default Select;
|
@@ -0,0 +1,70 @@
|
|
1
|
+
@use '../../../../assets/styles/fonts';
|
2
|
+
|
3
|
+
// todo color need to be add into style guide
|
4
|
+
|
5
|
+
@mixin absolute-position($top: auto, $right: auto, $bottom: auto, $left: auto) {
|
6
|
+
position: absolute;
|
7
|
+
top: $top;
|
8
|
+
right: $right;
|
9
|
+
bottom: $bottom;
|
10
|
+
left: $left;
|
11
|
+
}
|
12
|
+
|
13
|
+
.ff-select-dropdown-wrapper {
|
14
|
+
.ff-select-options-wrapper {
|
15
|
+
// Future use case. Increase the height by adding padding at the top and bottom.
|
16
|
+
max-height: 160px;
|
17
|
+
z-index: 100;
|
18
|
+
|
19
|
+
position: absolute;
|
20
|
+
min-width: 100px;
|
21
|
+
border: 1px solid var(--ff-select-option-border-color);
|
22
|
+
box-sizing: border-box;
|
23
|
+
margin-top: 4px;
|
24
|
+
border-radius: 4px;
|
25
|
+
background-color: var(--ff-select-background-color);
|
26
|
+
box-shadow: 0px 1px 4px 0px var(--ff-select-option-wrapper-box-shadow);
|
27
|
+
overflow: hidden auto;
|
28
|
+
|
29
|
+
&::-webkit-scrollbar {
|
30
|
+
width: 4px;
|
31
|
+
height: 12px;
|
32
|
+
|
33
|
+
&-thumb {
|
34
|
+
background-color: var(--ff-select-scroll-thumb-color);
|
35
|
+
border-radius: 4px;
|
36
|
+
}
|
37
|
+
|
38
|
+
&-track {
|
39
|
+
background-color: transparent;
|
40
|
+
border-radius: 4px;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
.ff-select-option {
|
45
|
+
width: calc(100% - 18px);
|
46
|
+
border: 1px solid transparent;
|
47
|
+
border-radius: 4px;
|
48
|
+
padding: 0px 8px;
|
49
|
+
overflow: hidden;
|
50
|
+
white-space: nowrap;
|
51
|
+
text-overflow: ellipsis;
|
52
|
+
cursor: pointer;
|
53
|
+
|
54
|
+
&:hover {
|
55
|
+
border-color: var(--ff-select-background-color);
|
56
|
+
background-color: var(--ff-select-option-hover-color);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
.ff-select-no-option {
|
61
|
+
width: calc(100% - 16px);
|
62
|
+
margin: 0;
|
63
|
+
overflow: hidden;
|
64
|
+
padding: 0px 8px;
|
65
|
+
white-space: nowrap;
|
66
|
+
text-overflow: ellipsis;
|
67
|
+
cursor: not-allowed;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
import { useRef } from 'react';
|
2
|
+
import { DropDownListProps, dropdownDefaultCSSData } from './dropdownTypes';
|
3
|
+
import useClickOutside from '../../../../hooks/useClickOutside';
|
4
|
+
import { checkEmpty } from '../../../../utils/checkEmpty/checkEmpty';
|
5
|
+
import './Dropdown.scss';
|
6
|
+
import Typography from '../../../Typography';
|
7
|
+
import ffid from '../../../../utils/ffID/ffid';
|
8
|
+
|
9
|
+
const Dropdown = ({
|
10
|
+
onSelectBlur,
|
11
|
+
onSelectOptionSelector,
|
12
|
+
dropdownPosition,
|
13
|
+
options = [],
|
14
|
+
optionZIndex = 100,
|
15
|
+
inputRef,
|
16
|
+
}: DropDownListProps) => {
|
17
|
+
const optionsWrapperRef = useRef<HTMLDivElement>(null);
|
18
|
+
useClickOutside(optionsWrapperRef, onSelectBlur, [inputRef]);
|
19
|
+
|
20
|
+
const { positionX, positionY, width, fromBottom } = dropdownPosition;
|
21
|
+
const { margin, optionHeight, selectInputHeight, dropDownWrapperPadding } =
|
22
|
+
dropdownDefaultCSSData;
|
23
|
+
|
24
|
+
const updateDropdownPosition = () => {
|
25
|
+
let dropdownContainerHeight;
|
26
|
+
|
27
|
+
if (checkEmpty(options)) {
|
28
|
+
dropdownContainerHeight = 32 + 2 * dropDownWrapperPadding;
|
29
|
+
} else if (options?.length > 5) {
|
30
|
+
dropdownContainerHeight = 160;
|
31
|
+
} else {
|
32
|
+
dropdownContainerHeight =
|
33
|
+
options.length * optionHeight + 2 * dropDownWrapperPadding;
|
34
|
+
}
|
35
|
+
|
36
|
+
if (fromBottom > dropdownContainerHeight + margin) {
|
37
|
+
return {
|
38
|
+
left: positionX,
|
39
|
+
top: positionY,
|
40
|
+
width: width,
|
41
|
+
zIndex: optionZIndex,
|
42
|
+
};
|
43
|
+
}
|
44
|
+
return {
|
45
|
+
zIndex: optionZIndex,
|
46
|
+
left: positionX,
|
47
|
+
width: width,
|
48
|
+
top: positionY - selectInputHeight - dropdownContainerHeight - margin,
|
49
|
+
};
|
50
|
+
};
|
51
|
+
|
52
|
+
return (
|
53
|
+
<div className="ff-select-dropdown-wrapper">
|
54
|
+
<div
|
55
|
+
ref={optionsWrapperRef}
|
56
|
+
// inline css required due to multiple overlay scenarios are present
|
57
|
+
style={updateDropdownPosition()}
|
58
|
+
className="ff-select-options-wrapper"
|
59
|
+
>
|
60
|
+
{!checkEmpty(options) ? (
|
61
|
+
options.map((option) => (
|
62
|
+
<Typography
|
63
|
+
key={ffid()}
|
64
|
+
as="div"
|
65
|
+
lineHeight="30px"
|
66
|
+
className="ff-select-option"
|
67
|
+
color="var(--ff-select-text-color)"
|
68
|
+
onClick={() => onSelectOptionSelector(option)}
|
69
|
+
>
|
70
|
+
{option.label}
|
71
|
+
</Typography>
|
72
|
+
))
|
73
|
+
) : (
|
74
|
+
<Typography
|
75
|
+
textAlign="center"
|
76
|
+
lineHeight="32px"
|
77
|
+
as="p"
|
78
|
+
color="var(--ff-select-text-color)"
|
79
|
+
className="ff-select-no-option"
|
80
|
+
>
|
81
|
+
No Results found
|
82
|
+
</Typography>
|
83
|
+
)}
|
84
|
+
</div>
|
85
|
+
</div>
|
86
|
+
);
|
87
|
+
};
|
88
|
+
|
89
|
+
export default Dropdown;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { DrowdownPosition, Option } from '../../types';
|
2
|
+
|
3
|
+
export interface DropDownListProps {
|
4
|
+
onSelectBlur: () => void;
|
5
|
+
onSelectOptionSelector: (option: Option) => void;
|
6
|
+
dropdownPosition: DrowdownPosition;
|
7
|
+
options?: Option[];
|
8
|
+
optionZIndex?: number;
|
9
|
+
inputRef?: React.RefObject<HTMLInputElement>;
|
10
|
+
}
|
11
|
+
|
12
|
+
export const dropdownDefaultCSSData = {
|
13
|
+
margin: 6,
|
14
|
+
optionHeight: 32,
|
15
|
+
selectInputHeight: 38,
|
16
|
+
|
17
|
+
// Future use case if we provide padding-top, padding-bottom for option wrapper
|
18
|
+
dropDownWrapperPadding: 0,
|
19
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './Select';
|
@@ -0,0 +1,122 @@
|
|
1
|
+
import { ReactNode } from "react";
|
2
|
+
|
3
|
+
export interface SelectProps {
|
4
|
+
/*
|
5
|
+
* Label for the select dropdown
|
6
|
+
*/
|
7
|
+
label?: string;
|
8
|
+
|
9
|
+
/*
|
10
|
+
* If true, the select dropdown will have a label
|
11
|
+
*/
|
12
|
+
showLabel?: boolean;
|
13
|
+
|
14
|
+
/*
|
15
|
+
* Options for the select dropdown
|
16
|
+
*/
|
17
|
+
optionsList: Option[];
|
18
|
+
|
19
|
+
/*
|
20
|
+
* Selected option for the select dropdown
|
21
|
+
*/
|
22
|
+
selectedOption?: Option;
|
23
|
+
|
24
|
+
/*
|
25
|
+
* onChange callback function for handling selected option changes
|
26
|
+
*/
|
27
|
+
onChange: (option: Option) => void;
|
28
|
+
|
29
|
+
/*
|
30
|
+
* If error is true, this message will be displayed
|
31
|
+
*/
|
32
|
+
errorMsg?: string;
|
33
|
+
|
34
|
+
/*
|
35
|
+
* provide the className for the select dropdown
|
36
|
+
*/
|
37
|
+
className?: string;
|
38
|
+
|
39
|
+
/*
|
40
|
+
* Providing the z-index for dropdown and select
|
41
|
+
*/
|
42
|
+
optionZIndex?: number;
|
43
|
+
|
44
|
+
/*
|
45
|
+
* Provide disable prop for the disabling the select component
|
46
|
+
*/
|
47
|
+
disabled?: boolean;
|
48
|
+
|
49
|
+
/*
|
50
|
+
* Provide disable prop for the providing border radius at right side
|
51
|
+
*/
|
52
|
+
borderRadius?: boolean;
|
53
|
+
|
54
|
+
/*
|
55
|
+
* Provide boolean value to show border or not
|
56
|
+
*/
|
57
|
+
showBorder?: boolean;
|
58
|
+
|
59
|
+
/*
|
60
|
+
* Provide the boolean value if the select component is required or not
|
61
|
+
*/
|
62
|
+
required?: boolean;
|
63
|
+
}
|
64
|
+
|
65
|
+
export interface DrowdownPosition {
|
66
|
+
positionX: number;
|
67
|
+
positionY: number;
|
68
|
+
width: number;
|
69
|
+
fromBottom: number;
|
70
|
+
}
|
71
|
+
|
72
|
+
export interface SelectState {
|
73
|
+
isInputFocused: boolean;
|
74
|
+
iconColor: string;
|
75
|
+
isIconClick: boolean;
|
76
|
+
showOptions: boolean;
|
77
|
+
options: Option[];
|
78
|
+
option: string;
|
79
|
+
dropdownPosition: DrowdownPosition;
|
80
|
+
}
|
81
|
+
|
82
|
+
export type SelectAction =
|
83
|
+
| { type: 'FOCUS_INPUT' }
|
84
|
+
| {
|
85
|
+
type: 'BLUR_INPUT';
|
86
|
+
payload: {
|
87
|
+
optionsList: Option[];
|
88
|
+
option: Option['value'];
|
89
|
+
};
|
90
|
+
}
|
91
|
+
| { type: 'MOUSE_ENTER' }
|
92
|
+
| { type: 'MOUSE_LEAVE' }
|
93
|
+
| {
|
94
|
+
type: 'UPDATE_DROPDOWN_POSITION';
|
95
|
+
payload: {
|
96
|
+
positionX: number;
|
97
|
+
positionY: number;
|
98
|
+
width: number;
|
99
|
+
fromBottom: number;
|
100
|
+
};
|
101
|
+
}
|
102
|
+
| {
|
103
|
+
type: 'UPDATE_OPTION';
|
104
|
+
payload: string;
|
105
|
+
}
|
106
|
+
| {
|
107
|
+
type: 'UPDATE_OPTION_LIST';
|
108
|
+
payload: Option[];
|
109
|
+
}
|
110
|
+
| {
|
111
|
+
type: 'SHOW_ERROR';
|
112
|
+
payload: {
|
113
|
+
optionsList: Option[];
|
114
|
+
option: Option['value'];
|
115
|
+
};
|
116
|
+
};
|
117
|
+
|
118
|
+
export interface Option {
|
119
|
+
label: string | ReactNode;
|
120
|
+
value: string;
|
121
|
+
disabled?: boolean;
|
122
|
+
}
|