@carbon/ibm-products 1.13.0 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. package/css/components/Datagrid/styles/addons/CustomizeColumnsModal.css +47 -0
  2. package/css/components/Datagrid/styles/addons/CustomizeColumnsModal.css.map +1 -0
  3. package/css/components/Datagrid/styles/addons/RowSizeDropdown.css +20 -0
  4. package/css/components/Datagrid/styles/addons/RowSizeDropdown.css.map +1 -0
  5. package/css/components/Datagrid/styles/datagrid.css +268 -0
  6. package/css/components/Datagrid/styles/datagrid.css.map +1 -0
  7. package/css/components/Datagrid/styles/index.css +513 -0
  8. package/css/components/Datagrid/styles/index.css.map +1 -0
  9. package/css/components/Datagrid/styles/useActionsColumn.css +23 -0
  10. package/css/components/Datagrid/styles/useActionsColumn.css.map +1 -0
  11. package/css/components/Datagrid/styles/useColumnRightAlign.css +28 -0
  12. package/css/components/Datagrid/styles/useColumnRightAlign.css.map +1 -0
  13. package/css/components/Datagrid/styles/useNestedRows.css +15 -0
  14. package/css/components/Datagrid/styles/useNestedRows.css.map +1 -0
  15. package/css/components/Datagrid/styles/useNestedTable.css +25 -0
  16. package/css/components/Datagrid/styles/useNestedTable.css.map +1 -0
  17. package/css/components/Datagrid/styles/useSelectAllToggle.css +28 -0
  18. package/css/components/Datagrid/styles/useSelectAllToggle.css.map +1 -0
  19. package/css/components/Datagrid/styles/useSortableColumns.css +50 -0
  20. package/css/components/Datagrid/styles/useSortableColumns.css.map +1 -0
  21. package/css/components/Datagrid/styles/useStickyColumn.css +35 -0
  22. package/css/components/Datagrid/styles/useStickyColumn.css.map +1 -0
  23. package/css/index-full-carbon.css +611 -10
  24. package/css/index-full-carbon.css.map +1 -1
  25. package/css/index-full-carbon.min.css +3 -3
  26. package/css/index-full-carbon.min.css.map +1 -1
  27. package/css/index-without-carbon-released-only.css +7 -4
  28. package/css/index-without-carbon-released-only.css.map +1 -1
  29. package/css/index-without-carbon-released-only.min.css +2 -2
  30. package/css/index-without-carbon-released-only.min.css.map +1 -1
  31. package/css/index-without-carbon.css +611 -10
  32. package/css/index-without-carbon.css.map +1 -1
  33. package/css/index-without-carbon.min.css +3 -3
  34. package/css/index-without-carbon.min.css.map +1 -1
  35. package/css/index.css +611 -10
  36. package/css/index.css.map +1 -1
  37. package/css/index.min.css +3 -3
  38. package/css/index.min.css.map +1 -1
  39. package/es/components/AddSelect/AddSelect.js +106 -43
  40. package/es/components/AddSelect/AddSelectFilter.js +172 -0
  41. package/es/components/AddSelect/add-select-utils.js +30 -0
  42. package/es/components/DataSpreadsheet/DataSpreadsheet.js +255 -175
  43. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +78 -17
  44. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +65 -20
  45. package/es/components/DataSpreadsheet/hooks/index.js +11 -0
  46. package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +139 -0
  47. package/es/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
  48. package/es/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +68 -0
  49. package/es/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +1 -3
  50. package/es/components/DataSpreadsheet/utils/createCellSelectionArea.js +20 -8
  51. package/es/components/DataSpreadsheet/utils/generateData.js +17 -9
  52. package/es/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +18 -0
  53. package/es/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +30 -0
  54. package/es/components/DataSpreadsheet/utils/handleActiveCellInSelectionEnter.js +121 -0
  55. package/es/components/DataSpreadsheet/utils/handleActiveCellInSelectionTab.js +108 -0
  56. package/es/components/DataSpreadsheet/utils/handleEditSubmit.js +87 -0
  57. package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +42 -8
  58. package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +225 -13
  59. package/es/components/DataSpreadsheet/utils/selectAllCells.js +53 -0
  60. package/es/components/Datagrid/Datagrid/Datagrid.js +70 -0
  61. package/es/components/Datagrid/Datagrid/DatagridBody.js +36 -0
  62. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +19 -0
  63. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -0
  64. package/es/components/Datagrid/Datagrid/DatagridHead.js +31 -0
  65. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +57 -0
  66. package/es/components/Datagrid/Datagrid/DatagridRefBody.js +37 -0
  67. package/es/components/Datagrid/Datagrid/DatagridRow.js +60 -0
  68. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +50 -0
  69. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +122 -0
  70. package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +36 -0
  71. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +22 -0
  72. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +87 -0
  73. package/es/components/Datagrid/Datagrid/DraggableElement.js +188 -0
  74. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +78 -0
  75. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +51 -0
  76. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +140 -0
  77. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +157 -0
  78. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +62 -0
  79. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +13 -0
  80. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +9 -0
  81. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +62 -0
  82. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +139 -0
  83. package/es/components/Datagrid/Datagrid/addons/RowSize/index.js +8 -0
  84. package/es/components/Datagrid/Datagrid/index.js +8 -0
  85. package/es/components/Datagrid/Datagrid.stories/CustomizeColumnStory.js +6 -0
  86. package/es/components/Datagrid/Datagrid.stories/LeftPanelStory.js +6 -0
  87. package/es/components/Datagrid/Datagrid.stories/RowSizeDropdownStory.js +6 -0
  88. package/es/components/Datagrid/Datagrid.stories/SelectAllWithToggleStory.js +6 -0
  89. package/es/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +92 -0
  90. package/es/components/Datagrid/Datagrid.stories/common.js +199 -0
  91. package/es/components/Datagrid/Datagrid.stories/index.js +5 -0
  92. package/es/components/Datagrid/common-column-ids.js +8 -0
  93. package/es/components/Datagrid/index.js +22 -0
  94. package/es/components/Datagrid/useActionsColumn.js +86 -0
  95. package/es/components/Datagrid/useColumnRightAlign.js +52 -0
  96. package/es/components/Datagrid/useCustomizeColumns.js +45 -0
  97. package/es/components/Datagrid/useDatagrid.js +44 -0
  98. package/es/components/Datagrid/useDefaultStringRenderer.js +48 -0
  99. package/es/components/Datagrid/useDisableSelectRows.js +84 -0
  100. package/es/components/Datagrid/useExpandedRow.js +52 -0
  101. package/es/components/Datagrid/useFlexResize.js +51 -0
  102. package/es/components/Datagrid/useFloatingScroll.js +88 -0
  103. package/es/components/Datagrid/useInfiniteScroll.js +54 -0
  104. package/es/components/Datagrid/useNestedRows.js +53 -0
  105. package/es/components/Datagrid/useOnRowClick.js +37 -0
  106. package/es/components/Datagrid/useParentDimensions.js +65 -0
  107. package/es/components/Datagrid/useResizeTable.js +40 -0
  108. package/es/components/Datagrid/useRowExpander.js +34 -0
  109. package/es/components/Datagrid/useRowIsMouseOver.js +61 -0
  110. package/es/components/Datagrid/useRowRenderer.js +30 -0
  111. package/es/components/Datagrid/useRowSize.js +56 -0
  112. package/es/components/Datagrid/useSelectAllToggle.js +74 -0
  113. package/es/components/Datagrid/useSelectRows.js +107 -0
  114. package/es/components/Datagrid/useSkeletonRows.js +32 -0
  115. package/es/components/Datagrid/useSortableColumns.js +110 -0
  116. package/es/components/Datagrid/useStickyColumn.js +183 -0
  117. package/es/components/MultiAddSelect/MultiAddSelect.js +150 -3
  118. package/es/components/PageHeader/PageHeader.js +3 -1
  119. package/es/components/SingleAddSelect/SingleAddSelect.js +90 -4
  120. package/es/components/TagSet/TagSet.js +13 -6
  121. package/es/components/Tearsheet/TearsheetShell.js +34 -10
  122. package/es/components/index.js +2 -1
  123. package/es/global/js/package-settings.js +4 -2
  124. package/lib/components/AddSelect/AddSelect.js +105 -41
  125. package/lib/components/AddSelect/AddSelectFilter.js +190 -0
  126. package/lib/components/AddSelect/add-select-utils.js +35 -2
  127. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +261 -177
  128. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +79 -23
  129. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +67 -21
  130. package/lib/components/DataSpreadsheet/hooks/index.js +45 -0
  131. package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +151 -0
  132. package/lib/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
  133. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +79 -0
  134. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +1 -3
  135. package/lib/components/DataSpreadsheet/utils/createCellSelectionArea.js +21 -8
  136. package/lib/components/DataSpreadsheet/utils/generateData.js +17 -9
  137. package/lib/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +27 -0
  138. package/lib/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +40 -0
  139. package/lib/components/DataSpreadsheet/utils/handleActiveCellInSelectionEnter.js +127 -0
  140. package/lib/components/DataSpreadsheet/utils/handleActiveCellInSelectionTab.js +118 -0
  141. package/lib/components/DataSpreadsheet/utils/handleEditSubmit.js +94 -0
  142. package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +44 -8
  143. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +235 -20
  144. package/lib/components/DataSpreadsheet/utils/selectAllCells.js +60 -0
  145. package/lib/components/Datagrid/Datagrid/Datagrid.js +86 -0
  146. package/lib/components/Datagrid/Datagrid/DatagridBody.js +50 -0
  147. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +31 -0
  148. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +38 -0
  149. package/lib/components/Datagrid/Datagrid/DatagridHead.js +43 -0
  150. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +73 -0
  151. package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +44 -0
  152. package/lib/components/Datagrid/Datagrid/DatagridRow.js +68 -0
  153. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +55 -0
  154. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +139 -0
  155. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +44 -0
  156. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +35 -0
  157. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +101 -0
  158. package/lib/components/Datagrid/Datagrid/DraggableElement.js +210 -0
  159. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +92 -0
  160. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +65 -0
  161. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +166 -0
  162. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +173 -0
  163. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +73 -0
  164. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +25 -0
  165. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +23 -0
  166. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +80 -0
  167. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +160 -0
  168. package/lib/components/Datagrid/Datagrid/addons/RowSize/index.js +15 -0
  169. package/lib/components/Datagrid/Datagrid/index.js +15 -0
  170. package/lib/components/Datagrid/Datagrid.stories/CustomizeColumnStory.js +13 -0
  171. package/lib/components/Datagrid/Datagrid.stories/LeftPanelStory.js +13 -0
  172. package/lib/components/Datagrid/Datagrid.stories/RowSizeDropdownStory.js +13 -0
  173. package/lib/components/Datagrid/Datagrid.stories/SelectAllWithToggleStory.js +13 -0
  174. package/lib/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +112 -0
  175. package/lib/components/Datagrid/Datagrid.stories/common.js +215 -0
  176. package/lib/components/Datagrid/Datagrid.stories/index.js +47 -0
  177. package/lib/components/Datagrid/common-column-ids.js +16 -0
  178. package/lib/components/Datagrid/index.js +127 -0
  179. package/lib/components/Datagrid/useActionsColumn.js +94 -0
  180. package/lib/components/Datagrid/useColumnRightAlign.js +59 -0
  181. package/lib/components/Datagrid/useCustomizeColumns.js +55 -0
  182. package/lib/components/Datagrid/useDatagrid.js +58 -0
  183. package/lib/components/Datagrid/useDefaultStringRenderer.js +54 -0
  184. package/lib/components/Datagrid/useDisableSelectRows.js +92 -0
  185. package/lib/components/Datagrid/useExpandedRow.js +58 -0
  186. package/lib/components/Datagrid/useFlexResize.js +61 -0
  187. package/lib/components/Datagrid/useFloatingScroll.js +101 -0
  188. package/lib/components/Datagrid/useInfiniteScroll.js +67 -0
  189. package/lib/components/Datagrid/useNestedRows.js +65 -0
  190. package/lib/components/Datagrid/useOnRowClick.js +45 -0
  191. package/lib/components/Datagrid/useParentDimensions.js +75 -0
  192. package/lib/components/Datagrid/useResizeTable.js +48 -0
  193. package/lib/components/Datagrid/useRowExpander.js +45 -0
  194. package/lib/components/Datagrid/useRowIsMouseOver.js +66 -0
  195. package/lib/components/Datagrid/useRowRenderer.js +40 -0
  196. package/lib/components/Datagrid/useRowSize.js +67 -0
  197. package/lib/components/Datagrid/useSelectAllToggle.js +88 -0
  198. package/lib/components/Datagrid/useSelectRows.js +119 -0
  199. package/lib/components/Datagrid/useSkeletonRows.js +42 -0
  200. package/lib/components/Datagrid/useSortableColumns.js +117 -0
  201. package/lib/components/Datagrid/useStickyColumn.js +190 -0
  202. package/lib/components/MultiAddSelect/MultiAddSelect.js +150 -2
  203. package/lib/components/PageHeader/PageHeader.js +3 -1
  204. package/lib/components/SingleAddSelect/SingleAddSelect.js +91 -3
  205. package/lib/components/TagSet/TagSet.js +13 -6
  206. package/lib/components/Tearsheet/TearsheetShell.js +36 -10
  207. package/lib/components/index.js +9 -1
  208. package/lib/global/js/package-settings.js +4 -2
  209. package/package.json +16 -12
  210. package/scss/components/AboutModal/_about-modal.scss +4 -0
  211. package/scss/components/AddSelect/_add-select.scss +46 -2
  212. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +41 -4
  213. package/scss/components/Datagrid/_datagrid.scss +66 -0
  214. package/scss/components/Datagrid/_index.scss +8 -0
  215. package/scss/components/Datagrid/_storybook-styles.scss +26 -0
  216. package/scss/components/Datagrid/styles/_variables.scss +9 -0
  217. package/scss/components/Datagrid/styles/addons/CustomizeColumnsModal.scss +48 -0
  218. package/scss/components/Datagrid/styles/addons/RowSizeDropdown.scss +23 -0
  219. package/scss/components/Datagrid/styles/datagrid.scss +326 -0
  220. package/scss/components/Datagrid/styles/index.scss +17 -0
  221. package/scss/components/Datagrid/styles/useActionsColumn.scss +24 -0
  222. package/scss/components/Datagrid/styles/useColumnRightAlign.scss +29 -0
  223. package/scss/components/Datagrid/styles/useNestedRows.scss +17 -0
  224. package/scss/components/Datagrid/styles/useNestedTable.scss +28 -0
  225. package/scss/components/Datagrid/styles/useSelectAllToggle.scss +28 -0
  226. package/scss/components/Datagrid/styles/useSortableColumns.scss +55 -0
  227. package/scss/components/Datagrid/styles/useStickyColumn.scss +38 -0
  228. package/scss/components/ExportModal/_export-modal.scss +0 -4
  229. package/scss/components/Tearsheet/_tearsheet.scss +4 -0
  230. package/scss/components/_index.scss +1 -0
