@telus-uds/components-base 1.3.0 → 1.5.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 (344) hide show
  1. package/.turbo/turbo-build.log +5 -2
  2. package/CHANGELOG.json +82 -0
  3. package/CHANGELOG.md +42 -2
  4. package/__tests__/ActivityIndicator/ActivityIndicator.test.jsx +35 -0
  5. package/__tests__/ActivityIndicator/__snapshots__/ActivityIndicator.test.jsx.snap +287 -0
  6. package/babel.config.js +27 -5
  7. package/component-docs.json +121 -438
  8. package/lib/A11yText/index.js +5 -4
  9. package/lib/ActivityIndicator/Spinner.js +46 -37
  10. package/lib/ActivityIndicator/Spinner.native.js +26 -15
  11. package/lib/Box/Box.js +4 -4
  12. package/lib/Button/ButtonBase.js +7 -8
  13. package/lib/Card/Card.js +5 -4
  14. package/lib/Card/PressableCardBase.js +6 -11
  15. package/lib/Checkbox/Checkbox.js +4 -6
  16. package/lib/Divider/Divider.js +12 -11
  17. package/lib/ExpandCollapse/Control.js +7 -7
  18. package/lib/ExpandCollapse/ExpandCollapse.js +6 -2
  19. package/lib/ExpandCollapse/Panel.js +6 -7
  20. package/lib/Feedback/Feedback.js +6 -5
  21. package/lib/Fieldset/Fieldset.js +1 -3
  22. package/lib/HorizontalScroll/HorizontalScroll.js +5 -7
  23. package/lib/HorizontalScroll/HorizontalScrollButton.js +23 -49
  24. package/lib/IconButton/IconButton.js +6 -6
  25. package/lib/InputLabel/InputLabel.js +7 -2
  26. package/lib/InputSupports/InputSupports.js +2 -2
  27. package/lib/Link/LinkBase.js +5 -6
  28. package/lib/List/List.js +4 -6
  29. package/lib/List/ListItem.js +6 -2
  30. package/lib/Modal/Modal.js +6 -2
  31. package/lib/Notification/Notification.js +12 -8
  32. package/lib/Pagination/Pagination.js +8 -3
  33. package/lib/Progress/Progress.js +5 -4
  34. package/lib/Progress/ProgressBar.js +8 -7
  35. package/lib/Radio/Radio.js +4 -6
  36. package/lib/Radio/RadioButton.js +6 -3
  37. package/lib/Radio/RadioGroup.js +7 -2
  38. package/lib/RadioCard/RadioCard.js +4 -4
  39. package/lib/RadioCard/RadioCardGroup.js +9 -6
  40. package/lib/Search/Search.js +7 -2
  41. package/lib/Select/Select.js +10 -9
  42. package/lib/SideNav/Item.js +7 -7
  43. package/lib/SideNav/SideNav.js +7 -3
  44. package/lib/Skeleton/Skeleton.js +6 -2
  45. package/lib/Spacer/Spacer.js +7 -18
  46. package/lib/StackView/StackView.js +7 -7
  47. package/lib/StackView/StackWrapBox.js +6 -7
  48. package/lib/StackView/StackWrapGap.js +6 -5
  49. package/lib/StepTracker/Step.js +7 -3
  50. package/lib/StepTracker/StepTracker.js +7 -7
  51. package/lib/Tabs/Tabs.js +6 -2
  52. package/lib/Tabs/TabsItem.js +6 -5
  53. package/lib/Tags/Tags.js +5 -6
  54. package/lib/TextInput/TextArea.js +13 -14
  55. package/lib/TextInput/TextInput.js +13 -14
  56. package/lib/TextInput/TextInputBase.js +5 -3
  57. package/lib/ToggleSwitch/ToggleSwitch.js +10 -9
  58. package/lib/ToggleSwitch/ToggleSwitchGroup.js +5 -7
  59. package/lib/Tooltip/Tooltip.js +7 -2
  60. package/lib/TooltipButton/TooltipButton.js +7 -2
  61. package/lib/Typography/Typography.js +8 -6
  62. package/lib/index.js +7 -0
  63. package/lib/utils/children.js +5 -1
  64. package/lib/utils/index.js +14 -0
  65. package/lib/utils/props/index.js +9 -0
  66. package/lib/{InputSupports/propTypes.js → utils/props/inputSupportsProps.js} +2 -3
  67. package/lib/utils/ssr.js +51 -0
  68. package/lib-module/A11yInfoProvider/index.js +62 -0
  69. package/lib-module/A11yText/index.js +55 -0
  70. package/lib-module/ActivityIndicator/Spinner.js +76 -0
  71. package/lib-module/ActivityIndicator/Spinner.native.js +143 -0
  72. package/lib-module/ActivityIndicator/index.js +40 -0
  73. package/lib-module/ActivityIndicator/shared.js +12 -0
  74. package/lib-module/BaseProvider/index.js +26 -0
  75. package/lib-module/Box/Box.js +243 -0
  76. package/lib-module/Box/index.js +2 -0
  77. package/lib-module/Button/Button.js +25 -0
  78. package/lib-module/Button/ButtonBase.js +254 -0
  79. package/lib-module/Button/ButtonGroup.js +164 -0
  80. package/lib-module/Button/ButtonLink.js +39 -0
  81. package/lib-module/Button/index.js +4 -0
  82. package/lib-module/Button/propTypes.js +36 -0
  83. package/lib-module/Card/Card.js +83 -0
  84. package/lib-module/Card/CardBase.js +62 -0
  85. package/lib-module/Card/PressableCardBase.js +113 -0
  86. package/lib-module/Card/index.js +4 -0
  87. package/lib-module/Checkbox/Checkbox.js +321 -0
  88. package/lib-module/Checkbox/CheckboxGroup.js +218 -0
  89. package/lib-module/Checkbox/CheckboxInput.js +58 -0
  90. package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
  91. package/lib-module/Checkbox/index.js +3 -0
  92. package/lib-module/Divider/Divider.js +123 -0
  93. package/lib-module/Divider/index.js +2 -0
  94. package/lib-module/ExpandCollapse/Accordion.js +15 -0
  95. package/lib-module/ExpandCollapse/Control.js +130 -0
  96. package/lib-module/ExpandCollapse/ExpandCollapse.js +94 -0
  97. package/lib-module/ExpandCollapse/Panel.js +158 -0
  98. package/lib-module/ExpandCollapse/index.js +7 -0
  99. package/lib-module/Feedback/Feedback.js +144 -0
  100. package/lib-module/Feedback/index.js +2 -0
  101. package/lib-module/Fieldset/Fieldset.js +145 -0
  102. package/lib-module/Fieldset/FieldsetContainer.js +29 -0
  103. package/lib-module/Fieldset/FieldsetContainer.native.js +20 -0
  104. package/lib-module/Fieldset/Legend.js +21 -0
  105. package/lib-module/Fieldset/Legend.native.js +28 -0
  106. package/lib-module/Fieldset/cssReset.js +14 -0
  107. package/lib-module/Fieldset/index.js +2 -0
  108. package/lib-module/FlexGrid/Col/Col.js +265 -0
  109. package/lib-module/FlexGrid/Col/index.js +2 -0
  110. package/lib-module/FlexGrid/FlexGrid.js +147 -0
  111. package/lib-module/FlexGrid/Row/Row.js +177 -0
  112. package/lib-module/FlexGrid/Row/index.js +2 -0
  113. package/lib-module/FlexGrid/helpers/index.js +18 -0
  114. package/lib-module/FlexGrid/index.js +2 -0
  115. package/lib-module/FlexGrid/providers/GutterContext.js +3 -0
  116. package/lib-module/HorizontalScroll/HorizontalScroll.js +170 -0
  117. package/lib-module/HorizontalScroll/HorizontalScrollButton.js +77 -0
  118. package/lib-module/HorizontalScroll/ScrollViewEnd.js +47 -0
  119. package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +24 -0
  120. package/lib-module/HorizontalScroll/dictionary.js +11 -0
  121. package/lib-module/HorizontalScroll/index.js +11 -0
  122. package/lib-module/HorizontalScroll/itemPositions.js +106 -0
  123. package/lib-module/Icon/Icon.js +61 -0
  124. package/lib-module/Icon/IconText.js +81 -0
  125. package/lib-module/Icon/index.js +4 -0
  126. package/lib-module/IconButton/IconButton.js +115 -0
  127. package/lib-module/IconButton/index.js +2 -0
  128. package/lib-module/InputLabel/InputLabel.js +131 -0
  129. package/lib-module/InputLabel/LabelContent.js +24 -0
  130. package/lib-module/InputLabel/LabelContent.native.js +16 -0
  131. package/lib-module/InputLabel/index.js +2 -0
  132. package/lib-module/InputSupports/InputSupports.js +88 -0
  133. package/lib-module/InputSupports/index.js +2 -0
  134. package/lib-module/InputSupports/useInputSupports.js +31 -0
  135. package/lib-module/Link/ChevronLink.js +51 -0
  136. package/lib-module/Link/InlinePressable.js +37 -0
  137. package/lib-module/Link/InlinePressable.native.js +85 -0
  138. package/lib-module/Link/Link.js +27 -0
  139. package/lib-module/Link/LinkBase.js +210 -0
  140. package/lib-module/Link/TextButton.js +43 -0
  141. package/lib-module/Link/index.js +5 -0
  142. package/lib-module/List/List.js +55 -0
  143. package/lib-module/List/ListItem.js +213 -0
  144. package/lib-module/List/index.js +5 -0
  145. package/lib-module/Modal/Modal.js +208 -0
  146. package/lib-module/Modal/dictionary.js +9 -0
  147. package/lib-module/Modal/index.js +2 -0
  148. package/lib-module/Notification/Notification.js +196 -0
  149. package/lib-module/Notification/dictionary.js +8 -0
  150. package/lib-module/Notification/index.js +2 -0
  151. package/lib-module/Pagination/PageButton.js +65 -0
  152. package/lib-module/Pagination/Pagination.js +140 -0
  153. package/lib-module/Pagination/SideButton.js +103 -0
  154. package/lib-module/Pagination/dictionary.js +18 -0
  155. package/lib-module/Pagination/index.js +2 -0
  156. package/lib-module/Pagination/usePagination.js +72 -0
  157. package/lib-module/Progress/Progress.js +85 -0
  158. package/lib-module/Progress/ProgressBar.js +134 -0
  159. package/lib-module/Progress/ProgressBarBackground.js +41 -0
  160. package/lib-module/Progress/index.js +4 -0
  161. package/lib-module/Radio/Radio.js +263 -0
  162. package/lib-module/Radio/RadioButton.js +128 -0
  163. package/lib-module/Radio/RadioGroup.js +225 -0
  164. package/lib-module/Radio/RadioInput.js +60 -0
  165. package/lib-module/Radio/RadioInput.native.js +6 -0
  166. package/lib-module/Radio/index.js +3 -0
  167. package/lib-module/RadioCard/RadioCard.js +218 -0
  168. package/lib-module/RadioCard/RadioCardGroup.js +232 -0
  169. package/lib-module/RadioCard/index.js +3 -0
  170. package/lib-module/Search/Search.js +233 -0
  171. package/lib-module/Search/dictionary.js +12 -0
  172. package/lib-module/Search/index.js +2 -0
  173. package/lib-module/Select/Group.js +20 -0
  174. package/lib-module/Select/Group.native.js +14 -0
  175. package/lib-module/Select/Item.js +17 -0
  176. package/lib-module/Select/Item.native.js +9 -0
  177. package/lib-module/Select/Picker.js +67 -0
  178. package/lib-module/Select/Picker.native.js +110 -0
  179. package/lib-module/Select/Select.js +317 -0
  180. package/lib-module/Select/index.js +6 -0
  181. package/lib-module/SideNav/Item.js +139 -0
  182. package/lib-module/SideNav/ItemContent.js +45 -0
  183. package/lib-module/SideNav/ItemsGroup.js +115 -0
  184. package/lib-module/SideNav/SideNav.js +133 -0
  185. package/lib-module/SideNav/index.js +1 -0
  186. package/lib-module/Skeleton/Skeleton.js +117 -0
  187. package/lib-module/Skeleton/index.js +2 -0
  188. package/lib-module/Skeleton/skeleton.constant.js +3 -0
  189. package/lib-module/Skeleton/skeletonWebAnimation.js +18 -0
  190. package/lib-module/Skeleton/useSkeletonNativeAnimation.js +24 -0
  191. package/lib-module/Spacer/Spacer.js +97 -0
  192. package/lib-module/Spacer/index.js +2 -0
  193. package/lib-module/StackView/StackView.js +124 -0
  194. package/lib-module/StackView/StackWrap.js +48 -0
  195. package/lib-module/StackView/StackWrap.native.js +3 -0
  196. package/lib-module/StackView/StackWrapBox.js +114 -0
  197. package/lib-module/StackView/StackWrapGap.js +58 -0
  198. package/lib-module/StackView/common.js +32 -0
  199. package/lib-module/StackView/getStackedContent.js +123 -0
  200. package/lib-module/StackView/index.js +5 -0
  201. package/lib-module/StepTracker/Step.js +229 -0
  202. package/lib-module/StepTracker/StepTracker.js +175 -0
  203. package/lib-module/StepTracker/dictionary.js +10 -0
  204. package/lib-module/StepTracker/index.js +2 -0
  205. package/lib-module/Tabs/Tabs.js +113 -0
  206. package/lib-module/Tabs/TabsItem.js +215 -0
  207. package/lib-module/Tabs/index.js +2 -0
  208. package/lib-module/Tags/Tags.js +238 -0
  209. package/lib-module/Tags/index.js +2 -0
  210. package/lib-module/TextInput/TextArea.js +88 -0
  211. package/lib-module/TextInput/TextInput.js +60 -0
  212. package/lib-module/TextInput/TextInputBase.js +233 -0
  213. package/lib-module/TextInput/index.js +3 -0
  214. package/lib-module/TextInput/propTypes.js +31 -0
  215. package/lib-module/ThemeProvider/ThemeProvider.js +35 -0
  216. package/lib-module/ThemeProvider/index.js +6 -0
  217. package/lib-module/ThemeProvider/useSetTheme.js +22 -0
  218. package/lib-module/ThemeProvider/useTheme.js +14 -0
  219. package/lib-module/ThemeProvider/useThemeTokens.js +105 -0
  220. package/lib-module/ThemeProvider/utils/index.js +2 -0
  221. package/lib-module/ThemeProvider/utils/styles.js +174 -0
  222. package/lib-module/ThemeProvider/utils/theme-tokens.js +151 -0
  223. package/lib-module/ToggleSwitch/ToggleSwitch.js +224 -0
  224. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +202 -0
  225. package/lib-module/ToggleSwitch/index.js +3 -0
  226. package/lib-module/Tooltip/Backdrop.js +52 -0
  227. package/lib-module/Tooltip/Backdrop.native.js +43 -0
  228. package/lib-module/Tooltip/Tooltip.js +332 -0
  229. package/lib-module/Tooltip/dictionary.js +8 -0
  230. package/lib-module/Tooltip/getTooltipPosition.js +164 -0
  231. package/lib-module/Tooltip/index.js +2 -0
  232. package/lib-module/TooltipButton/TooltipButton.js +71 -0
  233. package/lib-module/TooltipButton/index.js +2 -0
  234. package/lib-module/Typography/Typography.js +118 -0
  235. package/lib-module/Typography/index.js +2 -0
  236. package/lib-module/ViewportProvider/ViewportProvider.js +28 -0
  237. package/lib-module/ViewportProvider/index.js +3 -0
  238. package/lib-module/ViewportProvider/useViewport.js +3 -0
  239. package/lib-module/ViewportProvider/useViewportListener.js +43 -0
  240. package/lib-module/index.js +48 -0
  241. package/lib-module/utils/a11y/index.js +2 -0
  242. package/lib-module/utils/a11y/semantics.js +154 -0
  243. package/lib-module/utils/a11y/textSize.js +34 -0
  244. package/lib-module/utils/animation/index.js +2 -0
  245. package/lib-module/utils/animation/useVerticalExpandAnimation.js +49 -0
  246. package/lib-module/utils/children.js +118 -0
  247. package/lib-module/utils/index.js +15 -0
  248. package/lib-module/utils/info/index.js +7 -0
  249. package/lib-module/utils/info/platform/index.js +11 -0
  250. package/lib-module/utils/info/platform/platform.android.js +1 -0
  251. package/lib-module/utils/info/platform/platform.ios.js +1 -0
  252. package/lib-module/utils/info/platform/platform.js +1 -0
  253. package/lib-module/utils/info/platform/platform.native.js +4 -0
  254. package/lib-module/utils/info/versions.js +5 -0
  255. package/lib-module/utils/input.js +180 -0
  256. package/lib-module/utils/pressability.js +97 -0
  257. package/lib-module/utils/props/a11yProps.js +140 -0
  258. package/lib-module/utils/props/clickProps.js +25 -0
  259. package/lib-module/utils/props/componentPropType.js +63 -0
  260. package/lib-module/utils/props/copyPropTypes.js +2 -0
  261. package/lib-module/utils/props/getPropSelector.js +6 -0
  262. package/lib-module/utils/props/hrefAttrsProp.js +30 -0
  263. package/lib-module/utils/props/index.js +16 -0
  264. package/lib-module/utils/props/inputSupportsProps.js +54 -0
  265. package/lib-module/utils/props/linkProps.js +47 -0
  266. package/lib-module/utils/props/paddingProp.js +9 -0
  267. package/lib-module/utils/props/pressProps.js +42 -0
  268. package/lib-module/utils/props/rectProp.js +9 -0
  269. package/lib-module/utils/props/responsiveProps.js +30 -0
  270. package/lib-module/utils/props/selectSystemProps.js +24 -0
  271. package/lib-module/utils/props/spacingProps.js +56 -0
  272. package/lib-module/utils/props/tokens.js +120 -0
  273. package/lib-module/utils/props/variantProp.js +18 -0
  274. package/lib-module/utils/props/viewProps.js +22 -0
  275. package/lib-module/utils/ssr.js +35 -0
  276. package/lib-module/utils/useCopy.js +42 -0
  277. package/lib-module/utils/useHash.js +44 -0
  278. package/lib-module/utils/useHash.native.js +7 -0
  279. package/lib-module/utils/useResponsiveProp.js +47 -0
  280. package/lib-module/utils/useSpacingScale.js +123 -0
  281. package/lib-module/utils/useUniqueId.js +12 -0
  282. package/lib-module/utils/withLinkRouter.js +82 -0
  283. package/package.json +9 -5
  284. package/src/A11yText/index.jsx +7 -3
  285. package/src/ActivityIndicator/Spinner.jsx +56 -44
  286. package/src/ActivityIndicator/Spinner.native.jsx +20 -12
  287. package/src/Box/Box.jsx +10 -9
  288. package/src/Button/ButtonBase.jsx +9 -8
  289. package/src/Card/Card.jsx +7 -4
  290. package/src/Card/PressableCardBase.jsx +12 -12
  291. package/src/Checkbox/Checkbox.jsx +12 -5
  292. package/src/Divider/Divider.jsx +17 -10
  293. package/src/ExpandCollapse/Control.jsx +12 -7
  294. package/src/ExpandCollapse/ExpandCollapse.jsx +13 -3
  295. package/src/ExpandCollapse/Panel.jsx +15 -5
  296. package/src/Feedback/Feedback.jsx +13 -3
  297. package/src/Fieldset/Fieldset.jsx +1 -1
  298. package/src/HorizontalScroll/HorizontalScroll.jsx +13 -6
  299. package/src/HorizontalScroll/HorizontalScrollButton.jsx +21 -58
  300. package/src/IconButton/IconButton.jsx +12 -8
  301. package/src/InputLabel/InputLabel.jsx +16 -2
  302. package/src/InputSupports/InputSupports.jsx +1 -1
  303. package/src/Link/LinkBase.jsx +10 -9
  304. package/src/List/List.jsx +12 -5
  305. package/src/List/ListItem.jsx +16 -2
  306. package/src/Modal/Modal.jsx +63 -50
  307. package/src/Notification/Notification.jsx +23 -6
  308. package/src/Pagination/Pagination.jsx +10 -3
  309. package/src/Progress/Progress.jsx +5 -3
  310. package/src/Progress/ProgressBar.jsx +8 -6
  311. package/src/Radio/Radio.jsx +13 -5
  312. package/src/Radio/RadioButton.jsx +13 -3
  313. package/src/Radio/RadioGroup.jsx +14 -2
  314. package/src/RadioCard/RadioCard.jsx +9 -6
  315. package/src/RadioCard/RadioCardGroup.jsx +16 -4
  316. package/src/Search/Search.jsx +15 -3
  317. package/src/Select/Select.jsx +21 -7
  318. package/src/SideNav/Item.jsx +15 -7
  319. package/src/SideNav/SideNav.jsx +13 -2
  320. package/src/Skeleton/Skeleton.jsx +55 -43
  321. package/src/Spacer/Spacer.jsx +8 -16
  322. package/src/StackView/StackView.jsx +13 -12
  323. package/src/StackView/StackWrapBox.jsx +12 -12
  324. package/src/StackView/StackWrapGap.jsx +9 -7
  325. package/src/StepTracker/Step.jsx +7 -4
  326. package/src/StepTracker/StepTracker.jsx +8 -8
  327. package/src/Tabs/Tabs.jsx +16 -3
  328. package/src/Tabs/TabsItem.jsx +13 -9
  329. package/src/Tags/Tags.jsx +20 -5
  330. package/src/TextInput/TextArea.jsx +20 -8
  331. package/src/TextInput/TextInput.jsx +20 -8
  332. package/src/TextInput/TextInputBase.jsx +13 -3
  333. package/src/ToggleSwitch/ToggleSwitch.jsx +16 -5
  334. package/src/ToggleSwitch/ToggleSwitchGroup.jsx +14 -6
  335. package/src/Tooltip/Tooltip.jsx +13 -3
  336. package/src/TooltipButton/TooltipButton.jsx +6 -4
  337. package/src/Typography/Typography.jsx +10 -6
  338. package/src/index.js +1 -1
  339. package/src/utils/children.jsx +2 -1
  340. package/src/utils/index.js +1 -0
  341. package/src/utils/props/index.js +1 -0
  342. package/src/{InputSupports/propTypes.js → utils/props/inputSupportsProps.js} +2 -4
  343. package/src/utils/ssr.js +35 -0
  344. package/release-context.json +0 -7
