@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
@@ -25,7 +25,7 @@ var _utils = require("../utils");
25
25
 
26
26
  var _ViewportProvider = require("../ViewportProvider");
27
27
 
28
- var _ButtonBase = _interopRequireDefault(require("../Button/ButtonBase"));
28
+ var _IconButton = _interopRequireDefault(require("../IconButton"));
29
29
 
30
30
  var _dictionary = _interopRequireDefault(require("./dictionary"));
31
31
 
@@ -90,14 +90,6 @@ const selectCloseButtonContainerStyles = ({
90
90
  paddingRight,
91
91
  paddingTop
92
92
  });
93
-
94
- const selectCloseIconProps = ({
95
- closeIconSize,
96
- closeIconColor
97
- }) => ({
98
- size: closeIconSize,
99
- color: closeIconColor
100
- });
101
93
  /**
102
94
  * A modal window is a secondary window that opens on top of the main one.
103
95
  * Users have to interact with it before they can carry out their task and return to the main window.
@@ -122,6 +114,7 @@ const Modal = /*#__PURE__*/(0, _react.forwardRef)(({
122
114
  tokens,
123
115
  variant,
124
116
  copy,
117
+ closeButton,
125
118
  ...rest
126
119
  }, ref) => {
127
120
  const viewport = (0, _ViewportProvider.useViewport)();
@@ -144,12 +137,15 @@ const Modal = /*#__PURE__*/(0, _react.forwardRef)(({
144
137
 
145
138
  const handleKeyUp = event => {
146
139
  if (event.key === 'Escape') onClose();
147
- };
140
+ }; // Show the custom react node passed to `closedButton` or the default close button if `closeButton` is `undefined`.
141
+ // Hide the close button if `closeButton` is `null`.
142
+
143
+
144
+ const showCloseButton = closeButton !== null;
148
145
 
149
146
  if (!isOpen) {
150
147
  return null;
151
- } // TODO: replace the close button with IconButton when implemented (https://github.com/telus/universal-design-system/issues/281)
152
-
148
+ }
153
149
 
154
150
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Modal.default, {
155
151
  transparent: true,
@@ -164,15 +160,14 @@ const Modal = /*#__PURE__*/(0, _react.forwardRef)(({
164
160
  ref: ref,
165
161
  style: [staticStyles.modal, selectModalStyles(themeTokens)],
166
162
  onKeyUp: handleKeyUp,
167
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
163
+ children: [showCloseButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
168
164
  style: [staticStyles.closeButtonContainer, selectCloseButtonContainerStyles(themeTokens)],
169
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
165
+ children: closeButton || /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
170
166
  onPress: handleClose,
167
+ icon: CloseIconComponent,
171
168
  accessibilityRole: "button",
172
169
  accessibilityLabel: closeLabel,
173
- children: // TODO: add close button interactive states after IconButton is done
174
- () => /*#__PURE__*/(0, _jsxRuntime.jsx)(CloseIconComponent, { ...selectCloseIconProps(themeTokens)
175
- })
170
+ tokens: (0, _utils.selectTokens)('IconButton', themeTokens, 'close')
176
171
  })
177
172
  }), children]
178
173
  })
@@ -193,7 +188,12 @@ Modal.propTypes = { ...selectedSystemPropTypes,
193
188
  onClose: _propTypes.default.func,
194
189
  maxWidth: _propTypes.default.bool,
195
190
  tokens: (0, _utils.getTokensPropType)('Modal'),
196
- variant: _utils.variantProp.propType
191
+ variant: _utils.variantProp.propType,
192
+
193
+ /**
194
+ * Pass a react node to override the default close button or pass `null` to hide the close button.
195
+ */
196
+ closeButton: _propTypes.default.node
197
197
  };
198
198
  var _default = Modal;
199
199
  exports.default = _default;
@@ -35,7 +35,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
35
35
 
36
36
  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
37
 
38
- const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
38
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
39
39
 
40
40
  const selectContainerStyles = ({
41
41
  containerBackgroundColor,
@@ -186,22 +186,29 @@ const Radio = /*#__PURE__*/(0, _react.forwardRef)(({
186
186
  hover,
187
187
  pressed
188
188
  });
189
+ const labelStyles = selectLabelStyles(stateTokens);
190
+ const alignWithLabel = label ? [staticStyles.alignWithLabel, {
191
+ height: labelStyles.lineHeight
192
+ }] : null;
189
193
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.default, {
190
194
  space: 0,
191
195
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
192
196
  style: [staticStyles.container, selectContainerStyles(stateTokens)],
193
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioButton.default, {
194
- tokens: (0, _RadioButton.selectRadioButtonTokens)(stateTokens),
195
- isControlled: isControlled,
196
- isChecked: isChecked,
197
- inactive: inactive,
198
- defaultChecked: defaultChecked,
199
- inputId: inputId,
200
- handleChange: handleChange,
201
- name: inputName,
202
- value: value
197
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
198
+ style: alignWithLabel,
199
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioButton.default, {
200
+ tokens: (0, _RadioButton.selectRadioButtonTokens)(stateTokens),
201
+ isControlled: isControlled,
202
+ isChecked: isChecked,
203
+ inactive: inactive,
204
+ defaultChecked: defaultChecked,
205
+ inputId: inputId,
206
+ handleChange: handleChange,
207
+ name: inputName,
208
+ value: value
209
+ })
203
210
  }), Boolean(label) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
204
- style: selectLabelStyles(stateTokens),
211
+ style: labelStyles,
205
212
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LabelContent.default, {
206
213
  forId: inputId,
207
214
  children: label
@@ -285,5 +292,9 @@ const staticStyles = _StyleSheet.default.create({
285
292
  container: {
286
293
  flexDirection: 'row',
287
294
  alignItems: 'center'
295
+ },
296
+ alignWithLabel: {
297
+ alignSelf: 'flex-start',
298
+ justifyContent: 'center'
288
299
  }
289
300
  });
@@ -32,6 +32,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
32
32
  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; }
33
33
 
34
34
  const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
35
+ const [selectItemProps, selectedItemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
35
36
  /**
36
37
  * A group of Radios that behave as a radio group. Use when users select a single choice from mutually
37
38
  * exclusive options.
@@ -115,11 +116,18 @@ const RadioGroup = /*#__PURE__*/(0, _react.forwardRef)(({
115
116
  onChange,
116
117
  readOnly: readOnly || inactive
117
118
  });
119
+ const uniqueFields = ['id', 'label'];
120
+
121
+ if (!(0, _utils.containUniqueFields)(items, uniqueFields)) {
122
+ throw new Error(`RadioGroup items must have unique ${uniqueFields.join(', ')}`);
123
+ }
124
+
118
125
  const radios = items.map(({
119
126
  label,
120
127
  id,
121
128
  onChange: itemOnChange,
122
- ref: itemRef
129
+ ref: itemRef,
130
+ ...itemRest
123
131
  }, index) => {
124
132
  const radioId = id || `Radio[${index}]`;
125
133
  const isChecked = currentValue === radioId;
@@ -138,7 +146,8 @@ const RadioGroup = /*#__PURE__*/(0, _react.forwardRef)(({
138
146
  label: label,
139
147
  name: inputGroupName,
140
148
  tokens: radioTokens,
141
- variant: variant
149
+ variant: variant,
150
+ ...selectItemProps(itemRest)
142
151
  }, radioId);
143
152
  });
144
153
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Fieldset.default, {
@@ -180,7 +189,7 @@ RadioGroup.propTypes = { ...selectedSystemPropTypes,
180
189
  /**
181
190
  * Array of objects containing specifics for each Radio to be rendered in the group.
182
191
  */
183
- items: _propTypes.default.arrayOf(_propTypes.default.exact({
192
+ items: _propTypes.default.arrayOf(_propTypes.default.exact({ ...selectedItemPropTypes,
184
193
  label: _propTypes.default.string,
185
194
  id: _propTypes.default.string,
186
195
  onChange: _propTypes.default.func,
@@ -33,7 +33,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
33
33
 
34
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; }
35
35
 
36
- const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
36
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
37
37
  /**
38
38
  * A Card that behaves like a radio button. Use when users select a single choice from mutually exclusive options
39
39
  * with need to show additional information for each option. The whole card is interactive as one item.
@@ -30,6 +30,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
30
30
  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; }
31
31
 
32
32
  const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
33
+ const [selectItemProps, selectedItemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.viewProps]);
33
34
  /**
34
35
  * A group of Cards that behave as a radio button group. Use when users select a single choice from mutually
35
36
  * exclusive options with need to show additional information for each option. The whole cards are each
@@ -120,6 +121,12 @@ const RadioCardGroup = /*#__PURE__*/(0, _react.forwardRef)(({
120
121
  // and also needs 'radiogroup' role on fieldset for correct description on focusing the set.
121
122
  // TODO: test this on more web screen readers.
122
123
 
124
+ const uniqueFields = ['id'];
125
+
126
+ if (!(0, _utils.containUniqueFields)(items, uniqueFields)) {
127
+ throw new Error(`RadioCardGroup items must have unique ${uniqueFields.join(', ')}`);
128
+ }
129
+
123
130
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Fieldset.default, {
124
131
  ref: ref,
125
132
  name: inputGroupName,
@@ -139,7 +146,8 @@ const RadioCardGroup = /*#__PURE__*/(0, _react.forwardRef)(({
139
146
  title,
140
147
  content,
141
148
  id,
142
- onChange: itemOnChange
149
+ onChange: itemOnChange,
150
+ ...itemRest
143
151
  }, index) => {
144
152
  const cardId = id || `RadioCard[${index}]`;
145
153
 
@@ -158,6 +166,7 @@ const RadioCardGroup = /*#__PURE__*/(0, _react.forwardRef)(({
158
166
  tokens: radioCardTokens,
159
167
  variant: variant,
160
168
  readOnly: readOnly,
169
+ ...selectItemProps(itemRest),
161
170
  ...props,
162
171
  children: content
163
172
  }, cardId);
@@ -186,7 +195,7 @@ RadioCardGroup.propTypes = { ...selectedSystemPropTypes,
186
195
  /**
187
196
  * Array of objects containing specifics for each RadioCard to be rendered in the group.
188
197
  */
189
- items: _propTypes.default.arrayOf(_propTypes.default.exact({
198
+ items: _propTypes.default.arrayOf(_propTypes.default.exact({ ...selectedItemPropTypes,
190
199
  title: _propTypes.default.string,
191
200
  content: _propTypes.default.node,
192
201
  id: _propTypes.default.string,
@@ -35,7 +35,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
35
35
 
36
36
  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
37
 
38
- const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
38
+ const [selectContainerProps, selectedContainerPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
39
+ const [selectInputProps, selectedInputPropTypes] = (0, _utils.selectSystemProps)([_utils.textInputHandlerProps, _utils.textInputProps]);
39
40
 
40
41
  const selectInputTokens = ({
41
42
  searchTokens,
@@ -90,8 +91,9 @@ const selectIconTokens = ({
90
91
 
91
92
 
92
93
  const Search = /*#__PURE__*/(0, _react.forwardRef)(({
93
- initialValue = '',
94
- placeholder = 'Search',
94
+ initialValue,
95
+ value,
96
+ placeholder,
95
97
  inactive,
96
98
  onChange,
97
99
  onSubmit,
@@ -102,7 +104,14 @@ const Search = /*#__PURE__*/(0, _react.forwardRef)(({
102
104
  variant,
103
105
  ...rest
104
106
  }, ref) => {
105
- const [value, setValue] = (0, _react.useState)(initialValue);
107
+ const {
108
+ currentValue = '',
109
+ setValue
110
+ } = (0, _utils.useInputValue)({
111
+ value,
112
+ initialValue,
113
+ onChange
114
+ });
106
115
  const themeTokens = (0, _ThemeProvider.useThemeTokens)('Search', tokens, variant);
107
116
  const buttonTokens = (0, _ThemeProvider.useThemeTokens)('SearchButton', tokens, variant);
108
117
  const getThemeTokens = (0, _ThemeProvider.useThemeTokensCallback)('Search', tokens, variant);
@@ -123,26 +132,24 @@ const Search = /*#__PURE__*/(0, _react.forwardRef)(({
123
132
 
124
133
  const handleSubmit = event => {
125
134
  if (onSubmit !== undefined) {
126
- onSubmit(value, event);
135
+ onSubmit(currentValue, event);
127
136
  }
128
137
  };
129
138
 
130
- const handleChange = (currentValue, event) => {
131
- setValue(currentValue, event);
132
- if (onChange !== undefined) onChange(currentValue, event);
133
- };
134
-
135
139
  const handleClear = event => {
136
140
  setValue('', event);
137
141
  if (onClear !== undefined) onClear('', event);
138
- if (onChange !== undefined) onChange('', event);
139
142
  };
140
143
 
141
- const isEmpty = value === '';
144
+ const isEmpty = currentValue === ''; // Accessibility label should always be present and correctly localised
145
+
146
+ const a11yLabelText = accessibilityLabel || getCopy('accessibilityLabel'); // Placeholder is optional and may be unset by passing an empty string
147
+
148
+ const placeholderText = placeholder ?? a11yLabelText;
142
149
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
143
150
  style: staticStyles.container,
144
- ...selectProps(rest),
145
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInputBase.default, {
151
+ ...selectContainerProps(rest),
152
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInputBase.default, { ...selectInputProps(rest),
146
153
  ref: ref,
147
154
  tokens: appearances => selectInputTokens({
148
155
  searchTokens: getThemeTokens(appearances),
@@ -150,15 +157,15 @@ const Search = /*#__PURE__*/(0, _react.forwardRef)(({
150
157
  buttonsGapSize,
151
158
  isEmpty
152
159
  }),
153
- placeholder: placeholder,
160
+ placeholder: placeholderText,
154
161
  placeholderTextColor: placeholderColor,
155
162
  inactive: inactive,
156
163
  enablesReturnKeyAutomatically: true,
157
164
  returnKeyType: "search",
158
- value: value,
159
- onChange: handleChange,
165
+ value: currentValue,
166
+ onChange: setValue,
160
167
  onSubmitEditing: handleSubmit,
161
- accessibilityLabel: accessibilityLabel || getCopy('accessibilityLabel')
168
+ accessibilityLabel: a11yLabelText
162
169
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
163
170
  style: [staticStyles.iconsContainer, selectIconsContainerStyle(themeTokens)],
164
171
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.default, {
@@ -190,7 +197,8 @@ const Search = /*#__PURE__*/(0, _react.forwardRef)(({
190
197
  });
191
198
  });
192
199
  Search.displayName = 'Search';
193
- Search.propTypes = { ...selectedSystemPropTypes,
200
+ Search.propTypes = { ...selectedContainerPropTypes,
201
+ ...selectedInputPropTypes,
194
202
 
195
203
  /**
196
204
  * Use this to set the initial value of the search input.
@@ -221,7 +221,7 @@ const Select = /*#__PURE__*/(0, _react.forwardRef)(({
221
221
  const handleMouseOut = () => setIsHovered(false);
222
222
 
223
223
  const {
224
- props: supportsProps,
224
+ supportsProps,
225
225
  ...selectedProps
226
226
  } = selectProps(rest);
227
227
  const themeTokens = (0, _ThemeProvider.useThemeTokens)('Select', tokens, variant, {
@@ -262,8 +262,7 @@ const Select = /*#__PURE__*/(0, _react.forwardRef)(({
262
262
  }), ValidationIconComponent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
263
263
  pointerEvents: "none",
264
264
  style: [staticStyles.iconContainer, selectValidationIconContainerStyles(themeTokens)],
265
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ValidationIconComponent, {
266
- tokens: selectValidationIconTokens(themeTokens)
265
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ValidationIconComponent, { ...selectValidationIconTokens(themeTokens)
267
266
  })
268
267
  }), IconComponent && _Platform.default.OS !== 'android' &&
269
268
  /*#__PURE__*/
package/lib/Tags/Tags.js CHANGED
@@ -27,9 +27,7 @@ var _ViewportProvider = require("../ViewportProvider");
27
27
 
28
28
  var _ThemeProvider = require("../ThemeProvider");
29
29
 
30
- var _props = require("../utils/props");
31
-
32
- var _input = require("../utils/input");
30
+ var _utils = require("../utils");
33
31
 
34
32
  var _pressability = require("../utils/pressability");
35
33
 
@@ -41,7 +39,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
41
39
 
42
40
  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; }
43
41
 
44
- const [selectProps, selectedSystemPropTypes] = (0, _props.selectSystemProps)([_props.a11yProps, _props.pressProps, _props.viewProps]);
42
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
43
+ const [selectItemProps, selectedItemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.pressProps, _utils.viewProps]);
45
44
 
46
45
  const selectIconTextTokens = ({
47
46
  icon,
@@ -99,19 +98,19 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
99
98
  const themeTokens = (0, _ThemeProvider.useThemeTokens)('Tags', tokens, variant, {
100
99
  viewport
101
100
  });
102
- const stackTokens = (0, _props.selectTokens)('StackView', themeTokens);
101
+ const stackTokens = (0, _utils.selectTokens)('StackView', themeTokens);
103
102
  const {
104
103
  direction,
105
104
  space
106
105
  } = themeTokens;
107
106
  const getItemTokens = (0, _ThemeProvider.useThemeTokensCallback)('TagsItem', tokens, variant);
108
107
 
109
- const getButtonTokens = buttonState => (0, _props.selectTokens)('Button', getItemTokens(buttonState));
108
+ const getButtonTokens = buttonState => (0, _utils.selectTokens)('Button', getItemTokens(buttonState));
110
109
 
111
110
  const {
112
111
  currentValues,
113
112
  toggleOneValue
114
- } = (0, _input.useMultipleInputValues)({
113
+ } = (0, _utils.useMultipleInputValues)({
115
114
  initialValues,
116
115
  values,
117
116
  maxValues,
@@ -123,6 +122,12 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
123
122
  ...rest
124
123
  });
125
124
  const itemA11yRole = 'checkbox';
125
+ const uniqueFields = ['id', 'label'];
126
+
127
+ if (!(0, _utils.containUniqueFields)(items, uniqueFields)) {
128
+ throw new Error(`Tags items must have unique ${uniqueFields.join(', ')}`);
129
+ }
130
+
126
131
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.StackWrap, {
127
132
  ref: ref,
128
133
  ...selectedProps,
@@ -132,8 +137,8 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
132
137
  children: items.map(({
133
138
  label,
134
139
  id = label,
135
- accessibilityLabel,
136
- ref: itemRef
140
+ ref: itemRef,
141
+ ...itemRest
137
142
  }, index) => {
138
143
  const isSelected = currentValues.includes(id); // Pass an object of relevant component state as first argument for any passed-in press handlers
139
144
 
@@ -144,17 +149,17 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
144
149
  }]);
145
150
 
146
151
  const handlePress = event => {
147
- if (pressHandlers.onPress) pressHandlers.onPress();
152
+ if (pressHandlers.onPress) pressHandlers.onPress(event);
148
153
  toggleOneValue(id, event);
149
154
  };
150
155
 
151
- const itemA11y = {
156
+ const itemProps = {
152
157
  accessibilityState: {
153
158
  checked: isSelected
154
159
  },
155
160
  accessibilityRole: itemA11yRole,
156
- accessibilityLabel,
157
- ..._props.a11yProps.getPositionInSet(items.length, index)
161
+ ..._utils.a11yProps.getPositionInSet(items.length, index),
162
+ ...selectItemProps(itemRest)
158
163
  };
159
164
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonBase.default, {
160
165
  ref: itemRef,
@@ -163,7 +168,7 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
163
168
  tokens: getButtonTokens,
164
169
  selected: isSelected,
165
170
  inactive: inactive,
166
- ...itemA11y,
171
+ ...itemProps,
167
172
  children: ({
168
173
  textStyles,
169
174
  ...buttonState
@@ -203,8 +208,8 @@ const Tags = /*#__PURE__*/(0, _react.forwardRef)(({
203
208
  });
204
209
  Tags.displayName = 'Tags';
205
210
  Tags.propTypes = { ...selectedSystemPropTypes,
206
- tokens: (0, _props.getTokensPropType)('Tags'),
207
- variant: _props.variantProp.propType,
211
+ tokens: (0, _utils.getTokensPropType)('Tags'),
212
+ variant: _utils.variantProp.propType,
208
213
 
209
214
  /**
210
215
  * If provided, sets a maximum number of items a user may select at once.
@@ -214,7 +219,8 @@ Tags.propTypes = { ...selectedSystemPropTypes,
214
219
  /**
215
220
  * The options a user may select
216
221
  */
217
- items: _propTypes.default.arrayOf(_propTypes.default.shape({
222
+ items: _propTypes.default.arrayOf(_propTypes.default.shape({ ...selectedItemPropTypes,
223
+
218
224
  /**
219
225
  * The text displayed to the user in the button, describing this option,
220
226
  * passed to the button as its child.
@@ -27,7 +27,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
27
27
 
28
28
  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; }
29
29
 
30
- const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.inputSupportsProps, _utils.viewProps]);
30
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.inputSupportsProps, _utils.textInputHandlerProps, _utils.textInputProps, _utils.viewProps]);
31
31
  /**
32
32
  * Use to collect long-form information such as product feedback or support queries.
33
33
  * Due to React Native's implementation of `TextInput` it's not possible to access the current value by passing a ref.
@@ -75,7 +75,7 @@ const TextArea = /*#__PURE__*/(0, _react.forwardRef)(({
75
75
  };
76
76
 
77
77
  const {
78
- props: supportsProps,
78
+ supportsProps,
79
79
  ...selectedProps
80
80
  } = selectProps(rest);
81
81
  const inputProps = { ...selectedProps,
@@ -7,6 +7,8 @@ exports.default = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
+ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
11
+
10
12
  var _utils = require("../utils");
11
13
 
12
14
  var _InputSupports = _interopRequireDefault(require("../InputSupports"));
@@ -23,7 +25,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
23
25
 
24
26
  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; }
25
27
 
26
- const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.inputSupportsProps, _utils.viewProps]);
28
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.inputSupportsProps, _utils.textInputHandlerProps, _utils.textInputProps, _utils.viewProps]);
27
29
  /**
28
30
  * A basic text input component. Use in forms or individually to receive user's input.
29
31
  * Due to React Native's implementation of `TextInput` it's not possible to access the current value by passing a ref.
@@ -46,10 +48,18 @@ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_u
46
48
  const TextInput = /*#__PURE__*/(0, _react.forwardRef)(({
47
49
  tokens,
48
50
  variant = {},
51
+ pattern,
49
52
  ...rest
50
53
  }, ref) => {
54
+ _react.default.useEffect(() => {
55
+ if (_Platform.default.OS === 'web' && pattern && ref.current) {
56
+ // eslint-disable-next-line no-param-reassign
57
+ ref.current.pattern = pattern;
58
+ }
59
+ }, [ref, pattern]);
60
+
51
61
  const {
52
- props: supportsProps,
62
+ supportsProps,
53
63
  ...selectedProps
54
64
  } = selectProps(rest);
55
65
  const inputProps = { ...selectedProps,
@@ -29,7 +29,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
29
29
 
30
30
  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; }
31
31
 
32
- const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
32
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.textInputHandlerProps, _utils.textInputProps, _utils.viewProps]);
33
33
 
34
34
  const selectInputStyles = ({
35
35
  backgroundColor,
@@ -7,6 +7,8 @@ exports.default = void 0;
7
7
 
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
10
+ var _Platform = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Platform"));
11
+
10
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
13
 
12
14
  const textInputPropTypes = {
@@ -36,7 +38,12 @@ const textInputPropTypes = {
36
38
  * Use to react upon input's value changes. Required when the `value` prop is set.
37
39
  * Will receive the input's value as an argument.
38
40
  */
39
- onChange: _propTypes.default.func
41
+ onChange: _propTypes.default.func,
42
+ ..._Platform.default.select({
43
+ web: {
44
+ pattern: _propTypes.default.string
45
+ }
46
+ })
40
47
  };
41
48
  var _default = textInputPropTypes;
42
49
  exports.default = _default;
@@ -35,7 +35,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
35
35
 
36
36
  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
37
 
38
- const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.pressProps, _utils.viewProps]);
38
+ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.focusHandlerProps, _utils.pressProps, _utils.viewProps]);
39
39
 
40
40
  const selectButtonTokens = tokens => (0, _utils.selectTokens)('Button', { ...tokens,
41
41
  // Width tokens are applied to our inner track. Disable Button width token so it wraps our track width.
@@ -141,7 +141,7 @@ const ToggleSwitch = /*#__PURE__*/(0, _react.forwardRef)(({
141
141
  space: 2,
142
142
  direction: "row",
143
143
  children: [Boolean(label) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
144
- style: selectLabelStyles(themeTokens),
144
+ style: [selectLabelStyles(themeTokens), staticStyles.containText],
145
145
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputLabel.default, {
146
146
  forId: inputId,
147
147
  label: label,
@@ -244,6 +244,9 @@ const staticStyles = _StyleSheet.default.create({
244
244
  switch: {
245
245
  alignItems: 'center',
246
246
  justifyContent: 'center'
247
+ },
248
+ containText: {
249
+ flexShrink: 1
247
250
  }
248
251
  });
249
252