@carbon/react 1.73.0-rc.0 → 1.74.0-rc.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 (50) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +888 -876
  2. package/es/components/Breadcrumb/BreadcrumbItem.js +1 -0
  3. package/es/components/ComposedModal/ComposedModal.js +8 -1
  4. package/es/components/DataTable/DataTable.d.ts +8 -2
  5. package/es/components/DataTable/DataTable.js +6 -1
  6. package/es/components/DataTable/TableCell.d.ts +1 -1
  7. package/es/components/DataTable/TableCell.js +2 -2
  8. package/es/components/DataTable/TableDecoratorRow.d.ts +33 -0
  9. package/es/components/DataTable/TableDecoratorRow.js +48 -0
  10. package/es/components/DataTable/TableExpandRow.js +9 -9
  11. package/es/components/DataTable/TableHeader.d.ts +6 -1
  12. package/es/components/DataTable/TableHeader.js +20 -11
  13. package/es/components/DataTable/TableRow.js +5 -5
  14. package/es/components/DataTable/TableSlugRow.js +5 -1
  15. package/es/components/DataTable/index.d.ts +2 -1
  16. package/es/components/DataTable/index.js +3 -0
  17. package/es/components/DataTable/tools/normalize.js +3 -2
  18. package/es/components/IconButton/index.d.ts +4 -0
  19. package/es/components/IconButton/index.js +4 -0
  20. package/es/components/IconIndicator/index.d.ts +29 -0
  21. package/es/components/IconIndicator/index.js +72 -0
  22. package/es/index.d.ts +1 -0
  23. package/es/index.js +2 -0
  24. package/es/prop-types/deprecateComponent.js +22 -0
  25. package/lib/components/Breadcrumb/BreadcrumbItem.js +1 -0
  26. package/lib/components/ComposedModal/ComposedModal.js +8 -1
  27. package/lib/components/DataTable/DataTable.d.ts +8 -2
  28. package/lib/components/DataTable/DataTable.js +6 -1
  29. package/lib/components/DataTable/TableCell.d.ts +1 -1
  30. package/lib/components/DataTable/TableCell.js +2 -2
  31. package/lib/components/DataTable/TableDecoratorRow.d.ts +33 -0
  32. package/lib/components/DataTable/TableDecoratorRow.js +58 -0
  33. package/lib/components/DataTable/TableExpandRow.js +9 -9
  34. package/lib/components/DataTable/TableHeader.d.ts +6 -1
  35. package/lib/components/DataTable/TableHeader.js +20 -11
  36. package/lib/components/DataTable/TableRow.js +5 -5
  37. package/lib/components/DataTable/TableSlugRow.js +4 -0
  38. package/lib/components/DataTable/index.d.ts +2 -1
  39. package/lib/components/DataTable/index.js +3 -0
  40. package/lib/components/DataTable/tools/normalize.js +3 -2
  41. package/lib/components/IconButton/index.d.ts +4 -0
  42. package/lib/components/IconButton/index.js +4 -0
  43. package/lib/components/IconIndicator/index.d.ts +29 -0
  44. package/lib/components/IconIndicator/index.js +84 -0
  45. package/lib/index.d.ts +1 -0
  46. package/lib/index.js +42 -38
  47. package/lib/prop-types/deprecateComponent.js +26 -0
  48. package/package.json +17 -16
  49. package/scss/components/icon-indicator/_icon-indicator.scss +9 -0
  50. package/scss/components/icon-indicator/_index.scss +9 -0
@@ -56,6 +56,7 @@ const BreadcrumbItem = /*#__PURE__*/React__default.forwardRef(function Breadcrum
56
56
  href: href,
57
57
  "aria-current": ariaCurrent || isCurrentPage
58
58
  }, children) : /*#__PURE__*/React__default.createElement(Text, {
59
+ "aria-current": ariaCurrent || isCurrentPage,
59
60
  className: `${prefix}--link`
60
61
  }, children));
61
62
  }
@@ -119,6 +119,7 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
119
119
  const button = useRef(null);
120
120
  const startSentinel = useRef(null);
121
121
  const endSentinel = useRef(null);
122
+ const onMouseDownTarget = useRef(null);
122
123
  const focusTrapWithoutSentinels = useFeatureFlag('enable-experimental-focus-wrap-without-sentinels');
123
124
 
124
125
  // Keep track of modal open/close state
@@ -151,10 +152,15 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
151
152
  }
