@carbon/ibm-products 2.11.0 → 2.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/css/index-full-carbon.css +11 -7
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +3 -3
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon.css +11 -7
  6. package/css/index-without-carbon.css.map +1 -1
  7. package/css/index-without-carbon.min.css +3 -3
  8. package/css/index-without-carbon.min.css.map +1 -1
  9. package/css/index.css +10 -6
  10. package/css/index.css.map +1 -1
  11. package/css/index.min.css +2 -2
  12. package/css/index.min.css.map +1 -1
  13. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +30 -37
  14. package/es/components/Datagrid/Extensions/ExpandableRow/ExpandableRow.docs-page.js +1 -1
  15. package/es/components/Datagrid/useNestedRowExpander.js +22 -9
  16. package/es/components/Datagrid/useRowExpander.js +22 -9
  17. package/es/components/Datagrid/utils/DatagridActions.js +1 -1
  18. package/es/components/Datagrid/utils/getArgTypes.js +12 -0
  19. package/es/components/EditTearsheet/EditTearsheet.js +47 -38
  20. package/es/components/EditTearsheet/EditTearsheetForm.js +6 -0
  21. package/es/components/EditTearsheet/preview-components/MultiFormEditTearsheet.js +6 -1
  22. package/es/components/Tearsheet/Tearsheet.js +2 -2
  23. package/es/components/Tearsheet/TearsheetNarrow.js +2 -2
  24. package/es/components/Tearsheet/TearsheetShell.js +2 -2
  25. package/es/global/js/hooks/useRetrieveFormTitles.js +20 -0
  26. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +30 -37
  27. package/lib/components/Datagrid/Extensions/ExpandableRow/ExpandableRow.docs-page.js +1 -1
  28. package/lib/components/Datagrid/useNestedRowExpander.js +24 -9
  29. package/lib/components/Datagrid/useRowExpander.js +24 -9
  30. package/lib/components/Datagrid/utils/DatagridActions.js +1 -1
  31. package/lib/components/Datagrid/utils/getArgTypes.js +12 -0
  32. package/lib/components/EditTearsheet/EditTearsheet.js +47 -38
  33. package/lib/components/EditTearsheet/EditTearsheetForm.js +6 -0
  34. package/lib/components/EditTearsheet/preview-components/MultiFormEditTearsheet.js +6 -1
  35. package/lib/components/Tearsheet/Tearsheet.js +2 -2
  36. package/lib/components/Tearsheet/TearsheetNarrow.js +2 -2
  37. package/lib/components/Tearsheet/TearsheetShell.js +2 -2
  38. package/lib/global/js/hooks/useRetrieveFormTitles.js +28 -0
  39. package/package.json +5 -5
  40. package/scss/components/Datagrid/_datagrid.scss +9 -0
  41. package/scss/components/Datagrid/styles/_datagrid.scss +1 -0
  42. package/scss/components/Datagrid/styles/addons/_FilterFlyout.scss +1 -0
  43. package/scss/components/Datagrid/styles/addons/_FilterPanel.scss +1 -0
  44. package/scss/components/FilterSummary/_filter-summary.scss +1 -0
@@ -1,29 +1,41 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  /* eslint-disable react/prop-types */
4
- /*
5
- * Licensed Materials - Property of IBM
6
- * 5724-Q36
7
- * (c) Copyright IBM Corp. 2020
8
- * US Government Users Restricted Rights - Use, duplication or disclosure
9
- * restricted by GSA ADP Schedule Contract with IBM Corp.
4
+ /**
5
+ * Copyright IBM Corp. 2020, 2023
6
+ *
7
+ * This source code is licensed under the Apache-2.0 license found in the
8
+ * LICENSE file in the root directory of this source tree.
10
9
  */
11
- import React from 'react';
10
+
11
+ import React, { useRef } from 'react';
12
12
  import { ChevronDown, ChevronUp } from '@carbon/react/icons';
13
13
  import { pkg, carbon } from '../../settings';
14
14
  import cx from 'classnames';
15
15
  var blockClass = "".concat(pkg.prefix, "--datagrid");
