@telus-uds/components-base 1.3.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 (342) hide show
  1. package/.turbo/turbo-build.log +5 -2
  2. package/CHANGELOG.json +38 -0
  3. package/CHANGELOG.md +15 -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 +88 -424
  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 -6
  23. package/lib/IconButton/IconButton.js +6 -6
  24. package/lib/InputLabel/InputLabel.js +7 -2
  25. package/lib/InputSupports/InputSupports.js +2 -2
  26. package/lib/Link/LinkBase.js +5 -6
  27. package/lib/List/List.js +4 -6
  28. package/lib/List/ListItem.js +6 -2
  29. package/lib/Modal/Modal.js +6 -2
  30. package/lib/Notification/Notification.js +7 -2
  31. package/lib/Pagination/Pagination.js +8 -3
  32. package/lib/Progress/Progress.js +5 -4
  33. package/lib/Progress/ProgressBar.js +8 -7
  34. package/lib/Radio/Radio.js +4 -6
  35. package/lib/Radio/RadioButton.js +6 -3
  36. package/lib/Radio/RadioGroup.js +7 -2
  37. package/lib/RadioCard/RadioCard.js +4 -4
  38. package/lib/RadioCard/RadioCardGroup.js +9 -6
  39. package/lib/Search/Search.js +7 -2
  40. package/lib/Select/Select.js +10 -9
  41. package/lib/SideNav/Item.js +7 -7
  42. package/lib/SideNav/SideNav.js +7 -3
  43. package/lib/Skeleton/Skeleton.js +6 -2
  44. package/lib/Spacer/Spacer.js +7 -18
  45. package/lib/StackView/StackView.js +7 -7
  46. package/lib/StackView/StackWrapBox.js +6 -7
  47. package/lib/StackView/StackWrapGap.js +6 -5
  48. package/lib/StepTracker/Step.js +7 -3
  49. package/lib/StepTracker/StepTracker.js +7 -7
  50. package/lib/Tabs/Tabs.js +6 -2
  51. package/lib/Tabs/TabsItem.js +6 -5
  52. package/lib/Tags/Tags.js +5 -6
  53. package/lib/TextInput/TextArea.js +13 -14
  54. package/lib/TextInput/TextInput.js +13 -14
  55. package/lib/TextInput/TextInputBase.js +5 -3
  56. package/lib/ToggleSwitch/ToggleSwitch.js +10 -9
  57. package/lib/ToggleSwitch/ToggleSwitchGroup.js +5 -7
  58. package/lib/Tooltip/Tooltip.js +7 -2
  59. package/lib/TooltipButton/TooltipButton.js +7 -2
  60. package/lib/Typography/Typography.js +8 -6
  61. package/lib/index.js +7 -0
  62. package/lib/utils/children.js +5 -1
  63. package/lib/utils/index.js +14 -0
  64. package/lib/utils/props/index.js +9 -0
  65. package/lib/{InputSupports/propTypes.js → utils/props/inputSupportsProps.js} +2 -3
  66. package/lib/utils/ssr.js +51 -0
  67. package/lib-module/A11yInfoProvider/index.js +62 -0
  68. package/lib-module/A11yText/index.js +55 -0
  69. package/lib-module/ActivityIndicator/Spinner.js +76 -0
  70. package/lib-module/ActivityIndicator/Spinner.native.js +143 -0
  71. package/lib-module/ActivityIndicator/index.js +40 -0
  72. package/lib-module/ActivityIndicator/shared.js +12 -0
  73. package/lib-module/BaseProvider/index.js +26 -0
  74. package/lib-module/Box/Box.js +243 -0
  75. package/lib-module/Box/index.js +2 -0
  76. package/lib-module/Button/Button.js +25 -0
  77. package/lib-module/Button/ButtonBase.js +254 -0
  78. package/lib-module/Button/ButtonGroup.js +164 -0
  79. package/lib-module/Button/ButtonLink.js +39 -0
  80. package/lib-module/Button/index.js +4 -0
  81. package/lib-module/Button/propTypes.js +36 -0
  82. package/lib-module/Card/Card.js +83 -0
  83. package/lib-module/Card/CardBase.js +62 -0
  84. package/lib-module/Card/PressableCardBase.js +113 -0
  85. package/lib-module/Card/index.js +4 -0
  86. package/lib-module/Checkbox/Checkbox.js +321 -0
  87. package/lib-module/Checkbox/CheckboxGroup.js +218 -0
  88. package/lib-module/Checkbox/CheckboxInput.js +58 -0
  89. package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
  90. package/lib-module/Checkbox/index.js +3 -0
  91. package/lib-module/Divider/Divider.js +123 -0
  92. package/lib-module/Divider/index.js +2 -0
  93. package/lib-module/ExpandCollapse/Accordion.js +15 -0
  94. package/lib-module/ExpandCollapse/Control.js +130 -0
  95. package/lib-module/ExpandCollapse/ExpandCollapse.js +94 -0
  96. package/lib-module/ExpandCollapse/Panel.js +158 -0
  97. package/lib-module/ExpandCollapse/index.js +7 -0
  98. package/lib-module/Feedback/Feedback.js +144 -0
  99. package/lib-module/Feedback/index.js +2 -0
  100. package/lib-module/Fieldset/Fieldset.js +145 -0
  101. package/lib-module/Fieldset/FieldsetContainer.js +29 -0
  102. package/lib-module/Fieldset/FieldsetContainer.native.js +20 -0
  103. package/lib-module/Fieldset/Legend.js +21 -0
  104. package/lib-module/Fieldset/Legend.native.js +28 -0
  105. package/lib-module/Fieldset/cssReset.js +14 -0
  106. package/lib-module/Fieldset/index.js +2 -0
  107. package/lib-module/FlexGrid/Col/Col.js +265 -0
  108. package/lib-module/FlexGrid/Col/index.js +2 -0
  109. package/lib-module/FlexGrid/FlexGrid.js +147 -0
  110. package/lib-module/FlexGrid/Row/Row.js +177 -0
  111. package/lib-module/FlexGrid/Row/index.js +2 -0
  112. package/lib-module/FlexGrid/helpers/index.js +18 -0
  113. package/lib-module/FlexGrid/index.js +2 -0
  114. package/lib-module/FlexGrid/providers/GutterContext.js +3 -0
  115. package/lib-module/HorizontalScroll/HorizontalScroll.js +171 -0
  116. package/lib-module/HorizontalScroll/HorizontalScrollButton.js +102 -0
  117. package/lib-module/HorizontalScroll/ScrollViewEnd.js +47 -0
  118. package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +24 -0
  119. package/lib-module/HorizontalScroll/dictionary.js +11 -0
  120. package/lib-module/HorizontalScroll/index.js +11 -0
  121. package/lib-module/HorizontalScroll/itemPositions.js +106 -0
  122. package/lib-module/Icon/Icon.js +61 -0
  123. package/lib-module/Icon/IconText.js +81 -0
  124. package/lib-module/Icon/index.js +4 -0
  125. package/lib-module/IconButton/IconButton.js +115 -0
  126. package/lib-module/IconButton/index.js +2 -0
  127. package/lib-module/InputLabel/InputLabel.js +131 -0
  128. package/lib-module/InputLabel/LabelContent.js +24 -0
  129. package/lib-module/InputLabel/LabelContent.native.js +16 -0
  130. package/lib-module/InputLabel/index.js +2 -0
  131. package/lib-module/InputSupports/InputSupports.js +88 -0
  132. package/lib-module/InputSupports/index.js +2 -0
  133. package/lib-module/InputSupports/useInputSupports.js +31 -0
  134. package/lib-module/Link/ChevronLink.js +51 -0
  135. package/lib-module/Link/InlinePressable.js +37 -0
  136. package/lib-module/Link/InlinePressable.native.js +85 -0
  137. package/lib-module/Link/Link.js +27 -0
  138. package/lib-module/Link/LinkBase.js +210 -0
  139. package/lib-module/Link/TextButton.js +43 -0
  140. package/lib-module/Link/index.js +5 -0
  141. package/lib-module/List/List.js +55 -0
  142. package/lib-module/List/ListItem.js +213 -0
  143. package/lib-module/List/index.js +5 -0
  144. package/lib-module/Modal/Modal.js +208 -0
  145. package/lib-module/Modal/dictionary.js +9 -0
  146. package/lib-module/Modal/index.js +2 -0
  147. package/lib-module/Notification/Notification.js +196 -0
  148. package/lib-module/Notification/dictionary.js +8 -0
  149. package/lib-module/Notification/index.js +2 -0
  150. package/lib-module/Pagination/PageButton.js +65 -0
  151. package/lib-module/Pagination/Pagination.js +140 -0
  152. package/lib-module/Pagination/SideButton.js +103 -0
  153. package/lib-module/Pagination/dictionary.js +18 -0
  154. package/lib-module/Pagination/index.js +2 -0
  155. package/lib-module/Pagination/usePagination.js +72 -0
  156. package/lib-module/Progress/Progress.js +85 -0
  157. package/lib-module/Progress/ProgressBar.js +134 -0
  158. package/lib-module/Progress/ProgressBarBackground.js +41 -0
  159. package/lib-module/Progress/index.js +4 -0
  160. package/lib-module/Radio/Radio.js +263 -0
  161. package/lib-module/Radio/RadioButton.js +128 -0
  162. package/lib-module/Radio/RadioGroup.js +225 -0
  163. package/lib-module/Radio/RadioInput.js +60 -0
  164. package/lib-module/Radio/RadioInput.native.js +6 -0
  165. package/lib-module/Radio/index.js +3 -0
  166. package/lib-module/RadioCard/RadioCard.js +218 -0
  167. package/lib-module/RadioCard/RadioCardGroup.js +232 -0
  168. package/lib-module/RadioCard/index.js +3 -0
  169. package/lib-module/Search/Search.js +233 -0
  170. package/lib-module/Search/dictionary.js +12 -0
  171. package/lib-module/Search/index.js +2 -0
  172. package/lib-module/Select/Group.js +20 -0
  173. package/lib-module/Select/Group.native.js +14 -0
  174. package/lib-module/Select/Item.js +17 -0
  175. package/lib-module/Select/Item.native.js +9 -0
  176. package/lib-module/Select/Picker.js +67 -0
  177. package/lib-module/Select/Picker.native.js +110 -0
  178. package/lib-module/Select/Select.js +317 -0
  179. package/lib-module/Select/index.js +6 -0
  180. package/lib-module/SideNav/Item.js +139 -0
  181. package/lib-module/SideNav/ItemContent.js +45 -0
  182. package/lib-module/SideNav/ItemsGroup.js +115 -0
  183. package/lib-module/SideNav/SideNav.js +133 -0
  184. package/lib-module/SideNav/index.js +1 -0
  185. package/lib-module/Skeleton/Skeleton.js +117 -0
  186. package/lib-module/Skeleton/index.js +2 -0
  187. package/lib-module/Skeleton/skeleton.constant.js +3 -0
  188. package/lib-module/Skeleton/skeletonWebAnimation.js +18 -0
  189. package/lib-module/Skeleton/useSkeletonNativeAnimation.js +24 -0
  190. package/lib-module/Spacer/Spacer.js +97 -0
  191. package/lib-module/Spacer/index.js +2 -0
  192. package/lib-module/StackView/StackView.js +124 -0
  193. package/lib-module/StackView/StackWrap.js +48 -0
  194. package/lib-module/StackView/StackWrap.native.js +3 -0
  195. package/lib-module/StackView/StackWrapBox.js +114 -0
  196. package/lib-module/StackView/StackWrapGap.js +58 -0
  197. package/lib-module/StackView/common.js +32 -0
  198. package/lib-module/StackView/getStackedContent.js +123 -0
  199. package/lib-module/StackView/index.js +5 -0
  200. package/lib-module/StepTracker/Step.js +229 -0
  201. package/lib-module/StepTracker/StepTracker.js +175 -0
  202. package/lib-module/StepTracker/dictionary.js +10 -0
  203. package/lib-module/StepTracker/index.js +2 -0
  204. package/lib-module/Tabs/Tabs.js +113 -0
  205. package/lib-module/Tabs/TabsItem.js +215 -0
  206. package/lib-module/Tabs/index.js +2 -0
  207. package/lib-module/Tags/Tags.js +238 -0
  208. package/lib-module/Tags/index.js +2 -0
  209. package/lib-module/TextInput/TextArea.js +88 -0
  210. package/lib-module/TextInput/TextInput.js +60 -0
  211. package/lib-module/TextInput/TextInputBase.js +233 -0
  212. package/lib-module/TextInput/index.js +3 -0
  213. package/lib-module/TextInput/propTypes.js +31 -0
  214. package/lib-module/ThemeProvider/ThemeProvider.js +35 -0
  215. package/lib-module/ThemeProvider/index.js +6 -0
  216. package/lib-module/ThemeProvider/useSetTheme.js +22 -0
  217. package/lib-module/ThemeProvider/useTheme.js +14 -0
  218. package/lib-module/ThemeProvider/useThemeTokens.js +105 -0
  219. package/lib-module/ThemeProvider/utils/index.js +2 -0
  220. package/lib-module/ThemeProvider/utils/styles.js +174 -0
  221. package/lib-module/ThemeProvider/utils/theme-tokens.js +151 -0
  222. package/lib-module/ToggleSwitch/ToggleSwitch.js +224 -0
  223. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +202 -0
  224. package/lib-module/ToggleSwitch/index.js +3 -0
  225. package/lib-module/Tooltip/Backdrop.js +52 -0
  226. package/lib-module/Tooltip/Backdrop.native.js +43 -0
  227. package/lib-module/Tooltip/Tooltip.js +332 -0
  228. package/lib-module/Tooltip/dictionary.js +8 -0
  229. package/lib-module/Tooltip/getTooltipPosition.js +164 -0
  230. package/lib-module/Tooltip/index.js +2 -0
  231. package/lib-module/TooltipButton/TooltipButton.js +71 -0
  232. package/lib-module/TooltipButton/index.js +2 -0
  233. package/lib-module/Typography/Typography.js +118 -0
  234. package/lib-module/Typography/index.js +2 -0
  235. package/lib-module/ViewportProvider/ViewportProvider.js +28 -0
  236. package/lib-module/ViewportProvider/index.js +3 -0
  237. package/lib-module/ViewportProvider/useViewport.js +3 -0
  238. package/lib-module/ViewportProvider/useViewportListener.js +43 -0
  239. package/lib-module/index.js +48 -0
  240. package/lib-module/utils/a11y/index.js +2 -0
  241. package/lib-module/utils/a11y/semantics.js +154 -0
  242. package/lib-module/utils/a11y/textSize.js +34 -0
  243. package/lib-module/utils/animation/index.js +2 -0
  244. package/lib-module/utils/animation/useVerticalExpandAnimation.js +49 -0
  245. package/lib-module/utils/children.js +118 -0
  246. package/lib-module/utils/index.js +15 -0
  247. package/lib-module/utils/info/index.js +7 -0
  248. package/lib-module/utils/info/platform/index.js +11 -0
  249. package/lib-module/utils/info/platform/platform.android.js +1 -0
  250. package/lib-module/utils/info/platform/platform.ios.js +1 -0
  251. package/lib-module/utils/info/platform/platform.js +1 -0
  252. package/lib-module/utils/info/platform/platform.native.js +4 -0
  253. package/lib-module/utils/info/versions.js +5 -0
  254. package/lib-module/utils/input.js +180 -0
  255. package/lib-module/utils/pressability.js +97 -0
  256. package/lib-module/utils/props/a11yProps.js +140 -0
  257. package/lib-module/utils/props/clickProps.js +25 -0
  258. package/lib-module/utils/props/componentPropType.js +63 -0
  259. package/lib-module/utils/props/copyPropTypes.js +2 -0
  260. package/lib-module/utils/props/getPropSelector.js +6 -0
  261. package/lib-module/utils/props/hrefAttrsProp.js +30 -0
  262. package/lib-module/utils/props/index.js +16 -0
  263. package/lib-module/utils/props/inputSupportsProps.js +54 -0
  264. package/lib-module/utils/props/linkProps.js +47 -0
  265. package/lib-module/utils/props/paddingProp.js +9 -0
  266. package/lib-module/utils/props/pressProps.js +42 -0
  267. package/lib-module/utils/props/rectProp.js +9 -0
  268. package/lib-module/utils/props/responsiveProps.js +30 -0
  269. package/lib-module/utils/props/selectSystemProps.js +24 -0
  270. package/lib-module/utils/props/spacingProps.js +56 -0
  271. package/lib-module/utils/props/tokens.js +120 -0
  272. package/lib-module/utils/props/variantProp.js +18 -0
  273. package/lib-module/utils/props/viewProps.js +22 -0
  274. package/lib-module/utils/ssr.js +35 -0
  275. package/lib-module/utils/useCopy.js +42 -0
  276. package/lib-module/utils/useHash.js +44 -0
  277. package/lib-module/utils/useHash.native.js +7 -0
  278. package/lib-module/utils/useResponsiveProp.js +47 -0
  279. package/lib-module/utils/useSpacingScale.js +123 -0
  280. package/lib-module/utils/useUniqueId.js +12 -0
  281. package/lib-module/utils/withLinkRouter.js +82 -0
  282. package/package.json +9 -5
  283. package/src/A11yText/index.jsx +7 -3
  284. package/src/ActivityIndicator/Spinner.jsx +56 -44
  285. package/src/ActivityIndicator/Spinner.native.jsx +20 -12
  286. package/src/Box/Box.jsx +10 -9
  287. package/src/Button/ButtonBase.jsx +9 -8
  288. package/src/Card/Card.jsx +7 -4
  289. package/src/Card/PressableCardBase.jsx +12 -12
  290. package/src/Checkbox/Checkbox.jsx +12 -5
  291. package/src/Divider/Divider.jsx +17 -10
  292. package/src/ExpandCollapse/Control.jsx +12 -7
  293. package/src/ExpandCollapse/ExpandCollapse.jsx +13 -3
  294. package/src/ExpandCollapse/Panel.jsx +15 -5
  295. package/src/Feedback/Feedback.jsx +13 -3
  296. package/src/Fieldset/Fieldset.jsx +1 -1
  297. package/src/HorizontalScroll/HorizontalScroll.jsx +12 -5
  298. package/src/IconButton/IconButton.jsx +12 -8
  299. package/src/InputLabel/InputLabel.jsx +16 -2
  300. package/src/InputSupports/InputSupports.jsx +1 -1
  301. package/src/Link/LinkBase.jsx +10 -9
  302. package/src/List/List.jsx +12 -5
  303. package/src/List/ListItem.jsx +16 -2
  304. package/src/Modal/Modal.jsx +63 -50
  305. package/src/Notification/Notification.jsx +17 -3
  306. package/src/Pagination/Pagination.jsx +10 -3
  307. package/src/Progress/Progress.jsx +5 -3
  308. package/src/Progress/ProgressBar.jsx +8 -6
  309. package/src/Radio/Radio.jsx +13 -5
  310. package/src/Radio/RadioButton.jsx +13 -3
  311. package/src/Radio/RadioGroup.jsx +14 -2
  312. package/src/RadioCard/RadioCard.jsx +9 -6
  313. package/src/RadioCard/RadioCardGroup.jsx +16 -4
  314. package/src/Search/Search.jsx +15 -3
  315. package/src/Select/Select.jsx +21 -7
  316. package/src/SideNav/Item.jsx +15 -7
  317. package/src/SideNav/SideNav.jsx +13 -2
  318. package/src/Skeleton/Skeleton.jsx +55 -43
  319. package/src/Spacer/Spacer.jsx +8 -16
  320. package/src/StackView/StackView.jsx +13 -12
  321. package/src/StackView/StackWrapBox.jsx +12 -12
  322. package/src/StackView/StackWrapGap.jsx +9 -7
  323. package/src/StepTracker/Step.jsx +7 -4
  324. package/src/StepTracker/StepTracker.jsx +8 -8
  325. package/src/Tabs/Tabs.jsx +16 -3
  326. package/src/Tabs/TabsItem.jsx +13 -9
  327. package/src/Tags/Tags.jsx +20 -5
  328. package/src/TextInput/TextArea.jsx +20 -8
  329. package/src/TextInput/TextInput.jsx +20 -8
  330. package/src/TextInput/TextInputBase.jsx +13 -3
  331. package/src/ToggleSwitch/ToggleSwitch.jsx +16 -5
  332. package/src/ToggleSwitch/ToggleSwitchGroup.jsx +14 -6
  333. package/src/Tooltip/Tooltip.jsx +13 -3
  334. package/src/TooltipButton/TooltipButton.jsx +6 -4
  335. package/src/Typography/Typography.jsx +10 -6
  336. package/src/index.js +1 -1
  337. package/src/utils/children.jsx +2 -1
  338. package/src/utils/index.js +1 -0
  339. package/src/utils/props/index.js +1 -0
  340. package/src/{InputSupports/propTypes.js → utils/props/inputSupportsProps.js} +2 -4
  341. package/src/utils/ssr.js +35 -0
  342. package/release-context.json +0 -7