152
153
  onKeyDown?.(event);
153
154
  }
155
+ function handleOnMouseDown(evt) {
156
+ const target = evt.target;
157
+ onMouseDownTarget.current = target;
158
+ }
154
159
  function handleOnClick(evt) {
155
160
  const target = evt.target;
161
+ const mouseDownTarget = onMouseDownTarget.current;
156
162
  evt.stopPropagation();
157
- if (!preventCloseOnClickOutside && !elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target)) {
163
+ if (!preventCloseOnClickOutside && !elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target) && !innerModal.current.contains(mouseDownTarget)) {
158
164
  closeModal(evt);
159
165
  }
160
166
  }
@@ -265,6 +271,7 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
265
271
  "aria-hidden": !open,
266
272
  onBlur: !focusTrapWithoutSentinels ? handleBlur : () => {},
267
273
  onClick: composeEventHandlers([rest?.onClick, handleOnClick]),
274
+ onMouseDown: composeEventHandlers([rest?.onMouseDown, handleOnMouseDown]),
268
275
  onKeyDown: handleKeyDown,
269
276
  className: modalClass
270
277
  }), /*#__PURE__*/React__default.createElement("div", {
@@ -15,6 +15,7 @@ import TableBatchActions from './TableBatchActions';
15
15
  import TableBody from './TableBody';
16
16
  import TableCell from './TableCell';
17
17
  import TableContainer from './TableContainer';
18
+ import TableDecoratorRow from './TableDecoratorRow';
18
19
  import TableExpandHeader from './TableExpandHeader';
19
20
  import TableExpandRow from './TableExpandRow';
20
21
  import TableExpandedRow from './TableExpandedRow';
@@ -70,6 +71,7 @@ export interface DataTableHeader {
70
71
  key: string;
71
72
  header: React.ReactNode;
72
73
  slug?: React.ReactElement;
74
+ decorator?: React.ReactElement;
73
75
  }
74
76
  export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
75
77
  headers: Array<DataTableHeader>;
@@ -174,7 +176,8 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
174
176
  cell: DataTableCell<ColTypes>;
175
177
  }) => {
176
178
  [key: string]: unknown;
177
- hasSlugHeader?: boolean;
179
+ hasAILabelHeader?: boolean;
180
+ hasDecoratorHeader?: boolean;
178
181
  };
179
182
  onInputChange: (e: React.ChangeEvent<HTMLInputElement>, defaultValue?: string) => void;
180
183
  sortBy: (headerKey: string) => void;
@@ -318,6 +321,7 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
318
321
  static TableBody: typeof TableBody;
319
322
  static TableCell: typeof TableCell;
320
323
  static TableContainer: typeof TableContainer;
324
+ static TableDecoratorRow: typeof TableDecoratorRow;
321
325
  static TableExpandHeader: typeof TableExpandHeader;
322
326
  static TableExpandRow: typeof TableExpandRow;
323
327
  static TableExpandedRow: typeof TableExpandedRow;
@@ -358,6 +362,7 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
358
362
  isSortable: boolean | undefined;
359
363
  isSortHeader: boolean;
360
364
  slug: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
365
+ decorator: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
361
366
  onClick: (event: any) => void;
362
367
  };
