@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,138 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { Td as ChakraTd, useToken } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
import { getStickyStyles } from './Table.styles';
|
|
5
|
+
import { TableCellProps } from './Table.types';
|
|
6
|
+
import { useTableContext } from './TableContext';
|
|
7
|
+
|
|
8
|
+
export const Td = ({
|
|
9
|
+
wrap,
|
|
10
|
+
isSticky = false,
|
|
11
|
+
stickyDirection = 'left',
|
|
12
|
+
stickyIndex = 0,
|
|
13
|
+
_first,
|
|
14
|
+
style,
|
|
15
|
+
className,
|
|
16
|
+
children,
|
|
17
|
+
onClick,
|
|
18
|
+
onMouseEnter,
|
|
19
|
+
onMouseLeave,
|
|
20
|
+
...rest
|
|
21
|
+
}: TableCellProps & { wrap?: boolean }) => {
|
|
22
|
+
const cellRef = useRef<HTMLTableCellElement>(null);
|
|
23
|
+
const tableContext = useTableContext();
|
|
24
|
+
|
|
25
|
+
// Define all style variables ahead of time so they can be used constantly
|
|
26
|
+
const grayColor = useToken('colors', 'gray.300');
|
|
27
|
+
const paddingToken = useToken('space', '3'); // py={3} equivalent
|
|
28
|
+
const fontSizeToken = useToken('fontSizes', 'p');
|
|
29
|
+
const spacingToken = useToken('space', '4'); // spacing 4 for paddingInlineStart
|
|
30
|
+
|
|
31
|
+
// If not inside TableContext, render regular HTML td with same styles
|
|
32
|
+
if (!tableContext) {
|
|
33
|
+
// Extract only standard HTML props for the regular td element
|
|
34
|
+
const htmlProps = {
|
|
35
|
+
className,
|
|
36
|
+
onClick,
|
|
37
|
+
onMouseEnter,
|
|
38
|
+
onMouseLeave,
|
|
39
|
+
// Add other standard HTML props as needed
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<td
|
|
44
|
+
ref={cellRef}
|
|
45
|
+
style={{
|
|
46
|
+
border: 0,
|
|
47
|
+
borderTop: '1px solid',
|
|
48
|
+
borderTopColor: grayColor,
|
|
49
|
+
color: 'inherit',
|
|
50
|
+
fontSize: fontSizeToken,
|
|
51
|
+
paddingTop: paddingToken,
|
|
52
|
+
paddingBottom: paddingToken,
|
|
53
|
+
overflow: 'hidden',
|
|
54
|
+
textOverflow: 'ellipsis',
|
|
55
|
+
paddingInlineStart: _first ? spacingToken : undefined,
|
|
56
|
+
...(wrap
|
|
57
|
+
? {
|
|
58
|
+
whiteSpace: 'normal',
|
|
59
|
+
wordWrap: 'break-word',
|
|
60
|
+
overflowWrap: 'break-word',
|
|
61
|
+
}
|
|
62
|
+
: {}),
|
|
63
|
+
...style,
|
|
64
|
+
}}
|
|
65
|
+
{...htmlProps}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
</td>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const {
|
|
73
|
+
registerStickyColumn,
|
|
74
|
+
getStickyOffset,
|
|
75
|
+
isLastStickyColumn,
|
|
76
|
+
...scrollState
|
|
77
|
+
} = tableContext;
|
|
78
|
+
|
|
79
|
+
// Update width when element is mounted and dimensions change
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (isSticky && cellRef.current) {
|
|
82
|
+
const width = cellRef.current.getBoundingClientRect().width;
|
|
83
|
+
registerStickyColumn(stickyDirection, stickyIndex, width);
|
|
84
|
+
}
|
|
85
|
+
}, [isSticky, registerStickyColumn, stickyDirection, stickyIndex]);
|
|
86
|
+
|
|
87
|
+
// Get the sticky offset based on the column's position
|
|
88
|
+
const stickyOffset = isSticky
|
|
89
|
+
? getStickyOffset(stickyDirection, stickyIndex)
|
|
90
|
+
: 0;
|
|
91
|
+
|
|
92
|
+
// Check if this is the last sticky column on this side
|
|
93
|
+
const isLastSticky =
|
|
94
|
+
isSticky && isLastStickyColumn(stickyDirection, stickyIndex);
|
|
95
|
+
|
|
96
|
+
// Apply sticky styles with appropriate offset
|
|
97
|
+
const stickyStyles = getStickyStyles(
|
|
98
|
+
isSticky,
|
|
99
|
+
stickyDirection,
|
|
100
|
+
scrollState,
|
|
101
|
+
stickyOffset,
|
|
102
|
+
isLastSticky
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<ChakraTd
|
|
107
|
+
border={0}
|
|
108
|
+
borderTop="1px solid"
|
|
109
|
+
borderTopColor="gray.300"
|
|
110
|
+
color="inherit"
|
|
111
|
+
fontSize="p"
|
|
112
|
+
py={3}
|
|
113
|
+
overflow="hidden"
|
|
114
|
+
textOverflow="ellipsis"
|
|
115
|
+
ref={cellRef}
|
|
116
|
+
style={style}
|
|
117
|
+
_first={{
|
|
118
|
+
'&:not(:last-child)': {
|
|
119
|
+
paddingInlineStart: 4,
|
|
120
|
+
},
|
|
121
|
+
..._first,
|
|
122
|
+
}}
|
|
123
|
+
{...(wrap
|
|
124
|
+
? {
|
|
125
|
+
whiteSpace: 'normal',
|
|
126
|
+
wordWrap: 'break-word',
|
|
127
|
+
overflowWrap: 'break-word',
|
|
128
|
+
}
|
|
129
|
+
: {})}
|
|
130
|
+
{...stickyStyles}
|
|
131
|
+
{...rest}
|
|
132
|
+
>
|
|
133
|
+
{children}
|
|
134
|
+
</ChakraTd>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
Td.displayName = 'Td';
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { forwardRef, useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
TableColumnHeaderProps,
|
|
4
|
+
Th as ChakraTh,
|
|
5
|
+
useToken,
|
|
6
|
+
} from '@chakra-ui/react';
|
|
7
|
+
|
|
8
|
+
import { getStickyStyles } from './Table.styles';
|
|
9
|
+
import { TableCellProps } from './Table.types';
|
|
10
|
+
import { useTableContext } from './TableContext';
|
|
11
|
+
|
|
12
|
+
export const Th = forwardRef<
|
|
13
|
+
HTMLTableCellElement,
|
|
14
|
+
TableColumnHeaderProps & TableCellProps
|
|
15
|
+
>(
|
|
16
|
+
(
|
|
17
|
+
{
|
|
18
|
+
isSticky = false,
|
|
19
|
+
stickyDirection = 'left',
|
|
20
|
+
stickyIndex = 0,
|
|
21
|
+
style,
|
|
22
|
+
className,
|
|
23
|
+
children,
|
|
24
|
+
onClick,
|
|
25
|
+
onMouseEnter,
|
|
26
|
+
onMouseLeave,
|
|
27
|
+
...rest
|
|
28
|
+
},
|
|
29
|
+
forwardedRef
|
|
30
|
+
) => {
|
|
31
|
+
const tableContext = useTableContext();
|
|
32
|
+
const measureNodeRef = useRef<HTMLTableCellElement | null>(null);
|
|
33
|
+
const fontSizeToken = useToken('fontSizes', 'subtitle');
|
|
34
|
+
const spacingToken = useToken('space', '4'); // spacing 4 for paddingInlineStart
|
|
35
|
+
|
|
36
|
+
// If not inside TableContext, render regular HTML th with same styles
|
|
37
|
+
if (!tableContext) {
|
|
38
|
+
// Extract only standard HTML props for the regular th element
|
|
39
|
+
const htmlProps = {
|
|
40
|
+
className,
|
|
41
|
+
onClick,
|
|
42
|
+
onMouseEnter,
|
|
43
|
+
onMouseLeave,
|
|
44
|
+
// Add other standard HTML props as needed
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Combine refs for the regular th element
|
|
48
|
+
const setRefsForRegularTh = useCallback(
|
|
49
|
+
(node: HTMLTableCellElement | null) => {
|
|
50
|
+
// Set internal ref
|
|
51
|
+
measureNodeRef.current = node;
|
|
52
|
+
|
|
53
|
+
// Set forwarded ref
|
|
54
|
+
if (typeof forwardedRef === 'function') {
|
|
55
|
+
forwardedRef(node);
|
|
56
|
+
} else if (forwardedRef) {
|
|
57
|
+
forwardedRef.current = node;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
[forwardedRef]
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<th
|
|
65
|
+
ref={setRefsForRegularTh}
|
|
66
|
+
style={{
|
|
67
|
+
color: 'inherit',
|
|
68
|
+
fontWeight: 'inherit',
|
|
69
|
+
fontSize: fontSizeToken,
|
|
70
|
+
overflow: 'hidden',
|
|
71
|
+
textOverflow: 'ellipsis',
|
|
72
|
+
paddingInlineStart: spacingToken,
|
|
73
|
+
...style,
|
|
74
|
+
}}
|
|
75
|
+
{...htmlProps}
|
|
76
|
+
>
|
|
77
|
+
{children}
|
|
78
|
+
</th>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const {
|
|
83
|
+
registerStickyColumn,
|
|
84
|
+
getStickyOffset,
|
|
85
|
+
isLastStickyColumn,
|
|
86
|
+
...scrollState
|
|
87
|
+
} = tableContext;
|
|
88
|
+
|
|
89
|
+
// Update width when element is mounted and dimensions change
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (isSticky && measureNodeRef.current) {
|
|
92
|
+
const width = measureNodeRef.current.getBoundingClientRect().width;
|
|
93
|
+
registerStickyColumn(stickyDirection, stickyIndex, width);
|
|
94
|
+
}
|
|
95
|
+
}, [isSticky, registerStickyColumn, stickyDirection, stickyIndex]);
|
|
96
|
+
|
|
97
|
+
// Combine refs (forwarded ref and internal ref)
|
|
98
|
+
const setRefs = useCallback(
|
|
99
|
+
(node: HTMLTableCellElement | null) => {
|
|
100
|
+
// Set internal ref
|
|
101
|
+
measureNodeRef.current = node;
|
|
102
|
+
|
|
103
|
+
// Set forwarded ref
|
|
104
|
+
if (typeof forwardedRef === 'function') {
|
|
105
|
+
forwardedRef(node);
|
|
106
|
+
} else if (forwardedRef) {
|
|
107
|
+
forwardedRef.current = node;
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
[forwardedRef]
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
// Get the sticky offset based on the column's position
|
|
114
|
+
const stickyOffset = isSticky
|
|
115
|
+
? getStickyOffset(stickyDirection, stickyIndex)
|
|
116
|
+
: 0;
|
|
117
|
+
|
|
118
|
+
// Check if this is the last sticky column on this side
|
|
119
|
+
const isLastSticky =
|
|
120
|
+
isSticky && isLastStickyColumn(stickyDirection, stickyIndex);
|
|
121
|
+
|
|
122
|
+
// Apply sticky styles with appropriate offset
|
|
123
|
+
const stickyStyles = getStickyStyles(
|
|
124
|
+
isSticky,
|
|
125
|
+
stickyDirection,
|
|
126
|
+
scrollState,
|
|
127
|
+
stickyOffset,
|
|
128
|
+
isLastSticky
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<ChakraTh
|
|
133
|
+
color="inherit"
|
|
134
|
+
fontWeight="inherit"
|
|
135
|
+
fontSize="subtitle"
|
|
136
|
+
overflow="hidden"
|
|
137
|
+
textOverflow="ellipsis"
|
|
138
|
+
ref={setRefs}
|
|
139
|
+
style={style}
|
|
140
|
+
_first={{
|
|
141
|
+
'&:not(:last-child)': {
|
|
142
|
+
paddingInlineStart: 4,
|
|
143
|
+
},
|
|
144
|
+
}}
|
|
145
|
+
{...stickyStyles}
|
|
146
|
+
{...rest}
|
|
147
|
+
>
|
|
148
|
+
{children}
|
|
149
|
+
</ChakraTh>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
Th.displayName = 'Th';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ExpandingTr } from './ExpandingTr/ExpandingTr';
|
|
2
|
+
export { Table } from './Table';
|
|
3
|
+
export { TableContainer } from './TableContainer';
|
|
4
|
+
export { Tbody } from './Tbody';
|
|
5
|
+
export { Td } from './Td';
|
|
6
|
+
export { Th } from './Th';
|
|
7
|
+
export { Thead } from './Thead';
|
|
8
|
+
export { Tr } from './Tr';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as CSS from 'csstype';
|
|
2
|
+
|
|
3
|
+
import theme from '@/theme/index';
|
|
4
|
+
|
|
5
|
+
// TODO: investigate why these TS issues are coming up
|
|
6
|
+
export const verticalStyles = {
|
|
7
|
+
borderInlineStart: 'none',
|
|
8
|
+
position: 'relative' as CSS.Property.Position,
|
|
9
|
+
justifyContent: 'flex-start',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
textAlign: 'left' as CSS.Property.TextAlign,
|
|
12
|
+
p: 4,
|
|
13
|
+
width: '100%',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const horizontalSelectedStyles = {
|
|
17
|
+
color: theme.semanticTokens.colors.primary.main,
|
|
18
|
+
fontWeight: 'semibold',
|
|
19
|
+
position: 'relative',
|
|
20
|
+
_after: {
|
|
21
|
+
content: '""',
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
top: 'calc(100% - 1px)',
|
|
24
|
+
left: 0,
|
|
25
|
+
width: '100%',
|
|
26
|
+
height: '2px',
|
|
27
|
+
background: theme.semanticTokens.colors.primary.main,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const verticalSelectedStyles = {
|
|
32
|
+
backgroundColor: 'primary.light',
|
|
33
|
+
color: 'primary.dark',
|
|
34
|
+
fontWeight: 'bold',
|
|
35
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Tab as ChakraTab } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
import { useTabsContext } from '@/components/Tabs/TabsContext';
|
|
5
|
+
|
|
6
|
+
import { TabProps } from '../Tabs.types';
|
|
7
|
+
import {
|
|
8
|
+
horizontalSelectedStyles,
|
|
9
|
+
verticalSelectedStyles,
|
|
10
|
+
verticalStyles,
|
|
11
|
+
} from './Tab.styles';
|
|
12
|
+
|
|
13
|
+
// A global counter to assign unique IDs to tabs for identification
|
|
14
|
+
let nextTabId = 0;
|
|
15
|
+
|
|
16
|
+
export const Tab = ({ name, ...props }: TabProps) => {
|
|
17
|
+
const { orientation, registerTabName } = useTabsContext();
|
|
18
|
+
const tabRef = useRef<HTMLButtonElement>(null);
|
|
19
|
+
const [tabId] = useState(() => `tab-${nextTabId++}`);
|
|
20
|
+
|
|
21
|
+
// Record when this tab was mounted in the DOM
|
|
22
|
+
useLayoutEffect(() => {
|
|
23
|
+
// After mounting, find this tab's position
|
|
24
|
+
if (!name || !tabRef.current) {
|
|
25
|
+
console.warn('[Tab] Missing name or tabRef.current');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Use a timeout to ensure tabs are properly rendered
|
|
30
|
+
const timeoutId = setTimeout(() => {
|
|
31
|
+
try {
|
|
32
|
+
// Find all tab elements within the same tablist
|
|
33
|
+
const tabList = tabRef.current?.closest('[role="tablist"]');
|
|
34
|
+
if (!tabList) return;
|
|
35
|
+
|
|
36
|
+
const tabs = Array.from(tabList.querySelectorAll('[role="tab"]'));
|
|
37
|
+
const index = tabs.indexOf(tabRef.current!);
|
|
38
|
+
|
|
39
|
+
// Register this tab's name with the context
|
|
40
|
+
if (index !== -1) {
|
|
41
|
+
registerTabName(index, name);
|
|
42
|
+
}
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('[Tab] Error finding tab index:', error);
|
|
45
|
+
}
|
|
46
|
+
}, 50); // Short delay to ensure DOM is ready
|
|
47
|
+
|
|
48
|
+
return () => clearTimeout(timeoutId);
|
|
49
|
+
}, [name, registerTabName]);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<ChakraTab
|
|
53
|
+
ref={tabRef}
|
|
54
|
+
id={tabId}
|
|
55
|
+
data-tab-name={name}
|
|
56
|
+
{...(orientation === 'vertical' && verticalStyles)}
|
|
57
|
+
color="gray.800"
|
|
58
|
+
py={3}
|
|
59
|
+
_selected={{
|
|
60
|
+
...(orientation === 'vertical'
|
|
61
|
+
? verticalSelectedStyles
|
|
62
|
+
: horizontalSelectedStyles),
|
|
63
|
+
}}
|
|
64
|
+
{...props}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Tab } from './Tab';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Light mode styles only
|
|
2
|
+
export const tabListStyles = {
|
|
3
|
+
// This is the divider line. Tab colors are set in the Tab component.
|
|
4
|
+
// TODO: move to palette
|
|
5
|
+
// color: '#ababab',
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const verticalStyles = {
|
|
9
|
+
borderInlineEnd: '1px solid',
|
|
10
|
+
borderInlineStart: 'none',
|
|
11
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TabList as ChakraTabList, TabListProps } from '@chakra-ui/react';
|
|
2
|
+
|
|
3
|
+
import { useTabsContext } from '@/components/Tabs/TabsContext';
|
|
4
|
+
|
|
5
|
+
import { tabListStyles, verticalStyles } from './TabList.styles';
|
|
6
|
+
|
|
7
|
+
export const TabList = (props: TabListProps) => {
|
|
8
|
+
const { orientation } = useTabsContext();
|
|
9
|
+
return (
|
|
10
|
+
<ChakraTabList
|
|
11
|
+
width="100%"
|
|
12
|
+
borderBottom="1px solid"
|
|
13
|
+
borderColor="gray.100"
|
|
14
|
+
{...tabListStyles}
|
|
15
|
+
{...(orientation === 'vertical' && verticalStyles)}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TabList } from './TabList';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { Tab } from '@/components/Tabs/Tab/Tab';
|
|
5
|
+
import { TabList } from '@/components/Tabs/TabList';
|
|
6
|
+
import { TabPanel } from '@/components/Tabs/TabPanel';
|
|
7
|
+
import { TabPanels } from '@/components/Tabs/TabPanels';
|
|
8
|
+
|
|
9
|
+
import { Tabs } from './Tabs';
|
|
10
|
+
|
|
11
|
+
const meta: Meta<typeof Tabs> = {
|
|
12
|
+
title: 'Components/Tabs',
|
|
13
|
+
component: Tabs,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
type Story = StoryFn<typeof Tabs>;
|
|
18
|
+
|
|
19
|
+
const RenderTemplate = (props) => {
|
|
20
|
+
return (
|
|
21
|
+
<Tabs {...props}>
|
|
22
|
+
<TabList>
|
|
23
|
+
<Tab>Tab 1</Tab>
|
|
24
|
+
<Tab>Tab 2</Tab>
|
|
25
|
+
<Tab>Tab 3</Tab>
|
|
26
|
+
</TabList>
|
|
27
|
+
<TabPanels>
|
|
28
|
+
<TabPanel>Tab 1 content</TabPanel>
|
|
29
|
+
<TabPanel>Tab 2 content</TabPanel>
|
|
30
|
+
<TabPanel>Tab 3 content</TabPanel>
|
|
31
|
+
</TabPanels>
|
|
32
|
+
</Tabs>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Basic: Story = {
|
|
37
|
+
render: RenderTemplate,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const Vertical: Story = {
|
|
41
|
+
render: RenderTemplate,
|
|
42
|
+
args: {
|
|
43
|
+
orientation: 'vertical',
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Tabs as ChakraTabs } from '@chakra-ui/react';
|
|
2
|
+
|
|
3
|
+
import { TabsProps } from './Tabs.types';
|
|
4
|
+
import { TabsProvider, useTabsContext } from './TabsContext';
|
|
5
|
+
|
|
6
|
+
export const Tabs = ({
|
|
7
|
+
orientation,
|
|
8
|
+
children,
|
|
9
|
+
urlParam,
|
|
10
|
+
index,
|
|
11
|
+
onChange,
|
|
12
|
+
...rest
|
|
13
|
+
}: TabsProps) => {
|
|
14
|
+
return (
|
|
15
|
+
<TabsProvider orientation={orientation} urlParam={urlParam}>
|
|
16
|
+
<TabsWithUrlSync
|
|
17
|
+
orientation={orientation}
|
|
18
|
+
index={index}
|
|
19
|
+
onChange={onChange}
|
|
20
|
+
{...rest}
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
</TabsWithUrlSync>
|
|
24
|
+
</TabsProvider>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Internal component to handle URL synchronization between tabs and the browser URL
|
|
30
|
+
*/
|
|
31
|
+
const TabsWithUrlSync = ({
|
|
32
|
+
children,
|
|
33
|
+
onChange,
|
|
34
|
+
index: externalIndex,
|
|
35
|
+
...rest
|
|
36
|
+
}: Omit<TabsProps, 'urlParam'>) => {
|
|
37
|
+
const { selectedIndex, setSelectedIndex } = useTabsContext();
|
|
38
|
+
|
|
39
|
+
// Use the context's index if no external index is provided
|
|
40
|
+
const actualIndex =
|
|
41
|
+
externalIndex !== undefined ? externalIndex : selectedIndex;
|
|
42
|
+
|
|
43
|
+
// Handle tab changes
|
|
44
|
+
const handleTabChange = (newIndex: number) => {
|
|
45
|
+
// Update the context state
|
|
46
|
+
setSelectedIndex(newIndex);
|
|
47
|
+
|
|
48
|
+
// If an external onChange handler is provided, call it
|
|
49
|
+
if (onChange) {
|
|
50
|
+
onChange(newIndex);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<ChakraTabs
|
|
56
|
+
position="relative"
|
|
57
|
+
variant="unstyled"
|
|
58
|
+
index={actualIndex}
|
|
59
|
+
onChange={handleTabChange}
|
|
60
|
+
{...rest}
|
|
61
|
+
>
|
|
62
|
+
{children}
|
|
63
|
+
</ChakraTabs>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TabProps as ChakraTabProps,
|
|
3
|
+
TabsProps as ChakraTabsProps,
|
|
4
|
+
} from '@chakra-ui/react';
|
|
5
|
+
|
|
6
|
+
export type TabsProps = ChakraTabsProps & {
|
|
7
|
+
/**
|
|
8
|
+
* If provided, the selected tab will be synced with the provided url param
|
|
9
|
+
*/
|
|
10
|
+
urlParam?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type TabProps = ChakraTabProps & {
|
|
14
|
+
/**
|
|
15
|
+
* The name of the tab
|
|
16
|
+
* @default `tab-${index}`
|
|
17
|
+
*/
|
|
18
|
+
name?: string;
|
|
19
|
+
};
|