@carbon/ibm-products 1.27.0 → 1.31.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. package/css/index-full-carbon.css +513 -75
  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 +512 -74
  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 +513 -75
  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/DraggableElement.js +5 -1
  34. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +5 -40
  35. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +35 -10
  36. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +61 -24
  37. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
  38. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +63 -0
  39. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +1 -0
  40. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +459 -0
  41. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +1 -0
  42. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +112 -0
  43. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +27 -0
  44. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +1 -0
  45. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +31 -0
  46. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +19 -0
  47. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +197 -0
  48. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +6 -5
  49. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -2
  50. package/es/components/Datagrid/index.js +3 -1
  51. package/es/components/Datagrid/useColumnOrder.js +8 -0
  52. package/es/components/Datagrid/useCustomizeColumns.js +5 -0
  53. package/es/components/Datagrid/useDisableSelectRows.js +6 -2
  54. package/es/components/Datagrid/useInlineEdit.js +71 -0
  55. package/es/components/Datagrid/useRowSize.js +17 -6
  56. package/es/components/Datagrid/useSelectRows.js +12 -2
  57. package/es/components/Datagrid/useStickyColumn.js +11 -0
  58. package/es/components/Datagrid/utils/getInlineEditColumns.js +121 -0
  59. package/es/components/Datagrid/utils/makeData.js +17 -1
  60. package/es/components/ImportModal/ImportModal.js +2 -2
  61. package/es/components/InlineEdit/InlineEdit.js +4 -2
  62. package/es/components/ProductiveCard/ProductiveCard.js +5 -0
  63. package/es/components/index.js +1 -1
  64. package/es/global/js/hooks/useClickOutside.js +1 -1
  65. package/es/global/js/package-settings.js +3 -3
  66. package/es/global/js/utils/rangeWithCallback.js +13 -0
  67. package/es/global/js/utils/uuidv4.spec.js +4 -0
  68. package/lib/components/AddSelect/AddSelect.js +0 -4
  69. package/lib/components/AddSelect/AddSelectBody.js +20 -3
  70. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +14 -3
  71. package/lib/components/AddSelect/AddSelectColumn.js +3 -2
  72. package/lib/components/AddSelect/AddSelectFilter.js +3 -2
  73. package/lib/components/AddSelect/AddSelectList.js +39 -13
  74. package/lib/components/Card/Card.js +16 -6
  75. package/lib/components/Card/CardFooter.js +3 -1
  76. package/lib/components/Card/CardHeader.js +21 -1
  77. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +62 -10
  78. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
  79. package/lib/components/DataSpreadsheet/utils/handleCellDeletion.js +42 -0
  80. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
  81. package/lib/components/Datagrid/Datagrid/Datagrid.js +12 -45
  82. package/lib/components/Datagrid/Datagrid/DatagridContent.js +138 -0
  83. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +12 -3
  84. package/lib/components/Datagrid/Datagrid/DraggableElement.js +5 -1
  85. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +12 -41
  86. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +47 -25
  87. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +59 -23
  88. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
  89. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +79 -0
  90. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +13 -0
  91. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +483 -0
  92. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +13 -0
  93. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +129 -0
  94. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +36 -0
  95. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +19 -0
  96. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +42 -0
  97. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +28 -0
  98. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +204 -0
  99. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +6 -5
  100. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -2
  101. package/lib/components/Datagrid/index.js +17 -1
  102. package/lib/components/Datagrid/useColumnOrder.js +17 -0
  103. package/lib/components/Datagrid/useCustomizeColumns.js +5 -0
  104. package/lib/components/Datagrid/useDisableSelectRows.js +6 -2
  105. package/lib/components/Datagrid/useInlineEdit.js +85 -0
  106. package/lib/components/Datagrid/useRowSize.js +18 -13
  107. package/lib/components/Datagrid/useSelectRows.js +12 -2
  108. package/lib/components/Datagrid/useStickyColumn.js +11 -0
  109. package/lib/components/Datagrid/utils/getInlineEditColumns.js +133 -0
  110. package/lib/components/Datagrid/utils/makeData.js +17 -1
  111. package/lib/components/ImportModal/ImportModal.js +2 -2
  112. package/lib/components/InlineEdit/InlineEdit.js +4 -2
  113. package/lib/components/ProductiveCard/ProductiveCard.js +5 -0
  114. package/lib/components/index.js +12 -0
  115. package/lib/global/js/hooks/useClickOutside.js +1 -1
  116. package/lib/global/js/package-settings.js +3 -3
  117. package/lib/global/js/utils/rangeWithCallback.js +22 -0
  118. package/lib/global/js/utils/uuidv4.spec.js +4 -0
  119. package/package.json +13 -13
  120. package/scss/components/AddSelect/_add-select.scss +126 -28
  121. package/scss/components/Card/_card.scss +1 -0
  122. package/scss/components/Cascade/_cascade.scss +1 -1
  123. package/scss/components/CreateTearsheet/_create-tearsheet.scss +1 -0
  124. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +18 -1
  125. package/scss/components/Datagrid/_storybook-styles.scss +1 -1
  126. package/scss/components/Datagrid/styles/_datagrid.scss +27 -0
  127. package/scss/components/Datagrid/styles/_draggableElement.scss +26 -9
  128. package/scss/components/Datagrid/styles/_index.scss +1 -0
  129. package/scss/components/Datagrid/styles/_useInlineEdit.scss +211 -0
  130. package/scss/components/Datagrid/styles/_useStickyColumn.scss +24 -2
  131. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsModal.scss +44 -6
  132. package/scss/components/NotificationsPanel/_notifications-panel.scss +5 -6
  133. package/scss/components/ProductiveCard/_productive-card.scss +39 -0
  134. package/scss/components/RemoveModal/_remove-modal.scss +0 -4
  135. package/scss/components/SidePanel/_side-panel.scss +4 -6
  136. 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';
