@orfium/ictinus 4.56.1 → 4.58.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 (23) hide show
  1. package/dist/components/Chip/Chip.js +2 -1
  2. package/dist/components/DatePicker/DatePicker.js +11 -13
  3. package/dist/components/Select/Select.d.ts +16 -6
  4. package/dist/components/Select/Select.js +92 -26
  5. package/dist/components/Select/components/MultiselectTextField/MultiselectTextField.d.ts +19 -0
  6. package/dist/components/Select/components/MultiselectTextField/MultiselectTextField.js +186 -0
  7. package/dist/components/Select/components/MultiselectTextField/MultiselectTextField.style.d.ts +55 -0
  8. package/dist/components/Select/components/MultiselectTextField/MultiselectTextField.style.js +149 -0
  9. package/dist/components/Select/components/MultiselectTextField/index.d.ts +1 -0
  10. package/dist/components/Select/components/MultiselectTextField/index.js +10 -0
  11. package/dist/components/Select/hooks/useMultiselectUtils.d.ts +21 -0
  12. package/dist/components/Select/hooks/useMultiselectUtils.js +99 -0
  13. package/dist/components/TextField/TextField.d.ts +2 -1
  14. package/dist/components/TextField/TextField.js +1 -1
  15. package/dist/components/utils/PositionInScreen/PositionInScreen.d.ts +8 -1
  16. package/dist/components/utils/PositionInScreen/PositionInScreen.js +19 -66
  17. package/dist/components/utils/PositionInScreen/PositionInScreen.style.d.ts +2 -3
  18. package/dist/components/utils/PositionInScreen/PositionInScreen.style.js +7 -5
  19. package/dist/components/utils/PositionInScreen/hooks.d.ts +5 -0
  20. package/dist/components/utils/PositionInScreen/hooks.js +98 -0
  21. package/dist/utils/size-utils.d.ts +1 -0
  22. package/dist/utils/size-utils.js +3 -1
  23. package/package.json +1 -1
@@ -82,7 +82,8 @@ var Chip = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
82
82
  if (!disabled) {
83
83
  onClear();
84
84
  }
85
- }
85
+ },
86
+ dataTestId: (0, _helpers.generateTestDataId)('chip-delete', dataTestId)
86
87
  })));
87
88
 
