@telus-uds/components-base 1.8.2 → 1.8.5

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 (278) hide show
  1. package/CHANGELOG.md +33 -2
  2. package/component-docs.json +36 -1
  3. package/lib/ActivityIndicator/Spinner.js +7 -7
  4. package/lib/ActivityIndicator/Spinner.native.js +2 -2
  5. package/lib/Button/ButtonBase.js +2 -2
  6. package/lib/Button/ButtonGroup.js +1 -1
  7. package/lib/Checkbox/Checkbox.js +5 -3
  8. package/lib/Checkbox/CheckboxGroup.js +2 -2
  9. package/lib/Divider/Divider.js +2 -2
  10. package/lib/ExpandCollapse/Panel.js +2 -17
  11. package/lib/FlexGrid/Col/Col.js +1 -1
  12. package/lib/Icon/Icon.js +1 -1
  13. package/lib/Link/InlinePressable.js +5 -1
  14. package/lib/Link/LinkBase.js +5 -2
  15. package/lib/List/List.js +12 -7
  16. package/lib/List/ListItem.js +4 -5
  17. package/lib/Modal/Modal.js +2 -1
  18. package/lib/Pagination/PageButton.js +2 -2
  19. package/lib/Pagination/Pagination.js +5 -3
  20. package/lib/Pagination/usePagination.js +2 -2
  21. package/lib/Progress/ProgressBar.js +3 -3
  22. package/lib/Progress/ProgressBarBackground.js +3 -3
  23. package/lib/Radio/Radio.js +2 -2
  24. package/lib/Radio/RadioGroup.js +2 -2
  25. package/lib/RadioCard/RadioCard.js +1 -1
  26. package/lib/RadioCard/RadioCardGroup.js +2 -2
  27. package/lib/Search/Search.js +1 -1
  28. package/lib/SideNav/SideNav.js +2 -2
  29. package/lib/Skeleton/Skeleton.js +1 -1
  30. package/lib/Skeleton/skeletonWebAnimation.js +1 -1
  31. package/lib/StackView/StackWrap.js +3 -1
  32. package/lib/StackView/getStackedContent.js +2 -2
  33. package/lib/Tabs/Tabs.js +28 -3
  34. package/lib/Tabs/TabsItem.js +5 -6
  35. package/lib/Tags/Tags.js +1 -1
  36. package/lib/ThemeProvider/utils/styles.js +2 -2
  37. package/lib/ThemeProvider/utils/theme-tokens.js +7 -9
  38. package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
  39. package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
  40. package/lib/Tooltip/Backdrop.js +2 -10
  41. package/lib/utils/animation/useVerticalExpandAnimation.js +40 -14
  42. package/lib/utils/children.js +2 -2
  43. package/lib/utils/input.js +6 -12
  44. package/lib/utils/props/componentPropType.js +3 -3
  45. package/lib/utils/props/selectSystemProps.js +2 -2
  46. package/lib/utils/props/tokens.js +2 -2
  47. package/lib/utils/useSpacingScale.js +3 -1
  48. package/lib/utils/useUniqueId.js +1 -1
  49. package/lib-module/A11yInfoProvider/index.js +63 -0
  50. package/lib-module/A11yText/index.js +56 -0
  51. package/lib-module/ActivityIndicator/Spinner.js +77 -0
  52. package/lib-module/ActivityIndicator/Spinner.native.js +144 -0
  53. package/lib-module/ActivityIndicator/index.js +41 -0
  54. package/lib-module/ActivityIndicator/shared.js +12 -0
  55. package/lib-module/BaseProvider/index.js +29 -0
  56. package/lib-module/Box/Box.js +244 -0
  57. package/lib-module/Box/index.js +2 -0
  58. package/lib-module/Button/Button.js +26 -0
  59. package/lib-module/Button/ButtonBase.js +271 -0
  60. package/lib-module/Button/ButtonGroup.js +247 -0
  61. package/lib-module/Button/ButtonLink.js +40 -0
  62. package/lib-module/Button/index.js +4 -0
  63. package/lib-module/Button/propTypes.js +36 -0
  64. package/lib-module/Card/Card.js +84 -0
  65. package/lib-module/Card/CardBase.js +66 -0
  66. package/lib-module/Card/PressableCardBase.js +114 -0
  67. package/lib-module/Card/index.js +4 -0
  68. package/lib-module/Checkbox/Checkbox.js +348 -0
  69. package/lib-module/Checkbox/CheckboxGroup.js +233 -0
  70. package/lib-module/Checkbox/CheckboxInput.js +60 -0
  71. package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
  72. package/lib-module/Checkbox/index.js +3 -0
  73. package/lib-module/Divider/Divider.js +124 -0
  74. package/lib-module/Divider/index.js +2 -0
  75. package/lib-module/ExpandCollapse/Accordion.js +15 -0
  76. package/lib-module/ExpandCollapse/Control.js +136 -0
  77. package/lib-module/ExpandCollapse/ExpandCollapse.js +95 -0
  78. package/lib-module/ExpandCollapse/Panel.js +151 -0
  79. package/lib-module/ExpandCollapse/index.js +7 -0
  80. package/lib-module/Feedback/Feedback.js +157 -0
  81. package/lib-module/Feedback/index.js +2 -0
  82. package/lib-module/Fieldset/Fieldset.js +153 -0
  83. package/lib-module/Fieldset/FieldsetContainer.js +32 -0
  84. package/lib-module/Fieldset/FieldsetContainer.native.js +23 -0
  85. package/lib-module/Fieldset/Legend.js +24 -0
  86. package/lib-module/Fieldset/Legend.native.js +31 -0
  87. package/lib-module/Fieldset/cssReset.js +14 -0
  88. package/lib-module/Fieldset/index.js +2 -0
  89. package/lib-module/FlexGrid/Col/Col.js +276 -0
  90. package/lib-module/FlexGrid/Col/index.js +2 -0
  91. package/lib-module/FlexGrid/FlexGrid.js +148 -0
  92. package/lib-module/FlexGrid/Row/Row.js +184 -0
  93. package/lib-module/FlexGrid/Row/index.js +2 -0
  94. package/lib-module/FlexGrid/helpers/index.js +18 -0
  95. package/lib-module/FlexGrid/index.js +2 -0
  96. package/lib-module/FlexGrid/providers/GutterContext.js +3 -0
  97. package/lib-module/HorizontalScroll/HorizontalScroll.js +175 -0
  98. package/lib-module/HorizontalScroll/HorizontalScrollButton.js +81 -0
  99. package/lib-module/HorizontalScroll/ScrollViewEnd.js +48 -0
  100. package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +27 -0
  101. package/lib-module/HorizontalScroll/dictionary.js +11 -0
  102. package/lib-module/HorizontalScroll/index.js +11 -0
  103. package/lib-module/HorizontalScroll/itemPositions.js +112 -0
  104. package/lib-module/Icon/Icon.js +62 -0
  105. package/lib-module/Icon/IconText.js +83 -0
  106. package/lib-module/Icon/index.js +4 -0
  107. package/lib-module/IconButton/IconButton.js +122 -0
  108. package/lib-module/IconButton/index.js +2 -0
  109. package/lib-module/InputLabel/InputLabel.js +148 -0
  110. package/lib-module/InputLabel/LabelContent.js +27 -0
  111. package/lib-module/InputLabel/LabelContent.native.js +19 -0
  112. package/lib-module/InputLabel/index.js +2 -0
  113. package/lib-module/InputSupports/InputSupports.js +96 -0
  114. package/lib-module/InputSupports/index.js +2 -0
  115. package/lib-module/InputSupports/useInputSupports.js +32 -0
  116. package/lib-module/Link/ChevronLink.js +52 -0
  117. package/lib-module/Link/InlinePressable.js +44 -0
  118. package/lib-module/Link/InlinePressable.native.js +89 -0
  119. package/lib-module/Link/Link.js +28 -0
  120. package/lib-module/Link/LinkBase.js +243 -0
  121. package/lib-module/Link/TextButton.js +35 -0
  122. package/lib-module/Link/index.js +5 -0
  123. package/lib-module/List/List.js +62 -0
  124. package/lib-module/List/ListItem.js +248 -0
  125. package/lib-module/List/index.js +5 -0
  126. package/lib-module/Modal/Modal.js +222 -0
  127. package/lib-module/Modal/dictionary.js +9 -0
  128. package/lib-module/Modal/index.js +2 -0
  129. package/lib-module/Notification/Notification.js +209 -0
  130. package/lib-module/Notification/dictionary.js +8 -0
  131. package/lib-module/Notification/index.js +2 -0
  132. package/lib-module/Pagination/PageButton.js +66 -0
  133. package/lib-module/Pagination/Pagination.js +153 -0
  134. package/lib-module/Pagination/SideButton.js +106 -0
  135. package/lib-module/Pagination/dictionary.js +18 -0
  136. package/lib-module/Pagination/index.js +2 -0
  137. package/lib-module/Pagination/usePagination.js +73 -0
  138. package/lib-module/Progress/Progress.js +89 -0
  139. package/lib-module/Progress/ProgressBar.js +138 -0
  140. package/lib-module/Progress/ProgressBarBackground.js +42 -0
  141. package/lib-module/Progress/index.js +4 -0
  142. package/lib-module/Radio/Radio.js +285 -0
  143. package/lib-module/Radio/RadioButton.js +138 -0
  144. package/lib-module/Radio/RadioGroup.js +243 -0
  145. package/lib-module/Radio/RadioInput.js +62 -0
  146. package/lib-module/Radio/RadioInput.native.js +6 -0
  147. package/lib-module/Radio/index.js +3 -0
  148. package/lib-module/RadioCard/RadioCard.js +219 -0
  149. package/lib-module/RadioCard/RadioCardGroup.js +250 -0
  150. package/lib-module/RadioCard/index.js +3 -0
  151. package/lib-module/Search/Search.js +261 -0
  152. package/lib-module/Search/dictionary.js +12 -0
  153. package/lib-module/Search/index.js +2 -0
  154. package/lib-module/Select/Group.js +21 -0
  155. package/lib-module/Select/Group.native.js +15 -0
  156. package/lib-module/Select/Item.js +20 -0
  157. package/lib-module/Select/Item.native.js +3 -0
  158. package/lib-module/Select/Picker.js +68 -0
  159. package/lib-module/Select/Picker.native.js +120 -0
  160. package/lib-module/Select/Select.js +337 -0
  161. package/lib-module/Select/index.js +6 -0
  162. package/lib-module/SideNav/Item.js +145 -0
  163. package/lib-module/SideNav/ItemContent.js +48 -0
  164. package/lib-module/SideNav/ItemsGroup.js +117 -0
  165. package/lib-module/SideNav/SideNav.js +136 -0
  166. package/lib-module/SideNav/index.js +1 -0
  167. package/lib-module/Skeleton/Skeleton.js +179 -0
  168. package/lib-module/Skeleton/index.js +2 -0
  169. package/lib-module/Skeleton/skeleton.constant.js +3 -0
  170. package/lib-module/Skeleton/skeletonWebAnimation.js +18 -0
  171. package/lib-module/Skeleton/useSkeletonNativeAnimation.js +24 -0
  172. package/lib-module/Spacer/Spacer.js +98 -0
  173. package/lib-module/Spacer/index.js +2 -0
  174. package/lib-module/StackView/StackView.js +125 -0
  175. package/lib-module/StackView/StackWrap.js +50 -0
  176. package/lib-module/StackView/StackWrap.native.js +3 -0
  177. package/lib-module/StackView/StackWrapBox.js +115 -0
  178. package/lib-module/StackView/StackWrapGap.js +59 -0
  179. package/lib-module/StackView/common.js +35 -0
  180. package/lib-module/StackView/getStackedContent.js +124 -0
  181. package/lib-module/StackView/index.js +5 -0
  182. package/lib-module/StepTracker/Step.js +248 -0
  183. package/lib-module/StepTracker/StepTracker.js +185 -0
  184. package/lib-module/StepTracker/dictionary.js +10 -0
  185. package/lib-module/StepTracker/index.js +2 -0
  186. package/lib-module/Tabs/Tabs.js +143 -0
  187. package/lib-module/Tabs/TabsItem.js +224 -0
  188. package/lib-module/Tabs/index.js +2 -0
  189. package/lib-module/Tags/Tags.js +251 -0
  190. package/lib-module/Tags/index.js +2 -0
  191. package/lib-module/TextInput/TextArea.js +94 -0
  192. package/lib-module/TextInput/TextInput.js +72 -0
  193. package/lib-module/TextInput/TextInputBase.js +245 -0
  194. package/lib-module/TextInput/index.js +3 -0
  195. package/lib-module/TextInput/propTypes.js +37 -0
  196. package/lib-module/ThemeProvider/ThemeProvider.js +36 -0
  197. package/lib-module/ThemeProvider/index.js +6 -0
  198. package/lib-module/ThemeProvider/useSetTheme.js +25 -0
  199. package/lib-module/ThemeProvider/useTheme.js +14 -0
  200. package/lib-module/ThemeProvider/useThemeTokens.js +110 -0
  201. package/lib-module/ThemeProvider/utils/index.js +2 -0
  202. package/lib-module/ThemeProvider/utils/styles.js +181 -0
  203. package/lib-module/ThemeProvider/utils/theme-tokens.js +163 -0
  204. package/lib-module/ToggleSwitch/ToggleSwitch.js +250 -0
  205. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +220 -0
  206. package/lib-module/ToggleSwitch/index.js +3 -0
  207. package/lib-module/Tooltip/Backdrop.js +45 -0
  208. package/lib-module/Tooltip/Backdrop.native.js +44 -0
  209. package/lib-module/Tooltip/Tooltip.js +348 -0
  210. package/lib-module/Tooltip/dictionary.js +8 -0
  211. package/lib-module/Tooltip/getTooltipPosition.js +175 -0
  212. package/lib-module/Tooltip/index.js +2 -0
  213. package/lib-module/TooltipButton/TooltipButton.js +78 -0
  214. package/lib-module/TooltipButton/index.js +2 -0
  215. package/lib-module/Typography/Typography.js +124 -0
  216. package/lib-module/Typography/index.js +2 -0
  217. package/lib-module/ViewportProvider/ViewportProvider.js +29 -0
  218. package/lib-module/ViewportProvider/index.js +3 -0
  219. package/lib-module/ViewportProvider/useViewport.js +3 -0
  220. package/lib-module/ViewportProvider/useViewportListener.js +46 -0
  221. package/lib-module/index.js +48 -0
  222. package/lib-module/utils/a11y/index.js +2 -0
  223. package/lib-module/utils/a11y/semantics.js +157 -0
  224. package/lib-module/utils/a11y/textSize.js +36 -0
  225. package/lib-module/utils/animation/index.js +2 -0
  226. package/lib-module/utils/animation/useVerticalExpandAnimation.js +88 -0
  227. package/lib-module/utils/children.js +119 -0
  228. package/lib-module/utils/containUniqueFields.js +26 -0
  229. package/lib-module/utils/index.js +16 -0
  230. package/lib-module/utils/info/index.js +7 -0
  231. package/lib-module/utils/info/platform/index.js +11 -0
  232. package/lib-module/utils/info/platform/platform.android.js +1 -0
  233. package/lib-module/utils/info/platform/platform.ios.js +1 -0
  234. package/lib-module/utils/info/platform/platform.js +1 -0
  235. package/lib-module/utils/info/platform/platform.native.js +4 -0
  236. package/lib-module/utils/info/versions.js +5 -0
  237. package/lib-module/utils/input.js +179 -0
  238. package/lib-module/utils/pressability.js +111 -0
  239. package/lib-module/utils/props/a11yProps.js +140 -0
  240. package/lib-module/utils/props/clickProps.js +26 -0
  241. package/lib-module/utils/props/componentPropType.js +63 -0
  242. package/lib-module/utils/props/copyPropTypes.js +2 -0
  243. package/lib-module/utils/props/getPropSelector.js +9 -0
  244. package/lib-module/utils/props/handlerProps.js +65 -0
  245. package/lib-module/utils/props/hrefAttrsProp.js +33 -0
  246. package/lib-module/utils/props/index.js +19 -0
  247. package/lib-module/utils/props/inputSupportsProps.js +62 -0
  248. package/lib-module/utils/props/linkProps.js +44 -0
  249. package/lib-module/utils/props/paddingProp.js +9 -0
  250. package/lib-module/utils/props/pressProps.js +42 -0
  251. package/lib-module/utils/props/rectProp.js +9 -0
  252. package/lib-module/utils/props/responsiveProps.js +30 -0
  253. package/lib-module/utils/props/selectSystemProps.js +24 -0
  254. package/lib-module/utils/props/spacingProps.js +56 -0
  255. package/lib-module/utils/props/textInputProps.js +194 -0
  256. package/lib-module/utils/props/textProps.js +59 -0
  257. package/lib-module/utils/props/tokens.js +133 -0
  258. package/lib-module/utils/props/variantProp.js +18 -0
  259. package/lib-module/utils/props/viewProps.js +22 -0
  260. package/lib-module/utils/ssr.js +38 -0
  261. package/lib-module/utils/useCopy.js +44 -0
  262. package/lib-module/utils/useHash.js +45 -0
  263. package/lib-module/utils/useHash.native.js +7 -0
  264. package/lib-module/utils/useResponsiveProp.js +47 -0
  265. package/lib-module/utils/useSpacingScale.js +125 -0
  266. package/lib-module/utils/useUniqueId.js +13 -0
  267. package/lib-module/utils/withLinkRouter.js +83 -0
  268. package/package.json +3 -2
  269. package/src/Checkbox/Checkbox.jsx +3 -1
  270. package/src/ExpandCollapse/Panel.jsx +2 -19
  271. package/src/Link/InlinePressable.jsx +5 -2
  272. package/src/Link/LinkBase.jsx +4 -1
  273. package/src/List/List.jsx +34 -19
  274. package/src/List/ListItem.jsx +12 -2
  275. package/src/Modal/Modal.jsx +2 -1
  276. package/src/Tabs/Tabs.jsx +24 -2
  277. package/src/Tabs/TabsItem.jsx +6 -5
  278. package/src/utils/animation/useVerticalExpandAnimation.js +47 -13
