@telus-uds/components-base 1.5.0 → 1.7.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 (125) hide show
  1. package/.turbo/turbo-build.log +8 -8
  2. package/.turbo/turbo-lint.log +13 -0
  3. package/CHANGELOG.json +154 -1
  4. package/CHANGELOG.md +47 -2
  5. package/__tests__/FlexGrid/Row.test.jsx +100 -25
  6. package/__tests__/utils/containUniqueFields.test.js +25 -0
  7. package/component-docs.json +78 -26
  8. package/generate-component-docs.js +20 -7
  9. package/lib/Button/ButtonBase.js +1 -1
  10. package/lib/Button/ButtonGroup.js +20 -12
  11. package/lib/Card/PressableCardBase.js +1 -1
  12. package/lib/Checkbox/Checkbox.js +27 -16
  13. package/lib/Checkbox/CheckboxGroup.js +19 -5
  14. package/lib/ExpandCollapse/Panel.js +10 -10
  15. package/lib/FlexGrid/Col/Col.js +13 -3
  16. package/lib/FlexGrid/Row/Row.js +8 -2
  17. package/lib/InputLabel/InputLabel.js +27 -25
  18. package/lib/Link/LinkBase.js +19 -6
  19. package/lib/Link/TextButton.js +1 -10
  20. package/lib/List/ListItem.js +22 -12
  21. package/lib/Modal/Modal.js +18 -18
  22. package/lib/Radio/Radio.js +23 -12
  23. package/lib/Radio/RadioGroup.js +12 -3
  24. package/lib/RadioCard/RadioCard.js +1 -1
  25. package/lib/RadioCard/RadioCardGroup.js +11 -2
  26. package/lib/Search/Search.js +27 -19
  27. package/lib/Select/Select.js +2 -3
  28. package/lib/Tags/Tags.js +23 -17
  29. package/lib/TextInput/TextArea.js +2 -2
  30. package/lib/TextInput/TextInput.js +12 -2
  31. package/lib/TextInput/TextInputBase.js +1 -1
  32. package/lib/TextInput/propTypes.js +8 -1
  33. package/lib/ToggleSwitch/ToggleSwitch.js +5 -2
  34. package/lib/ToggleSwitch/ToggleSwitchGroup.js +20 -12
  35. package/lib/Typography/Typography.js +12 -10
  36. package/lib/index.js +22 -1
  37. package/lib/utils/containUniqueFields.js +34 -0
  38. package/lib/utils/index.js +10 -1
  39. package/lib/utils/input.js +5 -6
  40. package/lib/utils/props/handlerProps.js +72 -0
  41. package/lib/utils/props/index.js +32 -0
  42. package/lib/utils/props/inputSupportsProps.js +3 -5
  43. package/lib/utils/props/linkProps.js +3 -7
  44. package/lib/utils/props/textInputProps.js +206 -0
  45. package/lib/utils/props/textProps.js +72 -0
  46. package/lib-module/Button/ButtonBase.js +2 -2
  47. package/lib-module/Button/ButtonGroup.js +15 -6
  48. package/lib-module/Card/PressableCardBase.js +2 -2
  49. package/lib-module/Checkbox/Checkbox.js +28 -17
  50. package/lib-module/Checkbox/CheckboxGroup.js +20 -7
  51. package/lib-module/ExpandCollapse/Panel.js +10 -10
  52. package/lib-module/FlexGrid/Col/Col.js +13 -3
  53. package/lib-module/FlexGrid/Row/Row.js +8 -2
  54. package/lib-module/InputLabel/InputLabel.js +28 -25
  55. package/lib-module/Link/LinkBase.js +19 -6
  56. package/lib-module/Link/TextButton.js +1 -10
  57. package/lib-module/List/ListItem.js +22 -12
  58. package/lib-module/Modal/Modal.js +19 -19
  59. package/lib-module/Radio/Radio.js +24 -13
  60. package/lib-module/Radio/RadioGroup.js +13 -4
  61. package/lib-module/RadioCard/RadioCard.js +2 -2
  62. package/lib-module/RadioCard/RadioCardGroup.js +12 -3
  63. package/lib-module/Search/Search.js +29 -21
  64. package/lib-module/Select/Select.js +2 -3
  65. package/lib-module/Tags/Tags.js +18 -11
  66. package/lib-module/TextInput/TextArea.js +3 -3
  67. package/lib-module/TextInput/TextInput.js +11 -3
  68. package/lib-module/TextInput/TextInputBase.js +2 -2
  69. package/lib-module/TextInput/propTypes.js +7 -1
  70. package/lib-module/ToggleSwitch/ToggleSwitch.js +6 -3
  71. package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +15 -6
  72. package/lib-module/Typography/Typography.js +13 -11
  73. package/lib-module/index.js +1 -1
  74. package/lib-module/utils/containUniqueFields.js +26 -0
  75. package/lib-module/utils/index.js +2 -1
  76. package/lib-module/utils/input.js +6 -6
  77. package/lib-module/utils/props/handlerProps.js +59 -0
  78. package/lib-module/utils/props/index.js +3 -0
  79. package/lib-module/utils/props/inputSupportsProps.js +3 -5
  80. package/lib-module/utils/props/linkProps.js +3 -7
  81. package/lib-module/utils/props/textInputProps.js +193 -0
  82. package/lib-module/utils/props/textProps.js +59 -0
  83. package/package.json +5 -5
  84. package/src/Button/ButtonBase.jsx +8 -2
  85. package/src/Button/ButtonGroup.jsx +51 -34
  86. package/src/Card/PressableCardBase.jsx +6 -1
  87. package/src/Checkbox/Checkbox.jsx +35 -23
  88. package/src/Checkbox/CheckboxGroup.jsx +52 -22
  89. package/src/ExpandCollapse/Panel.jsx +9 -9
  90. package/src/FlexGrid/Col/Col.jsx +11 -2
  91. package/src/FlexGrid/Row/Row.jsx +8 -2
  92. package/src/InputLabel/InputLabel.jsx +36 -27
  93. package/src/Link/LinkBase.jsx +20 -4
  94. package/src/Link/TextButton.jsx +1 -19
  95. package/src/List/ListItem.jsx +17 -9
  96. package/src/Modal/Modal.jsx +30 -26
  97. package/src/Radio/Radio.jsx +26 -14
  98. package/src/Radio/RadioGroup.jsx +39 -21
  99. package/src/RadioCard/RadioCard.jsx +6 -1
  100. package/src/RadioCard/RadioCardGroup.jsx +17 -1
  101. package/src/Search/Search.jsx +33 -21
  102. package/src/Select/Select.jsx +2 -2
  103. package/src/Tags/Tags.jsx +23 -9
  104. package/src/TextInput/TextArea.jsx +7 -1
  105. package/src/TextInput/TextInput.jsx +15 -3
  106. package/src/TextInput/TextInputBase.jsx +8 -1
  107. package/src/TextInput/propTypes.js +7 -1
  108. package/src/ToggleSwitch/ToggleSwitch.jsx +11 -2
  109. package/src/ToggleSwitch/ToggleSwitchGroup.jsx +19 -6
  110. package/src/Typography/Typography.jsx +13 -9
  111. package/src/index.js +4 -1
  112. package/src/utils/containUniqueFields.js +32 -0
  113. package/src/utils/index.js +1 -0
  114. package/src/utils/input.js +5 -7
  115. package/src/utils/props/handlerProps.js +47 -0
  116. package/src/utils/props/index.js +3 -0
  117. package/src/utils/props/inputSupportsProps.js +3 -4
  118. package/src/utils/props/linkProps.js +3 -6
  119. package/src/utils/props/textInputProps.js +177 -0
  120. package/src/utils/props/textProps.js +58 -0
  121. package/stories/InputLabel/InputLabel.stories.jsx +25 -28
  122. package/stories/Modal/Modal.stories.jsx +25 -0
  123. package/stories/Search/Search.stories.jsx +53 -3
  124. package/stories/TextInput/TextInput.stories.jsx +40 -2
  125. package/__tests__/Link/LinkBase.test.jsx +0 -22
