@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,158 @@
1
+ import React, { forwardRef, useState } from 'react';
2
+ import Animated from "react-native-web/dist/exports/Animated";
3
+ import Platform from "react-native-web/dist/exports/Platform";
4
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
+ import View from "react-native-web/dist/exports/View";
6
+ import PropTypes from 'prop-types';
7
+ import ExpandCollapseControl from './Control';
8
+ import { useThemeTokens } from '../ThemeProvider';
9
+ import { a11yProps, getTokensPropType, selectSystemProps, useVerticalExpandAnimation, variantProp, viewProps } from '../utils';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]); // just void functions for now, since there are no style tokens for a panel or control at this point
13
+
14
+ const selectGroupStyles = () => {};
15
+
16
+ const selectContainerStyles = ({
17
+ contentPaddingLeft,
18
+ contentPaddingRight,
19
+ contentPaddingTop,
20
+ contentPaddingBottom
21
+ }) => ({
22
+ paddingLeft: contentPaddingLeft,
23
+ paddingRight: contentPaddingRight,
24
+ paddingTop: contentPaddingTop,
25
+ paddingBottom: contentPaddingBottom
26
+ });
27
+ /**
28
+ * An item in an `ExpandCollapse` which contains collapsible `children` and a `control` that opens
29
+ * and closes the collapsible children when pressed.
30
+ *
31
+ * Expects `openIds` and `onToggle` props from the `ExpandCollapse` render function and a unique
32
+ * `panelId` that matches the ids passed to the `<ExpandCollapse>`.
33
+ *
34
+ * The panel does not need to be a direct child of the `<ExpandCollapse>` (unless this is required
35
+ * by the chosen accessibility props for a particular accessibility tools).
36
+ */
37
+
38
+
39
+ const ExpandCollapsePanel = /*#__PURE__*/forwardRef(({
40
+ openIds = [],
41
+ panelId,
42
+ onToggle,
43
+ onPress,
44
+ control,
45
+ controlTokens,
46
+ children,
47
+ tokens,
48
+ variant,
49
+ ...rest
50
+ }, ref) => {
51
+ const [containerHeight, setContainerHeight] = useState(null);
52
+ const isExpanded = openIds.includes(panelId);
53
+ const selectedProps = selectProps(rest);
54
+ selectedProps.accessibilityState = { ...(selectedProps.accessibilityState || {}),
55
+ expanded: isExpanded
56
+ };
57
+ const themeTokens = useThemeTokens('ExpandCollapsePanel', tokens, variant, {
58
+ expanded: isExpanded
59
+ });
60
+
61
+ const handleControlPress = event => {
62
+ onToggle(panelId, event);
63
+ if (onPress) onPress(panelId, event);
64
+ };
65
+
66
+ const onContainerLayout = event => {
67
+ if (containerHeight === null) {
68
+ const {
69
+ layout: {
70
+ height = 0
71
+ } = {}
72
+ } = event.nativeEvent;
73
+ setContainerHeight(height);
74
+ }
75
+ };
76
+
77
+ const animatedStyles = useVerticalExpandAnimation({
78
+ containerHeight,
79
+ isExpanded,
80
+ tokens: themeTokens
81
+ }); // on web we can hide the contents until we have the container measured and avoid occasional jitter
82
+ // this won't work on native platforms
83
+
84
+ const overflowContainerStyles = containerHeight === null && Platform.OS === 'web' ? {
85
+ height: 0,
86
+ visibility: 'hidden'
87
+ } : undefined;
88
+ const focusabilityProps = isExpanded ? {} : a11yProps.nonFocusableProps;
89
+ return /*#__PURE__*/_jsxs(View, {
90
+ ref: ref,
91
+ style: selectGroupStyles(themeTokens),
92
+ children: [/*#__PURE__*/_jsx(ExpandCollapseControl, { ...selectedProps,
93
+ isExpanded: isExpanded,
94
+ tokens: controlTokens,
95
+ onPress: handleControlPress,
96
+ children: control
97
+ }), /*#__PURE__*/_jsx(View, {
98
+ style: overflowContainerStyles,
99
+ ...focusabilityProps,
100
+ children: /*#__PURE__*/_jsx(Animated.View, {
101
+ onLayout: onContainerLayout,
102
+ style: [staticStyles.itemsContainer, animatedStyles],
103
+ children: /*#__PURE__*/_jsx(View, {
104
+ style: selectContainerStyles(themeTokens),
105
+ children: children
106
+ })
107
+ })
108
+ })]
109
+ });
110
+ });
111
+ ExpandCollapsePanel.displayName = 'ExpandCollapsePanel';
112
+ ExpandCollapsePanel.propTypes = { ...selectedSystemPropTypes,
113
+ variant: variantProp.propType,
114
+ tokens: getTokensPropType('ExpandCollapsePanel'),
115
+
116
+ /**
117
+ * Array of the ids of currently open groups
118
+ */
119
+ openIds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),
120
+
121
+ /**
122
+ * Unique name by which the ExpandCollapse controls this element.
123
+ */
124
+ panelId: PropTypes.string.isRequired,
125
+
126
+ /**
127
+ * Function to call on pressing the panel's control, which should open or close the panel.
128
+ * If Panel is a direct child of `ExpandCollapse`, this prop will be provided by the ExpandCollapse parent.
129
+ */
130
+ onToggle: PropTypes.func.isRequired,
131
+
132
+ /**
133
+ * Optional function to call on pressing the panel's control, in addition to opening or closing the panel.
134
+ */
135
+ onPress: PropTypes.func,
136
+
137
+ /**
138
+ * ExpandCollapsePanel's children are the content that is hidden or revealed on open or close, and may be any
139
+ * single React element or a render function which takes this group's isExpanded state, onToggle function and panelId
140
+ */
141
+ children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
142
+
143
+ /**
144
+ * The content inside the always-visible control element that opens and closes the ExpandCollapse when pressed.
145
+ */
146
+ control: ExpandCollapseControl.propTypes.children.isRequired,
147
+
148
+ /**
149
+ * Optional theme token overrides that may be passed to the ExpandCollapseControl element.
150
+ */
151
+ controlTokens: getTokensPropType('ExpandCollapseControl')
152
+ };
153
+ const staticStyles = StyleSheet.create({
154
+ itemsContainer: {
155
+ overflow: 'hidden'
156
+ }
157
+ });
158
+ export default ExpandCollapsePanel;
@@ -0,0 +1,7 @@
1
+ import ExpandCollapse from './ExpandCollapse';
2
+ import Accordion from './Accordion';
3
+ import Panel from './Panel';
4
+ ExpandCollapse.Panel = Panel;
5
+ Accordion.Panel = Panel;
6
+ export default ExpandCollapse;
7
+ export { Accordion };
@@ -0,0 +1,144 @@
1
+ import React, { forwardRef } from 'react';
2
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
3
+ import Text from "react-native-web/dist/exports/Text";
4
+ import View from "react-native-web/dist/exports/View";
5
+ import PropTypes from 'prop-types';
6
+ import { applyTextStyles, useThemeTokens } from '../ThemeProvider';
7
+ import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, variantProp, viewProps } from '../utils';
8
+ import StackView from '../StackView';
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 selectStyles = tokens => selectTokens('Feedback', tokens);
14
+
15
+ const selectTitleTextStyles = ({
16
+ titleFontSize,
17
+ ...tokens
18
+ }) => applyTextStyles(selectTokens('Typography', { ...tokens,
19
+ fontSize: titleFontSize
20
+ }));
21
+
22
+ const selectContentTextStyles = ({
23
+ contentFontSize,
24
+ ...tokens
25
+ }) => applyTextStyles(selectTokens('Typography', { ...tokens,
26
+ fontSize: contentFontSize
27
+ }));
28
+
29
+ const selectIconTokens = ({
30
+ iconSize,
31
+ iconColor
32
+ }) => ({
33
+ size: iconSize,
34
+ color: iconColor
35
+ });
36
+
37
+ const selectIconContainerStyles = ({
38
+ iconGap
39
+ }) => ({
40
+ paddingRight: iconGap
41
+ });
42
+ /**
43
+ * A feedback box commonly used with form fields.
44
+ *
45
+ * ### Standalone usage
46
+ * While its primary use is to facilitate feedback states for other form components such as `TextInput`,
47
+ * you may use it standalone.
48
+ *
49
+ * ### Complex content
50
+ * You may pass any React tree as the children of this component, bear in mind that a render function
51
+ * is better suited for styling children based on Feedback's variant.
52
+ *
53
+ * ### Using a render function
54
+ * When a function is passed for rendering content, it will receive the feedback text styles and
55
+ * variant as arguments.
56
+ *
57
+ * ### Accessibility
58
+ * All accessibility props set on this component will be applied to the outer container.
59
+ */
60
+
61
+
62
+ const Feedback = /*#__PURE__*/forwardRef(({
63
+ title,
64
+ children,
65
+ id,
66
+ validation,
67
+ tokens,
68
+ variant,
69
+ ...rest
70
+ }, ref) => {
71
+ const themeTokens = useThemeTokens('Feedback', tokens, { ...variant,
72
+ validation
73
+ });
74
+ const {
75
+ space
76
+ } = themeTokens;
77
+ const {
78
+ icon: IconComponent
79
+ } = themeTokens;
80
+ const titleTextStyles = selectTitleTextStyles(themeTokens);
81
+ const contentTextStyles = selectContentTextStyles(themeTokens);
82
+ const content = typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
83
+ style: contentTextStyles,
84
+ children: children
85
+ }) : children;
86
+ const selectedProps = selectProps({
87
+ accessibilityRole: validation === 'error' ? 'alert' : undefined,
88
+ ...rest
89
+ });
90
+ return /*#__PURE__*/_jsx(View, {
91
+ ref: ref,
92
+ style: selectStyles(themeTokens),
93
+ nativeID: id,
94
+ ...selectedProps,
95
+ children: /*#__PURE__*/_jsxs(StackView, {
96
+ space: space,
97
+ children: [title !== undefined && /*#__PURE__*/_jsxs(View, {
98
+ style: staticStyles.title,
99
+ children: [IconComponent && /*#__PURE__*/_jsx(View, {
100
+ style: selectIconContainerStyles(themeTokens),
101
+ children: /*#__PURE__*/_jsx(IconComponent, { ...selectIconTokens(themeTokens)
102
+ })
103
+ }), /*#__PURE__*/_jsx(Text, {
104
+ style: titleTextStyles,
105
+ children: title
106
+ })]
107
+ }), content && typeof content === 'function' ? content({
108
+ textStyles: contentTextStyles,
109
+ variant
110
+ }) : content]
111
+ })
112
+ });
113
+ });
114
+ Feedback.displayName = 'Feedback';
115
+ Feedback.propTypes = { ...selectedSystemPropTypes,
116
+
117
+ /**
118
+ * Emphasized summary of the feedback. If an icon is set, it is rendered next to the title.
119
+ */
120
+ title: PropTypes.string,
121
+
122
+ /**
123
+ * Feedback content rendered below the title. A render function `({textStyles, variant}) => {}` is supported.
124
+ */
125
+ children: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.func]),
126
+
127
+ /**
128
+ * Use to visually mark the Feedback as valid or invalid.
129
+ */
130
+ validation: PropTypes.oneOf(['error', 'success']),
131
+
132
+ /** @ignore */
133
+ id: PropTypes.string,
134
+ tokens: getTokensPropType('Feedback'),
135
+ variant: variantProp.propType
136
+ };
137
+ export default Feedback;
138
+ const staticStyles = StyleSheet.create({
139
+ title: {
140
+ display: 'flex',
141
+ flexDirection: 'row',
142
+ alignItems: 'center'
143
+ }
144
+ });
@@ -0,0 +1,2 @@
1
+ import Feedback from './Feedback';
2
+ export default Feedback;
@@ -0,0 +1,145 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Feedback from '../Feedback';
4
+ import { spacingProps } from '../utils';
5
+ import FieldsetContainer from './FieldsetContainer';
6
+ import { getStackedContent } from '../StackView';
7
+ import InputLabel from '../InputLabel';
8
+ import useInputSupports from '../InputSupports/useInputSupports';
9
+ import Legend from './Legend';
10
+ /**
11
+ * An alternative to InputSupports for groups of input elements that, on web, are to be
12
+ * wrapped in a `<fieldset>` tag, with label content displated in a `<legend>` tag.
13
+ *
14
+ * Follows the same theming and most of the same props as InputSupports.
15
+ */
16
+
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { Fragment as _Fragment } from "react/jsx-runtime";
19
+ const Fieldset = /*#__PURE__*/forwardRef(({
20
+ space,
21
+ feedback,
22
+ feedbackPosition = 'top',
23
+ validation,
24
+ legend,
25
+ hint,
26
+ hintPosition,
27
+ tooltip,
28
+ inactive,
29
+ accessibilityRole,
30
+ name: fieldsetName,
31
+ children
32
+ }, ref) => {
33
+ // Skips `inputId` because a fieldset' legend describes multiple inputs
34
+ const {
35
+ hintId,
36
+ feedbackId,
37
+ a11yProps
38
+ } = useInputSupports({
39
+ feedback,
40
+ hint,
41
+ label: legend,
42
+ validation
43
+ });
44
+
45
+ const legendContent = legend && /*#__PURE__*/_jsx(Legend, {
46
+ children: /*#__PURE__*/_jsx(InputLabel, {
47
+ label: legend,
48
+ hint: hint,
49
+ hintPosition: hintPosition,
50
+ hintId: hintId,
51
+ tooltip: tooltip
52
+ })
53
+ });
54
+
55
+ const feedbackContent = feedback && /*#__PURE__*/_jsx(Feedback, {
56
+ id: feedbackId,
57
+ title: feedback,
58
+ validation: validation
59
+ }); // Some accessibility patterns depend on elements being direct children, e.g. fieldset -> legend,
60
+ // and on MacOS voiceover, radiogroup -> radio. To allow elements to be direct children of the
61
+ // fieldset as much as possible, but also allow different spacing within content and between
62
+ // fieldset / feedback / etc, wrap resolved children in a fragment, and stack with `preserveFragments`.
63
+
64
+
65
+ const childContent = /*#__PURE__*/_jsx(_Fragment, {
66
+ children: typeof children === 'function' ? children(a11yProps) : children
67
+ });
68
+
69
+ const orderedContent = feedbackPosition === 'bottom' ? [legendContent, feedbackContent, childContent] : [legendContent, childContent, feedbackContent];
70
+ const stackedContent = getStackedContent(orderedContent, {
71
+ space,
72
+ preserveFragments: true
73
+ });
74
+ return /*#__PURE__*/_jsx(FieldsetContainer, {
75
+ ref: ref,
76
+ inactive: inactive,
77
+ accessibilityRole: accessibilityRole,
78
+ name: fieldsetName,
79
+ children: stackedContent
80
+ });
81
+ });
82
+ Fieldset.displayName = 'Fieldset';
83
+ Fieldset.propTypes = {
84
+ children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
85
+
86
+ /**
87
+ * The accessibility role of the `<fieldset>` element itself. Other React Native accessibility
88
+ * props are not supported because there is not an appropriate counterpart for Fieldsets.
89
+ */
90
+ accessibilityRole: PropTypes.string,
91
+
92
+ /**
93
+ * The amout of space between legend, feedback and content; according to the theme's spacing scale.
94
+ * Either a number corresponding to a position on the theme's spacing scale (1 is smallest, 2 is second smallest, etc),
95
+ * or, a SpacingObject with viewport keys and options (see `useSpacingScale` for details).
96
+ */
97
+ space: spacingProps.types.spacingValue,
98
+
99
+ /**
100
+ * The text for the fieldset's legend, describing the fieldset content.
101
+ */
102
+ legend: PropTypes.string,
103
+
104
+ /**
105
+ * A short description of the expected input.
106
+ */
107
+ hint: PropTypes.string,
108
+
109
+ /**
110
+ * Position of the hint relative to label.
111
+ */
112
+ hintPosition: PropTypes.oneOf(['inline', 'below']),
113
+
114
+ /**
115
+ * A detailed description of validation error/success or additional instructions.
116
+ * Visual variant is determined based on the `validation` prop.
117
+ */
118
+ feedback: PropTypes.string,
119
+
120
+ /**
121
+ * Position of the feedback block relative to the fieldset's content.
122
+ */
123
+ feedbackPosition: PropTypes.oneOf(['above', 'below']),
124
+
125
+ /**
126
+ * If true, the fieldset is treated as inactive (setting `disabled` attribute on web).
127
+ */
128
+ inactive: PropTypes.bool,
129
+
130
+ /**
131
+ * Content of an optional `Tooltip`. If set, a tooltip button will be shown next to the label.
132
+ */
133
+ tooltip: PropTypes.string,
134
+
135
+ /**
136
+ * On web, this is passed to the `<fieldset>`'s `name` attribute.
137
+ */
138
+ name: PropTypes.string,
139
+
140
+ /**
141
+ * Use to visually mark an input as valid or invalid.
142
+ */
143
+ validation: PropTypes.oneOf(['error', 'success'])
144
+ };
145
+ export default Fieldset;
@@ -0,0 +1,29 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import cssReset from './cssReset';
4
+ /**
5
+ * On Web, wraps children with a HTML `<fieldset>` and sets its attributes as necessary.
6
+ */
7
+
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ const FieldsetContainer = /*#__PURE__*/forwardRef(({
10
+ children,
11
+ inactive,
12
+ accessibilityRole,
13
+ name: fieldsetName
14
+ }, ref) => /*#__PURE__*/_jsx("fieldset", {
15
+ ref: ref,
16
+ disabled: inactive,
17
+ style: cssReset,
18
+ role: accessibilityRole,
19
+ name: fieldsetName,
20
+ children: children
21
+ }));
22
+ FieldsetContainer.displayName = 'FieldsetContainer';
23
+ FieldsetContainer.propTypes = {
24
+ accessibilityRole: PropTypes.string,
25
+ children: PropTypes.node,
26
+ inactive: PropTypes.bool,
27
+ name: PropTypes.string
28
+ };
29
+ export default FieldsetContainer;
@@ -0,0 +1,20 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import View from "react-native-web/dist/exports/View"; // No equivalent of `<fieldset>` on native, so just apply accessibility role to container.
4
+ // If a11y testing finds any additional handling is needed at the container level, add it here.
5
+
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const FieldsetContainer = /*#__PURE__*/forwardRef(({
8
+ children,
9
+ accessibilityRole
10
+ }, ref) => /*#__PURE__*/_jsx(View, {
11
+ ref: ref,
12
+ accessibilityRole: accessibilityRole,
13
+ children: children
14
+ }));
15
+ FieldsetContainer.displayName = 'FieldsetContainer';
16
+ FieldsetContainer.propTypes = {
17
+ children: PropTypes.node,
18
+ accessibilityRole: PropTypes.string
19
+ };
20
+ export default FieldsetContainer;
@@ -0,0 +1,21 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import cssReset from './cssReset';
4
+ /**
5
+ * On Web, wraps children in HTML `<legend>` tag.
6
+ * On Native, `<legend>` does not exist, wraps in a width 100% block to follow <legend>'s behaviour in a flex.
7
+ */
8
+
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ const Legend = /*#__PURE__*/forwardRef(({
11
+ children
12
+ }, ref) => /*#__PURE__*/_jsx("legend", {
13
+ ref: ref,
14
+ style: cssReset,
15
+ children: children
16
+ }));
17
+ Legend.displayName = 'Legend';
18
+ Legend.propTypes = {
19
+ children: PropTypes.node
20
+ };
21
+ export default Legend;
@@ -0,0 +1,28 @@
1
+ import React, { forwardRef } 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
+ /**
6
+ * On Web, wraps children in HTML `<legend>` tag.
7
+ * On Native, `<legend>` does not exist, wraps in a width 100% block to follow <legend>'s behaviour in a flex.
8
+ */
9
+
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ const Legend = /*#__PURE__*/forwardRef(({
12
+ children
13
+ }, ref) => /*#__PURE__*/_jsx(View, {
14
+ ref: ref,
15
+ style: staticStyles.stretch,
16
+ children: children
17
+ }));
18
+ Legend.displayName = 'Legend';
19
+ Legend.propTypes = {
20
+ children: PropTypes.node
21
+ };
22
+ const staticStyles = StyleSheet.create({
23
+ stretch: {
24
+ width: '100%',
25
+ flexGrow: 1
26
+ }
27
+ });
28
+ export default Legend;
@@ -0,0 +1,14 @@
1
+ // React Native Web has no built-in `fieldset` or `legend` support.
2
+ // This reset makes them consistent with other RNW views.
3
+ // Can't use RN stylesheets because it's not an RN element (RNW's createElement tooling is unstable).
4
+ // Using CSS `all` doesn't work well as an inline style.
5
+ // https://github.com/necolas/react-native-web/issues/1385
6
+ export default {
7
+ margin: 'unset',
8
+ padding: 'unset',
9
+ float: 'unset',
10
+ border: 'unset',
11
+ width: 'unset',
12
+ display: 'flex',
13
+ flexDirection: 'column'
14
+ };
@@ -0,0 +1,2 @@
1
+ import Fieldset from './Fieldset';
2
+ export default Fieldset;