@carbon/ibm-products 1.27.0 → 1.32.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. package/css/index-full-carbon.css +570 -80
  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 +569 -79
  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 +570 -80
  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 +63 -11
  27. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  28. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
  29. package/es/components/DataSpreadsheet/utils/handleCellDeletion.js +31 -0
  30. package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
  31. package/es/components/Datagrid/Datagrid/Datagrid.js +10 -38
  32. package/es/components/Datagrid/Datagrid/DatagridContent.js +127 -0
  33. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  34. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +10 -3
  35. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +12 -3
  36. package/es/components/Datagrid/Datagrid/DraggableElement.js +5 -1
  37. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +5 -40
  38. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +35 -10
  39. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +61 -24
  40. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
  41. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +60 -0
  42. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +1 -0
  43. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +467 -0
  44. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +1 -0
  45. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +112 -0
  46. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +27 -0
  47. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +1 -0
  48. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +39 -0
  49. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +19 -0
  50. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +263 -0
  51. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +66 -0
  52. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +6 -5
  53. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -2
  54. package/es/components/Datagrid/index.js +3 -1
  55. package/es/components/Datagrid/useActionsColumn.js +28 -12
  56. package/es/components/Datagrid/useColumnOrder.js +8 -0
  57. package/es/components/Datagrid/useCustomizeColumns.js +5 -0
  58. package/es/components/Datagrid/useDisableSelectRows.js +6 -2
  59. package/es/components/Datagrid/useExpandedRow.js +0 -1
  60. package/es/components/Datagrid/useInlineEdit.js +71 -0
  61. package/es/components/Datagrid/useNestedRowExpander.js +42 -0
  62. package/es/components/Datagrid/useNestedRows.js +2 -2
  63. package/es/components/Datagrid/useRowSize.js +17 -6
  64. package/es/components/Datagrid/useSelectAllToggle.js +17 -4
  65. package/es/components/Datagrid/useSelectRows.js +12 -2
  66. package/es/components/Datagrid/useStickyColumn.js +11 -0
  67. package/es/components/Datagrid/utils/DatagridActions.js +121 -0
  68. package/es/components/Datagrid/utils/DatagridPagination.js +33 -0
  69. package/es/components/Datagrid/utils/Wrapper.js +21 -0
  70. package/es/components/Datagrid/utils/getArgTypes.js +85 -0
  71. package/es/components/Datagrid/utils/getInlineEditColumns.js +121 -0
  72. package/es/components/Datagrid/utils/makeData.js +17 -1
  73. package/es/components/ImportModal/ImportModal.js +2 -2
  74. package/es/components/InlineEdit/InlineEdit.js +4 -2
  75. package/es/components/ProductiveCard/ProductiveCard.js +5 -0
  76. package/es/components/index.js +1 -1
  77. package/es/global/js/hooks/useClickOutside.js +1 -1
  78. package/es/global/js/package-settings.js +3 -3
  79. package/es/global/js/utils/rangeWithCallback.js +13 -0
  80. package/es/global/js/utils/story-helper.js +5 -1
  81. package/es/global/js/utils/uuidv4.spec.js +4 -0
  82. package/lib/components/AddSelect/AddSelect.js +0 -4
  83. package/lib/components/AddSelect/AddSelectBody.js +20 -3
  84. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +14 -3
  85. package/lib/components/AddSelect/AddSelectColumn.js +3 -2
  86. package/lib/components/AddSelect/AddSelectFilter.js +3 -2
  87. package/lib/components/AddSelect/AddSelectList.js +39 -13
  88. package/lib/components/Card/Card.js +16 -6
  89. package/lib/components/Card/CardFooter.js +3 -1
  90. package/lib/components/Card/CardHeader.js +21 -1
  91. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +63 -10
  92. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  93. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
  94. package/lib/components/DataSpreadsheet/utils/handleCellDeletion.js +42 -0
  95. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
  96. package/lib/components/Datagrid/Datagrid/Datagrid.js +12 -45
  97. package/lib/components/Datagrid/Datagrid/DatagridContent.js +160 -0
  98. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  99. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +12 -3
  100. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +14 -3
  101. package/lib/components/Datagrid/Datagrid/DraggableElement.js +5 -1
  102. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +12 -41
  103. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +47 -25
  104. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +59 -23
  105. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
  106. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +76 -0
  107. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +13 -0
  108. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +491 -0
  109. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +13 -0
  110. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +129 -0
  111. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +36 -0
  112. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +19 -0
  113. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +45 -0
  114. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +28 -0
  115. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +272 -0
  116. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +78 -0
  117. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +6 -5
  118. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -2
  119. package/lib/components/Datagrid/index.js +17 -1
  120. package/lib/components/Datagrid/useActionsColumn.js +28 -13
  121. package/lib/components/Datagrid/useColumnOrder.js +17 -0
  122. package/lib/components/Datagrid/useCustomizeColumns.js +5 -0
  123. package/lib/components/Datagrid/useDisableSelectRows.js +6 -2
  124. package/lib/components/Datagrid/useExpandedRow.js +0 -1
  125. package/lib/components/Datagrid/useInlineEdit.js +85 -0
  126. package/lib/components/Datagrid/useNestedRowExpander.js +57 -0
  127. package/lib/components/Datagrid/useNestedRows.js +3 -3
  128. package/lib/components/Datagrid/useRowSize.js +18 -13
  129. package/lib/components/Datagrid/useSelectAllToggle.js +18 -4
  130. package/lib/components/Datagrid/useSelectRows.js +12 -2
  131. package/lib/components/Datagrid/useStickyColumn.js +11 -0
  132. package/lib/components/Datagrid/utils/DatagridActions.js +139 -0
  133. package/lib/components/Datagrid/utils/DatagridPagination.js +46 -0
  134. package/lib/components/Datagrid/utils/Wrapper.js +33 -0
  135. package/lib/components/Datagrid/utils/getArgTypes.js +93 -0
  136. package/lib/components/Datagrid/utils/getInlineEditColumns.js +133 -0
  137. package/lib/components/Datagrid/utils/makeData.js +17 -1
  138. package/lib/components/ImportModal/ImportModal.js +2 -2
  139. package/lib/components/InlineEdit/InlineEdit.js +4 -2
  140. package/lib/components/ProductiveCard/ProductiveCard.js +5 -0
  141. package/lib/components/index.js +12 -0
  142. package/lib/global/js/hooks/useClickOutside.js +1 -1
  143. package/lib/global/js/package-settings.js +3 -3
  144. package/lib/global/js/utils/rangeWithCallback.js +22 -0
  145. package/lib/global/js/utils/story-helper.js +5 -1
  146. package/lib/global/js/utils/uuidv4.spec.js +4 -0
  147. package/package.json +13 -13
  148. package/scss/components/AddSelect/_add-select.scss +126 -28
  149. package/scss/components/Card/_card.scss +1 -0
  150. package/scss/components/Cascade/_cascade.scss +1 -1
  151. package/scss/components/CreateTearsheet/_create-tearsheet.scss +1 -0
  152. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +18 -1
  153. package/scss/components/Datagrid/_storybook-styles.scss +1 -1
  154. package/scss/components/Datagrid/styles/_datagrid.scss +27 -4
  155. package/scss/components/Datagrid/styles/_draggableElement.scss +26 -9
  156. package/scss/components/Datagrid/styles/_index.scss +1 -0
  157. package/scss/components/Datagrid/styles/_useActionsColumn.scss +12 -0
  158. package/scss/components/Datagrid/styles/_useExpandedRow.scss +30 -0
  159. package/scss/components/Datagrid/styles/_useInlineEdit.scss +211 -0
  160. package/scss/components/Datagrid/styles/_useNestedRows.scss +15 -1
  161. package/scss/components/Datagrid/styles/_useStickyColumn.scss +30 -2
  162. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsModal.scss +44 -6
  163. package/scss/components/NotificationsPanel/_notifications-panel.scss +5 -6
  164. package/scss/components/ProductiveCard/_productive-card.scss +39 -0
  165. package/scss/components/RemoveModal/_remove-modal.scss +0 -4
  166. package/scss/components/SidePanel/_side-panel.scss +4 -6
  167. package/scss/components/_index-released-only.scss +1 -0
