@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,226 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box, Stack, VStack } from '@chakra-ui/react';
|
|
3
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
4
|
+
|
|
5
|
+
import { Radio, RadioGroup } from '.';
|
|
6
|
+
import { RadioOption } from './Radio.types';
|
|
7
|
+
|
|
8
|
+
const meta: Meta<typeof Radio> = {
|
|
9
|
+
title: 'Components/Radio',
|
|
10
|
+
component: Radio,
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: 'centered',
|
|
13
|
+
docs: {
|
|
14
|
+
description: {
|
|
15
|
+
component:
|
|
16
|
+
'Radio components allow users to select a single option from a set of mutually exclusive options. Use RadioGroup to manage a collection of related Radio components.',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
tags: ['autodocs'],
|
|
21
|
+
argTypes: {
|
|
22
|
+
children: {
|
|
23
|
+
control: 'text',
|
|
24
|
+
description: 'The label text for the radio button',
|
|
25
|
+
},
|
|
26
|
+
value: {
|
|
27
|
+
control: 'text',
|
|
28
|
+
description: 'The value of the radio button',
|
|
29
|
+
},
|
|
30
|
+
isChecked: {
|
|
31
|
+
control: 'boolean',
|
|
32
|
+
description: 'Whether the radio button is checked',
|
|
33
|
+
},
|
|
34
|
+
isDisabled: {
|
|
35
|
+
control: 'boolean',
|
|
36
|
+
description: 'Whether the radio button is disabled',
|
|
37
|
+
},
|
|
38
|
+
size: {
|
|
39
|
+
control: { type: 'select' },
|
|
40
|
+
options: ['sm', 'md', 'lg'],
|
|
41
|
+
description: 'The size of the radio button',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
args: {
|
|
45
|
+
children: 'Radio option',
|
|
46
|
+
value: 'option1',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default meta;
|
|
51
|
+
type Story = StoryFn<typeof Radio>;
|
|
52
|
+
|
|
53
|
+
export const Default: Story = (args) => <Radio {...args} />;
|
|
54
|
+
|
|
55
|
+
export const Checked: Story = (args) => <Radio {...args} isChecked />;
|
|
56
|
+
Checked.args = {
|
|
57
|
+
children: 'Selected option',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const Disabled: Story = (args) => (
|
|
61
|
+
<Stack spacing={3}>
|
|
62
|
+
<Radio {...args} isDisabled>
|
|
63
|
+
Disabled unchecked
|
|
64
|
+
</Radio>
|
|
65
|
+
<Radio {...args} isDisabled isChecked>
|
|
66
|
+
Disabled checked
|
|
67
|
+
</Radio>
|
|
68
|
+
</Stack>
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
export const Sizes: Story = (args) => (
|
|
72
|
+
<Stack spacing={4}>
|
|
73
|
+
<Radio {...args} size="sm">
|
|
74
|
+
Small radio
|
|
75
|
+
</Radio>
|
|
76
|
+
<Radio {...args} size="md">
|
|
77
|
+
Medium radio
|
|
78
|
+
</Radio>
|
|
79
|
+
<Radio {...args} size="lg">
|
|
80
|
+
Large radio
|
|
81
|
+
</Radio>
|
|
82
|
+
</Stack>
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
export const States: Story = (args) => (
|
|
86
|
+
<Stack spacing={3}>
|
|
87
|
+
<Radio {...args}>Default state</Radio>
|
|
88
|
+
<Radio {...args} isChecked>
|
|
89
|
+
Checked state
|
|
90
|
+
</Radio>
|
|
91
|
+
<Radio {...args} isDisabled>
|
|
92
|
+
Disabled state
|
|
93
|
+
</Radio>
|
|
94
|
+
<Radio {...args} isDisabled isChecked>
|
|
95
|
+
Disabled checked state
|
|
96
|
+
</Radio>
|
|
97
|
+
</Stack>
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
export const BasicGroup: StoryFn<typeof RadioGroup> = () => {
|
|
101
|
+
const [value, setValue] = useState<string>('option1');
|
|
102
|
+
|
|
103
|
+
const options: RadioOption[] = [
|
|
104
|
+
{ value: 'option1', label: 'First option' },
|
|
105
|
+
{ value: 'option2', label: 'Second option' },
|
|
106
|
+
{ value: 'option3', label: 'Third option' },
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<VStack align="flex-start" spacing={4}>
|
|
111
|
+
<Box>Selected value: {value}</Box>
|
|
112
|
+
<RadioGroup options={options} value={value} onChange={setValue} />
|
|
113
|
+
</VStack>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const HorizontalGroup: StoryFn<typeof RadioGroup> = () => {
|
|
118
|
+
const [value, setValue] = useState<string>('email');
|
|
119
|
+
|
|
120
|
+
const options: RadioOption[] = [
|
|
121
|
+
{ value: 'email', label: 'Email' },
|
|
122
|
+
{ value: 'sms', label: 'SMS' },
|
|
123
|
+
{ value: 'phone', label: 'Phone call' },
|
|
124
|
+
];
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<VStack align="flex-start" spacing={4}>
|
|
128
|
+
<Box>Preferred contact method: {value}</Box>
|
|
129
|
+
<RadioGroup
|
|
130
|
+
options={options}
|
|
131
|
+
value={value}
|
|
132
|
+
onChange={setValue}
|
|
133
|
+
direction="row"
|
|
134
|
+
spacing={6}
|
|
135
|
+
/>
|
|
136
|
+
</VStack>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export const WithLongLabels: StoryFn<typeof RadioGroup> = () => {
|
|
141
|
+
const [value, setValue] = useState<string>('option1');
|
|
142
|
+
|
|
143
|
+
const options: RadioOption[] = [
|
|
144
|
+
{
|
|
145
|
+
value: 'option1',
|
|
146
|
+
label:
|
|
147
|
+
'This is a very long label that demonstrates how radio buttons handle longer text content',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
value: 'option2',
|
|
151
|
+
label:
|
|
152
|
+
'Another option with extended descriptive text that might wrap to multiple lines',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
value: 'option3',
|
|
156
|
+
label: 'A third choice with substantial explanatory content',
|
|
157
|
+
},
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<Box maxW="400px">
|
|
162
|
+
<RadioGroup
|
|
163
|
+
options={options}
|
|
164
|
+
value={value}
|
|
165
|
+
onChange={setValue}
|
|
166
|
+
spacing={4}
|
|
167
|
+
/>
|
|
168
|
+
</Box>
|
|
169
|
+
);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export const FormExample: StoryFn<typeof RadioGroup> = () => {
|
|
173
|
+
const [notifications, setNotifications] = useState<string>('all');
|
|
174
|
+
const [theme, setTheme] = useState<string>('light');
|
|
175
|
+
|
|
176
|
+
const notificationOptions: RadioOption[] = [
|
|
177
|
+
{ value: 'all', label: 'All notifications' },
|
|
178
|
+
{ value: 'important', label: 'Important only' },
|
|
179
|
+
{ value: 'none', label: 'No notifications' },
|
|
180
|
+
];
|
|
181
|
+
|
|
182
|
+
const themeOptions: RadioOption[] = [
|
|
183
|
+
{ value: 'light', label: 'Light theme' },
|
|
184
|
+
{ value: 'dark', label: 'Dark theme' },
|
|
185
|
+
{ value: 'auto', label: 'Auto (system preference)' },
|
|
186
|
+
];
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<VStack align="flex-start" spacing={6} maxW="300px">
|
|
190
|
+
<Box>
|
|
191
|
+
<Box fontWeight="semibold" mb={2}>
|
|
192
|
+
Notification Preferences
|
|
193
|
+
</Box>
|
|
194
|
+
<RadioGroup
|
|
195
|
+
options={notificationOptions}
|
|
196
|
+
value={notifications}
|
|
197
|
+
onChange={setNotifications}
|
|
198
|
+
spacing={3}
|
|
199
|
+
/>
|
|
200
|
+
</Box>
|
|
201
|
+
|
|
202
|
+
<Box>
|
|
203
|
+
<Box fontWeight="semibold" mb={2}>
|
|
204
|
+
Theme Preference
|
|
205
|
+
</Box>
|
|
206
|
+
<RadioGroup
|
|
207
|
+
options={themeOptions}
|
|
208
|
+
value={theme}
|
|
209
|
+
onChange={setTheme}
|
|
210
|
+
direction="row"
|
|
211
|
+
spacing={4}
|
|
212
|
+
/>
|
|
213
|
+
</Box>
|
|
214
|
+
|
|
215
|
+
<Box p={4} bg="gray.50" borderRadius="md" w="100%">
|
|
216
|
+
<Box fontWeight="semibold" mb={2}>
|
|
217
|
+
Current Settings:
|
|
218
|
+
</Box>
|
|
219
|
+
<Box fontSize="sm">
|
|
220
|
+
<Box>Notifications: {notifications}</Box>
|
|
221
|
+
<Box>Theme: {theme}</Box>
|
|
222
|
+
</Box>
|
|
223
|
+
</Box>
|
|
224
|
+
</VStack>
|
|
225
|
+
);
|
|
226
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { Radio as ChakraRadio } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
import { RadioProps } from './Radio.types';
|
|
5
|
+
|
|
6
|
+
export const Radio = forwardRef<HTMLInputElement, RadioProps>(
|
|
7
|
+
({ children, ...rest }, ref) => {
|
|
8
|
+
return (
|
|
9
|
+
<ChakraRadio
|
|
10
|
+
ref={ref}
|
|
11
|
+
_checked={{
|
|
12
|
+
bg: 'primary.main',
|
|
13
|
+
borderColor: 'primary.main',
|
|
14
|
+
position: 'relative',
|
|
15
|
+
_before: {
|
|
16
|
+
content: '""',
|
|
17
|
+
bg: 'white',
|
|
18
|
+
w: '50%',
|
|
19
|
+
h: '50%',
|
|
20
|
+
borderRadius: 'full',
|
|
21
|
+
position: 'absolute',
|
|
22
|
+
top: '50%',
|
|
23
|
+
left: '50%',
|
|
24
|
+
transform: 'translate(-50%, -50%)',
|
|
25
|
+
},
|
|
26
|
+
}}
|
|
27
|
+
{...rest}
|
|
28
|
+
>
|
|
29
|
+
{children}
|
|
30
|
+
</ChakraRadio>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
Radio.displayName = 'Radio';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RadioGroupProps as ChakraRadioGroupProps,
|
|
3
|
+
RadioProps as ChakraRadioProps,
|
|
4
|
+
StackDirection,
|
|
5
|
+
} from '@chakra-ui/react';
|
|
6
|
+
|
|
7
|
+
export interface RadioOption {
|
|
8
|
+
value: string;
|
|
9
|
+
label: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface RadioProps extends ChakraRadioProps {
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface RadioGroupProps
|
|
17
|
+
extends Omit<ChakraRadioGroupProps, 'children'> {
|
|
18
|
+
options: RadioOption[];
|
|
19
|
+
direction?: StackDirection;
|
|
20
|
+
spacing?: number;
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { RadioGroup as ChakraRadioGroup, Stack } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
import { Radio } from './Radio';
|
|
5
|
+
import { RadioGroupProps, RadioOption } from './Radio.types';
|
|
6
|
+
|
|
7
|
+
export const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps>(
|
|
8
|
+
(
|
|
9
|
+
{ options, value, onChange, direction = 'column', spacing = 3, ...rest },
|
|
10
|
+
ref
|
|
11
|
+
) => {
|
|
12
|
+
return (
|
|
13
|
+
<ChakraRadioGroup value={value} onChange={onChange} {...rest}>
|
|
14
|
+
<Stack direction={direction} spacing={spacing} ref={ref}>
|
|
15
|
+
{options.map((option: RadioOption) => (
|
|
16
|
+
<Radio key={option.value} value={option.value}>
|
|
17
|
+
{option.label}
|
|
18
|
+
</Radio>
|
|
19
|
+
))}
|
|
20
|
+
</Stack>
|
|
21
|
+
</ChakraRadioGroup>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
RadioGroup.displayName = 'RadioGroup';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { SeeMoreButton } from './SeeMoreButton';
|
|
5
|
+
import { SeeMoreButtonProps } from './SeeMoreButton.types';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Components/SeeMoreButton',
|
|
9
|
+
component: SeeMoreButton,
|
|
10
|
+
args: {
|
|
11
|
+
currentCount: 0,
|
|
12
|
+
maxCount: 10,
|
|
13
|
+
},
|
|
14
|
+
argTypes: {
|
|
15
|
+
currentCount: {
|
|
16
|
+
control: 'number',
|
|
17
|
+
},
|
|
18
|
+
maxCount: {
|
|
19
|
+
control: 'number',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
parameters: {
|
|
23
|
+
controls: {
|
|
24
|
+
expanded: true,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
} as Meta<typeof SeeMoreButton>;
|
|
28
|
+
|
|
29
|
+
export const Default: StoryFn<SeeMoreButtonProps> = (args) => {
|
|
30
|
+
const [currentCount, setCurrentCount] = React.useState(args.currentCount);
|
|
31
|
+
|
|
32
|
+
const handleClick = () => {
|
|
33
|
+
setCurrentCount((prev) => Math.min(prev + 1, args.maxCount));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<SeeMoreButton
|
|
38
|
+
{...args}
|
|
39
|
+
currentCount={currentCount}
|
|
40
|
+
onClick={handleClick}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
Default.args = {
|
|
46
|
+
currentCount: 0,
|
|
47
|
+
maxCount: 10,
|
|
48
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
import { Icon } from '@/components/Icon';
|
|
5
|
+
import { useTranslate } from '@/hooks/useTranslate';
|
|
6
|
+
|
|
7
|
+
import { seeMoreButtonStyles } from './SeeMoreButton.styles';
|
|
8
|
+
import { SeeMoreButtonProps } from './SeeMoreButton.types';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A button component that allows users to load or see more items.
|
|
12
|
+
* It displays the current count and the maximum count of items.
|
|
13
|
+
*
|
|
14
|
+
* @param {object} props - Props for the SeeMoreButton component.
|
|
15
|
+
* @param {number} props.currentCount - The current number of items shown.
|
|
16
|
+
* @param {number} props.maxCount - The maximum number of items available.
|
|
17
|
+
*/
|
|
18
|
+
export const SeeMoreButton = ({
|
|
19
|
+
currentCount,
|
|
20
|
+
maxCount,
|
|
21
|
+
...rest
|
|
22
|
+
}: SeeMoreButtonProps) => {
|
|
23
|
+
const translate = useTranslate();
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Button
|
|
27
|
+
rightIcon={<Icon icon="IoChevronDownOutline" color="inherit" />}
|
|
28
|
+
{...seeMoreButtonStyles}
|
|
29
|
+
{...rest}
|
|
30
|
+
>
|
|
31
|
+
{translate('see_more')} ({currentCount}/{maxCount})
|
|
32
|
+
</Button>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SeeMoreButton } from './SeeMoreButton';
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { SegmentedControl } from './SegmentedControl';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof SegmentedControl> = {
|
|
7
|
+
title: 'Components/SegmentedControl',
|
|
8
|
+
component: SegmentedControl,
|
|
9
|
+
args: {
|
|
10
|
+
options: [
|
|
11
|
+
{
|
|
12
|
+
label: 'Complete',
|
|
13
|
+
value: 'complete',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
label: 'Incomplete',
|
|
17
|
+
value: 'incomplete',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: 'Pending',
|
|
21
|
+
value: 'pending',
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
argTypes: {
|
|
26
|
+
size: {
|
|
27
|
+
control: 'select',
|
|
28
|
+
options: ['xs', 'sm', 'md', 'lg', 'xl'],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default meta;
|
|
34
|
+
type Story = StoryFn<typeof SegmentedControl>;
|
|
35
|
+
|
|
36
|
+
const Template: Story = (props: any) => <SegmentedControl {...props} />;
|
|
37
|
+
|
|
38
|
+
export const Uncontrolled = Template.bind({});
|
|
39
|
+
Uncontrolled.args = {
|
|
40
|
+
options: [
|
|
41
|
+
{
|
|
42
|
+
label: 'Complete',
|
|
43
|
+
value: 'complete',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
label: 'Incomplete',
|
|
47
|
+
value: 'incomplete',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: 'Pending',
|
|
51
|
+
value: 'pending',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const Controlled: Story = (props: any) => {
|
|
57
|
+
const [selectedValue, setSelectedValue] = useState<string>('complete');
|
|
58
|
+
return (
|
|
59
|
+
<SegmentedControl
|
|
60
|
+
{...props}
|
|
61
|
+
value={selectedValue}
|
|
62
|
+
onSelect={(val: string) => {
|
|
63
|
+
setSelectedValue(val);
|
|
64
|
+
console.log('changed to ', val);
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
Controlled.args = {
|
|
70
|
+
options: [
|
|
71
|
+
{
|
|
72
|
+
label: 'Complete',
|
|
73
|
+
value: 'complete',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
label: 'Incomplete',
|
|
77
|
+
value: 'incomplete',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
label: 'Pending',
|
|
81
|
+
value: 'pending',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const Rounded = Template.bind({});
|
|
87
|
+
Rounded.args = {
|
|
88
|
+
borderRadius: 'full',
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const Small = Template.bind({});
|
|
92
|
+
Small.args = {
|
|
93
|
+
size: 'sm',
|
|
94
|
+
borderRadius: 'full',
|
|
95
|
+
w: 'fit-content',
|
|
96
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ButtonProps } from '../Button/Button.types';
|
|
2
|
+
import { SegmentedControlProps } from './SegmentedControl.types';
|
|
3
|
+
|
|
4
|
+
export const OptionStyles: Record<
|
|
5
|
+
Exclude<SegmentedControlProps['size'], undefined>,
|
|
6
|
+
ButtonProps
|
|
7
|
+
> = {
|
|
8
|
+
xs: {
|
|
9
|
+
minW: 6,
|
|
10
|
+
paddingInlineStart: 2,
|
|
11
|
+
paddingInlineEnd: 2,
|
|
12
|
+
h: 6,
|
|
13
|
+
},
|
|
14
|
+
sm: {
|
|
15
|
+
minW: 10,
|
|
16
|
+
paddingInlineStart: 6,
|
|
17
|
+
paddingInlineEnd: 6,
|
|
18
|
+
h: 8,
|
|
19
|
+
},
|
|
20
|
+
md: {
|
|
21
|
+
paddingInlineStart: 6,
|
|
22
|
+
paddingInlineEnd: 6,
|
|
23
|
+
minW: 10,
|
|
24
|
+
h: 10,
|
|
25
|
+
},
|
|
26
|
+
lg: {},
|
|
27
|
+
xl: {},
|
|
28
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { Button, Flex, useTheme } from '@chakra-ui/react';
|
|
3
|
+
import { motion } from 'framer-motion';
|
|
4
|
+
|
|
5
|
+
import { OptionStyles } from './SegmentedControl.styles';
|
|
6
|
+
import { SegmentedControlProps } from './SegmentedControl.types';
|
|
7
|
+
|
|
8
|
+
export const SegmentedControl = ({
|
|
9
|
+
options,
|
|
10
|
+
value,
|
|
11
|
+
onSelect,
|
|
12
|
+
borderRadius = 'md',
|
|
13
|
+
size,
|
|
14
|
+
...rest
|
|
15
|
+
}: SegmentedControlProps) => {
|
|
16
|
+
const [internalValue, setInternalValue] = useState(options[0].value);
|
|
17
|
+
const theme = useTheme();
|
|
18
|
+
|
|
19
|
+
// Use the controlled value if provided, otherwise use the internal state
|
|
20
|
+
const activeValue = value !== undefined ? value : internalValue;
|
|
21
|
+
const activeIndex = options.findIndex(
|
|
22
|
+
(option) => option.value === activeValue
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const getControlPadding: (
|
|
26
|
+
size: SegmentedControlProps['size']
|
|
27
|
+
) => SegmentedControlProps['padding'] = (size = 'md') => {
|
|
28
|
+
const paddings = {
|
|
29
|
+
xs: theme.space[1],
|
|
30
|
+
sm: theme.space[1],
|
|
31
|
+
md: theme.space[1],
|
|
32
|
+
lg: {},
|
|
33
|
+
xl: {},
|
|
34
|
+
};
|
|
35
|
+
return paddings[size];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const handleSelect = (selectedValue: string) => {
|
|
39
|
+
if (value === undefined) {
|
|
40
|
+
setInternalValue(selectedValue);
|
|
41
|
+
}
|
|
42
|
+
if (onSelect) onSelect(selectedValue);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Flex
|
|
47
|
+
position="relative"
|
|
48
|
+
borderRadius={borderRadius}
|
|
49
|
+
bg="gray.50"
|
|
50
|
+
// p="1"
|
|
51
|
+
{...rest}
|
|
52
|
+
>
|
|
53
|
+
<motion.div
|
|
54
|
+
initial={false}
|
|
55
|
+
animate={{
|
|
56
|
+
x: `calc(${100 * activeIndex}% + ${getControlPadding(size)})`,
|
|
57
|
+
}}
|
|
58
|
+
transition={{ type: 'spring', stiffness: 300, damping: 30 }}
|
|
59
|
+
style={{
|
|
60
|
+
position: 'absolute',
|
|
61
|
+
// @ts-expect-error - Chakra UI responsive values in Framer Motion styles
|
|
62
|
+
top: getControlPadding(size),
|
|
63
|
+
// @ts-expect-error - Chakra UI responsive values in Framer Motion styles
|
|
64
|
+
bottom: getControlPadding(size),
|
|
65
|
+
left: `calc(${activeIndex * 2} * ${getControlPadding(size)})`,
|
|
66
|
+
width: `calc(${100 / options.length}% - 2 * ${getControlPadding(size)})`,
|
|
67
|
+
borderRadius: theme.radii[borderRadius],
|
|
68
|
+
background: theme.colors.white,
|
|
69
|
+
boxShadow: theme.shadows.md,
|
|
70
|
+
}}
|
|
71
|
+
/>
|
|
72
|
+
|
|
73
|
+
{options.map((option) => (
|
|
74
|
+
<Button
|
|
75
|
+
key={option.value}
|
|
76
|
+
flex={1}
|
|
77
|
+
variant="ghost"
|
|
78
|
+
color={activeValue === option.value ? 'gray.1200' : 'gray.600'}
|
|
79
|
+
onClick={() => handleSelect(option.value)}
|
|
80
|
+
_hover={{ bg: 'transparent' }}
|
|
81
|
+
fontSize={size}
|
|
82
|
+
{...OptionStyles[size ?? 'md']}
|
|
83
|
+
>
|
|
84
|
+
{option.label}
|
|
85
|
+
</Button>
|
|
86
|
+
))}
|
|
87
|
+
</Flex>
|
|
88
|
+
);
|
|
89
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FlexProps, theme } from '@chakra-ui/react';
|
|
2
|
+
|
|
3
|
+
export type SegmentedControlOption = {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type SegmentedControlProps = Omit<FlexProps, 'onSelect'> & {
|
|
9
|
+
options: Array<SegmentedControlOption>;
|
|
10
|
+
value?: string;
|
|
11
|
+
onSelect?: (selectedValue: string) => void;
|
|
12
|
+
// Value is key in Chakra theme
|
|
13
|
+
borderRadius?: string;
|
|
14
|
+
size?: Extract<keyof typeof theme.sizes, 'xs' | 'sm' | 'md' | 'lg' | 'xl'>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ProgressBar } from '../ProgressBar';
|
|
2
|
+
import { ProgressSegmentProps } from './SegmentedProgressBar.types';
|
|
3
|
+
import { useSegmentedProgressBarContext } from './SegmentedProgressBarContext';
|
|
4
|
+
|
|
5
|
+
export const ProgressSegment = ({ value, ...rest }: ProgressSegmentProps) => {
|
|
6
|
+
const { max } = useSegmentedProgressBarContext();
|
|
7
|
+
return (
|
|
8
|
+
<ProgressBar
|
|
9
|
+
value={value}
|
|
10
|
+
max={value}
|
|
11
|
+
width={`${(value / max) * 100}%`}
|
|
12
|
+
height="100%"
|
|
13
|
+
bg="gray.200"
|
|
14
|
+
borderRadius={0}
|
|
15
|
+
{...rest}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
};
|