@telus-uds/components-base 1.1.0 → 1.3.1

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 (432) hide show
  1. package/.turbo/turbo-build.log +8 -0
  2. package/CHANGELOG.json +38 -0
  3. package/CHANGELOG.md +35 -2
  4. package/__fixtures__/Accessible.js +4 -2
  5. package/__fixtures__/Accessible.native.js +5 -2
  6. package/__fixtures__/testTheme.js +9 -0
  7. package/__tests__/ActivityIndicator/ActivityIndicator.test.jsx +35 -0
  8. package/__tests__/ActivityIndicator/__snapshots__/ActivityIndicator.test.jsx.snap +287 -0
  9. package/__tests__/FlexGrid/Col.test.jsx +6 -10
  10. package/__tests__/HorizontalScroll/HorizontalScroll.test.jsx +1 -0
  11. package/__tests__/ToggleSwitch/ToggleSwitch.test.jsx +10 -0
  12. package/__tests__/ToggleSwitch/ToggleSwitchGroup.test.jsx +192 -0
  13. package/__tests__/utils/props.test.js +36 -0
  14. package/__tests__/utils/semantics.test.jsx +1 -10
  15. package/babel.config.js +27 -5
  16. package/component-docs.json +638 -1145
  17. package/generate-component-docs.js +3 -0
  18. package/lib/A11yText/index.js +6 -5
  19. package/lib/ActivityIndicator/Spinner.js +46 -37
  20. package/lib/ActivityIndicator/Spinner.native.js +26 -15
  21. package/lib/ActivityIndicator/index.js +3 -3
  22. package/lib/Box/Box.js +8 -8
  23. package/lib/Button/Button.js +2 -2
  24. package/lib/Button/ButtonBase.js +25 -12
  25. package/lib/Button/ButtonGroup.js +10 -12
  26. package/lib/Button/ButtonLink.js +4 -4
  27. package/lib/Button/propTypes.js +4 -2
  28. package/lib/Card/Card.js +6 -5
  29. package/lib/Card/CardBase.js +6 -9
  30. package/lib/Card/PressableCardBase.js +15 -14
  31. package/lib/Checkbox/Checkbox.js +4 -8
  32. package/lib/Divider/Divider.js +14 -13
  33. package/lib/ExpandCollapse/Control.js +7 -7
  34. package/lib/ExpandCollapse/ExpandCollapse.js +6 -2
  35. package/lib/ExpandCollapse/Panel.js +6 -7
  36. package/lib/Feedback/Feedback.js +6 -5
  37. package/lib/Fieldset/Fieldset.js +1 -3
  38. package/lib/FlexGrid/FlexGrid.js +4 -4
  39. package/lib/FlexGrid/helpers/index.js +1 -4
  40. package/lib/HorizontalScroll/HorizontalScroll.js +5 -6
  41. package/lib/IconButton/IconButton.js +14 -9
  42. package/lib/InputLabel/InputLabel.js +7 -2
  43. package/lib/InputSupports/InputSupports.js +2 -2
  44. package/lib/Link/LinkBase.js +21 -15
  45. package/lib/List/List.js +4 -6
  46. package/lib/List/ListItem.js +6 -2
  47. package/lib/Modal/Modal.js +6 -2
  48. package/lib/Notification/Notification.js +7 -2
  49. package/lib/Pagination/PageButton.js +3 -1
  50. package/lib/Pagination/Pagination.js +22 -5
  51. package/lib/Pagination/SideButton.js +3 -1
  52. package/lib/Progress/Progress.js +5 -4
  53. package/lib/Progress/ProgressBar.js +8 -7
  54. package/lib/Radio/Radio.js +4 -8
  55. package/lib/Radio/RadioButton.js +6 -3
  56. package/lib/Radio/RadioGroup.js +7 -2
  57. package/lib/RadioCard/RadioCard.js +4 -4
  58. package/lib/RadioCard/RadioCardGroup.js +9 -6
  59. package/lib/Search/Search.js +7 -2
  60. package/lib/Select/Select.js +10 -9
  61. package/lib/SideNav/Item.js +7 -7
  62. package/lib/SideNav/SideNav.js +7 -3
  63. package/lib/Skeleton/Skeleton.js +6 -2
  64. package/lib/Spacer/Spacer.js +9 -20
  65. package/lib/StackView/StackView.js +7 -7
  66. package/lib/StackView/StackWrapBox.js +6 -7
  67. package/lib/StackView/StackWrapGap.js +6 -5
  68. package/lib/StackView/getStackedContent.js +1 -1
  69. package/lib/StepTracker/Step.js +7 -3
  70. package/lib/StepTracker/StepTracker.js +7 -7
  71. package/lib/Tabs/Tabs.js +16 -4
  72. package/lib/Tabs/TabsItem.js +18 -11
  73. package/lib/Tags/Tags.js +11 -12
  74. package/lib/TextInput/TextArea.js +13 -14
  75. package/lib/TextInput/TextInput.js +13 -14
  76. package/lib/TextInput/TextInputBase.js +5 -3
  77. package/lib/ThemeProvider/useThemeTokens.js +3 -3
  78. package/lib/ThemeProvider/utils/theme-tokens.js +3 -3
  79. package/lib/ToggleSwitch/ToggleSwitch.js +106 -43
  80. package/lib/ToggleSwitch/ToggleSwitchGroup.js +228 -0
  81. package/lib/ToggleSwitch/index.js +14 -4
  82. package/lib/Tooltip/Tooltip.js +7 -2
  83. package/lib/TooltipButton/TooltipButton.js +7 -2
  84. package/lib/Typography/Typography.js +8 -6
  85. package/lib/index.js +20 -8
  86. package/lib/utils/a11y/semantics.js +4 -3
  87. package/lib/utils/children.js +5 -1
  88. package/lib/utils/index.js +28 -5
  89. package/lib/utils/pressability.js +2 -2
  90. package/lib/utils/props/a11yProps.js +153 -0
  91. package/lib/utils/props/clickProps.js +36 -0
  92. package/lib/utils/props/componentPropType.js +70 -0
  93. package/lib/utils/props/copyPropTypes.js +14 -0
  94. package/lib/utils/props/getPropSelector.js +13 -0
  95. package/lib/utils/props/hrefAttrsProp.js +41 -0
  96. package/lib/utils/props/index.js +158 -0
  97. package/lib/{InputSupports/propTypes.js → utils/props/inputSupportsProps.js} +2 -3
  98. package/lib/utils/props/linkProps.js +64 -0
  99. package/lib/utils/props/paddingProp.js +20 -0
  100. package/lib/utils/props/pressProps.js +57 -0
  101. package/lib/utils/props/rectProp.js +20 -0
  102. package/lib/utils/props/responsiveProps.js +40 -0
  103. package/lib/utils/props/selectSystemProps.js +31 -0
  104. package/lib/utils/props/spacingProps.js +71 -0
  105. package/lib/utils/props/tokens.js +145 -0
  106. package/lib/utils/props/variantProp.js +28 -0
  107. package/lib/utils/props/viewProps.js +34 -0
  108. package/lib/utils/ssr.js +51 -0
  109. package/lib/utils/useResponsiveProp.js +1 -1
  110. package/lib/utils/useSpacingScale.js +4 -4
  111. package/lib/utils/withLinkRouter.js +98 -0
  112. package/lib-module/A11yInfoProvider/index.js +62 -0
  113. package/lib-module/A11yText/index.js +55 -0
  114. package/lib-module/ActivityIndicator/Spinner.js +76 -0
  115. package/lib-module/ActivityIndicator/Spinner.native.js +143 -0
  116. package/lib-module/ActivityIndicator/index.js +40 -0
  117. package/lib-module/ActivityIndicator/shared.js +12 -0
  118. package/lib-module/BaseProvider/index.js +26 -0
  119. package/lib-module/Box/Box.js +243 -0
  120. package/lib-module/Box/index.js +2 -0
  121. package/lib-module/Button/Button.js +25 -0
  122. package/lib-module/Button/ButtonBase.js +254 -0
  123. package/lib-module/Button/ButtonGroup.js +164 -0
  124. package/lib-module/Button/ButtonLink.js +39 -0
  125. package/lib-module/Button/index.js +4 -0
  126. package/lib-module/Button/propTypes.js +36 -0
  127. package/lib-module/Card/Card.js +83 -0
  128. package/lib-module/Card/CardBase.js +62 -0
  129. package/lib-module/Card/PressableCardBase.js +113 -0
  130. package/lib-module/Card/index.js +4 -0
  131. package/lib-module/Checkbox/Checkbox.js +321 -0
  132. package/lib-module/Checkbox/CheckboxGroup.js +218 -0
  133. package/lib-module/Checkbox/CheckboxInput.js +58 -0
  134. package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
  135. package/lib-module/Checkbox/index.js +3 -0
  136. package/lib-module/Divider/Divider.js +123 -0
  137. package/lib-module/Divider/index.js +2 -0
  138. package/lib-module/ExpandCollapse/Accordion.js +15 -0
  139. package/lib-module/ExpandCollapse/Control.js +130 -0
  140. package/lib-module/ExpandCollapse/ExpandCollapse.js +94 -0
  141. package/lib-module/ExpandCollapse/Panel.js +158 -0
  142. package/lib-module/ExpandCollapse/index.js +7 -0
  143. package/lib-module/Feedback/Feedback.js +144 -0
  144. package/lib-module/Feedback/index.js +2 -0
  145. package/lib-module/Fieldset/Fieldset.js +145 -0
  146. package/lib-module/Fieldset/FieldsetContainer.js +29 -0
  147. package/lib-module/Fieldset/FieldsetContainer.native.js +20 -0
  148. package/lib-module/Fieldset/Legend.js +21 -0
  149. package/lib-module/Fieldset/Legend.native.js +28 -0
  150. package/lib-module/Fieldset/cssReset.js +14 -0
  151. package/lib-module/Fieldset/index.js +2 -0
  152. package/lib-module/FlexGrid/Col/Col.js +265 -0
  153. package/lib-module/FlexGrid/Col/index.js +2 -0
  154. package/lib-module/FlexGrid/FlexGrid.js +147 -0
  155. package/lib-module/FlexGrid/Row/Row.js +177 -0
  156. package/lib-module/FlexGrid/Row/index.js +2 -0
  157. package/lib-module/FlexGrid/helpers/index.js +18 -0
  158. package/lib-module/FlexGrid/index.js +2 -0
  159. package/lib-module/FlexGrid/providers/GutterContext.js +3 -0
  160. package/lib-module/HorizontalScroll/HorizontalScroll.js +171 -0
  161. package/lib-module/HorizontalScroll/HorizontalScrollButton.js +102 -0
  162. package/lib-module/HorizontalScroll/ScrollViewEnd.js +47 -0
  163. package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +24 -0
  164. package/lib-module/HorizontalScroll/dictionary.js +11 -0
  165. package/lib-module/HorizontalScroll/index.js +11 -0
  166. package/lib-module/HorizontalScroll/itemPositions.js +106 -0
  167. package/lib-module/Icon/Icon.js +61 -0
  168. package/lib-module/Icon/IconText.js +81 -0
  169. package/lib-module/Icon/index.js +4 -0
  170. package/lib-module/IconButton/IconButton.js +115 -0
  171. package/lib-module/IconButton/index.js +2 -0
  172. package/lib-module/InputLabel/InputLabel.js +131 -0
  173. package/lib-module/InputLabel/LabelContent.js +24 -0
  174. package/lib-module/InputLabel/LabelContent.native.js +16 -0
  175. package/lib-module/InputLabel/index.js +2 -0
  176. package/lib-module/InputSupports/InputSupports.js +88 -0
  177. package/lib-module/InputSupports/index.js +2 -0
  178. package/lib-module/InputSupports/useInputSupports.js +31 -0
  179. package/lib-module/Link/ChevronLink.js +51 -0
  180. package/lib-module/Link/InlinePressable.js +37 -0
  181. package/lib-module/Link/InlinePressable.native.js +85 -0
  182. package/lib-module/Link/Link.js +27 -0
  183. package/lib-module/Link/LinkBase.js +210 -0
  184. package/lib-module/Link/TextButton.js +43 -0
  185. package/lib-module/Link/index.js +5 -0
  186. package/lib-module/List/List.js +55 -0
  187. package/lib-module/List/ListItem.js +213 -0
  188. package/lib-module/List/index.js +5 -0
  189. package/lib-module/Modal/Modal.js +208 -0
  190. package/lib-module/Modal/dictionary.js +9 -0
  191. package/lib-module/Modal/index.js +2 -0
  192. package/lib-module/Notification/Notification.js +196 -0
  193. package/lib-module/Notification/dictionary.js +8 -0
  194. package/lib-module/Notification/index.js +2 -0
  195. package/lib-module/Pagination/PageButton.js +65 -0
  196. package/lib-module/Pagination/Pagination.js +140 -0
  197. package/lib-module/Pagination/SideButton.js +103 -0
  198. package/lib-module/Pagination/dictionary.js +18 -0
  199. package/lib-module/Pagination/index.js +2 -0
  200. package/lib-module/Pagination/usePagination.js +72 -0
  201. package/lib-module/Progress/Progress.js +85 -0
  202. package/lib-module/Progress/ProgressBar.js +134 -0
  203. package/lib-module/Progress/ProgressBarBackground.js +41 -0
  204. package/lib-module/Progress/index.js +4 -0
  205. package/lib-module/Radio/Radio.js +263 -0
  206. package/lib-module/Radio/RadioButton.js +128 -0
  207. package/lib-module/Radio/RadioGroup.js +225 -0
  208. package/lib-module/Radio/RadioInput.js +60 -0
  209. package/lib-module/Radio/RadioInput.native.js +6 -0
  210. package/lib-module/Radio/index.js +3 -0
  211. package/lib-module/RadioCard/RadioCard.js +218 -0
  212. package/lib-module/RadioCard/RadioCardGroup.js +232 -0
  213. package/lib-module/RadioCard/index.js +3 -0
  214. package/lib-module/Search/Search.js +233 -0
  215. package/lib-module/Search/dictionary.js +12 -0
  216. package/lib-module/Search/index.js +2 -0
  217. package/lib-module/Select/Group.js +20 -0
  218. package/lib-module/Select/Group.native.js +14 -0
  219. package/lib-module/Select/Item.js +17 -0
  220. package/lib-module/Select/Item.native.js +9 -0
  221. package/lib-module/Select/Picker.js +67 -0
  222. package/lib-module/Select/Picker.native.js +110 -0
  223. package/lib-module/Select/Select.js +317 -0
  224. package/lib-module/Select/index.js +6 -0
  225. package/lib-module/SideNav/Item.js +139 -0
  226. package/lib-module/SideNav/ItemContent.js +45 -0
  227. package/lib-module/SideNav/ItemsGroup.js +115 -0
  228. package/lib-module/SideNav/SideNav.js +133 -0
  229. package/lib-module/SideNav/index.js +1 -0
  230. package/lib-module/Skeleton/Skeleton.js +117 -0
  231. package/lib-module/Skeleton/index.js +2 -0
  232. package/lib-module/Skeleton/skeleton.constant.js +3 -0
  233. package/lib-module/Skeleton/skeletonWebAnimation.js +18 -0
  234. package/lib-module/Skeleton/useSkeletonNativeAnimation.js +24 -0
  235. package/lib-module/Spacer/Spacer.js +97 -0
  236. package/lib-module/Spacer/index.js +2 -0
  237. package/lib-module/StackView/StackView.js +124 -0
  238. package/lib-module/StackView/StackWrap.js +48 -0
  239. package/lib-module/StackView/StackWrap.native.js +3 -0
  240. package/lib-module/StackView/StackWrapBox.js +114 -0
  241. package/lib-module/StackView/StackWrapGap.js +58 -0
  242. package/lib-module/StackView/common.js +32 -0
  243. package/lib-module/StackView/getStackedContent.js +123 -0
  244. package/lib-module/StackView/index.js +5 -0
  245. package/lib-module/StepTracker/Step.js +229 -0
  246. package/lib-module/StepTracker/StepTracker.js +175 -0
  247. package/lib-module/StepTracker/dictionary.js +10 -0
  248. package/lib-module/StepTracker/index.js +2 -0
  249. package/lib-module/Tabs/Tabs.js +113 -0
  250. package/lib-module/Tabs/TabsItem.js +215 -0
  251. package/lib-module/Tabs/index.js +2 -0
  252. package/lib-module/Tags/Tags.js +238 -0
  253. package/lib-module/Tags/index.js +2 -0
  254. package/lib-module/TextInput/TextArea.js +88 -0
  255. package/lib-module/TextInput/TextInput.js +60 -0
  256. package/lib-module/TextInput/TextInputBase.js +233 -0
  257. package/lib-module/TextInput/index.js +3 -0
  258. package/lib-module/TextInput/propTypes.js +31 -0
  259. package/lib-module/ThemeProvider/ThemeProvider.js +35 -0
  260. package/lib-module/ThemeProvider/index.js +6 -0
  261. package/lib-module/ThemeProvider/useSetTheme.js +22 -0
  262. package/lib-module/ThemeProvider/useTheme.js +14 -0
  263. package/lib-module/ThemeProvider/useThemeTokens.js +105 -0
  264. package/lib-module/ThemeProvider/utils/index.js +2 -0
  265. package/lib-module/ThemeProvider/utils/styles.js +174 -0
  266. package/lib-module/ThemeProvider/utils/theme-tokens.js +151 -0
  267. package/lib-module/ToggleSwitch/ToggleSwitch.js +224 -0
  268. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +202 -0
  269. package/lib-module/ToggleSwitch/index.js +3 -0
  270. package/lib-module/Tooltip/Backdrop.js +52 -0
  271. package/lib-module/Tooltip/Backdrop.native.js +43 -0
  272. package/lib-module/Tooltip/Tooltip.js +332 -0
  273. package/lib-module/Tooltip/dictionary.js +8 -0
  274. package/lib-module/Tooltip/getTooltipPosition.js +164 -0
  275. package/lib-module/Tooltip/index.js +2 -0
  276. package/lib-module/TooltipButton/TooltipButton.js +71 -0
  277. package/lib-module/TooltipButton/index.js +2 -0
  278. package/lib-module/Typography/Typography.js +118 -0
  279. package/lib-module/Typography/index.js +2 -0
  280. package/lib-module/ViewportProvider/ViewportProvider.js +28 -0
  281. package/lib-module/ViewportProvider/index.js +3 -0
  282. package/lib-module/ViewportProvider/useViewport.js +3 -0
  283. package/lib-module/ViewportProvider/useViewportListener.js +43 -0
  284. package/lib-module/index.js +48 -0
  285. package/lib-module/utils/a11y/index.js +2 -0
  286. package/lib-module/utils/a11y/semantics.js +154 -0
  287. package/lib-module/utils/a11y/textSize.js +34 -0
  288. package/lib-module/utils/animation/index.js +2 -0
  289. package/lib-module/utils/animation/useVerticalExpandAnimation.js +49 -0
  290. package/lib-module/utils/children.js +118 -0
  291. package/lib-module/utils/index.js +15 -0
  292. package/lib-module/utils/info/index.js +7 -0
  293. package/lib-module/utils/info/platform/index.js +11 -0
  294. package/lib-module/utils/info/platform/platform.android.js +1 -0
  295. package/lib-module/utils/info/platform/platform.ios.js +1 -0
  296. package/lib-module/utils/info/platform/platform.js +1 -0
  297. package/lib-module/utils/info/platform/platform.native.js +4 -0
  298. package/lib-module/utils/info/versions.js +5 -0
  299. package/lib-module/utils/input.js +180 -0
  300. package/lib-module/utils/pressability.js +97 -0
  301. package/lib-module/utils/props/a11yProps.js +140 -0
  302. package/lib-module/utils/props/clickProps.js +25 -0
  303. package/lib-module/utils/props/componentPropType.js +63 -0
  304. package/lib-module/utils/props/copyPropTypes.js +2 -0
  305. package/lib-module/utils/props/getPropSelector.js +6 -0
  306. package/lib-module/utils/props/hrefAttrsProp.js +30 -0
  307. package/lib-module/utils/props/index.js +16 -0
  308. package/lib-module/utils/props/inputSupportsProps.js +54 -0
  309. package/lib-module/utils/props/linkProps.js +47 -0
  310. package/lib-module/utils/props/paddingProp.js +9 -0
  311. package/lib-module/utils/props/pressProps.js +42 -0
  312. package/lib-module/utils/props/rectProp.js +9 -0
  313. package/lib-module/utils/props/responsiveProps.js +30 -0
  314. package/lib-module/utils/props/selectSystemProps.js +24 -0
  315. package/lib-module/utils/props/spacingProps.js +56 -0
  316. package/lib-module/utils/props/tokens.js +120 -0
  317. package/lib-module/utils/props/variantProp.js +18 -0
  318. package/lib-module/utils/props/viewProps.js +22 -0
  319. package/lib-module/utils/ssr.js +35 -0
  320. package/lib-module/utils/useCopy.js +42 -0
  321. package/lib-module/utils/useHash.js +44 -0
  322. package/lib-module/utils/useHash.native.js +7 -0
  323. package/lib-module/utils/useResponsiveProp.js +47 -0
  324. package/lib-module/utils/useSpacingScale.js +123 -0
  325. package/lib-module/utils/useUniqueId.js +12 -0
  326. package/lib-module/utils/withLinkRouter.js +82 -0
  327. package/package.json +9 -5
  328. package/src/A11yText/index.jsx +7 -3
  329. package/src/ActivityIndicator/Spinner.jsx +56 -44
  330. package/src/ActivityIndicator/Spinner.native.jsx +20 -12
  331. package/src/ActivityIndicator/index.jsx +1 -1
  332. package/src/Box/Box.jsx +15 -13
  333. package/src/Button/Button.jsx +1 -1
  334. package/src/Button/ButtonBase.jsx +20 -12
  335. package/src/Button/ButtonGroup.jsx +17 -8
  336. package/src/Button/ButtonLink.jsx +1 -1
  337. package/src/Button/propTypes.js +2 -1
  338. package/src/Card/Card.jsx +7 -4
  339. package/src/Card/CardBase.jsx +6 -5
  340. package/src/Card/PressableCardBase.jsx +16 -14
  341. package/src/Checkbox/Checkbox.jsx +12 -7
  342. package/src/Divider/Divider.jsx +19 -12
  343. package/src/ExpandCollapse/Control.jsx +12 -7
  344. package/src/ExpandCollapse/ExpandCollapse.jsx +13 -3
  345. package/src/ExpandCollapse/Panel.jsx +15 -5
  346. package/src/Feedback/Feedback.jsx +13 -3
  347. package/src/Fieldset/Fieldset.jsx +1 -1
  348. package/src/FlexGrid/FlexGrid.jsx +11 -5
  349. package/src/FlexGrid/helpers/index.js +1 -3
  350. package/src/HorizontalScroll/HorizontalScroll.jsx +12 -5
  351. package/src/IconButton/IconButton.jsx +18 -12
  352. package/src/InputLabel/InputLabel.jsx +16 -2
  353. package/src/InputSupports/InputSupports.jsx +1 -1
  354. package/src/Link/LinkBase.jsx +15 -12
  355. package/src/List/List.jsx +12 -5
  356. package/src/List/ListItem.jsx +16 -2
  357. package/src/Modal/Modal.jsx +63 -50
  358. package/src/Notification/Notification.jsx +17 -3
  359. package/src/Pagination/PageButton.jsx +3 -2
  360. package/src/Pagination/Pagination.jsx +38 -4
  361. package/src/Pagination/SideButton.jsx +2 -2
  362. package/src/Progress/Progress.jsx +5 -3
  363. package/src/Progress/ProgressBar.jsx +8 -6
  364. package/src/Radio/Radio.jsx +13 -7
  365. package/src/Radio/RadioButton.jsx +13 -3
  366. package/src/Radio/RadioGroup.jsx +14 -2
  367. package/src/RadioCard/RadioCard.jsx +9 -6
  368. package/src/RadioCard/RadioCardGroup.jsx +16 -4
  369. package/src/Search/Search.jsx +15 -3
  370. package/src/Select/Select.jsx +21 -7
  371. package/src/SideNav/Item.jsx +15 -7
  372. package/src/SideNav/SideNav.jsx +13 -2
  373. package/src/Skeleton/Skeleton.jsx +55 -43
  374. package/src/Spacer/Spacer.jsx +10 -18
  375. package/src/StackView/StackView.jsx +13 -12
  376. package/src/StackView/StackWrapBox.jsx +12 -12
  377. package/src/StackView/StackWrapGap.jsx +9 -7
  378. package/src/StackView/getStackedContent.jsx +1 -1
  379. package/src/StepTracker/Step.jsx +7 -4
  380. package/src/StepTracker/StepTracker.jsx +8 -8
  381. package/src/Tabs/Tabs.jsx +63 -23
  382. package/src/Tabs/TabsItem.jsx +22 -14
  383. package/src/Tags/Tags.jsx +16 -7
  384. package/src/TextInput/TextArea.jsx +20 -8
  385. package/src/TextInput/TextInput.jsx +20 -8
  386. package/src/TextInput/TextInputBase.jsx +13 -3
  387. package/src/ThemeProvider/useThemeTokens.js +3 -3
  388. package/src/ThemeProvider/utils/theme-tokens.js +3 -3
  389. package/src/ToggleSwitch/ToggleSwitch.jsx +104 -41
  390. package/src/ToggleSwitch/ToggleSwitchGroup.jsx +211 -0
  391. package/src/ToggleSwitch/index.js +2 -1
  392. package/src/Tooltip/Tooltip.jsx +13 -3
  393. package/src/TooltipButton/TooltipButton.jsx +6 -4
  394. package/src/Typography/Typography.jsx +10 -6
  395. package/src/index.js +2 -2
  396. package/src/utils/a11y/semantics.js +3 -2
  397. package/src/utils/children.jsx +2 -1
  398. package/src/utils/index.js +3 -1
  399. package/src/utils/pressability.js +1 -1
  400. package/src/utils/props/a11yProps.js +151 -0
  401. package/src/utils/props/clickProps.js +31 -0
  402. package/src/utils/props/componentPropType.js +67 -0
  403. package/src/utils/props/copyPropTypes.js +3 -0
  404. package/src/utils/props/getPropSelector.js +14 -0
  405. package/src/utils/props/hrefAttrsProp.js +25 -0
  406. package/src/utils/props/index.js +16 -0
  407. package/src/{InputSupports/propTypes.js → utils/props/inputSupportsProps.js} +2 -4
  408. package/src/utils/props/linkProps.js +43 -0
  409. package/src/utils/props/paddingProp.js +10 -0
  410. package/src/utils/props/pressProps.js +45 -0
  411. package/src/utils/props/rectProp.js +10 -0
  412. package/src/utils/props/responsiveProps.js +30 -0
  413. package/src/utils/props/selectSystemProps.js +25 -0
  414. package/src/utils/props/spacingProps.js +58 -0
  415. package/src/utils/props/tokens.js +150 -0
  416. package/src/utils/props/variantProp.js +20 -0
  417. package/src/utils/props/viewProps.js +23 -0
  418. package/src/utils/ssr.js +35 -0
  419. package/src/utils/useResponsiveProp.js +1 -1
  420. package/src/utils/useSpacingScale.js +4 -4
  421. package/src/utils/withLinkRouter.jsx +68 -0
  422. package/stories/TextInput/TextArea.stories.jsx +1 -0
  423. package/stories/ToggleSwitch/ToggleSwitch.stories.jsx +5 -1
  424. package/stories/ToggleSwitch/ToggleSwitchGroup.stories.jsx +81 -0
  425. package/.ultra.cache.json +0 -1
  426. package/lib/utils/a11y/propTypes.js +0 -61
  427. package/lib/utils/a11y/propTypes.native.js +0 -47
  428. package/lib/utils/propTypes.js +0 -541
  429. package/release-context.json +0 -7
  430. package/src/utils/a11y/propTypes.js +0 -61
  431. package/src/utils/a11y/propTypes.native.js +0 -39
  432. package/src/utils/propTypes.js +0 -531
