@telus-uds/components-base 1.8.3 → 1.9.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 (284) hide show
  1. package/CHANGELOG.md +37 -2
  2. package/component-docs.json +17 -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/Card/Card.js +9 -4
  8. package/lib/Checkbox/Checkbox.js +5 -3
  9. package/lib/Checkbox/CheckboxGroup.js +2 -2
  10. package/lib/Divider/Divider.js +2 -2
  11. package/lib/ExpandCollapse/Panel.js +12 -18
  12. package/lib/FlexGrid/Col/Col.js +1 -1
  13. package/lib/Icon/Icon.js +1 -1
  14. package/lib/Link/InlinePressable.js +5 -1
  15. package/lib/Link/LinkBase.js +5 -2
  16. package/lib/List/List.js +8 -2
  17. package/lib/Pagination/PageButton.js +2 -2
  18. package/lib/Pagination/Pagination.js +5 -3
  19. package/lib/Pagination/usePagination.js +2 -2
  20. package/lib/Progress/ProgressBar.js +3 -3
  21. package/lib/Progress/ProgressBarBackground.js +3 -3
  22. package/lib/Radio/Radio.js +2 -2
  23. package/lib/Radio/RadioGroup.js +2 -2
  24. package/lib/RadioCard/RadioCard.js +1 -1
  25. package/lib/RadioCard/RadioCardGroup.js +2 -2
  26. package/lib/Search/Search.js +1 -1
  27. package/lib/SideNav/SideNav.js +2 -2
  28. package/lib/Skeleton/Skeleton.js +1 -1
  29. package/lib/Skeleton/skeletonWebAnimation.js +1 -1
  30. package/lib/StackView/StackWrap.js +3 -1
  31. package/lib/StackView/getStackedContent.js +2 -2
  32. package/lib/Tabs/Tabs.js +28 -3
  33. package/lib/Tabs/TabsItem.js +5 -6
  34. package/lib/Tags/Tags.js +1 -1
  35. package/lib/TextInput/TextInput.js +0 -11
  36. package/lib/TextInput/TextInputBase.js +9 -0
  37. package/lib/TextInput/propTypes.js +3 -8
  38. package/lib/ThemeProvider/utils/styles.js +2 -2
  39. package/lib/ThemeProvider/utils/theme-tokens.js +7 -9
  40. package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
  41. package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
  42. package/lib/Tooltip/Backdrop.js +2 -10
  43. package/lib/utils/animation/useVerticalExpandAnimation.js +40 -14
  44. package/lib/utils/children.js +2 -2
  45. package/lib/utils/input.js +6 -12
  46. package/lib/utils/props/componentPropType.js +3 -3
  47. package/lib/utils/props/selectSystemProps.js +2 -2
  48. package/lib/utils/props/textInputProps.js +8 -1
  49. package/lib/utils/props/tokens.js +2 -2
  50. package/lib/utils/useSpacingScale.js +3 -1
  51. package/lib/utils/useUniqueId.js +1 -1
  52. package/lib-module/A11yInfoProvider/index.js +63 -0
  53. package/lib-module/A11yText/index.js +56 -0
  54. package/lib-module/ActivityIndicator/Spinner.js +77 -0
  55. package/lib-module/ActivityIndicator/Spinner.native.js +144 -0
  56. package/lib-module/ActivityIndicator/index.js +41 -0
  57. package/lib-module/ActivityIndicator/shared.js +12 -0
  58. package/lib-module/BaseProvider/index.js +29 -0
  59. package/lib-module/Box/Box.js +244 -0
  60. package/lib-module/Box/index.js +2 -0
  61. package/lib-module/Button/Button.js +26 -0
  62. package/lib-module/Button/ButtonBase.js +271 -0
  63. package/lib-module/Button/ButtonGroup.js +247 -0
  64. package/lib-module/Button/ButtonLink.js +40 -0
  65. package/lib-module/Button/index.js +4 -0
  66. package/lib-module/Button/propTypes.js +36 -0
  67. package/lib-module/Card/Card.js +85 -0
  68. package/lib-module/Card/CardBase.js +66 -0
  69. package/lib-module/Card/PressableCardBase.js +114 -0
  70. package/lib-module/Card/index.js +4 -0
  71. package/lib-module/Checkbox/Checkbox.js +348 -0
  72. package/lib-module/Checkbox/CheckboxGroup.js +233 -0
  73. package/lib-module/Checkbox/CheckboxInput.js +60 -0
  74. package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
  75. package/lib-module/Checkbox/index.js +3 -0
  76. package/lib-module/Divider/Divider.js +124 -0
  77. package/lib-module/Divider/index.js +2 -0
  78. package/lib-module/ExpandCollapse/Accordion.js +15 -0
  79. package/lib-module/ExpandCollapse/Control.js +136 -0
  80. package/lib-module/ExpandCollapse/ExpandCollapse.js +95 -0
  81. package/lib-module/ExpandCollapse/Panel.js +159 -0
  82. package/lib-module/ExpandCollapse/index.js +7 -0
  83. package/lib-module/Feedback/Feedback.js +157 -0
  84. package/lib-module/Feedback/index.js +2 -0
  85. package/lib-module/Fieldset/Fieldset.js +153 -0
  86. package/lib-module/Fieldset/FieldsetContainer.js +32 -0
  87. package/lib-module/Fieldset/FieldsetContainer.native.js +23 -0
  88. package/lib-module/Fieldset/Legend.js +24 -0
  89. package/lib-module/Fieldset/Legend.native.js +31 -0
  90. package/lib-module/Fieldset/cssReset.js +14 -0
  91. package/lib-module/Fieldset/index.js +2 -0
  92. package/lib-module/FlexGrid/Col/Col.js +276 -0
  93. package/lib-module/FlexGrid/Col/index.js +2 -0
  94. package/lib-module/FlexGrid/FlexGrid.js +148 -0
  95. package/lib-module/FlexGrid/Row/Row.js +184 -0
  96. package/lib-module/FlexGrid/Row/index.js +2 -0
  97. package/lib-module/FlexGrid/helpers/index.js +18 -0
  98. package/lib-module/FlexGrid/index.js +2 -0
  99. package/lib-module/FlexGrid/providers/GutterContext.js +3 -0
  100. package/lib-module/HorizontalScroll/HorizontalScroll.js +175 -0
  101. package/lib-module/HorizontalScroll/HorizontalScrollButton.js +81 -0
  102. package/lib-module/HorizontalScroll/ScrollViewEnd.js +48 -0
  103. package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +27 -0
  104. package/lib-module/HorizontalScroll/dictionary.js +11 -0
  105. package/lib-module/HorizontalScroll/index.js +11 -0
  106. package/lib-module/HorizontalScroll/itemPositions.js +112 -0
  107. package/lib-module/Icon/Icon.js +62 -0
  108. package/lib-module/Icon/IconText.js +83 -0
  109. package/lib-module/Icon/index.js +4 -0
  110. package/lib-module/IconButton/IconButton.js +122 -0
  111. package/lib-module/IconButton/index.js +2 -0
  112. package/lib-module/InputLabel/InputLabel.js +148 -0
  113. package/lib-module/InputLabel/LabelContent.js +27 -0
  114. package/lib-module/InputLabel/LabelContent.native.js +19 -0
  115. package/lib-module/InputLabel/index.js +2 -0
  116. package/lib-module/InputSupports/InputSupports.js +96 -0
  117. package/lib-module/InputSupports/index.js +2 -0
  118. package/lib-module/InputSupports/useInputSupports.js +32 -0
  119. package/lib-module/Link/ChevronLink.js +52 -0
  120. package/lib-module/Link/InlinePressable.js +44 -0
  121. package/lib-module/Link/InlinePressable.native.js +89 -0
  122. package/lib-module/Link/Link.js +28 -0
  123. package/lib-module/Link/LinkBase.js +243 -0
  124. package/lib-module/Link/TextButton.js +35 -0
  125. package/lib-module/Link/index.js +5 -0
  126. package/lib-module/List/List.js +62 -0
  127. package/lib-module/List/ListItem.js +248 -0
  128. package/lib-module/List/index.js +5 -0
  129. package/lib-module/Modal/Modal.js +222 -0
  130. package/lib-module/Modal/dictionary.js +9 -0
  131. package/lib-module/Modal/index.js +2 -0
  132. package/lib-module/Notification/Notification.js +209 -0
  133. package/lib-module/Notification/dictionary.js +8 -0
  134. package/lib-module/Notification/index.js +2 -0
  135. package/lib-module/Pagination/PageButton.js +66 -0
  136. package/lib-module/Pagination/Pagination.js +153 -0
  137. package/lib-module/Pagination/SideButton.js +106 -0
  138. package/lib-module/Pagination/dictionary.js +18 -0
  139. package/lib-module/Pagination/index.js +2 -0
  140. package/lib-module/Pagination/usePagination.js +73 -0
  141. package/lib-module/Progress/Progress.js +89 -0
  142. package/lib-module/Progress/ProgressBar.js +138 -0
  143. package/lib-module/Progress/ProgressBarBackground.js +42 -0
  144. package/lib-module/Progress/index.js +4 -0
  145. package/lib-module/Radio/Radio.js +285 -0
  146. package/lib-module/Radio/RadioButton.js +138 -0
  147. package/lib-module/Radio/RadioGroup.js +243 -0
  148. package/lib-module/Radio/RadioInput.js +62 -0
  149. package/lib-module/Radio/RadioInput.native.js +6 -0
  150. package/lib-module/Radio/index.js +3 -0
  151. package/lib-module/RadioCard/RadioCard.js +219 -0
  152. package/lib-module/RadioCard/RadioCardGroup.js +250 -0
  153. package/lib-module/RadioCard/index.js +3 -0
  154. package/lib-module/Search/Search.js +261 -0
  155. package/lib-module/Search/dictionary.js +12 -0
  156. package/lib-module/Search/index.js +2 -0
  157. package/lib-module/Select/Group.js +21 -0
  158. package/lib-module/Select/Group.native.js +15 -0
  159. package/lib-module/Select/Item.js +20 -0
  160. package/lib-module/Select/Item.native.js +3 -0
  161. package/lib-module/Select/Picker.js +68 -0
  162. package/lib-module/Select/Picker.native.js +120 -0
  163. package/lib-module/Select/Select.js +337 -0
  164. package/lib-module/Select/index.js +6 -0
  165. package/lib-module/SideNav/Item.js +145 -0
  166. package/lib-module/SideNav/ItemContent.js +48 -0
  167. package/lib-module/SideNav/ItemsGroup.js +117 -0
  168. package/lib-module/SideNav/SideNav.js +136 -0
  169. package/lib-module/SideNav/index.js +1 -0
  170. package/lib-module/Skeleton/Skeleton.js +179 -0
  171. package/lib-module/Skeleton/index.js +2 -0
  172. package/lib-module/Skeleton/skeleton.constant.js +3 -0
  173. package/lib-module/Skeleton/skeletonWebAnimation.js +18 -0
  174. package/lib-module/Skeleton/useSkeletonNativeAnimation.js +24 -0
  175. package/lib-module/Spacer/Spacer.js +98 -0
  176. package/lib-module/Spacer/index.js +2 -0
  177. package/lib-module/StackView/StackView.js +125 -0
  178. package/lib-module/StackView/StackWrap.js +50 -0
  179. package/lib-module/StackView/StackWrap.native.js +3 -0
  180. package/lib-module/StackView/StackWrapBox.js +115 -0
  181. package/lib-module/StackView/StackWrapGap.js +59 -0
  182. package/lib-module/StackView/common.js +35 -0
  183. package/lib-module/StackView/getStackedContent.js +124 -0
  184. package/lib-module/StackView/index.js +5 -0
  185. package/lib-module/StepTracker/Step.js +248 -0
  186. package/lib-module/StepTracker/StepTracker.js +185 -0
  187. package/lib-module/StepTracker/dictionary.js +10 -0
  188. package/lib-module/StepTracker/index.js +2 -0
  189. package/lib-module/Tabs/Tabs.js +143 -0
  190. package/lib-module/Tabs/TabsItem.js +224 -0
  191. package/lib-module/Tabs/index.js +2 -0
  192. package/lib-module/Tags/Tags.js +251 -0
  193. package/lib-module/Tags/index.js +2 -0
  194. package/lib-module/TextInput/TextArea.js +94 -0
  195. package/lib-module/TextInput/TextInput.js +64 -0
  196. package/lib-module/TextInput/TextInputBase.js +254 -0
  197. package/lib-module/TextInput/index.js +3 -0
  198. package/lib-module/TextInput/propTypes.js +33 -0
  199. package/lib-module/ThemeProvider/ThemeProvider.js +36 -0
  200. package/lib-module/ThemeProvider/index.js +6 -0
  201. package/lib-module/ThemeProvider/useSetTheme.js +25 -0
  202. package/lib-module/ThemeProvider/useTheme.js +14 -0
  203. package/lib-module/ThemeProvider/useThemeTokens.js +110 -0
  204. package/lib-module/ThemeProvider/utils/index.js +2 -0
  205. package/lib-module/ThemeProvider/utils/styles.js +181 -0
  206. package/lib-module/ThemeProvider/utils/theme-tokens.js +163 -0
  207. package/lib-module/ToggleSwitch/ToggleSwitch.js +250 -0
  208. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +220 -0
  209. package/lib-module/ToggleSwitch/index.js +3 -0
  210. package/lib-module/Tooltip/Backdrop.js +45 -0
  211. package/lib-module/Tooltip/Backdrop.native.js +44 -0
  212. package/lib-module/Tooltip/Tooltip.js +348 -0
  213. package/lib-module/Tooltip/dictionary.js +8 -0
  214. package/lib-module/Tooltip/getTooltipPosition.js +175 -0
  215. package/lib-module/Tooltip/index.js +2 -0
  216. package/lib-module/TooltipButton/TooltipButton.js +78 -0
  217. package/lib-module/TooltipButton/index.js +2 -0
  218. package/lib-module/Typography/Typography.js +124 -0
  219. package/lib-module/Typography/index.js +2 -0
  220. package/lib-module/ViewportProvider/ViewportProvider.js +29 -0
  221. package/lib-module/ViewportProvider/index.js +3 -0
  222. package/lib-module/ViewportProvider/useViewport.js +3 -0
  223. package/lib-module/ViewportProvider/useViewportListener.js +46 -0
  224. package/lib-module/index.js +48 -0
  225. package/lib-module/utils/a11y/index.js +2 -0
  226. package/lib-module/utils/a11y/semantics.js +157 -0
  227. package/lib-module/utils/a11y/textSize.js +36 -0
  228. package/lib-module/utils/animation/index.js +2 -0
  229. package/lib-module/utils/animation/useVerticalExpandAnimation.js +88 -0
  230. package/lib-module/utils/children.js +119 -0
  231. package/lib-module/utils/containUniqueFields.js +26 -0
  232. package/lib-module/utils/index.js +16 -0
  233. package/lib-module/utils/info/index.js +7 -0
  234. package/lib-module/utils/info/platform/index.js +11 -0
  235. package/lib-module/utils/info/platform/platform.android.js +1 -0
  236. package/lib-module/utils/info/platform/platform.ios.js +1 -0
  237. package/lib-module/utils/info/platform/platform.js +1 -0
  238. package/lib-module/utils/info/platform/platform.native.js +4 -0
  239. package/lib-module/utils/info/versions.js +5 -0
  240. package/lib-module/utils/input.js +179 -0
  241. package/lib-module/utils/pressability.js +111 -0
  242. package/lib-module/utils/props/a11yProps.js +140 -0
  243. package/lib-module/utils/props/clickProps.js +26 -0
  244. package/lib-module/utils/props/componentPropType.js +63 -0
  245. package/lib-module/utils/props/copyPropTypes.js +2 -0
  246. package/lib-module/utils/props/getPropSelector.js +9 -0
  247. package/lib-module/utils/props/handlerProps.js +65 -0
  248. package/lib-module/utils/props/hrefAttrsProp.js +33 -0
  249. package/lib-module/utils/props/index.js +19 -0
  250. package/lib-module/utils/props/inputSupportsProps.js +62 -0
  251. package/lib-module/utils/props/linkProps.js +44 -0
  252. package/lib-module/utils/props/paddingProp.js +9 -0
  253. package/lib-module/utils/props/pressProps.js +42 -0
  254. package/lib-module/utils/props/rectProp.js +9 -0
  255. package/lib-module/utils/props/responsiveProps.js +30 -0
  256. package/lib-module/utils/props/selectSystemProps.js +24 -0
  257. package/lib-module/utils/props/spacingProps.js +56 -0
  258. package/lib-module/utils/props/textInputProps.js +201 -0
  259. package/lib-module/utils/props/textProps.js +59 -0
  260. package/lib-module/utils/props/tokens.js +133 -0
  261. package/lib-module/utils/props/variantProp.js +18 -0
  262. package/lib-module/utils/props/viewProps.js +22 -0
  263. package/lib-module/utils/ssr.js +38 -0
  264. package/lib-module/utils/useCopy.js +44 -0
  265. package/lib-module/utils/useHash.js +45 -0
  266. package/lib-module/utils/useHash.native.js +7 -0
  267. package/lib-module/utils/useResponsiveProp.js +47 -0
  268. package/lib-module/utils/useSpacingScale.js +125 -0
  269. package/lib-module/utils/useUniqueId.js +13 -0
  270. package/lib-module/utils/withLinkRouter.js +83 -0
  271. package/package.json +3 -3
  272. package/src/Card/Card.jsx +6 -4
  273. package/src/Checkbox/Checkbox.jsx +3 -1
  274. package/src/ExpandCollapse/Panel.jsx +10 -20
  275. package/src/Link/InlinePressable.jsx +5 -2
  276. package/src/Link/LinkBase.jsx +4 -1
  277. package/src/List/List.jsx +6 -2
  278. package/src/Tabs/Tabs.jsx +24 -2
  279. package/src/Tabs/TabsItem.jsx +6 -5
  280. package/src/TextInput/TextInput.jsx +1 -8
  281. package/src/TextInput/TextInputBase.jsx +11 -1
  282. package/src/TextInput/propTypes.js +3 -7
  283. package/src/utils/animation/useVerticalExpandAnimation.js +47 -13
  284. package/src/utils/props/textInputProps.js +7 -1
