@carbon/ibm-products 2.43.2-canary.73 → 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
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"),
|
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"),
|
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",
|
@@ -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
|
}
|