@mindlogic-ai/logician-ui 2.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +234 -0
- package/USAGE.md +299 -0
- package/dist/Markdown-2D5K42BY.js +16 -0
- package/dist/Markdown-2D5K42BY.js.map +1 -0
- package/dist/Markdown-AZBXO5ZP.css +29 -0
- package/dist/Markdown-AZBXO5ZP.css.map +1 -0
- package/dist/Markdown-RJJEQN4R.mjs +3 -0
- package/dist/Markdown-RJJEQN4R.mjs.map +1 -0
- package/dist/analytics-GNSHP7X3.svg +1 -0
- package/dist/bulb-24SQINQB.svg +1 -0
- package/dist/chat-TLRFEUAS.svg +1 -0
- package/dist/chunk-5FHXD7KR.js +1735 -0
- package/dist/chunk-5FHXD7KR.js.map +1 -0
- package/dist/chunk-WSOHBA2C.mjs +1693 -0
- package/dist/chunk-WSOHBA2C.mjs.map +1 -0
- package/dist/edit-RWL72JNM.svg +1 -0
- package/dist/face-55KPDCH4.svg +1 -0
- package/dist/filled-analytics-RBC7KWND.svg +1 -0
- package/dist/filled-bulb-RC7E2WSM.svg +1 -0
- package/dist/filled-chat-A6J44Q7A.svg +1 -0
- package/dist/filled-edit-NKKWFSTW.svg +1 -0
- package/dist/filled-face-UML5C3LB.svg +1 -0
- package/dist/filled-layout-HBVCSDFO.svg +1 -0
- package/dist/index.css +51 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +964 -0
- package/dist/index.d.ts +964 -0
- package/dist/index.js +5600 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5401 -0
- package/dist/index.mjs.map +1 -0
- package/dist/language-VBJ24OPV.svg +1 -0
- package/dist/layout-NDDSWNNV.svg +1 -0
- package/dist/pending-NF7NSBYO.svg +1 -0
- package/dist/receipt-MNLQIFCO.svg +1 -0
- package/dist/sparkles-EOEGVL6G.svg +1 -0
- package/dist/store-3RQPBJWG.svg +1 -0
- package/dist/store_active-SAOAGVKC.svg +1 -0
- package/dist/studio-LYPUIEFA.svg +1 -0
- package/dist/studio_active-BC6O66OI.svg +1 -0
- package/dist/vertical-ellipsis-3G4WEOCW.svg +1 -0
- package/package.json +138 -0
- package/src/components/Accordion/Accordion.stories.tsx +41 -0
- package/src/components/Accordion/Accordion.tsx +14 -0
- package/src/components/Accordion/AccordionButton.tsx +40 -0
- package/src/components/Accordion/AccordionItem.tsx +17 -0
- package/src/components/Accordion/index.ts +4 -0
- package/src/components/Alert/Alert.stories.tsx +38 -0
- package/src/components/Alert/Alert.styles.ts +19 -0
- package/src/components/Alert/Alert.tsx +41 -0
- package/src/components/Alert/Alert.types.ts +5 -0
- package/src/components/Alert/index.ts +1 -0
- package/src/components/AutowidthInput/AutowidthInput.stories.tsx +23 -0
- package/src/components/AutowidthInput/AutowidthInput.tsx +47 -0
- package/src/components/AutowidthInput/index.ts +1 -0
- package/src/components/Avatar/Avatar.stories.tsx +23 -0
- package/src/components/Avatar/Avatar.tsx +19 -0
- package/src/components/Avatar/index.tsx +1 -0
- package/src/components/Badge/Badge.stories.tsx +23 -0
- package/src/components/Badge/Badge.styles.ts +11 -0
- package/src/components/Badge/Badge.tsx +26 -0
- package/src/components/Badge/index.ts +2 -0
- package/src/components/Banner/Banner.stories.tsx +37 -0
- package/src/components/Banner/Banner.styles.ts +79 -0
- package/src/components/Banner/Banner.tsx +68 -0
- package/src/components/Banner/Banner.types.ts +6 -0
- package/src/components/Banner/index.ts +2 -0
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +14 -0
- package/src/components/Breadcrumb/Breadcrumb.tsx +19 -0
- package/src/components/Breadcrumb/Breadcrumb.types.ts +3 -0
- package/src/components/Breadcrumb/BreadcrumbItem/BreadcrumbItem.tsx +12 -0
- package/src/components/Breadcrumb/BreadcrumbItem/BreadcrumbItem.types.ts +3 -0
- package/src/components/Breadcrumb/BreadcrumbItem/index.ts +2 -0
- package/src/components/Breadcrumb/BreadcrumbLink/BreadcrumbLink.tsx +30 -0
- package/src/components/Breadcrumb/BreadcrumbLink/BreadcrumbLink.types.ts +3 -0
- package/src/components/Breadcrumb/BreadcrumbLink/index.ts +2 -0
- package/src/components/Breadcrumb/index.ts +3 -0
- package/src/components/Button/Button.stories.tsx +52 -0
- package/src/components/Button/Button.styles.ts +59 -0
- package/src/components/Button/Button.tsx +43 -0
- package/src/components/Button/Button.types.ts +13 -0
- package/src/components/Button/index.tsx +3 -0
- package/src/components/Card/Card.stories.tsx +24 -0
- package/src/components/Card/Card.styles.ts +30 -0
- package/src/components/Card/Card.tsx +29 -0
- package/src/components/Card/Card.types.ts +8 -0
- package/src/components/Card/index.ts +2 -0
- package/src/components/Carousel/Carousel.stories.tsx +159 -0
- package/src/components/Carousel/Carousel.tsx +160 -0
- package/src/components/Carousel/Carousel.types.ts +22 -0
- package/src/components/Carousel/index.ts +1 -0
- package/src/components/CarouselModal/CarouselModal.stories.tsx +53 -0
- package/src/components/CarouselModal/CarouselModal.tsx +106 -0
- package/src/components/CarouselModal/CarouselModal.types.ts +16 -0
- package/src/components/CarouselModal/index.ts +2 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +16 -0
- package/src/components/Checkbox/Checkbox.tsx +29 -0
- package/src/components/Checkbox/Checkbox.types.ts +3 -0
- package/src/components/Checkbox/index.ts +2 -0
- package/src/components/Chip/Chip.stories.tsx +44 -0
- package/src/components/Chip/Chip.styles.ts +114 -0
- package/src/components/Chip/Chip.tsx +23 -0
- package/src/components/Chip/Chip.types.ts +14 -0
- package/src/components/Chip/index.ts +2 -0
- package/src/components/ChipButton/Chip.types.ts +4 -0
- package/src/components/ChipButton/ChipButton.tsx +25 -0
- package/src/components/ChipButton/index.ts +1 -0
- package/src/components/Code/Code.stories.tsx +28 -0
- package/src/components/Code/Code.tsx +160 -0
- package/src/components/Code/Code.types.ts +40 -0
- package/src/components/Code/_components/CopyButton.tsx +48 -0
- package/src/components/Code/index.ts +1 -0
- package/src/components/CodeTabs/CodeTabs.stories.tsx +51 -0
- package/src/components/CodeTabs/CodeTabs.tsx +98 -0
- package/src/components/CodeTabs/CodeTabs.types.ts +17 -0
- package/src/components/CodeTabs/index.ts +1 -0
- package/src/components/Container/Container.stories.tsx +28 -0
- package/src/components/Container/Container.tsx +21 -0
- package/src/components/Container/index.ts +1 -0
- package/src/components/Container/useContainerSize.ts +47 -0
- package/src/components/CopyableCode/CopyableCode.stories.tsx +26 -0
- package/src/components/CopyableCode/CopyableCode.tsx +58 -0
- package/src/components/CopyableCode/CopyableCode.types.ts +7 -0
- package/src/components/CopyableCode/index.ts +2 -0
- package/src/components/CrossPageToasts/CrossPageToasts.tsx +33 -0
- package/src/components/CrossPageToasts/index.ts +1 -0
- package/src/components/DataField/DataField.stories.tsx +61 -0
- package/src/components/DataField/DataField.styles.ts +33 -0
- package/src/components/DataField/DataField.tsx +141 -0
- package/src/components/DataField/DataField.types.ts +18 -0
- package/src/components/DataField/index.ts +1 -0
- package/src/components/DatePicker/RangeDatePicker.stories.tsx +45 -0
- package/src/components/DatePicker/RangeDatePicker.tsx +74 -0
- package/src/components/DatePicker/SingleDatePicker.stories.tsx +31 -0
- package/src/components/DatePicker/SingleDatePicker.tsx +72 -0
- package/src/components/DatePicker/index.ts +2 -0
- package/src/components/FileInput/FileInput.stories.tsx +28 -0
- package/src/components/FileInput/FileInput.tsx +117 -0
- package/src/components/FileInput/FileInput.types.ts +14 -0
- package/src/components/FileInput/index.ts +2 -0
- package/src/components/FileItem/FileItem.stories.tsx +27 -0
- package/src/components/FileItem/FileItem.tsx +134 -0
- package/src/components/FileItem/FileItem.types.ts +11 -0
- package/src/components/FileItem/index.ts +1 -0
- package/src/components/FileList/FileList.stories.tsx +65 -0
- package/src/components/FileList/FileList.tsx +97 -0
- package/src/components/FileList/FileList.types.ts +18 -0
- package/src/components/FileList/index.tsx +1 -0
- package/src/components/FormControl/FormControl.stories.tsx +16 -0
- package/src/components/FormControl/FormControl.tsx +12 -0
- package/src/components/FormControl/FormControl.types.ts +3 -0
- package/src/components/FormControl/index.ts +2 -0
- package/src/components/FormLabel/FormLabel.tsx +5 -0
- package/src/components/FormLabel/index.ts +1 -0
- package/src/components/GuideCue/GuideCue.stories.tsx +57 -0
- package/src/components/GuideCue/GuideCue.tsx +231 -0
- package/src/components/GuideCue/GuideCueContext.tsx +70 -0
- package/src/components/GuideCue/index.ts +2 -0
- package/src/components/Icon/Icon.stories.tsx +77 -0
- package/src/components/Icon/Icon.styles.ts +6 -0
- package/src/components/Icon/Icon.tsx +73 -0
- package/src/components/Icon/Icon.types.ts +10 -0
- package/src/components/Icon/IconMap.ts +290 -0
- package/src/components/Icon/icons/analytics.svg +1 -0
- package/src/components/Icon/icons/bulb.svg +1 -0
- package/src/components/Icon/icons/chat.svg +1 -0
- package/src/components/Icon/icons/edit.svg +1 -0
- package/src/components/Icon/icons/face.svg +1 -0
- package/src/components/Icon/icons/filled-analytics.svg +1 -0
- package/src/components/Icon/icons/filled-bulb.svg +1 -0
- package/src/components/Icon/icons/filled-chat.svg +1 -0
- package/src/components/Icon/icons/filled-edit.svg +1 -0
- package/src/components/Icon/icons/filled-face.svg +1 -0
- package/src/components/Icon/icons/filled-layout.svg +1 -0
- package/src/components/Icon/icons/language.svg +1 -0
- package/src/components/Icon/icons/layout.svg +1 -0
- package/src/components/Icon/icons/pending.svg +1 -0
- package/src/components/Icon/icons/receipt.svg +1 -0
- package/src/components/Icon/icons/sparkles.svg +1 -0
- package/src/components/Icon/icons/store.svg +1 -0
- package/src/components/Icon/icons/store_active.svg +1 -0
- package/src/components/Icon/icons/studio.svg +1 -0
- package/src/components/Icon/icons/studio_active.svg +1 -0
- package/src/components/Icon/icons/vertical-ellipsis.svg +1 -0
- package/src/components/Icon/index.tsx +3 -0
- package/src/components/IconButton/IconButton.stories.tsx +51 -0
- package/src/components/IconButton/IconButton.styles.ts +52 -0
- package/src/components/IconButton/IconButton.tsx +36 -0
- package/src/components/IconButton/IconButton.types.ts +12 -0
- package/src/components/IconButton/index.tsx +1 -0
- package/src/components/InfoSprinkle/InfoSprinkle.stories.tsx +25 -0
- package/src/components/InfoSprinkle/InfoSprinkle.tsx +48 -0
- package/src/components/InfoSprinkle/index.ts +1 -0
- package/src/components/InlineCode/InlineCode.tsx +18 -0
- package/src/components/InlineCode/index.ts +1 -0
- package/src/components/Input/Input.stories.tsx +55 -0
- package/src/components/Input/Input.tsx +358 -0
- package/src/components/Input/Input.types.ts +19 -0
- package/src/components/Input/index.tsx +2 -0
- package/src/components/LineGraph/LineGraph.stories.tsx +98 -0
- package/src/components/LineGraph/LineGraph.tsx +88 -0
- package/src/components/LineGraph/LineGraph.types.ts +41 -0
- package/src/components/LineGraph/index.ts +1 -0
- package/src/components/Link/Link.styles.ts +13 -0
- package/src/components/Link/Link.tsx +93 -0
- package/src/components/Link/index.ts +1 -0
- package/src/components/Loaders/PageLoader.stories.tsx +29 -0
- package/src/components/Loaders/PageLoader.tsx +30 -0
- package/src/components/Loaders/SectionLoader.stories.tsx +26 -0
- package/src/components/Loaders/SectionLoader.tsx +30 -0
- package/src/components/Loaders/index.ts +1 -0
- package/src/components/MDXEditor/MDXEditor.css +21 -0
- package/src/components/MDXEditor/MDXEditor.stories.tsx +45 -0
- package/src/components/MDXEditor/MDXEditor.tsx +189 -0
- package/src/components/MDXEditor/MDXEditor.types.ts +6 -0
- package/src/components/MDXEditor/index.ts +1 -0
- package/src/components/Markdown/Markdown.module.css +30 -0
- package/src/components/Markdown/Markdown.tsx +133 -0
- package/src/components/Markdown/Markdown.types.ts +5 -0
- package/src/components/Markdown/index.ts +2 -0
- package/src/components/Masonry/Masonry.stories.tsx +288 -0
- package/src/components/Masonry/Masonry.tsx +187 -0
- package/src/components/Masonry/Masonry.types.ts +18 -0
- package/src/components/Masonry/index.ts +2 -0
- package/src/components/MaxLengthIndicator/MaxLengthIndicator.stories.tsx +26 -0
- package/src/components/MaxLengthIndicator/MaxLengthIndicator.tsx +25 -0
- package/src/components/MaxLengthIndicator/index.tsx +1 -0
- package/src/components/Menu/Menu.stories.tsx +186 -0
- package/src/components/Menu/MenuButton.tsx +8 -0
- package/src/components/Menu/MenuButton.types.ts +23 -0
- package/src/components/Menu/MenuItem.tsx +35 -0
- package/src/components/Menu/MenuItem.types.ts +13 -0
- package/src/components/Menu/MenuList.tsx +19 -0
- package/src/components/Menu/index.ts +7 -0
- package/src/components/Modal/Modal.stories.tsx +83 -0
- package/src/components/Modal/Modal.styles.ts +14 -0
- package/src/components/Modal/Modal.tsx +14 -0
- package/src/components/Modal/Modal.types.ts +3 -0
- package/src/components/Modal/ModalBody.tsx +9 -0
- package/src/components/Modal/ModalCloseButton.tsx +18 -0
- package/src/components/Modal/ModalContent/ModalContent.tsx +8 -0
- package/src/components/Modal/ModalContent/ModalContent.types.ts +3 -0
- package/src/components/Modal/ModalContent/index.ts +1 -0
- package/src/components/Modal/ModalFooter/ModalFooter.module.css +3 -0
- package/src/components/Modal/ModalFooter/ModalFooter.tsx +20 -0
- package/src/components/Modal/ModalFooter/index.ts +1 -0
- package/src/components/Modal/ModalHeader.tsx +9 -0
- package/src/components/Modal/ModalOverlay.tsx +9 -0
- package/src/components/Modal/index.tsx +8 -0
- package/src/components/MonthRangePicker/MonthButton/MonthButton.tsx +105 -0
- package/src/components/MonthRangePicker/MonthButton/MonthButton.types.ts +42 -0
- package/src/components/MonthRangePicker/MonthButton/index.ts +2 -0
- package/src/components/MonthRangePicker/MonthRangePicker.stories.tsx +164 -0
- package/src/components/MonthRangePicker/MonthRangePicker.tsx +274 -0
- package/src/components/MonthRangePicker/MonthRangePicker.types.ts +38 -0
- package/src/components/MonthRangePicker/_utils/hasEnabledMonthsInYear.ts +15 -0
- package/src/components/MonthRangePicker/_utils/index.ts +6 -0
- package/src/components/MonthRangePicker/_utils/isMonthDisabled.ts +20 -0
- package/src/components/MonthRangePicker/_utils/isMonthInPreviewRange.ts +32 -0
- package/src/components/MonthRangePicker/_utils/isMonthInRange.ts +17 -0
- package/src/components/MonthRangePicker/_utils/isMonthSelected.ts +19 -0
- package/src/components/MonthRangePicker/_utils/isSelectionStart.ts +12 -0
- package/src/components/MonthRangePicker/constants.ts +63 -0
- package/src/components/MonthRangePicker/index.ts +2 -0
- package/src/components/Pagination/Pagination.stories.tsx +51 -0
- package/src/components/Pagination/Pagination.tsx +150 -0
- package/src/components/Pagination/Pagination.types.ts +12 -0
- package/src/components/Pagination/index.tsx +1 -0
- package/src/components/PasswordInput/PasswordInput.stories.tsx +16 -0
- package/src/components/PasswordInput/PasswordInput.tsx +42 -0
- package/src/components/PasswordInput/PasswordInput.types.ts +11 -0
- package/src/components/PasswordInput/index.ts +1 -0
- package/src/components/PinInput/PinInput.stories.tsx +26 -0
- package/src/components/PinInput/PinInput.tsx +53 -0
- package/src/components/PinInput/PinInput.types.ts +27 -0
- package/src/components/PinInput/index.tsx +2 -0
- package/src/components/ProgressBar/ProgressBar.stories.tsx +18 -0
- package/src/components/ProgressBar/ProgressBar.styles.ts +4 -0
- package/src/components/ProgressBar/ProgressBar.tsx +27 -0
- package/src/components/ProgressBar/ProgressBar.types.ts +4 -0
- package/src/components/ProgressBar/index.ts +1 -0
- package/src/components/RadialProgress/RadialProgress.stories.tsx +272 -0
- package/src/components/RadialProgress/RadialProgress.tsx +232 -0
- package/src/components/RadialProgress/RadialProgress.types.ts +27 -0
- package/src/components/RadialProgress/index.ts +2 -0
- package/src/components/Radio/Radio.stories.tsx +226 -0
- package/src/components/Radio/Radio.tsx +35 -0
- package/src/components/Radio/Radio.types.ts +21 -0
- package/src/components/Radio/RadioGroup.tsx +26 -0
- package/src/components/Radio/index.ts +3 -0
- package/src/components/SeeMoreButton/SeeMoreButton.stories.tsx +48 -0
- package/src/components/SeeMoreButton/SeeMoreButton.styles.ts +11 -0
- package/src/components/SeeMoreButton/SeeMoreButton.tsx +34 -0
- package/src/components/SeeMoreButton/SeeMoreButton.types.ts +6 -0
- package/src/components/SeeMoreButton/index.tsx +1 -0
- package/src/components/SegmentedControl/SegmentedControl.stories.tsx +96 -0
- package/src/components/SegmentedControl/SegmentedControl.styles.ts +28 -0
- package/src/components/SegmentedControl/SegmentedControl.tsx +89 -0
- package/src/components/SegmentedControl/SegmentedControl.types.ts +15 -0
- package/src/components/SegmentedControl/index.ts +2 -0
- package/src/components/SegmentedProgressBar/ProgressSegment.tsx +18 -0
- package/src/components/SegmentedProgressBar/SegmentedProgressBar.stories.tsx +228 -0
- package/src/components/SegmentedProgressBar/SegmentedProgressBar.tsx +25 -0
- package/src/components/SegmentedProgressBar/SegmentedProgressBar.types.ts +11 -0
- package/src/components/SegmentedProgressBar/SegmentedProgressBarContext.tsx +24 -0
- package/src/components/SegmentedProgressBar/index.ts +3 -0
- package/src/components/Select/MenuList/MenuList.tsx +87 -0
- package/src/components/Select/MenuList/MenuList.types.ts +21 -0
- package/src/components/Select/MenuList/VirtualizedMenuList.tsx +140 -0
- package/src/components/Select/MenuList/VirtualizedMenuListContext.tsx +35 -0
- package/src/components/Select/MenuList/index.ts +3 -0
- package/src/components/Select/Select.stories.tsx +70 -0
- package/src/components/Select/Select.styles.ts +102 -0
- package/src/components/Select/Select.tsx +204 -0
- package/src/components/Select/Select.types.ts +18 -0
- package/src/components/Select/_utils/resolveStyle.ts +21 -0
- package/src/components/Select/index.ts +1 -0
- package/src/components/Slider/Slider.stories.tsx +75 -0
- package/src/components/Slider/Slider.tsx +12 -0
- package/src/components/Slider/Slider.types.ts +3 -0
- package/src/components/Slider/SliderFilledTrack/SliderFilledTrack.tsx +14 -0
- package/src/components/Slider/SliderFilledTrack/SliderFilledTrack.types.ts +3 -0
- package/src/components/Slider/SliderFilledTrack/index.ts +2 -0
- package/src/components/Slider/SliderMark/SliderMark.tsx +12 -0
- package/src/components/Slider/SliderMark/SliderMark.types.ts +3 -0
- package/src/components/Slider/SliderMark/index.ts +2 -0
- package/src/components/Slider/SliderThumb/SliderThumb.tsx +22 -0
- package/src/components/Slider/SliderThumb/SliderThumb.types.ts +3 -0
- package/src/components/Slider/SliderThumb/index.ts +2 -0
- package/src/components/Slider/SliderTrack/SliderTrack.tsx +12 -0
- package/src/components/Slider/SliderTrack/SliderTrack.types.ts +3 -0
- package/src/components/Slider/SliderTrack/index.ts +2 -0
- package/src/components/Slider/index.ts +5 -0
- package/src/components/Spinner/Spinner.stories.tsx +16 -0
- package/src/components/Spinner/Spinner.tsx +20 -0
- package/src/components/Spinner/Spinner.types.ts +3 -0
- package/src/components/Spinner/index.ts +2 -0
- package/src/components/Switch/Switch.stories.tsx +63 -0
- package/src/components/Switch/Switch.tsx +8 -0
- package/src/components/Switch/index.ts +1 -0
- package/src/components/Table/ExpandingTr/ExpandingTr.tsx +31 -0
- package/src/components/Table/ExpandingTr/ExpandingTr.types.ts +9 -0
- package/src/components/Table/ExpandingTr/index.ts +2 -0
- package/src/components/Table/Table.stories.tsx +326 -0
- package/src/components/Table/Table.styles.ts +48 -0
- package/src/components/Table/Table.tsx +9 -0
- package/src/components/Table/Table.types.ts +16 -0
- package/src/components/Table/TableContainer.tsx +55 -0
- package/src/components/Table/TableContext.tsx +187 -0
- package/src/components/Table/Tbody.tsx +12 -0
- package/src/components/Table/Td.tsx +138 -0
- package/src/components/Table/Th.tsx +154 -0
- package/src/components/Table/Thead.tsx +5 -0
- package/src/components/Table/Tr.tsx +5 -0
- package/src/components/Table/index.tsx +8 -0
- package/src/components/Tabs/Tab/Tab.styles.ts +35 -0
- package/src/components/Tabs/Tab/Tab.tsx +67 -0
- package/src/components/Tabs/Tab/index.ts +1 -0
- package/src/components/Tabs/TabList/TabList.styles.ts +11 -0
- package/src/components/Tabs/TabList/TabList.tsx +19 -0
- package/src/components/Tabs/TabList/index.ts +1 -0
- package/src/components/Tabs/TabPanel.tsx +5 -0
- package/src/components/Tabs/TabPanels.tsx +5 -0
- package/src/components/Tabs/Tabs.stories.tsx +45 -0
- package/src/components/Tabs/Tabs.tsx +65 -0
- package/src/components/Tabs/Tabs.types.ts +19 -0
- package/src/components/Tabs/TabsContext.tsx +162 -0
- package/src/components/Tabs/index.tsx +5 -0
- package/src/components/Tag/Tag.stories.tsx +28 -0
- package/src/components/Tag/Tag.styles.ts +12 -0
- package/src/components/Tag/Tag.tsx +23 -0
- package/src/components/Tag/Tag.types.ts +5 -0
- package/src/components/Tag/TagCloseButton/TagCloseButton.tsx +12 -0
- package/src/components/Tag/TagCloseButton/TagCloseButton.types.ts +3 -0
- package/src/components/Tag/TagCloseButton/index.ts +2 -0
- package/src/components/Tag/TagLabel/TagLabel.tsx +12 -0
- package/src/components/Tag/TagLabel/TagLabel.types.ts +3 -0
- package/src/components/Tag/TagLabel/index.ts +2 -0
- package/src/components/Tag/TagLeftIcon/TagLeftIcon.tsx +12 -0
- package/src/components/Tag/TagLeftIcon/TagLeftIcon.types.ts +3 -0
- package/src/components/Tag/TagLeftIcon/index.ts +2 -0
- package/src/components/Tag/TagRightIcon/TagRightIcon.tsx +12 -0
- package/src/components/Tag/TagRightIcon/TagRightIcon.types.ts +3 -0
- package/src/components/Tag/TagRightIcon/index.ts +2 -0
- package/src/components/Tag/index.ts +5 -0
- package/src/components/Textarea/Textarea.tsx +56 -0
- package/src/components/Textarea/adjustHeight.tsx +9 -0
- package/src/components/Textarea/index.ts +1 -0
- package/src/components/Toast/Toast.stories.tsx +49 -0
- package/src/components/Toast/Toast.styles.ts +19 -0
- package/src/components/Toast/Toast.tsx +38 -0
- package/src/components/Toast/Toast.types.ts +22 -0
- package/src/components/Toast/ToastIcon/ToastIcon.tsx +26 -0
- package/src/components/Toast/ToastIcon/index.ts +0 -0
- package/src/components/Toast/index.ts +2 -0
- package/src/components/Toast/useToast.tsx +65 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +97 -0
- package/src/components/Tooltip/Tooltip.tsx +22 -0
- package/src/components/Tooltip/Tooltip.types.ts +3 -0
- package/src/components/Tooltip/index.ts +2 -0
- package/src/components/Typography/H1.tsx +17 -0
- package/src/components/Typography/H2.tsx +17 -0
- package/src/components/Typography/H3.tsx +17 -0
- package/src/components/Typography/H4.tsx +17 -0
- package/src/components/Typography/H5.tsx +17 -0
- package/src/components/Typography/Link.tsx +49 -0
- package/src/components/Typography/Subtext.tsx +17 -0
- package/src/components/Typography/Subtitle.tsx +18 -0
- package/src/components/Typography/Text.tsx +22 -0
- package/src/components/Typography/Typography.stories.tsx +54 -0
- package/src/components/Typography/Typography.types.ts +3 -0
- package/src/components/Typography/index.ts +26 -0
- package/src/components/UrlInput/UrlInput.stories.tsx +66 -0
- package/src/components/UrlInput/UrlInput.tsx +47 -0
- package/src/components/UrlInput/index.tsx +1 -0
- package/src/hooks/useLocale.ts +11 -0
- package/src/hooks/useTranslate.ts +57 -0
- package/src/index.ts +96 -0
- package/src/theme/Palette.stories.tsx +171 -0
- package/src/theme/colors.ts +64 -0
- package/src/theme/font.ts +23 -0
- package/src/theme/global.ts +30 -0
- package/src/theme/index.ts +49 -0
- package/src/translations/Defaults.translations.json +100 -0
- package/src/types/css-modules.d.ts +0 -0
- package/src/types/svg.d.ts +15 -0
- package/src/utils/findKeyByValue.ts +17 -0
- package/src/utils/formatDateByLocale.ts +36 -0
- package/src/utils/formatFileSize.ts +14 -0
- package/src/utils/formatNumber.ts +29 -0
- package/src/utils/formatTextForMarkdown.ts +3 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, {
|
|
4
|
+
createContext,
|
|
5
|
+
PropsWithChildren,
|
|
6
|
+
useCallback,
|
|
7
|
+
useContext,
|
|
8
|
+
useLayoutEffect,
|
|
9
|
+
useState,
|
|
10
|
+
} from 'react';
|
|
11
|
+
import { TabsProps as ChakraTabsProps } from '@chakra-ui/react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
|
|
14
|
+
// Optional Next.js navigation hooks with fallbacks
|
|
15
|
+
let useRouter:
|
|
16
|
+
| (() => { replace: (url: string, options?: any) => void })
|
|
17
|
+
| null = null;
|
|
18
|
+
let usePathname: (() => string) | null = null;
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
// Try to import Next.js navigation hooks
|
|
22
|
+
const nextNavigation = require('next/navigation');
|
|
23
|
+
useRouter = nextNavigation.useRouter;
|
|
24
|
+
usePathname = nextNavigation.usePathname;
|
|
25
|
+
} catch (error) {
|
|
26
|
+
// Next.js not available - create fallback implementations
|
|
27
|
+
useRouter = () => ({
|
|
28
|
+
replace: (url: string, options?: any) => {
|
|
29
|
+
if (typeof window !== 'undefined') {
|
|
30
|
+
window.history.replaceState(null, '', url);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
usePathname = () =>
|
|
35
|
+
typeof window !== 'undefined' ? window.location.pathname : '/';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface TabsContextProps {
|
|
39
|
+
orientation: ChakraTabsProps['orientation'];
|
|
40
|
+
urlParam?: string;
|
|
41
|
+
tabNames: string[];
|
|
42
|
+
setTabNames: React.Dispatch<React.SetStateAction<string[]>>;
|
|
43
|
+
selectedIndex: number;
|
|
44
|
+
setSelectedIndex: (index: number) => void;
|
|
45
|
+
registerTabName: (index: number, name: string) => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const TabsContext = createContext<TabsContextProps>({
|
|
49
|
+
orientation: undefined,
|
|
50
|
+
urlParam: undefined,
|
|
51
|
+
tabNames: [],
|
|
52
|
+
setTabNames: () => {},
|
|
53
|
+
selectedIndex: 0,
|
|
54
|
+
setSelectedIndex: () => {},
|
|
55
|
+
registerTabName: () => {},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const useTabsContext = () => useContext(TabsContext);
|
|
59
|
+
|
|
60
|
+
export function TabsProvider({
|
|
61
|
+
children,
|
|
62
|
+
orientation,
|
|
63
|
+
urlParam,
|
|
64
|
+
}: PropsWithChildren<{
|
|
65
|
+
orientation: ChakraTabsProps['orientation'];
|
|
66
|
+
urlParam?: string;
|
|
67
|
+
}>) {
|
|
68
|
+
const [tabNames, setTabNames] = useState<string[]>([]);
|
|
69
|
+
const [selectedIndex, setSelectedIndexState] = useState(0);
|
|
70
|
+
const router = useRouter?.() || { replace: () => {} };
|
|
71
|
+
const pathname = usePathname?.() || '/';
|
|
72
|
+
|
|
73
|
+
// A function to register a tab name at a specific index
|
|
74
|
+
const registerTabName = useCallback((index: number, name: string) => {
|
|
75
|
+
setTabNames((prev) => {
|
|
76
|
+
const newNames = [...prev];
|
|
77
|
+
newNames[index] = name;
|
|
78
|
+
return newNames;
|
|
79
|
+
});
|
|
80
|
+
}, []);
|
|
81
|
+
|
|
82
|
+
// On mount and when search parameters or tab names change, check URL for the tab parameter
|
|
83
|
+
useLayoutEffect(() => {
|
|
84
|
+
// Only sync from URL if Next.js navigation is available and urlParam is provided
|
|
85
|
+
if (!useRouter || !urlParam || tabNames.length === 0) return;
|
|
86
|
+
|
|
87
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
88
|
+
if (!searchParams) return;
|
|
89
|
+
|
|
90
|
+
const tabParam = searchParams.get(urlParam);
|
|
91
|
+
|
|
92
|
+
if (tabParam) {
|
|
93
|
+
const index = tabNames.indexOf(tabParam);
|
|
94
|
+
if (index !== -1) {
|
|
95
|
+
setSelectedIndexState(index);
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
// Handle case where the URL parameter doesn't match any tab
|
|
99
|
+
// Options: set to default tab, clear parameter, or log warning
|
|
100
|
+
console.warn(`Tab '${tabParam}' not found, defaulting to first tab`);
|
|
101
|
+
setSelectedIndexState(0);
|
|
102
|
+
}
|
|
103
|
+
}, [urlParam, tabNames, pathname]);
|
|
104
|
+
|
|
105
|
+
// When the selected index changes, update the URL
|
|
106
|
+
const setSelectedIndex = useCallback(
|
|
107
|
+
(index: number) => {
|
|
108
|
+
// Don't update if the index hasn't changed
|
|
109
|
+
if (index === selectedIndex) return;
|
|
110
|
+
|
|
111
|
+
setSelectedIndexState(index);
|
|
112
|
+
|
|
113
|
+
// Only sync with URL if Next.js navigation is available and urlParam is provided
|
|
114
|
+
if (
|
|
115
|
+
typeof window !== 'undefined' &&
|
|
116
|
+
urlParam &&
|
|
117
|
+
tabNames.length > index &&
|
|
118
|
+
tabNames[index] &&
|
|
119
|
+
useRouter && // Check if Next.js navigation is available
|
|
120
|
+
router.replace !== (() => {}) // Check if we have real router, not fallback
|
|
121
|
+
) {
|
|
122
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
123
|
+
// Create a new URLSearchParams based on the current search params
|
|
124
|
+
const params = new URLSearchParams(searchParams.toString());
|
|
125
|
+
const tabName = tabNames[index];
|
|
126
|
+
|
|
127
|
+
// Don't update URL if the parameter is already set correctly
|
|
128
|
+
if (searchParams.get(urlParam) === tabName) return;
|
|
129
|
+
|
|
130
|
+
params.set(urlParam, tabName);
|
|
131
|
+
|
|
132
|
+
// Replace the current URL
|
|
133
|
+
const newUrl = `${pathname}?${params.toString()}`;
|
|
134
|
+
router.replace(newUrl, { scroll: false });
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
[urlParam, tabNames, router, pathname, selectedIndex]
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<TabsContext.Provider
|
|
142
|
+
value={{
|
|
143
|
+
orientation,
|
|
144
|
+
urlParam,
|
|
145
|
+
tabNames,
|
|
146
|
+
setTabNames,
|
|
147
|
+
selectedIndex,
|
|
148
|
+
setSelectedIndex,
|
|
149
|
+
registerTabName,
|
|
150
|
+
}}
|
|
151
|
+
>
|
|
152
|
+
{children}
|
|
153
|
+
</TabsContext.Provider>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
TabsProvider.displayName = 'TabsProvider';
|
|
158
|
+
|
|
159
|
+
TabsProvider.propTypes = {
|
|
160
|
+
children: PropTypes.node,
|
|
161
|
+
contextDarkMode: PropTypes.bool,
|
|
162
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { Tag } from './Tag';
|
|
5
|
+
import { TagCloseButton } from './TagCloseButton';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Components/Tag',
|
|
9
|
+
component: Tag,
|
|
10
|
+
args: {
|
|
11
|
+
children: 'Insert your tag',
|
|
12
|
+
},
|
|
13
|
+
} as Meta<typeof Tag>;
|
|
14
|
+
|
|
15
|
+
const Template: StoryFn<typeof Tag> = (args) => <Tag {...args} />;
|
|
16
|
+
|
|
17
|
+
export const Default = Template.bind({});
|
|
18
|
+
Default.args = {};
|
|
19
|
+
|
|
20
|
+
export const Closable = Template.bind({});
|
|
21
|
+
Closable.args = {
|
|
22
|
+
children: (
|
|
23
|
+
<>
|
|
24
|
+
Insert your tag
|
|
25
|
+
<TagCloseButton />
|
|
26
|
+
</>
|
|
27
|
+
),
|
|
28
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ForwardedRef, forwardRef } from 'react';
|
|
2
|
+
import { Tag as ChakraTag } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
import { variantStyles } from './Tag.styles';
|
|
5
|
+
import { TagProps } from './Tag.types';
|
|
6
|
+
|
|
7
|
+
export const Tag = forwardRef(
|
|
8
|
+
(
|
|
9
|
+
{ variant = 'default', ...rest }: TagProps,
|
|
10
|
+
ref?: ForwardedRef<HTMLDivElement>
|
|
11
|
+
) => {
|
|
12
|
+
return (
|
|
13
|
+
<ChakraTag
|
|
14
|
+
border="1px solid"
|
|
15
|
+
{...variantStyles[variant]}
|
|
16
|
+
{...rest}
|
|
17
|
+
ref={ref}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
Tag.displayName = 'Tag';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ForwardedRef, forwardRef } from 'react';
|
|
2
|
+
import { TagCloseButton as ChakraTagCloseButton } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
import { TagCloseButtonProps } from './TagCloseButton.types';
|
|
5
|
+
|
|
6
|
+
export const TagCloseButton = forwardRef(
|
|
7
|
+
({ ...rest }: TagCloseButtonProps, ref?: ForwardedRef<HTMLDivElement>) => {
|
|
8
|
+
return <ChakraTagCloseButton {...rest} ref={ref} />;
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
TagCloseButton.displayName = 'TagCloseButton';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ForwardedRef, forwardRef } from 'react';
|
|
2
|
+
import { TagLabel as ChakraTagLabel } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
import { TagLabelProps } from './TagLabel.types';
|
|
5
|
+
|
|
6
|
+
export const TagLabel = forwardRef(
|
|
7
|
+
({ ...rest }: TagLabelProps, ref?: ForwardedRef<HTMLDivElement>) => {
|
|
8
|
+
return <ChakraTagLabel {...rest} ref={ref} />;
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
TagLabel.displayName = 'TagLabel';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ForwardedRef, forwardRef } from 'react';
|
|
2
|
+
import { TagLeftIcon as ChakraTagLeftIcon } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
import { TagLeftIconProps } from './TagLeftIcon.types';
|
|
5
|
+
|
|
6
|
+
export const TagLeftIcon = forwardRef(
|
|
7
|
+
({ ...rest }: TagLeftIconProps, ref?: ForwardedRef<SVGSVGElement>) => {
|
|
8
|
+
return <ChakraTagLeftIcon {...rest} ref={ref} />;
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
TagLeftIcon.displayName = 'TagLeftIcon';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ForwardedRef, forwardRef } from 'react';
|
|
2
|
+
import { TagRightIcon as ChakraTagRightIcon } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
import { TagRightIconProps } from './TagRightIcon.types';
|
|
5
|
+
|
|
6
|
+
export const TagRightIcon = forwardRef(
|
|
7
|
+
({ ...rest }: TagRightIconProps, ref?: ForwardedRef<SVGSVGElement>) => {
|
|
8
|
+
return <ChakraTagRightIcon {...rest} ref={ref} />;
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
TagRightIcon.displayName = 'TagRightIcon';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeEvent,
|
|
3
|
+
ForwardedRef,
|
|
4
|
+
forwardRef,
|
|
5
|
+
useEffect,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import {
|
|
9
|
+
Textarea as ChakraTextarea,
|
|
10
|
+
TextareaProps,
|
|
11
|
+
useTheme,
|
|
12
|
+
} from '@chakra-ui/react';
|
|
13
|
+
|
|
14
|
+
export const Textarea = forwardRef(
|
|
15
|
+
(
|
|
16
|
+
{
|
|
17
|
+
placeholder,
|
|
18
|
+
onChange,
|
|
19
|
+
value: propValue,
|
|
20
|
+
_focusVisible,
|
|
21
|
+
...props
|
|
22
|
+
}: TextareaProps,
|
|
23
|
+
ref?: ForwardedRef<HTMLTextAreaElement>
|
|
24
|
+
) => {
|
|
25
|
+
const theme = useTheme();
|
|
26
|
+
const [currentValue, setCurrentValue] = useState<
|
|
27
|
+
string | number | readonly string[] | undefined
|
|
28
|
+
>(propValue);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
setCurrentValue(propValue);
|
|
32
|
+
}, [propValue]);
|
|
33
|
+
|
|
34
|
+
const handleChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
|
|
35
|
+
setCurrentValue(e.target.value);
|
|
36
|
+
|
|
37
|
+
if (onChange) {
|
|
38
|
+
onChange(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return (
|
|
42
|
+
<ChakraTextarea
|
|
43
|
+
ref={ref}
|
|
44
|
+
placeholder={placeholder}
|
|
45
|
+
value={currentValue}
|
|
46
|
+
onChange={handleChange}
|
|
47
|
+
overflow="hidden"
|
|
48
|
+
resize="none"
|
|
49
|
+
focusBorderColor={theme.semanticTokens.colors.primary.main}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
Textarea.displayName = 'Textarea';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Textarea } from './Textarea';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Flex } from '@chakra-ui/react';
|
|
2
|
+
import { Meta } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { Button } from '../Button';
|
|
5
|
+
import { useToast } from './useToast';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof Text> = {
|
|
8
|
+
title: 'Components/Toast',
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
|
|
12
|
+
export function Toasts() {
|
|
13
|
+
const showToast = useToast();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Flex gap={3}>
|
|
17
|
+
<Button
|
|
18
|
+
onClick={() =>
|
|
19
|
+
showToast({
|
|
20
|
+
description: 'Your action was successful.',
|
|
21
|
+
status: 'success',
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
>
|
|
25
|
+
Show Success Toast
|
|
26
|
+
</Button>
|
|
27
|
+
<Button
|
|
28
|
+
onClick={() =>
|
|
29
|
+
showToast({
|
|
30
|
+
description: 'There was an error processing your request.',
|
|
31
|
+
status: 'info',
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
>
|
|
35
|
+
Show Info Toast
|
|
36
|
+
</Button>
|
|
37
|
+
<Button
|
|
38
|
+
onClick={() =>
|
|
39
|
+
showToast({
|
|
40
|
+
description: 'There was an error processing your request.',
|
|
41
|
+
status: 'error',
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
>
|
|
45
|
+
Show Error Toast
|
|
46
|
+
</Button>
|
|
47
|
+
</Flex>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BoxProps } from '@chakra-ui/react';
|
|
2
|
+
|
|
3
|
+
export const toastStyles: Record<string, BoxProps> = {
|
|
4
|
+
success: {
|
|
5
|
+
bg: 'success.lighter',
|
|
6
|
+
color: 'success.dark',
|
|
7
|
+
borderColor: 'success.light',
|
|
8
|
+
},
|
|
9
|
+
info: {
|
|
10
|
+
bg: 'primary.light',
|
|
11
|
+
color: 'primary.dark',
|
|
12
|
+
borderColor: 'primary.lighter',
|
|
13
|
+
},
|
|
14
|
+
error: {
|
|
15
|
+
bg: 'danger.lighter',
|
|
16
|
+
color: 'danger.dark',
|
|
17
|
+
borderColor: 'danger.light',
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Box, CloseButton, Flex } from '@chakra-ui/react'; // Import CloseButton
|
|
2
|
+
|
|
3
|
+
import { H5, Text } from '../Typography';
|
|
4
|
+
import { ToastProps } from './Toast.types';
|
|
5
|
+
import { ToastIcon } from './ToastIcon/ToastIcon';
|
|
6
|
+
|
|
7
|
+
export const Toast = ({
|
|
8
|
+
title,
|
|
9
|
+
description,
|
|
10
|
+
status = 'success',
|
|
11
|
+
onClose, // Add onClose prop
|
|
12
|
+
...rest
|
|
13
|
+
}: ToastProps & { onClose?: () => void }) => (
|
|
14
|
+
<Flex
|
|
15
|
+
align="center"
|
|
16
|
+
p={4}
|
|
17
|
+
gap={3}
|
|
18
|
+
borderWidth="1px"
|
|
19
|
+
borderRadius="md"
|
|
20
|
+
boxShadow="lg"
|
|
21
|
+
whiteSpace="pre-line"
|
|
22
|
+
position="relative"
|
|
23
|
+
{...rest}
|
|
24
|
+
>
|
|
25
|
+
<ToastIcon status={status} />
|
|
26
|
+
<Box flex={1}>
|
|
27
|
+
{title && (
|
|
28
|
+
<H5 fontWeight="bold" mb={2}>
|
|
29
|
+
{title}
|
|
30
|
+
</H5>
|
|
31
|
+
)}
|
|
32
|
+
<Text color="inherit">{description}</Text>
|
|
33
|
+
</Box>
|
|
34
|
+
<CloseButton
|
|
35
|
+
onClick={onClose} // Call onClose when clicked
|
|
36
|
+
/>
|
|
37
|
+
</Flex>
|
|
38
|
+
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
BoxProps,
|
|
4
|
+
ChakraProps,
|
|
5
|
+
UseToastOptions as ChakraUseToastOptions,
|
|
6
|
+
} from '@chakra-ui/react';
|
|
7
|
+
|
|
8
|
+
export interface MLToastOptions {
|
|
9
|
+
title?: ReactNode;
|
|
10
|
+
description: ReactNode;
|
|
11
|
+
status?: Extract<
|
|
12
|
+
ChakraUseToastOptions['status'],
|
|
13
|
+
'success' | 'error' | 'info'
|
|
14
|
+
>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ToastProps extends Omit<BoxProps, 'title'>, MLToastOptions {}
|
|
18
|
+
|
|
19
|
+
export type UseToastOptions = ChakraUseToastOptions &
|
|
20
|
+
MLToastOptions & {
|
|
21
|
+
styles?: ChakraProps;
|
|
22
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useTheme, useToken } from '@chakra-ui/react';
|
|
2
|
+
|
|
3
|
+
import { Icon, IconProps } from '../../Icon';
|
|
4
|
+
import { ToastProps } from '../Toast.types';
|
|
5
|
+
|
|
6
|
+
export const ToastIcon = ({ status }: Required<Pick<ToastProps, 'status'>>) => {
|
|
7
|
+
const theme = useTheme();
|
|
8
|
+
|
|
9
|
+
const iconProps: { [K in typeof status]: Omit<IconProps, 'ref'> } = {
|
|
10
|
+
success: {
|
|
11
|
+
icon: 'IoIosCheckmarkCircle',
|
|
12
|
+
color: useToken('colors', theme.semanticTokens.colors.success.main),
|
|
13
|
+
},
|
|
14
|
+
error: {
|
|
15
|
+
icon: 'MdError',
|
|
16
|
+
color: useToken('colors', theme.semanticTokens.colors.danger.main),
|
|
17
|
+
},
|
|
18
|
+
info: {
|
|
19
|
+
icon: 'LuInfo',
|
|
20
|
+
color: useToken('colors', theme.semanticTokens.colors.primary.main),
|
|
21
|
+
boxSize: 'md',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return <Icon boxSize="lg" {...iconProps[status]} />;
|
|
26
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { ToastId, useToast as useChakraToast } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
import { Toast } from './Toast';
|
|
5
|
+
import { toastStyles } from './Toast.styles';
|
|
6
|
+
import { UseToastOptions } from './Toast.types';
|
|
7
|
+
|
|
8
|
+
const MAX_TOASTS = 3;
|
|
9
|
+
|
|
10
|
+
export const useToast = (props?: UseToastOptions) => {
|
|
11
|
+
const toast = useChakraToast();
|
|
12
|
+
const activeToasts = useRef<ToastId[]>([]); // Track active toast IDs
|
|
13
|
+
|
|
14
|
+
const showToast = ({
|
|
15
|
+
status = 'success',
|
|
16
|
+
title,
|
|
17
|
+
description,
|
|
18
|
+
position = 'top',
|
|
19
|
+
styles: stylesProp,
|
|
20
|
+
...rest
|
|
21
|
+
}: UseToastOptions) => {
|
|
22
|
+
const styles = {
|
|
23
|
+
...toastStyles[status],
|
|
24
|
+
...stylesProp,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// Close the earliest toast if the limit is reached
|
|
28
|
+
if (activeToasts.current.length >= MAX_TOASTS) {
|
|
29
|
+
const [oldestToastId] = activeToasts.current;
|
|
30
|
+
if (oldestToastId) {
|
|
31
|
+
toast.close(oldestToastId); // Close the oldest toast
|
|
32
|
+
activeToasts.current.shift(); // Remove it from the list
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Create a new toast and capture its ID
|
|
37
|
+
const toastId = toast({
|
|
38
|
+
duration: 5000,
|
|
39
|
+
isClosable: true,
|
|
40
|
+
position,
|
|
41
|
+
...props,
|
|
42
|
+
render: () => (
|
|
43
|
+
<Toast
|
|
44
|
+
title={title || ''}
|
|
45
|
+
description={description}
|
|
46
|
+
status={status}
|
|
47
|
+
onClose={() => toast.close(toastId)} // Close this specific toast
|
|
48
|
+
{...styles} // Apply status-specific styles
|
|
49
|
+
/>
|
|
50
|
+
),
|
|
51
|
+
onCloseComplete: () => {
|
|
52
|
+
// Remove the toast ID from the active list once closed
|
|
53
|
+
activeToasts.current = activeToasts.current.filter(
|
|
54
|
+
(id) => id !== toastId
|
|
55
|
+
);
|
|
56
|
+
},
|
|
57
|
+
...rest,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Add the new toast ID to the active list
|
|
61
|
+
activeToasts.current.push(toastId);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return showToast;
|
|
65
|
+
};
|