@telus-uds/components-base 2.0.2 → 2.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/CHANGELOG.md +27 -2
- package/lib/A11yInfoProvider/index.js +0 -0
- package/lib/A11yText/index.js +0 -0
- package/lib/ActionCard/ActionCard.js +0 -0
- package/lib/ActionCard/index.js +0 -0
- package/lib/ActivityIndicator/Spinner.js +0 -0
- package/lib/ActivityIndicator/Spinner.native.js +0 -0
- package/lib/ActivityIndicator/index.js +0 -0
- package/lib/ActivityIndicator/shared.js +0 -0
- package/lib/Autocomplete/Autocomplete.js +0 -0
- package/lib/Autocomplete/Loading.js +0 -0
- package/lib/Autocomplete/Suggestions.js +0 -0
- package/lib/Autocomplete/constants.js +0 -0
- package/lib/Autocomplete/dictionary.js +0 -0
- package/lib/Autocomplete/index.js +0 -0
- package/lib/Badge/Badge.js +0 -0
- package/lib/Badge/index.js +0 -0
- package/lib/BaseProvider/HydrationContext.js +0 -0
- package/lib/BaseProvider/index.js +0 -0
- package/lib/Box/Box.js +0 -0
- package/lib/Box/backgroundImageStylesMap.js +0 -0
- package/lib/Box/index.js +0 -0
- package/lib/Button/Button.js +0 -0
- package/lib/Button/ButtonBase.js +0 -0
- package/lib/Button/ButtonDropdown.js +0 -0
- package/lib/Button/ButtonGroup.js +0 -0
- package/lib/Button/ButtonLink.js +0 -0
- package/lib/Button/index.js +0 -0
- package/lib/Button/propTypes.js +0 -0
- package/lib/Card/Card.js +0 -0
- package/lib/Card/CardBase.js +0 -0
- package/lib/Card/PressableCardBase.js +2 -1
- package/lib/Card/index.js +0 -0
- package/lib/CardGroup/CardGroup.js +0 -0
- package/lib/CardGroup/dictionary.js +0 -0
- package/lib/CardGroup/index.js +0 -0
- package/lib/Carousel/Carousel.js +121 -33
- package/lib/Carousel/CarouselContext.js +0 -0
- package/lib/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +0 -0
- package/lib/Carousel/CarouselItem/CarouselItem.js +39 -24
- package/lib/Carousel/CarouselItem/index.js +0 -0
- package/lib/Carousel/CarouselStepTracker/CarouselStepTracker.js +41 -4
- package/lib/Carousel/CarouselStepTracker/index.js +0 -0
- package/lib/Carousel/CarouselTabs/CarouselTabs.js +0 -0
- package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +0 -0
- package/lib/Carousel/CarouselTabs/CarouselTabsPanelItem.js +0 -0
- package/lib/Carousel/CarouselTabs/index.js +0 -0
- package/lib/Carousel/CarouselThumbnail.js +0 -0
- package/lib/Carousel/CarouselThumbnailNavigation.js +0 -0
- package/lib/Carousel/Constants.js +3 -0
- package/lib/Carousel/dictionary.js +0 -0
- package/lib/Carousel/index.js +0 -0
- package/lib/Checkbox/Checkbox.js +0 -0
- package/lib/Checkbox/CheckboxButton.js +0 -0
- package/lib/Checkbox/CheckboxGroup.js +4 -2
- package/lib/Checkbox/CheckboxInput.js +0 -0
- package/lib/Checkbox/CheckboxInput.native.js +0 -0
- package/lib/Checkbox/index.js +0 -0
- package/lib/CheckboxCard/CheckboxCard.js +0 -0
- package/lib/CheckboxCard/index.js +0 -0
- package/lib/CheckboxCardGroup/CheckboxCardGroup.js +0 -0
- package/lib/CheckboxCardGroup/index.js +0 -0
- package/lib/ColourToggle/ColourBubble.js +0 -0
- package/lib/ColourToggle/ColourToggle.js +0 -0
- package/lib/ColourToggle/index.js +0 -0
- package/lib/Divider/Divider.js +0 -0
- package/lib/Divider/index.js +0 -0
- package/lib/DownloadApp/DownloadApp.js +0 -0
- package/lib/DownloadApp/dictionary.js +0 -0
- package/lib/DownloadApp/index.js +0 -0
- package/lib/ExpandCollapse/Accordion.js +0 -0
- package/lib/ExpandCollapse/Control.js +0 -0
- package/lib/ExpandCollapse/ExpandCollapse.js +0 -0
- package/lib/ExpandCollapse/Panel.js +0 -0
- package/lib/ExpandCollapse/dictionary.js +0 -0
- package/lib/ExpandCollapse/index.js +0 -0
- package/lib/Feedback/Feedback.js +0 -0
- package/lib/Feedback/index.js +0 -0
- package/lib/Fieldset/Fieldset.js +0 -0
- package/lib/Fieldset/FieldsetContainer.js +0 -0
- package/lib/Fieldset/FieldsetContainer.native.js +0 -0
- package/lib/Fieldset/Legend.js +0 -0
- package/lib/Fieldset/Legend.native.js +0 -0
- package/lib/Fieldset/cssReset.js +0 -0
- package/lib/Fieldset/index.js +0 -0
- package/lib/FileUpload/FileUpload.js +0 -0
- package/lib/FileUpload/NotificationContent.js +0 -0
- package/lib/FileUpload/dictionary.js +0 -0
- package/lib/FileUpload/index.js +0 -0
- package/lib/FlexGrid/Col/Col.js +0 -0
- package/lib/FlexGrid/Col/index.js +0 -0
- package/lib/FlexGrid/FlexGrid.js +0 -0
- package/lib/FlexGrid/Row/Row.js +0 -0
- package/lib/FlexGrid/Row/index.js +0 -0
- package/lib/FlexGrid/helpers/index.js +0 -0
- package/lib/FlexGrid/index.js +0 -0
- package/lib/FlexGrid/providers/GutterContext.js +0 -0
- package/lib/Footnote/Footnote.js +0 -0
- package/lib/Footnote/FootnoteLink.js +0 -0
- package/lib/Footnote/dictionary.js +0 -0
- package/lib/Footnote/index.js +0 -0
- package/lib/HorizontalScroll/HorizontalScroll.js +17 -13
- package/lib/HorizontalScroll/HorizontalScrollButton.js +0 -0
- package/lib/HorizontalScroll/ScrollViewEnd.js +0 -0
- package/lib/HorizontalScroll/ScrollViewEnd.native.js +0 -0
- package/lib/HorizontalScroll/dictionary.js +0 -0
- package/lib/HorizontalScroll/index.js +0 -0
- package/lib/HorizontalScroll/itemPositions.js +0 -0
- package/lib/Icon/Icon.js +1 -0
- package/lib/Icon/IconText.js +0 -0
- package/lib/Icon/index.js +0 -0
- package/lib/IconButton/IconButton.js +0 -0
- package/lib/IconButton/index.js +0 -0
- package/lib/InputLabel/InputLabel.js +0 -0
- package/lib/InputLabel/LabelContent.js +0 -0
- package/lib/InputLabel/LabelContent.native.js +0 -0
- package/lib/InputLabel/index.js +0 -0
- package/lib/InputSupports/InputSupports.js +3 -0
- package/lib/InputSupports/index.js +0 -0
- package/lib/InputSupports/useInputSupports.js +0 -0
- package/lib/Link/ChevronLink.js +0 -0
- package/lib/Link/InlinePressable.js +0 -0
- package/lib/Link/InlinePressable.native.js +0 -0
- package/lib/Link/Link.js +0 -0
- package/lib/Link/LinkBase.js +2 -2
- package/lib/Link/TextButton.js +0 -0
- package/lib/Link/index.js +0 -0
- package/lib/List/List.js +0 -0
- package/lib/List/ListItem.js +0 -0
- package/lib/List/ListItemBase.js +0 -0
- package/lib/List/ListItemContent.js +0 -0
- package/lib/List/ListItemMark.js +0 -0
- package/lib/List/PressableListItemBase.js +0 -0
- package/lib/List/index.js +0 -0
- package/lib/Listbox/GroupControl.js +0 -0
- package/lib/Listbox/Listbox.js +0 -0
- package/lib/Listbox/ListboxContext.js +0 -0
- package/lib/Listbox/ListboxGroup.js +0 -0
- package/lib/Listbox/ListboxItem.js +0 -0
- package/lib/Listbox/ListboxOverlay.js +0 -0
- package/lib/Listbox/PressableItem.js +0 -0
- package/lib/Listbox/index.js +0 -0
- package/lib/Modal/Modal.js +4 -0
- package/lib/Modal/ModalContent.js +27 -8
- package/lib/Modal/WebModal.js +0 -0
- package/lib/Modal/dictionary.js +0 -0
- package/lib/Modal/index.js +0 -0
- package/lib/MultiSelectFilter/ModalOverlay.js +0 -0
- package/lib/MultiSelectFilter/MultiSelectFilter.js +0 -0
- package/lib/MultiSelectFilter/dictionary.js +0 -0
- package/lib/MultiSelectFilter/index.js +0 -0
- package/lib/Notification/Notification.js +0 -0
- package/lib/Notification/dictionary.js +0 -0
- package/lib/Notification/index.js +0 -0
- package/lib/OrderedList/Item.js +0 -0
- package/lib/OrderedList/ItemBase.js +0 -0
- package/lib/OrderedList/OrderedList.js +0 -0
- package/lib/OrderedList/OrderedListBase.js +0 -0
- package/lib/OrderedList/index.js +0 -0
- package/lib/Pagination/PageButton.js +0 -0
- package/lib/Pagination/Pagination.js +0 -0
- package/lib/Pagination/SideButton.js +0 -0
- package/lib/Pagination/constants.js +0 -0
- package/lib/Pagination/dictionary.js +0 -0
- package/lib/Pagination/index.js +0 -0
- package/lib/Pagination/usePagination.js +0 -0
- package/lib/Portal/Portal.js +0 -0
- package/lib/Portal/Portal.native.js +0 -0
- package/lib/Portal/index.js +0 -0
- package/lib/PriceLockup/PriceLockup.js +0 -0
- package/lib/PriceLockup/index.js +0 -0
- package/lib/PriceLockup/utils/renderFootnoteContent.js +0 -0
- package/lib/PriceLockup/utils/renderFootnoteLinks.js +0 -0
- package/lib/PriceLockup/utils/renderPrice.js +0 -0
- package/lib/PriceLockup/utils/renderTypography.js +0 -0
- package/lib/ProductCard/ProductCard.js +0 -0
- package/lib/ProductCard/dictionary.js +0 -0
- package/lib/ProductCard/index.js +0 -0
- package/lib/ProductCardGroup/ProductCardGroup.js +0 -0
- package/lib/ProductCardGroup/index.js +0 -0
- package/lib/Progress/Progress.js +8 -2
- package/lib/Progress/ProgressBar.js +40 -12
- package/lib/Progress/ProgressBarBackground.js +4 -2
- package/lib/Progress/constants.js +4 -0
- package/lib/Progress/index.js +0 -0
- package/lib/QuickLinks/QuickLinks.js +0 -0
- package/lib/QuickLinks/QuickLinksCard.js +0 -0
- package/lib/QuickLinks/QuickLinksItem.js +0 -0
- package/lib/QuickLinks/index.js +0 -0
- package/lib/QuickLinksFeature/QuickLinksFeature.js +0 -0
- package/lib/QuickLinksFeature/QuickLinksFeatureItem.js +0 -0
- package/lib/QuickLinksFeature/index.js +0 -0
- package/lib/Radio/Radio.js +0 -0
- package/lib/Radio/RadioButton.js +0 -0
- package/lib/Radio/RadioGroup.js +0 -0
- package/lib/Radio/RadioInput.js +0 -0
- package/lib/Radio/RadioInput.native.js +0 -0
- package/lib/Radio/index.js +0 -0
- package/lib/RadioCard/RadioCard.js +0 -0
- package/lib/RadioCard/RadioCardGroup.js +0 -0
- package/lib/RadioCard/index.js +0 -0
- package/lib/Responsive/Responsive.js +0 -0
- package/lib/Responsive/ResponsiveProp.js +0 -0
- package/lib/Responsive/ResponsiveWithMediaQueryStyleSheet.js +0 -0
- package/lib/Responsive/index.js +0 -0
- package/lib/Search/Search.js +2 -2
- package/lib/Search/dictionary.js +0 -0
- package/lib/Search/index.js +0 -0
- package/lib/Select/Group.js +0 -0
- package/lib/Select/Group.native.js +0 -0
- package/lib/Select/Item.js +0 -0
- package/lib/Select/Item.native.js +0 -0
- package/lib/Select/Picker.js +0 -0
- package/lib/Select/Picker.native.js +1 -0
- package/lib/Select/Select.js +1 -4
- package/lib/Select/constants.js +0 -0
- package/lib/Select/index.js +0 -0
- package/lib/SideNav/Item.js +0 -0
- package/lib/SideNav/ItemContent.js +0 -0
- package/lib/SideNav/ItemsGroup.js +0 -0
- package/lib/SideNav/SideNav.js +0 -0
- package/lib/SideNav/index.js +0 -0
- package/lib/Skeleton/Skeleton.js +0 -0
- package/lib/Skeleton/index.js +0 -0
- package/lib/Skeleton/skeleton.constant.js +0 -0
- package/lib/Skeleton/skeletonWebAnimation.js +0 -0
- package/lib/Skeleton/useSkeletonNativeAnimation.js +0 -0
- package/lib/SkipLink/SkipLink.js +0 -0
- package/lib/SkipLink/index.js +0 -0
- package/lib/Spacer/Spacer.js +0 -0
- package/lib/Spacer/index.js +0 -0
- package/lib/StackView/StackView.js +0 -0
- package/lib/StackView/StackWrap.js +0 -0
- package/lib/StackView/StackWrap.native.js +0 -0
- package/lib/StackView/StackWrapBox.js +0 -0
- package/lib/StackView/StackWrapGap.js +0 -0
- package/lib/StackView/common.js +0 -0
- package/lib/StackView/getStackedContent.js +0 -0
- package/lib/StackView/index.js +0 -0
- package/lib/Status/Status.js +6 -2
- package/lib/Status/index.js +0 -0
- package/lib/StepTracker/Step.js +0 -0
- package/lib/StepTracker/StepTracker.js +0 -0
- package/lib/StepTracker/dictionary.js +0 -0
- package/lib/StepTracker/index.js +0 -0
- package/lib/TabBar/TabBar.js +0 -0
- package/lib/TabBar/TabBarItem.js +0 -0
- package/lib/TabBar/index.js +0 -0
- package/lib/Tabs/Tabs.js +0 -0
- package/lib/Tabs/TabsItem.js +0 -0
- package/lib/Tabs/index.js +0 -0
- package/lib/Tags/Tags.js +0 -0
- package/lib/Tags/index.js +0 -0
- package/lib/TextInput/TextArea.js +0 -0
- package/lib/TextInput/TextInput.js +0 -0
- package/lib/TextInput/TextInputBase.js +2 -2
- package/lib/TextInput/dictionary.js +0 -0
- package/lib/TextInput/index.js +0 -0
- package/lib/TextInput/propTypes.js +0 -0
- package/lib/ThemeProvider/ThemeProvider.js +0 -0
- package/lib/ThemeProvider/index.js +0 -0
- package/lib/ThemeProvider/useResponsiveThemeTokens.js +0 -0
- package/lib/ThemeProvider/useSetTheme.js +0 -0
- package/lib/ThemeProvider/useTheme.js +0 -0
- package/lib/ThemeProvider/useThemeTokens.js +0 -0
- package/lib/ThemeProvider/utils/index.js +0 -0
- package/lib/ThemeProvider/utils/styles.js +0 -0
- package/lib/ThemeProvider/utils/theme-tokens.js +0 -0
- package/lib/Timeline/Timeline.js +0 -0
- package/lib/Timeline/index.js +0 -0
- package/lib/ToggleSwitch/ToggleSwitch.js +0 -0
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +0 -0
- package/lib/ToggleSwitch/index.js +0 -0
- package/lib/Tooltip/Backdrop.js +0 -0
- package/lib/Tooltip/Backdrop.native.js +0 -0
- package/lib/Tooltip/Tooltip.js +22 -13
- package/lib/Tooltip/Tooltip.native.js +24 -15
- package/lib/Tooltip/dictionary.js +0 -0
- package/lib/Tooltip/getTooltipPosition.js +0 -0
- package/lib/Tooltip/index.js +0 -0
- package/lib/Tooltip/shared.js +0 -0
- package/lib/TooltipButton/TooltipButton.js +0 -0
- package/lib/TooltipButton/index.js +0 -0
- package/lib/Typography/Typography.js +0 -0
- package/lib/Typography/index.js +0 -0
- package/lib/Validator/Validator.js +4 -0
- package/lib/Validator/index.js +0 -0
- package/lib/ViewportProvider/ViewportProvider.js +0 -0
- package/lib/ViewportProvider/index.js +0 -0
- package/lib/ViewportProvider/useViewport.js +0 -0
- package/lib/ViewportProvider/useViewportListener.js +0 -0
- package/lib/index.js +0 -0
- package/lib/server.js +0 -0
- package/lib/utils/BaseView/BaseView.js +0 -0
- package/lib/utils/BaseView/BaseView.native.js +0 -0
- package/lib/utils/BaseView/index.js +0 -0
- package/lib/utils/a11y/index.js +0 -0
- package/lib/utils/a11y/semantics.js +0 -0
- package/lib/utils/a11y/textSize.js +0 -0
- package/lib/utils/animation/index.js +0 -0
- package/lib/utils/animation/useVerticalExpandAnimation.js +0 -0
- package/lib/utils/children.js +0 -0
- package/lib/utils/containUniqueFields.js +0 -0
- package/lib/utils/convertFromMegaByteToByte.js +0 -0
- package/lib/utils/floating-ui/index.js +0 -0
- package/lib/utils/floating-ui/index.native.js +0 -0
- package/lib/utils/formatImageSource.js +0 -0
- package/lib/utils/hasOwnProperty.js +0 -0
- package/lib/utils/htmlAttrs.js +0 -0
- package/lib/utils/index.js +0 -0
- package/lib/utils/info/index.js +0 -0
- package/lib/utils/info/platform/index.js +0 -0
- package/lib/utils/info/platform/platform.android.js +0 -0
- package/lib/utils/info/platform/platform.ios.js +0 -0
- package/lib/utils/info/platform/platform.js +0 -0
- package/lib/utils/info/platform/platform.native.js +0 -0
- package/lib/utils/info/versions.js +0 -0
- package/lib/utils/input.js +0 -0
- package/lib/utils/pressability.js +0 -0
- package/lib/utils/props/a11yProps.js +0 -0
- package/lib/utils/props/clickProps.js +0 -0
- package/lib/utils/props/componentPropType.js +0 -0
- package/lib/utils/props/contentfulProps.js +22 -0
- package/lib/utils/props/copyPropTypes.js +0 -0
- package/lib/utils/props/getPropSelector.js +0 -0
- package/lib/utils/props/handlerProps.js +0 -0
- package/lib/utils/props/hrefAttrsProp.js +0 -0
- package/lib/utils/props/index.js +2 -1
- package/lib/utils/props/inputSupportsProps.js +0 -0
- package/lib/utils/props/linkProps.js +0 -0
- package/lib/utils/props/paddingProp.js +0 -0
- package/lib/utils/props/pressProps.js +0 -0
- package/lib/utils/props/rectProp.js +0 -0
- package/lib/utils/props/responsiveProps.js +0 -0
- package/lib/utils/props/selectSystemProps.js +0 -0
- package/lib/utils/props/spacingProps.js +0 -0
- package/lib/utils/props/textInputProps.js +0 -0
- package/lib/utils/props/textProps.js +0 -0
- package/lib/utils/props/tokens.js +0 -0
- package/lib/utils/props/variantProp.js +0 -0
- package/lib/utils/props/viewProps.js +0 -0
- package/lib/utils/ssr-media-query/create-stylesheet/create-stylesheet-mobile.js +0 -0
- package/lib/utils/ssr-media-query/create-stylesheet/index.android.js +0 -0
- package/lib/utils/ssr-media-query/create-stylesheet/index.ios.js +0 -0
- package/lib/utils/ssr-media-query/create-stylesheet/index.js +0 -0
- package/lib/utils/ssr-media-query/hash.js +0 -0
- package/lib/utils/ssr-media-query/index.js +0 -0
- package/lib/utils/ssr-media-query/utils/common.js +0 -0
- package/lib/utils/ssr-media-query/utils/create-declaration-block.js +0 -0
- package/lib/utils/ssr-media-query/utils/create-media-query-styles.js +0 -0
- package/lib/utils/ssr-media-query/utils/hyphenate-style-name.js +0 -0
- package/lib/utils/ssr-media-query/utils/inject.js +0 -0
- package/lib/utils/ssr.js +0 -0
- package/lib/utils/transformGradient.js +0 -0
- package/lib/utils/useCopy.js +0 -0
- package/lib/utils/useHash.js +0 -0
- package/lib/utils/useHash.native.js +0 -0
- package/lib/utils/useOverlaidPosition.js +0 -0
- package/lib/utils/useResponsiveProp.js +0 -0
- package/lib/utils/useSafeLayoutEffect.js +0 -0
- package/lib/utils/useScrollBlocking.js +0 -0
- package/lib/utils/useScrollBlocking.native.js +0 -0
- package/lib/utils/useSpacingScale.js +0 -0
- package/lib/utils/useUniqueId.js +0 -0
- package/lib/utils/withLinkRouter.js +0 -0
- package/package.json +2 -2
- package/src/Card/PressableCardBase.jsx +1 -1
- package/src/Carousel/Carousel.jsx +166 -34
- package/src/Carousel/CarouselItem/CarouselItem.jsx +56 -26
- package/src/Carousel/CarouselStepTracker/CarouselStepTracker.jsx +71 -37
- package/src/Carousel/Constants.js +3 -0
- package/src/Checkbox/CheckboxGroup.jsx +7 -3
- package/src/HorizontalScroll/HorizontalScroll.jsx +19 -15
- package/src/Icon/Icon.jsx +1 -0
- package/src/InputSupports/InputSupports.jsx +1 -0
- package/src/Link/LinkBase.jsx +8 -2
- package/src/Modal/Modal.jsx +4 -0
- package/src/Modal/ModalContent.jsx +23 -7
- package/src/Progress/Progress.jsx +12 -2
- package/src/Progress/ProgressBar.jsx +48 -13
- package/src/Progress/ProgressBarBackground.jsx +4 -2
- package/src/Progress/constants.js +4 -0
- package/src/Search/Search.jsx +7 -2
- package/src/Select/Picker.native.jsx +1 -0
- package/src/Select/Select.jsx +8 -9
- package/src/Status/Status.jsx +2 -2
- package/src/TextInput/TextInputBase.jsx +2 -2
- package/src/Tooltip/Tooltip.jsx +6 -1
- package/src/Tooltip/Tooltip.native.jsx +7 -1
- package/src/Validator/Validator.jsx +7 -1
- package/src/utils/props/contentfulProps.js +24 -0
- package/src/utils/props/index.js +1 -0
|
@@ -25,6 +25,7 @@ import CarouselThumbnailNavigation from './CarouselThumbnailNavigation'
|
|
|
25
25
|
import CarouselTabsPanel from './CarouselTabs/CarouselTabsPanel'
|
|
26
26
|
import CarouselTabsPanelItem from './CarouselTabs/CarouselTabsPanelItem'
|
|
27
27
|
import dictionary from './dictionary'
|
|
28
|
+
import { ITEMS_PER_VIEWPORT_MD, ITEMS_PER_VIEWPORT_LG_XL } from './Constants'
|
|
28
29
|
|
|
29
30
|
const TRANSITION_MODES = {
|
|
30
31
|
MANUAL: 'manual',
|
|
@@ -55,9 +56,15 @@ const selectContainerStyles = (width) => ({
|
|
|
55
56
|
width
|
|
56
57
|
})
|
|
57
58
|
|
|
58
|
-
const selectSwipeAreaStyles = (
|
|
59
|
+
const selectSwipeAreaStyles = (
|
|
60
|
+
count,
|
|
61
|
+
width,
|
|
62
|
+
enablePeeking,
|
|
63
|
+
enableDisplayMultipleItemsPerSlide
|
|
64
|
+
) => ({
|
|
59
65
|
width: width * count,
|
|
60
|
-
justifyContent:
|
|
66
|
+
justifyContent:
|
|
67
|
+
enablePeeking || enableDisplayMultipleItemsPerSlide ? 'flex-start' : 'space-between',
|
|
61
68
|
flexDirection: 'row'
|
|
62
69
|
})
|
|
63
70
|
|
|
@@ -69,7 +76,8 @@ const selectControlButtonPositionStyles = ({
|
|
|
69
76
|
buttonWidth,
|
|
70
77
|
positionProperty = getDynamicPositionProperty(),
|
|
71
78
|
spaceBetweenSlideAndButton,
|
|
72
|
-
enablePeeking
|
|
79
|
+
enablePeeking,
|
|
80
|
+
enableDisplayMultipleItemsPerSlide
|
|
73
81
|
}) => {
|
|
74
82
|
const styles = {}
|
|
75
83
|
if (positionVariant === 'edge') {
|
|
@@ -77,7 +85,7 @@ const selectControlButtonPositionStyles = ({
|
|
|
77
85
|
} else if (positionVariant === 'inside') {
|
|
78
86
|
styles[positionProperty] = 0
|
|
79
87
|
} else if (positionVariant === 'outside') {
|
|
80
|
-
if (enablePeeking) {
|
|
88
|
+
if (enablePeeking || enableDisplayMultipleItemsPerSlide) {
|
|
81
89
|
styles[positionProperty] = 0
|
|
82
90
|
} else {
|
|
83
91
|
styles[positionProperty] = -1 * (spaceBetweenSlideAndButton + buttonWidth)
|
|
@@ -93,7 +101,8 @@ const selectPreviousNextNavigationButtonStyles = (
|
|
|
93
101
|
isFirstSlide,
|
|
94
102
|
isLastSlide,
|
|
95
103
|
areStylesAppliedOnPreviousButton,
|
|
96
|
-
enablePeeking
|
|
104
|
+
enablePeeking,
|
|
105
|
+
enableDisplayMultipleItemsPerSlide
|
|
97
106
|
) => {
|
|
98
107
|
const styles = {
|
|
99
108
|
zIndex: 1,
|
|
@@ -114,7 +123,8 @@ const selectPreviousNextNavigationButtonStyles = (
|
|
|
114
123
|
buttonWidth: previousNextNavigationButtonWidth,
|
|
115
124
|
positionProperty: getDynamicPositionProperty(areStylesAppliedOnPreviousButton),
|
|
116
125
|
spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation,
|
|
117
|
-
enablePeeking
|
|
126
|
+
enablePeeking,
|
|
127
|
+
enableDisplayMultipleItemsPerSlide
|
|
118
128
|
})
|
|
119
129
|
}
|
|
120
130
|
}
|
|
@@ -140,6 +150,88 @@ const getPeekingProps = (viewport) => {
|
|
|
140
150
|
}
|
|
141
151
|
}
|
|
142
152
|
|
|
153
|
+
const getTotalItems = (enableDisplayMultipleItemsPerSlide, childrenArray, viewport) => {
|
|
154
|
+
if (enableDisplayMultipleItemsPerSlide) {
|
|
155
|
+
switch (viewport) {
|
|
156
|
+
case 'xs':
|
|
157
|
+
case 'sm':
|
|
158
|
+
return childrenArray.length
|
|
159
|
+
case 'md':
|
|
160
|
+
return Math.ceil(childrenArray.length / ITEMS_PER_VIEWPORT_MD)
|
|
161
|
+
case 'lg':
|
|
162
|
+
case 'xl':
|
|
163
|
+
return Math.ceil(childrenArray.length / ITEMS_PER_VIEWPORT_LG_XL)
|
|
164
|
+
default:
|
|
165
|
+
break
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return childrenArray.length
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Calculates the final width of the carousel container for displacement purposes based on various conditions.
|
|
173
|
+
*
|
|
174
|
+
* @param {number} containerWidth - The initial width of the container.
|
|
175
|
+
* @param {boolean} enablePeeking - Flag indicating if peeking is enabled.
|
|
176
|
+
* @param {object} viewport - The viewport properties.
|
|
177
|
+
* @param {object} activeIndexRef - A ref object holding the current active index.
|
|
178
|
+
* @param {number} totalItems - The total number of items in the carousel.
|
|
179
|
+
* @param {number} calcDelta - The delta value used for calculations.
|
|
180
|
+
* @returns {number} - The final calculated width of the container.
|
|
181
|
+
*
|
|
182
|
+
* The function adjusts the container width for displacement purposes based on the peeking properties and the position
|
|
183
|
+
* of the active item (first, middle, or last). It considers different peeking spaces and gaps
|
|
184
|
+
* to ensure the correct width is calculated for the carousel to display properly.
|
|
185
|
+
*/
|
|
186
|
+
const calculateFinalWidth = (
|
|
187
|
+
containerWidth,
|
|
188
|
+
enablePeeking,
|
|
189
|
+
viewport,
|
|
190
|
+
activeIndexRef,
|
|
191
|
+
totalItems,
|
|
192
|
+
calcDelta
|
|
193
|
+
) => {
|
|
194
|
+
let finalWidth = containerWidth
|
|
195
|
+
|
|
196
|
+
if (enablePeeking) {
|
|
197
|
+
const { peekingFirstSpace, peekingGap, peekingLastSpace, peekingMiddleSpace } =
|
|
198
|
+
getPeekingProps(viewport)
|
|
199
|
+
|
|
200
|
+
const isFirst = activeIndexRef.current === 0
|
|
201
|
+
const isLast = activeIndexRef.current + 1 >= totalItems
|
|
202
|
+
const isMiddle = !isFirst && !isLast
|
|
203
|
+
|
|
204
|
+
const basePeekingSpace = peekingFirstSpace + peekingGap + peekingMiddleSpace
|
|
205
|
+
const middlePeekingSpace = peekingMiddleSpace * 2 + peekingGap
|
|
206
|
+
|
|
207
|
+
if (isFirst) {
|
|
208
|
+
finalWidth -= basePeekingSpace
|
|
209
|
+
if (activeIndexRef.current + 1 === totalItems - 1) {
|
|
210
|
+
finalWidth -= peekingLastSpace - peekingMiddleSpace
|
|
211
|
+
}
|
|
212
|
+
} else if (isMiddle) {
|
|
213
|
+
if (calcDelta > 0) {
|
|
214
|
+
finalWidth -= basePeekingSpace + middlePeekingSpace * activeIndexRef.current
|
|
215
|
+
if (activeIndexRef.current + 1 === totalItems - 1) {
|
|
216
|
+
finalWidth -= peekingLastSpace - peekingMiddleSpace
|
|
217
|
+
}
|
|
218
|
+
} else {
|
|
219
|
+
finalWidth += basePeekingSpace + middlePeekingSpace * (activeIndexRef.current - 2)
|
|
220
|
+
if (activeIndexRef.current - 1 === 0) {
|
|
221
|
+
finalWidth -= peekingFirstSpace - peekingMiddleSpace
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
} else if (isLast) {
|
|
225
|
+
finalWidth += basePeekingSpace + middlePeekingSpace * (activeIndexRef.current - 2)
|
|
226
|
+
if (activeIndexRef.current - 1 === 0) {
|
|
227
|
+
finalWidth -= peekingLastSpace - peekingMiddleSpace
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return finalWidth
|
|
233
|
+
}
|
|
234
|
+
|
|
143
235
|
const selectIconStyles = ({ iconBackgroundColor }) => ({ backgroundColor: iconBackgroundColor })
|
|
144
236
|
|
|
145
237
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
|
|
@@ -219,10 +311,14 @@ const Carousel = React.forwardRef(
|
|
|
219
311
|
title = 'carousel',
|
|
220
312
|
springConfig = undefined,
|
|
221
313
|
thumbnails = undefined,
|
|
314
|
+
enableDisplayMultipleItemsPerSlide = false,
|
|
222
315
|
panelNavigation = thumbnails ? (
|
|
223
316
|
<CarouselThumbnailNavigation thumbnails={thumbnails} />
|
|
224
317
|
) : (
|
|
225
|
-
<CarouselStepTracker
|
|
318
|
+
<CarouselStepTracker
|
|
319
|
+
variant={stepTrackerVariant}
|
|
320
|
+
enableDisplayMultipleItemsPerSlide={enableDisplayMultipleItemsPerSlide}
|
|
321
|
+
/>
|
|
226
322
|
),
|
|
227
323
|
tag = 'ul',
|
|
228
324
|
accessibilityRole,
|
|
@@ -238,14 +334,16 @@ const Carousel = React.forwardRef(
|
|
|
238
334
|
ref
|
|
239
335
|
) => {
|
|
240
336
|
let childrenArray = unpackFragment(children)
|
|
337
|
+
const viewport = useViewport()
|
|
338
|
+
const totalItems = getTotalItems(enableDisplayMultipleItemsPerSlide, childrenArray, viewport)
|
|
241
339
|
const autoPlayFeatureEnabled =
|
|
242
|
-
autoPlay && slideDuration > 0 && transitionDuration > 0 &&
|
|
340
|
+
autoPlay && slideDuration > 0 && transitionDuration > 0 && totalItems > 1
|
|
243
341
|
// if `Carousel` only has one `Carousel.Item`, convert this to a single-item array
|
|
244
342
|
if (!Array.isArray(childrenArray)) {
|
|
245
343
|
childrenArray = [childrenArray]
|
|
246
344
|
}
|
|
247
345
|
const getCopy = useCopy({ dictionary, copy })
|
|
248
|
-
|
|
346
|
+
|
|
249
347
|
const themeTokens = useThemeTokens('Carousel', tokens, variant, {
|
|
250
348
|
viewport
|
|
251
349
|
})
|
|
@@ -289,7 +387,7 @@ const Carousel = React.forwardRef(
|
|
|
289
387
|
const autoPlayRef = React.useRef(null)
|
|
290
388
|
|
|
291
389
|
const isFirstSlide = !activeIndex
|
|
292
|
-
const isLastSlide = activeIndex + 1 >=
|
|
390
|
+
const isLastSlide = activeIndex + 1 >= totalItems
|
|
293
391
|
|
|
294
392
|
const handleAnimationStart = React.useCallback(
|
|
295
393
|
(...args) => {
|
|
@@ -330,7 +428,7 @@ const Carousel = React.forwardRef(
|
|
|
330
428
|
useNativeDriver: false,
|
|
331
429
|
duration: transitionDuration * 1000
|
|
332
430
|
}).start(handleAnimationEndToIndex)
|
|
333
|
-
} else if (enablePeeking) {
|
|
431
|
+
} else if (enablePeeking || enableDisplayMultipleItemsPerSlide) {
|
|
334
432
|
Animated.timing(pan, {
|
|
335
433
|
...springConfig,
|
|
336
434
|
toValue,
|
|
@@ -345,7 +443,15 @@ const Carousel = React.forwardRef(
|
|
|
345
443
|
}).start(handleAnimationEndToIndex)
|
|
346
444
|
}
|
|
347
445
|
},
|
|
348
|
-
[
|
|
446
|
+
[
|
|
447
|
+
pan,
|
|
448
|
+
springConfig,
|
|
449
|
+
handleAnimationEnd,
|
|
450
|
+
transitionDuration,
|
|
451
|
+
isAutoPlayEnabled,
|
|
452
|
+
enablePeeking,
|
|
453
|
+
enableDisplayMultipleItemsPerSlide
|
|
454
|
+
]
|
|
349
455
|
)
|
|
350
456
|
|
|
351
457
|
const stopAutoplay = React.useCallback(() => {
|
|
@@ -367,8 +473,8 @@ const Carousel = React.forwardRef(
|
|
|
367
473
|
let calcDelta = delta
|
|
368
474
|
if (activeIndexRef.current <= 0 && delta < 0) {
|
|
369
475
|
skipChanges = transitionMode !== TRANSITION_MODES.AUTOMATIC
|
|
370
|
-
calcDelta =
|
|
371
|
-
} else if (activeIndexRef.current + 1 >=
|
|
476
|
+
calcDelta = totalItems + delta
|
|
477
|
+
} else if (activeIndexRef.current + 1 >= totalItems && delta > 0) {
|
|
372
478
|
skipChanges = transitionMode !== TRANSITION_MODES.AUTOMATIC
|
|
373
479
|
calcDelta = -1 * activeIndexRef.current + delta - 1
|
|
374
480
|
}
|
|
@@ -382,13 +488,22 @@ const Carousel = React.forwardRef(
|
|
|
382
488
|
stopAutoplay()
|
|
383
489
|
setActiveIndex(index)
|
|
384
490
|
|
|
385
|
-
|
|
491
|
+
const finalWidth = calculateFinalWidth(
|
|
492
|
+
containerLayoutRef.current.width,
|
|
493
|
+
enablePeeking,
|
|
494
|
+
viewport,
|
|
495
|
+
activeIndexRef,
|
|
496
|
+
totalItems,
|
|
497
|
+
calcDelta
|
|
498
|
+
)
|
|
499
|
+
|
|
500
|
+
toValue.x = finalWidth * -1 * calcDelta
|
|
386
501
|
animate(toValue, index)
|
|
387
502
|
if (isCarouselPlaying) {
|
|
388
503
|
stopAutoplay()
|
|
389
504
|
if (
|
|
390
505
|
index === 0 &&
|
|
391
|
-
activeIndexRef.current + 1 ===
|
|
506
|
+
activeIndexRef.current + 1 === totalItems &&
|
|
392
507
|
transitionMode === TRANSITION_MODES.AUTOMATIC
|
|
393
508
|
) {
|
|
394
509
|
setisCarouselPlaying(false)
|
|
@@ -410,11 +525,13 @@ const Carousel = React.forwardRef(
|
|
|
410
525
|
slideDuration,
|
|
411
526
|
updateOffset,
|
|
412
527
|
animate,
|
|
413
|
-
|
|
528
|
+
totalItems,
|
|
414
529
|
onIndexChanged,
|
|
415
530
|
isCarouselPlaying,
|
|
416
531
|
stopAutoplay,
|
|
417
|
-
isAutoPlayEnabled
|
|
532
|
+
isAutoPlayEnabled,
|
|
533
|
+
viewport,
|
|
534
|
+
enablePeeking
|
|
418
535
|
]
|
|
419
536
|
)
|
|
420
537
|
|
|
@@ -500,9 +617,9 @@ const Carousel = React.forwardRef(
|
|
|
500
617
|
|
|
501
618
|
React.useEffect(() => {
|
|
502
619
|
setIsAutoPlayEnabled(
|
|
503
|
-
autoPlay && slideDuration > 0 && transitionDuration > 0 &&
|
|
620
|
+
autoPlay && slideDuration > 0 && transitionDuration > 0 && totalItems > 1
|
|
504
621
|
)
|
|
505
|
-
}, [autoPlay, slideDuration, transitionDuration,
|
|
622
|
+
}, [autoPlay, slideDuration, transitionDuration, totalItems])
|
|
506
623
|
|
|
507
624
|
React.useEffect(() => {
|
|
508
625
|
return () => {
|
|
@@ -523,14 +640,14 @@ const Carousel = React.forwardRef(
|
|
|
523
640
|
}) => setPreviousNextNavigationButtonWidth(width)
|
|
524
641
|
|
|
525
642
|
const isSwipeAllowed = React.useCallback(() => {
|
|
526
|
-
if (
|
|
643
|
+
if (totalItems === 1) {
|
|
527
644
|
return false
|
|
528
645
|
}
|
|
529
646
|
if (Platform.OS === 'web') {
|
|
530
647
|
return !!(viewport === 'xs' || viewport === 'sm')
|
|
531
648
|
}
|
|
532
649
|
return true
|
|
533
|
-
}, [viewport,
|
|
650
|
+
}, [viewport, totalItems])
|
|
534
651
|
|
|
535
652
|
const panResponder = React.useMemo(
|
|
536
653
|
() =>
|
|
@@ -623,12 +740,12 @@ const Carousel = React.forwardRef(
|
|
|
623
740
|
.replace(/%\{title\}/g, title)
|
|
624
741
|
.replace(/%\{itemLabel\}/g, itemLabel)
|
|
625
742
|
.replace(/%\{stepNumber\}/g, activeIndex + 1)
|
|
626
|
-
.replace(/%\{stepCount\}/g,
|
|
743
|
+
.replace(/%\{stepCount\}/g, totalItems)
|
|
627
744
|
|
|
628
745
|
// First word might be a lowercase placeholder: capitalize the first letter
|
|
629
746
|
return `${copyText[0].toUpperCase()}${copyText.slice(1)}`
|
|
630
747
|
},
|
|
631
|
-
[activeIndex,
|
|
748
|
+
[activeIndex, itemLabel, getCopy, title, totalItems]
|
|
632
749
|
)
|
|
633
750
|
|
|
634
751
|
const activePanelNavigation =
|
|
@@ -682,7 +799,7 @@ const Carousel = React.forwardRef(
|
|
|
682
799
|
goTo={goTo}
|
|
683
800
|
getCopyWithPlaceholders={getCopyWithPlaceholders}
|
|
684
801
|
itemLabel={itemLabel}
|
|
685
|
-
totalItems={
|
|
802
|
+
totalItems={totalItems}
|
|
686
803
|
themeTokens={themeTokens}
|
|
687
804
|
firstFocusRef={firstFocusRef}
|
|
688
805
|
refocus={refocus}
|
|
@@ -713,7 +830,8 @@ const Carousel = React.forwardRef(
|
|
|
713
830
|
buttonWidth: previousNextNavigationButtonWidth,
|
|
714
831
|
positionProperty: getDynamicPositionProperty(),
|
|
715
832
|
spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation,
|
|
716
|
-
enablePeeking
|
|
833
|
+
enablePeeking,
|
|
834
|
+
enableDisplayMultipleItemsPerSlide
|
|
717
835
|
})
|
|
718
836
|
]}
|
|
719
837
|
>
|
|
@@ -727,7 +845,7 @@ const Carousel = React.forwardRef(
|
|
|
727
845
|
/>
|
|
728
846
|
</View>
|
|
729
847
|
) : null}
|
|
730
|
-
{showPreviousNextNavigation &&
|
|
848
|
+
{showPreviousNextNavigation && totalItems > 1 ? (
|
|
731
849
|
<View
|
|
732
850
|
style={selectPreviousNextNavigationButtonStyles(
|
|
733
851
|
previousNextNavigationButtonWidth,
|
|
@@ -736,7 +854,8 @@ const Carousel = React.forwardRef(
|
|
|
736
854
|
isFirstSlide,
|
|
737
855
|
isLastSlide,
|
|
738
856
|
true,
|
|
739
|
-
enablePeeking
|
|
857
|
+
enablePeeking,
|
|
858
|
+
enableDisplayMultipleItemsPerSlide
|
|
740
859
|
)}
|
|
741
860
|
testID="previous-button-container"
|
|
742
861
|
>
|
|
@@ -769,7 +888,12 @@ const Carousel = React.forwardRef(
|
|
|
769
888
|
<View style={selectContainerStyles(containerLayout.width)}>
|
|
770
889
|
<Animated.View
|
|
771
890
|
style={StyleSheet.flatten([
|
|
772
|
-
selectSwipeAreaStyles(
|
|
891
|
+
selectSwipeAreaStyles(
|
|
892
|
+
totalItems,
|
|
893
|
+
containerLayout.width,
|
|
894
|
+
enablePeeking,
|
|
895
|
+
enableDisplayMultipleItemsPerSlide
|
|
896
|
+
),
|
|
773
897
|
{
|
|
774
898
|
transform: [{ translateX: pan.x }, { translateY: pan.y }]
|
|
775
899
|
}
|
|
@@ -784,15 +908,17 @@ const Carousel = React.forwardRef(
|
|
|
784
908
|
const hidden = !isAnimating && index !== activeIndex
|
|
785
909
|
const clonedElement = React.cloneElement(element, {
|
|
786
910
|
elementIndex: index,
|
|
787
|
-
hidden: enablePeeking ? false : hidden,
|
|
911
|
+
hidden: enablePeeking || enableDisplayMultipleItemsPerSlide ? false : hidden,
|
|
788
912
|
enablePeeking,
|
|
789
|
-
peekingProps: getPeekingProps(viewport)
|
|
913
|
+
peekingProps: getPeekingProps(viewport),
|
|
914
|
+
enableDisplayMultipleItemsPerSlide,
|
|
915
|
+
viewport
|
|
790
916
|
})
|
|
791
917
|
return <React.Fragment key={index.toFixed(2)}>{clonedElement}</React.Fragment>
|
|
792
918
|
})}
|
|
793
919
|
</Animated.View>
|
|
794
920
|
</View>
|
|
795
|
-
{showPreviousNextNavigation &&
|
|
921
|
+
{showPreviousNextNavigation && totalItems > 1 ? (
|
|
796
922
|
<View
|
|
797
923
|
style={selectPreviousNextNavigationButtonStyles(
|
|
798
924
|
previousNextNavigationButtonWidth,
|
|
@@ -801,7 +927,8 @@ const Carousel = React.forwardRef(
|
|
|
801
927
|
isFirstSlide,
|
|
802
928
|
isLastSlide,
|
|
803
929
|
false,
|
|
804
|
-
enablePeeking
|
|
930
|
+
enablePeeking,
|
|
931
|
+
enableDisplayMultipleItemsPerSlide
|
|
805
932
|
)}
|
|
806
933
|
testID="next-button-container"
|
|
807
934
|
>
|
|
@@ -1008,7 +1135,12 @@ Carousel.propTypes = {
|
|
|
1008
1135
|
* If set to `true`, the Carousel will show the previous and next slides
|
|
1009
1136
|
* - Default value is `false`
|
|
1010
1137
|
*/
|
|
1011
|
-
enablePeeking: PropTypes.bool
|
|
1138
|
+
enablePeeking: PropTypes.bool,
|
|
1139
|
+
/**
|
|
1140
|
+
* If set to `true`, the Carousel will show multiple slides at once
|
|
1141
|
+
* - Default value is `false`
|
|
1142
|
+
*/
|
|
1143
|
+
enableDisplayMultipleItemsPerSlide: PropTypes.bool
|
|
1012
1144
|
}
|
|
1013
1145
|
|
|
1014
1146
|
Carousel.Item = CarouselItem
|
|
@@ -10,50 +10,67 @@ import {
|
|
|
10
10
|
variantProp
|
|
11
11
|
} from '../../utils'
|
|
12
12
|
import { useCarousel } from '../CarouselContext'
|
|
13
|
+
import { ITEMS_PER_VIEWPORT_MD, ITEMS_PER_VIEWPORT_LG_XL, GAP_BETWEEN_ITEMS } from '../Constants'
|
|
13
14
|
|
|
14
15
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
|
|
15
16
|
|
|
16
17
|
const selectContainerStyle = ({
|
|
17
18
|
width,
|
|
18
|
-
activeIndex,
|
|
19
19
|
elementIndex,
|
|
20
|
-
totalItems,
|
|
21
20
|
enablePeeking,
|
|
22
21
|
peekingMarginLeft,
|
|
23
22
|
peekingFirstSpace,
|
|
24
|
-
peekingLastSpace,
|
|
25
|
-
peekingMiddleSpace,
|
|
26
23
|
peekingGap,
|
|
27
|
-
hidden
|
|
24
|
+
hidden,
|
|
25
|
+
enableDisplayMultipleItemsPerSlide,
|
|
26
|
+
viewport
|
|
28
27
|
}) => {
|
|
29
28
|
let adjustedWidth = width
|
|
30
29
|
let marginLeft = 0
|
|
31
30
|
const marginRight = 0
|
|
32
31
|
|
|
33
32
|
if (enablePeeking) {
|
|
34
|
-
adjustedWidth = width - (peekingMarginLeft + peekingGap + peekingFirstSpace)
|
|
35
33
|
const isFirst = elementIndex === 0
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (isFirst) {
|
|
40
|
-
marginLeft = peekingMarginLeft
|
|
41
|
-
} else {
|
|
42
|
-
marginLeft = peekingGap
|
|
43
|
-
}
|
|
44
|
-
} else if (isFirst) {
|
|
45
|
-
marginLeft = peekingMarginLeft + peekingGap + peekingFirstSpace + peekingMiddleSpace
|
|
46
|
-
if (activeIndex > 1) {
|
|
47
|
-
marginLeft += (peekingGap + peekingMiddleSpace * 2) * (activeIndex - 1)
|
|
48
|
-
}
|
|
49
|
-
if (activeIndex === totalItems - 1) {
|
|
50
|
-
marginLeft += peekingLastSpace - peekingMiddleSpace
|
|
51
|
-
}
|
|
34
|
+
adjustedWidth = width - (peekingMarginLeft + peekingGap + peekingFirstSpace)
|
|
35
|
+
if (isFirst) {
|
|
36
|
+
marginLeft = peekingMarginLeft
|
|
52
37
|
} else {
|
|
53
38
|
marginLeft = peekingGap
|
|
54
39
|
}
|
|
55
40
|
}
|
|
56
41
|
|
|
42
|
+
// Adjust width and margins for multiple items per slide.
|
|
43
|
+
if (enableDisplayMultipleItemsPerSlide) {
|
|
44
|
+
switch (viewport) {
|
|
45
|
+
case 'xs':
|
|
46
|
+
case 'sm':
|
|
47
|
+
break
|
|
48
|
+
case 'md':
|
|
49
|
+
if (enablePeeking) {
|
|
50
|
+
adjustedWidth =
|
|
51
|
+
adjustedWidth / ITEMS_PER_VIEWPORT_MD - (peekingGap * 1) / ITEMS_PER_VIEWPORT_MD
|
|
52
|
+
} else {
|
|
53
|
+
adjustedWidth =
|
|
54
|
+
width / ITEMS_PER_VIEWPORT_MD - (GAP_BETWEEN_ITEMS * 2) / ITEMS_PER_VIEWPORT_MD
|
|
55
|
+
marginLeft = GAP_BETWEEN_ITEMS
|
|
56
|
+
}
|
|
57
|
+
break
|
|
58
|
+
case 'lg':
|
|
59
|
+
case 'xl':
|
|
60
|
+
if (enablePeeking) {
|
|
61
|
+
adjustedWidth =
|
|
62
|
+
adjustedWidth / ITEMS_PER_VIEWPORT_LG_XL - (peekingGap * 2) / ITEMS_PER_VIEWPORT_LG_XL
|
|
63
|
+
} else {
|
|
64
|
+
adjustedWidth =
|
|
65
|
+
width / ITEMS_PER_VIEWPORT_LG_XL - (GAP_BETWEEN_ITEMS * 3) / ITEMS_PER_VIEWPORT_LG_XL
|
|
66
|
+
marginLeft = GAP_BETWEEN_ITEMS
|
|
67
|
+
}
|
|
68
|
+
break
|
|
69
|
+
default:
|
|
70
|
+
break
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
57
74
|
const style = {
|
|
58
75
|
width: adjustedWidth,
|
|
59
76
|
marginLeft,
|
|
@@ -72,8 +89,21 @@ const selectContainerStyle = ({
|
|
|
72
89
|
* only top-level component passed to the `Carousel`
|
|
73
90
|
*/
|
|
74
91
|
const CarouselItem = React.forwardRef(
|
|
75
|
-
(
|
|
76
|
-
|
|
92
|
+
(
|
|
93
|
+
{
|
|
94
|
+
children,
|
|
95
|
+
elementIndex,
|
|
96
|
+
tag = 'li',
|
|
97
|
+
hidden,
|
|
98
|
+
enablePeeking,
|
|
99
|
+
peekingProps,
|
|
100
|
+
enableDisplayMultipleItemsPerSlide,
|
|
101
|
+
viewport,
|
|
102
|
+
...rest
|
|
103
|
+
},
|
|
104
|
+
ref
|
|
105
|
+
) => {
|
|
106
|
+
const { width, activeIndex, height } = useCarousel()
|
|
77
107
|
|
|
78
108
|
const selectedProps = selectProps({
|
|
79
109
|
...rest,
|
|
@@ -86,12 +116,12 @@ const CarouselItem = React.forwardRef(
|
|
|
86
116
|
<View
|
|
87
117
|
style={selectContainerStyle({
|
|
88
118
|
width,
|
|
89
|
-
activeIndex,
|
|
90
119
|
elementIndex,
|
|
91
|
-
totalItems,
|
|
92
120
|
hidden,
|
|
93
121
|
height,
|
|
94
122
|
enablePeeking,
|
|
123
|
+
enableDisplayMultipleItemsPerSlide,
|
|
124
|
+
viewport,
|
|
95
125
|
...peekingProps
|
|
96
126
|
})}
|
|
97
127
|
{...selectedProps}
|
|
@@ -1,52 +1,86 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import { StyleSheet, View } from 'react-native'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
2
4
|
import { useCarousel } from '../CarouselContext'
|
|
3
5
|
import StepTracker from '../../StepTracker'
|
|
4
6
|
import StackView from '../../StackView'
|
|
7
|
+
import Spacer from '../../Spacer'
|
|
8
|
+
import Progress from '../../Progress'
|
|
5
9
|
import { variantProp } from '../../utils'
|
|
6
10
|
|
|
7
|
-
const CarouselStepTracker = React.forwardRef(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
const CarouselStepTracker = React.forwardRef(
|
|
12
|
+
({ variant, enableDisplayMultipleItemsPerSlide }, ref) => {
|
|
13
|
+
const {
|
|
14
|
+
activeIndex,
|
|
15
|
+
totalItems,
|
|
16
|
+
getCopyWithPlaceholders,
|
|
17
|
+
themeTokens: { stepTrackerCurrentBackgroundColor, ...themeTokens }
|
|
18
|
+
} = useCarousel()
|
|
19
|
+
const stackViewTokens = {
|
|
20
|
+
justifyContent: 'center'
|
|
21
|
+
}
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const stepTrackerTokens = {
|
|
24
|
+
showStepLabel: false,
|
|
25
|
+
showStepTrackerLabel: true,
|
|
26
|
+
// TODO: StepTracker 'isComplete'/'isCurrent' is incorrect, see line StepTracker/Step.jsx line 63, refactor incorrect values and remove this
|
|
27
|
+
knobCompletedBackgroundColor: stepTrackerCurrentBackgroundColor ?? 'none',
|
|
28
|
+
connectorCompletedColor: 'none',
|
|
29
|
+
connectorColor: 'none',
|
|
30
|
+
containerPaddingTop: themeTokens.spaceBetweenSlideAndPanelNavigation
|
|
31
|
+
}
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
const steps = Array.from(Array(totalItems)).map((_, index) => String(index))
|
|
34
|
+
|
|
35
|
+
if (enableDisplayMultipleItemsPerSlide) {
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<Spacer space={4} />
|
|
39
|
+
<StackView direction="row" tokens={stackViewTokens} ref={ref}>
|
|
40
|
+
<View style={staticStyles.progress}>
|
|
41
|
+
<Progress>
|
|
42
|
+
<Progress.Bar
|
|
43
|
+
offset={{
|
|
44
|
+
items: totalItems,
|
|
45
|
+
current: activeIndex + 1
|
|
46
|
+
}}
|
|
47
|
+
variant={{ style: 'subtle' }}
|
|
48
|
+
accessibilityLabel={getCopyWithPlaceholders('stepTrackerLabel')}
|
|
49
|
+
/>
|
|
50
|
+
</Progress>
|
|
51
|
+
</View>
|
|
52
|
+
</StackView>
|
|
53
|
+
</>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
return (
|
|
57
|
+
<StackView direction="row" tokens={stackViewTokens} ref={ref}>
|
|
58
|
+
<StepTracker
|
|
59
|
+
current={activeIndex}
|
|
60
|
+
steps={steps}
|
|
61
|
+
copy={{
|
|
62
|
+
stepLabel: getCopyWithPlaceholders('stepLabel'),
|
|
63
|
+
stepTrackerLabel: getCopyWithPlaceholders('stepTrackerLabel')
|
|
64
|
+
}}
|
|
65
|
+
tokens={stepTrackerTokens}
|
|
66
|
+
variant={variant}
|
|
67
|
+
/>
|
|
68
|
+
</StackView>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
)
|
|
45
72
|
|
|
46
73
|
CarouselStepTracker.displayName = 'CarouselStepTracker'
|
|
47
74
|
|
|
48
75
|
CarouselStepTracker.propTypes = {
|
|
49
|
-
variant: variantProp.propType
|
|
76
|
+
variant: variantProp.propType,
|
|
77
|
+
enableDisplayMultipleItemsPerSlide: PropTypes.bool
|
|
50
78
|
}
|
|
51
79
|
|
|
80
|
+
const staticStyles = StyleSheet.create({
|
|
81
|
+
progress: {
|
|
82
|
+
width: 288
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
|
|
52
86
|
export default CarouselStepTracker
|