@telus-uds/components-base 1.8.3 → 1.8.4

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 (269) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/component-docs.json +1 -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 +1 -1
  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/List/List.js +8 -2
  14. package/lib/Pagination/PageButton.js +2 -2
  15. package/lib/Pagination/Pagination.js +5 -3
  16. package/lib/Pagination/usePagination.js +2 -2
  17. package/lib/Progress/ProgressBar.js +3 -3
  18. package/lib/Progress/ProgressBarBackground.js +3 -3
  19. package/lib/Radio/Radio.js +2 -2
  20. package/lib/Radio/RadioGroup.js +2 -2
  21. package/lib/RadioCard/RadioCard.js +1 -1
  22. package/lib/RadioCard/RadioCardGroup.js +2 -2
  23. package/lib/Search/Search.js +1 -1
  24. package/lib/SideNav/SideNav.js +2 -2
  25. package/lib/Skeleton/Skeleton.js +1 -1
  26. package/lib/Skeleton/skeletonWebAnimation.js +1 -1
  27. package/lib/StackView/StackWrap.js +3 -1
  28. package/lib/StackView/getStackedContent.js +2 -2
  29. package/lib/Tabs/Tabs.js +28 -3
  30. package/lib/Tabs/TabsItem.js +5 -6
  31. package/lib/Tags/Tags.js +1 -1
  32. package/lib/ThemeProvider/utils/styles.js +2 -2
  33. package/lib/ThemeProvider/utils/theme-tokens.js +7 -9
  34. package/lib/ToggleSwitch/ToggleSwitch.js +1 -1
  35. package/lib/ToggleSwitch/ToggleSwitchGroup.js +1 -1
  36. package/lib/Tooltip/Backdrop.js +2 -10
  37. package/lib/utils/animation/useVerticalExpandAnimation.js +40 -14
  38. package/lib/utils/children.js +2 -2
  39. package/lib/utils/input.js +6 -12
  40. package/lib/utils/props/componentPropType.js +3 -3
  41. package/lib/utils/props/selectSystemProps.js +2 -2
  42. package/lib/utils/props/tokens.js +2 -2
  43. package/lib/utils/useSpacingScale.js +3 -1
  44. package/lib/utils/useUniqueId.js +1 -1
  45. package/lib-module/A11yInfoProvider/index.js +63 -0
  46. package/lib-module/A11yText/index.js +56 -0
  47. package/lib-module/ActivityIndicator/Spinner.js +77 -0
  48. package/lib-module/ActivityIndicator/Spinner.native.js +144 -0
  49. package/lib-module/ActivityIndicator/index.js +41 -0
  50. package/lib-module/ActivityIndicator/shared.js +12 -0
  51. package/lib-module/BaseProvider/index.js +29 -0
  52. package/lib-module/Box/Box.js +244 -0
  53. package/lib-module/Box/index.js +2 -0
  54. package/lib-module/Button/Button.js +26 -0
  55. package/lib-module/Button/ButtonBase.js +271 -0
  56. package/lib-module/Button/ButtonGroup.js +247 -0
  57. package/lib-module/Button/ButtonLink.js +40 -0
  58. package/lib-module/Button/index.js +4 -0
  59. package/lib-module/Button/propTypes.js +36 -0
  60. package/lib-module/Card/Card.js +84 -0
  61. package/lib-module/Card/CardBase.js +66 -0
  62. package/lib-module/Card/PressableCardBase.js +114 -0
  63. package/lib-module/Card/index.js +4 -0
  64. package/lib-module/Checkbox/Checkbox.js +346 -0
  65. package/lib-module/Checkbox/CheckboxGroup.js +233 -0
  66. package/lib-module/Checkbox/CheckboxInput.js +60 -0
  67. package/lib-module/Checkbox/CheckboxInput.native.js +6 -0
  68. package/lib-module/Checkbox/index.js +3 -0
  69. package/lib-module/Divider/Divider.js +124 -0
  70. package/lib-module/Divider/index.js +2 -0
  71. package/lib-module/ExpandCollapse/Accordion.js +15 -0
  72. package/lib-module/ExpandCollapse/Control.js +136 -0
  73. package/lib-module/ExpandCollapse/ExpandCollapse.js +95 -0
  74. package/lib-module/ExpandCollapse/Panel.js +151 -0
  75. package/lib-module/ExpandCollapse/index.js +7 -0
  76. package/lib-module/Feedback/Feedback.js +157 -0
  77. package/lib-module/Feedback/index.js +2 -0
  78. package/lib-module/Fieldset/Fieldset.js +153 -0
  79. package/lib-module/Fieldset/FieldsetContainer.js +32 -0
  80. package/lib-module/Fieldset/FieldsetContainer.native.js +23 -0
  81. package/lib-module/Fieldset/Legend.js +24 -0
  82. package/lib-module/Fieldset/Legend.native.js +31 -0
  83. package/lib-module/Fieldset/cssReset.js +14 -0
  84. package/lib-module/Fieldset/index.js +2 -0
  85. package/lib-module/FlexGrid/Col/Col.js +276 -0
  86. package/lib-module/FlexGrid/Col/index.js +2 -0
  87. package/lib-module/FlexGrid/FlexGrid.js +148 -0
  88. package/lib-module/FlexGrid/Row/Row.js +184 -0
  89. package/lib-module/FlexGrid/Row/index.js +2 -0
  90. package/lib-module/FlexGrid/helpers/index.js +18 -0
  91. package/lib-module/FlexGrid/index.js +2 -0
  92. package/lib-module/FlexGrid/providers/GutterContext.js +3 -0
  93. package/lib-module/HorizontalScroll/HorizontalScroll.js +175 -0
  94. package/lib-module/HorizontalScroll/HorizontalScrollButton.js +81 -0
  95. package/lib-module/HorizontalScroll/ScrollViewEnd.js +48 -0
  96. package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +27 -0
  97. package/lib-module/HorizontalScroll/dictionary.js +11 -0
  98. package/lib-module/HorizontalScroll/index.js +11 -0
  99. package/lib-module/HorizontalScroll/itemPositions.js +112 -0
  100. package/lib-module/Icon/Icon.js +62 -0
  101. package/lib-module/Icon/IconText.js +83 -0
  102. package/lib-module/Icon/index.js +4 -0
  103. package/lib-module/IconButton/IconButton.js +122 -0
  104. package/lib-module/IconButton/index.js +2 -0
  105. package/lib-module/InputLabel/InputLabel.js +148 -0
  106. package/lib-module/InputLabel/LabelContent.js +27 -0
  107. package/lib-module/InputLabel/LabelContent.native.js +19 -0
  108. package/lib-module/InputLabel/index.js +2 -0
  109. package/lib-module/InputSupports/InputSupports.js +96 -0
  110. package/lib-module/InputSupports/index.js +2 -0
  111. package/lib-module/InputSupports/useInputSupports.js +32 -0
  112. package/lib-module/Link/ChevronLink.js +52 -0
  113. package/lib-module/Link/InlinePressable.js +40 -0
  114. package/lib-module/Link/InlinePressable.native.js +89 -0
  115. package/lib-module/Link/Link.js +28 -0
  116. package/lib-module/Link/LinkBase.js +240 -0
  117. package/lib-module/Link/TextButton.js +35 -0
  118. package/lib-module/Link/index.js +5 -0
  119. package/lib-module/List/List.js +62 -0
  120. package/lib-module/List/ListItem.js +248 -0
  121. package/lib-module/List/index.js +5 -0
  122. package/lib-module/Modal/Modal.js +222 -0
  123. package/lib-module/Modal/dictionary.js +9 -0
  124. package/lib-module/Modal/index.js +2 -0
  125. package/lib-module/Notification/Notification.js +209 -0
  126. package/lib-module/Notification/dictionary.js +8 -0
  127. package/lib-module/Notification/index.js +2 -0
  128. package/lib-module/Pagination/PageButton.js +66 -0
  129. package/lib-module/Pagination/Pagination.js +153 -0
  130. package/lib-module/Pagination/SideButton.js +106 -0
  131. package/lib-module/Pagination/dictionary.js +18 -0
  132. package/lib-module/Pagination/index.js +2 -0
  133. package/lib-module/Pagination/usePagination.js +73 -0
  134. package/lib-module/Progress/Progress.js +89 -0
  135. package/lib-module/Progress/ProgressBar.js +138 -0
  136. package/lib-module/Progress/ProgressBarBackground.js +42 -0
  137. package/lib-module/Progress/index.js +4 -0
  138. package/lib-module/Radio/Radio.js +285 -0
  139. package/lib-module/Radio/RadioButton.js +138 -0
  140. package/lib-module/Radio/RadioGroup.js +243 -0
  141. package/lib-module/Radio/RadioInput.js +62 -0
  142. package/lib-module/Radio/RadioInput.native.js +6 -0
  143. package/lib-module/Radio/index.js +3 -0
  144. package/lib-module/RadioCard/RadioCard.js +219 -0
  145. package/lib-module/RadioCard/RadioCardGroup.js +250 -0
  146. package/lib-module/RadioCard/index.js +3 -0
  147. package/lib-module/Search/Search.js +261 -0
  148. package/lib-module/Search/dictionary.js +12 -0
  149. package/lib-module/Search/index.js +2 -0
  150. package/lib-module/Select/Group.js +21 -0
  151. package/lib-module/Select/Group.native.js +15 -0
  152. package/lib-module/Select/Item.js +20 -0
  153. package/lib-module/Select/Item.native.js +3 -0
  154. package/lib-module/Select/Picker.js +68 -0
  155. package/lib-module/Select/Picker.native.js +120 -0
  156. package/lib-module/Select/Select.js +337 -0
  157. package/lib-module/Select/index.js +6 -0
  158. package/lib-module/SideNav/Item.js +145 -0
  159. package/lib-module/SideNav/ItemContent.js +48 -0
  160. package/lib-module/SideNav/ItemsGroup.js +117 -0
  161. package/lib-module/SideNav/SideNav.js +136 -0
  162. package/lib-module/SideNav/index.js +1 -0
  163. package/lib-module/Skeleton/Skeleton.js +179 -0
  164. package/lib-module/Skeleton/index.js +2 -0
  165. package/lib-module/Skeleton/skeleton.constant.js +3 -0
  166. package/lib-module/Skeleton/skeletonWebAnimation.js +18 -0
  167. package/lib-module/Skeleton/useSkeletonNativeAnimation.js +24 -0
  168. package/lib-module/Spacer/Spacer.js +98 -0
  169. package/lib-module/Spacer/index.js +2 -0
  170. package/lib-module/StackView/StackView.js +125 -0
  171. package/lib-module/StackView/StackWrap.js +50 -0
  172. package/lib-module/StackView/StackWrap.native.js +3 -0
  173. package/lib-module/StackView/StackWrapBox.js +115 -0
  174. package/lib-module/StackView/StackWrapGap.js +59 -0
  175. package/lib-module/StackView/common.js +35 -0
  176. package/lib-module/StackView/getStackedContent.js +124 -0
  177. package/lib-module/StackView/index.js +5 -0
  178. package/lib-module/StepTracker/Step.js +248 -0
  179. package/lib-module/StepTracker/StepTracker.js +185 -0
  180. package/lib-module/StepTracker/dictionary.js +10 -0
  181. package/lib-module/StepTracker/index.js +2 -0
  182. package/lib-module/Tabs/Tabs.js +143 -0
  183. package/lib-module/Tabs/TabsItem.js +224 -0
  184. package/lib-module/Tabs/index.js +2 -0
  185. package/lib-module/Tags/Tags.js +251 -0
  186. package/lib-module/Tags/index.js +2 -0
  187. package/lib-module/TextInput/TextArea.js +94 -0
  188. package/lib-module/TextInput/TextInput.js +72 -0
  189. package/lib-module/TextInput/TextInputBase.js +245 -0
  190. package/lib-module/TextInput/index.js +3 -0
  191. package/lib-module/TextInput/propTypes.js +37 -0
  192. package/lib-module/ThemeProvider/ThemeProvider.js +36 -0
  193. package/lib-module/ThemeProvider/index.js +6 -0
  194. package/lib-module/ThemeProvider/useSetTheme.js +25 -0
  195. package/lib-module/ThemeProvider/useTheme.js +14 -0
  196. package/lib-module/ThemeProvider/useThemeTokens.js +110 -0
  197. package/lib-module/ThemeProvider/utils/index.js +2 -0
  198. package/lib-module/ThemeProvider/utils/styles.js +181 -0
  199. package/lib-module/ThemeProvider/utils/theme-tokens.js +163 -0
  200. package/lib-module/ToggleSwitch/ToggleSwitch.js +250 -0
  201. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +220 -0
  202. package/lib-module/ToggleSwitch/index.js +3 -0
  203. package/lib-module/Tooltip/Backdrop.js +45 -0
  204. package/lib-module/Tooltip/Backdrop.native.js +44 -0
  205. package/lib-module/Tooltip/Tooltip.js +348 -0
  206. package/lib-module/Tooltip/dictionary.js +8 -0
  207. package/lib-module/Tooltip/getTooltipPosition.js +175 -0
  208. package/lib-module/Tooltip/index.js +2 -0
  209. package/lib-module/TooltipButton/TooltipButton.js +78 -0
  210. package/lib-module/TooltipButton/index.js +2 -0
  211. package/lib-module/Typography/Typography.js +124 -0
  212. package/lib-module/Typography/index.js +2 -0
  213. package/lib-module/ViewportProvider/ViewportProvider.js +29 -0
  214. package/lib-module/ViewportProvider/index.js +3 -0
  215. package/lib-module/ViewportProvider/useViewport.js +3 -0
  216. package/lib-module/ViewportProvider/useViewportListener.js +46 -0
  217. package/lib-module/index.js +48 -0
  218. package/lib-module/utils/a11y/index.js +2 -0
  219. package/lib-module/utils/a11y/semantics.js +157 -0
  220. package/lib-module/utils/a11y/textSize.js +36 -0
  221. package/lib-module/utils/animation/index.js +2 -0
  222. package/lib-module/utils/animation/useVerticalExpandAnimation.js +88 -0
  223. package/lib-module/utils/children.js +119 -0
  224. package/lib-module/utils/containUniqueFields.js +26 -0
  225. package/lib-module/utils/index.js +16 -0
  226. package/lib-module/utils/info/index.js +7 -0
  227. package/lib-module/utils/info/platform/index.js +11 -0
  228. package/lib-module/utils/info/platform/platform.android.js +1 -0
  229. package/lib-module/utils/info/platform/platform.ios.js +1 -0
  230. package/lib-module/utils/info/platform/platform.js +1 -0
  231. package/lib-module/utils/info/platform/platform.native.js +4 -0
  232. package/lib-module/utils/info/versions.js +5 -0
  233. package/lib-module/utils/input.js +179 -0
  234. package/lib-module/utils/pressability.js +111 -0
  235. package/lib-module/utils/props/a11yProps.js +140 -0
  236. package/lib-module/utils/props/clickProps.js +26 -0
  237. package/lib-module/utils/props/componentPropType.js +63 -0
  238. package/lib-module/utils/props/copyPropTypes.js +2 -0
  239. package/lib-module/utils/props/getPropSelector.js +9 -0
  240. package/lib-module/utils/props/handlerProps.js +65 -0
  241. package/lib-module/utils/props/hrefAttrsProp.js +33 -0
  242. package/lib-module/utils/props/index.js +19 -0
  243. package/lib-module/utils/props/inputSupportsProps.js +62 -0
  244. package/lib-module/utils/props/linkProps.js +44 -0
  245. package/lib-module/utils/props/paddingProp.js +9 -0
  246. package/lib-module/utils/props/pressProps.js +42 -0
  247. package/lib-module/utils/props/rectProp.js +9 -0
  248. package/lib-module/utils/props/responsiveProps.js +30 -0
  249. package/lib-module/utils/props/selectSystemProps.js +24 -0
  250. package/lib-module/utils/props/spacingProps.js +56 -0
  251. package/lib-module/utils/props/textInputProps.js +194 -0
  252. package/lib-module/utils/props/textProps.js +59 -0
  253. package/lib-module/utils/props/tokens.js +133 -0
  254. package/lib-module/utils/props/variantProp.js +18 -0
  255. package/lib-module/utils/props/viewProps.js +22 -0
  256. package/lib-module/utils/ssr.js +38 -0
  257. package/lib-module/utils/useCopy.js +44 -0
  258. package/lib-module/utils/useHash.js +45 -0
  259. package/lib-module/utils/useHash.native.js +7 -0
  260. package/lib-module/utils/useResponsiveProp.js +47 -0
  261. package/lib-module/utils/useSpacingScale.js +125 -0
  262. package/lib-module/utils/useUniqueId.js +13 -0
  263. package/lib-module/utils/withLinkRouter.js +83 -0
  264. package/package.json +2 -2
  265. package/src/ExpandCollapse/Panel.jsx +2 -19
  266. package/src/List/List.jsx +6 -2
  267. package/src/Tabs/Tabs.jsx +24 -2
  268. package/src/Tabs/TabsItem.jsx +6 -5
  269. package/src/utils/animation/useVerticalExpandAnimation.js +47 -13
