@automattic/vip-design-system 0.27.6 → 0.27.8

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.
@@ -44,7 +44,8 @@ var inputStyles = {
44
44
  bg: 'backgroundSecondary'
45
45
  },
46
46
  '&::placeholder': {
47
- color: 'placeholder'
47
+ color: 'placeholder',
48
+ opacity: 1
48
49
  }
49
50
  };
50
51
 
@@ -33,7 +33,7 @@ var _FormSelectLoading = require("./FormSelectLoading");
33
33
 
34
34
  var _jsxRuntime = require("theme-ui/jsx-runtime");
35
35
 
36
- var _excluded = ["isInline", "forLabel", "options", "label", "getOptionLabel", "getOptionValue", "onChange", "onInputChange", "value", "showAllValues", "searchIcon", "minLength", "debounce", "loading", "required", "displayMenu", "noOptionsMessage", "id", "className"];
36
+ var _excluded = ["autoFilter", "className", "debounce", "displayMenu", "forLabel", "getOptionLabel", "getOptionValue", "id", "isInline", "label", "loading", "minLength", "noOptionsMessage", "onChange", "onInputChange", "options", "required", "searchIcon", "showAllValues", "value"];
37
37
 
38
38
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
39
39
 
@@ -134,35 +134,37 @@ var searchIconStyles = {
134
134
  };
135
135
 
136
136
  var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref, forwardRef) {
137
- var isInline = _ref.isInline,
137
+ var _ref$autoFilter = _ref.autoFilter,
138
+ autoFilter = _ref$autoFilter === void 0 ? true : _ref$autoFilter,
139
+ className = _ref.className,
140
+ _ref$debounce = _ref.debounce,
141
+ debounce = _ref$debounce === void 0 ? 0 : _ref$debounce,
142
+ _ref$displayMenu = _ref.displayMenu,
143
+ displayMenu = _ref$displayMenu === void 0 ? 'overlay' : _ref$displayMenu,
138
144
  forLabel = _ref.forLabel,
139
- _ref$options = _ref.options,
140
- options = _ref$options === void 0 ? [] : _ref$options,
141
- label = _ref.label,
142
145
  getOptionLabel = _ref.getOptionLabel,
143
146
  getOptionValue = _ref.getOptionValue,
144
- _ref$onChange = _ref.onChange,
145
- onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
146
- onInputChange = _ref.onInputChange,
147
- value = _ref.value,
148
- _ref$showAllValues = _ref.showAllValues,
149
- showAllValues = _ref$showAllValues === void 0 ? true : _ref$showAllValues,
150
- searchIcon = _ref.searchIcon,
147
+ _ref$id = _ref.id,
148
+ id = _ref$id === void 0 ? 'vip-autocomplete' : _ref$id,
149
+ isInline = _ref.isInline,
150
+ label = _ref.label,
151
+ loading = _ref.loading,
151
152
  _ref$minLength = _ref.minLength,
152
153
  minLength = _ref$minLength === void 0 ? 0 : _ref$minLength,
153
- _ref$debounce = _ref.debounce,
154
- debounce = _ref$debounce === void 0 ? 0 : _ref$debounce,
155
- loading = _ref.loading,
156
- required = _ref.required,
157
- _ref$displayMenu = _ref.displayMenu,
158
- displayMenu = _ref$displayMenu === void 0 ? 'overlay' : _ref$displayMenu,
159
154
  _ref$noOptionsMessage = _ref.noOptionsMessage,
160
155
  noOptionsMessage = _ref$noOptionsMessage === void 0 ? function () {
161
156
  return 'No results found.';
162
157
  } : _ref$noOptionsMessage,
163
- _ref$id = _ref.id,
164
- id = _ref$id === void 0 ? 'vip-autocomplete' : _ref$id,
165
- className = _ref.className,
158
+ _ref$onChange = _ref.onChange,
159
+ onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
160
+ onInputChange = _ref.onInputChange,
161
+ _ref$options = _ref.options,
162
+ options = _ref$options === void 0 ? [] : _ref$options,
163
+ required = _ref.required,
164
+ searchIcon = _ref.searchIcon,
165
+ _ref$showAllValues = _ref.showAllValues,
166
+ showAllValues = _ref$showAllValues === void 0 ? true : _ref$showAllValues,
167
+ value = _ref.value,
166
168
  props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
167
169
 
168
170
  var _useState = (0, _react.useState)(false),
@@ -210,6 +212,10 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
210
212
  });
