@carbon/ibm-products 2.43.2-canary.72 → 2.43.2-canary.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +34 -10
- package/es/components/Datagrid/types/index.d.ts +14 -2
- package/es/components/Datagrid/useDisableSelectRows.d.ts +2 -1
- package/es/components/Datagrid/useDisableSelectRows.js +27 -22
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +34 -10
- package/lib/components/Datagrid/types/index.d.ts +14 -2
- package/lib/components/Datagrid/useDisableSelectRows.d.ts +2 -1
- package/lib/components/Datagrid/useDisableSelectRows.js +27 -22
- package/package.json +3 -3
package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js
CHANGED
@@ -73,15 +73,39 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
|
|
73
73
|
onSaveColumnPrefs(updatedColumns);
|
74
74
|
};
|
75
75
|
var onCheckboxCheck = function onCheckboxCheck(col, value) {
|
76
|
+
// Update the visibility of columns based on a single column or an array of columns
|
76
77
|
var changedDefinitions = columnObjects.map(function (definition) {
|
77
|
-
|
78
|
-
|
78
|
+
// If select all is clicked
|
79
|
+
if (Array.isArray(col)) {
|
80
|
+
return col.includes(definition) && definition.canFilter && !definition.disabled ? _objectSpread2(_objectSpread2({}, definition), {}, {
|
79
81
|
isVisible: value
|
80
|
-
});
|
82
|
+
}) : definition;
|
81
83
|
}
|
82
|
-
return
|
84
|
+
// If a single checkbox is clicked which is written below as a default return
|
85
|
+
return col.id === definition.id ? _objectSpread2(_objectSpread2({}, definition), {}, {
|
86
|
+
isVisible: value
|
87
|
+
}) : definition;
|
83
88
|
});
|
84
|
-
|
89
|
+
|
90
|
+
// Count the number of visible columns excluding certain IDs after 1st mutation
|
91
|
+
var selectedColumnsCount = changedDefinitions.filter(function (definition) {
|
92
|
+
return definition.isVisible && !['datagridSelection', 'actions'].includes(definition.id);
|
93
|
+
}).length;
|
94
|
+
|
95
|
+
// Ensure special columns are visible if any other columns are visible
|
96
|
+
var finalDefinitions = changedDefinitions.map(function (definition) {
|
97
|
+
// If at least 1 column is visible after mutation, we add selection column and actions column (coming from various extensions)
|
98
|
+
if (selectedColumnsCount > 0) {
|
99
|
+
return ['datagridSelection', 'actions'].includes(definition.id) ? _objectSpread2(_objectSpread2({}, definition), {}, {
|
100
|
+
isVisible: true
|
101
|
+
}) : definition;
|
102
|
+
}
|
103
|
+
// Else we remove selection column and actions column
|
104
|
+
return ['datagridSelection', 'actions'].includes(definition.id) ? _objectSpread2(_objectSpread2({}, definition), {}, {
|
105
|
+
isVisible: false
|
106
|
+
}) : definition;
|
107
|
+
});
|
108
|
+
setColumnObjects(finalDefinitions);
|
85
109
|
setDirty();
|
86
110
|
};
|
87
111
|
var setDirty = function setDirty() {
|
@@ -96,14 +120,14 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
|
|
96
120
|
}, [columnObjects]);
|
97
121
|
var string = searchText.trim().toLowerCase();
|
98
122
|
useEffect(function () {
|
99
|
-
var notFilterableCount = columnObjects.filter(function (col) {
|
100
|
-
return !col.canFilter;
|
101
|
-
}).length;
|
102
123
|
var actionCount = columnObjects.filter(function (col) {
|
103
124
|
return col.id === 'actions';
|
104
125
|
}).length;
|
105
|
-
|
106
|
-
|
126
|
+
var datagridSelectionCount = columnObjects.filter(function (col) {
|
127
|
+
return col.id === 'datagridSelection';
|
128
|
+
}).length;
|
129
|
+
setVisibleColumnsCount(getVisibleColumnsCount() - actionCount - datagridSelectionCount < 0 ? 0 : getVisibleColumnsCount() - actionCount - datagridSelectionCount);
|
130
|
+
setTotalColumns(columnObjects.length - actionCount - datagridSelectionCount);
|
107
131
|
}, [getVisibleColumnsCount, columnObjects]);
|
108
132
|
return /*#__PURE__*/React__default.createElement(TearsheetNarrow, {
|
109
133
|
className: "".concat(blockClass, "__customize-columns-tearsheet"),
|
@@ -6,7 +6,7 @@ import { RadioButtonGroupProps } from '@carbon/react/lib/components/RadioButtonG
|
|
6
6
|
import { CheckboxProps } from '@carbon/react/lib/components/Checkbox';
|
7
7
|
import { NumberInputProps } from '@carbon/react/lib/components/NumberInput/NumberInput';
|
8
8
|
import React, { CSSProperties, ComponentType, FunctionComponent, JSXElementConstructor, MutableRefObject, ReactNode, TouchEventHandler } from 'react';
|
9
|
-
import { Cell, Column, ColumnInstance, FilterValue, Filters, HeaderGroup, Meta, Row, TableCommonProps, TableDispatch, TableInstance, TableToggleAllRowsSelectedProps, UseExpandedRowProps, UseFiltersInstanceProps, UsePaginationInstanceProps, UseResizeColumnsColumnProps, UseResizeColumnsOptions, UseResizeColumnsState, UseRowSelectInstanceProps, UseRowSelectRowProps, UseRowSelectState, UseSortByColumnProps, UseSortByOptions, UseTableHooks } from 'react-table';
|
9
|
+
import { Cell, Column, ColumnInstance, FilterValue, Filters, HeaderGroup, Meta, Row, TableCommonProps, TableDispatch, TableInstance, TableState, TableToggleAllRowsSelectedProps, UseExpandedRowProps, UseFiltersInstanceProps, UsePaginationInstanceProps, UseResizeColumnsColumnProps, UseResizeColumnsOptions, UseResizeColumnsState, UseRowSelectInstanceProps, UseRowSelectRowProps, UseRowSelectState, UseSortByColumnProps, UseSortByOptions, UseTableHooks } from 'react-table';
|
10
10
|
import { CarbonIconType } from '@carbon/react/icons';
|
11
11
|
import { IconButton, type ButtonProps } from '@carbon/react';
|
12
12
|
import { TableBatchActionsProps } from '@carbon/react/lib/components/DataTable/TableBatchActions';
|
@@ -129,7 +129,15 @@ export interface DataGridTableProps extends TableCommonProps {
|
|
129
129
|
interface DataGridTableState extends UseResizeColumnsState<any>, UseRowSelectState<any> {
|
130
130
|
filters: Filters<DataGridFilter>;
|
131
131
|
}
|
132
|
-
export interface DataGridTableInstance<T extends object = any> extends TableInstance<T
|
132
|
+
export interface DataGridTableInstance<T extends object = any> extends Omit<TableInstance<T>, 'state'>, Partial<UsePaginationInstanceProps<any>> {
|
133
|
+
shouldDisableSelectRow?: (...args: any[]) => void | boolean;
|
134
|
+
state?: Partial<TableState & UseRowSelectState<any>>;
|
135
|
+
disableSelectAll?: boolean;
|
136
|
+
disableSelectRowsProps?: {
|
137
|
+
labels?: {
|
138
|
+
toggleAllRowsLabel?: string;
|
139
|
+
};
|
140
|
+
};
|
133
141
|
withSelectRows?: boolean;
|
134
142
|
}
|
135
143
|
export interface RowAction {
|
@@ -253,4 +261,8 @@ export interface ResizeHeaderProps {
|
|
253
261
|
}
|
254
262
|
export type VisibleColumns<T extends object = {}> = (allColumns: Array<ColumnInstance<T>>, meta: Meta<T>) => Array<Column<T>>;
|
255
263
|
export type NodeFuncType = (props: any) => ReactNode;
|
264
|
+
export interface PropGetterMeta {
|
265
|
+
instance?: DataGridTableInstance;
|
266
|
+
row?: Partial<Row<any> & DatagridRow<any>>;
|
267
|
+
}
|
256
268
|
export {};
|
@@ -9,52 +9,56 @@ var useDisableSelectRows = function useDisableSelectRows(hooks) {
|
|
9
9
|
updateSelectAll(hooks);
|
10
10
|
updatePageSelectAll(hooks);
|
11
11
|
var getRowProps = function getRowProps(props, _ref) {
|
12
|
+
var _instance$shouldDisab;
|
12
13
|
var row = _ref.row,
|
13
14
|
instance = _ref.instance;
|
14
15
|
return [props, {
|
15
|
-
disabled: instance.shouldDisableSelectRow
|
16
|
+
disabled: instance === null || instance === void 0 || (_instance$shouldDisab = instance.shouldDisableSelectRow) === null || _instance$shouldDisab === void 0 ? void 0 : _instance$shouldDisab.call(instance, row)
|
16
17
|
}];
|
17
18
|
};
|
18
19
|
hooks.getRowProps.push(getRowProps);
|
19
20
|
};
|
20
21
|
var updateSelectAll = function updateSelectAll(hooks) {
|
21
22
|
var getToggleAllRowsSelectedProps = function getToggleAllRowsSelectedProps(props, _ref2) {
|
22
|
-
var _instance$disableSele;
|
23
|
+
var _instance$rows, _instance$disableSele, _instance$state2;
|
23
24
|
var instance = _ref2.instance;
|
24
|
-
var selectableRows = instance.rows.filter(function (row) {
|
25
|
+
var selectableRows = (instance === null || instance === void 0 || (_instance$rows = instance.rows) === null || _instance$rows === void 0 ? void 0 : _instance$rows.filter(function (row) {
|
25
26
|
return !(instance.shouldDisableSelectRow && instance.shouldDisableSelectRow(row));
|
26
|
-
});
|
27
|
-
var isAllRowsSelected = selectableRows.length > 0 && selectableRows.every(function (_ref3) {
|
27
|
+
})) || [];
|
28
|
+
var isAllRowsSelected = (selectableRows === null || selectableRows === void 0 ? void 0 : selectableRows.length) > 0 && selectableRows.every(function (_ref3) {
|
29
|
+
var _instance$state;
|
28
30
|
var id = _ref3.id;
|
29
|
-
return instance.state.selectedRowIds[id];
|
31
|
+
return instance === null || instance === void 0 || (_instance$state = instance.state) === null || _instance$state === void 0 || (_instance$state = _instance$state.selectedRowIds) === null || _instance$state === void 0 ? void 0 : _instance$state[id];
|
30
32
|
});
|
31
33
|
return [props, {
|
32
34
|
onChange: function onChange(e) {
|
33
35
|
selectableRows.forEach(function (row) {
|
34
|
-
|
36
|
+
var _toggleRowSelected, _ref4;
|
37
|
+
return row === null || row === void 0 || (_toggleRowSelected = (_ref4 = row).toggleRowSelected) === null || _toggleRowSelected === void 0 ? void 0 : _toggleRowSelected.call(_ref4, e.target.checked);
|
35
38
|
});
|
36
39
|
},
|
37
40
|
style: {
|
38
41
|
cursor: 'pointer'
|
39
42
|
},
|
40
43
|
checked: isAllRowsSelected,
|
41
|
-
disabled: instance.disableSelectAll,
|
44
|
+
disabled: instance === null || instance === void 0 ? void 0 : instance.disableSelectAll,
|
42
45
|
title: (instance === null || instance === void 0 || (_instance$disableSele = instance.disableSelectRowsProps) === null || _instance$disableSele === void 0 || (_instance$disableSele = _instance$disableSele.labels) === null || _instance$disableSele === void 0 ? void 0 : _instance$disableSele.toggleAllRowsLabel) || 'Toggle All Rows Selected',
|
43
|
-
indeterminate: Boolean(!isAllRowsSelected && Object.keys(instance.state.selectedRowIds).length)
|
46
|
+
indeterminate: Boolean(!isAllRowsSelected && Object.keys((instance === null || instance === void 0 || (_instance$state2 = instance.state) === null || _instance$state2 === void 0 ? void 0 : _instance$state2.selectedRowIds) || {}).length)
|
44
47
|
}];
|
45
48
|
};
|
46
49
|
hooks.getToggleAllRowsSelectedProps.push(getToggleAllRowsSelectedProps);
|
47
50
|
};
|
48
51
|
var updatePageSelectAll = function updatePageSelectAll(hooks) {
|
49
|
-
var getToggleAllPageRowsSelectedProps = function getToggleAllPageRowsSelectedProps(props,
|
50
|
-
var _instance$disableSele2;
|
51
|
-
var instance =
|
52
|
-
var selectableRows = instance.page.filter(function (row) {
|
52
|
+
var getToggleAllPageRowsSelectedProps = function getToggleAllPageRowsSelectedProps(props, _ref5) {
|
53
|
+
var _instance$page, _instance$disableSele2, _instance$page2;
|
54
|
+
var instance = _ref5.instance;
|
55
|
+
var selectableRows = (instance === null || instance === void 0 || (_instance$page = instance.page) === null || _instance$page === void 0 ? void 0 : _instance$page.filter(function (row) {
|
53
56
|
return !(instance.shouldDisableSelectRow && instance.shouldDisableSelectRow(row));
|
54
|
-
});
|
55
|
-
var isAllRowsSelected = selectableRows.length > 0 && selectableRows.every(function (
|
56
|
-
var
|
57
|
-
|
57
|
+
})) || [];
|
58
|
+
var isAllRowsSelected = (selectableRows === null || selectableRows === void 0 ? void 0 : selectableRows.length) > 0 && selectableRows.every(function (_ref6) {
|
59
|
+
var _instance$state3;
|
60
|
+
var id = _ref6.id;
|
61
|
+
return instance === null || instance === void 0 || (_instance$state3 = instance.state) === null || _instance$state3 === void 0 || (_instance$state3 = _instance$state3.selectedRowIds) === null || _instance$state3 === void 0 ? void 0 : _instance$state3[id];
|
58
62
|
});
|
59
63
|
return [props, {
|
60
64
|
onChange: function onChange(e) {
|
@@ -66,12 +70,13 @@ var updatePageSelectAll = function updatePageSelectAll(hooks) {
|
|
66
70
|
cursor: 'pointer'
|
67
71
|
},
|
68
72
|
checked: isAllRowsSelected,
|
69
|
-
disabled: instance.disableSelectAll,
|
73
|
+
disabled: instance === null || instance === void 0 ? void 0 : instance.disableSelectAll,
|
70
74
|
title: (instance === null || instance === void 0 || (_instance$disableSele2 = instance.disableSelectRowsProps) === null || _instance$disableSele2 === void 0 || (_instance$disableSele2 = _instance$disableSele2.labels) === null || _instance$disableSele2 === void 0 ? void 0 : _instance$disableSele2.toggleAllRowsLabel) || 'Toggle All Rows Selected',
|
71
|
-
indeterminate: Boolean(!isAllRowsSelected && instance.page.some(function (
|
72
|
-
var
|
73
|
-
|
74
|
-
|
75
|
+
indeterminate: Boolean(!isAllRowsSelected && (instance === null || instance === void 0 || (_instance$page2 = instance.page) === null || _instance$page2 === void 0 ? void 0 : _instance$page2.some(function (_ref7) {
|
76
|
+
var _instance$state4;
|
77
|
+
var id = _ref7.id;
|
78
|
+
return instance === null || instance === void 0 || (_instance$state4 = instance.state) === null || _instance$state4 === void 0 || (_instance$state4 = _instance$state4.selectedRowIds) === null || _instance$state4 === void 0 ? void 0 : _instance$state4[id];
|
79
|
+
})))
|
75
80
|
}];
|
76
81
|
};
|
77
82
|
hooks.getToggleAllPageRowsSelectedProps.push(getToggleAllPageRowsSelectedProps);
|
package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js
CHANGED
@@ -81,15 +81,39 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
|
|
81
81
|
onSaveColumnPrefs(updatedColumns);
|
82
82
|
};
|
83
83
|
var onCheckboxCheck = function onCheckboxCheck(col, value) {
|
84
|
+
// Update the visibility of columns based on a single column or an array of columns
|
84
85
|
var changedDefinitions = columnObjects.map(function (definition) {
|
85
|
-
|
86
|
-
|
86
|
+
// If select all is clicked
|
87
|
+
if (Array.isArray(col)) {
|
88
|
+
return col.includes(definition) && definition.canFilter && !definition.disabled ? _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, definition), {}, {
|
87
89
|
isVisible: value
|
88
|
-
});
|
90
|
+
}) : definition;
|
89
91
|
}
|
90
|
-
return
|
92
|
+
// If a single checkbox is clicked which is written below as a default return
|
93
|
+
return col.id === definition.id ? _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, definition), {}, {
|
94
|
+
isVisible: value
|
95
|
+
}) : definition;
|
91
96
|
});
|
92
|
-
|
97
|
+
|
98
|
+
// Count the number of visible columns excluding certain IDs after 1st mutation
|
99
|
+
var selectedColumnsCount = changedDefinitions.filter(function (definition) {
|
100
|
+
return definition.isVisible && !['datagridSelection', 'actions'].includes(definition.id);
|
101
|
+
}).length;
|
102
|
+
|
103
|
+
// Ensure special columns are visible if any other columns are visible
|
104
|
+
var finalDefinitions = changedDefinitions.map(function (definition) {
|
105
|
+
// If at least 1 column is visible after mutation, we add selection column and actions column (coming from various extensions)
|
106
|
+
if (selectedColumnsCount > 0) {
|
107
|
+
return ['datagridSelection', 'actions'].includes(definition.id) ? _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, definition), {}, {
|
108
|
+
isVisible: true
|
109
|
+
}) : definition;
|
110
|
+
}
|
111
|
+
// Else we remove selection column and actions column
|
112
|
+
return ['datagridSelection', 'actions'].includes(definition.id) ? _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, definition), {}, {
|
113
|
+
isVisible: false
|
114
|
+
}) : definition;
|
115
|
+
});
|
116
|
+
setColumnObjects(finalDefinitions);
|
93
117
|
setDirty();
|
94
118
|
};
|
95
119
|
var setDirty = function setDirty() {
|
@@ -104,14 +128,14 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
|
|
104
128
|
}, [columnObjects]);
|
105
129
|
var string = searchText.trim().toLowerCase();
|
106
130
|
React.useEffect(function () {
|
107
|
-
var notFilterableCount = columnObjects.filter(function (col) {
|
108
|
-
return !col.canFilter;
|
109
|
-
}).length;
|
110
131
|
var actionCount = columnObjects.filter(function (col) {
|
111
132
|
return col.id === 'actions';
|
112
133
|
}).length;
|
113
|
-
|
114
|
-
|
134
|
+
var datagridSelectionCount = columnObjects.filter(function (col) {
|
135
|
+
return col.id === 'datagridSelection';
|
136
|
+
}).length;
|
137
|
+
setVisibleColumnsCount(getVisibleColumnsCount() - actionCount - datagridSelectionCount < 0 ? 0 : getVisibleColumnsCount() - actionCount - datagridSelectionCount);
|
138
|
+
setTotalColumns(columnObjects.length - actionCount - datagridSelectionCount);
|
115
139
|
}, [getVisibleColumnsCount, columnObjects]);
|
116
140
|
return /*#__PURE__*/React__default["default"].createElement(TearsheetNarrow.TearsheetNarrow, {
|
117
141
|
className: "".concat(blockClass, "__customize-columns-tearsheet"),
|
@@ -6,7 +6,7 @@ import { RadioButtonGroupProps } from '@carbon/react/lib/components/RadioButtonG
|
|
6
6
|
import { CheckboxProps } from '@carbon/react/lib/components/Checkbox';
|
7
7
|
import { NumberInputProps } from '@carbon/react/lib/components/NumberInput/NumberInput';
|
8
8
|
import React, { CSSProperties, ComponentType, FunctionComponent, JSXElementConstructor, MutableRefObject, ReactNode, TouchEventHandler } from 'react';
|
9
|
-
import { Cell, Column, ColumnInstance, FilterValue, Filters, HeaderGroup, Meta, Row, TableCommonProps, TableDispatch, TableInstance, TableToggleAllRowsSelectedProps, UseExpandedRowProps, UseFiltersInstanceProps, UsePaginationInstanceProps, UseResizeColumnsColumnProps, UseResizeColumnsOptions, UseResizeColumnsState, UseRowSelectInstanceProps, UseRowSelectRowProps, UseRowSelectState, UseSortByColumnProps, UseSortByOptions, UseTableHooks } from 'react-table';
|
9
|
+
import { Cell, Column, ColumnInstance, FilterValue, Filters, HeaderGroup, Meta, Row, TableCommonProps, TableDispatch, TableInstance, TableState, TableToggleAllRowsSelectedProps, UseExpandedRowProps, UseFiltersInstanceProps, UsePaginationInstanceProps, UseResizeColumnsColumnProps, UseResizeColumnsOptions, UseResizeColumnsState, UseRowSelectInstanceProps, UseRowSelectRowProps, UseRowSelectState, UseSortByColumnProps, UseSortByOptions, UseTableHooks } from 'react-table';
|
10
10
|
import { CarbonIconType } from '@carbon/react/icons';
|
11
11
|
import { IconButton, type ButtonProps } from '@carbon/react';
|
12
12
|
import { TableBatchActionsProps } from '@carbon/react/lib/components/DataTable/TableBatchActions';
|
@@ -129,7 +129,15 @@ export interface DataGridTableProps extends TableCommonProps {
|
|
129
129
|
interface DataGridTableState extends UseResizeColumnsState<any>, UseRowSelectState<any> {
|
130
130
|
filters: Filters<DataGridFilter>;
|
131
131
|
}
|
132
|
-
export interface DataGridTableInstance<T extends object = any> extends TableInstance<T
|
132
|
+
export interface DataGridTableInstance<T extends object = any> extends Omit<TableInstance<T>, 'state'>, Partial<UsePaginationInstanceProps<any>> {
|
133
|
+
shouldDisableSelectRow?: (...args: any[]) => void | boolean;
|
134
|
+
state?: Partial<TableState & UseRowSelectState<any>>;
|
135
|
+
disableSelectAll?: boolean;
|
136
|
+
disableSelectRowsProps?: {
|
137
|
+
labels?: {
|
138
|
+
toggleAllRowsLabel?: string;
|
139
|
+
};
|
140
|
+
};
|
133
141
|
withSelectRows?: boolean;
|
134
142
|
}
|
135
143
|
export interface RowAction {
|
@@ -253,4 +261,8 @@ export interface ResizeHeaderProps {
|
|
253
261
|
}
|
254
262
|
export type VisibleColumns<T extends object = {}> = (allColumns: Array<ColumnInstance<T>>, meta: Meta<T>) => Array<Column<T>>;
|
255
263
|
export type NodeFuncType = (props: any) => ReactNode;
|
264
|
+
export interface PropGetterMeta {
|
265
|
+
instance?: DataGridTableInstance;
|
266
|
+
row?: Partial<Row<any> & DatagridRow<any>>;
|
267
|
+
}
|
256
268
|
export {};
|
@@ -13,52 +13,56 @@ var useDisableSelectRows = function useDisableSelectRows(hooks) {
|
|
13
13
|
updateSelectAll(hooks);
|
14
14
|
updatePageSelectAll(hooks);
|
15
15
|
var getRowProps = function getRowProps(props, _ref) {
|
16
|
+
var _instance$shouldDisab;
|
16
17
|
var row = _ref.row,
|
17
18
|
instance = _ref.instance;
|
18
19
|
return [props, {
|
19
|
-
disabled: instance.shouldDisableSelectRow
|
20
|
+
disabled: instance === null || instance === void 0 || (_instance$shouldDisab = instance.shouldDisableSelectRow) === null || _instance$shouldDisab === void 0 ? void 0 : _instance$shouldDisab.call(instance, row)
|
20
21
|
}];
|
21
22
|
};
|
22
23
|
hooks.getRowProps.push(getRowProps);
|
23
24
|
};
|
24
25
|
var updateSelectAll = function updateSelectAll(hooks) {
|
25
26
|
var getToggleAllRowsSelectedProps = function getToggleAllRowsSelectedProps(props, _ref2) {
|
26
|
-
var _instance$disableSele;
|
27
|
+
var _instance$rows, _instance$disableSele, _instance$state2;
|
27
28
|
var instance = _ref2.instance;
|
28
|
-
var selectableRows = instance.rows.filter(function (row) {
|
29
|
+
var selectableRows = (instance === null || instance === void 0 || (_instance$rows = instance.rows) === null || _instance$rows === void 0 ? void 0 : _instance$rows.filter(function (row) {
|
29
30
|
return !(instance.shouldDisableSelectRow && instance.shouldDisableSelectRow(row));
|
30
|
-
});
|
31
|
-
var isAllRowsSelected = selectableRows.length > 0 && selectableRows.every(function (_ref3) {
|
31
|
+
})) || [];
|
32
|
+
var isAllRowsSelected = (selectableRows === null || selectableRows === void 0 ? void 0 : selectableRows.length) > 0 && selectableRows.every(function (_ref3) {
|
33
|
+
var _instance$state;
|
32
34
|
var id = _ref3.id;
|
33
|
-
return instance.state.selectedRowIds[id];
|
35
|
+
return instance === null || instance === void 0 || (_instance$state = instance.state) === null || _instance$state === void 0 || (_instance$state = _instance$state.selectedRowIds) === null || _instance$state === void 0 ? void 0 : _instance$state[id];
|
34
36
|
});
|
35
37
|
return [props, {
|
36
38
|
onChange: function onChange(e) {
|
37
39
|
selectableRows.forEach(function (row) {
|
38
|
-
|
40
|
+
var _toggleRowSelected, _ref4;
|
41
|
+
return row === null || row === void 0 || (_toggleRowSelected = (_ref4 = row).toggleRowSelected) === null || _toggleRowSelected === void 0 ? void 0 : _toggleRowSelected.call(_ref4, e.target.checked);
|
39
42
|
});
|
40
43
|
},
|
41
44
|
style: {
|
42
45
|
cursor: 'pointer'
|
43
46
|
},
|
44
47
|
checked: isAllRowsSelected,
|
45
|
-
disabled: instance.disableSelectAll,
|
48
|
+
disabled: instance === null || instance === void 0 ? void 0 : instance.disableSelectAll,
|
46
49
|
title: (instance === null || instance === void 0 || (_instance$disableSele = instance.disableSelectRowsProps) === null || _instance$disableSele === void 0 || (_instance$disableSele = _instance$disableSele.labels) === null || _instance$disableSele === void 0 ? void 0 : _instance$disableSele.toggleAllRowsLabel) || 'Toggle All Rows Selected',
|
47
|
-
indeterminate: Boolean(!isAllRowsSelected && Object.keys(instance.state.selectedRowIds).length)
|
50
|
+
indeterminate: Boolean(!isAllRowsSelected && Object.keys((instance === null || instance === void 0 || (_instance$state2 = instance.state) === null || _instance$state2 === void 0 ? void 0 : _instance$state2.selectedRowIds) || {}).length)
|
48
51
|
}];
|
49
52
|
};
|
50
53
|
hooks.getToggleAllRowsSelectedProps.push(getToggleAllRowsSelectedProps);
|
51
54
|
};
|
52
55
|
var updatePageSelectAll = function updatePageSelectAll(hooks) {
|
53
|
-
var getToggleAllPageRowsSelectedProps = function getToggleAllPageRowsSelectedProps(props,
|
54
|
-
var _instance$disableSele2;
|
55
|
-
var instance =
|
56
|
-
var selectableRows = instance.page.filter(function (row) {
|
56
|
+
var getToggleAllPageRowsSelectedProps = function getToggleAllPageRowsSelectedProps(props, _ref5) {
|
57
|
+
var _instance$page, _instance$disableSele2, _instance$page2;
|
58
|
+
var instance = _ref5.instance;
|
59
|
+
var selectableRows = (instance === null || instance === void 0 || (_instance$page = instance.page) === null || _instance$page === void 0 ? void 0 : _instance$page.filter(function (row) {
|
57
60
|
return !(instance.shouldDisableSelectRow && instance.shouldDisableSelectRow(row));
|
58
|
-
});
|
59
|
-
var isAllRowsSelected = selectableRows.length > 0 && selectableRows.every(function (
|
60
|
-
var
|
61
|
-
|
61
|
+
})) || [];
|
62
|
+
var isAllRowsSelected = (selectableRows === null || selectableRows === void 0 ? void 0 : selectableRows.length) > 0 && selectableRows.every(function (_ref6) {
|
63
|
+
var _instance$state3;
|
64
|
+
var id = _ref6.id;
|
65
|
+
return instance === null || instance === void 0 || (_instance$state3 = instance.state) === null || _instance$state3 === void 0 || (_instance$state3 = _instance$state3.selectedRowIds) === null || _instance$state3 === void 0 ? void 0 : _instance$state3[id];
|
62
66
|
});
|
63
67
|
return [props, {
|
64
68
|
onChange: function onChange(e) {
|
@@ -70,12 +74,13 @@ var updatePageSelectAll = function updatePageSelectAll(hooks) {
|
|
70
74
|
cursor: 'pointer'
|
71
75
|
},
|
72
76
|
checked: isAllRowsSelected,
|
73
|
-
disabled: instance.disableSelectAll,
|
77
|
+
disabled: instance === null || instance === void 0 ? void 0 : instance.disableSelectAll,
|
74
78
|
title: (instance === null || instance === void 0 || (_instance$disableSele2 = instance.disableSelectRowsProps) === null || _instance$disableSele2 === void 0 || (_instance$disableSele2 = _instance$disableSele2.labels) === null || _instance$disableSele2 === void 0 ? void 0 : _instance$disableSele2.toggleAllRowsLabel) || 'Toggle All Rows Selected',
|
75
|
-
indeterminate: Boolean(!isAllRowsSelected && instance.page.some(function (
|
76
|
-
var
|
77
|
-
|
78
|
-
|
79
|
+
indeterminate: Boolean(!isAllRowsSelected && (instance === null || instance === void 0 || (_instance$page2 = instance.page) === null || _instance$page2 === void 0 ? void 0 : _instance$page2.some(function (_ref7) {
|
80
|
+
var _instance$state4;
|
81
|
+
var id = _ref7.id;
|
82
|
+
return instance === null || instance === void 0 || (_instance$state4 = instance.state) === null || _instance$state4 === void 0 || (_instance$state4 = _instance$state4.selectedRowIds) === null || _instance$state4 === void 0 ? void 0 : _instance$state4[id];
|
83
|
+
})))
|
79
84
|
}];
|
80
85
|
};
|
81
86
|
hooks.getToggleAllPageRowsSelectedProps.push(getToggleAllPageRowsSelectedProps);
|
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.74+e97438896",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "lib/index.js",
|
7
7
|
"module": "es/index.js",
|
@@ -96,7 +96,7 @@
|
|
96
96
|
"dependencies": {
|
97
97
|
"@babel/runtime": "^7.23.9",
|
98
98
|
"@carbon/feature-flags": "^0.20.0",
|
99
|
-
"@carbon/ibm-products-styles": "^2.
|
99
|
+
"@carbon/ibm-products-styles": "^2.41.0-rc.0",
|
100
100
|
"@carbon/telemetry": "^0.1.0",
|
101
101
|
"@dnd-kit/core": "^6.0.8",
|
102
102
|
"@dnd-kit/modifiers": "^7.0.0",
|
@@ -120,5 +120,5 @@
|
|
120
120
|
"react": "^16.8.6 || ^17.0.1 || ^18.2.0",
|
121
121
|
"react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
|
122
122
|
},
|
123
|
-
"gitHead": "
|
123
|
+
"gitHead": "e974388969170c4cf6dcb28adb5f98b3dc5ccc27"
|
124
124
|
}
|