@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,55 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { Icon } from '@/components/Icon';
|
|
5
|
+
|
|
6
|
+
import { Input, InputDataProps } from './Input';
|
|
7
|
+
|
|
8
|
+
const meta: Meta<typeof Input> = {
|
|
9
|
+
title: 'Components/Input',
|
|
10
|
+
component: Input,
|
|
11
|
+
argTypes: {
|
|
12
|
+
placeholder: { control: 'text' },
|
|
13
|
+
size: {
|
|
14
|
+
control: {
|
|
15
|
+
type: 'select',
|
|
16
|
+
options: ['sm', 'md', 'lg'],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
isDisabled: { control: 'boolean' },
|
|
20
|
+
isInvalid: { control: 'boolean' },
|
|
21
|
+
maxLength: { control: 'number' },
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default meta;
|
|
26
|
+
|
|
27
|
+
const Template: StoryFn<InputDataProps> = (args) => {
|
|
28
|
+
const [value, setValue] = useState('');
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Input {...args} value={value} onChange={(e) => setValue(e.target.value)} />
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const Basic: StoryFn<InputDataProps> = Template.bind({});
|
|
36
|
+
Basic.args = {};
|
|
37
|
+
|
|
38
|
+
export const LeftIcon: StoryFn<InputDataProps> = Template.bind({});
|
|
39
|
+
LeftIcon.args = {
|
|
40
|
+
placeholder: 'Phone number',
|
|
41
|
+
size: 'md',
|
|
42
|
+
isDisabled: false,
|
|
43
|
+
isInvalid: false,
|
|
44
|
+
leftIcon: <Icon icon="IoCall" color="gray.300" />,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const RightIcon: StoryFn<InputDataProps> = Template.bind({});
|
|
48
|
+
RightIcon.args = {
|
|
49
|
+
placeholder: 'Search...',
|
|
50
|
+
size: 'md',
|
|
51
|
+
isDisabled: false,
|
|
52
|
+
isInvalid: false,
|
|
53
|
+
rightIcon: <Icon icon="IoSearch" color="gray.300" />,
|
|
54
|
+
maxLength: 20,
|
|
55
|
+
};
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CompositionEvent,
|
|
3
|
+
ForwardedRef,
|
|
4
|
+
forwardRef,
|
|
5
|
+
KeyboardEvent,
|
|
6
|
+
useEffect,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from 'react';
|
|
10
|
+
import {
|
|
11
|
+
Input as ChakraInput,
|
|
12
|
+
InputGroup,
|
|
13
|
+
InputLeftElement,
|
|
14
|
+
InputRightElement,
|
|
15
|
+
useTheme,
|
|
16
|
+
} from '@chakra-ui/react';
|
|
17
|
+
|
|
18
|
+
import { formatNumber } from '@/utils/formatNumber';
|
|
19
|
+
|
|
20
|
+
import { InputProps } from './Input.types';
|
|
21
|
+
|
|
22
|
+
// Helper function for unformatting numbers
|
|
23
|
+
const unformatNumber = (value: string) => {
|
|
24
|
+
// Remove commas and any non-digit characters except decimal point
|
|
25
|
+
return value.replace(/,/g, '').replace(/[^\d.]/g, '');
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Helper function to calculate cursor position after formatting
|
|
29
|
+
const calculateCursorPosition = (
|
|
30
|
+
oldValue: string,
|
|
31
|
+
newValue: string,
|
|
32
|
+
oldCursorPos: number
|
|
33
|
+
): number => {
|
|
34
|
+
// Count commas before cursor in old value
|
|
35
|
+
const commasBeforeCursorOld = (
|
|
36
|
+
oldValue.slice(0, oldCursorPos).match(/,/g) || []
|
|
37
|
+
).length;
|
|
38
|
+
|
|
39
|
+
// Get the position in the unformatted string
|
|
40
|
+
const unformattedPos = oldCursorPos - commasBeforeCursorOld;
|
|
41
|
+
|
|
42
|
+
// Count commas before this position in new value
|
|
43
|
+
let newPos = 0;
|
|
44
|
+
let unformattedCount = 0;
|
|
45
|
+
|
|
46
|
+
for (
|
|
47
|
+
let i = 0;
|
|
48
|
+
i < newValue.length && unformattedCount < unformattedPos;
|
|
49
|
+
i++
|
|
50
|
+
) {
|
|
51
|
+
if (newValue[i] !== ',') {
|
|
52
|
+
unformattedCount++;
|
|
53
|
+
}
|
|
54
|
+
newPos = i + 1;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return Math.min(newPos, newValue.length);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const Input = forwardRef(
|
|
61
|
+
(
|
|
62
|
+
{
|
|
63
|
+
leftIcon,
|
|
64
|
+
leftElementProps,
|
|
65
|
+
rightIcon,
|
|
66
|
+
rightElementProps,
|
|
67
|
+
onKeyDown,
|
|
68
|
+
onCompositionEnd,
|
|
69
|
+
onCompositionStart,
|
|
70
|
+
maxLength,
|
|
71
|
+
value: propValue,
|
|
72
|
+
onChange,
|
|
73
|
+
size,
|
|
74
|
+
wrapperProps,
|
|
75
|
+
maskNumber = false,
|
|
76
|
+
type,
|
|
77
|
+
_hover,
|
|
78
|
+
_focus,
|
|
79
|
+
trimWhiteSpace = false,
|
|
80
|
+
noSpaces = false,
|
|
81
|
+
...rest
|
|
82
|
+
}: InputProps,
|
|
83
|
+
ref?: ForwardedRef<HTMLInputElement>
|
|
84
|
+
) => {
|
|
85
|
+
const rightElementRef = useRef<HTMLDivElement>(null);
|
|
86
|
+
const [rightElementWidth, setRightElementWidth] = useState(0);
|
|
87
|
+
const theme = useTheme();
|
|
88
|
+
const isComposing = useRef(false);
|
|
89
|
+
const cursorPosition = useRef<number | null>(null);
|
|
90
|
+
const [shouldRestoreCursor, setShouldRestoreCursor] = useState(false);
|
|
91
|
+
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (rightElementRef.current) {
|
|
94
|
+
setRightElementWidth(rightElementRef.current.offsetWidth);
|
|
95
|
+
}
|
|
96
|
+
}, [rightElementRef.current]);
|
|
97
|
+
|
|
98
|
+
// Restore cursor position after formatting
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (
|
|
101
|
+
shouldRestoreCursor &&
|
|
102
|
+
cursorPosition.current !== null &&
|
|
103
|
+
maskNumber &&
|
|
104
|
+
type === 'number'
|
|
105
|
+
) {
|
|
106
|
+
const inputElement = ref && 'current' in ref ? ref.current : null;
|
|
107
|
+
if (inputElement) {
|
|
108
|
+
inputElement.setSelectionRange(
|
|
109
|
+
cursorPosition.current,
|
|
110
|
+
cursorPosition.current
|
|
111
|
+
);
|
|
112
|
+
cursorPosition.current = null;
|
|
113
|
+
setShouldRestoreCursor(false);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}, [shouldRestoreCursor, maskNumber, type, ref]);
|
|
117
|
+
|
|
118
|
+
// Format the value if maskNumber is true and type is number
|
|
119
|
+
const getFormattedValue = (val: typeof propValue) => {
|
|
120
|
+
if (
|
|
121
|
+
maskNumber &&
|
|
122
|
+
type === 'number' &&
|
|
123
|
+
val !== undefined &&
|
|
124
|
+
val !== null &&
|
|
125
|
+
val !== ''
|
|
126
|
+
) {
|
|
127
|
+
const numVal = typeof val === 'string' ? parseFloat(val) : val;
|
|
128
|
+
if (!isNaN(numVal as number)) {
|
|
129
|
+
return formatNumber(numVal as number);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return val;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const [currentValue, setCurrentValue] = useState<
|
|
136
|
+
string | number | readonly string[] | undefined
|
|
137
|
+
>(getFormattedValue(propValue));
|
|
138
|
+
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
setCurrentValue(getFormattedValue(propValue));
|
|
141
|
+
}, [propValue]);
|
|
142
|
+
|
|
143
|
+
// 한글 타이핑 관련 버그 해결을 위해 composition event handler들을 사용합니다
|
|
144
|
+
const handleCompositionStart = (e: CompositionEvent<HTMLInputElement>) => {
|
|
145
|
+
isComposing.current = true;
|
|
146
|
+
if (onCompositionStart) onCompositionStart(e);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const handleCompositionEnd = (e: any) => {
|
|
150
|
+
isComposing.current = false;
|
|
151
|
+
if (onCompositionEnd) onCompositionEnd(e);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
|
155
|
+
if (e.key === 'Enter') {
|
|
156
|
+
if (isComposing.current) {
|
|
157
|
+
e.preventDefault();
|
|
158
|
+
e.stopPropagation();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (onKeyDown) onKeyDown(e);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// trimWhiteSpace prop이 존재하고, 입력된 값이 아예 없는 경우만 스페이스바를 통한 공백 입력 금지
|
|
166
|
+
// noSpaces prop이 존재하고, 스페이스바를 통한 공백 일체 입력 금지
|
|
167
|
+
if (
|
|
168
|
+
(noSpaces || (trimWhiteSpace && currentValue === '')) &&
|
|
169
|
+
e.key.match(/\s/)
|
|
170
|
+
) {
|
|
171
|
+
e.preventDefault();
|
|
172
|
+
e.stopPropagation();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// Helper function to create synthetic event with filtered value
|
|
178
|
+
const createSyntheticEvent = (
|
|
179
|
+
originalEvent: React.ChangeEvent<HTMLInputElement>,
|
|
180
|
+
newValue: string
|
|
181
|
+
) => {
|
|
182
|
+
// Create a new native event to ensure Formik properly updates
|
|
183
|
+
const nativeEvent = Object.create(originalEvent.nativeEvent);
|
|
184
|
+
const newTarget = {
|
|
185
|
+
...originalEvent.target,
|
|
186
|
+
value: newValue,
|
|
187
|
+
name: originalEvent.target.name,
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// Create a new synthetic event that Formik will recognize
|
|
191
|
+
const syntheticEvent = {
|
|
192
|
+
...originalEvent,
|
|
193
|
+
nativeEvent,
|
|
194
|
+
target: newTarget,
|
|
195
|
+
currentTarget: newTarget,
|
|
196
|
+
} as React.ChangeEvent<HTMLInputElement>;
|
|
197
|
+
|
|
198
|
+
return syntheticEvent;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
202
|
+
let processedValue = e.target.value;
|
|
203
|
+
|
|
204
|
+
// Handle trimWhiteSpace: prevent initial spaces and trim pasted content
|
|
205
|
+
if (trimWhiteSpace) {
|
|
206
|
+
// If input becomes entirely whitespace, clear it
|
|
207
|
+
if (processedValue.trim() === '') {
|
|
208
|
+
setCurrentValue('');
|
|
209
|
+
if (onChange) {
|
|
210
|
+
onChange(createSyntheticEvent(e, ''));
|
|
211
|
+
}
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
// Trim leading and trailing spaces from non-empty content
|
|
215
|
+
processedValue = processedValue.trim();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Handle noSpaces: remove all spaces
|
|
219
|
+
// prevent whitespace insertion on copy paste bug
|
|
220
|
+
if (noSpaces) {
|
|
221
|
+
processedValue = processedValue.replace(/\s/g, '');
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (maskNumber && type === 'number') {
|
|
225
|
+
const oldValue = String(currentValue || '');
|
|
226
|
+
const oldCursorPos = e.target.selectionStart || 0;
|
|
227
|
+
|
|
228
|
+
// Remove commas for processing
|
|
229
|
+
const unformatted = unformatNumber(processedValue);
|
|
230
|
+
|
|
231
|
+
// Update display value with formatting
|
|
232
|
+
if (unformatted === '') {
|
|
233
|
+
setCurrentValue('');
|
|
234
|
+
cursorPosition.current = 0;
|
|
235
|
+
setShouldRestoreCursor(true);
|
|
236
|
+
} else {
|
|
237
|
+
const num = parseFloat(unformatted);
|
|
238
|
+
if (!isNaN(num)) {
|
|
239
|
+
const newFormattedValue = formatNumber(num);
|
|
240
|
+
setCurrentValue(newFormattedValue);
|
|
241
|
+
|
|
242
|
+
// Calculate and store new cursor position
|
|
243
|
+
cursorPosition.current = calculateCursorPosition(
|
|
244
|
+
oldValue,
|
|
245
|
+
newFormattedValue,
|
|
246
|
+
oldCursorPos
|
|
247
|
+
);
|
|
248
|
+
setShouldRestoreCursor(true);
|
|
249
|
+
} else {
|
|
250
|
+
setCurrentValue(unformatted);
|
|
251
|
+
cursorPosition.current = oldCursorPos;
|
|
252
|
+
setShouldRestoreCursor(true);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Pass the raw numeric value to onChange
|
|
257
|
+
if (onChange) {
|
|
258
|
+
onChange(createSyntheticEvent(e, unformatted));
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
setCurrentValue(processedValue);
|
|
262
|
+
if (onChange) {
|
|
263
|
+
onChange(createSyntheticEvent(e, processedValue));
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
269
|
+
if (maskNumber && type === 'number' && e.target.value) {
|
|
270
|
+
const numericValue = parseFloat(unformatNumber(e.target.value));
|
|
271
|
+
if (!isNaN(numericValue)) {
|
|
272
|
+
setCurrentValue(formatNumber(numericValue));
|
|
273
|
+
|
|
274
|
+
if (rest.onBlur) {
|
|
275
|
+
// Create a new native event to ensure Formik properly updates
|
|
276
|
+
const nativeEvent = Object.create(e.nativeEvent);
|
|
277
|
+
const newTarget = {
|
|
278
|
+
...e.target,
|
|
279
|
+
value: numericValue.toString(),
|
|
280
|
+
name: e.target.name,
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// Create a new synthetic event that Formik will recognize
|
|
284
|
+
const syntheticEvent = {
|
|
285
|
+
...e,
|
|
286
|
+
nativeEvent,
|
|
287
|
+
target: newTarget,
|
|
288
|
+
currentTarget: newTarget,
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
rest.onBlur(syntheticEvent as React.FocusEvent<HTMLInputElement>);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
} else if (rest.onBlur) {
|
|
295
|
+
rest.onBlur(e);
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// If maskNumber is true and type is number, we need to use text type
|
|
300
|
+
// to allow for comma formatting
|
|
301
|
+
const inputType = maskNumber && type === 'number' ? 'text' : type;
|
|
302
|
+
|
|
303
|
+
return (
|
|
304
|
+
<InputGroup size={size} {...wrapperProps}>
|
|
305
|
+
{leftIcon && (
|
|
306
|
+
<InputLeftElement {...leftElementProps}>{leftIcon}</InputLeftElement>
|
|
307
|
+
)}
|
|
308
|
+
<ChakraInput
|
|
309
|
+
ref={ref}
|
|
310
|
+
maxLength={maxLength}
|
|
311
|
+
value={currentValue}
|
|
312
|
+
onChange={handleChange}
|
|
313
|
+
onBlur={handleBlur}
|
|
314
|
+
onCompositionStart={handleCompositionStart}
|
|
315
|
+
onCompositionEnd={handleCompositionEnd}
|
|
316
|
+
onKeyDown={handleKeyDown}
|
|
317
|
+
type={inputType}
|
|
318
|
+
borderColor="gray.400"
|
|
319
|
+
_hover={{
|
|
320
|
+
borderColor: 'gray.600',
|
|
321
|
+
..._hover,
|
|
322
|
+
}}
|
|
323
|
+
_focus={{
|
|
324
|
+
borderColor: 'primary.main',
|
|
325
|
+
..._focus,
|
|
326
|
+
}}
|
|
327
|
+
focusBorderColor={theme.semanticTokens.colors.primary.main}
|
|
328
|
+
_readOnly={{
|
|
329
|
+
opacity: 1,
|
|
330
|
+
cursor: 'not-allowed',
|
|
331
|
+
bg: 'gray.50',
|
|
332
|
+
color: 'gray.600',
|
|
333
|
+
borderColor: 'gray.200',
|
|
334
|
+
}}
|
|
335
|
+
_disabled={{
|
|
336
|
+
opacity: 1,
|
|
337
|
+
cursor: 'not-allowed',
|
|
338
|
+
bg: 'gray.50',
|
|
339
|
+
color: 'gray.1000',
|
|
340
|
+
fontWeight: 'semibold',
|
|
341
|
+
}}
|
|
342
|
+
sx={{
|
|
343
|
+
paddingInlineEnd: rightElementWidth,
|
|
344
|
+
}}
|
|
345
|
+
errorBorderColor={theme.semanticTokens.colors.danger.main}
|
|
346
|
+
{...rest}
|
|
347
|
+
/>
|
|
348
|
+
{rightIcon && (
|
|
349
|
+
<InputRightElement ref={rightElementRef} {...rightElementProps}>
|
|
350
|
+
{rightIcon}
|
|
351
|
+
</InputRightElement>
|
|
352
|
+
)}
|
|
353
|
+
</InputGroup>
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
Input.displayName = 'Input';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InputGroupProps,
|
|
3
|
+
InputLeftElementProps,
|
|
4
|
+
InputProps as ChakraInputProps,
|
|
5
|
+
InputRightElementProps,
|
|
6
|
+
} from '@chakra-ui/react';
|
|
7
|
+
|
|
8
|
+
export interface InputProps extends ChakraInputProps {
|
|
9
|
+
leftIcon?: React.ReactElement;
|
|
10
|
+
rightIcon?: React.ReactElement;
|
|
11
|
+
wrapperProps?: InputGroupProps;
|
|
12
|
+
leftElementProps?: InputLeftElementProps;
|
|
13
|
+
rightElementProps?: InputRightElementProps;
|
|
14
|
+
maskNumber?: boolean;
|
|
15
|
+
/** 빈값일 때 공백 입력 방지 및 복사 붙여넣기 시 앞뒤 공백 제거 */
|
|
16
|
+
trimWhiteSpace?: boolean;
|
|
17
|
+
/** 모든 공백을 허용하지 않음 */
|
|
18
|
+
noSpaces?: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { LineGraph } from '.';
|
|
5
|
+
|
|
6
|
+
const TEST_DATA = [
|
|
7
|
+
{
|
|
8
|
+
name: 'Page A',
|
|
9
|
+
uv: 4000,
|
|
10
|
+
pv: 2400,
|
|
11
|
+
amt: 2400,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'Page B',
|
|
15
|
+
uv: 3000,
|
|
16
|
+
pv: 1398,
|
|
17
|
+
amt: 2210,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'Page C',
|
|
21
|
+
uv: 2000,
|
|
22
|
+
pv: 9800,
|
|
23
|
+
amt: 2290,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'Page D',
|
|
27
|
+
uv: 2780,
|
|
28
|
+
pv: 3908,
|
|
29
|
+
amt: 2000,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'Page E',
|
|
33
|
+
uv: 1890,
|
|
34
|
+
pv: 4800,
|
|
35
|
+
amt: 2181,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'Page F',
|
|
39
|
+
uv: 2390,
|
|
40
|
+
pv: 3800,
|
|
41
|
+
amt: 2500,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'Page G',
|
|
45
|
+
uv: 3490,
|
|
46
|
+
pv: 4300,
|
|
47
|
+
amt: 2100,
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const meta: Meta<typeof LineGraph> = {
|
|
52
|
+
title: 'Components/LineGraph',
|
|
53
|
+
component: LineGraph,
|
|
54
|
+
args: {
|
|
55
|
+
data: TEST_DATA,
|
|
56
|
+
dataKeys: [
|
|
57
|
+
{
|
|
58
|
+
key: 'uv',
|
|
59
|
+
label: 'UV Stuff',
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default meta;
|
|
66
|
+
type Story = StoryFn<typeof LineGraph>;
|
|
67
|
+
|
|
68
|
+
export const Basic: Story = (args) => <LineGraph {...args} />;
|
|
69
|
+
|
|
70
|
+
export const TwoSeries: Story = (args) => <LineGraph {...args} />;
|
|
71
|
+
TwoSeries.args = {
|
|
72
|
+
dataKeys: [
|
|
73
|
+
{
|
|
74
|
+
key: 'uv',
|
|
75
|
+
label: 'UV Stuff',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
key: 'pv',
|
|
79
|
+
label: 'PV Stuff',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const CustomColors: Story = (args) => <LineGraph {...args} />;
|
|
85
|
+
CustomColors.args = {
|
|
86
|
+
dataKeys: [
|
|
87
|
+
{
|
|
88
|
+
key: 'uv',
|
|
89
|
+
label: 'UV Stuff',
|
|
90
|
+
color: 'red',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
key: 'pv',
|
|
94
|
+
label: 'PV Stuff',
|
|
95
|
+
color: 'purple',
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Box, useTheme, useToken } from '@chakra-ui/react';
|
|
2
|
+
import {
|
|
3
|
+
CartesianGrid,
|
|
4
|
+
Legend,
|
|
5
|
+
Line,
|
|
6
|
+
LineChart,
|
|
7
|
+
ResponsiveContainer,
|
|
8
|
+
Tooltip,
|
|
9
|
+
XAxis,
|
|
10
|
+
YAxis,
|
|
11
|
+
} from 'recharts';
|
|
12
|
+
|
|
13
|
+
import { DatumBase, LineGraphProps } from './LineGraph.types';
|
|
14
|
+
|
|
15
|
+
export const LineGraph = <T extends DatumBase>({
|
|
16
|
+
data = [],
|
|
17
|
+
dataKeys,
|
|
18
|
+
...rest
|
|
19
|
+
}: LineGraphProps<T>) => {
|
|
20
|
+
const theme = useTheme();
|
|
21
|
+
return (
|
|
22
|
+
<Box h="400px" {...rest}>
|
|
23
|
+
<ResponsiveContainer width="100%" height="100%">
|
|
24
|
+
<LineChart
|
|
25
|
+
data={data}
|
|
26
|
+
margin={{
|
|
27
|
+
top: 0,
|
|
28
|
+
bottom: 0,
|
|
29
|
+
left: 0,
|
|
30
|
+
right: 48,
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
<CartesianGrid
|
|
34
|
+
// No dashes
|
|
35
|
+
strokeDasharray=""
|
|
36
|
+
vertical={false}
|
|
37
|
+
stroke={theme.colors.gray[400]}
|
|
38
|
+
/>
|
|
39
|
+
<XAxis
|
|
40
|
+
dataKey="name"
|
|
41
|
+
// Color of line
|
|
42
|
+
stroke="transparent"
|
|
43
|
+
// Props of text
|
|
44
|
+
tick={{
|
|
45
|
+
fill: theme.colors.gray[1200],
|
|
46
|
+
fontSize: useToken('fontSizes', 'sm'),
|
|
47
|
+
}}
|
|
48
|
+
tickMargin={8}
|
|
49
|
+
/>
|
|
50
|
+
<YAxis
|
|
51
|
+
// Color of line
|
|
52
|
+
stroke="transparent"
|
|
53
|
+
// Props of text
|
|
54
|
+
tick={{
|
|
55
|
+
fill: theme.colors.gray[1200],
|
|
56
|
+
fontSize: useToken('fontSizes', 'sm'),
|
|
57
|
+
}}
|
|
58
|
+
tickMargin={0}
|
|
59
|
+
/>
|
|
60
|
+
<Tooltip
|
|
61
|
+
// invert label color since mode inside tooltip is different
|
|
62
|
+
labelStyle={{
|
|
63
|
+
color: theme.colors.gray[1500],
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
<Legend
|
|
67
|
+
wrapperStyle={{
|
|
68
|
+
bottom: -16,
|
|
69
|
+
}}
|
|
70
|
+
/>
|
|
71
|
+
{dataKeys.map(({ key, label, color }) => (
|
|
72
|
+
<Line
|
|
73
|
+
key={`line-${key}`}
|
|
74
|
+
type="monotone"
|
|
75
|
+
dataKey={key}
|
|
76
|
+
name={label}
|
|
77
|
+
stroke={
|
|
78
|
+
color ??
|
|
79
|
+
useToken('colors', theme.semanticTokens.colors.primary.main)
|
|
80
|
+
}
|
|
81
|
+
dot={{ r: 0 }}
|
|
82
|
+
/>
|
|
83
|
+
))}
|
|
84
|
+
</LineChart>
|
|
85
|
+
</ResponsiveContainer>
|
|
86
|
+
</Box>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BoxProps } from '@chakra-ui/react';
|
|
2
|
+
import { type DataKey as RechartsDataKey } from 'recharts/types/util/types.d';
|
|
3
|
+
|
|
4
|
+
export interface LineGraphProps<T extends DatumBase> extends BoxProps {
|
|
5
|
+
data: Array<Datum<T>>;
|
|
6
|
+
dataKeys: Array<DataKey<T>>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Any numerical data the user wants to define
|
|
11
|
+
*/
|
|
12
|
+
export type DatumBase = {
|
|
13
|
+
[key: string]: number | undefined;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A name prop has to be passed to have the XAxis key always defined
|
|
18
|
+
*/
|
|
19
|
+
export type Datum<T extends DatumBase> = {
|
|
20
|
+
name: string;
|
|
21
|
+
} & T;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The data for each series
|
|
25
|
+
*/
|
|
26
|
+
export type DataKey<T extends DatumBase> = {
|
|
27
|
+
/**
|
|
28
|
+
* Key used to reference a value in the data prop
|
|
29
|
+
*/
|
|
30
|
+
key: RechartsDataKey<keyof T>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Label for the XAxis
|
|
34
|
+
*/
|
|
35
|
+
label: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Optional custom colors for the series
|
|
39
|
+
*/
|
|
40
|
+
color?: string;
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LineGraph } from './LineGraph';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Property } from 'csstype';
|
|
2
|
+
|
|
3
|
+
import theme from '@/theme/index';
|
|
4
|
+
|
|
5
|
+
export const linkTextStyles = {
|
|
6
|
+
color: theme.colors.blue[700],
|
|
7
|
+
fontWeight: '500',
|
|
8
|
+
position: 'relative' as Property.Position,
|
|
9
|
+
_hover: {
|
|
10
|
+
textDecoration: 'none',
|
|
11
|
+
color: theme.colors.blue[900],
|
|
12
|
+
},
|
|
13
|
+
};
|