@telus-uds/components-base 1.8.3 → 1.9.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 (284) hide show
  1. package/CHANGELOG.md +37 -2
  2. package/component-docs.json +17 -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/Card/Card.js +9 -4
  8. package/lib/Checkbox/Checkbox.js +5 -3
  9. package/lib/Checkbox/CheckboxGroup.js +2 -2
  10. package/lib/Divider/Divider.js +2 -2
  11. package/lib/ExpandCollapse/Panel.js +12 -18
  12. package/lib/FlexGrid/Col/Col.js +1 -1
  13. package/lib/Icon/Icon.js +1 -1
  14. package/lib/Link/InlinePressable.js +5 -1
  15. package/lib/Link/LinkBase.js +5 -2
  16. package/lib/List/List.js +8 -2
  17. package/lib/Pagination/PageButton.js +2 -2
  18. package/lib/Pagination/Pagination.js +5 -3
  19. package/lib/Pagination/usePagination.js +2 -2
  20. package/lib/Progress/ProgressBar.js +3 -3
  21. package/lib/Progress/ProgressBarBackground.js +3 -3
  22. package/lib/Radio/Radio.js +2 -2
  23. package/lib/Radio/RadioGroup.js +2 -2
  24. package/lib/RadioCard/RadioCard.js +1 -1
  25. package/lib/RadioCard/RadioCardGroup.js +2 -2
  26. package/lib/Search/Search.js +1 -1
  27. package/lib/SideNav/SideNav.js +2 -2
  28. package/lib/Skeleton/Skeleton.js +1 -1
  29. package/lib/Skeleton/skeletonWebAnimation.js +1 -1
  30. package/lib/StackView/StackWrap.js +3 -1
  31. package/lib/StackView/getStackedContent.js +2 -2
  32. package/lib/Tabs/Tabs.js +28 -3
  33. package/lib/Tabs/TabsItem.js +5 -6
  34. package/lib/Tags/Tags.js +1 -1
  35. package/lib/TextInput/TextInput.js +0 -11
  36. package/lib/TextInput/TextInputBase.js +9 -0
  37. package/lib/TextInput/propTypes.js +3 -8
  38. package/lib/ThemeProvider/utils/styles.js +2 -2
  39. package/lib/ThemeProvider/utils/theme-tokens.js +7 -9
  40. package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
  41. package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
  42. package/lib/Tooltip/Backdrop.js +2 -10
  43. package/lib/utils/animation/useVerticalExpandAnimation.js +40 -14
  44. package/lib/utils/children.js +2 -2
  45. package/lib/utils/input.js +6 -12
  46. package/lib/utils/props/componentPropType.js +3 -3
  47. package/lib/utils/props/selectSystemProps.js +2 -2
  48. package/lib/utils/props/textInputProps.js +8 -1
  49. package/lib/utils/props/tokens.js +2 -2
  50. package/lib/utils/useSpacingScale.js +3 -1
  51. package/lib/utils/useUniqueId.js +1 -1
  52. package/lib-module/A11yInfoProvider/index.js +63 -0
  53. package/lib-module/A11yText/index.js +56 -0
  54. package/lib-module/ActivityIndicator/Spinner.js +77 -0
  55. package/lib-module/ActivityIndicator/Spinner.native.js +144 -0
  56. package/lib-module/ActivityIndicator/index.js +41 -0
  57. package/lib-module/ActivityIndicator/shared.js +12 -0
  58. package/lib-module/BaseProvider/index.js +29 -0
  59. package/lib-module/Box/Box.js +244 -0
  60. package/lib-module/Box/index.js +2 -0
  61. package/lib-module/Button/Button.js +26 -0
  62. package/lib-module/Button/ButtonBase.js +271 -0
  63. package/lib-module/Button/ButtonGroup.js +247 -0
  64. package/lib-module/Button/ButtonLink.js +40 -0
  65. package/lib-module/Button/index.js +4 -0
  66. package/lib-module/Button/propTypes.js +36 -0
  67. package/lib-module/Card/Card.js +85 -0
  68. package/lib-module/Card/CardBase.js +66 -0
  69. package/lib-module/Card/PressableCardBase.js +114 -0
  70. package/lib-module/Card/index.js +4 -0
  71. package/lib-module/Checkbox/Checkbox.js +348 -0
  72. package/lib-module/Checkbox/CheckboxGroup.js +233 -0
  73. package/lib-module/Checkbox/CheckboxInput.js +60 -0
  74. package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
  75. package/lib-module/Checkbox/index.js +3 -0
  76. package/lib-module/Divider/Divider.js +124 -0
  77. package/lib-module/Divider/index.js +2 -0
  78. package/lib-module/ExpandCollapse/Accordion.js +15 -0
  79. package/lib-module/ExpandCollapse/Control.js +136 -0
  80. package/lib-module/ExpandCollapse/ExpandCollapse.js +95 -0
  81. package/lib-module/ExpandCollapse/Panel.js +159 -0
  82. package/lib-module/ExpandCollapse/index.js +7 -0
  83. package/lib-module/Feedback/Feedback.js +157 -0
  84. package/lib-module/Feedback/index.js +2 -0
  85. package/lib-module/Fieldset/Fieldset.js +153 -0
  86. package/lib-module/Fieldset/FieldsetContainer.js +32 -0
  87. package/lib-module/Fieldset/FieldsetContainer.native.js +23 -0
  88. package/lib-module/Fieldset/Legend.js +24 -0
  89. package/lib-module/Fieldset/Legend.native.js +31 -0
  90. package/lib-module/Fieldset/cssReset.js +14 -0
  91. package/lib-module/Fieldset/index.js +2 -0
  92. package/lib-module/FlexGrid/Col/Col.js +276 -0
  93. package/lib-module/FlexGrid/Col/index.js +2 -0
  94. package/lib-module/FlexGrid/FlexGrid.js +148 -0
  95. package/lib-module/FlexGrid/Row/Row.js +184 -0
  96. package/lib-module/FlexGrid/Row/index.js +2 -0
  97. package/lib-module/FlexGrid/helpers/index.js +18 -0
  98. package/lib-module/FlexGrid/index.js +2 -0
  99. package/lib-module/FlexGrid/providers/GutterContext.js +3 -0
  100. package/lib-module/HorizontalScroll/HorizontalScroll.js +175 -0
  101. package/lib-module/HorizontalScroll/HorizontalScrollButton.js +81 -0
  102. package/lib-module/HorizontalScroll/ScrollViewEnd.js +48 -0
  103. package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +27 -0
  104. package/lib-module/HorizontalScroll/dictionary.js +11 -0
  105. package/lib-module/HorizontalScroll/index.js +11 -0
  106. package/lib-module/HorizontalScroll/itemPositions.js +112 -0
  107. package/lib-module/Icon/Icon.js +62 -0
  108. package/lib-module/Icon/IconText.js +83 -0
  109. package/lib-module/Icon/index.js +4 -0
  110. package/lib-module/IconButton/IconButton.js +122 -0
  111. package/lib-module/IconButton/index.js +2 -0
  112. package/lib-module/InputLabel/InputLabel.js +148 -0
  113. package/lib-module/InputLabel/LabelContent.js +27 -0
  114. package/lib-module/InputLabel/LabelContent.native.js +19 -0
  115. package/lib-module/InputLabel/index.js +2 -0
  116. package/lib-module/InputSupports/InputSupports.js +96 -0
  117. package/lib-module/InputSupports/index.js +2 -0
  118. package/lib-module/InputSupports/useInputSupports.js +32 -0
  119. package/lib-module/Link/ChevronLink.js +52 -0
  120. package/lib-module/Link/InlinePressable.js +44 -0
  121. package/lib-module/Link/InlinePressable.native.js +89 -0
  122. package/lib-module/Link/Link.js +28 -0
  123. package/lib-module/Link/LinkBase.js +243 -0
  124. package/lib-module/Link/TextButton.js +35 -0
  125. package/lib-module/Link/index.js +5 -0
  126. package/lib-module/List/List.js +62 -0
  127. package/lib-module/List/ListItem.js +248 -0
  128. package/lib-module/List/index.js +5 -0
  129. package/lib-module/Modal/Modal.js +222 -0
  130. package/lib-module/Modal/dictionary.js +9 -0
  131. package/lib-module/Modal/index.js +2 -0
  132. package/lib-module/Notification/Notification.js +209 -0
  133. package/lib-module/Notification/dictionary.js +8 -0
  134. package/lib-module/Notification/index.js +2 -0
  135. package/lib-module/Pagination/PageButton.js +66 -0
  136. package/lib-module/Pagination/Pagination.js +153 -0
  137. package/lib-module/Pagination/SideButton.js +106 -0
  138. package/lib-module/Pagination/dictionary.js +18 -0
  139. package/lib-module/Pagination/index.js +2 -0
  140. package/lib-module/Pagination/usePagination.js +73 -0
  141. package/lib-module/Progress/Progress.js +89 -0
  142. package/lib-module/Progress/ProgressBar.js +138 -0
  143. package/lib-module/Progress/ProgressBarBackground.js +42 -0
  144. package/lib-module/Progress/index.js +4 -0
  145. package/lib-module/Radio/Radio.js +285 -0
  146. package/lib-module/Radio/RadioButton.js +138 -0
  147. package/lib-module/Radio/RadioGroup.js +243 -0
  148. package/lib-module/Radio/RadioInput.js +62 -0
  149. package/lib-module/Radio/RadioInput.native.js +6 -0
  150. package/lib-module/Radio/index.js +3 -0
  151. package/lib-module/RadioCard/RadioCard.js +219 -0
  152. package/lib-module/RadioCard/RadioCardGroup.js +250 -0
  153. package/lib-module/RadioCard/index.js +3 -0
  154. package/lib-module/Search/Search.js +261 -0
  155. package/lib-module/Search/dictionary.js +12 -0
  156. package/lib-module/Search/index.js +2 -0
  157. package/lib-module/Select/Group.js +21 -0
  158. package/lib-module/Select/Group.native.js +15 -0
  159. package/lib-module/Select/Item.js +20 -0
  160. package/lib-module/Select/Item.native.js +3 -0
  161. package/lib-module/Select/Picker.js +68 -0
  162. package/lib-module/Select/Picker.native.js +120 -0
  163. package/lib-module/Select/Select.js +337 -0
  164. package/lib-module/Select/index.js +6 -0
  165. package/lib-module/SideNav/Item.js +145 -0
  166. package/lib-module/SideNav/ItemContent.js +48 -0
  167. package/lib-module/SideNav/ItemsGroup.js +117 -0
  168. package/lib-module/SideNav/SideNav.js +136 -0
  169. package/lib-module/SideNav/index.js +1 -0
  170. package/lib-module/Skeleton/Skeleton.js +179 -0
  171. package/lib-module/Skeleton/index.js +2 -0
  172. package/lib-module/Skeleton/skeleton.constant.js +3 -0
  173. package/lib-module/Skeleton/skeletonWebAnimation.js +18 -0
  174. package/lib-module/Skeleton/useSkeletonNativeAnimation.js +24 -0
  175. package/lib-module/Spacer/Spacer.js +98 -0
  176. package/lib-module/Spacer/index.js +2 -0
  177. package/lib-module/StackView/StackView.js +125 -0
  178. package/lib-module/StackView/StackWrap.js +50 -0
  179. package/lib-module/StackView/StackWrap.native.js +3 -0
  180. package/lib-module/StackView/StackWrapBox.js +115 -0
  181. package/lib-module/StackView/StackWrapGap.js +59 -0
  182. package/lib-module/StackView/common.js +35 -0
  183. package/lib-module/StackView/getStackedContent.js +124 -0
  184. package/lib-module/StackView/index.js +5 -0
  185. package/lib-module/StepTracker/Step.js +248 -0
  186. package/lib-module/StepTracker/StepTracker.js +185 -0
  187. package/lib-module/StepTracker/dictionary.js +10 -0
  188. package/lib-module/StepTracker/index.js +2 -0
  189. package/lib-module/Tabs/Tabs.js +143 -0
  190. package/lib-module/Tabs/TabsItem.js +224 -0
  191. package/lib-module/Tabs/index.js +2 -0
  192. package/lib-module/Tags/Tags.js +251 -0
  193. package/lib-module/Tags/index.js +2 -0
  194. package/lib-module/TextInput/TextArea.js +94 -0
  195. package/lib-module/TextInput/TextInput.js +64 -0
  196. package/lib-module/TextInput/TextInputBase.js +254 -0
  197. package/lib-module/TextInput/index.js +3 -0
  198. package/lib-module/TextInput/propTypes.js +33 -0
  199. package/lib-module/ThemeProvider/ThemeProvider.js +36 -0
  200. package/lib-module/ThemeProvider/index.js +6 -0
  201. package/lib-module/ThemeProvider/useSetTheme.js +25 -0
  202. package/lib-module/ThemeProvider/useTheme.js +14 -0
  203. package/lib-module/ThemeProvider/useThemeTokens.js +110 -0
  204. package/lib-module/ThemeProvider/utils/index.js +2 -0
  205. package/lib-module/ThemeProvider/utils/styles.js +181 -0
  206. package/lib-module/ThemeProvider/utils/theme-tokens.js +163 -0
  207. package/lib-module/ToggleSwitch/ToggleSwitch.js +250 -0
  208. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +220 -0
  209. package/lib-module/ToggleSwitch/index.js +3 -0
  210. package/lib-module/Tooltip/Backdrop.js +45 -0
  211. package/lib-module/Tooltip/Backdrop.native.js +44 -0
  212. package/lib-module/Tooltip/Tooltip.js +348 -0
  213. package/lib-module/Tooltip/dictionary.js +8 -0
  214. package/lib-module/Tooltip/getTooltipPosition.js +175 -0
  215. package/lib-module/Tooltip/index.js +2 -0
  216. package/lib-module/TooltipButton/TooltipButton.js +78 -0
  217. package/lib-module/TooltipButton/index.js +2 -0
  218. package/lib-module/Typography/Typography.js +124 -0
  219. package/lib-module/Typography/index.js +2 -0
  220. package/lib-module/ViewportProvider/ViewportProvider.js +29 -0
  221. package/lib-module/ViewportProvider/index.js +3 -0
  222. package/lib-module/ViewportProvider/useViewport.js +3 -0
  223. package/lib-module/ViewportProvider/useViewportListener.js +46 -0
  224. package/lib-module/index.js +48 -0
  225. package/lib-module/utils/a11y/index.js +2 -0
  226. package/lib-module/utils/a11y/semantics.js +157 -0
  227. package/lib-module/utils/a11y/textSize.js +36 -0
  228. package/lib-module/utils/animation/index.js +2 -0
  229. package/lib-module/utils/animation/useVerticalExpandAnimation.js +88 -0
  230. package/lib-module/utils/children.js +119 -0
  231. package/lib-module/utils/containUniqueFields.js +26 -0
  232. package/lib-module/utils/index.js +16 -0
  233. package/lib-module/utils/info/index.js +7 -0
  234. package/lib-module/utils/info/platform/index.js +11 -0
  235. package/lib-module/utils/info/platform/platform.android.js +1 -0
  236. package/lib-module/utils/info/platform/platform.ios.js +1 -0
  237. package/lib-module/utils/info/platform/platform.js +1 -0
  238. package/lib-module/utils/info/platform/platform.native.js +4 -0
  239. package/lib-module/utils/info/versions.js +5 -0
  240. package/lib-module/utils/input.js +179 -0
  241. package/lib-module/utils/pressability.js +111 -0
  242. package/lib-module/utils/props/a11yProps.js +140 -0
  243. package/lib-module/utils/props/clickProps.js +26 -0
  244. package/lib-module/utils/props/componentPropType.js +63 -0
  245. package/lib-module/utils/props/copyPropTypes.js +2 -0
  246. package/lib-module/utils/props/getPropSelector.js +9 -0
  247. package/lib-module/utils/props/handlerProps.js +65 -0
  248. package/lib-module/utils/props/hrefAttrsProp.js +33 -0
  249. package/lib-module/utils/props/index.js +19 -0
  250. package/lib-module/utils/props/inputSupportsProps.js +62 -0
  251. package/lib-module/utils/props/linkProps.js +44 -0
  252. package/lib-module/utils/props/paddingProp.js +9 -0
  253. package/lib-module/utils/props/pressProps.js +42 -0
  254. package/lib-module/utils/props/rectProp.js +9 -0
  255. package/lib-module/utils/props/responsiveProps.js +30 -0
  256. package/lib-module/utils/props/selectSystemProps.js +24 -0
  257. package/lib-module/utils/props/spacingProps.js +56 -0
  258. package/lib-module/utils/props/textInputProps.js +201 -0
  259. package/lib-module/utils/props/textProps.js +59 -0
  260. package/lib-module/utils/props/tokens.js +133 -0
  261. package/lib-module/utils/props/variantProp.js +18 -0
  262. package/lib-module/utils/props/viewProps.js +22 -0
  263. package/lib-module/utils/ssr.js +38 -0
  264. package/lib-module/utils/useCopy.js +44 -0
  265. package/lib-module/utils/useHash.js +45 -0
  266. package/lib-module/utils/useHash.native.js +7 -0
  267. package/lib-module/utils/useResponsiveProp.js +47 -0
  268. package/lib-module/utils/useSpacingScale.js +125 -0
  269. package/lib-module/utils/useUniqueId.js +13 -0
  270. package/lib-module/utils/withLinkRouter.js +83 -0
  271. package/package.json +3 -3
  272. package/src/Card/Card.jsx +6 -4
  273. package/src/Checkbox/Checkbox.jsx +3 -1
  274. package/src/ExpandCollapse/Panel.jsx +10 -20
  275. package/src/Link/InlinePressable.jsx +5 -2
  276. package/src/Link/LinkBase.jsx +4 -1
  277. package/src/List/List.jsx +6 -2
  278. package/src/Tabs/Tabs.jsx +24 -2
  279. package/src/Tabs/TabsItem.jsx +6 -5
  280. package/src/TextInput/TextInput.jsx +1 -8
  281. package/src/TextInput/TextInputBase.jsx +11 -1
  282. package/src/TextInput/propTypes.js +3 -7
  283. package/src/utils/animation/useVerticalExpandAnimation.js +47 -13
  284. package/src/utils/props/textInputProps.js +7 -1
