@carbon/ibm-products 1.13.0 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) 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 +264 -0
  6. package/css/components/Datagrid/styles/datagrid.css.map +1 -0
  7. package/css/components/Datagrid/styles/index.css +509 -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 +570 -3
  24. package/css/index-full-carbon.css.map +1 -1
  25. package/css/index-full-carbon.min.css +2 -2
  26. package/css/index-full-carbon.min.css.map +1 -1
  27. package/css/index-without-carbon-released-only.css +3 -0
  28. package/css/index-without-carbon-released-only.css.map +1 -1
  29. package/css/index-without-carbon-released-only.min.css +1 -1
  30. package/css/index-without-carbon-released-only.min.css.map +1 -1
  31. package/css/index-without-carbon.css +570 -3
  32. package/css/index-without-carbon.css.map +1 -1
  33. package/css/index-without-carbon.min.css +2 -2
  34. package/css/index-without-carbon.min.css.map +1 -1
  35. package/css/index.css +570 -3
  36. package/css/index.css.map +1 -1
  37. package/css/index.min.css +2 -2
  38. package/css/index.min.css.map +1 -1
  39. package/es/components/AddSelect/AddSelect.js +76 -24
  40. package/es/components/AddSelect/AddSelectFilter.js +129 -0
  41. package/es/components/AddSelect/add-select-utils.js +30 -0
  42. package/es/components/DataSpreadsheet/DataSpreadsheet.js +77 -53
  43. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +22 -9
  44. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +15 -11
  45. package/es/components/DataSpreadsheet/hooks/index.js +10 -0
  46. package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +111 -0
  47. package/es/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
  48. package/es/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +1 -3
  49. package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +80 -6
  50. package/es/components/Datagrid/Datagrid/Datagrid.js +70 -0
  51. package/es/components/Datagrid/Datagrid/DatagridBody.js +36 -0
  52. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +19 -0
  53. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -0
  54. package/es/components/Datagrid/Datagrid/DatagridHead.js +31 -0
  55. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +57 -0
  56. package/es/components/Datagrid/Datagrid/DatagridRefBody.js +37 -0
  57. package/es/components/Datagrid/Datagrid/DatagridRow.js +50 -0
  58. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +50 -0
  59. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +122 -0
  60. package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +36 -0
  61. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +22 -0
  62. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +87 -0
  63. package/es/components/Datagrid/Datagrid/DraggableElement.js +188 -0
  64. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +78 -0
  65. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +51 -0
  66. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +140 -0
  67. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +157 -0
  68. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +62 -0
  69. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +13 -0
  70. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +9 -0
  71. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +62 -0
  72. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +139 -0
  73. package/es/components/Datagrid/Datagrid/addons/RowSize/index.js +8 -0
  74. package/es/components/Datagrid/Datagrid/index.js +8 -0
  75. package/es/components/Datagrid/Datagrid.stories/CustomizeColumnStory.js +6 -0
  76. package/es/components/Datagrid/Datagrid.stories/LeftPanelStory.js +6 -0
  77. package/es/components/Datagrid/Datagrid.stories/RowSizeDropdownStory.js +6 -0
  78. package/es/components/Datagrid/Datagrid.stories/SelectAllWithToggleStory.js +6 -0
  79. package/es/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +92 -0
  80. package/es/components/Datagrid/Datagrid.stories/common.js +199 -0
  81. package/es/components/Datagrid/Datagrid.stories/index.js +5 -0
  82. package/es/components/Datagrid/common-column-ids.js +8 -0
  83. package/es/components/Datagrid/index.js +22 -0
  84. package/es/components/Datagrid/useActionsColumn.js +86 -0
  85. package/es/components/Datagrid/useColumnRightAlign.js +52 -0
  86. package/es/components/Datagrid/useCustomizeColumns.js +45 -0
  87. package/es/components/Datagrid/useDatagrid.js +44 -0
  88. package/es/components/Datagrid/useDefaultStringRenderer.js +48 -0
  89. package/es/components/Datagrid/useDisableSelectRows.js +84 -0
  90. package/es/components/Datagrid/useExpandedRow.js +52 -0
  91. package/es/components/Datagrid/useFlexResize.js +51 -0
  92. package/es/components/Datagrid/useFloatingScroll.js +88 -0
  93. package/es/components/Datagrid/useInfiniteScroll.js +54 -0
  94. package/es/components/Datagrid/useNestedRows.js +53 -0
  95. package/es/components/Datagrid/useOnRowClick.js +37 -0
  96. package/es/components/Datagrid/useParentDimensions.js +65 -0
  97. package/es/components/Datagrid/useResizeTable.js +40 -0
  98. package/es/components/Datagrid/useRowExpander.js +34 -0
  99. package/es/components/Datagrid/useRowIsMouseOver.js +61 -0
  100. package/es/components/Datagrid/useRowRenderer.js +30 -0
  101. package/es/components/Datagrid/useRowSize.js +56 -0
  102. package/es/components/Datagrid/useSelectAllToggle.js +74 -0
  103. package/es/components/Datagrid/useSelectRows.js +107 -0
  104. package/es/components/Datagrid/useSkeletonRows.js +32 -0
  105. package/es/components/Datagrid/useSortableColumns.js +110 -0
  106. package/es/components/Datagrid/useStickyColumn.js +183 -0
  107. package/es/components/index.js +2 -1
  108. package/es/global/js/package-settings.js +2 -1
  109. package/lib/components/AddSelect/AddSelect.js +75 -22
  110. package/lib/components/AddSelect/AddSelectFilter.js +147 -0
  111. package/lib/components/AddSelect/add-select-utils.js +35 -2
  112. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +79 -56
  113. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +22 -15
  114. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +15 -11
  115. package/lib/components/DataSpreadsheet/hooks/index.js +37 -0
  116. package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +123 -0
  117. package/lib/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
  118. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +1 -3
  119. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +83 -7
  120. package/lib/components/Datagrid/Datagrid/Datagrid.js +86 -0
  121. package/lib/components/Datagrid/Datagrid/DatagridBody.js +50 -0
  122. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +31 -0
  123. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +38 -0
  124. package/lib/components/Datagrid/Datagrid/DatagridHead.js +43 -0
  125. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +73 -0
  126. package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +44 -0
  127. package/lib/components/Datagrid/Datagrid/DatagridRow.js +56 -0
  128. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +55 -0
  129. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +139 -0
  130. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +44 -0
  131. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +35 -0
  132. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +101 -0
  133. package/lib/components/Datagrid/Datagrid/DraggableElement.js +210 -0
  134. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +92 -0
  135. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +65 -0
  136. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +166 -0
  137. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +173 -0
  138. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +73 -0
  139. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +25 -0
  140. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +23 -0
  141. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +80 -0
  142. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +160 -0
  143. package/lib/components/Datagrid/Datagrid/addons/RowSize/index.js +15 -0
  144. package/lib/components/Datagrid/Datagrid/index.js +15 -0
  145. package/lib/components/Datagrid/Datagrid.stories/CustomizeColumnStory.js +13 -0
  146. package/lib/components/Datagrid/Datagrid.stories/LeftPanelStory.js +13 -0
  147. package/lib/components/Datagrid/Datagrid.stories/RowSizeDropdownStory.js +13 -0
  148. package/lib/components/Datagrid/Datagrid.stories/SelectAllWithToggleStory.js +13 -0
  149. package/lib/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +112 -0
  150. package/lib/components/Datagrid/Datagrid.stories/common.js +215 -0
  151. package/lib/components/Datagrid/Datagrid.stories/index.js +47 -0
  152. package/lib/components/Datagrid/common-column-ids.js +16 -0
  153. package/lib/components/Datagrid/index.js +127 -0
  154. package/lib/components/Datagrid/useActionsColumn.js +94 -0
  155. package/lib/components/Datagrid/useColumnRightAlign.js +59 -0
  156. package/lib/components/Datagrid/useCustomizeColumns.js +55 -0
  157. package/lib/components/Datagrid/useDatagrid.js +58 -0
  158. package/lib/components/Datagrid/useDefaultStringRenderer.js +54 -0
  159. package/lib/components/Datagrid/useDisableSelectRows.js +92 -0
  160. package/lib/components/Datagrid/useExpandedRow.js +58 -0
  161. package/lib/components/Datagrid/useFlexResize.js +61 -0
  162. package/lib/components/Datagrid/useFloatingScroll.js +101 -0
  163. package/lib/components/Datagrid/useInfiniteScroll.js +67 -0
  164. package/lib/components/Datagrid/useNestedRows.js +65 -0
  165. package/lib/components/Datagrid/useOnRowClick.js +45 -0
  166. package/lib/components/Datagrid/useParentDimensions.js +75 -0
  167. package/lib/components/Datagrid/useResizeTable.js +48 -0
  168. package/lib/components/Datagrid/useRowExpander.js +45 -0
  169. package/lib/components/Datagrid/useRowIsMouseOver.js +66 -0
  170. package/lib/components/Datagrid/useRowRenderer.js +40 -0
  171. package/lib/components/Datagrid/useRowSize.js +67 -0
  172. package/lib/components/Datagrid/useSelectAllToggle.js +88 -0
  173. package/lib/components/Datagrid/useSelectRows.js +119 -0
  174. package/lib/components/Datagrid/useSkeletonRows.js +42 -0
  175. package/lib/components/Datagrid/useSortableColumns.js +117 -0
  176. package/lib/components/Datagrid/useStickyColumn.js +190 -0
  177. package/lib/components/index.js +9 -1
  178. package/lib/global/js/package-settings.js +2 -1
  179. package/package.json +6 -2
  180. package/scss/components/AddSelect/_add-select.scss +37 -0
  181. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +13 -3
  182. package/scss/components/Datagrid/_datagrid.scss +66 -0
  183. package/scss/components/Datagrid/_index.scss +8 -0
  184. package/scss/components/Datagrid/_storybook-styles.scss +26 -0
  185. package/scss/components/Datagrid/styles/_variables.scss +9 -0
  186. package/scss/components/Datagrid/styles/addons/CustomizeColumnsModal.scss +48 -0
  187. package/scss/components/Datagrid/styles/addons/RowSizeDropdown.scss +23 -0
  188. package/scss/components/Datagrid/styles/datagrid.scss +318 -0
  189. package/scss/components/Datagrid/styles/index.scss +17 -0
  190. package/scss/components/Datagrid/styles/useActionsColumn.scss +24 -0
  191. package/scss/components/Datagrid/styles/useColumnRightAlign.scss +29 -0
  192. package/scss/components/Datagrid/styles/useNestedRows.scss +17 -0
  193. package/scss/components/Datagrid/styles/useNestedTable.scss +28 -0
  194. package/scss/components/Datagrid/styles/useSelectAllToggle.scss +28 -0
  195. package/scss/components/Datagrid/styles/useSortableColumns.scss +55 -0
  196. package/scss/components/Datagrid/styles/useStickyColumn.scss +38 -0
  197. package/scss/components/Tearsheet/_tearsheet.scss +4 -0
  198. package/scss/components/_index.scss +1 -0