@@ -5,12 +5,12 @@
5
5
  * US Government Users Restricted Rights - Use, duplication or disclosure
6
6
  * restricted by GSA ADP Schedule Contract with IBM Corp.
7
7
  */
8
- import useRowExpander from './useRowExpander';
9
8
  import { pkg } from '../../settings';
9
+ import useNestedRowExpander from './useNestedRowExpander';
10
10
  var blockClass = "".concat(pkg.prefix, "--datagrid");
11
11
 
12
12
  var useNestedRows = function useNestedRows(hooks) {
13
- useRowExpander(hooks);
13
+ useNestedRowExpander(hooks);
14
14
  var marginLeft = 24;
15
15
 
16
16
  var getRowProps = function getRowProps(props, _ref) {
@@ -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) {
@@ -1,3 +1,5 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
1
3
  /*
2
4
  * Licensed Materials - Property of IBM
3
5
  * 5724-Q36
@@ -7,6 +9,7 @@
7
9
  */
8
10
  // @flow
9
11
  import React from 'react';
12
+ import cx from 'classnames';
10
13
  import { selectionColumnId } from './common-column-ids';
11
14
  import SelectAllWithToggle from './Datagrid/DatagridSelectAllWithToggle';
12
15
  import { pkg } from '../../settings';
@@ -40,12 +43,18 @@ var useSelectAllWithToggleComponent = function useSelectAllWithToggleComponent(h
40
43
 
41
44
  var useAddClassNameToSelectRow = function useAddClassNameToSelectRow(hooks) {
42
45
  hooks.getCellProps.push(function (props, data) {
46
+ var _columns$;
47
+
43
48
  var column = data.cell.column;
44
- var DatagridPagination = data.instance.DatagridPagination;
49
+ var _data$instance = data.instance,
50
+ DatagridPagination = _data$instance.DatagridPagination,
51
+ columns = _data$instance.columns,
52
+ withStickyColumn = _data$instance.withStickyColumn;
53
+ var isFirstColumnStickyLeft = ((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
45
54
 
46
55
  if (column.id === selectionColumnId && DatagridPagination) {
47
56
  return [props, {
48
- className: "".concat(blockClass, "__select-all-toggle-on")
57
+ className: cx("".concat(blockClass, "__select-all-toggle-on"), _defineProperty({}, "".concat(blockClass, "__select-all-sticky-left"), isFirstColumnStickyLeft))
49
58
  }];
50
59
  }
51
60
 
@@ -59,14 +68,18 @@ var Header = function Header(gridState) {
59
68
  selectAllToggle = gridState.selectAllToggle,
60
69
  getToggleAllPageRowsSelectedProps = gridState.getToggleAllPageRowsSelectedProps,
61
70
  getToggleAllRowsSelectedProps = gridState.getToggleAllRowsSelectedProps,
62
- isAllRowsSelected = gridState.isAllRowsSelected;
71
+ isAllRowsSelected = gridState.isAllRowsSelected,
72
+ withStickyColumn = gridState.withStickyColumn,
73
+ columns = gridState.columns;
63
74
  var props = {
64
75
  tableId: tableId,
65
76
  isFetching: isFetching,
66
77
  selectAllToggle: selectAllToggle,
67
78
  getToggleAllPageRowsSelectedProps: getToggleAllPageRowsSelectedProps,
68
79
  getToggleAllRowsSelectedProps: getToggleAllRowsSelectedProps,
69
- isAllRowsSelected: isAllRowsSelected
80
+ isAllRowsSelected: isAllRowsSelected,
81
+ withStickyColumn: withStickyColumn,
82
+ columns: columns
70
83
  };
71
84
  return /*#__PURE__*/React.createElement(SelectAllWithToggle, props);
72
85
  };
@@ -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. 2020, 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 React from 'react';
8
+ import { DataTable, Button } from 'carbon-components-react';
9
+ import { Download16, Filter16, Add16, Restart16 } from '@carbon/icons-react';
10
+ import { action } from '@storybook/addon-actions';
11
+ import { pkg } from '../../../settings';
12
+ import { ButtonMenu, ButtonMenuItem } from '../../ButtonMenu';
13
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
14
+ export var DatagridActions = function DatagridActions(datagridState) {
15
+ var selectedFlatRows = datagridState.selectedFlatRows,
16
+ setGlobalFilter = datagridState.setGlobalFilter,
17
+ CustomizeColumnsButton = datagridState.CustomizeColumnsButton,
18
+ RowSizeDropdown = datagridState.RowSizeDropdown,
19
+ rowSizeDropdownProps = datagridState.rowSizeDropdownProps,
20
+ useDenseHeader = datagridState.useDenseHeader;
21
+
22
+ var downloadCsv = function downloadCsv() {
23
+ alert('Downloading...');
24
+ };
25
+
26
+ var TableToolbarContent = DataTable.TableToolbarContent,
27
+ TableToolbarSearch = DataTable.TableToolbarSearch;
28
+
29
+ var refreshColumns = function refreshColumns() {
30
+ alert('refreshing...');
31
+ };
32
+
33
+ var leftPanelClick = function leftPanelClick() {
34
+ alert('open/close left panel...');
35
+ };
36
+
37
+ var searchForAColumn = 'Search';
38
+ var isNothingSelected = selectedFlatRows.length === 0;
39
+ var style = {
40
+ 'button:nth-child(1) > span:nth-child(1)': {
41
+ bottom: '-37px'
42
+ }
43
+ };
44
+ return isNothingSelected && (useDenseHeader && useDenseHeader ? /*#__PURE__*/React.createElement(TableToolbarContent, {
45
+ size: "sm"
46
+ }, /*#__PURE__*/React.createElement("div", {
47
+ style: style
48
+ }, /*#__PURE__*/React.createElement(Button, {
49
+ kind: "ghost",
50
+ hasIconOnly: true,
51
+ tooltipPosition: "bottom",
52
+ renderIcon: Download16,
53
+ iconDescription: 'Download CSV',
54
+ onClick: downloadCsv
55
+ })), /*#__PURE__*/React.createElement("div", {
56
+ style: style
57
+ }, /*#__PURE__*/React.createElement(Button, {
58
+ kind: "ghost",
59
+ hasIconOnly: true,
60
+ tooltipPosition: "bottom",
61
+ renderIcon: Filter16,
62
+ iconDescription: 'Left panel',
63
+ onClick: leftPanelClick
64
+ })), /*#__PURE__*/React.createElement(RowSizeDropdown, rowSizeDropdownProps), /*#__PURE__*/React.createElement("div", {
65
+ style: style,
66
+ className: "".concat(blockClass, "__toolbar-divider")
67
+ }, /*#__PURE__*/React.createElement(Button, {
68
+ kind: "ghost",
69
+ renderIcon: Add16,
70
+ iconDescription: 'Action'
71
+ }, "Ghost button")), CustomizeColumnsButton && /*#__PURE__*/React.createElement("div", {
72
+ style: style
73
+ }, /*#__PURE__*/React.createElement(CustomizeColumnsButton, null))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
74
+ kind: "ghost",
75
+ hasIconOnly: true,
76
+ tooltipPosition: "bottom",
77
+ renderIcon: Filter16,
78
+ iconDescription: 'Left panel',
79
+ onClick: leftPanelClick
80
+ }), /*#__PURE__*/React.createElement(TableToolbarContent, null, /*#__PURE__*/React.createElement(TableToolbarSearch, {
81
+ size: "xl",
82
+ id: "columnSearch",
83
+ persistent: true,
84
+ placeHolderText: searchForAColumn,
85
+ onChange: function onChange(e) {
86
+ return setGlobalFilter(e.target.value);
87
+ }
88
+ }), /*#__PURE__*/React.createElement(RowSizeDropdown, rowSizeDropdownProps), /*#__PURE__*/React.createElement("div", {
89
+ style: style
90
+ }, /*#__PURE__*/React.createElement(Button, {
91
+ kind: "ghost",
92
+ hasIconOnly: true,
93
+ tooltipPosition: "bottom",
94
+ renderIcon: Restart16,
95
+ iconDescription: 'Refresh',
96
+ onClick: refreshColumns
97
+ })), /*#__PURE__*/React.createElement("div", {
98
+ style: style
99
+ }, /*#__PURE__*/React.createElement(Button, {
100
+ kind: "ghost",
101
+ hasIconOnly: true,
102
+ tooltipPosition: "bottom",
103
+ renderIcon: Download16,
104
+ iconDescription: 'Download CSV',
105
+ onClick: downloadCsv
106
+ })), CustomizeColumnsButton && /*#__PURE__*/React.createElement("div", {
107
+ style: style
108
+ }, /*#__PURE__*/React.createElement(CustomizeColumnsButton, null)), /*#__PURE__*/React.createElement(ButtonMenu, {
109
+ label: "Primary button",
110
+ renderIcon: Add16
111
+ }, /*#__PURE__*/React.createElement(ButtonMenuItem, {
112
+ itemText: "Option 1",
113
+ onClick: action("Click on ButtonMenu Option 1")
114
+ }), /*#__PURE__*/React.createElement(ButtonMenuItem, {
115
+ itemText: "Option 2",
116
+ onClick: action("Click on ButtonMenu Option 2")
117
+ }), /*#__PURE__*/React.createElement(ButtonMenuItem, {
118
+ itemText: "Option 3",
119
+ onClick: action("Click on ButtonMenu Option 3")
120
+ })))));
121
+ };
@@ -0,0 +1,33 @@
1
+ /* eslint-disable react/prop-types */
2
+
3
+ /**
4
+ * Copyright IBM Corp. 2022, 2022
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ import React from 'react';
10
+ import { Pagination } from 'carbon-components-react';
11
+ export var DatagridPagination = function DatagridPagination(_ref) {
12
+ var state = _ref.state,
13
+ setPageSize = _ref.setPageSize,
14
+ gotoPage = _ref.gotoPage,
15
+ rows = _ref.rows;
16
+
17
+ var updatePagination = function updatePagination(_ref2) {
18
+ var page = _ref2.page,
19
+ pageSize = _ref2.pageSize;
20
+ console.log(state);
21
+ setPageSize(pageSize);
22
+ gotoPage(page - 1); // Carbon is non-zero-based
23
+ };
24
+
25
+ return /*#__PURE__*/React.createElement(Pagination, {
26
+ page: state.pageIndex + 1 // react-table is zero-based
27
+ ,
28
+ pageSize: state.pageSize,
29
+ pageSizes: state.pageSizes || [10, 20, 30, 40, 50],
30
+ totalItems: rows.length,
31
+ onChange: updatePagination
32
+ });
33
+ };
@@ -0,0 +1,21 @@
1
+ /* eslint-disable react/prop-types */
2
+
3
+ /**
4
+ * Copyright IBM Corp. 2020, 2022
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ import React from 'react';
10
+ export var Wrapper = function Wrapper(_ref) {
11
+ var children = _ref.children;
12
+ return /*#__PURE__*/React.createElement("div", {
13
+ style: {
14
+ height: '100vh',
15
+ width: '100%',
16
+ padding: '1rem',
17
+ margin: '0',
18
+ zIndex: '0'
19
+ }
20
+ }, children);
21
+ };
@@ -0,0 +1,85 @@
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
+ export var ARG_TYPES = {
8
+ gridTitle: {
9
+ name: 'gridTitle',
10
+ control: 'text',
11
+ description: 'This sets the title text for the Datagrid component. _This value is set/passed inside of the `datagridState` object._',
12
+ type: {
13
+ name: 'string',
14
+ required: false
15
+ }
16
+ },
17
+ gridDescription: {
18
+ name: 'gridDescription',
19
+ control: 'text',
20
+ description: 'This sets the description text for the Datagrid component. _This value is set/passed inside of the `datagridState` object._',
21
+ type: {
22
+ name: 'string',
23
+ required: false
24
+ }
25
+ },
26
+ emptyStateTitle: {
27
+ name: 'emptyStateTitle',
28
+ control: 'text',
29
+ description: 'This sets the empty state title text for the Datagrid component. _This value is set/passed inside of the `datagridState` object._',
30
+ type: {
31
+ name: 'string',
32
+ required: false
33
+ }
34
+ },
35
+ emptyStateDescription: {
36
+ name: 'emptyStateDescription',
37
+ control: 'text',
38
+ description: 'This sets the empty state description text for the Datagrid component. _This value is set/passed inside of the `datagridState` object._',
39
+ type: {
40
+ name: 'string',
41
+ required: false
42
+ }
43
+ },
44
+ emptyStateSize: {
45
+ control: 'select',
46
+ options: ['sm', 'lg']
47
+ },
48
+ useDenseHeader: {
49
+ control: {
50
+ type: 'radio'
51
+ },
52
+ options: [true, false],
53
+ description: 'This sets the dense header option for the Datagrid component. _This value is set/passed inside of the `datagridState` object._'
54
+ },
55
+ rowSize: {
56
+ control: 'select',
57
+ options: ['xs', 'sm', 'md', 'lg', 'xl'],
58
+ description: 'This sets the height for each row of the Datagrid component. _This value is set/passed inside of the `datagridState` object._'
59
+ },
60
+ rowSizes: {
61
+ control: 'object',
62
+ description: 'This array of objects specifies the different row size options that will render from the settings icon in the table actions. _This value is set/passed inside of the `datagridState` object._'
63
+ },
64
+ onRowSizeChange: {
65
+ description: 'Callback function that is called on row size changes. _This value is set/passed inside of the `datagridState` object._'
66
+ },
67
+ rowActions: {
68
+ control: 'object',
69
+ description: 'This array of objects renders the action buttons for each row in the Datagrid. _This value is set/passed inside of the `datagridState` object._',
70
+ action: 'Row action onClick'
71
+ },
72
+ batchActions: {
73
+ control: {
74
+ type: 'radio'
75
+ },
76
+ options: [true, false],
77
+ description: 'This will allow the Datagrid component to use batch actions. _This value is set/passed inside of the `datagridState` object._'
78
+ },
79
+ expandedContentHeight: {
80
+ control: {
81
+ type: 'number'
82
+ },
83
+ description: 'This value controls the height of the expanded content area. _This value is set/passed inside of the `datagridState` object._'
84
+ }
85
+ };
@@ -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
 
@@ -75,9 +75,9 @@ export var ImportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
75
75
  var acceptSet = new Set(accept);
76
76
  var name = file.name;
77
77
  var mimeType = file.type;
78
- var extension = name.split('.').pop();
78
+ var extension = ".".concat(name.split('.').pop());
79
79
 
80
- if (acceptSet.has(mimeType) || acceptSet.has(extension)) {
80
+ if (acceptSet.has(mimeType) || acceptSet.has(extension) || accept.length === 0) {
81
81
  return false;
82
82
  }
83
83
 
@@ -65,7 +65,9 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
65
65
  value = _ref.value,
66
66
  rest = _objectWithoutProperties(_ref, _excluded);
67
67
 
68
- var refInput = useRef(null);
68
+ var refInput = useRef({
69
+ innerText: value
70
+ });
69
71
  var localRef = useRef(null);
70
72
  var ref = refIn || localRef;
71
73
 
@@ -268,7 +270,7 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
268
270
  onPaste: handlePaste,
269
271
  suppressContentEditableWarning: true,
270
272
  ref: refInput,
271
- "data-placeholder": placeholder !== null && placeholder !== void 0 ? placeholder : labelText
273
+ "data-placeholder": placeholder
272
274
  }), value), /*#__PURE__*/React.createElement("div", {
273
275
  className: cx("".concat(blockClass, "__after-input-elements")) // tabindex -1 fixes blur target test when clicking on after-input-elements background
274
276
  ,
@@ -112,6 +112,11 @@ ProductiveCard.propTypes = {
112
112
  */
113
113
  primaryButtonIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
114
114
 
115
+ /**
116
+ * Determines if the primary button is on the top or bottom of the card
117
+ */
118
+ primaryButtonPlacement: PropTypes.oneOf(['top', 'bottom']),
119
+
115
120
  /**
116
121
  * The text that's displayed in the primary button
117
122
  */
@@ -37,7 +37,7 @@ export { EditSidePanel } from './EditSidePanel';
37
37
  export { OptionsTile } from './OptionsTile';
38
38
  export { InlineEdit } from './InlineEdit';
39
39
  export { DataSpreadsheet } from './DataSpreadsheet';
40
- export { Datagrid, useDatagrid, useInfiniteScroll, useNestedRows, useSelectRows, useExpandedRow, useOnRowClick, useSortableColumns, useRowIsMouseOver, useColumnRightAlign, useDisableSelectRows, useStickyColumn, useActionsColumn, useCustomizeColumns, useSelectAllWithToggle } from './Datagrid';
40
+ export { Datagrid, useDatagrid, useInfiniteScroll, useNestedRows, useSelectRows, useExpandedRow, useOnRowClick, useSortableColumns, useRowIsMouseOver, useColumnRightAlign, useDisableSelectRows, useStickyColumn, useActionsColumn, useCustomizeColumns, useSelectAllWithToggle, useColumnOrder, useInlineEdit } from './Datagrid';
41
41
  export { EditTearsheet } from './EditTearsheet';
42
42
  export { EditTearsheetNarrow } from './EditTearsheetNarrow';
43
43
  export { EditFullPage } from './EditFullPage';