88
89
  if (styleType === 'read-only') {
@@ -207,19 +207,17 @@ var DatePicker = function DatePicker(_ref) {
207
207
  onClick: onCancel
208
208
  }, (0, _react2.jsx)(_PositionInScreen["default"], {
209
209
  visible: isOpen,
210
- parent: function parent() {
211
- return (0, _react2.jsx)(_DatePickInput["default"], {
212
- filterConfig: filterConfig,
213
- isRangePicker: isRangePicker,
214
- selectedDay: selectedRange,
215
- inputProps: inputProps,
216
- dateFormatOverride: dateFormatOverride,
217
- handleFocus: handleFocus,
218
- handleClear: handleClear,
219
- isOpen: isOpen,
220
- dataTestId: dataTestId
221
- });
222
- }
210
+ parent: (0, _react2.jsx)(_DatePickInput["default"], {
211
+ filterConfig: filterConfig,
212
+ isRangePicker: isRangePicker,
213
+ selectedDay: selectedRange,
214
+ inputProps: inputProps,
215
+ dateFormatOverride: dateFormatOverride,
216
+ handleFocus: handleFocus,
217
+ handleClear: handleClear,
218
+ isOpen: isOpen,
219
+ dataTestId: dataTestId
220
+ })
223
221
  }, (0, _react2.jsx)("div", {
224
222
  css: (0, _DatePicker.datePickerStyles)()
225
223
  }, (0, _react2.jsx)(_OverlayComponent["default"], {
@@ -21,8 +21,6 @@ export declare type Props = {
21
21
  defaultValue?: SelectOption;
22
22
  /** the value of the select if select is controlled */
23
23
  selectedOption?: SelectOption;
24
- /** if the select has tags */
25
- multi?: boolean;
26
24
  /** Options for the select dropdown */
27
25
  options: SelectOption[];
28
26
  /** if the component is used asynchronously */
@@ -41,8 +39,15 @@ export declare type Props = {
41
39
  isLoading?: boolean;
42
40
  /** if options list is virtualized */
43
41
  isVirtualized?: boolean;
44
- /** A callback that's called when the user clicks the 'clear' icon */
42
+ /** A callback that's called when the user clicks the 'clear' icon of the (Single) Select, or the 'clear all' button of the MultiSelect */
45
43
  onClear?: () => void;
44
+ /** A callback that's called when the user clicks the 'clear' icon of a specific Chip in MultiSelect */
45
+ onOptionDelete?: (option: SelectOption) => void;
46
+ /** If true the user can select multiple options */
47
+ multi?: boolean;
48
+ /** The selected options in case of multiSelect */
49
+ /** @TODO merge selectedOption with selectedOptions in v5 */
50
+ selectedOptions?: SelectOption[];
46
51
  } & TextFieldProps;
47
52
  declare const Select: React.ForwardRefExoticComponent<{
48
53
  /** The function that is used to return the selected options */
@@ -52,8 +57,6 @@ declare const Select: React.ForwardRefExoticComponent<{
52
57
  defaultValue?: SelectOption | undefined;
53
58
  /** the value of the select if select is controlled */
54
59
  selectedOption?: SelectOption | undefined;
55
- /** if the select has tags */
56
- multi?: boolean | undefined;
57
60
  /** Options for the select dropdown */
58
61
  options: SelectOption[];
59
62
  /** if the component is used asynchronously */
@@ -72,8 +75,15 @@ declare const Select: React.ForwardRefExoticComponent<{
72
75
  isLoading?: boolean | undefined;
73
76
  /** if options list is virtualized */
74
77
  isVirtualized?: boolean | undefined;
75
- /** A callback that's called when the user clicks the 'clear' icon */
78
+ /** A callback that's called when the user clicks the 'clear' icon of the (Single) Select, or the 'clear all' button of the MultiSelect */
76
79
  onClear?: (() => void) | undefined;
80
+ /** A callback that's called when the user clicks the 'clear' icon of a specific Chip in MultiSelect */
81
+ onOptionDelete?: ((option: SelectOption) => void) | undefined;
82
+ /** If true the user can select multiple options */
83
+ multi?: boolean | undefined;
84
+ /** The selected options in case of multiSelect */
85
+ /** @TODO merge selectedOption with selectedOptions in v5 */
86
+ selectedOptions?: SelectOption[] | undefined;
77
87
  } & {
78
88
  id?: string | undefined;
79
89
  onBlur?: React.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement> | undefined;
@@ -21,15 +21,21 @@ var _ClickAwayListener = _interopRequireDefault(require("../utils/ClickAwayListe
21
21
 
22
22
  var _handleSearch = _interopRequireDefault(require("../utils/handleSearch"));
23
23
 
24
+ var _MultiselectTextField = _interopRequireDefault(require("./components/MultiselectTextField"));
25
+
24
26
  var _SelectMenu = _interopRequireDefault(require("./components/SelectMenu/SelectMenu"));
25
27
 
28
+ var _useMultiselectUtils2 = _interopRequireDefault(require("./hooks/useMultiselectUtils"));
29
+
26
30
  var _Select = require("./Select.style");
27
31
 
28
32
  var _Loader = _interopRequireDefault(require("../Loader"));
29
33
 
34
+ var _PositionInScreen = _interopRequireDefault(require("../utils/PositionInScreen"));
35
+
30
36
  var _react2 = require("@emotion/react");
31
37
 
32
- var _excluded = ["handleSelectedOption", "defaultValue", "selectedOption", "multi", "options", "isAsync", "isLoading", "asyncSearch", "status", "minCharactersToSearch", "highlightSearch", "isSearchable", "isVirtualized", "styleType", "disabled", "locked", "dataTestId", "onClear"];
38
+ var _excluded = ["handleSelectedOption", "defaultValue", "selectedOption", "multi", "options", "isAsync", "isLoading", "asyncSearch", "status", "minCharactersToSearch", "highlightSearch", "isSearchable", "isVirtualized", "styleType", "disabled", "locked", "dataTestId", "onClear", "onOptionDelete", "selectedOptions"];
33
39
 
34
40
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
35
41
 
@@ -79,6 +85,9 @@ var Select = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
79
85
  locked = _ref.locked,
80
86
  dataTestId = _ref.dataTestId,
81
87
  onClear = _ref.onClear,
88
+ onOptionDelete = _ref.onOptionDelete,
89
+ _ref$selectedOptions = _ref.selectedOptions,
90
+ selectedOptions = _ref$selectedOptions === void 0 ? [] : _ref$selectedOptions,
82
91
  restInputProps = _objectWithoutPropertiesLoose(_ref, _excluded);
83
92
 
84
93
  var theme = (0, _useTheme["default"])();
@@ -90,8 +99,9 @@ var Select = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
90
99
  var inputRef = _react["default"].useRef(null);
91
100
 
92
101
  var combinedRefs = (0, _useCombinedRefs["default"])(inputRef, ref);
102
+ var initialValue = defaultValue != null ? defaultValue : selectedOption;
93
103
 
94
- var _React$useState2 = _react["default"].useState(defaultValue || selectedOption),
104
+ var _React$useState2 = _react["default"].useState(initialValue),
95
105
  inputValue = _React$useState2[0],
96
106
  setInputValue = _React$useState2[1];
97
107
 
@@ -99,12 +109,39 @@ var Select = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
99
109
  searchValue = _React$useState3[0],
100
110
  setSearchValue = _React$useState3[1];
101
111
 
112
+ var textFieldValue = searchValue || inputValue.label;
113
+
114
+ var _useMultiselectUtils = (0, _useMultiselectUtils2["default"])({
115
+ selectedOptions: selectedOptions,
116
+ options: options,
117
+ setOpen: setOpen,
118
+ setSearchValue: setSearchValue,
119
+ isSearchable: isSearchable,
120
+ onClear: onClear,
121
+ onOptionDelete: onOptionDelete,
122
+ multi: multi
123
+ }),
124
+ multiSelectedOptions = _useMultiselectUtils.multiSelectedOptions,
125
+ setMultiSelectedOpts = _useMultiselectUtils.setMultiSelectedOpts,
126
+ availableMultiSelectOptions = _useMultiselectUtils.availableMultiSelectOptions,
127
+ setAvailableMultiSelectOptions = _useMultiselectUtils.setAvailableMultiSelectOptions,
128
+ handleOptionDelete = _useMultiselectUtils.handleOptionDelete,
129
+ handleClearAllOptions = _useMultiselectUtils.handleClearAllOptions;
130
+
102
131
  (0, _react.useEffect)(function () {
103
- setInputValue(defaultValue || selectedOption);
104
- }, [defaultValue, selectedOption]);
132
+ setInputValue(initialValue);
133
+ }, [initialValue]);
105
134
 
106
135
  var handleOptionClick = function handleOptionClick(option) {
107
- setInputValue(option);
136
+ if (multi) {
137
+ setMultiSelectedOpts([].concat(multiSelectedOptions, [option]));
138
+ setAvailableMultiSelectOptions(availableMultiSelectOptions.filter(function (opt) {
139
+ return opt.value !== option.value;
140
+ }));
141
+ } else {
142
+ setInputValue(option);
143
+ }
144
+
108
145
  setOpen(false);
109
146
 
110
147
  if (isSearchable) {
@@ -128,6 +165,14 @@ var Select = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
128
165
  }, 400), []);
129
166
 
130
167
  var handleOnInput = _react["default"].useCallback(function (event) {
168
+ /**
169
+ * For Multiselect: [for now] when we select an option the SelectMenu closes but the user
170
+ * can still type on the input field (so they must be able to see the SelectMenu)
171
+ */
172
+ if (!open) {
173
+ setOpen(true);
174
+ }
175
+
131
176
  (0, _handleSearch["default"])({
132
177
  event: event,
133
178
  isSearchable: isSearchable,
@@ -136,14 +181,16 @@ var Select = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
136
181
  onChange: debouncedOnChange,
137
182
  minCharactersToSearch: minCharactersToSearch
138
183
  });
139
- }, [debouncedOnChange, isAsync, isSearchable, minCharactersToSearch]);
184
+ }, [debouncedOnChange, isAsync, isSearchable, minCharactersToSearch, open]);
140
185
 
141
186
  var filteredOptions = (0, _react.useMemo)(function () {
187
+ var optionsToBeFiltered = multi ? availableMultiSelectOptions : options;
188
+
142
189
  if (isAsync) {
143
- return options;
190
+ return optionsToBeFiltered;
144
191
  }
145
192
 
146
- return options.filter(function (option) {
193
+ return optionsToBeFiltered.filter(function (option) {
147
194
  var _option$options;
148
195
 
149
196
  return !searchValue || option.label.toLowerCase().includes(searchValue.toLowerCase()) || !!((_option$options = option.options) != null && _option$options.find(function (option) {
@@ -158,7 +205,7 @@ var Select = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
158
205
  })
159
206
  });
160
207
  });
161
- }, [searchValue, options, isAsync]);
208
+ }, [isAsync, multi, availableMultiSelectOptions, options, searchValue]);
162
209
  var rightIconNameSelector = (0, _react.useMemo)(function () {
163
210
  if (isSearchable) {
164
211
  return searchValue || inputValue.value ? 'close' : 'search';
@@ -220,22 +267,41 @@ var Select = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
220
267
  css: (0, _Select.selectWrapper)({
221
268
  isSearchable: isSearchable
222
269
  })
223
- }), (0, _react2.jsx)(_TextField["default"], _extends({
224
- styleType: styleType,
225
- rightIcon: rightIconRender,
226
- onKeyDown: handleOnKeyDown,
227
- onInput: handleOnInput,
228
- onChange: ON_CHANGE_MOCK,
229
- readOnly: !isSearchable,
230
- disabled: disabled,
231
- locked: locked,
232
- dataTestId: (0, _helpers.generateTestDataId)('select-input', dataTestId)
233
- }, restInputProps, {
234
- status: status,
235
- value: searchValue || inputValue.label,
236
- ref: combinedRefs,
237
- autoComplete: "off"
238
- })), open && (0, _react2.jsx)(_SelectMenu["default"], {
270
+ }), (0, _react2.jsx)(_PositionInScreen["default"], {
271
+ visible: open,
272
+ hasWrapperWidth: true,
273
+ offsetY: 8,
274
+ parent: multi ? (0, _react2.jsx)(_MultiselectTextField["default"], _extends({
275
+ selectedOptions: multiSelectedOptions,
276
+ onInput: handleOnInput,
277
+ onOptionDelete: handleOptionDelete,
278
+ onClearAllOptions: handleClearAllOptions,
279
+ isLoading: isLoading,
280
+ disabled: disabled,
281
+ locked: locked,
282
+ readOnly: !isSearchable,
283
+ dataTestId: (0, _helpers.generateTestDataId)('select-input', dataTestId)
284
+ }, restInputProps, {
285
+ status: status,
286
+ value: textFieldValue,
287
+ autoComplete: "off"
288
+ })) : (0, _react2.jsx)(_TextField["default"], _extends({
289
+ styleType: styleType,
290
+ rightIcon: rightIconRender,
291
+ onKeyDown: handleOnKeyDown,
292
+ onInput: handleOnInput,
293
+ onChange: ON_CHANGE_MOCK,
294
+ readOnly: !isSearchable,
295
+ disabled: disabled,
296
+ locked: locked,
297
+ dataTestId: (0, _helpers.generateTestDataId)('select-input', dataTestId)
298
+ }, restInputProps, {
299
+ status: status,
300
+ value: textFieldValue,
301
+ ref: combinedRefs,
302
+ autoComplete: "off"
303
+ }))
304
+ }, (0, _react2.jsx)(_SelectMenu["default"], {
239
305
  filteredOptions: filteredOptions,
240
306
  handleOptionClick: handleOptionClick,
241
307
  selectedOption: inputValue.value,
@@ -244,7 +310,7 @@ var Select = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
244
310
  isLoading: isLoading,
245
311
  isVirtualized: isVirtualized,
246
312
  searchTerm: highlightSearch ? searchValue : undefined
247
- })));
313
+ }))));
248
314
  });
