carbon-react 142.13.5 → 143.0.1

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 (47) hide show
  1. package/esm/__internal__/validations/validation-icon.component.js +2 -1
  2. package/esm/components/accordion/accordion-group/accordion-group.component.d.ts +2 -1
  3. package/esm/components/accordion/accordion-group/accordion-group.component.js +4 -1
  4. package/esm/components/advanced-color-picker/advanced-color-picker.component.js +3 -1
  5. package/esm/components/pages/page/page.component.js +1 -0
  6. package/esm/components/preview/preview.component.js +6 -2
  7. package/esm/components/select/__internal__/select-list/select-list.component.d.ts +4 -2
  8. package/esm/components/select/__internal__/select-list/select-list.component.js +8 -4
  9. package/esm/components/select/__internal__/utils/with-filter.hoc.js +3 -1
  10. package/esm/components/select/filterable-select/filterable-select.component.d.ts +4 -2
  11. package/esm/components/select/filterable-select/filterable-select.component.js +17 -3
  12. package/esm/components/select/multi-select/multi-select.component.d.ts +4 -2
  13. package/esm/components/select/multi-select/multi-select.component.js +17 -3
  14. package/esm/components/select/option/option.component.d.ts +5 -5
  15. package/esm/components/select/option/option.component.js +8 -8
  16. package/esm/components/select/option/option.style.d.ts +1 -0
  17. package/esm/components/select/option/option.style.js +9 -7
  18. package/esm/components/select/option-group-header/option-group-header.component.d.ts +1 -1
  19. package/esm/components/select/option-group-header/option-group-header.component.js +2 -2
  20. package/esm/components/select/option-row/option-row.component.d.ts +1 -1
  21. package/esm/components/select/option-row/option-row.component.js +3 -3
  22. package/esm/components/select/simple-select/simple-select.component.d.ts +4 -2
  23. package/esm/components/select/simple-select/simple-select.component.js +36 -43
  24. package/lib/__internal__/validations/validation-icon.component.js +2 -1
  25. package/lib/components/accordion/accordion-group/accordion-group.component.d.ts +2 -1
  26. package/lib/components/accordion/accordion-group/accordion-group.component.js +4 -1
  27. package/lib/components/advanced-color-picker/advanced-color-picker.component.js +3 -1
  28. package/lib/components/pages/page/page.component.js +1 -0
  29. package/lib/components/preview/preview.component.js +6 -2
  30. package/lib/components/select/__internal__/select-list/select-list.component.d.ts +4 -2
  31. package/lib/components/select/__internal__/select-list/select-list.component.js +8 -4
  32. package/lib/components/select/__internal__/utils/with-filter.hoc.js +3 -1
  33. package/lib/components/select/filterable-select/filterable-select.component.d.ts +4 -2
  34. package/lib/components/select/filterable-select/filterable-select.component.js +17 -3
  35. package/lib/components/select/multi-select/multi-select.component.d.ts +4 -2
  36. package/lib/components/select/multi-select/multi-select.component.js +17 -3
  37. package/lib/components/select/option/option.component.d.ts +5 -5
  38. package/lib/components/select/option/option.component.js +8 -8
  39. package/lib/components/select/option/option.style.d.ts +1 -0
  40. package/lib/components/select/option/option.style.js +9 -7
  41. package/lib/components/select/option-group-header/option-group-header.component.d.ts +1 -1
  42. package/lib/components/select/option-group-header/option-group-header.component.js +2 -2
  43. package/lib/components/select/option-row/option-row.component.d.ts +1 -1
  44. package/lib/components/select/option-row/option-row.component.js +3 -3
  45. package/lib/components/select/simple-select/simple-select.component.d.ts +4 -2
  46. package/lib/components/select/simple-select/simple-select.component.js +36 -43
  47. package/package.json +2 -2
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { CSSProperties } from "styled-components";
3
3
  import { TagProps } from "__internal__/utils/helpers/tags";
4
4
  import { IconProps } from "../../icon";
