carbon-react 127.1.0 → 128.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.
@@ -17,8 +17,6 @@ export interface FilterableSelectProps extends Omit<FormInputPropTypes, "default
17
17
  children: React.ReactNode;
18
18
  /** The default selected value(s), when the component is operating in uncontrolled mode */
19
19
  defaultValue?: string | Record<string, unknown>;
20
- /** Boolean to toggle where SelectList is rendered in relation to the Select Input */
21
- disablePortal?: boolean;
22
20
  /** If true the loader animation is displayed in the option list */
23
21
  isLoading?: boolean;
24
22
  /** True for default text button or a Button Component to be rendered */
@@ -35,7 +35,6 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
35
35
  onBlur,
36
36
  openOnFocus,
37
37
  noResultsMessage,
38
- disablePortal,
39
38
  listActionButton,
40
39
  listMaxHeight,
41
40
  onListAction,
@@ -119,19 +118,22 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
119
118
  }
120
119
  const updateValues = useCallback((newFilterText, isDeleteEvent) => {
121
120
  setSelectedValue(previousValue => {
122
- const match = findElementWithMatchingText(newFilterText, children);
123
- const isFilterCleared = isDeleteEvent && newFilterText === "";
121
+ const trimmed = newFilterText.trimStart();
122
+ const match = findElementWithMatchingText(trimmed, children);
123
+ const isFilterCleared = isDeleteEvent && !newFilterText.length;
124
124
  if (!match || isFilterCleared || match.props.disabled) {
125
125
  setTextValue(newFilterText);
126
126
  triggerChange("", false);
127
127
  return "";
128
128
  }
129
- triggerChange(match.props.value, false);
129
+ if (trimmed.length) {
130
+ triggerChange(match.props.value, false);
131
+ }
130
132
  if (isDeleteEvent) {
131
133
  setTextValue(newFilterText);
132
134
  return match.props.value;
133
135
  }
134
- if (match.props.text?.toLowerCase().startsWith(newFilterText.toLowerCase())) {
136
+ if (trimmed.length && match.props.text?.toLowerCase().startsWith(trimmed.toLowerCase())) {
135
137
  setTextValue(match.props.text);
136
138
  } else {
137
139
  setTextValue(newFilterText);
@@ -147,7 +149,7 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
147
149
  const matchingOption = React.Children.toArray(children).find(child => /*#__PURE__*/React.isValidElement(child) && isExpectedOption(child, newValue));
148
150
  if (!matchingOption || matchingOption.props.text === undefined) {
149
151
  setTextValue(filterText || "");
150
- } else if (isClosing || matchingOption.props.text?.toLowerCase().startsWith(filterText?.toLowerCase())) {
152
+ } else if (isClosing || matchingOption.props.text?.toLowerCase().startsWith(filterText?.toLowerCase().trim())) {
151
153
  setTextValue(matchingOption.props.text);
152
154
  }
153
155
  }, [children, filterText]);
@@ -255,10 +257,11 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
255
257
  };
256
258
  }, [handleGlobalClick]);
257
259
  useEffect(() => {
258
- const textStartsWithFilter = textValue?.toLowerCase().startsWith(filterText?.toLowerCase());
260
+ const trimmed = filterText?.trimStart();
261
+ const textStartsWithFilter = textValue?.toLowerCase().startsWith(trimmed.toLowerCase());
259
262
  const isTextboxActive = !disabled && !readOnly;
260
- if (isTextboxActive && textboxRef && filterText?.length && textValue?.length > filterText?.length && textStartsWithFilter) {
261
- textboxRef.selectionStart = filterText.length;
263
+ if (isTextboxActive && textboxRef && trimmed.length && textValue?.length > trimmed.length && textStartsWithFilter) {
264
+ textboxRef.selectionStart = trimmed.length;
262
265
  }
263
266
  }, [textValue, filterText, textboxRef, disabled, readOnly]);
264
267
  const onSelectOption = useCallback(optionData => {
@@ -405,10 +408,9 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
405
408
  onSelect: onSelectOption,
406
409
  onSelectListClose,
407
410
  onMouseDown: handleListMouseDown,
408
- filterText,
411
+ filterText: filterText.trim(),
409
412
  highlightedValue,
410
413
  noResultsMessage,
411
- disablePortal,
412
414
  listActionButton,
413
415
  listMaxHeight,
414
416
  onListAction: handleOnListAction,
@@ -423,9 +425,7 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
423
425
  enableVirtualScroll,
424
426
  virtualScrollOverscan
425
427
  };
426
- const selectList = disableDefaultFiltering ? /*#__PURE__*/React.createElement(SelectList, selectListProps, children) : /*#__PURE__*/React.createElement(FilterableSelectList, _extends({}, selectListProps, {
427
- filterText: filterText
428
- }), children);
428
+ const selectList = disableDefaultFiltering ? /*#__PURE__*/React.createElement(SelectList, selectListProps, children) : /*#__PURE__*/React.createElement(FilterableSelectList, selectListProps, children);
429
429
  const marginProps = useFormSpacing(textboxProps);
430
430
  return /*#__PURE__*/React.createElement(StyledSelect, _extends({
431
431
  hasTextCursor: true,
@@ -535,7 +535,6 @@ if (process.env.NODE_ENV !== "production") {
535
535
  "dir": PropTypes.string,
536
536
  "disabled": PropTypes.bool,
537
537
  "disableDefaultFiltering": PropTypes.bool,
538
- "disablePortal": PropTypes.bool,
539
538
  "draggable": PropTypes.oneOfType([PropTypes.oneOf(["false", "true"]), PropTypes.bool]),
540
539
  "enableVirtualScroll": PropTypes.bool,
541
540
  "enterKeyHint": PropTypes.oneOf(["done", "enter", "go", "next", "previous", "search", "send"]),
@@ -18,8 +18,6 @@ export interface MultiSelectProps extends Omit<FormInputPropTypes, "defaultValue
18
18
  children: React.ReactNode;
19
19
  /** The default selected value(s), when the component is operating in uncontrolled mode */
20
20
  defaultValue?: string[] | Record<string, unknown>[];
21
- /** Boolean to toggle where SelectList is rendered in relation to the Select Input */
22
- disablePortal?: boolean;
23
21
  /** If true the loader animation is displayed in the option list */
24
22
  isLoading?: boolean;
25
23
  /** When true component will work in multi column mode.
@@ -40,7 +40,6 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
40
40
  openOnFocus = false,
41
41
  noResultsMessage,
42
42
  placeholder,
43
- disablePortal,
44
43
  isLoading,
45
44
  tableHeader,
46
45
  multiColumn,
@@ -417,10 +416,9 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
417
416
  onSelect: onSelectOption,
418
417
  onSelectListClose: onSelectListClose,
419
418
  onMouseDown: handleListMouseDown,
420
- filterText: filterText,
419
+ filterText: filterText.trim(),
421
420
  highlightedValue: highlightedValue,
422
421
  noResultsMessage: noResultsMessage,
423
- disablePortal: disablePortal,
424
422
  isLoading: isLoading,
425
423
  tableHeader: tableHeader,
426
424
  multiColumn: multiColumn,
@@ -546,7 +544,6 @@ if (process.env.NODE_ENV !== "production") {
546
544
  "deferTimeout": PropTypes.number,
547
545
  "dir": PropTypes.string,
548
546
  "disabled": PropTypes.bool,
549
- "disablePortal": PropTypes.bool,
550
547
  "draggable": PropTypes.oneOfType([PropTypes.oneOf(["false", "true"]), PropTypes.bool]),
551
548
  "enableVirtualScroll": PropTypes.bool,
552
549
  "enterKeyHint": PropTypes.oneOf(["done", "enter", "go", "next", "previous", "search", "send"]),
@@ -7,8 +7,6 @@ export interface SelectListProps {
7
7
  labelId?: string;
8
8
  /** Child components (such as <Option>) */
9
9
  children?: React.ReactNode;
10
- /** Boolean to toggle where DatePicker is rendered in relation to the Date Input */
11
- disablePortal?: boolean;
12
10
  /** DOM element to position the dropdown menu list relative to */
13
11
  anchorElement?: HTMLElement;
14
12
  /** A callback for when a child is selected */
@@ -33,7 +33,6 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
33
33
  filterText,
34
34
  anchorElement,
35
35
  highlightedValue,
36
- disablePortal,
37
36
  onListAction,
38
37
  isLoading,
39
38
  onListScrollBottom,
@@ -395,7 +394,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
395
394
  }
396
395
  }, /*#__PURE__*/React.createElement(Popover, {
397
396
  placement: listPlacement,
398
- disablePortal: disablePortal,
397
+ disablePortal: true,
399
398
  reference: anchorRef,
400
399
  middleware: popoverMiddleware,
401
400
  isOpen: isOpen,
@@ -432,7 +431,6 @@ if (process.env.NODE_ENV !== "production") {
432
431
  }
433
432
  },
434
433
  "children": PropTypes.node,
435
- "disablePortal": PropTypes.bool,
436
434
  "enableVirtualScroll": PropTypes.bool,
437
435
  "filterText": PropTypes.string,
438
436
  "flipEnabled": PropTypes.bool,
@@ -26,8 +26,6 @@ export interface SimpleSelectProps extends Omit<FormInputPropTypes, "defaultValu
26
26
  children: React.ReactNode;
27
27
  /** The default selected value(s), when the component is operating in uncontrolled mode */
28
28
  defaultValue?: string | Record<string, unknown>;
29
- /** Boolean to toggle where SelectList is rendered in relation to the Select Input */
30
- disablePortal?: boolean;
31
29
  /** If true the loader animation is displayed in the option list */
32
30
  isLoading?: boolean;
33
31
  /** When true component will work in multi column mode.
@@ -34,7 +34,6 @@ const SimpleSelect = /*#__PURE__*/React.forwardRef(({
34
34
  onFocus,
35
35
  onKeyDown,
36
36
  onBlur,
37
- disablePortal = false,
38
37
  isLoading,
39
38
  listMaxHeight,
40
39
  onListScrollBottom,
@@ -329,7 +328,6 @@ const SimpleSelect = /*#__PURE__*/React.forwardRef(({
329
328
  onMouseDown: handleListMouseDown,
330
329
  onSelectListClose: onSelectListClose,
331
330
  highlightedValue: selectedValue,
332
- disablePortal: disablePortal,
333
331
  listMaxHeight: listMaxHeight,
334
332
  isLoading: isLoading,
335
333
  onListScrollBottom: onListScrollBottom,
@@ -448,7 +446,6 @@ if (process.env.NODE_ENV !== "production") {
448
446
  "deferTimeout": PropTypes.number,
449
447
  "dir": PropTypes.string,
450
448
  "disabled": PropTypes.bool,
451
- "disablePortal": PropTypes.bool,
452
449
  "draggable": PropTypes.oneOfType([PropTypes.oneOf(["false", "true"]), PropTypes.bool]),
453
450
  "enableVirtualScroll": PropTypes.bool,
454
451
  "enterKeyHint": PropTypes.oneOf(["done", "enter", "go", "next", "previous", "search", "send"]),
@@ -17,8 +17,6 @@ export interface FilterableSelectProps extends Omit<FormInputPropTypes, "default
17
17
  children: React.ReactNode;
18
18
  /** The default selected value(s), when the component is operating in uncontrolled mode */
19
19
  defaultValue?: string | Record<string, unknown>;
20
- /** Boolean to toggle where SelectList is rendered in relation to the Select Input */
21
- disablePortal?: boolean;
22
20
  /** If true the loader animation is displayed in the option list */
23
21
  isLoading?: boolean;
24
22
  /** True for default text button or a Button Component to be rendered */
@@ -44,7 +44,6 @@ const FilterableSelect = exports.FilterableSelect = /*#__PURE__*/_react.default.
44
44
  onBlur,
45
45
  openOnFocus,
46
46
  noResultsMessage,
47
- disablePortal,
48
47
  listActionButton,
49
48
  listMaxHeight,
50
49
  onListAction,
@@ -128,19 +127,22 @@ const FilterableSelect = exports.FilterableSelect = /*#__PURE__*/_react.default.
128
127
  }
129
128
  const updateValues = (0, _react.useCallback)((newFilterText, isDeleteEvent) => {
130
129
  setSelectedValue(previousValue => {
131
- const match = findElementWithMatchingText(newFilterText, children);
132
- const isFilterCleared = isDeleteEvent && newFilterText === "";
130
+ const trimmed = newFilterText.trimStart();
131
+ const match = findElementWithMatchingText(trimmed, children);
132
+ const isFilterCleared = isDeleteEvent && !newFilterText.length;
133
133
  if (!match || isFilterCleared || match.props.disabled) {
134
134
  setTextValue(newFilterText);
135
135
  triggerChange("", false);
136
136
  return "";
137
137
  }
138
- triggerChange(match.props.value, false);
138
+ if (trimmed.length) {
139
+ triggerChange(match.props.value, false);
140
+ }
139
141
  if (isDeleteEvent) {
140
142
  setTextValue(newFilterText);
141
143
  return match.props.value;
142
144
  }
143
- if (match.props.text?.toLowerCase().startsWith(newFilterText.toLowerCase())) {
145
+ if (trimmed.length && match.props.text?.toLowerCase().startsWith(trimmed.toLowerCase())) {
144
146
  setTextValue(match.props.text);
145
147
  } else {
146
148
  setTextValue(newFilterText);
@@ -156,7 +158,7 @@ const FilterableSelect = exports.FilterableSelect = /*#__PURE__*/_react.default.
156
158
  const matchingOption = _react.default.Children.toArray(children).find(child => /*#__PURE__*/_react.default.isValidElement(child) && (0, _isExpectedOption.default)(child, newValue));
157
159
  if (!matchingOption || matchingOption.props.text === undefined) {
158
160
  setTextValue(filterText || "");
159
- } else if (isClosing || matchingOption.props.text?.toLowerCase().startsWith(filterText?.toLowerCase())) {
161
+ } else if (isClosing || matchingOption.props.text?.toLowerCase().startsWith(filterText?.toLowerCase().trim())) {
160
162
  setTextValue(matchingOption.props.text);
161
163
  }
162
164
  }, [children, filterText]);
@@ -264,10 +266,11 @@ const FilterableSelect = exports.FilterableSelect = /*#__PURE__*/_react.default.
264
266
  };
265
267
  }, [handleGlobalClick]);
266
268
  (0, _react.useEffect)(() => {
267
- const textStartsWithFilter = textValue?.toLowerCase().startsWith(filterText?.toLowerCase());
269
+ const trimmed = filterText?.trimStart();
270
+ const textStartsWithFilter = textValue?.toLowerCase().startsWith(trimmed.toLowerCase());
268
271
  const isTextboxActive = !disabled && !readOnly;
269
- if (isTextboxActive && textboxRef && filterText?.length && textValue?.length > filterText?.length && textStartsWithFilter) {
270
- textboxRef.selectionStart = filterText.length;
272
+ if (isTextboxActive && textboxRef && trimmed.length && textValue?.length > trimmed.length && textStartsWithFilter) {
273
+ textboxRef.selectionStart = trimmed.length;
271
274
  }
272
275
  }, [textValue, filterText, textboxRef, disabled, readOnly]);
273
276
  const onSelectOption = (0, _react.useCallback)(optionData => {
@@ -414,10 +417,9 @@ const FilterableSelect = exports.FilterableSelect = /*#__PURE__*/_react.default.
414
417
  onSelect: onSelectOption,
415
418
  onSelectListClose,
416
419
  onMouseDown: handleListMouseDown,
417
- filterText,
420
+ filterText: filterText.trim(),
418
421
  highlightedValue,
419
422
  noResultsMessage,
420
- disablePortal,
421
423
  listActionButton,
422
424
  listMaxHeight,
423
425
  onListAction: handleOnListAction,
@@ -432,9 +434,7 @@ const FilterableSelect = exports.FilterableSelect = /*#__PURE__*/_react.default.
432
434
  enableVirtualScroll,
433
435
  virtualScrollOverscan
434
436
  };
435
- const selectList = disableDefaultFiltering ? /*#__PURE__*/_react.default.createElement(_selectList.default, selectListProps, children) : /*#__PURE__*/_react.default.createElement(FilterableSelectList, _extends({}, selectListProps, {
436
- filterText: filterText
437
- }), children);
437
+ const selectList = disableDefaultFiltering ? /*#__PURE__*/_react.default.createElement(_selectList.default, selectListProps, children) : /*#__PURE__*/_react.default.createElement(FilterableSelectList, selectListProps, children);
438
438
  const marginProps = (0, _useFormSpacing.default)(textboxProps);
439
439
  return /*#__PURE__*/_react.default.createElement(_select.default, _extends({
440
440
  hasTextCursor: true,
@@ -544,7 +544,6 @@ if (process.env.NODE_ENV !== "production") {
544
544
  "dir": _propTypes.default.string,
545
545
  "disabled": _propTypes.default.bool,
546
546
  "disableDefaultFiltering": _propTypes.default.bool,
547
- "disablePortal": _propTypes.default.bool,
548
547
  "draggable": _propTypes.default.oneOfType([_propTypes.default.oneOf(["false", "true"]), _propTypes.default.bool]),
549
548
  "enableVirtualScroll": _propTypes.default.bool,
550
549
  "enterKeyHint": _propTypes.default.oneOf(["done", "enter", "go", "next", "previous", "search", "send"]),
@@ -18,8 +18,6 @@ export interface MultiSelectProps extends Omit<FormInputPropTypes, "defaultValue
18
18
  children: React.ReactNode;
19
19
  /** The default selected value(s), when the component is operating in uncontrolled mode */
20
20
  defaultValue?: string[] | Record<string, unknown>[];
21
- /** Boolean to toggle where SelectList is rendered in relation to the Select Input */
22
- disablePortal?: boolean;
23
21
  /** If true the loader animation is displayed in the option list */
24
22
  isLoading?: boolean;
25
23
  /** When true component will work in multi column mode.
@@ -49,7 +49,6 @@ const MultiSelect = exports.MultiSelect = /*#__PURE__*/_react.default.forwardRef
49
49
  openOnFocus = false,
50
50
  noResultsMessage,
51
51
  placeholder,
52
- disablePortal,
53
52
  isLoading,
54
53
  tableHeader,
55
54
  multiColumn,
@@ -426,10 +425,9 @@ const MultiSelect = exports.MultiSelect = /*#__PURE__*/_react.default.forwardRef
426
425
  onSelect: onSelectOption,
427
426
  onSelectListClose: onSelectListClose,
428
427
  onMouseDown: handleListMouseDown,
429
- filterText: filterText,
428
+ filterText: filterText.trim(),
430
429
  highlightedValue: highlightedValue,
431
430
  noResultsMessage: noResultsMessage,
432
- disablePortal: disablePortal,
433
431
  isLoading: isLoading,
434
432
  tableHeader: tableHeader,
435
433
  multiColumn: multiColumn,
@@ -555,7 +553,6 @@ if (process.env.NODE_ENV !== "production") {
555
553
  "deferTimeout": _propTypes.default.number,
556
554
  "dir": _propTypes.default.string,
557
555
  "disabled": _propTypes.default.bool,
558
- "disablePortal": _propTypes.default.bool,
559
556
  "draggable": _propTypes.default.oneOfType([_propTypes.default.oneOf(["false", "true"]), _propTypes.default.bool]),
560
557
  "enableVirtualScroll": _propTypes.default.bool,
561
558
  "enterKeyHint": _propTypes.default.oneOf(["done", "enter", "go", "next", "previous", "search", "send"]),
@@ -7,8 +7,6 @@ export interface SelectListProps {
7
7
  labelId?: string;
8
8
  /** Child components (such as <Option>) */
9
9
  children?: React.ReactNode;
10
- /** Boolean to toggle where DatePicker is rendered in relation to the Date Input */
11
- disablePortal?: boolean;
12
10
  /** DOM element to position the dropdown menu list relative to */
13
11
  anchorElement?: HTMLElement;
14
12
  /** A callback for when a child is selected */
@@ -42,7 +42,6 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
42
42
  filterText,
43
43
  anchorElement,
44
44
  highlightedValue,
45
- disablePortal,
46
45
  onListAction,
47
46
  isLoading,
48
47
  onListScrollBottom,
@@ -404,7 +403,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
404
403
  }
405
404
  }, /*#__PURE__*/_react.default.createElement(_popover.default, {
406
405
  placement: listPlacement,
407
- disablePortal: disablePortal,
406
+ disablePortal: true,
408
407
  reference: anchorRef,
409
408
  middleware: popoverMiddleware,
410
409
  isOpen: isOpen,
@@ -441,7 +440,6 @@ if (process.env.NODE_ENV !== "production") {
441
440
  }
442
441
  },
443
442
  "children": _propTypes.default.node,
444
- "disablePortal": _propTypes.default.bool,
445
443
  "enableVirtualScroll": _propTypes.default.bool,
446
444
  "filterText": _propTypes.default.string,
447
445
  "flipEnabled": _propTypes.default.bool,
@@ -26,8 +26,6 @@ export interface SimpleSelectProps extends Omit<FormInputPropTypes, "defaultValu
26
26
  children: React.ReactNode;
27
27
  /** The default selected value(s), when the component is operating in uncontrolled mode */
28
28
  defaultValue?: string | Record<string, unknown>;
29
- /** Boolean to toggle where SelectList is rendered in relation to the Select Input */
30
- disablePortal?: boolean;
31
29
  /** If true the loader animation is displayed in the option list */
32
30
  isLoading?: boolean;
33
31
  /** When true component will work in multi column mode.
@@ -43,7 +43,6 @@ const SimpleSelect = exports.SimpleSelect = /*#__PURE__*/_react.default.forwardR
43
43
  onFocus,
44
44
  onKeyDown,
45
45
  onBlur,
46
- disablePortal = false,
47
46
  isLoading,
48
47
  listMaxHeight,
49
48
  onListScrollBottom,
@@ -338,7 +337,6 @@ const SimpleSelect = exports.SimpleSelect = /*#__PURE__*/_react.default.forwardR
338
337
  onMouseDown: handleListMouseDown,
339
338
  onSelectListClose: onSelectListClose,
340
339
  highlightedValue: selectedValue,
341
- disablePortal: disablePortal,
342
340
  listMaxHeight: listMaxHeight,
343
341
  isLoading: isLoading,
344
342
  onListScrollBottom: onListScrollBottom,
@@ -457,7 +455,6 @@ if (process.env.NODE_ENV !== "production") {
457
455
  "deferTimeout": _propTypes.default.number,
458
456
  "dir": _propTypes.default.string,
459
457
  "disabled": _propTypes.default.bool,
460
- "disablePortal": _propTypes.default.bool,
461
458
  "draggable": _propTypes.default.oneOfType([_propTypes.default.oneOf(["false", "true"]), _propTypes.default.bool]),
462
459
  "enableVirtualScroll": _propTypes.default.bool,
463
460
  "enterKeyHint": _propTypes.default.oneOf(["done", "enter", "go", "next", "previous", "search", "send"]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "127.1.0",
3
+ "version": "128.0.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",