@carbon/ibm-products 1.25.1 → 1.31.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. package/css/index-full-carbon.css +562 -88
  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-released-only.css +942 -23
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +3 -3
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +561 -87
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +3 -3
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +562 -88
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +3 -3
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/AddSelect/AddSelect.js +0 -3
  18. package/es/components/AddSelect/AddSelectBody.js +20 -3
  19. package/es/components/AddSelect/AddSelectBreadcrumbs.js +11 -3
  20. package/es/components/AddSelect/AddSelectColumn.js +4 -3
  21. package/es/components/AddSelect/AddSelectFilter.js +4 -3
  22. package/es/components/AddSelect/AddSelectList.js +40 -14
  23. package/es/components/Card/Card.js +16 -6
  24. package/es/components/Card/CardFooter.js +3 -1
  25. package/es/components/Card/CardHeader.js +20 -1
  26. package/es/components/DataSpreadsheet/DataSpreadsheet.js +62 -11
  27. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
  28. package/es/components/DataSpreadsheet/utils/handleCellDeletion.js +31 -0
  29. package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
  30. package/es/components/Datagrid/Datagrid/Datagrid.js +10 -38
  31. package/es/components/Datagrid/Datagrid/DatagridContent.js +106 -0
  32. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +10 -3
  33. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +139 -11
  34. package/es/components/Datagrid/Datagrid/DraggableElement.js +5 -1
  35. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +5 -40
  36. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +35 -10
  37. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +61 -24
  38. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
  39. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +63 -0
  40. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +1 -0
  41. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +459 -0
  42. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +1 -0
  43. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +112 -0
  44. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +27 -0
  45. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +1 -0
  46. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +31 -0
  47. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +19 -0
  48. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +197 -0
  49. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +6 -5
  50. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -2
  51. package/es/components/Datagrid/index.js +3 -1
  52. package/es/components/Datagrid/useActionsColumn.js +31 -6
  53. package/es/components/Datagrid/useColumnOrder.js +8 -0
  54. package/es/components/Datagrid/useCustomizeColumns.js +5 -0
  55. package/es/components/Datagrid/useDefaultStringRenderer.js +4 -1
  56. package/es/components/Datagrid/useDisableSelectRows.js +6 -2
  57. package/es/components/Datagrid/useInlineEdit.js +71 -0
  58. package/es/components/Datagrid/useRowSize.js +17 -6
  59. package/es/components/Datagrid/useSelectRows.js +14 -4
  60. package/es/components/Datagrid/useStickyColumn.js +14 -0
  61. package/es/components/Datagrid/utils/getInlineEditColumns.js +121 -0
  62. package/es/components/Datagrid/utils/makeData.js +18 -2
  63. package/es/components/ImportModal/ImportModal.js +2 -2
  64. package/es/components/InlineEdit/InlineEdit.js +4 -2
  65. package/es/components/ProductiveCard/ProductiveCard.js +5 -0
  66. package/es/components/WebTerminal/WebTerminal.js +1 -1
  67. package/es/components/WebTerminal/WebTerminalContentWrapper.js +1 -1
  68. package/es/components/WebTerminal/hooks/index.js +6 -0
  69. package/es/components/WebTerminal/index.js +6 -0
  70. package/es/components/WebTerminal/preview-components/Navigation.js +6 -0
  71. package/es/components/WebTerminal/preview-components/documentationLinks.js +6 -0
  72. package/es/components/WebTerminal/preview-components/index.js +7 -0
  73. package/es/components/index.js +1 -1
  74. package/es/global/js/hooks/useClickOutside.js +1 -1
  75. package/es/global/js/package-settings.js +3 -3
  76. package/es/global/js/utils/rangeWithCallback.js +13 -0
  77. package/es/global/js/utils/uuidv4.spec.js +4 -0
  78. package/lib/components/AddSelect/AddSelect.js +0 -4
  79. package/lib/components/AddSelect/AddSelectBody.js +20 -3
  80. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +14 -3
  81. package/lib/components/AddSelect/AddSelectColumn.js +3 -2
  82. package/lib/components/AddSelect/AddSelectFilter.js +3 -2
  83. package/lib/components/AddSelect/AddSelectList.js +39 -13
  84. package/lib/components/Card/Card.js +16 -6
  85. package/lib/components/Card/CardFooter.js +3 -1
  86. package/lib/components/Card/CardHeader.js +21 -1
  87. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +62 -10
  88. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
  89. package/lib/components/DataSpreadsheet/utils/handleCellDeletion.js +42 -0
  90. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
  91. package/lib/components/Datagrid/Datagrid/Datagrid.js +12 -45
  92. package/lib/components/Datagrid/Datagrid/DatagridContent.js +138 -0
  93. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +12 -3
  94. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +148 -9
  95. package/lib/components/Datagrid/Datagrid/DraggableElement.js +5 -1
  96. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +12 -41
  97. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +47 -25
  98. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +59 -23
  99. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
  100. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +79 -0
  101. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +13 -0
  102. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +483 -0
  103. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +13 -0
  104. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +129 -0
  105. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +36 -0
  106. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +19 -0
  107. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +42 -0
  108. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +28 -0
  109. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +204 -0
  110. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +6 -5
  111. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -2
  112. package/lib/components/Datagrid/index.js +17 -1
  113. package/lib/components/Datagrid/useActionsColumn.js +31 -6
  114. package/lib/components/Datagrid/useColumnOrder.js +17 -0
  115. package/lib/components/Datagrid/useCustomizeColumns.js +5 -0
  116. package/lib/components/Datagrid/useDefaultStringRenderer.js +5 -1
  117. package/lib/components/Datagrid/useDisableSelectRows.js +6 -2
  118. package/lib/components/Datagrid/useInlineEdit.js +85 -0
  119. package/lib/components/Datagrid/useRowSize.js +18 -13
  120. package/lib/components/Datagrid/useSelectRows.js +13 -3
  121. package/lib/components/Datagrid/useStickyColumn.js +14 -0
  122. package/lib/components/Datagrid/utils/getInlineEditColumns.js +133 -0
  123. package/lib/components/Datagrid/utils/makeData.js +18 -2
  124. package/lib/components/ImportModal/ImportModal.js +2 -2
  125. package/lib/components/InlineEdit/InlineEdit.js +4 -2
  126. package/lib/components/ProductiveCard/ProductiveCard.js +5 -0
  127. package/lib/components/WebTerminal/hooks/index.js +6 -0
  128. package/lib/components/WebTerminal/preview-components/Navigation.js +6 -0
  129. package/lib/components/WebTerminal/preview-components/documentationLinks.js +6 -0
  130. package/lib/components/index.js +12 -0
  131. package/lib/global/js/hooks/useClickOutside.js +1 -1
  132. package/lib/global/js/package-settings.js +3 -3
  133. package/lib/global/js/utils/rangeWithCallback.js +22 -0
  134. package/lib/global/js/utils/uuidv4.spec.js +4 -0
  135. package/package.json +13 -13
  136. package/scss/components/AddSelect/_add-select.scss +126 -28
  137. package/scss/components/Card/_card.scss +1 -0
  138. package/scss/components/Cascade/_cascade.scss +1 -1
  139. package/scss/components/CreateTearsheet/_create-tearsheet.scss +1 -0
  140. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +18 -1
  141. package/scss/components/Datagrid/_datagrid.scss +5 -0
  142. package/scss/components/Datagrid/_storybook-styles.scss +1 -1
  143. package/scss/components/Datagrid/styles/_datagrid.scss +81 -12
  144. package/scss/components/Datagrid/styles/_draggableElement.scss +26 -9
  145. package/scss/components/Datagrid/styles/_index.scss +1 -0
  146. package/scss/components/Datagrid/styles/_useInlineEdit.scss +211 -0
  147. package/scss/components/Datagrid/styles/_useStickyColumn.scss +24 -2
  148. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsModal.scss +44 -6
  149. package/scss/components/InlineEdit/_inline-edit.scss +1 -1
  150. package/scss/components/NotificationsPanel/_notifications-panel.scss +5 -6
  151. package/scss/components/ProductiveCard/_productive-card.scss +39 -0
  152. package/scss/components/RemoveModal/_remove-modal.scss +0 -4
  153. package/scss/components/SidePanel/_side-panel.scss +4 -6
  154. package/scss/components/WebTerminal/_index.scss +7 -0
  155. package/scss/components/WebTerminal/_storybook-styles.scss +7 -0
  156. package/scss/components/WebTerminal/_web-terminal.scss +13 -0
  157. package/scss/components/_index-released-only.scss +1 -0