363
368
  /**
@@ -505,7 +510,8 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
505
510
  [x: string]: any;
506
511
  cell: any;
507
512
  }) => {
508
- hasSlugHeader: any;
513
+ hasAILabelHeader: any;
514
+ hasDecoratorHeader: any;
509
515
  };
510
516
  /**
511
517
  * Helper utility to get all the currently selected rows
@@ -23,6 +23,7 @@ import TableBatchActions from './TableBatchActions.js';
23
23
  import TableBody from './TableBody.js';
24
24
  import TableCell from './TableCell.js';
25
25
  import TableContainer from './TableContainer.js';
26
+ import TableDecoratorRow from './TableDecoratorRow.js';
26
27
  import TableExpandHeader from './TableExpandHeader.js';
27
28
  import TableExpandRow from './TableExpandRow.js';
28
29
  import TableExpandedRow from './TableExpandedRow.js';
@@ -109,6 +110,7 @@ class DataTable extends React__default.Component {
109
110
  isSortable,
110
111
  isSortHeader: sortHeaderKey === header.key,
111
112
  slug: header.slug,
113
+ decorator: header.decorator,
112
114
  onClick: event => {
113
115
  const nextSortState = getNextSortState(this.props, this.state, {
114
116
  key: header.key
@@ -363,7 +365,8 @@ class DataTable extends React__default.Component {
363
365
  } = _ref4;
364
366
  return {
365
367
  ...rest,
366
- hasSlugHeader: cell.hasSlugHeader
368
+ hasAILabelHeader: cell.hasAILabelHeader,
369
+ hasDecoratorHeader: cell.hasDecoratorHeader
367
370
  };
368
371
  });
369
372
  /**
@@ -743,6 +746,7 @@ _defineProperty(DataTable, "TableBatchActions", void 0);
743
746
  _defineProperty(DataTable, "TableBody", void 0);
744
747
  _defineProperty(DataTable, "TableCell", void 0);
745
748
  _defineProperty(DataTable, "TableContainer", void 0);
749
+ _defineProperty(DataTable, "TableDecoratorRow", void 0);
746
750
  _defineProperty(DataTable, "TableExpandHeader", void 0);
747
751
  _defineProperty(DataTable, "TableExpandRow", void 0);
748
752
  _defineProperty(DataTable, "TableExpandedRow", void 0);
@@ -764,6 +768,7 @@ DataTable.TableBatchActions = TableBatchActions;
764
768
  DataTable.TableBody = TableBody;
765
769
  DataTable.TableCell = TableCell;
766
770
  DataTable.TableContainer = TableContainer;
771
+ DataTable.TableDecoratorRow = TableDecoratorRow;
767
772
  DataTable.TableExpandHeader = TableExpandHeader;
768
773
  DataTable.TableExpandRow = TableExpandRow;
769
774
  DataTable.TableExpandedRow = TableExpandedRow;
@@ -22,7 +22,7 @@ interface TableCellProps extends ReactAttr<HTMLTableCellElement> {
22
22
  /**
23
23
  * Specify if the table cell is in an AI column
24
24
  */
25
- hasSlugHeader?: boolean;
25
+ hasAILabelHeader?: boolean;
26
26
  /**
27
27
  * The id of the matching th node in the table head. Addresses a11y concerns outlined here: https://www.ibm.com/able/guidelines/ci162/info_and_relationships.html and https://www.w3.org/TR/WCAG20-TECHS/H43
28
28
  */
@@ -14,13 +14,13 @@ const TableCell = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
14
14
  let {
15
15
  children,
16
16
  className,
17
- hasSlugHeader,
17
+ hasAILabelHeader,
18
18
  colSpan,
19
19
  ...rest
20
20
  } = _ref;
21
21
  const prefix = usePrefix();
22
22
  const tableCellClassNames = cx(className, {
23
- [`${prefix}--table-cell--column-slug`]: hasSlugHeader
23
+ [`${prefix}--table-cell--column-slug`]: hasAILabelHeader
24
24
  });
