@commercetools-uikit/selectable-search-input 19.20.1 → 19.22.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.
- package/dist/commercetools-uikit-selectable-search-input.cjs.dev.js +36 -26
- package/dist/commercetools-uikit-selectable-search-input.cjs.prod.js +34 -24
- package/dist/commercetools-uikit-selectable-search-input.esm.js +36 -26
- package/dist/declarations/src/selectable-search-input.d.ts +1 -2
- package/package.json +10 -10
|
@@ -11,6 +11,7 @@ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-
|
|
|
11
11
|
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
12
12
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
13
13
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
14
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
14
15
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
15
16
|
var _styled = require('@emotion/styled/base');
|
|
16
17
|
require('prop-types');
|
|
@@ -30,7 +31,6 @@ var selectUtils = require('@commercetools-uikit/select-utils');
|
|
|
30
31
|
var react = require('@emotion/react');
|
|
31
32
|
var inputUtils = require('@commercetools-uikit/input-utils');
|
|
32
33
|
var designSystem = require('@commercetools-uikit/design-system');
|
|
33
|
-
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
34
34
|
var reactIntl = require('react-intl');
|
|
35
35
|
var Select = require('react-select');
|
|
36
36
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
@@ -192,13 +192,13 @@ const createSelectableSelectStyles = _ref => {
|
|
|
192
192
|
});
|
|
193
193
|
};
|
|
194
194
|
|
|
195
|
-
const _excluded = ["id", "dataProps"];
|
|
195
|
+
const _excluded$1 = ["id", "dataProps"];
|
|
196
196
|
function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
197
197
|
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
198
198
|
const SingleValue = _ref => {
|
|
199
199
|
let id = _ref.id,
|
|
200
200
|
dataProps = _ref.dataProps,
|
|
201
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
201
|
+
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
202
202
|
return jsxRuntime.jsx(Select.components.SingleValue, _objectSpread$1(_objectSpread$1({}, props), {}, {
|
|
203
203
|
children: jsxRuntime.jsx("label", _objectSpread$1(_objectSpread$1({
|
|
204
204
|
htmlFor: id
|
|
@@ -255,6 +255,7 @@ const SelectableSelect = props => {
|
|
|
255
255
|
SelectableSelect.propTypes = {};
|
|
256
256
|
var SelectableSelect$1 = SelectableSelect;
|
|
257
257
|
|
|
258
|
+
const _excluded = ["horizontalConstraint", "isClearable", "menuHorizontalConstraint", "showSubmitButton", "menuPortalZIndex"];
|
|
258
259
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
259
260
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
260
261
|
const Container = /*#__PURE__*/_styled__default["default"]("div", {
|
|
@@ -265,14 +266,6 @@ const Container = /*#__PURE__*/_styled__default["default"]("div", {
|
|
|
265
266
|
} );
|
|
266
267
|
const getTextInputName = name => name ? `${name}.textInput` : undefined;
|
|
267
268
|
const getDropdownName = name => name ? `${name}.dropdown` : undefined;
|
|
268
|
-
const defaultProps = {
|
|
269
|
-
horizontalConstraint: 'scale',
|
|
270
|
-
isClearable: true,
|
|
271
|
-
menuHorizontalConstraint: 3,
|
|
272
|
-
showSubmitButton: true,
|
|
273
|
-
menuPortalZIndex: 1,
|
|
274
|
-
options: []
|
|
275
|
-
};
|
|
276
269
|
const selectableSearchInputSequentialId = utils.createSequentialId('selectable-search-input-');
|
|
277
270
|
const isOptionObject = option => option.options !== undefined;
|
|
278
271
|
const transformDataProps = dataProps => {
|
|
@@ -284,8 +277,19 @@ const transformDataProps = dataProps => {
|
|
|
284
277
|
return [`data-${key}`, value];
|
|
285
278
|
}));
|
|
286
279
|
};
|
|
287
|
-
const SelectableSearchInput =
|
|
280
|
+
const SelectableSearchInput = _ref3 => {
|
|
288
281
|
var _context2;
|
|
282
|
+
let _ref3$horizontalConst = _ref3.horizontalConstraint,
|
|
283
|
+
horizontalConstraint = _ref3$horizontalConst === void 0 ? 'scale' : _ref3$horizontalConst,
|
|
284
|
+
_ref3$isClearable = _ref3.isClearable,
|
|
285
|
+
isClearable = _ref3$isClearable === void 0 ? true : _ref3$isClearable,
|
|
286
|
+
_ref3$menuHorizontalC = _ref3.menuHorizontalConstraint,
|
|
287
|
+
menuHorizontalConstraint = _ref3$menuHorizontalC === void 0 ? 3 : _ref3$menuHorizontalC,
|
|
288
|
+
_ref3$showSubmitButto = _ref3.showSubmitButton,
|
|
289
|
+
showSubmitButton = _ref3$showSubmitButto === void 0 ? true : _ref3$showSubmitButto,
|
|
290
|
+
_ref3$menuPortalZInde = _ref3.menuPortalZIndex,
|
|
291
|
+
menuPortalZIndex = _ref3$menuPortalZInde === void 0 ? 1 : _ref3$menuPortalZInde,
|
|
292
|
+
props = _objectWithoutProperties(_ref3, _excluded);
|
|
289
293
|
const _useToggleState = hooks.useToggleState(false),
|
|
290
294
|
_useToggleState2 = _slicedToArray(_useToggleState, 2),
|
|
291
295
|
dropdownHasFocus = _useToggleState2[0],
|
|
@@ -300,6 +304,13 @@ const SelectableSearchInput = props => {
|
|
|
300
304
|
setSearchOption = _useState4[1];
|
|
301
305
|
const containerRef = react$1.useRef(null);
|
|
302
306
|
const textInputRef = react$1.useRef(null);
|
|
307
|
+
const allProps = _objectSpread({
|
|
308
|
+
horizontalConstraint,
|
|
309
|
+
isClearable,
|
|
310
|
+
menuHorizontalConstraint,
|
|
311
|
+
showSubmitButton,
|
|
312
|
+
menuPortalZIndex
|
|
313
|
+
}, props);
|
|
303
314
|
const legacyDataProps = utils.filterDataAttributes(props);
|
|
304
315
|
const transformedSelectDataProps = transformDataProps(props.selectDataProps);
|
|
305
316
|
const transformedInputDataProps = transformDataProps(props.inputDataProps);
|
|
@@ -316,7 +327,7 @@ const SelectableSearchInput = props => {
|
|
|
316
327
|
const selectablSearchInputId = hooks.useFieldId(props.id, selectableSearchInputSequentialId);
|
|
317
328
|
if (!props.isReadOnly) ;
|
|
318
329
|
selectUtils.warnIfMenuPortalPropsAreMissing({
|
|
319
|
-
menuPortalZIndex:
|
|
330
|
+
menuPortalZIndex: menuPortalZIndex,
|
|
320
331
|
menuPortalTarget: props.menuPortalTarget,
|
|
321
332
|
componentName: 'SelectableSearchInput'
|
|
322
333
|
});
|
|
@@ -426,14 +437,14 @@ const SelectableSearchInput = props => {
|
|
|
426
437
|
textInputRef.current?.focus();
|
|
427
438
|
}, [props.onChange, selectablSearchInputId, name]);
|
|
428
439
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
429
|
-
max:
|
|
440
|
+
max: horizontalConstraint,
|
|
430
441
|
children: jsxRuntime.jsxs(Container, {
|
|
431
442
|
ref: containerRef,
|
|
432
443
|
onBlur: handleContainerBlur,
|
|
433
444
|
"data-testid": "selectable-search-input-container",
|
|
434
445
|
children: [jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
435
|
-
max:
|
|
436
|
-
children: jsxRuntime.jsx(SelectableSelect$1, _objectSpread(_objectSpread({},
|
|
446
|
+
max: menuHorizontalConstraint,
|
|
447
|
+
children: jsxRuntime.jsx(SelectableSelect$1, _objectSpread(_objectSpread({}, allProps), {}, {
|
|
437
448
|
id: SelectableSearchInput.getDropdownId(selectablSearchInputId),
|
|
438
449
|
name: getDropdownName(props.name),
|
|
439
450
|
dropdownHasFocus: dropdownHasFocus,
|
|
@@ -447,7 +458,7 @@ const SelectableSearchInput = props => {
|
|
|
447
458
|
selectCustomComponents: props.selectCustomComponents
|
|
448
459
|
}))
|
|
449
460
|
}), jsxRuntime.jsxs("div", {
|
|
450
|
-
css: [getSelectableSearchInputContainerStyles(
|
|
461
|
+
css: [getSelectableSearchInputContainerStyles(allProps), dropdownHasFocus && !props.isReadOnly && /*#__PURE__*/react.css("border-left-color:", designSystem.designTokens.borderColorForInputWhenFocused, ";&:hover{border-left-color:", designSystem.designTokens.borderColorForInputWhenFocused, ";}" + ("" ), "" ), "" , "" ],
|
|
451
462
|
children: [jsxRuntime.jsx("input", _objectSpread(_objectSpread(_objectSpread({
|
|
452
463
|
ref: textInputRef,
|
|
453
464
|
id: SelectableSearchInput.getTextInputId(selectablSearchInputId),
|
|
@@ -464,7 +475,7 @@ const SelectableSearchInput = props => {
|
|
|
464
475
|
autoComplete: props.autoComplete,
|
|
465
476
|
"aria-readonly": props.isReadOnly,
|
|
466
477
|
contentEditable: !props.isReadOnly,
|
|
467
|
-
css: getSelectableSearchInputStyles(
|
|
478
|
+
css: getSelectableSearchInputStyles(allProps)
|
|
468
479
|
}, transformedInputDataProps), legacyDataProps), {}, {
|
|
469
480
|
/* ARIA */
|
|
470
481
|
"aria-invalid": props['aria-invalid'],
|
|
@@ -475,18 +486,18 @@ const SelectableSearchInput = props => {
|
|
|
475
486
|
handleSubmit(event);
|
|
476
487
|
}
|
|
477
488
|
}
|
|
478
|
-
})),
|
|
489
|
+
})), isClearable && searchInputValue && !props.isDisabled && !props.isReadOnly && jsxRuntime.jsx(SecondaryIconButton__default["default"], {
|
|
479
490
|
icon: jsxRuntime.jsx(icons.CloseIcon, {}),
|
|
480
491
|
size: props.isCondensed ? '10' : '20',
|
|
481
492
|
label: 'clear-button',
|
|
482
493
|
onClick: handleClear,
|
|
483
|
-
css: getClearIconButtonStyles(
|
|
484
|
-
}),
|
|
494
|
+
css: getClearIconButtonStyles(allProps)
|
|
495
|
+
}), showSubmitButton && jsxRuntime.jsx(SecondaryIconButton__default["default"], {
|
|
485
496
|
icon: jsxRuntime.jsx(icons.SearchIcon, {}),
|
|
486
497
|
size: props.isCondensed ? '20' : '40',
|
|
487
498
|
label: 'search-button',
|
|
488
499
|
onClick: handleSubmit,
|
|
489
|
-
css: getSearchIconButtonStyles(
|
|
500
|
+
css: getSearchIconButtonStyles(allProps),
|
|
490
501
|
isDisabled: props.isDisabled
|
|
491
502
|
}), props.rightActionIcon && props.rightActionProps && jsxRuntime.jsx("div", {
|
|
492
503
|
css: /*#__PURE__*/react.css("order:4;margin-left:", designSystem.designTokens.spacing30, ";" + ("" ), "" ),
|
|
@@ -503,7 +514,6 @@ const SelectableSearchInput = props => {
|
|
|
503
514
|
};
|
|
504
515
|
SelectableSearchInput.propTypes = {};
|
|
505
516
|
SelectableSearchInput.displayName = 'SelectableSearchInput';
|
|
506
|
-
SelectableSearchInput.defaultProps = defaultProps;
|
|
507
517
|
SelectableSearchInput.isEmpty = formValue => {
|
|
508
518
|
var _context3;
|
|
509
519
|
return !formValue || _trimInstanceProperty__default["default"](_context3 = formValue.text).call(_context3) === '';
|
|
@@ -513,7 +523,7 @@ SelectableSearchInput.getDropdownId = getDropdownName;
|
|
|
513
523
|
var SelectableSearchInput$1 = SelectableSearchInput;
|
|
514
524
|
|
|
515
525
|
// NOTE: This string will be replaced on build time with the package version.
|
|
516
|
-
var version = "19.
|
|
526
|
+
var version = "19.22.0";
|
|
517
527
|
|
|
518
528
|
exports["default"] = SelectableSearchInput$1;
|
|
519
529
|
exports.version = version;
|