@@ -0,0 +1,115 @@
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((_ref, ref) => {
37
+ let {
38
+ space = 1,
39
+ gap = space,
40
+ direction: directionProp = 'row',
41
+ children,
42
+ tokens,
43
+ variant,
44
+ tag,
45
+ accessibilityRole,
46
+ ...rest
47
+ } = _ref;
48
+ const viewport = useViewport();
49
+ const direction = useResponsiveProp(directionProp, 'row');
50
+ const themeTokens = useThemeTokens('StackView', tokens, variant, {
51
+ viewport
52
+ });
53
+ const flexStyles = selectFlexStyles(themeTokens);
54
+ const selectedProps = selectProps({ ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
55
+ ...rest
56
+ }); // Mimic CSS `gap` using box spacing on the side after a wrapped row then offsetting it on the last row.
57
+
58
+ const gapSize = useSpacingScale(gap);
59
+ const offsetStyle = {
60
+ [offsetSides[direction]]: -1 * gapSize
61
+ };
62
+ const boxProps = {
63
+ [gapSides[direction]]: gap,
64
+ [spaceSides[direction]]: space
65
+ };
66
+ const content = getStackedContent(children, {
67
+ direction,
68
+ space: 0,
69
+ box: boxProps
70
+ });
71
+ return /*#__PURE__*/_jsx(View, {
72
+ ref: ref,
73
+ ...selectedProps,
74
+ style: [flexStyles, staticStyles.wrap, staticStyles[direction], offsetStyle],
75
+ children: content
76
+ });
77
+ });
78
+ StackWrapBox.displayName = 'StackWrapBox';
79
+ StackWrapBox.propTypes = { ...selectedSystemPropTypes,
80
+ tokens: getTokensPropType('StackView'),
81
+
82
+ /**
83
+ * Sets the `flexDirection` of the container
84
+ */
85
+ direction: responsiveProps.getTypeOptionallyByViewport(PropTypes.oneOf(['column', 'row', 'row-reverse', 'column-reverse'])),
86
+
87
+ /**
88
+ * The size of the space between items according to the theme's spacing scale.
89
+ * Either a number corresponding to a position on the theme's spacing scale (1 is smallest, 2 is second smallest, etc),
90
+ * or, a SpacingObject with viewport keys and options (see `useSpacingScale` for details).
91
+ */
92
+ space: spacingProps.types.spacingValue,
93
+
94
+ /**
95
+ * The size of the space between lines of content, according to the theme's spacing scale. By default, matches `space`.
96
+ * Either a number corresponding to a position on the theme's spacing scale (1 is smallest, 2 is second smallest, etc),
97
+ * or, a SpacingObject with viewport keys and options (see `useSpacingScale` for details).
98
+ */
99
+ gap: spacingProps.types.spacingValue,
100
+
101
+ /**
102
+ * Optional semantic HTML tag, to apply to the container on web. Does not change styling.
103
+ *
104
+ * In native apps, if a header tag is provided ("h1", "h2" etc) and accessibilityRole prop
105
+ * is not defined, the accessibilityRole will default to "heading".
106
+ */
107
+ tag: PropTypes.oneOf(layoutTags),
108
+
109
+ /**
110
+ * A StackWrap may take any children, but will have no effect if it is only passed one child or is passed children
111
+ * wrapped in a component. If necessary, children may be wrapped in one React Fragment.
112
+ */
113
+ children: PropTypes.node
114
+ };
115
+ export default StackWrapBox;
@@ -0,0 +1,59 @@
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((_ref, ref) => {
23
+ let {
24
+ space = 1,
25
+ tokens,
26
+ variant,
27
+ direction: directionProp = 'row',
28
+ children,
29
+ tag,
30
+ accessibilityRole,
31
+ ...rest
32
+ } = _ref;
33
+ const viewport = useViewport();
34
+ const direction = useResponsiveProp(directionProp, 'row');
35
+ const themeTokens = useThemeTokens('StackView', tokens, variant, {
36
+ viewport
37
+ });
38
+ const flexStyles = selectFlexStyles(themeTokens);
39
+ const selectedProps = selectProps({ ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
40
+ ...rest
41
+ });
42
+ const size = useSpacingScale(space);
43
+ const gapStyle = {
44
+ gap: size
45
+ };
46
+ const content = getStackedContent(children, {
47
+ direction,
48
+ space: 0
49
+ });
50
+ return /*#__PURE__*/_jsx(View, {
51
+ ref: ref,
52
+ ...selectedProps,
53
+ style: [flexStyles, staticStyles.wrap, staticStyles[direction], gapStyle],
54
+ children: content
55
+ });
56
+ });
57
+ StackWrapGap.displayName = 'StackWrapGap';
58
+ StackWrapGap.propTypes = StackWrapBox.propTypes;
59
+ export default StackWrapGap;
@@ -0,0 +1,35 @@
1
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
2
+ export const selectFlexStyles = _ref => {
3
+ let {
4
+ alignItems,
5
+ justifyContent,
6
+ flexGrow,
7
+ flexShrink
8
+ } = _ref;
9
+ return {
10
+ alignItems,
11
+ justifyContent,
12
+ flexGrow,
13
+ flexShrink
14
+ };
15
+ };
16
+ export const staticStyles = StyleSheet.create({
17
+ wrap: {
18
+ flexShrink: 1,
19
+ flexWrap: 'wrap'
20
+ },
21
+ row: {
22
+ flexDirection: 'row'
23
+ },
24
+ 'row-reverse': {
25
+ flexDirection: 'row-reverse'
26
+ },
27
+ column: {
28
+ // This is the React Native View default, but also it's very fundamental to the behaviour,
29
+ // so make it explicit and allow it to be tested for.
30
+ flexDirection: 'column'
31
+ },
32
+ 'column-reverse': {
33
+ flexDirection: 'column-reverse'
34
+ }
35
+ });
@@ -0,0 +1,124 @@
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, _ref) => {
36
+ let {
37
+ divider,
38
+ space,
39
+ direction = 'column',
40
+ box,
41
+ preserveFragments = false
42
+ } = _ref;
43
+ const boxProps = box && typeof box === 'object' ? box : {
44
+ space
45
+ };
46
+ const dividerProps = divider && typeof divider === 'object' ? divider : {}; // Avoid surprises if children contains comments, nulls, or is a variable wrapped as a fragment
47
+
48
+ const topLevelChildren = preserveFragments ? children : unpackFragment(children);
49
+ const validChildren = Children.toArray(topLevelChildren).filter(Boolean);
50
+ const content = validChildren.reduce((newChildren, child, index) => {
51
+ const boxID = "Stack-Box-".concat(index);
52
+ const item = box ?
53
+ /*#__PURE__*/
54
+ // If wrapped in Box, that Box needs a key.
55
+ // If possible, use an existing content key; use an index-based key only if necessary.
56
+ _createElement(Box, { ...boxProps,
57
+ key: child.key || boxID,
58
+ testID: boxID
59
+ }, child) : child;
60
+ if (!index || !space && !divider) return [...newChildren, item];
61
+ const testID = "Stack-".concat(divider ? 'Divider' : 'Spacer', "-").concat(index);
62
+ const commonProps = {
63
+ testID,
64
+ key: testID,
65
+ space
66
+ };
67
+ const separator = divider ? /*#__PURE__*/_jsx(Divider, {
68
+ vertical: direction.startsWith('row'),
69
+ ...dividerProps,
70
+ ...commonProps
71
+ }) : /*#__PURE__*/_jsx(Spacer, {
72
+ direction: direction.startsWith('row') ? 'row' : 'column',
73
+ ...commonProps
74
+ });
75
+ return [...newChildren, separator, item];
76
+ }, []);
77
+ return content;
78
+ };
79
+ /**
80
+ * Unpacks top-level fragments, so that common compositional patterns such as the following examples
81
+ * can be iterated as flat siblings (as if they were `<Child1 /><Child2 /><Child3 />`):
82
+ *
83
+ * - Setting `children` as a property wrapped in a fragment:
84
+ *
85
+ * ```jsx
86
+ * args.children = <><Child1 /><Child2 /><Child3 /></>
87
+ * ```
88
+ *
89
+ * - Defining `children` as a variable wrapped in a fragment:
90
+ *
91
+ * ```jsx
92
+ * const content = <><Child1 /><Child2 /><Child3 /></>
93
+ * if (someCondition) return <SomeWrapper>{content}</SomeWrapper>
94
+ * ```
95
+ *
96
+ * - Using fragments at the top level of a JSX block for conditional rendering:
97
+ *
98
+ * ```jsx
99
+ * <Child1 />
100
+ * {someCondition && (
101
+ * <>
102
+ * <Child2 />
103
+ * <Child3 />
104
+ * </>
105
+ * )}
106
+ * ```
107
+ *
108
+ * @param {ReactChildren} child
109
+ * @returns {ReactChildren}
110
+ */
111
+
112
+
113
+ const unpackFragment = child => {
114
+ var _child$props;
115
+
116
+ // If this level is a set of top-level siblings rather than one child, check each in turn
117
+ 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
118
+
119
+ 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
120
+
121
+ return child;
122
+ };
123
+
124
+ 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,248 @@
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 = _ref => {
15
+ let {
16
+ completedIconColor,
17
+ completedIconSize
18
+ } = _ref;
19
+ return {
20
+ size: completedIconSize,
21
+ color: completedIconColor
22
+ };
23
+ };
24
+
25
+ const selectConnectorStyles = (_ref2, isCompleted) => {
26
+ let {
27
+ connectorColor,
28
+ connectorHeight,
29
+ connectorMinWidth,
30
+ connectorCompletedHeight,
31
+ connectorCompletedColor
32
+ } = _ref2;
33
+ return {
34
+ backgroundColor: connectorColor,
35
+ height: connectorHeight,
36
+ minWidth: connectorMinWidth,
37
+ ...(isCompleted && {
38
+ height: connectorCompletedHeight,
39
+ backgroundColor: connectorCompletedColor
40
+ })
41
+ };
42
+ };
43
+
44
+ const selectCurrentInnerStyles = _ref3 => {
45
+ let {
46
+ knobCurrentInnerColor,
47
+ knobCurrentInnerSize
48
+ } = _ref3;
49
+ return {
50
+ backgroundColor: knobCurrentInnerColor,
51
+ borderRadius: knobCurrentInnerSize / 2,
52
+ height: knobCurrentInnerSize,
53
+ width: knobCurrentInnerSize
54
+ };
55
+ };
56
+
57
+ const selectKnobStyles = (_ref4, isCompleted, isCurrent) => {
58
+ let {
59
+ knobBackgroundColor,
60
+ knobBorderColor,
61
+ knobBorderWidth,
62
+ knobCompletedBackgroundColor,
63
+ knobCompletedBorderColor,
64
+ knobCompletedPaddingLeft,
65
+ knobCompletedPaddingTop,
66
+ knobCurrentBackgroundColor,
67
+ knobCurrentBorderColor,
68
+ knobCurrentBorderWidth,
69
+ knobCurrentPaddingLeft,
70
+ knobCurrentPaddingTop,
71
+ knobSize
72
+ } = _ref4;
73
+ return {
74
+ backgroundColor: knobBackgroundColor,
75
+ borderColor: knobBorderColor,
76
+ borderRadius: knobSize / 2,
77
+ borderWidth: knobBorderWidth,
78
+ height: knobSize,
79
+ width: knobSize,
80
+ ...(isCompleted && {
81
+ backgroundColor: knobCompletedBackgroundColor,
82
+ borderColor: knobCompletedBorderColor,
83
+ paddingLeft: knobCompletedPaddingLeft,
84
+ paddingTop: knobCompletedPaddingTop
85
+ }),
86
+ ...(isCurrent && {
87
+ backgroundColor: knobCurrentBackgroundColor,
88
+ borderColor: knobCurrentBorderColor,
89
+ borderWidth: knobCurrentBorderWidth,
90
+ paddingLeft: knobCurrentPaddingLeft,
91
+ paddingTop: knobCurrentPaddingTop
92
+ })
93
+ };
94
+ };
95
+
96
+ const selectLabelContainerStyles = _ref5 => {
97
+ let {
98
+ labelDirection,
99
+ labelGap,
100
+ labelMarginTop,
101
+ labelPaddingLeft,
102
+ labelPaddingRight
103
+ } = _ref5;
104
+ return {
105
+ marginTop: labelMarginTop,
106
+ paddingLeft: labelPaddingLeft,
107
+ paddingRight: labelPaddingRight,
108
+ flexDirection: labelDirection,
109
+ gap: labelGap
110
+ };
111
+ };
112
+
113
+ const selectLabelStyles = (_ref6, isCurrent) => {
114
+ let {
115
+ labelColor,
116
+ labelCurrentColor,
117
+ labelCurrentFontWeight,
118
+ labelFontSize,
119
+ labelFontWeight,
120
+ labelFontName,
121
+ labelLineHeight
122
+ } = _ref6;
123
+ return applyTextStyles({
124
+ color: isCurrent ? labelCurrentColor : labelColor,
125
+ fontSize: labelFontSize,
126
+ lineHeight: labelLineHeight,
127
+ fontWeight: isCurrent ? labelCurrentFontWeight : labelFontWeight,
128
+ fontName: labelFontName
129
+ });
130
+ };
131
+
132
+ const getStepTestID = (isCompleted, isCurrent) => {
133
+ let testID = 'StepTracker-Step';
134
+
135
+ if (isCompleted) {
136
+ testID += '-Completed';
137
+ } else if (isCurrent) {
138
+ testID += '-Current';
139
+ }
140
+
141
+ return testID;
142
+ };
143
+ /**
144
+ * A single step of a StepTracker.
145
+ */
146
+
147
+
148
+ const Step = _ref7 => {
149
+ let {
150
+ label,
151
+ name,
152
+ status = 0,
153
+ stepCount = 0,
154
+ stepIndex = 0,
155
+ tokens,
156
+ ...rest
157
+ } = _ref7;
158
+ const {
159
+ completedIcon,
160
+ showStepLabel,
161
+ showStepName,
162
+ ...themeTokens
163
+ } = tokens;
164
+ const isFirst = stepIndex === 0;
165
+ const isLast = stepIndex === stepCount - 1;
166
+ const isCompleted = status > stepIndex;
167
+ const isCurrent = status === stepIndex;
168
+ const isActive = isCompleted || isCurrent;
169
+ return /*#__PURE__*/_jsxs(StackView, {
170
+ space: 0,
171
+ tokens: {
172
+ alignItems: 'stretch',
173
+ flexGrow: 1
174
+ },
175
+ accessibilityLabel: label,
176
+ accessibilityLevel: 2,
177
+ accessibilityCurrent: status === stepIndex,
178
+ ...selectProps(rest),
179
+ children: [/*#__PURE__*/_jsxs(StackView, {
180
+ direction: "row",
181
+ space: 0,
182
+ tokens: {
183
+ alignItems: 'center',
184
+ flexGrow: 0
185
+ },
186
+ children: [/*#__PURE__*/_jsx(View, {
187
+ style: [staticStyles.connector, !isFirst && selectConnectorStyles(themeTokens, isActive)]
188
+ }), /*#__PURE__*/_jsxs(View, {
189
+ style: [staticStyles.knob, selectKnobStyles(themeTokens, isCompleted, isCurrent)],
190
+ testID: getStepTestID(isCompleted, isCurrent),
191
+ children: [isCompleted && completedIcon && /*#__PURE__*/_jsx(Icon, {
192
+ icon: completedIcon,
193
+ tokens: selectCompletedIconTokens(themeTokens)
194
+ }), isCurrent && /*#__PURE__*/_jsx(View, {
195
+ style: selectCurrentInnerStyles(themeTokens)
196
+ })]
197
+ }), /*#__PURE__*/_jsx(View, {
198
+ style: [staticStyles.connector, !isLast && selectConnectorStyles(themeTokens, isCompleted)]
199
+ })]
200
+ }), showStepLabel && /*#__PURE__*/_jsxs(View, {
201
+ style: [staticStyles.stepLabelContainer, selectLabelContainerStyles(tokens)],
202
+ children: [showStepName && /*#__PURE__*/_jsx(Text, {
203
+ style: [staticStyles.centeredText, selectLabelStyles(tokens, isCurrent)],
204
+ children: name
205
+ }), /*#__PURE__*/_jsx(StackView, {
206
+ direction: "row",
207
+ children: /*#__PURE__*/_jsx(Text, {
208
+ style: [staticStyles.centeredText, tokens.labelDirection === 'column' && staticStyles.wrappingLabel, selectLabelStyles(tokens, isCurrent)],
209
+ children: label
210
+ })
211
+ })]
212
+ })]
213
+ });
214
+ };
215
+
216
+ Step.propTypes = { ...selectedSystemPropTypes,
217
+ label: PropTypes.string.isRequired,
218
+ name: PropTypes.string.isRequired,
219
+ status: PropTypes.number.isRequired,
220
+ stepCount: PropTypes.number.isRequired,
221
+ stepIndex: PropTypes.number.isRequired,
222
+ tokens: getTokensPropType('StepTracker'),
223
+ variant: variantProp.propType
224
+ };
225
+ export default Step;
226
+ const staticStyles = StyleSheet.create({
227
+ centeredText: {
228
+ textAlign: 'center'
229
+ },
230
+ connector: {
231
+ flex: 1,
232
+ height: 1
233
+ },
234
+ completedKnob: {
235
+ backgroundColor: 'transparent',
236
+ textAlign: 'center'
237
+ },
238
+ knob: {
239
+ borderWidth: 1
240
+ },
241
+ stepLabelContainer: {
242
+ justifyContent: 'center'
243
+ },
244
+ wrappingLabel: {
245
+ width: 0,
246
+ flex: 1
247
+ }
248
+ });