@carbon/ibm-products 1.25.1 → 1.26.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,19 +32,44 @@ var useActionsColumn = function useActionsColumn(hooks) {
32
32
 
33
33
  return [props, {
34
34
  children: /*#__PURE__*/React.createElement("div", {
35
- className: "".concat(blockClass, "__actions-column-content")
35
+ className: "".concat(blockClass, "__actions-column-contents")
36
36
  }, isFetching && /*#__PURE__*/React.createElement(IconSkeleton, {
37
37
  className: "".concat(blockClass, "__actions-column-loading")
38
- }), !isFetching && /*#__PURE__*/React.createElement(OverflowMenu, {
38
+ }), !isFetching && rowActions.length <= 2 && /*#__PURE__*/React.createElement("div", {
39
+ className: "".concat(blockClass, "_actions-column"),
40
+ style: {
41
+ display: 'flex'
42
+ }
43
+ }, rowActions.map(function (action) {
44
+ var id = action.id,
45
+ itemText = action.itemText,
46
+ _onClick = action.onClick,
47
+ icon = action.icon;
48
+ return /*#__PURE__*/React.createElement("div", {
49
+ className: "".concat(blockClass, "__actions-column-button"),
50
+ key: ""
51
+ }, /*#__PURE__*/React.createElement(OverflowMenu, {
52
+ renderIcon: icon,
53
+ hasIconOnly: true,
54
+ light: true,
55
+ iconDescription: itemText,
56
+ kind: "ghost",
57
+ onClick: function onClick(e) {
58
+ e.stopPropagation();
59
+
60
+ _onClick(id, row, e);
61
+ }
62
+ }));
63
+ })), !isFetching && rowActions.length > 2 && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(OverflowMenu, {
39
64
  size: "sm",
40
65
  light: true,
41
66
  flipped: true,
42
67
  onClick: function onClick(e) {
43
- return e.stopPropagation();
68
+ e.stopPropagation();
44
69
  }
45
70
  }, rowActions.map(function (action) {
46
71
  var id = action.id,
47
- _onClick = action.onClick,
72
+ _onClick2 = action.onClick,
48
73
  shouldHideMenuItem = action.shouldHideMenuItem,
49
74
  shouldDisableMenuItem = action.shouldDisableMenuItem,
50
75
  disabled = action.disabled,
@@ -64,11 +89,11 @@ var useActionsColumn = function useActionsColumn(hooks) {
64
89
  onClick: function onClick(e) {
65
90
  e.stopPropagation();
66
91
 
67
- _onClick(id, row, e);
92
+ _onClick2(id, row, e);
68
93
  },
69
94
  key: id
70
95
  }));
71
- }))),
96
+ })))),
72
97
  className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__actions-column-cell"), true), _defineProperty(_cx, "".concat(blockClass, "__cell"), true), _cx))
73
98
  }];
74
99
  }
@@ -21,7 +21,7 @@ import cx from 'classnames';
21
21
  import { TableSelectRow } from 'carbon-components-react';
22
22
  import { SelectAll } from './Datagrid/DatagridSelectAll';
23
23
  import { selectionColumnId } from './common-column-ids';
24
- import { pkg } from '../../settings';
24
+ import { pkg, carbon } from '../../settings';
25
25
  var blockClass = "".concat(pkg.prefix, "--datagrid");
26
26
 