@@ -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));
@@ -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) {
@@ -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,
@@ -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) {
@@ -144,6 +145,16 @@ var changeProps = function changeProps(elementName, headerCellRef, props, data)
144
145
  })];
145
146
  }
146
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
+
147
158
  return [props];
148
159
  };
149
160
 
@@ -0,0 +1,121 @@
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 { ChartBubble16, ChartColumnFloating16, ChartVennDiagram16 } from '@carbon/icons-react';
8
+ export var inlineEditSelectItems = [{
9
+ id: 'option-0',
10
+ icon: ChartColumnFloating16,
11
+ text: 'Column Chart'
12
+ }, {
13
+ id: 'option-1',
14
+ icon: ChartBubble16,
15
+ text: 'Bubble Chart'
16
+ }, {
17
+ id: 'option-2',
18
+ icon: ChartVennDiagram16,
19
+ text: 'Venn Diagram'
20
+ }];
21
+ export var getInlineEditColumns = function getInlineEditColumns() {
22
+ return [{
23
+ Header: 'Row Index',
24
+ accessor: function accessor(row, i) {
25
+ return i;
26
+ },
27
+ id: 'rowIndex' // id is required when accessor is a function.
28
+
29
+ }, {
30
+ Header: 'First Name',
31
+ accessor: 'firstName',
32
+ inlineEdit: {
33
+ type: 'text',
34
+ inputProps: {} // These props are passed to the Carbon component used for inline editing
35
+
36
+ }
37
+ }, {
38
+ Header: 'Last Name',
39
+ accessor: 'lastName',
40
+ inlineEdit: {
41
+ type: 'text',
42
+ inputProps: {} // These props are passed to the Carbon component used for inline editing
43
+
44
+ }
45
+ }, {
46
+ Header: 'Age',
47
+ accessor: 'age',
48
+ width: 120,
49
+ inlineEdit: {
50
+ type: 'number',
51
+ inputProps: {} // These props are passed to the Carbon component used for inline editing
52
+
53
+ }
54
+ }, {
55
+ Header: 'Visits',
56
+ accessor: 'visits',
57
+ width: 120,
58
+ inlineEdit: {
59
+ type: 'number',
60
+ inputProps: {} // These props are passed to the Carbon component used for inline editing
61
+
62
+ }
63
+ }, {
64
+ Header: 'Active since',
65
+ accessor: 'activeSince',
66
+ inlineEdit: {
67
+ type: 'date',
68
+ inputProps: {
69
+ // optionally pass props here to be passed through to Carbon's DatePicker component
70
+ onChange: function onChange(newDateObj, cell) {
71
+ console.log(newDateObj, cell);
72
+ },
73
+ labelText: 'Change active since date',
74
+ // optionally pass props here to be passed through to Carbon's DatePickerInput component
75
+ datePickerInputProps: {
76
+ labelText: 'Change active since date'
77
+ }
78
+ }
79
+ }
80
+ }, {
81
+ Header: 'Chart type',
82
+ accessor: 'chartType',
83
+ inlineEdit: {
84
+ type: 'selection',
85
+ inputProps: {
86
+ // These props are passed to the Carbon component used for inline editing
87
+ items: inlineEditSelectItems,
88
+ onChange: function onChange(item) {
89
+ return console.log(item);
90
+ }
91
+ }
92
+ }
93
+ }, {
94
+ Header: 'Someone 2',
95
+ accessor: 'someone2'
96
+ }, {
97
+ Header: 'Someone 3',
98
+ accessor: 'someone3'
99
+ }, {
100
+ Header: 'Someone 4',
101
+ accessor: 'someone4'
102
+ }, {
103
+ Header: 'Someone 5',
104
+ accessor: 'someone5'
105
+ }, {
106
+ Header: 'Someone 6',
107
+ accessor: 'someone6'
108
+ }, {
109
+ Header: 'Someone 7',
110
+ accessor: 'someone7'
111
+ }, {
112
+ Header: 'Someone 8',
113
+ accessor: 'someone8'
114
+ }, {
115
+ Header: 'Someone 9',
116
+ accessor: 'someone9'
117
+ }, {
118
+ Header: 'Someone 10',
119
+ accessor: 'someone10'
120
+ }];
121
+ };
@@ -12,6 +12,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
12
12
  */
