@telus-uds/components-base 1.83.0 → 1.85.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 (474) hide show
  1. package/CHANGELOG.md +36 -2
  2. package/lib/A11yInfoProvider/index.js +8 -10
  3. package/lib/A11yText/index.js +2 -4
  4. package/lib/ActivityIndicator/Spinner.js +3 -4
  5. package/lib/ActivityIndicator/Spinner.native.js +2 -4
  6. package/lib/Autocomplete/Autocomplete.js +13 -17
  7. package/lib/Autocomplete/Loading.js +4 -2
  8. package/lib/Autocomplete/Suggestions.js +2 -4
  9. package/lib/Badge/Badge.js +2 -4
  10. package/lib/BaseProvider/HydrationContext.js +5 -7
  11. package/lib/Box/Box.js +5 -7
  12. package/lib/Button/Button.js +3 -3
  13. package/lib/Button/ButtonBase.js +2 -7
  14. package/lib/Button/ButtonDropdown.js +3 -3
  15. package/lib/Button/ButtonGroup.js +11 -4
  16. package/lib/Button/ButtonLink.js +3 -3
  17. package/lib/Card/Card.js +159 -16
  18. package/lib/Card/CardBase.js +2 -4
  19. package/lib/Card/PressableCardBase.js +3 -5
  20. package/lib/CardGroup/CardGroup.js +220 -0
  21. package/lib/CardGroup/dictionary.js +15 -0
  22. package/lib/CardGroup/index.js +10 -0
  23. package/lib/Carousel/Carousel.js +308 -129
  24. package/lib/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +2 -4
  25. package/lib/Carousel/CarouselItem/CarouselItem.js +3 -2
  26. package/lib/Carousel/CarouselStepTracker/CarouselStepTracker.js +4 -2
  27. package/lib/Carousel/CarouselTabs/CarouselTabs.js +2 -4
  28. package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +6 -8
  29. package/lib/Carousel/CarouselTabs/CarouselTabsPanelItem.js +3 -5
  30. package/lib/Carousel/CarouselThumbnail.js +4 -2
  31. package/lib/Carousel/CarouselThumbnailNavigation.js +2 -4
  32. package/lib/Checkbox/Checkbox.js +2 -4
  33. package/lib/Checkbox/CheckboxButton.js +3 -5
  34. package/lib/Checkbox/CheckboxGroup.js +2 -4
  35. package/lib/Checkbox/CheckboxInput.js +4 -14
  36. package/lib/CheckboxCard/CheckboxCard.js +3 -3
  37. package/lib/CheckboxCardGroup/CheckboxCardGroup.js +3 -3
  38. package/lib/ColourToggle/ColourBubble.js +5 -6
  39. package/lib/ColourToggle/ColourToggle.js +3 -5
  40. package/lib/Divider/Divider.js +2 -4
  41. package/lib/ExpandCollapse/Accordion.js +2 -4
  42. package/lib/ExpandCollapse/Control.js +2 -4
  43. package/lib/ExpandCollapse/ExpandCollapse.js +20 -13
  44. package/lib/ExpandCollapse/Panel.js +15 -5
  45. package/lib/ExpandCollapse/dictionary.js +17 -0
  46. package/lib/Feedback/Feedback.js +2 -4
  47. package/lib/Fieldset/Fieldset.js +2 -4
  48. package/lib/Fieldset/FieldsetContainer.js +2 -4
  49. package/lib/Fieldset/FieldsetContainer.native.js +2 -4
  50. package/lib/Fieldset/Legend.js +2 -4
  51. package/lib/Fieldset/Legend.native.js +2 -4
  52. package/lib/FlexGrid/Col/Col.js +3 -5
  53. package/lib/FlexGrid/FlexGrid.js +2 -4
  54. package/lib/FlexGrid/Row/Row.js +2 -4
  55. package/lib/Footnote/Footnote.js +9 -9
  56. package/lib/Footnote/FootnoteLink.js +5 -3
  57. package/lib/HorizontalScroll/HorizontalScroll.js +8 -10
  58. package/lib/HorizontalScroll/HorizontalScrollButton.js +2 -4
  59. package/lib/HorizontalScroll/ScrollViewEnd.js +5 -10
  60. package/lib/HorizontalScroll/ScrollViewEnd.native.js +2 -4
  61. package/lib/Icon/Icon.js +2 -4
  62. package/lib/Icon/IconText.js +6 -6
  63. package/lib/IconButton/IconButton.js +2 -4
  64. package/lib/InputLabel/InputLabel.js +2 -4
  65. package/lib/InputLabel/LabelContent.js +2 -4
  66. package/lib/InputLabel/LabelContent.native.js +2 -4
  67. package/lib/InputSupports/InputSupports.js +4 -5
  68. package/lib/Link/ChevronLink.js +2 -4
  69. package/lib/Link/InlinePressable.js +8 -7
  70. package/lib/Link/InlinePressable.native.js +10 -8
  71. package/lib/Link/Link.js +2 -4
  72. package/lib/Link/LinkBase.js +2 -4
  73. package/lib/Link/TextButton.js +2 -4
  74. package/lib/List/List.js +13 -11
  75. package/lib/List/ListItem.js +2 -4
  76. package/lib/List/ListItemBase.js +6 -10
  77. package/lib/List/ListItemContent.js +4 -2
  78. package/lib/List/ListItemMark.js +4 -2
  79. package/lib/List/PressableListItemBase.js +2 -4
  80. package/lib/Listbox/GroupControl.js +4 -2
  81. package/lib/Listbox/Listbox.js +6 -6
  82. package/lib/Listbox/ListboxContext.js +3 -4
  83. package/lib/Listbox/ListboxGroup.js +2 -4
  84. package/lib/Listbox/ListboxItem.js +2 -6
  85. package/lib/Listbox/ListboxOverlay.js +2 -6
  86. package/lib/Listbox/PressableItem.js +2 -6
  87. package/lib/Modal/Modal.js +5 -7
  88. package/lib/Modal/ModalContent.js +7 -7
  89. package/lib/Modal/WebModal.js +19 -10
  90. package/lib/MultiSelectFilter/ModalOverlay.js +2 -4
  91. package/lib/MultiSelectFilter/MultiSelectFilter.js +10 -10
  92. package/lib/Notification/Notification.js +5 -7
  93. package/lib/OrderedList/Item.js +4 -10
  94. package/lib/OrderedList/ItemBase.js +2 -4
  95. package/lib/OrderedList/OrderedList.js +5 -13
  96. package/lib/OrderedList/OrderedListBase.js +2 -4
  97. package/lib/Pagination/PageButton.js +1 -1
  98. package/lib/Pagination/Pagination.js +1 -1
  99. package/lib/Pagination/SideButton.js +2 -4
  100. package/lib/PriceLockup/PriceLockup.js +5 -5
  101. package/lib/ProductCard/ProductCard.js +3 -2
  102. package/lib/ProductCardGroup/ProductCardGroup.js +5 -6
  103. package/lib/Progress/Progress.js +2 -4
  104. package/lib/Progress/ProgressBar.js +2 -4
  105. package/lib/Progress/ProgressBarBackground.js +2 -4
  106. package/lib/QuickLinks/QuickLinks.js +2 -4
  107. package/lib/QuickLinks/QuickLinksCard.js +4 -2
  108. package/lib/QuickLinks/QuickLinksItem.js +2 -4
  109. package/lib/QuickLinksFeature/QuickLinksFeature.js +9 -7
  110. package/lib/QuickLinksFeature/QuickLinksFeatureItem.js +10 -12
  111. package/lib/Radio/Radio.js +3 -3
  112. package/lib/Radio/RadioButton.js +61 -15
  113. package/lib/Radio/RadioGroup.js +2 -4
  114. package/lib/Radio/RadioInput.js +6 -18
  115. package/lib/RadioCard/RadioCard.js +3 -3
  116. package/lib/RadioCard/RadioCardGroup.js +3 -3
  117. package/lib/Responsive/Responsive.js +3 -2
  118. package/lib/Responsive/ResponsiveWithMediaQueryStyleSheet.js +3 -2
  119. package/lib/Search/Search.js +2 -4
  120. package/lib/Select/Group.js +4 -2
  121. package/lib/Select/Item.js +4 -2
  122. package/lib/Select/Picker.js +2 -4
  123. package/lib/Select/Picker.native.js +3 -5
  124. package/lib/Select/Select.js +4 -6
  125. package/lib/SideNav/Item.js +2 -4
  126. package/lib/SideNav/ItemContent.js +4 -2
  127. package/lib/SideNav/ItemsGroup.js +2 -4
  128. package/lib/SideNav/SideNav.js +2 -2
  129. package/lib/Skeleton/Skeleton.js +2 -4
  130. package/lib/SkipLink/SkipLink.js +2 -4
  131. package/lib/Spacer/Spacer.js +2 -4
  132. package/lib/StackView/StackView.js +2 -4
  133. package/lib/StackView/StackWrap.js +3 -5
  134. package/lib/StackView/StackWrapBox.js +2 -4
  135. package/lib/StackView/StackWrapGap.js +2 -4
  136. package/lib/StackView/getStackedContent.js +3 -3
  137. package/lib/StepTracker/Step.js +4 -2
  138. package/lib/StepTracker/StepTracker.js +2 -4
  139. package/lib/Tabs/Tabs.js +4 -4
  140. package/lib/Tabs/TabsItem.js +3 -5
  141. package/lib/Tags/Tags.js +2 -4
  142. package/lib/TextInput/TextArea.js +3 -5
  143. package/lib/TextInput/TextInput.js +2 -4
  144. package/lib/TextInput/TextInputBase.js +7 -9
  145. package/lib/ThemeProvider/ThemeProvider.js +5 -7
  146. package/lib/Timeline/Timeline.js +2 -4
  147. package/lib/ToggleSwitch/ToggleSwitch.js +2 -4
  148. package/lib/ToggleSwitch/ToggleSwitchGroup.js +2 -4
  149. package/lib/Tooltip/Tooltip.js +6 -8
  150. package/lib/Tooltip/Tooltip.native.js +12 -14
  151. package/lib/TooltipButton/TooltipButton.js +4 -2
  152. package/lib/Typography/Typography.js +2 -4
  153. package/lib/Validator/Validator.js +11 -13
  154. package/lib/ViewportProvider/ViewportProvider.js +2 -4
  155. package/lib/index.js +8 -0
  156. package/lib/utils/BaseView/BaseView.js +2 -4
  157. package/lib/utils/children.js +4 -6
  158. package/lib/utils/withLinkRouter.js +3 -5
  159. package/lib-module/A11yInfoProvider/index.js +8 -8
  160. package/lib-module/A11yText/index.js +2 -2
  161. package/lib-module/ActivityIndicator/Spinner.js +2 -2
  162. package/lib-module/ActivityIndicator/Spinner.native.js +2 -2
  163. package/lib-module/Autocomplete/Autocomplete.js +13 -14
  164. package/lib-module/Autocomplete/Loading.js +4 -2
  165. package/lib-module/Autocomplete/Suggestions.js +2 -2
  166. package/lib-module/Badge/Badge.js +2 -2
  167. package/lib-module/BaseProvider/HydrationContext.js +5 -5
  168. package/lib-module/Box/Box.js +5 -5
  169. package/lib-module/Button/Button.js +2 -2
  170. package/lib-module/Button/ButtonBase.js +2 -5
  171. package/lib-module/Button/ButtonDropdown.js +2 -2
  172. package/lib-module/Button/ButtonGroup.js +11 -2
  173. package/lib-module/Button/ButtonLink.js +2 -2
  174. package/lib-module/Card/Card.js +159 -14
  175. package/lib-module/Card/CardBase.js +2 -2
  176. package/lib-module/Card/PressableCardBase.js +4 -4
  177. package/lib-module/CardGroup/CardGroup.js +210 -0
  178. package/lib-module/CardGroup/dictionary.js +8 -0
  179. package/lib-module/CardGroup/index.js +2 -0
  180. package/lib-module/Carousel/Carousel.js +308 -129
  181. package/lib-module/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +2 -2
  182. package/lib-module/Carousel/CarouselItem/CarouselItem.js +3 -2
  183. package/lib-module/Carousel/CarouselStepTracker/CarouselStepTracker.js +4 -2
  184. package/lib-module/Carousel/CarouselTabs/CarouselTabs.js +2 -2
  185. package/lib-module/Carousel/CarouselTabs/CarouselTabsPanel.js +6 -6
  186. package/lib-module/Carousel/CarouselTabs/CarouselTabsPanelItem.js +3 -3
  187. package/lib-module/Carousel/CarouselThumbnail.js +4 -2
  188. package/lib-module/Carousel/CarouselThumbnailNavigation.js +2 -2
  189. package/lib-module/Checkbox/Checkbox.js +2 -2
  190. package/lib-module/Checkbox/CheckboxButton.js +3 -3
  191. package/lib-module/Checkbox/CheckboxGroup.js +2 -2
  192. package/lib-module/Checkbox/CheckboxInput.js +4 -12
  193. package/lib-module/CheckboxCard/CheckboxCard.js +2 -2
  194. package/lib-module/CheckboxCardGroup/CheckboxCardGroup.js +2 -2
  195. package/lib-module/ColourToggle/ColourBubble.js +5 -4
  196. package/lib-module/ColourToggle/ColourToggle.js +3 -3
  197. package/lib-module/Divider/Divider.js +2 -2
  198. package/lib-module/ExpandCollapse/Accordion.js +2 -2
  199. package/lib-module/ExpandCollapse/Control.js +2 -2
  200. package/lib-module/ExpandCollapse/ExpandCollapse.js +20 -11
  201. package/lib-module/ExpandCollapse/Panel.js +16 -4
  202. package/lib-module/ExpandCollapse/dictionary.js +10 -0
  203. package/lib-module/Feedback/Feedback.js +2 -2
  204. package/lib-module/Fieldset/Fieldset.js +2 -2
  205. package/lib-module/Fieldset/FieldsetContainer.js +2 -2
  206. package/lib-module/Fieldset/FieldsetContainer.native.js +2 -2
  207. package/lib-module/Fieldset/Legend.js +2 -2
  208. package/lib-module/Fieldset/Legend.native.js +2 -2
  209. package/lib-module/FlexGrid/Col/Col.js +3 -3
  210. package/lib-module/FlexGrid/FlexGrid.js +2 -2
  211. package/lib-module/FlexGrid/Row/Row.js +2 -2
  212. package/lib-module/Footnote/Footnote.js +9 -7
  213. package/lib-module/Footnote/FootnoteLink.js +5 -4
  214. package/lib-module/HorizontalScroll/HorizontalScroll.js +8 -8
  215. package/lib-module/HorizontalScroll/HorizontalScrollButton.js +2 -2
  216. package/lib-module/HorizontalScroll/ScrollViewEnd.js +5 -8
  217. package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +2 -2
  218. package/lib-module/Icon/Icon.js +2 -2
  219. package/lib-module/Icon/IconText.js +5 -5
  220. package/lib-module/IconButton/IconButton.js +2 -2
  221. package/lib-module/InputLabel/InputLabel.js +2 -2
  222. package/lib-module/InputLabel/LabelContent.js +2 -2
  223. package/lib-module/InputLabel/LabelContent.native.js +2 -2
  224. package/lib-module/InputSupports/InputSupports.js +4 -3
  225. package/lib-module/Link/ChevronLink.js +2 -2
  226. package/lib-module/Link/InlinePressable.js +10 -4
  227. package/lib-module/Link/InlinePressable.native.js +12 -6
  228. package/lib-module/Link/Link.js +2 -2
  229. package/lib-module/Link/LinkBase.js +2 -2
  230. package/lib-module/Link/TextButton.js +2 -2
  231. package/lib-module/List/List.js +13 -9
  232. package/lib-module/List/ListItem.js +2 -2
  233. package/lib-module/List/ListItemBase.js +6 -8
  234. package/lib-module/List/ListItemContent.js +4 -2
  235. package/lib-module/List/ListItemMark.js +4 -2
  236. package/lib-module/List/PressableListItemBase.js +2 -2
  237. package/lib-module/Listbox/GroupControl.js +4 -2
  238. package/lib-module/Listbox/Listbox.js +7 -7
  239. package/lib-module/Listbox/ListboxContext.js +2 -2
  240. package/lib-module/Listbox/ListboxGroup.js +2 -2
  241. package/lib-module/Listbox/ListboxItem.js +2 -3
  242. package/lib-module/Listbox/ListboxOverlay.js +2 -3
  243. package/lib-module/Listbox/PressableItem.js +2 -3
  244. package/lib-module/Modal/Modal.js +5 -5
  245. package/lib-module/Modal/ModalContent.js +7 -5
  246. package/lib-module/Modal/WebModal.js +19 -10
  247. package/lib-module/MultiSelectFilter/ModalOverlay.js +2 -2
  248. package/lib-module/MultiSelectFilter/MultiSelectFilter.js +10 -8
  249. package/lib-module/Notification/Notification.js +5 -5
  250. package/lib-module/OrderedList/Item.js +4 -8
  251. package/lib-module/OrderedList/ItemBase.js +2 -2
  252. package/lib-module/OrderedList/OrderedList.js +6 -12
  253. package/lib-module/OrderedList/OrderedListBase.js +2 -2
  254. package/lib-module/Pagination/PageButton.js +2 -2
  255. package/lib-module/Pagination/Pagination.js +2 -2
  256. package/lib-module/Pagination/SideButton.js +2 -2
  257. package/lib-module/PriceLockup/PriceLockup.js +5 -5
  258. package/lib-module/ProductCard/ProductCard.js +3 -2
  259. package/lib-module/ProductCardGroup/ProductCardGroup.js +5 -4
  260. package/lib-module/Progress/Progress.js +2 -2
  261. package/lib-module/Progress/ProgressBar.js +2 -2
  262. package/lib-module/Progress/ProgressBarBackground.js +2 -2
  263. package/lib-module/QuickLinks/QuickLinks.js +2 -2
  264. package/lib-module/QuickLinks/QuickLinksCard.js +4 -2
  265. package/lib-module/QuickLinks/QuickLinksItem.js +2 -2
  266. package/lib-module/QuickLinksFeature/QuickLinksFeature.js +9 -5
  267. package/lib-module/QuickLinksFeature/QuickLinksFeatureItem.js +10 -10
  268. package/lib-module/Radio/Radio.js +2 -2
  269. package/lib-module/Radio/RadioButton.js +62 -14
  270. package/lib-module/Radio/RadioGroup.js +2 -2
  271. package/lib-module/Radio/RadioInput.js +6 -16
  272. package/lib-module/RadioCard/RadioCard.js +2 -2
  273. package/lib-module/RadioCard/RadioCardGroup.js +2 -2
  274. package/lib-module/Responsive/Responsive.js +3 -2
  275. package/lib-module/Responsive/ResponsiveWithMediaQueryStyleSheet.js +3 -2
  276. package/lib-module/Search/Search.js +2 -2
  277. package/lib-module/Select/Group.js +4 -2
  278. package/lib-module/Select/Item.js +4 -2
  279. package/lib-module/Select/Picker.js +2 -2
  280. package/lib-module/Select/Picker.native.js +3 -3
  281. package/lib-module/Select/Select.js +4 -4
  282. package/lib-module/SideNav/Item.js +2 -2
  283. package/lib-module/SideNav/ItemContent.js +4 -2
  284. package/lib-module/SideNav/ItemsGroup.js +2 -2
  285. package/lib-module/SideNav/SideNav.js +3 -3
  286. package/lib-module/Skeleton/Skeleton.js +2 -2
  287. package/lib-module/SkipLink/SkipLink.js +2 -2
  288. package/lib-module/Spacer/Spacer.js +2 -2
  289. package/lib-module/StackView/StackView.js +2 -2
  290. package/lib-module/StackView/StackWrap.js +3 -3
  291. package/lib-module/StackView/StackWrapBox.js +2 -2
  292. package/lib-module/StackView/StackWrapGap.js +2 -2
  293. package/lib-module/StackView/getStackedContent.js +4 -4
  294. package/lib-module/StepTracker/Step.js +4 -2
  295. package/lib-module/StepTracker/StepTracker.js +2 -2
  296. package/lib-module/Tabs/Tabs.js +3 -3
  297. package/lib-module/Tabs/TabsItem.js +3 -3
  298. package/lib-module/Tags/Tags.js +2 -2
  299. package/lib-module/TextInput/TextArea.js +3 -3
  300. package/lib-module/TextInput/TextInput.js +2 -2
  301. package/lib-module/TextInput/TextInputBase.js +7 -7
  302. package/lib-module/ThemeProvider/ThemeProvider.js +5 -5
  303. package/lib-module/Timeline/Timeline.js +2 -2
  304. package/lib-module/ToggleSwitch/ToggleSwitch.js +2 -2
  305. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +2 -2
  306. package/lib-module/Tooltip/Tooltip.js +6 -6
  307. package/lib-module/Tooltip/Tooltip.native.js +12 -12
  308. package/lib-module/TooltipButton/TooltipButton.js +4 -2
  309. package/lib-module/Typography/Typography.js +2 -2
  310. package/lib-module/Validator/Validator.js +11 -11
  311. package/lib-module/ViewportProvider/ViewportProvider.js +2 -2
  312. package/lib-module/index.js +1 -0
  313. package/lib-module/utils/BaseView/BaseView.js +2 -2
  314. package/lib-module/utils/children.js +4 -4
  315. package/lib-module/utils/withLinkRouter.js +3 -3
  316. package/package.json +2 -2
  317. package/src/A11yInfoProvider/index.jsx +8 -8
  318. package/src/A11yText/index.jsx +2 -2
  319. package/src/ActivityIndicator/Spinner.jsx +2 -2
  320. package/src/ActivityIndicator/Spinner.native.jsx +2 -2
  321. package/src/Autocomplete/Autocomplete.jsx +15 -14
  322. package/src/Autocomplete/Loading.jsx +6 -3
  323. package/src/Autocomplete/Suggestions.jsx +2 -2
  324. package/src/Badge/Badge.jsx +2 -2
  325. package/src/BaseProvider/HydrationContext.jsx +5 -5
  326. package/src/Box/Box.jsx +5 -5
  327. package/src/Button/Button.jsx +11 -9
  328. package/src/Button/ButtonBase.jsx +2 -3
  329. package/src/Button/ButtonDropdown.jsx +2 -2
  330. package/src/Button/ButtonGroup.jsx +11 -2
  331. package/src/Button/ButtonLink.jsx +2 -2
  332. package/src/Card/Card.jsx +151 -11
  333. package/src/Card/CardBase.jsx +2 -2
  334. package/src/Card/PressableCardBase.jsx +18 -4
  335. package/src/CardGroup/CardGroup.jsx +249 -0
  336. package/src/CardGroup/dictionary.js +8 -0
  337. package/src/CardGroup/index.js +3 -0
  338. package/src/Carousel/Carousel.jsx +338 -117
  339. package/src/Carousel/CarouselFirstFocus/CarouselFirstFocus.jsx +2 -2
  340. package/src/Carousel/CarouselItem/CarouselItem.jsx +19 -17
  341. package/src/Carousel/CarouselStepTracker/CarouselStepTracker.jsx +5 -3
  342. package/src/Carousel/CarouselTabs/CarouselTabs.jsx +2 -2
  343. package/src/Carousel/CarouselTabs/CarouselTabsPanel.jsx +6 -6
  344. package/src/Carousel/CarouselTabs/CarouselTabsPanelItem.jsx +3 -3
  345. package/src/Carousel/CarouselThumbnail.jsx +6 -2
  346. package/src/Carousel/CarouselThumbnailNavigation.jsx +2 -2
  347. package/src/Checkbox/Checkbox.jsx +2 -2
  348. package/src/Checkbox/CheckboxButton.jsx +5 -7
  349. package/src/Checkbox/CheckboxGroup.jsx +2 -2
  350. package/src/Checkbox/CheckboxInput.jsx +15 -12
  351. package/src/CheckboxCard/CheckboxCard.jsx +2 -2
  352. package/src/CheckboxCardGroup/CheckboxCardGroup.jsx +2 -2
  353. package/src/ColourToggle/ColourBubble.jsx +5 -4
  354. package/src/ColourToggle/ColourToggle.jsx +3 -3
  355. package/src/Divider/Divider.jsx +2 -2
  356. package/src/ExpandCollapse/Accordion.jsx +4 -2
  357. package/src/ExpandCollapse/Control.jsx +2 -2
  358. package/src/ExpandCollapse/ExpandCollapse.jsx +15 -7
  359. package/src/ExpandCollapse/Panel.jsx +30 -8
  360. package/src/ExpandCollapse/dictionary.js +10 -0
  361. package/src/Feedback/Feedback.jsx +2 -2
  362. package/src/Fieldset/Fieldset.jsx +2 -2
  363. package/src/Fieldset/FieldsetContainer.jsx +2 -2
  364. package/src/Fieldset/FieldsetContainer.native.jsx +2 -2
  365. package/src/Fieldset/Legend.jsx +2 -2
  366. package/src/Fieldset/Legend.native.jsx +2 -2
  367. package/src/FlexGrid/Col/Col.jsx +3 -3
  368. package/src/FlexGrid/FlexGrid.jsx +2 -2
  369. package/src/FlexGrid/Row/Row.jsx +2 -2
  370. package/src/Footnote/Footnote.jsx +111 -98
  371. package/src/Footnote/FootnoteLink.jsx +35 -31
  372. package/src/HorizontalScroll/HorizontalScroll.jsx +8 -8
  373. package/src/HorizontalScroll/HorizontalScrollButton.jsx +2 -2
  374. package/src/HorizontalScroll/ScrollViewEnd.jsx +4 -8
  375. package/src/HorizontalScroll/ScrollViewEnd.native.jsx +2 -2
  376. package/src/Icon/Icon.jsx +2 -2
  377. package/src/Icon/IconText.jsx +7 -5
  378. package/src/IconButton/IconButton.jsx +2 -2
  379. package/src/InputLabel/InputLabel.jsx +2 -2
  380. package/src/InputLabel/LabelContent.jsx +2 -2
  381. package/src/InputLabel/LabelContent.native.jsx +2 -2
  382. package/src/InputSupports/InputSupports.jsx +4 -3
  383. package/src/Link/ChevronLink.jsx +2 -2
  384. package/src/Link/InlinePressable.jsx +22 -15
  385. package/src/Link/InlinePressable.native.jsx +12 -6
  386. package/src/Link/Link.jsx +2 -2
  387. package/src/Link/LinkBase.jsx +2 -2
  388. package/src/Link/TextButton.jsx +2 -2
  389. package/src/List/List.jsx +15 -7
  390. package/src/List/ListItem.jsx +2 -2
  391. package/src/List/ListItemBase.jsx +6 -12
  392. package/src/List/ListItemContent.jsx +5 -2
  393. package/src/List/ListItemMark.jsx +5 -3
  394. package/src/List/PressableListItemBase.jsx +2 -2
  395. package/src/Listbox/GroupControl.jsx +5 -2
  396. package/src/Listbox/Listbox.jsx +7 -7
  397. package/src/Listbox/ListboxContext.js +2 -2
  398. package/src/Listbox/ListboxGroup.jsx +2 -2
  399. package/src/Listbox/ListboxItem.jsx +2 -3
  400. package/src/Listbox/ListboxOverlay.jsx +2 -3
  401. package/src/Listbox/PressableItem.jsx +2 -3
  402. package/src/Modal/Modal.jsx +5 -5
  403. package/src/Modal/ModalContent.jsx +132 -125
  404. package/src/Modal/WebModal.jsx +17 -8
  405. package/src/MultiSelectFilter/ModalOverlay.jsx +2 -2
  406. package/src/MultiSelectFilter/MultiSelectFilter.jsx +263 -252
  407. package/src/Notification/Notification.jsx +5 -5
  408. package/src/OrderedList/Item.jsx +4 -6
  409. package/src/OrderedList/ItemBase.jsx +2 -2
  410. package/src/OrderedList/OrderedList.jsx +4 -7
  411. package/src/OrderedList/OrderedListBase.jsx +2 -2
  412. package/src/Pagination/PageButton.jsx +2 -2
  413. package/src/Pagination/Pagination.jsx +2 -2
  414. package/src/Pagination/SideButton.jsx +2 -2
  415. package/src/PriceLockup/PriceLockup.jsx +93 -88
  416. package/src/ProductCard/ProductCard.jsx +90 -84
  417. package/src/ProductCardGroup/ProductCardGroup.jsx +5 -5
  418. package/src/Progress/Progress.jsx +2 -2
  419. package/src/Progress/ProgressBar.jsx +2 -2
  420. package/src/Progress/ProgressBarBackground.jsx +4 -2
  421. package/src/QuickLinks/QuickLinks.jsx +2 -2
  422. package/src/QuickLinks/QuickLinksCard.jsx +9 -3
  423. package/src/QuickLinks/QuickLinksItem.jsx +2 -2
  424. package/src/QuickLinksFeature/QuickLinksFeature.jsx +31 -27
  425. package/src/QuickLinksFeature/QuickLinksFeatureItem.jsx +3 -3
  426. package/src/Radio/Radio.jsx +2 -2
  427. package/src/Radio/RadioButton.jsx +58 -6
  428. package/src/Radio/RadioGroup.jsx +2 -2
  429. package/src/Radio/RadioInput.jsx +15 -14
  430. package/src/RadioCard/RadioCard.jsx +2 -2
  431. package/src/RadioCard/RadioCardGroup.jsx +2 -2
  432. package/src/Responsive/Responsive.jsx +8 -3
  433. package/src/Responsive/ResponsiveWithMediaQueryStyleSheet.jsx +23 -16
  434. package/src/Search/Search.jsx +2 -2
  435. package/src/Select/Group.jsx +9 -3
  436. package/src/Select/Item.jsx +7 -1
  437. package/src/Select/Picker.jsx +2 -2
  438. package/src/Select/Picker.native.jsx +3 -3
  439. package/src/Select/Select.jsx +4 -4
  440. package/src/SideNav/Item.jsx +2 -2
  441. package/src/SideNav/ItemContent.jsx +7 -3
  442. package/src/SideNav/ItemsGroup.jsx +2 -2
  443. package/src/SideNav/SideNav.jsx +3 -3
  444. package/src/Skeleton/Skeleton.jsx +2 -2
  445. package/src/SkipLink/SkipLink.jsx +2 -2
  446. package/src/Spacer/Spacer.jsx +2 -2
  447. package/src/StackView/StackView.jsx +2 -2
  448. package/src/StackView/StackWrap.jsx +3 -3
  449. package/src/StackView/StackWrapBox.jsx +2 -2
  450. package/src/StackView/StackWrapGap.jsx +2 -2
  451. package/src/StackView/getStackedContent.jsx +4 -4
  452. package/src/StepTracker/Step.jsx +75 -67
  453. package/src/StepTracker/StepTracker.jsx +2 -2
  454. package/src/Tabs/Tabs.jsx +3 -3
  455. package/src/Tabs/TabsItem.jsx +3 -3
  456. package/src/Tags/Tags.jsx +2 -2
  457. package/src/TextInput/TextArea.jsx +3 -3
  458. package/src/TextInput/TextInput.jsx +2 -2
  459. package/src/TextInput/TextInputBase.jsx +7 -7
  460. package/src/ThemeProvider/ThemeProvider.jsx +5 -5
  461. package/src/Timeline/Timeline.jsx +2 -2
  462. package/src/ToggleSwitch/ToggleSwitch.jsx +2 -2
  463. package/src/ToggleSwitch/ToggleSwitchGroup.jsx +2 -2
  464. package/src/Tooltip/Tooltip.jsx +6 -6
  465. package/src/Tooltip/Tooltip.native.jsx +12 -12
  466. package/src/TooltipButton/TooltipButton.jsx +5 -2
  467. package/src/Typography/Typography.jsx +2 -2
  468. package/src/Validator/Validator.jsx +11 -11
  469. package/src/ViewportProvider/ViewportProvider.jsx +2 -2
  470. package/src/index.js +1 -0
  471. package/src/utils/BaseView/BaseView.jsx +2 -2
  472. package/src/utils/children.jsx +4 -4
  473. package/src/utils/withLinkRouter.jsx +3 -3
  474. package/types/ExpandCollapse.d.ts +1 -1
