@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,210 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Text from "react-native-web/dist/exports/Text";
4
+ import Platform from "react-native-web/dist/exports/Platform";
5
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
6
+ import { a11yProps, clickProps, getTokensPropType, hrefAttrsProp, linkProps, selectSystemProps, variantProp, viewProps } from '../utils/props';
7
+ import { resolvePressableTokens } from '../utils/pressability';
8
+ import { withLinkRouter } from '../utils';
9
+ import InlinePressable from './InlinePressable';
10
+ import { applyTextStyles, applyOuterBorder } from '../ThemeProvider';
11
+ import { IconText, iconComponentPropTypes } from '../Icon';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, linkProps, viewProps]);
14
+
15
+ const selectOuterBorderStyles = ({
16
+ outerBorderColor,
17
+ outerBorderWidth,
18
+ outerBorderGap,
19
+ borderRadius,
20
+ outerBorderOutline
21
+ }) => // A view wrapper with a border on native messes up inline text alignment
22
+ // so for now make focus styles strictly web-only
23
+ Platform.OS === 'web' ? {
24
+ // Allow theme to define outline, or, turn off outline and use border if rounded corners required
25
+ outline: outerBorderOutline,
26
+ ...applyOuterBorder({
27
+ outerBorderColor,
28
+ outerBorderWidth,
29
+ outerBorderGap,
30
+ borderRadius
31
+ }),
32
+ // Stops focus ring stretching horizontally if parent has display: block
33
+ // width: fit-content isn't supported on Firefox; can't cascade props like CSS `width: fit-content; width: --moz-fit-content;`
34
+ display: 'inline-flex'
35
+ } : {};
36
+
37
+ const selectTextStyles = ({
38
+ color,
39
+ textLine,
40
+ textLineStyle
41
+ }) => ({
42
+ color,
43
+ textDecorationLine: textLine,
44
+ textDecorationStyle: textLineStyle,
45
+ ...Platform.select({
46
+ web: {
47
+ // TODO: https://github.com/telus/universal-design-system/issues/487
48
+ transition: 'color 200ms'
49
+ }
50
+ })
51
+ });
52
+
53
+ const selectBlockStyles = ({
54
+ blockFontWeight,
55
+ blockFontSize,
56
+ blockLineHeight,
57
+ blockFontName
58
+ }) => applyTextStyles({
59
+ fontWeight: blockFontWeight,
60
+ fontSize: blockFontSize,
61
+ lineHeight: blockLineHeight,
62
+ fontName: blockFontName
63
+ });
64
+
65
+ const selectIconTokens = ({
66
+ color,
67
+ iconSize,
68
+ iconTranslateX,
69
+ iconTranslateY
70
+ }) => ({
71
+ color,
72
+ translateX: iconTranslateX,
73
+ translateY: iconTranslateY,
74
+ size: iconSize
75
+ });
76
+ /**
77
+ * Renders a pressable text link, with optional icon. This is rendered as a block element
78
+ * only (see 'Current Limitations'). On Web, renders an `<a>` anchor tag if `href` is provided.
79
+ *
80
+ * ## Current limitations
81
+ *
82
+ * - Not yet integrated with widely-used Telus navigation packages. This will probably
83
+ * require adding a `navigate` prop that aliases onPress so this can be passed to
84
+ * router's Link components' `Component` or `as` props but this needs testing
85
+ * as part of https://github.com/telus/universal-design-system/issues/24
86
+ *
87
+ * - Doesn't work inline e.g. in paragraphs. Support for inline links in native and
88
+ * web was implemented in https://github.com/telus/universal-design-system/pull/233
89
+ * but removed and will need to be restored at some point. When inline link support
90
+ * is restored, icons in inline links on Android will be slightly off-centre
91
+ * vertically (see )
92
+ *
93
+ * - Doesn't support :visited styles on web. Support for :visited styles was
94
+ * implemented in https://github.com/telus/universal-design-system/pull/234 but
95
+ * dropped in favour of investigating if a full-featured CSS-in-JS package could or
96
+ * should be used more widely (e.g. styled components)
97
+ */
98
+
99
+
100
+ const LinkBase = /*#__PURE__*/forwardRef(({
101
+ href,
102
+ icon,
103
+ iconPosition = icon ? 'left' : undefined,
104
+ iconProps,
105
+ variant,
106
+ tokens = {},
107
+ children,
108
+ accessibilityRole = 'link',
109
+ ...rawRest
110
+ }, ref) => {
111
+ const {
112
+ onPress,
113
+ ...props
114
+ } = clickProps.toPressProps(rawRest);
115
+ const {
116
+ hrefAttrs,
117
+ rest
118
+ } = hrefAttrsProp.bundle(props);
119
+ const selectedProps = selectProps({
120
+ accessibilityRole,
121
+ href,
122
+ onPress: linkProps.handleHref({
123
+ href,
124
+ onPress
125
+ }),
126
+ hrefAttrs,
127
+ ...rest
128
+ });
129
+
130
+ const resolveLinkTokens = pressState => resolvePressableTokens(tokens, pressState, {
131
+ iconPosition
132
+ }); // On web, this makes focus rings wrap only the link, not the entire block
133
+
134
+
135
+ const blockLeftStyle = Platform.OS === 'web' && staticStyles.blockLeft;
136
+ return /*#__PURE__*/_jsx(InlinePressable, { ...selectedProps,
137
+ ref: ref,
138
+ style: linkState => {
139
+ const themeTokens = resolveLinkTokens(linkState);
140
+ const outerBorderStyles = selectOuterBorderStyles(themeTokens);
141
+ const hasIcon = Boolean(icon || themeTokens.icon);
142
+ return [outerBorderStyles, blockLeftStyle, hasIcon && staticStyles.rowContainer];
143
+ },
144
+ children: linkState => {
145
+ const themeTokens = resolveLinkTokens(linkState);
146
+ const textStyles = selectTextStyles(themeTokens);
147
+ const iconTokens = selectIconTokens(themeTokens); // TODO: may need to apply some smarter text inheritance here if inline to avoid native
148
+ // issues like double-application of line heights breaking align-items: baseline
149
+
150
+ const blockTextStyles = selectBlockStyles(themeTokens);
151
+ const IconComponent = icon || themeTokens.icon;
152
+ const {
153
+ iconSpace
154
+ } = themeTokens;
155
+ return /*#__PURE__*/_jsx(IconText, {
156
+ icon: IconComponent,
157
+ iconPosition: iconPosition,
158
+ space: iconSpace,
159
+ iconProps: { ...iconProps,
160
+ tokens: iconTokens
161
+ },
162
+ children: /*#__PURE__*/_jsx(Text, {
163
+ style: [textStyles, blockTextStyles, staticStyles.baseline],
164
+ children: children
165
+ })
166
+ });
167
+ }
168
+ });
169
+ });
170
+ LinkBase.displayName = 'LinkBase';
171
+ LinkBase.propTypes = { ...selectedSystemPropTypes,
172
+ tokens: getTokensPropType('Link'),
173
+ variant: variantProp.propType,
174
+
175
+ /**
176
+ * Optional variant that may be passed down to the link's icon if there is one
177
+ */
178
+ iconProps: PropTypes.exact(iconComponentPropTypes),
179
+
180
+ /**
181
+ * A function component for an SVG icon to render inside the link. Inherits size and color from
182
+ * the link and any Typography the link is nested inside.
183
+ */
184
+ icon: PropTypes.func,
185
+
186
+ /**
187
+ * When `icon` is provided, use `iconPosition` to place the Icon to the left or right side of Link.
188
+ */
189
+ iconPosition: PropTypes.oneOf(['left', 'right']),
190
+
191
+ /**
192
+ * On Web if href is passed, React Native Web maps this object's props to
193
+ * `rel`, `target` and `download` attrs.
194
+ */
195
+ hrefAttrs: PropTypes.shape(hrefAttrsProp.types)
196
+ };
197
+ const staticStyles = StyleSheet.create({
198
+ blockLeft: {
199
+ alignSelf: 'flex-start'
200
+ },
201
+ rowContainer: {
202
+ flexDirection: 'row',
203
+ alignItems: 'center',
204
+ justifyContent: 'flex-start'
205
+ },
206
+ baseline: {
207
+ alignSelf: 'baseline'
208
+ }
209
+ });
210
+ export default withLinkRouter(LinkBase);
@@ -0,0 +1,43 @@
1
+ var _TextButton$propTypes;
2
+
3
+ import React, { forwardRef } from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import { useThemeTokensCallback } from '../ThemeProvider';
6
+ import LinkBase from './LinkBase';
7
+ /**
8
+ * `TextButton` is a button that looks like a Link. It uses the same theming and variants as
9
+ * Link but has the accessibility role of a `Button`. It should be used for actions that
10
+ * take place on the current page, or for navigation within an app.
11
+ */
12
+
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ const TextButton = /*#__PURE__*/forwardRef(({
15
+ onPress,
16
+ children,
17
+ variant,
18
+ tokens,
19
+ // TODO: this may need to use `link` role on Web in the case of being passed both `href` and
20
+ // `onPress` in an omniplatform app that uses React Navigation's useLinkProps for internal nav.
21
+ accessibilityRole = 'button',
22
+ ...linkProps
23
+ }, ref) => {
24
+ const getTokens = useThemeTokensCallback('Link', tokens, variant);
25
+ return /*#__PURE__*/_jsx(LinkBase, {
26
+ onPress: onPress,
27
+ accessibilityRole: accessibilityRole,
28
+ tokens: getTokens,
29
+ ref: ref,
30
+ ...linkProps,
31
+ children: children
32
+ });
33
+ });
34
+ TextButton.displayName = 'TextButton';
35
+ TextButton.propTypes = { ...LinkBase.propTypes,
36
+ onPress: PropTypes.func.isRequired
37
+ }; // Remove incompatible Link prop (if this build includes propTypes)
38
+ // TODO: test if this works with web navigation in omniplatform React Navigation
39
+ // https://github.com/telus/universal-design-system/issues/665
40
+ // eslint-disable-next-line react/forbid-foreign-prop-types
41
+
42
+ if ((_TextButton$propTypes = TextButton.propTypes) !== null && _TextButton$propTypes !== void 0 && _TextButton$propTypes.href) delete TextButton.propTypes.href;
43
+ export default TextButton;
@@ -0,0 +1,5 @@
1
+ import ChevronLink from './ChevronLink';
2
+ import Link from './Link';
3
+ import LinkBase from './LinkBase';
4
+ import TextButton from './TextButton';
5
+ export { ChevronLink, Link, LinkBase, TextButton };
@@ -0,0 +1,55 @@
1
+ import React, { cloneElement, forwardRef, Children } from 'react';
2
+ import View from "react-native-web/dist/exports/View";
3
+ import Platform from "react-native-web/dist/exports/Platform";
4
+ import PropTypes from 'prop-types';
5
+ import { a11yProps, componentPropType, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
6
+ import ListItem from './ListItem';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
9
+ /**
10
+ * An unordered List component has a child a ListItem that
11
+ * allows icon, dividers and customized typography
12
+ */
13
+
14
+ const List = /*#__PURE__*/forwardRef(({
15
+ children,
16
+ showDivider,
17
+ tokens,
18
+ variant,
19
+ ...rest
20
+ }, ref) => {
21
+ const accessibilityRole = Platform.select({
22
+ web: 'list',
23
+ default: 'none'
24
+ });
25
+ const items = Children.map(children, (child, index) => {
26
+ if (child.type.name === ListItem.name) {
27
+ return /*#__PURE__*/cloneElement(child, {
28
+ showDivider,
29
+ isLastItem: index + 1 === Children.count(children),
30
+ tokens,
31
+ variant
32
+ });
33
+ }
34
+
35
+ return child;
36
+ });
37
+ return /*#__PURE__*/_jsx(View, {
38
+ ref: ref,
39
+ accessibilityRole: accessibilityRole,
40
+ ...selectProps(rest),
41
+ children: items
42
+ });
43
+ });
44
+ List.displayName = 'List';
45
+ List.propTypes = { ...selectedSystemPropTypes,
46
+ tokens: getTokensPropType('List'),
47
+ variant: variantProp.propType,
48
+ children: componentPropType('ListItem'),
49
+
50
+ /**
51
+ * In case it is not the last item allow display divider
52
+ */
53
+ showDivider: PropTypes.bool
54
+ };
55
+ export default List;
@@ -0,0 +1,213 @@
1
+ import React, { forwardRef } from 'react';
2
+ import View from "react-native-web/dist/exports/View";
3
+ import Platform from "react-native-web/dist/exports/Platform";
4
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
+ import PropTypes from 'prop-types';
6
+ import { useThemeTokens, applyTextStyles } from '../ThemeProvider';
7
+ import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps, wrapStringsInText } from '../utils';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { Fragment as _Fragment } from "react/jsx-runtime";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
12
+
13
+ const selectBulletStyles = ({
14
+ itemBulletWidth,
15
+ itemBulletHeight,
16
+ itemBulletColor
17
+ }) => ({
18
+ width: itemBulletWidth,
19
+ height: itemBulletHeight,
20
+ borderRadius: itemBulletHeight / 2,
21
+ backgroundColor: itemBulletColor
22
+ });
23
+
24
+ const selectBulletContainerStyles = ({
25
+ itemBulletContainerWidth,
26
+ itemBulletContainerAlign
27
+ }) => ({
28
+ width: itemBulletContainerWidth,
29
+ alignItems: itemBulletContainerAlign,
30
+ justifyContent: itemBulletContainerAlign
31
+ });
32
+
33
+ const selectItemIconTokens = ({
34
+ itemIconSize,
35
+ itemIconColor
36
+ }) => ({
37
+ size: itemIconSize,
38
+ color: itemIconColor
39
+ });
40
+
41
+ const selectCommonIconStyles = ({
42
+ iconMarginTop
43
+ }) => ({
44
+ marginTop: iconMarginTop
45
+ });
46
+
47
+ const selectSideItemContainerStyles = ({
48
+ listGutter
49
+ }) => ({
50
+ marginRight: listGutter
51
+ });
52
+
53
+ const selectItemStyles = ({
54
+ itemFontWeight,
55
+ itemFontSize,
56
+ itemLineHeight,
57
+ itemFontName
58
+ }) => applyTextStyles({
59
+ fontWeight: itemFontWeight,
60
+ fontSize: itemFontSize,
61
+ lineHeight: itemLineHeight,
62
+ fontName: itemFontName
63
+ });
64
+
65
+ const selectItemBlockStyles = ({
66
+ interItemMargin
67
+ }) => ({
68
+ marginBottom: interItemMargin
69
+ });
70
+
71
+ const selectDividerStyles = ({
72
+ dividerColor,
73
+ dividerSize,
74
+ interItemMarginWithDivider
75
+ }) => ({
76
+ borderBottomWidth: dividerSize,
77
+ borderColor: dividerColor,
78
+ marginBottom: interItemMarginWithDivider,
79
+ paddingBottom: interItemMarginWithDivider
80
+ });
81
+ /**
82
+ * ListItem is responsible for rendering icon or a bullet as side item
83
+ */
84
+
85
+
86
+ const ListItem = /*#__PURE__*/forwardRef(({
87
+ tokens,
88
+ variant,
89
+ icon,
90
+ iconColor,
91
+ iconSize,
92
+ showDivider,
93
+ children,
94
+ isLastItem,
95
+ ...rest
96
+ }, ref) => {
97
+ const themeTokens = useThemeTokens('List', tokens, variant);
98
+ const itemStyles = selectItemStyles(themeTokens);
99
+ const itemBlockStyles = selectItemBlockStyles(themeTokens);
100
+ const dividerStyles = selectDividerStyles(themeTokens);
101
+ const itemBulletContainerStyles = selectBulletContainerStyles(themeTokens);
102
+ const itemBulletStyles = selectBulletStyles(themeTokens);
103
+ const iconTokens = selectItemIconTokens(themeTokens);
104
+ const commonIconStyles = selectCommonIconStyles(themeTokens);
105
+ const sideItemContainerStyles = selectSideItemContainerStyles(themeTokens);
106
+ const accessibilityRole = Platform.select({
107
+ web: 'listitem',
108
+ default: 'item'
109
+ });
110
+
111
+ const renderItem = () => /*#__PURE__*/_jsx(View, {
112
+ style: staticStyles.wrap,
113
+ children: wrapStringsInText(children, {
114
+ style: itemStyles
115
+ })
116
+ });
117
+ /**
118
+ * Function responsible returning styling, in case the item is the last shouldn't
119
+ * add extra margin on the bottom, if "showDivider" is true it should add a divider
120
+ * and custom margin and padding, otherwise just adds a margin to the bottom
121
+ */
122
+
123
+
124
+ const getContainerStyle = () => {
125
+ if (isLastItem) {
126
+ return undefined;
127
+ }
128
+
129
+ if (showDivider) {
130
+ return dividerStyles;
131
+ }
132
+
133
+ return itemBlockStyles;
134
+ };
135
+ /**
136
+ * Renders item bullet or Icon in case it's defined
137
+ * in case children are string the icon is centered otherwise
138
+ * it will align itself at start of the container
139
+ */
140
+
141
+
142
+ const renderMarker = () => {
143
+ const IconComponent = icon || /*#__PURE__*/_jsx(_Fragment, {});
144
+
145
+ if (icon) {
146
+ return /*#__PURE__*/_jsx(View, {
147
+ style: [sideItemContainerStyles, commonIconStyles],
148
+ children: /*#__PURE__*/_jsx(IconComponent, {
149
+ size: iconSize || iconTokens.size,
150
+ color: iconColor || iconTokens.color
151
+ })
152
+ });
153
+ }
154
+
155
+ return /*#__PURE__*/_jsx(View, {
156
+ style: [sideItemContainerStyles, itemBulletContainerStyles],
157
+ children: /*#__PURE__*/_jsx(View, {
158
+ style: itemBulletStyles,
159
+ testID: "unordered-item-bullet"
160
+ })
161
+ });
162
+ };
163
+
164
+ return /*#__PURE__*/_jsxs(View, {
165
+ ref: ref,
166
+ style: [staticStyles.itemContainer, getContainerStyle()],
167
+ accessibilityRole: accessibilityRole,
168
+ ...selectProps(rest),
169
+ children: [renderMarker(), renderItem()]
170
+ });
171
+ });
172
+ ListItem.displayName = 'ListItem';
173
+ const staticStyles = StyleSheet.create({
174
+ itemContainer: {
175
+ flexDirection: 'row'
176
+ },
177
+ wrap: {
178
+ flex: 1
179
+ }
180
+ });
181
+ ListItem.propTypes = { ...selectedSystemPropTypes,
182
+ tokens: getTokensPropType('List'),
183
+ variant: variantProp.propType,
184
+ children: PropTypes.node.isRequired,
185
+
186
+ /**
187
+ * Renders side item icon
188
+ */
189
+ icon: PropTypes.func,
190
+
191
+ /**
192
+ * Will set display icon color
193
+ */
194
+ iconColor: PropTypes.string,
195
+
196
+ /**
197
+ * Allow the user define the icon size if not defined the theme's file
198
+ */
199
+ iconSize: PropTypes.number,
200
+
201
+ /**
202
+ * @ignore
203
+ * Defined by parent if it's last item on the list
204
+ */
205
+ isLastItem: PropTypes.bool,
206
+
207
+ /**
208
+ * @ignore
209
+ * In case it is not the last item allow display divider
210
+ */
211
+ showDivider: PropTypes.bool
212
+ };
213
+ export default ListItem;
@@ -0,0 +1,5 @@
1
+ import List from './List';
2
+ import ListItem from './ListItem';
3
+ List.Item = ListItem;
4
+ export { List as ListBase, ListItem };
5
+ export default List;