@carbon/react 1.73.0-rc.0 → 1.73.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 (34) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +863 -863
  2. package/es/components/DataTable/DataTable.d.ts +8 -2
  3. package/es/components/DataTable/DataTable.js +6 -1
  4. package/es/components/DataTable/TableCell.d.ts +1 -1
  5. package/es/components/DataTable/TableCell.js +2 -2
  6. package/es/components/DataTable/TableDecoratorRow.d.ts +33 -0
  7. package/es/components/DataTable/TableDecoratorRow.js +48 -0
  8. package/es/components/DataTable/TableExpandRow.js +9 -9
  9. package/es/components/DataTable/TableHeader.d.ts +6 -1
  10. package/es/components/DataTable/TableHeader.js +20 -11
  11. package/es/components/DataTable/TableRow.js +5 -5
  12. package/es/components/DataTable/TableSlugRow.js +5 -1
  13. package/es/components/DataTable/index.d.ts +2 -1
  14. package/es/components/DataTable/index.js +3 -0
  15. package/es/components/DataTable/tools/normalize.js +3 -2
  16. package/es/index.js +1 -0
  17. package/es/prop-types/deprecateComponent.js +22 -0
  18. package/lib/components/DataTable/DataTable.d.ts +8 -2
  19. package/lib/components/DataTable/DataTable.js +6 -1
  20. package/lib/components/DataTable/TableCell.d.ts +1 -1
  21. package/lib/components/DataTable/TableCell.js +2 -2
  22. package/lib/components/DataTable/TableDecoratorRow.d.ts +33 -0
  23. package/lib/components/DataTable/TableDecoratorRow.js +58 -0
  24. package/lib/components/DataTable/TableExpandRow.js +9 -9
  25. package/lib/components/DataTable/TableHeader.d.ts +6 -1
  26. package/lib/components/DataTable/TableHeader.js +20 -11
  27. package/lib/components/DataTable/TableRow.js +5 -5
  28. package/lib/components/DataTable/TableSlugRow.js +4 -0
  29. package/lib/components/DataTable/index.d.ts +2 -1
  30. package/lib/components/DataTable/index.js +3 -0
  31. package/lib/components/DataTable/tools/normalize.js +3 -2
  32. package/lib/index.js +2 -0
  33. package/lib/prop-types/deprecateComponent.js +26 -0
  34. package/package.json +4 -4
