@visns-studio/visns-components 3.4.6 → 3.4.7

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.
@@ -248,19 +248,39 @@ const DataGrid = forwardRef(
248
248
  }
249
249
  };
250
250
 
251
- const handleSelectionChange = useCallback((param) => {
252
- if (param.selected === true) {
253
- const s = {};
251
+ const handleSelectionChange = useCallback(
252
+ (param) => {
253
+ if (param.selected === true) {
254
+ const s = {};
254
255
 
255
- param.data.forEach((obj) => {
256
- s[obj.id] = obj;
257
- });
256
+ param.data.forEach((obj) => {
257
+ s[obj.id] = obj;
258
+ });
258
259
 
259
- setSelected(s);
260
- } else {
261
- setSelected(param.selected);
262
- }
263
- }, []);
260
+ setSelected(s);
261
+ } else if (typeof param.selected === 'object') {
262
+ // Assuming param.selected is an object where keys are the ids of the selections
263
+ const selectedKey = Object.keys(param.selected)[0]; // Get the key of the selected object
264
+ const isSelectedAlready =
265
+ selected.hasOwnProperty(selectedKey); // Check if this key is already in selected
266
+
267
+ if (isSelectedAlready) {
268
+ // If the key already exists, reset selected
269
+ setSelected({});
270
+ } else {
271
+ // If it does not exist, update selected with the new object
272
+ setSelected((prevSelected) => ({
273
+ ...prevSelected,
274
+ [selectedKey]: param.selected[selectedKey],
275
+ }));
276
+ }
277
+ } else {
278
+ // Handle other cases as needed
279
+ setSelected(param.selected);
280
+ }
281
+ },
282
+ [selected]
283
+ ); // Including selected in the dependency array
264
284
 
265
285
  const findUpdatedFilter = (filters, currentValues) => {
266
286
  for (const filter of filters) {
package/package.json CHANGED
@@ -49,7 +49,7 @@
49
49
  "react-dom": "^17.0.1"
50
50
  },
51
51
  "name": "@visns-studio/visns-components",
52
- "version": "3.4.6",
52
+ "version": "3.4.7",
53
53
  "description": "Various packages to assist in the development of our Custom Applications.",
54
54
  "main": "index.js",
55
55
  "scripts": {