249
315
 
250
316
  Select.displayName = 'Select';
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { TestProps } from 'utils/types';
3
+ import { SelectOption } from 'components/Select/Select';
4
+ import { Props as TextFieldProps } from 'components/TextField/TextField';
5
+ declare const MultiselectTextField: React.ForwardRefExoticComponent<{
6
+ /** the values of the MultiSelect if MultiSelect is controlled */
7
+ selectedOptions?: SelectOption[] | undefined;
8
+ /** Callback fired when the `input` value typed is changed */
9
+ onInput?: ((event: any) => void) | undefined;
10
+ /** Value of the `input` element */
11
+ value?: string | number | undefined;
12
+ /** Callback fired when the Delete button of each Chip is clicked */
13
+ onOptionDelete: (option?: SelectOption | undefined) => void;
14
+ /** Callback fired when the Delete button of the whole MultiSelect is clicked */
15
+ onClearAllOptions: () => void;
16
+ /** If the component is loading */
17
+ isLoading?: boolean | undefined;
18
+ } & Omit<TextFieldProps, "size"> & Partial<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">> & TestProps & React.RefAttributes<HTMLInputElement>>;
19
+ export default MultiselectTextField;
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports["default"] = void 0;
5
+
6
+ var _useTheme = _interopRequireDefault(require("../../../../hooks/useTheme"));
7
+
8
+ var _omit = _interopRequireDefault(require("lodash/omit"));
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _helpers = require("../../../../utils/helpers");
13
+
14
+ var _MultiselectTextField = require("./MultiselectTextField.style");
15
+
16
+ var _Chip = _interopRequireDefault(require("../../../Chip"));
17
+
18
+ var _Icon = _interopRequireDefault(require("../../../Icon"));
19
+
20
+ var _Label = _interopRequireDefault(require("../../../Label"));
21
+
22
+ var _Loader = _interopRequireDefault(require("../../../Loader"));
23
+
24
+ var _TextInputBase = _interopRequireDefault(require("../../../TextInputBase"));
25
+
26
+ var _TextInputBase2 = require("../../../TextInputBase/TextInputBase.style");
27
+
28
+ var _react2 = require("@emotion/react");
29
+
30
+ var _excluded = ["selectedOptions", "value", "disabled", "locked", "status", "lean", "dark", "readOnly", "label", "id", "placeholder", "required", "styleType", "onOptionDelete", "onClearAllOptions", "isLoading", "rightIcon"];
31
+
32
+ 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); }
33
+
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
+
36
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
37
+
38
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
39
+
40
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
41
+
42
+ var MultiselectTextField = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
43
+ var selectedOptions = props.selectedOptions,
44
+ value = props.value,
45
+ disabled = props.disabled,
46
+ locked = props.locked,
47
+ status = props.status,
48
+ lean = props.lean,
49
+ dark = props.dark,
50
+ readOnly = props.readOnly,
51
+ label = props.label,
52
+ id = props.id,
53
+ placeholder = props.placeholder,
54
+ _props$required = props.required,
55
+ required = _props$required === void 0 ? false : _props$required,
56
+ styleType = props.styleType,
57
+ onOptionDelete = props.onOptionDelete,
58
+ onClearAllOptions = props.onClearAllOptions,
59
+ isLoading = props.isLoading,
60
+ rightIcon = props.rightIcon,
61
+ rest = _objectWithoutPropertiesLoose(props, _excluded);
62
+
63
+ var TextfieldRef = _react["default"].useRef(null);
64
+
65
+ var theme = (0, _useTheme["default"])();
66
+ var hasValue = Boolean(value || (selectedOptions == null ? void 0 : selectedOptions.length) && (selectedOptions == null ? void 0 : selectedOptions.length) > 0);
67
+ var inputPlaceholder = (0, _react.useMemo)(function () {
68
+ if (!label && placeholder) {
69
+ return required ? placeholder + " *" : placeholder;
70
+ }
71
+
72
+ return label;
73
+ }, [label, placeholder, required]);
74
+ var iconName = (0, _react.useMemo)(function () {
75
+ if (locked) {
76
+ return 'lock';
77
+ }
78
+
79
+ if (hasValue) {
80
+ return 'close';
81
+ }
82
+
83
+ return 'search';
84
+ }, [hasValue, locked]);
85
+
86
+ var handleKeyDown = function handleKeyDown(event) {
87
+ if (value === '' && event.key === 'Backspace') {
88
+ onOptionDelete();
89
+ }
90
+ };
91
+
92
+ var chips = (0, _react.useMemo)(function () {
93
+ return (0, _react2.jsx)(_react["default"].Fragment, null, selectedOptions == null ? void 0 : selectedOptions.map(function (option, index) {
94
+ var _TextfieldRef$current;
95
+
96
+ return (0, _react2.jsx)("span", {
97
+ key: (0, _helpers.generateUniqueID)('chip' + index),
98
+ css: (0, _MultiselectTextField.chipStyle)()
99
+ }, (0, _react2.jsx)(_Chip["default"], {
100
+ onClear: !(locked || disabled) ? function () {
101
+ return onOptionDelete(option);
102
+ } : undefined,
103
+ fill: "lightGrey",
104
+ dataTestId: "chip_" + index
105
+ }, (0, _react2.jsx)("div", {
106
+ title: option.label,
107
+ css: (0, _MultiselectTextField.chipContent)({
108
+ maxWidth: (_TextfieldRef$current = TextfieldRef.current) == null ? void 0 : _TextfieldRef$current.getBoundingClientRect().width
109
+ })
110
+ }, option.label)));
111
+ }));
112
+ }, [disabled, locked, onOptionDelete, selectedOptions]);
113
+ var icon = (0, _react.useMemo)(function () {
114
+ if (rightIcon) {
115
+ if (typeof rightIcon === 'string') {
116
+ return (0, _react2.jsx)(_Icon["default"], {
117
+ name: rightIcon,
118
+ size: 20,
119
+ color: theme.utils.getColor('lightGrey', 650)
120
+ });
121
+ }
122
+
123
+ return rightIcon;
124
+ }
125
+
126
+ return (0, _react2.jsx)(_Icon["default"], {
127
+ size: 20,
128
+ name: iconName,
129
+ color: theme.utils.getColor('lightGrey', 650),
130
+ onClick: hasValue && !locked ? onClearAllOptions : undefined,
131
+ dataTestId: "select-right-icon"
132
+ });
133
+ }, [hasValue, iconName, locked, onClearAllOptions, rightIcon, theme.utils]);
134
+ return (0, _react2.jsx)("div", {
135
+ ref: TextfieldRef
136
+ }, (0, _react2.jsx)(_TextInputBase["default"], _extends({
137
+ disabled: disabled,
138
+ locked: locked,
139
+ status: status,
140
+ lean: lean,
141
+ size: 'md',
142
+ styleType: styleType
143
+ }, rest, {
144
+ sx: (0, _MultiselectTextField.textInputBaseOverrides)({
145
+ hasValue: hasValue,
146
+ isLoading: isLoading
147
+ })(theme)
148
+ }), (0, _react2.jsx)("div", {
149
+ css: (0, _MultiselectTextField.inputContainer)()
150
+ }, chips, (0, _react2.jsx)("input", _extends({
151
+ readOnly: readOnly,
152
+ onKeyDown: handleKeyDown,
153
+ css: (0, _TextInputBase2.inputStyle)({
154
+ size: 'md',
155
+ placeholder: placeholder,
156
+ label: label,
157
+ dark: dark,
158
+ lean: lean,
159
+ sx: (0, _MultiselectTextField.inputOverrides)()
160
+ }),
161
+ placeholder: inputPlaceholder,
162
+ required: required,
163
+ id: id,
164
+ disabled: disabled || locked
165
+ }, (0, _omit["default"])(rest, 'dataTestId'), {
166
+ value: value,
167
+ ref: ref
168
+ })), label && (0, _react2.jsx)(_Label["default"], {
169
+ size: 'md',
170
+ htmlFor: id,
171
+ label: label,
172
+ required: required,
173
+ animateToTop: hasValue,
174
+ error: status === 'error'
175
+ })), !disabled && (0, _react2.jsx)("div", {
176
+ css: (0, _MultiselectTextField.rightIconsContainer)()
177
+ }, isLoading && (0, _react2.jsx)(_Loader["default"], null), (0, _react2.jsx)("div", {
178
+ css: (0, _MultiselectTextField.rightIconStyles)({
179
+ isClickable: hasValue && !locked
180
+ })
181
+ }, icon))));
182
+ });
183
+
184
+ MultiselectTextField.displayName = 'MultiselectTextField';
185
+ var _default = MultiselectTextField;
186
+ exports["default"] = _default;
@@ -0,0 +1,55 @@
1
+ import { SerializedStyles } from '@emotion/react';
2
+ import { Theme } from 'theme';
3
+ export declare const chipContent: ({ maxWidth }: {
4
+ maxWidth?: number | undefined;
5
+ }) => () => SerializedStyles;
6
+ export declare const textFieldContainer: () => (theme: Theme) => SerializedStyles;
7
+ export declare const rightIconsContainer: () => (theme: Theme) => SerializedStyles;
8
+ export declare const rightIconStyles: ({ isClickable }: {
9
+ isClickable: boolean;
10
+ }) => () => SerializedStyles;
11
+ export declare const chipStyle: () => (theme: Theme) => SerializedStyles;
12
+ export declare const inputContainer: () => (theme: Theme) => SerializedStyles;
13
+ /** TextField overrides */
14
+ export declare const textInputBaseOverrides: ({ hasValue, isLoading }: {
15
+ hasValue: boolean;
16
+ isLoading?: boolean | undefined;
17
+ }) => (theme: Theme) => {
18
+ wrapper: {
19
+ label: {
20
+ fontWeight: any;
21
+ transform: string;
22
+ bottom: string;
23
+ };
24
+ height: string;
25
+ minHeight: string;
26
+ } | {
27
+ 'input:focus': {
28
+ label: {
29
+ fontWeight: any;
30
+ transform: string;
31
+ bottom: string;
32
+ };
33
+ };
34
+ label: {
35
+ transform: string;
36
+ };
37
+ height: string;
38
+ minHeight: string;
39
+ };
40
+ textField: {
41
+ padding: string;
42
+ };
43
+ };
44
+ export declare const inputOverrides: () => {
45
+ input: {
46
+ top: string;
47
+ flex: string;
48
+ minWidth: string;
49
+ '&:focus, &:not(:placeholder-shown)': {
50
+ '& + label': {
51
+ transform: string;
52
+ };
53
+ };
54
+ };
55
+ };