@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,288 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, SimpleGrid, Text, useBreakpointValue } from '@chakra-ui/react';
|
|
3
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
4
|
+
|
|
5
|
+
import { Masonry } from './Masonry';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof Masonry> = {
|
|
8
|
+
title: 'Components/Masonry',
|
|
9
|
+
component: Masonry,
|
|
10
|
+
args: {
|
|
11
|
+
numCols: 3,
|
|
12
|
+
gap: 4,
|
|
13
|
+
horizontalArrangement: false,
|
|
14
|
+
},
|
|
15
|
+
argTypes: {
|
|
16
|
+
numCols: {
|
|
17
|
+
control: 'number',
|
|
18
|
+
description: 'Number of columns in the masonry layout',
|
|
19
|
+
defaultValue: 3,
|
|
20
|
+
},
|
|
21
|
+
gap: {
|
|
22
|
+
control: 'number',
|
|
23
|
+
description: 'Gap between items',
|
|
24
|
+
defaultValue: 4,
|
|
25
|
+
},
|
|
26
|
+
horizontalArrangement: {
|
|
27
|
+
control: 'boolean',
|
|
28
|
+
description:
|
|
29
|
+
'Whether to arrange items horizontally (true) or balance column heights (false)',
|
|
30
|
+
defaultValue: false,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
parameters: {
|
|
34
|
+
docs: {
|
|
35
|
+
description: {
|
|
36
|
+
component:
|
|
37
|
+
'A responsive masonry layout component that arranges items in optimal position based on available vertical space.',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default meta;
|
|
44
|
+
type Story = StoryFn<typeof Masonry>;
|
|
45
|
+
|
|
46
|
+
// Helper to generate items with varying heights
|
|
47
|
+
const generateItems = (count: number) => {
|
|
48
|
+
return Array.from({ length: count }).map((_, index) => ({
|
|
49
|
+
id: index,
|
|
50
|
+
height: 100 + Math.floor(Math.random() * 200), // Random heights between 100-300px
|
|
51
|
+
color: index % 2 === 0 ? 'blue.50' : 'purple.50',
|
|
52
|
+
title: `Item ${index + 1}`,
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Basic usage example
|
|
57
|
+
export const Basic: Story = (args) => {
|
|
58
|
+
const items = generateItems(12);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<Masonry {...args}>
|
|
62
|
+
{items.map((item) => (
|
|
63
|
+
<Box
|
|
64
|
+
key={item.id}
|
|
65
|
+
bg={item.color}
|
|
66
|
+
height={`${item.height}px`}
|
|
67
|
+
p={4}
|
|
68
|
+
borderRadius="md"
|
|
69
|
+
shadow="sm"
|
|
70
|
+
>
|
|
71
|
+
<Text fontWeight="bold">{item.title}</Text>
|
|
72
|
+
<Text fontSize="sm">Height: {item.height}px</Text>
|
|
73
|
+
</Box>
|
|
74
|
+
))}
|
|
75
|
+
</Masonry>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Example with realistic content
|
|
80
|
+
export const WithRealContent: Story = (args) => {
|
|
81
|
+
const bgColor = 'gray.50'; // Light mode only
|
|
82
|
+
const categories = [
|
|
83
|
+
{
|
|
84
|
+
name: 'Social Media',
|
|
85
|
+
items: ['Facebook', 'Twitter', 'Instagram', 'LinkedIn', 'TikTok'],
|
|
86
|
+
},
|
|
87
|
+
{ name: 'Messaging', items: ['WhatsApp', 'Telegram', 'Signal'] },
|
|
88
|
+
{ name: 'Video', items: ['YouTube', 'Vimeo', 'TikTok', 'Twitch'] },
|
|
89
|
+
{
|
|
90
|
+
name: 'Productivity',
|
|
91
|
+
items: [
|
|
92
|
+
'Notion',
|
|
93
|
+
'Slack',
|
|
94
|
+
'Microsoft Teams',
|
|
95
|
+
'Asana',
|
|
96
|
+
'Trello',
|
|
97
|
+
'Monday',
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
{ name: 'Design', items: ['Figma', 'Adobe XD', 'Sketch', 'Canva'] },
|
|
101
|
+
{
|
|
102
|
+
name: 'Development',
|
|
103
|
+
items: ['GitHub', 'GitLab', 'Bitbucket', 'Stack Overflow'],
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<Masonry {...args}>
|
|
109
|
+
{categories.map((category) => (
|
|
110
|
+
<Box
|
|
111
|
+
key={category.name}
|
|
112
|
+
bg={bgColor}
|
|
113
|
+
p={4}
|
|
114
|
+
borderRadius="md"
|
|
115
|
+
shadow="sm"
|
|
116
|
+
mb={4}
|
|
117
|
+
>
|
|
118
|
+
<Text fontWeight="bold" fontSize="lg" mb={2} color="blue.500">
|
|
119
|
+
{category.name}
|
|
120
|
+
</Text>
|
|
121
|
+
{category.items.map((item) => (
|
|
122
|
+
<Box
|
|
123
|
+
key={item}
|
|
124
|
+
p={2}
|
|
125
|
+
_hover={{ bg: 'gray.100' }}
|
|
126
|
+
borderRadius="md"
|
|
127
|
+
transition="background 0.2s"
|
|
128
|
+
cursor="pointer"
|
|
129
|
+
display="flex"
|
|
130
|
+
alignItems="center"
|
|
131
|
+
>
|
|
132
|
+
<Box w="24px" h="24px" bg="blue.100" borderRadius="full" mr={2} />
|
|
133
|
+
<Text>{item}</Text>
|
|
134
|
+
</Box>
|
|
135
|
+
))}
|
|
136
|
+
</Box>
|
|
137
|
+
))}
|
|
138
|
+
</Masonry>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// Responsive example
|
|
143
|
+
export const Responsive: Story = (args) => {
|
|
144
|
+
// Use Chakra's breakpoint system for responsive columns
|
|
145
|
+
const responsiveColumns =
|
|
146
|
+
useBreakpointValue({
|
|
147
|
+
base: 1, // Mobile
|
|
148
|
+
sm: 2, // Tablet
|
|
149
|
+
md: 3, // Medium screens
|
|
150
|
+
lg: 4, // Large screens
|
|
151
|
+
xl: 5, // Extra large screens
|
|
152
|
+
}) || 3; // Default fallback
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<Box>
|
|
156
|
+
<Text mb={4}>Resize the viewport to see the columns adjust:</Text>
|
|
157
|
+
<Masonry {...args} numCols={responsiveColumns}>
|
|
158
|
+
{generateItems(20).map((item) => (
|
|
159
|
+
<Box
|
|
160
|
+
key={item.id}
|
|
161
|
+
bg={item.color}
|
|
162
|
+
height={`${item.height}px`}
|
|
163
|
+
p={4}
|
|
164
|
+
borderRadius="md"
|
|
165
|
+
shadow="sm"
|
|
166
|
+
>
|
|
167
|
+
<Text fontWeight="bold">{item.title}</Text>
|
|
168
|
+
</Box>
|
|
169
|
+
))}
|
|
170
|
+
</Masonry>
|
|
171
|
+
</Box>
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// Example with controls for column count
|
|
176
|
+
export const CustomizableColumns: Story = (args) => {
|
|
177
|
+
const items = generateItems(16);
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<Masonry {...args}>
|
|
181
|
+
{items.map((item) => (
|
|
182
|
+
<Box
|
|
183
|
+
key={item.id}
|
|
184
|
+
bg={item.color}
|
|
185
|
+
height={`${item.height}px`}
|
|
186
|
+
p={4}
|
|
187
|
+
borderRadius="md"
|
|
188
|
+
shadow="sm"
|
|
189
|
+
>
|
|
190
|
+
<Text fontWeight="bold">{item.title}</Text>
|
|
191
|
+
</Box>
|
|
192
|
+
))}
|
|
193
|
+
</Masonry>
|
|
194
|
+
);
|
|
195
|
+
};
|
|
196
|
+
CustomizableColumns.args = {
|
|
197
|
+
numCols: 3, // Set a single number to control in Storybook
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
// Horizontal arrangement example
|
|
201
|
+
export const HorizontalArrangement: Story = (args) => {
|
|
202
|
+
const items = generateItems(12);
|
|
203
|
+
|
|
204
|
+
return (
|
|
205
|
+
<Box>
|
|
206
|
+
<Text fontSize="xl" fontWeight="bold" mb={4}>
|
|
207
|
+
Horizontal Arrangement (row by row)
|
|
208
|
+
</Text>
|
|
209
|
+
<Masonry numCols={3} horizontalArrangement={true} gap={4}>
|
|
210
|
+
{items.map((item) => (
|
|
211
|
+
<Box
|
|
212
|
+
key={item.id}
|
|
213
|
+
bg={item.color}
|
|
214
|
+
height={`${item.height}px`}
|
|
215
|
+
p={4}
|
|
216
|
+
borderRadius="md"
|
|
217
|
+
shadow="sm"
|
|
218
|
+
>
|
|
219
|
+
<Text>{item.title}</Text>
|
|
220
|
+
</Box>
|
|
221
|
+
))}
|
|
222
|
+
</Masonry>
|
|
223
|
+
|
|
224
|
+
<Text fontSize="xl" fontWeight="bold" mt={8} mb={4}>
|
|
225
|
+
Height-Balanced Arrangement (default)
|
|
226
|
+
</Text>
|
|
227
|
+
<Masonry numCols={3} horizontalArrangement={false} gap={4}>
|
|
228
|
+
{items.map((item) => (
|
|
229
|
+
<Box
|
|
230
|
+
key={item.id}
|
|
231
|
+
bg={item.color}
|
|
232
|
+
height={`${item.height}px`}
|
|
233
|
+
p={4}
|
|
234
|
+
borderRadius="md"
|
|
235
|
+
shadow="sm"
|
|
236
|
+
>
|
|
237
|
+
<Text>{item.title}</Text>
|
|
238
|
+
</Box>
|
|
239
|
+
))}
|
|
240
|
+
</Masonry>
|
|
241
|
+
</Box>
|
|
242
|
+
);
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// Comparison with regular grid
|
|
246
|
+
export const ComparisonWithGrid: Story = (args) => {
|
|
247
|
+
const items = generateItems(12);
|
|
248
|
+
|
|
249
|
+
return (
|
|
250
|
+
<Box>
|
|
251
|
+
<Text fontSize="xl" fontWeight="bold" mb={4}>
|
|
252
|
+
Masonry Layout
|
|
253
|
+
</Text>
|
|
254
|
+
<Masonry {...args}>
|
|
255
|
+
{items.map((item) => (
|
|
256
|
+
<Box
|
|
257
|
+
key={item.id}
|
|
258
|
+
bg={item.color}
|
|
259
|
+
height={`${item.height}px`}
|
|
260
|
+
p={4}
|
|
261
|
+
borderRadius="md"
|
|
262
|
+
shadow="sm"
|
|
263
|
+
>
|
|
264
|
+
<Text>{item.title}</Text>
|
|
265
|
+
</Box>
|
|
266
|
+
))}
|
|
267
|
+
</Masonry>
|
|
268
|
+
|
|
269
|
+
<Text fontSize="xl" fontWeight="bold" mt={8} mb={4}>
|
|
270
|
+
Regular Grid Layout
|
|
271
|
+
</Text>
|
|
272
|
+
<SimpleGrid columns={{ base: 1, md: 2, lg: 3, xl: 4 }} spacing={4}>
|
|
273
|
+
{items.map((item) => (
|
|
274
|
+
<Box
|
|
275
|
+
key={item.id}
|
|
276
|
+
bg={item.color}
|
|
277
|
+
height={`${item.height}px`}
|
|
278
|
+
p={4}
|
|
279
|
+
borderRadius="md"
|
|
280
|
+
shadow="sm"
|
|
281
|
+
>
|
|
282
|
+
<Text>{item.title}</Text>
|
|
283
|
+
</Box>
|
|
284
|
+
))}
|
|
285
|
+
</SimpleGrid>
|
|
286
|
+
</Box>
|
|
287
|
+
);
|
|
288
|
+
};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
cloneElement,
|
|
4
|
+
isValidElement,
|
|
5
|
+
PropsWithChildren,
|
|
6
|
+
ReactNode,
|
|
7
|
+
useCallback,
|
|
8
|
+
useEffect,
|
|
9
|
+
useLayoutEffect,
|
|
10
|
+
useMemo,
|
|
11
|
+
useRef,
|
|
12
|
+
useState,
|
|
13
|
+
} from 'react';
|
|
14
|
+
import { Box, Flex, Grid } from '@chakra-ui/react';
|
|
15
|
+
|
|
16
|
+
import { MasonryProps } from './Masonry.types';
|
|
17
|
+
|
|
18
|
+
export const Masonry = ({
|
|
19
|
+
children,
|
|
20
|
+
numCols = 3,
|
|
21
|
+
gap = 4,
|
|
22
|
+
horizontalArrangement = false,
|
|
23
|
+
...rest
|
|
24
|
+
}: PropsWithChildren<MasonryProps>) => {
|
|
25
|
+
const childrenArray = useMemo(
|
|
26
|
+
() => Children.toArray(children).filter(isValidElement),
|
|
27
|
+
[children]
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const [itemHeights, setItemHeights] = useState<Record<string, number>>({});
|
|
31
|
+
const itemRefs = useRef<Record<string, HTMLDivElement | null>>({});
|
|
32
|
+
const resizeObserverRef = useRef<ResizeObserver | null>(null);
|
|
33
|
+
const isInitialRender = useRef(true);
|
|
34
|
+
|
|
35
|
+
// Clear refs for items that no longer exist
|
|
36
|
+
const cleanupItemRefs = useCallback(() => {
|
|
37
|
+
const currentKeys = childrenArray.map(
|
|
38
|
+
(_, index) => `masonry-item-${index}`
|
|
39
|
+
);
|
|
40
|
+
Object.keys(itemRefs.current).forEach((key) => {
|
|
41
|
+
if (!currentKeys.includes(key)) {
|
|
42
|
+
delete itemRefs.current[key];
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}, [childrenArray]);
|
|
46
|
+
|
|
47
|
+
// Measure item heights with optimized comparison
|
|
48
|
+
const measureItemHeights = useCallback(() => {
|
|
49
|
+
let hasChanges = false;
|
|
50
|
+
const newHeights = { ...itemHeights };
|
|
51
|
+
|
|
52
|
+
Object.entries(itemRefs.current).forEach(([key, ref]) => {
|
|
53
|
+
if (ref) {
|
|
54
|
+
const height = Math.round(ref.offsetHeight);
|
|
55
|
+
if (newHeights[key] !== height) {
|
|
56
|
+
newHeights[key] = height;
|
|
57
|
+
hasChanges = true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (hasChanges) {
|
|
63
|
+
setItemHeights(newHeights);
|
|
64
|
+
}
|
|
65
|
+
}, [itemHeights]);
|
|
66
|
+
|
|
67
|
+
// Setup measurements on initial render and when children change
|
|
68
|
+
useLayoutEffect(() => {
|
|
69
|
+
// Use layout effect for synchronous measurement before paint
|
|
70
|
+
cleanupItemRefs();
|
|
71
|
+
|
|
72
|
+
// Measure after DOM update but before browser paint
|
|
73
|
+
if (isInitialRender.current) {
|
|
74
|
+
isInitialRender.current = false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const timer = setTimeout(measureItemHeights, 0);
|
|
78
|
+
return () => clearTimeout(timer);
|
|
79
|
+
}, [childrenArray.length, cleanupItemRefs, measureItemHeights]);
|
|
80
|
+
|
|
81
|
+
// Set up resize observer
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
// Clear previous observer
|
|
84
|
+
if (resizeObserverRef.current) {
|
|
85
|
+
resizeObserverRef.current.disconnect();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Create new observer that uses throttled measurement
|
|
89
|
+
let rafId: number;
|
|
90
|
+
const handleResize = () => {
|
|
91
|
+
cancelAnimationFrame(rafId);
|
|
92
|
+
rafId = requestAnimationFrame(measureItemHeights);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
resizeObserverRef.current = new ResizeObserver(handleResize);
|
|
96
|
+
|
|
97
|
+
// Observe all current refs
|
|
98
|
+
Object.values(itemRefs.current).forEach((ref) => {
|
|
99
|
+
if (ref) {
|
|
100
|
+
resizeObserverRef.current?.observe(ref);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
return () => {
|
|
105
|
+
cancelAnimationFrame(rafId);
|
|
106
|
+
resizeObserverRef.current?.disconnect();
|
|
107
|
+
};
|
|
108
|
+
}, [measureItemHeights, childrenArray.length]);
|
|
109
|
+
|
|
110
|
+
// Create column layout with optimized distribution
|
|
111
|
+
const columns = useMemo(() => {
|
|
112
|
+
const colElements: ReactNode[][] = Array.from(
|
|
113
|
+
{ length: numCols },
|
|
114
|
+
() => []
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
if (horizontalArrangement) {
|
|
118
|
+
// Horizontal arrangement (row by row)
|
|
119
|
+
childrenArray.forEach((child, index) => {
|
|
120
|
+
const columnIndex = index % numCols;
|
|
121
|
+
const itemKey = `masonry-item-${index}`;
|
|
122
|
+
|
|
123
|
+
colElements[columnIndex].push(
|
|
124
|
+
<Box
|
|
125
|
+
key={itemKey}
|
|
126
|
+
ref={(el) => {
|
|
127
|
+
itemRefs.current[itemKey] = el;
|
|
128
|
+
}}
|
|
129
|
+
mb={gap}
|
|
130
|
+
w="100%"
|
|
131
|
+
>
|
|
132
|
+
{cloneElement(child, { key: itemKey })}
|
|
133
|
+
</Box>
|
|
134
|
+
);
|
|
135
|
+
});
|
|
136
|
+
} else {
|
|
137
|
+
// Height-balanced arrangement
|
|
138
|
+
const columnHeights = Array(numCols).fill(0);
|
|
139
|
+
|
|
140
|
+
childrenArray.forEach((child, index) => {
|
|
141
|
+
// Find column with the shortest height
|
|
142
|
+
const shortestColumnIndex = columnHeights.indexOf(
|
|
143
|
+
Math.min(...columnHeights)
|
|
144
|
+
);
|
|
145
|
+
const itemKey = `masonry-item-${index}`;
|
|
146
|
+
|
|
147
|
+
colElements[shortestColumnIndex].push(
|
|
148
|
+
<Box
|
|
149
|
+
key={itemKey}
|
|
150
|
+
ref={(el) => {
|
|
151
|
+
itemRefs.current[itemKey] = el;
|
|
152
|
+
}}
|
|
153
|
+
_notLast={{
|
|
154
|
+
mb: gap,
|
|
155
|
+
}}
|
|
156
|
+
w="100%"
|
|
157
|
+
>
|
|
158
|
+
{cloneElement(child, { key: itemKey })}
|
|
159
|
+
</Box>
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
// Update column height
|
|
163
|
+
const itemHeight = itemHeights[itemKey] || 0;
|
|
164
|
+
columnHeights[shortestColumnIndex] +=
|
|
165
|
+
itemHeight + (typeof gap === 'number' ? gap : 0);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return colElements;
|
|
170
|
+
}, [childrenArray, numCols, horizontalArrangement, gap, itemHeights]);
|
|
171
|
+
|
|
172
|
+
// Use Chakra UI's Grid for perfectly equal column widths
|
|
173
|
+
return (
|
|
174
|
+
<Grid
|
|
175
|
+
width="full"
|
|
176
|
+
templateColumns={`repeat(${numCols}, 1fr)`}
|
|
177
|
+
gap={gap}
|
|
178
|
+
{...rest}
|
|
179
|
+
>
|
|
180
|
+
{columns.map((colItems, i) => (
|
|
181
|
+
<Flex key={`masonry-column-${i}`} direction="column" width="100%">
|
|
182
|
+
{colItems}
|
|
183
|
+
</Flex>
|
|
184
|
+
))}
|
|
185
|
+
</Grid>
|
|
186
|
+
);
|
|
187
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FlexProps } from '@chakra-ui/react';
|
|
2
|
+
|
|
3
|
+
export interface MasonryProps extends Omit<FlexProps, 'gap'> {
|
|
4
|
+
/**
|
|
5
|
+
* Number of columns in the masonry layout
|
|
6
|
+
*/
|
|
7
|
+
numCols: number;
|
|
8
|
+
/**
|
|
9
|
+
* Gap between items (applied to both columns and rows)
|
|
10
|
+
* @default 4
|
|
11
|
+
*/
|
|
12
|
+
gap?: number | string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to arrange items from left to right (true) or top to bottom (false)
|
|
15
|
+
* @default false (arrange vertically)
|
|
16
|
+
*/
|
|
17
|
+
horizontalArrangement?: boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { MaxLengthIndicator } from '.';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof MaxLengthIndicator> = {
|
|
7
|
+
title: 'Components/MaxLengthIndicator',
|
|
8
|
+
component: MaxLengthIndicator,
|
|
9
|
+
args: {
|
|
10
|
+
value: 1,
|
|
11
|
+
maxLength: 50,
|
|
12
|
+
},
|
|
13
|
+
argTypes: {
|
|
14
|
+
value: {
|
|
15
|
+
control: 'number',
|
|
16
|
+
},
|
|
17
|
+
maxLength: {
|
|
18
|
+
control: 'number',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
24
|
+
type Story = StoryFn<typeof MaxLengthIndicator>;
|
|
25
|
+
|
|
26
|
+
export const Basic: Story = (args) => <MaxLengthIndicator {...args} />;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { TextProps } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
import { Subtitle } from '../Typography';
|
|
5
|
+
|
|
6
|
+
export const MaxLengthIndicator = ({
|
|
7
|
+
value,
|
|
8
|
+
maxLength,
|
|
9
|
+
...rest
|
|
10
|
+
}: {
|
|
11
|
+
value: number;
|
|
12
|
+
maxLength: number;
|
|
13
|
+
} & TextProps) => {
|
|
14
|
+
const [currentValue, setCurrentValue] = useState<number>(0);
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
setCurrentValue(value);
|
|
18
|
+
}, [value]);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Subtitle fontSize="sm" color="gray.600" {...rest}>
|
|
22
|
+
{currentValue}/{maxLength}
|
|
23
|
+
</Subtitle>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MaxLengthIndicator } from './MaxLengthIndicator';
|