@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,261 @@
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
+ import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider';
6
+ import { a11yProps, getTokensPropType, selectSystemProps, selectTokens, useInputValue, useSpacingScale, textInputHandlerProps, textInputProps, variantProp, viewProps } from '../utils';
7
+ import TextInputBase from '../TextInput/TextInputBase';
8
+ import ButtonBase from '../Button/ButtonBase';
9
+ import StackView from '../StackView';
10
+ import useCopy from '../utils/useCopy';
11
+ import dictionary from './dictionary';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
14
+ const [selectContainerProps, selectedContainerPropTypes] = selectSystemProps([a11yProps, viewProps]);
15
+ const [selectInputProps, selectedInputPropTypes] = selectSystemProps([textInputHandlerProps, textInputProps]);
16
+
17
+ const selectInputTokens = _ref => {
18
+ let {
19
+ searchTokens,
20
+ buttonTokens,
21
+ buttonsGapSize
22
+ } = _ref;
23
+ const {
24
+ paddingRight: inputPaddingRight,
25
+ clearButtonIcon,
26
+ submitButtonIcon
27
+ } = searchTokens;
28
+ const {
29
+ paddingLeft = 0,
30
+ paddingRight = 0,
31
+ iconSize = 0
32
+ } = buttonTokens;
33
+ const buttonWidth = paddingLeft + paddingRight + iconSize;
34
+ const paddingWithButtons = inputPaddingRight + (submitButtonIcon ? buttonWidth : 0) + (clearButtonIcon ? buttonsGapSize + buttonWidth : 0);
35
+ return { ...selectTokens('TextInput', searchTokens),
36
+ paddingRight: paddingWithButtons
37
+ };
38
+ };
39
+
40
+ const selectButtonTokens = tokens => selectTokens('Button', tokens);
41
+
42
+ const selectIconsContainerStyle = _ref2 => {
43
+ let {
44
+ paddingRight
45
+ } = _ref2;
46
+ return {
47
+ paddingRight
48
+ };
49
+ };
50
+
51
+ const selectIconTokens = _ref3 => {
52
+ let {
53
+ iconSize,
54
+ iconColor
55
+ } = _ref3;
56
+ return {
57
+ color: iconColor,
58
+ size: iconSize
59
+ };
60
+ };
61
+ /**
62
+ * The `Search` component is a combination of a `TextInput` and 2 different kinds of custom buttons.
63
+ * Use `Search` to feature autocomplete interactions.
64
+ *
65
+ * This component includes a clear button, which will appear as text is entered and pressing it will
66
+ * cause the input's internal state value to be set to an empty string.
67
+ *
68
+ * This component may only be used as uncontrolled, as the search value is managed within an internal state.
69
+ * You can use the `onChange` prop to react to value changes and the `onSubmit` prop to react on search submission.
70
+ *
71
+ * Use the following props to supply additional accessibility labels for the input - `accessibilityLabel`,
72
+ * clear button - `clearButtonAccessibilityLabel`, and submit button - `submitButtonAccessibilityLabel`.
73
+ */
74
+
75
+
76
+ const Search = /*#__PURE__*/forwardRef((_ref4, ref) => {
77
+ let {
78
+ initialValue,
79
+ value,
80
+ placeholder,
81
+ inactive,
82
+ onChange,
83
+ onSubmit,
84
+ onClear,
85
+ onFocus,
86
+ accessibilityLabel,
87
+ copy = 'en',
88
+ tokens,
89
+ variant,
90
+ ...rest
91
+ } = _ref4;
92
+ const {
93
+ currentValue = '',
94
+ setValue
95
+ } = useInputValue({
96
+ value,
97
+ initialValue,
98
+ onChange
99
+ });
100
+ const themeTokens = useThemeTokens('Search', tokens, variant);
101
+ const buttonTokens = useThemeTokens('SearchButton', tokens, variant);
102
+ const getThemeTokens = useThemeTokensCallback('Search', tokens, variant);
103
+ const getButtonTokens = useThemeTokensCallback('SearchButton', tokens, variant); // TODO: support overriding the a11y props using a custom dictionary
104
+
105
+ const getCopy = useCopy({
106
+ dictionary,
107
+ copy
108
+ });
109
+ const {
110
+ placeholderColor,
111
+ buttonsGap,
112
+ clearButtonIcon: ClearButtonIcon,
113
+ submitButtonIcon: SubmitButtonIcon
114
+ } = themeTokens; // get the actual gap value for the current viewport
115
+
116
+ const buttonsGapSize = useSpacingScale(buttonsGap);
117
+
118
+ const handleSubmit = event => {
119
+ if (onSubmit !== undefined) {
120
+ onSubmit(currentValue, event);
121
+ }
122
+ };
123
+
124
+ const handleClear = event => {
125
+ setValue('', event);
126
+ if (onClear !== undefined) onClear('', event);
127
+ };
128
+
129
+ const handleFocus = event => {
130
+ if (onFocus !== undefined) onFocus(event);
131
+ };
132
+
133
+ const isEmpty = currentValue === ''; // Accessibility label should always be present and correctly localised
134
+
135
+ const a11yLabelText = accessibilityLabel || getCopy('accessibilityLabel'); // Placeholder is optional and may be unset by passing an empty string
136
+
137
+ const placeholderText = placeholder !== null && placeholder !== void 0 ? placeholder : a11yLabelText;
138
+ return /*#__PURE__*/_jsxs(View, {
139
+ style: staticStyles.container,
140
+ ...selectContainerProps(rest),
141
+ children: [/*#__PURE__*/_jsx(TextInputBase, { ...selectInputProps(rest),
142
+ ref: ref,
143
+ tokens: appearances => selectInputTokens({
144
+ searchTokens: getThemeTokens(appearances),
145
+ buttonTokens,
146
+ buttonsGapSize,
147
+ isEmpty
148
+ }),
149
+ placeholder: placeholderText,
150
+ placeholderTextColor: placeholderColor,
151
+ inactive: inactive,
152
+ enablesReturnKeyAutomatically: true,
153
+ returnKeyType: "search",
154
+ value: currentValue,
155
+ onChange: setValue,
156
+ onSubmitEditing: handleSubmit,
157
+ onFocus: handleFocus,
158
+ accessibilityLabel: a11yLabelText
159
+ }), /*#__PURE__*/_jsx(View, {
160
+ style: [staticStyles.iconsContainer, selectIconsContainerStyle(themeTokens)],
161
+ children: /*#__PURE__*/_jsxs(StackView, {
162
+ direction: "row",
163
+ space: buttonsGap,
164
+ children: [ClearButtonIcon && !isEmpty && /*#__PURE__*/_jsx(ButtonBase, {
165
+ onPress: handleClear,
166
+ inactive: inactive,
167
+ accessibilityRole: "button",
168
+ accessibilityLabel: getCopy('clearButtonAccessibilityLabel'),
169
+ tokens: appearances => selectButtonTokens(getButtonTokens(appearances)),
170
+ children: buttonState => /*#__PURE__*/_jsx(ClearButtonIcon, { ...selectIconTokens(getButtonTokens(buttonState))
171
+ })
172
+ }), SubmitButtonIcon && /*#__PURE__*/_jsx(ButtonBase, {
173
+ onPress: handleSubmit,
174
+ inactive: inactive,
175
+ accessibilityRole: "button",
176
+ accessibilityLabel: getCopy('submitButtonAccessibilityLabel'),
177
+ tokens: buttonState => selectButtonTokens(getButtonTokens({ ...buttonState,
178
+ priority: 'high'
179
+ })),
180
+ children: buttonState => /*#__PURE__*/_jsx(SubmitButtonIcon, { ...selectIconTokens(getButtonTokens({ ...buttonState,
181
+ priority: 'high'
182
+ }))
183
+ })
184
+ })]
185
+ })
186
+ })]
187
+ });
188
+ });
189
+ Search.displayName = 'Search';
190
+ Search.propTypes = { ...selectedContainerPropTypes,
191
+ ...selectedInputPropTypes,
192
+
193
+ /**
194
+ * Use this to set the initial value of the search input.
195
+ * Updating `initialValue` will **not** update the actual value.
196
+ */
197
+ initialValue: PropTypes.string,
198
+
199
+ /**
200
+ * Label rendered in the search input when it has no value.
201
+ */
202
+ placeholder: PropTypes.string,
203
+
204
+ /**
205
+ * Disables all user interactions with the search input.
206
+ */
207
+ inactive: PropTypes.bool,
208
+
209
+ /**
210
+ * Use to react upon search input's value changes.
211
+ * Will receive the searched value as an argument.
212
+ */
213
+ onChange: PropTypes.func,
214
+
215
+ /**
216
+ * Triggered when the search input is submitted,
217
+ * either by pressing the submit button, "Enter" key on web,
218
+ * or "Search" key in a mobile keyboard.
219
+ */
220
+ onSubmit: PropTypes.func,
221
+
222
+ /**
223
+ * Triggered when the clear button is pressed.
224
+ */
225
+ onClear: PropTypes.func,
226
+
227
+ /**
228
+ * Triggered when the search input is focused.
229
+ */
230
+ onFocus: PropTypes.func,
231
+
232
+ /**
233
+ *
234
+ * Use to provide an accessible label for the input (visually hidden).
235
+ */
236
+ accessibilityLabel: PropTypes.string,
237
+
238
+ /**
239
+ * Select English or French copy for the accessible labels.
240
+ * You may also pass in a custom dictionary object.
241
+ */
242
+ copy: PropTypes.oneOfType([PropTypes.oneOf(['en', 'fr']), PropTypes.shape({
243
+ accessibilityLabel: PropTypes.string,
244
+ clearButtonAccessibilityLabel: PropTypes.string,
245
+ submitButtonAccessibilityLabel: PropTypes.string
246
+ })]),
247
+ tokens: getTokensPropType('Search'),
248
+ variant: variantProp.propType
249
+ };
250
+ export default Search;
251
+ const staticStyles = StyleSheet.create({
252
+ container: {// No styles needed here except the View defaults (position: relative etc)
253
+ },
254
+ iconsContainer: {
255
+ position: 'absolute',
256
+ right: 0,
257
+ top: 0,
258
+ bottom: 0,
259
+ justifyContent: 'center'
260
+ }
261
+ });
@@ -0,0 +1,12 @@
1
+ export default {
2
+ en: {
3
+ accessibilityLabel: 'Search',
4
+ clearButtonAccessibilityLabel: 'Clear',
5
+ submitButtonAccessibilityLabel: 'Search'
6
+ },
7
+ fr: {
8
+ accessibilityLabel: 'Chercher',
9
+ clearButtonAccessibilityLabel: 'Effacer',
10
+ submitButtonAccessibilityLabel: 'Chercher'
11
+ }
12
+ };
@@ -0,0 +1,2 @@
1
+ import Search from './Search';
2
+ export default Search;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { componentPropType } from '../utils';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+
6
+ const Group = _ref => {
7
+ let {
8
+ children,
9
+ label
10
+ } = _ref;
11
+ return /*#__PURE__*/_jsx("optgroup", {
12
+ label: label,
13
+ children: children
14
+ });
15
+ };
16
+
17
+ export default Group;
18
+ Group.propTypes = {
19
+ children: componentPropType('Item'),
20
+ label: PropTypes.string.isRequired
21
+ };
@@ -0,0 +1,15 @@
1
+ import PropTypes from 'prop-types';
2
+ import { componentPropType } from '../utils';
3
+
4
+ const Group = _ref => {
5
+ let {
6
+ children
7
+ } = _ref;
8
+ return children;
9
+ };
10
+
11
+ export default Group;
12
+ Group.propTypes = {
13
+ children: componentPropType('Item'),
14
+ label: PropTypes.string.isRequired
15
+ };
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+
5
+ const Item = _ref => {
6
+ let {
7
+ children,
8
+ value
9
+ } = _ref;
10
+ return /*#__PURE__*/_jsx("option", {
11
+ value: value,
12
+ children: children
13
+ });
14
+ };
15
+
16
+ export default Item;
17
+ Item.propTypes = {
18
+ children: PropTypes.string.isRequired,
19
+ value: PropTypes.string.isRequired
20
+ };
@@ -0,0 +1,3 @@
1
+ const Item = () => null;
2
+
3
+ export default Item;
@@ -0,0 +1,68 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { componentPropType } from '../utils';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { jsxs as _jsxs } from "react/jsx-runtime";
6
+ const Picker = /*#__PURE__*/forwardRef((_ref, ref) => {
7
+ let {
8
+ value,
9
+ onChange,
10
+ onFocus,
11
+ onBlur,
12
+ onMouseOver,
13
+ onMouseOut,
14
+ style,
15
+ inactive,
16
+ children,
17
+ placeholder,
18
+ nativeID,
19
+ testID,
20
+ ...rest
21
+ } = _ref;
22
+ const {
23
+ accessibilityLabel,
24
+ accessibilityDescribedBy,
25
+ accessibilityInvalid
26
+ } = rest;
27
+ return /*#__PURE__*/_jsxs("select", {
28
+ ref: ref,
29
+ style: style,
30
+ onMouseOver: onMouseOver,
31
+ onMouseOut: onMouseOut,
32
+ onFocus: onFocus,
33
+ onBlur: onBlur,
34
+ disabled: inactive,
35
+ value: value || (placeholder !== undefined ? placeholder.value : undefined),
36
+ onChange: event => onChange(event.target.value, event),
37
+ id: nativeID,
38
+ "aria-label": accessibilityLabel,
39
+ "aria-describedby": accessibilityDescribedBy,
40
+ "aria-invalid": accessibilityInvalid,
41
+ "data-testid": testID,
42
+ children: [placeholder !== undefined && /*#__PURE__*/_jsx("option", {
43
+ value: placeholder.value,
44
+ disabled: true,
45
+ hidden: true,
46
+ children: placeholder.label
47
+ }), children]
48
+ });
49
+ });
50
+ Picker.displayName = 'Picker';
51
+ export default Picker;
52
+ Picker.propTypes = {
53
+ value: PropTypes.string,
54
+ onChange: PropTypes.func,
55
+ onFocus: PropTypes.func,
56
+ onBlur: PropTypes.func,
57
+ onMouseOver: PropTypes.func,
58
+ onMouseOut: PropTypes.func,
59
+ style: PropTypes.object,
60
+ inactive: PropTypes.bool,
61
+ children: componentPropType(['Item', 'Group']),
62
+ placeholder: PropTypes.shape({
63
+ value: PropTypes.string,
64
+ label: PropTypes.string
65
+ }),
66
+ nativeID: PropTypes.string,
67
+ testID: PropTypes.string
68
+ };
@@ -0,0 +1,120 @@
1
+ import React, { forwardRef, Children } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import View from "react-native-web/dist/exports/View";
4
+ import Platform from "react-native-web/dist/exports/Platform";
5
+ import NativePicker from 'react-native-picker-select';
6
+ import { a11yProps, componentPropType } from '../utils';
7
+ import Group from './Group'; // styling of the native input is very limited, most of the styles have to be applied to an additional View
8
+
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { Fragment as _Fragment } from "react/jsx-runtime";
11
+
12
+ const selectAndroidInputStyles = _ref => {
13
+ let {
14
+ height = 0,
15
+ paddingBottom = 0,
16
+ paddingTop = 0,
17
+ borderWidth = 0,
18
+ color
19
+ } = _ref;
20
+ return {
21
+ height: height - paddingTop - paddingBottom - 2 * borderWidth,
22
+ color
23
+ };
24
+ }; // the native input has a side padding of 8px, which can't be adjusted, so we have to account for that in the container
25
+
26
+
27
+ const selectAndroidContainerStyles = _ref2 => {
28
+ let {
29
+ paddingLeft = 0,
30
+ paddingRight = 0,
31
+ ...rest
32
+ } = _ref2;
33
+ return {
34
+ paddingLeft: paddingLeft > 8 ? paddingLeft - 8 : 0,
35
+ paddingRight: paddingRight > 8 ? paddingRight - 8 : 0,
36
+ ...rest
37
+ };
38
+ };
39
+
40
+ const Picker = /*#__PURE__*/forwardRef((_ref3, ref) => {
41
+ let {
42
+ value,
43
+ onChange,
44
+ onFocus,
45
+ onBlur,
46
+ style,
47
+ inactive,
48
+ children,
49
+ placeholder,
50
+ ...rest
51
+ } = _ref3;
52
+ // ungroup items, since there's no way to support groups on native
53
+ const flatChildren = Children.toArray(children).flatMap(child => {
54
+ if (child.type === Group) {
55
+ return child.props.children;
56
+ }
57
+
58
+ return child;
59
+ });
60
+ const items = flatChildren.map(_ref4 => {
61
+ let {
62
+ props
63
+ } = _ref4;
64
+ return {
65
+ label: props.children,
66
+ value: props.value
67
+ };
68
+ }); // Unlike other input components, react-native-picker-select doesn't pass an event to its change fn.
69
+
70
+ const handleChange = (newValue, index) => {
71
+ if (onChange) onChange(newValue, {
72
+ // TODO: see if it's possible to pass a real React SyntheticEvent here. For now, just pass an
73
+ // object with a shape where if an onChange deconstructs `event.nativeEvent`, it won't crash.
74
+ nativeEvent: {
75
+ index,
76
+ value: newValue
77
+ }
78
+ });
79
+ };
80
+
81
+ const picker = /*#__PURE__*/_jsx(NativePicker, {
82
+ pickerProps: {
83
+ ref
84
+ },
85
+ touchableWrapperProps: a11yProps.select(rest),
86
+ onOpen: onFocus,
87
+ onClose: onBlur,
88
+ disabled: inactive,
89
+ items: items,
90
+ value: value,
91
+ onValueChange: handleChange,
92
+ style: {
93
+ inputIOS: style,
94
+ inputAndroid: selectAndroidInputStyles(style)
95
+ },
96
+ placeholder: placeholder !== undefined ? placeholder : {}
97
+ });
98
+
99
+ return /*#__PURE__*/_jsx(_Fragment, {
100
+ children: Platform.OS === 'android' ? /*#__PURE__*/_jsx(View, {
101
+ style: selectAndroidContainerStyles(style),
102
+ children: picker
103
+ }) : picker
104
+ });
105
+ });
106
+ Picker.displayName = 'Picker';
107
+ export default Picker;
108
+ Picker.propTypes = {
109
+ value: PropTypes.string,
110
+ onChange: PropTypes.func,
111
+ onFocus: PropTypes.func,
112
+ onBlur: PropTypes.func,
113
+ style: PropTypes.object,
114
+ inactive: PropTypes.bool,
115
+ children: componentPropType(['Item', 'Group']),
116
+ placeholder: PropTypes.shape({
117
+ value: PropTypes.string,
118
+ label: PropTypes.string
119
+ })
120
+ };