27
27
  var useSelectRows = function useSelectRows(hooks) {
@@ -57,7 +57,7 @@ var useHighlightSelection = function useHighlightSelection(hooks) {
57
57
  var getRowProps = function getRowProps(props, _ref) {
58
58
  var row = _ref.row;
59
59
  return [props, {
60
- className: cx("".concat(blockClass, "__carbon-row"), row.getToggleRowSelectedProps().checked ? 'bx--data-table--selected' : '')
60
+ className: cx("".concat(blockClass, "__carbon-row"), row.getToggleRowSelectedProps().checked ? "".concat(carbon.prefix, "--data-table--selected ").concat(blockClass, "__active-row") : '')
61
61
  }];
62
62
  };
63
63
 
@@ -117,6 +117,9 @@ var useStickyColumn = function useStickyColumn(hooks) {
117
117
  if (spacerIdx >= 0 && stickyIdx >= 0 && stickyIdx < spacerIdx) {
118
118
  var _temp = newHeaders[spacerIdx];
119
119
  newHeaders[spacerIdx] = newHeaders[stickyIdx];
120
+ newHeaders[spacerIdx].canResize = false;
121
+ newHeaders[spacerIdx].disableResizing = true;
122
+ delete newHeaders[spacerIdx].getResizerProps;
120
123
  newHeaders[stickyIdx] = _temp;
121
124
  }
122
125
  });
@@ -2,33 +2,172 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
8
10
  exports.default = void 0;
9
11
 
10
- var _react = _interopRequireDefault(require("react"));
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
+
16
+ var _react = _interopRequireWildcard(require("react"));
17
+
18
+ var _iconsReact = require("@carbon/icons-react");
11
19
 
12
20
  var _carbonComponentsReact = require("carbon-components-react");
13
21
 
22
+ var _reactResizeDetector = require("react-resize-detector");
23
+
24
+ var _ButtonMenu = require("../../ButtonMenu");
25
+
14
26
  var _settings = require("../../../settings");
15
27
 
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.
28
+ var _classnames = _interopRequireDefault(require("classnames"));
29
+
30
+ 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); }
31
+
32
+ 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; }
33
+
34
+ /**
35
+ * Copyright IBM Corp. 2022, 2022
36
+ *
37
+ * This source code is licensed under the Apache-2.0 license found in the
38
+ * LICENSE file in the root directory of this source tree.
22
39
  */
23
40
  var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
24
41
  var TableToolbar = _carbonComponentsReact.DataTable.TableToolbar;
25
42
 