@@ -0,0 +1,238 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import ABBPropTypes from 'airbnb-prop-types';
4
+ import Platform from "react-native-web/dist/exports/Platform";
5
+ import Text from "react-native-web/dist/exports/Text";
6
+ import View from "react-native-web/dist/exports/View";
7
+ import ButtonBase from '../Button/ButtonBase';
8
+ import Icon from '../Icon';
9
+ import { StackWrap, getStackedContent } from '../StackView';
10
+ import { useViewport } from '../ViewportProvider';
11
+ import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider';
12
+ import { a11yProps, getTokensPropType, pressProps, selectSystemProps, selectTokens, variantProp, viewProps } from '../utils/props';
13
+ import { useMultipleInputValues } from '../utils/input';
14
+ import { getPressHandlersWithArgs } from '../utils/pressability';
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, pressProps, viewProps]);
17
+
18
+ const selectIconTextTokens = ({
19
+ icon,
20
+ iconPosition,
21
+ iconSpace,
22
+ iconSize,
23
+ iconColor,
24
+ iconBackground,
25
+ iconBorderRadius,
26
+ iconAlignSelf,
27
+ iconPadding,
28
+ iconTranslateX,
29
+ iconTranslateY
30
+ }) => ({
31
+ icon,
32
+ iconPosition,
33
+ iconSpace,
34
+ iconWrapperStyle: {
35
+ backgroundColor: iconBackground,
36
+ borderRadius: iconBorderRadius,
37
+ alignSelf: iconAlignSelf,
38
+ padding: iconPadding,
39
+ ...Platform.select({
40
+ // TODO: https://github.com/telus/universal-design-system/issues/487
41
+ web: {
42
+ transition: 'color 200ms, background 200ms'
43
+ }
44
+ })
45
+ },
46
+ iconTokens: {
47
+ size: iconSize,
48
+ color: iconColor,
49
+ translateX: iconTranslateX,
50
+ translateY: iconTranslateY
51
+ }
52
+ });
53
+
54
+ const Tags = /*#__PURE__*/forwardRef(({
55
+ variant,
56
+ tokens,
57
+ items = [],
58
+ values,
59
+ initialValues,
60
+ maxValues,
61
+ onChange,
62
+ readOnly = false,
63
+ inactive = false,
64
+ accessibilityRole = Platform.select({
65
+ web: 'group',
66
+ default: 'none'
67
+ }),
68
+ ...rest
69
+ }, ref) => {
70
+ const viewport = useViewport();
71
+ const themeTokens = useThemeTokens('Tags', tokens, variant, {
72
+ viewport
73
+ });
74
+ const stackTokens = selectTokens('StackView', themeTokens);
75
+ const {
76
+ direction,
77
+ space
78
+ } = themeTokens;
79
+ const getItemTokens = useThemeTokensCallback('TagsItem', tokens, variant);
80
+
81
+ const getButtonTokens = buttonState => selectTokens('Button', getItemTokens(buttonState));
82
+
83
+ const {
84
+ currentValues,
85
+ toggleOneValue
86
+ } = useMultipleInputValues({
87
+ initialValues,
88
+ values,
89
+ maxValues,
90
+ onChange,
91
+ readOnly
92
+ });
93
+ const selectedProps = selectProps({
94
+ accessibilityRole,
95
+ ...rest
96
+ });
97
+ const itemA11yRole = 'checkbox';
98
+ return /*#__PURE__*/_jsx(StackWrap, {
99
+ ref: ref,
100
+ ...selectedProps,
101
+ space: space,
102
+ direction: direction,
103
+ tokens: stackTokens,
104
+ children: items.map(({
105
+ label,
106
+ id = label,
107
+ accessibilityLabel,
108
+ ref: itemRef
109
+ }, index) => {
110
+ const isSelected = currentValues.includes(id); // Pass an object of relevant component state as first argument for any passed-in press handlers
111
+
112
+ const pressHandlers = getPressHandlersWithArgs(rest, [{
113
+ id,
114
+ label,
115
+ currentValues
116
+ }]);
117
+
118
+ const handlePress = event => {
119
+ if (pressHandlers.onPress) pressHandlers.onPress();
120
+ toggleOneValue(id, event);
121
+ };
122
+
123
+ const itemA11y = {
124
+ accessibilityState: {
125
+ checked: isSelected
126
+ },
127
+ accessibilityRole: itemA11yRole,
128
+ accessibilityLabel,
129
+ ...a11yProps.getPositionInSet(items.length, index)
130
+ };
131
+ return /*#__PURE__*/_jsx(ButtonBase, {
132
+ ref: itemRef,
133
+ ...pressHandlers,
134
+ onPress: handlePress,
135
+ tokens: getButtonTokens,
136
+ selected: isSelected,
137
+ inactive: inactive,
138
+ ...itemA11y,
139
+ children: ({
140
+ textStyles,
141
+ ...buttonState
142
+ }) => {
143
+ // TODO: once Icon/IconButton designs are stable, see if this sort of styling around
144
+ // an icon should go in Icon itself, or possibly via an IconText token set. Related issues:
145
+ // - Icon: https://github.com/telus/universal-design-system/issues/327
146
+ // - IconButton: https://github.com/telus/universal-design-system/issues/281
147
+ // - Token sets: https://github.com/telus/universal-design-system/issues/782
148
+ const itemTokens = getItemTokens(buttonState);
149
+ const {
150
+ iconTokens,
151
+ iconPosition,
152
+ iconSpace,
153
+ iconWrapperStyle,
154
+ icon: IconComponent
155
+ } = selectIconTextTokens(itemTokens);
156
+ const iconContent = IconComponent ? /*#__PURE__*/_jsx(View, {
157
+ style: iconWrapperStyle,
158
+ children: /*#__PURE__*/_jsx(Icon, {
159
+ icon: IconComponent,
160
+ tokens: iconTokens
161
+ })
162
+ }) : null;
163
+
164
+ const textContent = /*#__PURE__*/_jsx(Text, {
165
+ style: textStyles,
166
+ children: label
167
+ });
168
+
169
+ return getStackedContent(iconPosition === 'left' ? [iconContent, textContent] : [textContent, iconContent], {
170
+ space: iconSpace,
171
+ direction: 'row'
172
+ });
173
+ }
174
+ }, id);
175
+ })
176
+ });
177
+ });
178
+ Tags.displayName = 'Tags';
179
+ Tags.propTypes = { ...selectedSystemPropTypes,
180
+ tokens: getTokensPropType('Tags'),
181
+ variant: variantProp.propType,
182
+
183
+ /**
184
+ * If provided, sets a maximum number of items a user may select at once.
185
+ */
186
+ maxValues: PropTypes.number,
187
+
188
+ /**
189
+ * The options a user may select
190
+ */
191
+ items: PropTypes.arrayOf(PropTypes.shape({
192
+ /**
193
+ * The text displayed to the user in the button, describing this option,
194
+ * passed to the button as its child.
195
+ */
196
+ label: PropTypes.string.isRequired,
197
+
198
+ /**
199
+ * An optional accessibility label may be passed to ButtonGroup Buttons
200
+ * which is applied as normal for a React Native accessibilityLabel prop.
201
+ */
202
+ accessibilityLabel: PropTypes.string,
203
+
204
+ /**
205
+ * An optional unique string may be provided to identify this option,
206
+ * which will be used in code and passed to any onChange function.
207
+ * If not provided, the label is used.
208
+ */
209
+ id: PropTypes.string,
210
+
211
+ /**
212
+ * An optional ref for one individual Tag button in the tags
213
+ */
214
+ ref: ABBPropTypes.ref()
215
+ })),
216
+
217
+ /**
218
+ * If provided, this function is called when the current selection is changed
219
+ * and is passed an array of the `id`s of all currently selected `items`.
220
+ */
221
+ onChange: PropTypes.func,
222
+
223
+ /**
224
+ * If the selected item(s) in the button group are to be controlled externally by
225
+ * a parent component, pass an array of strings as well as an `onChange` handler.
226
+ * Passing an array for "values" makes the ButtonGroup a "controlled" component that
227
+ * expects its state to be handled via `onChange` and so doesn't handle it itself.
228
+ */
229
+ values: PropTypes.arrayOf(PropTypes.string),
230
+
231
+ /**
232
+ * If `values` is not passed, making the ButtonGroup an "uncontrolled" component
233
+ * managing its own selected state, a default set of selections may be provided.
234
+ * Changing the `initialValues` does not change the user's selections.
235
+ */
236
+ initialValues: PropTypes.arrayOf(PropTypes.string)
237
+ };
238
+ export default Tags;
@@ -0,0 +1,2 @@
1
+ import Tags from './Tags';
2
+ export default Tags;
@@ -0,0 +1,88 @@
1
+ import React, { forwardRef, useState } from 'react';
2
+ import Platform from "react-native-web/dist/exports/Platform";
3
+ import { a11yProps, getTokensPropType, inputSupportsProps, selectSystemProps, variantProp, viewProps } from '../utils';
4
+ import InputSupports from '../InputSupports';
5
+ import TextInputBase from './TextInputBase';
6
+ import { useThemeTokens } from '../ThemeProvider';
7
+ import textInputPropTypes from './propTypes';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, inputSupportsProps, viewProps]);
10
+ /**
11
+ * Use to collect long-form information such as product feedback or support queries.
12
+ * Due to React Native's implementation of `TextInput` it's not possible to access the current value by passing a ref.
13
+ * The `TextArea` height will automatically increase when new lines are added - this behavior can be limited within the theme.
14
+ *
15
+ * ## Controlled component
16
+ * If it is required that the state of the `TextArea` be controlled by the application or other external methods,
17
+ * `value` and `onChange` props must be passed to the `TextArea`.
18
+ * If the `TextArea` value should not be changed by user input, a `readOnly` prop must be provided.
19
+ *
20
+ * ## Uncontrolled component
21
+ * If it is not necessary to control the `TextArea` state, you can create one without a value prop.
22
+ * In this case its value can be accessed within the `onChange` callback.
23
+ *
24
+ * ## Getting feedback for entered values
25
+ * Use the `feedback` prop to give the user feedback regarding their input.
26
+ * You can affirm that the user's input was correct, or highlight errors that must be corrected, using the `validation` prop.
27
+ * Keep feedback text as brief as possible, should be limited to text and links.
28
+ *
29
+ * ## Supplying a hint
30
+ * Use the `hint` prop to succinctly clarify attributes of the expected input data, such as the expected format,
31
+ * or an indicator that the field is optional.
32
+ * It is a more usable and accessible option than the HTML `placeholder` attribute.
33
+ */
34
+
35
+ const TextArea = /*#__PURE__*/forwardRef(({
36
+ tokens,
37
+ variant = {},
38
+ ...rest
39
+ }, ref) => {
40
+ const themeTokens = useThemeTokens('TextArea', tokens, variant);
41
+ const [inputHeight, setInputHeight] = useState(); // adjust the text area's height as new lines are added to the content
42
+
43
+ const onHeightChange = ({
44
+ nativeEvent: {
45
+ contentSize: {
46
+ height
47
+ }
48
+ }
49
+ }) => {
50
+ // on native this is happens out of the box
51
+ if (Platform.OS === 'web') {
52
+ setInputHeight(height);
53
+ }
54
+ };
55
+
56
+ const {
57
+ props: supportsProps,
58
+ ...selectedProps
59
+ } = selectProps(rest);
60
+ const inputProps = { ...selectedProps,
61
+ variant: { ...variant,
62
+ validation: supportsProps.validation
63
+ },
64
+ multiline: true,
65
+ onContentSizeChange: onHeightChange,
66
+ height: inputHeight,
67
+ tokens: themeTokens
68
+ };
69
+ return /*#__PURE__*/_jsx(InputSupports, { ...supportsProps,
70
+ children: ({
71
+ inputId,
72
+ ...props
73
+ }) => /*#__PURE__*/_jsx(TextInputBase, {
74
+ ref: ref,
75
+ ...inputProps,
76
+ nativeID: inputId,
77
+ ...props
78
+ })
79
+ });
80
+ });
81
+ TextArea.displayName = 'TextArea';
82
+ TextArea.propTypes = { ...selectedSystemPropTypes,
83
+ ...textInputPropTypes,
84
+ tokens: getTokensPropType('TextArea', 'TextInput'),
85
+ // TODO: support both TextArea and TextInput tokens
86
+ variant: variantProp.propType
87
+ };
88
+ export default TextArea;
@@ -0,0 +1,60 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { a11yProps, getTokensPropType, inputSupportsProps, selectSystemProps, variantProp, viewProps } from '../utils';
3
+ import InputSupports from '../InputSupports';
4
+ import TextInputBase from './TextInputBase';
5
+ import textInputPropTypes from './propTypes';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, inputSupportsProps, viewProps]);
8
+ /**
9
+ * A basic text input component. Use in forms or individually to receive user's input.
10
+ * Due to React Native's implementation of `TextInput` it's not possible to access the current value by passing a ref.
11
+ *
12
+ * ## Controlled component
13
+ * If it is required that the state of the `TextInput` be controlled by the application or other external methods,
14
+ * `value` and `onChange` props must be passed to the `TextInput`.
15
+ * If the `TextInput` value should not be changed by user input, a `readOnly` prop must be provided.
16
+ *
17
+ * ## Uncontrolled component
18
+ * If it is not necessary to control the `TextInput` state, you can create one without a value prop.
19
+ * In this case its value can be accessed within the `onChange` callback.
20
+ *
21
+ * NOTE: In order to support more advanced usages all additional props will be passed down to the React Native's
22
+ * `TextInput` component. See <a href="https://reactnative.dev/docs/textinput" target="_blank">React Native documentation</a> for
23
+ * supported props and <a href="https://reactnative.dev/docs/textinput" target="_blank">React Native Web documentation</a> for
24
+ * their implementation on the web.
25
+ */
26
+
27
+ const TextInput = /*#__PURE__*/forwardRef(({
28
+ tokens,
29
+ variant = {},
30
+ ...rest
31
+ }, ref) => {
32
+ const {
33
+ props: supportsProps,
34
+ ...selectedProps
35
+ } = selectProps(rest);
36
+ const inputProps = { ...selectedProps,
37
+ tokens,
38
+ variant: { ...variant,
39
+ validation: supportsProps.validation
40
+ }
41
+ };
42
+ return /*#__PURE__*/_jsx(InputSupports, { ...supportsProps,
43
+ children: ({
44
+ inputId,
45
+ ...props
46
+ }) => /*#__PURE__*/_jsx(TextInputBase, {
47
+ ref: ref,
48
+ ...inputProps,
49
+ nativeID: inputId,
50
+ ...props
51
+ })
52
+ });
53
+ });
54
+ TextInput.displayName = 'TextInput';
55
+ TextInput.propTypes = { ...selectedSystemPropTypes,
56
+ ...textInputPropTypes,
57
+ tokens: getTokensPropType('TextInput'),
58
+ variant: variantProp.propType
59
+ };
60
+ export default TextInput;
@@ -0,0 +1,233 @@
1
+ import React, { forwardRef, useState } from 'react';
2
+ import Platform from "react-native-web/dist/exports/Platform";
3
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
4
+ import NativeTextInput from "react-native-web/dist/exports/TextInput";
5
+ import View from "react-native-web/dist/exports/View";
6
+ import PropTypes from 'prop-types';
7
+ import { applyTextStyles, useThemeTokens, applyOuterBorder } from '../ThemeProvider';
8
+ import { a11yProps, getTokensPropType, selectSystemProps, useInputValue, variantProp, viewProps } from '../utils';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
12
+
13
+ const selectInputStyles = ({
14
+ backgroundColor,
15
+ color,
16
+ borderWidth = 0,
17
+ borderColor,
18
+ borderRadius,
19
+ paddingTop = 0,
20
+ paddingBottom = 0,
21
+ paddingLeft,
22
+ paddingRight = 0,
23
+ fontName,
24
+ fontSize,
25
+ fontWeight,
26
+ lineHeight,
27
+ icon,
28
+ iconSize = 0,
29
+ minLines,
30
+ maxLines,
31
+ width,
32
+ height
33
+ }, inactive) => {
34
+ // Subtract border width from padding so overall input width/height doesn't
35
+ // jump around if the border width changes (avoiding NaN and negative padding)
36
+ const offsetBorder = value => typeof value === 'number' ? Math.max(0, value - borderWidth) : value;
37
+
38
+ const textStyles = applyTextStyles({
39
+ fontName,
40
+ fontSize,
41
+ lineHeight,
42
+ fontWeight
43
+ });
44
+
45
+ function linesToHeight(lines) {
46
+ const {
47
+ lineHeight: absoluteLineHeight
48
+ } = textStyles;
49
+ return lines !== undefined ? lines * absoluteLineHeight + paddingTop + paddingBottom : undefined;
50
+ }
51
+
52
+ const minHeight = linesToHeight(minLines);
53
+ const maxHeight = linesToHeight(maxLines);
54
+ const webStyles = Platform.select({
55
+ web: {
56
+ outline: 'none',
57
+ cursor: inactive ? 'not-allowed' : undefined,
58
+ resize: minHeight !== maxHeight ? 'vertical' : 'none' // does nothing for an input, only needed for textarea
59
+
60
+ }
61
+ });
62
+ const paddingWithIcon = iconSize + paddingRight;
63
+ return {
64
+ backgroundColor,
65
+ color,
66
+ borderWidth,
67
+ borderColor,
68
+ borderRadius,
69
+ paddingLeft: offsetBorder(paddingLeft),
70
+ paddingRight: icon ? offsetBorder(paddingWithIcon) : offsetBorder(paddingRight),
71
+ paddingTop: offsetBorder(paddingTop),
72
+ paddingBottom: offsetBorder(paddingBottom),
73
+ minHeight,
74
+ maxHeight,
75
+ width,
76
+ height,
77
+ ...textStyles,
78
+ ...webStyles
79
+ };
80
+ };
81
+
82
+ const selectOuterBorderStyles = ({
83
+ outerBackgroundColor,
84
+ outerBorderWidth,
85
+ outerBorderColor,
86
+ borderRadius
87
+ }) => ({
88
+ background: outerBackgroundColor,
89
+ ...applyOuterBorder({
90
+ outerBorderColor,
91
+ outerBorderWidth,
92
+ borderRadius
93
+ })
94
+ });
95
+
96
+ const selectIconTokens = ({
97
+ iconSize,
98
+ iconColor
99
+ }) => ({
100
+ size: iconSize,
101
+ color: iconColor
102
+ });
103
+
104
+ const selectIconContainerStyles = ({
105
+ paddingRight,
106
+ paddingBottom
107
+ }) => ({
108
+ paddingRight,
109
+ paddingBottom
110
+ });
111
+
112
+ const TextInputBase = /*#__PURE__*/forwardRef(({
113
+ value,
114
+ height,
115
+ initialValue,
116
+ inactive,
117
+ readOnly,
118
+ onChange,
119
+ onChangeText,
120
+ onFocus,
121
+ onBlur,
122
+ onMouseOver,
123
+ onMouseOut,
124
+ tokens,
125
+ variant = {},
126
+ ...rest
127
+ }, ref) => {
128
+ const [isFocused, setIsFocused] = useState(false);
129
+
130
+ const handleFocus = event => {
131
+ setIsFocused(true);
132
+ if (typeof onFocus === 'function') onFocus(event);
133
+ };
134
+
135
+ const handleBlur = event => {
136
+ setIsFocused(false);
137
+ if (typeof onBlur === 'function') onBlur(event);
138
+ };
139
+
140
+ const [isHovered, setIsHovered] = useState(false);
141
+
142
+ const handleMouseOver = event => {
143
+ setIsHovered(true);
144
+ if (typeof onMouseOver === 'function') onMouseOver(event);
145
+ };
146
+
147
+ const handleMouseOut = event => {
148
+ setIsHovered(false);
149
+ if (typeof onMouseOut === 'function') onMouseOut(event);
150
+ };
151
+
152
+ const {
153
+ currentValue,
154
+ setValue,
155
+ isControlled
156
+ } = useInputValue({
157
+ value,
158
+ initialValue,
159
+ onChange,
160
+ readOnly
161
+ });
162
+
163
+ const handleChangeText = event => {
164
+ var _event$nativeEvent, _event$target;
165
+
166
+ const text = ((_event$nativeEvent = event.nativeEvent) === null || _event$nativeEvent === void 0 ? void 0 : _event$nativeEvent.text) || ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value);
167
+ setValue(text, event);
168
+ if (typeof onChangeText === 'function') onChangeText(text, event);
169
+ };
170
+
171
+ const states = {
172
+ focus: isFocused,
173
+ hover: isHovered,
174
+ inactive
175
+ };
176
+ const themeTokens = useThemeTokens('TextInput', tokens, variant, states);
177
+ const {
178
+ icon: IconComponent
179
+ } = themeTokens;
180
+ const inputProps = { ...selectProps(rest),
181
+ editable: !inactive,
182
+ onFocus: handleFocus,
183
+ onBlur: handleBlur,
184
+ onMouseOver: handleMouseOver,
185
+ onMouseOut: handleMouseOut,
186
+ onChange: handleChangeText,
187
+ defaultValue: initialValue,
188
+ // currentValue is being updated even if the input is not controlled, passing it down to the
189
+ // Input could lead to changing its state from uncontrolled to controlled
190
+ value: isControlled ? currentValue : undefined
191
+ };
192
+ const nativeInputStyle = selectInputStyles({ ...themeTokens,
193
+ height
194
+ }, inactive);
195
+ return /*#__PURE__*/_jsxs(View, {
196
+ style: selectOuterBorderStyles(themeTokens),
197
+ children: [/*#__PURE__*/_jsx(NativeTextInput, {
198
+ ref: ref,
199
+ style: nativeInputStyle,
200
+ ...inputProps
201
+ }), IconComponent && /*#__PURE__*/_jsx(View, {
202
+ pointerEvents: "none" // avoid hijacking input press events
203
+ ,
204
+ style: [staticStyles.iconContainer, selectIconContainerStyles(themeTokens)],
205
+ children: /*#__PURE__*/_jsx(IconComponent, { ...selectIconTokens(themeTokens)
206
+ })
207
+ })]
208
+ });
209
+ });
210
+ TextInputBase.displayName = 'TextInputBase';
211
+ TextInputBase.propTypes = { ...selectedSystemPropTypes,
212
+ value: PropTypes.string,
213
+ height: PropTypes.number,
214
+ initialValue: PropTypes.string,
215
+ inactive: PropTypes.bool,
216
+ readOnly: PropTypes.bool,
217
+ onChange: PropTypes.func,
218
+ onChangeText: PropTypes.func,
219
+ onFocus: PropTypes.func,
220
+ onBlur: PropTypes.func,
221
+ onMouseOver: PropTypes.func,
222
+ onMouseOut: PropTypes.func,
223
+ tokens: getTokensPropType('TextInput', 'TextArea'),
224
+ variant: variantProp.propType
225
+ };
226
+ export default TextInputBase;
227
+ const staticStyles = StyleSheet.create({
228
+ iconContainer: {
229
+ position: 'absolute',
230
+ right: 0,
231
+ bottom: 0
232
+ }
233
+ });
@@ -0,0 +1,3 @@
1
+ import TextInput from './TextInput';
2
+ import TextArea from './TextArea';
3
+ export { TextInput, TextArea };
@@ -0,0 +1,31 @@
1
+ import PropTypes from 'prop-types';
2
+ const textInputPropTypes = {
3
+ /**
4
+ * If the input's state is to be controlled by a parent component, use this prop
5
+ * together with the `onChange` to pass down and update the lifted state.
6
+ */
7
+ value: PropTypes.string,
8
+
9
+ /**
10
+ * Use this to set the initial value of an uncontrolled input.
11
+ * Updating `initialValue` will **not** update the actual value.
12
+ */
13
+ initialValue: PropTypes.string,
14
+
15
+ /**
16
+ * Disables all user interactions with the input.
17
+ */
18
+ inactive: PropTypes.bool,
19
+
20
+ /**
21
+ * Makes it impossible to change the input's value.
22
+ */
23
+ readOnly: PropTypes.bool,
24
+
25
+ /**
26
+ * Use to react upon input's value changes. Required when the `value` prop is set.
27
+ * Will receive the input's value as an argument.
28
+ */
29
+ onChange: PropTypes.func
30
+ };
31
+ export default textInputPropTypes;
@@ -0,0 +1,35 @@
1
+ import React, { createContext, useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { validateThemeTokensVersion } from './utils';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ export const uninitialisedError = new Error('Theme context used outside of ThemeProvider');
6
+ export const ThemeContext = /*#__PURE__*/createContext(uninitialisedError);
7
+ export const ThemeSetterContext = /*#__PURE__*/createContext(uninitialisedError);
8
+
9
+ const ThemeProvider = ({
10
+ children,
11
+ defaultTheme
12
+ }) => {
13
+ const [theme, setTheme] = useState(defaultTheme); // Validate the theme tokens version on every render.
14
+ // This will intentionally break the application when attempting to use an invalid theme.
15
+ // This will surface an incompatibility quickly rather than allowing the potential for strange bugs due to missing or incompatible tokens.
16
+
17
+ validateThemeTokensVersion(theme);
18
+ return /*#__PURE__*/_jsx(ThemeSetterContext.Provider, {
19
+ value: setTheme,
20
+ children: /*#__PURE__*/_jsx(ThemeContext.Provider, {
21
+ value: theme,
22
+ children: children
23
+ })
24
+ });
25
+ };
26
+
27
+ ThemeProvider.propTypes = {
28
+ children: PropTypes.node.isRequired,
29
+ defaultTheme: PropTypes.shape({
30
+ metadata: PropTypes.shape({
31
+ themeTokensVersion: PropTypes.string.isRequired
32
+ }).isRequired
33
+ }).isRequired
34
+ };
35
+ export default ThemeProvider;
@@ -0,0 +1,6 @@
1
+ import ThemeProvider from './ThemeProvider';
2
+ export { default as useTheme } from './useTheme';
3
+ export { default as useSetTheme } from './useSetTheme';
4
+ export * from './useThemeTokens';
5
+ export * from './utils';
6
+ export default ThemeProvider;