@commercetools-uikit/selectable-search-input 15.15.0 → 16.0.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.d.ts +1 -0
- package/dist/commercetools-uikit-selectable-search-input.cjs.d.ts.map +1 -0
- package/dist/commercetools-uikit-selectable-search-input.cjs.dev.js +132 -158
- package/dist/commercetools-uikit-selectable-search-input.cjs.prod.js +132 -158
- package/dist/commercetools-uikit-selectable-search-input.esm.js +133 -159
- package/package.json +12 -12
|
@@ -54,8 +54,8 @@ function ownKeys$2(object, enumerableOnly) { var keys = _Object$keys__default["d
|
|
|
54
54
|
|
|
55
55
|
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$2(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$2(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const getInputContainerBorderColor = function (props) {
|
|
58
|
+
let defaultColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : designSystem.designTokens.borderColorForInput;
|
|
59
59
|
|
|
60
60
|
if (props.isDisabled) {
|
|
61
61
|
return designSystem.designTokens.borderColorForInputWhenDisabled;
|
|
@@ -76,7 +76,7 @@ var getInputContainerBorderColor = function getInputContainerBorderColor(props)
|
|
|
76
76
|
return defaultColor;
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
const getInputFontColor = props => {
|
|
80
80
|
if (props.isDisabled) {
|
|
81
81
|
return designSystem.designTokens.fontColorForInputWhenDisabled;
|
|
82
82
|
}
|
|
@@ -96,7 +96,7 @@ var getInputFontColor = function getInputFontColor(props) {
|
|
|
96
96
|
return designSystem.designTokens.fontColorForInput;
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
const getInputBoxShadow = props => {
|
|
100
100
|
if (props.hasError) {
|
|
101
101
|
return designSystem.designTokens.shadowForInputWhenError;
|
|
102
102
|
}
|
|
@@ -108,15 +108,11 @@ var getInputBoxShadow = function getInputBoxShadow(props) {
|
|
|
108
108
|
return designSystem.designTokens.shadowForInput;
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
return [inputUtils.getInputStyles(props), /*#__PURE__*/react.css("border:none;box-shadow:none;background:none;&,&:focus,&:focus:not(:read-only){box-shadow:none;}&:focus,&:hover{background-color:transparent!important;}width:100%;color:", getInputFontColor(props), ";" + ("" ), "" )];
|
|
113
|
-
};
|
|
111
|
+
const getSelectableSearchInputStyles = props => [inputUtils.getInputStyles(props), /*#__PURE__*/react.css("border:none;box-shadow:none;background:none;&,&:focus,&:focus:not(:read-only){box-shadow:none;}&:focus,&:hover{background-color:transparent!important;}width:100%;color:", getInputFontColor(props), ";" + ("" ), "" )];
|
|
114
112
|
|
|
115
|
-
|
|
116
|
-
return /*#__PURE__*/react.css("border:none;background:none;height:100%;border-top-right-radius:", designSystem.designTokens.borderRadiusForInput, ";border-bottom-right-radius:", designSystem.designTokens.borderRadiusForInput, ";border-left:none;align-items:center;transition:border-color ", designSystem.designTokens.transitionStandard, ",background-color ", designSystem.designTokens.transitionStandard, ";transition:border-color ", designSystem.designTokens.transitionStandard, ",box-shadow ", designSystem.designTokens.transitionStandard, ";margin-right:", designSystem.designTokens.marginRightForClearInputIcon, ";" + ("" ), "" );
|
|
117
|
-
};
|
|
113
|
+
const getButtonStyles = () => /*#__PURE__*/react.css("border:none;background:none;height:100%;border-top-right-radius:", designSystem.designTokens.borderRadiusForInput, ";border-bottom-right-radius:", designSystem.designTokens.borderRadiusForInput, ";border-left:none;align-items:center;transition:border-color ", designSystem.designTokens.transitionStandard, ",background-color ", designSystem.designTokens.transitionStandard, ";transition:border-color ", designSystem.designTokens.transitionStandard, ",box-shadow ", designSystem.designTokens.transitionStandard, ";margin-right:", designSystem.designTokens.marginRightForClearInputIcon, ";" + ("" ), "" );
|
|
118
114
|
|
|
119
|
-
|
|
115
|
+
const getIconColor = (props, defaultColor) => {
|
|
120
116
|
if (props.isDisabled) {
|
|
121
117
|
return designSystem.designTokens.fontColorForInputWhenDisabled;
|
|
122
118
|
}
|
|
@@ -128,15 +124,11 @@ var getIconColor = function getIconColor(props, defaultColor) {
|
|
|
128
124
|
return defaultColor;
|
|
129
125
|
};
|
|
130
126
|
|
|
131
|
-
|
|
132
|
-
return [getButtonStyles(), /*#__PURE__*/react.css("fill:", getIconColor(props, designSystem.designTokens.fontColorForClearInputIcon), ";&:hover{fill:", getIconColor(props, designSystem.designTokens.fontColorForClearInputIconWhenHovered), ";}" + ("" ), "" )];
|
|
133
|
-
};
|
|
127
|
+
const getClearIconButtonStyles = props => [getButtonStyles(), /*#__PURE__*/react.css("fill:", getIconColor(props, designSystem.designTokens.fontColorForClearInputIcon), ";&:hover{fill:", getIconColor(props, designSystem.designTokens.fontColorForClearInputIconWhenHovered), ";}" + ("" ), "" )];
|
|
134
128
|
|
|
135
|
-
|
|
136
|
-
return [getButtonStyles(), /*#__PURE__*/react.css("margin-right:", designSystem.designTokens.marginRightForSearchInputIcon, ";fill:", getIconColor(props, designSystem.designTokens.fontColorForSearchInputIcon), ";cursor:", props.isReadOnly ? 'default' : 'pointer', ";&:hover{fill:", getIconColor(props, designSystem.designTokens.fontColorForSearchInputIconWhenHovered), ";}" + ("" ), "" )];
|
|
137
|
-
};
|
|
129
|
+
const getSearchIconButtonStyles = props => [getButtonStyles(), /*#__PURE__*/react.css("margin-right:", designSystem.designTokens.marginRightForSearchInputIcon, ";fill:", getIconColor(props, designSystem.designTokens.fontColorForSearchInputIcon), ";cursor:", props.isReadOnly ? 'default' : 'pointer', ";&:hover{fill:", getIconColor(props, designSystem.designTokens.fontColorForSearchInputIconWhenHovered), ";}" + ("" ), "" )];
|
|
138
130
|
|
|
139
|
-
|
|
131
|
+
const getBackgroundColor = (props, defaultColor) => {
|
|
140
132
|
if (props.isDisabled) {
|
|
141
133
|
return designSystem.designTokens.backgroundColorForInputWhenDisabled;
|
|
142
134
|
}
|
|
@@ -148,12 +140,10 @@ var getBackgroundColor = function getBackgroundColor(props, defaultColor) {
|
|
|
148
140
|
return defaultColor;
|
|
149
141
|
};
|
|
150
142
|
|
|
151
|
-
|
|
152
|
-
return [/*#__PURE__*/react.css("display:flex;align-items:center;background-color:", getBackgroundColor(props, designSystem.designTokens.backgroundColorForInput), ";border:1px solid ", getInputContainerBorderColor(props), ";border-radius:", designSystem.designTokens.borderRadiusForInput, ";box-shadow:", getInputBoxShadow(props), ";height:", designSystem.designTokens.heightForInput, ";box-sizing:border-box;border-top-left-radius:0;border-bottom-left-radius:0;margin-left:0;width:100%;transition:border-color ", designSystem.designTokens.transitionStandard, ",background-color ", designSystem.designTokens.transitionStandard, ";&::placeholder{color:", designSystem.designTokens.placeholderFontColorForInput, ";}&:hover{border-color:", getInputContainerBorderColor(props, designSystem.designTokens.borderColorForInputWhenHovered), ";background-color:", getBackgroundColor(props, designSystem.designTokens.backgroundColorForInputWhenHovered), ";}&:focus{border-color:", designSystem.designTokens.borderColorForInputWhenFocused, ";}" + ("" ), "" ), !props.isDisabled && !props.isReadOnly && /*#__PURE__*/react.css("&:focus-within{border-color:", designSystem.designTokens.borderColorForInputWhenFocused, ";box-shadow:", designSystem.designTokens.boxShadowForDatetimeInputWhenHovered, " ", designSystem.designTokens.borderColorForInputWhenFocused, ";}" + ("" ), "" )];
|
|
153
|
-
};
|
|
143
|
+
const getSelectableSearchInputContainerStyles = props => [/*#__PURE__*/react.css("display:flex;align-items:center;background-color:", getBackgroundColor(props, designSystem.designTokens.backgroundColorForInput), ";border:1px solid ", getInputContainerBorderColor(props), ";border-radius:", designSystem.designTokens.borderRadiusForInput, ";box-shadow:", getInputBoxShadow(props), ";height:", designSystem.designTokens.heightForInput, ";box-sizing:border-box;border-top-left-radius:0;border-bottom-left-radius:0;margin-left:0;width:100%;transition:border-color ", designSystem.designTokens.transitionStandard, ",background-color ", designSystem.designTokens.transitionStandard, ";&::placeholder{color:", designSystem.designTokens.placeholderFontColorForInput, ";}&:hover{border-color:", getInputContainerBorderColor(props, designSystem.designTokens.borderColorForInputWhenHovered), ";background-color:", getBackgroundColor(props, designSystem.designTokens.backgroundColorForInputWhenHovered), ";}&:focus{border-color:", designSystem.designTokens.borderColorForInputWhenFocused, ";}" + ("" ), "" ), !props.isDisabled && !props.isReadOnly && /*#__PURE__*/react.css("&:focus-within{border-color:", designSystem.designTokens.borderColorForInputWhenFocused, ";box-shadow:", designSystem.designTokens.boxShadowForDatetimeInputWhenHovered, " ", designSystem.designTokens.borderColorForInputWhenFocused, ";}" + ("" ), "" )];
|
|
154
144
|
|
|
155
|
-
|
|
156
|
-
|
|
145
|
+
const createSelectableSelectStyles = _ref => {
|
|
146
|
+
let hasWarning = _ref.hasWarning,
|
|
157
147
|
hasError = _ref.hasError,
|
|
158
148
|
isDisabled = _ref.isDisabled,
|
|
159
149
|
isReadOnly = _ref.isReadOnly,
|
|
@@ -161,83 +151,77 @@ var createSelectableSelectStyles = function createSelectableSelectStyles(_ref) {
|
|
|
161
151
|
isNewTheme = _ref.isNewTheme,
|
|
162
152
|
dropdownHasFocus = _ref.dropdownHasFocus,
|
|
163
153
|
textInputHasFocus = _ref.textInputHasFocus;
|
|
164
|
-
|
|
165
|
-
hasWarning
|
|
166
|
-
hasError
|
|
167
|
-
menuPortalZIndex
|
|
168
|
-
isNewTheme
|
|
169
|
-
isDisabled
|
|
170
|
-
isReadOnly
|
|
154
|
+
const selectStyles = selectUtils.createSelectStyles({
|
|
155
|
+
hasWarning,
|
|
156
|
+
hasError,
|
|
157
|
+
menuPortalZIndex,
|
|
158
|
+
isNewTheme,
|
|
159
|
+
isDisabled,
|
|
160
|
+
isReadOnly
|
|
171
161
|
});
|
|
172
162
|
return _objectSpread$2(_objectSpread$2({}, selectStyles), {}, {
|
|
173
|
-
control:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
163
|
+
control: (base, state) => _objectSpread$2(_objectSpread$2({}, selectStyles.control(base, state)), {}, {
|
|
164
|
+
padding: designSystem.designTokens.paddingForSelectableSearchInputDropdown,
|
|
165
|
+
borderTopRightRadius: '0',
|
|
166
|
+
borderBottomRightRadius: '0',
|
|
167
|
+
borderRight: '0',
|
|
168
|
+
height: '100%',
|
|
169
|
+
borderColor: (() => {
|
|
170
|
+
if (isDisabled) return "".concat(designSystem.designTokens.borderColorForInputWhenDisabled, " !important");
|
|
171
|
+
if (isReadOnly) return "".concat(designSystem.designTokens.borderColorForInputWhenReadonly, " !important");
|
|
172
|
+
if (hasError) return designSystem.designTokens.borderColorForInputWhenError;
|
|
173
|
+
if (hasWarning) return designSystem.designTokens.borderColorForInputWhenWarning;
|
|
174
|
+
|
|
175
|
+
if (textInputHasFocus && !isNewTheme) {
|
|
176
|
+
return designSystem.designTokens.borderColorForInputWhenFocused;
|
|
177
|
+
}
|
|
189
178
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
179
|
+
if (dropdownHasFocus) {
|
|
180
|
+
return designSystem.designTokens.borderColorForInputWhenFocused;
|
|
181
|
+
}
|
|
193
182
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
183
|
+
return designSystem.designTokens.borderColorForInput;
|
|
184
|
+
})(),
|
|
185
|
+
cursor: (() => {
|
|
186
|
+
if (isDisabled) return 'not-allowed';
|
|
187
|
+
if (isReadOnly) return "default";
|
|
188
|
+
return 'pointer';
|
|
189
|
+
})(),
|
|
190
|
+
backgroundColor: getBackgroundColor({
|
|
191
|
+
isDisabled,
|
|
192
|
+
isReadOnly
|
|
193
|
+
}, base.backgroundColor || ''),
|
|
194
|
+
'&:hover': {
|
|
201
195
|
backgroundColor: getBackgroundColor({
|
|
202
|
-
isDisabled
|
|
203
|
-
isReadOnly
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
isDisabled: isDisabled,
|
|
221
|
-
isReadOnly: isReadOnly
|
|
222
|
-
})
|
|
223
|
-
});
|
|
224
|
-
},
|
|
225
|
-
dropdownIndicator: function dropdownIndicator() {
|
|
226
|
-
return {
|
|
227
|
-
fill: isReadOnly ? designSystem.designTokens.fontColorForInputWhenDisabled : designSystem.designTokens.fontColorForSelectInputIcon
|
|
228
|
-
};
|
|
229
|
-
}
|
|
196
|
+
isDisabled,
|
|
197
|
+
isReadOnly
|
|
198
|
+
}, designSystem.designTokens.backgroundColorForInputWhenHovered)
|
|
199
|
+
}
|
|
200
|
+
}),
|
|
201
|
+
singleValue: base => _objectSpread$2(_objectSpread$2({}, base), {}, {
|
|
202
|
+
marginLeft: 0,
|
|
203
|
+
maxWidth: 'initial',
|
|
204
|
+
color: getInputFontColor({
|
|
205
|
+
hasWarning,
|
|
206
|
+
hasError,
|
|
207
|
+
isDisabled,
|
|
208
|
+
isReadOnly
|
|
209
|
+
})
|
|
210
|
+
}),
|
|
211
|
+
dropdownIndicator: () => ({
|
|
212
|
+
fill: isReadOnly ? designSystem.designTokens.fontColorForInputWhenDisabled : designSystem.designTokens.fontColorForSelectInputIcon
|
|
213
|
+
})
|
|
230
214
|
});
|
|
231
215
|
};
|
|
232
216
|
|
|
233
|
-
|
|
217
|
+
const _excluded = ["id"];
|
|
234
218
|
|
|
235
219
|
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
236
220
|
|
|
237
221
|
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
238
222
|
|
|
239
|
-
|
|
240
|
-
|
|
223
|
+
const SingleValue = _ref => {
|
|
224
|
+
let id = _ref.id,
|
|
241
225
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
242
226
|
|
|
243
227
|
return jsxRuntime.jsx(Select.components.SingleValue, _objectSpread$1(_objectSpread$1({}, props), {}, {
|
|
@@ -248,29 +232,29 @@ var _SingleValue = function SingleValue(_ref) {
|
|
|
248
232
|
}));
|
|
249
233
|
};
|
|
250
234
|
|
|
251
|
-
|
|
235
|
+
SingleValue.propTypes = {};
|
|
252
236
|
|
|
253
|
-
|
|
254
|
-
|
|
237
|
+
const SelectableSelect = props => {
|
|
238
|
+
const intl = reactIntl.useIntl();
|
|
255
239
|
|
|
256
|
-
|
|
257
|
-
|
|
240
|
+
const _useTheme = designSystem.useTheme(),
|
|
241
|
+
isNewTheme = _useTheme.isNewTheme;
|
|
258
242
|
|
|
259
|
-
|
|
243
|
+
const dropdownStyles = createSelectableSelectStyles({
|
|
260
244
|
hasWarning: props.hasWarning,
|
|
261
245
|
hasError: props.hasError,
|
|
262
246
|
isDisabled: props.isDisabled,
|
|
263
247
|
isReadOnly: props.isReadOnly,
|
|
264
248
|
menuPortalZIndex: props.menuPortalZIndex,
|
|
265
|
-
isNewTheme
|
|
249
|
+
isNewTheme,
|
|
266
250
|
dropdownHasFocus: props.dropdownHasFocus,
|
|
267
251
|
textInputHasFocus: props.textInputHasFocus
|
|
268
252
|
});
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
253
|
+
const onChange = props.onChange,
|
|
254
|
+
name = props.name,
|
|
255
|
+
id = props.id,
|
|
256
|
+
textInputRef = props.textInputRef;
|
|
257
|
+
const handleDropdownChange = react$1.useCallback(nextSelectedOptions => {
|
|
274
258
|
var _textInputRef$current;
|
|
275
259
|
|
|
276
260
|
if (onChange) {
|
|
@@ -294,11 +278,9 @@ var SelectableSelect = function SelectableSelect(props) {
|
|
|
294
278
|
maxMenuHeight: props.maxMenuHeight,
|
|
295
279
|
closeMenuOnSelect: props.closeMenuOnSelect,
|
|
296
280
|
components: {
|
|
297
|
-
SingleValue:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}));
|
|
301
|
-
},
|
|
281
|
+
SingleValue: innerProps => jsxRuntime.jsx(SingleValue, _objectSpread$1(_objectSpread$1({}, innerProps), {}, {
|
|
282
|
+
id: props.id
|
|
283
|
+
})),
|
|
302
284
|
DropdownIndicator: selectUtils.DropdownIndicator
|
|
303
285
|
},
|
|
304
286
|
options: props.options,
|
|
@@ -311,12 +293,12 @@ var SelectableSelect = function SelectableSelect(props) {
|
|
|
311
293
|
onBlur: props.handleDropdownBlur,
|
|
312
294
|
onChange: handleDropdownChange,
|
|
313
295
|
onInputChange: props.onMenuInputChange,
|
|
314
|
-
noOptionsMessage: props.noMenuOptionsMessage ||
|
|
315
|
-
|
|
296
|
+
noOptionsMessage: props.noMenuOptionsMessage || (_ref2 => {
|
|
297
|
+
let inputValue = _ref2.inputValue;
|
|
316
298
|
return !inputValue || inputValue === '' ? intl.formatMessage(selectUtils.messages.noOptionsMessageWithoutInputValue) : intl.formatMessage(selectUtils.messages.noOptionsMessageWithInputValue, {
|
|
317
|
-
inputValue
|
|
299
|
+
inputValue
|
|
318
300
|
});
|
|
319
|
-
}
|
|
301
|
+
})
|
|
320
302
|
});
|
|
321
303
|
};
|
|
322
304
|
|
|
@@ -327,22 +309,18 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["def
|
|
|
327
309
|
|
|
328
310
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
329
311
|
|
|
330
|
-
|
|
312
|
+
const Container = /*#__PURE__*/_styled__default["default"]("div", {
|
|
331
313
|
target: "encv1cf0"
|
|
332
314
|
} )({
|
|
333
315
|
name: "zjik7",
|
|
334
316
|
styles: "display:flex"
|
|
335
317
|
} );
|
|
336
318
|
|
|
337
|
-
|
|
338
|
-
return name ? "".concat(name, ".textInput") : undefined;
|
|
339
|
-
};
|
|
319
|
+
const getTextInputName = name => name ? "".concat(name, ".textInput") : undefined;
|
|
340
320
|
|
|
341
|
-
|
|
342
|
-
return name ? "".concat(name, ".dropdown") : undefined;
|
|
343
|
-
};
|
|
321
|
+
const getDropdownName = name => name ? "".concat(name, ".dropdown") : undefined;
|
|
344
322
|
|
|
345
|
-
|
|
323
|
+
const defaultProps = {
|
|
346
324
|
horizontalConstraint: 'scale',
|
|
347
325
|
isClearable: true,
|
|
348
326
|
menuHorizontalConstraint: 3,
|
|
@@ -350,37 +328,35 @@ var defaultProps = {
|
|
|
350
328
|
menuPortalZIndex: 1,
|
|
351
329
|
options: []
|
|
352
330
|
};
|
|
353
|
-
|
|
331
|
+
const selectableSearchInputSequentialId = utils.createSequentialId('selectable-search-input-');
|
|
354
332
|
|
|
355
|
-
|
|
356
|
-
return option.options !== undefined;
|
|
357
|
-
};
|
|
333
|
+
const isOptionObject = option => option.options !== undefined;
|
|
358
334
|
|
|
359
|
-
|
|
335
|
+
const SelectableSearchInput = props => {
|
|
360
336
|
var _context;
|
|
361
337
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
338
|
+
const _useToggleState = hooks.useToggleState(false),
|
|
339
|
+
_useToggleState2 = _slicedToArray(_useToggleState, 2),
|
|
340
|
+
textInputHasFocus = _useToggleState2[0],
|
|
341
|
+
toggleTextInputHasFocus = _useToggleState2[1];
|
|
366
342
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
343
|
+
const _useToggleState3 = hooks.useToggleState(false),
|
|
344
|
+
_useToggleState4 = _slicedToArray(_useToggleState3, 2),
|
|
345
|
+
dropdownHasFocus = _useToggleState4[0],
|
|
346
|
+
toggleDropdownHasFocus = _useToggleState4[1];
|
|
371
347
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
348
|
+
const _useState = react$1.useState(props.value.text || ''),
|
|
349
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
350
|
+
searchValue = _useState2[0],
|
|
351
|
+
setSearchValue = _useState2[1];
|
|
376
352
|
|
|
377
|
-
|
|
378
|
-
|
|
353
|
+
const containerRef = react$1.useRef(null);
|
|
354
|
+
const textInputRef = react$1.useRef(null);
|
|
379
355
|
|
|
380
|
-
|
|
381
|
-
|
|
356
|
+
const _useTheme = designSystem.useTheme(),
|
|
357
|
+
isNewTheme = _useTheme.isNewTheme;
|
|
382
358
|
|
|
383
|
-
|
|
359
|
+
const optionsWithoutGroups = _flatMapInstanceProperty__default["default"](_context = props.options).call(_context, option => {
|
|
384
360
|
if (isOptionObject(option)) {
|
|
385
361
|
return option.options;
|
|
386
362
|
}
|
|
@@ -388,11 +364,9 @@ var SelectableSearchInput = function SelectableSearchInput(props) {
|
|
|
388
364
|
return option;
|
|
389
365
|
});
|
|
390
366
|
|
|
391
|
-
|
|
392
|
-
return option.value === props.value.option;
|
|
393
|
-
});
|
|
367
|
+
const selectedOption = _findInstanceProperty__default["default"](optionsWithoutGroups).call(optionsWithoutGroups, option => option.value === props.value.option);
|
|
394
368
|
|
|
395
|
-
|
|
369
|
+
const selectablSearchInputId = hooks.useFieldId(props.id, selectableSearchInputSequentialId);
|
|
396
370
|
|
|
397
371
|
if (!props.isReadOnly) ;
|
|
398
372
|
|
|
@@ -401,10 +375,10 @@ var SelectableSearchInput = function SelectableSearchInput(props) {
|
|
|
401
375
|
menuPortalTarget: props.menuPortalTarget,
|
|
402
376
|
componentName: 'SelectableSearchInput'
|
|
403
377
|
});
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
378
|
+
const onFocus = props.onFocus,
|
|
379
|
+
onBlur = props.onBlur,
|
|
380
|
+
name = props.name;
|
|
381
|
+
const handleTextInputFocus = react$1.useCallback(() => {
|
|
408
382
|
if (onFocus) {
|
|
409
383
|
onFocus({
|
|
410
384
|
target: {
|
|
@@ -416,7 +390,7 @@ var SelectableSearchInput = function SelectableSearchInput(props) {
|
|
|
416
390
|
|
|
417
391
|
toggleTextInputHasFocus(true);
|
|
418
392
|
}, [toggleTextInputHasFocus, onFocus, selectablSearchInputId, name]);
|
|
419
|
-
|
|
393
|
+
const handleTextInputBlur = react$1.useCallback(() => {
|
|
420
394
|
if (onBlur) {
|
|
421
395
|
onBlur({
|
|
422
396
|
target: {
|
|
@@ -429,7 +403,7 @@ var SelectableSearchInput = function SelectableSearchInput(props) {
|
|
|
429
403
|
toggleTextInputHasFocus(false);
|
|
430
404
|
}, [toggleTextInputHasFocus, onBlur, selectablSearchInputId, name]);
|
|
431
405
|
|
|
432
|
-
|
|
406
|
+
const handleClear = () => {
|
|
433
407
|
setSearchValue('');
|
|
434
408
|
|
|
435
409
|
if (props.onReset) {
|
|
@@ -437,7 +411,7 @@ var SelectableSearchInput = function SelectableSearchInput(props) {
|
|
|
437
411
|
}
|
|
438
412
|
};
|
|
439
413
|
|
|
440
|
-
|
|
414
|
+
const handleChange = event => {
|
|
441
415
|
setSearchValue(event.target.value);
|
|
442
416
|
|
|
443
417
|
if (props.onChange) {
|
|
@@ -451,7 +425,7 @@ var SelectableSearchInput = function SelectableSearchInput(props) {
|
|
|
451
425
|
}
|
|
452
426
|
};
|
|
453
427
|
|
|
454
|
-
|
|
428
|
+
const handleSubmit = event => {
|
|
455
429
|
event.preventDefault();
|
|
456
430
|
|
|
457
431
|
if (props.onSubmit) {
|
|
@@ -464,9 +438,9 @@ var SelectableSearchInput = function SelectableSearchInput(props) {
|
|
|
464
438
|
}
|
|
465
439
|
};
|
|
466
440
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
441
|
+
const dropdownName = getDropdownName(props.name);
|
|
442
|
+
const dropdownId = SelectableSearchInput.getDropdownId(selectablSearchInputId);
|
|
443
|
+
const handleDropdownFocus = react$1.useCallback(() => {
|
|
470
444
|
if (onFocus) {
|
|
471
445
|
onFocus({
|
|
472
446
|
target: {
|
|
@@ -478,7 +452,7 @@ var SelectableSearchInput = function SelectableSearchInput(props) {
|
|
|
478
452
|
|
|
479
453
|
toggleDropdownHasFocus(true);
|
|
480
454
|
}, [onFocus, toggleDropdownHasFocus, dropdownName, dropdownId]);
|
|
481
|
-
|
|
455
|
+
const handleDropdownBlur = react$1.useCallback(() => {
|
|
482
456
|
if (onBlur) {
|
|
483
457
|
onBlur({
|
|
484
458
|
target: {
|
|
@@ -490,7 +464,7 @@ var SelectableSearchInput = function SelectableSearchInput(props) {
|
|
|
490
464
|
|
|
491
465
|
toggleDropdownHasFocus(false);
|
|
492
466
|
}, [toggleDropdownHasFocus, onBlur, dropdownName, dropdownId]);
|
|
493
|
-
|
|
467
|
+
const handleContainerBlur = react$1.useCallback(event => {
|
|
494
468
|
var _containerRef$current;
|
|
495
469
|
|
|
496
470
|
// ensures that both fields are marked as touched when one of them
|
|
@@ -553,7 +527,7 @@ var SelectableSearchInput = function SelectableSearchInput(props) {
|
|
|
553
527
|
"aria-invalid": props['aria-invalid'],
|
|
554
528
|
"aria-errormessage": props['aria-errormessage'],
|
|
555
529
|
"data-testid": "selectable-input",
|
|
556
|
-
onKeyDown:
|
|
530
|
+
onKeyDown: event => {
|
|
557
531
|
if (!props.isReadOnly && event.key === 'Enter') {
|
|
558
532
|
handleSubmit(event);
|
|
559
533
|
}
|
|
@@ -580,7 +554,7 @@ SelectableSearchInput.propTypes = {};
|
|
|
580
554
|
SelectableSearchInput.displayName = 'SelectableSearchInput';
|
|
581
555
|
SelectableSearchInput.defaultProps = defaultProps;
|
|
582
556
|
|
|
583
|
-
SelectableSearchInput.isEmpty =
|
|
557
|
+
SelectableSearchInput.isEmpty = formValue => {
|
|
584
558
|
var _context2;
|
|
585
559
|
|
|
586
560
|
return !formValue || _trimInstanceProperty__default["default"](_context2 = formValue.text).call(_context2) === '';
|
|
@@ -591,7 +565,7 @@ SelectableSearchInput.getDropdownId = getDropdownName;
|
|
|
591
565
|
var SelectableSearchInput$1 = SelectableSearchInput;
|
|
592
566
|
|
|
593
567
|
// NOTE: This string will be replaced on build time with the package version.
|
|
594
|
-
var version = "
|
|
568
|
+
var version = "16.0.0";
|
|
595
569
|
|
|
596
570
|
exports["default"] = SelectableSearchInput$1;
|
|
597
571
|
exports.version = version;
|