@@ -0,0 +1,251 @@
1
+ import React, { forwardRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import ABBPropTypes from 'airbnb-prop-types';
4
+ import Platform from "react-native-web/dist/exports/Platform";
5
+ import Text from "react-native-web/dist/exports/Text";
6
+ import View from "react-native-web/dist/exports/View";
7
+ import ButtonBase from '../Button/ButtonBase';
8
+ import Icon from '../Icon';
9
+ import { StackWrap, getStackedContent } from '../StackView';
10
+ import { useViewport } from '../ViewportProvider';
11
+ import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider';
12
+ import { a11yProps, containUniqueFields, focusHandlerProps, getTokensPropType, pressProps, selectSystemProps, selectTokens, useMultipleInputValues, variantProp, viewProps } from '../utils';
13
+ import { getPressHandlersWithArgs } from '../utils/pressability';
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
16
+ const [selectItemProps, selectedItemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, pressProps, viewProps]);
17
+
18
+ const selectIconTextTokens = _ref => {
19
+ let {
20
+ icon,
21
+ iconPosition,
22
+ iconSpace,
23
+ iconSize,
24
+ iconColor,
25
+ iconBackground,
26
+ iconBorderRadius,
27
+ iconAlignSelf,
28
+ iconPadding,
29
+ iconTranslateX,
30
+ iconTranslateY
31
+ } = _ref;
32
+ return {
33
+ icon,
34
+ iconPosition,
35
+ iconSpace,
36
+ iconWrapperStyle: {
37
+ backgroundColor: iconBackground,
38
+ borderRadius: iconBorderRadius,
39
+ alignSelf: iconAlignSelf,
40
+ padding: iconPadding,
41
+ ...Platform.select({
42
+ // TODO: https://github.com/telus/universal-design-system/issues/487
43
+ web: {
44
+ transition: 'color 200ms, background 200ms'
45
+ }
46
+ })
47
+ },
48
+ iconTokens: {
49
+ size: iconSize,
50
+ color: iconColor,
51
+ translateX: iconTranslateX,
52
+ translateY: iconTranslateY
53
+ }
54
+ };
55
+ };
56
+
57
+ const Tags = /*#__PURE__*/forwardRef((_ref2, ref) => {
58
+ let {
59
+ variant,
60
+ tokens,
61
+ items = [],
62
+ values,
63
+ initialValues,
64
+ maxValues,
65
+ onChange,
66
+ readOnly = false,
67
+ inactive = false,
68
+ accessibilityRole = Platform.select({
69
+ web: 'group',
70
+ default: 'none'
71
+ }),
72
+ ...rest
73
+ } = _ref2;
74
+ const viewport = useViewport();
75
+ const themeTokens = useThemeTokens('Tags', tokens, variant, {
76
+ viewport
77
+ });
78
+ const stackTokens = selectTokens('StackView', themeTokens);
79
+ const {
80
+ direction,
81
+ space
82
+ } = themeTokens;
83
+ const getItemTokens = useThemeTokensCallback('TagsItem', tokens, variant);
84
+
85
+ const getButtonTokens = buttonState => selectTokens('Button', getItemTokens(buttonState));
86
+
87
+ const {
88
+ currentValues,
89
+ toggleOneValue
90
+ } = useMultipleInputValues({
91
+ initialValues,
92
+ values,
93
+ maxValues,
94
+ onChange,
95
+ readOnly
96
+ });
97
+ const selectedProps = selectProps({
98
+ accessibilityRole,
99
+ ...rest
100
+ });
101
+ const itemA11yRole = 'checkbox';
102
+ const uniqueFields = ['id', 'label'];
103
+
104
+ if (!containUniqueFields(items, uniqueFields)) {
105
+ throw new Error("Tags items must have unique ".concat(uniqueFields.join(', ')));
106
+ }
107
+
108
+ return /*#__PURE__*/_jsx(StackWrap, {
109
+ ref: ref,
110
+ ...selectedProps,
111
+ space: space,
112
+ direction: direction,
113
+ tokens: stackTokens,
114
+ children: items.map((_ref3, index) => {
115
+ let {
116
+ label,
117
+ id = label,
118
+ ref: itemRef,
119
+ ...itemRest
120
+ } = _ref3;
121
+ const isSelected = currentValues.includes(id); // Pass an object of relevant component state as first argument for any passed-in press handlers
122
+
123
+ const pressHandlers = getPressHandlersWithArgs(rest, [{
124
+ id,
125
+ label,
126
+ currentValues
127
+ }]);
128
+
129
+ const handlePress = event => {
130
+ if (pressHandlers.onPress) pressHandlers.onPress(event);
131
+ toggleOneValue(id, event);
132
+ };
133
+
134
+ const itemProps = {
135
+ accessibilityState: {
136
+ checked: isSelected
137
+ },
138
+ accessibilityRole: itemA11yRole,
139
+ ...a11yProps.getPositionInSet(items.length, index),
140
+ ...selectItemProps(itemRest)
141
+ };
142
+ return /*#__PURE__*/_jsx(ButtonBase, {
143
+ ref: itemRef,
144
+ ...pressHandlers,
145
+ onPress: handlePress,
146
+ tokens: getButtonTokens,
147
+ selected: isSelected,
148
+ inactive: inactive,
149
+ ...itemProps,
150
+ children: _ref4 => {
151
+ let {
152
+ textStyles,
153
+ ...buttonState
154
+ } = _ref4;
155
+ // TODO: once Icon/IconButton designs are stable, see if this sort of styling around
156
+ // an icon should go in Icon itself, or possibly via an IconText token set. Related issues:
157
+ // - Icon: https://github.com/telus/universal-design-system/issues/327
158
+ // - IconButton: https://github.com/telus/universal-design-system/issues/281
159
+ // - Token sets: https://github.com/telus/universal-design-system/issues/782
160
+ const itemTokens = getItemTokens(buttonState);
161
+ const {
162
+ iconTokens,
163
+ iconPosition,
164
+ iconSpace,
165
+ iconWrapperStyle,
166
+ icon: IconComponent
167
+ } = selectIconTextTokens(itemTokens);
168
+ const iconContent = IconComponent ? /*#__PURE__*/_jsx(View, {
169
+ style: iconWrapperStyle,
170
+ children: /*#__PURE__*/_jsx(Icon, {
171
+ icon: IconComponent,
172
+ tokens: iconTokens
173
+ })
174
+ }) : null;
175
+
176
+ const textContent = /*#__PURE__*/_jsx(Text, {
177
+ style: textStyles,
178
+ children: label
179
+ });
180
+
181
+ return getStackedContent(iconPosition === 'left' ? [iconContent, textContent] : [textContent, iconContent], {
182
+ space: iconSpace,
183
+ direction: 'row'
184
+ });
185
+ }
186
+ }, id);
187
+ })
188
+ });
189
+ });
190
+ Tags.displayName = 'Tags';
191
+ Tags.propTypes = { ...selectedSystemPropTypes,
192
+ tokens: getTokensPropType('Tags'),
193
+ variant: variantProp.propType,
194
+
195
+ /**
196
+ * If provided, sets a maximum number of items a user may select at once.
197
+ */
198
+ maxValues: PropTypes.number,
199
+
200
+ /**
201
+ * The options a user may select
202
+ */
203
+ items: PropTypes.arrayOf(PropTypes.shape({ ...selectedItemPropTypes,
204
+
205
+ /**
206
+ * The text displayed to the user in the button, describing this option,
207
+ * passed to the button as its child.
208
+ */
209
+ label: PropTypes.string.isRequired,
210
+
211
+ /**
212
+ * An optional accessibility label may be passed to ButtonGroup Buttons
213
+ * which is applied as normal for a React Native accessibilityLabel prop.
214
+ */
215
+ accessibilityLabel: PropTypes.string,
216
+
217
+ /**
218
+ * An optional unique string may be provided to identify this option,
219
+ * which will be used in code and passed to any onChange function.
220
+ * If not provided, the label is used.
221
+ */
222
+ id: PropTypes.string,
223
+
224
+ /**
225
+ * An optional ref for one individual Tag button in the tags
226
+ */
227
+ ref: ABBPropTypes.ref()
228
+ })),
229
+
230
+ /**
231
+ * If provided, this function is called when the current selection is changed
232
+ * and is passed an array of the `id`s of all currently selected `items`.
233
+ */
234
+ onChange: PropTypes.func,
235
+
236
+ /**
237
+ * If the selected item(s) in the button group are to be controlled externally by
238
+ * a parent component, pass an array of strings as well as an `onChange` handler.
239
+ * Passing an array for "values" makes the ButtonGroup a "controlled" component that
240
+ * expects its state to be handled via `onChange` and so doesn't handle it itself.
241
+ */
242
+ values: PropTypes.arrayOf(PropTypes.string),
243
+
244
+ /**
245
+ * If `values` is not passed, making the ButtonGroup an "uncontrolled" component
246
+ * managing its own selected state, a default set of selections may be provided.
247
+ * Changing the `initialValues` does not change the user's selections.
248
+ */
249
+ initialValues: PropTypes.arrayOf(PropTypes.string)
250
+ };
251
+ export default Tags;
@@ -0,0 +1,2 @@
1
+ import Tags from './Tags';
2
+ export default Tags;
@@ -0,0 +1,94 @@
1
+ import React, { forwardRef, useState } from 'react';
2
+ import Platform from "react-native-web/dist/exports/Platform";
3
+ import { a11yProps, focusHandlerProps, getTokensPropType, inputSupportsProps, selectSystemProps, textInputHandlerProps, textInputProps, variantProp, viewProps } from '../utils';
4
+ import InputSupports from '../InputSupports';
5
+ import TextInputBase from './TextInputBase';
6
+ import { useThemeTokens } from '../ThemeProvider';
7
+ import textInputPropTypes from './propTypes';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, inputSupportsProps, textInputHandlerProps, textInputProps, viewProps]);
10
+ /**
11
+ * Use to collect long-form information such as product feedback or support queries.
12
+ * Due to React Native's implementation of `TextInput` it's not possible to access the current value by passing a ref.
13
+ * The `TextArea` height will automatically increase when new lines are added - this behavior can be limited within the theme.
14
+ *
15
+ * ## Controlled component
16
+ * If it is required that the state of the `TextArea` be controlled by the application or other external methods,
17
+ * `value` and `onChange` props must be passed to the `TextArea`.
18
+ * If the `TextArea` value should not be changed by user input, a `readOnly` prop must be provided.
19
+ *
20
+ * ## Uncontrolled component
21
+ * If it is not necessary to control the `TextArea` state, you can create one without a value prop.
22
+ * In this case its value can be accessed within the `onChange` callback.
23
+ *
24
+ * ## Getting feedback for entered values
25
+ * Use the `feedback` prop to give the user feedback regarding their input.
26
+ * You can affirm that the user's input was correct, or highlight errors that must be corrected, using the `validation` prop.
27
+ * Keep feedback text as brief as possible, should be limited to text and links.
28
+ *
29
+ * ## Supplying a hint
30
+ * Use the `hint` prop to succinctly clarify attributes of the expected input data, such as the expected format,
31
+ * or an indicator that the field is optional.
32
+ * It is a more usable and accessible option than the HTML `placeholder` attribute.
33
+ */
34
+
35
+ const TextArea = /*#__PURE__*/forwardRef((_ref, ref) => {
36
+ let {
37
+ tokens,
38
+ variant = {},
39
+ ...rest
40
+ } = _ref;
41
+ const themeTokens = useThemeTokens('TextArea', tokens, variant);
42
+ const [inputHeight, setInputHeight] = useState(); // adjust the text area's height as new lines are added to the content
43
+
44
+ const onHeightChange = _ref2 => {
45
+ let {
46
+ nativeEvent: {
47
+ contentSize: {
48
+ height
49
+ }
50
+ }
51
+ } = _ref2;
52
+
53
+ // on native this is happens out of the box
54
+ if (Platform.OS === 'web') {
55
+ setInputHeight(height);
56
+ }
57
+ };
58
+
59
+ const {
60
+ supportsProps,
61
+ ...selectedProps
62
+ } = selectProps(rest);
63
+ const inputProps = { ...selectedProps,
64
+ variant: { ...variant,
65
+ validation: supportsProps.validation
66
+ },
67
+ multiline: true,
68
+ onContentSizeChange: onHeightChange,
69
+ height: inputHeight,
70
+ tokens: themeTokens
71
+ };
72
+ return /*#__PURE__*/_jsx(InputSupports, { ...supportsProps,
73
+ children: _ref3 => {
74
+ let {
75
+ inputId,
76
+ ...props
77
+ } = _ref3;
78
+ return /*#__PURE__*/_jsx(TextInputBase, {
79
+ ref: ref,
80
+ ...inputProps,
81
+ nativeID: inputId,
82
+ ...props
83
+ });
84
+ }
85
+ });
86
+ });
87
+ TextArea.displayName = 'TextArea';
88
+ TextArea.propTypes = { ...selectedSystemPropTypes,
89
+ ...textInputPropTypes,
90
+ tokens: getTokensPropType('TextArea', 'TextInput'),
91
+ // TODO: support both TextArea and TextInput tokens
92
+ variant: variantProp.propType
93
+ };
94
+ export default TextArea;
@@ -0,0 +1,72 @@
1
+ import React, { forwardRef } from 'react';
2
+ import Platform from "react-native-web/dist/exports/Platform";
3
+ import { a11yProps, focusHandlerProps, getTokensPropType, inputSupportsProps, selectSystemProps, textInputHandlerProps, textInputProps, variantProp, viewProps } from '../utils';
4
+ import InputSupports from '../InputSupports';
5
+ import TextInputBase from './TextInputBase';
6
+ import textInputPropTypes from './propTypes';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, inputSupportsProps, textInputHandlerProps, textInputProps, viewProps]);
9
+ /**
10
+ * A basic text input component. Use in forms or individually to receive user's input.
11
+ * Due to React Native's implementation of `TextInput` it's not possible to access the current value by passing a ref.
12
+ *
13
+ * ## Controlled component
14
+ * If it is required that the state of the `TextInput` be controlled by the application or other external methods,
15
+ * `value` and `onChange` props must be passed to the `TextInput`.
16
+ * If the `TextInput` value should not be changed by user input, a `readOnly` prop must be provided.
17
+ *
18
+ * ## Uncontrolled component
19
+ * If it is not necessary to control the `TextInput` state, you can create one without a value prop.
20
+ * In this case its value can be accessed within the `onChange` callback.
21
+ *
22
+ * NOTE: In order to support more advanced usages all additional props will be passed down to the React Native's
23
+ * `TextInput` component. See <a href="https://reactnative.dev/docs/textinput" target="_blank">React Native documentation</a> for
24
+ * supported props and <a href="https://reactnative.dev/docs/textinput" target="_blank">React Native Web documentation</a> for
25
+ * their implementation on the web.
26
+ */
27
+
28
+ const TextInput = /*#__PURE__*/forwardRef((_ref, ref) => {
29
+ let {
30
+ tokens,
31
+ variant = {},
32
+ pattern,
33
+ ...rest
34
+ } = _ref;
35
+ React.useEffect(() => {
36
+ if (Platform.OS === 'web' && pattern && ref.current) {
37
+ // eslint-disable-next-line no-param-reassign
38
+ ref.current.pattern = pattern;
39
+ }
40
+ }, [ref, pattern]);
41
+ const {
42
+ supportsProps,
43
+ ...selectedProps
44
+ } = selectProps(rest);
45
+ const inputProps = { ...selectedProps,
46
+ tokens,
47
+ variant: { ...variant,
48
+ validation: supportsProps.validation
49
+ }
50
+ };
51
+ return /*#__PURE__*/_jsx(InputSupports, { ...supportsProps,
52
+ children: _ref2 => {
53
+ let {
54
+ inputId,
55
+ ...props
56
+ } = _ref2;
57
+ return /*#__PURE__*/_jsx(TextInputBase, {
58
+ ref: ref,
59
+ ...inputProps,
60
+ nativeID: inputId,
61
+ ...props
62
+ });
63
+ }
64
+ });
65
+ });
66
+ TextInput.displayName = 'TextInput';
67
+ TextInput.propTypes = { ...selectedSystemPropTypes,
68
+ ...textInputPropTypes,
69
+ tokens: getTokensPropType('TextInput'),
70
+ variant: variantProp.propType
71
+ };
72
+ export default TextInput;
@@ -0,0 +1,245 @@
1
+ import React, { forwardRef, useState } from 'react';
2
+ import Platform from "react-native-web/dist/exports/Platform";
3
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
4
+ import NativeTextInput from "react-native-web/dist/exports/TextInput";
5
+ import View from "react-native-web/dist/exports/View";
6
+ import PropTypes from 'prop-types';
7
+ import { applyTextStyles, useThemeTokens, applyOuterBorder } from '../ThemeProvider';
8
+ import { a11yProps, getTokensPropType, selectSystemProps, textInputHandlerProps, textInputProps, useInputValue, 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, textInputHandlerProps, textInputProps, viewProps]);
12
+
13
+ const selectInputStyles = (_ref, inactive) => {
14
+ let {
15
+ backgroundColor,
16
+ color,
17
+ borderWidth = 0,
18
+ borderColor,
19
+ borderRadius,
20
+ paddingTop = 0,
21
+ paddingBottom = 0,
22
+ paddingLeft,
23
+ paddingRight = 0,
24
+ fontName,
25
+ fontSize,
26
+ fontWeight,
27
+ lineHeight,
28
+ icon,
29
+ iconSize = 0,
30
+ minLines,
31
+ maxLines,
32
+ width,
33
+ height
34
+ } = _ref;
35
+
36
+ // Subtract border width from padding so overall input width/height doesn't
37
+ // jump around if the border width changes (avoiding NaN and negative padding)
38
+ const offsetBorder = value => typeof value === 'number' ? Math.max(0, value - borderWidth) : value;
39
+
40
+ const textStyles = applyTextStyles({
41
+ fontName,
42
+ fontSize,
43
+ lineHeight,
44
+ fontWeight
45
+ });
46
+
47
+ function linesToHeight(lines) {
48
+ const {
49
+ lineHeight: absoluteLineHeight
50
+ } = textStyles;
51
+ return lines !== undefined ? lines * absoluteLineHeight + paddingTop + paddingBottom : undefined;
52
+ }
53
+
54
+ const minHeight = linesToHeight(minLines);
55
+ const maxHeight = linesToHeight(maxLines);
56
+ const webStyles = Platform.select({
57
+ web: {
58
+ outline: 'none',
59
+ cursor: inactive ? 'not-allowed' : undefined,
60
+ resize: minHeight !== maxHeight ? 'vertical' : 'none' // does nothing for an input, only needed for textarea
61
+
62
+ }
63
+ });
64
+ const paddingWithIcon = iconSize + paddingRight;
65
+ return {
66
+ backgroundColor,
67
+ color,
68
+ borderWidth,
69
+ borderColor,
70
+ borderRadius,
71
+ paddingLeft: offsetBorder(paddingLeft),
72
+ paddingRight: icon ? offsetBorder(paddingWithIcon) : offsetBorder(paddingRight),
73
+ paddingTop: offsetBorder(paddingTop),
74
+ paddingBottom: offsetBorder(paddingBottom),
75
+ minHeight,
76
+ maxHeight,
77
+ width,
78
+ height,
79
+ ...textStyles,
80
+ ...webStyles
81
+ };
82
+ };
83
+
84
+ const selectOuterBorderStyles = _ref2 => {
85
+ let {
86
+ outerBackgroundColor,
87
+ outerBorderWidth,
88
+ outerBorderColor,
89
+ borderRadius
90
+ } = _ref2;
91
+ return {
92
+ background: outerBackgroundColor,
93
+ ...applyOuterBorder({
94
+ outerBorderColor,
95
+ outerBorderWidth,
96
+ borderRadius
97
+ })
98
+ };
99
+ };
100
+
101
+ const selectIconTokens = _ref3 => {
102
+ let {
103
+ iconSize,
104
+ iconColor
105
+ } = _ref3;
106
+ return {
107
+ size: iconSize,
108
+ color: iconColor
109
+ };
110
+ };
111
+
112
+ const selectIconContainerStyles = _ref4 => {
113
+ let {
114
+ paddingRight,
115
+ paddingBottom
116
+ } = _ref4;
117
+ return {
118
+ paddingRight,
119
+ paddingBottom
120
+ };
121
+ };
122
+
123
+ const TextInputBase = /*#__PURE__*/forwardRef((_ref5, ref) => {
124
+ let {
125
+ value,
126
+ height,
127
+ initialValue,
128
+ inactive,
129
+ readOnly,
130
+ onChange,
131
+ onChangeText,
132
+ onFocus,
133
+ onBlur,
134
+ onMouseOver,
135
+ onMouseOut,
136
+ tokens,
137
+ variant = {},
138
+ ...rest
139
+ } = _ref5;
140
+ const [isFocused, setIsFocused] = useState(false);
141
+
142
+ const handleFocus = event => {
143
+ setIsFocused(true);
144
+ if (typeof onFocus === 'function') onFocus(event);
145
+ };
146
+
147
+ const handleBlur = event => {
148
+ setIsFocused(false);
149
+ if (typeof onBlur === 'function') onBlur(event);
150
+ };
151
+
152
+ const [isHovered, setIsHovered] = useState(false);
153
+
154
+ const handleMouseOver = event => {
155
+ setIsHovered(true);
156
+ if (typeof onMouseOver === 'function') onMouseOver(event);
157
+ };
158
+
159
+ const handleMouseOut = event => {
160
+ setIsHovered(false);
161
+ if (typeof onMouseOut === 'function') onMouseOut(event);
162
+ };
163
+
164
+ const {
165
+ currentValue,
166
+ setValue,
167
+ isControlled
168
+ } = useInputValue({
169
+ value,
170
+ initialValue,
171
+ onChange,
172
+ readOnly
173
+ });
174
+
175
+ const handleChangeText = event => {
176
+ var _event$nativeEvent, _event$target;
177
+
178
+ const text = ((_event$nativeEvent = event.nativeEvent) === null || _event$nativeEvent === void 0 ? void 0 : _event$nativeEvent.text) || ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.value);
179
+ setValue(text, event);
180
+ if (typeof onChangeText === 'function') onChangeText(text, event);
181
+ };
182
+
183
+ const states = {
184
+ focus: isFocused,
185
+ hover: isHovered,
186
+ inactive
187
+ };
188
+ const themeTokens = useThemeTokens('TextInput', tokens, variant, states);
189
+ const {
190
+ icon: IconComponent
191
+ } = themeTokens;
192
+ const inputProps = { ...selectProps(rest),
193
+ editable: !inactive,
194
+ onFocus: handleFocus,
195
+ onBlur: handleBlur,
196
+ onMouseOver: handleMouseOver,
197
+ onMouseOut: handleMouseOut,
198
+ onChange: handleChangeText,
199
+ defaultValue: initialValue,
200
+ // currentValue is being updated even if the input is not controlled, passing it down to the
201
+ // Input could lead to changing its state from uncontrolled to controlled
202
+ value: isControlled ? currentValue : undefined
203
+ };
204
+ const nativeInputStyle = selectInputStyles({ ...themeTokens,
205
+ height
206
+ }, inactive);
207
+ return /*#__PURE__*/_jsxs(View, {
208
+ style: selectOuterBorderStyles(themeTokens),
209
+ children: [/*#__PURE__*/_jsx(NativeTextInput, {
210
+ ref: ref,
211
+ style: nativeInputStyle,
212
+ ...inputProps
213
+ }), IconComponent && /*#__PURE__*/_jsx(View, {
214
+ pointerEvents: "none" // avoid hijacking input press events
215
+ ,
216
+ style: [staticStyles.iconContainer, selectIconContainerStyles(themeTokens)],
217
+ children: /*#__PURE__*/_jsx(IconComponent, { ...selectIconTokens(themeTokens)
218
+ })
219
+ })]
220
+ });
221
+ });
222
+ TextInputBase.displayName = 'TextInputBase';
223
+ TextInputBase.propTypes = { ...selectedSystemPropTypes,
224
+ value: PropTypes.string,
225
+ height: PropTypes.number,
226
+ initialValue: PropTypes.string,
227
+ inactive: PropTypes.bool,
228
+ readOnly: PropTypes.bool,
229
+ onChange: PropTypes.func,
230
+ onChangeText: PropTypes.func,
231
+ onFocus: PropTypes.func,
232
+ onBlur: PropTypes.func,
233
+ onMouseOver: PropTypes.func,
234
+ onMouseOut: PropTypes.func,
235
+ tokens: getTokensPropType('TextInput', 'TextArea'),
236
+ variant: variantProp.propType
237
+ };
238
+ export default TextInputBase;
239
+ const staticStyles = StyleSheet.create({
240
+ iconContainer: {
241
+ position: 'absolute',
242
+ right: 0,
243
+ bottom: 0
244
+ }
245
+ });
@@ -0,0 +1,3 @@
1
+ import TextInput from './TextInput';
2
+ import TextArea from './TextArea';
3
+ export { TextInput, TextArea };
@@ -0,0 +1,37 @@
1
+ import PropTypes from 'prop-types';
2
+ import Platform from "react-native-web/dist/exports/Platform";
3
+ const textInputPropTypes = {
4
+ /**
5
+ * If the input's state is to be controlled by a parent component, use this prop
6
+ * together with the `onChange` to pass down and update the lifted state.
7
+ */
8
+ value: PropTypes.string,
9
+
10
+ /**
11
+ * Use this to set the initial value of an uncontrolled input.
12
+ * Updating `initialValue` will **not** update the actual value.
13
+ */
14
+ initialValue: PropTypes.string,
15
+
16
+ /**
17
+ * Disables all user interactions with the input.
18
+ */
19
+ inactive: PropTypes.bool,
20
+
21
+ /**
22
+ * Makes it impossible to change the input's value.
23
+ */
24
+ readOnly: PropTypes.bool,
25
+
26
+ /**
27
+ * Use to react upon input's value changes. Required when the `value` prop is set.
28
+ * Will receive the input's value as an argument.
29
+ */
30
+ onChange: PropTypes.func,
31
+ ...Platform.select({
32
+ web: {
33
+ pattern: PropTypes.string
34
+ }
35
+ })
36
+ };
37
+ export default textInputPropTypes;