@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,282 @@
|
|
|
1
|
+
import { Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
2
|
+
import { ArgTypes } from '@storybook/blocks'
|
|
3
|
+
import Alerts from '.'
|
|
4
|
+
import Box from '../Box'
|
|
5
|
+
import Typography from '../Typography'
|
|
6
|
+
|
|
7
|
+
<Meta
|
|
8
|
+
title="Base components/Alerts"
|
|
9
|
+
parameters={{
|
|
10
|
+
layout: 'fullscreen',
|
|
11
|
+
controls: {
|
|
12
|
+
include: ['alerts']
|
|
13
|
+
}
|
|
14
|
+
}}
|
|
15
|
+
component={Alerts}
|
|
16
|
+
args={{
|
|
17
|
+
a11y: {
|
|
18
|
+
nextSlideMessage: 'Next alert',
|
|
19
|
+
prevSlideMessage: 'Previous alert',
|
|
20
|
+
paginationBulletMessage: 'Navigate to slide number {{index}}'
|
|
21
|
+
},
|
|
22
|
+
closeButtonAriaLabel: 'Close alerts',
|
|
23
|
+
onOpenChange: (isOpen) => console.log(`Alerts component was ${isOpen ? 'opened' : 'closed'}`),
|
|
24
|
+
onNavigationPrev: () => console.log('Navigated to previous slide'),
|
|
25
|
+
onNavigationNext: () => console.log('Navigated to next slide'),
|
|
26
|
+
}}
|
|
27
|
+
argTypes={{
|
|
28
|
+
closeButton: {
|
|
29
|
+
table: {
|
|
30
|
+
defaultValue: {
|
|
31
|
+
summary: 'AlertsCloseButton'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
a11y: {
|
|
36
|
+
description: "React Swiper's accessibility module parameters"
|
|
37
|
+
},
|
|
38
|
+
children: {
|
|
39
|
+
description: 'Function looping through every alert and passing the current alert. Can be used for rendering all alerts wrapping `AlertsItem` in another component',
|
|
40
|
+
table: {
|
|
41
|
+
type: {
|
|
42
|
+
summary: '(alert: TAlertsItem) => React.ReactNode'
|
|
43
|
+
},
|
|
44
|
+
defaultValue: {
|
|
45
|
+
summary: '(alert: TAlertsItem) => <AlertsItem {...alert />}'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
prevButton: {
|
|
50
|
+
description: 'Custom previous button component for the carousel. Falls back to an arrow button',
|
|
51
|
+
table: {
|
|
52
|
+
defaultValue: {
|
|
53
|
+
summary: 'AlertsNavigationButton'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
nextButton: {
|
|
58
|
+
description: 'Custom previous button component for the carousel. Falls back to an arrow button',
|
|
59
|
+
table: {
|
|
60
|
+
defaultValue: {
|
|
61
|
+
summary: 'AlertsNavigationButton'
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
setOpen: {
|
|
66
|
+
description: 'For controlled states'
|
|
67
|
+
},
|
|
68
|
+
onOpenChange: {
|
|
69
|
+
table: {
|
|
70
|
+
type: {
|
|
71
|
+
summary: '(isOpen) => void'
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
description: 'Triggered when the alerts are closed or opened'
|
|
75
|
+
},
|
|
76
|
+
modules: {
|
|
77
|
+
table: {
|
|
78
|
+
defaultValue: {
|
|
79
|
+
summary: "['A11y', 'Keyboard']"
|
|
80
|
+
},
|
|
81
|
+
type: {
|
|
82
|
+
summary: 'Array<A11y | Autoplay | Controller | EffectCoverflow | EffectCube | EffectFade | EffectFlip | EffectCreative | EffectCards | HashNavigation | History | Keyboard | Lazy | Mousewheel | Navigation | Pagination | Parallax | Scrollbar | Thumbs | Virtual | Zoom | FreeMode | Grid | Manipulation>'
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
description: 'String list of modules the swiper will automatically import'
|
|
86
|
+
}
|
|
87
|
+
}}
|
|
88
|
+
/>
|
|
89
|
+
|
|
90
|
+
export const Template = (args) => (
|
|
91
|
+
<Alerts {...args} />
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
# Alerts
|
|
95
|
+
|
|
96
|
+
### A closable and navigable carousel showcasing multiple alerts
|
|
97
|
+
|
|
98
|
+
## Props
|
|
99
|
+
|
|
100
|
+
<ArgTypes include={[
|
|
101
|
+
'alerts',
|
|
102
|
+
'onOpenChange',
|
|
103
|
+
'a11y',
|
|
104
|
+
'closeButtonAriaLabel',
|
|
105
|
+
'setOpen',
|
|
106
|
+
'nextButton',
|
|
107
|
+
'prevButton',
|
|
108
|
+
'closeButton',
|
|
109
|
+
'transitionComponent',
|
|
110
|
+
'themeName',
|
|
111
|
+
'tokens',
|
|
112
|
+
'customTheme',
|
|
113
|
+
'as',
|
|
114
|
+
'onSwiper',
|
|
115
|
+
'onNavigationPrev',
|
|
116
|
+
'onNavigationNext',
|
|
117
|
+
'children',
|
|
118
|
+
'modules',
|
|
119
|
+
]} />
|
|
120
|
+
|
|
121
|
+
## Showcase
|
|
122
|
+
|
|
123
|
+
### Single alert
|
|
124
|
+
|
|
125
|
+
<Canvas>
|
|
126
|
+
<Story
|
|
127
|
+
name="Single alert"
|
|
128
|
+
args={{
|
|
129
|
+
alerts: [{
|
|
130
|
+
id: '1',
|
|
131
|
+
title: 'Alert 1 title',
|
|
132
|
+
'aria-label': 'Alert 1 aria',
|
|
133
|
+
icon: 'X',
|
|
134
|
+
content: (
|
|
135
|
+
<>
|
|
136
|
+
<Box>
|
|
137
|
+
<Typography tokens={{ size: 'h4' }}>This is alert 1 large content</Typography>
|
|
138
|
+
</Box>
|
|
139
|
+
<Box>
|
|
140
|
+
<Typography tokens={{ size: 'xs' }}>This is alert 1 small content</Typography>
|
|
141
|
+
</Box>
|
|
142
|
+
</>
|
|
143
|
+
)
|
|
144
|
+
}]
|
|
145
|
+
}}
|
|
146
|
+
>
|
|
147
|
+
{Template.bind({})}
|
|
148
|
+
</Story>
|
|
149
|
+
</Canvas>
|
|
150
|
+
|
|
151
|
+
### Navigation
|
|
152
|
+
|
|
153
|
+
<Canvas>
|
|
154
|
+
<Story
|
|
155
|
+
name="Navigation"
|
|
156
|
+
args={{
|
|
157
|
+
modules: ['Navigation'],
|
|
158
|
+
alerts: [
|
|
159
|
+
{
|
|
160
|
+
id: '1',
|
|
161
|
+
title: 'Alert 1 title',
|
|
162
|
+
'aria-label': 'Alert 1 aria',
|
|
163
|
+
icon: 'X',
|
|
164
|
+
content: (
|
|
165
|
+
<>
|
|
166
|
+
<Box>
|
|
167
|
+
<Typography tokens={{ size: 'h4' }}>This is alert 1 large content</Typography>
|
|
168
|
+
</Box>
|
|
169
|
+
<Box>
|
|
170
|
+
<Typography tokens={{ size: 'xs' }}>This is alert 1 small content</Typography>
|
|
171
|
+
</Box>
|
|
172
|
+
</>
|
|
173
|
+
)
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
button: {
|
|
177
|
+
href: '#',
|
|
178
|
+
as: 'a',
|
|
179
|
+
children: 'Consulter toutes les alertes'
|
|
180
|
+
},
|
|
181
|
+
id: '2',
|
|
182
|
+
title: 'Alert 2 title',
|
|
183
|
+
'aria-label': 'Alert 2 aria',
|
|
184
|
+
icon: 'YouTube',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
id: '3',
|
|
188
|
+
title: 'Alert 3 title',
|
|
189
|
+
'aria-label': 'Alert 3 aria',
|
|
190
|
+
icon: 'Mail',
|
|
191
|
+
},
|
|
192
|
+
]
|
|
193
|
+
}}
|
|
194
|
+
>
|
|
195
|
+
{Template.bind({})}
|
|
196
|
+
</Story>
|
|
197
|
+
</Canvas>
|
|
198
|
+
|
|
199
|
+
### Pagination
|
|
200
|
+
|
|
201
|
+
<Canvas>
|
|
202
|
+
<Story
|
|
203
|
+
name="Pagination"
|
|
204
|
+
args={{
|
|
205
|
+
modules: ['Pagination'],
|
|
206
|
+
alerts: [
|
|
207
|
+
{
|
|
208
|
+
id: '1',
|
|
209
|
+
'aria-label': 'Alert 1 aria',
|
|
210
|
+
icon: 'X',
|
|
211
|
+
content: (
|
|
212
|
+
<>
|
|
213
|
+
<Box>
|
|
214
|
+
<Typography tokens={{ size: 'h4' }}>This is alert 1 large content</Typography>
|
|
215
|
+
</Box>
|
|
216
|
+
<Box>
|
|
217
|
+
<Typography tokens={{ size: 'xs' }}>This is alert 1 small content</Typography>
|
|
218
|
+
</Box>
|
|
219
|
+
</>
|
|
220
|
+
)
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
id: '2',
|
|
224
|
+
title: 'Alert 2 title',
|
|
225
|
+
'aria-label': 'Alert 2 aria',
|
|
226
|
+
icon: 'YouTube',
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
id: '3',
|
|
230
|
+
title: 'Alert 3 title',
|
|
231
|
+
'aria-label': 'Alert 3 aria',
|
|
232
|
+
icon: 'Mail',
|
|
233
|
+
},
|
|
234
|
+
]
|
|
235
|
+
}}
|
|
236
|
+
>
|
|
237
|
+
{Template.bind({})}
|
|
238
|
+
</Story>
|
|
239
|
+
</Canvas>
|
|
240
|
+
|
|
241
|
+
### Pagination & Navigation
|
|
242
|
+
|
|
243
|
+
<Canvas>
|
|
244
|
+
<Story
|
|
245
|
+
name="Pagination & Navigation"
|
|
246
|
+
args={{
|
|
247
|
+
modules: ['Pagination', 'Navigation'],
|
|
248
|
+
alerts: [
|
|
249
|
+
{
|
|
250
|
+
id: '1',
|
|
251
|
+
title: 'Alert 1 title',
|
|
252
|
+
'aria-label': 'Alert 1 aria',
|
|
253
|
+
icon: 'X',
|
|
254
|
+
content: (
|
|
255
|
+
<>
|
|
256
|
+
<Box>
|
|
257
|
+
<Typography tokens={{ size: 'h4' }}>This is alert 1 large content</Typography>
|
|
258
|
+
</Box>
|
|
259
|
+
<Box>
|
|
260
|
+
<Typography tokens={{ size: 'xs' }}>This is alert 1 small content</Typography>
|
|
261
|
+
</Box>
|
|
262
|
+
</>
|
|
263
|
+
)
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
id: '2',
|
|
267
|
+
title: 'Alert 2 title',
|
|
268
|
+
'aria-label': 'Alert 2 aria',
|
|
269
|
+
icon: 'YouTube',
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
id: '3',
|
|
273
|
+
title: 'Alert 3 title',
|
|
274
|
+
'aria-label': 'Alert 3 aria',
|
|
275
|
+
icon: 'Mail',
|
|
276
|
+
},
|
|
277
|
+
]
|
|
278
|
+
}}
|
|
279
|
+
>
|
|
280
|
+
{Template.bind({})}
|
|
281
|
+
</Story>
|
|
282
|
+
</Canvas>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Ref } from 'react'
|
|
2
|
+
import { forwardRef } from 'react'
|
|
3
|
+
import { ButtonWithForwardRef } from '../../Button'
|
|
4
|
+
import type { TButtonProps } from '../../Button/interface'
|
|
5
|
+
import Icon from '../../Icon'
|
|
6
|
+
import CloseBtn from '../../icons/CloseBtn'
|
|
7
|
+
|
|
8
|
+
const AlertsCloseButton = forwardRef((props: TButtonProps, ref: Ref<HTMLButtonElement & HTMLAnchorElement>) => {
|
|
9
|
+
const { themeName = 'alerts.closeBtn', ...rest } = props
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<ButtonWithForwardRef ref={ref} themeName={themeName} {...rest}>
|
|
13
|
+
<Icon icon={<CloseBtn />} />
|
|
14
|
+
</ButtonWithForwardRef>
|
|
15
|
+
)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
AlertsCloseButton.displayName = 'AlertsCloseButton'
|
|
19
|
+
|
|
20
|
+
export default AlertsCloseButton
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { useSwiperSlide } from 'swiper/react'
|
|
5
|
+
import Box from '../../Box'
|
|
6
|
+
import Button from '../../Button'
|
|
7
|
+
import Icon from '../../Icon'
|
|
8
|
+
import type { TAlertsItemProps } from '../interface'
|
|
9
|
+
|
|
10
|
+
const AlertsItem = (props: TAlertsItemProps) => {
|
|
11
|
+
const { title, button, content, themeName = 'alerts.item', tokens, icon, id } = props
|
|
12
|
+
const { isActive } = useSwiperSlide()
|
|
13
|
+
|
|
14
|
+
if (!title && !button && !content && !icon) return null
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
{icon && <Icon icon={icon} themeName={`${themeName}.icon`} tokens={tokens} />}
|
|
19
|
+
{(title || button || content) && (
|
|
20
|
+
<Box themeName={`${themeName}.container`} tokens={tokens}>
|
|
21
|
+
{title && (
|
|
22
|
+
<Box as="span" themeName={`${themeName}.title`} tokens={tokens} {...{ id }}>
|
|
23
|
+
{title}
|
|
24
|
+
</Box>
|
|
25
|
+
)}
|
|
26
|
+
{button && (
|
|
27
|
+
<Button tabIndex={isActive ? 0 : -1} themeName={`${themeName}.button`} tokens={tokens} {...button} />
|
|
28
|
+
)}
|
|
29
|
+
{content &&
|
|
30
|
+
(React.isValidElement(content)
|
|
31
|
+
? React.cloneElement(content, { ...content.props, themeName: `${themeName}.content`, tokens })
|
|
32
|
+
: content)}
|
|
33
|
+
</Box>
|
|
34
|
+
)}
|
|
35
|
+
</>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default AlertsItem
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Ref } from 'react'
|
|
2
|
+
import { forwardRef } from 'react'
|
|
3
|
+
import { FocusRing, usePress } from 'react-aria'
|
|
4
|
+
import { useAlertsController } from '../../../providers/Alerts'
|
|
5
|
+
import { ButtonWithForwardRef } from '../../Button'
|
|
6
|
+
import type { TButtonProps } from '../../Button/interface'
|
|
7
|
+
import Icon from '../../Icon'
|
|
8
|
+
|
|
9
|
+
type TAlertsNavigationButtonProps = TButtonProps & {
|
|
10
|
+
onSubmit?: () => void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const AlertsNavigationButton = forwardRef(
|
|
14
|
+
(props: TAlertsNavigationButtonProps, ref: Ref<HTMLButtonElement & HTMLAnchorElement>) => {
|
|
15
|
+
const { themeName = 'alerts.navigationBtn', tokens, customTheme, children, onSubmit, ...rest } = props
|
|
16
|
+
const { isDisabled } = rest
|
|
17
|
+
|
|
18
|
+
const { pressProps } = usePress({
|
|
19
|
+
onPress: () => onSubmit?.(),
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<FocusRing within focusRingClass="has-focus-ring">
|
|
24
|
+
<ButtonWithForwardRef
|
|
25
|
+
themeName={themeName}
|
|
26
|
+
tokens={tokens}
|
|
27
|
+
ref={ref}
|
|
28
|
+
{...pressProps}
|
|
29
|
+
{...rest}
|
|
30
|
+
{...{ 'aria-disabled': isDisabled }}
|
|
31
|
+
>
|
|
32
|
+
{children}
|
|
33
|
+
</ButtonWithForwardRef>
|
|
34
|
+
</FocusRing>
|
|
35
|
+
)
|
|
36
|
+
},
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
export const AlertsNextNavigationButton = forwardRef(
|
|
40
|
+
(props: TButtonProps, ref: Ref<HTMLButtonElement & HTMLAnchorElement>) => {
|
|
41
|
+
const { controller } = useAlertsController()
|
|
42
|
+
|
|
43
|
+
const disabled = controller?.activeIndex === (controller?.slides?.length ?? 1) - 1
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<AlertsNavigationButton onSubmit={() => controller?.slideNext()} {...props} ref={ref} isDisabled={disabled}>
|
|
47
|
+
<Icon icon="ArrowRight" />
|
|
48
|
+
</AlertsNavigationButton>
|
|
49
|
+
)
|
|
50
|
+
},
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
export const AlertsPrevNavigationButton = forwardRef(
|
|
54
|
+
(props: TButtonProps, ref: Ref<HTMLButtonElement & HTMLAnchorElement>) => {
|
|
55
|
+
const { controller } = useAlertsController()
|
|
56
|
+
|
|
57
|
+
const disabled = controller?.activeIndex === 0
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<AlertsNavigationButton onSubmit={() => controller?.slidePrev()} {...props} ref={ref} isDisabled={disabled}>
|
|
61
|
+
<Icon icon="ArrowLeft" />
|
|
62
|
+
</AlertsNavigationButton>
|
|
63
|
+
)
|
|
64
|
+
},
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
AlertsNavigationButton.displayName = 'AlertsNavigationButton'
|
|
68
|
+
AlertsNextNavigationButton.displayName = 'AlertsNextNavigationButton'
|
|
69
|
+
AlertsPrevNavigationButton.displayName = 'AlertsPrevNavigationButton'
|
|
70
|
+
|
|
71
|
+
export default AlertsNavigationButton
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { useRef, useState } from 'react'
|
|
2
|
+
import slugify from 'slugify'
|
|
3
|
+
import * as swiperModules from 'swiper/modules'
|
|
4
|
+
import type { SwiperClass } from 'swiper/react'
|
|
5
|
+
import { Swiper, SwiperSlide } from 'swiper/react'
|
|
6
|
+
import { AlertsControllerContextProvider } from '../../../providers/Alerts'
|
|
7
|
+
import useThemeContext from '../../../providers/Theme/hooks'
|
|
8
|
+
import type { TAlertsComponentProps, TAlertsProps } from '../interface'
|
|
9
|
+
import AlertsItem from './AlertsItem'
|
|
10
|
+
import 'swiper/css'
|
|
11
|
+
import 'swiper/css/pagination'
|
|
12
|
+
import { AlertsNextNavigationButton, AlertsPrevNavigationButton } from './AlertsNavigationButton'
|
|
13
|
+
import AlertsPagination from './pagination/AlertsPagination'
|
|
14
|
+
|
|
15
|
+
const AlertsSwiper = (props: TAlertsProps) => {
|
|
16
|
+
const {
|
|
17
|
+
themeName,
|
|
18
|
+
tokens,
|
|
19
|
+
customTheme,
|
|
20
|
+
children = (itemProps) => <AlertsItem {...itemProps} />,
|
|
21
|
+
alerts,
|
|
22
|
+
a11y,
|
|
23
|
+
slidesPerView = 1,
|
|
24
|
+
spaceBetween = 50,
|
|
25
|
+
modules,
|
|
26
|
+
prevButton: PrevButton = AlertsPrevNavigationButton,
|
|
27
|
+
nextButton: NextButton = AlertsNextNavigationButton,
|
|
28
|
+
...rest
|
|
29
|
+
} = props
|
|
30
|
+
const prevButtonRef = useRef(null)
|
|
31
|
+
const nextButtonRef = useRef(null)
|
|
32
|
+
|
|
33
|
+
const {
|
|
34
|
+
itemRoleDescriptionMessage = 'slide',
|
|
35
|
+
slideRole = 'group',
|
|
36
|
+
containerRoleDescriptionMessage = 'carousel',
|
|
37
|
+
paginationGroupLabel = 'pagination',
|
|
38
|
+
} = a11y ?? {}
|
|
39
|
+
|
|
40
|
+
const itemWrapperTheme = useThemeContext(`${themeName}.item.wrapper`, tokens, customTheme)
|
|
41
|
+
const swiperTheme = useThemeContext(`${themeName}.swiper.swiper`, tokens, customTheme)
|
|
42
|
+
const swiperWrapperTheme = useThemeContext(`${themeName}.swiper.wrapper`, tokens, customTheme)
|
|
43
|
+
|
|
44
|
+
const defaultModules: TAlertsComponentProps['modules'] = ['A11y']
|
|
45
|
+
|
|
46
|
+
const importedModules = [...(modules?.filter((module) => module !== 'Pagination') ?? []), ...defaultModules].map(
|
|
47
|
+
(module) => swiperModules[module],
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
const hasNavigation = modules?.includes('Navigation')
|
|
51
|
+
const hasPagination = modules?.includes('Pagination')
|
|
52
|
+
|
|
53
|
+
const [controller, setController] = useState<SwiperClass>()
|
|
54
|
+
const [activeIndex, setActiveIndex] = useState<number>(0)
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<AlertsControllerContextProvider controller={controller}>
|
|
58
|
+
{hasNavigation && (
|
|
59
|
+
<PrevButton
|
|
60
|
+
themeName={`${themeName}.navigation.button`}
|
|
61
|
+
tokens={{ ...tokens, order: 'prev' }}
|
|
62
|
+
ref={prevButtonRef}
|
|
63
|
+
aria-label={a11y?.prevSlideMessage}
|
|
64
|
+
/>
|
|
65
|
+
)}
|
|
66
|
+
{hasNavigation && (
|
|
67
|
+
<NextButton
|
|
68
|
+
themeName={`${themeName}.navigation.button`}
|
|
69
|
+
tokens={{ ...tokens, order: 'next' }}
|
|
70
|
+
ref={nextButtonRef}
|
|
71
|
+
aria-label={a11y?.nextSlideMessage}
|
|
72
|
+
/>
|
|
73
|
+
)}
|
|
74
|
+
{hasPagination && (
|
|
75
|
+
<AlertsPagination
|
|
76
|
+
themeName={`${themeName}.pagination`}
|
|
77
|
+
tokens={tokens}
|
|
78
|
+
activeIndex={activeIndex}
|
|
79
|
+
alerts={alerts}
|
|
80
|
+
paginationGroupLabel={paginationGroupLabel}
|
|
81
|
+
/>
|
|
82
|
+
)}
|
|
83
|
+
<Swiper
|
|
84
|
+
tabIndex={0}
|
|
85
|
+
{...rest}
|
|
86
|
+
onSwiper={(c) => {
|
|
87
|
+
setController(c)
|
|
88
|
+
setActiveIndex(c.activeIndex)
|
|
89
|
+
}}
|
|
90
|
+
onSlideChange={(c) => setActiveIndex(c.activeIndex)}
|
|
91
|
+
role="group"
|
|
92
|
+
aria-roledescription={containerRoleDescriptionMessage ?? undefined}
|
|
93
|
+
slidesPerView={slidesPerView}
|
|
94
|
+
spaceBetween={spaceBetween}
|
|
95
|
+
className={swiperTheme}
|
|
96
|
+
wrapperClass={swiperWrapperTheme}
|
|
97
|
+
modules={importedModules}
|
|
98
|
+
keyboard={{
|
|
99
|
+
enabled: true,
|
|
100
|
+
onlyInViewport: false,
|
|
101
|
+
}}
|
|
102
|
+
a11y={a11y}
|
|
103
|
+
>
|
|
104
|
+
{alerts.map((alert) => {
|
|
105
|
+
const { id, title, ariaLabel } = alert
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<SwiperSlide
|
|
109
|
+
key={id}
|
|
110
|
+
className={itemWrapperTheme}
|
|
111
|
+
{...(title ? { 'aria-labelledby': id } : { 'aria-label': ariaLabel })}
|
|
112
|
+
{...{ id: slugify(`${id}-${title}`) }}
|
|
113
|
+
role={slideRole}
|
|
114
|
+
aria-roledescription={itemRoleDescriptionMessage ?? undefined}
|
|
115
|
+
>
|
|
116
|
+
{children({ ...alert, themeName: `${themeName}.item`, tokens })}
|
|
117
|
+
</SwiperSlide>
|
|
118
|
+
)
|
|
119
|
+
})}
|
|
120
|
+
</Swiper>
|
|
121
|
+
</AlertsControllerContextProvider>
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export default AlertsSwiper
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FocusScope } from 'react-aria'
|
|
2
|
+
import Box from '../../../Box'
|
|
3
|
+
import type { TAlertsPaginationProps } from '../../interface'
|
|
4
|
+
import AlertsPaginationBullet from './AlertsPaginationBullet'
|
|
5
|
+
|
|
6
|
+
const AlertsPagination = (props: TAlertsPaginationProps) => {
|
|
7
|
+
const { themeName, tokens, alerts, activeIndex, paginationGroupLabel } = props
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<Box
|
|
11
|
+
as="div"
|
|
12
|
+
themeName={`${themeName}.wrapper`}
|
|
13
|
+
tokens={tokens}
|
|
14
|
+
{...{ role: 'group', 'aria-label': paginationGroupLabel }}
|
|
15
|
+
>
|
|
16
|
+
<FocusScope>
|
|
17
|
+
{alerts.map((_, index) => (
|
|
18
|
+
<AlertsPaginationBullet
|
|
19
|
+
key={JSON.stringify(_)}
|
|
20
|
+
index={index}
|
|
21
|
+
activeIndex={activeIndex}
|
|
22
|
+
alerts={alerts}
|
|
23
|
+
themeName={themeName}
|
|
24
|
+
tokens={tokens}
|
|
25
|
+
/>
|
|
26
|
+
))}
|
|
27
|
+
</FocusScope>
|
|
28
|
+
</Box>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default AlertsPagination
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useAlertsController } from 'libs/stack/stack-ui/src/providers/Alerts'
|
|
2
|
+
import { useFocusManager, useKeyboard, usePress } from 'react-aria'
|
|
3
|
+
import slugify from 'slugify'
|
|
4
|
+
import Button from '../../../Button'
|
|
5
|
+
import type { TAlertsPaginationBulletProps } from '../../interface'
|
|
6
|
+
|
|
7
|
+
const AlertsPaginationBullet = (props: TAlertsPaginationBulletProps) => {
|
|
8
|
+
const { themeName, tokens, alerts, activeIndex, index } = props
|
|
9
|
+
|
|
10
|
+
const { controller } = useAlertsController()
|
|
11
|
+
|
|
12
|
+
const focusManager = useFocusManager()
|
|
13
|
+
const prevIndex = index === 0 ? alerts.length - 1 : index - 1
|
|
14
|
+
const nextIndex = index === alerts.length - 1 ? 0 : index + 1
|
|
15
|
+
|
|
16
|
+
const { keyboardProps } = useKeyboard({
|
|
17
|
+
onKeyUp: (e) => {
|
|
18
|
+
if (e.key === 'ArrowLeft') {
|
|
19
|
+
e.preventDefault()
|
|
20
|
+
focusManager?.focusPrevious({ wrap: true })
|
|
21
|
+
controller?.slideTo(prevIndex)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (e.key === 'ArrowRight') {
|
|
25
|
+
e.preventDefault()
|
|
26
|
+
focusManager?.focusNext({ wrap: true })
|
|
27
|
+
controller?.slideTo(nextIndex)
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const { pressProps } = usePress({
|
|
33
|
+
onPress: () => controller?.slideTo(index),
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const alert = alerts[index]
|
|
37
|
+
const isActive = index === activeIndex
|
|
38
|
+
const { title, id } = alert
|
|
39
|
+
|
|
40
|
+
const hasTitle = title && title.length > 0
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Button
|
|
44
|
+
as="button"
|
|
45
|
+
{...{
|
|
46
|
+
tabIndex: 0,
|
|
47
|
+
role: 'button',
|
|
48
|
+
'aria-current': isActive ? 'true' : 'false',
|
|
49
|
+
'aria-disabled': isActive,
|
|
50
|
+
'aria-label': !hasTitle ? `${index + 1} / ${alerts.length}` : undefined,
|
|
51
|
+
'aria-labelledby': hasTitle ? slugify(`${id}-${title}`) : undefined,
|
|
52
|
+
}}
|
|
53
|
+
{...keyboardProps}
|
|
54
|
+
{...pressProps}
|
|
55
|
+
themeName={`${themeName}.bullet`}
|
|
56
|
+
tokens={{ ...tokens, active: isActive }}
|
|
57
|
+
/>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default AlertsPaginationBullet
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useRef } from 'react'
|
|
4
|
+
import { useOverlayTriggerState } from 'react-stately'
|
|
5
|
+
import RenderWithOpacity from '../../transitions/RenderWithOpacity'
|
|
6
|
+
import Box from '../Box'
|
|
7
|
+
import useOverlayHook from '../Lightbox/hooks/overlay'
|
|
8
|
+
import AlertsCloseButton from './components/AlertsCloseButton'
|
|
9
|
+
import AlertsSwiper from './components/AlertsSwiper'
|
|
10
|
+
import type { TAlertsProps } from './interface'
|
|
11
|
+
|
|
12
|
+
const Alerts = (props: TAlertsProps) => {
|
|
13
|
+
const {
|
|
14
|
+
themeName = 'alerts',
|
|
15
|
+
tokens,
|
|
16
|
+
customTheme,
|
|
17
|
+
defaultOpen = true,
|
|
18
|
+
closeButton: CloseButton = AlertsCloseButton,
|
|
19
|
+
transitionComponent: TransitionComponent = RenderWithOpacity,
|
|
20
|
+
closeButtonAriaLabel,
|
|
21
|
+
isOpen,
|
|
22
|
+
onOpenChange,
|
|
23
|
+
setOpen,
|
|
24
|
+
...rest
|
|
25
|
+
} = props
|
|
26
|
+
|
|
27
|
+
const triggerRef = useRef(null)
|
|
28
|
+
|
|
29
|
+
const state = useOverlayTriggerState({ ...props, defaultOpen })
|
|
30
|
+
|
|
31
|
+
const { triggerProps, overlayProps } = useOverlayHook({ ...props, type: 'dialog' }, state, triggerRef)
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<TransitionComponent
|
|
35
|
+
{...overlayProps}
|
|
36
|
+
role="alert"
|
|
37
|
+
themeName={`${themeName}.wrapper`}
|
|
38
|
+
tokens={tokens}
|
|
39
|
+
isVisible={state.isOpen}
|
|
40
|
+
>
|
|
41
|
+
<CloseButton
|
|
42
|
+
ref={triggerRef}
|
|
43
|
+
themeName={`${themeName}.closeBtn`}
|
|
44
|
+
aria-label={closeButtonAriaLabel}
|
|
45
|
+
{...triggerProps}
|
|
46
|
+
/>
|
|
47
|
+
<Box themeName={`${themeName}.container`} tokens={tokens}>
|
|
48
|
+
<AlertsSwiper themeName={themeName} tokens={tokens} {...rest} />
|
|
49
|
+
</Box>
|
|
50
|
+
</TransitionComponent>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default Alerts
|