5
- export interface OptionGroupHeaderProps extends TagProps {
5
+ export interface OptionGroupHeaderProps extends Omit<TagProps, "data-component"> {
6
6
  /**
7
7
  * Unique identifier for the component.
8
8
  * Will use a randomly generated GUID if none is provided.
@@ -30,7 +30,8 @@ const OptionGroupHeader = /*#__PURE__*/_react.default.forwardRef(({
30
30
  style: style,
31
31
  id: internalIdRef.current
32
32
  }, rest, {
33
- ref: ref
33
+ ref: ref,
34
+ "data-component": "option-group-header"
34
35
  }), children || /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, icon && /*#__PURE__*/_react.default.createElement(_icon.default, {
35
36
  type: icon
36
37
  }), /*#__PURE__*/_react.default.createElement("h4", null, label)));
@@ -38,7 +39,6 @@ const OptionGroupHeader = /*#__PURE__*/_react.default.forwardRef(({
38
39
  if (process.env.NODE_ENV !== "production") {
39
40
  OptionGroupHeader.propTypes = {
40
41
  "children": _propTypes.default.node,
41
- "data-component": _propTypes.default.string,
42
42
  "data-element": _propTypes.default.string,
43
43
  "data-role": _propTypes.default.string,
44
44
  "icon": _propTypes.default.oneOf(["accessibility_web", "add", "admin", "alert_on", "alert", "analysis", "app_facebook", "app_instagram", "app_tiktok", "app_twitter", "app_youtube", "apps", "arrow_bottom_right_circle", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_top_left_circle", "arrow_up", "arrow", "arrows_left_right", "attach", "bank_with_card", "bank", "basket_with_squares", "basket", "bed", "bill_paid", "bill_unpaid", "bin", "biometric", "block_arrow_right", "blocked_square", "blocked", "bold", "box_arrow_left", "box_arrow_right", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_pay_date", "calendar_today", "calendar", "call", "camera", "car_lock", "car_money", "car_repair", "card_view", "card_wallet", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "cash", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "check_all", "check_none", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "cloud_co2", "coins", "collaborate", "computer_clock", "connect_off", "connect", "construction", "contact_card", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "dashboard", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "drill", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "export", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "form_refresh", "gift", "go", "graduation_hat", "graph", "grid", "hand_cash_coins", "hand_cash_note", "heart_pulse", "help", "hide", "home", "image", "import", "in_progress", "in_transit", "individual", "info", "intranet", "italic", "job_seeked", "key", "laptop", "leaf", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "like_no", "like", "link_cloud", "link_on", "link", "list_view", "location", "locked", "logout", "lookup", "maintenance", "marker", "message", "messages", "microphone", "minimise", "minus_large", "minus", "mobile", "money_bag", "new", "none", "old_warning", "palm_tree", "pause_circle", "pause", "pdf", "people_switch", "people", "percentage_boxed", "person_info", "person_tick", "person", "petrol_pump", "phone", "piggy_bank", "pin", "plane", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "protect", "question_hollow", "question_mark", "question", "recruiting", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "send", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "success", "support_online", "sync", "tag", "talk", "target_man", "target", "theatre_masks", "three_boxes", "tick_circle", "tick_thick", "tick", "true_tick", "u_turn_left", "u_turn_right", "undo", "unlocked", "upload", "uploaded", "video", "view", "volunteering", "warning", "website", "welfare"]),
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { CSSProperties } from "styled-components";
3
3
  import { TagProps } from "__internal__/utils/helpers/tags";
4
- export interface OptionRowProps extends TagProps {
4
+ export interface OptionRowProps extends Omit<TagProps, "data-component"> {
5
5
  /** The option's visible text, displayed within <Textbox> of <Select> */
6
6
  text: string;
7
7
  /** Row content, should consist of multiple td elements */
@@ -46,19 +46,19 @@ const OptionRow = /*#__PURE__*/_react.default.forwardRef(({
46
46
  ref: ref,
47
47
  "aria-selected": isSelected,
48
48
  "aria-disabled": disabled,
49
- "data-component": "option-row",
50
49
  isDisabled: disabled,
51
50
  onClick: handleClick,
52
51
  isHighlighted: selectListContext.currentOptionsListIndex === index,
53
52
  role: "option",
54
53
  hidden: hidden,
55
54
  style: style
56
- }, rest), children);
55
+ }, rest, {
56
+ "data-component": "option-row"
57
+ }), children);
57
58
  });
58
59
  if (process.env.NODE_ENV !== "production") {
59
60
  OptionRow.propTypes = {
60
61
  "children": _propTypes.default.node,
61
- "data-component": _propTypes.default.string,
62
62
  "data-element": _propTypes.default.string,
63
63
  "data-role": _propTypes.default.string,
64
64
  "disabled": _propTypes.default.bool,
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
- import { Side } from "@floating-ui/dom";
3
2
  import { FormInputPropTypes } from "../__internal__/select-textbox";
3
+ import { ListPlacement } from "../__internal__/select-list/select-list.component";
4
4
  export interface OptionData {
5
5
  text?: string;
6
6
  value?: string | Record<string, unknown>;
@@ -51,7 +51,7 @@ export interface SimpleSelectProps extends Omit<FormInputPropTypes, "defaultValu
51
51
  /** Maximum list height - defaults to 180 */
52
52
  listMaxHeight?: number;
53
53
  /** Placement of the select list in relation to the input element */
54
- listPlacement?: Side;
54
+ listPlacement?: ListPlacement;
55
55
  /** Use the opposite list placement if the set placement does not fit */
56
56
  flipEnabled?: boolean;
57
57
  /** Set this prop to enable a virtualised list of options. If it is not used then all options will be in the
@@ -67,6 +67,8 @@ export interface SimpleSelectProps extends Omit<FormInputPropTypes, "defaultValu
67
67
  isRequired?: boolean;
68
68
  /** Specify a callback triggered on change */
69
69
  onChange?: (ev: CustomSelectChangeEvent | React.ChangeEvent<HTMLInputElement>) => void;
70
+ /** Override the default width of the list element. Number passed is converted into pixel value */
71
+ listWidth?: number;
70
72
  }
71
73
  export declare const SimpleSelect: React.ForwardRefExoticComponent<SimpleSelectProps & React.RefAttributes<HTMLInputElement>>;
72
74
  export default SimpleSelect;
@@ -57,12 +57,13 @@ const SimpleSelect = exports.SimpleSelect = /*#__PURE__*/_react.default.forwardR
57
57
  virtualScrollOverscan,
58
58
  isOptional,
59
59
  required,
60
+ listWidth,
60
61
  ...props
61
62
  }, ref) => {
62
63
  const selectListId = (0, _react.useRef)((0, _guid.default)());
63
64
  const containerRef = (0, _react.useRef)(null);
64
65
  const listboxRef = (0, _react.useRef)(null);
65
- const filterTimer = (0, _react.useRef)();
66
+ const filterTimer = (0, _react.useRef)(undefined);
66
67
  const isMouseDownReported = (0, _react.useRef)();
67
68
  const isControlled = (0, _react.useRef)(value !== undefined);
68
69
  const isTimerCounting = (0, _react.useRef)();
@@ -80,7 +81,7 @@ const SimpleSelect = exports.SimpleSelect = /*#__PURE__*/_react.default.forwardR
80
81
  id: inputId.current,
81
82
  label
82
83
  });
83
- const focusTimer = (0, _react.useRef)(null);
84
+ const focusTimer = (0, _react.useRef)(undefined);
84
85
  const componentIsUncontrolled = !isControlled || !onChange && defaultValue;
85
86
  if (!deprecateUncontrolledWarnTriggered && componentIsUncontrolled) {
86
87
  deprecateUncontrolledWarnTriggered = true;
@@ -109,9 +110,7 @@ const SimpleSelect = exports.SimpleSelect = /*#__PURE__*/_react.default.forwardR
109
110
  if (!match) {
110
111
  return previousValue;
111
112
  }
112
- if (onChange) {
113
- onChange(createCustomEvent(match.props.value));
114
- }
113
+ onChange?.(createCustomEvent(match.props.value));
115
114
  if (isControlled.current) {
116
115
  return previousValue;
117
116
  }
@@ -124,14 +123,14 @@ const SimpleSelect = exports.SimpleSelect = /*#__PURE__*/_react.default.forwardR
124
123
  const newVal = filterText.current + newCharacter;
125
124
  filterText.current = newVal;
126
125
  selectValueStartingWithText(newVal);
127
- clearTimeout(filterTimer.current);
126
+ window.clearTimeout(filterTimer.current);
128
127
  } else {
129
128
  filterText.current = newCharacter;
130
129
  selectValueStartingWithText(newCharacter);
131
130
  }
132
131
  isTimerCounting.current = true;
133
- clearTimeout(filterTimer.current);
134
- filterTimer.current = setTimeout(() => {
132
+ window.clearTimeout(filterTimer.current);
133
+ filterTimer.current = window.setTimeout(() => {
135
134
  isTimerCounting.current = false;
136
135
  filterText.current = "";
137
136
  }, 500);
@@ -140,18 +139,12 @@ const SimpleSelect = exports.SimpleSelect = /*#__PURE__*/_react.default.forwardR
140
139
  const {
141
140
  key
142
141
  } = event;
143
- if (onKeyDown) {
144
- onKeyDown(event);
145
- }
146
- if (readOnly) {
147
- return;
148
- }
142
+ onKeyDown?.(event);
143
+ if (readOnly) return;
149
144
  if (key === " " || (0, _isNavigationKey.default)(key)) {
150
145
  event.preventDefault();
151
146
  setOpenState(isAlreadyOpen => {
152
- if (!isAlreadyOpen && onOpen) {
153
- onOpen();
154
- }
147
+ if (!isAlreadyOpen) onOpen?.();
155
148
  return true;
156
149
  });
157
150
  } else if (key.length === 1 && !event.metaKey && !event.ctrlKey) {
@@ -193,21 +186,18 @@ const SimpleSelect = exports.SimpleSelect = /*#__PURE__*/_react.default.forwardR
193
186
  }, [handleGlobalClick]);
194
187
  (0, _react.useEffect)(() => {
195
188
  return function cleanup() {
196
- clearTimeout(filterTimer.current);
189
+ window.clearTimeout(filterTimer.current);
190
+ window.clearTimeout(focusTimer.current);
197
191
  };
198
192
  }, []);
199
193
  function handleTextboxClick(event) {
200
194
  isMouseDownReported.current = false;
201
- if (onClick) {
202
- onClick(event);
203
- }
195
+ onClick?.(event);
204
196
  setOpenState(isAlreadyOpen => {
205
197
  if (isAlreadyOpen) {
206
198
  return false;
207
199
  }
208
- if (onOpen) {
209
- onOpen();
210
- }
200
+ onOpen?.();
211
201
  return true;
212
202
  });
213
203
  }
@@ -221,9 +211,7 @@ const SimpleSelect = exports.SimpleSelect = /*#__PURE__*/_react.default.forwardR
221
211
  if (isMouseDownReported.current) {
222
212
  return;
223
213
  }
224
- if (onBlur) {
225
- onBlur(event);
226
- }
214
+ onBlur?.(event);
227
215
  }
228
216
  function handleTextboxMouseDown() {
229
217
  isMouseDownReported.current = true;
@@ -232,28 +220,22 @@ const SimpleSelect = exports.SimpleSelect = /*#__PURE__*/_react.default.forwardR
232
220
  if (isClickTriggeredBySelect.current) {
233
221
  return;
234
222
  }
235
- if (onFocus) {
236
- onFocus(event);
237
- }
223
+ onFocus?.(event);
238
224
  if (isMouseDownReported.current) {
239
225
  isMouseDownReported.current = false;
240
226
  return;
241
227
  }
242
228
  if (openOnFocus) {
243
- if (focusTimer.current) {
244
- clearTimeout(focusTimer.current);
245
- }
229
+ window.clearTimeout(focusTimer.current);
246
230
 
247
231
  // we need to use a timeout here as there is a race condition when rendered in a modal
248
232
  // whereby the select list isn't visible when the select is auto focused straight away
249
- focusTimer.current = setTimeout(() => {
233
+ focusTimer.current = window.setTimeout(() => {
250
234
  setOpenState(isAlreadyOpen => {
251
235
  if (isAlreadyOpen) {
252
236
  return true;
253
237
  }
254
- if (onOpen) {
255
- onOpen();
256
- }
238
+ onOpen?.();
257
239
  return true;
258
240
  });
259
241
  });
@@ -264,9 +246,7 @@ const SimpleSelect = exports.SimpleSelect = /*#__PURE__*/_react.default.forwardR
264
246
  setSelectedValue(newValue);
265
247
  setTextValue(text);
266
248
  }
267
- if (onChange) {
268
- onChange(createCustomEvent(newValue, selectionConfirmed));
269
- }
249
+ onChange?.(createCustomEvent(newValue, selectionConfirmed));
270
250
  }
271
251
  function onSelectOption(optionData) {
272
252
  const {
@@ -323,6 +303,17 @@ const SimpleSelect = exports.SimpleSelect = /*#__PURE__*/_react.default.forwardR
323
303
  ...(0, _utils.filterOutStyledSystemSpacingProps)(props)
324
304
  };
325
305
  }
306
+ let placement;
307
+ switch (listPlacement) {
308
+ case "top":
309
+ placement = "top-end";
310
+ break;
311
+ case "bottom":
312
+ placement = "bottom-end";
313
+ break;
314
+ default:
315
+ placement = listPlacement;
316
+ }
326
317
  const selectList = /*#__PURE__*/_react.default.createElement(_selectList.default, {
327
318
  ref: listboxRef,
328
319
  id: selectListId.current,
@@ -337,11 +328,12 @@ const SimpleSelect = exports.SimpleSelect = /*#__PURE__*/_react.default.forwardR
337
328
  onListScrollBottom: onListScrollBottom,
338
329
  tableHeader: tableHeader,
339
330
  multiColumn: multiColumn,
340
- listPlacement: listPlacement,
331
+ listPlacement: listWidth !== undefined ? placement : listPlacement,
341
332
  flipEnabled: flipEnabled,
342
333
  isOpen: isOpen,
343
334
  enableVirtualScroll: enableVirtualScroll,
344
- virtualScrollOverscan: virtualScrollOverscan
335
+ virtualScrollOverscan: virtualScrollOverscan,
336
+ listWidth: listWidth
345
337
  }, children);
346
338
  const marginProps = (0, _useFormSpacing.default)(props);
347
339
  return /*#__PURE__*/_react.default.createElement(_select.default, _extends({
@@ -495,7 +487,8 @@ if (process.env.NODE_ENV !== "production") {
495
487
  "leftChildren": _propTypes.default.node,
496
488
  "list": _propTypes.default.string,
497
489
  "listMaxHeight": _propTypes.default.number,
498
- "listPlacement": _propTypes.default.oneOf(["bottom", "left", "right", "top"]),
490
+ "listPlacement": _propTypes.default.oneOf(["bottom-end", "bottom-start", "bottom", "top-end", "top-start", "top"]),
491
+ "listWidth": _propTypes.default.number,
499
492
  "m": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
500
493
  "__@toStringTag": _propTypes.default.string.isRequired,
501
494
  "description": _propTypes.default.string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "142.13.5",
3
+ "version": "143.0.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",
@@ -184,7 +184,7 @@
184
184
  "@floating-ui/react-dom": "~1.3.0",
185
185
  "@octokit/rest": "^18.12.0",
186
186
  "@styled-system/prop-types": "^5.1.5",
187
- "@tanstack/react-virtual": "^3.0.0-beta.68",
187
+ "@tanstack/react-virtual": "^3.10.8",
188
188
  "@types/styled-system": "^5.1.22",
189
189
  "chalk": "^4.1.2",
190
190
  "ci-info": "^3.8.0",