@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,56 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
2
|
+
import RadioGroup from './index'
|
|
3
|
+
import Radio from '../Radio/index'
|
|
4
|
+
|
|
5
|
+
<Meta title="Form/Fields/RadioGroup" component={RadioGroup} />
|
|
6
|
+
|
|
7
|
+
export const Template = (args) => {
|
|
8
|
+
return (
|
|
9
|
+
<RadioGroup label="Question 1/12" {...args}>
|
|
10
|
+
<Radio id="item1" label="Item 1" name="item" value="1" aria-label="Choose item 1" />
|
|
11
|
+
<Radio id="item2" label="Item 2" name="item" value="2" aria-label="Choose item 2" />
|
|
12
|
+
<Radio id="item3" label="Item 3" name="item" value="3" aria-label="Choose item 3" />
|
|
13
|
+
</RadioGroup>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const TemplateError = (args) => {
|
|
18
|
+
return (
|
|
19
|
+
<RadioGroup label="Question 2/12" {...args}>
|
|
20
|
+
<Radio id="item4" label="Item 1" name="item" value="1" aria-label="Choose item 1" />
|
|
21
|
+
<Radio id="item5" label="Item 2" name="item" value="2" aria-label="Choose item 2" />
|
|
22
|
+
<Radio id="item6" label="Item 3" name="item" value="3" aria-label="Choose item 3" />
|
|
23
|
+
</RadioGroup>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# RadioGroup
|
|
28
|
+
|
|
29
|
+
RadioGroup 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
|
+
{Template.bind({})}
|
|
43
|
+
</Story>
|
|
44
|
+
</Canvas>
|
|
45
|
+
|
|
46
|
+
<Canvas>
|
|
47
|
+
<Story
|
|
48
|
+
name="Error"
|
|
49
|
+
args={{
|
|
50
|
+
isError: true,
|
|
51
|
+
errorMessage: 'This is an error message',
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
{TemplateError.bind({})}
|
|
55
|
+
</Story>
|
|
56
|
+
</Canvas>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { FocusRing, useSearchField } from 'react-aria'
|
|
5
|
+
import { useSearchFieldState } from 'react-stately'
|
|
6
|
+
import useThemeContext from '../../../providers/Theme/hooks'
|
|
7
|
+
import { useUserQueryValHook } from '../../../providers/UserSearchQuery'
|
|
8
|
+
import Button from '../../Button'
|
|
9
|
+
import Close from '../../icons/CloseBtn'
|
|
10
|
+
import Search from '../../icons/Search'
|
|
11
|
+
import Typography from '../../Typography'
|
|
12
|
+
import type TSearchProps from './interface'
|
|
13
|
+
|
|
14
|
+
const SearchField = (props: TSearchProps) => {
|
|
15
|
+
const { setUserSearchQuery } = useUserQueryValHook()
|
|
16
|
+
const { label, themeName = 'search', tokens, customTheme, disabled, errorMessage, placeholder } = props
|
|
17
|
+
const state = useSearchFieldState(props)
|
|
18
|
+
setUserSearchQuery(state.value)
|
|
19
|
+
const ref = React.useRef(null)
|
|
20
|
+
const { labelProps, inputProps, errorMessageProps, clearButtonProps } = useSearchField(props, state, ref)
|
|
21
|
+
|
|
22
|
+
const searchTokens = { ...tokens, isError: errorMessage != null }
|
|
23
|
+
|
|
24
|
+
const wrapperTheme = useThemeContext(`${themeName}.wrapper`, searchTokens, customTheme)
|
|
25
|
+
const inputTheme = useThemeContext(`${themeName}.input`, searchTokens, customTheme)
|
|
26
|
+
const labelTheme = useThemeContext(`${themeName}.label`, searchTokens, customTheme)
|
|
27
|
+
const containerTheme = useThemeContext(`${themeName}.container`, searchTokens, customTheme)
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className={wrapperTheme} aria-disabled={disabled}>
|
|
31
|
+
{label && (
|
|
32
|
+
// eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
33
|
+
<label {...labelProps} className={labelTheme}>
|
|
34
|
+
{label}
|
|
35
|
+
</label>
|
|
36
|
+
)}
|
|
37
|
+
<div className={containerTheme}>
|
|
38
|
+
<input ref={ref} {...inputProps} placeholder={placeholder} className={inputTheme} disabled={disabled} />
|
|
39
|
+
<FocusRing focusRingClass="has-focus-ring">
|
|
40
|
+
<Button
|
|
41
|
+
handlePress={clearButtonProps.onPress}
|
|
42
|
+
tokens={{ isIconOnly: true, buttonStyle: 'hollow' }}
|
|
43
|
+
themeName={`${themeName}.icon`}
|
|
44
|
+
aria-label="clear"
|
|
45
|
+
>
|
|
46
|
+
{state.value === '' ? <Search width="16" height="16" /> : <Close width="16" height="16" />}
|
|
47
|
+
</Button>
|
|
48
|
+
</FocusRing>
|
|
49
|
+
</div>
|
|
50
|
+
{errorMessage && (
|
|
51
|
+
<Typography themeName={`${themeName}.errorMessage`} tokens={searchTokens} {...errorMessageProps}>
|
|
52
|
+
{errorMessage}
|
|
53
|
+
</Typography>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default SearchField
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type React from 'react'
|
|
2
|
+
import type { AriaSearchFieldProps } from 'react-aria'
|
|
3
|
+
import type { TDefaultComponent } from '../../../types/components'
|
|
4
|
+
|
|
5
|
+
export default interface TSearchProps extends AriaSearchFieldProps, TDefaultComponent {
|
|
6
|
+
disabled?: boolean
|
|
7
|
+
placeholder?: string
|
|
8
|
+
ariaLabel?: string
|
|
9
|
+
errorMessage?: React.ReactNode
|
|
10
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
2
|
+
import { ArgTypes } from '@storybook/blocks'
|
|
3
|
+
import Search from './'
|
|
4
|
+
import { SearchBarProvider } from '../../../providers/UserSearchQuery'
|
|
5
|
+
|
|
6
|
+
<Meta
|
|
7
|
+
title="Form/Fields/Search"
|
|
8
|
+
component={Search}
|
|
9
|
+
args={{
|
|
10
|
+
placeholder: 'Search',
|
|
11
|
+
onChange: (value) => console.log(`You have typed ${value}`),
|
|
12
|
+
onSubmit: (value) => console.log(`You have submitted ${value}`),
|
|
13
|
+
'aria-label': 'Search',
|
|
14
|
+
}}
|
|
15
|
+
/>
|
|
16
|
+
|
|
17
|
+
export const Template = (args) => (
|
|
18
|
+
<SearchBarProvider userQuery="">
|
|
19
|
+
<Search {...args} />
|
|
20
|
+
</SearchBarProvider>
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# Search
|
|
24
|
+
|
|
25
|
+
### Search component. Used to search various information. To see typing events, look at the console.
|
|
26
|
+
|
|
27
|
+
## Props
|
|
28
|
+
|
|
29
|
+
<ArgTypes />
|
|
30
|
+
|
|
31
|
+
## Showcase
|
|
32
|
+
|
|
33
|
+
### Default
|
|
34
|
+
|
|
35
|
+
<Canvas>
|
|
36
|
+
<Story
|
|
37
|
+
name="Default"
|
|
38
|
+
args={{
|
|
39
|
+
id: 'default',
|
|
40
|
+
label: 'Search',
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
{Template.bind({})}
|
|
44
|
+
</Story>
|
|
45
|
+
</Canvas>
|
|
46
|
+
|
|
47
|
+
### No label
|
|
48
|
+
|
|
49
|
+
<Canvas>
|
|
50
|
+
<Story
|
|
51
|
+
name="No label"
|
|
52
|
+
args={{
|
|
53
|
+
id: 'no-label',
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
{Template.bind({})}
|
|
57
|
+
</Story>
|
|
58
|
+
</Canvas>
|
|
59
|
+
|
|
60
|
+
### Disabled
|
|
61
|
+
|
|
62
|
+
<Canvas>
|
|
63
|
+
<Story
|
|
64
|
+
name="Disabled"
|
|
65
|
+
args={{
|
|
66
|
+
id: 'disabled',
|
|
67
|
+
label: 'Search',
|
|
68
|
+
disabled: true,
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{Template.bind({})}
|
|
72
|
+
</Story>
|
|
73
|
+
</Canvas>
|
|
74
|
+
|
|
75
|
+
### Error
|
|
76
|
+
|
|
77
|
+
<Canvas>
|
|
78
|
+
<Story
|
|
79
|
+
name="Error"
|
|
80
|
+
args={{
|
|
81
|
+
id: 'error',
|
|
82
|
+
label: 'Search',
|
|
83
|
+
errorMessage: 'This is an error message',
|
|
84
|
+
}}
|
|
85
|
+
|
|
86
|
+
>
|
|
87
|
+
|
|
88
|
+
{Template.bind({})}
|
|
89
|
+
|
|
90
|
+
</Story>
|
|
91
|
+
</Canvas>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Key } from 'react'
|
|
2
|
+
import type React from 'react'
|
|
3
|
+
import type { RefCallBack } from 'react-hook-form'
|
|
4
|
+
import type { TDefaultComponent, TReactHookForm } from '../../../types/components'
|
|
5
|
+
|
|
6
|
+
export type TFieldReactHookForm = TReactHookForm & Omit<TDefaultComponent, 'children'>
|
|
7
|
+
export interface TSelectProps extends TFieldReactHookForm {
|
|
8
|
+
id: string
|
|
9
|
+
icon?: string | React.ReactNode
|
|
10
|
+
label?: string
|
|
11
|
+
name: string
|
|
12
|
+
required?: boolean
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
isError?: boolean
|
|
15
|
+
errorMessage?: string
|
|
16
|
+
fieldRef?: RefCallBack
|
|
17
|
+
placeholderLabel: string
|
|
18
|
+
hookFormRef?: RefCallBack
|
|
19
|
+
onSelectionChange?: (value: Key) => void
|
|
20
|
+
defaultValue?: string
|
|
21
|
+
value?: string
|
|
22
|
+
popoverMatchesWidth?: boolean
|
|
23
|
+
options?: { key: string; value: string }[]
|
|
24
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{/* Select.stories.mdx */}
|
|
2
|
+
|
|
3
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
4
|
+
import Select, { SelectStyled } from './Select'
|
|
5
|
+
import SelectItem from '../SelectItem/SelectItem'
|
|
6
|
+
import SelectContent from '../../../storybook/SelectField'
|
|
7
|
+
import ChevronLeft from '../../icons/ChevronLeft'
|
|
8
|
+
|
|
9
|
+
<Meta
|
|
10
|
+
title="Form/Fields/Select"
|
|
11
|
+
component={Select}
|
|
12
|
+
args={{
|
|
13
|
+
id: 'season',
|
|
14
|
+
name: 'season',
|
|
15
|
+
label: 'Season',
|
|
16
|
+
placeholderLabel: 'Select a season',
|
|
17
|
+
onSelectionChange: () => console.log('test'),
|
|
18
|
+
}}
|
|
19
|
+
/>
|
|
20
|
+
|
|
21
|
+
export const Template = (args) => <SelectContent {...args} />
|
|
22
|
+
|
|
23
|
+
# Select
|
|
24
|
+
|
|
25
|
+
Select Field component.
|
|
26
|
+
|
|
27
|
+
<Canvas>
|
|
28
|
+
<Story name="Default">{Template.bind({})}</Story>
|
|
29
|
+
</Canvas>
|
|
30
|
+
|
|
31
|
+
<Canvas>
|
|
32
|
+
<Story
|
|
33
|
+
name="Disabled"
|
|
34
|
+
args={{
|
|
35
|
+
disabled: true,
|
|
36
|
+
icon: 'ChevronLeft',
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
{Template.bind({})}
|
|
40
|
+
</Story>
|
|
41
|
+
</Canvas>
|
|
42
|
+
|
|
43
|
+
<Canvas>
|
|
44
|
+
<Story
|
|
45
|
+
name="Error"
|
|
46
|
+
args={{
|
|
47
|
+
isError: true,
|
|
48
|
+
errorMessage: 'This is an error message',
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
{Template.bind({})}
|
|
52
|
+
</Story>
|
|
53
|
+
</Canvas>
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { isEmpty } from 'lodash'
|
|
4
|
+
import React, { useRef } from 'react'
|
|
5
|
+
import { HiddenSelect, useSelect } from 'react-aria'
|
|
6
|
+
import { get, useFormContext } from 'react-hook-form'
|
|
7
|
+
import { useSelectState } from 'react-stately'
|
|
8
|
+
import Box from '../../Box'
|
|
9
|
+
import { ButtonWithForwardRef } from '../../Button'
|
|
10
|
+
import Icon from '../../Icon'
|
|
11
|
+
import Typography from '../../Typography'
|
|
12
|
+
import SelectItem from '../SelectItem/SelectItem'
|
|
13
|
+
import { ListBox } from './components/Listbox'
|
|
14
|
+
import Popover from './components/Popover'
|
|
15
|
+
import type { TSelectProps } from './Select.interface'
|
|
16
|
+
|
|
17
|
+
const Select = (props: TSelectProps) => {
|
|
18
|
+
const {
|
|
19
|
+
name,
|
|
20
|
+
placeholderLabel,
|
|
21
|
+
disabled,
|
|
22
|
+
hookFormRef,
|
|
23
|
+
isError = false,
|
|
24
|
+
errorMessage,
|
|
25
|
+
themeName = 'select',
|
|
26
|
+
tokens,
|
|
27
|
+
customTheme,
|
|
28
|
+
label,
|
|
29
|
+
onSelectionChange,
|
|
30
|
+
defaultValue,
|
|
31
|
+
value,
|
|
32
|
+
icon,
|
|
33
|
+
popoverMatchesWidth,
|
|
34
|
+
options,
|
|
35
|
+
...rest
|
|
36
|
+
} = props
|
|
37
|
+
const fieldRef = useRef<HTMLButtonElement & HTMLAnchorElement>(null)
|
|
38
|
+
|
|
39
|
+
const state = useSelectState({
|
|
40
|
+
...rest,
|
|
41
|
+
children: SelectItem,
|
|
42
|
+
selectedKey: value,
|
|
43
|
+
defaultSelectedKey: defaultValue,
|
|
44
|
+
items: options,
|
|
45
|
+
onSelectionChange,
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const { triggerProps, menuProps, labelProps } = useSelect({ ...rest, label }, state, fieldRef)
|
|
49
|
+
const { onPress, onPressStart, ...restofTriggerProps } = triggerProps
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Box themeName={`${themeName}.wrapper`}>
|
|
53
|
+
{label && (
|
|
54
|
+
<Typography {...labelProps} as="label" themeName={`${themeName}.label`}>
|
|
55
|
+
{label}
|
|
56
|
+
</Typography>
|
|
57
|
+
)}
|
|
58
|
+
<HiddenSelect {...hookFormRef} state={state} triggerRef={fieldRef} name={name} isDisabled />
|
|
59
|
+
<Box themeName={`${themeName}.container`}>
|
|
60
|
+
<ButtonWithForwardRef
|
|
61
|
+
{...restofTriggerProps}
|
|
62
|
+
handlePress={(event) => {
|
|
63
|
+
onPress?.(event)
|
|
64
|
+
onPressStart?.(event)
|
|
65
|
+
}}
|
|
66
|
+
ref={fieldRef}
|
|
67
|
+
disabled={disabled}
|
|
68
|
+
themeName={`${themeName}.button`}
|
|
69
|
+
tokens={{ ...tokens, intent: isError ? 'error' : 'default' }}
|
|
70
|
+
>
|
|
71
|
+
{state.selectedItem ? state.selectedItem.rendered : placeholderLabel}
|
|
72
|
+
<Icon icon={icon ?? 'ArrowDown'} />
|
|
73
|
+
</ButtonWithForwardRef>
|
|
74
|
+
{state.isOpen && fieldRef.current && (
|
|
75
|
+
<Popover
|
|
76
|
+
tokens={tokens}
|
|
77
|
+
state={state}
|
|
78
|
+
triggerRef={fieldRef}
|
|
79
|
+
placement="bottom"
|
|
80
|
+
themeName={`${themeName}.popover`}
|
|
81
|
+
style={{ [`--${themeName}-container-width`]: `${fieldRef.current?.offsetWidth}px` } as React.CSSProperties}
|
|
82
|
+
>
|
|
83
|
+
<ListBox {...menuProps} themeName={themeName} state={state} />
|
|
84
|
+
</Popover>
|
|
85
|
+
)}
|
|
86
|
+
{isError && (
|
|
87
|
+
<Typography tokens={{ ...tokens, isError }} themeName={`${themeName}.errorMessage`}>
|
|
88
|
+
{errorMessage}
|
|
89
|
+
</Typography>
|
|
90
|
+
)}
|
|
91
|
+
</Box>
|
|
92
|
+
</Box>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export const ReactHookFormSelect = (props: TSelectProps) => {
|
|
97
|
+
const { name, required } = props
|
|
98
|
+
const { register, formState } = useFormContext()
|
|
99
|
+
const errors = get(formState.errors, name)
|
|
100
|
+
const errMsg = errors?.message ?? undefined
|
|
101
|
+
const { ref } = register(name, {
|
|
102
|
+
required: required ? 'This is an error message' : false,
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
return <Select {...props} isError={!isEmpty(errMsg)} errorMessage={errMsg} hookFormRef={ref} />
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default Select
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import type
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import type React from 'react'
|
|
3
|
+
import type { AriaListBoxOptions, AriaOptionProps } from 'react-aria'
|
|
4
|
+
import type { ListState } from 'react-stately'
|
|
5
|
+
import type { TDefaultComponent } from '../../../../types/components'
|
|
6
|
+
|
|
5
7
|
export interface TListBoxProps extends AriaListBoxOptions<unknown>, TDefaultComponent {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
listBoxRef?: React.RefObject<any>
|
|
9
|
+
state: ListState<unknown>
|
|
8
10
|
}
|
|
11
|
+
|
|
9
12
|
export interface TOptionProps extends AriaOptionProps, TDefaultComponent {
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
item: any
|
|
14
|
+
state: ListState<unknown>
|
|
12
15
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { FocusScope, useListBox, useOption } from 'react-aria'
|
|
3
|
+
import useThemeContext from '../../../../providers/Theme/hooks'
|
|
4
|
+
import { TypographyWithForwardRef } from '../../../Typography'
|
|
5
|
+
import type { TListBoxProps, TOptionProps } from './Listbox.interface'
|
|
6
|
+
|
|
7
|
+
const Option = ({ item, state, themeName = 'li' }: TOptionProps) => {
|
|
8
|
+
const ref = React.useRef(null)
|
|
9
|
+
const { optionProps, isFocusVisible } = useOption({ key: item.key }, state, ref)
|
|
10
|
+
|
|
11
|
+
const theme = useThemeContext(themeName)
|
|
12
|
+
return (
|
|
13
|
+
<TypographyWithForwardRef
|
|
14
|
+
as="li"
|
|
15
|
+
{...optionProps}
|
|
16
|
+
tokens={{ className: `${theme} ${isFocusVisible ? 'has-focus-ring' : ''}` }}
|
|
17
|
+
ref={ref}
|
|
18
|
+
>
|
|
19
|
+
{item.rendered}
|
|
20
|
+
</TypographyWithForwardRef>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const ListBox = (props: TListBoxProps) => {
|
|
25
|
+
const ref = React.useRef(null)
|
|
26
|
+
const { listBoxRef = ref, state, themeName = 'option' } = props
|
|
27
|
+
const { listBoxProps } = useListBox(props, state, listBoxRef)
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<FocusScope autoFocus restoreFocus contain>
|
|
31
|
+
<TypographyWithForwardRef {...listBoxProps} ref={listBoxRef} as="ul" themeName={`${themeName}.ul`}>
|
|
32
|
+
{[...state.collection].map((item) => (
|
|
33
|
+
<Option themeName={`${themeName}.li`} key={item.key} item={item} state={state} />
|
|
34
|
+
))}
|
|
35
|
+
</TypographyWithForwardRef>
|
|
36
|
+
</FocusScope>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { ListBox, Option }
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type React from 'react'
|
|
2
|
+
import type { AriaPopoverProps } from 'react-aria'
|
|
3
|
+
import type { OverlayTriggerState } from 'react-stately'
|
|
4
|
+
import type { TToken } from '../../../../providers/Theme/interface'
|
|
5
|
+
import type { TDefaultComponent } from '../../../../types/components'
|
|
6
|
+
|
|
7
|
+
export interface TPopoverProps extends Omit<AriaPopoverProps, 'popoverRef'>, TDefaultComponent {
|
|
8
|
+
children: React.ReactNode
|
|
9
|
+
state: OverlayTriggerState
|
|
10
|
+
variant?: string
|
|
11
|
+
popoverRef?: React.RefObject<HTMLDivElement>
|
|
12
|
+
tokens?: TToken
|
|
13
|
+
style?: React.CSSProperties
|
|
14
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { DismissButton, Overlay, usePopover } from 'react-aria'
|
|
3
|
+
import Box, { BoxWithForwardRef } from '../../../Box'
|
|
4
|
+
import type { TPopoverProps } from './Popover.interface'
|
|
5
|
+
|
|
6
|
+
const Popover = (props: TPopoverProps) => {
|
|
7
|
+
const ref = React.useRef(null)
|
|
8
|
+
const { popoverRef = ref, state, children, themeName = 'popover', tokens, customTheme, triggerRef, ...rest } = props
|
|
9
|
+
const { popoverProps, underlayProps } = usePopover(
|
|
10
|
+
{
|
|
11
|
+
...props,
|
|
12
|
+
popoverRef,
|
|
13
|
+
triggerRef,
|
|
14
|
+
},
|
|
15
|
+
state,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Overlay>
|
|
20
|
+
<div {...underlayProps} style={{ position: 'fixed', inset: 0 }} />
|
|
21
|
+
<Box {...rest}>
|
|
22
|
+
<BoxWithForwardRef {...popoverProps} ref={popoverRef} themeName={themeName} tokens={tokens}>
|
|
23
|
+
<DismissButton onDismiss={state.close} />
|
|
24
|
+
{children}
|
|
25
|
+
<DismissButton onDismiss={state.close} />
|
|
26
|
+
</BoxWithForwardRef>
|
|
27
|
+
</Box>
|
|
28
|
+
</Overlay>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default Popover
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { TDefaultComponent } from '../../../types/components'
|
|
1
|
+
import type { TDefaultComponent } from '../../../types/components'
|
|
2
|
+
|
|
2
3
|
export interface TSelectItemProps extends TDefaultComponent {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
key: string
|
|
5
|
+
value: string
|
|
5
6
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Item } from 'react-stately'
|
|
2
|
+
import type { TSelectItemProps } from './SelectItem.interface'
|
|
3
|
+
|
|
4
|
+
const SelectItem = (props: TSelectItemProps) => {
|
|
5
|
+
const { key, value } = props
|
|
6
|
+
|
|
7
|
+
return <Item key={key}>{value}</Item>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default SelectItem
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/* eslint-disable jsx-a11y/label-has-associated-control */
|
|
2
|
+
|
|
3
|
+
'use client'
|
|
4
|
+
|
|
5
|
+
import { FocusRing } from '@react-aria/focus'
|
|
6
|
+
import { isEmpty } from 'radash'
|
|
7
|
+
import React, { useRef } from 'react'
|
|
8
|
+
import { useTextField } from 'react-aria'
|
|
9
|
+
import { useFormContext, get } from 'react-hook-form'
|
|
10
|
+
import { useTranslation } from 'react-i18next'
|
|
11
|
+
import useThemeContext from '../../../providers/Theme/hooks'
|
|
12
|
+
import Typography from '../../Typography'
|
|
13
|
+
import type { TTextInputProps } from '../TextInputField/interface'
|
|
14
|
+
|
|
15
|
+
const TextArea = (props: TTextInputProps) => {
|
|
16
|
+
const {
|
|
17
|
+
id,
|
|
18
|
+
label,
|
|
19
|
+
name,
|
|
20
|
+
placeholder,
|
|
21
|
+
required,
|
|
22
|
+
disabled = false,
|
|
23
|
+
errorMessage,
|
|
24
|
+
ariaLabel,
|
|
25
|
+
value,
|
|
26
|
+
onBlur,
|
|
27
|
+
onChange,
|
|
28
|
+
fieldRef,
|
|
29
|
+
themeName = 'textarea',
|
|
30
|
+
tokens,
|
|
31
|
+
customTheme,
|
|
32
|
+
} = props
|
|
33
|
+
const ref = useRef<HTMLTextAreaElement | null>(null)
|
|
34
|
+
const { errorMessageProps, inputProps, labelProps } = useTextField<'textarea' | 'input'>(props, ref)
|
|
35
|
+
|
|
36
|
+
const inputTokens = { ...tokens, isDisabled: disabled, isError: errorMessage != null }
|
|
37
|
+
|
|
38
|
+
const wrapper = useThemeContext(`${themeName}.wrapper`, inputTokens, customTheme)
|
|
39
|
+
const input = useThemeContext(`${themeName}.input`, inputTokens, customTheme)
|
|
40
|
+
const labelTheme = useThemeContext(`${themeName}.label`, inputTokens, customTheme)
|
|
41
|
+
const container = useThemeContext(`${themeName}.container`, inputTokens, customTheme)
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div>
|
|
45
|
+
<div className={wrapper} aria-disabled={disabled}>
|
|
46
|
+
{label && (
|
|
47
|
+
<label className={labelTheme} {...labelProps}>
|
|
48
|
+
{label}
|
|
49
|
+
</label>
|
|
50
|
+
)}
|
|
51
|
+
<div className={container}>
|
|
52
|
+
<FocusRing focusRingClass="has-focus-ring">
|
|
53
|
+
<textarea
|
|
54
|
+
{...(inputProps as object)}
|
|
55
|
+
ref={(e) => {
|
|
56
|
+
fieldRef?.(e)
|
|
57
|
+
ref.current = e
|
|
58
|
+
}}
|
|
59
|
+
className={input}
|
|
60
|
+
placeholder={placeholder}
|
|
61
|
+
disabled={disabled}
|
|
62
|
+
required={required}
|
|
63
|
+
id={id}
|
|
64
|
+
name={name}
|
|
65
|
+
aria-label={ariaLabel}
|
|
66
|
+
aria-labelledby={id}
|
|
67
|
+
value={value}
|
|
68
|
+
onBlur={onBlur}
|
|
69
|
+
onChange={onChange}
|
|
70
|
+
/>
|
|
71
|
+
</FocusRing>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
{errorMessage && (
|
|
75
|
+
<Typography themeName={`${themeName}.errorMessage`} tokens={inputTokens} {...errorMessageProps}>
|
|
76
|
+
{errorMessage}
|
|
77
|
+
</Typography>
|
|
78
|
+
)}
|
|
79
|
+
</div>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const ReactHookFormTextArea = (props: TTextInputProps) => {
|
|
84
|
+
const { name, required, minLength = 0, maxLength = 99999999, validation } = props
|
|
85
|
+
const { register, formState } = useFormContext()
|
|
86
|
+
const error: Error = get(formState.errors, name)
|
|
87
|
+
const errMsg = error?.message ?? undefined
|
|
88
|
+
const { t } = useTranslation('components')
|
|
89
|
+
const { ref: refCallback, ...rest } = register(name, {
|
|
90
|
+
required: required ? t('FORM.ERROR.REQUIRED') ?? 'required' : false,
|
|
91
|
+
minLength: {
|
|
92
|
+
value: minLength,
|
|
93
|
+
message: t('FORM.ERROR.MIN_LENGTH', { length: minLength }),
|
|
94
|
+
},
|
|
95
|
+
maxLength: {
|
|
96
|
+
value: maxLength,
|
|
97
|
+
message: t('FORM.ERROR.MAX_LENGTH', { length: minLength }),
|
|
98
|
+
},
|
|
99
|
+
...validation,
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
return <TextArea fieldRef={refCallback} {...rest} {...props} isError={!isEmpty(errMsg)} errorMessage={errMsg} />
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export default TextArea
|