16
16
  var useRowExpander = function useRowExpander(hooks) {
17
+ var tempState = useRef();
18
+ var useInstance = function useInstance(instance) {
19
+ tempState.current = instance;
20
+ };
17
21
  var visibleColumns = function visibleColumns(columns) {
18
22
  var expanderColumn = {
19
23
  id: 'expander',
20
24
  Cell: function Cell(_ref) {
21
25
  var row = _ref.row;
26
+ var _ref2 = (tempState === null || tempState === void 0 ? void 0 : tempState.current) || {},
27
+ _ref2$expanderButtonT = _ref2.expanderButtonTitleExpanded,
28
+ expanderButtonTitleExpanded = _ref2$expanderButtonT === void 0 ? 'Collapse row' : _ref2$expanderButtonT,
29
+ _ref2$expanderButtonT2 = _ref2.expanderButtonTitleCollapsed,
30
+ expanderButtonTitleCollapsed = _ref2$expanderButtonT2 === void 0 ? 'Expand row' : _ref2$expanderButtonT2;
31
+ var expanderTitle = row.isExpanded ? expanderButtonTitleExpanded : expanderButtonTitleCollapsed;
22
32
  return row.canExpand && /*#__PURE__*/React.createElement("button", _extends({
23
33
  type: "button",
24
- "aria-label": "Expand current row",
34
+ "aria-label": expanderTitle,
25
35
  className: cx("".concat(blockClass, "__row-expander"), "".concat(carbon.prefix, "--btn"), "".concat(carbon.prefix, "--btn--ghost"))
26
- }, row.getToggleRowExpandedProps()), row.isExpanded ? /*#__PURE__*/React.createElement(ChevronUp, {
36
+ }, row.getToggleRowExpandedProps(), {
37
+ title: expanderTitle
38
+ }), row.isExpanded ? /*#__PURE__*/React.createElement(ChevronUp, {
27
39
  className: "".concat(blockClass, "__row-expander--icon")
28
40
  }) : /*#__PURE__*/React.createElement(ChevronDown, {
29
41
  className: "".concat(blockClass, "__row-expander--icon")
@@ -37,5 +49,6 @@ var useRowExpander = function useRowExpander(hooks) {
37
49
  return [expanderColumn].concat(_toConsumableArray(columns));
38
50
  };
39
51
  hooks.visibleColumns.push(visibleColumns);
52
+ hooks.useInstance.push(useInstance);
40
53
  };
41
54
  export default useRowExpander;
@@ -1,6 +1,6 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  /**
3
- * Copyright IBM Corp. 2020, 2022
3
+ * Copyright IBM Corp. 2020, 2023
4
4
  *
5
5
  * This source code is licensed under the Apache-2.0 license found in the
6
6
  * LICENSE file in the root directory of this source tree.
@@ -87,6 +87,18 @@ export var ARG_TYPES = {
87
87
  },
88
88
  description: 'This value controls the height of the expanded content area. _This value is set/passed inside of the `datagridState` object._'
89
89
  },
90
+ expanderButtonTitleExpanded: {
91
+ control: {
92
+ type: 'text'
93
+ },
94
+ description: 'This value controls the expander title/aria-label when expanded. _This value is set/passed inside of the `datagridState` object._'
95
+ },
96
+ expanderButtonTitleCollapsed: {
97
+ control: {
98
+ type: 'text'
99
+ },
100
+ description: 'This value controls the expander title/aria-label when expanded. _This value is set/passed inside of the `datagridState` object._'
101
+ },
90
102
  customizeColumnsProps: {
91
103
  control: 'object',
92
104
  description: 'This is an object containing all of the props used with the column customization extension. _This value is set/passed inside of the `datagridState` object._'
@@ -1,9 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["cancelButtonText", "children", "className", "description", "influencerWidth", "label", "onClose", "open", "submitButtonText", "title", "verticalPosition", "onHandleModalClick"];
4
+ var _excluded = ["cancelButtonText", "children", "className", "description", "influencerWidth", "label", "onClose", "open", "submitButtonText", "title", "verticalPosition", "onHandleModalClick", "onFormChange", "sideNavAriaLabel"];
5
5
  /**
6
- * Copyright IBM Corp. 2022, 2022
6
+ * Copyright IBM Corp. 2022, 2023
7
7
  *
8
8
  * This source code is licensed under the Apache-2.0 license found in the
9
9
  * LICENSE file in the root directory of this source tree.
@@ -31,7 +31,8 @@ export var FormNumberContext = /*#__PURE__*/createContext(0);
31
31
  // Default values for props
32
32
  var defaults = {
33
33
  verticalPosition: 'normal',
34
- influencerWidth: 'narrow'
34
+ influencerWidth: 'narrow',
35
+ sideNavAriaLabel: 'Side navigation'
35
36
  };
36
37
 
37
38
  /**
@@ -52,40 +53,43 @@ export var EditTearsheet = /*#__PURE__*/forwardRef(function (_ref, ref) {
52
53
  _ref$verticalPosition = _ref.verticalPosition,
53
54
  verticalPosition = _ref$verticalPosition === void 0 ? defaults.verticalPosition : _ref$verticalPosition,
54
55
  onHandleModalClick = _ref.onHandleModalClick,
56
+ onFormChange = _ref.onFormChange,
57
+ _ref$sideNavAriaLabel = _ref.sideNavAriaLabel,
58
+ sideNavAriaLabel = _ref$sideNavAriaLabel === void 0 ? defaults.sideNavAriaLabel : _ref$sideNavAriaLabel,
55
59
  rest = _objectWithoutProperties(_ref, _excluded);
56
60
  var _useState = useState(0),
57
61
  _useState2 = _slicedToArray(_useState, 2),
58
62
  currentForm = _useState2[0],
59
63
  setCurrentForm = _useState2[1];
64
+ var _useState3 = useState([]),
65
+ _useState4 = _slicedToArray(_useState3, 2),
66
+ formTitles = _useState4[0],
67
+ setFormTitles = _useState4[1];
60
68
  var contentRef = useRef();
61
- var handleCurrentForm = function handleCurrentForm(form) {
62
- setCurrentForm(form);
69
+ var handleCurrentForm = function handleCurrentForm(formIndex) {
70
+ setCurrentForm(formIndex);
71
+ if (onFormChange) {
72
+ onFormChange(formIndex);
73
+ }
63
74
  };
64
- var sideNavItems = [{
65
- label: 'Topic Name'
66
- }, {
67
- label: 'Location'
68
- }, {
69
- label: 'Partitions'
70
- }, {
71
- label: 'Message retention'
72
- }];
73
- var influencer = /*#__PURE__*/React.createElement("div", {
74
- className: "tearsheet-stories__dummy-influencer-block"
75
- }, /*#__PURE__*/React.createElement(SideNav, {
76
- "aria-label": "Side navigation",
77
- className: "".concat(blockClass, "__side-nav"),
78
- expanded: true,
79
- isFixedNav: false
80
- }, /*#__PURE__*/React.createElement(SideNavItems, null, sideNavItems.map(function (item, index) {
81
- return /*#__PURE__*/React.createElement(SideNavMenuItem, {
82
- key: index,
83
- onClick: function onClick() {
84
- return handleCurrentForm(index);
85
- },
86
- isActive: currentForm === index
87
- }, item.label);
88
- }))));
75
+ function defaultInfluencer() {
76
+ return /*#__PURE__*/React.createElement("div", {
77
+ className: "".concat(blockClass, "__side-nav-wrapper")
78
+ }, /*#__PURE__*/React.createElement(SideNav, {
79
+ "aria-label": sideNavAriaLabel,
80
+ className: "".concat(blockClass, "__side-nav"),
81
+ expanded: true,
82
+ isFixedNav: false
83
+ }, /*#__PURE__*/React.createElement(SideNavItems, null, formTitles.map(function (title, index) {
84
+ return /*#__PURE__*/React.createElement(SideNavMenuItem, {
85
+ key: index,
86
+ onClick: function onClick() {
87
+ return handleCurrentForm(index);
88
+ },
89
+ isActive: currentForm === index
90
+ }, title);
91
+ }))));
92
+ }
89
93
  return /*#__PURE__*/React.createElement(TearsheetShell, _extends({}, rest, getDevtoolsProps(componentName), {
90
94
  actions: [{
91
95
  label: submitButtonText,
@@ -99,7 +103,7 @@ export var EditTearsheet = /*#__PURE__*/forwardRef(function (_ref, ref) {
99
103
  className: cx(blockClass, className),
100
104
  description: description,
101
105
  hasCloseIcon: false,
102
- influencer: influencer,
106
+ influencer: defaultInfluencer(),
103
107
  influencerPosition: "left",
104
108
  influencerWidth: influencerWidth,
105
109
  label: label,
@@ -115,7 +119,8 @@ export var EditTearsheet = /*#__PURE__*/forwardRef(function (_ref, ref) {
115
119
  role: "main"
116
120
  }, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(FormContext.Provider, {
117
121
  value: {
118
- currentForm: currentForm
122
+ currentForm: currentForm,
123
+ setFormTitles: setFormTitles
119
124
  }
120
125
  }, React.Children.map(children, function (child, index) {
121
126
  return /*#__PURE__*/React.createElement(FormNumberContext.Provider, {
@@ -150,12 +155,6 @@ EditTearsheet.propTypes = {
150
155
  * A description of the flow, displayed in the header area of the tearsheet.
151
156
  */
152
157
  description: PropTypes.node,
153
- /**
154
- * The content for the influencer section of the tearsheet, displayed
155
- * alongside the main content. This is typically a menu, or filter, or
156
- * progress indicator, or similar.
157
- */
158
- influencer: PropTypes.element,
159
158
  /**
160
159
  * Used to set the size of the influencer
161
160
  */
@@ -172,6 +171,12 @@ EditTearsheet.propTypes = {
172
171
  * Returning `false` here prevents the modal from closing.
173
172
  */
174
173
  onClose: PropTypes.func,
174
+ /**
175
+ * An optional handler that is called when a user changes forms via clicking
176
+ * an influencer nav item.
177
+ * Returns the index of the selected form.
178
+ */
179
+ onFormChange: PropTypes.func,
175
180
  /**
176
181
  * Specifies whether the tearsheet is currently open.
177
182
  */
@@ -180,6 +185,10 @@ EditTearsheet.propTypes = {
180
185
  * Specifies whether the tearsheet is currently open.
181
186
  */
182
187
  open: PropTypes.bool,
188
+ /**
189
+ * Specifies the aria label for the SideNav from Carbon UIShell
190
+ */
191
+ sideNavAriaLabel: PropTypes.string,
183
192
  /**
184
193
  * The submit button text
185
194
  */
@@ -16,6 +16,7 @@ import { Column, FormGroup, Grid } from '@carbon/react';
16
16
  import { FormContext, FormNumberContext } from './EditTearsheet';
17
17
  import { pkg } from '../../settings';
18
18
  import pconsole from '../../global/js/utils/pconsole';
19
+ import { useRetrieveFormTitles } from '../../global/js/hooks/useRetrieveFormTitles';
19
20
  var componentName = 'EditTearsheetForm';
20
21
  var blockClass = "".concat(pkg.prefix, "--tearsheet-edit__form");
21
22
 
@@ -36,6 +37,11 @@ export var EditTearsheetForm = /*#__PURE__*/forwardRef(function (_ref, ref) {
36
37
  rest = _objectWithoutProperties(_ref, _excluded);
37
38
  var formContext = useContext(FormContext);
38
39
  var formNumber = useContext(FormNumberContext);
40
+ useRetrieveFormTitles({
41
+ formContext: formContext,
42
+ formNumber: formNumber,
43
+ title: title
44
+ });
39
45
  return formContext ? /*#__PURE__*/React.createElement("div", _extends({}, rest, {
40
46
  className: cx(blockClass, className, (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__form--hidden-form"), formNumber !== (formContext === null || formContext === void 0 ? void 0 : formContext.currentForm)), _defineProperty(_cx, "".concat(blockClass, "__form--visible-form"), formNumber === (formContext === null || formContext === void 0 ? void 0 : formContext.currentForm)), _cx)),
41
47
  ref: ref
@@ -13,6 +13,7 @@ import cx from 'classnames';
13
13
  import { pkg } from '../../../settings';
14
14
  import { EditTearsheet } from '../EditTearsheet';
15
15
  import { EditTearsheetForm } from '../EditTearsheetForm';
16
+ import { action } from '@storybook/addon-actions';
16
17
  var blockClass = "".concat(pkg.prefix, "--tearsheet-edit-multi-form");
17
18
  export var MultiFormEditTearsheet = function MultiFormEditTearsheet(_ref) {
18
19
  var cancelButtonText = _ref.cancelButtonText,
@@ -72,6 +73,9 @@ export var MultiFormEditTearsheet = function MultiFormEditTearsheet(_ref) {
72
73
  var handleModalClick = function handleModalClick() {
73
74
  setOpen(!open);
74
75
  };
76
+ var handleFormChange = function handleFormChange() {
77
+ action('handleFormChange')();
78
+ };
75
79
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("style", null, ".".concat(blockClass, " { opacity: 0 }"), ";"), /*#__PURE__*/React.createElement(Button, {
76
80
  onClick: handleModalClick
77
81
  }, open ? 'Close EditTearsheet' : 'Open EditTearsheet'), /*#__PURE__*/React.createElement(EditTearsheet, {
@@ -84,7 +88,8 @@ export var MultiFormEditTearsheet = function MultiFormEditTearsheet(_ref) {
84
88
  title: title,
85
89
  open: open,
86
90
  onHandleModalClick: handleModalClick,
87
- onClose: clearCreateData
91
+ onClose: clearCreateData,
92
+ onFormChange: handleFormChange
88
93
  }, /*#__PURE__*/React.createElement(EditTearsheetForm, {
89
94
  title: "Topic name",
90
95
  fieldsetLegendText: "Topic information",
@@ -176,9 +176,9 @@ Tearsheet.propTypes = _objectSpread({
176
176
  */
177
177
  open: PropTypes.bool,
178
178
  /**
179
- * The DOM node the tearsheet should be rendered within. Defaults to document.body.
179
+ * The DOM element that the tearsheet should be rendered within. Defaults to document.body.
180
180
  */
181
- portalTarget: PropTypes.node,
181
+ portalTarget: PropTypes.instanceOf(Element),
182
182
  /**
183
183
  * Specify a CSS selector that matches the DOM element that should be focused when the Modal opens
184
184
  */
@@ -142,9 +142,9 @@ TearsheetNarrow.propTypes = _objectSpread({
142
142
  */
143
143
  open: PropTypes.bool,
144
144
  /**
145
- * The DOM node the tearsheet should be rendered within. Defaults to document.body.
145
+ * The DOM element that the tearsheet should be rendered within. Defaults to document.body.
146
146
  */
147
- portalTarget: PropTypes.node,
147
+ portalTarget: PropTypes.instanceOf(Element),
148
148
  /**
149
149
  * The main title of the tearsheet, displayed in the header area.
150
150
  */
@@ -383,9 +383,9 @@ TearsheetShell.propTypes = _objectSpread({
383
383
  */
384
384
  open: PropTypes.bool,
385
385
  /**
386
- * The DOM node the tearsheet should be rendered within. Defaults to document.body.
386
+ * The DOM element that the tearsheet should be rendered within. Defaults to document.body.
387
387
  */
388
- portalTarget: PropTypes.node,
388
+ portalTarget: PropTypes.instanceOf(Element),
389
389
  /**
390
390
  * Specifies the width of the tearsheet, 'narrow' or 'wide'.
391
391
  */
@@ -0,0 +1,20 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import { useEffect } from 'react';
3
+ export var useRetrieveFormTitles = function useRetrieveFormTitles(_ref) {
4
+ var formContext = _ref.formContext,
5
+ formNumber = _ref.formNumber,
6
+ title = _ref.title;
7
+ useEffect(function () {
8
+ if (formContext) {
9
+ formContext.setFormTitles(function (prev) {
10
+ var prevTitle = prev[formNumber];
11
+ if (prevTitle !== title) {
12
+ var clone = _toConsumableArray(prev);
13
+ clone[formNumber] = title;
14
+ return clone;
15
+ }
16
+ return prev;
17
+ });
18
+ }
19
+ }, [title, formContext, formNumber]);
20
+ };
@@ -16,7 +16,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
16
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
18
  /**
19
- * Copyright IBM Corp. 2022, 2023
19
+ * Copyright IBM Corp. 2021, 2023
20
20
  *
21
21
  * This source code is licensed under the Apache-2.0 license found in the
22
22
  * LICENSE file in the root directory of this source tree.
@@ -83,39 +83,41 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
83
83
  // Do not render ButtonMenu when there are 3 or less items
84
84
  // and if there is enough available space to render all the items
85
85
  if ((toolbarBatchActions === null || toolbarBatchActions === void 0 ? void 0 : toolbarBatchActions.length) <= 3 && !displayAllInMenu) {
86
- return null;
86
+ return;
87
87
  }
88
- return /*#__PURE__*/_react.default.createElement(_react2.MenuButton, {
89
- label: "More",
90
- className: (0, _classnames.default)("".concat(blockClass, "__button-menu"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__button-menu--icon-only"), width <= minWidthBeforeOverflowIcon))
91
- }, toolbarBatchActions && toolbarBatchActions.map(function (batchAction, index) {
92
- if (index < 2) {
93
- if (displayAllInMenu) {
94
- return /*#__PURE__*/_react.default.createElement(_react2.MenuItem, {
95
- key: "".concat(batchAction.label, "-").concat(index),
96
- label: batchAction.label,
97
- onClick: function onClick(event) {
98
- batchAction.onClick(getSelectedRowData(), event);
99
- if (batchAction.type === 'select_all') {
100
- toggleAllRowsSelected(true);
101
- }
102
- }
103
- });
104
- }
105
- return null;
106
- }
88
+ var renderItem = function renderItem(batchAction, index) {
107
89
  return /*#__PURE__*/_react.default.createElement(_react2.MenuItem, {
108
90
  key: "".concat(batchAction.label, "-").concat(index),
109
91
  label: batchAction.label,
110
92
  onClick: function onClick(event) {
111
- batchAction.onClick(getSelectedRowData(), event);
112
- if (batchAction.type === 'select_all') {
113
- toggleAllRowsSelected(true);
114
- }
93
+ return onClickHandler(event, batchAction);
115
94
  }
116
95
  });
96
+ };
97
+ return /*#__PURE__*/_react.default.createElement(_react2.MenuButton, {
98
+ label: "More",
99
+ className: (0, _classnames.default)("".concat(blockClass, "__button-menu"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__button-menu--icon-only"), width <= minWidthBeforeOverflowIcon))
100
+ }, toolbarBatchActions && toolbarBatchActions.map(function (batchAction, index) {
101
+ if (index < 2 && !displayAllInMenu) {
102
+ return;
103
+ }
104
+ return renderItem(batchAction, index);
117
105
  }));
118
106
  };
107
+ var onClickHandler = function onClickHandler(event, batchAction) {
108
+ batchAction.onClick(getSelectedRowData(), event);
109
+ if (batchAction.type === 'select_all') {
110
+ toggleAllRowsSelected(true);
111
+ }
112
+ };
113
+ var onCancelHandler = function onCancelHandler() {
114
+ toggleAllRowsSelected(false);
115
+ setGlobalFilter(null);
116
+ };
117
+ var onSelectAllHandler = function onSelectAllHandler() {
118
+ toggleAllRowsSelected(true);
119
+ onSelectAllRows === null || onSelectAllRows === void 0 || onSelectAllRows(true);
120
+ };
119
121
 
120
122
  // Only display the first two batch actions, the rest are
121
123
  // displayed inside of the ButtonMenu if there are more than
@@ -123,14 +125,8 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
123
125
  return /*#__PURE__*/_react.default.createElement(_react2.TableBatchActions, {
124
126
  shouldShowBatchActions: totalSelected > 0,
125
127
  totalSelected: totalSelected,
126
- onCancel: function onCancel() {
127
- toggleAllRowsSelected(false);
128
- setGlobalFilter(null);
129
- },
130
- onSelectAll: function onSelectAll() {
131
- toggleAllRowsSelected(true);
132
- onSelectAllRows === null || onSelectAllRows === void 0 || onSelectAllRows(true);
133
- },
128
+ onCancel: onCancelHandler,
129
+ onSelectAll: onSelectAllHandler,
134
130
  totalCount: rows && rows.length
135
131
  }, !displayAllInMenu && toolbarBatchActions && (toolbarBatchActions === null || toolbarBatchActions === void 0 ? void 0 : toolbarBatchActions.map(function (batchAction, index) {
136
132
  if (index < 2 && toolbarBatchActions.length > 3 || index < 3 && toolbarBatchActions.length <= 3) {
@@ -138,10 +134,7 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
138
134
  key: "".concat(batchAction.label, "-").concat(index),
139
135
  renderIcon: batchAction.renderIcon,
140
136
  onClick: function onClick(event) {
141
- batchAction.onClick(getSelectedRowData(), event);
142
- if (batchAction.type === 'select_all') {
143
- toggleAllRowsSelected(true);
144
- }
137
+ return onClickHandler(batchAction, event);
145
138
  },
146
139
  iconDescription: batchAction.label
147
140
  }, batchAction.label);
@@ -13,7 +13,7 @@ var DocsPage = function DocsPage() {
13
13
  description: "The `Datagrid` supports expandable rows with the use of the `useExpandedRow` hook.",
14
14
  source: {
15
15
  language: 'jsx',
16
- code: "\nimport { Datagrid, useDatagrid, useExpandedRow } from '@carbon/ibm-products';\n\nconst App = () => {\n const columns = React.useMemo(() => defaultHeader, []); // These are the columns that will be used by the datagrid\n const [data] = useState(makeData(10)); // This is the data that will be rendered by the datagrid\n\n const expansionRenderer = ({ row }) => {\n return <div>Content for row index: {row.id}</div>;\n };\n\n const datagridState = useDatagrid(\n {\n columns,\n data,\n ExpandedRowContentComponent: expansionRenderer,\n },\n useExpandedRow\n );\n\n return <Datagrid datagridState={datagridState} />;\n};\n "
16
+ code: "\nimport { Datagrid, useDatagrid, useExpandedRow } from '@carbon/ibm-products';\n\nconst App = () => {\n const columns = React.useMemo(() => defaultHeader, []); // These are the columns that will be used by the datagrid\n const [data] = useState(makeData(10)); // This is the data that will be rendered by the datagrid\n\n const expansionRenderer = ({ row }) => {\n return <div>Content for row index: {row.id}</div>;\n };\n\n const datagridState = useDatagrid(\n {\n columns,\n data,\n ExpandedRowContentComponent: expansionRenderer,\n expanderButtonTitleExpanded: 'Collapse row',\n expanderButtonTitleCollapsed: 'Expand row', \n },\n useExpandedRow\n );\n\n return <Datagrid datagridState={datagridState} />;\n};\n "
17
17
  }
18
18
  }]
19
19
  });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
@@ -8,32 +9,45 @@ exports.default = void 0;
8
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
- var _react = _interopRequireDefault(require("react"));
12
+ var _react = _interopRequireWildcard(require("react"));
12
13
  var _icons = require("@carbon/react/icons");
13
14
  var _classnames = _interopRequireDefault(require("classnames"));
14
15
  var _settings = require("../../settings");
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
18
  /* eslint-disable react/prop-types */
16
- /*
17
- * Licensed Materials - Property of IBM
18
- * 5724-Q36
19
- * (c) Copyright IBM Corp. 2020
20
- * US Government Users Restricted Rights - Use, duplication or disclosure
21
- * restricted by GSA ADP Schedule Contract with IBM Corp.
19
+ /**
20
+ * Copyright IBM Corp. 2020, 2023
21
+ *
22
+ * This source code is licensed under the Apache-2.0 license found in the
23
+ * LICENSE file in the root directory of this source tree.
22
24
  */
23
25
 
24
26
  var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
25
27
  var useNestedRowExpander = function useNestedRowExpander(hooks) {
28
+ var tempState = (0, _react.useRef)();
29
+ var useInstance = function useInstance(instance) {
30
+ tempState.current = instance;
31
+ };
26
32
  var visibleColumns = function visibleColumns(columns) {
27
33
  var expanderColumn = {
28
34
  id: 'expander',
29
35
  Cell: function Cell(_ref) {
30
36
  var _cx;
31
37
  var row = _ref.row;
38
+ var _ref2 = (tempState === null || tempState === void 0 ? void 0 : tempState.current) || {},
39
+ _ref2$expanderButtonT = _ref2.expanderButtonTitleExpanded,
40
+ expanderButtonTitleExpanded = _ref2$expanderButtonT === void 0 ? 'Collapse row' : _ref2$expanderButtonT,
41
+ _ref2$expanderButtonT2 = _ref2.expanderButtonTitleCollapsed,
42
+ expanderButtonTitleCollapsed = _ref2$expanderButtonT2 === void 0 ? 'Expand row' : _ref2$expanderButtonT2;
43
+ var expanderTitle = row.isExpanded ? expanderButtonTitleExpanded : expanderButtonTitleCollapsed;
32
44
  return row.canExpand && /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({
33
45
  type: "button",
34
- "aria-label": "Expand current row",
46
+ "aria-label": expanderTitle,
35
47
  className: (0, _classnames.default)("".concat(blockClass, "__row-expander"), "".concat(_settings.carbon.prefix, "--btn"), "".concat(_settings.carbon.prefix, "--btn--ghost"))
36
- }, row.getToggleRowExpandedProps()), /*#__PURE__*/_react.default.createElement(_icons.ChevronRight, {
48
+ }, row.getToggleRowExpandedProps(), {
49
+ title: expanderTitle
50
+ }), /*#__PURE__*/_react.default.createElement(_icons.ChevronRight, {
37
51
  className: (0, _classnames.default)("".concat(blockClass, "__expander-icon"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__expander-icon--not-open"), !row.isExpanded), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__expander-icon--open"), row.isExpanded), _cx))
38
52
  }));
39
53
  },
@@ -45,6 +59,7 @@ var useNestedRowExpander = function useNestedRowExpander(hooks) {
45
59
  return [expanderColumn].concat((0, _toConsumableArray2.default)(columns));
46
60
  };
47
61
  hooks.visibleColumns.push(visibleColumns);
62
+ hooks.useInstance.push(useInstance);
48
63
  };
49
64
  var _default = useNestedRowExpander;
50
65
  exports.default = _default;
@@ -1,37 +1,51 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
8
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var _react = _interopRequireDefault(require("react"));
11
+ var _react = _interopRequireWildcard(require("react"));
11
12
  var _icons = require("@carbon/react/icons");
12
13
  var _settings = require("../../settings");
13
14
  var _classnames = _interopRequireDefault(require("classnames"));
15
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
17
  /* eslint-disable react/prop-types */
15
- /*
16
- * Licensed Materials - Property of IBM
17
- * 5724-Q36
18
- * (c) Copyright IBM Corp. 2020
19
- * US Government Users Restricted Rights - Use, duplication or disclosure
20
- * restricted by GSA ADP Schedule Contract with IBM Corp.
18
+ /**
19
+ * Copyright IBM Corp. 2020, 2023
20
+ *
21
+ * This source code is licensed under the Apache-2.0 license found in the
22
+ * LICENSE file in the root directory of this source tree.
21
23
  */
22
24
 
23
25
  var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
24
26
  var useRowExpander = function useRowExpander(hooks) {
27
+ var tempState = (0, _react.useRef)();
28
+ var useInstance = function useInstance(instance) {
29
+ tempState.current = instance;
30
+ };
25
31
  var visibleColumns = function visibleColumns(columns) {
26
32
  var expanderColumn = {
27
33
  id: 'expander',
28
34
  Cell: function Cell(_ref) {
29
35
  var row = _ref.row;
36
+ var _ref2 = (tempState === null || tempState === void 0 ? void 0 : tempState.current) || {},
37
+ _ref2$expanderButtonT = _ref2.expanderButtonTitleExpanded,
38
+ expanderButtonTitleExpanded = _ref2$expanderButtonT === void 0 ? 'Collapse row' : _ref2$expanderButtonT,
39
+ _ref2$expanderButtonT2 = _ref2.expanderButtonTitleCollapsed,
40
+ expanderButtonTitleCollapsed = _ref2$expanderButtonT2 === void 0 ? 'Expand row' : _ref2$expanderButtonT2;
41
+ var expanderTitle = row.isExpanded ? expanderButtonTitleExpanded : expanderButtonTitleCollapsed;
30
42
  return row.canExpand && /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({
31
43
  type: "button",
32
- "aria-label": "Expand current row",
44
+ "aria-label": expanderTitle,
33
45
  className: (0, _classnames.default)("".concat(blockClass, "__row-expander"), "".concat(_settings.carbon.prefix, "--btn"), "".concat(_settings.carbon.prefix, "--btn--ghost"))
34
- }, row.getToggleRowExpandedProps()), row.isExpanded ? /*#__PURE__*/_react.default.createElement(_icons.ChevronUp, {
46
+ }, row.getToggleRowExpandedProps(), {
47
+ title: expanderTitle
48
+ }), row.isExpanded ? /*#__PURE__*/_react.default.createElement(_icons.ChevronUp, {
35
49
  className: "".concat(blockClass, "__row-expander--icon")
36
50
  }) : /*#__PURE__*/_react.default.createElement(_icons.ChevronDown, {
37
51
  className: "".concat(blockClass, "__row-expander--icon")
@@ -45,6 +59,7 @@ var useRowExpander = function useRowExpander(hooks) {
45
59
  return [expanderColumn].concat((0, _toConsumableArray2.default)(columns));
46
60
  };
47
61
  hooks.visibleColumns.push(visibleColumns);
62
+ hooks.useInstance.push(useInstance);
48
63
  };
49
64
  var _default = useRowExpander;
50
65
  exports.default = _default;
@@ -16,7 +16,7 @@ var _hooks = require("../Datagrid/addons/Filtering/hooks");
16
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
18
  /**
19
- * Copyright IBM Corp. 2020, 2022
19
+ * Copyright IBM Corp. 2020, 2023
20
20
  *
21
21
  * This source code is licensed under the Apache-2.0 license found in the
22
22
  * LICENSE file in the root directory of this source tree.
@@ -93,6 +93,18 @@ var ARG_TYPES = {
93
93
  },
94
94
  description: 'This value controls the height of the expanded content area. _This value is set/passed inside of the `datagridState` object._'
95
95
  },
96
+ expanderButtonTitleExpanded: {
97
+ control: {
98
+ type: 'text'
99
+ },
100
+ description: 'This value controls the expander title/aria-label when expanded. _This value is set/passed inside of the `datagridState` object._'
101
+ },
102
+ expanderButtonTitleCollapsed: {
103
+ control: {
104
+ type: 'text'
105
+ },
106
+ description: 'This value controls the expander title/aria-label when expanded. _This value is set/passed inside of the `datagridState` object._'
107
+ },
96
108
  customizeColumnsProps: {
97
109
  control: 'object',
98
110
  description: 'This is an object containing all of the props used with the column customization extension. _This value is set/passed inside of the `datagridState` object._'