@telus-uds/components-base 1.8.2 → 1.8.5

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 (278) hide show
  1. package/CHANGELOG.md +33 -2
  2. package/component-docs.json +36 -1
  3. package/lib/ActivityIndicator/Spinner.js +7 -7
  4. package/lib/ActivityIndicator/Spinner.native.js +2 -2
  5. package/lib/Button/ButtonBase.js +2 -2
  6. package/lib/Button/ButtonGroup.js +1 -1
  7. package/lib/Checkbox/Checkbox.js +5 -3
  8. package/lib/Checkbox/CheckboxGroup.js +2 -2
  9. package/lib/Divider/Divider.js +2 -2
  10. package/lib/ExpandCollapse/Panel.js +2 -17
  11. package/lib/FlexGrid/Col/Col.js +1 -1
  12. package/lib/Icon/Icon.js +1 -1
  13. package/lib/Link/InlinePressable.js +5 -1
  14. package/lib/Link/LinkBase.js +5 -2
  15. package/lib/List/List.js +12 -7
  16. package/lib/List/ListItem.js +4 -5
  17. package/lib/Modal/Modal.js +2 -1
  18. package/lib/Pagination/PageButton.js +2 -2
  19. package/lib/Pagination/Pagination.js +5 -3
  20. package/lib/Pagination/usePagination.js +2 -2
  21. package/lib/Progress/ProgressBar.js +3 -3
  22. package/lib/Progress/ProgressBarBackground.js +3 -3
  23. package/lib/Radio/Radio.js +2 -2
  24. package/lib/Radio/RadioGroup.js +2 -2
  25. package/lib/RadioCard/RadioCard.js +1 -1
  26. package/lib/RadioCard/RadioCardGroup.js +2 -2
  27. package/lib/Search/Search.js +1 -1
  28. package/lib/SideNav/SideNav.js +2 -2
  29. package/lib/Skeleton/Skeleton.js +1 -1
  30. package/lib/Skeleton/skeletonWebAnimation.js +1 -1
  31. package/lib/StackView/StackWrap.js +3 -1
  32. package/lib/StackView/getStackedContent.js +2 -2
  33. package/lib/Tabs/Tabs.js +28 -3
  34. package/lib/Tabs/TabsItem.js +5 -6
  35. package/lib/Tags/Tags.js +1 -1
  36. package/lib/ThemeProvider/utils/styles.js +2 -2
  37. package/lib/ThemeProvider/utils/theme-tokens.js +7 -9
  38. package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
  39. package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
  40. package/lib/Tooltip/Backdrop.js +2 -10
  41. package/lib/utils/animation/useVerticalExpandAnimation.js +40 -14
  42. package/lib/utils/children.js +2 -2
  43. package/lib/utils/input.js +6 -12
  44. package/lib/utils/props/componentPropType.js +3 -3
  45. package/lib/utils/props/selectSystemProps.js +2 -2
  46. package/lib/utils/props/tokens.js +2 -2
  47. package/lib/utils/useSpacingScale.js +3 -1
  48. package/lib/utils/useUniqueId.js +1 -1
  49. package/lib-module/A11yInfoProvider/index.js +63 -0
  50. package/lib-module/A11yText/index.js +56 -0
  51. package/lib-module/ActivityIndicator/Spinner.js +77 -0
  52. package/lib-module/ActivityIndicator/Spinner.native.js +144 -0
  53. package/lib-module/ActivityIndicator/index.js +41 -0
  54. package/lib-module/ActivityIndicator/shared.js +12 -0
  55. package/lib-module/BaseProvider/index.js +29 -0
  56. package/lib-module/Box/Box.js +244 -0
  57. package/lib-module/Box/index.js +2 -0
  58. package/lib-module/Button/Button.js +26 -0
  59. package/lib-module/Button/ButtonBase.js +271 -0
  60. package/lib-module/Button/ButtonGroup.js +247 -0
  61. package/lib-module/Button/ButtonLink.js +40 -0
  62. package/lib-module/Button/index.js +4 -0
  63. package/lib-module/Button/propTypes.js +36 -0
  64. package/lib-module/Card/Card.js +84 -0
  65. package/lib-module/Card/CardBase.js +66 -0
  66. package/lib-module/Card/PressableCardBase.js +114 -0
  67. package/lib-module/Card/index.js +4 -0
  68. package/lib-module/Checkbox/Checkbox.js +348 -0
  69. package/lib-module/Checkbox/CheckboxGroup.js +233 -0
  70. package/lib-module/Checkbox/CheckboxInput.js +60 -0
  71. package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
  72. package/lib-module/Checkbox/index.js +3 -0
  73. package/lib-module/Divider/Divider.js +124 -0
  74. package/lib-module/Divider/index.js +2 -0
  75. package/lib-module/ExpandCollapse/Accordion.js +15 -0
  76. package/lib-module/ExpandCollapse/Control.js +136 -0
  77. package/lib-module/ExpandCollapse/ExpandCollapse.js +95 -0
  78. package/lib-module/ExpandCollapse/Panel.js +151 -0
  79. package/lib-module/ExpandCollapse/index.js +7 -0
  80. package/lib-module/Feedback/Feedback.js +157 -0
  81. package/lib-module/Feedback/index.js +2 -0
  82. package/lib-module/Fieldset/Fieldset.js +153 -0
  83. package/lib-module/Fieldset/FieldsetContainer.js +32 -0
  84. package/lib-module/Fieldset/FieldsetContainer.native.js +23 -0
  85. package/lib-module/Fieldset/Legend.js +24 -0
  86. package/lib-module/Fieldset/Legend.native.js +31 -0
  87. package/lib-module/Fieldset/cssReset.js +14 -0
  88. package/lib-module/Fieldset/index.js +2 -0
  89. package/lib-module/FlexGrid/Col/Col.js +276 -0
  90. package/lib-module/FlexGrid/Col/index.js +2 -0
  91. package/lib-module/FlexGrid/FlexGrid.js +148 -0
  92. package/lib-module/FlexGrid/Row/Row.js +184 -0
  93. package/lib-module/FlexGrid/Row/index.js +2 -0
  94. package/lib-module/FlexGrid/helpers/index.js +18 -0
  95. package/lib-module/FlexGrid/index.js +2 -0
  96. package/lib-module/FlexGrid/providers/GutterContext.js +3 -0
  97. package/lib-module/HorizontalScroll/HorizontalScroll.js +175 -0
  98. package/lib-module/HorizontalScroll/HorizontalScrollButton.js +81 -0
  99. package/lib-module/HorizontalScroll/ScrollViewEnd.js +48 -0
  100. package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +27 -0
  101. package/lib-module/HorizontalScroll/dictionary.js +11 -0
  102. package/lib-module/HorizontalScroll/index.js +11 -0
  103. package/lib-module/HorizontalScroll/itemPositions.js +112 -0
  104. package/lib-module/Icon/Icon.js +62 -0
  105. package/lib-module/Icon/IconText.js +83 -0
  106. package/lib-module/Icon/index.js +4 -0
  107. package/lib-module/IconButton/IconButton.js +122 -0
  108. package/lib-module/IconButton/index.js +2 -0
  109. package/lib-module/InputLabel/InputLabel.js +148 -0
  110. package/lib-module/InputLabel/LabelContent.js +27 -0
  111. package/lib-module/InputLabel/LabelContent.native.js +19 -0
  112. package/lib-module/InputLabel/index.js +2 -0
  113. package/lib-module/InputSupports/InputSupports.js +96 -0
  114. package/lib-module/InputSupports/index.js +2 -0
  115. package/lib-module/InputSupports/useInputSupports.js +32 -0
  116. package/lib-module/Link/ChevronLink.js +52 -0
  117. package/lib-module/Link/InlinePressable.js +44 -0
  118. package/lib-module/Link/InlinePressable.native.js +89 -0
  119. package/lib-module/Link/Link.js +28 -0
  120. package/lib-module/Link/LinkBase.js +243 -0
  121. package/lib-module/Link/TextButton.js +35 -0
  122. package/lib-module/Link/index.js +5 -0
  123. package/lib-module/List/List.js +62 -0
  124. package/lib-module/List/ListItem.js +248 -0
  125. package/lib-module/List/index.js +5 -0
  126. package/lib-module/Modal/Modal.js +222 -0
  127. package/lib-module/Modal/dictionary.js +9 -0
  128. package/lib-module/Modal/index.js +2 -0
  129. package/lib-module/Notification/Notification.js +209 -0
  130. package/lib-module/Notification/dictionary.js +8 -0
  131. package/lib-module/Notification/index.js +2 -0
  132. package/lib-module/Pagination/PageButton.js +66 -0
  133. package/lib-module/Pagination/Pagination.js +153 -0
  134. package/lib-module/Pagination/SideButton.js +106 -0
  135. package/lib-module/Pagination/dictionary.js +18 -0
  136. package/lib-module/Pagination/index.js +2 -0
  137. package/lib-module/Pagination/usePagination.js +73 -0
  138. package/lib-module/Progress/Progress.js +89 -0
  139. package/lib-module/Progress/ProgressBar.js +138 -0
  140. package/lib-module/Progress/ProgressBarBackground.js +42 -0
  141. package/lib-module/Progress/index.js +4 -0
  142. package/lib-module/Radio/Radio.js +285 -0
  143. package/lib-module/Radio/RadioButton.js +138 -0
  144. package/lib-module/Radio/RadioGroup.js +243 -0
  145. package/lib-module/Radio/RadioInput.js +62 -0
  146. package/lib-module/Radio/RadioInput.native.js +6 -0
  147. package/lib-module/Radio/index.js +3 -0
  148. package/lib-module/RadioCard/RadioCard.js +219 -0
  149. package/lib-module/RadioCard/RadioCardGroup.js +250 -0
  150. package/lib-module/RadioCard/index.js +3 -0
  151. package/lib-module/Search/Search.js +261 -0
  152. package/lib-module/Search/dictionary.js +12 -0
  153. package/lib-module/Search/index.js +2 -0
  154. package/lib-module/Select/Group.js +21 -0
  155. package/lib-module/Select/Group.native.js +15 -0
  156. package/lib-module/Select/Item.js +20 -0
  157. package/lib-module/Select/Item.native.js +3 -0
  158. package/lib-module/Select/Picker.js +68 -0
  159. package/lib-module/Select/Picker.native.js +120 -0
  160. package/lib-module/Select/Select.js +337 -0
  161. package/lib-module/Select/index.js +6 -0
  162. package/lib-module/SideNav/Item.js +145 -0
  163. package/lib-module/SideNav/ItemContent.js +48 -0
  164. package/lib-module/SideNav/ItemsGroup.js +117 -0
  165. package/lib-module/SideNav/SideNav.js +136 -0
  166. package/lib-module/SideNav/index.js +1 -0
  167. package/lib-module/Skeleton/Skeleton.js +179 -0
  168. package/lib-module/Skeleton/index.js +2 -0
  169. package/lib-module/Skeleton/skeleton.constant.js +3 -0
  170. package/lib-module/Skeleton/skeletonWebAnimation.js +18 -0
  171. package/lib-module/Skeleton/useSkeletonNativeAnimation.js +24 -0
  172. package/lib-module/Spacer/Spacer.js +98 -0
  173. package/lib-module/Spacer/index.js +2 -0
  174. package/lib-module/StackView/StackView.js +125 -0
  175. package/lib-module/StackView/StackWrap.js +50 -0
  176. package/lib-module/StackView/StackWrap.native.js +3 -0
  177. package/lib-module/StackView/StackWrapBox.js +115 -0
  178. package/lib-module/StackView/StackWrapGap.js +59 -0
  179. package/lib-module/StackView/common.js +35 -0
  180. package/lib-module/StackView/getStackedContent.js +124 -0
  181. package/lib-module/StackView/index.js +5 -0
  182. package/lib-module/StepTracker/Step.js +248 -0
  183. package/lib-module/StepTracker/StepTracker.js +185 -0
  184. package/lib-module/StepTracker/dictionary.js +10 -0
  185. package/lib-module/StepTracker/index.js +2 -0
  186. package/lib-module/Tabs/Tabs.js +143 -0
  187. package/lib-module/Tabs/TabsItem.js +224 -0
  188. package/lib-module/Tabs/index.js +2 -0
  189. package/lib-module/Tags/Tags.js +251 -0
  190. package/lib-module/Tags/index.js +2 -0
  191. package/lib-module/TextInput/TextArea.js +94 -0
  192. package/lib-module/TextInput/TextInput.js +72 -0
  193. package/lib-module/TextInput/TextInputBase.js +245 -0
  194. package/lib-module/TextInput/index.js +3 -0
  195. package/lib-module/TextInput/propTypes.js +37 -0
  196. package/lib-module/ThemeProvider/ThemeProvider.js +36 -0
  197. package/lib-module/ThemeProvider/index.js +6 -0
  198. package/lib-module/ThemeProvider/useSetTheme.js +25 -0
  199. package/lib-module/ThemeProvider/useTheme.js +14 -0
  200. package/lib-module/ThemeProvider/useThemeTokens.js +110 -0
  201. package/lib-module/ThemeProvider/utils/index.js +2 -0
  202. package/lib-module/ThemeProvider/utils/styles.js +181 -0
  203. package/lib-module/ThemeProvider/utils/theme-tokens.js +163 -0
  204. package/lib-module/ToggleSwitch/ToggleSwitch.js +250 -0
  205. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +220 -0
  206. package/lib-module/ToggleSwitch/index.js +3 -0
  207. package/lib-module/Tooltip/Backdrop.js +45 -0
  208. package/lib-module/Tooltip/Backdrop.native.js +44 -0
  209. package/lib-module/Tooltip/Tooltip.js +348 -0
  210. package/lib-module/Tooltip/dictionary.js +8 -0
  211. package/lib-module/Tooltip/getTooltipPosition.js +175 -0
  212. package/lib-module/Tooltip/index.js +2 -0
  213. package/lib-module/TooltipButton/TooltipButton.js +78 -0
  214. package/lib-module/TooltipButton/index.js +2 -0
  215. package/lib-module/Typography/Typography.js +124 -0
  216. package/lib-module/Typography/index.js +2 -0
  217. package/lib-module/ViewportProvider/ViewportProvider.js +29 -0
  218. package/lib-module/ViewportProvider/index.js +3 -0
  219. package/lib-module/ViewportProvider/useViewport.js +3 -0
  220. package/lib-module/ViewportProvider/useViewportListener.js +46 -0
  221. package/lib-module/index.js +48 -0
  222. package/lib-module/utils/a11y/index.js +2 -0
  223. package/lib-module/utils/a11y/semantics.js +157 -0
  224. package/lib-module/utils/a11y/textSize.js +36 -0
  225. package/lib-module/utils/animation/index.js +2 -0
  226. package/lib-module/utils/animation/useVerticalExpandAnimation.js +88 -0
  227. package/lib-module/utils/children.js +119 -0
  228. package/lib-module/utils/containUniqueFields.js +26 -0
  229. package/lib-module/utils/index.js +16 -0
  230. package/lib-module/utils/info/index.js +7 -0
  231. package/lib-module/utils/info/platform/index.js +11 -0
  232. package/lib-module/utils/info/platform/platform.android.js +1 -0
  233. package/lib-module/utils/info/platform/platform.ios.js +1 -0
  234. package/lib-module/utils/info/platform/platform.js +1 -0
  235. package/lib-module/utils/info/platform/platform.native.js +4 -0
  236. package/lib-module/utils/info/versions.js +5 -0
  237. package/lib-module/utils/input.js +179 -0
  238. package/lib-module/utils/pressability.js +111 -0
  239. package/lib-module/utils/props/a11yProps.js +140 -0
  240. package/lib-module/utils/props/clickProps.js +26 -0
  241. package/lib-module/utils/props/componentPropType.js +63 -0
  242. package/lib-module/utils/props/copyPropTypes.js +2 -0
  243. package/lib-module/utils/props/getPropSelector.js +9 -0
  244. package/lib-module/utils/props/handlerProps.js +65 -0
  245. package/lib-module/utils/props/hrefAttrsProp.js +33 -0
  246. package/lib-module/utils/props/index.js +19 -0
  247. package/lib-module/utils/props/inputSupportsProps.js +62 -0
  248. package/lib-module/utils/props/linkProps.js +44 -0
  249. package/lib-module/utils/props/paddingProp.js +9 -0
  250. package/lib-module/utils/props/pressProps.js +42 -0
  251. package/lib-module/utils/props/rectProp.js +9 -0
  252. package/lib-module/utils/props/responsiveProps.js +30 -0
  253. package/lib-module/utils/props/selectSystemProps.js +24 -0
  254. package/lib-module/utils/props/spacingProps.js +56 -0
  255. package/lib-module/utils/props/textInputProps.js +194 -0
  256. package/lib-module/utils/props/textProps.js +59 -0
  257. package/lib-module/utils/props/tokens.js +133 -0
  258. package/lib-module/utils/props/variantProp.js +18 -0
  259. package/lib-module/utils/props/viewProps.js +22 -0
  260. package/lib-module/utils/ssr.js +38 -0
  261. package/lib-module/utils/useCopy.js +44 -0
  262. package/lib-module/utils/useHash.js +45 -0
  263. package/lib-module/utils/useHash.native.js +7 -0
  264. package/lib-module/utils/useResponsiveProp.js +47 -0
  265. package/lib-module/utils/useSpacingScale.js +125 -0
  266. package/lib-module/utils/useUniqueId.js +13 -0
  267. package/lib-module/utils/withLinkRouter.js +83 -0
  268. package/package.json +3 -2
  269. package/src/Checkbox/Checkbox.jsx +3 -1
  270. package/src/ExpandCollapse/Panel.jsx +2 -19
  271. package/src/Link/InlinePressable.jsx +5 -2
  272. package/src/Link/LinkBase.jsx +4 -1
  273. package/src/List/List.jsx +34 -19
  274. package/src/List/ListItem.jsx +12 -2
  275. package/src/Modal/Modal.jsx +2 -1
  276. package/src/Tabs/Tabs.jsx +24 -2
  277. package/src/Tabs/TabsItem.jsx +6 -5
  278. package/src/utils/animation/useVerticalExpandAnimation.js +47 -13