@@ -0,0 +1,124 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Text from "react-native-web/dist/exports/Text";
4
+ import View from "react-native-web/dist/exports/View";
5
+ import { useThemeTokens } from '../ThemeProvider';
6
+ import { useViewport } from '../ViewportProvider';
7
+ import { applyTextStyles } from '../ThemeProvider/utils';
8
+ import { a11yProps, variantProp, getTokensPropType, getMaxFontMultiplier, headingTags, selectSystemProps, textTags, textProps, viewProps, getA11yPropsFromHtmlTag } from '../utils';
9
+ /**
10
+ * @typedef {import('../utils/a11y/semantics').TextTag} TextTag
11
+ */
12
+
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ const [selectContainerProps, selectedContainerPropTypes] = selectSystemProps([a11yProps, viewProps]);
15
+ const [selectTextProps, selectedTextPropTypes] = selectSystemProps([textProps]);
16
+
17
+ const selectTextStyles = _ref => {
18
+ let {
19
+ fontWeight,
20
+ fontSize,
21
+ color,
22
+ lineHeight,
23
+ fontName,
24
+ textAlign,
25
+ textTransform,
26
+ letterSpacing
27
+ } = _ref;
28
+ return applyTextStyles({
29
+ fontWeight,
30
+ fontSize,
31
+ color,
32
+ lineHeight,
33
+ fontName,
34
+ textAlign,
35
+ textTransform,
36
+ letterSpacing
37
+ });
38
+ }; // General-purpose flexible theme-neutral base component for text
39
+
40
+
41
+ const Typography = /*#__PURE__*/forwardRef((_ref2, ref) => {
42
+ let {
43
+ children,
44
+ variant,
45
+ heading,
46
+ tag = typeof heading === 'string' ? heading : undefined,
47
+ accessibilityRole = heading === true ? 'header' : undefined,
48
+ block = false,
49
+ align = undefined,
50
+ tokens,
51
+ dataSet,
52
+ ...rest
53
+ } = _ref2;
54
+ const viewport = useViewport();
55
+ const themeTokens = useThemeTokens('Typography', tokens, variant, {
56
+ viewport
57
+ });
58
+ const resolvedTextProps = { ...selectTextProps(rest),
59
+ style: selectTextStyles(align ? { ...themeTokens,
60
+ textAlign: align
61
+ } : themeTokens),
62
+ dataSet,
63
+ maxFontSizeMultiplier: getMaxFontMultiplier(themeTokens)
64
+ };
65
+ const containerProps = { ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
66
+ ...selectContainerProps(rest)
67
+ };
68
+ return block ? /*#__PURE__*/_jsx(View, {
69
+ ref: ref,
70
+ ...containerProps,
71
+ children: /*#__PURE__*/_jsx(Text, { ...resolvedTextProps,
72
+ children: children
73
+ })
74
+ }) : /*#__PURE__*/_jsx(Text, {
75
+ ref: ref,
76
+ ...containerProps,
77
+ ...resolvedTextProps,
78
+ children: children
79
+ });
80
+ });
81
+ Typography.displayName = 'Typography';
82
+ Typography.propTypes = { ...selectedContainerPropTypes,
83
+ ...selectedTextPropTypes,
84
+ tokens: getTokensPropType('Typography'),
85
+ variant: variantProp.propType,
86
+
87
+ /**
88
+ * Renders the text as a semantic heading. If a html heading tag is provided, uses that tag on Web.
89
+ *
90
+ * Does not affect styling: <Typography heading="h2"> will render a <h2> that looks like plain text.
91
+ * Use both `heading` and `variant` props to render semantic headings that look like headings.
92
+ *
93
+ * In native apps, if this is `true` or any html heading tag string and accessibilityRole prop
94
+ * is not defined, the accessibilityRole will default to "heading".
95
+ */
96
+ heading: PropTypes.oneOf([...headingTags, true]),
97
+
98
+ /**
99
+ * Optional semantic HTML tag, to apply to the text on web. Does not change styling.
100
+ *
101
+ * `tag` and `heading` props set the same thing, so shouldn't be used together (`tag` overrides `heading`).
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(textTags),
107
+
108
+ /**
109
+ * If true, forces the element to behave as a View block even if nested in other text
110
+ */
111
+ block: PropTypes.bool,
112
+
113
+ /**
114
+ * Works the same as css text-align, note that RN doesn't support "start" or "end" (see https://reactnative.dev/docs/text-style-props#textalign)
115
+ * Justify is known to make text harder to read, especially for people with dyslexia (see https://developer.mozilla.org/en-US/docs/Web/CSS/text-align#accessibility_concerns)
116
+ */
117
+ align: PropTypes.oneOf(['auto', 'left', 'right', 'center', 'justify']),
118
+
119
+ /**
120
+ * Same children allowed as a React Native <Text> node
121
+ */
122
+ children: PropTypes.node
123
+ };
124
+ export default Typography;
@@ -0,0 +1,2 @@
1
+ import Typography from './Typography';
2
+ export default Typography;
@@ -0,0 +1,29 @@
1
+ import React, { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { viewports } from '@telus-uds/system-constants';
4
+ import { ViewportContext } from './useViewport';
5
+ import useViewportListener from './useViewportListener';
6
+ /**
7
+ * Provides an up-to-date viewport value from system-constants, available via the `useViewport` hook
8
+ */
9
+
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+
12
+ const ViewportProvider = _ref => {
13
+ let {
14
+ children
15
+ } = _ref;
16
+ // Default to the smallest viewport for mobile-first SSR. On client side, this is updated
17
+ // by useViewportListener in a layout effect before anything is shown to the user.
18
+ const [viewport, setViewport] = useState(viewports.keys[0]);
19
+ useViewportListener(setViewport);
20
+ return /*#__PURE__*/_jsx(ViewportContext.Provider, {
21
+ value: viewport,
22
+ children: children
23
+ });
24
+ };
25
+
26
+ ViewportProvider.propTypes = {
27
+ children: PropTypes.node.isRequired
28
+ };
29
+ export default ViewportProvider;
@@ -0,0 +1,3 @@
1
+ import ViewportProvider from './ViewportProvider';
2
+ export default ViewportProvider;
3
+ export * from './useViewport';
@@ -0,0 +1,3 @@
1
+ import { createContext, useContext } from 'react';
2
+ export const ViewportContext = /*#__PURE__*/createContext({});
3
+ export const useViewport = () => useContext(ViewportContext);
@@ -0,0 +1,46 @@
1
+ import { useLayoutEffect } from 'react';
2
+ import Dimensions from "react-native-web/dist/exports/Dimensions";
3
+ import { viewports } from '@telus-uds/system-constants'; // Use Dimensions instead of useWindowDimensions because useWindowDimensions forces context
4
+ // to update on every pixel change during window resize; but we only want rerenders to occur
5
+ // when a viewport threshold has been crossed.
6
+
7
+ const lookupViewport = () => viewports.select(Dimensions.get('window').width);
8
+ /**
9
+ * In SSR, React gets spooked if it sees `useLayoutEffect` and fires warnings assuming the
10
+ * developer doesn't realise the effect won't run: https://reactjs.org/link/uselayouteffect-ssr
11
+ *
12
+ * To avoid these warnings while still conforming to the rules of hooks, always use this
13
+ * explicitly no-op hook, instead of the useLayoutEffect that is implicitly no-op on SSR.
14
+ */
15
+
16
+
17
+ const useViewportListenerSSR = () => {};
18
+ /**
19
+ * When client-side rendering, immediately set the viewport to the correct value as a layout effect so
20
+ * if the viewport isn't the smallest, any SSR-rendered components rerender correctly before anything
21
+ * is shown to the user. Then bind events to update the viewport if it changes.
22
+ */
23
+
24
+
25
+ const useViewportListenerCSR = setViewport => {
26
+ useLayoutEffect(() => {
27
+ setViewport(lookupViewport());
28
+
29
+ const onChange = _ref => {
30
+ let {
31
+ window
32
+ } = _ref;
33
+ return setViewport(viewports.select(window.width));
34
+ };
35
+
36
+ const listener = Dimensions.addEventListener('change', onChange); // From RN 0.65.0, Dimensions.removeEventListener is deprecated for `remove` on addEventListener return value;
37
+ // however, that is not available in RN <=0.64.X, therefore not in any Expo release as of 2021 (Expo SDK 43).
38
+
39
+ return (listener === null || listener === void 0 ? void 0 : listener.remove) || (() => Dimensions.removeEventListener('change', onChange)); // setViewport is a function from `useState` so it is stable and won't make the effect re-run
40
+ }, [setViewport]);
41
+ }; // Window is a defined global object in both Web and Native client-side, and undefined in SSR
42
+
43
+
44
+ const isSSR = typeof window === 'undefined';
45
+ const useViewportListener = isSSR ? useViewportListenerSSR : useViewportListenerCSR;
46
+ export default useViewportListener;
@@ -0,0 +1,48 @@
1
+ export { default as A11yText } from './A11yText';
2
+ export { default as ActivityIndicator } from './ActivityIndicator';
3
+ export { default as Box } from './Box';
4
+ export * from './Button';
5
+ export { default as Card, PressableCardBase } from './Card';
6
+ export { default as Checkbox } from './Checkbox';
7
+ export * from './Checkbox';
8
+ export { default as Divider } from './Divider';
9
+ export { default as ExpandCollapse, Accordion } from './ExpandCollapse';
10
+ export { default as Feedback } from './Feedback';
11
+ export { default as Fieldset } from './Fieldset';
12
+ export { default as FlexGrid } from './FlexGrid';
13
+ export { default as HorizontalScroll } from './HorizontalScroll';
14
+ export * from './HorizontalScroll';
15
+ export { default as Icon } from './Icon';
16
+ export * from './Icon';
17
+ export { default as IconButton } from './IconButton';
18
+ export { default as InputLabel } from './InputLabel';
19
+ export * from './Link';
20
+ export { default as List, ListItem, ListBase } from './List';
21
+ export { default as Modal } from './Modal';
22
+ export { default as Notification } from './Notification';
23
+ export { default as Pagination } from './Pagination';
24
+ export { default as Progress } from './Progress';
25
+ export { default as Radio } from './Radio';
26
+ export * from './Radio';
27
+ export { default as RadioCard } from './RadioCard';
28
+ export * from './RadioCard';
29
+ export { default as Search } from './Search';
30
+ export { default as Select } from './Select';
31
+ export { default as SideNav } from './SideNav';
32
+ export { default as Skeleton } from './Skeleton';
33
+ export { default as Spacer } from './Spacer';
34
+ export { default as StackView } from './StackView';
35
+ export * from './StackView';
36
+ export { default as StepTracker } from './StepTracker';
37
+ export { default as Tabs } from './Tabs';
38
+ export { default as Tags } from './Tags';
39
+ export * from './TextInput';
40
+ export * from './ToggleSwitch';
41
+ export { default as Tooltip } from './Tooltip';
42
+ export { default as TooltipButton } from './TooltipButton';
43
+ export { default as Typography } from './Typography';
44
+ export { default as A11yInfoProvider, useA11yInfo } from './A11yInfoProvider';
45
+ export { default as BaseProvider } from './BaseProvider';
46
+ export { default as ViewportProvider, useViewport, ViewportContext } from './ViewportProvider';
47
+ export { default as ThemeProvider, useTheme, useSetTheme, useThemeTokens, getThemeTokens, applyOuterBorder, applyTextStyles, applyShadowToken } from './ThemeProvider';
48
+ export * from './utils';
@@ -0,0 +1,2 @@
1
+ export * from './textSize';
2
+ export * from './semantics';
@@ -0,0 +1,157 @@
1
+ import Platform from "react-native-web/dist/exports/Platform";
2
+ /**
3
+ * @typedef {import('react-native').AccessibilityRole} AccessibilityRole
4
+ */
5
+
6
+ /**
7
+ * This is based on the role-to-tag mapping that React Native Web uses to set HTML tags.
8
+ * It's not exported in any way from RNW, so we need to keep this up-to-date manually.
9
+ * https://github.com/necolas/react-native-web/blob/master/packages/react-native-web/src/modules/AccessibilityUtil/propsToAccessibilityComponent.js
10
+ *
11
+ * Note: every role in this list is a web-only aria-role. There is no overlap between _these_ web tags
12
+ * or roles and native accessibilityRoles. Only h1, h2, h3 etc map to an RN equivalent ("heading").
13
+ *
14
+ * - RN "summary" native role maps to "region" aria-role, but setting `<section>`/"region" does not
15
+ * set React Native's "summary" role, which has a much narrower use case.
16
+ * - `<Header>`/"Banner" also do not map to RN's "heading". Only h1 / h2 etc map to RN "heading".
17
+ *
18
+ * Therefore, all of these tags / roles default to no accessibilityRole in native apps. This is not wrong:
19
+ * in general, RN accessibilityRoles tend to be more about interaction and less about semantics than web roles.
20
+ *
21
+ * RNW's one-way mapping of React Native accessibilityRoles to web aria-roles:
22
+ * https://github.com/necolas/react-native-web/blob/master/packages/react-native-web/src/modules/AccessibilityUtil/propsToAriaRole.js
23
+ */
24
+ // Adding `/** @type {const} */ ({...})` denotes object content as `readonly` in many IDEs
25
+ // eslint-disable-next-line prettier/prettier
26
+
27
+ const rolesToTags =
28
+ /** @type {const} */
29
+ {
30
+ article: 'article',
31
+ banner: 'header',
32
+ blockquote: 'blockquote',
33
+ code: 'code',
34
+ complementary: 'aside',
35
+ contentinfo: 'footer',
36
+ deletion: 'del',
37
+ emphasis: 'em',
38
+ figure: 'figure',
39
+ insertion: 'ins',
40
+ form: 'form',
41
+ list: 'ul',
42
+ listitem: 'li',
43
+ main: 'main',
44
+ navigation: 'nav',
45
+ region: 'section',
46
+ strong: 'strong',
47
+ // Add special cases that are in RNW's function logic but not in its mapping object
48
+ label: 'label' // eslint-disable-next-line prettier/prettier
49
+
50
+ }; // Invert React Native Web's mapping, so a tag gets the role that gets that tag
51
+
52
+ export const tagsToRoles = Object.fromEntries(Object.entries(rolesToTags).map(_ref => {
53
+ let [key, value] = _ref;
54
+ return [value, key];
55
+ }));
56
+ /**
57
+ * Heading HTML tags map to the "heading" accessibilityRole in native apps, which is similar
58
+ * to headings on web but without the expectation of a hierarchy of headings within one screen.
59
+ */
60
+ // eslint-disable-next-line prettier/prettier
61
+
62
+ export const headingTags =
63
+ /** @type {const} */
64
+ ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
65
+ /**
66
+ * @typedef {typeof headingTags[number]} HeadingTag
67
+ */
68
+
69
+ /**
70
+ * All HTML tags that may be set via RNW accesibility props alone and therefore may be set using
71
+ * the getA11yPropsFromHtmlTag function without changing other behaviour.
72
+ *
73
+ * Of these, only headers (h1, h2, ...h5, h6) set a corresponding accessibilityRole in native apps ("heading").
74
+ */
75
+
76
+ export const supportedTags = [...Object.keys(tagsToRoles), ...headingTags];
77
+ /**
78
+ * Uses readonly mapping keys/values to generate static types for IDEs that support TS in JSDoc.
79
+ * @typedef {keyof rolesToTags} RoleWithTag
80
+ * @typedef {typeof rolesToTags[RoleWithTag] | typeof headingTags[number]} SupportedTag
81
+ */
82
+
83
+ /**
84
+ * Subset of supported HTML tags that may be used with layout containers like Box.
85
+ *
86
+ * Of these, only headers (h1, h2, ...h5, h6) set a corresponding accessibilityRole in native apps ("heading").
87
+ */
88
+ // eslint-disable-next-line prettier/prettier
89
+
90
+ export const layoutTags =
91
+ /** @type {const} */
92
+ [...headingTags, 'article', 'aside', 'blockquote', 'footer', 'figure', 'form', 'header', 'ul', 'li', 'main', 'nav', 'section', 'label' // eslint-disable-next-line prettier/prettier
93
+ ];
94
+ /**
95
+ * @typedef {typeof layoutTags[number]} LayoutTag
96
+ */
97
+
98
+ /**
99
+ * Subset of supported HTML tags that may be used with text elements like Typography.
100
+ *
101
+ * Of these, only headers (h1, h2, ...h5, h6) set a corresponding accessibilityRole in native apps ("heading").
102
+ */
103
+ // eslint-disable-next-line prettier/prettier
104
+
105
+ export const textTags =
106
+ /** @type {const} */
107
+ [...headingTags, 'blockquote', 'code', 'del', 'em', 'ins', 'li', 'strong', 'label' // eslint-disable-next-line prettier/prettier
108
+ ];
109
+ /**
110
+ * @typedef {typeof layoutTags[number]} TextTag
111
+ */
112
+
113
+ /**
114
+ * If passed a heading tag string like 'h1', 'h2' etc, returns the heading number as a number
115
+ * ready for use in `accessibilityLevel` props and similar.
116
+ *
117
+ * @param {string} [tag] - HTML tag string; returns undefined if not a {@link HeadingTag}
118
+ * @returns {'1' | '2' | '3' | '4' | '5' | '6' | undefined}
119
+ */
120
+
121
+ export const getHeadingLevel = tag => headingTags.includes(tag) ? Number(tag[1]) : undefined;
122
+ /**
123
+ * Takes a supported HTML tag, and returns the accessibility props that, on web, make React Native Web
124
+ * render that tag.
125
+ *
126
+ * For cross-platform apps, a second argument may be passed with an [accessibilityRole](https://reactnative.dev/docs/accessibility#accessibilityrole)
127
+ * to use in native apps. Heading tags (h1, h2, ...h5, h6) map to "heading" role by default;
128
+ * no other supported semantic HTML tags have an equivalent native accessibilityRole.
129
+ *
130
+ * @param {SupportedTag} tag - HTML tag to use on web
131
+ * @param {AccessibilityRole | null} [nativeRole] - optional accessibilityRole for native apps
132
+ * @returns {{ accessibilityRole: string, accessibilityLevel?: string } | undefined}
133
+ */
134
+
135
+ export const getA11yPropsFromHtmlTag = (tag, nativeRole) => {
136
+ // Allow cross-platform apps to set accessibilityRoles alongside a web tag without conflict
137
+ if (nativeRole !== undefined && Platform.OS !== 'web') return {
138
+ accessibilityRole: nativeRole
139
+ };
140
+
141
+ if (tag) {
142
+ // aria roles don't have native counterparts and RN may throw an error if an unrecognised role is passed
143
+ const ariaRole = Platform.OS === 'web' && tagsToRoles[tag];
144
+ if (ariaRole) return {
145
+ accessibilityRole: ariaRole
146
+ };
147
+ const accessibilityLevel = getHeadingLevel(tag);
148
+ if (accessibilityLevel) return {
149
+ accessibilityRole: 'header',
150
+ accessibilityLevel
151
+ };
152
+ } // If nothing matches or no tag supplied, return undefined and let component decide how to fall back.
153
+ // Note that return value may always be spread in objects (it is safe to spread undefined like { ...undefined })
154
+
155
+
156
+ return undefined;
157
+ };
@@ -0,0 +1,36 @@
1
+ import PixelRatio from "react-native-web/dist/exports/PixelRatio";
2
+ import Platform from "react-native-web/dist/exports/Platform";
3
+ /**
4
+ * When a user increases text size using device accessibility settings, some elements
5
+ * should also scale, such as icons alongside text and space between paragraphs.
6
+ *
7
+ * @param {number} [value] - the value to multiply; defaults to system default font size
8
+ * @param {number} [maxScale] - the maximum multiplier to apply; defaults to no maximum
9
+ */
10
+
11
+ export const scaleWithText = function (value) {
12
+ let maxScale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
13
+ if (!value) return value;
14
+ const scale = Math.min(PixelRatio.getFontScale(), maxScale) || 1;
15
+ return value * scale;
16
+ };
17
+ /**
18
+ * Native only, returns `undefined` on Web.
19
+ *
20
+ * Enforces `fontScaleCap` theme tokens as the maximum font size text can become
21
+ * after iOS or Android font scaling, to give consistent accessible maximum sizes
22
+ * that don't make the content unusable.
23
+ *
24
+ * The return value of this function can be used as a React Native `Text` element's
25
+ * `maxFontSizeMultiplier` prop value.
26
+ */
27
+
28
+ export const getMaxFontMultiplier = _ref => {
29
+ let {
30
+ fontSize,
31
+ fontScaleCap
32
+ } = _ref;
33
+ if (Platform.OS === 'web' || !fontScaleCap || !fontSize) return undefined;
34
+ if (fontScaleCap <= fontSize) return 1;
35
+ return fontScaleCap / fontSize;
36
+ };
@@ -0,0 +1,2 @@
1
+ /* eslint-disable import/prefer-default-export */
2
+ export { default as useVerticalExpandAnimation } from './useVerticalExpandAnimation';
@@ -0,0 +1,88 @@
1
+ import { useEffect, useLayoutEffect, useRef, useState } from 'react';
2
+ import Animated from "react-native-web/dist/exports/Animated";
3
+ import Easing from "react-native-web/dist/exports/Easing";
4
+ import Platform from "react-native-web/dist/exports/Platform"; // TODO: systematise animations
5
+ // https://github.com/telus/universal-design-system/issues/487
6
+
7
+ function useVerticalExpandAnimation(_ref) {
8
+ let {
9
+ containerHeight,
10
+ isExpanded,
11
+ tokens
12
+ } = _ref;
13
+ const [isAnimating, setIsAnimating] = useState(false);
14
+ const [wasExpanded, setWasExpanded] = useState(isExpanded);
15
+ const expandStateChanged = isExpanded !== wasExpanded;
16
+ const expandAnimatedValue = useRef(new Animated.Value(0)).current;
17
+ const elementRef = useRef(null);
18
+ const {
19
+ expandDuration,
20
+ collapseDuration
21
+ } = tokens;
22
+ useLayoutEffect(() => {
23
+ if (expandStateChanged) {
24
+ setIsAnimating(true);
25
+ setWasExpanded(isExpanded);
26
+ }
27
+ }, [expandStateChanged, isExpanded]);
28
+ useEffect(() => {
29
+ const onComplete = () => setIsAnimating(false);
30
+
31
+ if (Platform.OS === 'web') {
32
+ if (!elementRef.current) return () => {}; // React Native Web does not pass `onTransitionEnd` through, must attach manually.
33
+ // https://github.com/necolas/react-native-web/pull/1713
34
+
35
+ const element = elementRef.current;
36
+ element.addEventListener('transitionend', onComplete);
37
+ return () => element.removeEventListener('transitionend', onComplete);
38
+ }
39
+
40
+ const animationConfig = {
41
+ duration: isExpanded ? expandDuration : collapseDuration,
42
+ easing: Easing.inOut(Easing.ease),
43
+ toValue: isExpanded ? containerHeight : 0,
44
+ useNativeDriver: false
45
+ };
46
+ const animation = Animated.timing(expandAnimatedValue, animationConfig);
47
+ animation.start(onComplete);
48
+ return () => animation.stop();
49
+ }, [isExpanded, expandAnimatedValue, containerHeight, expandDuration, collapseDuration]);
50
+ const containerStyles = {};
51
+ if (isAnimating || expandStateChanged) containerStyles.overflow = 'hidden';
52
+
53
+ if (!isExpanded && !isAnimating && !expandStateChanged) {
54
+ if (Platform.OS === 'web') {
55
+ // Without `visibility: 'hidden', descendents are focusable on web even when collapsed.
56
+ containerStyles.visibility = 'hidden';
57
+ } else {
58
+ // There's no `visibility: hidden` in React Native, and display: none causes a flicker on expand.
59
+ // Without some form of hiding, some children leak through even when closed e.g. `List.Item` bullets.
60
+ containerStyles.opacity = 0;
61
+ }
62
+ } // don't visually collapse the container until we have it measured
63
+
64
+
65
+ if (containerHeight === null) {
66
+ if (Platform.OS === 'web') {
67
+ // on web we can hide the contents until we have the container measured and avoid occasional jitter
68
+ // this won't work on native platforms
69
+ containerStyles.height = 0;
70
+ containerStyles.visibility = 'hidden';
71
+ }
72
+ } else if (Platform.OS === 'web') {
73
+ const transitionDuration = isExpanded ? expandDuration : collapseDuration;
74
+ containerStyles.transition = "height ".concat(transitionDuration, "ms ease-in-out");
75
+ containerStyles.height = isExpanded ? containerHeight : 0;
76
+ } else if (Platform.OS === 'ios' && isExpanded && !isAnimating && !expandStateChanged && typeof containerHeight === 'number') {
77
+ // iOS reflows text while the height animation is in progress. Sometimes, it hits a timing bug where
78
+ // it fails to reflow properly after the last animation frame, leaving the last line of text not visible.
79
+ // Force reflow after animation completes with a static height non-identical to the last animated height.
80
+ containerStyles.height = containerHeight + 1;
81
+ } else {
82
+ containerStyles.height = expandAnimatedValue;
83
+ }
84
+
85
+ return [containerStyles, elementRef];
86
+ }
87
+
88
+ export default useVerticalExpandAnimation;
@@ -0,0 +1,119 @@
1
+ import React, { Children, Fragment } from 'react';
2
+ import Text from "react-native-web/dist/exports/Text";
3
+ import A11yText from '../A11yText';
4
+ /**
5
+ * Unpacks top-level fragments, so that common compositional patterns such as the following examples
6
+ * can be iterated as flat siblings (as if they were `<Child1 /><Child2 /><Child3 />`):
7
+ *
8
+ * - Setting `children` as a property wrapped in a fragment:
9
+ *
10
+ * ```jsx
11
+ * args.children = <><Child1 /><Child2 /><Child3 /></>
12
+ * ```
13
+ *
14
+ * - Defining `children` as a variable wrapped in a fragment:
15
+ *
16
+ * ```jsx
17
+ * const content = <><Child1 /><Child2 /><Child3 /></>
18
+ * if (someCondition) return <SomeWrapper>{content}</SomeWrapper>
19
+ * ```
20
+ *
21
+ * - Using fragments at the top level of a JSX block for conditional rendering:
22
+ *
23
+ * ```jsx
24
+ * <Child1 />
25
+ * {someCondition && (
26
+ * <>
27
+ * <Child2 />
28
+ * <Child3 />
29
+ * </>
30
+ * )}
31
+ * ```
32
+ *
33
+ * @param {ReactChildren} child
34
+ * @returns {ReactChildren}
35
+ */
36
+
37
+ import { jsx as _jsx } from "react/jsx-runtime";
38
+ export const unpackFragment = child => {
39
+ var _child$props;
40
+
41
+ // If this level is a set of top-level siblings rather than one child, check each in turn
42
+ 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
43
+
44
+ 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
45
+
46
+ return child;
47
+ };
48
+
49
+ const isStringOrNumber = child => typeof child === 'string' || typeof child === 'number'; // Wrap an A11yText with neighouring text strings so it doesn't split them into multiple <Text>s
50
+
51
+
52
+ const isWrapable = child => {
53
+ var _child$type;
54
+
55
+ return isStringOrNumber(child) || child.type === A11yText || ((_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.name) === 'FootnoteLink';
56
+ };
57
+
58
+ const combineKeys = childrenArray => childrenArray.reduce((newKey, child) => "".concat(newKey).concat(child.key || ''), ''); // Group wrappable children for one `<Text>` parent, merging adjacent text nodes
59
+
60
+
61
+ const wrapChild = (child, wrappedText) => {
62
+ const lastIndex = wrappedText.length - 1; // If possible, simplify content by combining text nodes into one string.
63
+ // jest-native's `.toHaveTextContent` is buggy about array of text nodes in <Text> elements.
64
+
65
+ if (lastIndex >= 0 && isStringOrNumber(child) && isStringOrNumber(wrappedText[lastIndex])) {
66
+ /* eslint-disable-next-line no-param-reassign */
67
+ wrappedText[lastIndex] = "".concat(wrappedText[lastIndex]).concat(child);
68
+ } else {
69
+ wrappedText.push(child);
70
+ }
71
+ };
72
+ /**
73
+ * React Native on Native crashes if text content is rendered outside `<Text>`, and on web,
74
+ * text style inheritance behaves differently with text compared to regular HTML.
75
+ *
76
+ * Call this function on children that may contain text (strings or numbers) at the top level,
77
+ * and any that are found will be wrapped in a React Native `<Text>` element with supplied props.
78
+ *
79
+ * Note that this does not wrap strings that are nested children of rendered top level children:
80
+ * `wrapStringsInText(<View>Some text</View>)` will not wrap the inner text and will still crash,
81
+ * but `wrapStringsInText(<>{someString}{anotherString}</>)` wraps the strings inside the fragment.
82
+ *
83
+ * @param {ReactChildren} children
84
+ * @param {TextProps} props
85
+ * @returns {ReactChildren}
86
+ */
87
+
88
+
89
+ export const wrapStringsInText = function (children) {
90
+ let textProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
91
+ const childrenArray = unpackFragment(Children.toArray(children)); // Group adjacent wrapable children together in one Text element to create as few Text elements
92
+ // as possible, e.g. give <X>Text {someString}</X> one Text, same as <X>{`Text ${someString}`}</X>
93
+
94
+ const wrapables = [[]];
95
+ let wrapablesIndex = 0;
96
+ childrenArray.forEach(child => {
97
+ if (isWrapable(child)) {
98
+ // Make this child a child of the current `Text`
99
+ wrapChild(child, wrapables[wrapablesIndex]);
100
+ } else {
101
+ // Close current `Text` and start a new one after this child
102
+ wrapables.push(child, []);
103
+ wrapablesIndex += 2;
104
+ }
105
+ });
106
+ const items = wrapables.reduce((flatChildren, group, index) => {
107
+ // Skip nullish children and empty arrays
108
+ if (!group || Array.isArray(group) && !group.length) return flatChildren;
109
+ return [...flatChildren, Array.isArray(group) && group.some(child => isStringOrNumber(child)) ?
110
+ /*#__PURE__*/
111
+ // Wrap text nodes and their wrappable neighbours in Text with as stable a key as possible.
112
+ // Avoid one-item arrays because jest-native's `.toHaveTextContent` is buggy
113
+ // and sometimes fails to match text content in arrays.
114
+ _jsx(Text, { ...textProps,
115
+ children: group.length === 1 ? group[0] : group
116
+ }, combineKeys(group) || index) : group];
117
+ }, []);
118
+ return items.length === 1 ? items[0] : items;
119
+ };