@carbon/react 1.50.0-rc.0 → 1.50.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 (30) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +985 -936
  2. package/es/components/Accordion/AccordionItem.js +10 -15
  3. package/es/components/ChatButton/ChatButton.Skeleton.js +40 -0
  4. package/es/components/ChatButton/ChatButton.js +81 -0
  5. package/es/components/DataTable/DataTable.d.ts +21 -0
  6. package/es/components/DataTable/DataTable.js +19 -0
  7. package/es/components/DataTable/TableCell.d.ts +28 -3
  8. package/es/components/DataTable/TableCell.js +22 -5
  9. package/es/components/DataTable/TableExpandRow.js +1 -1
  10. package/es/components/DataTable/TableHeader.js +2 -2
  11. package/es/components/DataTable/TableRow.js +12 -1
  12. package/es/components/DataTable/tools/normalize.js +3 -1
  13. package/es/index.d.ts +1 -0
  14. package/es/index.js +2 -0
  15. package/lib/components/Accordion/AccordionItem.js +9 -14
  16. package/lib/components/ChatButton/ChatButton.Skeleton.js +50 -0
  17. package/lib/components/ChatButton/ChatButton.js +91 -0
  18. package/lib/components/DataTable/DataTable.d.ts +21 -0
  19. package/lib/components/DataTable/DataTable.js +19 -0
  20. package/lib/components/DataTable/TableCell.d.ts +28 -3
  21. package/lib/components/DataTable/TableCell.js +27 -5
  22. package/lib/components/DataTable/TableExpandRow.js +1 -1
  23. package/lib/components/DataTable/TableHeader.js +2 -2
  24. package/lib/components/DataTable/TableRow.js +12 -1
  25. package/lib/components/DataTable/tools/normalize.js +3 -1
  26. package/lib/index.d.ts +1 -0
  27. package/lib/index.js +4 -0
  28. package/package.json +5 -5
  29. package/scss/components/chat-button/_chat-button.scss +9 -0
  30. package/scss/components/chat-button/_index.scss +9 -0
@@ -9,7 +9,7 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
9
9
  import { ChevronRight } from '@carbon/icons-react';
10
10
  import cx from 'classnames';
11
11
  import PropTypes from 'prop-types';
12
- import React__default, { useState, useContext, useRef } from 'react';
12
+ import React__default, { useState, useContext } from 'react';
13
13
  import '../Text/index.js';
14
14
  import { useId } from '../../internal/useId.js';
15
15
  import deprecate from '../../prop-types/deprecate.js';
@@ -51,7 +51,15 @@ function AccordionItem(_ref) {
51
51
  });
52
52
  const Toggle = renderToggle || renderExpando; // remove renderExpando in next major release
53
53
 