@@ -0,0 +1,58 @@
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
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var PropTypes = require('prop-types');
13
+ var React = require('react');
14
+ var cx = require('classnames');
15
+ var usePrefix = require('../../internal/usePrefix.js');
16
+
17
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
+
19
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
20
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
21
+ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
22
+
23
+ const TableDecoratorRow = _ref => {
24
+ let {
25
+ className,
26
+ decorator
27
+ } = _ref;
28
+ const prefix = usePrefix.usePrefix();
29
+ const TableDecoratorRowClasses = cx__default["default"]({
30
+ ...(className && {
31
+ [className]: true
32
+ }),
33
+ [`${prefix}--table-column-decorator`]: true,
34
+ [`${prefix}--table-column-decorator--active`]: decorator
35
+ });
36
+ let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(decorator) ? decorator : null;
37
+ if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
38
+ normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
39
+ size: 'mini'
40
+ });
41
+ }
42
+ return /*#__PURE__*/React__default["default"].createElement("td", {
43
+ className: TableDecoratorRowClasses
44
+ }, normalizedDecorator);
45
+ };
46
+ TableDecoratorRow.displayName = 'TableDecoratorRow';
47
+ TableDecoratorRow.propTypes = {
48
+ /**
49
+ * The CSS class names of the cell that wraps the underlying input control
50
+ */
51
+ className: PropTypes__default["default"].string,
52
+ /**
53
+ * **Experimental**: Provide a `decorator` component to be rendered inside the `TableDecoratorRow` component
54
+ */
55
+ decorator: PropTypes__default["default"].node
56
+ };
57
+
58
+ exports["default"] = TableDecoratorRow;
@@ -39,18 +39,18 @@ const TableExpandRow = /*#__PURE__*/React__default["default"].forwardRef((_ref,
39
39
  } = _ref;
40
40
  const prefix = usePrefix.usePrefix();
41
41
 
42
- // We need to put the slug before the expansion arrow and all other table cells after the arrow.
43
- let rowHasSlug;
44
- const slug = React__default["default"].Children.toArray(children).map(child => {
45
- if (child.type?.displayName === 'TableSlugRow') {
46
- if (child.props.slug) {
47
- rowHasSlug = true;
42
+ // We need to put the AILabel and Decorator before the expansion arrow and all other table cells after the arrow.
43
+ let rowHasAILabel;
44
+ const decorator = React__default["default"].Children.toArray(children).map(child => {
45
+ if (child.type?.displayName === 'TableSlugRow' || child.type?.displayName === 'TableDecoratorRow') {
46
+ if (child.props.slug || child.props.decorator?.type.displayName === 'AILabel') {
47
+ rowHasAILabel = true;
48
48
  }
49
49
  return child;
50
50
  }
51
51
  });
52
52
  const normalizedChildren = React__default["default"].Children.toArray(children).map(child => {
53
- if (child.type?.displayName !== 'TableSlugRow') {
53
+ if (child.type?.displayName !== 'TableSlugRow' && child.type?.displayName !== 'TableDecoratorRow') {
54
54
  return child;
55
55
  }
56
56
  });
@@ -58,14 +58,14 @@ const TableExpandRow = /*#__PURE__*/React__default["default"].forwardRef((_ref,
58
58
  [`${prefix}--parent-row`]: true,
59
59
  [`${prefix}--expandable-row`]: isExpanded,
60
60
  [`${prefix}--data-table--selected`]: isSelected,
61
- [`${prefix}--data-table--slug-row`]: rowHasSlug
61
+ [`${prefix}--data-table--slug-row ${prefix}--data-table--ai-label-row`]: rowHasAILabel
62
62
  }, rowClassName);
63
63
  const previousValue = isExpanded ? 'collapsed' : undefined;
64
64
  return /*#__PURE__*/React__default["default"].createElement("tr", _rollupPluginBabelHelpers["extends"]({}, rest, {
65
65
  ref: ref,
66
66
  className: className,
67
67
  "data-parent-row": true
68
- }), slug, /*#__PURE__*/React__default["default"].createElement(TableCell["default"], {
68
+ }), decorator, /*#__PURE__*/React__default["default"].createElement(TableCell["default"], {
69
69
  className: `${prefix}--table-expand`,
70
70
  "data-previous-value": previousValue,
71
71
  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.
@@ -56,6 +56,7 @@ const TableHeader = /*#__PURE__*/React__default["default"].forwardRef(function T
56
56
  className: headerClassName,
57
57
  children,
58
58
  colSpan,
59
+ decorator,
59
60
  isSortable = false,
60
61
  isSortHeader,
61
62
  onClick,
@@ -69,18 +70,21 @@ const TableHeader = /*#__PURE__*/React__default["default"].forwardRef(function T
69
70
  const prefix = usePrefix.usePrefix();
70
71
  const uniqueId = useId.useId('table-sort');
71
72
 
72
- // Slug is always size `mini`
73
- const slugRef = React.useRef(null);
74
- let normalizedSlug;
75
- if (slug) {
76
- normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
73
+ // AILabel is always size `mini`
74
+ const AILableRef = React.useRef(null);
75
+ let colHasAILabel;
76
+ let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
77
+ if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
78
+ colHasAILabel = true;
79
+ normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
77
80
  size: 'mini',
78
- ref: slugRef
81
+ ref: AILableRef
79
82
  });
80
83
  }
81
84
  const headerLabelClassNames = cx__default["default"]({
82
85
  [`${prefix}--table-header-label`]: true,
83
- [`${prefix}--table-header-label--slug`]: slug
86
+ [`${prefix}--table-header-label--slug ${prefix}--table-header-label--ai-label`]: colHasAILabel,
87
+ [`${prefix}--table-header-label--decorator`]: decorator
84
88
  });
85
89
  if (!isSortable) {
86
90
  return /*#__PURE__*/React__default["default"].createElement("th", _rollupPluginBabelHelpers["extends"]({}, rest, {
@@ -91,7 +95,9 @@ const TableHeader = /*#__PURE__*/React__default["default"].forwardRef(function T
91
95
  ref: ref
92
96
  }), children ? /*#__PURE__*/React__default["default"].createElement("div", {
93
97
  className: headerLabelClassNames
94
- }, children, normalizedSlug) : null);
98
+ }, children, /*#__PURE__*/React__default["default"].createElement("div", {
99
+ className: `${prefix}--table-header-label--decorator-inner`
100
+ }, normalizedDecorator)) : null);
95
101
  }
96
102
  const className = cx__default["default"](headerClassName, {
97
103
  [`${prefix}--table-sort`]: true,
@@ -106,10 +112,11 @@ const TableHeader = /*#__PURE__*/React__default["default"].forwardRef(function T
106
112
  sortStates: sortStates.sortStates
107
113
  });
108
114
  const headerClasses = cx__default["default"](headerClassName, `${prefix}--table-sort__header`, {
109
- [`${prefix}--table-sort__header--slug`]: slug
115
+ [`${prefix}--table-sort__header--ai-label`]: colHasAILabel,
116
+ [`${prefix}--table-sort__header--decorator`]: decorator
110
117
  });
111
118
  const handleClick = evt => {
112
- if (slug && slugRef.current && slugRef.current.contains(evt.target)) {
119
+ if (colHasAILabel && AILableRef.current && AILableRef.current.contains(evt.target)) {
113
120
  return;
114
121
  } else if (onClick) {
115
122
  return onClick(evt);
@@ -140,7 +147,9 @@ const TableHeader = /*#__PURE__*/React__default["default"].forwardRef(function T
140
147
  }), /*#__PURE__*/React__default["default"].createElement(iconsReact.ArrowsVertical, {
141
148
  size: 20,
142
149
  className: `${prefix}--table-sort__icon-unsorted`
143
- }), normalizedSlug)));
150
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
151
+ className: `${prefix}--table-header-label--decorator-inner`
152
+ }, normalizedDecorator))));
144
153
  });