@@ -0,0 +1,92 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
+ import React, { useState, useEffect } from 'react';
4
+ import { Datagrid, useActionsColumn, useDatagrid, useStickyColumn } from '..';
5
+ import { defaultHeader, makeData, Wrapper } from './common';
6
+
7
+ var StickyActionsColumn = function StickyActionsColumn() {
8
+ var columns = React.useMemo(function () {
9
+ return [].concat(_toConsumableArray(defaultHeader), [{
10
+ Header: '',
11
+ accessor: 'actions',
12
+ sticky: 'right',
13
+ width: 60,
14
+ isAction: true
15
+ }]);
16
+ }, []);
17
+
18
+ var _useState = useState([]),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ data = _useState2[0],
21
+ setData = _useState2[1];
22
+
23
+ var _useState3 = useState('click action menu'),
24
+ _useState4 = _slicedToArray(_useState3, 2),
25
+ msg = _useState4[0],
26
+ setMsg = _useState4[1];
27
+
28
+ var onActionClick = function onActionClick(actionId, row) {
29
+ var original = row.original;
30
+ setMsg("Clicked [".concat(actionId, "] on row: <").concat(original.firstName, " ").concat(original.lastName, ">"));
31
+ };
32
+
33
+ var _useState5 = useState(true),
34
+ _useState6 = _slicedToArray(_useState5, 2),
35
+ isFetching = _useState6[0],
36
+ setIsFetching = _useState6[1];
37
+
38
+ useEffect(function () {
39
+ var fetchData = function fetchData() {
40
+ return new Promise(function (resolve) {
41
+ setIsFetching(true);
42
+ setTimeout(function () {
43
+ setData(data.concat(makeData(30, 5, 2)));
44
+ resolve();
45
+ }, 1000);
46
+ }).then(function () {
47
+ return setIsFetching(false);
48
+ });
49
+ };
50
+
51
+ fetchData();
52
+ }, [data]);
53
+ var datagridState = useDatagrid({
54
+ columns: columns,
55
+ data: data,
56
+ isFetching: isFetching,
57
+ rowActions: [{
58
+ id: 'edit',
59
+ itemText: 'Edit',
60
+ onClick: onActionClick
61
+ }, {
62
+ id: 'vote',
63
+ itemText: 'Vote',
64
+ onClick: onActionClick,
65
+ shouldHideMenuItem: function shouldHideMenuItem(row) {
66
+ return row.original.age <= 18;
67
+ }
68
+ }, {
69
+ id: 'retire',
70
+ itemText: 'Retire',
71
+ onClick: onActionClick,
72
+ disabled: false,
73
+ shouldDisableMenuItem: function shouldDisableMenuItem(row) {
74
+ return row.original.age <= 60;
75
+ }
76
+ }, {
77
+ id: 'delete',
78
+ itemText: 'Delete',
79
+ hasDivider: true,
80
+ isDelete: true,
81
+ onClick: onActionClick
82
+ }]
83
+ }, useStickyColumn, useActionsColumn);
84
+ return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement("h3", null, msg), /*#__PURE__*/React.createElement(Datagrid, datagridState), /*#__PURE__*/React.createElement("p", null, "More details documentation check the Notes section below"));
85
+ };
86
+
87
+ StickyActionsColumn.story = {
88
+ parameters: {
89
+ notes: "\n Sticky column and actions column can be used at the same time like the demo above. Following is the doc for each of them.\n\n # Sticky column\n This will make the column mark with `sticky: \"right\"` to be sticky on the right.\n\n ## Incompatible with following plugins:\n - `useInfiniteScroll`\n\n ## Sample usage:\n \n 1. include the `useStickyColumn` hook\n 2. add `sticky=\"right\"` to the column object\n\n ```js\n const columns = [\n ... // other columns\n {\n Header: \"\",\n accessor: \"actions\",\n sticky: \"right\",\n width: 60,\n },\n ]\n const datagridState = useDatagrid(\n {\n columns,\n data,\n },\n useStickyColumn\n );\n ```\n ```html\n <Datagrid {...datagridState} />\n ```\n\n # Actions column\n This will add OverflowMenu component to the cells on the column mark with `isAction: true`. Each action button callback will include the actionId and row object\n\n ## Sample usage:\n 1. include `useActionsColumn` hook\n 2. add `isAction = true` to the column object in which you which to add the overflow menu actions\n 3. add `rowActions = []` array to the props\n - `rowActions[].id` for callback to identify the action is called\n - `rowActions[].onClick(actionId: string, row: Row, event: ClickEvent)` callback on menuitem clicked. [Row properties](https://react-table.tanstack.com/docs/api/useTable#row-properties)\n - `rowActions[].shouldHideMenuItem(row: Row)` callback to hide this menuitem. [Row properties](https://react-table.tanstack.com/docs/api/useTable#row-properties)\n - `rowActions[].shouldDisableMenuItem(row: Row)` callback to disable this menuitem. [Row properties](https://react-table.tanstack.com/docs/api/useTable#row-properties)\n - This will override `rowActions[].disabled` (from Carbon) because `shouldDisableMenuItem` is more specific to the row.\n - each action object can take all the props from `OverflowMenuItem` props, see [carbon docs](https://react.carbondesignsystem.com/?path=/docs/components-overflowmenu--default#overflowmenu)\n\n ```js\n const columns = [\n ... // other columns\n {\n Header: \"\",\n accessor: \"actions\",\n isAction: true,\n },\n ]\n const onActionClick = (actionId, row, event) => {};\n const datagridState = useDatagrid(\n {\n columns,\n data,\n rowActions: [\n {\n id: 'edit',\n itemText: 'Edit',\n onClick: onActionClick\n },\n {\n id: 'hidden',\n itemText: 'Hidden item',\n onClick: onActionClick,\n shouldHideMenuItem: () => true,\n },\n {\n id: 'delete',\n itemText: 'Delete',\n hasDivider: true,\n isDelete: true,\n onClick: onActionClick\n },\n ]\n },\n useActionsColumn,\n );\n ```\n ```html\n <Datagrid {...datagridState} />\n ```\n "
90
+ }
91
+ };
92
+ export default StickyActionsColumn;
@@ -0,0 +1,199 @@
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
+ import React from 'react';
8
+ import namor from 'namor';
9
+
10
+ var range = function range(len) {
11
+ var arr = [];
12
+
13
+ for (var i = 0; i < len; i++) {
14
+ arr.push(i);
15
+ }
16
+
17
+ return arr;
18
+ };
19
+
20
+ var newPerson = function newPerson() {
21
+ var statusChance = Math.random();
22
+ return {
23
+ firstName: namor.generate({
24
+ words: 1,
25
+ numbers: 0
26
+ }),
27
+ lastName: namor.generate({
28
+ words: 1,
29
+ numbers: 0
30
+ }),
31
+ age: Math.floor(Math.random() * 30),
32
+ visits: Math.floor(Math.random() * 100),
33
+ progress: Math.floor(Math.random() * 100),
34
+ someone1: namor.generate({
35
+ words: 1,
36
+ numbers: 0
37
+ }),
38
+ someone2: namor.generate({
39
+ words: 1,
40
+ numbers: 0
41
+ }),
42
+ someone3: namor.generate({
43
+ words: 1,
44
+ numbers: 0
45
+ }),
46
+ someone4: namor.generate({
47
+ words: 1,
48
+ numbers: 0
49
+ }),
50
+ someone5: namor.generate({
51
+ words: 1,
52
+ numbers: 0
53
+ }),
54
+ someone6: namor.generate({
55
+ words: 1,
56
+ numbers: 0
57
+ }),
58
+ someone7: namor.generate({
59
+ words: 1,
60
+ numbers: 0
61
+ }),
62
+ someone8: namor.generate({
63
+ words: 1,
64
+ numbers: 0
65
+ }),
66
+ someone9: namor.generate({
67
+ words: 1,
68
+ numbers: 0
69
+ }),
70
+ someone10: namor.generate({
71
+ words: 1,
72
+ numbers: 0
73
+ }),
74
+ someone11: namor.generate({
75
+ words: 1,
76
+ numbers: 0
77
+ }),
78
+ someone12: namor.generate({
79
+ words: 1,
80
+ numbers: 0
81
+ }),
82
+ someone13: namor.generate({
83
+ words: 1,
84
+ numbers: 0
85
+ }),
86
+ someone14: namor.generate({
87
+ words: 1,
88
+ numbers: 0
89
+ }),
90
+ someone15: namor.generate({
91
+ words: 1,
92
+ numbers: 0
93
+ }),
94
+ someone16: namor.generate({
95
+ words: 1,
96
+ numbers: 0
97
+ }),
98
+ someone17: namor.generate({
99
+ words: 1,
100
+ numbers: 0
101
+ }),
102
+ someone18: namor.generate({
103
+ words: 1,
104
+ numbers: 0
105
+ }),
106
+ someone19: namor.generate({
107
+ words: 1,
108
+ numbers: 0
109
+ }),
110
+ someone20: namor.generate({
111
+ words: 1,
112
+ numbers: 0
113
+ }),
114
+ status: statusChance > 0.66 ? 'relationship' : statusChance > 0.33 ? 'complicated' : 'single'
115
+ };
116
+ }; // eslint-disable-next-line react/prop-types
117
+
118
+
119
+ export var Wrapper = function Wrapper(_ref) {
120
+ var children = _ref.children;
121
+ return /*#__PURE__*/React.createElement("div", {
122
+ style: {
123
+ height: '490px',
124
+ width: '100%',
125
+ padding: '16px',
126
+ margin: '0',
127
+ zIndex: '0'
128
+ }
129
+ }, children);
130
+ };
131
+ export var makeData = function makeData() {
132
+ for (var _len = arguments.length, lens = new Array(_len), _key = 0; _key < _len; _key++) {
133
+ lens[_key] = arguments[_key];
134
+ }
135
+
136
+ var makeDataLevel = function makeDataLevel() {
137
+ var depth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
138
+ var len = lens[depth];
139
+ return range(len).map(function () {
140
+ return _objectSpread(_objectSpread({}, newPerson()), {}, {
141
+ subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined
142
+ });
143
+ });
144
+ };
145
+
146
+ return makeDataLevel();
147
+ };
148
+ export var defaultHeader = [{
149
+ Header: 'Row Index',
150
+ accessor: function accessor(row, i) {
151
+ return i;
152
+ },
153
+ sticky: 'left'
154
+ }, {
155
+ Header: 'First Name',
156
+ accessor: 'firstName',
157
+ sticky: 'left'
158
+ }, {
159
+ Header: 'Last Name',
160
+ accessor: 'lastName'
161
+ }, {
162
+ Header: 'Age',
163
+ accessor: 'age',
164
+ width: 50
165
+ }, {
166
+ Header: 'Visits',
167
+ accessor: 'visits',
168
+ width: 60
169
+ }, {
170
+ Header: 'Someone 1',
171
+ accessor: 'someone1'
172
+ }, {
173
+ Header: 'Someone 2',
174
+ accessor: 'someone2'
175
+ }, {
176
+ Header: 'Someone 3',
177
+ accessor: 'someone3'
178
+ }, {
179
+ Header: 'Someone 4',
180
+ accessor: 'someone4'
181
+ }, {
182
+ Header: 'Someone 5',
183
+ accessor: 'someone5'
184
+ }, {
185
+ Header: 'Someone 6',
186
+ accessor: 'someone6'
187
+ }, {
188
+ Header: 'Someone 7',
189
+ accessor: 'someone7'
190
+ }, {
191
+ Header: 'Someone 8',
192
+ accessor: 'someone8'
193
+ }, {
194
+ Header: 'Someone 9',
195
+ accessor: 'someone9'
196
+ }, {
197
+ Header: 'Someone 10',
198
+ accessor: 'someone10'
199
+ }];
@@ -0,0 +1,5 @@
1
+ export { story as CustomizeColumnStory } from './CustomizeColumnStory';
2
+ export { default as StickyActionsColumn } from './StickyActionsColumnStory';
3
+ export { story as RowSizeDropdownStory } from './RowSizeDropdownStory';
4
+ export { story as LeftPanelStory } from './LeftPanelStory';
5
+ export { story as SelectAllWitHToggle } from './SelectAllWithToggleStory';
@@ -0,0 +1,8 @@
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
+ export var selectionColumnId = 'datagridSelection';
@@ -0,0 +1,22 @@
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
+ export { default as Datagrid } from './Datagrid';
9
+ export { default as useDatagrid } from './useDatagrid';
10
+ export { default as useInfiniteScroll } from './useInfiniteScroll';
11
+ export { default as useNestedRows } from './useNestedRows';
12
+ export { default as useSelectRows } from './useSelectRows';
13
+ export { default as useExpandedRow } from './useExpandedRow';
14
+ export { default as useOnRowClick } from './useOnRowClick';
15
+ export { default as useSortableColumns } from './useSortableColumns';
16
+ export { default as useRowIsMouseOver } from './useRowIsMouseOver';
17
+ export { default as useColumnRightAlign } from './useColumnRightAlign';
18
+ export { default as useDisableSelectRows } from './useDisableSelectRows';
19
+ export { default as useStickyColumn } from './useStickyColumn';
20
+ export { default as useActionsColumn } from './useActionsColumn';
21
+ export { default as useCustomizeColumns } from './useCustomizeColumns';
22
+ export { default as useSelectAllWithToggle } from './useSelectAllToggle';
@@ -0,0 +1,86 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["id", "onClick", "shouldHideMenuItem", "shouldDisableMenuItem", "disabled"];
5
+
6
+ /*
7
+ * Licensed Materials - Property of IBM
8
+ * 5724-Q36
9
+ * (c) Copyright IBM Corp. 2021
10
+ * US Government Users Restricted Rights - Use, duplication or disclosure
11
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
12
+ */
13
+ import React from 'react';
14
+ import cx from 'classnames';
15
+ import { IconSkeleton, OverflowMenu, OverflowMenuItem } from 'carbon-components-react';
16
+ import { pkg } from '../../settings';
17
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
18
+
19
+ var useActionsColumn = function useActionsColumn(hooks) {
20
+ var useAttachActionsOnInstance = function useAttachActionsOnInstance(instance) {
21
+ var rowActions = instance.rowActions,
22
+ isFetching = instance.isFetching;
23
+
24
+ if (rowActions && Array.isArray(rowActions)) {
25
+ var addActionsMenu = function addActionsMenu(props, cellData) {
26
+ var cell = cellData.cell;
27
+ var row = cell.row,
28
+ column = cell.column;
29
+
30
+ if (column.isAction) {
31
+ var _cx;
32
+
33
+ return [props, {
34
+ children: /*#__PURE__*/React.createElement("div", {
35
+ className: "".concat(blockClass, "__actions-column-content")
36
+ }, isFetching && /*#__PURE__*/React.createElement(IconSkeleton, {
37
+ className: "".concat(blockClass, "__actions-column-loading")
38
+ }), !isFetching && /*#__PURE__*/React.createElement(OverflowMenu, {
39
+ size: "sm",
40
+ light: true,
41
+ flipped: true,
42
+ onClick: function onClick(e) {
43
+ return e.stopPropagation();
44
+ }
45
+ }, rowActions.map(function (action) {
46
+ var id = action.id,
47
+ _onClick = action.onClick,
48
+ shouldHideMenuItem = action.shouldHideMenuItem,
49
+ shouldDisableMenuItem = action.shouldDisableMenuItem,
50
+ disabled = action.disabled,
51
+ rest = _objectWithoutProperties(action, _excluded);
52
+
53
+ var hidden = typeof shouldHideMenuItem === 'function' && shouldHideMenuItem(row); // shouldDisableMenuItem will override disabled because it's more specific
54
+ // if shouldDisableMenuItem doesn't exists, fall back to disabled
55
+
56
+ var isDisabledByRow = typeof shouldDisableMenuItem === 'function' ? shouldDisableMenuItem(row) : disabled;
57
+
58
+ if (hidden) {
59
+ return null;
60
+ }
61
+
62
+ return /*#__PURE__*/React.createElement(OverflowMenuItem, _extends({}, rest, {
63
+ disabled: isDisabledByRow,
64
+ onClick: function onClick(e) {
65
+ e.stopPropagation();
66
+
67
+ _onClick(id, row, e);
68
+ },
69
+ key: id
70
+ }));
71
+ }))),
72
+ className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__actions-column-cell"), true), _defineProperty(_cx, "".concat(blockClass, "__cell"), true), _cx))
73
+ }];
74
+ }
75
+
76
+ return [props];
77
+ };
78
+
79
+ hooks.getCellProps.push(addActionsMenu);
80
+ }
81
+ };
82
+
83
+ hooks.useInstance.push(useAttachActionsOnInstance);
84
+ };
85
+
86
+ export default useActionsColumn;
@@ -0,0 +1,52 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
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 React from 'react';
16
+ import cx from 'classnames';
17
+ import { pkg } from '../../settings';
18
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
19
+
20
+ var useColumnRightAlign = function useColumnRightAlign(hooks) {
21
+ var RightAlignRenderer = function RightAlignRenderer(tableProps, column) {
22
+ return /*#__PURE__*/React.createElement("div", {
23
+ className: cx("".concat(blockClass, "__right-align-cell-renderer"), {
24
+ sortDisabled: !tableProps.isTableSortable || tableProps.column.disableSortBy === true
25
+ })
26
+ }, column.Cell(tableProps));
27
+ };
28
+
29
+ var RightAlignHeader = function RightAlignHeader(headerProp, column) {
30
+ return /*#__PURE__*/React.createElement("div", {
31
+ className: "".concat(blockClass, "__right-align-header")
32
+ }, typeof column.Header === 'function' ? column.Header(headerProp) : column.Header);
33
+ };
34
+
35
+ var rightAlignedColumns = function rightAlignedColumns(columns) {
36
+ var columnsWithDefaultCells = columns.map(function (column) {
37
+ return _objectSpread(_objectSpread({}, column), {}, {
38
+ Cell: column.rightAlignedColumn ? function (tableProp) {
39
+ return RightAlignRenderer(tableProp, column);
40
+ } : column.Cell,
41
+ Header: column.rightAlignedColumn ? function (headerProp) {
42
+ return RightAlignHeader(headerProp, column);
43
+ } : column.Header
44
+ });
45
+ });
46
+ return _toConsumableArray(columnsWithDefaultCells);
47
+ };
48
+
49
+ hooks.visibleColumns.push(rightAlignedColumns);
50
+ };
51
+
52
+ export default useColumnRightAlign;
@@ -0,0 +1,45 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+
5
+ 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; }
6
+
7
+ 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; }
8
+
9
+ // @flow
10
+
11
+ /*
12
+ * Licensed Materials - Property of IBM
13
+ * 5724-Q36
14
+ * (c) Copyright IBM Corp. 2021
15
+ * US Government Users Restricted Rights - Use, duplication or disclosure
16
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
17
+ */
18
+ import * as React from 'react';
19
+ import { CustomizeColumnsModalWrapper, ToggleButtonWrapper } from './Datagrid/addons/CustomizeColumns';
20
+
21
+ var useCustomizeColumns = function useCustomizeColumns(hooks) {
22
+ var _React$useState = React.useState(false),
23
+ _React$useState2 = _slicedToArray(_React$useState, 2),
24
+ isModalOpen = _React$useState2[0],
25
+ setIsModalOpen = _React$useState2[1];
26
+
27
+ hooks.useInstance.push(function (instance) {
28
+ var customizeColumnsProps = instance.customizeColumnsProps;
29
+ Object.assign(instance, {
30
+ customizeColumnsProps: _objectSpread(_objectSpread({}, customizeColumnsProps), {}, {
31
+ isModalOpen: isModalOpen,
32
+ setIsModalOpen: setIsModalOpen
33
+ }),
34
+ CustomizeColumnsButton: function CustomizeColumnsButton(props) {
35
+ return /*#__PURE__*/React.createElement(ToggleButtonWrapper, _extends({
36
+ isModalOpen: isModalOpen,
37
+ setIsModalOpen: setIsModalOpen
38
+ }, props));
39
+ },
40
+ CustomizeColumnsModal: CustomizeColumnsModalWrapper
41
+ });
42
+ });
43
+ };
44
+
45
+ export default useCustomizeColumns;
@@ -0,0 +1,44 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
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 - 2021
12
+ * US Government Users Restricted Rights - Use, duplication or disclosure
13
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
14
+ */
15
+ import { useMemo } from 'react';
16
+ import { useTable, useFlexLayout, useResizeColumns, useExpanded, useRowSelect, useSortBy, useGlobalFilter, useFilters, usePagination } from 'react-table';
17
+ import uniqueId from 'lodash/uniqueId';
18
+ import useSkeletonRows from './useSkeletonRows';
19
+ import useDefaultStringRenderer from './useDefaultStringRenderer';
20
+ import useRowRenderer from './useRowRenderer';
21
+ import useRowSize from './useRowSize';
22
+ import useHeaderRow from './Datagrid/DatagridHeaderRow';
23
+ import useFlexResize from './useFlexResize';
24
+ import useFloatingScroll from './useFloatingScroll';
25
+
26
+ var useDatagrid = function useDatagrid(params) {
27
+ var defaultPlugins = [useFlexLayout, useHeaderRow, useSkeletonRows, useResizeColumns, useRowRenderer, useDefaultStringRenderer, useRowSize, useFilters, useGlobalFilter, useSortBy, useExpanded];
28
+ var defaultEndPlugins = [usePagination, useRowSelect, useFlexResize, useFloatingScroll];
29
+ var clientEndPlugins = params.endPlugins || [];
30
+ var tableId = useMemo(function () {
31
+ return uniqueId('datagrid-table-id');
32
+ }, []);
33
+
34
+ for (var _len = arguments.length, plugins = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
35
+ plugins[_key - 1] = arguments[_key];
36
+ }
37
+
38
+ var tableState = useTable.apply(void 0, [_objectSpread({
39
+ tableId: tableId
40
+ }, params)].concat(defaultPlugins, plugins, defaultEndPlugins, _toConsumableArray(clientEndPlugins)));
41
+ return tableState;
42
+ };
43
+
44
+ export default useDatagrid;
@@ -0,0 +1,48 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
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 React from 'react';
16
+ import { pkg } from '../../settings';
17
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
18
+
19
+ var useDefaultStringRenderer = function useDefaultStringRenderer(hooks) {
20
+ var StringRenderer = function StringRenderer(tableProps) {
21
+ return /*#__PURE__*/React.createElement("div", {
22
+ className: "".concat(blockClass, "__defaultStringRenderer"),
23
+ title: tableProps.value
24
+ }, tableProps.value);
25
+ };
26
+
27
+ var HeaderRenderer = function HeaderRenderer(header) {
28
+ return /*#__PURE__*/React.createElement("div", {
29
+ className: "".concat(blockClass, "__defaultStringRenderer"),
30
+ title: typeof header === 'string' ? header : ''
31
+ }, header);
32
+ };
33
+
34
+ var visibleColumns = function visibleColumns(columns) {
35
+ var columnsWithDefaultCells = columns.map(function (column) {
36
+ return _objectSpread(_objectSpread({
37
+ Cell: StringRenderer
38
+ }, column), {}, {
39
+ Header: column.HeaderRenderer || HeaderRenderer(column.Header)
40
+ });
41
+ });
42
+ return _toConsumableArray(columnsWithDefaultCells);
43
+ };
44
+
45
+ hooks.visibleColumns.push(visibleColumns);
46
+ };
47
+
48
+ export default useDefaultStringRenderer;