@@ -23,9 +23,7 @@ var _ViewportProvider = require("../ViewportProvider");
23
23
 
24
24
  var _ThemeProvider = require("../ThemeProvider");
25
25
 
26
- var _props = require("../utils/props");
27
-
28
- var _input = require("../utils/input");
26
+ var _utils = require("../utils");
29
27
 
30
28
  var _jsxRuntime = require("react/jsx-runtime");
31
29
 
@@ -35,7 +33,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
35
33
 
36
34
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
37
35
 
38
- const [selectProps, selectedSystemPropTypes] = (0, _props.selectSystemProps)([_props.a11yProps, _props.pressProps, _props.viewProps]);
36
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
37
+ const [selectItemProps, selectedItemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
39
38
  const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
40
39
  variant,
41
40
  tokens,
@@ -70,7 +69,7 @@ const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
70
69
  const {
71
70
  currentValues,
72
71
  toggleOneValue
73
- } = (0, _input.useMultipleInputValues)({
72
+ } = (0, _utils.useMultipleInputValues)({
74
73
  initialValues,
75
74
  values,
76
75
  maxValues,
@@ -82,13 +81,20 @@ const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
82
81
  ...rest
83
82
  });
84
83
  const itemA11yRole = selectedProps.accessibilityRole === 'radiogroup' ? 'radio' : 'switch';
84
+ const uniqueFields = ['id', 'label'];
85
+
86
+ if (!(0, _utils.containUniqueFields)(items, uniqueFields)) {
87
+ throw new Error(`ToggleSwitchGroup items must have unique ${uniqueFields.join(', ')}`);
88
+ }
89
+
85
90
  const toggleSwitches = items.map(({
86
91
  label,
87
92
  id = label,
88
93
  accessibilityLabel = label,
89
94
  onChange: itemOnChange,
90
95
  ref: itemRef,
91
- tooltip: itemTooltip
96
+ tooltip: itemTooltip,
97
+ ...itemRest
92
98
  }, index) => {
93
99
  const isSelected = currentValues.includes(id);
94
100
 
@@ -103,7 +109,7 @@ const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
103
109
  },
104
110
  accessibilityRole: itemA11yRole,
105
111
  accessibilityLabel,
106
- ..._props.a11yProps.getPositionInSet(items.length, index)
112
+ ..._utils.a11yProps.getPositionInSet(items.length, index)
107
113
  };
108
114
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleSwitch.default, {
109
115
  id: id,
@@ -114,7 +120,8 @@ const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
114
120
  inactive: inactive,
115
121
  label: label,
116
122
  tooltip: itemTooltip,
117
- ...itemA11y
123
+ ...itemA11y,
124
+ ...selectItemProps(itemRest)
118
125
  }, id);
119
126
  });