@@ -26,6 +26,12 @@ import CarouselTabsPanel from './CarouselTabs/CarouselTabsPanel'
26
26
  import CarouselTabsPanelItem from './CarouselTabs/CarouselTabsPanelItem'
27
27
  import dictionary from './dictionary'
28
28
 
29
+ const TRANSITION_MODES = {
30
+ MANUAL: 'manual',
31
+ AUTOMATIC: 'automatic',
32
+ SWIPE: 'swipe'
33
+ }
34
+
29
35
  const staticStyles = StyleSheet.create({
30
36
  root: {
31
37
  backgroundColor: 'transparent',
@@ -34,6 +40,12 @@ const staticStyles = StyleSheet.create({
34
40
  position: 'relative',
35
41
  top: 0,
36
42
  left: 0
43
+ },
44
+ animationControlButton: {
45
+ position: 'absolute',
46
+ zIndex: 1,
47
+ right: Platform.OS === 'web' ? undefined : 40,
48
+ top: 40
37
49
  }
38
50
  })
39
51
 
@@ -49,6 +61,26 @@ const selectSwipeAreaStyles = (count, width) => ({
49
61
  flexDirection: 'row'
50
62
  })
51
63
 
64
+ const getDynamicPositionProperty = (areStylesAppliedOnPreviousButton) =>
65
+ areStylesAppliedOnPreviousButton ? 'left' : 'right'
66
+
67
+ const selectControlButtonPositionStyles = ({
68
+ positionVariant,
69
+ buttonWidth,
70
+ positionProperty = getDynamicPositionProperty(),
71
+ spaceBetweenSlideAndButton
72
+ }) => {
73
+ const styles = {}
74
+ if (positionVariant === 'edge') {
75
+ styles[positionProperty] = -1 * (buttonWidth / 2)
76
+ } else if (positionVariant === 'inside') {
77
+ styles[positionProperty] = 0
78
+ } else if (positionVariant === 'outside') {
79
+ styles[positionProperty] = -1 * (spaceBetweenSlideAndButton + buttonWidth)
80
+ }
81
+ return styles
82
+ }
83
+
52
84
  const selectPreviousNextNavigationButtonStyles = (
53
85
  previousNextNavigationButtonWidth,
54
86
  previousNextNavigationPosition,
@@ -61,7 +93,6 @@ const selectPreviousNextNavigationButtonStyles = (
61
93
  zIndex: 1,
62
94
  position: 'absolute'
63
95
  }
64
- const dynamicPositionProperty = areStylesAppliedOnPreviousButton ? 'left' : 'right'
65
96
  if (isFirstSlide) {
66
97
  styles.visibility = areStylesAppliedOnPreviousButton ? 'hidden' : 'visible'
67
98
  } else if (isLastSlide) {
@@ -70,15 +101,15 @@ const selectPreviousNextNavigationButtonStyles = (
70
101
  styles.visibility = 'visible'
71
102
  }
72
103
 
73
- if (previousNextNavigationPosition === 'edge') {
74
- styles[dynamicPositionProperty] = -1 * (previousNextNavigationButtonWidth / 2)
75
- } else if (previousNextNavigationPosition === 'inside') {
76
- styles[dynamicPositionProperty] = 0
77
- } else if (previousNextNavigationPosition === 'outside') {
78
- styles[dynamicPositionProperty] =
79
- -1 * (spaceBetweenSlideAndPreviousNextNavigation + previousNextNavigationButtonWidth)
104
+ return {
105
+ ...styles,
106
+ ...selectControlButtonPositionStyles({
107
+ positionVariant: previousNextNavigationPosition,
108
+ buttonWidth: previousNextNavigationButtonWidth,
109
+ positionProperty: getDynamicPositionProperty(areStylesAppliedOnPreviousButton),
110
+ spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation
111
+ })
80
112
  }
81
- return styles
82
113
  }
83
114
 
84
115
  const selectIconStyles = ({ iconBackgroundColor }) => ({ backgroundColor: iconBackgroundColor })
@@ -170,10 +201,21 @@ const Carousel = React.forwardRef(
170
201
  accessibilityLabel,
171
202
  accessibilityLiveRegion = 'polite',
172
203
  copy,
204
+ slideDuration = 0,
205
+ transitionDuration = 0,
206
+ autoPlay = false,
173
207
  ...rest
174
208
  },
175
209
  ref
176
210
  ) => {
211
+ let childrenArray = unpackFragment(children)
212
+ const autoPlayFeatureEnabled =
213
+ autoPlay && slideDuration > 0 && transitionDuration > 0 && childrenArray.length > 1
214
+ // if `Carousel` only has one `Carousel.Item`, convert this to a single-item array
215
+ if (!Array.isArray(childrenArray)) {
216
+ childrenArray = [childrenArray]
217
+ }
218
+ const getCopy = useCopy({ dictionary, copy })
177
219
  const viewport = useViewport()
178
220
  const themeTokens = useThemeTokens('Carousel', tokens, variant, {
179
221
  viewport
@@ -181,14 +223,45 @@ const Carousel = React.forwardRef(
181
223
  const {
182
224
  previousIcon,
183
225
  nextIcon,
226
+ playIcon,
227
+ pauseIcon,
184
228
  showPreviousNextNavigation,
185
229
  showPanelNavigation,
186
230
  showPanelTabs,
187
231
  spaceBetweenSlideAndPreviousNextNavigation
188
232
  } = themeTokens
189
233
  const [activeIndex, setActiveIndex] = React.useState(0)
234
+ const activeIndexRef = React.useRef(activeIndex)
235
+ const { reduceMotionEnabled } = useA11yInfo()
236
+ const reduceMotionRef = React.useRef(reduceMotionEnabled)
237
+ const [containerLayout, setContainerLayout] = React.useState({
238
+ x: 0,
239
+ y: 0,
240
+ width: 0
241
+ })
242
+ const containerLayoutRef = React.useRef(containerLayout)
190
243
 
244
+ const [previousNextNavigationButtonWidth, setPreviousNextNavigationButtonWidth] =
245
+ React.useState(0)
246
+ const firstFocusRef = React.useRef(null)
247
+ const pan = React.useRef(new Animated.ValueXY()).current
248
+ const animatedX = React.useRef(0)
249
+ const animatedY = React.useRef(0)
191
250
  const [isAnimating, setIsAnimating] = React.useState(false)
251
+ /**
252
+ * While having the same starting point, `isAutoPlayEnabled` and `isCarouselPlaying` are different states
253
+ *
254
+ * `isAutoPlayEnabled` is a state to determine if the autoplay feature is enabled or disabled
255
+ * `isCarouselPlaying` is a state to determine if the carousel is currently playing or paused
256
+ */
257
+ const [isAutoPlayEnabled, setIsAutoPlayEnabled] = React.useState(autoPlayFeatureEnabled)
258
+ const [isCarouselPlaying, setisCarouselPlaying] = React.useState(autoPlayFeatureEnabled)
259
+ const isSwiping = React.useRef(false)
260
+ const autoPlayRef = React.useRef(null)
261
+
262
+ const isFirstSlide = !activeIndex
263
+ const isLastSlide = activeIndex + 1 >= childrenArray.length
264
+
192
265
  const handleAnimationStart = React.useCallback(
193
266
  (...args) => {
194
267
  if (typeof onAnimationStart === 'function') onAnimationStart(...args)
@@ -204,68 +277,30 @@ const Carousel = React.forwardRef(
204
277
  [onAnimationEnd]
205
278
  )
206
279
 
207
- const getCopy = useCopy({ dictionary, copy })
208
-
209
- let childrenArray = unpackFragment(children)
210
- // if `Carousel` only has one `Carousel.Item`, convert this to a single-item array
211
- if (!Array.isArray(childrenArray)) {
212
- childrenArray = [childrenArray]
213
- }
214
- const systemProps = selectProps({
215
- ...rest,
216
- accessibilityRole,
217
- accessibilityLabel,
218
- accessibilityValue: {
219
- min: 1,
220
- max: childrenArray.length,
221
- now: activeIndex + 1
222
- }
223
- })
224
- const { reduceMotionEnabled } = useA11yInfo()
225
- const [containerLayout, setContainerLayout] = React.useState({
226
- x: 0,
227
- y: 0,
228
- width: 0
229
- })
230
-
231
- const [previousNextNavigationButtonWidth, setPreviousNextNavigationButtonWidth] =
232
- React.useState(0)
233
- const firstFocusRef = React.useRef(null)
234
- const pan = React.useRef(new Animated.ValueXY()).current
235
- const animatedX = React.useRef(0)
236
- const animatedY = React.useRef(0)
237
- const isFirstSlide = !activeIndex
238
- const isLastSlide = activeIndex + 1 >= children.length
239
-
240
- const onContainerLayout = ({
241
- nativeEvent: {
242
- layout: { x, y, width }
243
- }
244
- }) => setContainerLayout((prevState) => ({ ...prevState, x, y, width }))
245
-
246
- const onPreviousNextNavigationButtonLayout = ({
247
- nativeEvent: {
248
- layout: { width }
249
- }
250
- }) => setPreviousNextNavigationButtonWidth(width)
251
-
252
280
  const updateOffset = React.useCallback(() => {
253
- animatedX.current = containerLayout.width * activeIndex * -1
281
+ animatedX.current = containerLayoutRef.current.width * activeIndexRef.current * -1
254
282
  animatedY.current = 0
255
283
  pan.setOffset({
256
284
  x: animatedX.current,
257
285
  y: animatedY.current
258
286
  })
259
287
  pan.setValue({ x: 0, y: 0 })
260
- }, [activeIndex, containerLayout.width, pan, animatedX])
288
+ }, [pan, animatedX])
261
289
 
262
290
  const animate = React.useCallback(
263
291
  (toValue, toIndex) => {
264
292
  const handleAnimationEndToIndex = (...args) => handleAnimationEnd(toIndex, ...args)
265
- if (reduceMotionEnabled) {
293
+ if (reduceMotionRef.current || isSwiping.current) {
266
294
  Animated.timing(pan, { toValue, duration: 1, useNativeDriver: false }).start(
267
295
  handleAnimationEndToIndex
268
296
  )
297
+ } else if (isAutoPlayEnabled) {
298
+ Animated.timing(pan, {
299
+ ...springConfig,
300
+ toValue,
301
+ useNativeDriver: false,
302
+ duration: transitionDuration * 1000
303
+ }).start(handleAnimationEndToIndex)
269
304
  } else {
270
305
  Animated.spring(pan, {
271
306
  ...springConfig,
@@ -274,59 +309,183 @@ const Carousel = React.forwardRef(
274
309
  }).start(handleAnimationEndToIndex)
275
310
  }
276
311
  },
277
- [pan, springConfig, reduceMotionEnabled, handleAnimationEnd]
312
+ [pan, springConfig, handleAnimationEnd, transitionDuration, isAutoPlayEnabled]
278
313
  )
279
314
 
315
+ const stopAutoplay = React.useCallback(() => {
316
+ if (autoPlayRef?.current) {
317
+ clearTimeout(autoPlayRef?.current)
318
+ }
319
+ }, [])
320
+
321
+ const triggerRefocus = React.useCallback(() => {
322
+ if (refocus && Platform.OS === 'web') {
323
+ firstFocusRef.current?.focus({ preventScroll: true, focusVisible: false })
324
+ }
325
+ }, [refocus, firstFocusRef])
326
+
280
327
  const updateIndex = React.useCallback(
281
- (delta = 1) => {
328
+ (delta = 1, transitionMode) => {
282
329
  const toValue = { x: 0, y: 0 }
283
330
  let skipChanges = !delta
284
331
  let calcDelta = delta
285
-
286
- if (activeIndex <= 0 && delta < 0) {
287
- skipChanges = true
288
- calcDelta = children.length + delta
289
- } else if (activeIndex + 1 >= children.length && delta > 0) {
290
- skipChanges = true
291
- calcDelta = -1 * activeIndex + delta - 1
332
+ if (activeIndexRef.current <= 0 && delta < 0) {
333
+ skipChanges = transitionMode !== TRANSITION_MODES.AUTOMATIC
334
+ calcDelta = childrenArray.length + delta
335
+ } else if (activeIndexRef.current + 1 >= childrenArray.length && delta > 0) {
336
+ skipChanges = transitionMode !== TRANSITION_MODES.AUTOMATIC
337
+ calcDelta = -1 * activeIndexRef.current + delta - 1
292
338
  }
293
339
 
294
- const index = activeIndex + calcDelta
295
-
340
+ const index = activeIndexRef.current + calcDelta
296
341
  if (skipChanges) {
297
342
  animate(toValue, index)
298
343
  return calcDelta
299
344
  }
300
345
 
346
+ stopAutoplay()
301
347
  setActiveIndex(index)
302
348
 
303
- toValue.x = containerLayout.width * -1 * calcDelta
304
-
349
+ toValue.x = containerLayoutRef.current.width * -1 * calcDelta
305
350
  animate(toValue, index)
306
-
351
+ if (isCarouselPlaying) {
352
+ stopAutoplay()
353
+ if (
354
+ index === 0 &&
355
+ activeIndexRef.current + 1 === childrenArray.length &&
356
+ transitionMode === TRANSITION_MODES.AUTOMATIC
357
+ ) {
358
+ setisCarouselPlaying(false)
359
+ } else if (isAutoPlayEnabled) {
360
+ autoPlayRef.current = setTimeout(() => {
361
+ updateOffset()
362
+ handleAnimationStart(activeIndexRef.current)
363
+ updateIndex(slideDuration < 0 ? -1 : 1, TRANSITION_MODES.AUTOMATIC)
364
+ triggerRefocus()
365
+ }, Math.abs(slideDuration) * 1000)
366
+ }
367
+ }
307
368
  if (onIndexChanged) onIndexChanged(calcDelta, index)
308
369
  return calcDelta
309
370
  },
310
- [containerLayout.width, activeIndex, animate, children.length, onIndexChanged]
371
+ [
372
+ handleAnimationStart,
373
+ triggerRefocus,
374
+ slideDuration,
375
+ updateOffset,
376
+ animate,
377
+ childrenArray.length,
378
+ onIndexChanged,
379
+ isCarouselPlaying,
380
+ stopAutoplay,
381
+ isAutoPlayEnabled
382
+ ]
311
383
  )
312
384
 
385
+ const startAutoplay = React.useCallback(() => {
386
+ stopAutoplay()
387
+ if (isAutoPlayEnabled) {
388
+ autoPlayRef.current = setTimeout(() => {
389
+ updateOffset()
390
+ handleAnimationStart(activeIndexRef.current)
391
+ updateIndex(slideDuration < 0 ? -1 : 1, TRANSITION_MODES.AUTOMATIC)
392
+ triggerRefocus()
393
+ }, Math.abs(slideDuration) * 1000)
394
+ }
395
+ }, [
396
+ handleAnimationStart,
397
+ triggerRefocus,
398
+ updateIndex,
399
+ updateOffset,
400
+ slideDuration,
401
+ stopAutoplay,
402
+ isAutoPlayEnabled
403
+ ])
404
+
313
405
  const fixOffsetAndGo = React.useCallback(
314
- (delta) => {
406
+ (delta, transitionMode) => {
315
407
  updateOffset()
316
- handleAnimationStart(activeIndex)
317
- updateIndex(delta)
318
- if (refocus) firstFocusRef.current?.focus()
408
+ handleAnimationStart(activeIndexRef.current)
409
+ updateIndex(delta, transitionMode)
410
+ triggerRefocus()
319
411
  },
320
- [updateIndex, updateOffset, activeIndex, handleAnimationStart, refocus]
412
+ [updateIndex, updateOffset, handleAnimationStart, triggerRefocus]
321
413
  )
322
414
 
323
415
  const goToNeighboring = React.useCallback(
324
- (toPrev = false) => {
325
- fixOffsetAndGo(toPrev ? -1 : 1)
416
+ (toPrev = false, transitionMode = TRANSITION_MODES.MANUAL) => {
417
+ fixOffsetAndGo(toPrev ? -1 : 1, transitionMode)
326
418
  },
327
419
  [fixOffsetAndGo]
328
420
  )
329
421
 
422
+ React.useEffect(() => {
423
+ activeIndexRef.current = activeIndex
424
+ }, [activeIndex])
425
+
426
+ React.useEffect(() => {
427
+ reduceMotionRef.current = reduceMotionEnabled
428
+ }, [reduceMotionEnabled])
429
+
430
+ React.useEffect(() => {
431
+ containerLayoutRef.current = containerLayout
432
+ }, [containerLayout])
433
+
434
+ React.useEffect(() => {
435
+ pan.x.addListener(({ value }) => {
436
+ animatedX.current = value
437
+ })
438
+ pan.y.addListener(({ value }) => {
439
+ animatedY.current = value
440
+ })
441
+ if (isCarouselPlaying) {
442
+ startAutoplay()
443
+ }
444
+ return () => {
445
+ stopAutoplay()
446
+ pan.x.removeAllListeners()
447
+ pan.y.removeAllListeners()
448
+ }
449
+ }, [pan.x, pan.y, startAutoplay, stopAutoplay, isCarouselPlaying])
450
+
451
+ React.useEffect(() => {
452
+ const subscription = Dimensions.addEventListener('change', () => {
453
+ updateOffset()
454
+ })
455
+
456
+ return () => {
457
+ if (subscription.remove) {
458
+ subscription.remove()
459
+ } else {
460
+ Dimensions.removeEventListener('change', updateOffset)
461
+ }
462
+ }
463
+ }, [updateOffset])
464
+
465
+ React.useEffect(() => {
466
+ setIsAutoPlayEnabled(
467
+ autoPlay && slideDuration > 0 && transitionDuration > 0 && childrenArray.length > 1
468
+ )
469
+ }, [autoPlay, slideDuration, transitionDuration, childrenArray.length])
470
+
471
+ React.useEffect(() => {
472
+ return () => {
473
+ stopAutoplay()
474
+ }
475
+ }, [stopAutoplay])
476
+
477
+ const onContainerLayout = ({
478
+ nativeEvent: {
479
+ layout: { x, y, width }
480
+ }
481
+ }) => setContainerLayout((prevState) => ({ ...prevState, x, y, width }))
482
+
483
+ const onPreviousNextNavigationButtonLayout = ({
484
+ nativeEvent: {
485
+ layout: { width }
486
+ }
487
+ }) => setPreviousNextNavigationButtonWidth(width)
488
+
330
489
  const isSwipeAllowed = React.useCallback(() => {
331
490
  if (childrenArray.length === 1) {
332
491
  return false
@@ -347,60 +506,54 @@ const Carousel = React.forwardRef(
347
506
  return false
348
507
  }
349
508
 
350
- handleAnimationStart(activeIndex)
509
+ handleAnimationStart(activeIndexRef.current)
510
+
511
+ const allow = Math.abs(gestureState.dx) > minDistanceToCapture
351
512
 
352
- return Math.abs(gestureState.dx) > minDistanceToCapture
513
+ if (allow) {
514
+ isSwiping.current = true
515
+ stopAutoplay()
516
+ }
517
+
518
+ return allow
519
+ },
520
+ onPanResponderGrant: () => {
521
+ updateOffset()
353
522
  },
354
- onPanResponderGrant: () => updateOffset(),
355
523
  onPanResponderMove: Animated.event([null, { dx: pan.x }], {
356
524
  useNativeDriver: false
357
525
  }),
358
526
  onPanResponderRelease: (_, gesture) => {
527
+ if (isCarouselPlaying) {
528
+ startAutoplay()
529
+ }
359
530
  const correction = gesture.moveX - gesture.x0
360
531
 
361
- if (Math.abs(correction) < containerLayout.width * minDistanceForAction) {
532
+ if (Math.abs(correction) < containerLayoutRef.current.width * minDistanceForAction) {
362
533
  animate({ x: 0, y: 0 }, 0)
363
534
  } else {
364
535
  const delta = correction > 0 ? -1 : 1
365
- updateIndex(delta)
536
+ updateIndex(delta, TRANSITION_MODES.SWIPE)
366
537
  }
538
+
539
+ isSwiping.current = false
367
540
  }
368
541
  }),
369
542
  [
370
- containerLayout.width,
371
543
  updateIndex,
372
544
  updateOffset,
373
545
  animate,
374
546
  isSwipeAllowed,
375
- activeIndex,
376
547
  minDistanceForAction,
377
548
  handleAnimationStart,
378
549
  minDistanceToCapture,
379
- pan.x
550
+ pan.x,
551
+ startAutoplay,
552
+ stopAutoplay,
553
+ isCarouselPlaying
380
554
  ]
381
555
  )
382
556
 
383
- React.useEffect(() => {
384
- pan.x.addListener(({ value }) => {
385
- animatedX.current = value
386
- })
387
- pan.y.addListener(({ value }) => {
388
- animatedY.current = value
389
- })
390
- return () => {
391
- pan.x.removeAllListeners()
392
- pan.y.removeAllListeners()
393
- }
394
- }, [pan.x, pan.y])
395
-
396
- React.useEffect(() => {
397
- const subscription = Dimensions.addEventListener('change', () => {
398
- updateOffset()
399
- })
400
-
401
- return () => subscription?.remove()
402
- })
403
-
404
557
  const goToNext = React.useCallback(() => {
405
558
  goToNeighboring()
406
559
  }, [goToNeighboring])
@@ -411,12 +564,12 @@ const Carousel = React.forwardRef(
411
564
 
412
565
  const goTo = React.useCallback(
413
566
  (index = 0) => {
414
- const delta = index - activeIndex
567
+ const delta = index - activeIndexRef.current
415
568
  if (delta) {
416
- fixOffsetAndGo(delta)
569
+ fixOffsetAndGo(delta, TRANSITION_MODES.MANUAL)
417
570
  }
418
571
  },
419
- [fixOffsetAndGo, activeIndex]
572
+ [fixOffsetAndGo]
420
573
  )
421
574
 
422
575
  // @TODO: - these are Allium-theme variants and won't have any effect in themes that don't implement them.
@@ -459,6 +612,18 @@ const Carousel = React.forwardRef(
459
612
  }
460
613
  }
461
614
  }
615
+
616
+ const systemProps = selectProps({
617
+ ...rest,
618
+ accessibilityRole,
619
+ accessibilityLabel,
620
+ accessibilityValue: {
621
+ min: 1,
622
+ max: childrenArray.length,
623
+ now: activeIndex + 1
624
+ }
625
+ })
626
+
462
627
  // If container isn't used for focus, give it a label of title if none is passed in,
463
628
  // otherwise read the current position on focus
464
629
  const containerAccessibilityLabel =
@@ -471,6 +636,15 @@ const Carousel = React.forwardRef(
471
636
  ...(isFirstFocusContainer && { ref: containerRef, focusable: true })
472
637
  }
473
638
 
639
+ const onAnimationControlButtonPress = React.useCallback(() => {
640
+ if (isCarouselPlaying) {
641
+ stopAutoplay()
642
+ } else {
643
+ startAutoplay()
644
+ }
645
+ setisCarouselPlaying((prevState) => !prevState)
646
+ }, [isCarouselPlaying, stopAutoplay, startAutoplay])
647
+
474
648
  return (
475
649
  <CarouselProvider
476
650
  activeIndex={activeIndex}
@@ -484,12 +658,40 @@ const Carousel = React.forwardRef(
484
658
  width={containerLayout.width}
485
659
  >
486
660
  <View
487
- style={staticStyles.root}
661
+ style={[
662
+ staticStyles.root,
663
+ {
664
+ ...Platform.select({
665
+ web: {
666
+ outline: 'none'
667
+ }
668
+ })
669
+ }
670
+ ]}
488
671
  onLayout={onContainerLayout}
489
672
  ref={ref}
490
673
  {...systemProps}
491
674
  {...containerProps}
492
675
  >
676
+ {isAutoPlayEnabled ? (
677
+ <View
678
+ style={[
679
+ staticStyles.animationControlButton,
680
+ selectControlButtonPositionStyles({
681
+ positionVariant: previousNextNavigationPosition,
682
+ buttonWidth: previousNextNavigationButtonWidth,
683
+ positionProperty: getDynamicPositionProperty(),
684
+ spaceBetweenSlideAndButton: spaceBetweenSlideAndPreviousNextNavigation
685
+ })
686
+ ]}
687
+ >
688
+ <IconButton
689
+ icon={isCarouselPlaying ? pauseIcon : playIcon}
690
+ variant={previousNextIconButtonVariants}
691
+ onPress={onAnimationControlButtonPress}
692
+ />
693
+ </View>
694
+ ) : null}
493
695
  {showPreviousNextNavigation && childrenArray.length > 1 ? (
494
696
  <View
495
697
  style={selectPreviousNextNavigationButtonStyles(
@@ -531,7 +733,7 @@ const Carousel = React.forwardRef(
531
733
  <View style={selectContainerStyles(containerLayout.width)}>
532
734
  <Animated.View
533
735
  style={StyleSheet.flatten([
534
- selectSwipeAreaStyles(children.length, containerLayout.width),
736
+ selectSwipeAreaStyles(childrenArray.length, containerLayout.width),
535
737
  {
536
738
  transform: [{ translateX: pan.x }, { translateY: pan.y }]
537
739
  }
@@ -650,7 +852,7 @@ Carousel.propTypes = {
650
852
  * <Carousel.Item>First Slide</Carousel.Item>
651
853
  * </Carousel>
652
854
  * ```
653
- * Caution: Always consider wrapping your callback for `onIndexChanged` in `useCallback` in order to avoid bugs and performance issues
855
+ * Caution: Always consider wrapping your callback for `onIndexChanged` in `React.useCallback` in order to avoid bugs and performance issues
654
856
  */
655
857
  onIndexChanged: PropTypes.func,
656
858
  /**
@@ -701,7 +903,7 @@ Carousel.propTypes = {
701
903
  * <Carousel.Item>First Slide</Carousel.Item>
702
904
  * </Carousel>
703
905
  * ```
704
- * Caution: Always consider wrapping your callback for `onAnimationStart` in `useCallback` in order to avoid bugs and performance issues
906
+ * Caution: Always consider wrapping your callback for `onAnimationStart` in `React.useCallback` in order to avoid bugs and performance issues
705
907
  */
706
908
  onAnimationStart: PropTypes.func,
707
909
  /**
@@ -718,7 +920,7 @@ Carousel.propTypes = {
718
920
  * <Carousel.Item>First Slide</Carousel.Item>
719
921
  * </Carousel>
720
922
  * ```
721
- * Caution: Always consider wrapping your callback for `onAnimationEnd` in `useCallback` in order to avoid bugs and performance issues
923
+ * Caution: Always consider wrapping your callback for `onAnimationEnd` in `React.useCallback` in order to avoid bugs and performance issues
722
924
  */
723
925
  onAnimationEnd: PropTypes.func,
724
926
  /**
@@ -743,7 +945,26 @@ Carousel.propTypes = {
743
945
  * Note that if the immediate Carousel children do not all render as `'li'` elements,
744
946
  * this should be changed (e.g. pass tag="div") because only 'li' is a valid child of 'ul'.
745
947
  */
746
- tag: PropTypes.oneOf(layoutTags)
948
+ tag: PropTypes.oneOf(layoutTags),
949
+ /**
950
+ * If set to `true`, the Carousel will automatically transition between slides
951
+ * and show the play/pause button
952
+ * - Default value is `false`
953
+ * - `slideDuration` and `transitionDuration` are required to be set for this to work
954
+ */
955
+ autoPlay: PropTypes.bool,
956
+ /**
957
+ * Duration of the time in seconds spent on each slide
958
+ * - Default value is `0`
959
+ * - `autoPlay` and `transitionDuration` are required to be set for this to work
960
+ */
961
+ slideDuration: PropTypes.number,
962
+ /**
963
+ * Duration of the time in seconds between each slide transition
964
+ * - Default value is `0`
965
+ * - `autoPlay` and `slideDuration` are required to be set for this to work
966
+ */
967
+ transitionDuration: PropTypes.number
747
968
  }
748
969
 
749
970
  Carousel.Item = CarouselItem
@@ -1,4 +1,4 @@
1
- import React, { forwardRef } from 'react'
1
+ import React from 'react'
2
2
  import { Pressable, Platform, StyleSheet } from 'react-native'
3
3
  import { PropTypes } from 'prop-types'
4
4
 
@@ -10,7 +10,7 @@ import { useCarousel } from '../CarouselContext'
10
10
  *
11
11
  * @TODO rework this after integrating with SkipLink when available.
12
12
  */
13
- const CarouselFirstFocus = forwardRef(({ title }, ref) => {
13
+ const CarouselFirstFocus = React.forwardRef(({ title }, ref) => {
14
14
  const { getCopyWithPlaceholders } = useCarousel()
15
15
 
16
16
  // TODO: integrate skip link description if behaving as skip link.