@@ -0,0 +1,122 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Pressable from "react-native-web/dist/exports/Pressable";
4
+ import Platform from "react-native-web/dist/exports/Platform";
5
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
6
+ import View from "react-native-web/dist/exports/View";
7
+ import { applyOuterBorder, useThemeTokensCallback, applyShadowToken } from '../ThemeProvider';
8
+ import { a11yProps, clickProps, getTokensPropType, hrefAttrsProp, linkProps, resolvePressableState, selectSystemProps, selectTokens, variantProp, viewProps, withLinkRouter } from '../utils';
9
+ import Icon from '../Icon';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
12
+
13
+ const selectOuterStyle = _ref => {
14
+ let {
15
+ backgroundColor,
16
+ borderRadius,
17
+ outerBorderWidth,
18
+ outerBorderColor,
19
+ outerBorderGap,
20
+ shadow
21
+ } = _ref;
22
+ return [{
23
+ backgroundColor,
24
+ ...applyShadowToken(shadow),
25
+ ...applyOuterBorder({
26
+ borderRadius,
27
+ outerBorderWidth,
28
+ outerBorderColor,
29
+ outerBorderGap
30
+ }),
31
+ ...Platform.select({
32
+ web: {
33
+ outline: 'none',
34
+ display: 'inline-flex'
35
+ }
36
+ })
37
+ }, staticStyles.outer];
38
+ };
39
+
40
+ const selectInnerStyle = _ref2 => {
41
+ let {
42
+ borderColor,
43
+ borderWidth = 0,
44
+ borderRadius,
45
+ padding = 0
46
+ } = _ref2;
47
+ return {
48
+ // Inner borders animate with the icon and should be treated like a themable feature of the icon
49
+ borderColor,
50
+ borderRadius,
51
+ borderWidth,
52
+ padding: Math.max(0, padding - borderWidth) // Stable size as border changes
53
+
54
+ };
55
+ };
56
+ /**
57
+ * A pressable themeless base component that handles pressable states and passes tokens
58
+ * based on these to an outer border and a base Card component. Not intended to be used in
59
+ * apps or sites directly: build themed components on top of this.
60
+ */
61
+
62
+
63
+ const IconButton = /*#__PURE__*/forwardRef((_ref3, ref) => {
64
+ let {
65
+ tokens,
66
+ variant,
67
+ icon: IconComponent,
68
+ href,
69
+ hrefAttrs,
70
+ accessibilityRole = href ? 'link' : 'button',
71
+ ...rawRest
72
+ } = _ref3;
73
+ const {
74
+ onPress,
75
+ ...rest
76
+ } = clickProps.toPressProps(rawRest);
77
+ const selectedProps = selectProps({ ...rest,
78
+ accessibilityRole
79
+ });
80
+ const handlePress = linkProps.handleHref({
81
+ href,
82
+ onPress
83
+ });
84
+ const getTokens = useThemeTokensCallback('IconButton', tokens, variant);
85
+
86
+ const getOuterStyle = pressableState => selectOuterStyle(getTokens(resolvePressableState(pressableState)));
87
+
88
+ return /*#__PURE__*/_jsx(Pressable, {
89
+ ref: ref,
90
+ href: href,
91
+ onPress: handlePress,
92
+ hrefAttrs: hrefAttrs,
93
+ style: getOuterStyle,
94
+ ...selectedProps,
95
+ children: pressableState => {
96
+ const themeTokens = getTokens(resolvePressableState(pressableState));
97
+ return /*#__PURE__*/_jsx(View, {
98
+ style: selectInnerStyle(themeTokens),
99
+ children: /*#__PURE__*/_jsx(Icon, {
100
+ icon: IconComponent,
101
+ title: selectedProps.accessibilityLabel,
102
+ tokens: selectTokens('Icon', themeTokens, 'icon')
103
+ })
104
+ });
105
+ }
106
+ });
107
+ });
108
+ IconButton.displayName = 'IconButton';
109
+ IconButton.propTypes = { ...selectedSystemPropTypes,
110
+ variant: variantProp.propType,
111
+ tokens: getTokensPropType('IconButton'),
112
+ icon: PropTypes.elementType.isRequired,
113
+ href: PropTypes.string,
114
+ hrefAttrs: PropTypes.shape(hrefAttrsProp.types),
115
+ onPress: PropTypes.func
116
+ };
117
+ const staticStyles = StyleSheet.create({
118
+ outer: {
119
+ alignSelf: 'flex-start'
120
+ }
121
+ });
122
+ export default withLinkRouter(IconButton);
@@ -0,0 +1,2 @@
1
+ import IconButton from './IconButton';
2
+ export default IconButton;
@@ -0,0 +1,148 @@
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 LabelContent from './LabelContent';
9
+ import Tooltip from '../Tooltip';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ import { Fragment as _Fragment } from "react/jsx-runtime";
13
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
14
+
15
+ const selectLabelStyles = tokens => applyTextStyles(selectTokens('Typography', tokens));
16
+
17
+ const selectHintStyles = _ref => {
18
+ let {
19
+ hintColor,
20
+ hintFontName,
21
+ hintFontSize,
22
+ hintFontWeight,
23
+ hintLineHeight
24
+ } = _ref;
25
+ return applyTextStyles({
26
+ color: hintColor,
27
+ fontName: hintFontName,
28
+ fontSize: hintFontSize,
29
+ fontWeight: hintFontWeight,
30
+ lineHeight: hintLineHeight
31
+ });
32
+ };
33
+
34
+ const selectGapStyles = _ref2 => {
35
+ let {
36
+ gap
37
+ } = _ref2;
38
+ return {
39
+ marginRight: gap
40
+ };
41
+ };
42
+
43
+ const InputLabel = /*#__PURE__*/forwardRef((_ref3, ref) => {
44
+ let {
45
+ copy = 'en',
46
+ label,
47
+ forId,
48
+ hint,
49
+ hintPosition = 'inline',
50
+ hintId,
51
+ tooltip,
52
+ tokens,
53
+ variant,
54
+ ...rest
55
+ } = _ref3;
56
+ const themeTokens = useThemeTokens('InputLabel', tokens, variant);
57
+ const hasTooltip = tooltip !== undefined;
58
+ const isHintInline = hintPosition === 'inline';
59
+ return /*#__PURE__*/_jsxs(_Fragment, {
60
+ children: [/*#__PURE__*/_jsxs(View, {
61
+ ref: ref,
62
+ style: staticStyles.container,
63
+ ...selectProps(rest),
64
+ children: [/*#__PURE__*/_jsx(Text, {
65
+ style: [selectLabelStyles(themeTokens), selectGapStyles(themeTokens), staticStyles.label],
66
+ children: /*#__PURE__*/_jsx(LabelContent, {
67
+ forId: forId,
68
+ children: label
69
+ })
70
+ }), hint && isHintInline && /*#__PURE__*/_jsx(Text, {
71
+ style: [selectHintStyles(themeTokens), hasTooltip && selectGapStyles(themeTokens), staticStyles.label],
72
+ nativeID: hintId,
73
+ children: hint
74
+ }), hasTooltip && /*#__PURE__*/_jsx(View, {
75
+ style: [staticStyles.tooltipAlign, {
76
+ height: themeTokens.fontSize * themeTokens.lineHeight
77
+ }],
78
+ children: /*#__PURE__*/_jsx(Tooltip, {
79
+ content: tooltip,
80
+ copy: copy
81
+ })
82
+ })]
83
+ }), hint && !isHintInline && /*#__PURE__*/_jsx(Text, {
84
+ style: [selectHintStyles(themeTokens), staticStyles.hintBelow],
85
+ nativeID: hintId,
86
+ children: hint
87
+ })]
88
+ });
89
+ });
90
+ InputLabel.displayName = 'InputLabel';
91
+ InputLabel.propTypes = { ...selectedSystemPropTypes,
92
+
93
+ /**
94
+ * Whether the English or French copy will be used (e.g. for accessibility labels).
95
+ */
96
+ copy: PropTypes.oneOf(['en', 'fr']),
97
+
98
+ /**
99
+ * The input label.
100
+ */
101
+ label: PropTypes.string.isRequired,
102
+
103
+ /**
104
+ * The id attribute of the input which this label refers to.
105
+ */
106
+ forId: PropTypes.string,
107
+
108
+ /**
109
+ * A short description of the expected input.
110
+ */
111
+ hint: PropTypes.string,
112
+
113
+ /**
114
+ * Position of the hint relative to label. Use `below` to display a larger hint below the label.
115
+ */
116
+ hintPosition: PropTypes.oneOf(['inline', 'below']),
117
+
118
+ /**
119
+ * The id attribute passed down to the hint element.
120
+ */
121
+ hintId: PropTypes.string,
122
+
123
+ /**
124
+ * Content of an optional `Tooltip`. If set, a tooltip button will be shown next to the label.
125
+ */
126
+ tooltip: PropTypes.string,
127
+ tokens: getTokensPropType('InputLabel'),
128
+ variant: variantProp.propType
129
+ };
130
+ export default InputLabel;
131
+ const staticStyles = StyleSheet.create({
132
+ container: {
133
+ flexShrink: 1,
134
+ flexDirection: 'row',
135
+ alignItems: 'baseline'
136
+ },
137
+ label: {
138
+ flexShrink: 1
139
+ },
140
+ hintBelow: {
141
+ flexBasis: '100%',
142
+ flexShrink: 0
143
+ },
144
+ tooltipAlign: {
145
+ alignSelf: 'flex-start',
146
+ justifyContent: 'center'
147
+ }
148
+ });
@@ -0,0 +1,27 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ const LabelContent = /*#__PURE__*/forwardRef((_ref, ref) => {
5
+ let {
6
+ children,
7
+ forId
8
+ } = _ref;
9
+ return /*#__PURE__*/_jsx("label", {
10
+ ref: ref,
11
+ htmlFor: forId,
12
+ style: staticStyles.inheritCursor,
13
+ children: children
14
+ });
15
+ });
16
+ LabelContent.displayName = 'LabelContent';
17
+ LabelContent.propTypes = {
18
+ children: PropTypes.string,
19
+ forId: PropTypes.string
20
+ }; // Note that <label> is not React Native, so we can't use `StyleSheet.create` here
21
+
22
+ const staticStyles = {
23
+ inheritCursor: {
24
+ cursor: 'inherit'
25
+ }
26
+ };
27
+ export default LabelContent;
@@ -0,0 +1,19 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import View from "react-native-web/dist/exports/View"; // Since there's no equivalent for web's <label> element we're simply rendering whatever is passed to this component.
4
+
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const LabelContent = /*#__PURE__*/forwardRef((_ref, ref) => {
7
+ let {
8
+ children
9
+ } = _ref;
10
+ return ref ? /*#__PURE__*/_jsx(View, {
11
+ ref: ref,
12
+ children: children
13
+ }) : children;
14
+ });
15
+ LabelContent.displayName = 'LabelContent';
16
+ LabelContent.propTypes = {
17
+ children: PropTypes.node
18
+ };
19
+ export default LabelContent;
@@ -0,0 +1,2 @@
1
+ import InputLabel from './InputLabel';
2
+ export default InputLabel;
@@ -0,0 +1,96 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import InputLabel from '../InputLabel';
4
+ import Feedback from '../Feedback';
5
+ import StackView from '../StackView';
6
+ import { useThemeTokens } from '../ThemeProvider';
7
+ import useInputSupports from './useInputSupports';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ const InputSupports = /*#__PURE__*/forwardRef((_ref, ref) => {
11
+ let {
12
+ children,
13
+ copy = 'en',
14
+ label,
15
+ hint,
16
+ hintPosition = 'inline',
17
+ feedback,
18
+ tooltip,
19
+ validation
20
+ } = _ref;
21
+ const {
22
+ space
23
+ } = useThemeTokens('InputSupports');
24
+ const {
25
+ inputId,
26
+ hintId,
27
+ feedbackId,
28
+ a11yProps
29
+ } = useInputSupports({
30
+ feedback,
31
+ hint,
32
+ label,
33
+ validation
34
+ });
35
+ return /*#__PURE__*/_jsxs(StackView, {
36
+ space: space,
37
+ ref: ref,
38
+ children: [label && /*#__PURE__*/_jsx(InputLabel, {
39
+ copy: copy,
40
+ label: label,
41
+ hint: hint,
42
+ hintPosition: hintPosition,
43
+ hintId: hintId,
44
+ tooltip: tooltip,
45
+ forId: inputId
46
+ }), typeof children === 'function' ? children({
47
+ inputId,
48
+ ...a11yProps
49
+ }) : children, feedback && /*#__PURE__*/_jsx(Feedback, {
50
+ id: feedbackId,
51
+ title: feedback,
52
+ validation: validation
53
+ })]
54
+ });
55
+ });
56
+ InputSupports.displayName = 'InputSupports';
57
+ InputSupports.propTypes = {
58
+ children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
59
+
60
+ /**
61
+ * Whether the English or French copy will be used (e.g. for accessibility labels).
62
+ */
63
+ copy: PropTypes.oneOf(['en', 'fr']),
64
+
65
+ /**
66
+ * The input label.
67
+ */
68
+ label: PropTypes.string,
69
+
70
+ /**
71
+ * A short description of the expected input.
72
+ */
73
+ hint: PropTypes.string,
74
+
75
+ /**
76
+ * Position of the hint relative to label.
77
+ */
78
+ hintPosition: PropTypes.oneOf(['inline', 'below']),
79
+
80
+ /**
81
+ * A detailed description of validation error/success or additional instructions.
82
+ * Visual variant is determined based on the `validation` prop.
83
+ */
84
+ feedback: PropTypes.string,
85
+
86
+ /**
87
+ * Content of an optional `Tooltip`. If set, a tooltip button will be shown next to the label.
88
+ */
89
+ tooltip: PropTypes.string,
90
+
91
+ /**
92
+ * Use to visually mark an input as valid or invalid.
93
+ */
94
+ validation: PropTypes.oneOf(['error', 'success'])
95
+ };
96
+ export default InputSupports;
@@ -0,0 +1,2 @@
1
+ import InputSupports from './InputSupports';
2
+ export default InputSupports;
@@ -0,0 +1,32 @@
1
+ import useUniqueId from '../utils/useUniqueId';
2
+
3
+ const joinDefined = array => array.filter(item => item !== undefined).join(' ');
4
+
5
+ const useInputSupports = _ref => {
6
+ let {
7
+ label,
8
+ feedback,
9
+ validation,
10
+ hint
11
+ } = _ref;
12
+ const hasValidationError = validation === 'error';
13
+ const inputId = useUniqueId('input');
14
+ const hintId = useUniqueId('input-hint');
15
+ const feedbackId = useUniqueId('input-feedback');
16
+ const a11yProps = {
17
+ accessibilityLabel: label,
18
+ accessibilityHint: joinDefined([!hasValidationError && feedback, hint]),
19
+ // native only -> replaced with describedBy on web
20
+ accessibilityDescribedBy: joinDefined([!hasValidationError && feedback && feedbackId, // feedback receives a11yRole=alert on error, so there's no need to include it here
21
+ hint && hintId]),
22
+ accessibilityInvalid: hasValidationError
23
+ };
24
+ return {
25
+ inputId,
26
+ hintId,
27
+ feedbackId,
28
+ a11yProps
29
+ };
30
+ };
31
+
32
+ export default useInputSupports;
@@ -0,0 +1,52 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useThemeTokensCallback } from '../ThemeProvider';
4
+ import { selectTokens, getTokensPropType } from '../utils';
5
+ import LinkBase from './LinkBase';
6
+ /**
7
+ * `ChevronLink` is a convenience wrapper around the `Link` component to enable "directional" links.
8
+ * It effectively pre-binds left and right icons, and a directional translation of the icon on hover.
9
+ *
10
+ * ChevronLink is not intended to be deeply themable; variants passed to ChevronLink are forwarded to Link.
11
+ */
12
+
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ const ChevronLink = /*#__PURE__*/forwardRef((_ref, ref) => {
15
+ let {
16
+ direction = 'right',
17
+ children,
18
+ tokens,
19
+ variant,
20
+ dataSet,
21
+ ...linkProps
22
+ } = _ref;
23
+ const getChevronTokens = useThemeTokensCallback('ChevronLink', tokens, variant);
24
+
25
+ const applyChevronTokens = linkState => {
26
+ const {
27
+ leftIcon,
28
+ rightIcon,
29
+ iconDisplace,
30
+ ...otherTokens
31
+ } = getChevronTokens(linkState);
32
+ return { ...selectTokens('Link', otherTokens),
33
+ icon: direction === 'right' ? rightIcon : leftIcon,
34
+ iconTranslateX: iconDisplace * (direction === 'right' ? 1 : -1) || 0
35
+ };
36
+ };
37
+
38
+ const getTokens = useThemeTokensCallback('Link', applyChevronTokens, variant);
39
+ return /*#__PURE__*/_jsx(LinkBase, { ...linkProps,
40
+ iconPosition: direction,
41
+ tokens: getTokens,
42
+ dataSet: dataSet,
43
+ ref: ref,
44
+ children: children
45
+ });
46
+ });
47
+ ChevronLink.displayName = 'ChevronLink';
48
+ ChevronLink.propTypes = { ...LinkBase.propTypes,
49
+ tokens: getTokensPropType('ChevronLink', 'Link'),
50
+ direction: PropTypes.oneOf(['left', 'right'])
51
+ };
52
+ export default ChevronLink;
@@ -0,0 +1,44 @@
1
+ import React, { forwardRef } from 'react';
2
+ import Pressable from "react-native-web/dist/exports/Pressable";
3
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
4
+ /**
5
+ * @typedef {import('react-native').PressableProps} PressableProps
6
+ */
7
+
8
+ /**
9
+ * InlinePressable is an alternative to React Native's Pressable that works better when nested
10
+ * inline inside Text. It accepts the same props as React Native's Pressable.
11
+ *
12
+ * On Web it simply passes its props to Pressable and defaults to `inline-flex` instead of `flex`.
13
+ *
14
+ * @param {PressableProps} PressableProps
15
+ */
16
+ // React Native exports prop Types but not propTypes, use JSDoc types here rather than duplicate RN
17
+ // eslint-disable-next-line react/prop-types
18
+
19
+ import { jsx as _jsx } from "react/jsx-runtime";
20
+ const InlinePressable = /*#__PURE__*/forwardRef((_ref, ref) => {
21
+ let {
22
+ children,
23
+ style,
24
+ inline = false,
25
+ ...props
26
+ } = _ref;
27
+ return /*#__PURE__*/_jsx(Pressable, {
28
+ ref: ref,
29
+ style: pressState => [staticStyles[inline ? 'inline' : 'inlineFlex'], typeof style === 'function' ? style(pressState) : style],
30
+ ...props,
31
+ children: pressState => typeof children === 'function' ? children(pressState) : children
32
+ });
33
+ });
34
+ InlinePressable.displayName = 'InlinePressable';
35
+ const staticStyles = StyleSheet.create({
36
+ inline: {
37
+ // Stop Pressable defaulting to (block) flex
38
+ display: 'inline'
39
+ },
40
+ inlineFlex: {
41
+ display: 'inline-flex'
42
+ }
43
+ });
44
+ export default InlinePressable;
@@ -0,0 +1,89 @@
1
+ /* eslint-disable camelcase */
2
+ import React, { forwardRef, useState } from 'react';
3
+ import Text from "react-native-web/dist/exports/Text";
4
+ import TouchableWithoutFeedback from "react-native-web/dist/exports/TouchableWithoutFeedback";
5
+ /**
6
+ * @typedef {import('react-native').PressableProps} PressableProps
7
+ */
8
+ // TouchableWithoutFeedback and Pressable have similar but not identical props APIs
9
+
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+
12
+ const pressablePropsToTouchable = _ref => {
13
+ let {
14
+ unstable_pressDelay,
15
+ android_disableSound,
16
+ android_ripple,
17
+ // Unsupported, discard it
18
+ ...props
19
+ } = _ref;
20
+ return { ...props,
21
+ touchSoundDisabled: android_disableSound,
22
+ delayPressIn: unstable_pressDelay
23
+ };
24
+ };
25
+ /**
26
+ * InlinePressable is an alternative to React Native's Pressable that works better when nested
27
+ * inline inside Text. It accepts the same props as React Native's Pressable.
28
+ *
29
+ * There are a lot of React Native bugs around Views/Pressables nested in Text, e.g.:
30
+ *
31
+ * - https://github.com/facebook/react-native/issues/23601#issuecomment-468069822
32
+ * - https://github.com/facebook/react-native/issues/30375
33
+ * - https://github.com/facebook/react-native/issues/31955
34
+ *
35
+ * On Native, these can be avoided using a `Text` wrapped in a `TouchableWithoutFeedback`; the latter
36
+ * injects additional handlers such as onPressIn to `Text`, resulting in a tree that is purely `Text`.
37
+ *
38
+ * Note that this should only be used on Native, not Web, because React Navigation's Web navigation
39
+ * functions don't work in Touchables (but do work in Pressable) due to different event handling.
40
+ *
41
+ * @param {PressableProps} PressableProps
42
+ */
43
+ // React Native exports prop Types but not propTypes, use JSDoc types here rather than duplicate RN
44
+ // eslint-disable-next-line react/prop-types
45
+
46
+
47
+ const InlinePressable = /*#__PURE__*/forwardRef((_ref2, ref) => {
48
+ let {
49
+ onPress,
50
+ children,
51
+ style,
52
+ ...rest
53
+ } = _ref2;
54
+ const [isFocused, setIsFocused] = useState(false);
55
+
56
+ const handleFocus = () => setIsFocused(true);
57
+
58
+ const handleBlur = () => setIsFocused(false);
59
+
60
+ const [isPressed, setIsPressed] = useState(false);
61
+
62
+ const handlePressIn = () => setIsPressed(true);
63
+
64
+ const handlePressOut = () => setIsPressed(false);
65
+
66
+ const pressState = {
67
+ pressed: isPressed,
68
+ focus: isFocused,
69
+ // limited support on native
70
+ hover: false // not yet supported on native
71
+
72
+ };
73
+ const currentStyle = typeof style === 'function' ? style(pressState) : style;
74
+ return /*#__PURE__*/_jsx(TouchableWithoutFeedback, {
75
+ onPress: onPress,
76
+ onPressIn: handlePressIn,
77
+ onPressOut: handlePressOut,
78
+ onFocus: handleFocus,
79
+ onBlur: handleBlur,
80
+ ref: ref,
81
+ ...pressablePropsToTouchable(rest),
82
+ children: /*#__PURE__*/_jsx(Text, {
83
+ style: currentStyle,
84
+ children: typeof children === 'function' ? children(pressState) : children
85
+ })
86
+ });
87
+ });
88
+ InlinePressable.displayName = 'InlinePressable';
89
+ export default InlinePressable;
@@ -0,0 +1,28 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { useThemeTokensCallback } from '../ThemeProvider';
3
+ import LinkBase from './LinkBase';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const Link = /*#__PURE__*/forwardRef((_ref, ref) => {
6
+ let {
7
+ href,
8
+ children,
9
+ accessibilityRole = 'link',
10
+ variant = {},
11
+ tokens,
12
+ dataSet,
13
+ ...linkProps
14
+ } = _ref;
15
+ const getTokens = useThemeTokensCallback('Link', tokens, variant);
16
+ return /*#__PURE__*/_jsx(LinkBase, {
17
+ href: href,
18
+ accessibilityRole: accessibilityRole,
19
+ tokens: getTokens,
20
+ ref: ref,
21
+ dataSet: dataSet,
22
+ ...linkProps,
23
+ children: children
24
+ });
25
+ });
26
+ Link.displayName = 'Link';
27
+ Link.propTypes = LinkBase.propTypes;
28
+ export default Link;