@lumx/react 3.0.7 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{CONTRIBUTING.md → dist/CONTRIBUTING.md} +0 -0
- package/{LICENSE.md → dist/LICENSE.md} +0 -0
- package/dist/README.md +38 -0
- package/{_internal → dist/_internal}/ClickAwayProvider.js +0 -0
- package/{_internal → dist/_internal}/ClickAwayProvider.js.map +0 -0
- package/{_internal → dist/_internal}/types.d.ts +1 -1
- package/{index.d.ts → dist/index.d.ts} +67 -8
- package/{index.js → dist/index.js} +766 -613
- package/dist/index.js.map +1 -0
- package/dist/package.json +117 -0
- package/dist/src/components/alert-dialog/AlertDialog.stories.tsx +196 -0
- package/dist/src/components/alert-dialog/AlertDialog.test.tsx +43 -0
- package/dist/src/components/alert-dialog/AlertDialog.tsx +185 -0
- package/dist/src/components/alert-dialog/__snapshots__/AlertDialog.test.tsx.snap +551 -0
- package/dist/src/components/alert-dialog/index.ts +1 -0
- package/dist/src/components/autocomplete/Autocomplete.stories.tsx +70 -0
- package/dist/src/components/autocomplete/Autocomplete.test.tsx +181 -0
- package/dist/src/components/autocomplete/Autocomplete.tsx +292 -0
- package/dist/src/components/autocomplete/AutocompleteMultiple.stories.tsx +170 -0
- package/dist/src/components/autocomplete/AutocompleteMultiple.test.tsx +94 -0
- package/dist/src/components/autocomplete/AutocompleteMultiple.tsx +156 -0
- package/dist/src/components/autocomplete/__mockData__/index.ts +34 -0
- package/dist/src/components/autocomplete/__snapshots__/Autocomplete.test.tsx.snap +213 -0
- package/dist/src/components/autocomplete/__snapshots__/AutocompleteMultiple.test.tsx.snap +88 -0
- package/dist/src/components/autocomplete/index.ts +2 -0
- package/dist/src/components/avatar/Avatar.stories.tsx +92 -0
- package/dist/src/components/avatar/Avatar.test.tsx +39 -0
- package/dist/src/components/avatar/Avatar.tsx +112 -0
- package/dist/src/components/avatar/__snapshots__/Avatar.test.tsx.snap +681 -0
- package/dist/src/components/avatar/index.ts +1 -0
- package/dist/src/components/badge/Badge.stories.tsx +45 -0
- package/dist/src/components/badge/Badge.test.tsx +91 -0
- package/dist/src/components/badge/Badge.tsx +55 -0
- package/dist/src/components/badge/__snapshots__/Badge.test.tsx.snap +11 -0
- package/dist/src/components/badge/index.ts +1 -0
- package/dist/src/components/button/Button.stories.tsx +156 -0
- package/dist/src/components/button/Button.test.tsx +152 -0
- package/dist/src/components/button/Button.tsx +81 -0
- package/dist/src/components/button/ButtonGroup.test.tsx +66 -0
- package/dist/src/components/button/ButtonGroup.tsx +46 -0
- package/dist/src/components/button/ButtonRoot.test.tsx +203 -0
- package/dist/src/components/button/ButtonRoot.tsx +190 -0
- package/dist/src/components/button/IconButton.test.tsx +103 -0
- package/dist/src/components/button/IconButton.tsx +80 -0
- package/dist/src/components/button/__snapshots__/Button.test.tsx.snap +96 -0
- package/dist/src/components/button/__snapshots__/ButtonGroup.test.tsx.snap +22 -0
- package/dist/src/components/button/__snapshots__/ButtonRoot.test.tsx.snap +160 -0
- package/dist/src/components/button/__snapshots__/IconButton.test.tsx.snap +83 -0
- package/dist/src/components/button/index.ts +4 -0
- package/dist/src/components/checkbox/Checkbox.stories.tsx +37 -0
- package/dist/src/components/checkbox/Checkbox.test.tsx +114 -0
- package/dist/src/components/checkbox/Checkbox.tsx +145 -0
- package/dist/src/components/checkbox/__snapshots__/Checkbox.test.tsx.snap +141 -0
- package/dist/src/components/checkbox/index.ts +1 -0
- package/dist/src/components/chip/Chip.stories.tsx +21 -0
- package/dist/src/components/chip/Chip.test.tsx +199 -0
- package/dist/src/components/chip/Chip.tsx +154 -0
- package/dist/src/components/chip/ChipGroup.test.tsx +29 -0
- package/dist/src/components/chip/ChipGroup.tsx +62 -0
- package/dist/src/components/chip/__snapshots__/Chip.test.tsx.snap +12 -0
- package/dist/src/components/chip/__snapshots__/ChipGroup.test.tsx.snap +29 -0
- package/dist/src/components/chip/index.ts +2 -0
- package/dist/src/components/comment-block/CommentBlock.stories.tsx +30 -0
- package/dist/src/components/comment-block/CommentBlock.test.tsx +28 -0
- package/dist/src/components/comment-block/CommentBlock.tsx +174 -0
- package/dist/src/components/comment-block/__snapshots__/CommentBlock.test.tsx.snap +92 -0
- package/dist/src/components/comment-block/index.ts +1 -0
- package/dist/src/components/date-picker/DatePicker.test.tsx +41 -0
- package/dist/src/components/date-picker/DatePicker.tsx +56 -0
- package/dist/src/components/date-picker/DatePickerControlled.test.tsx +44 -0
- package/dist/src/components/date-picker/DatePickerControlled.tsx +128 -0
- package/dist/src/components/date-picker/DatePickerField.stories.tsx +93 -0
- package/dist/src/components/date-picker/DatePickerField.test.tsx +47 -0
- package/dist/src/components/date-picker/DatePickerField.tsx +141 -0
- package/dist/src/components/date-picker/__snapshots__/DatePicker.test.tsx.snap +22 -0
- package/dist/src/components/date-picker/__snapshots__/DatePickerControlled.test.tsx.snap +597 -0
- package/dist/src/components/date-picker/__snapshots__/DatePickerField.test.tsx.snap +43 -0
- package/dist/src/components/date-picker/constants.ts +11 -0
- package/dist/src/components/date-picker/index.ts +4 -0
- package/dist/src/components/date-picker/types.ts +28 -0
- package/dist/src/components/dialog/Dialog.stories.tsx +426 -0
- package/dist/src/components/dialog/Dialog.test.tsx +93 -0
- package/dist/src/components/dialog/Dialog.tsx +263 -0
- package/dist/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +960 -0
- package/dist/src/components/dialog/index.ts +1 -0
- package/dist/src/components/divider/Divider.test.tsx +93 -0
- package/dist/src/components/divider/Divider.tsx +51 -0
- package/dist/src/components/divider/__snapshots__/Divider.test.tsx.snap +9 -0
- package/dist/src/components/divider/index.ts +1 -0
- package/dist/src/components/drag-handle/DragHandle.tsx +50 -0
- package/dist/src/components/drag-handle/index.ts +1 -0
- package/dist/src/components/dropdown/Dropdown.stories.tsx +216 -0
- package/dist/src/components/dropdown/Dropdown.test.tsx +97 -0
- package/dist/src/components/dropdown/Dropdown.tsx +184 -0
- package/dist/src/components/dropdown/__snapshots__/Dropdown.test.tsx.snap +35 -0
- package/dist/src/components/dropdown/index.ts +1 -0
- package/dist/src/components/expansion-panel/ExpansionPanel.test.tsx +116 -0
- package/dist/src/components/expansion-panel/ExpansionPanel.tsx +170 -0
- package/dist/src/components/expansion-panel/index.ts +1 -0
- package/dist/src/components/flag/Flag.stories.tsx +23 -0
- package/dist/src/components/flag/Flag.test.tsx +86 -0
- package/dist/src/components/flag/Flag.tsx +47 -0
- package/dist/src/components/flag/__snapshots__/Flag.test.tsx.snap +133 -0
- package/dist/src/components/flag/index.ts +1 -0
- package/dist/src/components/flex-box/FlexBox.stories.tsx +245 -0
- package/dist/src/components/flex-box/FlexBox.test.tsx +65 -0
- package/dist/src/components/flex-box/FlexBox.tsx +98 -0
- package/dist/src/components/flex-box/__snapshots__/FlexBox.test.tsx.snap +492 -0
- package/dist/src/components/flex-box/index.ts +1 -0
- package/dist/src/components/generic-block/GenericBlock.stories.jsx +128 -0
- package/dist/src/components/generic-block/GenericBlock.test.tsx +152 -0
- package/dist/src/components/generic-block/GenericBlock.tsx +222 -0
- package/dist/src/components/generic-block/constants.ts +9 -0
- package/dist/src/components/generic-block/index.ts +2 -0
- package/dist/src/components/grid/Grid.tsx +73 -0
- package/dist/src/components/grid/GridItem.tsx +54 -0
- package/dist/src/components/grid/index.ts +2 -0
- package/dist/src/components/grid-column/GridColumn.stories.jsx +56 -0
- package/dist/src/components/grid-column/GridColumn.test.jsx +58 -0
- package/dist/src/components/grid-column/GridColumn.tsx +90 -0
- package/dist/src/components/grid-column/index.ts +1 -0
- package/dist/src/components/heading/Heading.stories.tsx +108 -0
- package/dist/src/components/heading/Heading.test.tsx +82 -0
- package/dist/src/components/heading/Heading.tsx +63 -0
- package/dist/src/components/heading/HeadingLevelProvider.tsx +30 -0
- package/dist/src/components/heading/constants.ts +16 -0
- package/dist/src/components/heading/context.tsx +13 -0
- package/dist/src/components/heading/index.ts +3 -0
- package/dist/src/components/heading/useHeadingLevel.tsx +8 -0
- package/dist/src/components/icon/Icon.stories.tsx +76 -0
- package/dist/src/components/icon/Icon.test.tsx +102 -0
- package/dist/src/components/icon/Icon.tsx +121 -0
- package/dist/src/components/icon/__snapshots__/Icon.test.tsx.snap +49 -0
- package/dist/src/components/icon/index.ts +1 -0
- package/dist/src/components/image-block/ImageBlock.stories.tsx +52 -0
- package/dist/src/components/image-block/ImageBlock.test.tsx +28 -0
- package/dist/src/components/image-block/ImageBlock.tsx +151 -0
- package/dist/src/components/image-block/__snapshots__/ImageBlock.test.tsx.snap +64 -0
- package/dist/src/components/image-block/index.ts +1 -0
- package/dist/src/components/index.ts +176 -0
- package/dist/src/components/inline-list/InlineList.stories.tsx +40 -0
- package/dist/src/components/inline-list/InlineList.test.tsx +41 -0
- package/dist/src/components/inline-list/InlineList.tsx +82 -0
- package/dist/src/components/inline-list/index.ts +1 -0
- package/dist/src/components/input-helper/InputHelper.stories.tsx +29 -0
- package/dist/src/components/input-helper/InputHelper.test.tsx +107 -0
- package/dist/src/components/input-helper/InputHelper.tsx +61 -0
- package/dist/src/components/input-helper/__snapshots__/InputHelper.test.tsx.snap +9 -0
- package/dist/src/components/input-helper/constants.ts +11 -0
- package/dist/src/components/input-helper/index.ts +1 -0
- package/dist/src/components/input-label/InputLabel.stories.tsx +15 -0
- package/dist/src/components/input-label/InputLabel.test.tsx +86 -0
- package/dist/src/components/input-label/InputLabel.tsx +59 -0
- package/dist/src/components/input-label/__snapshots__/InputLabel.test.tsx.snap +10 -0
- package/dist/src/components/input-label/index.ts +1 -0
- package/dist/src/components/lightbox/Lightbox.stories.tsx +83 -0
- package/dist/src/components/lightbox/Lightbox.test.tsx +30 -0
- package/dist/src/components/lightbox/Lightbox.tsx +153 -0
- package/dist/src/components/lightbox/__snapshots__/Lightbox.test.tsx.snap +194 -0
- package/dist/src/components/lightbox/index.ts +1 -0
- package/dist/src/components/link/Link.stories.tsx +141 -0
- package/dist/src/components/link/Link.test.tsx +60 -0
- package/dist/src/components/link/Link.tsx +156 -0
- package/dist/src/components/link/__snapshots__/Link.test.tsx.snap +29 -0
- package/dist/src/components/link/index.ts +1 -0
- package/dist/src/components/link-preview/LinkPreview.stories.tsx +88 -0
- package/dist/src/components/link-preview/LinkPreview.test.tsx +102 -0
- package/dist/src/components/link-preview/LinkPreview.tsx +158 -0
- package/dist/src/components/link-preview/index.ts +1 -0
- package/dist/src/components/list/List.stories.tsx +141 -0
- package/dist/src/components/list/List.test.tsx +29 -0
- package/dist/src/components/list/List.tsx +94 -0
- package/dist/src/components/list/ListDivider.stories.tsx +7 -0
- package/dist/src/components/list/ListDivider.test.tsx +29 -0
- package/dist/src/components/list/ListDivider.tsx +42 -0
- package/dist/src/components/list/ListItem.stories.tsx +62 -0
- package/{src/components/progress/Progress.test.tsx → dist/src/components/list/ListItem.test.tsx} +8 -7
- package/dist/src/components/list/ListItem.tsx +154 -0
- package/dist/src/components/list/ListSubheader.stories.tsx +8 -0
- package/dist/src/components/list/ListSubheader.test.tsx +29 -0
- package/dist/src/components/list/ListSubheader.tsx +43 -0
- package/dist/src/components/list/__snapshots__/List.test.tsx.snap +360 -0
- package/dist/src/components/list/__snapshots__/ListDivider.test.tsx.snap +7 -0
- package/dist/src/components/list/__snapshots__/ListItem.test.tsx.snap +160 -0
- package/dist/src/components/list/__snapshots__/ListSubheader.test.tsx.snap +9 -0
- package/dist/src/components/list/index.ts +4 -0
- package/dist/src/components/list/useInteractiveList.tsx +202 -0
- package/dist/src/components/message/Message.stories.tsx +27 -0
- package/dist/src/components/message/Message.test.tsx +76 -0
- package/dist/src/components/message/Message.tsx +74 -0
- package/dist/src/components/message/__snapshots__/Message.test.tsx.snap +15 -0
- package/dist/src/components/message/index.ts +1 -0
- package/dist/src/components/mosaic/Mosaic.stories.tsx +85 -0
- package/dist/src/components/mosaic/Mosaic.test.tsx +120 -0
- package/dist/src/components/mosaic/Mosaic.tsx +95 -0
- package/dist/src/components/mosaic/__snapshots__/Mosaic.test.tsx.snap +357 -0
- package/dist/src/components/mosaic/index.ts +1 -0
- package/dist/src/components/notification/Notification.test.tsx +108 -0
- package/dist/src/components/notification/Notification.tsx +130 -0
- package/dist/src/components/notification/Notifications.stories.tsx +77 -0
- package/dist/src/components/notification/__snapshots__/Notification.test.tsx.snap +34 -0
- package/dist/src/components/notification/constants.ts +28 -0
- package/dist/src/components/notification/index.ts +1 -0
- package/dist/src/components/popover/Popover.stories.tsx +386 -0
- package/dist/src/components/popover/Popover.test.tsx +30 -0
- package/dist/src/components/popover/Popover.tsx +382 -0
- package/dist/src/components/popover/__snapshots__/Popover.test.tsx.snap +343 -0
- package/dist/src/components/popover/index.ts +1 -0
- package/dist/src/components/popover-dialog/PopoverDialog.stories.tsx +75 -0
- package/dist/src/components/popover-dialog/PopoverDialog.test.tsx +65 -0
- package/dist/src/components/popover-dialog/PopoverDialog.tsx +65 -0
- package/dist/src/components/popover-dialog/index.tsx +1 -0
- package/dist/src/components/post-block/PostBlock.test.tsx +28 -0
- package/dist/src/components/post-block/PostBlock.tsx +123 -0
- package/dist/src/components/post-block/__snapshots__/PostBlock.test.tsx.snap +139 -0
- package/dist/src/components/post-block/index.ts +1 -0
- package/dist/src/components/progress/Progress.tsx +68 -0
- package/dist/src/components/progress/ProgressCircular.stories.tsx +18 -0
- package/dist/src/components/progress/ProgressCircular.test.tsx +49 -0
- package/dist/src/components/progress/ProgressCircular.tsx +68 -0
- package/dist/src/components/progress/ProgressLinear.stories.tsx +8 -0
- package/dist/src/components/progress/ProgressLinear.test.tsx +37 -0
- package/dist/src/components/progress/ProgressLinear.tsx +52 -0
- package/dist/src/components/progress/index.ts +3 -0
- package/dist/src/components/progress-tracker/ProgressTracker.stories.tsx +145 -0
- package/dist/src/components/progress-tracker/ProgressTracker.test.tsx +57 -0
- package/dist/src/components/progress-tracker/ProgressTracker.tsx +89 -0
- package/dist/src/components/progress-tracker/ProgressTrackerProvider.test.tsx +42 -0
- package/dist/src/components/progress-tracker/ProgressTrackerProvider.tsx +66 -0
- package/dist/src/components/progress-tracker/ProgressTrackerStep.test.tsx +128 -0
- package/dist/src/components/progress-tracker/ProgressTrackerStep.tsx +159 -0
- package/dist/src/components/progress-tracker/ProgressTrackerStepPanel.test.tsx +73 -0
- package/dist/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +67 -0
- package/dist/src/components/progress-tracker/__snapshots__/ProgressTracker.test.tsx.snap +41 -0
- package/dist/src/components/progress-tracker/__snapshots__/ProgressTrackerStep.test.tsx.snap +141 -0
- package/dist/src/components/progress-tracker/__snapshots__/ProgressTrackerStepPanel.test.tsx.snap +25 -0
- package/dist/src/components/progress-tracker/index.ts +4 -0
- package/dist/src/components/radio-button/RadioButton.stories.tsx +28 -0
- package/dist/src/components/radio-button/RadioButton.test.tsx +123 -0
- package/dist/src/components/radio-button/RadioButton.tsx +141 -0
- package/dist/src/components/radio-button/RadioGroup.stories.tsx +42 -0
- package/dist/src/components/radio-button/RadioGroup.test.tsx +77 -0
- package/dist/src/components/radio-button/RadioGroup.tsx +52 -0
- package/dist/src/components/radio-button/__snapshots__/RadioButton.test.tsx.snap +113 -0
- package/dist/src/components/radio-button/__snapshots__/RadioGroup.test.tsx.snap +26 -0
- package/dist/src/components/radio-button/index.ts +2 -0
- package/dist/src/components/select/Select.stories.tsx +399 -0
- package/dist/src/components/select/Select.test.tsx +359 -0
- package/dist/src/components/select/Select.tsx +193 -0
- package/dist/src/components/select/SelectMultiple.stories.tsx +227 -0
- package/dist/src/components/select/SelectMultiple.test.tsx +405 -0
- package/dist/src/components/select/SelectMultiple.tsx +198 -0
- package/dist/src/components/select/WithSelectContext.tsx +143 -0
- package/dist/src/components/select/__snapshots__/Select.test.tsx.snap +43 -0
- package/dist/src/components/select/__snapshots__/SelectMultiple.test.tsx.snap +87 -0
- package/dist/src/components/select/constants.ts +53 -0
- package/dist/src/components/select/index.ts +2 -0
- package/dist/src/components/side-navigation/SideNavigation.stories.tsx +191 -0
- package/dist/src/components/side-navigation/SideNavigation.test.tsx +52 -0
- package/dist/src/components/side-navigation/SideNavigation.tsx +54 -0
- package/dist/src/components/side-navigation/SideNavigationItem.test.tsx +175 -0
- package/dist/src/components/side-navigation/SideNavigationItem.tsx +162 -0
- package/dist/src/components/side-navigation/__snapshots__/SideNavigation.test.tsx.snap +7 -0
- package/dist/src/components/side-navigation/__snapshots__/SideNavigationItem.test.tsx.snap +30 -0
- package/dist/src/components/side-navigation/index.ts +2 -0
- package/dist/src/components/skeleton/SkeletonCircle.stories.tsx +25 -0
- package/dist/src/components/skeleton/SkeletonCircle.test.tsx +28 -0
- package/dist/src/components/skeleton/SkeletonCircle.tsx +52 -0
- package/dist/src/components/skeleton/SkeletonRectangle.stories.tsx +107 -0
- package/dist/src/components/skeleton/SkeletonRectangle.test.tsx +28 -0
- package/dist/src/components/skeleton/SkeletonRectangle.tsx +78 -0
- package/dist/src/components/skeleton/SkeletonTypography.stories.tsx +26 -0
- package/dist/src/components/skeleton/SkeletonTypography.test.tsx +28 -0
- package/dist/src/components/skeleton/SkeletonTypography.tsx +57 -0
- package/dist/src/components/skeleton/__snapshots__/SkeletonCircle.test.tsx.snap +54 -0
- package/dist/src/components/skeleton/__snapshots__/SkeletonRectangle.test.tsx.snap +177 -0
- package/dist/src/components/skeleton/__snapshots__/SkeletonTypography.test.tsx.snap +174 -0
- package/dist/src/components/skeleton/index.ts +3 -0
- package/dist/src/components/slider/Slider.stories.tsx +29 -0
- package/dist/src/components/slider/Slider.test.tsx +31 -0
- package/dist/src/components/slider/Slider.tsx +299 -0
- package/dist/src/components/slider/__snapshots__/Slider.test.tsx.snap +122 -0
- package/dist/src/components/slider/index.ts +2 -0
- package/dist/src/components/slideshow/Slides.tsx +124 -0
- package/dist/src/components/slideshow/Slideshow.stories.tsx +212 -0
- package/dist/src/components/slideshow/Slideshow.test.tsx +39 -0
- package/dist/src/components/slideshow/Slideshow.tsx +170 -0
- package/dist/src/components/slideshow/SlideshowControls.stories.tsx +112 -0
- package/dist/src/components/slideshow/SlideshowControls.tsx +241 -0
- package/dist/src/components/slideshow/SlideshowItem.tsx +52 -0
- package/dist/src/components/slideshow/SlideshowItemGroup.tsx +64 -0
- package/dist/src/components/slideshow/__snapshots__/Slideshow.test.tsx.snap +157 -0
- package/dist/src/components/slideshow/constants.ts +24 -0
- package/dist/src/components/slideshow/index.ts +4 -0
- package/dist/src/components/slideshow/useKeyNavigate.ts +28 -0
- package/dist/src/components/slideshow/usePaginationVisibleRange.ts +37 -0
- package/dist/src/components/slideshow/useSlideFocusManagement.tsx +92 -0
- package/dist/src/components/slideshow/useSwipeNavigate.ts +18 -0
- package/dist/src/components/switch/Switch.stories.tsx +36 -0
- package/dist/src/components/switch/Switch.test.tsx +189 -0
- package/dist/src/components/switch/Switch.tsx +141 -0
- package/dist/src/components/switch/__snapshots__/Switch.test.tsx.snap +179 -0
- package/dist/src/components/switch/index.ts +1 -0
- package/dist/src/components/table/Table.test.tsx +28 -0
- package/dist/src/components/table/Table.tsx +59 -0
- package/dist/src/components/table/TableBody.test.tsx +22 -0
- package/dist/src/components/table/TableBody.tsx +44 -0
- package/dist/src/components/table/TableCell.test.tsx +23 -0
- package/dist/src/components/table/TableCell.tsx +125 -0
- package/dist/src/components/table/TableHeader.test.tsx +22 -0
- package/dist/src/components/table/TableHeader.tsx +50 -0
- package/dist/src/components/table/TableRow.test.tsx +22 -0
- package/dist/src/components/table/TableRow.tsx +68 -0
- package/dist/src/components/table/__snapshots__/Table.test.tsx.snap +263 -0
- package/dist/src/components/table/index.ts +5 -0
- package/dist/src/components/tabs/Tab.test.tsx +116 -0
- package/dist/src/components/tabs/Tab.tsx +120 -0
- package/dist/src/components/tabs/TabList.test.tsx +80 -0
- package/dist/src/components/tabs/TabList.tsx +82 -0
- package/dist/src/components/tabs/TabPanel.test.tsx +74 -0
- package/dist/src/components/tabs/TabPanel.tsx +65 -0
- package/dist/src/components/tabs/TabProvider.test.tsx +42 -0
- package/dist/src/components/tabs/TabProvider.tsx +59 -0
- package/dist/src/components/tabs/Tabs.stories.tsx +134 -0
- package/dist/src/components/tabs/__snapshots__/Tab.test.tsx.snap +62 -0
- package/dist/src/components/tabs/__snapshots__/TabList.test.tsx.snap +22 -0
- package/dist/src/components/tabs/__snapshots__/TabPanel.test.tsx.snap +25 -0
- package/dist/src/components/tabs/index.ts +4 -0
- package/dist/src/components/tabs/state.ts +116 -0
- package/dist/src/components/tabs/test.mocks.ts +33 -0
- package/dist/src/components/text/Text.stories.jsx +75 -0
- package/dist/src/components/text/Text.test.tsx +108 -0
- package/dist/src/components/text/Text.tsx +121 -0
- package/dist/src/components/text/index.ts +1 -0
- package/dist/src/components/text-field/TextField.stories.tsx +169 -0
- package/dist/src/components/text-field/TextField.test.tsx +171 -0
- package/dist/src/components/text-field/TextField.tsx +432 -0
- package/dist/src/components/text-field/__snapshots__/TextField.test.tsx.snap +42 -0
- package/dist/src/components/text-field/index.ts +1 -0
- package/dist/src/components/thumbnail/Thumbnail.stories.tsx +510 -0
- package/dist/src/components/thumbnail/Thumbnail.test.tsx +46 -0
- package/dist/src/components/thumbnail/Thumbnail.tsx +222 -0
- package/dist/src/components/thumbnail/__snapshots__/Thumbnail.test.tsx.snap +130 -0
- package/dist/src/components/thumbnail/index.ts +3 -0
- package/dist/src/components/thumbnail/types.ts +39 -0
- package/dist/src/components/thumbnail/useFocusPointStyle.test.ts +92 -0
- package/dist/src/components/thumbnail/useFocusPointStyle.tsx +111 -0
- package/dist/src/components/thumbnail/useImageLoad.ts +40 -0
- package/dist/src/components/toolbar/Toolbar.tsx +67 -0
- package/dist/src/components/toolbar/index.ts +1 -0
- package/dist/src/components/tooltip/Tooltip.stories.tsx +172 -0
- package/dist/src/components/tooltip/Tooltip.test.tsx +105 -0
- package/dist/src/components/tooltip/Tooltip.tsx +122 -0
- package/dist/src/components/tooltip/__snapshots__/Tooltip.test.tsx.snap +233 -0
- package/dist/src/components/tooltip/index.ts +1 -0
- package/dist/src/components/tooltip/useInjectTooltipRef.tsx +44 -0
- package/dist/src/components/tooltip/useTooltipOpen.tsx +113 -0
- package/dist/src/components/uploader/Uploader.test.tsx +87 -0
- package/dist/src/components/uploader/Uploader.tsx +105 -0
- package/dist/src/components/uploader/__snapshots__/Uploader.test.tsx.snap +14 -0
- package/dist/src/components/uploader/index.ts +1 -0
- package/dist/src/components/user-block/UserBlock.stories.tsx +76 -0
- package/dist/src/components/user-block/UserBlock.test.tsx +38 -0
- package/dist/src/components/user-block/UserBlock.tsx +179 -0
- package/dist/src/components/user-block/__snapshots__/UserBlock.test.tsx.snap +362 -0
- package/dist/src/components/user-block/index.ts +1 -0
- package/dist/src/constants.ts +17 -0
- package/dist/src/hooks/useBooleanState.tsx +13 -0
- package/dist/src/hooks/useCallbackOnEscape.ts +34 -0
- package/dist/src/hooks/useChipGroupNavigation.tsx +75 -0
- package/dist/src/hooks/useClickAway.tsx +47 -0
- package/dist/src/hooks/useDisableBodyScroll.ts +28 -0
- package/dist/src/hooks/useEventCallback.tsx +17 -0
- package/dist/src/hooks/useFocus.tsx +21 -0
- package/dist/src/hooks/useFocusTrap.ts +85 -0
- package/dist/src/hooks/useFocusWithin.ts +33 -0
- package/dist/src/hooks/useInfiniteScroll.tsx +60 -0
- package/dist/src/hooks/useIntersectionObserver.tsx +43 -0
- package/dist/src/hooks/useInterval.tsx +31 -0
- package/dist/src/hooks/useKeyboardListNavigation.tsx +204 -0
- package/dist/src/hooks/useListenFocus.tsx +26 -0
- package/dist/src/hooks/useOnResize.ts +41 -0
- package/dist/src/hooks/useRovingTabIndex.tsx +90 -0
- package/dist/src/hooks/useSlideshowControls.ts +243 -0
- package/dist/src/hooks/useStopPropagation.ts +21 -0
- package/dist/src/hooks/useTransitionVisibility.ts +54 -0
- package/dist/src/index.ts +58 -0
- package/dist/src/stories/chromaticForceScreenSize.tsx +7 -0
- package/dist/src/stories/generated/Autocomplete/Demos.stories.tsx +7 -0
- package/dist/src/stories/generated/Avatar/Demos.stories.tsx +7 -0
- package/dist/src/stories/generated/Badge/Demos.stories.tsx +9 -0
- package/dist/src/stories/generated/Button/Demos.stories.tsx +11 -0
- package/dist/src/stories/generated/Checkbox/Demos.stories.tsx +6 -0
- package/dist/src/stories/generated/Chip/Demos.stories.tsx +11 -0
- package/dist/src/stories/generated/CommentBlock/Demos.stories.tsx +8 -0
- package/dist/src/stories/generated/DatePicker/Demos.stories.tsx +8 -0
- package/dist/src/stories/generated/Dialog/Demos.stories.tsx +10 -0
- package/dist/src/stories/generated/Divider/Demos.stories.tsx +6 -0
- package/dist/src/stories/generated/Dropdown/Demos.stories.tsx +8 -0
- package/dist/src/stories/generated/ExpansionPanel/Demos.stories.tsx +9 -0
- package/dist/src/stories/generated/Flag/Demos.stories.tsx +6 -0
- package/dist/src/stories/generated/GenericBlock/Demos.stories.tsx +8 -0
- package/dist/src/stories/generated/Heading/Demos.stories.tsx +6 -0
- package/dist/src/stories/generated/Icon/Demos.stories.tsx +8 -0
- package/dist/src/stories/generated/ImageBlock/Demos.stories.tsx +9 -0
- package/dist/src/stories/generated/Lightbox/Demos.stories.tsx +6 -0
- package/dist/src/stories/generated/Link/Demos.stories.tsx +8 -0
- package/dist/src/stories/generated/LinkPreview/Demos.stories.tsx +7 -0
- package/dist/src/stories/generated/List/Demos.stories.tsx +11 -0
- package/dist/src/stories/generated/Message/Demos.stories.tsx +10 -0
- package/dist/src/stories/generated/Mosaic/Demos.stories.tsx +9 -0
- package/dist/src/stories/generated/Notification/Demos.stories.tsx +6 -0
- package/dist/src/stories/generated/Popover/Demos.stories.tsx +11 -0
- package/dist/src/stories/generated/PopoverDialog/Demos.stories.tsx +6 -0
- package/dist/src/stories/generated/PostBlock/Demos.stories.tsx +6 -0
- package/dist/src/stories/generated/Progress/Demos.stories.tsx +7 -0
- package/dist/src/stories/generated/ProgressTracker/Demos.stories.tsx +9 -0
- package/dist/src/stories/generated/RadioButton/Demos.stories.tsx +6 -0
- package/dist/src/stories/generated/Select/Demos.stories.tsx +14 -0
- package/dist/src/stories/generated/SideNavigation/Demos.stories.tsx +10 -0
- package/dist/src/stories/generated/Skeleton/Demos.stories.tsx +9 -0
- package/dist/src/stories/generated/Slider/Demos.stories.tsx +9 -0
- package/dist/src/stories/generated/Slideshow/Demos.stories.tsx +8 -0
- package/dist/src/stories/generated/Switch/Demos.stories.tsx +6 -0
- package/dist/src/stories/generated/Table/Demos.stories.tsx +6 -0
- package/dist/src/stories/generated/Tabs/Demos.stories.tsx +8 -0
- package/dist/src/stories/generated/TextField/Demos.stories.tsx +19 -0
- package/dist/src/stories/generated/Thumbnail/Demos.stories.tsx +12 -0
- package/dist/src/stories/generated/Toolbar/Demos.stories.tsx +10 -0
- package/dist/src/stories/generated/Tooltip/Demos.stories.tsx +8 -0
- package/dist/src/stories/generated/Uploader/Demos.stories.tsx +8 -0
- package/dist/src/stories/generated/UserBlock/Demos.stories.tsx +10 -0
- package/dist/src/stories/knobs/buttonKnob.ts +9 -0
- package/dist/src/stories/knobs/emphasisKnob.ts +8 -0
- package/dist/src/stories/knobs/enumKnob.ts +14 -0
- package/dist/src/stories/knobs/focusKnob.ts +3 -0
- package/dist/src/stories/knobs/image.ts +69 -0
- package/dist/src/stories/knobs/lorem.ts +59 -0
- package/dist/src/stories/knobs/sizeKnob.ts +5 -0
- package/dist/src/stories/knobs/thumbnailsKnob.ts +9 -0
- package/dist/src/stories/utils/CustomLink.tsx +7 -0
- package/dist/src/stories/withResizableBox.tsx +18 -0
- package/dist/src/testing/utils/commonTestsSuite.ts +71 -0
- package/dist/src/testing/utils/commonTestsSuiteRTL.ts +55 -0
- package/dist/src/testing/utils/index.ts +4 -0
- package/dist/src/testing/utils/itShouldRenderStories.tsx +103 -0
- package/dist/src/testing/utils/queries.ts +19 -0
- package/dist/src/untypped-modules.d.ts +7 -0
- package/dist/src/utils/ClickAwayProvider/ClickAwayProvider.stories.jsx +58 -0
- package/dist/src/utils/ClickAwayProvider/ClickAwayProvider.tsx +65 -0
- package/dist/src/utils/ClickAwayProvider/index.ts +1 -0
- package/dist/src/utils/MaterialThemeSwitcher/MaterialThemeSwitcher.tsx +54 -0
- package/dist/src/utils/MaterialThemeSwitcher/index.ts +1 -0
- package/dist/src/utils/browserDoesNotSupportHover.test.js +24 -0
- package/dist/src/utils/browserDoesNotSupportHover.ts +2 -0
- package/dist/src/utils/clamp.ts +17 -0
- package/dist/src/utils/className.ts +44 -0
- package/dist/src/utils/event.ts +1 -0
- package/dist/src/utils/flattenChildren.test.tsx +58 -0
- package/dist/src/utils/flattenChildren.ts +27 -0
- package/dist/src/utils/focus/constants.ts +5 -0
- package/dist/src/utils/focus/getFirstAndLastFocusable.test.ts +134 -0
- package/dist/src/utils/focus/getFirstAndLastFocusable.ts +21 -0
- package/dist/src/utils/focus/getFocusableElements.test.ts +151 -0
- package/dist/src/utils/focus/getFocusableElements.ts +7 -0
- package/dist/src/utils/index.ts +5 -0
- package/dist/src/utils/isInternetExplorer.ts +15 -0
- package/dist/src/utils/makeListenerTowerContext.ts +32 -0
- package/dist/src/utils/mergeRefs.ts +22 -0
- package/dist/src/utils/partitionMulti.ts +28 -0
- package/dist/src/utils/renderLink.tsx +17 -0
- package/dist/src/utils/type.ts +113 -0
- package/dist/src/utils/userHasReducedMotion.ts +7 -0
- package/dist/src/utils/utils.test.ts +48 -0
- package/{utils → dist/utils}/index.d.ts +0 -0
- package/{utils → dist/utils}/index.js +0 -0
- package/{utils → dist/utils}/index.js.map +0 -0
- package/jest/__mocks__/@storybook/addon-actions.js +3 -0
- package/jest/__mocks__/@storybook/addon-knobs.js +6 -0
- package/jest/__mocks__/emptyFileMockTransformer.js +8 -0
- package/jest/__mocks__/emptyModuleMock.js +1 -0
- package/jest/configure.js +6 -0
- package/jest/index.js +36 -0
- package/jest/transform.js +6 -0
- package/package.json +3 -5
- package/rollup.config.js +98 -0
- package/src/components/badge/Badge.tsx +2 -2
- package/src/components/button/ButtonRoot.tsx +2 -2
- package/src/components/chip/Chip.tsx +2 -2
- package/src/components/grid-column/GridColumn.stories.jsx +56 -0
- package/src/components/grid-column/GridColumn.test.jsx +58 -0
- package/src/components/grid-column/GridColumn.tsx +90 -0
- package/src/components/grid-column/index.ts +1 -0
- package/src/components/icon/Icon.tsx +2 -2
- package/src/components/link/Link.tsx +2 -2
- package/src/components/progress/Progress.tsx +6 -25
- package/src/components/progress/ProgressCircular.stories.tsx +18 -0
- package/src/components/progress/ProgressCircular.test.tsx +49 -0
- package/src/components/progress/ProgressCircular.tsx +68 -0
- package/src/components/progress/ProgressLinear.stories.tsx +8 -0
- package/src/components/progress/ProgressLinear.test.tsx +37 -0
- package/src/components/progress/ProgressLinear.tsx +52 -0
- package/src/components/progress/index.ts +2 -0
- package/src/index.ts +1 -0
- package/storybook/build +4 -0
- package/storybook/generate-demo-stories.js +59 -0
- package/storybook/main.js +67 -0
- package/storybook/package.json +13 -0
- package/storybook/preview.js +11 -0
- package/storybook/start +4 -0
- package/storybook/story-block/StoryBlock.tsx +49 -0
- package/storybook/story-block/decorator.jsx +7 -0
- package/storybook/story-block/index.scss +27 -0
- package/storybook/yarn.lock +13192 -0
- package/tsconfig.json +3 -0
- package/index.js.map +0 -1
- package/src/components/progress/__snapshots__/Progress.test.tsx.snap +0 -48
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import React, { Children, CSSProperties, forwardRef } from 'react';
|
|
2
|
+
import chunk from 'lodash/chunk';
|
|
3
|
+
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
|
|
6
|
+
import { FULL_WIDTH_PERCENT } from '@lumx/react/components/slideshow/constants';
|
|
7
|
+
import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
8
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
9
|
+
import { buildSlideShowGroupId, SlideshowItemGroup } from './SlideshowItemGroup';
|
|
10
|
+
|
|
11
|
+
export interface SlidesProps extends GenericProps, HasTheme {
|
|
12
|
+
/** current slide active */
|
|
13
|
+
activeIndex: number;
|
|
14
|
+
/** slides id to be added to the wrapper */
|
|
15
|
+
id?: string;
|
|
16
|
+
/** Whether the automatic rotation of the slideshow is enabled or not. */
|
|
17
|
+
autoPlay?: boolean;
|
|
18
|
+
/** Whether the image has to fill its container height or not. */
|
|
19
|
+
fillHeight?: boolean;
|
|
20
|
+
/** Number of slides to group together. */
|
|
21
|
+
groupBy?: number;
|
|
22
|
+
/** whether the slides are currently playing or not */
|
|
23
|
+
isAutoPlaying?: boolean;
|
|
24
|
+
/** id to be passed in into the slides */
|
|
25
|
+
slidesId?: string;
|
|
26
|
+
/** callback to change whether the slideshow is playing or not */
|
|
27
|
+
toggleAutoPlay: () => void;
|
|
28
|
+
/** component to be rendered after the slides */
|
|
29
|
+
afterSlides?: React.ReactNode;
|
|
30
|
+
/** Whether the slides have controls linked */
|
|
31
|
+
hasControls?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Accessible label to set on a slide group.
|
|
34
|
+
* Receives the group position starting from 1 and the total number of groups.
|
|
35
|
+
* */
|
|
36
|
+
slideGroupLabel?: (groupPosition: number, groupTotal: number) => string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Component display name.
|
|
41
|
+
*/
|
|
42
|
+
const COMPONENT_NAME = 'Slideshow';
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Component default class name and class prefix.
|
|
46
|
+
*/
|
|
47
|
+
const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Slides component.
|
|
51
|
+
*
|
|
52
|
+
* @param props Component props.
|
|
53
|
+
* @param ref Component ref.
|
|
54
|
+
* @return React element.
|
|
55
|
+
*/
|
|
56
|
+
export const Slides: Comp<SlidesProps, HTMLDivElement> = forwardRef((props, ref) => {
|
|
57
|
+
const {
|
|
58
|
+
activeIndex,
|
|
59
|
+
id,
|
|
60
|
+
className,
|
|
61
|
+
theme,
|
|
62
|
+
fillHeight,
|
|
63
|
+
groupBy,
|
|
64
|
+
isAutoPlaying,
|
|
65
|
+
toggleAutoPlay,
|
|
66
|
+
slidesId,
|
|
67
|
+
children,
|
|
68
|
+
afterSlides,
|
|
69
|
+
hasControls,
|
|
70
|
+
slideGroupLabel,
|
|
71
|
+
...forwardedProps
|
|
72
|
+
} = props;
|
|
73
|
+
const wrapperRef = React.useRef<HTMLDivElement>(null);
|
|
74
|
+
const startIndexVisible = activeIndex;
|
|
75
|
+
const endIndexVisible = startIndexVisible + 1;
|
|
76
|
+
|
|
77
|
+
// Inline style of wrapper element.
|
|
78
|
+
const wrapperStyle: CSSProperties = { transform: `translateX(-${FULL_WIDTH_PERCENT * activeIndex}%)` };
|
|
79
|
+
|
|
80
|
+
const groups = React.useMemo(() => {
|
|
81
|
+
const childrenArray = Children.toArray(children);
|
|
82
|
+
return groupBy && groupBy > 1 ? chunk(childrenArray, groupBy) : childrenArray;
|
|
83
|
+
}, [children, groupBy]);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<section
|
|
87
|
+
id={id}
|
|
88
|
+
ref={ref}
|
|
89
|
+
{...forwardedProps}
|
|
90
|
+
className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, theme }), {
|
|
91
|
+
[`${CLASSNAME}--fill-height`]: fillHeight,
|
|
92
|
+
[`${CLASSNAME}--group-by-${groupBy}`]: Boolean(groupBy),
|
|
93
|
+
})}
|
|
94
|
+
aria-roledescription="carousel"
|
|
95
|
+
>
|
|
96
|
+
<div
|
|
97
|
+
id={slidesId}
|
|
98
|
+
className={`${CLASSNAME}__slides`}
|
|
99
|
+
onMouseEnter={toggleAutoPlay}
|
|
100
|
+
onMouseLeave={toggleAutoPlay}
|
|
101
|
+
aria-live={isAutoPlaying ? 'off' : 'polite'}
|
|
102
|
+
>
|
|
103
|
+
<div ref={wrapperRef} className={`${CLASSNAME}__wrapper`} style={wrapperStyle}>
|
|
104
|
+
{groups.map((group, index) => (
|
|
105
|
+
<SlideshowItemGroup
|
|
106
|
+
key={index}
|
|
107
|
+
id={slidesId && buildSlideShowGroupId(slidesId, index)}
|
|
108
|
+
role={hasControls ? 'tabpanel' : 'group'}
|
|
109
|
+
label={slideGroupLabel ? slideGroupLabel(index + 1, groups.length) : undefined}
|
|
110
|
+
isDisplayed={index >= startIndexVisible && index < endIndexVisible}
|
|
111
|
+
>
|
|
112
|
+
{group}
|
|
113
|
+
</SlideshowItemGroup>
|
|
114
|
+
))}
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
{afterSlides}
|
|
119
|
+
</section>
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
Slides.displayName = COMPONENT_NAME;
|
|
124
|
+
Slides.className = CLASSNAME;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import range from 'lodash/range';
|
|
3
|
+
import { AspectRatio, Button, FlexBox, ImageBlock, Slideshow, SlideshowItem, Orientation } from '@lumx/react';
|
|
4
|
+
import { boolean, number } from '@storybook/addon-knobs';
|
|
5
|
+
import { thumbnailsKnob } from '@lumx/react/stories/knobs/thumbnailsKnob';
|
|
6
|
+
|
|
7
|
+
export default { title: 'LumX components/slideshow/Slideshow' };
|
|
8
|
+
|
|
9
|
+
export const Simple = ({ theme }: any) => {
|
|
10
|
+
const images = thumbnailsKnob(6);
|
|
11
|
+
const activeIndex = number('Active index', 0);
|
|
12
|
+
const groupBy = number('Group by', 1);
|
|
13
|
+
const autoPlay = boolean('Autoplay', false);
|
|
14
|
+
const interval = number('Autoplay interval (in milliseconds)', 1000);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Slideshow
|
|
18
|
+
aria-label="Simple carousel example"
|
|
19
|
+
activeIndex={activeIndex}
|
|
20
|
+
autoPlay={autoPlay}
|
|
21
|
+
interval={interval}
|
|
22
|
+
slideshowControlsProps={{
|
|
23
|
+
nextButtonProps: { label: 'Next' },
|
|
24
|
+
previousButtonProps: { label: 'Previous' },
|
|
25
|
+
}}
|
|
26
|
+
theme={theme}
|
|
27
|
+
groupBy={groupBy}
|
|
28
|
+
style={{ width: '50%' }}
|
|
29
|
+
slideGroupLabel={(currentGroup, totalGroup) => `${currentGroup} of ${totalGroup}`}
|
|
30
|
+
>
|
|
31
|
+
{images.map(({ image, alt }, index) => (
|
|
32
|
+
<SlideshowItem key={`${image}-${index}`}>
|
|
33
|
+
<ImageBlock
|
|
34
|
+
thumbnailProps={{ aspectRatio: AspectRatio.horizontal, loading: 'eager' }}
|
|
35
|
+
image={image}
|
|
36
|
+
alt={alt}
|
|
37
|
+
theme={theme}
|
|
38
|
+
/>
|
|
39
|
+
</SlideshowItem>
|
|
40
|
+
))}
|
|
41
|
+
</Slideshow>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const SimpleWithAutoPlay = ({ theme }: any) => {
|
|
46
|
+
const images = thumbnailsKnob(6);
|
|
47
|
+
const activeIndex = number('Active index', 0);
|
|
48
|
+
const groupBy = number('Group by', 1);
|
|
49
|
+
const interval = number('Autoplay interval (in milliseconds)', 1000);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Slideshow
|
|
53
|
+
aria-label="Simple with autoplay example"
|
|
54
|
+
activeIndex={activeIndex}
|
|
55
|
+
autoPlay
|
|
56
|
+
interval={interval}
|
|
57
|
+
slideshowControlsProps={{
|
|
58
|
+
nextButtonProps: { label: 'Next' },
|
|
59
|
+
previousButtonProps: { label: 'Previous' },
|
|
60
|
+
playButtonProps: { label: 'Play/Pause' },
|
|
61
|
+
}}
|
|
62
|
+
theme={theme}
|
|
63
|
+
groupBy={groupBy}
|
|
64
|
+
style={{ width: '50%' }}
|
|
65
|
+
slideGroupLabel={(currentGroup, totalGroup) => `${currentGroup} of ${totalGroup}`}
|
|
66
|
+
>
|
|
67
|
+
{images.map(({ image, alt }, index) => (
|
|
68
|
+
<SlideshowItem key={`${image}-${index}`}>
|
|
69
|
+
<ImageBlock
|
|
70
|
+
thumbnailProps={{ aspectRatio: AspectRatio.horizontal, loading: 'eager' }}
|
|
71
|
+
image={image}
|
|
72
|
+
alt={alt}
|
|
73
|
+
theme={theme}
|
|
74
|
+
/>
|
|
75
|
+
</SlideshowItem>
|
|
76
|
+
))}
|
|
77
|
+
</Slideshow>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const ResponsiveSlideShowSwipe = () => {
|
|
82
|
+
const slides = range(5);
|
|
83
|
+
return (
|
|
84
|
+
<>
|
|
85
|
+
In responsive mode
|
|
86
|
+
<ul>
|
|
87
|
+
<li>The slideshow is swipe-able (horizontal left/right)</li>
|
|
88
|
+
<li>The vertical scroll should still be possible</li>
|
|
89
|
+
<li>Clicking on elements inside a slide should work correctly</li>
|
|
90
|
+
</ul>
|
|
91
|
+
<FlexBox vAlign="center">
|
|
92
|
+
<Slideshow
|
|
93
|
+
aria-label="Responsive SlideShow Swipe"
|
|
94
|
+
activeIndex={0}
|
|
95
|
+
slideshowControlsProps={{
|
|
96
|
+
nextButtonProps: { label: 'Next' },
|
|
97
|
+
previousButtonProps: { label: 'Previous' },
|
|
98
|
+
}}
|
|
99
|
+
slideGroupLabel={(currentGroup, totalGroup) => `${currentGroup} of ${totalGroup}`}
|
|
100
|
+
>
|
|
101
|
+
{slides.map((slide) => (
|
|
102
|
+
<SlideshowItem key={`${slide}`}>
|
|
103
|
+
<FlexBox
|
|
104
|
+
style={{ border: '1px solid grey', maxWidth: 300, height: 300 }}
|
|
105
|
+
hAlign="center"
|
|
106
|
+
vAlign="center"
|
|
107
|
+
>
|
|
108
|
+
<Button onClick={() => alert(`Clicked button ${slide}`)}>Button {slide}</Button>
|
|
109
|
+
</FlexBox>
|
|
110
|
+
</SlideshowItem>
|
|
111
|
+
))}
|
|
112
|
+
</Slideshow>
|
|
113
|
+
</FlexBox>
|
|
114
|
+
{
|
|
115
|
+
/* Line padding to test the vertical scroll.*/
|
|
116
|
+
range(100).map((i) => (
|
|
117
|
+
<br key={i} />
|
|
118
|
+
))
|
|
119
|
+
}
|
|
120
|
+
</>
|
|
121
|
+
);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const slides = [
|
|
125
|
+
{
|
|
126
|
+
id: 0,
|
|
127
|
+
src: 'https://www.w3.org/WAI/ARIA/apg/example-index/carousel/images/foyleswarslide__800x600.jpg',
|
|
128
|
+
alt: 'A man in a suit and fedora and a woman with coiffed hair look sternly into the camera.',
|
|
129
|
+
title: 'Foyle’s War Revisited',
|
|
130
|
+
subtitle: '8 pm Sunday, March 8, on TV: Sneak peek at the final season',
|
|
131
|
+
link: '#',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: 1,
|
|
135
|
+
src: 'https://www.w3.org/WAI/ARIA/apg/example-index/carousel/images/britcomdavidslide__800x600.jpg',
|
|
136
|
+
alt: 'British flag with WILL-TV host David Thiel.',
|
|
137
|
+
title: 'Great Britain Vote: 7 pm Sat.',
|
|
138
|
+
link: '#',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: 2,
|
|
142
|
+
src: 'https://www.w3.org/WAI/ARIA/apg/example-index/carousel/images/mag800-2__800x600.jpg',
|
|
143
|
+
alt: 'Mid-American Gardener panelists on the set.',
|
|
144
|
+
title: 'Mid-American Gardener: Thursdays at 7 pm',
|
|
145
|
+
subtitle: 'Watch the latest episode',
|
|
146
|
+
link: '#',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
id: 3,
|
|
150
|
+
src: 'https://www.w3.org/WAI/ARIA/apg/example-index/carousel/images/foyleswarslide__800x600.jpg',
|
|
151
|
+
alt: 'A man in a suit and fedora and a woman with coiffed hair look sternly into the camera.',
|
|
152
|
+
title: 'Foyle’s War Revisited',
|
|
153
|
+
subtitle: '8 pm Sunday, March 8, on TV: Sneak peek at the final season',
|
|
154
|
+
link: '#',
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: 4,
|
|
158
|
+
src: 'https://www.w3.org/WAI/ARIA/apg/example-index/carousel/images/britcomdavidslide__800x600.jpg',
|
|
159
|
+
alt: 'British flag with WILL-TV host David Thiel.',
|
|
160
|
+
title: 'Great Britain Vote: 7 pm Sat.',
|
|
161
|
+
link: '#',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: 5,
|
|
165
|
+
src: 'https://www.w3.org/WAI/ARIA/apg/example-index/carousel/images/mag800-2__800x600.jpg',
|
|
166
|
+
alt: 'Mid-American Gardener panelists on the set.',
|
|
167
|
+
title: 'Mid-American Gardener: Thursdays at 7 pm',
|
|
168
|
+
subtitle: 'Watch the latest episode',
|
|
169
|
+
link: '#',
|
|
170
|
+
},
|
|
171
|
+
];
|
|
172
|
+
export const WithComplexContent = () => (
|
|
173
|
+
<Slideshow
|
|
174
|
+
aria-label="Carousel with complex content"
|
|
175
|
+
activeIndex={0}
|
|
176
|
+
groupBy={2}
|
|
177
|
+
slideshowControlsProps={{
|
|
178
|
+
nextButtonProps: { label: 'Next' },
|
|
179
|
+
previousButtonProps: { label: 'Previous' },
|
|
180
|
+
playButtonProps: { label: 'Play/Pause' },
|
|
181
|
+
paginationItemProps: (index) => ({ label: `Slide ${index + 1}` }),
|
|
182
|
+
}}
|
|
183
|
+
slideGroupLabel={(currentGroup, totalGroup) => `${currentGroup} of ${totalGroup}`}
|
|
184
|
+
>
|
|
185
|
+
{range(number('Slides', 6)).map((nb) => {
|
|
186
|
+
const slide = slides[nb % slides.length];
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<SlideshowItem key={slide.id}>
|
|
190
|
+
<a href={slide.link}>
|
|
191
|
+
<ImageBlock
|
|
192
|
+
thumbnailProps={{ aspectRatio: AspectRatio.horizontal, loading: 'eager' }}
|
|
193
|
+
image={slide.src}
|
|
194
|
+
alt={slide.alt}
|
|
195
|
+
/>
|
|
196
|
+
</a>
|
|
197
|
+
<FlexBox orientation={Orientation.vertical}>
|
|
198
|
+
<h3>
|
|
199
|
+
<a href={slide.link}>{slide.title}</a>
|
|
200
|
+
{/* Add a non focusable element to test that it stays that way after a page change. */}
|
|
201
|
+
<button type="button" tabIndex={-1} aria-hidden="true">
|
|
202
|
+
Not focusable
|
|
203
|
+
</button>
|
|
204
|
+
<button type="button">Focusable</button>
|
|
205
|
+
</h3>
|
|
206
|
+
{slide.subtitle && <p>{slide.subtitle}</p>}
|
|
207
|
+
</FlexBox>
|
|
208
|
+
</SlideshowItem>
|
|
209
|
+
);
|
|
210
|
+
})}
|
|
211
|
+
</Slideshow>
|
|
212
|
+
);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
import pick from 'lodash/pick';
|
|
3
|
+
|
|
4
|
+
import { mount, shallow } from 'enzyme';
|
|
5
|
+
import 'jest-enzyme';
|
|
6
|
+
|
|
7
|
+
import { commonTestsSuite, itShouldRenderStories, Wrapper } from '@lumx/react/testing/utils';
|
|
8
|
+
import { Slideshow, SlideshowProps } from './Slideshow';
|
|
9
|
+
import { SlideshowControls } from './SlideshowControls';
|
|
10
|
+
import * as stories from './Slideshow.stories';
|
|
11
|
+
|
|
12
|
+
const CLASSNAME = Slideshow.className as string;
|
|
13
|
+
|
|
14
|
+
const setup = ({ ...propsOverride }: Partial<SlideshowProps> = {}, shallowRendering = true) => {
|
|
15
|
+
const props: SlideshowProps = {
|
|
16
|
+
slideshowControlsProps: {
|
|
17
|
+
nextButtonProps: { label: 'Next' },
|
|
18
|
+
previousButtonProps: { label: 'Prev' },
|
|
19
|
+
},
|
|
20
|
+
...propsOverride,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const renderer: (el: ReactElement) => Wrapper = shallowRendering ? shallow : mount;
|
|
24
|
+
const wrapper: Wrapper = renderer(<Slideshow {...props} />);
|
|
25
|
+
|
|
26
|
+
return { props, wrapper };
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
describe(`<${Slideshow.displayName}>`, () => {
|
|
30
|
+
// 1. Test render via snapshot.
|
|
31
|
+
describe('Snapshots and structure', () => {
|
|
32
|
+
itShouldRenderStories(pick(stories, ['default', 'Simple']), {
|
|
33
|
+
or: [Slideshow, { path: [Slideshow, SlideshowControls] }],
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Common tests suite.
|
|
38
|
+
commonTestsSuite(setup, { prop: 'wrapper' }, { className: CLASSNAME });
|
|
39
|
+
});
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { SlideshowControls, SlideshowControlsProps, Theme, Slides, SlidesProps } from '@lumx/react';
|
|
4
|
+
import { DEFAULT_OPTIONS } from '@lumx/react/hooks/useSlideshowControls';
|
|
5
|
+
import { Comp, GenericProps } from '@lumx/react/utils/type';
|
|
6
|
+
import { useFocusWithin } from '@lumx/react/hooks/useFocusWithin';
|
|
7
|
+
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
8
|
+
import { buildSlideShowGroupId } from './SlideshowItemGroup';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Defines the props of the component.
|
|
12
|
+
*/
|
|
13
|
+
export interface SlideshowProps
|
|
14
|
+
extends GenericProps,
|
|
15
|
+
Pick<SlidesProps, 'autoPlay' | 'slidesId' | 'id' | 'theme' | 'fillHeight' | 'groupBy' | 'slideGroupLabel'> {
|
|
16
|
+
/** current slide active */
|
|
17
|
+
activeIndex?: SlidesProps['activeIndex'];
|
|
18
|
+
/** Interval between each slide when automatic rotation is enabled. */
|
|
19
|
+
interval?: number;
|
|
20
|
+
/** Props to pass to the slideshow controls (minus those already set by the Slideshow props). */
|
|
21
|
+
slideshowControlsProps?: Pick<
|
|
22
|
+
SlideshowControlsProps,
|
|
23
|
+
'nextButtonProps' | 'previousButtonProps' | 'paginationItemProps'
|
|
24
|
+
> &
|
|
25
|
+
Omit<
|
|
26
|
+
SlideshowControlsProps,
|
|
27
|
+
| 'activeIndex'
|
|
28
|
+
| 'onPaginationClick'
|
|
29
|
+
| 'onNextClick'
|
|
30
|
+
| 'onPreviousClick'
|
|
31
|
+
| 'slidesCount'
|
|
32
|
+
| 'parentRef'
|
|
33
|
+
| 'theme'
|
|
34
|
+
>;
|
|
35
|
+
/** Callback when slide changes */
|
|
36
|
+
onChange?(index: number): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Component default props.
|
|
41
|
+
*/
|
|
42
|
+
const DEFAULT_PROPS: Partial<SlideshowProps> = {
|
|
43
|
+
...DEFAULT_OPTIONS,
|
|
44
|
+
theme: Theme.light,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Slideshow component.
|
|
49
|
+
*
|
|
50
|
+
* @param props Component props.
|
|
51
|
+
* @param ref Component ref.
|
|
52
|
+
* @return React element.
|
|
53
|
+
*/
|
|
54
|
+
export const Slideshow: Comp<SlideshowProps, HTMLDivElement> = forwardRef((props, ref) => {
|
|
55
|
+
const {
|
|
56
|
+
activeIndex,
|
|
57
|
+
autoPlay,
|
|
58
|
+
children,
|
|
59
|
+
className,
|
|
60
|
+
fillHeight,
|
|
61
|
+
groupBy,
|
|
62
|
+
interval,
|
|
63
|
+
onChange,
|
|
64
|
+
slideshowControlsProps,
|
|
65
|
+
theme,
|
|
66
|
+
id,
|
|
67
|
+
slidesId,
|
|
68
|
+
slideGroupLabel,
|
|
69
|
+
...forwardedProps
|
|
70
|
+
} = props;
|
|
71
|
+
// Number of slideshow items.
|
|
72
|
+
const itemsCount = React.Children.count(children);
|
|
73
|
+
|
|
74
|
+
const {
|
|
75
|
+
activeIndex: currentIndex,
|
|
76
|
+
slideshowId,
|
|
77
|
+
setSlideshow,
|
|
78
|
+
isAutoPlaying,
|
|
79
|
+
slideshowSlidesId,
|
|
80
|
+
slidesCount,
|
|
81
|
+
onNextClick,
|
|
82
|
+
onPaginationClick,
|
|
83
|
+
onPreviousClick,
|
|
84
|
+
slideshow,
|
|
85
|
+
stopAutoPlay,
|
|
86
|
+
startAutoPlay,
|
|
87
|
+
toggleAutoPlay,
|
|
88
|
+
toggleForcePause,
|
|
89
|
+
} = SlideshowControls.useSlideshowControls({
|
|
90
|
+
activeIndex,
|
|
91
|
+
defaultActiveIndex: DEFAULT_PROPS.activeIndex as number,
|
|
92
|
+
autoPlay: Boolean(autoPlay),
|
|
93
|
+
itemsCount,
|
|
94
|
+
groupBy,
|
|
95
|
+
id,
|
|
96
|
+
interval,
|
|
97
|
+
onChange,
|
|
98
|
+
slidesId,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
useFocusWithin({
|
|
102
|
+
element: slideshow,
|
|
103
|
+
onFocusIn: stopAutoPlay,
|
|
104
|
+
onFocusOut: startAutoPlay,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const showControls = slideshowControlsProps && slidesCount > 1;
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<Slides
|
|
111
|
+
activeIndex={currentIndex}
|
|
112
|
+
id={slideshowId}
|
|
113
|
+
className={className}
|
|
114
|
+
theme={theme}
|
|
115
|
+
fillHeight={fillHeight}
|
|
116
|
+
groupBy={groupBy}
|
|
117
|
+
isAutoPlaying={isAutoPlaying}
|
|
118
|
+
autoPlay={autoPlay}
|
|
119
|
+
slidesId={slideshowSlidesId}
|
|
120
|
+
toggleAutoPlay={toggleAutoPlay}
|
|
121
|
+
ref={mergeRefs(ref, setSlideshow)}
|
|
122
|
+
hasControls={showControls}
|
|
123
|
+
slideGroupLabel={slideGroupLabel}
|
|
124
|
+
afterSlides={
|
|
125
|
+
slideshowControlsProps && slidesCount > 1 ? (
|
|
126
|
+
<div className={`${Slides.className}__controls`}>
|
|
127
|
+
<SlideshowControls
|
|
128
|
+
{...slideshowControlsProps}
|
|
129
|
+
activeIndex={currentIndex}
|
|
130
|
+
onPaginationClick={onPaginationClick}
|
|
131
|
+
onNextClick={onNextClick}
|
|
132
|
+
onPreviousClick={onPreviousClick}
|
|
133
|
+
slidesCount={slidesCount}
|
|
134
|
+
parentRef={slideshow}
|
|
135
|
+
theme={theme}
|
|
136
|
+
isAutoPlaying={isAutoPlaying}
|
|
137
|
+
nextButtonProps={{
|
|
138
|
+
'aria-controls': slideshowSlidesId,
|
|
139
|
+
...slideshowControlsProps.nextButtonProps,
|
|
140
|
+
}}
|
|
141
|
+
previousButtonProps={{
|
|
142
|
+
'aria-controls': slideshowSlidesId,
|
|
143
|
+
...slideshowControlsProps.previousButtonProps,
|
|
144
|
+
}}
|
|
145
|
+
playButtonProps={
|
|
146
|
+
autoPlay
|
|
147
|
+
? {
|
|
148
|
+
'aria-controls': slideshowSlidesId,
|
|
149
|
+
onClick: toggleForcePause,
|
|
150
|
+
...slideshowControlsProps.playButtonProps,
|
|
151
|
+
}
|
|
152
|
+
: undefined
|
|
153
|
+
}
|
|
154
|
+
paginationItemProps={(index) => ({
|
|
155
|
+
'aria-controls': buildSlideShowGroupId(slideshowSlidesId, index),
|
|
156
|
+
...slideshowControlsProps.paginationItemProps?.(index),
|
|
157
|
+
})}
|
|
158
|
+
/>
|
|
159
|
+
</div>
|
|
160
|
+
) : undefined
|
|
161
|
+
}
|
|
162
|
+
{...forwardedProps}
|
|
163
|
+
>
|
|
164
|
+
{children}
|
|
165
|
+
</Slides>
|
|
166
|
+
);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
Slideshow.displayName = 'Slideshow';
|
|
170
|
+
Slideshow.defaultProps = DEFAULT_PROPS;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { AspectRatio, ImageBlock, Slides, SlideshowControls, SlideshowItem } from '@lumx/react';
|
|
4
|
+
import { thumbnailsKnob } from '@lumx/react/stories/knobs/thumbnailsKnob';
|
|
5
|
+
import { useFocusWithin } from '@lumx/react/hooks/useFocusWithin';
|
|
6
|
+
|
|
7
|
+
export default { title: 'LumX components/slideshow/Slideshow controls' };
|
|
8
|
+
|
|
9
|
+
export const Simple = () => {
|
|
10
|
+
const {
|
|
11
|
+
activeIndex,
|
|
12
|
+
slidesCount,
|
|
13
|
+
onNextClick,
|
|
14
|
+
onPreviousClick,
|
|
15
|
+
onPaginationClick,
|
|
16
|
+
} = SlideshowControls.useSlideshowControls({
|
|
17
|
+
itemsCount: 9,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<SlideshowControls
|
|
22
|
+
activeIndex={activeIndex}
|
|
23
|
+
slidesCount={slidesCount}
|
|
24
|
+
onNextClick={onNextClick}
|
|
25
|
+
onPreviousClick={onPreviousClick}
|
|
26
|
+
onPaginationClick={onPaginationClick}
|
|
27
|
+
nextButtonProps={{ label: 'Next' }}
|
|
28
|
+
previousButtonProps={{ label: 'Previous' }}
|
|
29
|
+
paginationItemLabel={(index) => `Slide ${index}`}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const ControllingSlideshow = ({ theme }: any) => {
|
|
35
|
+
const images = thumbnailsKnob(6);
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
activeIndex: currentIndex,
|
|
39
|
+
slideshowId,
|
|
40
|
+
setSlideshow,
|
|
41
|
+
isAutoPlaying,
|
|
42
|
+
slideshowSlidesId,
|
|
43
|
+
slidesCount,
|
|
44
|
+
onNextClick,
|
|
45
|
+
onPaginationClick,
|
|
46
|
+
onPreviousClick,
|
|
47
|
+
slideshow,
|
|
48
|
+
stopAutoPlay,
|
|
49
|
+
startAutoPlay,
|
|
50
|
+
toggleAutoPlay,
|
|
51
|
+
toggleForcePause,
|
|
52
|
+
} = SlideshowControls.useSlideshowControls({
|
|
53
|
+
activeIndex: 0,
|
|
54
|
+
defaultActiveIndex: 0,
|
|
55
|
+
autoPlay: true,
|
|
56
|
+
itemsCount: 6,
|
|
57
|
+
groupBy: 1,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
useFocusWithin({
|
|
61
|
+
element: slideshow,
|
|
62
|
+
onFocusIn: stopAutoPlay,
|
|
63
|
+
onFocusOut: startAutoPlay,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Slides
|
|
68
|
+
activeIndex={currentIndex}
|
|
69
|
+
id={slideshowId}
|
|
70
|
+
ref={setSlideshow}
|
|
71
|
+
theme={theme}
|
|
72
|
+
isAutoPlaying={isAutoPlaying}
|
|
73
|
+
slidesId={slideshowSlidesId}
|
|
74
|
+
toggleAutoPlay={toggleAutoPlay}
|
|
75
|
+
groupBy={1}
|
|
76
|
+
style={{ width: '50%' }}
|
|
77
|
+
afterSlides={
|
|
78
|
+
<div className={`${Slides.className}__controls`}>
|
|
79
|
+
<SlideshowControls
|
|
80
|
+
activeIndex={currentIndex}
|
|
81
|
+
onPaginationClick={onPaginationClick}
|
|
82
|
+
onNextClick={onNextClick}
|
|
83
|
+
onPreviousClick={onPreviousClick}
|
|
84
|
+
slidesCount={slidesCount}
|
|
85
|
+
parentRef={slideshow}
|
|
86
|
+
theme={theme}
|
|
87
|
+
isAutoPlaying={isAutoPlaying}
|
|
88
|
+
nextButtonProps={{ label: 'Next', 'aria-controls': slideshowSlidesId }}
|
|
89
|
+
previousButtonProps={{ label: 'Previous', 'aria-controls': slideshowSlidesId }}
|
|
90
|
+
playButtonProps={{
|
|
91
|
+
label: 'Play/Pause',
|
|
92
|
+
'aria-controls': slideshowSlidesId,
|
|
93
|
+
onClick: toggleForcePause,
|
|
94
|
+
}}
|
|
95
|
+
paginationItemLabel={(index) => `Slide ${index}`}
|
|
96
|
+
/>
|
|
97
|
+
</div>
|
|
98
|
+
}
|
|
99
|
+
>
|
|
100
|
+
{images.map(({ image, alt }, index) => (
|
|
101
|
+
<SlideshowItem key={`${image}-${index}`}>
|
|
102
|
+
<ImageBlock
|
|
103
|
+
thumbnailProps={{ aspectRatio: AspectRatio.horizontal, loading: 'eager' }}
|
|
104
|
+
image={image}
|
|
105
|
+
alt={alt}
|
|
106
|
+
theme={theme}
|
|
107
|
+
/>
|
|
108
|
+
</SlideshowItem>
|
|
109
|
+
))}
|
|
110
|
+
</Slides>
|
|
111
|
+
);
|
|
112
|
+
};
|