@carbon/ibm-products 2.43.2-canary.12 → 2.43.2-canary.15
Sign up to get free protection for your applications and to get access to all the features.
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +7 -4
- package/es/components/Datagrid/types/index.d.ts +13 -2
- package/es/components/Datagrid/useActionsColumn.d.ts +8 -1
- package/es/components/Datagrid/useActionsColumn.js +7 -6
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +7 -4
- package/lib/components/Datagrid/types/index.d.ts +13 -2
- package/lib/components/Datagrid/useActionsColumn.d.ts +8 -1
- package/lib/components/Datagrid/useActionsColumn.js +7 -6
- package/package.json +2 -2
@@ -211,9 +211,12 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
211
211
|
}
|
212
212
|
if ((prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row) !== (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) || (prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column) !== (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column)) {
|
213
213
|
if (activeCellCoordinates && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
|
214
|
-
var _activeCellFullData$r;
|
215
214
|
var activeCellFullData = typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'number' && typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'number' ? rows[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row].cells[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
|
216
|
-
|
215
|
+
if (activeCellFullData) {
|
216
|
+
setActiveCellContent(activeCellFullData.render('Cell'));
|
217
|
+
} else {
|
218
|
+
setActiveCellContent(null);
|
219
|
+
}
|
217
220
|
}
|
218
221
|
if (activeCellCoordinates && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
|
219
222
|
setActiveCellContent(null);
|
@@ -428,8 +431,8 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
|
|
428
431
|
var activeCellFullData = typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'number' && typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'number' ? rows[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row].cells[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
|
429
432
|
var activeCellValue;
|
430
433
|
if (activeCellFullData && activeCellCoordinates !== null && activeCellCoordinates !== void 0 && activeCellCoordinates.column) {
|
431
|
-
var _activeCellFullData$
|
432
|
-
activeCellValue = activeCellFullData ? (_activeCellFullData$
|
434
|
+
var _activeCellFullData$r;
|
435
|
+
activeCellValue = activeCellFullData ? (_activeCellFullData$r = activeCellFullData.row.cells) === null || _activeCellFullData$r === void 0 || (_activeCellFullData$r = _activeCellFullData$r[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column]) === null || _activeCellFullData$r === void 0 ? void 0 : _activeCellFullData$r.value : null;
|
433
436
|
}
|
434
437
|
setCellEditorValue(activeCellValue || '');
|
435
438
|
if (cellEditorRulerRef !== null && cellEditorRulerRef !== void 0 && cellEditorRulerRef.current) {
|
@@ -5,10 +5,10 @@ import { RadioButtonProps } from '@carbon/react/lib/components/RadioButton/Radio
|
|
5
5
|
import { RadioButtonGroupProps } from '@carbon/react/lib/components/RadioButtonGroup/RadioButtonGroup';
|
6
6
|
import { CheckboxProps } from '@carbon/react/lib/components/Checkbox';
|
7
7
|
import { NumberInputProps } from '@carbon/react/lib/components/NumberInput/NumberInput';
|
8
|
-
import { CSSProperties, JSXElementConstructor, MutableRefObject, ReactNode, TouchEventHandler } from 'react';
|
8
|
+
import React, { CSSProperties, ComponentType, FunctionComponent, JSXElementConstructor, MutableRefObject, ReactNode, TouchEventHandler } from 'react';
|
9
9
|
import { Cell, Column, ColumnInstance, FilterValue, Filters, HeaderGroup, Meta, Row, TableCommonProps, TableDispatch, TableInstance, TableToggleAllRowsSelectedProps, UseExpandedRowProps, UseFiltersInstanceProps, UsePaginationInstanceProps, UseResizeColumnsColumnProps, UseResizeColumnsState, UseRowSelectInstanceProps, UseRowSelectRowProps, UseRowSelectState, UseSortByColumnProps, UseSortByOptions, UseTableHooks } from 'react-table';
|
10
10
|
import { CarbonIconType } from '@carbon/react/icons';
|
11
|
-
import { type ButtonProps } from '@carbon/react';
|
11
|
+
import { IconButton, type ButtonProps } from '@carbon/react';
|
12
12
|
import { TableBatchActionsProps } from '@carbon/react/lib/components/DataTable/TableBatchActions';
|
13
13
|
export type Size = 'xs' | 'sm' | 'md' | 'lg';
|
14
14
|
export interface ResizerProps {
|
@@ -122,6 +122,16 @@ interface DataGridTableState extends UseResizeColumnsState<any>, UseRowSelectSta
|
|
122
122
|
}
|
123
123
|
export interface DataGridTableInstance<T extends object = any> extends TableInstance<T> {
|
124
124
|
}
|
125
|
+
export interface RowAction {
|
126
|
+
id?: string;
|
127
|
+
itemText?: string;
|
128
|
+
icon?: ComponentType | FunctionComponent;
|
129
|
+
align?: React.ComponentProps<typeof IconButton>['align'];
|
130
|
+
shouldHideMenuItem?: (...args: any[]) => void;
|
131
|
+
shouldDisableMenuItem?: (...args: any[]) => void;
|
132
|
+
disabled?: boolean;
|
133
|
+
onClick?: (...args: any[]) => void;
|
134
|
+
}
|
125
135
|
export interface DataGridState<T extends object = any> extends TableCommonProps, UsePaginationInstanceProps<T>, Omit<TableInstance<T>, 'state' | 'headers' | 'rows' | 'columns'>, Omit<UseFiltersInstanceProps<T>, 'rows'>, UseRowSelectInstanceProps<T>, Pick<UseRowSelectInstanceProps<T>, 'toggleAllRowsSelected'> {
|
126
136
|
withVirtualScroll?: boolean;
|
127
137
|
DatagridPagination?: JSXElementConstructor<any>;
|
@@ -144,6 +154,7 @@ export interface DataGridState<T extends object = any> extends TableCommonProps,
|
|
144
154
|
batchActions?: boolean;
|
145
155
|
row: DatagridRow;
|
146
156
|
rows: Array<DatagridRow<any>>;
|
157
|
+
rowActions?: RowAction[];
|
147
158
|
columns: Array<DatagridColumn>;
|
148
159
|
key?: any;
|
149
160
|
rowSize?: Size;
|
@@ -1,2 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2021, 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 useActionsColumn: (hooks: Hooks) => void;
|
1
9
|
export default useActionsColumn;
|
2
|
-
declare function useActionsColumn(hooks: any): void;
|
@@ -17,9 +17,10 @@ var _excluded = ["align", "id", "itemText", "onClick", "icon", "shouldHideMenuIt
|
|
17
17
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
18
18
|
var useActionsColumn = function useActionsColumn(hooks) {
|
19
19
|
var useAttachActionsOnInstance = function useAttachActionsOnInstance(instance) {
|
20
|
-
var
|
21
|
-
|
22
|
-
|
20
|
+
var _ref = instance,
|
21
|
+
rowActions = _ref.rowActions,
|
22
|
+
isFetching = _ref.isFetching,
|
23
|
+
selectedRowIds = _ref.state.selectedRowIds;
|
23
24
|
var getDisabledState = function getDisabledState(rowIndex) {
|
24
25
|
var selectedRowIndexes = Object.keys(selectedRowIds).map(function (n) {
|
25
26
|
return Number(n);
|
@@ -79,10 +80,10 @@ var useActionsColumn = function useActionsColumn(hooks) {
|
|
79
80
|
return;
|
80
81
|
}
|
81
82
|
e.stopPropagation();
|
82
|
-
_onClick(id, row, e);
|
83
|
+
_onClick === null || _onClick === void 0 || _onClick(id, row, e);
|
83
84
|
},
|
84
85
|
disabled: isDisabledByRow
|
85
|
-
}), /*#__PURE__*/React__default.createElement(Icon, null)));
|
86
|
+
}), Icon && /*#__PURE__*/React__default.createElement(Icon, null)));
|
86
87
|
})), !isFetching && (rowActions.length > 2 || isColumnSticky) && /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(OverflowMenu, {
|
87
88
|
align: "left",
|
88
89
|
size: "sm",
|
@@ -108,7 +109,7 @@ var useActionsColumn = function useActionsColumn(hooks) {
|
|
108
109
|
disabled: isDisabledByRow,
|
109
110
|
onClick: function onClick(e) {
|
110
111
|
e.stopPropagation();
|
111
|
-
_onClick2(id, row, e);
|
112
|
+
_onClick2 === null || _onClick2 === void 0 || _onClick2(id, row, e);
|
112
113
|
},
|
113
114
|
key: id
|
114
115
|
}));
|
@@ -220,9 +220,12 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
|
|
220
220
|
}
|
221
221
|
if ((prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row) !== (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) || (prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column) !== (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column)) {
|
222
222
|
if (activeCellCoordinates && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
|
223
|
-
var _activeCellFullData$r;
|
224
223
|
var activeCellFullData = typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'number' && typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'number' ? rows[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row].cells[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
|
225
|
-
|
224
|
+
if (activeCellFullData) {
|
225
|
+
setActiveCellContent(activeCellFullData.render('Cell'));
|
226
|
+
} else {
|
227
|
+
setActiveCellContent(null);
|
228
|
+
}
|
226
229
|
}
|
227
230
|
if (activeCellCoordinates && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
|
228
231
|
setActiveCellContent(null);
|
@@ -437,8 +440,8 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
|
|
437
440
|
var activeCellFullData = typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'number' && typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'number' ? rows[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row].cells[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
|
438
441
|
var activeCellValue;
|
439
442
|
if (activeCellFullData && activeCellCoordinates !== null && activeCellCoordinates !== void 0 && activeCellCoordinates.column) {
|
440
|
-
var _activeCellFullData$
|
441
|
-
activeCellValue = activeCellFullData ? (_activeCellFullData$
|
443
|
+
var _activeCellFullData$r;
|
444
|
+
activeCellValue = activeCellFullData ? (_activeCellFullData$r = activeCellFullData.row.cells) === null || _activeCellFullData$r === void 0 || (_activeCellFullData$r = _activeCellFullData$r[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column]) === null || _activeCellFullData$r === void 0 ? void 0 : _activeCellFullData$r.value : null;
|
442
445
|
}
|
443
446
|
setCellEditorValue(activeCellValue || '');
|
444
447
|
if (cellEditorRulerRef !== null && cellEditorRulerRef !== void 0 && cellEditorRulerRef.current) {
|
@@ -5,10 +5,10 @@ import { RadioButtonProps } from '@carbon/react/lib/components/RadioButton/Radio
|
|
5
5
|
import { RadioButtonGroupProps } from '@carbon/react/lib/components/RadioButtonGroup/RadioButtonGroup';
|
6
6
|
import { CheckboxProps } from '@carbon/react/lib/components/Checkbox';
|
7
7
|
import { NumberInputProps } from '@carbon/react/lib/components/NumberInput/NumberInput';
|
8
|
-
import { CSSProperties, JSXElementConstructor, MutableRefObject, ReactNode, TouchEventHandler } from 'react';
|
8
|
+
import React, { CSSProperties, ComponentType, FunctionComponent, JSXElementConstructor, MutableRefObject, ReactNode, TouchEventHandler } from 'react';
|
9
9
|
import { Cell, Column, ColumnInstance, FilterValue, Filters, HeaderGroup, Meta, Row, TableCommonProps, TableDispatch, TableInstance, TableToggleAllRowsSelectedProps, UseExpandedRowProps, UseFiltersInstanceProps, UsePaginationInstanceProps, UseResizeColumnsColumnProps, UseResizeColumnsState, UseRowSelectInstanceProps, UseRowSelectRowProps, UseRowSelectState, UseSortByColumnProps, UseSortByOptions, UseTableHooks } from 'react-table';
|
10
10
|
import { CarbonIconType } from '@carbon/react/icons';
|
11
|
-
import { type ButtonProps } from '@carbon/react';
|
11
|
+
import { IconButton, type ButtonProps } from '@carbon/react';
|
12
12
|
import { TableBatchActionsProps } from '@carbon/react/lib/components/DataTable/TableBatchActions';
|
13
13
|
export type Size = 'xs' | 'sm' | 'md' | 'lg';
|
14
14
|
export interface ResizerProps {
|
@@ -122,6 +122,16 @@ interface DataGridTableState extends UseResizeColumnsState<any>, UseRowSelectSta
|
|
122
122
|
}
|
123
123
|
export interface DataGridTableInstance<T extends object = any> extends TableInstance<T> {
|
124
124
|
}
|
125
|
+
export interface RowAction {
|
126
|
+
id?: string;
|
127
|
+
itemText?: string;
|
128
|
+
icon?: ComponentType | FunctionComponent;
|
129
|
+
align?: React.ComponentProps<typeof IconButton>['align'];
|
130
|
+
shouldHideMenuItem?: (...args: any[]) => void;
|
131
|
+
shouldDisableMenuItem?: (...args: any[]) => void;
|
132
|
+
disabled?: boolean;
|
133
|
+
onClick?: (...args: any[]) => void;
|
134
|
+
}
|
125
135
|
export interface DataGridState<T extends object = any> extends TableCommonProps, UsePaginationInstanceProps<T>, Omit<TableInstance<T>, 'state' | 'headers' | 'rows' | 'columns'>, Omit<UseFiltersInstanceProps<T>, 'rows'>, UseRowSelectInstanceProps<T>, Pick<UseRowSelectInstanceProps<T>, 'toggleAllRowsSelected'> {
|
126
136
|
withVirtualScroll?: boolean;
|
127
137
|
DatagridPagination?: JSXElementConstructor<any>;
|
@@ -144,6 +154,7 @@ export interface DataGridState<T extends object = any> extends TableCommonProps,
|
|
144
154
|
batchActions?: boolean;
|
145
155
|
row: DatagridRow;
|
146
156
|
rows: Array<DatagridRow<any>>;
|
157
|
+
rowActions?: RowAction[];
|
147
158
|
columns: Array<DatagridColumn>;
|
148
159
|
key?: any;
|
149
160
|
rowSize?: Size;
|
@@ -1,2 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2021, 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 useActionsColumn: (hooks: Hooks) => void;
|
1
9
|
export default useActionsColumn;
|
2
|
-
declare function useActionsColumn(hooks: any): void;
|
@@ -26,9 +26,10 @@ var _excluded = ["align", "id", "itemText", "onClick", "icon", "shouldHideMenuIt
|
|
26
26
|
var blockClass = "".concat(settings.pkg.prefix, "--datagrid");
|
27
27
|
var useActionsColumn = function useActionsColumn(hooks) {
|
28
28
|
var useAttachActionsOnInstance = function useAttachActionsOnInstance(instance) {
|
29
|
-
var
|
30
|
-
|
31
|
-
|
29
|
+
var _ref = instance,
|
30
|
+
rowActions = _ref.rowActions,
|
31
|
+
isFetching = _ref.isFetching,
|
32
|
+
selectedRowIds = _ref.state.selectedRowIds;
|
32
33
|
var getDisabledState = function getDisabledState(rowIndex) {
|
33
34
|
var selectedRowIndexes = Object.keys(selectedRowIds).map(function (n) {
|
34
35
|
return Number(n);
|
@@ -88,10 +89,10 @@ var useActionsColumn = function useActionsColumn(hooks) {
|
|
88
89
|
return;
|
89
90
|
}
|
90
91
|
e.stopPropagation();
|
91
|
-
_onClick(id, row, e);
|
92
|
+
_onClick === null || _onClick === void 0 || _onClick(id, row, e);
|
92
93
|
},
|
93
94
|
disabled: isDisabledByRow
|
94
|
-
}), /*#__PURE__*/React__default["default"].createElement(Icon, null)));
|
95
|
+
}), Icon && /*#__PURE__*/React__default["default"].createElement(Icon, null)));
|
95
96
|
})), !isFetching && (rowActions.length > 2 || isColumnSticky) && /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement(react.OverflowMenu, {
|
96
97
|
align: "left",
|
97
98
|
size: "sm",
|
@@ -117,7 +118,7 @@ var useActionsColumn = function useActionsColumn(hooks) {
|
|
117
118
|
disabled: isDisabledByRow,
|
118
119
|
onClick: function onClick(e) {
|
119
120
|
e.stopPropagation();
|
120
|
-
_onClick2(id, row, e);
|
121
|
+
_onClick2 === null || _onClick2 === void 0 || _onClick2(id, row, e);
|
121
122
|
},
|
122
123
|
key: id
|
123
124
|
}));
|
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.43.2-canary.
|
4
|
+
"version": "2.43.2-canary.15+d38593707",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "lib/index.js",
|
7
7
|
"module": "es/index.js",
|
@@ -119,5 +119,5 @@
|
|
119
119
|
"react": "^16.8.6 || ^17.0.1 || ^18.2.0",
|
120
120
|
"react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
|
121
121
|
},
|
122
|
-
"gitHead": "
|
122
|
+
"gitHead": "d38593707b174e14377e467257a4864dc78c8513"
|
123
123
|
}
|