@carbon/ibm-products 2.42.1-canary.11 → 2.42.1-canary.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,6 +20,7 @@ export namespace InlineEditCell {
20
20
  rows: PropTypes.Requireable<(object | null | undefined)[]>;
21
21
  rowSize: PropTypes.Requireable<string>;
22
22
  tableId: PropTypes.Requireable<string>;
23
+ cellEditing: PropTypes.Requireable<object>;
23
24
  }>>;
24
25
  let nonEditCell: PropTypes.Requireable<boolean>;
25
26
  let placeholder: PropTypes.Requireable<string>;
@@ -36,7 +36,8 @@ var InlineEditCell = function InlineEditCell(_ref) {
36
36
  var columnIndex = instance.columns.findIndex(function (col) {
37
37
  return col.id === columnId;
38
38
  });
39
- var cellId = "column-".concat(columnIndex, "-row-").concat(cell.row.index);
39
+ var rowIndex = cell.row.index;
40
+ var cellId = "column-".concat(columnIndex, "-row-").concat(rowIndex);
40
41
  var _useContext = useContext(InlineEditContext),
41
42
  state = _useContext.state,
42
43
  dispatch = _useContext.dispatch;
@@ -72,6 +73,14 @@ var InlineEditCell = function InlineEditCell(_ref) {
72
73
  var rowSize = instance.rowSize,
73
74
  onDataUpdate = instance.onDataUpdate;
74
75
  var saveCellData;
76
+ if (inEditMode) {
77
+ instance.cellEditing = {
78
+ cellId: cellId,
79
+ columnIndex: columnIndex,
80
+ rowIndex: rowIndex,
81
+ curCellValue: cellValue
82
+ };
83
+ }
75
84
  useEffect(function () {
76
85
  setInitialValue(value);
77
86
  var columnId = cell.column.id;
@@ -469,7 +478,8 @@ InlineEditCell.propTypes = {
469
478
  onDataUpdate: PropTypes.func,
470
479
  rows: PropTypes.arrayOf(PropTypes.object),
471
480
  rowSize: PropTypes.string,
472
- tableId: PropTypes.string
481
+ tableId: PropTypes.string,
482
+ cellEditing: PropTypes.object
473
483
  }),
474
484
  nonEditCell: PropTypes.bool,
475
485
  placeholder: PropTypes.string,
@@ -192,6 +192,7 @@ export interface DataGridState<T extends object = any> extends TableCommonProps,
192
192
  onVirtualScroll?: (evt?: boolean) => void;
193
193
  fetchMoreData?: () => void;
194
194
  loadMoreThreshold?: number;
195
+ onRowClick?: (row: any, event: any) => void;
195
196
  onSort?: boolean;
196
197
  }
197
198
  export interface ResizeHeaderProps {
@@ -1,2 +1,8 @@
1
- export default useColumnOrder;
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
+ */
2
7
  import { useColumnOrder } from 'react-table';
8
+ export default useColumnOrder;
@@ -15,6 +15,23 @@ var blockClass = "".concat(pkg.prefix, "--datagrid");
15
15
  var useNestedRows = function useNestedRows(hooks) {
16
16
  useNestedRowExpander(hooks);
17
17
  var useInstance = function useInstance(instance) {
18
+ useEffect(function () {
19
+ var rows = instance.rows;
20
+ var defaultExpandedRows = rows.filter(function (row) {
21
+ var _row$original;
22
+ return row === null || row === void 0 || (_row$original = row.original) === null || _row$original === void 0 ? void 0 : _row$original.defaultExpanded;
23
+ });
24
+ if (defaultExpandedRows !== null && defaultExpandedRows !== void 0 && defaultExpandedRows.length) {
25
+ defaultExpandedRows.map(function (defaultExpandedRow) {
26
+ if (!defaultExpandedRow.isExpanded && !defaultExpandedRow.hasExpanded) {
27
+ var _defaultExpandedRow$t;
28
+ defaultExpandedRow === null || defaultExpandedRow === void 0 || (_defaultExpandedRow$t = defaultExpandedRow.toggleRowExpanded) === null || _defaultExpandedRow$t === void 0 || _defaultExpandedRow$t.call(defaultExpandedRow);
29
+ defaultExpandedRow.hasExpanded = true;
30
+ return;
31
+ }
32
+ });
33
+ }
34
+ }, [instance, instance.rows]);
18
35
  // This useEffect will expand rows if they exist in the initialState obj
19
36
  useEffect(function () {
20
37
  var rows = instance.rows,
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2023
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 { Hooks } from 'react-table';
8
+ declare const useOnRowClick: (hooks: Hooks) => void;
1
9
  export default useOnRowClick;
2
- declare function useOnRowClick(hooks: any): void;
@@ -9,7 +9,8 @@ import { pkg, carbon } from '../../settings.js';
9
9
 
10
10
  var useOnRowClick = function useOnRowClick(hooks) {
11
11
  var useInstance = function useInstance(rowInstance) {
12
- var onRowClick = rowInstance.onRowClick;
12
+ var _ref = rowInstance,
13
+ onRowClick = _ref.onRowClick;
13
14
  var getRowProps = function getRowProps(props, datagridState) {
14
15
  var isFetching = datagridState.isFetching,
15
16
  row = datagridState.row,
@@ -1,2 +1,3 @@
1
+ import { Hooks } from 'react-table';
2
+ declare const useRowIsMouseOver: (hooks: Hooks) => void;
1
3
  export default useRowIsMouseOver;
2
- declare function useRowIsMouseOver(hooks: any): void;
@@ -17,7 +17,7 @@ var useRowIsMouseOver = function useRowIsMouseOver(hooks) {
17
17
  setMouseOverRowIndex = _useState2[1];
18
18
  var onMouseChange = useDebounce(function (datagridState) {
19
19
  var row = datagridState.row;
20
- setMouseOverRowIndex(row.index);
20
+ setMouseOverRowIndex(row === null || row === void 0 ? void 0 : row.index);
21
21
  }, 100);
22
22
  var getRowProps = function getRowProps(props, datagridState) {
23
23
  var onMouseOver = function onMouseOver() {
@@ -20,6 +20,7 @@ export namespace InlineEditCell {
20
20
  rows: PropTypes.Requireable<(object | null | undefined)[]>;
21
21
  rowSize: PropTypes.Requireable<string>;
22
22
  tableId: PropTypes.Requireable<string>;
23
+ cellEditing: PropTypes.Requireable<object>;
23
24
  }>>;
24
25
  let nonEditCell: PropTypes.Requireable<boolean>;
25
26
  let placeholder: PropTypes.Requireable<string>;
@@ -45,7 +45,8 @@ var InlineEditCell = function InlineEditCell(_ref) {
45
45
  var columnIndex = instance.columns.findIndex(function (col) {
46
46
  return col.id === columnId;
47
47
  });
48
- var cellId = "column-".concat(columnIndex, "-row-").concat(cell.row.index);
48
+ var rowIndex = cell.row.index;
49
+ var cellId = "column-".concat(columnIndex, "-row-").concat(rowIndex);
49
50
  var _useContext = React.useContext(InlineEditContext.InlineEditContext),
50
51
  state = _useContext.state,
51
52
  dispatch = _useContext.dispatch;
@@ -81,6 +82,14 @@ var InlineEditCell = function InlineEditCell(_ref) {
81
82
  var rowSize = instance.rowSize,
82
83
  onDataUpdate = instance.onDataUpdate;
83
84
  var saveCellData;
85
+ if (inEditMode) {
86
+ instance.cellEditing = {
87
+ cellId: cellId,
88
+ columnIndex: columnIndex,
89
+ rowIndex: rowIndex,
90
+ curCellValue: cellValue
91
+ };
92
+ }
84
93
  React.useEffect(function () {
85
94
  setInitialValue(value);
86
95
  var columnId = cell.column.id;
@@ -478,7 +487,8 @@ InlineEditCell.propTypes = {
478
487
  onDataUpdate: index["default"].func,
479
488
  rows: index["default"].arrayOf(index["default"].object),
480
489
  rowSize: index["default"].string,
481
- tableId: index["default"].string
490
+ tableId: index["default"].string,
491
+ cellEditing: index["default"].object
482
492
  }),
483
493
  nonEditCell: index["default"].bool,
484
494
  placeholder: index["default"].string,
@@ -192,6 +192,7 @@ export interface DataGridState<T extends object = any> extends TableCommonProps,
192
192
  onVirtualScroll?: (evt?: boolean) => void;
193
193
  fetchMoreData?: () => void;
194
194
  loadMoreThreshold?: number;
195
+ onRowClick?: (row: any, event: any) => void;
195
196
  onSort?: boolean;
196
197
  }
197
198
  export interface ResizeHeaderProps {
@@ -1,2 +1,8 @@
1
- export default useColumnOrder;
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
+ */
2
7
  import { useColumnOrder } from 'react-table';
8
+ export default useColumnOrder;
@@ -23,6 +23,23 @@ var blockClass = "".concat(settings.pkg.prefix, "--datagrid");
23
23
  var useNestedRows = function useNestedRows(hooks) {
24
24
  useNestedRowExpander["default"](hooks);
25
25
  var useInstance = function useInstance(instance) {
26
+ React.useEffect(function () {
27
+ var rows = instance.rows;
28
+ var defaultExpandedRows = rows.filter(function (row) {
29
+ var _row$original;
30
+ return row === null || row === void 0 || (_row$original = row.original) === null || _row$original === void 0 ? void 0 : _row$original.defaultExpanded;
31
+ });
32
+ if (defaultExpandedRows !== null && defaultExpandedRows !== void 0 && defaultExpandedRows.length) {
33
+ defaultExpandedRows.map(function (defaultExpandedRow) {
34
+ if (!defaultExpandedRow.isExpanded && !defaultExpandedRow.hasExpanded) {
35
+ var _defaultExpandedRow$t;
36
+ defaultExpandedRow === null || defaultExpandedRow === void 0 || (_defaultExpandedRow$t = defaultExpandedRow.toggleRowExpanded) === null || _defaultExpandedRow$t === void 0 || _defaultExpandedRow$t.call(defaultExpandedRow);
37
+ defaultExpandedRow.hasExpanded = true;
38
+ return;
39
+ }
40
+ });
41
+ }
42
+ }, [instance, instance.rows]);
26
43
  // This useEffect will expand rows if they exist in the initialState obj
27
44
  React.useEffect(function () {
28
45
  var rows = instance.rows,
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2023
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 { Hooks } from 'react-table';
8
+ declare const useOnRowClick: (hooks: Hooks) => void;
1
9
  export default useOnRowClick;
2
- declare function useOnRowClick(hooks: any): void;
@@ -13,7 +13,8 @@ var settings = require('../../settings.js');
13
13
 
14
14
  var useOnRowClick = function useOnRowClick(hooks) {
15
15
  var useInstance = function useInstance(rowInstance) {
16
- var onRowClick = rowInstance.onRowClick;
16
+ var _ref = rowInstance,
17
+ onRowClick = _ref.onRowClick;
17
18
  var getRowProps = function getRowProps(props, datagridState) {
18
19
  var isFetching = datagridState.isFetching,
19
20
  row = datagridState.row,
@@ -1,2 +1,3 @@
1
+ import { Hooks } from 'react-table';
2
+ declare const useRowIsMouseOver: (hooks: Hooks) => void;
1
3
  export default useRowIsMouseOver;
2
- declare function useRowIsMouseOver(hooks: any): void;
@@ -25,7 +25,7 @@ var useRowIsMouseOver = function useRowIsMouseOver(hooks) {
25
25
  setMouseOverRowIndex = _useState2[1];
26
26
  var onMouseChange = useDebounce(function (datagridState) {
27
27
  var row = datagridState.row;
28
- setMouseOverRowIndex(row.index);
28
+ setMouseOverRowIndex(row === null || row === void 0 ? void 0 : row.index);
29
29
  }, 100);
30
30
  var getRowProps = function getRowProps(props, datagridState) {
31
31
  var onMouseOver = function onMouseOver() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/ibm-products",
3
3
  "description": "Carbon for IBM Products",
4
- "version": "2.42.1-canary.11+928f909b6",
4
+ "version": "2.42.1-canary.17+cc36a9e2d",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -121,5 +121,5 @@
121
121
  "react": "^16.8.6 || ^17.0.1 || ^18.2.0",
122
122
  "react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
123
123
  },
124
- "gitHead": "928f909b69cac3ca6b2ac5c6646866c5639d04af"
124
+ "gitHead": "cc36a9e2d4a35d3126451fc611e3e717eaf74c23"
125
125
  }