@automattic/vip-design-system 0.27.7 → 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.
|
@@ -33,7 +33,7 @@ var _FormSelectLoading = require("./FormSelectLoading");
|
|
|
33
33
|
|
|
34
34
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
35
35
|
|
|
36
|
-
var _excluded = ["
|
|
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
|
|
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$
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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$
|
|
164
|
-
|
|
165
|
-
|
|
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),
|
|
@@ -227,7 +229,7 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
|
|
|
227
229
|
handleInputChange(query);
|
|
228
230
|
}
|
|
229
231
|
|
|
230
|
-
var data = handleTypeChange(query);
|
|
232
|
+
var data = autoFilter ? handleTypeChange(query) : options;
|
|
231
233
|
populateResults(data == null ? void 0 : data.map(function (option) {
|
|
232
234
|
return optionLabel(option);
|
|
233
235
|
}));
|
|
@@ -268,24 +270,25 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
|
|
|
268
270
|
|
|
269
271
|
exports.FormAutocomplete = FormAutocomplete;
|
|
270
272
|
FormAutocomplete.propTypes = {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
loading: _propTypes["default"].bool,
|
|
275
|
-
required: _propTypes["default"].bool,
|
|
276
|
-
isInline: _propTypes["default"].bool,
|
|
277
|
-
forLabel: _propTypes["default"].string,
|
|
278
|
-
value: _propTypes["default"].string,
|
|
273
|
+
autoFilter: _propTypes["default"].bool,
|
|
274
|
+
className: _propTypes["default"].any,
|
|
275
|
+
debounce: _propTypes["default"].number,
|
|
279
276
|
displayMenu: _propTypes["default"].string,
|
|
280
|
-
|
|
281
|
-
options: _propTypes["default"].array,
|
|
277
|
+
forLabel: _propTypes["default"].string,
|
|
282
278
|
getOptionLabel: _propTypes["default"].func,
|
|
283
279
|
getOptionValue: _propTypes["default"].func,
|
|
284
|
-
|
|
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,
|
|
285
285
|
noOptionsMessage: _propTypes["default"].func,
|
|
286
286
|
onChange: _propTypes["default"].func,
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|
|
290
293
|
};
|
|
291
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": "#
|
|
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": "#
|
|
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": "#
|
|
1479
|
+
"value": "#757575",
|
|
1480
1480
|
"type": "color"
|
|
1481
1481
|
},
|
|
1482
1482
|
"50": {
|
package/package.json
CHANGED
|
@@ -95,25 +95,26 @@ const searchIconStyles = {
|
|
|
95
95
|
const FormAutocomplete = React.forwardRef(
|
|
96
96
|
(
|
|
97
97
|
{
|
|
98
|
-
|
|
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
|
-
|
|
107
|
-
showAllValues = true,
|
|
108
|
-
searchIcon,
|
|
109
|
-
minLength = 0,
|
|
110
|
-
debounce = 0,
|
|
111
|
-
loading,
|
|
113
|
+
options = [],
|
|
112
114
|
required,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
className,
|
|
115
|
+
searchIcon,
|
|
116
|
+
showAllValues = true,
|
|
117
|
+
value,
|
|
117
118
|
...props
|
|
118
119
|
},
|
|
119
120
|
forwardRef
|
|
@@ -186,7 +187,7 @@ const FormAutocomplete = React.forwardRef(
|
|
|
186
187
|
if ( isDirty && onInputChange ) {
|
|
187
188
|
handleInputChange( query );
|
|
188
189
|
}
|
|
189
|
-
const data = handleTypeChange( query );
|
|
190
|
+
const data = autoFilter ? handleTypeChange( query ) : options;
|
|
190
191
|
populateResults( data?.map( option => optionLabel( option ) ) );
|
|
191
192
|
},
|
|
192
193
|
[ options, isDirty ]
|
|
@@ -248,25 +249,26 @@ const FormAutocomplete = React.forwardRef(
|
|
|
248
249
|
);
|
|
249
250
|
|
|
250
251
|
FormAutocomplete.propTypes = {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
loading: PropTypes.bool,
|
|
255
|
-
required: PropTypes.bool,
|
|
256
|
-
isInline: PropTypes.bool,
|
|
257
|
-
forLabel: PropTypes.string,
|
|
258
|
-
value: PropTypes.string,
|
|
252
|
+
autoFilter: PropTypes.bool,
|
|
253
|
+
className: PropTypes.any,
|
|
254
|
+
debounce: PropTypes.number,
|
|
259
255
|
displayMenu: PropTypes.string,
|
|
260
|
-
|
|
261
|
-
options: PropTypes.array,
|
|
256
|
+
forLabel: PropTypes.string,
|
|
262
257
|
getOptionLabel: PropTypes.func,
|
|
263
258
|
getOptionValue: PropTypes.func,
|
|
264
|
-
|
|
259
|
+
id: PropTypes.string,
|
|
260
|
+
isInline: PropTypes.bool,
|
|
261
|
+
label: PropTypes.string,
|
|
262
|
+
loading: PropTypes.bool,
|
|
263
|
+
minLength: PropTypes.number,
|
|
265
264
|
noOptionsMessage: PropTypes.func,
|
|
266
265
|
onChange: PropTypes.func,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
266
|
+
onInputChange: PropTypes.func,
|
|
267
|
+
options: PropTypes.array,
|
|
268
|
+
required: PropTypes.bool,
|
|
269
|
+
searchIcon: PropTypes.bool,
|
|
270
|
+
showAllValues: PropTypes.bool,
|
|
271
|
+
value: PropTypes.string,
|
|
270
272
|
};
|
|
271
273
|
|
|
272
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": "#
|
|
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": "#
|
|
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": "#
|
|
1479
|
+
"value": "#757575",
|
|
1480
1480
|
"type": "color"
|
|
1481
1481
|
},
|
|
1482
1482
|
"50": {
|