@insticc/react-datagrid-2 1.1.25 → 1.1.26
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/build/wrapper/index.js +39 -46
- package/package.json +1 -1
package/build/wrapper/index.js
CHANGED
|
@@ -144,7 +144,7 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
144
144
|
// get the selected rows (if is a int that means that the row is selected if is a double that means that is a subrow)
|
|
145
145
|
// so if is a subrow we need to go to the parent row and get the id that is on the position after the .
|
|
146
146
|
// 308.1 this is a subrow so we need to get the 308 row and get the id of the subrow that is in the position 1 of the array
|
|
147
|
-
var getSelectedRows = function
|
|
147
|
+
var getSelectedRows = (0, _react.useCallback)(function (rows) {
|
|
148
148
|
var data = createRows;
|
|
149
149
|
return Object.keys(rows).filter(function (key) {
|
|
150
150
|
return rows[key];
|
|
@@ -167,7 +167,7 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
167
167
|
}).filter(function (row) {
|
|
168
168
|
return row;
|
|
169
169
|
});
|
|
170
|
-
};
|
|
170
|
+
}, [createRows]);
|
|
171
171
|
|
|
172
172
|
// implemented to update selectedIds when props change
|
|
173
173
|
(0, _react.useEffect)(function () {
|
|
@@ -183,28 +183,7 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
183
183
|
}, {});
|
|
184
184
|
setRowSelection(newSelection);
|
|
185
185
|
}
|
|
186
|
-
}, [selectedIds]);
|
|
187
|
-
(0, _react.useEffect)(function () {
|
|
188
|
-
if (hasSubRows) {
|
|
189
|
-
if (Object.keys(rowSelection).length > 0) {
|
|
190
|
-
selectData(getSelectedRows(rowSelection));
|
|
191
|
-
}
|
|
192
|
-
} else {
|
|
193
|
-
// DEPRECATED:
|
|
194
|
-
// selectData(table.getSelectedRowModel().rows.map(row => row.original));
|
|
195
|
-
|
|
196
|
-
var selectedRowIds = Object.keys(table.getState().rowSelection);
|
|
197
|
-
var selectedRows = selectedRowIds.map(function (rowId) {
|
|
198
|
-
var matchingRow = table.getSelectedRowModel().rows.find(function (row) {
|
|
199
|
-
return "".concat(row.id) === rowId;
|
|
200
|
-
});
|
|
201
|
-
return matchingRow ? matchingRow.original : null; // Return original if found
|
|
202
|
-
}).filter(function (row) {
|
|
203
|
-
return row !== null;
|
|
204
|
-
}); // Filter out any null values
|
|
205
|
-
selectData(selectedRows);
|
|
206
|
-
}
|
|
207
|
-
}, [rowSelection]);
|
|
186
|
+
}, [selectedIds, rowSelection]);
|
|
208
187
|
(0, _react.useEffect)(function () {
|
|
209
188
|
if (typeof window !== 'undefined') {
|
|
210
189
|
setIsLoading(false);
|
|
@@ -294,23 +273,20 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
294
273
|
flexWrap: 'wrap'
|
|
295
274
|
},
|
|
296
275
|
children: (actions === null || actions === void 0 ? void 0 : actions.length) > 0 && actions.map(function (e) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
disabled: e.disabled
|
|
312
|
-
}, e.key || e.name);
|
|
313
|
-
}
|
|
276
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ActionButton["default"], {
|
|
277
|
+
table: table,
|
|
278
|
+
toggle: e.toggle,
|
|
279
|
+
active: e.active,
|
|
280
|
+
name: e.name,
|
|
281
|
+
tooltip: e.tooltip,
|
|
282
|
+
onClick: e["function"],
|
|
283
|
+
icon: e.icon,
|
|
284
|
+
color: e.color,
|
|
285
|
+
selectionMode: e.selectionMode,
|
|
286
|
+
confirmMessage: e.confirmMessage,
|
|
287
|
+
hasConfirmMessage: e.hasConfirmMessage,
|
|
288
|
+
disabled: e.disabled
|
|
289
|
+
}, e.key || e.name);
|
|
314
290
|
})
|
|
315
291
|
}), !disableSideActions && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
316
292
|
style: {
|
|
@@ -791,7 +767,6 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
791
767
|
var row = _ref8.row;
|
|
792
768
|
return {
|
|
793
769
|
checked: rowSelection[row.id] || false,
|
|
794
|
-
indeterminate: false,
|
|
795
770
|
onChange: function onChange() {
|
|
796
771
|
var rowId = row.id.toString();
|
|
797
772
|
setRowSelection(function (prev) {
|
|
@@ -817,15 +792,33 @@ var DataGrid = function DataGrid(_ref) {
|
|
|
817
792
|
// </div>
|
|
818
793
|
// )}
|
|
819
794
|
});
|
|
795
|
+
(0, _react.useEffect)(function () {
|
|
796
|
+
if (hasSubRows) {
|
|
797
|
+
if (Object.keys(rowSelection).length > 0) {
|
|
798
|
+
selectData(getSelectedRows(rowSelection));
|
|
799
|
+
}
|
|
800
|
+
} else {
|
|
801
|
+
var selectedRowIds = Object.keys(table.getState().rowSelection);
|
|
802
|
+
var selectedRows = selectedRowIds.map(function (rowId) {
|
|
803
|
+
var matchingRow = table.getSelectedRowModel().rows.find(function (row) {
|
|
804
|
+
return "".concat(row.id) === rowId;
|
|
805
|
+
});
|
|
806
|
+
return matchingRow ? matchingRow.original : null;
|
|
807
|
+
}).filter(function (row) {
|
|
808
|
+
return row !== null;
|
|
809
|
+
});
|
|
810
|
+
selectData(selectedRows);
|
|
811
|
+
}
|
|
812
|
+
}, [rowSelection, table, hasSubRows, selectData, getSelectedRows]);
|
|
820
813
|
(0, _react.useEffect)(function () {
|
|
821
814
|
var rows = table.getRowModel().rows.map(function (r) {
|
|
822
815
|
return r.original;
|
|
823
816
|
});
|
|
824
|
-
|
|
825
|
-
}, [table
|
|
817
|
+
if (onVisibleRowsChange) onVisibleRowsChange(rows);
|
|
818
|
+
}, [table, onVisibleRowsChange]);
|
|
826
819
|
(0, _react.useEffect)(function () {
|
|
827
|
-
|
|
828
|
-
}, []);
|
|
820
|
+
if (enableFixedHeader) (0, _gridFixedHeader["default"])('fixed-header', enableFixedActions);
|
|
821
|
+
}, [enableFixedHeader, enableFixedActions]);
|
|
829
822
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_xDatePickers.LocalizationProvider, {
|
|
830
823
|
dateAdapter: _AdapterDateFns.AdapterDateFns,
|
|
831
824
|
children: [open && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridHelper["default"], {
|