@@ -0,0 +1,197 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+
7
+ /**
8
+ * Copyright IBM Corp. 2022, 2022
9
+ *
10
+ * This source code is licensed under the Apache-2.0 license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
13
+ import { carbon, pkg } from '../../../../../settings';
14
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
15
+ export var handleGridKeyPress = function handleGridKeyPress(event, dispatch, state, instance) {
16
+ var key = event.key;
17
+ var gridActive = state.gridActive,
18
+ activeCellId = state.activeCellId,
19
+ editId = state.editId;
20
+ var focusedCell = document.querySelector("#".concat(instance.tableId, " .").concat(blockClass, "__table-with-inline-edit [data-cell-id=\"").concat(activeCellId, "\"]")); // If we reach this it means that tab was pressed while in
21
+ // edit mode which should not remove the focus from the grid
22
+
23
+ if (activeCellId === editId && key === 'Tab') {
24
+ // Attempting to exit date picker
25
+ if (focusedCell.getAttribute('data-inline-type') === 'date') {
26
+ dispatch({
27
+ type: 'EXIT_EDIT_MODE',
28
+ payload: activeCellId
29
+ });
30
+ }
31
+
32
+ event.preventDefault();
33
+ var inlineEditArea = document.querySelector("#".concat(instance.tableId, " .").concat(blockClass, "__table-with-inline-edit"));
34
+ inlineEditArea.focus();
35
+ return;
36
+ }
37
+
38
+ if (activeCellId === editId && key === 'Escape') {
39
+ if (focusedCell.getAttribute('data-inline-type') === 'date') {
40
+ dispatch({
41
+ type: 'EXIT_EDIT_MODE',
42
+ payload: activeCellId
43
+ });
44
+ event.preventDefault();
45
+
46
+ var _inlineEditArea = document.querySelector("#".concat(instance.tableId, " .").concat(blockClass, "__table-with-inline-edit"));
47
+
48
+ _inlineEditArea.focus();
49
+
50
+ return;
51
+ }
52
+ } // Checks if the dropdown menu is open
53
+
54
+
55
+ var dropdownIsActive = function dropdownIsActive() {
56
+ var focusedElementRole = document.activeElement.getAttribute('role');
57
+
58
+ if (focusedElementRole === 'listbox' && document.activeElement.classList.contains("".concat(carbon.prefix, "--list-box__menu"))) {
59
+ // Prevents arrow keys from scrolling any other content when dropdown menu is open
60
+ event.preventDefault();
61
+ return true;
62
+ }
63
+
64
+ return false;
65
+ }; // Checks if the date picker is open
66
+
67
+
68
+ var datePickerIsActive = function datePickerIsActive() {
69
+ var focusedCalendarElement = document.querySelector(".".concat(carbon.prefix, "--date-picker__input.flatpickr-input.active"));
70
+
71
+ if (focusedCalendarElement || document.activeElement.classList.contains("flatpickr-day")) {
72
+ event.preventDefault();
73
+ return true;
74
+ }
75
+
76
+ return false;
77
+ }; // Stop grid key listener when in edit mode
78
+
79
+
80
+ var isEditing = document.activeElement.id === activeCellId && document.activeElement.id === editId || dropdownIsActive() || datePickerIsActive();
81
+
82
+ if (isEditing || !gridActive) {
83
+ return;
84
+ } // Command keys need to be returned as there is default browser behavior with these keys
85
+
86
+
87
+ if (key === 'Meta' || key === 'Control') {
88
+ return;
89
+ } // Prevent arrow keys, home key, and end key from scrolling the page when the data spreadsheet container has focus
90
+
91
+
92
+ if (['End', 'Home', 'ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1 && !isEditing) {
93
+ event.preventDefault();
94
+ }
95
+
96
+ var isDisabledCell = !!focusedCell.getAttribute('data-disabled');
97
+ var sharedUpdateParams = {
98
+ oldId: activeCellId,
99
+ instance: instance
100
+ };
101
+
102
+ switch (key) {
103
+ case 'Tab':
104
+ {
105
+ if (!editId) {
106
+ dispatch({
107
+ type: 'REMOVE_GRID_ACTIVE_FOCUS',
108
+ payload: activeCellId
109
+ });
110
+ }
111
+
112
+ break;
113
+ }
114
+
115
+ case 'ArrowRight':
116
+ {
117
+ dispatch({
118
+ type: 'UPDATE_ACTIVE_CELL_ID',
119
+ payload: _objectSpread({
120
+ direction: 'right'
121
+ }, sharedUpdateParams)
122
+ });
123
+ break;
124
+ }
125
+
126
+ case 'ArrowLeft':
127
+ {
128
+ dispatch({
129
+ type: 'UPDATE_ACTIVE_CELL_ID',
130
+ payload: _objectSpread({
131
+ direction: 'left'
132
+ }, sharedUpdateParams)
133
+ });
134
+ break;
135
+ }
136
+
137
+ case 'ArrowUp':
138
+ {
139
+ dispatch({
140
+ type: 'UPDATE_ACTIVE_CELL_ID',
141
+ payload: _objectSpread({
142
+ direction: 'up'
143
+ }, sharedUpdateParams)
144
+ });
145
+ break;
146
+ }
147
+
148
+ case 'ArrowDown':
149
+ {
150
+ dispatch({
151
+ type: 'UPDATE_ACTIVE_CELL_ID',
152
+ payload: _objectSpread({
153
+ direction: 'down'
154
+ }, sharedUpdateParams)
155
+ });
156
+ break;
157
+ }
158
+
159
+ case ' ':
160
+ case 'F2':
161
+ case 'Enter':
162
+ {
163
+ // Disabled cells are not allowed to go into edit mode
164
+ if (isDisabledCell) {
165
+ return;
166
+ } // Only go into edit mode if there is no editId, meaning that we're not already in edit mode
167
+
168
+
169
+ if (!editId) {
170
+ var focusedType = focusedCell.getAttribute('data-inline-type'); // Open dropdown immediately after entering edit mode for selection type
171
+
172
+ if (focusedType === 'selection') {
173
+ setTimeout(function () {
174
+ var dropdownTrigger = focusedCell.querySelector('button');
175
+ dropdownTrigger === null || dropdownTrigger === void 0 ? void 0 : dropdownTrigger.click();
176
+ }, 1);
177
+ }
178
+
179
+ if (focusedType === 'date') {
180
+ setTimeout(function () {
181
+ var dateInputTrigger = focusedCell.querySelector('input');
182
+ dateInputTrigger === null || dateInputTrigger === void 0 ? void 0 : dateInputTrigger.click();
183
+ dateInputTrigger === null || dateInputTrigger === void 0 ? void 0 : dateInputTrigger.focus();
184
+ }, 1);
185
+ }
186
+
187
+ dispatch({
188
+ type: 'ENTER_EDIT_MODE',
189
+ payload: {
190
+ activeCellId: activeCellId,
191
+ editId: activeCellId
192
+ }
193
+ });
194
+ }
195
+ }
196
+ }
197
+ };
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["buttonLabel"];
5
+ var _excluded = ["legendText"];
6
6
  // @flow
7
7
 
8
8
  /*
@@ -22,8 +22,8 @@ import { pkg } from '../../../../../settings';
22
22
  var blockClass = "".concat(pkg.prefix, "--datagrid");
23
23
 
24
24
  var RowSizeDropdown = function RowSizeDropdown(_ref) {
25
- var _ref$buttonLabel = _ref.buttonLabel,
26
- buttonLabel = _ref$buttonLabel === void 0 ? 'Row height' : _ref$buttonLabel,
25
+ var _ref$legendText = _ref.legendText,
26
+ legendText = _ref$legendText === void 0 ? 'Row height' : _ref$legendText,
27
27
  props = _objectWithoutProperties(_ref, _excluded);
28
28
 
29
29
  var buttonRef = React.useRef({});
@@ -42,9 +42,10 @@ var RowSizeDropdown = function RowSizeDropdown(_ref) {
42
42
  onClick: function onClick() {
43
43
  return setIsOpen(!isOpen);
44
44
  },
45
- iconDescription: buttonLabel,
45
+ iconDescription: legendText,
46
46
  className: cx(_defineProperty({}, "".concat(blockClass, "__row-size-button--open"), isOpen))
47
47
  }), isOpen && /*#__PURE__*/React.createElement(RowSizeRadioGroup, _extends({}, props, {
48
+ legendText: legendText,
48
49
  buttonRef: buttonRef,
49
50
  hideRadioGroup: function hideRadioGroup() {
50
51
  setIsOpen(false);
@@ -53,8 +54,8 @@ var RowSizeDropdown = function RowSizeDropdown(_ref) {
53
54
  };
54
55
 
55
56
  RowSizeDropdown.propTypes = {
56
- buttonLabel: PropTypes.string,
57
57
  datagridName: PropTypes.string,
58
+ legendText: PropTypes.string,
58
59
  light: PropTypes.bool,
59
60
  onChange: PropTypes.func.isRequired,
60
61
  selectedOption: PropTypes.string
@@ -22,8 +22,7 @@ var RowSizeRadioGroup = function RowSizeRadioGroup(_ref) {
22
22
  buttonRef = _ref.buttonRef,
23
23
  onChange = _ref.onChange,
24
24
  hideRadioGroup = _ref.hideRadioGroup,
25
- _ref$legendText = _ref.legendText,
26
- legendText = _ref$legendText === void 0 ? 'Row height' : _ref$legendText,
25
+ legendText = _ref.legendText,
27
26
  _ref$rowSizeLabels = _ref.rowSizeLabels,
28
27
  rowSizeLabels = _ref$rowSizeLabels === void 0 ? {
29
28
  xl: 'Extra large',
@@ -20,4 +20,6 @@ export { default as useStickyColumn } from './useStickyColumn';
20
20
  export { default as useActionsColumn } from './useActionsColumn';
21
21
  export { default as useCustomizeColumns } from './useCustomizeColumns';
22
22
  export { default as useSelectAllWithToggle } from './useSelectAllToggle';
23
- export { default as useColumnCenterAlign } from './useColumnCenterAlign';
23
+ export { default as useColumnCenterAlign } from './useColumnCenterAlign';
24
+ export { default as useColumnOrder } from './useColumnOrder';
25
+ export { default as useInlineEdit } from './useInlineEdit';
@@ -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
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2022
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 { useColumnOrder } from 'react-table';
8
+ export default useColumnOrder;
@@ -26,6 +26,10 @@ var useCustomizeColumns = function useCustomizeColumns(hooks) {
26
26
 
27
27
  hooks.useInstance.push(function (instance) {
28
28
  var customizeColumnsProps = instance.customizeColumnsProps;
29
+
30
+ var _ref = customizeColumnsProps || {},
31
+ labels = _ref.labels;
32
+
29
33
  Object.assign(instance, {
30
34
  customizeColumnsProps: _objectSpread(_objectSpread({}, customizeColumnsProps), {}, {
31
35
  isModalOpen: isModalOpen,
@@ -33,6 +37,7 @@ var useCustomizeColumns = function useCustomizeColumns(hooks) {
33
37
  }),
34
38
  CustomizeColumnsButton: function CustomizeColumnsButton(props) {
35
39
  return /*#__PURE__*/React.createElement(ToggleButtonWrapper, _extends({
40
+ iconTooltipLabel: labels === null || labels === void 0 ? void 0 : labels.iconTooltipLabel,
36
41
  isModalOpen: isModalOpen,
37
42
  setIsModalOpen: setIsModalOpen
38
43
  }, props));
@@ -13,13 +13,16 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
13
13
  * restricted by GSA ADP Schedule Contract with IBM Corp.
14
14
  */
15
15
  import React from 'react';
16
+ import cx from 'classnames';
16
17
  import { pkg } from '../../settings';
17
18
  var blockClass = "".concat(pkg.prefix, "--datagrid");
18
19
 
19
20
  var useDefaultStringRenderer = function useDefaultStringRenderer(hooks) {
20
21
  var StringRenderer = function StringRenderer(tableProps) {
22
+ var _tableProps$column;
23
+
21
24
  return /*#__PURE__*/React.createElement("div", {
22
- className: "".concat(blockClass, "__defaultStringRenderer"),
25
+ className: cx("".concat(blockClass, "__defaultStringRenderer"), _defineProperty({}, "".concat(blockClass, "__defaultStringRenderer--multiline"), (_tableProps$column = tableProps.column) === null || _tableProps$column === void 0 ? void 0 : _tableProps$column.multiLineWrap)),
23
26
  title: tableProps.value
24
27
  }, tableProps.value);
25
28
  };
@@ -22,6 +22,8 @@ var useDisableSelectRows = function useDisableSelectRows(hooks) {
22
22
 
23
23
  var updateSelectAll = function updateSelectAll(hooks) {
24
24
  var getToggleAllRowsSelectedProps = function getToggleAllRowsSelectedProps(props, _ref2) {
25
+ var _instance$disableSele, _instance$disableSele2;
26
+
25
27
  var instance = _ref2.instance;
26
28
  var selectableRows = instance.rows.filter(function (row) {
27
29
  return !(instance.shouldDisableSelectRow && instance.shouldDisableSelectRow(row));
@@ -41,7 +43,7 @@ var updateSelectAll = function updateSelectAll(hooks) {
41
43
  },
42
44
  checked: isAllRowsSelected,
43
45
  disabled: instance.disableSelectAll,
44
- title: 'Toggle All Rows Selected',
46
+ title: (instance === null || instance === void 0 ? void 0 : (_instance$disableSele = instance.disableSelectRowsProps) === null || _instance$disableSele === void 0 ? void 0 : (_instance$disableSele2 = _instance$disableSele.labels) === null || _instance$disableSele2 === void 0 ? void 0 : _instance$disableSele2.toggleAllRowsLabel) || 'Toggle All Rows Selected',
45
47
  indeterminate: Boolean(!isAllRowsSelected && Object.keys(instance.state.selectedRowIds).length)
46
48
  }];
47
49
  };
@@ -51,6 +53,8 @@ var updateSelectAll = function updateSelectAll(hooks) {
51
53
 
52
54
  var updatePageSelectAll = function updatePageSelectAll(hooks) {
53
55
  var getToggleAllPageRowsSelectedProps = function getToggleAllPageRowsSelectedProps(props, _ref4) {
56
+ var _instance$disableSele3, _instance$disableSele4;
57
+
54
58
  var instance = _ref4.instance;
55
59
  var selectableRows = instance.page.filter(function (row) {
56
60
  return !(instance.shouldDisableSelectRow && instance.shouldDisableSelectRow(row));
@@ -70,7 +74,7 @@ var updatePageSelectAll = function updatePageSelectAll(hooks) {
70
74
  },
71
75
  checked: isAllRowsSelected,
72
76
  disabled: instance.disableSelectAll,
73
- title: 'Toggle All Rows Selected',
77
+ title: (instance === null || instance === void 0 ? void 0 : (_instance$disableSele3 = instance.disableSelectRowsProps) === null || _instance$disableSele3 === void 0 ? void 0 : (_instance$disableSele4 = _instance$disableSele3.labels) === null || _instance$disableSele4 === void 0 ? void 0 : _instance$disableSele4.toggleAllRowsLabel) || 'Toggle All Rows Selected',
74
78
  indeterminate: Boolean(!isAllRowsSelected && instance.page.some(function (_ref6) {
75
79
  var id = _ref6.id;
76
80
  return instance.state.selectedRowIds[id];
@@ -0,0 +1,71 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ /*
4
+ * Licensed Materials - Property of IBM
5
+ * 5724-Q36
6
+ * (c) Copyright IBM Corp. 2022
7
+ * US Government Users Restricted Rights - Use, duplication or disclosure
8
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
9
+ */
10
+ import React from 'react';
11
+ import { pkg } from '../../settings';
12
+ import cx from 'classnames';
13
+ import { InlineEditCell } from './Datagrid/addons/InlineEdit/InlineEditCell';
14
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
15
+
16
+ var useInlineEdit = function useInlineEdit(hooks) {
17
+ var addInlineEdit = function addInlineEdit(props, _ref) {
18
+ var _cell$column, _cell$column$inlineEd, _instance$columns$fil;
19
+
20
+ var cell = _ref.cell,
21
+ instance = _ref.instance;
22
+ var columnInlineEditConfig = cell.column.inlineEdit;
23
+ var inlineEditType = (_cell$column = cell.column) === null || _cell$column === void 0 ? void 0 : (_cell$column$inlineEd = _cell$column.inlineEdit) === null || _cell$column$inlineEd === void 0 ? void 0 : _cell$column$inlineEd.type;
24
+ var totalInlineEditColumns = (_instance$columns$fil = instance.columns.filter(function (item) {
25
+ return item.inlineEdit;
26
+ })) === null || _instance$columns$fil === void 0 ? void 0 : _instance$columns$fil.length;
27
+
28
+ var renderInlineEditComponent = function renderInlineEditComponent(type) {
29
+ return /*#__PURE__*/React.createElement(InlineEditCell, {
30
+ config: columnInlineEditConfig,
31
+ tabIndex: -1,
32
+ value: cell.value,
33
+ cell: cell,
34
+ instance: instance,
35
+ totalInlineEditColumns: totalInlineEditColumns,
36
+ type: type
37
+ });
38
+ };
39
+
40
+ if (cell.column.id === 'spacer') {
41
+ return [props, {
42
+ className: cx("".concat(blockClass, "__cell"), "".concat(blockClass, "__cell--spacer"))
43
+ }];
44
+ }
45
+
46
+ return [props, {
47
+ className: cx("".concat(blockClass, "__cell"), _defineProperty({}, "".concat(blockClass, "__cell-inline-edit"), true)),
48
+ role: 'gridcell',
49
+ children: /*#__PURE__*/React.createElement(React.Fragment, null, inlineEditType === 'text' && renderInlineEditComponent(inlineEditType), inlineEditType === 'number' && renderInlineEditComponent(inlineEditType), inlineEditType === 'selection' && renderInlineEditComponent(inlineEditType), inlineEditType === 'date' && renderInlineEditComponent(inlineEditType), !inlineEditType && /*#__PURE__*/React.createElement(InlineEditCell, {
50
+ config: columnInlineEditConfig,
51
+ tabIndex: -1,
52
+ value: cell.value,
53
+ cell: cell,
54
+ instance: instance,
55
+ disabled: true,
56
+ nonEditCell: true,
57
+ totalInlineEditColumns: totalInlineEditColumns,
58
+ type: "text"
59
+ }))
60
+ }];
61
+ };
62
+
63
+ hooks.getCellProps.push(addInlineEdit);
64
+ hooks.useInstance.push(function (instance) {
65
+ Object.assign(instance, {
66
+ withInlineEdit: true
67
+ });
68
+ });
69
+ };
70
+
71
+ export default useInlineEdit;
@@ -1,5 +1,10 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
 
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
+
3
8
  /*
4
9
  * Licensed Materials - Property of IBM
5
10
  * 5724-Q36
@@ -17,13 +22,19 @@ var useRowSize = function useRowSize(hooks) {
17
22
  setRowSize = _useState2[1];
18
23
 
19
24
  hooks.useInstance.push(function (instance) {
20
- var rowSizes = instance.rowSizes,
25
+ var rowSizeProps = instance.rowSizeProps,
26
+ rowSizes = instance.rowSizes,
21
27
  rowSize = instance.rowSize,
22
28
  onRowSizeChange = instance.onRowSizeChange;
29
+
30
+ var _ref = rowSizeProps || {},
31
+ labels = _ref.labels;
32
+
23
33
  Object.assign(instance, {
24
34
  rowSize: internalRowSize || rowSize,
25
- rowSizeDropdownProps: {
26
- rowSizes: rowSizes,
35
+ rowSizeDropdownProps: _objectSpread(_objectSpread({
36
+ rowSizes: rowSizes
37
+ }, labels), {}, {
27
38
  selectedOption: internalRowSize || rowSize,
28
39
  onChange: function onChange(value) {
29
40
  setRowSize(value);
@@ -32,13 +43,13 @@ var useRowSize = function useRowSize(hooks) {
32
43
  onRowSizeChange(value);
33
44
  }
34
45
  }
35
- },
46
+ }),
36
47
  RowSizeDropdown: RowSizeDropdown
37
48
  });
38
49
  });
39
50
 
40
- var getTableProps = function getTableProps(props, _ref) {
41
- var instance = _ref.instance;
51
+ var getTableProps = function getTableProps(props, _ref2) {
52
+ var instance = _ref2.instance;
42
53
  var rowSize = instance.rowSize;
43
54
 
44
55
  if (!rowSize) {
@@ -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) {
@@ -40,6 +40,11 @@ var useSelectRows = function useSelectRows(hooks) {
40
40
  };
41
41
 
42
42
  hooks.useInstance.push(useInstance);
43
+ hooks.useInstance.push(function (instance) {
44
+ Object.assign(instance, {
45
+ withSelectRows: true
46
+ });
47
+ });
43
48
  hooks.visibleColumns.push(function (columns) {
44
49
  return [{
45
50
  id: selectionColumnId,
@@ -57,7 +62,7 @@ var useHighlightSelection = function useHighlightSelection(hooks) {
57
62
  var getRowProps = function getRowProps(props, _ref) {
58
63
  var row = _ref.row;
59
64
  return [props, {
60
- className: cx("".concat(blockClass, "__carbon-row"), row.getToggleRowSelectedProps().checked ? 'bx--data-table--selected' : '')
65
+ className: cx("".concat(blockClass, "__carbon-row"), row.getToggleRowSelectedProps().checked ? "".concat(carbon.prefix, "--data-table--selected ").concat(blockClass, "__active-row") : '')
61
66
  }];
62
67
  };
63
68
 
@@ -65,6 +70,8 @@ var useHighlightSelection = function useHighlightSelection(hooks) {
65
70
  };
66
71
 
67
72
  var SelectRow = function SelectRow(datagridState) {
73
+ var _columns$;
74
+
68
75
  var _datagridState$isFetc = datagridState.isFetching,
69
76
  isFetching = _datagridState$isFetc === void 0 ? false : _datagridState$isFetc,
70
77
  tableId = datagridState.tableId,
@@ -72,7 +79,9 @@ var SelectRow = function SelectRow(datagridState) {
72
79
  cell = datagridState.cell,
73
80
  radio = datagridState.radio,
74
81
  toggleAllRowsSelected = datagridState.toggleAllRowsSelected,
75
- onRadioSelect = datagridState.onRadioSelect;
82
+ onRadioSelect = datagridState.onRadioSelect,
83
+ columns = datagridState.columns,
84
+ withStickyColumn = datagridState.withStickyColumn;
76
85
  var selectDisabled = isFetching || row.getRowProps().selectDisabled;
77
86
 
78
87
  var _row$getToggleRowSele = row.getToggleRowSelectedProps(),
@@ -80,6 +89,7 @@ var SelectRow = function SelectRow(datagridState) {
80
89
  selectProps = _objectWithoutProperties(_row$getToggleRowSele, _excluded);
81
90
 
82
91
  var cellProps = cell.getCellProps();
92
+ var isFirstColumnStickyLeft = ((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
83
93
  return /*#__PURE__*/React.createElement(TableSelectRow, _extends({}, cellProps, selectProps, {
84
94
  radio: radio,
85
95
  onSelect: function onSelect(e) {
@@ -97,7 +107,7 @@ var SelectRow = function SelectRow(datagridState) {
97
107
  },
98
108
  id: "".concat(tableId, "-").concat(row.index),
99
109
  name: "".concat(tableId, "-").concat(row.index, "-name"),
100
- className: cx("".concat(blockClass, "__checkbox-cell"), cellProps.className),
110
+ className: cx("".concat(blockClass, "__checkbox-cell"), cellProps.className, _defineProperty({}, "".concat(blockClass, "__checkbox-cell-sticky-left"), isFirstColumnStickyLeft)),
101
111
  ariaLabel: "".concat(tableId, "-row-").concat(row.index) // TODO: aria label should be i18n'ed
102
112
  ,
103
113
  disabled: selectDisabled
@@ -17,6 +17,7 @@ import cx from 'classnames';
17
17
  import { pkg } from '../../settings';
18
18
  var blockClass = "".concat(pkg.prefix, "--datagrid");
19
19
  var styleClassPrefix = "".concat(blockClass, "__right-sticky-column");
20
+ var leftStickyStyleClassPrefix = "".concat(blockClass, "__left-sticky-column");
20
21
  var OFFSET_SCROLL_CLASS = "".concat(styleClassPrefix, "-offset-scroll");
21
22
 
22
23
  var useStickyColumn = function useStickyColumn(hooks) {
@@ -117,6 +118,9 @@ var useStickyColumn = function useStickyColumn(hooks) {
117
118
  if (spacerIdx >= 0 && stickyIdx >= 0 && stickyIdx < spacerIdx) {
118
119
  var _temp = newHeaders[spacerIdx];
119
120
  newHeaders[spacerIdx] = newHeaders[stickyIdx];
121
+ newHeaders[spacerIdx].canResize = false;
122
+ newHeaders[spacerIdx].disableResizing = true;
123
+ delete newHeaders[spacerIdx].getResizerProps;
120
124
  newHeaders[stickyIdx] = _temp;
121
125
  }
122
126
  });
@@ -141,6 +145,16 @@ var changeProps = function changeProps(elementName, headerCellRef, props, data)
141
145
  })];
142
146
  }
143
147
 
148
+ if (column.sticky === 'left') {
149
+ var _data$instance, _cx2;
150
+
151
+ return [props, _objectSpread({
152
+ className: cx((_cx2 = {}, _defineProperty(_cx2, "".concat(leftStickyStyleClassPrefix, "-").concat(elementName), true), _defineProperty(_cx2, "".concat(leftStickyStyleClassPrefix, "-").concat(elementName, "--with-extra-select-column"), data === null || data === void 0 ? void 0 : (_data$instance = data.instance) === null || _data$instance === void 0 ? void 0 : _data$instance.withSelectRows), _cx2))
153
+ }, headerCellRef && {
154
+ ref: headerCellRef
155
+ })];
156
+ }
157
+
144
158
  return [props];
145
159
  };
146
160