@@ -0,0 +1,151 @@
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 View from "react-native-web/dist/exports/View";
5
+ import PropTypes from 'prop-types';
6
+ import ExpandCollapseControl from './Control';
7
+ import { useThemeTokens } from '../ThemeProvider';
8
+ import { a11yProps, getTokensPropType, selectSystemProps, useVerticalExpandAnimation, 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]); // just void functions for now, since there are no style tokens for a panel or control at this point
12
+
13
+ const selectGroupStyles = () => {};
14
+
15
+ const selectContainerStyles = _ref => {
16
+ let {
17
+ contentPaddingLeft,
18
+ contentPaddingRight,
19
+ contentPaddingTop,
20
+ contentPaddingBottom
21
+ } = _ref;
22
+ return {
23
+ paddingLeft: contentPaddingLeft,
24
+ paddingRight: contentPaddingRight,
25
+ paddingTop: contentPaddingTop,
26
+ paddingBottom: contentPaddingBottom
27
+ };
28
+ };
29
+ /**
30
+ * An item in an `ExpandCollapse` which contains collapsible `children` and a `control` that opens
31
+ * and closes the collapsible children when pressed.
32
+ *
33
+ * Expects `openIds` and `onToggle` props from the `ExpandCollapse` render function and a unique
34
+ * `panelId` that matches the ids passed to the `<ExpandCollapse>`.
35
+ *
36
+ * The panel does not need to be a direct child of the `<ExpandCollapse>` (unless this is required
37
+ * by the chosen accessibility props for a particular accessibility tools).
38
+ */
39
+
40
+
41
+ const ExpandCollapsePanel = /*#__PURE__*/forwardRef((_ref2, ref) => {
42
+ let {
43
+ openIds = [],
44
+ panelId,
45
+ onToggle,
46
+ onPress,
47
+ control,
48
+ controlTokens,
49
+ children,
50
+ tokens,
51
+ variant,
52
+ ...rest
53
+ } = _ref2;
54
+ const [containerHeight, setContainerHeight] = useState(null);
55
+ const isExpanded = openIds.includes(panelId);
56
+ const selectedProps = selectProps(rest);
57
+ selectedProps.accessibilityState = { ...(selectedProps.accessibilityState || {}),
58
+ expanded: isExpanded
59
+ };
60
+ const themeTokens = useThemeTokens('ExpandCollapsePanel', tokens, variant, {
61
+ expanded: isExpanded
62
+ });
63
+
64
+ const handleControlPress = event => {
65
+ onToggle(panelId, event);
66
+ if (onPress) onPress(panelId, event);
67
+ };
68
+
69
+ const onContainerLayout = event => {
70
+ const {
71
+ layout: {
72
+ height = 0
73
+ } = {}
74
+ } = event.nativeEvent;
75
+
76
+ if (Platform.OS === 'web' || Platform.OS !== 'web' && containerHeight === null) {
77
+ setContainerHeight(height);
78
+ }
79
+ };
80
+
81
+ const [animatedStyles, animatedRef] = useVerticalExpandAnimation({
82
+ containerHeight,
83
+ isExpanded,
84
+ tokens: themeTokens
85
+ });
86
+ const focusabilityProps = isExpanded ? {} : a11yProps.nonFocusableProps;
87
+ return /*#__PURE__*/_jsxs(View, {
88
+ ref: ref,
89
+ style: selectGroupStyles(themeTokens),
90
+ children: [/*#__PURE__*/_jsx(ExpandCollapseControl, { ...selectedProps,
91
+ isExpanded: isExpanded,
92
+ tokens: controlTokens,
93
+ onPress: handleControlPress,
94
+ children: control
95
+ }), /*#__PURE__*/_jsx(Animated.View, {
96
+ ref: animatedRef,
97
+ style: animatedStyles,
98
+ ...focusabilityProps,
99
+ children: /*#__PURE__*/_jsx(View, {
100
+ onLayout: onContainerLayout,
101
+ children: /*#__PURE__*/_jsx(View, {
102
+ style: selectContainerStyles(themeTokens),
103
+ children: children
104
+ })
105
+ })
106
+ })]
107
+ });
108
+ });
109
+ ExpandCollapsePanel.displayName = 'ExpandCollapsePanel';
110
+ ExpandCollapsePanel.propTypes = { ...selectedSystemPropTypes,
111
+ variant: variantProp.propType,
112
+ tokens: getTokensPropType('ExpandCollapsePanel'),
113
+
114
+ /**
115
+ * Array of the ids of currently open groups
116
+ */
117
+ openIds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),
118
+
119
+ /**
120
+ * Unique name by which the ExpandCollapse controls this element.
121
+ */
122
+ panelId: PropTypes.string.isRequired,
123
+
124
+ /**
125
+ * Function to call on pressing the panel's control, which should open or close the panel.
126
+ * If Panel is a direct child of `ExpandCollapse`, this prop will be provided by the ExpandCollapse parent.
127
+ */
128
+ onToggle: PropTypes.func.isRequired,
129
+
130
+ /**
131
+ * Optional function to call on pressing the panel's control, in addition to opening or closing the panel.
132
+ */
133
+ onPress: PropTypes.func,
134
+
135
+ /**
136
+ * ExpandCollapsePanel's children are the content that is hidden or revealed on open or close, and may be any
137
+ * single React element or a render function which takes this group's isExpanded state, onToggle function and panelId
138
+ */
139
+ children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
140
+
141
+ /**
142
+ * The content inside the always-visible control element that opens and closes the ExpandCollapse when pressed.
143
+ */
144
+ control: ExpandCollapseControl.propTypes.children.isRequired,
145
+
146
+ /**
147
+ * Optional theme token overrides that may be passed to the ExpandCollapseControl element.
148
+ */
149
+ controlTokens: getTokensPropType('ExpandCollapseControl')
150
+ };
151
+ 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,157 @@
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 = _ref => {
16
+ let {
17
+ titleFontSize,
18
+ ...tokens
19
+ } = _ref;
20
+ return applyTextStyles(selectTokens('Typography', { ...tokens,
21
+ fontSize: titleFontSize
22
+ }));
23
+ };
24
+
25
+ const selectContentTextStyles = _ref2 => {
26
+ let {
27
+ contentFontSize,
28
+ ...tokens
29
+ } = _ref2;
30
+ return applyTextStyles(selectTokens('Typography', { ...tokens,
31
+ fontSize: contentFontSize
32
+ }));
33
+ };
34
+
35
+ const selectIconTokens = _ref3 => {
36
+ let {
37
+ iconSize,
38
+ iconColor
39
+ } = _ref3;
40
+ return {
41
+ size: iconSize,
42
+ color: iconColor
43
+ };
44
+ };
45
+
46
+ const selectIconContainerStyles = _ref4 => {
47
+ let {
48
+ iconGap
49
+ } = _ref4;
50
+ return {
51
+ paddingRight: iconGap
52
+ };
53
+ };
54
+ /**
55
+ * A feedback box commonly used with form fields.
56
+ *
57
+ * ### Standalone usage
58
+ * While its primary use is to facilitate feedback states for other form components such as `TextInput`,
59
+ * you may use it standalone.
60
+ *
61
+ * ### Complex content
62
+ * You may pass any React tree as the children of this component, bear in mind that a render function
63
+ * is better suited for styling children based on Feedback's variant.
64
+ *
65
+ * ### Using a render function
66
+ * When a function is passed for rendering content, it will receive the feedback text styles and
67
+ * variant as arguments.
68
+ *
69
+ * ### Accessibility
70
+ * All accessibility props set on this component will be applied to the outer container.
71
+ */
72
+
73
+
74
+ const Feedback = /*#__PURE__*/forwardRef((_ref5, ref) => {
75
+ let {
76
+ title,
77
+ children,
78
+ id,
79
+ validation,
80
+ tokens,
81
+ variant,
82
+ ...rest
83
+ } = _ref5;
84
+ const themeTokens = useThemeTokens('Feedback', tokens, { ...variant,
85
+ validation
86
+ });
87
+ const {
88
+ space
89
+ } = themeTokens;
90
+ const {
91
+ icon: IconComponent
92
+ } = themeTokens;
93
+ const titleTextStyles = selectTitleTextStyles(themeTokens);
94
+ const contentTextStyles = selectContentTextStyles(themeTokens);
95
+ const content = typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
96
+ style: contentTextStyles,
97
+ children: children
98
+ }) : children;
99
+ const selectedProps = selectProps({
100
+ accessibilityRole: validation === 'error' ? 'alert' : undefined,
101
+ ...rest
102
+ });
103
+ return /*#__PURE__*/_jsx(View, {
104
+ ref: ref,
105
+ style: selectStyles(themeTokens),
106
+ nativeID: id,
107
+ ...selectedProps,
108
+ children: /*#__PURE__*/_jsxs(StackView, {
109
+ space: space,
110
+ children: [title !== undefined && /*#__PURE__*/_jsxs(View, {
111
+ style: staticStyles.title,
112
+ children: [IconComponent && /*#__PURE__*/_jsx(View, {
113
+ style: selectIconContainerStyles(themeTokens),
114
+ children: /*#__PURE__*/_jsx(IconComponent, { ...selectIconTokens(themeTokens)
115
+ })
116
+ }), /*#__PURE__*/_jsx(Text, {
117
+ style: titleTextStyles,
118
+ children: title
119
+ })]
120
+ }), content && typeof content === 'function' ? content({
121
+ textStyles: contentTextStyles,
122
+ variant
123
+ }) : content]
124
+ })
125
+ });
126
+ });
127
+ Feedback.displayName = 'Feedback';
128
+ Feedback.propTypes = { ...selectedSystemPropTypes,
129
+
130
+ /**
131
+ * Emphasized summary of the feedback. If an icon is set, it is rendered next to the title.
132
+ */
133
+ title: PropTypes.string,
134
+
135
+ /**
136
+ * Feedback content rendered below the title. A render function `({textStyles, variant}) => {}` is supported.
137
+ */
138
+ children: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.func]),
139
+
140
+ /**
141
+ * Use to visually mark the Feedback as valid or invalid.
142
+ */
143
+ validation: PropTypes.oneOf(['error', 'success']),
144
+
145
+ /** @ignore */
146
+ id: PropTypes.string,
147
+ tokens: getTokensPropType('Feedback'),
148
+ variant: variantProp.propType
149
+ };
150
+ export default Feedback;
151
+ const staticStyles = StyleSheet.create({
152
+ title: {
153
+ display: 'flex',
154
+ flexDirection: 'row',
155
+ alignItems: 'center'
156
+ }
157
+ });
@@ -0,0 +1,2 @@
1
+ import Feedback from './Feedback';
2
+ export default Feedback;
@@ -0,0 +1,153 @@
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((_ref, ref) => {
20
+ let {
21
+ copy = 'en',
22
+ space,
23
+ feedback,
24
+ feedbackPosition = 'top',
25
+ validation,
26
+ legend,
27
+ hint,
28
+ hintPosition,
29
+ tooltip,
30
+ inactive,
31
+ accessibilityRole,
32
+ name: fieldsetName,
33
+ children
34
+ } = _ref;
35
+ // Skips `inputId` because a fieldset' legend describes multiple inputs
36
+ const {
37
+ hintId,
38
+ feedbackId,
39
+ a11yProps
40
+ } = useInputSupports({
41
+ feedback,
42
+ hint,
43
+ label: legend,
44
+ validation
45
+ });
46
+
47
+ const legendContent = legend && /*#__PURE__*/_jsx(Legend, {
48
+ children: /*#__PURE__*/_jsx(InputLabel, {
49
+ copy: copy,
50
+ label: legend,
51
+ hint: hint,
52
+ hintPosition: hintPosition,
53
+ hintId: hintId,
54
+ tooltip: tooltip
55
+ })
56
+ });
57
+
58
+ const feedbackContent = feedback && /*#__PURE__*/_jsx(Feedback, {
59
+ id: feedbackId,
60
+ title: feedback,
61
+ validation: validation
62
+ }); // Some accessibility patterns depend on elements being direct children, e.g. fieldset -> legend,
63
+ // and on MacOS voiceover, radiogroup -> radio. To allow elements to be direct children of the
64
+ // fieldset as much as possible, but also allow different spacing within content and between
65
+ // fieldset / feedback / etc, wrap resolved children in a fragment, and stack with `preserveFragments`.
66
+
67
+
68
+ const childContent = /*#__PURE__*/_jsx(_Fragment, {
69
+ children: typeof children === 'function' ? children(a11yProps) : children
70
+ });
71
+
72
+ const orderedContent = feedbackPosition === 'bottom' ? [legendContent, feedbackContent, childContent] : [legendContent, childContent, feedbackContent];
73
+ const stackedContent = getStackedContent(orderedContent, {
74
+ space,
75
+ preserveFragments: true
76
+ });
77
+ return /*#__PURE__*/_jsx(FieldsetContainer, {
78
+ ref: ref,
79
+ inactive: inactive,
80
+ accessibilityRole: accessibilityRole,
81
+ name: fieldsetName,
82
+ children: stackedContent
83
+ });
84
+ });
85
+ Fieldset.displayName = 'Fieldset';
86
+ Fieldset.propTypes = {
87
+ children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
88
+
89
+ /**
90
+ * Whether the English or French copy will be used (e.g. for accessibility labels).
91
+ */
92
+ copy: PropTypes.oneOf(['en', 'fr']),
93
+
94
+ /**
95
+ * The accessibility role of the `<fieldset>` element itself. Other React Native accessibility
96
+ * props are not supported because there is not an appropriate counterpart for Fieldsets.
97
+ */
98
+ accessibilityRole: PropTypes.string,
99
+
100
+ /**
101
+ * The amout of space between legend, feedback and content; according to the theme's spacing scale.
102
+ * Either a number corresponding to a position on the theme's spacing scale (1 is smallest, 2 is second smallest, etc),
103
+ * or, a SpacingObject with viewport keys and options (see `useSpacingScale` for details).
104
+ */
105
+ space: spacingProps.types.spacingValue,
106
+
107
+ /**
108
+ * The text for the fieldset's legend, describing the fieldset content.
109
+ */
110
+ legend: PropTypes.string,
111
+
112
+ /**
113
+ * A short description of the expected input.
114
+ */
115
+ hint: PropTypes.string,
116
+
117
+ /**
118
+ * Position of the hint relative to label.
119
+ */
120
+ hintPosition: PropTypes.oneOf(['inline', 'below']),
121
+
122
+ /**
123
+ * A detailed description of validation error/success or additional instructions.
124
+ * Visual variant is determined based on the `validation` prop.
125
+ */
126
+ feedback: PropTypes.string,
127
+
128
+ /**
129
+ * Position of the feedback block relative to the fieldset's content.
130
+ */
131
+ feedbackPosition: PropTypes.oneOf(['above', 'below']),
132
+
133
+ /**
134
+ * If true, the fieldset is treated as inactive (setting `disabled` attribute on web).
135
+ */
136
+ inactive: PropTypes.bool,
137
+
138
+ /**
139
+ * Content of an optional `Tooltip`. If set, a tooltip button will be shown next to the label.
140
+ */
141
+ tooltip: PropTypes.string,
142
+
143
+ /**
144
+ * On web, this is passed to the `<fieldset>`'s `name` attribute.
145
+ */
146
+ name: PropTypes.string,
147
+
148
+ /**
149
+ * Use to visually mark an input as valid or invalid.
150
+ */
151
+ validation: PropTypes.oneOf(['error', 'success'])
152
+ };
153
+ export default Fieldset;
@@ -0,0 +1,32 @@
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((_ref, ref) => {
10
+ let {
11
+ children,
12
+ inactive,
13
+ accessibilityRole,
14
+ name: fieldsetName
15
+ } = _ref;
16
+ return /*#__PURE__*/_jsx("fieldset", {
17
+ ref: ref,
18
+ disabled: inactive,
19
+ style: cssReset,
20
+ role: accessibilityRole,
21
+ name: fieldsetName,
22
+ children: children
23
+ });
24
+ });
25
+ FieldsetContainer.displayName = 'FieldsetContainer';
26
+ FieldsetContainer.propTypes = {
27
+ accessibilityRole: PropTypes.string,
28
+ children: PropTypes.node,
29
+ inactive: PropTypes.bool,
30
+ name: PropTypes.string
31
+ };
32
+ export default FieldsetContainer;
@@ -0,0 +1,23 @@
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((_ref, ref) => {
8
+ let {
9
+ children,
10
+ accessibilityRole
11
+ } = _ref;
12
+ return /*#__PURE__*/_jsx(View, {
13
+ ref: ref,
14
+ accessibilityRole: accessibilityRole,
15
+ children: children
16
+ });
17
+ });
18
+ FieldsetContainer.displayName = 'FieldsetContainer';
19
+ FieldsetContainer.propTypes = {
20
+ children: PropTypes.node,
21
+ accessibilityRole: PropTypes.string
22
+ };
23
+ export default FieldsetContainer;
@@ -0,0 +1,24 @@
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((_ref, ref) => {
11
+ let {
12
+ children
13
+ } = _ref;
14
+ return /*#__PURE__*/_jsx("legend", {
15
+ ref: ref,
16
+ style: cssReset,
17
+ children: children
18
+ });
19
+ });
20
+ Legend.displayName = 'Legend';
21
+ Legend.propTypes = {
22
+ children: PropTypes.node
23
+ };
24
+ export default Legend;
@@ -0,0 +1,31 @@
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((_ref, ref) => {
12
+ let {
13
+ children
14
+ } = _ref;
15
+ return /*#__PURE__*/_jsx(View, {
16
+ ref: ref,
17
+ style: staticStyles.stretch,
18
+ children: children
19
+ });
20
+ });
21
+ Legend.displayName = 'Legend';
22
+ Legend.propTypes = {
23
+ children: PropTypes.node
24
+ };
25
+ const staticStyles = StyleSheet.create({
26
+ stretch: {
27
+ width: '100%',
28
+ flexGrow: 1
29
+ }
30
+ });
31
+ 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;