145
154
  TableHeader.propTypes = {
146
155
  /**
@@ -22,12 +22,12 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
22
22
 
23
23
  const TableRow = props => {
24
24
  const prefix = usePrefix.usePrefix();
25
- let rowHasSlug;
25
+ let rowHasAILabel;
26
26
  if (props?.children) {
27
27
  React__default["default"].Children.toArray(props.children).map(child => {
28
- if (child.type?.displayName === 'TableSlugRow') {
29
- if (child.props.slug) {
30
- rowHasSlug = true;
28
+ if (child.type?.displayName === 'TableSlugRow' || child.type?.displayName === 'TableDecoratorRow') {
29
+ if (child.props.slug || child.props.decorator?.type.displayName === 'AILabel') {
30
+ rowHasAILabel = true;
31
31
  }
32
32
  }
33
33
  });
@@ -36,7 +36,7 @@ const TableRow = props => {
36
36
  // only useful in `TableExpandRow`
37
37
  const className = cx__default["default"](props.className, {
38
38
  [`${prefix}--data-table--selected`]: props.isSelected,
39
- [`${prefix}--data-table--slug-row`]: rowHasSlug
39
+ [`${prefix}--data-table--slug-row ${prefix}--data-table--ai-label-row`]: rowHasAILabel
40
40
  });
41
41
  const {
42
42
  ariaLabel,
@@ -13,6 +13,7 @@ var PropTypes = require('prop-types');
13
13
  var React = require('react');
14
14
  var cx = require('classnames');
15
15
  var usePrefix = require('../../internal/usePrefix.js');
16
+ var deprecateComponent = require('../../prop-types/deprecateComponent.js');
16
17
 
17
18
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
19
 
@@ -25,6 +26,9 @@ const TableSlugRow = _ref => {
25
26
  className,
26
27
  slug
27
28
  } = _ref;
29
+ React.useEffect(() => {
30
+ deprecateComponent["default"]('TableSlugRow', 'The `TableSlugRow` component has been deprecated and will be removed in the next major version. Use the TableDecoratorRow component instead.');
31
+ }, []);
28
32
  const prefix = usePrefix.usePrefix();
29
33
  const TableSlugRowClasses = cx__default["default"]({
30
34
  ...(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;
@@ -18,6 +18,7 @@ var TableBody = require('./TableBody.js');
18
18
  var TableCell = require('./TableCell.js');
19
19
  var TableContainer = require('./TableContainer.js');
20
20
  var TableExpandHeader = require('./TableExpandHeader.js');
21
+ var TableDecoratorRow = require('./TableDecoratorRow.js');
21
22
  var TableExpandRow = require('./TableExpandRow.js');
22
23
  var TableExpandedRow = require('./TableExpandedRow.js');
23
24
  var TableHead = require('./TableHead.js');
@@ -39,6 +40,7 @@ DataTable["default"].TableBatchActions = TableBatchActions["default"];
39
40
  DataTable["default"].TableBody = TableBody["default"];
40
41
  DataTable["default"].TableCell = TableCell["default"];
41
42
  DataTable["default"].TableContainer = TableContainer["default"];
43
+ DataTable["default"].TableDecoratorRow = TableDecoratorRow["default"];
42
44
  DataTable["default"].TableExpandHeader = TableExpandHeader["default"];
43
45
  DataTable["default"].TableExpandRow = TableExpandRow["default"];
44
46
  DataTable["default"].TableExpandedRow = TableExpandedRow["default"];
@@ -64,6 +66,7 @@ exports.TableBody = TableBody["default"];
64
66
  exports.TableCell = TableCell["default"];
65
67
  exports.TableContainer = TableContainer["default"];
66
68
  exports.TableExpandHeader = TableExpandHeader["default"];
69
+ exports.TableDecoratorRow = TableDecoratorRow["default"];
67
70
  exports.TableExpandRow = TableExpandRow["default"];
68
71
  exports.TableExpandedRow = TableExpandedRow["default"];
69
72
  exports.TableHead = TableHead["default"];
@@ -53,7 +53,8 @@ const normalize = function (rows, headers) {
53
53
  headers.forEach((_ref, i) => {
54
54
  let {
55
55
  key,
56
- slug
56
+ slug,
57
+ decorator
57
58
  } = _ref;
58
59
  const id = cells.getCellId(row.id, key);
59
60
  // Initialize the cell info and state values, namely for editing
@@ -64,7 +65,7 @@ const normalize = function (rows, headers) {
64
65
  isEditing: false,
65
66
  isValid: true,
66
67
  errors: null,
67
- hasSlugHeader: !!slug,
68
+ hasAILabelHeader: !!(slug || decorator?.type?.displayName === 'AILabel'),
68
69
  info: {
69
70
  header: key
70
71
  }
package/lib/index.js CHANGED
@@ -224,6 +224,7 @@ var TableBatchActions = require('./components/DataTable/TableBatchActions.js');
224
224
  var TableBody = require('./components/DataTable/TableBody.js');
225
225
  var TableCell = require('./components/DataTable/TableCell.js');
226
226
  var TableContainer = require('./components/DataTable/TableContainer.js');
227
+ var TableDecoratorRow = require('./components/DataTable/TableDecoratorRow.js');
227
228
  var TableExpandHeader = require('./components/DataTable/TableExpandHeader.js');
228
229
  var TableExpandRow = require('./components/DataTable/TableExpandRow.js');
229
230
  var TableExpandedRow = require('./components/DataTable/TableExpandedRow.js');
@@ -507,6 +508,7 @@ exports.TableBatchActions = TableBatchActions["default"];
507
508
  exports.TableBody = TableBody["default"];
508
509
  exports.TableCell = TableCell["default"];
509
510
  exports.TableContainer = TableContainer["default"];
511
+ exports.TableDecoratorRow = TableDecoratorRow["default"];
510
512
  exports.TableExpandHeader = TableExpandHeader["default"];
511
513
  exports.TableExpandRow = TableExpandRow["default"];
512
514
  exports.TableExpandedRow = TableExpandedRow["default"];
@@ -0,0 +1,26 @@
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
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var warning = require('../internal/warning.js');
13
+
14
+ const didWarnAboutDeprecation = {};
15
+ function deprecateComponent(componentName, message) {
16
+ if (!componentName) {
17
+ return;
18
+ }
19
+ if (!didWarnAboutDeprecation[componentName]) {
20
+ didWarnAboutDeprecation[componentName] = true;
21
+ process.env.NODE_ENV !== "production" ? warning.warning(false, message || `The ${componentName} component has been deprecated and will be removed in the next major release.`) : void 0;
22
+ }
23
+ return componentName;
24
+ }
25
+
26
+ exports["default"] = deprecateComponent;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/react",
3
3
  "description": "React components for the Carbon Design System",
4
- "version": "1.73.0-rc.0",
4
+ "version": "1.73.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -52,7 +52,7 @@
52
52
  "@carbon/feature-flags": "^0.24.0",
53
53
  "@carbon/icons-react": "^11.53.0",
54
54
  "@carbon/layout": "^11.28.0",
55
- "@carbon/styles": "^1.72.0-rc.0",
55
+ "@carbon/styles": "^1.72.0",
56
56
  "@floating-ui/react": "^0.26.0",
57
57
  "@ibm/telemetry-js": "^1.5.0",
58
58
  "classnames": "2.5.1",
@@ -78,7 +78,7 @@
78
78
  "@babel/preset-react": "^7.24.7",
79
79
  "@babel/preset-typescript": "^7.24.7",
80
80
  "@carbon/test-utils": "^10.34.0",
81
- "@carbon/themes": "^11.44.0-rc.0",
81
+ "@carbon/themes": "^11.44.0",
82
82
  "@figma/code-connect": "^1.2.4",
83
83
  "@rollup/plugin-babel": "^6.0.0",
84
84
  "@rollup/plugin-commonjs": "^28.0.0",
@@ -143,5 +143,5 @@
143
143
  "**/*.scss",
144
144
  "**/*.css"
145
145
  ],
146
- "gitHead": "7b6d921583ff275baace5baa66da9d9b31740fa8"
146
+ "gitHead": "97fc2e65d5d78f3bc191f036cb669b072db1d85f"
147
147
  }