211
213
  }, [options]);
212
214
  var handleInputChange = (0, _react.useCallback)(function (query) {
215
+ if (!debounce) {
216
+ return onInputChange(query);
217
+ }
218
+
213
219
  clearTimeout(debounceTimeout);
214
220
 
215
221
  if (!query.length || query.length >= minLength) {
@@ -223,8 +229,8 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
223
229
  handleInputChange(query);
224
230
  }
225
231
 
226
- var data = handleTypeChange(query);
227
- populateResults(data.map(function (option) {
232
+ var data = autoFilter ? handleTypeChange(query) : options;
233
+ populateResults(data == null ? void 0 : data.map(function (option) {
228
234
  return optionLabel(option);
229
235
  }));
230
236
  }, [options, isDirty]);
@@ -264,24 +270,25 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
264
270
 
265
271
  exports.FormAutocomplete = FormAutocomplete;
266
272
  FormAutocomplete.propTypes = {
267
- id: _propTypes["default"].string,
268
- showAllValues: _propTypes["default"].bool,
269
- searchIcon: _propTypes["default"].bool,
270
- loading: _propTypes["default"].bool,
271
- required: _propTypes["default"].bool,
272
- isInline: _propTypes["default"].bool,
273
- forLabel: _propTypes["default"].string,
274
- value: _propTypes["default"].string,
273
+ autoFilter: _propTypes["default"].bool,
274
+ className: _propTypes["default"].any,
275
+ debounce: _propTypes["default"].number,
275
276
  displayMenu: _propTypes["default"].string,
276
- label: _propTypes["default"].string,
277
- options: _propTypes["default"].array,
277
+ forLabel: _propTypes["default"].string,
278
278
  getOptionLabel: _propTypes["default"].func,
279
279
  getOptionValue: _propTypes["default"].func,
280
- onInputChange: _propTypes["default"].func,
280
+ id: _propTypes["default"].string,
281
+ isInline: _propTypes["default"].bool,
282
+ label: _propTypes["default"].string,
283
+ loading: _propTypes["default"].bool,
284
+ minLength: _propTypes["default"].number,
281
285
  noOptionsMessage: _propTypes["default"].func,
282
286
  onChange: _propTypes["default"].func,
283
- className: _propTypes["default"].any,
284
- minLength: _propTypes["default"].number,
285
- debounce: _propTypes["default"].number
287
+ onInputChange: _propTypes["default"].func,
288
+ options: _propTypes["default"].array,
289
+ required: _propTypes["default"].bool,
290
+ searchIcon: _propTypes["default"].bool,
291
+ showAllValues: _propTypes["default"].bool,
292
+ value: _propTypes["default"].string
286
293
  };
287
294
  FormAutocomplete.displayName = 'FormAutocomplete';
@@ -96,7 +96,7 @@
96
96
  "placeholder": {
97
97
  "type": "color",
98
98
  "description": "Use for placeholder text in fields",
99
- "value": "#8f8c8b"
99
+ "value": "#757575"
100
100
  },
101
101
  "disabled": {
102
102
  "type": "color",
@@ -149,7 +149,7 @@
149
149
  },
150
150
  "disabled": {
151
151
  "type": "color",
152
- "value": "#8f8c8b"
152
+ "value": "#757575"
153
153
  }
154
154
  },
155
155
  "button": {
@@ -1476,7 +1476,7 @@
1476
1476
  "type": "color"
1477
1477
  },
1478
1478
  "45": {
1479
- "value": "#8f8c8b",
1479
+ "value": "#757575",
1480
1480
  "type": "color"
1481
1481
  },
1482
1482
  "50": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip-design-system",
3
- "version": "0.27.6",
3
+ "version": "0.27.8",
4
4
  "main": "build/system/index.js",
5
5
  "scripts": {
6
6
  "build-storybook": "build-storybook",
@@ -33,6 +33,7 @@ const inputStyles = {
33
33
  },
34
34
  '&::placeholder': {
35
35
  color: 'placeholder',
36
+ opacity: 1,
36
37
  },
37
38
  };
38
39
 
@@ -95,25 +95,26 @@ const searchIconStyles = {
95
95
  const FormAutocomplete = React.forwardRef(
96
96
  (
97
97
  {
98
- isInline,
98
+ autoFilter = true,
99
+ className,
100
+ debounce = 0,
101
+ displayMenu = 'overlay',
99
102
  forLabel,
100
- options = [],
101
- label,
102
103
  getOptionLabel,
103
104
  getOptionValue,
105
+ id = 'vip-autocomplete',
106
+ isInline,
107
+ label,
108
+ loading,
109
+ minLength = 0,
110
+ noOptionsMessage = () => 'No results found.',
104
111
  onChange = () => {},
105
112
  onInputChange,
106
- value,
107
- showAllValues = true,
108
- searchIcon,
109
- minLength = 0,
110
- debounce = 0,
111
- loading,
113
+ options = [],
112
114
  required,
113
- displayMenu = 'overlay',
114
- noOptionsMessage = () => 'No results found.',
115
- id = 'vip-autocomplete',
116
- className,
115
+ searchIcon,
116
+ showAllValues = true,
117
+ value,
117
118
  ...props
118
119
  },
119
120
  forwardRef
@@ -168,6 +169,9 @@ const FormAutocomplete = React.forwardRef(
168
169
 
169
170
  const handleInputChange = useCallback(
170
171
  query => {
172
+ if ( ! debounce ) {
173
+ return onInputChange( query );
174
+ }
171
175
  clearTimeout( debounceTimeout );
172
176
  if ( ! query.length || query.length >= minLength ) {
173
177
  debounceTimeout = setTimeout( () => {
@@ -183,8 +187,8 @@ const FormAutocomplete = React.forwardRef(
183
187
  if ( isDirty && onInputChange ) {
184
188
  handleInputChange( query );
185
189
  }
186
- const data = handleTypeChange( query );
187
- populateResults( data.map( option => optionLabel( option ) ) );
190
+ const data = autoFilter ? handleTypeChange( query ) : options;
191
+ populateResults( data?.map( option => optionLabel( option ) ) );
188
192
  },
189
193
  [ options, isDirty ]
190
194
  );
@@ -245,25 +249,26 @@ const FormAutocomplete = React.forwardRef(
245
249
  );
246
250
 
247
251
  FormAutocomplete.propTypes = {
248
- id: PropTypes.string,
249
- showAllValues: PropTypes.bool,
250
- searchIcon: PropTypes.bool,
251
- loading: PropTypes.bool,
252
- required: PropTypes.bool,
253
- isInline: PropTypes.bool,
254
- forLabel: PropTypes.string,
255
- value: PropTypes.string,
252
+ autoFilter: PropTypes.bool,
253
+ className: PropTypes.any,
254
+ debounce: PropTypes.number,
256
255
  displayMenu: PropTypes.string,
257
- label: PropTypes.string,
258
- options: PropTypes.array,
256
+ forLabel: PropTypes.string,
259
257
  getOptionLabel: PropTypes.func,
260
258
  getOptionValue: PropTypes.func,
261
- onInputChange: PropTypes.func,
259
+ id: PropTypes.string,
260
+ isInline: PropTypes.bool,
261
+ label: PropTypes.string,
262
+ loading: PropTypes.bool,
263
+ minLength: PropTypes.number,
262
264
  noOptionsMessage: PropTypes.func,
263
265
  onChange: PropTypes.func,
264
- className: PropTypes.any,
265
- minLength: PropTypes.number,
266
- debounce: PropTypes.number,
266
+ onInputChange: PropTypes.func,
267
+ options: PropTypes.array,
268
+ required: PropTypes.bool,
269
+ searchIcon: PropTypes.bool,
270
+ showAllValues: PropTypes.bool,
271
+ value: PropTypes.string,
267
272
  };
268
273
 
269
274
  FormAutocomplete.displayName = 'FormAutocomplete';
@@ -96,7 +96,7 @@
96
96
  "placeholder": {
97
97
  "type": "color",
98
98
  "description": "Use for placeholder text in fields",
99
- "value": "#8f8c8b"
99
+ "value": "#757575"
100
100
  },
101
101
  "disabled": {
102
102
  "type": "color",
@@ -149,7 +149,7 @@
149
149
  },
150
150
  "disabled": {
151
151
  "type": "color",
152
- "value": "#8f8c8b"
152
+ "value": "#757575"
153
153
  }
154
154
  },
155
155
  "button": {
@@ -1476,7 +1476,7 @@
1476
1476
  "type": "color"
1477
1477
  },
1478
1478
  "45": {
1479
- "value": "#8f8c8b",
1479
+ "value": "#757575",
1480
1480
  "type": "color"
1481
1481
  },
1482
1482
  "50": {