@@ -0,0 +1,84 @@
1
+ /*
2
+ * Licensed Materials - Property of IBM
3
+ * 5724-Q36
4
+ * (c) Copyright IBM Corp. 2020
5
+ * US Government Users Restricted Rights - Use, duplication or disclosure
6
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
7
+ */
8
+ var useDisableSelectRows = function useDisableSelectRows(hooks) {
9
+ updateSelectAll(hooks);
10
+ updatePageSelectAll(hooks);
11
+
12
+ var getRowProps = function getRowProps(props, _ref) {
13
+ var row = _ref.row,
14
+ instance = _ref.instance;
15
+ return [props, {
16
+ selectDisabled: instance.shouldDisableSelectRow && instance.shouldDisableSelectRow(row)
17
+ }];
18
+ };
19
+
20
+ hooks.getRowProps.push(getRowProps);
21
+ };
22
+
23
+ var updateSelectAll = function updateSelectAll(hooks) {
24
+ var getToggleAllRowsSelectedProps = function getToggleAllRowsSelectedProps(props, _ref2) {
25
+ var instance = _ref2.instance;
26
+ var selectableRows = instance.rows.filter(function (row) {
27
+ return !(instance.shouldDisableSelectRow && instance.shouldDisableSelectRow(row));
28
+ });
29
+ var isAllRowsSelected = selectableRows.length > 0 && selectableRows.every(function (_ref3) {
30
+ var id = _ref3.id;
31
+ return instance.state.selectedRowIds[id];
32
+ });
33
+ return [props, {
34
+ onChange: function onChange(e) {
35
+ selectableRows.forEach(function (row) {
36
+ return row.toggleRowSelected(e.target.checked);
37
+ });
38
+ },
39
+ style: {
40
+ cursor: 'pointer'
41
+ },
42
+ checked: isAllRowsSelected,
43
+ disabled: instance.disableSelectAll,
44
+ title: 'Toggle All Rows Selected',
45
+ indeterminate: Boolean(!isAllRowsSelected && Object.keys(instance.state.selectedRowIds).length)
46
+ }];
47
+ };
48
+
49
+ hooks.getToggleAllRowsSelectedProps.push(getToggleAllRowsSelectedProps);
50
+ };
51
+
52
+ var updatePageSelectAll = function updatePageSelectAll(hooks) {
53
+ var getToggleAllPageRowsSelectedProps = function getToggleAllPageRowsSelectedProps(props, _ref4) {
54
+ var instance = _ref4.instance;
55
+ var selectableRows = instance.page.filter(function (row) {
56
+ return !(instance.shouldDisableSelectRow && instance.shouldDisableSelectRow(row));
57
+ });
58
+ var isAllRowsSelected = selectableRows.length > 0 && selectableRows.every(function (_ref5) {
59
+ var id = _ref5.id;
60
+ return instance.state.selectedRowIds[id];
61
+ });
62
+ return [props, {
63
+ onChange: function onChange(e) {
64
+ selectableRows.forEach(function (row) {
65
+ return row.toggleRowSelected(e.target.checked);
66
+ });
67
+ },
68
+ style: {
69
+ cursor: 'pointer'
70
+ },
71
+ checked: isAllRowsSelected,
72
+ disabled: instance.disableSelectAll,
73
+ title: 'Toggle All Rows Selected',
74
+ indeterminate: Boolean(!isAllRowsSelected && instance.page.some(function (_ref6) {
75
+ var id = _ref6.id;
76
+ return instance.state.selectedRowIds[id];
77
+ }))
78
+ }];
79
+ };
80
+
81
+ hooks.getToggleAllPageRowsSelectedProps.push(getToggleAllPageRowsSelectedProps);
82
+ };
83
+
84
+ export default useDisableSelectRows;
@@ -0,0 +1,52 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
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
+
8
+ /*
9
+ * Licensed Materials - Property of IBM
10
+ * 5724-Q36
11
+ * (c) Copyright IBM Corp. 2020
12
+ * US Government Users Restricted Rights - Use, duplication or disclosure
13
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
14
+ */
15
+ import { useState } from 'react';
16
+ import DatagridExpandedRow from './Datagrid/DatagridExpandedRow';
17
+ import useRowExpander from './useRowExpander';
18
+
19
+ var useExpandedRow = function useExpandedRow(hooks) {
20
+ useRowExpander(hooks);
21
+
22
+ var useInstance = function useInstance(instance) {
23
+ var rows = instance.rows,
24
+ expandedContentHeight = instance.expandedContentHeight,
25
+ ExpandedRowContentComponent = instance.ExpandedRowContentComponent;
26
+
27
+ var _useState = useState({}),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ expandedRowsHeight = _useState2[0],
30
+ setExpandedRowsHeight = _useState2[1];
31
+
32
+ var setExpandedRowHeight = function setExpandedRowHeight(rowIndex, height) {
33
+ return setExpandedRowsHeight(_objectSpread(_objectSpread({}, expandedRowsHeight), {}, _defineProperty({}, rowIndex, height)));
34
+ };
35
+
36
+ var rowsWithExpand = rows.map(function (row) {
37
+ return _objectSpread(_objectSpread({}, row), {}, {
38
+ canExpand: row.original && !row.original.notExpandable,
39
+ expandedContentHeight: expandedRowsHeight[row.index] || expandedContentHeight,
40
+ RowRenderer: DatagridExpandedRow(row.RowRenderer, ExpandedRowContentComponent)
41
+ });
42
+ });
43
+ Object.assign(instance, {
44
+ rows: rowsWithExpand,
45
+ setExpandedRowHeight: setExpandedRowHeight
46
+ });
47
+ };
48
+
49
+ hooks.useInstance.push(useInstance);
50
+ };
51
+
52
+ export default useExpandedRow;
@@ -0,0 +1,51 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+
3
+ /*
4
+ * Licensed Materials - Property of IBM
5
+ * 5724-Q36
6
+ * (c) Copyright IBM Corp. 2020
7
+ * US Government Users Restricted Rights - Use, duplication or disclosure
8
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
9
+ */
10
+ var useFlexResize = function useFlexResize(hooks) {
11
+ var spacerColumn = {
12
+ id: 'spacer',
13
+ width: 0,
14
+ disableSortBy: true,
15
+ disableResizing: true
16
+ };
17
+ hooks.visibleColumns.push(function (columns) {
18
+ return [].concat(_toConsumableArray(columns), [spacerColumn]);
19
+ });
20
+
21
+ var changeProps = function changeProps(props, data) {
22
+ var column = data.column;
23
+
24
+ if (!column && data.cell) {
25
+ column = data.cell.column;
26
+ }
27
+
28
+ if (column.id === spacerColumn.id) {
29
+ return [props, {
30
+ style: {
31
+ flex: '1 1 0'
32
+ }
33
+ }];
34
+ }
35
+
36
+ return [props, {
37
+ style: {
38
+ flex: '0 0 auto'
39
+ }
40
+ }];
41
+ };
42
+
43
+ hooks.getHeaderProps.push(function (props, data) {
44
+ return changeProps(props, data);
45
+ });
46
+ hooks.getCellProps.push(function (props, data) {
47
+ return changeProps(props, data);
48
+ });
49
+ };
50
+
51
+ export default useFlexResize;
@@ -0,0 +1,88 @@
1
+ /*
2
+ * Licensed Materials - Property of IBM
3
+ * 5724-Q36
4
+ * (c) Copyright IBM Corp. 2021
5
+ * US Government Users Restricted Rights - Use, duplication or disclosure
6
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
7
+ */
8
+ import { useEffect } from 'react';
9
+ import cx from 'classnames';
10
+ import { pkg } from '../../settings';
11
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
12
+
13
+ var useFloatingScroll = function useFloatingScroll(hooks) {
14
+ var useInstance = function useInstance(instance) {
15
+ var tableId = instance.tableId,
16
+ withVirtualScroll = instance.withVirtualScroll,
17
+ ExpandedRowContentComponent = instance.ExpandedRowContentComponent;
18
+ useEffect(function () {
19
+ // Floating scroll doesn't work with expanded rows and virtual scroll
20
+ if (withVirtualScroll || ExpandedRowContentComponent) {
21
+ return;
22
+ }
23
+
24
+ var datagrid = document.getElementById(tableId); // eslint-disable-next-line no-unused-expressions
25
+
26
+ datagrid === null || datagrid === void 0 ? void 0 : datagrid.classList.add("".concat(blockClass, "__sticky"));
27
+ }, [ExpandedRowContentComponent, tableId, withVirtualScroll]);
28
+ };
29
+
30
+ var useAddStickyClass = function useAddStickyClass(instance) {
31
+ var withVirtualScroll = instance.withVirtualScroll,
32
+ ExpandedRowContentComponent = instance.ExpandedRowContentComponent; // Floating scroll doesn't work with expanded rows and virtual scroll
33
+
34
+ if (withVirtualScroll || ExpandedRowContentComponent) {
35
+ return;
36
+ }
37
+
38
+ var addStickyClass = function addStickyClass(props) {
39
+ return [props, {
40
+ className: cx(props.className, "".concat(blockClass, "__sticky"))
41
+ }];
42
+ };
43
+
44
+ hooks.getTableProps.push(addStickyClass);
45
+ hooks.getTableBodyProps.push(addStickyClass);
46
+ hooks.getHeaderGroupProps.push(addStickyClass);
47
+ };
48
+
49
+ var useAddScrollListener = function useAddScrollListener(instance) {
50
+ var withVirtualScroll = instance.withVirtualScroll,
51
+ ExpandedRowContentComponent = instance.ExpandedRowContentComponent,
52
+ tableId = instance.tableId; // Floating scroll doesn't work with expanded rows and virtual scroll
53
+
54
+ if (withVirtualScroll || ExpandedRowContentComponent) {
55
+ return;
56
+ }
57
+
58
+ var memoHead;
59
+
60
+ var addOnScroll = function addOnScroll(props) {
61
+ return [props, {
62
+ onScroll: function onScroll(e) {
63
+ var simpleThead;
64
+
65
+ if (memoHead) {
66
+ simpleThead = memoHead;
67
+ } else {
68
+ var datagrid = document.getElementById(tableId);
69
+ simpleThead = datagrid === null || datagrid === void 0 ? void 0 : datagrid.querySelector(".".concat(blockClass, "__table-simple thead > div"));
70
+ memoHead = simpleThead;
71
+ }
72
+
73
+ if (simpleThead) {
74
+ simpleThead.scrollLeft = e.target.scrollLeft;
75
+ }
76
+ }
77
+ }];
78
+ };
79
+
80
+ hooks.getTableBodyProps.push(addOnScroll);
81
+ };
82
+
83
+ hooks.useInstance.push(useAddStickyClass);
84
+ hooks.useInstance.push(useAddScrollListener);
85
+ hooks.useInstance.push(useInstance);
86
+ };
87
+
88
+ export default useFloatingScroll;
@@ -0,0 +1,54 @@
1
+ /*
2
+ * Licensed Materials - Property of IBM
3
+ * 5724-Q36
4
+ * (c) Copyright IBM Corp. 2020
5
+ * US Government Users Restricted Rights - Use, duplication or disclosure
6
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
7
+ */
8
+ import { useCallback } from 'react';
9
+ import debounce from 'lodash/debounce';
10
+ import useParentDimensions from './useParentDimensions';
11
+ import useResizeTable from './useResizeTable';
12
+
13
+ var useInfiniteScroll = function useInfiniteScroll(hooks) {
14
+ useParentDimensions(hooks);
15
+ useResizeTable(hooks);
16
+
17
+ var useInstance = function useInstance(instance) {
18
+ var isFetching = instance.isFetching,
19
+ tableHeight = instance.tableHeight,
20
+ innerListRef = instance.innerListRef,
21
+ fetchMoreData = instance.fetchMoreData;
22
+ var loadMoreThreshold = 200;
23
+
24
+ var emptyFetchData = function emptyFetchData() {}; // eslint-disable-next-line react-hooks/exhaustive-deps
25
+
26
+
27
+ var fetchMore = useCallback(debounce(fetchMoreData || emptyFetchData, 3000, {
28
+ leading: true,
29
+ trailing: false
30
+ }), [fetchMoreData]);
31
+
32
+ var onScroll = function onScroll(_ref) {
33
+ var scrollDirection = _ref.scrollDirection,
34
+ scrollOffset = _ref.scrollOffset;
35
+
36
+ if (innerListRef && innerListRef.current) {
37
+ if (!isFetching && scrollDirection === 'forward' && scrollOffset + tableHeight >= innerListRef.current.clientHeight - loadMoreThreshold) {
38
+ if (fetchMoreData) {
39
+ fetchMore();
40
+ }
41
+ }
42
+ }
43
+ };
44
+
45
+ Object.assign(instance, {
46
+ onScroll: onScroll,
47
+ withVirtualScroll: true
48
+ });
49
+ };
50
+
51
+ hooks.useInstance.push(useInstance);
52
+ };
53
+
54
+ export default useInfiniteScroll;
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Licensed Materials - Property of IBM
3
+ * 5724-Q36
4
+ * (c) Copyright IBM Corp. 2020
5
+ * US Government Users Restricted Rights - Use, duplication or disclosure
6
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
7
+ */
8
+ import useRowExpander from './useRowExpander';
9
+ import { pkg } from '../../settings';
10
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
11
+
12
+ var useNestedRows = function useNestedRows(hooks) {
13
+ useRowExpander(hooks);
14
+ var marginLeft = 24;
15
+
16
+ var getRowProps = function getRowProps(props, _ref) {
17
+ var row = _ref.row;
18
+ return [props, {
19
+ className: row.depth > 0 ? "".concat(blockClass, "__carbon-nested-row") : ''
20
+ }];
21
+ };
22
+
23
+ var getRowStyles = function getRowStyles(props, _ref2) {
24
+ var row = _ref2.row;
25
+ return [props, {
26
+ style: {
27
+ marginLeft: "".concat(row.depth > 0 ? marginLeft : 0, "px"),
28
+ paddingLeft: "".concat(row.depth > 1 ? marginLeft * (row.depth - 1) + marginLeft : row.depth === 1 ? marginLeft : 0, "px"),
29
+ maxWidth: "calc(100% - ".concat(marginLeft * row.depth, "px)")
30
+ }
31
+ }];
32
+ };
33
+
34
+ var getCellProps = function getCellProps(props, _ref3) {
35
+ var cell = _ref3.cell,
36
+ instance = _ref3.instance;
37
+ // reduce the "first cell"s width to compensate added (left) margin
38
+ var isFirstCell = instance.columns.findIndex(function (c) {
39
+ return c.id === cell.column.id;
40
+ }) === 0;
41
+ return [props, {
42
+ style: {
43
+ marginRight: "".concat(isFirstCell && cell.row.depth > 0 ? "-".concat(marginLeft * (cell.row.depth + 1), "px") : '')
44
+ }
45
+ }];
46
+ };
47
+
48
+ hooks.getRowProps.push(getRowProps);
49
+ hooks.getRowProps.push(getRowStyles);
50
+ hooks.getCellProps.push(getCellProps);
51
+ };
52
+
53
+ export default useNestedRows;
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Licensed Materials - Property of IBM
3
+ * 5724-Q36
4
+ * (c) Copyright IBM Corp. 2020
5
+ * US Government Users Restricted Rights - Use, duplication or disclosure
6
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
7
+ */
8
+ var useOnRowClick = function useOnRowClick(hooks) {
9
+ var useInstance = function useInstance(instance) {
10
+ var onRowClick = instance.onRowClick;
11
+
12
+ var getRowProps = function getRowProps(props, datagridState) {
13
+ var isFetching = datagridState.isFetching,
14
+ row = datagridState.row;
15
+
16
+ var onClick = function onClick() {
17
+ if (!isFetching && onRowClick) {
18
+ onRowClick(row);
19
+ }
20
+ };
21
+
22
+ return [props, {
23
+ onClick: onClick
24
+ }, {
25
+ style: {
26
+ cursor: 'pointer'
27
+ }
28
+ }];
29
+ };
30
+
31
+ hooks.getRowProps.push(getRowProps);
32
+ };
33
+
34
+ hooks.useInstance.push(useInstance);
35
+ };
36
+
37
+ export default useOnRowClick;
@@ -0,0 +1,65 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+
3
+ /*
4
+ * Licensed Materials - Property of IBM
5
+ * 5724-Q36
6
+ * (c) Copyright IBM Corp. 2020
7
+ * US Government Users Restricted Rights - Use, duplication or disclosure
8
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
9
+ */
10
+ import { useRef, useState } from 'react';
11
+
12
+ var useParentDimensions = function useParentDimensions(hooks) {
13
+ var rootRef = useRef();
14
+ var headRef = useRef();
15
+ var innerListRef = useRef();
16
+ var listRef = useRef();
17
+
18
+ var _useState = useState(),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ tableHeight = _useState2[0],
21
+ setTableHeight = _useState2[1];
22
+
23
+ var useInstance = function useInstance(instance) {
24
+ var DatagridActions = instance.DatagridActions,
25
+ DatagridBatchActions = instance.DatagridBatchActions,
26
+ totalColumnsWidth = instance.totalColumnsWidth,
27
+ DatagridPagination = instance.DatagridPagination;
28
+
29
+ var handleResize = function handleResize() {
30
+ var parent = rootRef && rootRef.current && rootRef.current.parentElement;
31
+
32
+ if (!parent) {
33
+ return;
34
+ }
35
+
36
+ var parentHeight = parent.clientHeight;
37
+ var parentWidth = parent.clientWidth;
38
+ var headHeight = headRef && headRef.current && headRef.current.clientHeight;
39
+ var parentStyles = window.getComputedStyle(parent);
40
+ var parentMarginBottom = parseFloat(parentStyles.getPropertyValue('margin-bottom'));
41
+ var parentPaddingBottom = parseFloat(parentStyles.getPropertyValue('padding-bottom'));
42
+ var parentMarginTop = parseFloat(parentStyles.getPropertyValue('margin-top'));
43
+ var parentPaddingTop = parseFloat(parentStyles.getPropertyValue('padding-top'));
44
+ var datagridActionsHeight = DatagridActions || DatagridBatchActions ? 48 : 0;
45
+ var datagridPaginationHeight = DatagridPagination ? 48 : 0;
46
+ var hasHorizontalScrollbar = parentWidth < totalColumnsWidth;
47
+ var horizontalScrollbarHolder = hasHorizontalScrollbar ? 16 : 0;
48
+ var newHeight = parentHeight - headHeight - parentMarginBottom - parentPaddingBottom - parentMarginTop - parentPaddingTop - datagridActionsHeight - datagridPaginationHeight - horizontalScrollbarHolder;
49
+ setTableHeight(newHeight);
50
+ };
51
+
52
+ Object.assign(instance, {
53
+ tableHeight: tableHeight,
54
+ rootRef: rootRef,
55
+ headRef: headRef,
56
+ innerListRef: innerListRef,
57
+ handleResize: handleResize,
58
+ listRef: listRef
59
+ });
60
+ };
61
+
62
+ hooks.useInstance.push(useInstance);
63
+ };
64
+
65
+ export default useParentDimensions;
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Licensed Materials - Property of IBM
3
+ * 5724-Q36
4
+ * (c) Copyright IBM Corp. 2020
5
+ * US Government Users Restricted Rights - Use, duplication or disclosure
6
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
7
+ */
8
+ import { useLayoutEffect } from 'react';
9
+
10
+ var useResizeTable = function useResizeTable(hooks) {
11
+ var useInstanceBeforeDimensions = function useInstanceBeforeDimensions(instance) {
12
+ var rootRef = instance.rootRef,
13
+ handleResize = instance.handleResize;
14
+ var parent = rootRef && rootRef.current && rootRef.current.parentElement;
15
+ useLayoutEffect(function () {
16
+ if (!parent) {
17
+ return function () {};
18
+ }
19
+
20
+ handleResize();
21
+
22
+ if (typeof ResizeObserver === 'function') {
23
+ var resizeObserver = new ResizeObserver(function () {
24
+ handleResize();
25
+ });
26
+ resizeObserver.observe(parent);
27
+ return function () {
28
+ resizeObserver.disconnect(parent);
29
+ resizeObserver = null;
30
+ };
31
+ }
32
+
33
+ return console.error(' Could not resize table, no support for ResizeObserver');
34
+ }, [handleResize, parent]);
35
+ };
36
+
37
+ hooks.useInstanceBeforeDimensions.push(useInstanceBeforeDimensions);
38
+ };
39
+
40
+ export default useResizeTable;
@@ -0,0 +1,34 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+
3
+ /* eslint-disable react/prop-types */
4
+
5
+ /*
6
+ * Licensed Materials - Property of IBM
7
+ * 5724-Q36
8
+ * (c) Copyright IBM Corp. 2020
9
+ * US Government Users Restricted Rights - Use, duplication or disclosure
10
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
11
+ */
12
+ import React from 'react';
13
+ import { ChevronDown16, ChevronUp16 } from '@carbon/icons-react';
14
+
15
+ var useRowExpander = function useRowExpander(hooks) {
16
+ var visibleColumns = function visibleColumns(columns) {
17
+ var expanderColumn = {
18
+ id: 'expander',
19
+ Cell: function Cell(_ref) {
20
+ var row = _ref.row;
21
+ return row.canExpand && /*#__PURE__*/React.createElement("span", row.getToggleRowExpandedProps(), row.isExpanded ? /*#__PURE__*/React.createElement(ChevronUp16, null) : /*#__PURE__*/React.createElement(ChevronDown16, null));
22
+ },
23
+ width: 48,
24
+ disableResizing: true,
25
+ disableSortBy: true,
26
+ Header: ''
27
+ };
28
+ return [expanderColumn].concat(_toConsumableArray(columns));
29
+ };
30
+
31
+ hooks.visibleColumns.push(visibleColumns);
32
+ };
33
+
34
+ export default useRowExpander;
@@ -0,0 +1,61 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
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
+
8
+ /*
9
+ * Licensed Materials - Property of IBM
10
+ * 5724-Q36
11
+ * (c) Copyright IBM Corp. 2020
12
+ * US Government Users Restricted Rights - Use, duplication or disclosure
13
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
14
+ */
15
+ import { useState, useCallback } from 'react';
16
+ import debounce from 'lodash/debounce';
17
+
18
+ var useRowIsMouseOver = function useRowIsMouseOver(hooks) {
19
+ var useInstance = function useInstance(instance) {
20
+ var _useState = useState(),
21
+ _useState2 = _slicedToArray(_useState, 2),
22
+ mouseOverRowIndex = _useState2[0],
23
+ setMouseOverRowIndex = _useState2[1];
24
+
25
+ var onMouseChange = useDebounce(function (datagridState) {
26
+ var row = datagridState.row;
27
+ setMouseOverRowIndex(row.index);
28
+ }, 100);
29
+
30
+ var getRowProps = function getRowProps(props, datagridState) {
31
+ var onMouseOver = function onMouseOver() {
32
+ return onMouseChange(datagridState);
33
+ };
34
+
35
+ return [props, {
36
+ onMouseOver: onMouseOver
37
+ }];
38
+ };
39
+
40
+ var rows = instance.rows;
41
+ var rowsWithMouseOver = rows.map(function (row) {
42
+ return _objectSpread(_objectSpread({}, row), {}, {
43
+ isMouseOver: row.index === mouseOverRowIndex
44
+ });
45
+ });
46
+ Object.assign(instance, {
47
+ rows: rowsWithMouseOver
48
+ });
49
+ hooks.getRowProps.push(getRowProps);
50
+ };
51
+
52
+ hooks.useInstance.push(useInstance);
53
+ };
54
+
55
+ var useDebounce = function useDebounce(fn, wait) {
56
+ return (// eslint-disable-next-line react-hooks/exhaustive-deps
57
+ useCallback(debounce(fn, wait), [])
58
+ );
59
+ };
60
+
61
+ export default useRowIsMouseOver;
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Licensed Materials - Property of IBM
3
+ * 5724-Q36
4
+ * (c) Copyright IBM Corp. 2020
5
+ * US Government Users Restricted Rights - Use, duplication or disclosure
6
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
7
+ */
8
+ import DatagridRow from './Datagrid/DatagridRow';
9
+
10
+ var useRowRenderer = function useRowRenderer(hooks) {
11
+ var useInstance = function useInstance(instance) {
12
+ var rows = instance.rows;
13
+
14
+ var addRowRenderer = function addRowRenderer(row) {
15
+ return Object.assign(row, {
16
+ RowRenderer: DatagridRow,
17
+ subRows: (row.subRows || []).map(addRowRenderer)
18
+ });
19
+ };
20
+
21
+ var rowsWithRenderer = rows.map(addRowRenderer);
22
+ Object.assign(instance, {
23
+ rows: rowsWithRenderer
24
+ });
25
+ };
26
+
27
+ hooks.useInstance.push(useInstance);
28
+ };
29
+
30
+ export default useRowRenderer;