13
13
  import React from 'react';
14
14
  import namor from 'namor';
15
+ import { inlineEditSelectItems } from './getInlineEditColumns';
16
+
17
+ var getRandomInteger = function getRandomInteger(min, max) {
18
+ min = Math.ceil(min);
19
+ max = Math.floor(max);
20
+ return Math.floor(Math.random() * (max - min + 1)) + min;
21
+ };
22
+
15
23
  export var makeData = function makeData() {
16
24
  for (var _len = arguments.length, lens = new Array(_len), _key = 0; _key < _len; _key++) {
17
25
  lens[_key] = arguments[_key];
@@ -41,6 +49,12 @@ export var range = function range(len) {
41
49
 
42
50
  var newPerson = function newPerson() {
43
51
  var statusChance = Math.random();
52
+ var initialChartTypeIndex = getRandomInteger(0, 2);
53
+ var activeSinceDate = new Date();
54
+ var yesterdayDate = new Date();
55
+ yesterdayDate.setDate(yesterdayDate.getDate() - 1);
56
+ var twoDaysAgoDate = new Date();
57
+ twoDaysAgoDate.setDate(twoDaysAgoDate.getDate() - 2);
44
58
  return {
45
59
  firstName: namor.generate({
46
60
  words: 1,
@@ -133,7 +147,9 @@ var newPerson = function newPerson() {
133
147
  words: 1,
134
148
  numbers: 0
135
149
  }),
136
- status: statusChance > 0.66 ? 'relationship' : statusChance > 0.33 ? 'complicated' : 'single'
150
+ status: statusChance > 0.66 ? 'relationship' : statusChance > 0.33 ? 'complicated' : 'single',
151
+ chartType: initialChartTypeIndex === 0 ? inlineEditSelectItems[0] : initialChartTypeIndex === 1 ? inlineEditSelectItems[1] : inlineEditSelectItems[2],
152
+ activeSince: statusChance > 0.66 ? activeSinceDate : statusChance > 0.33 ? yesterdayDate : twoDaysAgoDate
137
153
  };
138
154
  };
139
155