@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.
- package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +888 -876
- package/es/components/Breadcrumb/BreadcrumbItem.js +1 -0
- package/es/components/ComposedModal/ComposedModal.js +8 -1
- package/es/components/DataTable/DataTable.d.ts +8 -2
- package/es/components/DataTable/DataTable.js +6 -1
- package/es/components/DataTable/TableCell.d.ts +1 -1
- package/es/components/DataTable/TableCell.js +2 -2
- package/es/components/DataTable/TableDecoratorRow.d.ts +33 -0
- package/es/components/DataTable/TableDecoratorRow.js +48 -0
- package/es/components/DataTable/TableExpandRow.js +9 -9
- package/es/components/DataTable/TableHeader.d.ts +6 -1
- package/es/components/DataTable/TableHeader.js +20 -11
- package/es/components/DataTable/TableRow.js +5 -5
- package/es/components/DataTable/TableSlugRow.js +5 -1
- package/es/components/DataTable/index.d.ts +2 -1
- package/es/components/DataTable/index.js +3 -0
- package/es/components/DataTable/tools/normalize.js +3 -2
- package/es/components/IconButton/index.d.ts +4 -0
- package/es/components/IconButton/index.js +4 -0
- package/es/components/IconIndicator/index.d.ts +29 -0
- package/es/components/IconIndicator/index.js +72 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -0
- package/es/prop-types/deprecateComponent.js +22 -0
- package/lib/components/Breadcrumb/BreadcrumbItem.js +1 -0
- package/lib/components/ComposedModal/ComposedModal.js +8 -1
- package/lib/components/DataTable/DataTable.d.ts +8 -2
- package/lib/components/DataTable/DataTable.js +6 -1
- package/lib/components/DataTable/TableCell.d.ts +1 -1
- package/lib/components/DataTable/TableCell.js +2 -2
- package/lib/components/DataTable/TableDecoratorRow.d.ts +33 -0
- package/lib/components/DataTable/TableDecoratorRow.js +58 -0
- package/lib/components/DataTable/TableExpandRow.js +9 -9
- package/lib/components/DataTable/TableHeader.d.ts +6 -1
- package/lib/components/DataTable/TableHeader.js +20 -11
- package/lib/components/DataTable/TableRow.js +5 -5
- package/lib/components/DataTable/TableSlugRow.js +4 -0
- package/lib/components/DataTable/index.d.ts +2 -1
- package/lib/components/DataTable/index.js +3 -0
- package/lib/components/DataTable/tools/normalize.js +3 -2
- package/lib/components/IconButton/index.d.ts +4 -0
- package/lib/components/IconButton/index.js +4 -0
- package/lib/components/IconIndicator/index.d.ts +29 -0
- package/lib/components/IconIndicator/index.js +84 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +42 -38
- package/lib/prop-types/deprecateComponent.js +26 -0
- package/package.json +17 -16
- package/scss/components/icon-indicator/_icon-indicator.scss +9 -0
- package/scss/components/icon-indicator/_index.scss +9 -0
|
@@ -66,6 +66,7 @@ const BreadcrumbItem = /*#__PURE__*/React__default["default"].forwardRef(functio
|
|
|
66
66
|
href: href,
|
|
67
67
|
"aria-current": ariaCurrent || isCurrentPage
|
|
68
68
|
}, children) : /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
69
|
+
"aria-current": ariaCurrent || isCurrentPage,
|
|
69
70
|
className: `${prefix}--link`
|
|
70
71
|
}, children));
|
|
71
72
|
}
|
|
@@ -129,6 +129,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
129
129
|
const button = React.useRef(null);
|
|
130
130
|
const startSentinel = React.useRef(null);
|
|
131
131
|
const endSentinel = React.useRef(null);
|
|
132
|
+
const onMouseDownTarget = React.useRef(null);
|
|
132
133
|
const focusTrapWithoutSentinels = index$1.useFeatureFlag('enable-experimental-focus-wrap-without-sentinels');
|
|
133
134
|
|
|
134
135
|
// Keep track of modal open/close state
|
|
@@ -161,10 +162,15 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
161
162
|
}
|
|
162
163
|
onKeyDown?.(event);
|
|
163
164
|
}
|
|
165
|
+
function handleOnMouseDown(evt) {
|
|
166
|
+
const target = evt.target;
|
|
167
|
+
onMouseDownTarget.current = target;
|
|
168
|
+
}
|
|
164
169
|
function handleOnClick(evt) {
|
|
165
170
|
const target = evt.target;
|
|
171
|
+
const mouseDownTarget = onMouseDownTarget.current;
|
|
166
172
|
evt.stopPropagation();
|
|
167
|
-
if (!preventCloseOnClickOutside && !wrapFocus.elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target)) {
|
|
173
|
+
if (!preventCloseOnClickOutside && !wrapFocus.elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target) && !innerModal.current.contains(mouseDownTarget)) {
|
|
168
174
|
closeModal(evt);
|
|
169
175
|
}
|
|
170
176
|
}
|
|
@@ -275,6 +281,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
275
281
|
"aria-hidden": !open,
|
|
276
282
|
onBlur: !focusTrapWithoutSentinels ? handleBlur : () => {},
|
|
277
283
|
onClick: events.composeEventHandlers([rest?.onClick, handleOnClick]),
|
|
284
|
+
onMouseDown: events.composeEventHandlers([rest?.onMouseDown, handleOnMouseDown]),
|
|
278
285
|
onKeyDown: handleKeyDown,
|
|
279
286
|
className: modalClass
|
|
280
287
|
}), /*#__PURE__*/React__default["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
|
-
|
|
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
|
-
|
|
513
|
+
hasAILabelHeader: any;
|
|
514
|
+
hasDecoratorHeader: any;
|
|
509
515
|
};
|
|
510
516
|
/**
|
|
511
517
|
* Helper utility to get all the currently selected rows
|
|
@@ -27,6 +27,7 @@ var TableBatchActions = require('./TableBatchActions.js');
|
|
|
27
27
|
var TableBody = require('./TableBody.js');
|
|
28
28
|
var TableCell = require('./TableCell.js');
|
|
29
29
|
var TableContainer = require('./TableContainer.js');
|
|
30
|
+
var TableDecoratorRow = require('./TableDecoratorRow.js');
|
|
30
31
|
var TableExpandHeader = require('./TableExpandHeader.js');
|
|
31
32
|
var TableExpandRow = require('./TableExpandRow.js');
|
|
32
33
|
var TableExpandedRow = require('./TableExpandedRow.js');
|
|
@@ -119,6 +120,7 @@ class DataTable extends React__default["default"].Component {
|
|
|
119
120
|
isSortable,
|
|
120
121
|
isSortHeader: sortHeaderKey === header.key,
|
|
121
122
|
slug: header.slug,
|
|
123
|
+
decorator: header.decorator,
|
|
122
124
|
onClick: event => {
|
|
123
125
|
const nextSortState = sorting.getNextSortState(this.props, this.state, {
|
|
124
126
|
key: header.key
|
|
@@ -373,7 +375,8 @@ class DataTable extends React__default["default"].Component {
|
|
|
373
375
|
} = _ref4;
|
|
374
376
|
return {
|
|
375
377
|
...rest,
|
|
376
|
-
|
|
378
|
+
hasAILabelHeader: cell.hasAILabelHeader,
|
|
379
|
+
hasDecoratorHeader: cell.hasDecoratorHeader
|
|
377
380
|
};
|
|
378
381
|
});
|
|
379
382
|
/**
|
|
@@ -753,6 +756,7 @@ _rollupPluginBabelHelpers.defineProperty(DataTable, "TableBatchActions", void 0)
|
|
|
753
756
|
_rollupPluginBabelHelpers.defineProperty(DataTable, "TableBody", void 0);
|
|
754
757
|
_rollupPluginBabelHelpers.defineProperty(DataTable, "TableCell", void 0);
|
|
755
758
|
_rollupPluginBabelHelpers.defineProperty(DataTable, "TableContainer", void 0);
|
|
759
|
+
_rollupPluginBabelHelpers.defineProperty(DataTable, "TableDecoratorRow", void 0);
|
|
756
760
|
_rollupPluginBabelHelpers.defineProperty(DataTable, "TableExpandHeader", void 0);
|
|
757
761
|
_rollupPluginBabelHelpers.defineProperty(DataTable, "TableExpandRow", void 0);
|
|
758
762
|
_rollupPluginBabelHelpers.defineProperty(DataTable, "TableExpandedRow", void 0);
|
|
@@ -774,6 +778,7 @@ DataTable.TableBatchActions = TableBatchActions["default"];
|
|
|
774
778
|
DataTable.TableBody = TableBody["default"];
|
|
775
779
|
DataTable.TableCell = TableCell["default"];
|
|
776
780
|
DataTable.TableContainer = TableContainer["default"];
|
|
781
|
+
DataTable.TableDecoratorRow = TableDecoratorRow["default"];
|
|
777
782
|
DataTable.TableExpandHeader = TableExpandHeader["default"];
|
|
778
783
|
DataTable.TableExpandRow = TableExpandRow["default"];
|
|
779
784
|
DataTable.TableExpandedRow = TableExpandedRow["default"];
|
|
@@ -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
|
-
|
|
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
|
*/
|
|
@@ -23,13 +23,13 @@ const TableCell = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
23
23
|
let {
|
|
24
24
|
children,
|
|
25
25
|
className,
|
|
26
|
-
|
|
26
|
+
hasAILabelHeader,
|
|
27
27
|
colSpan,
|
|
28
28
|
...rest
|
|
29
29
|
} = _ref;
|
|
30
30
|
const prefix = usePrefix.usePrefix();
|
|
31
31
|
const tableCellClassNames = cx__default["default"](className, {
|
|
32
|
-
[`${prefix}--table-cell--column-slug`]:
|
|
32
|
+
[`${prefix}--table-cell--column-slug`]: hasAILabelHeader
|
|
33
33
|
});
|
|
34
34
|
return /*#__PURE__*/React__default["default"].createElement("td", _rollupPluginBabelHelpers["extends"]({
|
|
35
35
|
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,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
|
|
43
|
-
let
|
|
44
|
-
const
|
|
45
|
-
if (child.type?.displayName === 'TableSlugRow') {
|
|
46
|
-
if (child.props.slug) {
|
|
47
|
-
|
|
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`]:
|
|
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
|
-
}),
|
|
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
|
-
*
|
|
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
|
-
//
|
|
73
|
-
const
|
|
74
|
-
let
|
|
75
|
-
|
|
76
|
-
|
|
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:
|
|
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`]:
|
|
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,
|
|
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--
|
|
115
|
+
[`${prefix}--table-sort__header--ai-label`]: colHasAILabel,
|
|
116
|
+
[`${prefix}--table-sort__header--decorator`]: decorator
|
|
110
117
|
});
|
|
111
118
|
const handleClick = evt => {
|
|
112
|
-
if (
|
|
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
|
-
}),
|
|
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
|
|
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
|
-
|
|
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`]:
|
|
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
|
-
|
|
68
|
+
hasAILabelHeader: !!(slug || decorator?.type?.displayName === 'AILabel'),
|
|
68
69
|
info: {
|
|
69
70
|
header: key
|
|
70
71
|
}
|
|
@@ -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
|
*/
|
|
@@ -114,6 +114,10 @@ IconButton.propTypes = {
|
|
|
114
114
|
* **Experimental**: Will attempt to automatically align the tooltip
|
|
115
115
|
*/
|
|
116
116
|
autoAlign: PropTypes__default["default"].bool,
|
|
117
|
+
/**
|
|
118
|
+
* Optionally specify an href for your IconButton to become an `<a>` element
|
|
119
|
+
*/
|
|
120
|
+
href: PropTypes__default["default"].string,
|
|
117
121
|
/**
|
|
118
122
|
* Provide an icon or asset to be rendered inside of the IconButton
|
|
119
123
|
*/
|
|
@@ -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,84 @@
|
|
|
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
|
+
var iconsReact = require('@carbon/icons-react');
|
|
17
|
+
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
21
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
23
|
+
|
|
24
|
+
const IconIndicatorKinds = ['failed', 'caution-major', 'caution-minor', 'undefined', 'succeeded', 'normal', 'in-progress', 'incomplete', 'not-started', 'pending', 'unknown', 'informative'];
|
|
25
|
+
const iconTypes = {
|
|
26
|
+
failed: iconsReact.ErrorFilled,
|
|
27
|
+
['caution-major']: iconsReact.WarningAltInvertedFilled,
|
|
28
|
+
['caution-minor']: iconsReact.WarningAltFilled,
|
|
29
|
+
undefined: iconsReact.UndefinedFilled,
|
|
30
|
+
succeeded: iconsReact.CheckmarkFilled,
|
|
31
|
+
normal: iconsReact.CheckmarkOutline,
|
|
32
|
+
['in-progress']: iconsReact.InProgress,
|
|
33
|
+
incomplete: iconsReact.Incomplete,
|
|
34
|
+
['not-started']: iconsReact.CircleDash,
|
|
35
|
+
pending: iconsReact.PendingFilled,
|
|
36
|
+
unknown: iconsReact.UnknownFilled,
|
|
37
|
+
informative: iconsReact.WarningSquareFilled
|
|
38
|
+
};
|
|
39
|
+
const IconIndicator = /*#__PURE__*/React__default["default"].forwardRef(function IconIndicatorContent(_ref, ref) {
|
|
40
|
+
let {
|
|
41
|
+
className: customClassName,
|
|
42
|
+
kind,
|
|
43
|
+
label,
|
|
44
|
+
size = 16,
|
|
45
|
+
...rest
|
|
46
|
+
} = _ref;
|
|
47
|
+
const prefix = usePrefix.usePrefix();
|
|
48
|
+
const classNames = cx__default["default"](`${prefix}--icon-indicator`, customClassName, {
|
|
49
|
+
[`${prefix}--icon-indicator--20`]: size == 20
|
|
50
|
+
});
|
|
51
|
+
const IconForKind = iconTypes[kind];
|
|
52
|
+
if (!IconForKind) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
56
|
+
className: classNames,
|
|
57
|
+
ref: ref
|
|
58
|
+
}, /*#__PURE__*/React__default["default"].createElement(IconForKind, {
|
|
59
|
+
size: size,
|
|
60
|
+
className: `${prefix}--icon-indicator--${kind}`
|
|
61
|
+
}), label);
|
|
62
|
+
});
|
|
63
|
+
IconIndicator.propTypes = {
|
|
64
|
+
/**
|
|
65
|
+
* Specify an optional className to add.
|
|
66
|
+
*/
|
|
67
|
+
className: PropTypes__default["default"].string,
|
|
68
|
+
/**
|
|
69
|
+
* Specify the kind of the Icon Indicator
|
|
70
|
+
*/
|
|
71
|
+
kind: PropTypes__default["default"].oneOf(IconIndicatorKinds).isRequired,
|
|
72
|
+
/**
|
|
73
|
+
* Label next to the icon.
|
|
74
|
+
*/
|
|
75
|
+
label: PropTypes__default["default"].string.isRequired,
|
|
76
|
+
/**
|
|
77
|
+
* Specify the size of the Icon Indicator. Defaults to 16.
|
|
78
|
+
*/
|
|
79
|
+
size: PropTypes__default["default"].oneOf([16, 20])
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
exports.IconIndicator = IconIndicator;
|
|
83
|
+
exports.IconIndicatorKinds = IconIndicatorKinds;
|
|
84
|
+
exports["default"] = IconIndicator;
|
package/lib/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';
|