54
- const content = useRef(null);
54
+ const content = React__default.useCallback(node => {
55
+ if (!node) {
56
+ return;
57
+ }
58
+ if (isOpen) {
59
+ // accordion closes
60
+ node.style.maxBlockSize = '';
61
+ }
62
+ }, [isOpen]);
55
63
  if (open !== prevIsOpen) {
56
64
  setIsOpen(open);
57
65
  setPrevIsOpen(open);
@@ -60,19 +68,6 @@ function AccordionItem(_ref) {
60
68
  // When the AccordionItem heading is clicked, toggle the open state of the
61
69
  // panel
62
70
  function onClick(event) {
63
- // type guard for ref
64
- if (!content.current) {
65
- return;
66
- }
67
- if (isOpen) {
68
- // accordion closes
69
- content.current.style.maxBlockSize = '';
70
- } else {
71
- // accordion opens
72
- content.current.style.maxBlockSize =
73
- // Scroll height plus top/bottom padding
74
- content.current.scrollHeight + 32 + 'px';
75
- }
76
71
  const nextValue = !isOpen;
77
72
  setIsOpen(nextValue);
78
73
  if (onHeadingClick) {
@@ -0,0 +1,40 @@
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 { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import PropTypes from 'prop-types';
10
+ import React__default from 'react';
11
+ import cx from 'classnames';
12
+ import { usePrefix } from '../../internal/usePrefix.js';
13
+
14
+ const ChatButtonSkeleton = _ref => {
15
+ let {
16
+ className,
17
+ size,
18
+ ...rest
19
+ } = _ref;
20
+ const prefix = usePrefix();
21
+ const skeletonClasses = cx(className, `${prefix}--skeleton`, `${prefix}--btn`, `${prefix}--chat-btn`, {
22
+ [`${prefix}--layout--size-${size}`]: size
23
+ });
24
+ return /*#__PURE__*/React__default.createElement("div", _extends({
25
+ className: skeletonClasses
26
+ }, rest));
27
+ };
28
+ ChatButtonSkeleton.propTypes = {
29
+ /**
30
+ * Specify an optional className to add.
31
+ */
32
+ className: PropTypes.string,
33
+ /**
34
+ * Specify the size of the `ChatButtonSkeleton`, from the following list of sizes:
35
+ */
36
+ size: PropTypes.oneOf(['sm', 'md', 'lg'])
37
+ };
38
+ var ChatButtonSkeleton$1 = ChatButtonSkeleton;
39
+
40
+ export { ChatButtonSkeleton$1 as default };
@@ -0,0 +1,81 @@
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 { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import PropTypes from 'prop-types';
10
+ import React__default from 'react';
11
+ import cx from 'classnames';
12
+ import Button from '../Button/Button.js';
13
+ import '../Button/Button.Skeleton.js';
14
+ import { usePrefix } from '../../internal/usePrefix.js';
15
+
16
+ const ChatButton = /*#__PURE__*/React__default.forwardRef(function ChatButton(_ref, ref) {
17
+ let {
18
+ className,
19
+ children,
20
+ disabled,
21
+ isQuickAction,
22
+ isSelected,
23
+ kind,
24
+ size,
25
+ ...other
26
+ } = _ref;
27
+ const prefix = usePrefix();
28
+ const classNames = cx(className, {
29
+ [`${prefix}--chat-btn`]: true,
30
+ [`${prefix}--chat-btn--quick-action`]: isQuickAction,
31
+ [`${prefix}--chat-btn--quick-action--selected`]: isSelected
32
+ });
33
+ const allowedSizes = ['sm', 'md', 'lg'];
34
+ if (isQuickAction) {
35
+ kind = 'ghost';
36
+ size = 'sm';
37
+ } else {
38
+ // Do not allow size larger than `lg`
39
+ size = allowedSizes.includes(size) ? size : 'lg';
40
+ }
41
+ return /*#__PURE__*/React__default.createElement(Button, _extends({
42
+ disabled: disabled,
43
+ className: classNames,
44
+ kind: kind,
45
+ ref: ref,
46
+ size: size
47
+ }, other), children);
48
+ });
49
+ ChatButton.propTypes = {
50
+ /**
51
+ * Provide the contents of your Select
52
+ */
53
+ children: PropTypes.node,
54
+ /**
55
+ * Specify an optional className to be applied to the node containing the label and the select box
56
+ */
57
+ className: PropTypes.string,
58
+ /**
59
+ * Specify whether the `ChatButton` should be disabled
60
+ */
61
+ disabled: PropTypes.bool,
62
+ /**
63
+ * Specify whether the `ChatButton` should be rendered as a quick action button
64
+ */
65
+ isQuickAction: PropTypes.bool,
66
+ /**
67
+ * Specify whether the quick action `ChatButton` should be rendered as selected. This disables the input
68
+ */
69
+ isSelected: PropTypes.bool,
70
+ /**
71
+ * Specify the kind of `ChatButton` you want to create
72
+ */
73
+ kind: PropTypes.oneOf(['primary', 'secondary', 'danger', 'ghost', 'tertiary']),
74
+ /**
75
+ * Specify the size of the `ChatButton`, from the following list of sizes:
76
+ */
77
+ size: PropTypes.oneOf(['sm', 'md', 'lg'])
78
+ };
79
+ var ChatButton$1 = ChatButton;
80
+
81
+ export { ChatButton$1 as default };
@@ -53,6 +53,7 @@ export interface DataTableRow<ColTypes extends any[]> {
53
53
  export interface DataTableHeader {
54
54
  key: string;
55
55
  header: React.ReactNode;
56
+ slug: React.ReactElement;
56
57
  }
57
58
  export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
58
59
  headers: Array<DataTableHeader>;
@@ -152,6 +153,12 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
152
153
  stickyHeader?: boolean;
153
154
  useStaticWidth?: boolean;
154
155
  };
156
+ getCellProps: (getCellPropsArgs: {
157
+ cell: DataTableCell<ColTypes>;
158
+ }) => {
159
+ [key: string]: unknown;
160
+ hasSlugHeader?: boolean;
161
+ };
155
162
  onInputChange: (e: React.ChangeEvent<HTMLInputElement>, defaultValue?: string) => void;
156
163
  sortBy: (headerKey: string) => void;
157
164
  selectAll: () => void;
@@ -334,6 +341,7 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
334
341
  sortDirection: DataTableSortState;
335
342
  isSortable: boolean | undefined;
336
343
  isSortHeader: boolean;
344
+ slug: React.ReactElement<any, string | React.JSXElementConstructor<any>>;
337
345
  onClick: (event: any) => void;
338
346
  };
339
347
  /**
@@ -468,6 +476,19 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
468
476
  stickyHeader: boolean | undefined;
469
477
  useStaticWidth: boolean | undefined;
470
478
  };
479
+ /**
480
+ * Get the props associated with the given table cell.
481
+ *
482
+ * @param {object} config
483
+ * @param {object} config.cell the cell we want the props for
484
+ * @returns {object}
485
+ */
486
+ getCellProps: ({ cell, ...rest }: {
487
+ [x: string]: any;
488
+ cell: any;
489
+ }) => {
490
+ hasSlugHeader: any;
491
+ };
471
492
  /**
472
493
  * Helper utility to get all the currently selected rows
473
494
  * @returns {Array<string>} the array of rowIds that are currently selected
@@ -103,6 +103,7 @@ class DataTable extends React__default.Component {
103
103
  sortDirection,
104
104
  isSortable,
105
105
  isSortHeader: sortHeaderKey === header.key,
106
+ slug: header.slug,
106
107
  onClick: event => {
107
108
  const nextSortState = getNextSortState(this.props, this.state, {
108
109
  key: header.key
@@ -339,6 +340,23 @@ class DataTable extends React__default.Component {
339
340
  useStaticWidth
340
341
  };
341
342
  });
343
+ /**
344
+ * Get the props associated with the given table cell.
345
+ *
346
+ * @param {object} config
347
+ * @param {object} config.cell the cell we want the props for
348
+ * @returns {object}
349
+ */
350
+ _defineProperty(this, "getCellProps", _ref4 => {
351
+ let {
352
+ cell,
353
+ ...rest
354
+ } = _ref4;
355
+ return {
356
+ ...rest,
357
+ hasSlugHeader: cell.hasSlugHeader
358
+ };
359
+ });
342
360
  /**
343
361
  * Helper utility to get all the currently selected rows
344
362
  * @returns {Array<string>} the array of rowIds that are currently selected
@@ -612,6 +630,7 @@ class DataTable extends React__default.Component {
612
630
  getBatchActionProps: this.getBatchActionProps,
613
631
  getTableProps: this.getTableProps,
614
632
  getTableContainerProps: this.getTableContainerProps,
633
+ getCellProps: this.getCellProps,
615
634
  // Custom event handlers
616
635
  onInputChange: this.handleOnInputValueChange,
617
636
  // Expose internal state change actions
@@ -4,7 +4,32 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { TdHTMLAttributes } from 'react';
8
- export type TableCellProps = TdHTMLAttributes<HTMLTableCellElement>;
9
- declare const TableCell: React.FC<TableCellProps>;
7
+ import React from 'react';
8
+ import { ReactAttr } from '../../types/common';
9
+ interface TableCellProps extends ReactAttr<HTMLTableCellElement> {
10
+ /**
11
+ * Pass in children that will be embedded in the table header label
12
+ */
13
+ children?: React.ReactNode;
14
+ /**
15
+ * Specify an optional className to be applied to the container node
16
+ */
17
+ className?: string;
18
+ /**
19
+ * The width of the expanded row's internal cell
20
+ */
21
+ colSpan?: number;
22
+ /**
23
+ * Specify if the table cell is in an AI column
24
+ */
25
+ hasSlugHeader?: boolean;
26
+ /**
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
+ */
29
+ headers?: string;
30
+ }
31
+ declare const TableCell: {
32
+ ({ children, className, hasSlugHeader, colSpan, ...rest }: TableCellProps): import("react/jsx-runtime").JSX.Element;
33
+ displayName: string;
34
+ };
10
35
  export default TableCell;
@@ -5,11 +5,28 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import wrapComponent from '../../tools/wrapComponent.js';
8
+ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import React__default from 'react';
10
+ import cx from 'classnames';
11
+ import { usePrefix } from '../../internal/usePrefix.js';
9
12
 
10
- const TableCell = wrapComponent({
11
- name: 'TableCell',
12
- type: 'td'
13
- });
13
+ const TableCell = _ref => {
14
+ let {
15
+ children,
16
+ className,
17
+ hasSlugHeader,
18
+ colSpan,
19
+ ...rest
20
+ } = _ref;
21
+ const prefix = usePrefix();
22
+ const tableCellClassNames = cx(className, {
23
+ [`${prefix}--table-cell--column-slug`]: hasSlugHeader
24
+ });
25
+ return /*#__PURE__*/React__default.createElement("td", _extends({
26
+ className: tableCellClassNames ? tableCellClassNames : undefined,
27
+ colSpan: colSpan
28
+ }, rest), children);
29
+ };
30
+ TableCell.displayName = 'TableCell';
14
31
 
15
32
  export { TableCell as default };
@@ -48,7 +48,7 @@ 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}--parent-row--slug`]: rowHasSlug
51
+ [`${prefix}--data-table--slug-row`]: rowHasSlug
52
52
  }, rowClassName);
53
53
  const previousValue = isExpanded ? 'collapsed' : undefined;
54
54
  return /*#__PURE__*/React__default.createElement("tr", _extends({}, rest, {
@@ -124,13 +124,13 @@ const TableHeader = /*#__PURE__*/React__default.forwardRef(function TableHeader(
124
124
  className: `${prefix}--table-sort__flex`
125
125
  }, /*#__PURE__*/React__default.createElement("div", {
126
126
  className: `${prefix}--table-header-label`
127
- }, children), normalizedSlug, /*#__PURE__*/React__default.createElement(ArrowUp, {
127
+ }, children), /*#__PURE__*/React__default.createElement(ArrowUp, {
128
128
  size: 20,
129
129
  className: `${prefix}--table-sort__icon`
130
130
  }), /*#__PURE__*/React__default.createElement(ArrowsVertical, {
131
131
  size: 20,
132
132
  className: `${prefix}--table-sort__icon-unsorted`
133
- }))));
133
+ }), normalizedSlug)));
134
134
  });
135
135
  TableHeader.propTypes = {
136
136
  /**
@@ -13,10 +13,21 @@ import { usePrefix } from '../../internal/usePrefix.js';
13
13
 
14
14
  const TableRow = props => {
15
15
  const prefix = usePrefix();
16
+ let rowHasSlug;
17
+ if (props?.children) {
18
+ React__default.Children.toArray(props.children).map(child => {
19
+ if (child.type?.displayName === 'TableSlugRow') {
20
+ if (child.props.slug) {
21
+ rowHasSlug = true;
22
+ }
23
+ }
24
+ });
25
+ }
16
26
  // Remove unnecessary props if provided to this component, these are
17
27
  // only useful in `TableExpandRow`
18
28
  const className = cx(props.className, {
19
- [`${prefix}--data-table--selected`]: props.isSelected
29
+ [`${prefix}--data-table--selected`]: props.isSelected,
30
+ [`${prefix}--data-table--slug-row`]: rowHasSlug
20
31
  });
21
32
  const cleanProps = {
22
33
  ...omit(props, ['ariaLabel', 'aria-label', 'aria-controls', 'onExpand', 'isExpanded', 'isSelected']),
@@ -48,7 +48,8 @@ const normalize = function (rows, headers) {
48
48
  }
49
49
  headers.forEach((_ref, i) => {
50
50
  let {
51
- key
51
+ key,
52
+ slug
52
53
  } = _ref;
53
54
  const id = getCellId(row.id, key);
54
55
  // Initialize the cell info and state values, namely for editing
@@ -59,6 +60,7 @@ const normalize = function (rows, headers) {
59
60
  isEditing: false,
60
61
  isValid: true,
61
62
  errors: null,
63
+ hasSlugHeader: !!slug,
62
64
  info: {
63
65
  header: key
64
66
  }
package/es/index.d.ts CHANGED
@@ -115,6 +115,7 @@ export { PageSelector as unstable_PageSelector, Pagination as unstable_Paginatio
115
115
  export * from './components/Popover';
116
116
  export * from './components/ProgressBar';
117
117
  export { Slug as unstable__Slug, SlugContent as unstable__SlugContent, SlugActions as unstable__SlugActions, } from './components/Slug';
118
+ export { ChatButton as unstable__ChatButton, ChatButtonSkeleton as unstable__ChatButtonSkeleton, } from './components/ChatButton';
118
119
  export * from './components/Stack';
119
120
  export * from './components/Tooltip';
120
121
  export { Text as unstable_Text, TextDirection as unstable_TextDirection, } from './components/Text';
package/es/index.js CHANGED
@@ -189,6 +189,8 @@ export { default as unstable__FluidTimePickerSkeleton } from './components/Fluid
189
189
  export { default as unstable__FluidTimePickerSelect } from './components/FluidTimePickerSelect/FluidTimePickerSelect.js';
190
190
  export { LayoutDirection as unstable_LayoutDirection } from './components/LayoutDirection/LayoutDirection.js';
191
191
  export { useLayoutDirection as unstable_useLayoutDirection } from './components/LayoutDirection/useLayoutDirection.js';
192
+ export { default as unstable__ChatButton } from './components/ChatButton/ChatButton.js';
193
+ export { default as unstable__ChatButtonSkeleton } from './components/ChatButton/ChatButton.Skeleton.js';
192
194
  export { Text as unstable_Text } from './components/Text/Text.js';
193
195
  export { TextDirection as unstable_TextDirection } from './components/Text/TextDirection.js';
194
196
  export { default as DataTable } from './components/DataTable/DataTable.js';
@@ -61,7 +61,15 @@ function AccordionItem(_ref) {
61
61
  });
62
62
  const Toggle = renderToggle || renderExpando; // remove renderExpando in next major release
63
63
 
64
- const content = React.useRef(null);
64
+ const content = React__default["default"].useCallback(node => {
65
+ if (!node) {
66
+ return;
67
+ }
68
+ if (isOpen) {
69
+ // accordion closes
70
+ node.style.maxBlockSize = '';
71
+ }
72
+ }, [isOpen]);
65
73
  if (open !== prevIsOpen) {
66
74
  setIsOpen(open);
67
75
  setPrevIsOpen(open);
@@ -70,19 +78,6 @@ function AccordionItem(_ref) {
70
78
  // When the AccordionItem heading is clicked, toggle the open state of the
71
79
  // panel
72
80
  function onClick(event) {
73
- // type guard for ref
74
- if (!content.current) {
75
- return;
76
- }
77
- if (isOpen) {
78
- // accordion closes
79
- content.current.style.maxBlockSize = '';
80
- } else {
81
- // accordion opens
82
- content.current.style.maxBlockSize =
83
- // Scroll height plus top/bottom padding
84
- content.current.scrollHeight + 32 + 'px';
85
- }
86
81
  const nextValue = !isOpen;
87
82
  setIsOpen(nextValue);
88
83
  if (onHeadingClick) {
@@ -0,0 +1,50 @@
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 _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
13
+ var PropTypes = require('prop-types');
14
+ var React = require('react');
15
+ var cx = require('classnames');
16
+ var usePrefix = require('../../internal/usePrefix.js');
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 ChatButtonSkeleton = _ref => {
25
+ let {
26
+ className,
27
+ size,
28
+ ...rest
29
+ } = _ref;
30
+ const prefix = usePrefix.usePrefix();
31
+ const skeletonClasses = cx__default["default"](className, `${prefix}--skeleton`, `${prefix}--btn`, `${prefix}--chat-btn`, {
32
+ [`${prefix}--layout--size-${size}`]: size
33
+ });
34
+ return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
35
+ className: skeletonClasses
36
+ }, rest));
37
+ };
38
+ ChatButtonSkeleton.propTypes = {
39
+ /**
40
+ * Specify an optional className to add.
41
+ */
42
+ className: PropTypes__default["default"].string,
43
+ /**
44
+ * Specify the size of the `ChatButtonSkeleton`, from the following list of sizes:
45
+ */
46
+ size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg'])
47
+ };
48
+ var ChatButtonSkeleton$1 = ChatButtonSkeleton;
49
+
50
+ exports["default"] = ChatButtonSkeleton$1;
@@ -0,0 +1,91 @@
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 _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
13
+ var PropTypes = require('prop-types');
14
+ var React = require('react');
15
+ var cx = require('classnames');
16
+ var Button = require('../Button/Button.js');
17
+ require('../Button/Button.Skeleton.js');
18
+ var usePrefix = require('../../internal/usePrefix.js');
19
+
20
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
+
22
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
23
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
24
+ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
25
+
26
+ const ChatButton = /*#__PURE__*/React__default["default"].forwardRef(function ChatButton(_ref, ref) {
27
+ let {
28
+ className,
29
+ children,
30
+ disabled,
31
+ isQuickAction,
32
+ isSelected,
33
+ kind,
34
+ size,
35
+ ...other
36
+ } = _ref;
37
+ const prefix = usePrefix.usePrefix();
38
+ const classNames = cx__default["default"](className, {
39
+ [`${prefix}--chat-btn`]: true,
40
+ [`${prefix}--chat-btn--quick-action`]: isQuickAction,
41
+ [`${prefix}--chat-btn--quick-action--selected`]: isSelected
42
+ });
43
+ const allowedSizes = ['sm', 'md', 'lg'];
44
+ if (isQuickAction) {
45
+ kind = 'ghost';
46
+ size = 'sm';
47
+ } else {
48
+ // Do not allow size larger than `lg`
49
+ size = allowedSizes.includes(size) ? size : 'lg';
50
+ }
51
+ return /*#__PURE__*/React__default["default"].createElement(Button["default"], _rollupPluginBabelHelpers["extends"]({
52
+ disabled: disabled,
53
+ className: classNames,
54
+ kind: kind,
55
+ ref: ref,
56
+ size: size
57
+ }, other), children);
58
+ });
59
+ ChatButton.propTypes = {
60
+ /**
61
+ * Provide the contents of your Select
62
+ */
63
+ children: PropTypes__default["default"].node,
64
+ /**
65
+ * Specify an optional className to be applied to the node containing the label and the select box
66
+ */
67
+ className: PropTypes__default["default"].string,
68
+ /**
69
+ * Specify whether the `ChatButton` should be disabled
70
+ */
71
+ disabled: PropTypes__default["default"].bool,
72
+ /**
73
+ * Specify whether the `ChatButton` should be rendered as a quick action button
74
+ */
75
+ isQuickAction: PropTypes__default["default"].bool,
76
+ /**
77
+ * Specify whether the quick action `ChatButton` should be rendered as selected. This disables the input
78
+ */
79
+ isSelected: PropTypes__default["default"].bool,
80
+ /**
81
+ * Specify the kind of `ChatButton` you want to create
82
+ */
83
+ kind: PropTypes__default["default"].oneOf(['primary', 'secondary', 'danger', 'ghost', 'tertiary']),
84
+ /**
85
+ * Specify the size of the `ChatButton`, from the following list of sizes:
86
+ */
87
+ size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg'])
88
+ };
89
+ var ChatButton$1 = ChatButton;
90
+
91
+ exports["default"] = ChatButton$1;
@@ -53,6 +53,7 @@ export interface DataTableRow<ColTypes extends any[]> {
53
53
  export interface DataTableHeader {
54
54
  key: string;
55
55
  header: React.ReactNode;
56
+ slug: React.ReactElement;
56
57
  }
57
58
  export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
58
59
  headers: Array<DataTableHeader>;
@@ -152,6 +153,12 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
152
153
  stickyHeader?: boolean;
153
154
  useStaticWidth?: boolean;
154
155
  };
156
+ getCellProps: (getCellPropsArgs: {
157
+ cell: DataTableCell<ColTypes>;
158
+ }) => {
159
+ [key: string]: unknown;
160
+ hasSlugHeader?: boolean;
161
+ };
155
162
  onInputChange: (e: React.ChangeEvent<HTMLInputElement>, defaultValue?: string) => void;
156
163
  sortBy: (headerKey: string) => void;
157
164
  selectAll: () => void;
@@ -334,6 +341,7 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
334
341
  sortDirection: DataTableSortState;
335
342
  isSortable: boolean | undefined;
336
343
  isSortHeader: boolean;
344
+ slug: React.ReactElement<any, string | React.JSXElementConstructor<any>>;
337
345
  onClick: (event: any) => void;
338
346
  };
339
347
  /**
@@ -468,6 +476,19 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
468
476
  stickyHeader: boolean | undefined;
469
477
  useStaticWidth: boolean | undefined;
470
478
  };
479
+ /**
480
+ * Get the props associated with the given table cell.
481
+ *
482
+ * @param {object} config
483
+ * @param {object} config.cell the cell we want the props for
484
+ * @returns {object}
485
+ */
486
+ getCellProps: ({ cell, ...rest }: {
487
+ [x: string]: any;
488
+ cell: any;
489
+ }) => {
490
+ hasSlugHeader: any;
491
+ };
471
492
  /**
472
493
  * Helper utility to get all the currently selected rows
473
494
  * @returns {Array<string>} the array of rowIds that are currently selected