@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.
Files changed (392) hide show
  1. package/CHANGELOG.md +27 -2
  2. package/lib/A11yInfoProvider/index.js +0 -0
  3. package/lib/A11yText/index.js +0 -0
  4. package/lib/ActionCard/ActionCard.js +0 -0
  5. package/lib/ActionCard/index.js +0 -0
  6. package/lib/ActivityIndicator/Spinner.js +0 -0
  7. package/lib/ActivityIndicator/Spinner.native.js +0 -0
  8. package/lib/ActivityIndicator/index.js +0 -0
  9. package/lib/ActivityIndicator/shared.js +0 -0
  10. package/lib/Autocomplete/Autocomplete.js +0 -0
  11. package/lib/Autocomplete/Loading.js +0 -0
  12. package/lib/Autocomplete/Suggestions.js +0 -0
  13. package/lib/Autocomplete/constants.js +0 -0
  14. package/lib/Autocomplete/dictionary.js +0 -0
  15. package/lib/Autocomplete/index.js +0 -0
  16. package/lib/Badge/Badge.js +0 -0
  17. package/lib/Badge/index.js +0 -0
  18. package/lib/BaseProvider/HydrationContext.js +0 -0
  19. package/lib/BaseProvider/index.js +0 -0
  20. package/lib/Box/Box.js +0 -0
  21. package/lib/Box/backgroundImageStylesMap.js +0 -0
  22. package/lib/Box/index.js +0 -0
  23. package/lib/Button/Button.js +0 -0
  24. package/lib/Button/ButtonBase.js +0 -0
  25. package/lib/Button/ButtonDropdown.js +0 -0
  26. package/lib/Button/ButtonGroup.js +0 -0
  27. package/lib/Button/ButtonLink.js +0 -0
  28. package/lib/Button/index.js +0 -0
  29. package/lib/Button/propTypes.js +0 -0
  30. package/lib/Card/Card.js +0 -0
  31. package/lib/Card/CardBase.js +0 -0
  32. package/lib/Card/PressableCardBase.js +2 -1
  33. package/lib/Card/index.js +0 -0
  34. package/lib/CardGroup/CardGroup.js +0 -0
  35. package/lib/CardGroup/dictionary.js +0 -0
  36. package/lib/CardGroup/index.js +0 -0
  37. package/lib/Carousel/Carousel.js +121 -33
  38. package/lib/Carousel/CarouselContext.js +0 -0
  39. package/lib/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +0 -0
  40. package/lib/Carousel/CarouselItem/CarouselItem.js +39 -24
  41. package/lib/Carousel/CarouselItem/index.js +0 -0
  42. package/lib/Carousel/CarouselStepTracker/CarouselStepTracker.js +41 -4
  43. package/lib/Carousel/CarouselStepTracker/index.js +0 -0
  44. package/lib/Carousel/CarouselTabs/CarouselTabs.js +0 -0
  45. package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +0 -0
  46. package/lib/Carousel/CarouselTabs/CarouselTabsPanelItem.js +0 -0
  47. package/lib/Carousel/CarouselTabs/index.js +0 -0
  48. package/lib/Carousel/CarouselThumbnail.js +0 -0
  49. package/lib/Carousel/CarouselThumbnailNavigation.js +0 -0
  50. package/lib/Carousel/Constants.js +3 -0
  51. package/lib/Carousel/dictionary.js +0 -0
  52. package/lib/Carousel/index.js +0 -0
  53. package/lib/Checkbox/Checkbox.js +0 -0
  54. package/lib/Checkbox/CheckboxButton.js +0 -0
  55. package/lib/Checkbox/CheckboxGroup.js +4 -2
  56. package/lib/Checkbox/CheckboxInput.js +0 -0
  57. package/lib/Checkbox/CheckboxInput.native.js +0 -0
  58. package/lib/Checkbox/index.js +0 -0
  59. package/lib/CheckboxCard/CheckboxCard.js +0 -0
  60. package/lib/CheckboxCard/index.js +0 -0
  61. package/lib/CheckboxCardGroup/CheckboxCardGroup.js +0 -0
  62. package/lib/CheckboxCardGroup/index.js +0 -0
  63. package/lib/ColourToggle/ColourBubble.js +0 -0
  64. package/lib/ColourToggle/ColourToggle.js +0 -0
  65. package/lib/ColourToggle/index.js +0 -0
  66. package/lib/Divider/Divider.js +0 -0
  67. package/lib/Divider/index.js +0 -0
  68. package/lib/DownloadApp/DownloadApp.js +0 -0
  69. package/lib/DownloadApp/dictionary.js +0 -0
  70. package/lib/DownloadApp/index.js +0 -0
  71. package/lib/ExpandCollapse/Accordion.js +0 -0
  72. package/lib/ExpandCollapse/Control.js +0 -0
  73. package/lib/ExpandCollapse/ExpandCollapse.js +0 -0
  74. package/lib/ExpandCollapse/Panel.js +0 -0
  75. package/lib/ExpandCollapse/dictionary.js +0 -0
  76. package/lib/ExpandCollapse/index.js +0 -0
  77. package/lib/Feedback/Feedback.js +0 -0
  78. package/lib/Feedback/index.js +0 -0
  79. package/lib/Fieldset/Fieldset.js +0 -0
  80. package/lib/Fieldset/FieldsetContainer.js +0 -0
  81. package/lib/Fieldset/FieldsetContainer.native.js +0 -0
  82. package/lib/Fieldset/Legend.js +0 -0
  83. package/lib/Fieldset/Legend.native.js +0 -0
  84. package/lib/Fieldset/cssReset.js +0 -0
  85. package/lib/Fieldset/index.js +0 -0
  86. package/lib/FileUpload/FileUpload.js +0 -0
  87. package/lib/FileUpload/NotificationContent.js +0 -0
  88. package/lib/FileUpload/dictionary.js +0 -0
  89. package/lib/FileUpload/index.js +0 -0
  90. package/lib/FlexGrid/Col/Col.js +0 -0
  91. package/lib/FlexGrid/Col/index.js +0 -0
  92. package/lib/FlexGrid/FlexGrid.js +0 -0
  93. package/lib/FlexGrid/Row/Row.js +0 -0
  94. package/lib/FlexGrid/Row/index.js +0 -0
  95. package/lib/FlexGrid/helpers/index.js +0 -0
  96. package/lib/FlexGrid/index.js +0 -0
  97. package/lib/FlexGrid/providers/GutterContext.js +0 -0
  98. package/lib/Footnote/Footnote.js +0 -0
  99. package/lib/Footnote/FootnoteLink.js +0 -0
  100. package/lib/Footnote/dictionary.js +0 -0
  101. package/lib/Footnote/index.js +0 -0
  102. package/lib/HorizontalScroll/HorizontalScroll.js +17 -13
  103. package/lib/HorizontalScroll/HorizontalScrollButton.js +0 -0
  104. package/lib/HorizontalScroll/ScrollViewEnd.js +0 -0
  105. package/lib/HorizontalScroll/ScrollViewEnd.native.js +0 -0
  106. package/lib/HorizontalScroll/dictionary.js +0 -0
  107. package/lib/HorizontalScroll/index.js +0 -0
  108. package/lib/HorizontalScroll/itemPositions.js +0 -0
  109. package/lib/Icon/Icon.js +1 -0
  110. package/lib/Icon/IconText.js +0 -0
  111. package/lib/Icon/index.js +0 -0
  112. package/lib/IconButton/IconButton.js +0 -0
  113. package/lib/IconButton/index.js +0 -0
  114. package/lib/InputLabel/InputLabel.js +0 -0
  115. package/lib/InputLabel/LabelContent.js +0 -0
  116. package/lib/InputLabel/LabelContent.native.js +0 -0
  117. package/lib/InputLabel/index.js +0 -0
  118. package/lib/InputSupports/InputSupports.js +3 -0
  119. package/lib/InputSupports/index.js +0 -0
  120. package/lib/InputSupports/useInputSupports.js +0 -0
  121. package/lib/Link/ChevronLink.js +0 -0
  122. package/lib/Link/InlinePressable.js +0 -0
  123. package/lib/Link/InlinePressable.native.js +0 -0
  124. package/lib/Link/Link.js +0 -0
  125. package/lib/Link/LinkBase.js +2 -2
  126. package/lib/Link/TextButton.js +0 -0
  127. package/lib/Link/index.js +0 -0
  128. package/lib/List/List.js +0 -0
  129. package/lib/List/ListItem.js +0 -0
  130. package/lib/List/ListItemBase.js +0 -0
  131. package/lib/List/ListItemContent.js +0 -0
  132. package/lib/List/ListItemMark.js +0 -0
  133. package/lib/List/PressableListItemBase.js +0 -0
  134. package/lib/List/index.js +0 -0
  135. package/lib/Listbox/GroupControl.js +0 -0
  136. package/lib/Listbox/Listbox.js +0 -0
  137. package/lib/Listbox/ListboxContext.js +0 -0
  138. package/lib/Listbox/ListboxGroup.js +0 -0
  139. package/lib/Listbox/ListboxItem.js +0 -0
  140. package/lib/Listbox/ListboxOverlay.js +0 -0
  141. package/lib/Listbox/PressableItem.js +0 -0
  142. package/lib/Listbox/index.js +0 -0
  143. package/lib/Modal/Modal.js +4 -0
  144. package/lib/Modal/ModalContent.js +27 -8
  145. package/lib/Modal/WebModal.js +0 -0
  146. package/lib/Modal/dictionary.js +0 -0
  147. package/lib/Modal/index.js +0 -0
  148. package/lib/MultiSelectFilter/ModalOverlay.js +0 -0
  149. package/lib/MultiSelectFilter/MultiSelectFilter.js +0 -0
  150. package/lib/MultiSelectFilter/dictionary.js +0 -0
  151. package/lib/MultiSelectFilter/index.js +0 -0
  152. package/lib/Notification/Notification.js +0 -0
  153. package/lib/Notification/dictionary.js +0 -0
  154. package/lib/Notification/index.js +0 -0
  155. package/lib/OrderedList/Item.js +0 -0
  156. package/lib/OrderedList/ItemBase.js +0 -0
  157. package/lib/OrderedList/OrderedList.js +0 -0
  158. package/lib/OrderedList/OrderedListBase.js +0 -0
  159. package/lib/OrderedList/index.js +0 -0
  160. package/lib/Pagination/PageButton.js +0 -0
  161. package/lib/Pagination/Pagination.js +0 -0
  162. package/lib/Pagination/SideButton.js +0 -0
  163. package/lib/Pagination/constants.js +0 -0
  164. package/lib/Pagination/dictionary.js +0 -0
  165. package/lib/Pagination/index.js +0 -0
  166. package/lib/Pagination/usePagination.js +0 -0
  167. package/lib/Portal/Portal.js +0 -0
  168. package/lib/Portal/Portal.native.js +0 -0
  169. package/lib/Portal/index.js +0 -0
  170. package/lib/PriceLockup/PriceLockup.js +0 -0
  171. package/lib/PriceLockup/index.js +0 -0
  172. package/lib/PriceLockup/utils/renderFootnoteContent.js +0 -0
  173. package/lib/PriceLockup/utils/renderFootnoteLinks.js +0 -0
  174. package/lib/PriceLockup/utils/renderPrice.js +0 -0
  175. package/lib/PriceLockup/utils/renderTypography.js +0 -0
  176. package/lib/ProductCard/ProductCard.js +0 -0
  177. package/lib/ProductCard/dictionary.js +0 -0
  178. package/lib/ProductCard/index.js +0 -0
  179. package/lib/ProductCardGroup/ProductCardGroup.js +0 -0
  180. package/lib/ProductCardGroup/index.js +0 -0
  181. package/lib/Progress/Progress.js +8 -2
  182. package/lib/Progress/ProgressBar.js +40 -12
  183. package/lib/Progress/ProgressBarBackground.js +4 -2
  184. package/lib/Progress/constants.js +4 -0
  185. package/lib/Progress/index.js +0 -0
  186. package/lib/QuickLinks/QuickLinks.js +0 -0
  187. package/lib/QuickLinks/QuickLinksCard.js +0 -0
  188. package/lib/QuickLinks/QuickLinksItem.js +0 -0
  189. package/lib/QuickLinks/index.js +0 -0
  190. package/lib/QuickLinksFeature/QuickLinksFeature.js +0 -0
  191. package/lib/QuickLinksFeature/QuickLinksFeatureItem.js +0 -0
  192. package/lib/QuickLinksFeature/index.js +0 -0
  193. package/lib/Radio/Radio.js +0 -0
  194. package/lib/Radio/RadioButton.js +0 -0
  195. package/lib/Radio/RadioGroup.js +0 -0
  196. package/lib/Radio/RadioInput.js +0 -0
  197. package/lib/Radio/RadioInput.native.js +0 -0
  198. package/lib/Radio/index.js +0 -0
  199. package/lib/RadioCard/RadioCard.js +0 -0
  200. package/lib/RadioCard/RadioCardGroup.js +0 -0
  201. package/lib/RadioCard/index.js +0 -0
  202. package/lib/Responsive/Responsive.js +0 -0
  203. package/lib/Responsive/ResponsiveProp.js +0 -0
  204. package/lib/Responsive/ResponsiveWithMediaQueryStyleSheet.js +0 -0
  205. package/lib/Responsive/index.js +0 -0
  206. package/lib/Search/Search.js +2 -2
  207. package/lib/Search/dictionary.js +0 -0
  208. package/lib/Search/index.js +0 -0
  209. package/lib/Select/Group.js +0 -0
  210. package/lib/Select/Group.native.js +0 -0
  211. package/lib/Select/Item.js +0 -0
  212. package/lib/Select/Item.native.js +0 -0
  213. package/lib/Select/Picker.js +0 -0
  214. package/lib/Select/Picker.native.js +1 -0
  215. package/lib/Select/Select.js +1 -4
  216. package/lib/Select/constants.js +0 -0
  217. package/lib/Select/index.js +0 -0
  218. package/lib/SideNav/Item.js +0 -0
  219. package/lib/SideNav/ItemContent.js +0 -0
  220. package/lib/SideNav/ItemsGroup.js +0 -0
  221. package/lib/SideNav/SideNav.js +0 -0
  222. package/lib/SideNav/index.js +0 -0
  223. package/lib/Skeleton/Skeleton.js +0 -0
  224. package/lib/Skeleton/index.js +0 -0
  225. package/lib/Skeleton/skeleton.constant.js +0 -0
  226. package/lib/Skeleton/skeletonWebAnimation.js +0 -0
  227. package/lib/Skeleton/useSkeletonNativeAnimation.js +0 -0
  228. package/lib/SkipLink/SkipLink.js +0 -0
  229. package/lib/SkipLink/index.js +0 -0
  230. package/lib/Spacer/Spacer.js +0 -0
  231. package/lib/Spacer/index.js +0 -0
  232. package/lib/StackView/StackView.js +0 -0
  233. package/lib/StackView/StackWrap.js +0 -0
  234. package/lib/StackView/StackWrap.native.js +0 -0
  235. package/lib/StackView/StackWrapBox.js +0 -0
  236. package/lib/StackView/StackWrapGap.js +0 -0
  237. package/lib/StackView/common.js +0 -0
  238. package/lib/StackView/getStackedContent.js +0 -0
  239. package/lib/StackView/index.js +0 -0
  240. package/lib/Status/Status.js +6 -2
  241. package/lib/Status/index.js +0 -0
  242. package/lib/StepTracker/Step.js +0 -0
  243. package/lib/StepTracker/StepTracker.js +0 -0
  244. package/lib/StepTracker/dictionary.js +0 -0
  245. package/lib/StepTracker/index.js +0 -0
  246. package/lib/TabBar/TabBar.js +0 -0
  247. package/lib/TabBar/TabBarItem.js +0 -0
  248. package/lib/TabBar/index.js +0 -0
  249. package/lib/Tabs/Tabs.js +0 -0
  250. package/lib/Tabs/TabsItem.js +0 -0
  251. package/lib/Tabs/index.js +0 -0
  252. package/lib/Tags/Tags.js +0 -0
  253. package/lib/Tags/index.js +0 -0
  254. package/lib/TextInput/TextArea.js +0 -0
  255. package/lib/TextInput/TextInput.js +0 -0
  256. package/lib/TextInput/TextInputBase.js +2 -2
  257. package/lib/TextInput/dictionary.js +0 -0
  258. package/lib/TextInput/index.js +0 -0
  259. package/lib/TextInput/propTypes.js +0 -0
  260. package/lib/ThemeProvider/ThemeProvider.js +0 -0
  261. package/lib/ThemeProvider/index.js +0 -0
  262. package/lib/ThemeProvider/useResponsiveThemeTokens.js +0 -0
  263. package/lib/ThemeProvider/useSetTheme.js +0 -0
  264. package/lib/ThemeProvider/useTheme.js +0 -0
  265. package/lib/ThemeProvider/useThemeTokens.js +0 -0
  266. package/lib/ThemeProvider/utils/index.js +0 -0
  267. package/lib/ThemeProvider/utils/styles.js +0 -0
  268. package/lib/ThemeProvider/utils/theme-tokens.js +0 -0
  269. package/lib/Timeline/Timeline.js +0 -0
  270. package/lib/Timeline/index.js +0 -0
  271. package/lib/ToggleSwitch/ToggleSwitch.js +0 -0
  272. package/lib/ToggleSwitch/ToggleSwitchGroup.js +0 -0
  273. package/lib/ToggleSwitch/index.js +0 -0
  274. package/lib/Tooltip/Backdrop.js +0 -0
  275. package/lib/Tooltip/Backdrop.native.js +0 -0
  276. package/lib/Tooltip/Tooltip.js +22 -13
  277. package/lib/Tooltip/Tooltip.native.js +24 -15
  278. package/lib/Tooltip/dictionary.js +0 -0
  279. package/lib/Tooltip/getTooltipPosition.js +0 -0
  280. package/lib/Tooltip/index.js +0 -0
  281. package/lib/Tooltip/shared.js +0 -0
  282. package/lib/TooltipButton/TooltipButton.js +0 -0
  283. package/lib/TooltipButton/index.js +0 -0
  284. package/lib/Typography/Typography.js +0 -0
  285. package/lib/Typography/index.js +0 -0
  286. package/lib/Validator/Validator.js +4 -0
  287. package/lib/Validator/index.js +0 -0
  288. package/lib/ViewportProvider/ViewportProvider.js +0 -0
  289. package/lib/ViewportProvider/index.js +0 -0
  290. package/lib/ViewportProvider/useViewport.js +0 -0
  291. package/lib/ViewportProvider/useViewportListener.js +0 -0
  292. package/lib/index.js +0 -0
  293. package/lib/server.js +0 -0
  294. package/lib/utils/BaseView/BaseView.js +0 -0
  295. package/lib/utils/BaseView/BaseView.native.js +0 -0
  296. package/lib/utils/BaseView/index.js +0 -0
  297. package/lib/utils/a11y/index.js +0 -0
  298. package/lib/utils/a11y/semantics.js +0 -0
  299. package/lib/utils/a11y/textSize.js +0 -0
  300. package/lib/utils/animation/index.js +0 -0
  301. package/lib/utils/animation/useVerticalExpandAnimation.js +0 -0
  302. package/lib/utils/children.js +0 -0
  303. package/lib/utils/containUniqueFields.js +0 -0
  304. package/lib/utils/convertFromMegaByteToByte.js +0 -0
  305. package/lib/utils/floating-ui/index.js +0 -0
  306. package/lib/utils/floating-ui/index.native.js +0 -0
  307. package/lib/utils/formatImageSource.js +0 -0
  308. package/lib/utils/hasOwnProperty.js +0 -0
  309. package/lib/utils/htmlAttrs.js +0 -0
  310. package/lib/utils/index.js +0 -0
  311. package/lib/utils/info/index.js +0 -0
  312. package/lib/utils/info/platform/index.js +0 -0
  313. package/lib/utils/info/platform/platform.android.js +0 -0
  314. package/lib/utils/info/platform/platform.ios.js +0 -0
  315. package/lib/utils/info/platform/platform.js +0 -0
  316. package/lib/utils/info/platform/platform.native.js +0 -0
  317. package/lib/utils/info/versions.js +0 -0
  318. package/lib/utils/input.js +0 -0
  319. package/lib/utils/pressability.js +0 -0
  320. package/lib/utils/props/a11yProps.js +0 -0
  321. package/lib/utils/props/clickProps.js +0 -0
  322. package/lib/utils/props/componentPropType.js +0 -0
  323. package/lib/utils/props/contentfulProps.js +22 -0
  324. package/lib/utils/props/copyPropTypes.js +0 -0
  325. package/lib/utils/props/getPropSelector.js +0 -0
  326. package/lib/utils/props/handlerProps.js +0 -0
  327. package/lib/utils/props/hrefAttrsProp.js +0 -0
  328. package/lib/utils/props/index.js +2 -1
  329. package/lib/utils/props/inputSupportsProps.js +0 -0
  330. package/lib/utils/props/linkProps.js +0 -0
  331. package/lib/utils/props/paddingProp.js +0 -0
  332. package/lib/utils/props/pressProps.js +0 -0
  333. package/lib/utils/props/rectProp.js +0 -0
  334. package/lib/utils/props/responsiveProps.js +0 -0
  335. package/lib/utils/props/selectSystemProps.js +0 -0
  336. package/lib/utils/props/spacingProps.js +0 -0
  337. package/lib/utils/props/textInputProps.js +0 -0
  338. package/lib/utils/props/textProps.js +0 -0
  339. package/lib/utils/props/tokens.js +0 -0
  340. package/lib/utils/props/variantProp.js +0 -0
  341. package/lib/utils/props/viewProps.js +0 -0
  342. package/lib/utils/ssr-media-query/create-stylesheet/create-stylesheet-mobile.js +0 -0
  343. package/lib/utils/ssr-media-query/create-stylesheet/index.android.js +0 -0
  344. package/lib/utils/ssr-media-query/create-stylesheet/index.ios.js +0 -0
  345. package/lib/utils/ssr-media-query/create-stylesheet/index.js +0 -0
  346. package/lib/utils/ssr-media-query/hash.js +0 -0
  347. package/lib/utils/ssr-media-query/index.js +0 -0
  348. package/lib/utils/ssr-media-query/utils/common.js +0 -0
  349. package/lib/utils/ssr-media-query/utils/create-declaration-block.js +0 -0
  350. package/lib/utils/ssr-media-query/utils/create-media-query-styles.js +0 -0
  351. package/lib/utils/ssr-media-query/utils/hyphenate-style-name.js +0 -0
  352. package/lib/utils/ssr-media-query/utils/inject.js +0 -0
  353. package/lib/utils/ssr.js +0 -0
  354. package/lib/utils/transformGradient.js +0 -0
  355. package/lib/utils/useCopy.js +0 -0
  356. package/lib/utils/useHash.js +0 -0
  357. package/lib/utils/useHash.native.js +0 -0
  358. package/lib/utils/useOverlaidPosition.js +0 -0
  359. package/lib/utils/useResponsiveProp.js +0 -0
  360. package/lib/utils/useSafeLayoutEffect.js +0 -0
  361. package/lib/utils/useScrollBlocking.js +0 -0
  362. package/lib/utils/useScrollBlocking.native.js +0 -0
  363. package/lib/utils/useSpacingScale.js +0 -0
  364. package/lib/utils/useUniqueId.js +0 -0
  365. package/lib/utils/withLinkRouter.js +0 -0
  366. package/package.json +2 -2
  367. package/src/Card/PressableCardBase.jsx +1 -1
  368. package/src/Carousel/Carousel.jsx +166 -34
  369. package/src/Carousel/CarouselItem/CarouselItem.jsx +56 -26
  370. package/src/Carousel/CarouselStepTracker/CarouselStepTracker.jsx +71 -37
  371. package/src/Carousel/Constants.js +3 -0
  372. package/src/Checkbox/CheckboxGroup.jsx +7 -3
  373. package/src/HorizontalScroll/HorizontalScroll.jsx +19 -15
  374. package/src/Icon/Icon.jsx +1 -0
  375. package/src/InputSupports/InputSupports.jsx +1 -0
  376. package/src/Link/LinkBase.jsx +8 -2
  377. package/src/Modal/Modal.jsx +4 -0
  378. package/src/Modal/ModalContent.jsx +23 -7
  379. package/src/Progress/Progress.jsx +12 -2
  380. package/src/Progress/ProgressBar.jsx +48 -13
  381. package/src/Progress/ProgressBarBackground.jsx +4 -2
  382. package/src/Progress/constants.js +4 -0
  383. package/src/Search/Search.jsx +7 -2
  384. package/src/Select/Picker.native.jsx +1 -0
  385. package/src/Select/Select.jsx +8 -9
  386. package/src/Status/Status.jsx +2 -2
  387. package/src/TextInput/TextInputBase.jsx +2 -2
  388. package/src/Tooltip/Tooltip.jsx +6 -1
  389. package/src/Tooltip/Tooltip.native.jsx +7 -1
  390. package/src/Validator/Validator.jsx +7 -1
  391. package/src/utils/props/contentfulProps.js +24 -0
  392. 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 = (count, width, enablePeeking) => ({
59
+ const selectSwipeAreaStyles = (
60
+ count,
61
+ width,
62
+ enablePeeking,
63
+ enableDisplayMultipleItemsPerSlide
64
+ ) => ({
59
65
  width: width * count,
60
- justifyContent: enablePeeking ? 'flex-start' : 'space-between',
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 variant={stepTrackerVariant} />
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 && childrenArray.length > 1
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
- const viewport = useViewport()
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 >= childrenArray.length
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
- [pan, springConfig, handleAnimationEnd, transitionDuration, isAutoPlayEnabled, enablePeeking]
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 = childrenArray.length + delta
371
- } else if (activeIndexRef.current + 1 >= childrenArray.length && delta > 0) {
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
- toValue.x = containerLayoutRef.current.width * -1 * calcDelta
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 === childrenArray.length &&
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
- childrenArray.length,
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 && childrenArray.length > 1
620
+ autoPlay && slideDuration > 0 && transitionDuration > 0 && totalItems > 1
504
621
  )
505
- }, [autoPlay, slideDuration, transitionDuration, childrenArray.length])
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 (childrenArray.length === 1) {
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, childrenArray.length])
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, childrenArray.length)
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, childrenArray.length, itemLabel, getCopy, title]
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={childrenArray.length}
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 && childrenArray.length > 1 ? (
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(childrenArray.length, containerLayout.width, enablePeeking),
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 && childrenArray.length > 1 ? (
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
- const isActive = activeIndex === elementIndex
37
-
38
- if (isActive) {
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
- ({ children, elementIndex, tag = 'li', hidden, enablePeeking, peekingProps, ...rest }, ref) => {
76
- const { width, activeIndex, totalItems, height } = useCarousel()
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(({ variant }, ref) => {
8
- const {
9
- activeIndex,
10
- totalItems,
11
- getCopyWithPlaceholders,
12
- themeTokens: { stepTrackerCurrentBackgroundColor, ...themeTokens }
13
- } = useCarousel()
14
- const stackViewTokens = {
15
- justifyContent: 'center'
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
- const stepTrackerTokens = {
19
- showStepLabel: false,
20
- showStepTrackerLabel: true,
21
- // TODO: StepTracker 'isComplete'/'isCurrent' is incorrect, see line StepTracker/Step.jsx line 63, refactor incorrect values and remove this
22
- knobCompletedBackgroundColor: stepTrackerCurrentBackgroundColor ?? 'none',
23
- connectorCompletedColor: 'none',
24
- connectorColor: 'none',
25
- containerPaddingTop: themeTokens.spaceBetweenSlideAndPanelNavigation
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
- const steps = Array.from(Array(totalItems)).map((_, index) => String(index))
29
- return (
30
- <StackView direction="row" tokens={stackViewTokens} ref={ref}>
31
- <StepTracker
32
- current={activeIndex}
33
- steps={steps}
34
- copy={{
35
- // Give StepTracker copy from Carousel's language and dictionary
36
- stepLabel: getCopyWithPlaceholders('stepLabel'),
37
- stepTrackerLabel: getCopyWithPlaceholders('stepTrackerLabel')
38
- }}
39
- tokens={stepTrackerTokens}
40
- variant={variant}
41
- />
42
- </StackView>
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
@@ -0,0 +1,3 @@
1
+ export const ITEMS_PER_VIEWPORT_MD = 2
2
+ export const ITEMS_PER_VIEWPORT_LG_XL = 3
3
+ export const GAP_BETWEEN_ITEMS = 16