@@ -0,0 +1,48 @@
1
+ import React, { forwardRef } from 'react';
2
+ import Platform from "react-native-web/dist/exports/Platform";
3
+ import StackWrapBox from './StackWrapBox';
4
+ import StackWrapGap from './StackWrapGap'; // In Jest/CI/SSR, global CSS isn't always available and doesn't always have .supports method
5
+
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+
8
+ const cssSupports = (...args) => {
9
+ var _window$CSS;
10
+
11
+ return typeof window !== 'undefined' && typeof ((_window$CSS = window.CSS) === null || _window$CSS === void 0 ? void 0 : _window$CSS.supports) === 'function' && window.CSS.supports(...args);
12
+ }; // CSS.supports needs an example of the type of value you intend to use.
13
+ // Will be an integer appended `px` after hooks and JSX styles are resolved.
14
+
15
+
16
+ const exampleGapValue = '1px';
17
+ /**
18
+ * StackWrap is an alternative to StackView where the spaced items are allowed to wrap.
19
+ *
20
+ * As well as providing space between the items, StackWrap provides `gap` space between
21
+ * wrapped lines of items. By default, this `gap` is the same as the gap between spaced items.
22
+ * If a different spacing is desired between wrapped lines, pass a spacing value to the `gap` prop.
23
+ */
24
+
25
+ const StackWrap = /*#__PURE__*/forwardRef((props, ref) => {
26
+ const {
27
+ space
28
+ } = props; // Don't apply separate gap if `null` or `undefined`, so can be unset in Storybook etc
29
+
30
+ const gap = props.gap ?? space;
31
+ const canUseCSSGap = Platform.OS === 'web' && gap === space && cssSupports('gap', exampleGapValue);
32
+ return canUseCSSGap ?
33
+ /*#__PURE__*/
34
+ // If possible, use the cleaner implementation that applies CSS `gap` styles to the container.
35
+ _jsx(StackWrapGap, {
36
+ ref: ref,
37
+ ...props
38
+ }) :
39
+ /*#__PURE__*/
40
+ // Else, use the fallback implementation which renders a `Box` component around each child.
41
+ _jsx(StackWrapBox, {
42
+ ref: ref,
43
+ ...props
44
+ });
45
+ });
46
+ StackWrap.displayName = 'StackWrap';
47
+ StackWrap.propTypes = StackWrapBox.propTypes;
48
+ export default StackWrap;
@@ -0,0 +1,3 @@
1
+ import StackWrapBox from './StackWrapBox'; // No support for CSS `gap` on React Native, so always use the fallback "box" implementation.
2
+
3
+ export default StackWrapBox;
@@ -0,0 +1,114 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import View from "react-native-web/dist/exports/View";
4
+ import { a11yProps, getA11yPropsFromHtmlTag, getTokensPropType, layoutTags, responsiveProps, selectSystemProps, spacingProps, useSpacingScale, useResponsiveProp, viewProps } from '../utils';
5
+ import { useThemeTokens } from '../ThemeProvider';
6
+ import { useViewport } from '../ViewportProvider';
7
+ import getStackedContent from './getStackedContent';
8
+ import { staticStyles, selectFlexStyles } from './common';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
11
+ const offsetSides = {
12
+ row: 'marginBottom',
13
+ column: 'marginRight'
14
+ };
15
+ const gapSides = {
16
+ row: 'bottom',
17
+ column: 'right'
18
+ };
19
+ const spaceSides = {
20
+ row: 'right',
21
+ column: 'bottom'
22
+ };
23
+ /**
24
+ * An alternative fallback implementation of `StackWrap` that doesn't use CSS `gap`.
25
+ *
26
+ * This is not intended to be used directly. It will automatically be used instead of StackWrap in:
27
+ *
28
+ * - Native apps (no `gap` style prop in React Native).
29
+ * - Older (~<=2020) browsers which don't support CSS `gap`.
30
+ * - Cases where the `space` between items should be different to the `gap` between wrapped rows .
31
+ *
32
+ * Unlike the cleaner and more side-effect-free CSS gap StackWrap implementation, this renders a Box (View)
33
+ * between the container and the stacked children, and requires a negative margin on the container.
34
+ */
35
+
36
+ const StackWrapBox = /*#__PURE__*/forwardRef(({
37
+ space = 1,
38
+ gap = space,
39
+ direction: directionProp = 'row',
40
+ children,
41
+ tokens,
42
+ variant,
43
+ tag,
44
+ accessibilityRole,
45
+ ...rest
46
+ }, ref) => {
47
+ const viewport = useViewport();
48
+ const direction = useResponsiveProp(directionProp, 'row');
49
+ const themeTokens = useThemeTokens('StackView', tokens, variant, {
50
+ viewport
51
+ });
52
+ const flexStyles = selectFlexStyles(themeTokens);
53
+ const selectedProps = selectProps({ ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
54
+ ...rest
55
+ }); // Mimic CSS `gap` using box spacing on the side after a wrapped row then offsetting it on the last row.
56
+
57
+ const gapSize = useSpacingScale(gap);
58
+ const offsetStyle = {
59
+ [offsetSides[direction]]: -1 * gapSize
60
+ };
61
+ const boxProps = {
62
+ [gapSides[direction]]: gap,
63
+ [spaceSides[direction]]: space
64
+ };
65
+ const content = getStackedContent(children, {
66
+ direction,
67
+ space: 0,
68
+ box: boxProps
69
+ });
70
+ return /*#__PURE__*/_jsx(View, {
71
+ ref: ref,
72
+ ...selectedProps,
73
+ style: [flexStyles, staticStyles.wrap, staticStyles[direction], offsetStyle],
74
+ children: content
75
+ });
76
+ });
77
+ StackWrapBox.displayName = 'StackWrapBox';
78
+ StackWrapBox.propTypes = { ...selectedSystemPropTypes,
79
+ tokens: getTokensPropType('StackView'),
80
+
81
+ /**
82
+ * Sets the `flexDirection` of the container
83
+ */
84
+ direction: responsiveProps.getTypeOptionallyByViewport(PropTypes.oneOf(['column', 'row', 'row-reverse', 'column-reverse'])),
85
+
86
+ /**
87
+ * The size of the space between items according to the theme's spacing scale.
88
+ * Either a number corresponding to a position on the theme's spacing scale (1 is smallest, 2 is second smallest, etc),
89
+ * or, a SpacingObject with viewport keys and options (see `useSpacingScale` for details).
90
+ */
91
+ space: spacingProps.types.spacingValue,
92
+
93
+ /**
94
+ * The size of the space between lines of content, according to the theme's spacing scale. By default, matches `space`.
95
+ * Either a number corresponding to a position on the theme's spacing scale (1 is smallest, 2 is second smallest, etc),
96
+ * or, a SpacingObject with viewport keys and options (see `useSpacingScale` for details).
97
+ */
98
+ gap: spacingProps.types.spacingValue,
99
+
100
+ /**
101
+ * Optional semantic HTML tag, to apply to the container on web. Does not change styling.
102
+ *
103
+ * In native apps, if a header tag is provided ("h1", "h2" etc) and accessibilityRole prop
104
+ * is not defined, the accessibilityRole will default to "heading".
105
+ */
106
+ tag: PropTypes.oneOf(layoutTags),
107
+
108
+ /**
109
+ * A StackWrap may take any children, but will have no effect if it is only passed one child or is passed children
110
+ * wrapped in a component. If necessary, children may be wrapped in one React Fragment.
111
+ */
112
+ children: PropTypes.node
113
+ };
114
+ export default StackWrapBox;
@@ -0,0 +1,58 @@
1
+ import React, { forwardRef } from 'react';
2
+ import View from "react-native-web/dist/exports/View";
3
+ import StackWrapBox from './StackWrapBox';
4
+ import { a11yProps, getA11yPropsFromHtmlTag, selectSystemProps, useSpacingScale, useResponsiveProp, viewProps } from '../utils';
5
+ import { useThemeTokens } from '../ThemeProvider';
6
+ import { useViewport } from '../ViewportProvider';
7
+ import getStackedContent from './getStackedContent';
8
+ import { staticStyles, selectFlexStyles } from './common';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ const [selectProps] = selectSystemProps([a11yProps, viewProps]);
11
+ /**
12
+ * The primary implementation of StackWrap.
13
+ *
14
+ * This is not intended to be used directly. It will automatically be used instead of StackWrap if:
15
+ *
16
+ * - On web, and,
17
+ * - On a browser that supports CSS `gap` (most browser versions from 2020 onwards), and,
18
+ * - The `space` between items is the same as the `gap` between wrapped rows (this is the
19
+ * default if `gap` prop is undefined)
20
+ */
21
+
22
+ const StackWrapGap = /*#__PURE__*/forwardRef(({
23
+ space = 1,
24
+ tokens,
25
+ variant,
26
+ direction: directionProp = 'row',
27
+ children,
28
+ tag,
29
+ accessibilityRole,
30
+ ...rest
31
+ }, ref) => {
32
+ const viewport = useViewport();
33
+ const direction = useResponsiveProp(directionProp, 'row');
34
+ const themeTokens = useThemeTokens('StackView', tokens, variant, {
35
+ viewport
36
+ });
37
+ const flexStyles = selectFlexStyles(themeTokens);
38
+ const selectedProps = selectProps({ ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
39
+ ...rest
40
+ });
41
+ const size = useSpacingScale(space);
42
+ const gapStyle = {
43
+ gap: size
44
+ };
45
+ const content = getStackedContent(children, {
46
+ direction,
47
+ space: 0
48
+ });
49
+ return /*#__PURE__*/_jsx(View, {
50
+ ref: ref,
51
+ ...selectedProps,
52
+ style: [flexStyles, staticStyles.wrap, staticStyles[direction], gapStyle],
53
+ children: content
54
+ });
55
+ });
56
+ StackWrapGap.displayName = 'StackWrapGap';
57
+ StackWrapGap.propTypes = StackWrapBox.propTypes;
58
+ export default StackWrapGap;
@@ -0,0 +1,32 @@
1
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
2
+ export const selectFlexStyles = ({
3
+ alignItems,
4
+ justifyContent,
5
+ flexGrow,
6
+ flexShrink
7
+ }) => ({
8
+ alignItems,
9
+ justifyContent,
10
+ flexGrow,
11
+ flexShrink
12
+ });
13
+ export const staticStyles = StyleSheet.create({
14
+ wrap: {
15
+ flexShrink: 1,
16
+ flexWrap: 'wrap'
17
+ },
18
+ row: {
19
+ flexDirection: 'row'
20
+ },
21
+ 'row-reverse': {
22
+ flexDirection: 'row-reverse'
23
+ },
24
+ column: {
25
+ // This is the React Native View default, but also it's very fundamental to the behaviour,
26
+ // so make it explicit and allow it to be tested for.
27
+ flexDirection: 'column'
28
+ },
29
+ 'column-reverse': {
30
+ flexDirection: 'column-reverse'
31
+ }
32
+ });
@@ -0,0 +1,123 @@
1
+ import React, { Children, Fragment } from 'react';
2
+ import Box from '../Box';
3
+ import Divider from '../Divider';
4
+ import Spacer from '../Spacer';
5
+ /**
6
+ * @typedef {import('react').ReactChildren} ReactChildren
7
+ * @typedef {import('react').ReactElement} ReactElement
8
+ * @typedef {import('../utils/props/spacingProps.js').SpacingValue} SpacingValue
9
+ */
10
+
11
+ /**
12
+ * Takes valid React Children and inserts a specified amount of space between each valid (not nullish) top
13
+ * level element, according to the provided `options`.
14
+ *
15
+ * Returns an array of the original elements plus inserted spacing elements.
16
+ * This array of elements is keyed and may be used as a component's `children` without mapping.
17
+ *
18
+ * @param {ReactChildren} children
19
+ * @param {object} [options] -
20
+ * - `space`: amount of space to insert using the theme spacing scale (see `useSpacingScale`)
21
+ * - `direction`: if 'row' or 'row-reverse', applies space horizontally, if 'column' or 'column-reverse', applies space vertically
22
+ * - `box`: if truthy, wraps each valid child in a Box component; if an object, passes it to Box as props
23
+ * - `divider`: if truthy, inserts Divider components; if an object, passes it to Divider as props
24
+ * - `preserveFragments`: if true, adds no space between top-level elements that were passed inside a nested fragment
25
+ * @param {SpacingValue} [options.space]
26
+ * @param {boolean | object} [options.divider]
27
+ * @param {"row" | "column" | "row-reverse" | "column-reverse"} [options.direction]
28
+ * @param {boolean} [options.preserveFragments]
29
+ * @returns {ReactElement[]}
30
+ */
31
+
32
+ import { createElement as _createElement } from "react";
33
+ import { jsx as _jsx } from "react/jsx-runtime";
34
+
35
+ const getStackedContent = (children, {
36
+ divider,
37
+ space,
38
+ direction = 'column',
39
+ box,
40
+ preserveFragments = false
41
+ }) => {
42
+ const boxProps = box && typeof box === 'object' ? box : {
43
+ space
44
+ };
45
+ const dividerProps = divider && typeof divider === 'object' ? divider : {}; // Avoid surprises if children contains comments, nulls, or is a variable wrapped as a fragment
46
+
47
+ const topLevelChildren = preserveFragments ? children : unpackFragment(children);
48
+ const validChildren = Children.toArray(topLevelChildren).filter(Boolean);
49
+ const content = validChildren.reduce((newChildren, child, index) => {
50
+ const boxID = `Stack-Box-${index}`;
51
+ const item = box ?
52
+ /*#__PURE__*/
53
+ // If wrapped in Box, that Box needs a key.
54
+ // If possible, use an existing content key; use an index-based key only if necessary.
55
+ _createElement(Box, { ...boxProps,
56
+ key: child.key || boxID,
57
+ testID: boxID
58
+ }, child) : child;
59
+ if (!index || !space && !divider) return [...newChildren, item];
60
+ const testID = `Stack-${divider ? 'Divider' : 'Spacer'}-${index}`;
61
+ const commonProps = {
62
+ testID,
63
+ key: testID,
64
+ space
65
+ };
66
+ const separator = divider ? /*#__PURE__*/_jsx(Divider, {
67
+ vertical: direction.startsWith('row'),
68
+ ...dividerProps,
69
+ ...commonProps
70
+ }) : /*#__PURE__*/_jsx(Spacer, {
71
+ direction: direction.startsWith('row') ? 'row' : 'column',
72
+ ...commonProps
73
+ });
74
+ return [...newChildren, separator, item];
75
+ }, []);
76
+ return content;
77
+ };
78
+ /**
79
+ * Unpacks top-level fragments, so that common compositional patterns such as the following examples
80
+ * can be iterated as flat siblings (as if they were `<Child1 /><Child2 /><Child3 />`):
81
+ *
82
+ * - Setting `children` as a property wrapped in a fragment:
83
+ *
84
+ * ```jsx
85
+ * args.children = <><Child1 /><Child2 /><Child3 /></>
86
+ * ```
87
+ *
88
+ * - Defining `children` as a variable wrapped in a fragment:
89
+ *
90
+ * ```jsx
91
+ * const content = <><Child1 /><Child2 /><Child3 /></>
92
+ * if (someCondition) return <SomeWrapper>{content}</SomeWrapper>
93
+ * ```
94
+ *
95
+ * - Using fragments at the top level of a JSX block for conditional rendering:
96
+ *
97
+ * ```jsx
98
+ * <Child1 />
99
+ * {someCondition && (
100
+ * <>
101
+ * <Child2 />
102
+ * <Child3 />
103
+ * </>
104
+ * )}
105
+ * ```
106
+ *
107
+ * @param {ReactChildren} child
108
+ * @returns {ReactChildren}
109
+ */
110
+
111
+
112
+ const unpackFragment = child => {
113
+ var _child$props;
114
+
115
+ // If this level is a set of top-level siblings rather than one child, check each in turn
116
+ if (Children.count(child) > 1) return Children.map(child, unpackFragment); // When a fragment is found, unpack its children to the top level and check them
117
+
118
+ if ((child === null || child === void 0 ? void 0 : child.type) === Fragment) return unpackFragment((_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.children); // Stop unpacking as soon as any non-fragment child is found
119
+
120
+ return child;
121
+ };
122
+
123
+ export default getStackedContent;
@@ -0,0 +1,5 @@
1
+ import StackView from './StackView';
2
+ import StackWrap from './StackWrap';
3
+ export default StackView;
4
+ export { StackWrap };
5
+ export { default as getStackedContent } from './getStackedContent';
@@ -0,0 +1,229 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
4
+ import Text from "react-native-web/dist/exports/Text";
5
+ import View from "react-native-web/dist/exports/View";
6
+ import StackView from '../StackView';
7
+ import Icon from '../Icon';
8
+ import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
9
+ import { applyTextStyles } from '../ThemeProvider';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
13
+
14
+ const selectCompletedIconTokens = ({
15
+ completedIconColor,
16
+ completedIconSize
17
+ }) => ({
18
+ size: completedIconSize,
19
+ color: completedIconColor
20
+ });
21
+
22
+ const selectConnectorStyles = ({
23
+ connectorColor,
24
+ connectorHeight,
25
+ connectorMinWidth,
26
+ connectorCompletedHeight,
27
+ connectorCompletedColor
28
+ }, isCompleted) => ({
29
+ backgroundColor: connectorColor,
30
+ height: connectorHeight,
31
+ minWidth: connectorMinWidth,
32
+ ...(isCompleted && {
33
+ height: connectorCompletedHeight,
34
+ backgroundColor: connectorCompletedColor
35
+ })
36
+ });
37
+
38
+ const selectCurrentInnerStyles = ({
39
+ knobCurrentInnerColor,
40
+ knobCurrentInnerSize
41
+ }) => ({
42
+ backgroundColor: knobCurrentInnerColor,
43
+ borderRadius: knobCurrentInnerSize / 2,
44
+ height: knobCurrentInnerSize,
45
+ width: knobCurrentInnerSize
46
+ });
47
+
48
+ const selectKnobStyles = ({
49
+ knobBackgroundColor,
50
+ knobBorderColor,
51
+ knobBorderWidth,
52
+ knobCompletedBackgroundColor,
53
+ knobCompletedBorderColor,
54
+ knobCompletedPaddingLeft,
55
+ knobCompletedPaddingTop,
56
+ knobCurrentBackgroundColor,
57
+ knobCurrentBorderColor,
58
+ knobCurrentBorderWidth,
59
+ knobCurrentPaddingLeft,
60
+ knobCurrentPaddingTop,
61
+ knobSize
62
+ }, isCompleted, isCurrent) => ({
63
+ backgroundColor: knobBackgroundColor,
64
+ borderColor: knobBorderColor,
65
+ borderRadius: knobSize / 2,
66
+ borderWidth: knobBorderWidth,
67
+ height: knobSize,
68
+ width: knobSize,
69
+ ...(isCompleted && {
70
+ backgroundColor: knobCompletedBackgroundColor,
71
+ borderColor: knobCompletedBorderColor,
72
+ paddingLeft: knobCompletedPaddingLeft,
73
+ paddingTop: knobCompletedPaddingTop
74
+ }),
75
+ ...(isCurrent && {
76
+ backgroundColor: knobCurrentBackgroundColor,
77
+ borderColor: knobCurrentBorderColor,
78
+ borderWidth: knobCurrentBorderWidth,
79
+ paddingLeft: knobCurrentPaddingLeft,
80
+ paddingTop: knobCurrentPaddingTop
81
+ })
82
+ });
83
+
84
+ const selectLabelContainerStyles = ({
85
+ labelDirection,
86
+ labelGap,
87
+ labelMarginTop,
88
+ labelPaddingLeft,
89
+ labelPaddingRight
90
+ }) => ({
91
+ marginTop: labelMarginTop,
92
+ paddingLeft: labelPaddingLeft,
93
+ paddingRight: labelPaddingRight,
94
+ flexDirection: labelDirection,
95
+ gap: labelGap
96
+ });
97
+
98
+ const selectLabelStyles = ({
99
+ labelColor,
100
+ labelCurrentColor,
101
+ labelCurrentFontWeight,
102
+ labelFontSize,
103
+ labelFontWeight,
104
+ labelFontName,
105
+ labelLineHeight
106
+ }, isCurrent) => applyTextStyles({
107
+ color: isCurrent ? labelCurrentColor : labelColor,
108
+ fontSize: labelFontSize,
109
+ lineHeight: labelLineHeight,
110
+ fontWeight: isCurrent ? labelCurrentFontWeight : labelFontWeight,
111
+ fontName: labelFontName
112
+ });
113
+
114
+ const getStepTestID = (isCompleted, isCurrent) => {
115
+ let testID = 'StepTracker-Step';
116
+
117
+ if (isCompleted) {
118
+ testID += '-Completed';
119
+ } else if (isCurrent) {
120
+ testID += '-Current';
121
+ }
122
+
123
+ return testID;
124
+ };
125
+ /**
126
+ * A single step of a StepTracker.
127
+ */
128
+
129
+
130
+ const Step = ({
131
+ label,
132
+ name,
133
+ status = 0,
134
+ stepCount = 0,
135
+ stepIndex = 0,
136
+ tokens,
137
+ ...rest
138
+ }) => {
139
+ const {
140
+ completedIcon,
141
+ showStepLabel,
142
+ showStepName,
143
+ ...themeTokens
144
+ } = tokens;
145
+ const isFirst = stepIndex === 0;
146
+ const isLast = stepIndex === stepCount - 1;
147
+ const isCompleted = status > stepIndex;
148
+ const isCurrent = status === stepIndex;
149
+ const isActive = isCompleted || isCurrent;
150
+ return /*#__PURE__*/_jsxs(StackView, {
151
+ space: 0,
152
+ tokens: {
153
+ alignItems: 'stretch',
154
+ flexGrow: 1
155
+ },
156
+ accessibilityLabel: label,
157
+ accessibilityLevel: 2,
158
+ accessibilityCurrent: status === stepIndex,
159
+ ...selectProps(rest),
160
+ children: [/*#__PURE__*/_jsxs(StackView, {
161
+ direction: "row",
162
+ space: 0,
163
+ tokens: {
164
+ alignItems: 'center',
165
+ flexGrow: 0
166
+ },
167
+ children: [/*#__PURE__*/_jsx(View, {
168
+ style: [staticStyles.connector, !isFirst && selectConnectorStyles(themeTokens, isActive)]
169
+ }), /*#__PURE__*/_jsxs(View, {
170
+ style: [staticStyles.knob, selectKnobStyles(themeTokens, isCompleted, isCurrent)],
171
+ testID: getStepTestID(isCompleted, isCurrent),
172
+ children: [isCompleted && completedIcon && /*#__PURE__*/_jsx(Icon, {
173
+ icon: completedIcon,
174
+ tokens: selectCompletedIconTokens(themeTokens)
175
+ }), isCurrent && /*#__PURE__*/_jsx(View, {
176
+ style: selectCurrentInnerStyles(themeTokens)
177
+ })]
178
+ }), /*#__PURE__*/_jsx(View, {
179
+ style: [staticStyles.connector, !isLast && selectConnectorStyles(themeTokens, isCompleted)]
180
+ })]
181
+ }), showStepLabel && /*#__PURE__*/_jsxs(View, {
182
+ style: [staticStyles.stepLabelContainer, selectLabelContainerStyles(tokens)],
183
+ children: [showStepName && /*#__PURE__*/_jsx(Text, {
184
+ style: [staticStyles.centeredText, selectLabelStyles(tokens, isCurrent)],
185
+ children: name
186
+ }), /*#__PURE__*/_jsx(StackView, {
187
+ direction: "row",
188
+ children: /*#__PURE__*/_jsx(Text, {
189
+ style: [staticStyles.centeredText, tokens.labelDirection === 'column' && staticStyles.wrappingLabel, selectLabelStyles(tokens, isCurrent)],
190
+ children: label
191
+ })
192
+ })]
193
+ })]
194
+ });
195
+ };
196
+
197
+ Step.propTypes = { ...selectedSystemPropTypes,
198
+ label: PropTypes.string.isRequired,
199
+ name: PropTypes.string.isRequired,
200
+ status: PropTypes.number.isRequired,
201
+ stepCount: PropTypes.number.isRequired,
202
+ stepIndex: PropTypes.number.isRequired,
203
+ tokens: getTokensPropType('StepTracker'),
204
+ variant: variantProp.propType
205
+ };
206
+ export default Step;
207
+ const staticStyles = StyleSheet.create({
208
+ centeredText: {
209
+ textAlign: 'center'
210
+ },
211
+ connector: {
212
+ flex: 1,
213
+ height: 1
214
+ },
215
+ completedKnob: {
216
+ backgroundColor: 'transparent',
217
+ textAlign: 'center'
218
+ },
219
+ knob: {
220
+ borderWidth: 1
221
+ },
222
+ stepLabelContainer: {
223
+ justifyContent: 'center'
224
+ },
225
+ wrappingLabel: {
226
+ width: 0,
227
+ flex: 1
228
+ }
229
+ });