25
25
  return /*#__PURE__*/React__default.createElement("td", _extends({
26
26
  className: tableCellClassNames ? tableCellClassNames : undefined,
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import PropTypes from 'prop-types';
8
+ import { ReactNode } from 'react';
9
+ export interface TableDecoratorRowProps {
10
+ /**
11
+ * The CSS class names of the cell that wraps the underlying input control
12
+ */
13
+ className?: string;
14
+ /**
15
+ * **Experimental**: Provide a `decorator` component to be rendered inside the `TableDecoratorRow` component
16
+ */
17
+ decorator?: ReactNode;
18
+ }
19
+ declare const TableDecoratorRow: {
20
+ ({ className, decorator, }: TableDecoratorRowProps): import("react/jsx-runtime").JSX.Element;
21
+ displayName: string;
22
+ propTypes: {
23
+ /**
24
+ * The CSS class names of the cell that wraps the underlying input control
25
+ */
26
+ className: PropTypes.Requireable<string>;
27
+ /**
28
+ * **Experimental**: Provide a `decorator` component to be rendered inside the `TableDecoratorRow` component
29
+ */
30
+ decorator: PropTypes.Requireable<PropTypes.ReactNodeLike>;
31
+ };
32
+ };
33
+ export default TableDecoratorRow;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import PropTypes from 'prop-types';
9
+ import React__default from 'react';
10
+ import cx from 'classnames';
11
+ import { usePrefix } from '../../internal/usePrefix.js';
12
+
13
+ const TableDecoratorRow = _ref => {
14
+ let {
15
+ className,
16
+ decorator
17
+ } = _ref;
18
+ const prefix = usePrefix();
19
+ const TableDecoratorRowClasses = cx({
20
+ ...(className && {
21
+ [className]: true
22
+ }),
23
+ [`${prefix}--table-column-decorator`]: true,
24
+ [`${prefix}--table-column-decorator--active`]: decorator
25
+ });
26
+ let normalizedDecorator = /*#__PURE__*/React__default.isValidElement(decorator) ? decorator : null;
27
+ if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
28
+ normalizedDecorator = /*#__PURE__*/React__default.cloneElement(normalizedDecorator, {
29
+ size: 'mini'
30
+ });
31
+ }
32
+ return /*#__PURE__*/React__default.createElement("td", {
33
+ className: TableDecoratorRowClasses
34
+ }, normalizedDecorator);
35
+ };
36
+ TableDecoratorRow.displayName = 'TableDecoratorRow';
37
+ TableDecoratorRow.propTypes = {
38
+ /**
39
+ * The CSS class names of the cell that wraps the underlying input control
40
+ */
41
+ className: PropTypes.string,
42
+ /**
43
+ * **Experimental**: Provide a `decorator` component to be rendered inside the `TableDecoratorRow` component
44
+ */
45
+ decorator: PropTypes.node
46
+ };
47
+
48
+ export { TableDecoratorRow as default };
@@ -29,18 +29,18 @@ const TableExpandRow = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
29
29
  } = _ref;
30
30
  const prefix = usePrefix();
31
31
 
32
- // We need to put the slug before the expansion arrow and all other table cells after the arrow.
33
- let rowHasSlug;
34
- const slug = React__default.Children.toArray(children).map(child => {
35
- if (child.type?.displayName === 'TableSlugRow') {
36
- if (child.props.slug) {
37
- rowHasSlug = true;
32
+ // We need to put the AILabel and Decorator before the expansion arrow and all other table cells after the arrow.
33
+ let rowHasAILabel;
34
+ const decorator = React__default.Children.toArray(children).map(child => {
35
+ if (child.type?.displayName === 'TableSlugRow' || child.type?.displayName === 'TableDecoratorRow') {
36
+ if (child.props.slug || child.props.decorator?.type.displayName === 'AILabel') {
37
+ rowHasAILabel = true;
38
38
  }
39
39
  return child;
40
40
  }
41
41
  });
42
42
  const normalizedChildren = React__default.Children.toArray(children).map(child => {
43
- if (child.type?.displayName !== 'TableSlugRow') {
43
+ if (child.type?.displayName !== 'TableSlugRow' && child.type?.displayName !== 'TableDecoratorRow') {
44
44
  return child;
45
45
  }
46
46
  });
@@ -48,14 +48,14 @@ const TableExpandRow = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
48
48
  [`${prefix}--parent-row`]: true,
49
49
  [`${prefix}--expandable-row`]: isExpanded,
50
50
  [`${prefix}--data-table--selected`]: isSelected,
51
- [`${prefix}--data-table--slug-row`]: rowHasSlug
51
+ [`${prefix}--data-table--slug-row ${prefix}--data-table--ai-label-row`]: rowHasAILabel
52
52
  }, rowClassName);
53
53
  const previousValue = isExpanded ? 'collapsed' : undefined;
54
54
  return /*#__PURE__*/React__default.createElement("tr", _extends({}, rest, {
55
55
  ref: ref,
56
56
  className: className,
57
57
  "data-parent-row": true
58
- }), slug, /*#__PURE__*/React__default.createElement(TableCell, {
58
+ }), decorator, /*#__PURE__*/React__default.createElement(TableCell, {
59
59
  className: `${prefix}--table-expand`,
60
60
  "data-previous-value": previousValue,
61
61
  headers: expandHeader
@@ -58,9 +58,14 @@ interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonEl
58
58
  */
59
59
  scope?: string;
60
60
  /**
61
- * **Experimental**: Provide a `Slug` component to be rendered inside the `TableSlugRow` component
61
+ * @deprecated please use decorator instead.
62
+ * Provide a `Slug` component to be rendered inside the `TableSlugRow` component
62
63
  */
63
64
  slug?: ReactNode;
65
+ /**
66
+ * **Experimental**: Provide a `decorator` component to be rendered inside the `TableDecoratorRow` component
67
+ */
68
+ decorator?: ReactNode;
64
69
  /**
65
70
  * Specify which direction we are currently sorting by, should be one of DESC,
66
71
  * NONE, or ASC.
@@ -46,6 +46,7 @@ const TableHeader = /*#__PURE__*/React__default.forwardRef(function TableHeader(
46
46
  className: headerClassName,
47
47
  children,
48
48
  colSpan,
49
+ decorator,
49
50
  isSortable = false,
50
51
  isSortHeader,
51
52
  onClick,
@@ -59,18 +60,21 @@ const TableHeader = /*#__PURE__*/React__default.forwardRef(function TableHeader(
59
60
  const prefix = usePrefix();
60
61
  const uniqueId = useId('table-sort');
61
62
 
62
- // Slug is always size `mini`
63
- const slugRef = useRef(null);
64
- let normalizedSlug;
65
- if (slug) {
66
- normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
63
+ // AILabel is always size `mini`
64
+ const AILableRef = useRef(null);
65
+ let colHasAILabel;
66
+ let normalizedDecorator = /*#__PURE__*/React__default.isValidElement(slug ?? decorator) ? slug ?? decorator : null;
67
+ if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
68
+ colHasAILabel = true;
69
+ normalizedDecorator = /*#__PURE__*/React__default.cloneElement(normalizedDecorator, {
67
70
  size: 'mini',
68
- ref: slugRef
71
+ ref: AILableRef
69
72
  });
70
73
  }
71
74
  const headerLabelClassNames = cx({
72
75
  [`${prefix}--table-header-label`]: true,
73
- [`${prefix}--table-header-label--slug`]: slug
76
+ [`${prefix}--table-header-label--slug ${prefix}--table-header-label--ai-label`]: colHasAILabel,
77
+ [`${prefix}--table-header-label--decorator`]: decorator
74
78
  });
75
79
  if (!isSortable) {
76
80
  return /*#__PURE__*/React__default.createElement("th", _extends({}, rest, {
@@ -81,7 +85,9 @@ const TableHeader = /*#__PURE__*/React__default.forwardRef(function TableHeader(
81
85
  ref: ref
82
86
  }), children ? /*#__PURE__*/React__default.createElement("div", {
83
87
  className: headerLabelClassNames
84
- }, children, normalizedSlug) : null);
88
+ }, children, /*#__PURE__*/React__default.createElement("div", {
89
+ className: `${prefix}--table-header-label--decorator-inner`
90
+ }, normalizedDecorator)) : null);
85
91
  }
86
92
  const className = cx(headerClassName, {
87
93
  [`${prefix}--table-sort`]: true,
@@ -96,10 +102,11 @@ const TableHeader = /*#__PURE__*/React__default.forwardRef(function TableHeader(
96
102
  sortStates
97
103
  });
98
104
  const headerClasses = cx(headerClassName, `${prefix}--table-sort__header`, {
99
- [`${prefix}--table-sort__header--slug`]: slug
105
+ [`${prefix}--table-sort__header--ai-label`]: colHasAILabel,
106
+ [`${prefix}--table-sort__header--decorator`]: decorator
100
107
  });
101
108
  const handleClick = evt => {
102
- if (slug && slugRef.current && slugRef.current.contains(evt.target)) {
109
+ if (colHasAILabel && AILableRef.current && AILableRef.current.contains(evt.target)) {
103
110
  return;
104
111
  } else if (onClick) {
105
112
  return onClick(evt);
@@ -130,7 +137,9 @@ const TableHeader = /*#__PURE__*/React__default.forwardRef(function TableHeader(
130
137
  }), /*#__PURE__*/React__default.createElement(ArrowsVertical, {
131
138
  size: 20,
132
139
  className: `${prefix}--table-sort__icon-unsorted`
133
- }), normalizedSlug)));
140
+ }), /*#__PURE__*/React__default.createElement("div", {
141
+ className: `${prefix}--table-header-label--decorator-inner`
142
+ }, normalizedDecorator))));
134
143
  });
135
144
  TableHeader.propTypes = {
136
145
  /**
@@ -12,12 +12,12 @@ import { usePrefix } from '../../internal/usePrefix.js';
12
12
 
13
13
  const TableRow = props => {
14
14
  const prefix = usePrefix();
15
- let rowHasSlug;
15
+ let rowHasAILabel;
16
16
  if (props?.children) {
17
17
  React__default.Children.toArray(props.children).map(child => {
18
- if (child.type?.displayName === 'TableSlugRow') {
19
- if (child.props.slug) {
20
- rowHasSlug = true;
18
+ if (child.type?.displayName === 'TableSlugRow' || child.type?.displayName === 'TableDecoratorRow') {
19
+ if (child.props.slug || child.props.decorator?.type.displayName === 'AILabel') {
20
+ rowHasAILabel = true;
21
21
  }
22
22
  }
23
23
  });
@@ -26,7 +26,7 @@ const TableRow = props => {
26
26
  // only useful in `TableExpandRow`
27
27
  const className = cx(props.className, {
28
28
  [`${prefix}--data-table--selected`]: props.isSelected,
29
- [`${prefix}--data-table--slug-row`]: rowHasSlug
29
+ [`${prefix}--data-table--slug-row ${prefix}--data-table--ai-label-row`]: rowHasAILabel
30
30
  });
31
31
  const {
32
32
  ariaLabel,
@@ -6,15 +6,19 @@
6
6
  */
7
7
 
8
8
  import PropTypes from 'prop-types';
9
- import React__default from 'react';
9
+ import React__default, { useEffect } from 'react';
10
10
  import cx from 'classnames';
11
11
  import { usePrefix } from '../../internal/usePrefix.js';
12
+ import deprecateComponent from '../../prop-types/deprecateComponent.js';
12
13
 
13
14
  const TableSlugRow = _ref => {
14
15
  let {
15
16
  className,
16
17
  slug
17
18
  } = _ref;
19
+ useEffect(() => {
20
+ deprecateComponent('TableSlugRow', 'The `TableSlugRow` component has been deprecated and will be removed in the next major version. Use the TableDecoratorRow component instead.');
21
+ }, []);
18
22
  const prefix = usePrefix();
19
23
  const TableSlugRowClasses = cx({
20
24
  ...(className && {
@@ -13,6 +13,7 @@ import TableBody from './TableBody';
13
13
  import TableCell from './TableCell';
14
14
  import TableContainer from './TableContainer';
15
15
  import TableExpandHeader from './TableExpandHeader';
16
+ import TableDecoratorRow from './TableDecoratorRow';
16
17
  import TableExpandRow from './TableExpandRow';
17
18
  import TableExpandedRow from './TableExpandedRow';
18
19
  import TableHead from './TableHead';
@@ -27,5 +28,5 @@ import TableToolbarContent from './TableToolbarContent';
27
28
  import TableToolbarSearch from './TableToolbarSearch';
28
29
  import TableToolbarMenu from './TableToolbarMenu';
29
30
  import type { DataTableSortState } from './state/sortStates';
30
- export { DataTable, type DataTableCell, type DataTableHeader, type DataTableProps, type DataTableRenderProps, type DataTableSortState, type DataTableRow, type DataTableSize, Table, TableActionList, TableBatchAction, TableBatchActions, TableBody, TableCell, TableContainer, TableExpandHeader, TableExpandRow, TableExpandedRow, TableHead, TableHeader, type TableHeaderTranslationKey, type TableHeaderTranslationArgs, TableRow, TableSelectAll, TableSelectRow, TableSlugRow, TableToolbar, TableToolbarAction, TableToolbarContent, TableToolbarSearch, TableToolbarMenu, };
31
+ export { DataTable, type DataTableCell, type DataTableHeader, type DataTableProps, type DataTableRenderProps, type DataTableSortState, type DataTableRow, type DataTableSize, Table, TableActionList, TableBatchAction, TableBatchActions, TableBody, TableCell, TableContainer, TableDecoratorRow, TableExpandHeader, TableExpandRow, TableExpandedRow, TableHead, TableHeader, type TableHeaderTranslationKey, type TableHeaderTranslationArgs, TableRow, TableSelectAll, TableSelectRow, TableSlugRow, TableToolbar, TableToolbarAction, TableToolbarContent, TableToolbarSearch, TableToolbarMenu, };
31
32
  export default DataTable;
@@ -23,6 +23,8 @@ import TableContainer from './TableContainer.js';
23
23
  export { default as TableContainer } from './TableContainer.js';
24
24
  import TableExpandHeader from './TableExpandHeader.js';
25
25
  export { default as TableExpandHeader } from './TableExpandHeader.js';
26
+ import TableDecoratorRow from './TableDecoratorRow.js';
27
+ export { default as TableDecoratorRow } from './TableDecoratorRow.js';
26
28
  import TableExpandRow from './TableExpandRow.js';
27
29
  export { default as TableExpandRow } from './TableExpandRow.js';
28
30
  import TableExpandedRow from './TableExpandedRow.js';
@@ -57,6 +59,7 @@ DataTable.TableBatchActions = TableBatchActions;
57
59
  DataTable.TableBody = TableBody;
58
60
  DataTable.TableCell = TableCell;
59
61
  DataTable.TableContainer = TableContainer;
62
+ DataTable.TableDecoratorRow = TableDecoratorRow;
60
63
  DataTable.TableExpandHeader = TableExpandHeader;
61
64
  DataTable.TableExpandRow = TableExpandRow;
62
65
  DataTable.TableExpandedRow = TableExpandedRow;
@@ -49,7 +49,8 @@ const normalize = function (rows, headers) {
49
49
  headers.forEach((_ref, i) => {
50
50
  let {
51
51
  key,
52
- slug
52
+ slug,
53
+ decorator
53
54
  } = _ref;
54
55
  const id = getCellId(row.id, key);
55
56
  // Initialize the cell info and state values, namely for editing
@@ -60,7 +61,7 @@ const normalize = function (rows, headers) {
60
61
  isEditing: false,
61
62
  isValid: true,
62
63
  errors: null,
63
- hasSlugHeader: !!slug,
64
+ hasAILabelHeader: !!(slug || decorator?.type?.displayName === 'AILabel'),
64
65
  info: {
65
66
  header: key
66
67
  }
@@ -20,6 +20,10 @@ interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>
20
20
  * **Experimental**: Will attempt to automatically align the tooltip
21
21
  */
22
22
  autoAlign?: boolean;
23
+ /**
24
+ * Optionally specify an href for your IconButton to become an `<a>` element
25
+ */
26
+ href?: string;
23
27
  /**
24
28
  * Provide an icon or asset to be rendered inside of the IconButton
25
29
  */
@@ -104,6 +104,10 @@ IconButton.propTypes = {
104
104
  * **Experimental**: Will attempt to automatically align the tooltip
105
105
  */
106
106
  autoAlign: PropTypes.bool,
107
+ /**
108
+ * Optionally specify an href for your IconButton to become an `<a>` element
109
+ */
110
+ href: PropTypes.string,
107
111
  /**
108
112
  * Provide an icon or asset to be rendered inside of the IconButton
109
113
  */
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ export declare const IconIndicatorKinds: string[];
9
+ export type IconIndicatorKind = (typeof IconIndicatorKinds)[number];
10
+ interface IconIndicatorProps {
11
+ /**
12
+ * Specify an optional className to add.
13
+ */
14
+ className?: string;
15
+ /**
16
+ * Specify the kind of icon to be used
17
+ */
18
+ kind: IconIndicatorKind;
19
+ /**
20
+ * Label next to the icon
21
+ */
22
+ label: string;
23
+ /**
24
+ * Specify the size of the Icon Indicator. Defaults to 16.
25
+ */
26
+ size?: 16 | 20;
27
+ }
28
+ export declare const IconIndicator: React.ForwardRefExoticComponent<IconIndicatorProps & React.RefAttributes<HTMLDivElement>>;
29
+ export default IconIndicator;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import PropTypes from 'prop-types';
9
+ import React__default from 'react';
10
+ import cx from 'classnames';
11
+ import { usePrefix } from '../../internal/usePrefix.js';
12
+ import { ErrorFilled, WarningAltInvertedFilled, WarningAltFilled, UndefinedFilled, CheckmarkFilled, CheckmarkOutline, InProgress, Incomplete, CircleDash, PendingFilled, UnknownFilled, WarningSquareFilled } from '@carbon/icons-react';
13
+
14
+ const IconIndicatorKinds = ['failed', 'caution-major', 'caution-minor', 'undefined', 'succeeded', 'normal', 'in-progress', 'incomplete', 'not-started', 'pending', 'unknown', 'informative'];
15
+ const iconTypes = {
16
+ failed: ErrorFilled,
17
+ ['caution-major']: WarningAltInvertedFilled,
18
+ ['caution-minor']: WarningAltFilled,
19
+ undefined: UndefinedFilled,
20
+ succeeded: CheckmarkFilled,
21
+ normal: CheckmarkOutline,
22
+ ['in-progress']: InProgress,
23
+ incomplete: Incomplete,
24
+ ['not-started']: CircleDash,
25
+ pending: PendingFilled,
26
+ unknown: UnknownFilled,
27
+ informative: WarningSquareFilled
28
+ };
29
+ const IconIndicator = /*#__PURE__*/React__default.forwardRef(function IconIndicatorContent(_ref, ref) {
30
+ let {
31
+ className: customClassName,
32
+ kind,
33
+ label,
34
+ size = 16,
35
+ ...rest
36
+ } = _ref;
37
+ const prefix = usePrefix();
38
+ const classNames = cx(`${prefix}--icon-indicator`, customClassName, {
39
+ [`${prefix}--icon-indicator--20`]: size == 20
40
+ });
41
+ const IconForKind = iconTypes[kind];
42
+ if (!IconForKind) {
43
+ return null;
44
+ }
45
+ return /*#__PURE__*/React__default.createElement("div", {
46
+ className: classNames,
47
+ ref: ref
48
+ }, /*#__PURE__*/React__default.createElement(IconForKind, {
49
+ size: size,
50
+ className: `${prefix}--icon-indicator--${kind}`
51
+ }), label);
52
+ });
53
+ IconIndicator.propTypes = {
54
+ /**
55
+ * Specify an optional className to add.
56
+ */
57
+ className: PropTypes.string,
58
+ /**
59
+ * Specify the kind of the Icon Indicator
60
+ */
61
+ kind: PropTypes.oneOf(IconIndicatorKinds).isRequired,
62
+ /**
63
+ * Label next to the icon.
64
+ */
65
+ label: PropTypes.string.isRequired,
66
+ /**
67
+ * Specify the size of the Icon Indicator. Defaults to 16.
68
+ */
69
+ size: PropTypes.oneOf([16, 20])
70
+ };
71
+
72
+ export { IconIndicator, IconIndicatorKinds, IconIndicator as default };
package/es/index.d.ts CHANGED
@@ -128,3 +128,4 @@ export * from './components/Tooltip/DefinitionTooltip';
128
128
  export * from './components/Theme';
129
129
  export * from './internal/usePrefix';
130
130
  export { useIdPrefix } from './internal/useIdPrefix';
131
+ export { IconIndicator as unstable__IconIndicator } from './components/IconIndicator';
package/es/index.js CHANGED
@@ -201,6 +201,7 @@ import './components/Text/index.js';
201
201
  export { GlobalTheme, Theme, ThemeContext, usePrefersDarkScheme, useTheme } from './components/Theme/index.js';
202
202
  export { PrefixContext, usePrefix } from './internal/usePrefix.js';
203
203
  export { useIdPrefix } from './internal/useIdPrefix.js';
204
+ export { IconIndicator as unstable__IconIndicator } from './components/IconIndicator/index.js';
204
205
  export { default as unstable_PageSelector } from './components/Pagination/experimental/PageSelector.js';
205
206
  export { default as unstable_Pagination } from './components/Pagination/experimental/Pagination.js';
206
207
  export { default as ContainedListItem } from './components/ContainedList/ContainedListItem/ContainedListItem.js';
@@ -220,6 +221,7 @@ export { default as TableBatchActions } from './components/DataTable/TableBatchA
220
221
  export { default as TableBody } from './components/DataTable/TableBody.js';
221
222
  export { default as TableCell } from './components/DataTable/TableCell.js';
222
223
  export { default as TableContainer } from './components/DataTable/TableContainer.js';
224
+ export { default as TableDecoratorRow } from './components/DataTable/TableDecoratorRow.js';
223
225
  export { default as TableExpandHeader } from './components/DataTable/TableExpandHeader.js';
224
226
  export { default as TableExpandRow } from './components/DataTable/TableExpandRow.js';
225
227
  export { default as TableExpandedRow } from './components/DataTable/TableExpandedRow.js';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { warning } from '../internal/warning.js';
9
+
10
+ const didWarnAboutDeprecation = {};
11
+ function deprecateComponent(componentName, message) {
12
+ if (!componentName) {
13
+ return;
14
+ }
15
+ if (!didWarnAboutDeprecation[componentName]) {
16
+ didWarnAboutDeprecation[componentName] = true;
17
+ process.env.NODE_ENV !== "production" ? warning(false, message || `The ${componentName} component has been deprecated and will be removed in the next major release.`) : void 0;
18
+ }
19
+ return componentName;
20
+ }
21
+
22
+ export { deprecateComponent as default };