@okam/stack-ui 1.25.2 → 1.25.3
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/.eslintrc.js +32 -0
- package/.storybook/.eslintrc.js +29 -0
- package/.storybook/main.ts +33 -0
- package/.storybook/preview.js +56 -0
- package/.storybook/tsconfig.json +17 -0
- package/CHANGELOG.md +574 -0
- package/README.md +8 -0
- package/package.json +1 -1
- package/postcss.config.js +15 -0
- package/project.json +77 -0
- package/src/_stories/icons/code-brackets.svg +1 -0
- package/src/_stories/icons/colors.svg +1 -0
- package/src/_stories/icons/comments.svg +1 -0
- package/src/_stories/icons/direction.svg +1 -0
- package/src/_stories/icons/flow.svg +1 -0
- package/src/_stories/icons/plugin.svg +1 -0
- package/src/_stories/icons/repo.svg +1 -0
- package/src/_stories/icons/stackalt.svg +1 -0
- package/src/components/Accordion/accordion.stories.mdx +240 -0
- package/src/components/Accordion/components/AccordionItem.tsx +53 -0
- package/src/components/Accordion/components/AriaAccordionItem.tsx +76 -0
- package/src/components/Accordion/hooks/useAccordionState.ts +46 -0
- package/src/components/Accordion/index.tsx +38 -0
- package/{components/Accordion/interface.d.ts → src/components/Accordion/interface.ts} +23 -17
- package/src/components/Alerts/alerts.stories.mdx +282 -0
- package/src/components/Alerts/components/AlertsCloseButton.tsx +20 -0
- package/src/components/Alerts/components/AlertsItem.tsx +39 -0
- package/src/components/Alerts/components/AlertsNavigationButton.tsx +71 -0
- package/src/components/Alerts/components/AlertsSwiper.tsx +125 -0
- package/src/components/Alerts/components/pagination/AlertsPagination.tsx +32 -0
- package/src/components/Alerts/components/pagination/AlertsPaginationBullet.tsx +61 -0
- package/src/components/Alerts/index.tsx +54 -0
- package/src/components/Alerts/interface.ts +51 -0
- package/src/components/Box/box.stories.mdx +27 -0
- package/src/components/Box/index.tsx +36 -0
- package/src/components/Box/interface.ts +10 -0
- package/src/components/Button/button.stories.mdx +99 -0
- package/src/components/Button/index.tsx +92 -0
- package/src/components/Button/interface.ts +22 -0
- package/src/components/Calendar/RangeCalendar.tsx +61 -0
- package/src/components/Calendar/calendar.stories.mdx +28 -0
- package/src/components/Calendar/components/CalendarCell.tsx +60 -0
- package/src/components/Calendar/components/CalendarGrid.tsx +44 -0
- package/src/components/Calendar/index.tsx +63 -0
- package/src/components/Calendar/interface.ts +37 -0
- package/src/components/Carousel/carousel.stories.mdx +182 -0
- package/src/components/Carousel/index.tsx +99 -0
- package/src/components/Carousel/interface.ts +26 -0
- package/src/components/Date/date.stories.mdx +122 -0
- package/src/components/Date/index.tsx +35 -0
- package/src/components/Date/interface.ts +7 -0
- package/src/components/Dialog/index.tsx +14 -0
- package/src/components/Dialog/interface.ts +6 -0
- package/src/components/DirectusImg/index.tsx +59 -0
- package/src/components/DirectusImg/interface.ts +19 -0
- package/src/components/Icon/index.tsx +40 -0
- package/src/components/Icon/interface.ts +8 -0
- package/src/components/Img/img.stories.mdx +28 -0
- package/src/components/Img/index.tsx +30 -0
- package/src/components/Img/interface.ts +9 -0
- package/src/components/Lightbox/hooks/overlay/index.tsx +36 -0
- package/src/components/Lightbox/index.tsx +82 -0
- package/src/components/Lightbox/interface.ts +28 -0
- package/src/components/Lightbox/lightbox.stories.mdx +79 -0
- package/src/components/Menu/Menu.tsx +43 -0
- package/src/components/Menu/MenuSidePanel.tsx +41 -0
- package/src/components/Menu/components/InnerContent.tsx +26 -0
- package/src/components/Menu/components/MenuItems.tsx +133 -0
- package/src/components/Menu/components/TabContainer.tsx +13 -0
- package/src/components/Menu/interface.ts +41 -0
- package/src/components/Menu/menu.stories.mdx +23 -0
- package/src/components/Modal/components/ModalDialog.tsx +31 -0
- package/src/components/Modal/components/ModalOverlay.tsx +21 -0
- package/src/components/Modal/index.tsx +32 -0
- package/{components/Modal/interface.d.ts → src/components/Modal/interface.ts} +14 -11
- package/src/components/Popover/index.tsx +138 -0
- package/src/components/Popover/interface.ts +25 -0
- package/src/components/Popover/popover.stories.mdx +66 -0
- package/src/components/ShareButton/index.tsx +172 -0
- package/src/components/ShareButton/interface.ts +29 -0
- package/src/components/ShareButton/share-button.stories.mdx +48 -0
- package/src/components/ShareButton/utils/generateUtmTags.ts +4 -0
- package/src/components/ShareButton/utils/useFacebookShareUrl.ts +15 -0
- package/src/components/ShareButton/utils/useMailToShareUrl.ts +15 -0
- package/src/components/ShareButton/utils/useTwitterShareUrl.ts +15 -0
- package/src/components/ShareButton/utils/useWindow.ts +17 -0
- package/src/components/SidePanel/index.tsx +43 -0
- package/src/components/SidePanel/interface.ts +16 -0
- package/src/components/SidePanel/side-panel.stories.mdx +44 -0
- package/src/components/TabList/components/Tab/Tab.tsx +19 -0
- package/src/components/TabList/components/TabPanel/TabPanel.tsx +27 -0
- package/src/components/TabList/index.tsx +44 -0
- package/src/components/TabList/interface.ts +23 -0
- package/src/components/Typography/index.tsx +35 -0
- package/src/components/Typography/interface.ts +9 -0
- package/src/components/Typography/typo.stories.mdx +157 -0
- package/src/components/WysiwygBlock/index.tsx +20 -0
- package/src/components/WysiwygBlock/interface.ts +7 -0
- package/src/components/WysiwygBlock/wysiwyg.stories.mdx +53 -0
- package/src/components/fields/Checkbox/Checkbox.interface.ts +21 -0
- package/src/components/fields/Checkbox/Checkbox.stories.mdx +127 -0
- package/src/components/fields/Checkbox/index.tsx +62 -0
- package/src/components/fields/CheckboxGroup/checkbox-group.stories.mdx +59 -0
- package/src/components/fields/CheckboxGroup/components/CheckboxGroupItem/index.tsx +66 -0
- package/src/components/fields/CheckboxGroup/index.tsx +49 -0
- package/src/components/fields/CheckboxGroup/interface.ts +17 -0
- package/src/components/fields/DatePicker/DateRangePicker.tsx +73 -0
- package/src/components/fields/DatePicker/components/CalendarPopover.tsx +31 -0
- package/src/components/fields/DatePicker/components/DateField.tsx +61 -0
- package/src/components/fields/DatePicker/date-picker.stories.mdx +55 -0
- package/src/components/fields/DatePicker/index.tsx +71 -0
- package/src/components/fields/DatePicker/interface.ts +69 -0
- package/src/components/fields/Radio/Radio.interface.ts +30 -0
- package/src/components/fields/Radio/index.tsx +63 -0
- package/src/components/fields/RadioGroup/index.tsx +33 -0
- package/src/components/fields/RadioGroup/interface.ts +10 -0
- package/src/components/fields/RadioGroup/radio-group.stories.mdx +56 -0
- package/src/components/fields/SearchField/index.tsx +59 -0
- package/src/components/fields/SearchField/interface.ts +10 -0
- package/src/components/fields/SearchField/search.stories.mdx +91 -0
- package/src/components/fields/Select/Select.interface.ts +24 -0
- package/src/components/fields/Select/Select.stories.mdx +53 -0
- package/src/components/fields/Select/Select.tsx +108 -0
- package/{components/fields/Select/components/Listbox.interface.d.ts → src/components/fields/Select/components/Listbox.interface.ts} +11 -8
- package/src/components/fields/Select/components/Listbox.tsx +40 -0
- package/src/components/fields/Select/components/Popover.interface.ts +14 -0
- package/src/components/fields/Select/components/Popover.tsx +32 -0
- package/{components/fields/SelectItem/SelectItem.interface.d.ts → src/components/fields/SelectItem/SelectItem.interface.ts} +4 -3
- package/src/components/fields/SelectItem/SelectItem.tsx +10 -0
- package/src/components/fields/TextArea/index.tsx +105 -0
- package/src/components/fields/TextArea/textArea.stories.mdx +60 -0
- package/src/components/fields/TextInputField/index.tsx +107 -0
- package/src/components/fields/TextInputField/interface.ts +30 -0
- package/src/components/fields/TextInputField/text-input-field.stories.mdx +64 -0
- package/src/components/icons/ArrowDown.tsx +11 -0
- package/src/components/icons/ArrowLeft.tsx +18 -0
- package/src/components/icons/ArrowRight.tsx +18 -0
- package/src/components/icons/Check.tsx +11 -0
- package/src/components/icons/ChevronLeft.tsx +11 -0
- package/src/components/icons/ChevronRight.tsx +11 -0
- package/src/components/icons/CloseBtn.tsx +11 -0
- package/src/components/icons/Facebook.tsx +14 -0
- package/src/components/icons/FacebookColored.tsx +16 -0
- package/src/components/icons/FacebookRounded.tsx +16 -0
- package/src/components/icons/Globe.tsx +38 -0
- package/src/components/icons/IconFallback.tsx +8 -0
- package/src/components/icons/Instagram.tsx +14 -0
- package/src/components/icons/InstagramColored.tsx +59 -0
- package/src/components/icons/Link.tsx +14 -0
- package/src/components/icons/LinkedIn.tsx +16 -0
- package/src/components/icons/Mail.tsx +16 -0
- package/src/components/icons/Plus.tsx +18 -0
- package/src/components/icons/Search.tsx +19 -0
- package/src/components/icons/Share.tsx +16 -0
- package/src/components/icons/Twitter.tsx +16 -0
- package/src/components/icons/TwitterColored.tsx +16 -0
- package/src/components/icons/Upload.tsx +14 -0
- package/src/components/icons/X.tsx +14 -0
- package/src/components/icons/YouTube.tsx +16 -0
- package/src/components/icons/YouTubeColored.tsx +17 -0
- package/src/components/icons/index.ts +24 -0
- package/src/examples/PageLayout/index.tsx +61 -0
- package/src/examples/PageLayout/layout.stories.mdx +35 -0
- package/{index.d.ts → src/index.ts} +72 -57
- package/src/message.tsx +8 -0
- package/src/providers/Accordion/index.tsx +15 -0
- package/src/providers/Accordion/interface.ts +14 -0
- package/src/providers/Alerts/index.tsx +15 -0
- package/src/providers/Alerts/interface.ts +11 -0
- package/src/providers/CheckboxGroup/index.tsx +22 -0
- package/{providers/CheckboxGroup/interface.d.ts → src/providers/CheckboxGroup/interface.ts} +5 -4
- package/src/providers/Client/index.tsx +21 -0
- package/src/providers/Client/interface.ts +13 -0
- package/src/providers/Menu/index.tsx +43 -0
- package/src/providers/Menu/interface.ts +32 -0
- package/src/providers/RadioGroup/RadioGroup.interface.ts +8 -0
- package/src/providers/RadioGroup/RadioGroup.tsx +25 -0
- package/src/providers/SidePanel/index.tsx +55 -0
- package/src/providers/SidePanel/interface.ts +26 -0
- package/src/providers/Theme/hooks.ts +25 -0
- package/src/providers/Theme/index.tsx +40 -0
- package/src/providers/Theme/interface.ts +28 -0
- package/src/providers/Theme/utils.ts +3 -0
- package/src/providers/UserSearchQuery/index.tsx +20 -0
- package/src/providers/UserSearchQuery/interface.ts +12 -0
- package/src/storybook/Lightbox/LightboxControlledState.tsx +28 -0
- package/src/storybook/Menu/Menu.tsx +177 -0
- package/src/storybook/Menu/NestedMenu.tsx +24 -0
- package/src/storybook/Menu/mock.tsx +84 -0
- package/src/storybook/SelectField/index.tsx +57 -0
- package/src/storybook/ShareButtonExample/index.tsx +66 -0
- package/src/tailwind.css +3 -0
- package/src/theme/Accordion/index.tsx +101 -0
- package/src/theme/Alerts/index.ts +97 -0
- package/src/theme/Box/index.ts +45 -0
- package/src/theme/Button/index.tsx +72 -0
- package/src/theme/Calendar/index.tsx +167 -0
- package/src/theme/Carousel/index.ts +36 -0
- package/src/theme/Checkbox/index.ts +49 -0
- package/src/theme/CheckboxGroup/index.ts +14 -0
- package/src/theme/DatePicker/index.tsx +42 -0
- package/src/theme/Image/index.ts +8 -0
- package/src/theme/LightBox/index.ts +56 -0
- package/src/theme/Radio/index.ts +31 -0
- package/src/theme/RadioGroup/index.ts +14 -0
- package/src/theme/Search/index.ts +20 -0
- package/src/theme/ShareButton/index.tsx +76 -0
- package/src/theme/SidePanel/index.ts +9 -0
- package/src/theme/TextArea/index.ts +25 -0
- package/src/theme/Typography/index.tsx +44 -0
- package/src/theme/index.tsx +178 -0
- package/src/transitions/AccordionTransition.tsx +26 -0
- package/src/transitions/ModalTransition.tsx +38 -0
- package/src/transitions/RenderWithOpacity.tsx +25 -0
- package/src/transitions/RenderWithSlide.tsx +21 -0
- package/src/transitions/SidePanelTransition.tsx +30 -0
- package/src/types/components.ts +34 -0
- package/static/images/image.png +0 -0
- package/tailwind.config.js +14 -0
- package/tsconfig.json +20 -0
- package/tsconfig.lib.json +25 -0
- package/vite.config.ts +58 -0
- package/components/Accordion/components/AccordionItem.d.ts +0 -3
- package/components/Accordion/components/AriaAccordionItem.d.ts +0 -3
- package/components/Accordion/hooks/useAccordionState.d.ts +0 -10
- package/components/Accordion/index.d.ts +0 -3
- package/components/Alerts/components/AlertsCloseButton.d.ts +0 -4
- package/components/Alerts/components/AlertsItem.d.ts +0 -3
- package/components/Alerts/components/AlertsNavigationButton.d.ts +0 -8
- package/components/Alerts/components/AlertsSwiper.d.ts +0 -3
- package/components/Alerts/components/pagination/AlertsPagination.d.ts +0 -3
- package/components/Alerts/components/pagination/AlertsPaginationBullet.d.ts +0 -3
- package/components/Alerts/index.d.ts +0 -3
- package/components/Alerts/interface.d.ts +0 -41
- package/components/Box/index.d.ts +0 -5
- package/components/Box/interface.d.ts +0 -10
- package/components/Button/index.d.ts +0 -6
- package/components/Button/interface.d.ts +0 -20
- package/components/Calendar/RangeCalendar.d.ts +0 -3
- package/components/Calendar/components/CalendarCell.d.ts +0 -3
- package/components/Calendar/components/CalendarGrid.d.ts +0 -3
- package/components/Calendar/index.d.ts +0 -3
- package/components/Calendar/interface.d.ts +0 -32
- package/components/Carousel/index.d.ts +0 -3
- package/components/Carousel/interface.d.ts +0 -24
- package/components/Date/index.d.ts +0 -3
- package/components/Date/interface.d.ts +0 -6
- package/components/Dialog/index.d.ts +0 -2
- package/components/Dialog/interface.d.ts +0 -6
- package/components/DirectusImg/index.d.ts +0 -3
- package/components/DirectusImg/interface.d.ts +0 -13
- package/components/Icon/index.d.ts +0 -3
- package/components/Icon/interface.d.ts +0 -7
- package/components/Img/index.d.ts +0 -3
- package/components/Img/interface.d.ts +0 -6
- package/components/Lightbox/index.d.ts +0 -3
- package/components/Lightbox/interface.d.ts +0 -25
- package/components/Menu/Menu.d.ts +0 -3
- package/components/Menu/MenuSidePanel.d.ts +0 -3
- package/components/Menu/components/InnerContent.d.ts +0 -3
- package/components/Menu/components/MenuItems.d.ts +0 -3
- package/components/Menu/components/TabContainer.d.ts +0 -3
- package/components/Menu/interface.d.ts +0 -31
- package/components/Modal/components/ModalDialog.d.ts +0 -3
- package/components/Modal/components/ModalOverlay.d.ts +0 -3
- package/components/Modal/index.d.ts +0 -3
- package/components/Popover/index.d.ts +0 -3
- package/components/Popover/interface.d.ts +0 -21
- package/components/ShareButton/index.d.ts +0 -4
- package/components/ShareButton/interface.d.ts +0 -26
- package/components/ShareButton/utils/generateUtmTags.d.ts +0 -2
- package/components/ShareButton/utils/useFacebookShareUrl.d.ts +0 -2
- package/components/ShareButton/utils/useMailToShareUrl.d.ts +0 -2
- package/components/ShareButton/utils/useTwitterShareUrl.d.ts +0 -2
- package/components/ShareButton/utils/useWindow.d.ts +0 -5
- package/components/SidePanel/index.d.ts +0 -4
- package/components/SidePanel/interface.d.ts +0 -12
- package/components/TabList/components/TabPanel/TabPanel.d.ts +0 -4
- package/components/TabList/interface.d.ts +0 -18
- package/components/Typography/index.d.ts +0 -5
- package/components/Typography/interface.d.ts +0 -9
- package/components/WysiwygBlock/index.d.ts +0 -3
- package/components/WysiwygBlock/interface.d.ts +0 -5
- package/components/fields/Checkbox/Checkbox.interface.d.ts +0 -18
- package/components/fields/Checkbox/index.d.ts +0 -3
- package/components/fields/CheckboxGroup/components/CheckboxGroupItem/index.d.ts +0 -3
- package/components/fields/CheckboxGroup/index.d.ts +0 -3
- package/components/fields/CheckboxGroup/interface.d.ts +0 -13
- package/components/fields/DatePicker/DateRangePicker.d.ts +0 -3
- package/components/fields/DatePicker/components/CalendarPopover.d.ts +0 -2
- package/components/fields/DatePicker/components/DateField.d.ts +0 -4
- package/components/fields/DatePicker/index.d.ts +0 -3
- package/components/fields/DatePicker/interface.d.ts +0 -37
- package/components/fields/Radio/Radio.interface.d.ts +0 -26
- package/components/fields/Radio/index.d.ts +0 -4
- package/components/fields/RadioGroup/index.d.ts +0 -3
- package/components/fields/RadioGroup/interface.d.ts +0 -9
- package/components/fields/SearchField/index.d.ts +0 -3
- package/components/fields/SearchField/interface.d.ts +0 -9
- package/components/fields/Select/Select.d.ts +0 -4
- package/components/fields/Select/Select.interface.d.ts +0 -26
- package/components/fields/Select/components/Listbox.d.ts +0 -4
- package/components/fields/Select/components/Popover.d.ts +0 -3
- package/components/fields/Select/components/Popover.interface.d.ts +0 -13
- package/components/fields/SelectItem/SelectItem.d.ts +0 -3
- package/components/fields/TextArea/index.d.ts +0 -4
- package/components/fields/TextInputField/index.d.ts +0 -4
- package/components/fields/TextInputField/interface.d.ts +0 -24
- package/components/icons/ArrowDown.d.ts +0 -3
- package/components/icons/ArrowLeft.d.ts +0 -3
- package/components/icons/ArrowRight.d.ts +0 -3
- package/components/icons/Check.d.ts +0 -3
- package/components/icons/ChevronLeft.d.ts +0 -3
- package/components/icons/ChevronRight.d.ts +0 -3
- package/components/icons/CloseBtn.d.ts +0 -3
- package/components/icons/Facebook.d.ts +0 -3
- package/components/icons/FacebookColored.d.ts +0 -3
- package/components/icons/FacebookRounded.d.ts +0 -3
- package/components/icons/Globe.d.ts +0 -3
- package/components/icons/IconFallback.d.ts +0 -3
- package/components/icons/Instagram.d.ts +0 -3
- package/components/icons/InstagramColored.d.ts +0 -3
- package/components/icons/Link.d.ts +0 -3
- package/components/icons/LinkedIn.d.ts +0 -3
- package/components/icons/Mail.d.ts +0 -3
- package/components/icons/Plus.d.ts +0 -3
- package/components/icons/Search.d.ts +0 -3
- package/components/icons/Share.d.ts +0 -3
- package/components/icons/Twitter.d.ts +0 -3
- package/components/icons/TwitterColored.d.ts +0 -3
- package/components/icons/Upload.d.ts +0 -3
- package/components/icons/X.d.ts +0 -3
- package/components/icons/YouTube.d.ts +0 -3
- package/components/icons/YouTubeColored.d.ts +0 -3
- package/components/icons/index.d.ts +0 -24
- package/index.js +0 -110
- package/index.mjs +0 -12897
- package/providers/Accordion/index.d.ts +0 -4
- package/providers/Accordion/interface.d.ts +0 -12
- package/providers/Alerts/index.d.ts +0 -4
- package/providers/Alerts/interface.d.ts +0 -9
- package/providers/CheckboxGroup/index.d.ts +0 -5
- package/providers/Client/index.d.ts +0 -4
- package/providers/Client/interface.d.ts +0 -10
- package/providers/Menu/index.d.ts +0 -4
- package/providers/Menu/interface.d.ts +0 -28
- package/providers/RadioGroup/RadioGroup.d.ts +0 -5
- package/providers/RadioGroup/RadioGroup.interface.d.ts +0 -7
- package/providers/SidePanel/index.d.ts +0 -4
- package/providers/SidePanel/interface.d.ts +0 -23
- package/providers/Theme/hooks.d.ts +0 -3
- package/providers/Theme/index.d.ts +0 -10
- package/providers/Theme/interface.d.ts +0 -24
- package/providers/Theme/utils.d.ts +0 -2
- package/providers/UserSearchQuery/index.d.ts +0 -4
- package/providers/UserSearchQuery/interface.d.ts +0 -10
- package/style.css +0 -1
- package/theme/Accordion/index.d.ts +0 -274
- package/theme/Alerts/index.d.ts +0 -1167
- package/theme/Box/index.d.ts +0 -214
- package/theme/Button/index.d.ts +0 -121
- package/theme/Calendar/index.d.ts +0 -366
- package/theme/Carousel/index.d.ts +0 -9
- package/theme/Checkbox/index.d.ts +0 -159
- package/theme/CheckboxGroup/index.d.ts +0 -30
- package/theme/DatePicker/index.d.ts +0 -43
- package/theme/Image/index.d.ts +0 -3
- package/theme/LightBox/index.d.ts +0 -455
- package/theme/Radio/index.d.ts +0 -108
- package/theme/RadioGroup/index.d.ts +0 -30
- package/theme/Search/index.d.ts +0 -30
- package/theme/ShareButton/index.d.ts +0 -174
- package/theme/SidePanel/index.d.ts +0 -3
- package/theme/TextArea/index.d.ts +0 -29
- package/theme/Typography/index.d.ts +0 -233
- package/theme/index.d.ts +0 -5
- package/transitions/AccordionTransition.d.ts +0 -3
- package/transitions/ModalTransition.d.ts +0 -7
- package/transitions/RenderWithOpacity.d.ts +0 -3
- package/transitions/RenderWithSlide.d.ts +0 -7
- package/transitions/SidePanelTransition.d.ts +0 -7
- package/types/components.d.ts +0 -28
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useTabPanel } from '@react-aria/tabs'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import RenderWithOpacity from '../../../../transitions/RenderWithOpacity'
|
|
4
|
+
import type { TDefaultComponent } from '../../../../types/components'
|
|
5
|
+
import { BoxWithForwardRef } from '../../../Box'
|
|
6
|
+
import type { TTabPanel } from '../../interface'
|
|
7
|
+
|
|
8
|
+
function TabPanel({ state, customTheme, themeName = 'tabPanel', tokens, ...props }: TTabPanel & TDefaultComponent) {
|
|
9
|
+
const ref = React.useRef(null)
|
|
10
|
+
const { tabPanelProps } = useTabPanel(props, state, ref)
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<RenderWithOpacity isVisible>
|
|
14
|
+
<BoxWithForwardRef
|
|
15
|
+
themeName={`${themeName}`}
|
|
16
|
+
tokens={tokens}
|
|
17
|
+
customTheme={customTheme}
|
|
18
|
+
{...tabPanelProps}
|
|
19
|
+
ref={ref}
|
|
20
|
+
>
|
|
21
|
+
{state.selectedItem?.props.children}
|
|
22
|
+
</BoxWithForwardRef>
|
|
23
|
+
</RenderWithOpacity>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default TabPanel
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useTabList } from '@react-aria/tabs'
|
|
2
|
+
import { useTabListState } from '@react-stately/tabs'
|
|
3
|
+
import { isEmpty } from 'lodash'
|
|
4
|
+
import { useRef } from 'react'
|
|
5
|
+
import Box, { BoxWithForwardRef } from '../Box'
|
|
6
|
+
import Heading from '../Typography'
|
|
7
|
+
import Tab from './components/Tab/Tab'
|
|
8
|
+
import TabPanel from './components/TabPanel/TabPanel'
|
|
9
|
+
import type { TTabList } from './interface'
|
|
10
|
+
|
|
11
|
+
function TabList(props: TTabList) {
|
|
12
|
+
const { label, id } = props
|
|
13
|
+
|
|
14
|
+
const state = useTabListState({
|
|
15
|
+
...props,
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const ref = useRef(null)
|
|
19
|
+
const { tabListProps } = useTabList(props, state, ref)
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Box>
|
|
23
|
+
<Box>
|
|
24
|
+
{!isEmpty(label) && (
|
|
25
|
+
<Box>
|
|
26
|
+
<Box>
|
|
27
|
+
<Heading as="p">{label}</Heading>
|
|
28
|
+
</Box>
|
|
29
|
+
</Box>
|
|
30
|
+
)}
|
|
31
|
+
<BoxWithForwardRef {...tabListProps} ref={ref}>
|
|
32
|
+
{[...state.collection].map((item) => (
|
|
33
|
+
<Box key={`tablist-${id}-${item.key}`}>
|
|
34
|
+
<Tab key={item.key} item={item} state={state} />
|
|
35
|
+
</Box>
|
|
36
|
+
))}
|
|
37
|
+
</BoxWithForwardRef>
|
|
38
|
+
</Box>
|
|
39
|
+
<TabPanel key={state.selectedItem?.key} state={state} />
|
|
40
|
+
</Box>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default TabList
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* eslint-disable import/no-unresolved */
|
|
2
|
+
import type { TabListState } from '@react-stately/tabs'
|
|
3
|
+
import type { Node } from '@react-types/shared'
|
|
4
|
+
import type { AriaTabListProps, AriaTabPanelProps } from '@react-types/tabs'
|
|
5
|
+
import type React from 'react'
|
|
6
|
+
|
|
7
|
+
export interface TTab {
|
|
8
|
+
item: Node<object>
|
|
9
|
+
state: TabListState<object>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface TTabPanel extends AriaTabPanelProps {
|
|
13
|
+
state: TabListState<object>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TTabList extends AriaTabListProps<object> {
|
|
17
|
+
label?: React.ReactNode | string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface TPreviousTabState {
|
|
21
|
+
previousSelectedHash: string
|
|
22
|
+
previousSelectedKey: string
|
|
23
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
/* eslint-disable react/display-name */
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import useThemeContext from '../../providers/Theme/hooks'
|
|
6
|
+
import type { TTypographyProps } from './interface'
|
|
7
|
+
|
|
8
|
+
const Typography = ({
|
|
9
|
+
as: Component = 'span',
|
|
10
|
+
themeName = 'typography',
|
|
11
|
+
tokens,
|
|
12
|
+
customTheme,
|
|
13
|
+
children,
|
|
14
|
+
...rest
|
|
15
|
+
}: TTypographyProps) => {
|
|
16
|
+
const theme = useThemeContext(themeName, tokens, customTheme)
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Component {...rest} className={theme}>
|
|
20
|
+
{children}
|
|
21
|
+
</Component>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const TypographyWithForwardRef = React.forwardRef((props: TTypographyProps, ref: React.Ref<HTMLElement>) => {
|
|
26
|
+
const { as: Component = 'span', tokens, themeName = 'typography', customTheme, children, ...rest } = props
|
|
27
|
+
const theme = useThemeContext(themeName, tokens, customTheme)
|
|
28
|
+
return (
|
|
29
|
+
<Component {...rest} ref={ref} className={theme}>
|
|
30
|
+
{children}
|
|
31
|
+
</Component>
|
|
32
|
+
)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
export default Typography
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import type React from 'react'
|
|
3
|
+
import type { TToken } from '../../providers/Theme/interface'
|
|
4
|
+
import type { TDefaultComponent } from '../../types/components'
|
|
5
|
+
|
|
6
|
+
export interface TTypographyProps<T = TToken> extends TDefaultComponent<T> {
|
|
7
|
+
children?: React.ReactNode
|
|
8
|
+
dangerouslySetInnerHTML?: { __html: string | TrustedHTML }
|
|
9
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
{/* typo.stories.mdx */}
|
|
2
|
+
|
|
3
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
4
|
+
import Typography from './index'
|
|
5
|
+
|
|
6
|
+
<Meta title="BASE COMPONENTS/Typography" component={Typography} />
|
|
7
|
+
|
|
8
|
+
export const Template = (args) => (
|
|
9
|
+
<div>
|
|
10
|
+
<Typography {...args}>Hello world!</Typography>
|
|
11
|
+
</div>
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
# Typography
|
|
15
|
+
|
|
16
|
+
Typography component. You can pass `size tokens` to change the style, from 'h1' to 'h6', 'leading', 'paragraph' and 'footnote' and 'xs'.
|
|
17
|
+
You can use property `as` to render the typography with a different component, e.g. `h1` to `h6` or even `div` and `header`.
|
|
18
|
+
|
|
19
|
+
<Canvas>
|
|
20
|
+
<Story
|
|
21
|
+
name="Heading 1"
|
|
22
|
+
args={{
|
|
23
|
+
as: 'h1',
|
|
24
|
+
tokens: {
|
|
25
|
+
size: 'h1',
|
|
26
|
+
},
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
{Template.bind({})}
|
|
30
|
+
</Story>
|
|
31
|
+
</Canvas>
|
|
32
|
+
|
|
33
|
+
<Canvas>
|
|
34
|
+
<Story
|
|
35
|
+
name="Heading 2"
|
|
36
|
+
args={{
|
|
37
|
+
as: 'h2',
|
|
38
|
+
tokens: {
|
|
39
|
+
size: 'h2',
|
|
40
|
+
},
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
{Template.bind({})}
|
|
44
|
+
</Story>
|
|
45
|
+
</Canvas>
|
|
46
|
+
|
|
47
|
+
<Canvas>
|
|
48
|
+
<Story
|
|
49
|
+
name="Heading 3"
|
|
50
|
+
args={{
|
|
51
|
+
as: 'h3',
|
|
52
|
+
tokens: {
|
|
53
|
+
size: 'h3',
|
|
54
|
+
},
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
{Template.bind({})}
|
|
58
|
+
</Story>
|
|
59
|
+
</Canvas>
|
|
60
|
+
|
|
61
|
+
<Canvas>
|
|
62
|
+
<Story
|
|
63
|
+
name="Heading 4"
|
|
64
|
+
args={{
|
|
65
|
+
as: 'h4',
|
|
66
|
+
tokens: {
|
|
67
|
+
size: 'h4',
|
|
68
|
+
},
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{Template.bind({})}
|
|
72
|
+
</Story>
|
|
73
|
+
</Canvas>
|
|
74
|
+
|
|
75
|
+
<Canvas>
|
|
76
|
+
<Story
|
|
77
|
+
name="Heading 5"
|
|
78
|
+
args={{
|
|
79
|
+
as: 'h5',
|
|
80
|
+
tokens: {
|
|
81
|
+
size: 'h5',
|
|
82
|
+
},
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
{Template.bind({})}
|
|
86
|
+
</Story>
|
|
87
|
+
</Canvas>
|
|
88
|
+
|
|
89
|
+
<Canvas>
|
|
90
|
+
<Story
|
|
91
|
+
name="Heading 6"
|
|
92
|
+
args={{
|
|
93
|
+
as: 'h6',
|
|
94
|
+
tokens: {
|
|
95
|
+
size: 'h6',
|
|
96
|
+
},
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
{Template.bind({})}
|
|
100
|
+
</Story>
|
|
101
|
+
</Canvas>
|
|
102
|
+
|
|
103
|
+
<Canvas>
|
|
104
|
+
<Story
|
|
105
|
+
name="Default"
|
|
106
|
+
args={{
|
|
107
|
+
as: 'p',
|
|
108
|
+
tokens: {
|
|
109
|
+
size: 'paragraph',
|
|
110
|
+
},
|
|
111
|
+
}}
|
|
112
|
+
>
|
|
113
|
+
{Template.bind({})}
|
|
114
|
+
</Story>
|
|
115
|
+
</Canvas>
|
|
116
|
+
|
|
117
|
+
<Canvas>
|
|
118
|
+
<Story
|
|
119
|
+
name="Leading"
|
|
120
|
+
args={{
|
|
121
|
+
as: 'strong',
|
|
122
|
+
tokens: {
|
|
123
|
+
size: 'leading',
|
|
124
|
+
},
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
{Template.bind({})}
|
|
128
|
+
</Story>
|
|
129
|
+
</Canvas>
|
|
130
|
+
|
|
131
|
+
<Canvas>
|
|
132
|
+
<Story
|
|
133
|
+
name="Footnotes"
|
|
134
|
+
args={{
|
|
135
|
+
as: 'p',
|
|
136
|
+
tokens: {
|
|
137
|
+
size: 'footnote',
|
|
138
|
+
},
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
{Template.bind({})}
|
|
142
|
+
</Story>
|
|
143
|
+
</Canvas>
|
|
144
|
+
|
|
145
|
+
<Canvas>
|
|
146
|
+
<Story
|
|
147
|
+
name="XSmall"
|
|
148
|
+
args={{
|
|
149
|
+
as: 'p',
|
|
150
|
+
tokens: {
|
|
151
|
+
size: 'xs',
|
|
152
|
+
},
|
|
153
|
+
}}
|
|
154
|
+
>
|
|
155
|
+
{Template.bind({})}
|
|
156
|
+
</Story>
|
|
157
|
+
</Canvas>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import DOMPurify from 'isomorphic-dompurify'
|
|
2
|
+
import Typography from '../Typography'
|
|
3
|
+
import type TWysiwygBlockProps from './interface'
|
|
4
|
+
|
|
5
|
+
const WysiwygBlock = ({ content, themeName = 'wysiwyg', ...rest }: TWysiwygBlockProps) => {
|
|
6
|
+
return (
|
|
7
|
+
<Typography
|
|
8
|
+
{...rest}
|
|
9
|
+
themeName={themeName}
|
|
10
|
+
dangerouslySetInnerHTML={{
|
|
11
|
+
__html: DOMPurify.sanitize(content, {
|
|
12
|
+
ADD_TAGS: ['iframe'],
|
|
13
|
+
ADD_ATTR: ['allow', 'allowfullscreen', 'frameborder', 'scrolling', 'target'],
|
|
14
|
+
}),
|
|
15
|
+
}}
|
|
16
|
+
/>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default WysiwygBlock
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
2
|
+
import { ArgTypes } from '@storybook/blocks'
|
|
3
|
+
import WysiwygBlock from './'
|
|
4
|
+
|
|
5
|
+
<Meta
|
|
6
|
+
title="BASE COMPONENTS/Wysiwyg Block"
|
|
7
|
+
component={WysiwygBlock}
|
|
8
|
+
argTypes={{
|
|
9
|
+
content: {
|
|
10
|
+
description: 'Takes HTML elements in string form from the Wysiwyg block content',
|
|
11
|
+
},
|
|
12
|
+
WysiwygBlockAttributes: {
|
|
13
|
+
description: 'target, allow, allowfullscreen, frameborder, scrolling, iframe',
|
|
14
|
+
}
|
|
15
|
+
}}
|
|
16
|
+
args={{
|
|
17
|
+
content: '<a target="_self" href="https://www.google.com/">Link with target _self</a>',
|
|
18
|
+
}}
|
|
19
|
+
/>
|
|
20
|
+
|
|
21
|
+
export const Template = (args) => {
|
|
22
|
+
return <WysiwygBlock {...args} />
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
# Wysiwyg Block
|
|
26
|
+
|
|
27
|
+
#### Wysiwyg Block. Can be used in CMS to insert HTML elements as text with certain attributes (h1, h2, h3, link with target, etc.)
|
|
28
|
+
|
|
29
|
+
## Props
|
|
30
|
+
|
|
31
|
+
<ArgTypes />
|
|
32
|
+
|
|
33
|
+
## Showcase
|
|
34
|
+
|
|
35
|
+
### Wysiwyg Block link with target \_self
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
<Canvas>
|
|
39
|
+
<Story name="Link with target _self">{Template.bind({})}</Story>
|
|
40
|
+
</Canvas>
|
|
41
|
+
|
|
42
|
+
### Wysiwyg Block link with target \_blank
|
|
43
|
+
|
|
44
|
+
<Canvas>
|
|
45
|
+
<Story
|
|
46
|
+
name="Link with target blank"
|
|
47
|
+
args={{
|
|
48
|
+
content: '<a target="_blank" href="https://www.google.com/">Link with target _blank</a>',
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
{Template.bind({})}
|
|
52
|
+
</Story>
|
|
53
|
+
</Canvas>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type React from 'react'
|
|
2
|
+
import type { AriaCheckboxProps } from 'react-aria'
|
|
3
|
+
import type { TDefaultComponent } from '../../../types/components'
|
|
4
|
+
|
|
5
|
+
export interface TCheckboxProps extends TDefaultComponent, AriaCheckboxProps {
|
|
6
|
+
label: string
|
|
7
|
+
isError?: boolean
|
|
8
|
+
errorMessage?: string
|
|
9
|
+
ariaLabel?: string
|
|
10
|
+
icon?: React.ReactNode
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface TCheckboxLabelStyles {
|
|
14
|
+
isDisabled?: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface TCheckboxStyles {
|
|
18
|
+
isDisabled?: boolean
|
|
19
|
+
isFocused?: boolean
|
|
20
|
+
isError?: boolean
|
|
21
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
{/* Checkbox.stories.mdx */}
|
|
2
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
3
|
+
import Checkbox from './index'
|
|
4
|
+
import Check from '../../icons/Check'
|
|
5
|
+
import Button from '../../Button'
|
|
6
|
+
import { useState } from 'react'
|
|
7
|
+
|
|
8
|
+
<Meta
|
|
9
|
+
title="Form/Fields/Checkbox"
|
|
10
|
+
component={Checkbox}
|
|
11
|
+
args={{
|
|
12
|
+
label: 'This is a checkbox label',
|
|
13
|
+
name: 'checkbox',
|
|
14
|
+
ariaLabel: 'checkbox-label',
|
|
15
|
+
onChange: (isSelected) => console.log(`isSelected: ${isSelected}`),
|
|
16
|
+
}}
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
export const Template = (args) => <Checkbox {...args} />
|
|
20
|
+
|
|
21
|
+
export const TemplateWithButton = (args) => {
|
|
22
|
+
const [checked, setChecked] = useState(args?.defaultSelected ?? false)
|
|
23
|
+
const { onChange, ...restOfArgs } = args
|
|
24
|
+
return (
|
|
25
|
+
<div className={`flex gap-4 items-center`}>
|
|
26
|
+
<Checkbox
|
|
27
|
+
isSelected={checked}
|
|
28
|
+
onChange={(isSelected) => {
|
|
29
|
+
setChecked(!checked)
|
|
30
|
+
onChange(isSelected)
|
|
31
|
+
}}
|
|
32
|
+
{...restOfArgs}
|
|
33
|
+
/>
|
|
34
|
+
<Button handlePress={() => setChecked(!checked)}>Click to check</Button>
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
# Checkbox
|
|
40
|
+
|
|
41
|
+
Checkbox component.
|
|
42
|
+
|
|
43
|
+
## Default
|
|
44
|
+
|
|
45
|
+
<Canvas>
|
|
46
|
+
<Story
|
|
47
|
+
name="Default"
|
|
48
|
+
args={{
|
|
49
|
+
id: 'checkbox-1',
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
{Template.bind({})}
|
|
53
|
+
</Story>
|
|
54
|
+
</Canvas>
|
|
55
|
+
|
|
56
|
+
## Color variant
|
|
57
|
+
|
|
58
|
+
<Canvas>
|
|
59
|
+
<Story
|
|
60
|
+
name="Gray"
|
|
61
|
+
args={{
|
|
62
|
+
id: 'checkbox-8',
|
|
63
|
+
tokens: {
|
|
64
|
+
color: 'gray',
|
|
65
|
+
},
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
{Template.bind({})}
|
|
69
|
+
</Story>
|
|
70
|
+
</Canvas>
|
|
71
|
+
|
|
72
|
+
## With icon
|
|
73
|
+
|
|
74
|
+
<Canvas>
|
|
75
|
+
<Story
|
|
76
|
+
name="With icon"
|
|
77
|
+
args={{
|
|
78
|
+
id: 'checkbox-2',
|
|
79
|
+
icon: <Check />,
|
|
80
|
+
defaultSelected: true,
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
{Template.bind({})}
|
|
84
|
+
</Story>
|
|
85
|
+
</Canvas>
|
|
86
|
+
|
|
87
|
+
## Disabled
|
|
88
|
+
|
|
89
|
+
<Canvas>
|
|
90
|
+
<Story
|
|
91
|
+
name="Disabled"
|
|
92
|
+
args={{
|
|
93
|
+
id: 'checkbox-3',
|
|
94
|
+
isDisabled: true,
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
{Template.bind({})}
|
|
98
|
+
</Story>
|
|
99
|
+
</Canvas>
|
|
100
|
+
|
|
101
|
+
## Error
|
|
102
|
+
|
|
103
|
+
<Canvas>
|
|
104
|
+
<Story
|
|
105
|
+
name="Error"
|
|
106
|
+
args={{
|
|
107
|
+
id: 'checkbox-4',
|
|
108
|
+
isError: true,
|
|
109
|
+
errorMessage: 'This is an error message',
|
|
110
|
+
}}
|
|
111
|
+
>
|
|
112
|
+
{Template.bind({})}
|
|
113
|
+
</Story>
|
|
114
|
+
</Canvas>
|
|
115
|
+
|
|
116
|
+
## Check from other component
|
|
117
|
+
|
|
118
|
+
<Canvas>
|
|
119
|
+
<Story
|
|
120
|
+
name="Check from other component"
|
|
121
|
+
args={{
|
|
122
|
+
id: 'checkbox-5',
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
{TemplateWithButton.bind({})}
|
|
126
|
+
</Story>
|
|
127
|
+
</Canvas>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useCheckbox } from '@react-aria/checkbox'
|
|
4
|
+
import { FocusRing, useFocusRing } from '@react-aria/focus'
|
|
5
|
+
import { VisuallyHidden } from '@react-aria/visually-hidden'
|
|
6
|
+
import { useToggleState } from '@react-stately/toggle'
|
|
7
|
+
import { useRef } from 'react'
|
|
8
|
+
import useThemeContext from '../../../providers/Theme/hooks'
|
|
9
|
+
import Icon from '../../Icon'
|
|
10
|
+
import Typography from '../../Typography'
|
|
11
|
+
import type { TCheckboxProps } from './Checkbox.interface'
|
|
12
|
+
|
|
13
|
+
const Checkbox = (props: TCheckboxProps) => {
|
|
14
|
+
const {
|
|
15
|
+
id,
|
|
16
|
+
label,
|
|
17
|
+
isDisabled = false,
|
|
18
|
+
isError = false,
|
|
19
|
+
errorMessage,
|
|
20
|
+
ariaLabel,
|
|
21
|
+
icon,
|
|
22
|
+
themeName = 'checkbox',
|
|
23
|
+
tokens,
|
|
24
|
+
customTheme,
|
|
25
|
+
} = props
|
|
26
|
+
const state = useToggleState(props)
|
|
27
|
+
const ref = useRef<HTMLInputElement | null>(null)
|
|
28
|
+
const { inputProps } = useCheckbox(props, state, ref)
|
|
29
|
+
const { isSelected } = state
|
|
30
|
+
const { focusProps, isFocusVisible } = useFocusRing()
|
|
31
|
+
|
|
32
|
+
const checkBoxTokens = { ...tokens, selected: isSelected, isDisabled, isError, isFocusVisible }
|
|
33
|
+
const checkBoxContainerTheme = useThemeContext(`${themeName}.container`, checkBoxTokens, customTheme)
|
|
34
|
+
const checkBoxTheme = useThemeContext(`${themeName}.checkBox`, checkBoxTokens, customTheme)
|
|
35
|
+
const checkMarkTheme = useThemeContext(`${themeName}.checkMark`, checkBoxTokens, customTheme)
|
|
36
|
+
const checkMarkIconTheme = useThemeContext(`${themeName}.checkMarkIcon`, checkBoxTokens, customTheme)
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div>
|
|
40
|
+
<FocusRing focusRingClass="has-focus-ring" within>
|
|
41
|
+
<label className={checkBoxContainerTheme} htmlFor={id} aria-label={ariaLabel} aria-disabled={isDisabled}>
|
|
42
|
+
<VisuallyHidden>
|
|
43
|
+
<input type="checkbox" ref={ref} aria-labelledby={id} {...inputProps} {...focusProps} />
|
|
44
|
+
</VisuallyHidden>
|
|
45
|
+
<div className={checkBoxTheme} aria-checked={isSelected} role="checkbox" aria-labelledby={id}>
|
|
46
|
+
<div className={checkMarkTheme}>{icon && <Icon icon={icon} customTheme={checkMarkIconTheme} />}</div>
|
|
47
|
+
</div>
|
|
48
|
+
<Typography themeName={`${themeName}.label`} tokens={checkBoxTokens}>
|
|
49
|
+
{label}
|
|
50
|
+
</Typography>
|
|
51
|
+
</label>
|
|
52
|
+
</FocusRing>
|
|
53
|
+
{isError && errorMessage && (
|
|
54
|
+
<Typography themeName={`${themeName}.errorMessage`} tokens={checkBoxTokens}>
|
|
55
|
+
{errorMessage}
|
|
56
|
+
</Typography>
|
|
57
|
+
)}
|
|
58
|
+
</div>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default Checkbox
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
2
|
+
import CheckboxGroup from './index'
|
|
3
|
+
import CheckboxGroupItem from './components/CheckboxGroupItem'
|
|
4
|
+
|
|
5
|
+
<Meta title="Form/Fields/CheckboxGroup" component={CheckboxGroup} />
|
|
6
|
+
|
|
7
|
+
export const Template = (args) => {
|
|
8
|
+
return (
|
|
9
|
+
<CheckboxGroup label="Question 1/12" {...args}>
|
|
10
|
+
<CheckboxGroupItem id="item1" label="Item 1" name="item" value="1" ariaLabel="Item 1" />
|
|
11
|
+
<CheckboxGroupItem id="item2" label="Item 2" name="item" value="2" ariaLabel="Item 2" />
|
|
12
|
+
<CheckboxGroupItem id="item3" label="Item 3" name="item" value="3" ariaLabel="Item 3" />
|
|
13
|
+
</CheckboxGroup>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const TemplateError = (args) => {
|
|
18
|
+
return (
|
|
19
|
+
<CheckboxGroup label="Question 2/12" {...args}>
|
|
20
|
+
<CheckboxGroupItem id="item4" label="Item 1" name="item" value="1" ariaLabel="Item 1" />
|
|
21
|
+
<CheckboxGroupItem id="item5" label="Item 2" name="item" value="2" ariaLabel="Item 2" />
|
|
22
|
+
<CheckboxGroupItem id="item6" label="Item 3" name="item" value="3" ariaLabel="Item 3" />
|
|
23
|
+
</CheckboxGroup>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# CheckboxGroup
|
|
28
|
+
|
|
29
|
+
CheckboxGroup component.
|
|
30
|
+
|
|
31
|
+
<Canvas>
|
|
32
|
+
<Story name="Default">{Template.bind({})}</Story>
|
|
33
|
+
</Canvas>
|
|
34
|
+
|
|
35
|
+
<Canvas>
|
|
36
|
+
<Story
|
|
37
|
+
name="Disabled"
|
|
38
|
+
args={{
|
|
39
|
+
isDisabled: true,
|
|
40
|
+
}}
|
|
41
|
+
|
|
42
|
+
>
|
|
43
|
+
|
|
44
|
+
{Template.bind({})}
|
|
45
|
+
|
|
46
|
+
</Story>
|
|
47
|
+
</Canvas>
|
|
48
|
+
|
|
49
|
+
<Canvas>
|
|
50
|
+
<Story
|
|
51
|
+
name="Error"
|
|
52
|
+
args={{
|
|
53
|
+
isError: true,
|
|
54
|
+
errorMessage: 'This is an error message',
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
{TemplateError.bind({})}
|
|
58
|
+
</Story>
|
|
59
|
+
</Canvas>
|