43
+ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridState, width, ref) {
44
+ var _useState = (0, _react.useState)(false),
45
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
46
+ displayAllInMenu = _useState2[0],
47
+ setDisplayAllInMenu = _useState2[1];
48
+
49
+ var _useState3 = (0, _react.useState)(null),
50
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
51
+ initialListWidth = _useState4[0],
52
+ setInitialListWidth = _useState4[1];
53
+
54
+ var _useState5 = (0, _react.useState)(false),
55
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
56
+ receivedInitialWidth = _useState6[0],
57
+ setReceivedInitialWidth = _useState6[1];
58
+
59
+ var selectedFlatRows = datagridState.selectedFlatRows,
60
+ toggleAllRowsSelected = datagridState.toggleAllRowsSelected,
61
+ toolbarBatchActions = datagridState.toolbarBatchActions;
62
+ var totalSelected = selectedFlatRows && selectedFlatRows.length; // Get initial width of batch actions container,
63
+ // used to measure when all items are put inside
64
+ // the ButtonMenu
65
+
66
+ (0, _react.useEffect)(function () {
67
+ if (totalSelected === 1 && !receivedInitialWidth) {
68
+ var batchActionListWidth = ref.current.querySelector(".".concat(_settings.carbon.prefix, "--action-list")).offsetWidth;
69
+ setInitialListWidth(batchActionListWidth);
70
+ setReceivedInitialWidth(true);
71
+ }
72
+ }, [totalSelected, receivedInitialWidth, ref]);
73
+ (0, _react.useEffect)(function () {
74
+ var summaryWidth = ref.current.querySelector(".".concat(_settings.carbon.prefix, "--batch-summary")).offsetWidth;
75
+
76
+ if (width < summaryWidth + initialListWidth + 32) {
77
+ setDisplayAllInMenu(true);
78
+ } else {
79
+ setDisplayAllInMenu(false);
80
+ }
81
+ }, [width, ref, initialListWidth]); // Render batch actions in ButtonMenu
82
+
83
+ var renderBatchActionOverflow = function renderBatchActionOverflow() {
84
+ var minWidthBeforeOverflowIcon = 380; // Do not render ButtonMenu when there are 3 or less items
85
+ // and if there is enough available space to render all the items
86
+
87
+ if ((toolbarBatchActions === null || toolbarBatchActions === void 0 ? void 0 : toolbarBatchActions.length) <= 3 && !displayAllInMenu) {
88
+ return null;
89
+ }
90
+
91
+ return /*#__PURE__*/_react.default.createElement(_ButtonMenu.ButtonMenu, {
92
+ label: width > minWidthBeforeOverflowIcon ? 'More' : null,
93
+ renderIcon: width > minWidthBeforeOverflowIcon ? _iconsReact.Add16 : _iconsReact.OverflowMenuVertical16,
94
+ className: (0, _classnames.default)("".concat(blockClass, "__button-menu"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__button-menu--icon-only"), width <= minWidthBeforeOverflowIcon)),
95
+ menuOptionsClass: "".concat(blockClass, "__button-menu-options"),
96
+ flipped: true
97
+ }, toolbarBatchActions && toolbarBatchActions.map(function (batchAction, index) {
98
+ if (index < 2) {
99
+ if (displayAllInMenu) {
100
+ return /*#__PURE__*/_react.default.createElement(_ButtonMenu.ButtonMenuItem, {
101
+ key: "".concat(batchAction.label, "-").concat(index),
102
+ itemText: batchAction.label,
103
+ onClick: function onClick() {
104
+ batchAction.onClick();
105
+
106
+ if (batchAction.type === 'select_all') {
107
+ toggleAllRowsSelected(true);
108
+ }
109
+ }
110
+ });
111
+ }
112
+
113
+ return null;
114
+ }
115
+
116
+ return /*#__PURE__*/_react.default.createElement(_ButtonMenu.ButtonMenuItem, {
117
+ key: "".concat(batchAction.label, "-").concat(index),
118
+ itemText: batchAction.label,
119
+ onClick: function onClick() {
120
+ batchAction.onClick();
121
+
122
+ if (batchAction.type === 'select_all') {
123
+ toggleAllRowsSelected(true);
124
+ }
125
+ }
126
+ });
127
+ }));
128
+ }; // Only display the first two batch actions, the rest are
129
+ // displayed inside of the ButtonMenu if there are more than
130
+ // 3 batch actions
131
+
132
+
133
+ return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.TableBatchActions, {
134
+ shouldShowBatchActions: totalSelected > 0,
135
+ totalSelected: totalSelected,
136
+ onCancel: function onCancel() {
137
+ return toggleAllRowsSelected(false);
138
+ }
139
+ }, !displayAllInMenu && toolbarBatchActions && (toolbarBatchActions === null || toolbarBatchActions === void 0 ? void 0 : toolbarBatchActions.map(function (batchAction, index) {
140
+ if (index < 2 && toolbarBatchActions.length > 3 || index < 3 && toolbarBatchActions.length === 3) {
141
+ return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.TableBatchAction, {
142
+ key: "".concat(batchAction.label, "-").concat(index),
143
+ renderIcon: batchAction.renderIcon,
144
+ onClick: function onClick() {
145
+ batchAction.onClick();
146
+
147
+ if (batchAction.type === 'select_all') {
148
+ toggleAllRowsSelected(true);
149
+ }
150
+ },
151
+ iconDescription: batchAction.label
152
+ }, batchAction.label);
153
+ }
154
+ })), renderBatchActionOverflow());
155
+ };
156
+
26
157
  var DatagridToolbar = function DatagridToolbar(datagridState) {
158
+ var _useResizeDetector = (0, _reactResizeDetector.useResizeDetector)(),
159
+ width = _useResizeDetector.width,
160
+ ref = _useResizeDetector.ref;
161
+
27
162
  var DatagridActions = datagridState.DatagridActions,
28
- DatagridBatchActions = datagridState.DatagridBatchActions;
29
- return DatagridActions || DatagridBatchActions ? /*#__PURE__*/_react.default.createElement("div", {
163
+ DatagridBatchActions = datagridState.DatagridBatchActions,
164
+ batchActions = datagridState.batchActions;
165
+ return batchActions && DatagridActions ? /*#__PURE__*/_react.default.createElement("div", {
166
+ ref: ref,
167
+ className: "".concat(blockClass, "__table-toolbar")
168
+ }, /*#__PURE__*/_react.default.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActionsToolbar && DatagridBatchActionsToolbar(datagridState, width, ref))) : /*#__PURE__*/_react.default.createElement("div", {
30
169
  className: "".concat(blockClass, "__table-toolbar")
31
- }, /*#__PURE__*/_react.default.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActions && DatagridBatchActions(datagridState))) : null;
170
+ }, /*#__PURE__*/_react.default.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActions && DatagridBatchActions(datagridState)));
32
171
  };
33
172
 
34
173
  var _default = DatagridToolbar;