120
127
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Fieldset.default, {
@@ -136,8 +143,8 @@ const ToggleSwitchGroup = /*#__PURE__*/(0, _react.forwardRef)(({
136
143
  });
137
144
  ToggleSwitchGroup.displayName = 'ToggleSwitchGroup';
138
145
  ToggleSwitchGroup.propTypes = { ...selectedSystemPropTypes,
139
- tokens: (0, _props.getTokensPropType)('ToggleSwitchGroup'),
140
- variant: _props.variantProp.propType,
146
+ tokens: (0, _utils.getTokensPropType)('ToggleSwitchGroup'),
147
+ variant: _utils.variantProp.propType,
141
148
 
142
149
  /**
143
150
  * The maximum number of items a user may select at once. Defaults to 1 and behaves
@@ -148,7 +155,8 @@ ToggleSwitchGroup.propTypes = { ...selectedSystemPropTypes,
148
155
  /**
149
156
  * The options a user may select
150
157
  */
151
- items: _propTypes.default.arrayOf(_propTypes.default.shape({
158
+ items: _propTypes.default.arrayOf(_propTypes.default.shape({ ...selectedItemPropTypes,
159
+
152
160
  /**
153
161
  * The text displayed to the user on the label.
154
162
  */
@@ -217,7 +225,7 @@ ToggleSwitchGroup.propTypes = { ...selectedSystemPropTypes,
217
225
  /**
218
226
  * Toggle switch token overrides.
219
227
  */
220
- toggleSwitchTokens: (0, _props.getTokensPropType)('ToggleSwitch'),
228
+ toggleSwitchTokens: (0, _utils.getTokensPropType)('ToggleSwitch'),
221
229
 
222
230
  /**
223
231
  * Current validation status of the group, passed to the feedback element if there is one.
@@ -32,7 +32,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
32
32
  /**
33
33
  * @typedef {import('../utils/a11y/semantics').TextTag} TextTag
34
34
  */
35
- const [selectProps, selectedSystemPropTypes] = (0, _utils2.selectSystemProps)([_utils2.a11yProps, _utils2.viewProps]);
35
+ const [selectContainerProps, selectedContainerPropTypes] = (0, _utils2.selectSystemProps)([_utils2.a11yProps, _utils2.viewProps]);
36
+ const [selectTextProps, selectedTextPropTypes] = (0, _utils2.selectSystemProps)([_utils2.textProps]);
36
37
 
37
38
  const selectTextStyles = ({
38
39
  fontWeight,
@@ -71,31 +72,32 @@ const Typography = /*#__PURE__*/(0, _react.forwardRef)(({
71
72
  const themeTokens = (0, _ThemeProvider.useThemeTokens)('Typography', tokens, variant, {
72
73
  viewport
73
74
  });
74
- const textProps = {
75
+ const resolvedTextProps = { ...selectTextProps(rest),
75
76
  style: selectTextStyles(align ? { ...themeTokens,
76
77
  textAlign: align
77
78
  } : themeTokens),
78
79
  dataSet,
79
80
  maxFontSizeMultiplier: (0, _utils2.getMaxFontMultiplier)(themeTokens)
80
81
  };
81
- const selectedProps = selectProps({ ...(0, _utils2.getA11yPropsFromHtmlTag)(tag, accessibilityRole),
82
- ...rest
83
- });
82
+ const containerProps = { ...(0, _utils2.getA11yPropsFromHtmlTag)(tag, accessibilityRole),
83
+ ...selectContainerProps(rest)
84
+ };
84
85
  return block ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
85
86
  ref: ref,
86
- ...selectedProps,
87
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, { ...textProps,
87
+ ...containerProps,
88
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, { ...resolvedTextProps,
88
89
  children: children
89
90
  })
90
91
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
91
92
  ref: ref,
92
- ...textProps,
93
- ...selectedProps,
93
+ ...containerProps,
94
+ ...resolvedTextProps,
94
95
  children: children
95
96
  });
96
97
  });
97
98
  Typography.displayName = 'Typography';
98
- Typography.propTypes = { ...selectedSystemPropTypes,
99
+ Typography.propTypes = { ...selectedContainerPropTypes,
100
+ ...selectedTextPropTypes,
99
101
  tokens: (0, _utils2.getTokensPropType)('Typography'),
100
102
  variant: _utils2.variantProp.propType,
101
103
 
package/lib/index.js CHANGED
@@ -51,7 +51,10 @@ var _exportNames = {
51
51
  useTheme: true,
52
52
  useSetTheme: true,
53
53
  useThemeTokens: true,
54
- getThemeTokens: true
54
+ getThemeTokens: true,
55
+ applyOuterBorder: true,
56
+ applyTextStyles: true,
57
+ applyShadowToken: true
55
58
  };
56
59
  Object.defineProperty(exports, "A11yText", {
57
60
  enumerable: true,
@@ -341,6 +344,24 @@ Object.defineProperty(exports, "getThemeTokens", {
341
344
  return _ThemeProvider.getThemeTokens;
342
345
  }
343
346
  });
347
+ Object.defineProperty(exports, "applyOuterBorder", {
348
+ enumerable: true,
349
+ get: function () {
350
+ return _ThemeProvider.applyOuterBorder;
351
+ }
352
+ });
353
+ Object.defineProperty(exports, "applyTextStyles", {
354
+ enumerable: true,
355
+ get: function () {
356
+ return _ThemeProvider.applyTextStyles;
357
+ }
358
+ });
359
+ Object.defineProperty(exports, "applyShadowToken", {
360
+ enumerable: true,
361
+ get: function () {
362
+ return _ThemeProvider.applyShadowToken;
363
+ }
364
+ });
344
365
 
345
366
  var _A11yText = _interopRequireDefault(require("./A11yText"));
346
367
 
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ // Returns true if there are no duplicate values of the fields listed
9
+ // in the `fields` array across the objects in the `items` array, false
10
+ // otherwise.
11
+ // Note that if a value of a field in an item is not set, it will be
12
+ // excluded from comparison.
13
+ const containUniqueFields = (items, fields) => {
14
+ const map = [];
15
+ const itemsHaveDuplicateFields = items.some(item => fields.some(field => {
16
+ if (!map[field]) {
17
+ map[field] = [];
18
+ }
19
+
20
+ if (!item[field]) {
21
+ // We exclude empty values from comparison
22
+ return false;
23
+ } // Duplicate found!
24
+
25
+
26
+ if (map[field][item[field]]) return true;
27
+ map[field][item[field]] = true;
28
+ return false;
29
+ }));
30
+ return !itemsHaveDuplicateFields;
31
+ };
32
+
33
+ var _default = containUniqueFields;
34
+ exports.default = _default;
@@ -10,7 +10,8 @@ var _exportNames = {
10
10
  useSpacingScale: true,
11
11
  useResponsiveProp: true,
12
12
  useUniqueId: true,
13
- withLinkRouter: true
13
+ withLinkRouter: true,
14
+ containUniqueFields: true
14
15
  };
15
16
  Object.defineProperty(exports, "info", {
16
17
  enumerable: true,
@@ -54,6 +55,12 @@ Object.defineProperty(exports, "withLinkRouter", {
54
55
  return _withLinkRouter.default;
55
56
  }
56
57
  });
58
+ Object.defineProperty(exports, "containUniqueFields", {
59
+ enumerable: true,
60
+ get: function () {
61
+ return _containUniqueFields.default;
62
+ }
63
+ });
57
64
 
58
65
  var _a11y = require("./a11y");
59
66
 
@@ -179,6 +186,8 @@ Object.keys(_ssr).forEach(function (key) {
179
186
  });
180
187
  });
181
188
 
189
+ var _containUniqueFields = _interopRequireDefault(require("./containUniqueFields"));
190
+
182
191
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
183
192
 
184
193
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -7,6 +7,9 @@ exports.useMultipleInputValues = exports.useInputValue = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
10
+ /**
11
+ * @typedef {import('react').SyntheticEvent} Event
12
+ */
10
13
  const pluralHooks = ['useMultipleInputValues'];
11
14
 
12
15
  const validateProps = ({
@@ -64,11 +67,9 @@ Consumers of this hook must be one of:
64
67
  *
65
68
  * @param {string} hookName - optional, used for tailoring error messages
66
69
  *
67
- * @typedef {(oldValue: string|number|null) => string|number|null} UpdaterFunction - `setValue` takes a value or
68
- * a function returning a new value from the old value
69
70
  * @returns {{
70
71
  * currentValue: string|number|null
71
- * setValue: (newValue: string|number|null|UpdaterFunction) => void
72
+ * setValue: (newValue: string|number|null|(oldValue: string|number) => string|number, event: Event) => void
72
73
  * resetValue: () => void
73
74
  * isControlled: bool
74
75
  * }}
@@ -130,12 +131,10 @@ const useInputValue = (props = {}, hookName = 'useInputValue') => {
130
131
  *
131
132
  * @param {string} componentName - optional, used in error messages
132
133
  *
133
- * @typedef {(oldValues: string[]|number[]) => string[]|number[]} UpdaterFunction - `setValues` takes values or
134
- * a function returning new values from old values
135
134
  * @returns {{
136
135
  * currentValues: any
137
136
  * resetValues: () => void
138
- * setValues: (newValues: string[]|number[]|UpdaterFunction) => void
137
+ * setValues: (newValues: string[]|number[]|(oldValues: string[]|number[]) => string[]|number[], event: Event) => void
139
138
  * toggleOneValue: (value: string|number) => void
140
139
  * unsetValues: () => void
141
140
  * }}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.textInputHandlerProps = exports.focusHandlerProps = void 0;
7
+
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const focusHandlerProps = {
13
+ types: {
14
+ /**
15
+ * onBlur handler
16
+ */
17
+ onBlur: _propTypes.default.func,
18
+
19
+ /**
20
+ * onFocus handler
21
+ */
22
+ onFocus: _propTypes.default.func
23
+ },
24
+ select: ({
25
+ onBlur,
26
+ onFocus
27
+ }) => ({
28
+ onBlur,
29
+ onFocus
30
+ })
31
+ };
32
+ exports.focusHandlerProps = focusHandlerProps;
33
+ const textInputHandlerProps = {
34
+ types: {
35
+ /**
36
+ * onChange handler
37
+ */
38
+ onChange: _propTypes.default.func,
39
+
40
+ /**
41
+ * onChangeText handler
42
+ */
43
+ onChangeText: _propTypes.default.func,
44
+
45
+ /**
46
+ * onSubmit handler
47
+ */
48
+ onSubmit: _propTypes.default.func,
49
+
50
+ /**
51
+ * onSubmitEditing handler
52
+ */
53
+ onSubmitEditing: _propTypes.default.func
54
+ },
55
+ select: ({
56
+ onChange,
57
+ onChangeText,
58
+ onSubmit,
59
+ onSubmitEditing
60
+ }) => ({
61
+ onChange,
62
+ onChangeText,
63
+ onSubmit,
64
+ onSubmitEditing
65
+ })
66
+ };
67
+ exports.textInputHandlerProps = textInputHandlerProps;
68
+ var _default = {
69
+ focusHandlerProps,
70
+ textInputHandlerProps
71
+ };
72
+ exports.default = _default;
@@ -17,6 +17,8 @@ var _exportNames = {
17
17
  responsiveProps: true,
18
18
  spacingProps: true,
19
19
  selectSystemProps: true,
20
+ textInputProps: true,
21
+ textProps: true,
20
22
  variantProp: true,
21
23
  viewProps: true
22
24
  };
@@ -98,6 +100,18 @@ Object.defineProperty(exports, "selectSystemProps", {
98
100
  return _selectSystemProps.default;
99
101
  }
100
102
  });
103
+ Object.defineProperty(exports, "textInputProps", {
104
+ enumerable: true,
105
+ get: function () {
106
+ return _textInputProps.default;
107
+ }
108
+ });
109
+ Object.defineProperty(exports, "textProps", {
110
+ enumerable: true,
111
+ get: function () {
112
+ return _textProps.default;
113
+ }
114
+ });
101
115
  Object.defineProperty(exports, "variantProp", {
102
116
  enumerable: true,
103
117
  get: function () {
@@ -125,6 +139,20 @@ Object.keys(_tokens).forEach(function (key) {
125
139
  });
126
140
  });
127
141
 
142
+ var _handlerProps = require("./handlerProps");
143
+
144
+ Object.keys(_handlerProps).forEach(function (key) {
145
+ if (key === "default" || key === "__esModule") return;
146
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
147
+ if (key in exports && exports[key] === _handlerProps[key]) return;
148
+ Object.defineProperty(exports, key, {
149
+ enumerable: true,
150
+ get: function () {
151
+ return _handlerProps[key];
152
+ }
153
+ });
154
+ });
155
+
128
156
  var _a11yProps = _interopRequireDefault(require("./a11yProps"));
129
157
 
130
158
  var _clickProps = _interopRequireDefault(require("./clickProps"));
@@ -151,6 +179,10 @@ var _spacingProps = _interopRequireDefault(require("./spacingProps"));
151
179
 
152
180
  var _selectSystemProps = _interopRequireDefault(require("./selectSystemProps"));
153
181
 
182
+ var _textInputProps = _interopRequireDefault(require("./textInputProps"));
183
+
184
+ var _textProps = _interopRequireDefault(require("./textProps"));
185
+
154
186
  var _variantProp = _interopRequireDefault(require("./variantProp"));
155
187
 
156
188
  var _viewProps = _interopRequireDefault(require("./viewProps"));
@@ -48,18 +48,16 @@ var _default = {
48
48
  hintPosition,
49
49
  feedback,
50
50
  tooltip,
51
- validation,
52
- ...rest
51
+ validation
53
52
  }) => ({
54
- props: {
53
+ supportsProps: {
55
54
  label,
56
55
  hint,
57
56
  hintPosition,
58
57
  feedback,
59
58
  tooltip,
60
59
  validation
61
- },
62
- ...rest
60
+ }
63
61
  })
64
62
  };
65
63
  exports.default = _default;
@@ -38,20 +38,16 @@ var _default = {
38
38
  select: (0, _getPropSelector.default)(linkPropTypes),
39
39
 
40
40
  /**
41
- * Turn hrefs into press handlers on Native and throw if not given `onPress` or `href`.
41
+ * Turn hrefs into press handlers that open links on Native.
42
42
  *
43
43
  * @param {({ onPress?: () => void, href?: string })}
44
- * @returns {(() => void)|undefined} Returns a press handler, or undefined on web if href
45
- * string is provided. Expects calling component to use href string on web (e.g. in `<a>`).
44
+ * @returns {(() => void)|undefined} Returns a press handler, or undefined on web if no press
45
+ * handler is provided (expects calling component to render as `<a href={href}>` on web).
46
46
  */
47
47
  handleHref: ({
48
48
  onPress,
49
49
  href
50
50
  }) => {
51
- if (!href && !onPress) {
52
- throw new Error('handleHref requires either href or onPress');
53
- }
54
-
55
51
  return _Platform.default.select({
56
52
  web: onPress,
57
53
  default: (...args) => {
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+
10
+ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
11
+
12
+ var _getPropSelector = _interopRequireDefault(require("./getPropSelector"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ // This file contains common props for components that render a React Native TextInput
17
+ // It excludes interaction handler functions which are in `./handlerProps.js`
18
+
19
+ /**
20
+ * TextInput (web and native) supports some common React Native props
21
+ * shared with React Native's Text component.
22
+ */
23
+ const textProps = {
24
+ maxFontSizeMultiplier: _propTypes.default.number,
25
+ nativeId: _propTypes.default.string,
26
+ onLayout: _propTypes.default.func
27
+ };
28
+ /**
29
+ * UDS text inputs accept props related to UDS's useInputValue hook
30
+ */
31
+
32
+ const inputValueProps = {
33
+ value: _propTypes.default.string,
34
+ initialValue: _propTypes.default.string,
35
+ readOnly: _propTypes.default.bool
36
+ };
37
+ /**
38
+ * This collection adds props that can be passed through to both React Native's
39
+ * and React Native Web's implementations of the React Native TextInput component.
40
+ */
41
+
42
+ const crossPlatform = { ...textProps,
43
+ ...inputValueProps,
44
+
45
+ /**
46
+ * Web and Android; 'off' disables device autocomplete, other strings are platform-specific.
47
+ * Valid values on Native: https://reactnative.dev/docs/textinput#autocomplete-android
48
+ * Valid values on Web: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
49
+ */
50
+ autoComplete: _propTypes.default.string,
51
+
52
+ /**
53
+ * On Native, default is `true`, passing `false` disables autoCorrect.
54
+ * On web, only supported by Safari and expects "on" or "off" strings.
55
+ */
56
+ autoCorrect: _propTypes.default.oneOf([true, false, 'on', 'off']),
57
+
58
+ /**
59
+ * Focuses the element on mount. On Web, only the first form element with autoFocus is focussed.
60
+ */
61
+ autoFocus: _propTypes.default.bool,
62
+
63
+ /**
64
+ * Default is `true` for single line, `false` for multi-line
65
+ */
66
+ blurOnSubmit: _propTypes.default.bool,
67
+
68
+ /**
69
+ * iOS and Web only, no effect on Android
70
+ */
71
+ clearTextOnFocus: _propTypes.default.bool,
72
+
73
+ /**
74
+ * Default is `true`. On web, this works by mapping to input's `readonly` attribute
75
+ */
76
+ editable: _propTypes.default.bool,
77
+
78
+ /**
79
+ * See documentation for allowed values (varies between Web, Android and iOS) and important notes:
80
+ * - Native: https://reactnative.dev/docs/textinput#keyboardtype
81
+ * - Web: equivalent to `inputmode` but see https://necolas.github.io/react-native-web/docs/text-input/
82
+ */
83
+ keyboardType: _propTypes.default.string,
84
+
85
+ /**
86
+ * Uses native tools (no flicker) to cap the maximum number of characters.
87
+ * On Web, works via `maxlength` attr.
88
+ */
89
+ maxLength: _propTypes.default.number,
90
+
91
+ /**
92
+ * If passed as true, the text input can be multiple lines.
93
+ *
94
+ * > It is important to note that this aligns the text to the top on iOS, and centers it on Android.
95
+ * > Use with textAlignVertical set to top for the same behavior in both platforms.
96
+ */
97
+ multiline: _propTypes.default.bool,
98
+
99
+ /**
100
+ * Web and Android only, requires `multiline` to be `true`.
101
+ */
102
+ numberOfLines: _propTypes.default.number,
103
+
104
+ /**
105
+ * Text to display when no value set.
106
+ * Accesibility guidelines recommend using labels to describe the input and using
107
+ * placeholders rarely and sparingly to prompt a particular format.
108
+ */
109
+ placeholder: _propTypes.default.string,
110
+
111
+ /**
112
+ * Sets placeholder colour. On Web, uses `::placeholder { color: ... }` selector.
113
+ */
114
+ placeholderTextColor: _propTypes.default.string,
115
+
116
+ /**
117
+ * One of a subset of platform-specific options that controls labelling and presentation
118
+ * in on-screen keyboards and accessibility tools. Uses `enterkeyhint` attr on Web.
119
+ *
120
+ * 'done', 'go', 'next', 'search', and 'send' are available for Web, Android and iOS.
121
+ */
122
+ returnKeyType: _propTypes.default.string,
123
+
124
+ /**
125
+ * Obscures passwords and similar. Equivalent to type="password" on Web.
126
+ * Does not work if multiline is true.
127
+ */
128
+ secureTextEntry: _propTypes.default.bool,
129
+
130
+ /**
131
+ * If true, all text will automatically be selected on focus.
132
+ */
133
+ selectTextOnFocus: _propTypes.default.bool,
134
+
135
+ /**
136
+ * Web and iOS. On iOS, default inherits from `autoCorrect`.
137
+ * On Web, equivalent to `spellcheck` attr.
138
+ */
139
+ spellCheck: _propTypes.default.bool
140
+ };
141
+ /**
142
+ * These web-only props all control HTML `input` attributes of the same name.
143
+ * Refer to general HTML documentation for more details.
144
+ */
145
+
146
+ const webOnly = {
147
+ disabled: _propTypes.default.bool,
148
+ dir: _propTypes.default.oneOf(['auto', 'ltr', 'rtl']),
149
+ lang: _propTypes.default.string
150
+ };
151
+ /**
152
+ * These props are supported in React Native but not React Native Web.
153
+ *
154
+ * React Native text inputs can be quirky, so a full set of props should be allowed to handle edge cases.
155
+ * Refer to React Native documentation for details, allowed values, and Android/iOS support and versions:
156
+ * https://reactnative.dev/docs/textinput
157
+ *
158
+ * Beware that many React Native text input props apply via complicated logic that chooses a built-in
159
+ * native component based on the values of multiple boolean flags, and may sometimes appear to pick an
160
+ * option that is inappropriate for one flag based on the values of one or more other other flags.
161
+ */
162
+
163
+ const nativeOnly = {
164
+ caretHidden: _propTypes.default.bool,
165
+ clearButtonMode: _propTypes.default.string,
166
+ contextMenuHidden: _propTypes.default.bool,
167
+ dataDetectorTypes: _propTypes.default.string,
168
+ disableFullscreenUI: _propTypes.default.bool,
169
+ enablesReturnKeyAutomatically: _propTypes.default.bool,
170
+ importantForAutofill: _propTypes.default.string,
171
+ inlineImageLeft: _propTypes.default.string,
172
+ keyboardAppearance: _propTypes.default.string,
173
+ returnKeyLabel: _propTypes.default.string,
174
+ rejectResponderTermination: _propTypes.default.bool,
175
+ scrollEnabled: _propTypes.default.bool,
176
+ selection: _propTypes.default.object,
177
+ selectionColor: _propTypes.default.string,
178
+ showSoftInputOnFocus: _propTypes.default.bool,
179
+ textAlign: _propTypes.default.string,
180
+ textContentType: _propTypes.default.string,
181
+ passwordRules: _propTypes.default.string,
182
+ textBreakStrategy: _propTypes.default.string,
183
+ underlineColorAndroid: _propTypes.default.string
184
+ };
185
+ var _default = {
186
+ /**
187
+ * Subset of proptypes that can be passed down to a React Native or React Native Web
188
+ * `TextInput` component. Allow regardless of platform, so cross-platform apps don't warn.
189
+ */
190
+ types: { ...crossPlatform,
191
+ ...webOnly,
192
+ ...nativeOnly
193
+ },
194
+
195
+ /**
196
+ * Filters a props object. Return only platform-appropriate TextInput props, native inputs
197
+ * may throw errors on receiving unknown props.
198
+ */
199
+ select: (0, _getPropSelector.default)({ ...crossPlatform,
200
+ ..._Platform.default.select({
201
+ web: webOnly,
202
+ default: nativeOnly
203
+ })
204
+ })
205
+ };
206
+ exports.default = _default;