@@ -0,0 +1,218 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
4
+ import Text from "react-native-web/dist/exports/Text";
5
+ import View from "react-native-web/dist/exports/View";
6
+ import { useThemeTokensCallback, applyTextStyles } from '../ThemeProvider';
7
+ import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, useInputValue, useUniqueId, variantProp, viewProps } from '../utils';
8
+ import { PressableCardBase, selectPressableCardTokens } from '../Card';
9
+ import StackView from '../StackView';
10
+ import RadioButton, { selectRadioButtonTokens } from '../Radio/RadioButton';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
14
+ /**
15
+ * A Card that behaves like a radio button. Use when users select a single choice from mutually exclusive options
16
+ * with need to show additional information for each option. The whole card is interactive as one item.
17
+ *
18
+ * ## Component API
19
+ *
20
+ * Use `title` prop to provide a main description, and `children` for additional content. Avoid including
21
+ * interactive elements within the RadioCard content.
22
+ *
23
+ * For a disabled `RadioCard`, set the `inactive` prop to `true`.
24
+ *
25
+ * ### Controlled version
26
+ *
27
+ * If the radio card is controlled from outside, it needs to receive `checked` and `onChange` props.
28
+ *
29
+ * ### Uncontrolled version
30
+ *
31
+ * In case of uncontrolled radio card you can use `defaultChecked` prop to provide the initial value.
32
+ * Whenever the radio card gets toggled, it calls the `onChange` callback with the new value (boolean).
33
+ *
34
+ * ### Using within forms
35
+ *
36
+ * You can pass `name` and `value` props if you need a particular radio card to be a part of a radio group
37
+ * on a form.
38
+ *
39
+ * ### Validation
40
+ *
41
+ * You can mark a radio card as failing validation by setting the `error` prop to `true`.
42
+ *
43
+ * ## A11y guidelines
44
+ *
45
+ * Radio card accepts all the common accessibility props, but also sets some defaults, including
46
+ * accessibility role `'radio'` and accessibility state that depends on the other props (`checked`, `inactive`)
47
+ * or the internal state in case of uncontrolled radio button.
48
+ */
49
+
50
+ const RadioCard = /*#__PURE__*/forwardRef(({
51
+ tokens,
52
+ variant,
53
+ title,
54
+ children,
55
+ inactive,
56
+ defaultChecked,
57
+ checked,
58
+ name: inputName,
59
+ value,
60
+ id,
61
+ onChange,
62
+ ...rest
63
+ }, ref) => {
64
+ const {
65
+ currentValue: isChecked,
66
+ setValue: setIsChecked,
67
+ isControlled
68
+ } = useInputValue({
69
+ value: checked,
70
+ initialValue: defaultChecked,
71
+ onChange
72
+ });
73
+
74
+ const handleChange = event => {
75
+ if (!inactive && !isChecked) {
76
+ setIsChecked(true, event);
77
+ }
78
+ };
79
+
80
+ const uniqueId = useUniqueId('RadioCard');
81
+ const inputId = id ?? uniqueId;
82
+ const getTokens = useThemeTokensCallback('RadioCard', tokens, variant);
83
+
84
+ const getCardTokens = cardState => selectPressableCardTokens(getTokens(cardState));
85
+
86
+ return /*#__PURE__*/_jsx(PressableCardBase, {
87
+ ref: ref,
88
+ inactive: inactive,
89
+ checked: isChecked,
90
+ tokens: getCardTokens,
91
+ onPress: handleChange,
92
+ accessibilityRole: "radio",
93
+ accessibilityState: {
94
+ checked: isChecked,
95
+ disabled: inactive
96
+ },
97
+ ...selectProps(rest),
98
+ children: cardState => {
99
+ const {
100
+ radioSpace,
101
+ contentSpace,
102
+ ...themeTokens
103
+ } = getTokens(cardState);
104
+ const radioTokens = selectRadioButtonTokens(themeTokens, 'radio');
105
+ const titleTokens = selectTokens('Typography', themeTokens);
106
+ const textStyle = applyTextStyles(titleTokens);
107
+ return /*#__PURE__*/_jsxs(StackView, {
108
+ direction: "row",
109
+ space: radioSpace,
110
+ children: [/*#__PURE__*/_jsx(View, {
111
+ style: [staticStyles.alignWithText, {
112
+ height: textStyle.lineHeight
113
+ }],
114
+ children: /*#__PURE__*/_jsx(RadioButton, {
115
+ tokens: radioTokens,
116
+ isControlled: isControlled,
117
+ isChecked: isChecked,
118
+ inactive: inactive,
119
+ defaultChecked: defaultChecked,
120
+ inputId: inputId,
121
+ handleChange: handleChange,
122
+ name: inputName,
123
+ value: value
124
+ })
125
+ }), /*#__PURE__*/_jsxs(StackView, {
126
+ direction: "column",
127
+ space: contentSpace,
128
+ tokens: {
129
+ flexShrink: 1
130
+ },
131
+ children: [title && /*#__PURE__*/_jsx(Text, {
132
+ style: textStyle,
133
+ children: title
134
+ }), typeof children === 'function' ? children(cardState, textStyle) : children]
135
+ })]
136
+ });
137
+ }
138
+ });
139
+ });
140
+ RadioCard.displayName = 'RadioCard';
141
+ RadioCard.propTypes = { ...selectedSystemPropTypes,
142
+
143
+ /**
144
+ * Content to be displayed at the top of the card alongside the radio button
145
+ */
146
+ title: PropTypes.string,
147
+
148
+ /**
149
+ * Additional content to be displayed below the button.
150
+ */
151
+ children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
152
+
153
+ /**
154
+ * Use `checked` for controlled Radio. For uncontrolled Radio, use the `defaultChecked` prop.
155
+ */
156
+ checked: PropTypes.bool,
157
+
158
+ /**
159
+ * Use `defaultChecked` to provide the initial value for an uncontrolled Radio.
160
+ */
161
+ defaultChecked: PropTypes.bool,
162
+
163
+ /**
164
+ * An optional radio button description.
165
+ */
166
+ description: PropTypes.string,
167
+
168
+ /**
169
+ * Radio card button ID.
170
+ */
171
+ id: PropTypes.string,
172
+
173
+ /**
174
+ * Whether the corresponding input is disabled or active.
175
+ */
176
+ inactive: PropTypes.bool,
177
+
178
+ /**
179
+ * The label.
180
+ */
181
+ label: PropTypes.string,
182
+
183
+ /**
184
+ * Associate this radio card with a group (set as the name attribute).
185
+ */
186
+ name: PropTypes.string,
187
+
188
+ /**
189
+ * Whether the underlying input triggered a validation error or not.
190
+ */
191
+ error: PropTypes.bool,
192
+
193
+ /**
194
+ * The value. Must be unique within the group.
195
+ */
196
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
197
+
198
+ /**
199
+ * Callback called when a controlled radio card gets interacted with.
200
+ */
201
+ onChange: PropTypes.func,
202
+
203
+ /**
204
+ * Radio card tokens.
205
+ */
206
+ tokens: getTokensPropType('RadioCard'),
207
+
208
+ /**
209
+ * Radio variant.
210
+ */
211
+ variant: variantProp.propType
212
+ };
213
+ const staticStyles = StyleSheet.create({
214
+ alignWithText: {
215
+ justifyContent: 'center'
216
+ }
217
+ });
218
+ export default RadioCard;
@@ -0,0 +1,232 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useViewport } from '../ViewportProvider';
4
+ import { useThemeTokens } from '../ThemeProvider';
5
+ import { a11yProps, getTokensPropType, selectSystemProps, useInputValue, variantProp, viewProps } from '../utils';
6
+ import StackView, { StackWrap } from '../StackView';
7
+ import RadioCard from './RadioCard';
8
+ import Fieldset from '../Fieldset';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
11
+ /**
12
+ * A group of Cards that behave as a radio button group. Use when users select a single choice from mutually
13
+ * exclusive options with need to show additional information for each option. The whole cards are each
14
+ * interactive as one item.
15
+ *
16
+ * ## Component API
17
+ *
18
+ * Use the `items` prop to pass an array of objects describing each RadioCard in the group:
19
+ *
20
+ * - `title`: main text passed to RadioCard's `title` prop
21
+ * - `content`: React content passed to RadioCard's `children` prop
22
+ * - `id`: identifier used to store which RadioCard is selected (uses `title` if undefinded)
23
+ * - `onChange`: optional function called on selection, in addition to updating the group's selection state
24
+ *
25
+ * ### Controlled version
26
+ *
27
+ * If the selection state is controlled from outside, it needs to receive `checkedId` and `onChange` props.
28
+ *
29
+ * ### Uncontrolled version
30
+ *
31
+ * If the RadioCardGroup manages its own state, you can use `initialCheckedId` prop to provide the initial value.
32
+ * Whenever the radio card gets toggled, it calls the `onChange` callback with the new value (string).
33
+ *
34
+ * ### Use in forms
35
+ *
36
+ * For web forms, the `name` prop may be used to define the name of the group's `fieldset` and input elements.
37
+ *
38
+ * ### Validation
39
+ *
40
+ * Validation state may be set by passing 'error' or 'success' to the `validation` prop.
41
+ *
42
+ * ## A11y guidelines
43
+ *
44
+ * RadioCardGroup accepts all the common accessibility props, but also sets accessibility role `'radiogroup'`
45
+ * and controls the accessibility state of children like RadioCard and Feedback based on current state.
46
+ *
47
+ * @example
48
+ * ```jsx
49
+ * <RadioCardGroup
50
+ * initialCheckedId="card1"
51
+ * items={[
52
+ * { title: 'Card 1', id: 'card1', content: <Typography>More info</Typography> },
53
+ * { title: 'Card 2', id: 'card2', content: <Typography>Extra content</Typography> },
54
+ * { title: 'Card 3', id: 'card3', content: <Typography>More content</Typography> }
55
+ * ]}
56
+ * legend="Cards"
57
+ * hint="Choose a card to select"
58
+ * />
59
+ * ```
60
+ */
61
+
62
+ const RadioCardGroup = /*#__PURE__*/forwardRef(({
63
+ tokens,
64
+ radioCardTokens,
65
+ variant,
66
+ items = [],
67
+ legend,
68
+ tooltip,
69
+ hint,
70
+ validation,
71
+ feedback,
72
+ initialCheckedId,
73
+ checkedId,
74
+ onChange,
75
+ readOnly,
76
+ name: inputGroupName,
77
+ inactive,
78
+ ...rest
79
+ }, ref) => {
80
+ const viewport = useViewport();
81
+ const {
82
+ space,
83
+ fieldSpace,
84
+ direction
85
+ } = useThemeTokens('RadioCardGroup', tokens, variant, {
86
+ viewport
87
+ });
88
+ const {
89
+ currentValue,
90
+ setValue
91
+ } = useInputValue({
92
+ value: checkedId,
93
+ initialValue: initialCheckedId,
94
+ onChange,
95
+ readOnly: readOnly || inactive
96
+ });
97
+ const StackContainer = direction === 'row' ? StackWrap : StackView; // Needs 'radiogroup' role on direct parent of radios for MacOS Voiceover's numbering to work,
98
+ // and also needs 'radiogroup' role on fieldset for correct description on focusing the set.
99
+ // TODO: test this on more web screen readers.
100
+
101
+ return /*#__PURE__*/_jsx(Fieldset, {
102
+ ref: ref,
103
+ name: inputGroupName,
104
+ legend: legend,
105
+ tooltip: tooltip,
106
+ hint: hint,
107
+ space: fieldSpace,
108
+ feedback: feedback,
109
+ inactive: inactive || readOnly,
110
+ validation: validation,
111
+ accessibilityRole: "radiogroup",
112
+ ...selectProps(rest),
113
+ children: props => /*#__PURE__*/_jsx(StackContainer, {
114
+ space: space,
115
+ accessibilityRole: "radiogroup",
116
+ children: items.map(({
117
+ title,
118
+ content,
119
+ id,
120
+ onChange: itemOnChange
121
+ }, index) => {
122
+ const cardId = id || `RadioCard[${index}]`;
123
+
124
+ const handleChange = (newCheckedState, event) => {
125
+ if (typeof itemOnChange === 'function') itemOnChange(newCheckedState, event);
126
+ if (newCheckedState) setValue(cardId, event);
127
+ };
128
+
129
+ return /*#__PURE__*/_jsx(RadioCard, {
130
+ id: cardId,
131
+ checked: currentValue === cardId,
132
+ onChange: handleChange,
133
+ inactive: inactive,
134
+ title: title,
135
+ name: inputGroupName,
136
+ tokens: radioCardTokens,
137
+ variant: variant,
138
+ readOnly: readOnly,
139
+ ...props,
140
+ children: content
141
+ }, cardId);
142
+ })
143
+ })
144
+ });
145
+ });
146
+ RadioCardGroup.displayName = 'RadioCardGroup';
147
+ RadioCardGroup.propTypes = { ...selectedSystemPropTypes,
148
+
149
+ /**
150
+ * Optional theme token overrides for the outer RadioCardGroup component
151
+ */
152
+ tokens: getTokensPropType('RadioCardGroup'),
153
+
154
+ /**
155
+ * Optional theme token overrides for each inner RadioCard component
156
+ */
157
+ radioCardTokens: getTokensPropType('RadioCard'),
158
+
159
+ /**
160
+ * Theme variants, shared between both RadioCardGroup and RadioCard
161
+ */
162
+ variant: variantProp.propType,
163
+
164
+ /**
165
+ * Array of objects containing specifics for each RadioCard to be rendered in the group.
166
+ */
167
+ items: PropTypes.arrayOf(PropTypes.exact({
168
+ title: PropTypes.string,
169
+ content: PropTypes.node,
170
+ id: PropTypes.string,
171
+ onChange: PropTypes.func
172
+ })),
173
+
174
+ /**
175
+ * Main text used to describe this group, used in Fieldset's Legend element.
176
+ */
177
+ legend: PropTypes.string,
178
+
179
+ /**
180
+ * Optional additional text giving more detail to help a user make a choice.
181
+ */
182
+ hint: PropTypes.string,
183
+
184
+ /**
185
+ * Optional tooltip text content to include alongside the legend and hint.
186
+ */
187
+ tooltip: PropTypes.string,
188
+
189
+ /**
190
+ * Current validation status of the group, passed to the feedback element if there is one.
191
+ */
192
+ validation: PropTypes.oneOf(['error', 'success']),
193
+
194
+ /**
195
+ * If provided, a Feedback element is rendered containing this text.
196
+ */
197
+ feedback: PropTypes.string,
198
+
199
+ /**
200
+ * If provided, the radio card with this id is selected on first render.
201
+ */
202
+ initialCheckedId: PropTypes.string,
203
+
204
+ /**
205
+ * If not undefined, the radio card with this id is selected (or none is selected if `null`), and the
206
+ * element's selection state will be controlled by its parent using the `onChange` function.
207
+ */
208
+ checkedId: PropTypes.string,
209
+
210
+ /**
211
+ * Function to call on change in selection state. Is required if the selection state is controlled
212
+ * by a parent using checkedId and the input is not readOnly.
213
+ */
214
+ onChange: PropTypes.func,
215
+
216
+ /**
217
+ * If true, the radio cards cannot be selected by the user and simply show their current state.
218
+ */
219
+ readOnly: PropTypes.bool,
220
+
221
+ /**
222
+ * If true, the radio card cannot be interacted with, elements are set as `disabled` and if the
223
+ * theme supports `inactive` appearances rules, these are applied.
224
+ */
225
+ inactive: PropTypes.bool,
226
+
227
+ /**
228
+ * On Web, this is passed to the `name` attribute of the fieldset and each radio input.
229
+ */
230
+ name: PropTypes.string
231
+ };
232
+ export default RadioCardGroup;
@@ -0,0 +1,3 @@
1
+ import RadioCard from './RadioCard';
2
+ export default RadioCard;
3
+ export { default as RadioCardGroup } from './RadioCardGroup';
@@ -0,0 +1,233 @@
1
+ import React, { forwardRef, useState } from 'react';
2
+ import View from "react-native-web/dist/exports/View";
3
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
4
+ import PropTypes from 'prop-types';
5
+ import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider';
6
+ import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, useSpacingScale, variantProp, viewProps } from '../utils';
7
+ import TextInputBase from '../TextInput/TextInputBase';
8
+ import ButtonBase from '../Button/ButtonBase';
9
+ import StackView from '../StackView';
10
+ import useCopy from '../utils/useCopy';
11
+ import dictionary from './dictionary';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
14
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
15
+
16
+ const selectInputTokens = ({
17
+ searchTokens,
18
+ buttonTokens,
19
+ buttonsGapSize
20
+ }) => {
21
+ const {
22
+ paddingRight: inputPaddingRight,
23
+ clearButtonIcon,
24
+ submitButtonIcon
25
+ } = searchTokens;
26
+ const {
27
+ paddingLeft = 0,
28
+ paddingRight = 0,
29
+ iconSize = 0
30
+ } = buttonTokens;
31
+ const buttonWidth = paddingLeft + paddingRight + iconSize;
32
+ const paddingWithButtons = inputPaddingRight + (submitButtonIcon ? buttonWidth : 0) + (clearButtonIcon ? buttonsGapSize + buttonWidth : 0);
33
+ return { ...selectTokens('TextInput', searchTokens),
34
+ paddingRight: paddingWithButtons
35
+ };
36
+ };
37
+
38
+ const selectButtonTokens = tokens => selectTokens('Button', tokens);
39
+
40
+ const selectIconsContainerStyle = ({
41
+ paddingRight
42
+ }) => ({
43
+ paddingRight
44
+ });
45
+
46
+ const selectIconTokens = ({
47
+ iconSize,
48
+ iconColor
49
+ }) => ({
50
+ color: iconColor,
51
+ size: iconSize
52
+ });
53
+ /**
54
+ * The `Search` component is a combination of a `TextInput` and 2 different kinds of custom buttons.
55
+ * Use `Search` to feature autocomplete interactions.
56
+ *
57
+ * This component includes a clear button, which will appear as text is entered and pressing it will
58
+ * cause the input's internal state value to be set to an empty string.
59
+ *
60
+ * This component may only be used as uncontrolled, as the search value is managed within an internal state.
61
+ * You can use the `onChange` prop to react to value changes and the `onSubmit` prop to react on search submission.
62
+ *
63
+ * Use the following props to supply additional accessibility labels for the input - `accessibilityLabel`,
64
+ * clear button - `clearButtonAccessibilityLabel`, and submit button - `submitButtonAccessibilityLabel`.
65
+ */
66
+
67
+
68
+ const Search = /*#__PURE__*/forwardRef(({
69
+ initialValue = '',
70
+ placeholder = 'Search',
71
+ inactive,
72
+ onChange,
73
+ onSubmit,
74
+ onClear,
75
+ accessibilityLabel,
76
+ copy = 'en',
77
+ tokens,
78
+ variant,
79
+ ...rest
80
+ }, ref) => {
81
+ const [value, setValue] = useState(initialValue);
82
+ const themeTokens = useThemeTokens('Search', tokens, variant);
83
+ const buttonTokens = useThemeTokens('SearchButton', tokens, variant);
84
+ const getThemeTokens = useThemeTokensCallback('Search', tokens, variant);
85
+ const getButtonTokens = useThemeTokensCallback('SearchButton', tokens, variant); // TODO: support overriding the a11y props using a custom dictionary
86
+
87
+ const getCopy = useCopy({
88
+ dictionary,
89
+ copy
90
+ });
91
+ const {
92
+ placeholderColor,
93
+ buttonsGap,
94
+ clearButtonIcon: ClearButtonIcon,
95
+ submitButtonIcon: SubmitButtonIcon
96
+ } = themeTokens; // get the actual gap value for the current viewport
97
+
98
+ const buttonsGapSize = useSpacingScale(buttonsGap);
99
+
100
+ const handleSubmit = event => {
101
+ if (onSubmit !== undefined) {
102
+ onSubmit(value, event);
103
+ }
104
+ };
105
+
106
+ const handleChange = (currentValue, event) => {
107
+ setValue(currentValue, event);
108
+ if (onChange !== undefined) onChange(currentValue, event);
109
+ };
110
+
111
+ const handleClear = event => {
112
+ setValue('', event);
113
+ if (onClear !== undefined) onClear('', event);
114
+ if (onChange !== undefined) onChange('', event);
115
+ };
116
+
117
+ const isEmpty = value === '';
118
+ return /*#__PURE__*/_jsxs(View, {
119
+ style: staticStyles.container,
120
+ ...selectProps(rest),
121
+ children: [/*#__PURE__*/_jsx(TextInputBase, {
122
+ ref: ref,
123
+ tokens: appearances => selectInputTokens({
124
+ searchTokens: getThemeTokens(appearances),
125
+ buttonTokens,
126
+ buttonsGapSize,
127
+ isEmpty
128
+ }),
129
+ placeholder: placeholder,
130
+ placeholderTextColor: placeholderColor,
131
+ inactive: inactive,
132
+ enablesReturnKeyAutomatically: true,
133
+ returnKeyType: "search",
134
+ value: value,
135
+ onChange: handleChange,
136
+ onSubmitEditing: handleSubmit,
137
+ accessibilityLabel: accessibilityLabel || getCopy('accessibilityLabel')
138
+ }), /*#__PURE__*/_jsx(View, {
139
+ style: [staticStyles.iconsContainer, selectIconsContainerStyle(themeTokens)],
140
+ children: /*#__PURE__*/_jsxs(StackView, {
141
+ direction: "row",
142
+ space: buttonsGap,
143
+ children: [ClearButtonIcon && !isEmpty && /*#__PURE__*/_jsx(ButtonBase, {
144
+ onPress: handleClear,
145
+ inactive: inactive,
146
+ accessibilityRole: "button",
147
+ accessibilityLabel: getCopy('clearButtonAccessibilityLabel'),
148
+ tokens: appearances => selectButtonTokens(getButtonTokens(appearances)),
149
+ children: buttonState => /*#__PURE__*/_jsx(ClearButtonIcon, { ...selectIconTokens(getButtonTokens(buttonState))
150
+ })
151
+ }), SubmitButtonIcon && /*#__PURE__*/_jsx(ButtonBase, {
152
+ onPress: handleSubmit,
153
+ inactive: inactive,
154
+ accessibilityRole: "button",
155
+ accessibilityLabel: getCopy('submitButtonAccessibilityLabel'),
156
+ tokens: buttonState => selectButtonTokens(getButtonTokens({ ...buttonState,
157
+ priority: 'high'
158
+ })),
159
+ children: buttonState => /*#__PURE__*/_jsx(SubmitButtonIcon, { ...selectIconTokens(getButtonTokens({ ...buttonState,
160
+ priority: 'high'
161
+ }))
162
+ })
163
+ })]
164
+ })
165
+ })]
166
+ });
167
+ });
168
+ Search.displayName = 'Search';
169
+ Search.propTypes = { ...selectedSystemPropTypes,
170
+
171
+ /**
172
+ * Use this to set the initial value of the search input.
173
+ * Updating `initialValue` will **not** update the actual value.
174
+ */
175
+ initialValue: PropTypes.string,
176
+
177
+ /**
178
+ * Label rendered in the search input when it has no value.
179
+ */
180
+ placeholder: PropTypes.string,
181
+
182
+ /**
183
+ * Disables all user interactions with the search input.
184
+ */
185
+ inactive: PropTypes.bool,
186
+
187
+ /**
188
+ * Use to react upon search input's value changes.
189
+ * Will receive the searched value as an argument.
190
+ */
191
+ onChange: PropTypes.func,
192
+
193
+ /**
194
+ * Triggered when the search input is submitted,
195
+ * either by pressing the submit button, "Enter" key on web,
196
+ * or "Search" key in a mobile keyboard.
197
+ */
198
+ onSubmit: PropTypes.func,
199
+
200
+ /**
201
+ * Triggered when the clear button is pressed.
202
+ */
203
+ onClear: PropTypes.func,
204
+
205
+ /**
206
+ * Use to provide an accessible label for the input (visually hidden).
207
+ */
208
+ accessibilityLabel: PropTypes.string,
209
+
210
+ /**
211
+ * Select english or french copy for the accessible labels.
212
+ * You may also pass in a custom dictionary object.
213
+ */
214
+ copy: PropTypes.oneOfType([PropTypes.oneOf(['en', 'fr']), PropTypes.shape({
215
+ accessibilityLabel: PropTypes.string,
216
+ clearButtonAccessibilityLabel: PropTypes.string,
217
+ submitButtonAccessibilityLabel: PropTypes.string
218
+ })]),
219
+ tokens: getTokensPropType('Search'),
220
+ variant: variantProp.propType
221
+ };
222
+ export default Search;
223
+ const staticStyles = StyleSheet.create({
224
+ container: {// No styles needed here except the View defaults (position: relative etc)
225
+ },
226
+ iconsContainer: {
227
+ position: 'absolute',
228
+ right: 0,
229
+ top: 0,
230
+ bottom: 0,
231
+ justifyContent: 'center'
232
+ }
233
+ });
@@ -0,0 +1,12 @@
1
+ export default {
2
+ en: {
3
+ accessibilityLabel: 'Search',
4
+ clearButtonAccessibilityLabel: 'Clear',
5
+ submitButtonAccessibilityLabel: 'Search'
6
+ },
7
+ fr: {
8
+ accessibilityLabel: 'Chercher',
9
+ clearButtonAccessibilityLabel: 'Effacer',
10
+ submitButtonAccessibilityLabel: 'Chercher'
11
+ }
12
+ };
@@ -0,0 +1,2 @@
1
+ import Search from './Search';
2
+ export default Search;