@@ -40,19 +40,44 @@ var useActionsColumn = function useActionsColumn(hooks) {
40
40
 
41
41
  return [props, {
42
42
  children: /*#__PURE__*/_react.default.createElement("div", {
43
- className: "".concat(blockClass, "__actions-column-content")
43
+ className: "".concat(blockClass, "__actions-column-contents")
44
44
  }, isFetching && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.IconSkeleton, {
45
45
  className: "".concat(blockClass, "__actions-column-loading")
46
- }), !isFetching && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.OverflowMenu, {
46
+ }), !isFetching && rowActions.length <= 2 && /*#__PURE__*/_react.default.createElement("div", {
47
+ className: "".concat(blockClass, "_actions-column"),
48
+ style: {
49
+ display: 'flex'
50
+ }
51
+ }, rowActions.map(function (action) {
52
+ var id = action.id,
53
+ itemText = action.itemText,
54
+ _onClick = action.onClick,
55
+ icon = action.icon;
56
+ return /*#__PURE__*/_react.default.createElement("div", {
57
+ className: "".concat(blockClass, "__actions-column-button"),
58
+ key: ""
59
+ }, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.OverflowMenu, {
60
+ renderIcon: icon,
61
+ hasIconOnly: true,
62
+ light: true,
63
+ iconDescription: itemText,
64
+ kind: "ghost",
65
+ onClick: function onClick(e) {
66
+ e.stopPropagation();
67
+
68
+ _onClick(id, row, e);
69
+ }
70
+ }));
71
+ })), !isFetching && rowActions.length > 2 && /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.OverflowMenu, {
47
72
  size: "sm",
48
73
  light: true,
49
74
  flipped: true,
50
75
  onClick: function onClick(e) {
51
- return e.stopPropagation();
76
+ e.stopPropagation();
52
77
  }
53
78
  }, rowActions.map(function (action) {
54
79
  var id = action.id,
55
- _onClick = action.onClick,
80
+ _onClick2 = action.onClick,
56
81
  shouldHideMenuItem = action.shouldHideMenuItem,
57
82
  shouldDisableMenuItem = action.shouldDisableMenuItem,
58
83
  disabled = action.disabled,
@@ -71,11 +96,11 @@ var useActionsColumn = function useActionsColumn(hooks) {
71
96
  onClick: function onClick(e) {
72
97
  e.stopPropagation();
73
98
 
74
- _onClick(id, row, e);
99
+ _onClick2(id, row, e);
75
100
  },
76
101
  key: id
77
102
  }));
78
- }))),
103
+ })))),
79
104
  className: (0, _classnames.default)((_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__actions-column-cell"), true), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__cell"), true), _cx))
80
105
  }];
81
106
  }
@@ -68,7 +68,7 @@ var useHighlightSelection = function useHighlightSelection(hooks) {
68
68
  var getRowProps = function getRowProps(props, _ref) {
69
69
  var row = _ref.row;
70
70
  return [props, {
71
- className: (0, _classnames.default)("".concat(blockClass, "__carbon-row"), row.getToggleRowSelectedProps().checked ? 'bx--data-table--selected' : '')
71
+ className: (0, _classnames.default)("".concat(blockClass, "__carbon-row"), row.getToggleRowSelectedProps().checked ? "".concat(_settings.carbon.prefix, "--data-table--selected ").concat(blockClass, "__active-row") : '')
72
72
  }];
73
73
  };
74
74
 
@@ -123,6 +123,9 @@ var useStickyColumn = function useStickyColumn(hooks) {
123
123
  if (spacerIdx >= 0 && stickyIdx >= 0 && stickyIdx < spacerIdx) {
124
124
  var _temp = newHeaders[spacerIdx];
125
125
  newHeaders[spacerIdx] = newHeaders[stickyIdx];
126
+ newHeaders[spacerIdx].canResize = false;
127
+ newHeaders[spacerIdx].disableResizing = true;
128
+ delete newHeaders[spacerIdx].getResizerProps;
126
129
  newHeaders[stickyIdx] = _temp;
127
130
  }
128
131
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/ibm-products",
3
3
  "description": "Carbon for IBM Products",
4
- "version": "1.25.1",
4
+ "version": "1.26.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -60,13 +60,13 @@
60
60
  "fs-extra": "^10.1.0",
61
61
  "glob": "^8.0.3",
62
62
  "jest": "^28.1.3",
63
- "jest-config-ibm-cloud-cognitive": "^0.24.3",
63
+ "jest-config-ibm-cloud-cognitive": "^0.24.4",
64
64
  "jest-environment-jsdom": "^28.1.3",
65
65
  "namor": "^1.1.2",
66
66
  "npm-check-updates": "^16.0.5",
67
67
  "npm-run-all": "^4.1.5",
68
68
  "rimraf": "^3.0.2",
69
- "sass": "^1.54.0",
69
+ "sass": "^1.54.4",
70
70
  "yargs": "^17.5.1"
71
71
  },
72
72
  "dependencies": {
@@ -93,5 +93,5 @@
93
93
  "react": "^16.8.6 || ^17.0.1",
94
94
  "react-dom": "^16.8.6 || ^17.0.1"
95
95
  },
96
- "gitHead": "72a6dbc4c1456c4c8dd8778cedbb532ecf0df711"
96
+ "gitHead": "69eb4ba877913337300fd0dc0fd64bf6fd07a50c"
97
97
  }
