@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,51 @@
|
|
|
1
|
+
import type React from 'react'
|
|
2
|
+
import type * as SwiperModules from 'swiper/modules'
|
|
3
|
+
import type { SwiperProps } from 'swiper/react'
|
|
4
|
+
import type { A11yOptions } from 'swiper/types'
|
|
5
|
+
import type { TDefaultComponent } from '../../types/components'
|
|
6
|
+
import type { TButtonProps } from '../Button/interface'
|
|
7
|
+
import type { LightboxProps } from '../Lightbox/interface'
|
|
8
|
+
|
|
9
|
+
type TAlertsNavigationProps = React.ForwardRefExoticComponent<
|
|
10
|
+
TButtonProps & React.RefAttributes<HTMLButtonElement & HTMLAnchorElement>
|
|
11
|
+
>
|
|
12
|
+
|
|
13
|
+
export interface TAlertsItem {
|
|
14
|
+
id: string
|
|
15
|
+
icon?: React.ReactNode
|
|
16
|
+
title?: string
|
|
17
|
+
ariaLabel?: string
|
|
18
|
+
content?: React.ReactNode
|
|
19
|
+
button?: TButtonProps
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface TAlertsPaginationProps extends TDefaultComponent {
|
|
23
|
+
activeIndex: number
|
|
24
|
+
alerts: TAlertsItem[]
|
|
25
|
+
paginationGroupLabel?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface TAlertsPaginationBulletProps extends TDefaultComponent {
|
|
29
|
+
activeIndex: number
|
|
30
|
+
alerts: TAlertsItem[]
|
|
31
|
+
index: number
|
|
32
|
+
}
|
|
33
|
+
interface TCustomA11yOptions extends A11yOptions {
|
|
34
|
+
paginationGroupLabel?: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface TAlertsComponentProps
|
|
38
|
+
extends Omit<TDefaultComponent, 'children'>,
|
|
39
|
+
Omit<SwiperProps, 'children' | 'modules' | 'a11y'> {
|
|
40
|
+
a11y?: TCustomA11yOptions
|
|
41
|
+
alerts: TAlertsItem[]
|
|
42
|
+
children?: (props: TAlertsItemProps) => React.ReactNode
|
|
43
|
+
modules?: (keyof typeof SwiperModules)[]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type TAlertsItemProps = TAlertsItem & TDefaultComponent
|
|
47
|
+
|
|
48
|
+
export interface TAlertsProps extends Omit<LightboxProps, 'children'>, TAlertsComponentProps {
|
|
49
|
+
prevButton?: TAlertsNavigationProps
|
|
50
|
+
nextButton?: TAlertsNavigationProps
|
|
51
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{/* box.stories.mdx */}
|
|
2
|
+
|
|
3
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
4
|
+
import Box from './index'
|
|
5
|
+
|
|
6
|
+
<Meta title="BASE COMPONENTS/Box" component={Box} />
|
|
7
|
+
|
|
8
|
+
export const Template = (args) => (
|
|
9
|
+
<div className="bg-slate-200 p-4">
|
|
10
|
+
<Box {...args}>Hello world!</Box>
|
|
11
|
+
</div>
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
# Box
|
|
15
|
+
|
|
16
|
+
Box component. Generic wrapper for your website or app.
|
|
17
|
+
|
|
18
|
+
<Canvas>
|
|
19
|
+
<Story
|
|
20
|
+
name="Box"
|
|
21
|
+
args={{
|
|
22
|
+
as: 'div',
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
{Template.bind({})}
|
|
26
|
+
</Story>
|
|
27
|
+
</Canvas>
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { TBoxProps } from './interface'
|
|
7
|
+
|
|
8
|
+
const Box = ({
|
|
9
|
+
as: Component = 'div',
|
|
10
|
+
themeName = 'box',
|
|
11
|
+
tokens,
|
|
12
|
+
customTheme,
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
...rest
|
|
16
|
+
}: TBoxProps) => {
|
|
17
|
+
const theme = useThemeContext(themeName, tokens, customTheme)
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Component {...rest} className={theme}>
|
|
21
|
+
{children}
|
|
22
|
+
</Component>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const BoxWithForwardRef = React.forwardRef((props: TBoxProps, ref: React.Ref<HTMLElement>) => {
|
|
27
|
+
const { as: Component = 'div', tokens, themeName = 'box', customTheme, children, ...rest } = props
|
|
28
|
+
const theme = useThemeContext(themeName, tokens, customTheme)
|
|
29
|
+
return (
|
|
30
|
+
<Component {...rest} ref={ref} className={theme}>
|
|
31
|
+
{children}
|
|
32
|
+
</Component>
|
|
33
|
+
)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
export default Box
|
|
@@ -0,0 +1,10 @@
|
|
|
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 TBoxProps<T = TToken> extends TDefaultComponent<T> {
|
|
7
|
+
className?: string
|
|
8
|
+
children?: React.ReactNode
|
|
9
|
+
dangerouslySetInnerHTML?: { __html: string | TrustedHTML }
|
|
10
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
2
|
+
import Button from './'
|
|
3
|
+
import Icon from '../Icon'
|
|
4
|
+
|
|
5
|
+
<Meta
|
|
6
|
+
title="BASE COMPONENTS/Button"
|
|
7
|
+
component={Button}
|
|
8
|
+
args={{
|
|
9
|
+
as: 'button',
|
|
10
|
+
disabled: false,
|
|
11
|
+
}}
|
|
12
|
+
/>
|
|
13
|
+
|
|
14
|
+
export const Template = (args) => <Button {...args}>Button</Button>
|
|
15
|
+
|
|
16
|
+
export const IconButton = (args) => (
|
|
17
|
+
<Button {...args}>
|
|
18
|
+
<span>Button</span>
|
|
19
|
+
<Icon icon="ArrowRight" />
|
|
20
|
+
</Button>
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# Button
|
|
24
|
+
|
|
25
|
+
Button component. You can pass `shape`, `size` and `buttonStyle` into the `tokens` object to change the style.
|
|
26
|
+
You can use property `as` to render the button with a different component, e.g. `button` to `a` if its a link.
|
|
27
|
+
|
|
28
|
+
<Canvas>
|
|
29
|
+
<Story name="Primary" args={{}}>
|
|
30
|
+
{Template.bind({})}
|
|
31
|
+
</Story>
|
|
32
|
+
</Canvas>
|
|
33
|
+
|
|
34
|
+
<Canvas>
|
|
35
|
+
<Story
|
|
36
|
+
name="Large"
|
|
37
|
+
args={{
|
|
38
|
+
tokens: {
|
|
39
|
+
size: 'large',
|
|
40
|
+
shape: 'circular',
|
|
41
|
+
},
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
{Template.bind({})}
|
|
45
|
+
</Story>
|
|
46
|
+
</Canvas>
|
|
47
|
+
|
|
48
|
+
<Canvas>
|
|
49
|
+
<Story
|
|
50
|
+
name="Rounded"
|
|
51
|
+
args={{
|
|
52
|
+
tokens: {
|
|
53
|
+
shape: 'rounded',
|
|
54
|
+
},
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
{Template.bind({})}
|
|
58
|
+
</Story>
|
|
59
|
+
</Canvas>
|
|
60
|
+
|
|
61
|
+
<Canvas>
|
|
62
|
+
<Story
|
|
63
|
+
name="Outline"
|
|
64
|
+
args={{
|
|
65
|
+
tokens: {
|
|
66
|
+
buttonStyle: 'outline',
|
|
67
|
+
},
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
{Template.bind({})}
|
|
71
|
+
</Story>
|
|
72
|
+
</Canvas>
|
|
73
|
+
|
|
74
|
+
<Canvas>
|
|
75
|
+
<Story
|
|
76
|
+
name="Hollow"
|
|
77
|
+
args={{
|
|
78
|
+
tokens: {
|
|
79
|
+
buttonStyle: 'hollow',
|
|
80
|
+
},
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
{Template.bind({})}
|
|
84
|
+
</Story>
|
|
85
|
+
</Canvas>
|
|
86
|
+
|
|
87
|
+
<Canvas>
|
|
88
|
+
<Story
|
|
89
|
+
name="Icon"
|
|
90
|
+
args={{
|
|
91
|
+
tokens: {
|
|
92
|
+
buttonStyle: 'outline',
|
|
93
|
+
intent: 'error',
|
|
94
|
+
},
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
{IconButton.bind({})}
|
|
98
|
+
</Story>
|
|
99
|
+
</Canvas>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/* eslint-disable react/display-name */
|
|
2
|
+
|
|
3
|
+
'use client'
|
|
4
|
+
|
|
5
|
+
import type { RefObject } from 'react'
|
|
6
|
+
import React, { useRef } from 'react'
|
|
7
|
+
import { FocusRing, useButton, useLink } from 'react-aria'
|
|
8
|
+
import useThemeContext from '../../providers/Theme/hooks'
|
|
9
|
+
import type { TAnchorPropsProps, TButtonProps } from './interface'
|
|
10
|
+
|
|
11
|
+
export const Anchor = React.forwardRef(
|
|
12
|
+
(props: TAnchorPropsProps, forwardRef: React.Ref<HTMLButtonElement & HTMLAnchorElement>) => {
|
|
13
|
+
const {
|
|
14
|
+
as: Component = 'a',
|
|
15
|
+
handlePress,
|
|
16
|
+
children,
|
|
17
|
+
as,
|
|
18
|
+
customTheme,
|
|
19
|
+
tokens,
|
|
20
|
+
themeName = 'button',
|
|
21
|
+
nextLinkProps,
|
|
22
|
+
...rest
|
|
23
|
+
} = props
|
|
24
|
+
|
|
25
|
+
const ref = forwardRef
|
|
26
|
+
const { linkProps } = useLink(
|
|
27
|
+
{
|
|
28
|
+
...{ ...props, ...nextLinkProps },
|
|
29
|
+
href: props.href ?? nextLinkProps?.href?.toString(),
|
|
30
|
+
elementType: as?.toString(),
|
|
31
|
+
onPress: handlePress,
|
|
32
|
+
},
|
|
33
|
+
(forwardRef as RefObject<HTMLElement>) ?? ref,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
const theme = useThemeContext(themeName, tokens, customTheme)
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<FocusRing focusRingClass="has-focus-ring">
|
|
40
|
+
<Component ref={ref} {...linkProps} {...nextLinkProps} {...rest} className={theme}>
|
|
41
|
+
{children}
|
|
42
|
+
</Component>
|
|
43
|
+
</FocusRing>
|
|
44
|
+
)
|
|
45
|
+
},
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
const Button = React.forwardRef((props: TButtonProps, forwardRef: React.Ref<HTMLButtonElement & HTMLAnchorElement>) => {
|
|
49
|
+
const {
|
|
50
|
+
as: Component = 'button',
|
|
51
|
+
handlePress,
|
|
52
|
+
children,
|
|
53
|
+
as,
|
|
54
|
+
customTheme,
|
|
55
|
+
tokens,
|
|
56
|
+
themeName = 'button',
|
|
57
|
+
isDisabled = false,
|
|
58
|
+
...rest
|
|
59
|
+
} = props
|
|
60
|
+
const ref = forwardRef
|
|
61
|
+
const { buttonProps } = useButton(
|
|
62
|
+
{ ...props, isDisabled, elementType: as, onPress: handlePress },
|
|
63
|
+
(forwardRef as RefObject<HTMLElement>) ?? ref,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
const theme = useThemeContext(themeName, tokens, customTheme)
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<FocusRing within focusRingClass="has-focus-ring">
|
|
70
|
+
<Component ref={ref} {...buttonProps} {...rest} className={theme}>
|
|
71
|
+
{children}
|
|
72
|
+
</Component>
|
|
73
|
+
</FocusRing>
|
|
74
|
+
)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
export const ButtonWithForwardRef = React.forwardRef(
|
|
78
|
+
(props: TButtonProps, ref: React.Ref<HTMLButtonElement & HTMLAnchorElement>) => {
|
|
79
|
+
const { as } = props
|
|
80
|
+
if (as === 'a') return <Anchor ref={ref} {...props} />
|
|
81
|
+
return <Button ref={ref} {...props} />
|
|
82
|
+
},
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
const ButtonComponent = (props: TButtonProps) => {
|
|
86
|
+
const { as } = props
|
|
87
|
+
const ref = useRef(null)
|
|
88
|
+
if (as === 'a') return <Anchor ref={ref} {...props} />
|
|
89
|
+
return <Button ref={ref} {...props} />
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default React.memo(ButtonComponent)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PressEvent } from '@react-types/shared'
|
|
2
|
+
import type { LinkProps } from 'next/link'
|
|
3
|
+
import type React from 'react'
|
|
4
|
+
import type { TDefaultComponent } from '../../types/components'
|
|
5
|
+
|
|
6
|
+
export interface TButtonProps extends TDefaultComponent {
|
|
7
|
+
children?: React.ReactNode
|
|
8
|
+
id?: string
|
|
9
|
+
href?: string
|
|
10
|
+
disabled?: boolean
|
|
11
|
+
download?: boolean
|
|
12
|
+
target?: string
|
|
13
|
+
rel?: string
|
|
14
|
+
handlePress?: ((e: PressEvent) => void) | undefined
|
|
15
|
+
tabIndex?: number
|
|
16
|
+
role?: string
|
|
17
|
+
isDisabled?: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface TAnchorPropsProps extends TButtonProps {
|
|
21
|
+
nextLinkProps?: LinkProps
|
|
22
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
import { createCalendar } from '@internationalized/date'
|
|
3
|
+
import { useRangeCalendar } from '@react-aria/calendar'
|
|
4
|
+
import { useLocale } from '@react-aria/i18n'
|
|
5
|
+
import { useRangeCalendarState } from '@react-stately/calendar'
|
|
6
|
+
import { useRef } from 'react'
|
|
7
|
+
import useThemeContext from '../../providers/Theme/hooks'
|
|
8
|
+
import Button from '../Button'
|
|
9
|
+
import Icon from '../Icon'
|
|
10
|
+
import Typography from '../Typography'
|
|
11
|
+
import CalendarGrid from './components/CalendarGrid'
|
|
12
|
+
import type { TRangeCalendarProps } from './interface'
|
|
13
|
+
|
|
14
|
+
function RangeCalendar({ buttons, tokens, customTheme, themeName = 'calendar', ...rest }: TRangeCalendarProps) {
|
|
15
|
+
const { locale } = useLocale()
|
|
16
|
+
const state = useRangeCalendarState({
|
|
17
|
+
...rest,
|
|
18
|
+
locale,
|
|
19
|
+
createCalendar,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const ref = useRef(null)
|
|
23
|
+
const { calendarProps, prevButtonProps, nextButtonProps, title } = useRangeCalendar({ ...rest }, state, ref)
|
|
24
|
+
|
|
25
|
+
const containerTheme = useThemeContext(`${themeName}.container`, tokens)
|
|
26
|
+
const headerTheme = useThemeContext(`${themeName}.header`, tokens)
|
|
27
|
+
const navigationButtonsContainer = useThemeContext(`${themeName}.navigationButtonsContainer`, tokens)
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div {...calendarProps} ref={ref} className={containerTheme}>
|
|
31
|
+
<div className={headerTheme}>
|
|
32
|
+
<Typography as="p" tokens={{ size: 'h6' }}>
|
|
33
|
+
{title}
|
|
34
|
+
</Typography>
|
|
35
|
+
<div className={navigationButtonsContainer}>
|
|
36
|
+
<Button
|
|
37
|
+
themeName={`${themeName}.navigationButtons`}
|
|
38
|
+
tokens={{ ...tokens }}
|
|
39
|
+
type="button"
|
|
40
|
+
{...prevButtonProps}
|
|
41
|
+
handlePress={prevButtonProps?.onPress}
|
|
42
|
+
>
|
|
43
|
+
<Icon icon={buttons?.buttonPrev?.icon ?? 'ArrowLeft'} />
|
|
44
|
+
</Button>
|
|
45
|
+
<Button
|
|
46
|
+
themeName={`${themeName}.navigationButtons`}
|
|
47
|
+
tokens={{ ...tokens }}
|
|
48
|
+
type="button"
|
|
49
|
+
{...nextButtonProps}
|
|
50
|
+
handlePress={nextButtonProps?.onPress}
|
|
51
|
+
>
|
|
52
|
+
<Icon icon={buttons?.buttonNext?.icon ?? 'ArrowRight'} />
|
|
53
|
+
</Button>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
<CalendarGrid state={state} />
|
|
57
|
+
</div>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default RangeCalendar
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
2
|
+
import Calendar from './'
|
|
3
|
+
import RangeCalendar from './RangeCalendar'
|
|
4
|
+
import { OverlayContainer } from '@react-aria/overlays'
|
|
5
|
+
|
|
6
|
+
<Meta
|
|
7
|
+
title="Base Components/Calendar"
|
|
8
|
+
component={Calendar}
|
|
9
|
+
args={{
|
|
10
|
+
label: 'Filter by date',
|
|
11
|
+
variant: 'primary',
|
|
12
|
+
}}
|
|
13
|
+
/>
|
|
14
|
+
|
|
15
|
+
export const CalendarTemplate = (args) => <Calendar {...args} />
|
|
16
|
+
export const RangeCalendarTemplate = (args) => <RangeCalendar {...args} />
|
|
17
|
+
|
|
18
|
+
# Calendar
|
|
19
|
+
|
|
20
|
+
Calendar component.
|
|
21
|
+
|
|
22
|
+
<Canvas>
|
|
23
|
+
<Story name="Calendar">{CalendarTemplate.bind({})}</Story>
|
|
24
|
+
</Canvas>
|
|
25
|
+
|
|
26
|
+
<Canvas>
|
|
27
|
+
<Story name="Range Calendar">{RangeCalendarTemplate.bind({})}</Story>
|
|
28
|
+
</Canvas>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { isSameDay, getDayOfWeek } from '@internationalized/date'
|
|
2
|
+
import { useCalendarCell } from '@react-aria/calendar'
|
|
3
|
+
import { useFocusRing } from '@react-aria/focus'
|
|
4
|
+
import { mergeProps } from '@react-aria/utils'
|
|
5
|
+
import type { RangeCalendarState } from '@react-stately/calendar'
|
|
6
|
+
import { useRef } from 'react'
|
|
7
|
+
import { useLocale } from 'react-aria'
|
|
8
|
+
import useThemeContext from '../../../providers/Theme/hooks'
|
|
9
|
+
import type { TCalendarCellProps } from '../interface'
|
|
10
|
+
|
|
11
|
+
function CalendarCell({ themeName = 'calendar', tokens, state, date }: TCalendarCellProps) {
|
|
12
|
+
const ref = useRef(null)
|
|
13
|
+
const { cellProps, buttonProps, isSelected, isOutsideVisibleRange, isDisabled, formattedDate, isInvalid } =
|
|
14
|
+
useCalendarCell({ date }, state, ref)
|
|
15
|
+
|
|
16
|
+
// The start and end date of the selected range will have
|
|
17
|
+
// an emphasized appearance.
|
|
18
|
+
const isSelectionStart = (state as RangeCalendarState)?.highlightedRange
|
|
19
|
+
? isSameDay(date, (state as RangeCalendarState)?.highlightedRange.start)
|
|
20
|
+
: isSelected
|
|
21
|
+
const isSelectionEnd = (state as RangeCalendarState)?.highlightedRange
|
|
22
|
+
? isSameDay(date, (state as RangeCalendarState)?.highlightedRange.end)
|
|
23
|
+
: isSelected
|
|
24
|
+
|
|
25
|
+
const { locale } = useLocale()
|
|
26
|
+
const dayOfWeek = getDayOfWeek(date, locale)
|
|
27
|
+
const isRoundedLeft = isSelected && (isSelectionStart || dayOfWeek === 0 || date.day === 1)
|
|
28
|
+
const isRoundedRight =
|
|
29
|
+
isSelected && (isSelectionEnd || dayOfWeek === 6 || date.day === date.calendar.getDaysInMonth(date))
|
|
30
|
+
|
|
31
|
+
const { focusProps, isFocusVisible } = useFocusRing()
|
|
32
|
+
|
|
33
|
+
const cellContainerTheme = useThemeContext(`${themeName}.cellContainer`, { ...tokens, isFocusVisible })
|
|
34
|
+
const cellTheme = useThemeContext(`${themeName}.cell`, {
|
|
35
|
+
...tokens,
|
|
36
|
+
isSelected,
|
|
37
|
+
isInvalid,
|
|
38
|
+
isDisabled,
|
|
39
|
+
isRoundedLeft,
|
|
40
|
+
isRoundedRight,
|
|
41
|
+
})
|
|
42
|
+
const cellDate = useThemeContext(`${themeName}.cellDate`, {
|
|
43
|
+
...tokens,
|
|
44
|
+
isSelected,
|
|
45
|
+
isInvalid,
|
|
46
|
+
isDisabled,
|
|
47
|
+
isSelectionStart,
|
|
48
|
+
isSelectionEnd,
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<td {...cellProps} aria-disabled={false} className={cellContainerTheme}>
|
|
53
|
+
<div {...mergeProps(buttonProps, focusProps)} ref={ref} hidden={isOutsideVisibleRange} className={cellTheme}>
|
|
54
|
+
<div className={cellDate}>{formattedDate}</div>
|
|
55
|
+
</div>
|
|
56
|
+
</td>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default CalendarCell
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* eslint-disable react/no-array-index-key */
|
|
2
|
+
/* eslint-disable no-unused-vars */
|
|
3
|
+
import { getWeeksInMonth } from '@internationalized/date'
|
|
4
|
+
import { useCalendarGrid } from '@react-aria/calendar'
|
|
5
|
+
import { useLocale } from '@react-aria/i18n'
|
|
6
|
+
import useThemeContext from '../../../providers/Theme/hooks'
|
|
7
|
+
import type { TCalendarGridProps } from '../interface'
|
|
8
|
+
import CalendarCell from './CalendarCell'
|
|
9
|
+
|
|
10
|
+
function CalendarGrid({ themeName = 'calendar', customTheme, tokens, state, ...rest }: TCalendarGridProps) {
|
|
11
|
+
const { locale } = useLocale()
|
|
12
|
+
const { gridProps, headerProps, weekDays } = useCalendarGrid({ ...rest }, state)
|
|
13
|
+
|
|
14
|
+
// Get the number of weeks in the month so we can render the proper number of rows.
|
|
15
|
+
const weeksInMonth = getWeeksInMonth(state.visibleRange.start, locale)
|
|
16
|
+
|
|
17
|
+
const tableTheme = useThemeContext(`${themeName}.calendarTable`, tokens)
|
|
18
|
+
const dayLabelTheme = useThemeContext(`${themeName}.dayLabel`, tokens)
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<table {...gridProps} cellPadding="0" className={tableTheme}>
|
|
22
|
+
<thead {...headerProps}>
|
|
23
|
+
<tr>
|
|
24
|
+
{weekDays.map((day) => (
|
|
25
|
+
<th key={`${day}`} className={dayLabelTheme}>
|
|
26
|
+
{day}
|
|
27
|
+
</th>
|
|
28
|
+
))}
|
|
29
|
+
</tr>
|
|
30
|
+
</thead>
|
|
31
|
+
<tbody>
|
|
32
|
+
{[...new Array(weeksInMonth).keys()].map((weekIndex) => (
|
|
33
|
+
<tr key={weekIndex}>
|
|
34
|
+
{state
|
|
35
|
+
.getDatesInWeek(weekIndex)
|
|
36
|
+
.map((date, i) => (date ? <CalendarCell key={date?.day} state={state} date={date} /> : <td key={i} />))}
|
|
37
|
+
</tr>
|
|
38
|
+
))}
|
|
39
|
+
</tbody>
|
|
40
|
+
</table>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default CalendarGrid
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
/* eslint-disable no-unused-vars */
|
|
4
|
+
import { createCalendar } from '@internationalized/date'
|
|
5
|
+
import { useCalendar } from '@react-aria/calendar'
|
|
6
|
+
import { useLocale } from '@react-aria/i18n'
|
|
7
|
+
import { useCalendarState } from '@react-stately/calendar'
|
|
8
|
+
import { useRef } from 'react'
|
|
9
|
+
import useThemeContext from '../../providers/Theme/hooks'
|
|
10
|
+
import Button from '../Button'
|
|
11
|
+
import Icon from '../Icon'
|
|
12
|
+
import Typography from '../Typography'
|
|
13
|
+
import CalendarGrid from './components/CalendarGrid'
|
|
14
|
+
import type { TCalendarProps } from './interface'
|
|
15
|
+
|
|
16
|
+
function Calendar({ buttons, tokens, customTheme, themeName = 'calendar', ...rest }: TCalendarProps) {
|
|
17
|
+
const { locale } = useLocale()
|
|
18
|
+
const state = useCalendarState({
|
|
19
|
+
...rest,
|
|
20
|
+
locale,
|
|
21
|
+
createCalendar,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const ref = useRef(null)
|
|
25
|
+
const { calendarProps, prevButtonProps, nextButtonProps, title } = useCalendar({ ...rest }, state)
|
|
26
|
+
|
|
27
|
+
const containerTheme = useThemeContext(`${themeName}.container`, tokens)
|
|
28
|
+
const headerTheme = useThemeContext(`${themeName}.header`, tokens)
|
|
29
|
+
const navigationButtonsContainer = useThemeContext(`${themeName}.navigationButtonsContainer`, tokens)
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div {...calendarProps} ref={ref} className={containerTheme}>
|
|
33
|
+
<div className={headerTheme}>
|
|
34
|
+
<Typography as="p" tokens={{ size: 'h6' }}>
|
|
35
|
+
{title}
|
|
36
|
+
</Typography>
|
|
37
|
+
<div className={navigationButtonsContainer}>
|
|
38
|
+
<Button
|
|
39
|
+
themeName={`${themeName}.navigationButtons`}
|
|
40
|
+
tokens={{ ...tokens }}
|
|
41
|
+
type="button"
|
|
42
|
+
{...prevButtonProps}
|
|
43
|
+
handlePress={prevButtonProps?.onPress}
|
|
44
|
+
>
|
|
45
|
+
<Icon icon={buttons?.buttonPrev?.icon ?? 'ArrowLeft'} />
|
|
46
|
+
</Button>
|
|
47
|
+
<Button
|
|
48
|
+
themeName={`${themeName}.navigationButtons`}
|
|
49
|
+
tokens={{ ...tokens }}
|
|
50
|
+
type="button"
|
|
51
|
+
{...nextButtonProps}
|
|
52
|
+
handlePress={nextButtonProps?.onPress}
|
|
53
|
+
>
|
|
54
|
+
<Icon icon={buttons?.buttonNext?.icon ?? 'ArrowRight'} />
|
|
55
|
+
</Button>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
<CalendarGrid state={state} />
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default Calendar
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
import type { CalendarDate, DateValue } from '@internationalized/date'
|
|
3
|
+
import type { CalendarProps, RangeCalendarProps } from '@react-aria/calendar'
|
|
4
|
+
import type { CalendarState, RangeCalendarState } from '@react-stately/calendar'
|
|
5
|
+
import type { AriaCalendarGridProps } from 'react-aria'
|
|
6
|
+
import type { TDefaultComponent } from '../../types/components'
|
|
7
|
+
|
|
8
|
+
export interface TCalendarProps extends CalendarProps<DateValue>, TDefaultComponent {
|
|
9
|
+
buttons?: {
|
|
10
|
+
buttonPrev?: {
|
|
11
|
+
icon?: string
|
|
12
|
+
}
|
|
13
|
+
buttonNext?: {
|
|
14
|
+
icon?: string
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface TRangeCalendarProps extends RangeCalendarProps<DateValue>, TDefaultComponent {
|
|
20
|
+
buttons?: {
|
|
21
|
+
buttonPrev?: {
|
|
22
|
+
icon?: string
|
|
23
|
+
}
|
|
24
|
+
buttonNext?: {
|
|
25
|
+
icon?: string
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface TCalendarGridProps extends AriaCalendarGridProps, TDefaultComponent {
|
|
31
|
+
state: RangeCalendarState | CalendarState
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface TCalendarCellProps extends TDefaultComponent {
|
|
35
|
+
state: RangeCalendarState | CalendarState
|
|
36
|
+
date: CalendarDate
|
|
37
|
+
}
|