@@ -49,6 +49,11 @@
49
49
  }
50
50
  }
51
51
  }
52
+
53
+ .bx--overflow-menu-options > .c4p--datagrid__row-size-dropdown {
54
+ left: $spacing-01;
55
+ width: 112px;
56
+ }
52
57
  }
53
58
 
54
59
  @include exports('datagrid') {
@@ -451,11 +451,13 @@
451
451
  }
452
452
  }
453
453
 
454
- .#{$block-class} .#{$carbon-prefix}--data-table--selected {
454
+ .#{$block-class}
455
+ .#{$carbon-prefix}--data-table--selected:not(.#{$block-class}__active-row) {
455
456
  position: relative;
456
457
  }
457
458
 
458
- .#{$block-class} .#{$carbon-prefix}--data-table--selected::before {
459
+ .#{$block-class}
460
+ .#{$carbon-prefix}--data-table--selected:not(.#{$block-class}__active-row)::before {
459
461
  position: absolute;
460
462
  left: 0;
461
463
  width: $spacing-02;
@@ -463,3 +465,41 @@
463
465
  background-color: $interactive-01;
464
466
  content: '';
465
467
  }
468
+
469
+ .#{$pkg-prefix}--datagrid__table-toolbar
470
+ .#{$carbon-prefix}--batch-summary__para {
471
+ white-space: nowrap;
472
+ }
473
+
474
+ .#{$pkg-prefix}--datagrid__table-toolbar
475
+ .#{$carbon-prefix}--batch-actions
476
+ .#{$carbon-prefix}--batch-actions--active {
477
+ overflow-x: hidden;
478
+ }
479
+
480
+ .#{$pkg-prefix}--datagrid__table-toolbar
481
+ .#{$pkg-prefix}--datagrid__button-menu--icon-only.#{$pkg-prefix}--button-menu {
482
+ display: flex;
483
+ min-width: $spacing-08;
484
+ justify-content: center;
485
+ margin-right: $spacing-04;
486
+ }
487
+
488
+ .#{$pkg-prefix}--datagrid__table-toolbar
489
+ .#{$pkg-prefix}--datagrid__button-menu {
490
+ min-width: calc(#{$spacing-12} + #{$spacing-03});
491
+ }
492
+
493
+ .#{$pkg-prefix}--datagrid__table-toolbar
494
+ .#{$pkg-prefix}--datagrid__button-menu--icon-only.#{$pkg-prefix}--button-menu
495
+ .#{$pkg-prefix}--button-menu__trigger {
496
+ display: flex;
497
+ width: 100%;
498
+ min-width: $spacing-09;
499
+ justify-content: center;
500
+ padding: 0;
501
+ margin: 0;
502
+ .#{$carbon-prefix}--btn__icon {
503
+ margin: 0;
504
+ }
505
+ }
@@ -22,7 +22,7 @@
22
22
  @mixin input-outline($color: $focus) {
23
23
  /* stylelint-disable-next-line carbon/theme-token-use */
24
24
  outline: $spacing-01 solid $color;
25
- outline-offset: calc(-1 * $spacing-01);
25
+ outline-offset: calc(-1 * #{$spacing-01});
26
26
 
27
27
  @media screen and (prefers-contrast) {
28
28
  outline-style: dotted;