@crystaldesign/grid 26.2.0-beta.2 → 26.2.0-beta.21
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/esm/index.js +460 -312
- package/build/types/grid/src/GirdOptions.d.ts +1 -0
- package/build/types/grid/src/GirdOptions.d.ts.map +1 -1
- package/build/types/grid/src/Grid.d.ts +22 -8
- package/build/types/grid/src/Grid.d.ts.map +1 -1
- package/build/types/grid/src/hooks/useApiInterface/apiFetchData.d.ts.map +1 -1
- package/build/types/grid/src/hooks/useApiInterface/apiFetchSelectValues.d.ts.map +1 -1
- package/build/types/grid/src/hooks/useEditActions.d.ts +1 -0
- package/build/types/grid/src/hooks/useEditActions.d.ts.map +1 -1
- package/build/types/grid/src/hooks/useSelection.d.ts.map +1 -1
- package/build/types/grid/src/index.d.ts +1 -0
- package/build/types/grid/src/index.d.ts.map +1 -1
- package/build/types/grid/src/ui/components/Table.d.ts +6 -2
- package/build/types/grid/src/ui/components/Table.d.ts.map +1 -1
- package/build/types/grid/src/ui/components/Toolbar.d.ts +19 -1
- package/build/types/grid/src/ui/components/Toolbar.d.ts.map +1 -1
- package/package.json +5 -5
package/build/esm/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import 'regenerator-runtime/runtime';
|
|
|
3
3
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
4
4
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
5
5
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
6
|
-
import React, { useState, useEffect,
|
|
6
|
+
import React, { useState, useEffect, createElement, forwardRef, useMemo, useRef, useReducer, useCallback } from 'react';
|
|
7
7
|
import { useTranslation, useDivaCore, DivaUtils, getLogger, DivaError } from '@crystaldesign/diva-core';
|
|
8
8
|
import { useAsyncDebounce, useRowSelect, useTable, useFilters, useGlobalFilter, useGroupBy, useSortBy, useExpanded, usePagination } from 'react-table';
|
|
9
9
|
import makeStyles from '@mui/styles/makeStyles';
|
|
@@ -30,18 +30,19 @@ import DragIndicatorIcon from '@mui/icons-material/DragIndicator';
|
|
|
30
30
|
import { DragDropContext, Droppable, Draggable } from '@hello-pangea/dnd';
|
|
31
31
|
import classnames from 'classnames';
|
|
32
32
|
import MaToolbar from '@mui/material/Toolbar';
|
|
33
|
-
import ButtonGroup from '@mui/material/ButtonGroup';
|
|
34
33
|
import Button from '@mui/material/Button';
|
|
34
|
+
import ButtonGroup from '@mui/material/ButtonGroup';
|
|
35
35
|
import AccordionDetails from '@mui/material/AccordionDetails';
|
|
36
36
|
import Accordion from '@mui/material/Accordion';
|
|
37
37
|
import AccordionSummary from '@mui/material/AccordionSummary';
|
|
38
38
|
import FilterListIcon from '@mui/icons-material/FilterList';
|
|
39
|
-
import Tooltip from '@mui/material/Tooltip';
|
|
40
|
-
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
41
|
-
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
42
39
|
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
40
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
43
41
|
import Menu from '@mui/material/Menu';
|
|
44
42
|
import MenuItem from '@mui/material/MenuItem';
|
|
43
|
+
import Stack from '@mui/material/Stack';
|
|
44
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
45
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
45
46
|
import ImageList from '@mui/material/ImageList';
|
|
46
47
|
import ImageListItem from '@mui/material/ImageListItem';
|
|
47
48
|
import Grid$1 from '@mui/material/Grid2';
|
|
@@ -155,48 +156,32 @@ var withToolbar = "with-toolbar-X2Mxk";
|
|
|
155
156
|
var css_248z$6 = ".dragged-cell-9YMHK {\n display: flex;\n justify-content: space-between;\n}\n\n.dragged-cell-9YMHK td {\n display: block;\n flex-grow: 100;\n}\n\n.dragged-cell-9YMHK td:nth-child(1) {\n padding: 16px 0 !important;\n}\n\n.dragged-cell-9YMHK td:nth-child(1) {\n max-width: 42px;\n width: 29px;\n}\n\n.no-data-q8Gzm {\n display: flex;\n justify-content: center;\n align-items: center;\n height: calc(100% - 59px - 63px);\n flex-direction: column;\n gap: 15px;\n margin: auto;\n box-shadow: inset 0 0 3px 0px rgba(0, 0, 0, 0.1);\n border-radius: 5px;\n position: absolute;\n margin-top: 59px;\n width: 100%;\n}\n\n.with-toolbar-X2Mxk {\n height: calc(100% - 98px - 61px - 63px);\n margin-top: calc(59px + 98px);\n}\n";
|
|
156
157
|
styleInject(css_248z$6);
|
|
157
158
|
|
|
158
|
-
var _excluded$4 = ["
|
|
159
|
-
_excluded2 = ["
|
|
160
|
-
_excluded3 = ["
|
|
161
|
-
_excluded4 = ["
|
|
162
|
-
|
|
163
|
-
function
|
|
164
|
-
function _objectSpread$h(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$h(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$h(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
165
|
-
function MemoizedTable(_ref) {
|
|
166
|
-
var headerGroups = _ref.headerGroups,
|
|
167
|
-
rows = _ref.rows,
|
|
168
|
-
isLoading = _ref.isLoading,
|
|
169
|
-
selectedFlatRows = _ref.selectedFlatRows,
|
|
170
|
-
others = _objectWithoutProperties(_ref, _excluded$4);
|
|
171
|
-
return useMemo(function () {
|
|
172
|
-
return /*#__PURE__*/jsx(Table, _objectSpread$h({
|
|
173
|
-
headerGroups: headerGroups,
|
|
174
|
-
rows: rows,
|
|
175
|
-
isLoading: isLoading
|
|
176
|
-
}, others));
|
|
177
|
-
}, [headerGroups, rows, isLoading, selectedFlatRows]);
|
|
178
|
-
}
|
|
179
|
-
|
|
159
|
+
var _excluded$4 = ["prepareRow", "row", "provided", "renderSubComponent", "toggleSelected", "dragDropRows"],
|
|
160
|
+
_excluded2 = ["key"],
|
|
161
|
+
_excluded3 = ["key"],
|
|
162
|
+
_excluded4 = ["row", "provided"];
|
|
163
|
+
function ownKeys$i(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
164
|
+
function _objectSpread$i(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$i(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$i(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
180
165
|
/**
|
|
181
166
|
* Displays die data in a standart table view.
|
|
182
167
|
*/
|
|
183
|
-
function Table(
|
|
184
|
-
var getTableProps =
|
|
185
|
-
prepareRow =
|
|
186
|
-
getTableBodyProps =
|
|
187
|
-
|
|
188
|
-
headerGroups =
|
|
189
|
-
|
|
190
|
-
rows =
|
|
191
|
-
|
|
192
|
-
isLoading =
|
|
193
|
-
|
|
194
|
-
toggleSelected =
|
|
195
|
-
renderSubComponent =
|
|
196
|
-
dragDropRows =
|
|
197
|
-
onDragEndAction =
|
|
198
|
-
rowHight =
|
|
199
|
-
|
|
168
|
+
function Table(_ref) {
|
|
169
|
+
var getTableProps = _ref.getTableProps,
|
|
170
|
+
prepareRow = _ref.prepareRow,
|
|
171
|
+
getTableBodyProps = _ref.getTableBodyProps,
|
|
172
|
+
_ref$headerGroups = _ref.headerGroups,
|
|
173
|
+
headerGroups = _ref$headerGroups === void 0 ? [] : _ref$headerGroups,
|
|
174
|
+
_ref$rows = _ref.rows,
|
|
175
|
+
rows = _ref$rows === void 0 ? [] : _ref$rows,
|
|
176
|
+
_ref$isLoading = _ref.isLoading,
|
|
177
|
+
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
178
|
+
_ref$toggleSelected = _ref.toggleSelected,
|
|
179
|
+
toggleSelected = _ref$toggleSelected === void 0 ? function () {} : _ref$toggleSelected,
|
|
180
|
+
renderSubComponent = _ref.renderSubComponent,
|
|
181
|
+
dragDropRows = _ref.dragDropRows,
|
|
182
|
+
onDragEndAction = _ref.onDragEndAction,
|
|
183
|
+
rowHight = _ref.rowHight;
|
|
184
|
+
_ref.noData;
|
|
200
185
|
var classes = useStyles$7();
|
|
201
186
|
var onDragEnd = function onDragEnd(result) {
|
|
202
187
|
if (!result.destination) {
|
|
@@ -215,7 +200,7 @@ function Table(_ref2) {
|
|
|
215
200
|
}
|
|
216
201
|
return /*#__PURE__*/jsx(TableContainer, {
|
|
217
202
|
className: classes.table,
|
|
218
|
-
children: /*#__PURE__*/jsxs(MaUTable, _objectSpread$
|
|
203
|
+
children: /*#__PURE__*/jsxs(MaUTable, _objectSpread$i(_objectSpread$i({}, getTableProps()), {}, {
|
|
219
204
|
stickyHeader: true,
|
|
220
205
|
"aria-label": "sticky table",
|
|
221
206
|
children: [/*#__PURE__*/jsx(TableHead, {
|
|
@@ -224,7 +209,7 @@ function Table(_ref2) {
|
|
|
224
209
|
whiteSpace: 'nowrap'
|
|
225
210
|
},
|
|
226
211
|
children: headerGroups.map(function (headerGroup) {
|
|
227
|
-
return /*#__PURE__*/createElement(TableRow, _objectSpread$
|
|
212
|
+
return /*#__PURE__*/createElement(TableRow, _objectSpread$i(_objectSpread$i({}, headerGroup.getHeaderGroupProps()), {}, {
|
|
228
213
|
key: headerGroup.getHeaderGroupProps().key
|
|
229
214
|
}), dragDropRows && /*#__PURE__*/jsx(TableCell, {
|
|
230
215
|
style: {
|
|
@@ -238,7 +223,7 @@ function Table(_ref2) {
|
|
|
238
223
|
var lastFlexible = ((_headers = headers[i + 1]) === null || _headers === void 0 ? void 0 : _headers.fixed) === true;
|
|
239
224
|
var cells = [];
|
|
240
225
|
if (column.fixed) {
|
|
241
|
-
cells.push(/*#__PURE__*/createElement(TableCell, _objectSpread$
|
|
226
|
+
cells.push(/*#__PURE__*/createElement(TableCell, _objectSpread$i(_objectSpread$i({}, column.getHeaderProps({
|
|
242
227
|
style: {
|
|
243
228
|
zIndex: 5,
|
|
244
229
|
backgroundColor: 'white',
|
|
@@ -252,7 +237,7 @@ function Table(_ref2) {
|
|
|
252
237
|
width: 5
|
|
253
238
|
}
|
|
254
239
|
})));
|
|
255
|
-
cells.push(/*#__PURE__*/createElement(TableCell, _objectSpread$
|
|
240
|
+
cells.push(/*#__PURE__*/createElement(TableCell, _objectSpread$i(_objectSpread$i({}, column.getHeaderProps({
|
|
256
241
|
style: {
|
|
257
242
|
zIndex: 4
|
|
258
243
|
}
|
|
@@ -265,7 +250,7 @@ function Table(_ref2) {
|
|
|
265
250
|
}
|
|
266
251
|
})));
|
|
267
252
|
}
|
|
268
|
-
cells.push(/*#__PURE__*/createElement(TableCell, _objectSpread$
|
|
253
|
+
cells.push(/*#__PURE__*/createElement(TableCell, _objectSpread$i(_objectSpread$i({}, column.getHeaderProps({
|
|
269
254
|
style: {
|
|
270
255
|
width: lastFlexible ? undefined : column.width,
|
|
271
256
|
padding: column.padding,
|
|
@@ -279,7 +264,7 @@ function Table(_ref2) {
|
|
|
279
264
|
sortDirection: column.isSorted ? column.isSortedDesc ? 'desc' : 'asc' : false
|
|
280
265
|
}),
|
|
281
266
|
// only wrap in tableSortLabel if it is actually sortable, otherwise other functionalities (e.g. select) don't work
|
|
282
|
-
column.canSort && /*#__PURE__*/jsx(TableSortLabel, _objectSpread$
|
|
267
|
+
column.canSort && /*#__PURE__*/jsx(TableSortLabel, _objectSpread$i(_objectSpread$i({}, column.getSortByToggleProps()), {}, {
|
|
283
268
|
disabled: !column.canSort,
|
|
284
269
|
active: column.isSorted,
|
|
285
270
|
direction: column.isSortedDesc ? 'desc' : 'asc',
|
|
@@ -289,7 +274,7 @@ function Table(_ref2) {
|
|
|
289
274
|
});
|
|
290
275
|
}());
|
|
291
276
|
})
|
|
292
|
-
}), !dragDropRows && /*#__PURE__*/jsxs(TableBody, _objectSpread$
|
|
277
|
+
}), !dragDropRows && /*#__PURE__*/jsxs(TableBody, _objectSpread$i(_objectSpread$i({}, getTableBodyProps()), {}, {
|
|
293
278
|
children: [!isLoading && rows.map(function (row, index) {
|
|
294
279
|
return /*#__PURE__*/jsx(MemoizedRow, {
|
|
295
280
|
row: row,
|
|
@@ -308,7 +293,7 @@ function Table(_ref2) {
|
|
|
308
293
|
direction: "vertical",
|
|
309
294
|
type: "group",
|
|
310
295
|
children: function children(provided, snapshot) {
|
|
311
|
-
return /*#__PURE__*/jsxs(TableBody, _objectSpread$
|
|
296
|
+
return /*#__PURE__*/jsxs(TableBody, _objectSpread$i(_objectSpread$i(_objectSpread$i({}, provided.droppableProps), {}, {
|
|
312
297
|
ref: provided.innerRef
|
|
313
298
|
}, getTableBodyProps()), {}, {
|
|
314
299
|
children: [!isLoading && rows.map(function (row, index) {
|
|
@@ -323,10 +308,10 @@ function Table(_ref2) {
|
|
|
323
308
|
transform = transform.replace(/\(.+\,/, '(0,');
|
|
324
309
|
others.className = draggedCell;
|
|
325
310
|
}
|
|
326
|
-
others.style = _objectSpread$
|
|
311
|
+
others.style = _objectSpread$i(_objectSpread$i({}, provided.draggableProps.style), {}, {
|
|
327
312
|
transform: transform
|
|
328
313
|
});
|
|
329
|
-
return /*#__PURE__*/createElement(MemoizedRow, _objectSpread$
|
|
314
|
+
return /*#__PURE__*/createElement(MemoizedRow, _objectSpread$i(_objectSpread$i({
|
|
330
315
|
provided: provided,
|
|
331
316
|
ref: provided.innerRef
|
|
332
317
|
}, provided.draggableProps), {}, {
|
|
@@ -349,30 +334,28 @@ function Table(_ref2) {
|
|
|
349
334
|
}))
|
|
350
335
|
});
|
|
351
336
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
dragDropRows = _ref4.dragDropRows,
|
|
371
|
-
others = _objectWithoutProperties(_ref4, _excluded3);
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Custom equality check for React.memo.
|
|
340
|
+
* Only re-renders Table when data, loading state, or selection changes.
|
|
341
|
+
*/
|
|
342
|
+
function areTablePropsEqual(prev, next) {
|
|
343
|
+
return prev.headerGroups === next.headerGroups && prev.rows === next.rows && prev.isLoading === next.isLoading && prev.selectedFlatRows === next.selectedFlatRows;
|
|
344
|
+
}
|
|
345
|
+
var Table$1 = /*#__PURE__*/React.memo(Table, areTablePropsEqual);
|
|
346
|
+
var MyRow = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
347
|
+
var _allCells$;
|
|
348
|
+
var prepareRow = _ref2.prepareRow,
|
|
349
|
+
row = _ref2.row,
|
|
350
|
+
provided = _ref2.provided,
|
|
351
|
+
renderSubComponent = _ref2.renderSubComponent,
|
|
352
|
+
toggleSelected = _ref2.toggleSelected,
|
|
353
|
+
dragDropRows = _ref2.dragDropRows,
|
|
354
|
+
others = _objectWithoutProperties(_ref2, _excluded$4);
|
|
372
355
|
prepareRow(row);
|
|
373
356
|
var _row$getRowProps = row.getRowProps(),
|
|
374
357
|
key = _row$getRowProps.key,
|
|
375
|
-
rowProps = _objectWithoutProperties(_row$getRowProps,
|
|
358
|
+
rowProps = _objectWithoutProperties(_row$getRowProps, _excluded2);
|
|
376
359
|
var handleRowClick = function handleRowClick(e) {
|
|
377
360
|
var _cell$parentElement;
|
|
378
361
|
// Only toggle selection when clicking on the first column (selection column)
|
|
@@ -382,8 +365,79 @@ var MyRow = /*#__PURE__*/forwardRef(function (_ref4, ref) {
|
|
|
382
365
|
if (!isFirstColumn) return;
|
|
383
366
|
toggleSelected(row.id);
|
|
384
367
|
};
|
|
368
|
+
var allCells = row.cells.flat();
|
|
369
|
+
// The first cell may be the selection checkbox (beginActions column).
|
|
370
|
+
// It must re-render on every selection change to reflect the current checked state,
|
|
371
|
+
// so it is rendered outside the data cell memo below.
|
|
372
|
+
var hasSelectionCell = ((_allCells$ = allCells[0]) === null || _allCells$ === void 0 ? void 0 : _allCells$.column.id) === 'beginActions';
|
|
373
|
+
var dataStartIndex = hasSelectionCell ? 1 : 0;
|
|
374
|
+
|
|
375
|
+
// Memoize the expensive data cell rendering based on row data.
|
|
376
|
+
// When only selection changes, row.original stays the same so data cells
|
|
377
|
+
// are returned from cache. This avoids re-rendering all 10+ cells per row
|
|
378
|
+
// on "select all".
|
|
379
|
+
var dataCellElements = useMemo(function () {
|
|
380
|
+
return allCells.slice(dataStartIndex).map(function (cell, i) {
|
|
381
|
+
var _allCells;
|
|
382
|
+
var actualIndex = dataStartIndex + i;
|
|
383
|
+
var lastFlexible = ((_allCells = allCells[actualIndex + 1]) === null || _allCells === void 0 ? void 0 : _allCells.column.fixed) === true;
|
|
384
|
+
var cells = [];
|
|
385
|
+
if (cell.column.fixed) {
|
|
386
|
+
var _cell$getCellProps = cell.getCellProps(),
|
|
387
|
+
_key = _cell$getCellProps.key,
|
|
388
|
+
cellProps = _objectWithoutProperties(_cell$getCellProps, _excluded3);
|
|
389
|
+
cells.push(/*#__PURE__*/createElement(TableCell, _objectSpread$i(_objectSpread$i({}, cellProps), {}, {
|
|
390
|
+
className: "fixed-spacer1",
|
|
391
|
+
key: _key + '_a',
|
|
392
|
+
"data-test-id": "table-cell"
|
|
393
|
+
})));
|
|
394
|
+
cells.push(/*#__PURE__*/createElement(TableCell, _objectSpread$i(_objectSpread$i({}, cellProps), {}, {
|
|
395
|
+
className: "fixed-spacer2",
|
|
396
|
+
key: _key + '_b',
|
|
397
|
+
"data-test-id": "table-cell"
|
|
398
|
+
}), /*#__PURE__*/jsx("div", _objectSpread$i({}, cellProps))));
|
|
399
|
+
}
|
|
400
|
+
cells.push(/*#__PURE__*/createElement(TableCell, _objectSpread$i(_objectSpread$i({
|
|
401
|
+
className: cell.column.fixed ? 'fixed' : ''
|
|
402
|
+
}, cell.getCellProps({
|
|
403
|
+
style: _objectSpread$i(_objectSpread$i({}, cellStyleHelper(cell)), {}, {
|
|
404
|
+
width: lastFlexible ? undefined : cell.column.width
|
|
405
|
+
})
|
|
406
|
+
})), {}, {
|
|
407
|
+
key: cell.getCellProps().key,
|
|
408
|
+
"data-test-id": "table-cell"
|
|
409
|
+
}), cell.isGrouped ?
|
|
410
|
+
/*#__PURE__*/
|
|
411
|
+
// If it's a grouped cell, add an expander and row count
|
|
412
|
+
jsxs("div", {
|
|
413
|
+
style: {
|
|
414
|
+
display: 'flex'
|
|
415
|
+
},
|
|
416
|
+
children: [/*#__PURE__*/jsx(IconButton, _objectSpread$i(_objectSpread$i({
|
|
417
|
+
"aria-label": "expand row",
|
|
418
|
+
size: "small"
|
|
419
|
+
}, row.getToggleRowExpandedProps()), {}, {
|
|
420
|
+
onClick: undefined,
|
|
421
|
+
children: row.isExpanded ? /*#__PURE__*/jsx(KeyboardArrowUpIcon, {}) : /*#__PURE__*/jsx(KeyboardArrowDownIcon, {})
|
|
422
|
+
})), /*#__PURE__*/jsxs("div", {
|
|
423
|
+
style: {
|
|
424
|
+
marginRight: '5px'
|
|
425
|
+
},
|
|
426
|
+
children: ["(", row.subRows.length, ")"]
|
|
427
|
+
}), cell.render('Cell')]
|
|
428
|
+
}) : cell.isAggregated ?
|
|
429
|
+
// If the cell is aggregated, use the Aggregated
|
|
430
|
+
// renderer for cell
|
|
431
|
+
cell.render('Aggregated') : cell.isPlaceholder ? /*#__PURE__*/jsx(Fragment, {}) // For cells with repeated values, render null
|
|
432
|
+
:
|
|
433
|
+
// Otherwise, just render the regular cell
|
|
434
|
+
cell.column.valueMapping ? getCellDisplayValue(cell, cell.column.valueMapping) // If value mapping is defined, use it
|
|
435
|
+
: cell.render('Cell')));
|
|
436
|
+
return cells;
|
|
437
|
+
});
|
|
438
|
+
}, [row.original]);
|
|
385
439
|
return /*#__PURE__*/jsxs(React.Fragment, {
|
|
386
|
-
children: [/*#__PURE__*/createElement(TableRow, _objectSpread$
|
|
440
|
+
children: [/*#__PURE__*/createElement(TableRow, _objectSpread$i(_objectSpread$i({}, rowProps), {}, {
|
|
387
441
|
key: key,
|
|
388
442
|
className: classnames({
|
|
389
443
|
childRow: row.depth,
|
|
@@ -393,74 +447,34 @@ var MyRow = /*#__PURE__*/forwardRef(function (_ref4, ref) {
|
|
|
393
447
|
onClick: handleRowClick,
|
|
394
448
|
ref: ref,
|
|
395
449
|
"data-test-id": "table-row"
|
|
396
|
-
}, others), dragDropRows && /*#__PURE__*/createElement(TableCell, _objectSpread$
|
|
450
|
+
}, others), dragDropRows && /*#__PURE__*/createElement(TableCell, _objectSpread$i(_objectSpread$i(_objectSpread$i({}, provided === null || provided === void 0 ? void 0 : provided.dragHandleProps), row.cells[0].getCellProps()), {}, {
|
|
397
451
|
className: "drag-handle",
|
|
398
452
|
key: row.cells[0].getCellProps().key,
|
|
399
453
|
"data-test-id": "table-cell"
|
|
400
|
-
}), /*#__PURE__*/jsx(DragIndicatorIcon, {})),
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
_key = _cell$getCellProps.key,
|
|
409
|
-
cellProps = _objectWithoutProperties(_cell$getCellProps, _excluded5);
|
|
410
|
-
cells.push(/*#__PURE__*/createElement(TableCell, _objectSpread$h(_objectSpread$h({}, cellProps), {}, {
|
|
411
|
-
className: "fixed-spacer1",
|
|
412
|
-
key: _key + '_a',
|
|
413
|
-
"data-test-id": "table-cell"
|
|
414
|
-
})));
|
|
415
|
-
cells.push(/*#__PURE__*/createElement(TableCell, _objectSpread$h(_objectSpread$h({}, cellProps), {}, {
|
|
416
|
-
className: "fixed-spacer2",
|
|
417
|
-
key: _key + '_b',
|
|
418
|
-
"data-test-id": "table-cell"
|
|
419
|
-
}), /*#__PURE__*/jsx("div", _objectSpread$h({}, cellProps))));
|
|
420
|
-
}
|
|
421
|
-
cells.push(/*#__PURE__*/createElement(TableCell, _objectSpread$h(_objectSpread$h({
|
|
422
|
-
className: cell.column.fixed ? 'fixed' : ''
|
|
423
|
-
}, cell.getCellProps({
|
|
424
|
-
style: _objectSpread$h(_objectSpread$h({}, cellStyleHelper(cell)), {}, {
|
|
425
|
-
width: lastFlexible ? undefined : cell.column.width
|
|
426
|
-
})
|
|
427
|
-
})), {}, {
|
|
428
|
-
key: cell.getCellProps().key,
|
|
429
|
-
"data-test-id": "table-cell"
|
|
430
|
-
}), cell.isGrouped ?
|
|
431
|
-
/*#__PURE__*/
|
|
432
|
-
// If it's a grouped cell, add an expander and row count
|
|
433
|
-
jsxs("div", {
|
|
434
|
-
style: {
|
|
435
|
-
display: 'flex'
|
|
436
|
-
},
|
|
437
|
-
children: [/*#__PURE__*/jsx(IconButton, _objectSpread$h(_objectSpread$h({
|
|
438
|
-
"aria-label": "expand row",
|
|
439
|
-
size: "small"
|
|
440
|
-
}, row.getToggleRowExpandedProps()), {}, {
|
|
441
|
-
onClick: undefined,
|
|
442
|
-
children: row.isExpanded ? /*#__PURE__*/jsx(KeyboardArrowUpIcon, {}) : /*#__PURE__*/jsx(KeyboardArrowDownIcon, {})
|
|
443
|
-
})), /*#__PURE__*/jsxs("div", {
|
|
444
|
-
style: {
|
|
445
|
-
marginRight: '5px'
|
|
446
|
-
},
|
|
447
|
-
children: ["(", row.subRows.length, ")"]
|
|
448
|
-
}), cell.render('Cell')]
|
|
449
|
-
}) : cell.isAggregated ?
|
|
450
|
-
// If the cell is aggregated, use the Aggregated
|
|
451
|
-
// renderer for cell
|
|
452
|
-
cell.render('Aggregated') : cell.isPlaceholder ? /*#__PURE__*/jsx(Fragment, {}) // For cells with repeated values, render null
|
|
453
|
-
:
|
|
454
|
-
// Otherwise, just render the regular cell
|
|
455
|
-
cell.column.valueMapping ? getCellDisplayValue(cell, cell.column.valueMapping) // If value mapping is defined, use it
|
|
456
|
-
: cell.render('Cell')));
|
|
457
|
-
return cells;
|
|
458
|
-
});
|
|
459
|
-
}()), row.isExpanded && renderSubComponent && !row.isGrouped && /*#__PURE__*/jsx(Fragment, {
|
|
454
|
+
}), /*#__PURE__*/jsx(DragIndicatorIcon, {})), hasSelectionCell && /*#__PURE__*/createElement(TableCell, _objectSpread$i(_objectSpread$i({}, allCells[0].getCellProps({
|
|
455
|
+
style: _objectSpread$i(_objectSpread$i({}, cellStyleHelper(allCells[0])), {}, {
|
|
456
|
+
width: allCells[0].column.width
|
|
457
|
+
})
|
|
458
|
+
})), {}, {
|
|
459
|
+
key: allCells[0].getCellProps().key,
|
|
460
|
+
"data-test-id": "table-cell"
|
|
461
|
+
}), allCells[0].render('Cell')), dataCellElements), row.isExpanded && renderSubComponent && !row.isGrouped && /*#__PURE__*/jsx(Fragment, {
|
|
460
462
|
children: renderSubComponent(row)
|
|
461
463
|
})]
|
|
462
464
|
}, key + '_fragment');
|
|
463
465
|
});
|
|
466
|
+
var MemoizedRow = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
467
|
+
var row = _ref3.row,
|
|
468
|
+
provided = _ref3.provided,
|
|
469
|
+
others = _objectWithoutProperties(_ref3, _excluded4);
|
|
470
|
+
return useMemo(function () {
|
|
471
|
+
return /*#__PURE__*/jsx(MyRow, _objectSpread$i({
|
|
472
|
+
row: row,
|
|
473
|
+
ref: ref,
|
|
474
|
+
provided: provided
|
|
475
|
+
}, others));
|
|
476
|
+
}, [row.isExpanded, row.isSelected, row.original]);
|
|
477
|
+
});
|
|
464
478
|
function getCellDisplayValue(cell, valueMapping) {
|
|
465
479
|
var value = cell.value;
|
|
466
480
|
var mapping = valueMapping.find(function (m) {
|
|
@@ -589,11 +603,11 @@ var cellStyleHelper = function cellStyleHelper(cell) {
|
|
|
589
603
|
zIndex: 3
|
|
590
604
|
};
|
|
591
605
|
};
|
|
592
|
-
function Loading(
|
|
593
|
-
var
|
|
594
|
-
var headerGroups =
|
|
595
|
-
parentRow =
|
|
596
|
-
rowHight =
|
|
606
|
+
function Loading(_ref4) {
|
|
607
|
+
var _ref5;
|
|
608
|
+
var headerGroups = _ref4.headerGroups,
|
|
609
|
+
parentRow = _ref4.parentRow,
|
|
610
|
+
rowHight = _ref4.rowHight;
|
|
597
611
|
var headers = headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups[headerGroups.length - 1].headers.flat();
|
|
598
612
|
var cellDefinitions = parentRow === null || parentRow === void 0 ? void 0 : parentRow.cells.flat();
|
|
599
613
|
var depth = parentRow ? parentRow.depth : 0;
|
|
@@ -601,7 +615,7 @@ function Loading(_ref5) {
|
|
|
601
615
|
className: classnames({
|
|
602
616
|
childRow: !!depth
|
|
603
617
|
}),
|
|
604
|
-
children: ((
|
|
618
|
+
children: ((_ref5 = headers !== null && headers !== void 0 ? headers : cellDefinitions) !== null && _ref5 !== void 0 ? _ref5 : []).map(function (h, i) {
|
|
605
619
|
var _headers$fixed, _headers2, _cellDefinitions, _cellDefinitions$i, _cellDefinitions$i2, _cellDefinitions$i3, _cellDefinitions$i4;
|
|
606
620
|
var lastFlexible = ((_headers$fixed = headers === null || headers === void 0 || (_headers2 = headers[i + 1]) === null || _headers2 === void 0 ? void 0 : _headers2.fixed) !== null && _headers$fixed !== void 0 ? _headers$fixed : cellDefinitions === null || cellDefinitions === void 0 || (_cellDefinitions = cellDefinitions[i + 1]) === null || _cellDefinitions === void 0 ? void 0 : _cellDefinitions.column.fixed) === true;
|
|
607
621
|
var isFixed = 'fixed' in h ? h.fixed : cellDefinitions === null || cellDefinitions === void 0 || (_cellDefinitions$i = cellDefinitions[i]) === null || _cellDefinitions$i === void 0 ? void 0 : _cellDefinitions$i.column.fixed;
|
|
@@ -676,8 +690,8 @@ function GlobalFilter(_ref) {
|
|
|
676
690
|
});
|
|
677
691
|
}
|
|
678
692
|
|
|
679
|
-
function ownKeys$
|
|
680
|
-
function _objectSpread$
|
|
693
|
+
function ownKeys$h(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
694
|
+
function _objectSpread$h(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$h(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$h(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
681
695
|
/**
|
|
682
696
|
* The toolbar component for the grid, it holds filters and general action buttons.
|
|
683
697
|
* If there are filters specified it is expandable, otherwise it its a simple toolbar.
|
|
@@ -693,7 +707,13 @@ function Toolbar(_ref) {
|
|
|
693
707
|
_ref$onViewSwitch = _ref.onViewSwitch,
|
|
694
708
|
onViewSwitch = _ref$onViewSwitch === void 0 ? function () {} : _ref$onViewSwitch,
|
|
695
709
|
selectedView = _ref.selectedView,
|
|
696
|
-
customElement = _ref.customElement
|
|
710
|
+
customElement = _ref.customElement,
|
|
711
|
+
_ref$actionsVisibleCo = _ref.actionsVisibleCount,
|
|
712
|
+
actionsVisibleCount = _ref$actionsVisibleCo === void 0 ? 3 : _ref$actionsVisibleCo,
|
|
713
|
+
_ref$actionsPosition = _ref.actionsPosition,
|
|
714
|
+
actionsPosition = _ref$actionsPosition === void 0 ? 'right' : _ref$actionsPosition,
|
|
715
|
+
_ref$hasSelection = _ref.hasSelection,
|
|
716
|
+
hasSelection = _ref$hasSelection === void 0 ? false : _ref$hasSelection;
|
|
697
717
|
var _React$useState = React.useState(false),
|
|
698
718
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
699
719
|
expanded = _React$useState2[0],
|
|
@@ -703,6 +723,23 @@ function Toolbar(_ref) {
|
|
|
703
723
|
_useState2 = _slicedToArray(_useState, 2),
|
|
704
724
|
showCustomElement = _useState2[0],
|
|
705
725
|
setShowCustomElement = _useState2[1];
|
|
726
|
+
var _useState3 = useState(null),
|
|
727
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
728
|
+
menuAnchorEl = _useState4[0],
|
|
729
|
+
setMenuAnchorEl = _useState4[1];
|
|
730
|
+
var menuOpen = Boolean(menuAnchorEl);
|
|
731
|
+
var handleMenuOpen = function handleMenuOpen(event) {
|
|
732
|
+
setMenuAnchorEl(event.currentTarget);
|
|
733
|
+
};
|
|
734
|
+
var handleMenuClose = function handleMenuClose() {
|
|
735
|
+
setMenuAnchorEl(null);
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
// Split actions into visible and overflow
|
|
739
|
+
// If there are more actions than the visible count, reserve the last position for the menu button
|
|
740
|
+
var hasOverflow = actions.length > actionsVisibleCount;
|
|
741
|
+
var visibleActions = hasOverflow ? actions.slice(0, actionsVisibleCount - 1) : actions.slice(0, actionsVisibleCount);
|
|
742
|
+
var overflowActions = hasOverflow ? actions.slice(actionsVisibleCount - 1) : [];
|
|
706
743
|
useEffect(function () {
|
|
707
744
|
if (ref.current) {
|
|
708
745
|
var resizeObserver = new ResizeObserver(function (entries) {
|
|
@@ -719,6 +756,72 @@ function Toolbar(_ref) {
|
|
|
719
756
|
//toolbar would be completely empty, so it doesn't have to show at all.
|
|
720
757
|
return /*#__PURE__*/jsx(Fragment, {});
|
|
721
758
|
}
|
|
759
|
+
var renderActionButtons = function renderActionButtons() {
|
|
760
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
761
|
+
children: /*#__PURE__*/jsxs(Stack, {
|
|
762
|
+
direction: "row",
|
|
763
|
+
spacing: 1,
|
|
764
|
+
sx: {
|
|
765
|
+
marginRight: actionsPosition === 'right' ? 2 : 0,
|
|
766
|
+
marginLeft: actionsPosition === 'left' ? 0 : 0
|
|
767
|
+
},
|
|
768
|
+
children: [visibleActions.map(function (action, i) {
|
|
769
|
+
var _action$tooltip;
|
|
770
|
+
return /*#__PURE__*/jsx(Tooltip, {
|
|
771
|
+
title: (_action$tooltip = action.tooltip) !== null && _action$tooltip !== void 0 ? _action$tooltip : '',
|
|
772
|
+
disableHoverListener: !action.tooltip,
|
|
773
|
+
children: /*#__PURE__*/jsx("span", {
|
|
774
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
775
|
+
onClick: action.onClick,
|
|
776
|
+
variant: action.selected ? 'contained' : 'outlined',
|
|
777
|
+
disabled: action.disabled,
|
|
778
|
+
color: "primary",
|
|
779
|
+
children: action.label
|
|
780
|
+
})
|
|
781
|
+
})
|
|
782
|
+
}, i);
|
|
783
|
+
}), overflowActions.length > 0 && /*#__PURE__*/jsxs(Fragment, {
|
|
784
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
785
|
+
variant: "outlined",
|
|
786
|
+
onClick: handleMenuOpen,
|
|
787
|
+
children: /*#__PURE__*/jsx(MoreVertIcon, {})
|
|
788
|
+
}), /*#__PURE__*/jsx(Menu, {
|
|
789
|
+
id: "actions-menu",
|
|
790
|
+
anchorEl: menuAnchorEl,
|
|
791
|
+
open: menuOpen,
|
|
792
|
+
onClose: handleMenuClose,
|
|
793
|
+
anchorOrigin: {
|
|
794
|
+
vertical: 'bottom',
|
|
795
|
+
horizontal: 'right'
|
|
796
|
+
},
|
|
797
|
+
transformOrigin: {
|
|
798
|
+
vertical: 'top',
|
|
799
|
+
horizontal: 'right'
|
|
800
|
+
},
|
|
801
|
+
children: overflowActions.map(function (action, i) {
|
|
802
|
+
var _action$tooltip2;
|
|
803
|
+
return /*#__PURE__*/jsx(Tooltip, {
|
|
804
|
+
title: (_action$tooltip2 = action.tooltip) !== null && _action$tooltip2 !== void 0 ? _action$tooltip2 : '',
|
|
805
|
+
disableHoverListener: !action.tooltip,
|
|
806
|
+
placement: "left",
|
|
807
|
+
children: /*#__PURE__*/jsx("span", {
|
|
808
|
+
children: /*#__PURE__*/jsx(MenuItem, {
|
|
809
|
+
onClick: function onClick(e) {
|
|
810
|
+
action.onClick(e);
|
|
811
|
+
handleMenuClose();
|
|
812
|
+
},
|
|
813
|
+
disabled: action.disabled,
|
|
814
|
+
selected: action.selected,
|
|
815
|
+
children: action.label
|
|
816
|
+
})
|
|
817
|
+
})
|
|
818
|
+
}, i);
|
|
819
|
+
})
|
|
820
|
+
})]
|
|
821
|
+
})]
|
|
822
|
+
})
|
|
823
|
+
});
|
|
824
|
+
};
|
|
722
825
|
return /*#__PURE__*/jsxs(Accordion, {
|
|
723
826
|
expanded: expanded,
|
|
724
827
|
className: "grid-toolbar",
|
|
@@ -754,32 +857,11 @@ function Toolbar(_ref) {
|
|
|
754
857
|
minWidth: '100%',
|
|
755
858
|
minHeight: '45px'
|
|
756
859
|
},
|
|
757
|
-
children: [showCustomElement && customElement, /*#__PURE__*/jsx("div", {
|
|
860
|
+
children: [actionsPosition === 'left' && actions.length > 0 && hasSelection && renderActionButtons(), showCustomElement && customElement, /*#__PURE__*/jsx("div", {
|
|
758
861
|
style: {
|
|
759
862
|
flexGrow: 1
|
|
760
863
|
}
|
|
761
|
-
}), /*#__PURE__*/jsx(ButtonGroup, {
|
|
762
|
-
style: {
|
|
763
|
-
marginRight: 10
|
|
764
|
-
},
|
|
765
|
-
color: "primary",
|
|
766
|
-
"aria-label": "actions",
|
|
767
|
-
children: actions.map(function (action, i) {
|
|
768
|
-
var _action$tooltip;
|
|
769
|
-
return /*#__PURE__*/jsx(Tooltip, {
|
|
770
|
-
title: (_action$tooltip = action.tooltip) !== null && _action$tooltip !== void 0 ? _action$tooltip : '',
|
|
771
|
-
disableHoverListener: !action.tooltip,
|
|
772
|
-
children: /*#__PURE__*/jsx("span", {
|
|
773
|
-
children: /*#__PURE__*/jsx(Button, {
|
|
774
|
-
onClick: action.onClick,
|
|
775
|
-
variant: action.selected ? 'contained' : 'outlined',
|
|
776
|
-
disabled: action.disabled,
|
|
777
|
-
children: action.label
|
|
778
|
-
})
|
|
779
|
-
})
|
|
780
|
-
}, i);
|
|
781
|
-
})
|
|
782
|
-
}), /*#__PURE__*/jsx(ButtonGroup, {
|
|
864
|
+
}), actionsPosition === 'right' && actions.length > 0 && hasSelection && renderActionButtons(), /*#__PURE__*/jsx(ButtonGroup, {
|
|
783
865
|
style: {
|
|
784
866
|
marginRight: 10
|
|
785
867
|
},
|
|
@@ -796,7 +878,7 @@ function Toolbar(_ref) {
|
|
|
796
878
|
children: view.icon
|
|
797
879
|
}, view.label);
|
|
798
880
|
})
|
|
799
|
-
}), globalFilter && /*#__PURE__*/jsx(GlobalFilter, _objectSpread$
|
|
881
|
+
}), globalFilter && /*#__PURE__*/jsx(GlobalFilter, _objectSpread$h({}, globalFilter))]
|
|
800
882
|
})
|
|
801
883
|
}), /*#__PURE__*/jsx(AccordionDetails, {
|
|
802
884
|
style: {
|
|
@@ -953,8 +1035,8 @@ function ActionCell(_ref) {
|
|
|
953
1035
|
}
|
|
954
1036
|
|
|
955
1037
|
var _excluded$3 = ["isLoading", "noData"];
|
|
956
|
-
function ownKeys$
|
|
957
|
-
function _objectSpread$
|
|
1038
|
+
function ownKeys$g(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1039
|
+
function _objectSpread$g(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$g(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$g(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
958
1040
|
function Gallery(_ref) {
|
|
959
1041
|
var isLoading = _ref.isLoading;
|
|
960
1042
|
_ref.noData;
|
|
@@ -971,9 +1053,9 @@ function Gallery(_ref) {
|
|
|
971
1053
|
if (props.rows.length > 0) {
|
|
972
1054
|
GalleryNode = props.rows.some(function (r) {
|
|
973
1055
|
return r.isExpanded;
|
|
974
|
-
}) ? /*#__PURE__*/jsx(GroupedGallery, _objectSpread$
|
|
1056
|
+
}) ? /*#__PURE__*/jsx(GroupedGallery, _objectSpread$g(_objectSpread$g({}, props), {}, {
|
|
975
1057
|
className: classes.gallery
|
|
976
|
-
})) : /*#__PURE__*/jsx(SimpleGallery, _objectSpread$
|
|
1058
|
+
})) : /*#__PURE__*/jsx(SimpleGallery, _objectSpread$g(_objectSpread$g({}, props), {}, {
|
|
977
1059
|
className: classes.gallery
|
|
978
1060
|
}));
|
|
979
1061
|
} else {
|
|
@@ -1290,8 +1372,8 @@ function parseDate(value) {
|
|
|
1290
1372
|
}
|
|
1291
1373
|
}
|
|
1292
1374
|
|
|
1293
|
-
function ownKeys$
|
|
1294
|
-
function _objectSpread$
|
|
1375
|
+
function ownKeys$f(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1376
|
+
function _objectSpread$f(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$f(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$f(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1295
1377
|
var localeMap = {
|
|
1296
1378
|
en: enLocale,
|
|
1297
1379
|
fr: frLocale,
|
|
@@ -1314,7 +1396,7 @@ function DateRangeFilter(_ref) {
|
|
|
1314
1396
|
if (date == undefined && (filterValue === null || filterValue === void 0 ? void 0 : filterValue.to) == undefined) {
|
|
1315
1397
|
setFilter(undefined);
|
|
1316
1398
|
} else {
|
|
1317
|
-
setFilter(_objectSpread$
|
|
1399
|
+
setFilter(_objectSpread$f(_objectSpread$f({}, filterValue), {}, {
|
|
1318
1400
|
type: 'date',
|
|
1319
1401
|
from: date || undefined
|
|
1320
1402
|
}));
|
|
@@ -1328,7 +1410,7 @@ function DateRangeFilter(_ref) {
|
|
|
1328
1410
|
if (date == undefined && (filterValue === null || filterValue === void 0 ? void 0 : filterValue.from) == undefined) {
|
|
1329
1411
|
setFilter(undefined);
|
|
1330
1412
|
} else {
|
|
1331
|
-
setFilter(_objectSpread$
|
|
1413
|
+
setFilter(_objectSpread$f(_objectSpread$f({}, filterValue), {}, {
|
|
1332
1414
|
type: 'date',
|
|
1333
1415
|
to: date || undefined
|
|
1334
1416
|
}));
|
|
@@ -1392,7 +1474,7 @@ function apiFetchSelectValues(_x, _x2, _x3, _x4) {
|
|
|
1392
1474
|
*/
|
|
1393
1475
|
function _apiFetchSelectValues() {
|
|
1394
1476
|
_apiFetchSelectValues = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(endpoint, organizationId, authToken, catalogServiceUrl) {
|
|
1395
|
-
var headers, response, data, valuesArray;
|
|
1477
|
+
var headers, response, data, valuesArray, dedublicationMap, _iterator2, _step2, _item$key, item;
|
|
1396
1478
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1397
1479
|
while (1) switch (_context.prev = _context.next) {
|
|
1398
1480
|
case 0:
|
|
@@ -1422,22 +1504,34 @@ function _apiFetchSelectValues() {
|
|
|
1422
1504
|
data = _context.sent;
|
|
1423
1505
|
// Extract the values array from the response using valuePath
|
|
1424
1506
|
valuesArray = getNestedValue$1(data, endpoint.valuePath);
|
|
1425
|
-
if (!Array.isArray(valuesArray)) {
|
|
1507
|
+
if (!(!Array.isArray(valuesArray) || valuesArray.length === 0)) {
|
|
1426
1508
|
_context.next = 15;
|
|
1427
1509
|
break;
|
|
1428
1510
|
}
|
|
1429
|
-
return _context.abrupt("return", valuesArray);
|
|
1430
|
-
case 15:
|
|
1431
1511
|
return _context.abrupt("return", []);
|
|
1432
|
-
case
|
|
1433
|
-
|
|
1512
|
+
case 15:
|
|
1513
|
+
dedublicationMap = new Map();
|
|
1514
|
+
_iterator2 = _createForOfIteratorHelper$1(valuesArray);
|
|
1515
|
+
try {
|
|
1516
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1517
|
+
item = _step2.value;
|
|
1518
|
+
dedublicationMap.set((_item$key = item.key) !== null && _item$key !== void 0 ? _item$key : '', item);
|
|
1519
|
+
}
|
|
1520
|
+
} catch (err) {
|
|
1521
|
+
_iterator2.e(err);
|
|
1522
|
+
} finally {
|
|
1523
|
+
_iterator2.f();
|
|
1524
|
+
}
|
|
1525
|
+
return _context.abrupt("return", Array.from(dedublicationMap.values()));
|
|
1526
|
+
case 21:
|
|
1527
|
+
_context.prev = 21;
|
|
1434
1528
|
_context.t0 = _context["catch"](0);
|
|
1435
1529
|
throw _context.t0;
|
|
1436
|
-
case
|
|
1530
|
+
case 24:
|
|
1437
1531
|
case "end":
|
|
1438
1532
|
return _context.stop();
|
|
1439
1533
|
}
|
|
1440
|
-
}, _callee, null, [[0,
|
|
1534
|
+
}, _callee, null, [[0, 21]]);
|
|
1441
1535
|
}));
|
|
1442
1536
|
return _apiFetchSelectValues.apply(this, arguments);
|
|
1443
1537
|
}
|
|
@@ -1705,8 +1799,8 @@ var numbers = "numbers-mJ9nr";
|
|
|
1705
1799
|
var css_248z$4 = ".editalbe-jZFBd {\n width: 100%;\n min-height: 20px;\n cursor: text;\n}\n.editalbe-jZFBd:hover {\n border-bottom: 1px solid rgba(0, 0, 0, 0.42);\n font-size: 16px;\n font-weight: 400;\n}\n\n.numbers-mJ9nr {\n text-align: right;\n}\n.numbers-mJ9nr input {\n text-align: right;\n}\n";
|
|
1706
1800
|
styleInject(css_248z$4);
|
|
1707
1801
|
|
|
1708
|
-
function ownKeys$
|
|
1709
|
-
function _objectSpread$
|
|
1802
|
+
function ownKeys$e(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1803
|
+
function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$e(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$e(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1710
1804
|
function DefaultCell (_ref) {
|
|
1711
1805
|
var stateValue = _ref.value,
|
|
1712
1806
|
column = _ref.column,
|
|
@@ -1753,7 +1847,7 @@ function DefaultCell (_ref) {
|
|
|
1753
1847
|
break;
|
|
1754
1848
|
case 10:
|
|
1755
1849
|
_context.next = 12;
|
|
1756
|
-
return updateData === null || updateData === void 0 ? void 0 : updateData(unflatten(_objectSpread$
|
|
1850
|
+
return updateData === null || updateData === void 0 ? void 0 : updateData(unflatten(_objectSpread$e(_objectSpread$e({}, row.original), {}, _defineProperty({}, column.id, column.type == 'number' ? Number(value) : value))), row.id);
|
|
1757
1851
|
case 12:
|
|
1758
1852
|
setEditing(false);
|
|
1759
1853
|
case 13:
|
|
@@ -1803,7 +1897,7 @@ function DefaultCell (_ref) {
|
|
|
1803
1897
|
case 2:
|
|
1804
1898
|
setValue(newValue);
|
|
1805
1899
|
_context2.next = 5;
|
|
1806
|
-
return updateData === null || updateData === void 0 ? void 0 : updateData(unflatten(_objectSpread$
|
|
1900
|
+
return updateData === null || updateData === void 0 ? void 0 : updateData(unflatten(_objectSpread$e(_objectSpread$e({}, row.original), {}, _defineProperty({}, column.id, column.type == 'number' ? Number(newValue) : newValue))), row.id);
|
|
1807
1901
|
case 5:
|
|
1808
1902
|
case "end":
|
|
1809
1903
|
return _context2.stop();
|
|
@@ -1854,8 +1948,8 @@ var tooltip = "tooltip-uMWFc";
|
|
|
1854
1948
|
var css_248z$3 = ".tooltip-uMWFc {\n /* margin-top: 1rem; */\n background-color: #1b181a;\n color: white;\n padding: 6px;\n border-radius: 4px;\n}\n";
|
|
1855
1949
|
styleInject(css_248z$3);
|
|
1856
1950
|
|
|
1857
|
-
function ownKeys$
|
|
1858
|
-
function _objectSpread$
|
|
1951
|
+
function ownKeys$d(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1952
|
+
function _objectSpread$d(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$d(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$d(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1859
1953
|
function BooleanCell (_ref) {
|
|
1860
1954
|
var val = _ref.value,
|
|
1861
1955
|
column = _ref.column,
|
|
@@ -1893,7 +1987,7 @@ function BooleanCell (_ref) {
|
|
|
1893
1987
|
if (loading) return;
|
|
1894
1988
|
if (!isEditalbe) return;
|
|
1895
1989
|
setLoading(true);
|
|
1896
|
-
var updatedData = _objectSpread$
|
|
1990
|
+
var updatedData = _objectSpread$d({}, row.original);
|
|
1897
1991
|
column.id.split('.').reduce(function (acc, key, index, arr) {
|
|
1898
1992
|
if (index === arr.length - 1) {
|
|
1899
1993
|
if (column.dataType == 'organizationIdArray') {
|
|
@@ -1941,7 +2035,7 @@ function BooleanCell (_ref) {
|
|
|
1941
2035
|
layerProps = _useLayer.layerProps,
|
|
1942
2036
|
renderLayer = _useLayer.renderLayer;
|
|
1943
2037
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
1944
|
-
children: [/*#__PURE__*/jsx("div", _objectSpread$
|
|
2038
|
+
children: [/*#__PURE__*/jsx("div", _objectSpread$d(_objectSpread$d(_objectSpread$d({}, triggerProps), hoverProps), {}, {
|
|
1945
2039
|
children: /*#__PURE__*/jsx(Checkbox, {
|
|
1946
2040
|
checked: value,
|
|
1947
2041
|
onChange: onChange,
|
|
@@ -1951,7 +2045,7 @@ function BooleanCell (_ref) {
|
|
|
1951
2045
|
disabled: !isEditalbe || !!disabled
|
|
1952
2046
|
})
|
|
1953
2047
|
})), renderLayer(/*#__PURE__*/jsx(Fragment, {
|
|
1954
|
-
children: isOver && !!disabled && /*#__PURE__*/jsx("div", _objectSpread$
|
|
2048
|
+
children: isOver && !!disabled && /*#__PURE__*/jsx("div", _objectSpread$d(_objectSpread$d({}, layerProps), {}, {
|
|
1955
2049
|
className: tooltip,
|
|
1956
2050
|
children: disabled
|
|
1957
2051
|
}))
|
|
@@ -2046,8 +2140,8 @@ var LazyImage = function LazyImage(_ref2) {
|
|
|
2046
2140
|
});
|
|
2047
2141
|
};
|
|
2048
2142
|
|
|
2049
|
-
function ownKeys$
|
|
2050
|
-
function _objectSpread$
|
|
2143
|
+
function ownKeys$c(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2144
|
+
function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$c(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$c(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2051
2145
|
function MediaViewerCell (props) {
|
|
2052
2146
|
var _props$value, _props$column$fallbac;
|
|
2053
2147
|
var _useState = useState(undefined),
|
|
@@ -2085,7 +2179,7 @@ function MediaViewerCell (props) {
|
|
|
2085
2179
|
});
|
|
2086
2180
|
});
|
|
2087
2181
|
}, [timeStamp]);
|
|
2088
|
-
if (!id) return /*#__PURE__*/jsx(ImgCell, _objectSpread$
|
|
2182
|
+
if (!id) return /*#__PURE__*/jsx(ImgCell, _objectSpread$c(_objectSpread$c({}, props), {}, {
|
|
2089
2183
|
value: props.row.original[(_props$column$fallbac = props.column.fallbackField) !== null && _props$column$fallbac !== void 0 ? _props$column$fallbac : '']
|
|
2090
2184
|
}));
|
|
2091
2185
|
var openContentBox = function openContentBox() {
|
|
@@ -2113,8 +2207,8 @@ function MediaViewerCell (props) {
|
|
|
2113
2207
|
}
|
|
2114
2208
|
|
|
2115
2209
|
var _excluded$2 = ["showArrows"];
|
|
2116
|
-
function ownKeys$
|
|
2117
|
-
function _objectSpread$
|
|
2210
|
+
function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2211
|
+
function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2118
2212
|
function SelectionCell (_ref) {
|
|
2119
2213
|
var _props$value;
|
|
2120
2214
|
var showArrows = _ref.showArrows,
|
|
@@ -2153,7 +2247,7 @@ function SelectionCell (_ref) {
|
|
|
2153
2247
|
if (loading) return;
|
|
2154
2248
|
setLoading(true);
|
|
2155
2249
|
setValue(event.target.value);
|
|
2156
|
-
(_props$updateData = props.updateData) === null || _props$updateData === void 0 || _props$updateData.call(props, _objectSpread$
|
|
2250
|
+
(_props$updateData = props.updateData) === null || _props$updateData === void 0 || _props$updateData.call(props, _objectSpread$b(_objectSpread$b({}, props.row.original), {}, _defineProperty({}, props.column.id, event.target.value)), props.row.id, props.column).then(function () {
|
|
2157
2251
|
setLoading(false);
|
|
2158
2252
|
});
|
|
2159
2253
|
};
|
|
@@ -2168,7 +2262,7 @@ function SelectionCell (_ref) {
|
|
|
2168
2262
|
setLoading(true);
|
|
2169
2263
|
var newIndex = type == 'back' ? currentOptionIndex - 1 : currentOptionIndex + 1;
|
|
2170
2264
|
setValue((_options$newIndex = options[newIndex]) === null || _options$newIndex === void 0 ? void 0 : _options$newIndex.key);
|
|
2171
|
-
(_props$updateData2 = props.updateData) === null || _props$updateData2 === void 0 || _props$updateData2.call(props, _objectSpread$
|
|
2265
|
+
(_props$updateData2 = props.updateData) === null || _props$updateData2 === void 0 || _props$updateData2.call(props, _objectSpread$b(_objectSpread$b({}, props.row.original), {}, _defineProperty({}, props.column.id, (_options$newIndex2 = options[newIndex]) === null || _options$newIndex2 === void 0 ? void 0 : _options$newIndex2.key)), props.row.id, props.column).then(function () {
|
|
2172
2266
|
setLoading(false);
|
|
2173
2267
|
});
|
|
2174
2268
|
};
|
|
@@ -2209,11 +2303,11 @@ function SelectionCell (_ref) {
|
|
|
2209
2303
|
}) :
|
|
2210
2304
|
/*#__PURE__*/
|
|
2211
2305
|
//if it is not editalbe it behaves the same as a string cell
|
|
2212
|
-
jsx(DefaultCell, _objectSpread$
|
|
2306
|
+
jsx(DefaultCell, _objectSpread$b({}, props));
|
|
2213
2307
|
}
|
|
2214
2308
|
|
|
2215
|
-
function ownKeys$
|
|
2216
|
-
function _objectSpread$
|
|
2309
|
+
function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2310
|
+
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2217
2311
|
function TextCell (props) {
|
|
2218
2312
|
var _ref;
|
|
2219
2313
|
var isTranslated = props.column.type == 'textTranslation' || props.column.type == 'richTextTranslation';
|
|
@@ -2232,10 +2326,10 @@ function TextCell (props) {
|
|
|
2232
2326
|
if (save === 0) return;
|
|
2233
2327
|
if (isTranslated) {
|
|
2234
2328
|
var _props$updateData;
|
|
2235
|
-
(_props$updateData = props.updateData) === null || _props$updateData === void 0 || _props$updateData.call(props, _objectSpread$
|
|
2329
|
+
(_props$updateData = props.updateData) === null || _props$updateData === void 0 || _props$updateData.call(props, _objectSpread$a(_objectSpread$a({}, props.row.original), {}, _defineProperty(_defineProperty({}, props.column.id, value[languages[0]]), props.column.id + '_locales', value)), props.row.id);
|
|
2236
2330
|
} else {
|
|
2237
2331
|
var _props$updateData2;
|
|
2238
|
-
(_props$updateData2 = props.updateData) === null || _props$updateData2 === void 0 || _props$updateData2.call(props, _objectSpread$
|
|
2332
|
+
(_props$updateData2 = props.updateData) === null || _props$updateData2 === void 0 || _props$updateData2.call(props, _objectSpread$a(_objectSpread$a({}, props.row.original), {}, _defineProperty({}, props.column.id, value)), props.row.id);
|
|
2239
2333
|
}
|
|
2240
2334
|
}, [save]);
|
|
2241
2335
|
var onChange = function onChange(accepted) {
|
|
@@ -2247,7 +2341,7 @@ function TextCell (props) {
|
|
|
2247
2341
|
};
|
|
2248
2342
|
|
|
2249
2343
|
//if it is not editalbe it behaves the same as a string cell
|
|
2250
|
-
return /*#__PURE__*/jsx(DefaultCell, _objectSpread$
|
|
2344
|
+
return /*#__PURE__*/jsx(DefaultCell, _objectSpread$a(_objectSpread$a({}, props), {}, {
|
|
2251
2345
|
onClick: function onClick() {
|
|
2252
2346
|
var _props$column$type, _props$column$type$st, _props$column$type2, _props$column$type2$e;
|
|
2253
2347
|
return openModal({
|
|
@@ -2286,7 +2380,7 @@ function Text(_ref3) {
|
|
|
2286
2380
|
}, [value]);
|
|
2287
2381
|
function changeText(text) {
|
|
2288
2382
|
if (translation) {
|
|
2289
|
-
setValue(_objectSpread$
|
|
2383
|
+
setValue(_objectSpread$a(_objectSpread$a({}, value), {}, _defineProperty({}, languages[curLangIndex], text)));
|
|
2290
2384
|
} else {
|
|
2291
2385
|
setValue(text);
|
|
2292
2386
|
}
|
|
@@ -2300,7 +2394,7 @@ function Text(_ref3) {
|
|
|
2300
2394
|
defaultValue: translation ? value[languages[curLangIndex]] : value,
|
|
2301
2395
|
onChange: function onChange(e) {
|
|
2302
2396
|
if (translation) {
|
|
2303
|
-
setValue(_objectSpread$
|
|
2397
|
+
setValue(_objectSpread$a(_objectSpread$a({}, value), {}, _defineProperty({}, languages[curLangIndex], e.target.value)));
|
|
2304
2398
|
} else setValue(e.target.value);
|
|
2305
2399
|
},
|
|
2306
2400
|
maxLength: maxLength,
|
|
@@ -2336,7 +2430,7 @@ function TranslationSelector(_ref4) {
|
|
|
2336
2430
|
return setCutLang(newValue);
|
|
2337
2431
|
},
|
|
2338
2432
|
children: languages.map(function (lang, index) {
|
|
2339
|
-
return /*#__PURE__*/jsx(Tab, _objectSpread$
|
|
2433
|
+
return /*#__PURE__*/jsx(Tab, _objectSpread$a({
|
|
2340
2434
|
style: {
|
|
2341
2435
|
minWidth: 72,
|
|
2342
2436
|
height: '30px',
|
|
@@ -2356,8 +2450,8 @@ function a11yProps(index) {
|
|
|
2356
2450
|
}
|
|
2357
2451
|
|
|
2358
2452
|
var _excluded$1 = ["onValueChange", "value"];
|
|
2359
|
-
function ownKeys$
|
|
2360
|
-
function _objectSpread$
|
|
2453
|
+
function ownKeys$9(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2454
|
+
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2361
2455
|
function PriceCell (props) {
|
|
2362
2456
|
var _useState = useState(false),
|
|
2363
2457
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -2396,7 +2490,7 @@ function PriceCell (props) {
|
|
|
2396
2490
|
break;
|
|
2397
2491
|
case 10:
|
|
2398
2492
|
_context.next = 12;
|
|
2399
|
-
return (_props$updateData2 = props.updateData) === null || _props$updateData2 === void 0 ? void 0 : _props$updateData2.call(props, _objectSpread$
|
|
2493
|
+
return (_props$updateData2 = props.updateData) === null || _props$updateData2 === void 0 ? void 0 : _props$updateData2.call(props, _objectSpread$9(_objectSpread$9({}, props.row.original), {}, _defineProperty({}, props.column.id, value)), props.row.id);
|
|
2400
2494
|
case 12:
|
|
2401
2495
|
setEditing(false);
|
|
2402
2496
|
case 13:
|
|
@@ -2411,8 +2505,8 @@ function PriceCell (props) {
|
|
|
2411
2505
|
}();
|
|
2412
2506
|
var isEditalbe = props.column.editable && props.inlineEditing;
|
|
2413
2507
|
if (!editing || !isEditalbe) {
|
|
2414
|
-
return /*#__PURE__*/jsx(DefaultCell, _objectSpread$
|
|
2415
|
-
column: _objectSpread$
|
|
2508
|
+
return /*#__PURE__*/jsx(DefaultCell, _objectSpread$9(_objectSpread$9({}, props), {}, {
|
|
2509
|
+
column: _objectSpread$9({}, props.column),
|
|
2416
2510
|
value: DivaUtils.formatPrice(props.value),
|
|
2417
2511
|
onClick: function onClick() {
|
|
2418
2512
|
return setEditing(true);
|
|
@@ -2475,7 +2569,7 @@ function ControlledNumberFormat(_ref2) {
|
|
|
2475
2569
|
}
|
|
2476
2570
|
(_props$onBlur = props.onBlur) === null || _props$onBlur === void 0 || _props$onBlur.call(props, e);
|
|
2477
2571
|
};
|
|
2478
|
-
return /*#__PURE__*/jsx(NumericFormat, _objectSpread$
|
|
2572
|
+
return /*#__PURE__*/jsx(NumericFormat, _objectSpread$9(_objectSpread$9({}, props), {}, {
|
|
2479
2573
|
value: value,
|
|
2480
2574
|
customInput: StyledTextFiled,
|
|
2481
2575
|
onChange: function onChange() {
|
|
@@ -2538,8 +2632,8 @@ function getLocale(lang) {
|
|
|
2538
2632
|
}
|
|
2539
2633
|
}
|
|
2540
2634
|
|
|
2541
|
-
function ownKeys$
|
|
2542
|
-
function _objectSpread$
|
|
2635
|
+
function ownKeys$8(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2636
|
+
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2543
2637
|
function FormularCell (props) {
|
|
2544
2638
|
var _useDivaCore = useDivaCore(),
|
|
2545
2639
|
openModal = _useDivaCore.actions.openModal;
|
|
@@ -2547,7 +2641,7 @@ function FormularCell (props) {
|
|
|
2547
2641
|
t = _useTranslation.t;
|
|
2548
2642
|
function doUpdateVariant(d) {
|
|
2549
2643
|
var _props$updateData;
|
|
2550
|
-
(_props$updateData = props.updateData) === null || _props$updateData === void 0 || _props$updateData.call(props, _objectSpread$
|
|
2644
|
+
(_props$updateData = props.updateData) === null || _props$updateData === void 0 || _props$updateData.call(props, _objectSpread$8({}, d), props.row.id);
|
|
2551
2645
|
}
|
|
2552
2646
|
return /*#__PURE__*/jsx(Fragment, {
|
|
2553
2647
|
children: /*#__PURE__*/jsx(Button, {
|
|
@@ -2617,51 +2711,51 @@ function HTMLTextCell(_ref) {
|
|
|
2617
2711
|
});
|
|
2618
2712
|
}
|
|
2619
2713
|
|
|
2620
|
-
function ownKeys$
|
|
2621
|
-
function _objectSpread$
|
|
2714
|
+
function ownKeys$7(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2715
|
+
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2622
2716
|
function CustomCell (props) {
|
|
2623
2717
|
var classes = useStyles$1();
|
|
2624
2718
|
return /*#__PURE__*/jsx("div", {
|
|
2625
2719
|
className: classes.wrapper,
|
|
2626
|
-
children: /*#__PURE__*/jsx(Cell, _objectSpread$
|
|
2720
|
+
children: /*#__PURE__*/jsx(Cell, _objectSpread$7({}, props))
|
|
2627
2721
|
});
|
|
2628
2722
|
}
|
|
2629
2723
|
function Cell(props) {
|
|
2630
2724
|
switch (props.column.type) {
|
|
2631
2725
|
case 'organizationIdArray':
|
|
2632
2726
|
case 'boolean':
|
|
2633
|
-
return /*#__PURE__*/jsx(BooleanCell, _objectSpread$
|
|
2727
|
+
return /*#__PURE__*/jsx(BooleanCell, _objectSpread$7({}, props));
|
|
2634
2728
|
case 'mediaViewer':
|
|
2635
|
-
return /*#__PURE__*/jsx(MediaViewerCell, _objectSpread$
|
|
2729
|
+
return /*#__PURE__*/jsx(MediaViewerCell, _objectSpread$7({}, props));
|
|
2636
2730
|
case 'image':
|
|
2637
|
-
return /*#__PURE__*/jsx(ImgCell, _objectSpread$
|
|
2731
|
+
return /*#__PURE__*/jsx(ImgCell, _objectSpread$7({}, props));
|
|
2638
2732
|
case 'select':
|
|
2639
|
-
return /*#__PURE__*/jsx(SelectionCell, _objectSpread$
|
|
2733
|
+
return /*#__PURE__*/jsx(SelectionCell, _objectSpread$7({}, props));
|
|
2640
2734
|
case 'selectArrows':
|
|
2641
|
-
return /*#__PURE__*/jsx(SelectionCell, _objectSpread$
|
|
2735
|
+
return /*#__PURE__*/jsx(SelectionCell, _objectSpread$7(_objectSpread$7({}, props), {}, {
|
|
2642
2736
|
showArrows: true
|
|
2643
2737
|
}));
|
|
2644
2738
|
case 'text':
|
|
2645
2739
|
case 'textTranslation':
|
|
2646
2740
|
case 'richText':
|
|
2647
2741
|
case 'richTextTranslation':
|
|
2648
|
-
return /*#__PURE__*/jsx(TextCell, _objectSpread$
|
|
2742
|
+
return /*#__PURE__*/jsx(TextCell, _objectSpread$7({}, props));
|
|
2649
2743
|
case 'htmlTextCopy':
|
|
2650
|
-
return /*#__PURE__*/jsx(HTMLTextCell, _objectSpread$
|
|
2744
|
+
return /*#__PURE__*/jsx(HTMLTextCell, _objectSpread$7(_objectSpread$7({}, props), {}, {
|
|
2651
2745
|
enableCopyText: true
|
|
2652
2746
|
}));
|
|
2653
2747
|
case 'htmlText':
|
|
2654
|
-
return /*#__PURE__*/jsx(HTMLTextCell, _objectSpread$
|
|
2748
|
+
return /*#__PURE__*/jsx(HTMLTextCell, _objectSpread$7({}, props));
|
|
2655
2749
|
case 'price':
|
|
2656
|
-
return /*#__PURE__*/jsx(PriceCell, _objectSpread$
|
|
2750
|
+
return /*#__PURE__*/jsx(PriceCell, _objectSpread$7({}, props));
|
|
2657
2751
|
case 'date':
|
|
2658
|
-
return /*#__PURE__*/jsx(DateCell, _objectSpread$
|
|
2752
|
+
return /*#__PURE__*/jsx(DateCell, _objectSpread$7({}, props));
|
|
2659
2753
|
case 'formular':
|
|
2660
|
-
return /*#__PURE__*/jsx(FormularCell, _objectSpread$
|
|
2754
|
+
return /*#__PURE__*/jsx(FormularCell, _objectSpread$7({}, props));
|
|
2661
2755
|
case 'string':
|
|
2662
2756
|
case 'number':
|
|
2663
2757
|
default:
|
|
2664
|
-
return /*#__PURE__*/jsx(DefaultCell, _objectSpread$
|
|
2758
|
+
return /*#__PURE__*/jsx(DefaultCell, _objectSpread$7({}, props));
|
|
2665
2759
|
}
|
|
2666
2760
|
}
|
|
2667
2761
|
var useStyles$1 = makeStyles(function (theme) {
|
|
@@ -2673,11 +2767,11 @@ var useStyles$1 = makeStyles(function (theme) {
|
|
|
2673
2767
|
});
|
|
2674
2768
|
});
|
|
2675
2769
|
|
|
2676
|
-
function ownKeys$
|
|
2677
|
-
function _objectSpread$
|
|
2770
|
+
function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2771
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2678
2772
|
function useParsedOptions(options) {
|
|
2679
2773
|
return useMemo(function () {
|
|
2680
|
-
var parsedOptions = _objectSpread$
|
|
2774
|
+
var parsedOptions = _objectSpread$6(_objectSpread$6({}, options), {}, {
|
|
2681
2775
|
columns: [],
|
|
2682
2776
|
hiddenColumns: [],
|
|
2683
2777
|
pagination: _typeof(options.pagination) == 'object' ? options.pagination : options.pagination ? {} : undefined
|
|
@@ -2779,13 +2873,15 @@ function getSortType(sortType, valueType) {
|
|
|
2779
2873
|
return 'alphanumeric';
|
|
2780
2874
|
}
|
|
2781
2875
|
|
|
2876
|
+
function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2877
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2782
2878
|
function apiFetchData (_x) {
|
|
2783
2879
|
return _ref2.apply(this, arguments);
|
|
2784
2880
|
}
|
|
2785
2881
|
function _ref2() {
|
|
2786
2882
|
_ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
2787
|
-
var _apiInterface$customS, _serverSideFilteringS;
|
|
2788
|
-
var apiInterface, columns, serverSideFilteringState, abortSignal, skip, limit, result, _loop, i,
|
|
2883
|
+
var _apiInterface$request, _apiInterface$customS, _serverSideFilteringS;
|
|
2884
|
+
var apiInterface, columns, serverSideFilteringState, abortSignal, requestMethod, skip, limit, result, _loop, i, _url, params, body, url;
|
|
2789
2885
|
return _regeneratorRuntime.wrap(function _callee$(_context2) {
|
|
2790
2886
|
while (1) switch (_context2.prev = _context2.next) {
|
|
2791
2887
|
case 0:
|
|
@@ -2796,18 +2892,20 @@ function _ref2() {
|
|
|
2796
2892
|
}
|
|
2797
2893
|
throw new Error('If no data is specified in the apiInterface, an url to fetch the data is mandatory.');
|
|
2798
2894
|
case 3:
|
|
2895
|
+
requestMethod = (_apiInterface$request = apiInterface.requestMethod) !== null && _apiInterface$request !== void 0 ? _apiInterface$request : 'GET'; //customSettings get only applied if there are no userfilter set
|
|
2896
|
+
//with customSettings "filterServerSide" is always assumed to be true, otherwise it makes no sense
|
|
2799
2897
|
if (!((_apiInterface$customS = apiInterface.customSettings) !== null && _apiInterface$customS !== void 0 && _apiInterface$customS.find(function (setting) {
|
|
2800
2898
|
return setting.filter;
|
|
2801
2899
|
}) && !((_serverSideFilteringS = serverSideFilteringState.filters) !== null && _serverSideFilteringS !== void 0 && _serverSideFilteringS.length) && !serverSideFilteringState.globalFilter)) {
|
|
2802
|
-
_context2.next =
|
|
2900
|
+
_context2.next = 20;
|
|
2803
2901
|
break;
|
|
2804
2902
|
}
|
|
2805
2903
|
if (apiInterface.filterServerSide) {
|
|
2806
|
-
_context2.next =
|
|
2904
|
+
_context2.next = 7;
|
|
2807
2905
|
break;
|
|
2808
2906
|
}
|
|
2809
2907
|
throw new Error('If customSettings are used, apiInterface.filterServerSide must be enabled');
|
|
2810
|
-
case
|
|
2908
|
+
case 7:
|
|
2811
2909
|
skip = serverSideFilteringState.skip;
|
|
2812
2910
|
limit = serverSideFilteringState.limit;
|
|
2813
2911
|
result = {
|
|
@@ -2854,32 +2952,43 @@ function _ref2() {
|
|
|
2854
2952
|
}, _loop);
|
|
2855
2953
|
});
|
|
2856
2954
|
i = 0;
|
|
2857
|
-
case
|
|
2955
|
+
case 12:
|
|
2858
2956
|
if (!(i < apiInterface.customSettings.length)) {
|
|
2859
|
-
_context2.next =
|
|
2957
|
+
_context2.next = 19;
|
|
2860
2958
|
break;
|
|
2861
2959
|
}
|
|
2862
|
-
return _context2.delegateYield(_loop(), "t0",
|
|
2863
|
-
case
|
|
2960
|
+
return _context2.delegateYield(_loop(), "t0", 14);
|
|
2961
|
+
case 14:
|
|
2864
2962
|
if (!_context2.t0) {
|
|
2865
|
-
_context2.next =
|
|
2963
|
+
_context2.next = 16;
|
|
2866
2964
|
break;
|
|
2867
2965
|
}
|
|
2868
|
-
return _context2.abrupt("continue",
|
|
2869
|
-
case
|
|
2966
|
+
return _context2.abrupt("continue", 16);
|
|
2967
|
+
case 16:
|
|
2870
2968
|
i++;
|
|
2871
|
-
_context2.next =
|
|
2969
|
+
_context2.next = 12;
|
|
2872
2970
|
break;
|
|
2873
|
-
case
|
|
2971
|
+
case 19:
|
|
2874
2972
|
return _context2.abrupt("return", result);
|
|
2875
|
-
case
|
|
2973
|
+
case 20:
|
|
2974
|
+
if (!(requestMethod === 'POST')) {
|
|
2975
|
+
_context2.next = 25;
|
|
2976
|
+
break;
|
|
2977
|
+
}
|
|
2978
|
+
_url = new URL(apiInterface.url);
|
|
2979
|
+
params = getUrlParams(apiInterface, columns, serverSideFilteringState.skip, serverSideFilteringState.limit, serverSideFilteringState.sortBy, serverSideFilteringState.filters, serverSideFilteringState.globalFilter, apiInterface.customSettings);
|
|
2980
|
+
body = buildQueryBody(params);
|
|
2981
|
+
return _context2.abrupt("return", fetchData(abortSignal, _url.toString(), apiInterface.authToken, {
|
|
2982
|
+
method: 'POST',
|
|
2983
|
+
body: body
|
|
2984
|
+
}));
|
|
2985
|
+
case 25:
|
|
2876
2986
|
url = new URL(apiInterface.url);
|
|
2877
2987
|
getUrlParams(apiInterface, columns, serverSideFilteringState.skip, serverSideFilteringState.limit, serverSideFilteringState.sortBy, serverSideFilteringState.filters, serverSideFilteringState.globalFilter, apiInterface.customSettings).forEach(function (value, key) {
|
|
2878
2988
|
url.searchParams.append(key, value);
|
|
2879
2989
|
});
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
case 25:
|
|
2990
|
+
return _context2.abrupt("return", fetchData(abortSignal, url.toString(), apiInterface.authToken));
|
|
2991
|
+
case 28:
|
|
2883
2992
|
case "end":
|
|
2884
2993
|
return _context2.stop();
|
|
2885
2994
|
}
|
|
@@ -2887,78 +2996,93 @@ function _ref2() {
|
|
|
2887
2996
|
}));
|
|
2888
2997
|
return _ref2.apply(this, arguments);
|
|
2889
2998
|
}
|
|
2890
|
-
function
|
|
2999
|
+
function buildQueryBody(params) {
|
|
3000
|
+
var body = {};
|
|
3001
|
+
params.forEach(function (value, key) {
|
|
3002
|
+
body[key] = value;
|
|
3003
|
+
});
|
|
3004
|
+
return body;
|
|
3005
|
+
}
|
|
3006
|
+
function fetchData(_x2, _x3, _x4, _x5) {
|
|
2891
3007
|
return _fetchData.apply(this, arguments);
|
|
2892
3008
|
}
|
|
2893
3009
|
function _fetchData() {
|
|
2894
|
-
_fetchData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(abortSignal, url, authToken) {
|
|
2895
|
-
var response, data;
|
|
3010
|
+
_fetchData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(abortSignal, url, authToken, options) {
|
|
3011
|
+
var _options$method, method, headers, response, data;
|
|
2896
3012
|
return _regeneratorRuntime.wrap(function _callee2$(_context3) {
|
|
2897
3013
|
while (1) switch (_context3.prev = _context3.next) {
|
|
2898
3014
|
case 0:
|
|
2899
3015
|
_context3.prev = 0;
|
|
2900
|
-
|
|
2901
|
-
|
|
3016
|
+
method = (_options$method = options === null || options === void 0 ? void 0 : options.method) !== null && _options$method !== void 0 ? _options$method : 'GET';
|
|
3017
|
+
headers = authToken ? {
|
|
3018
|
+
Authorization: "Bearer ".concat(authToken)
|
|
3019
|
+
} : {};
|
|
3020
|
+
if (method === 'POST') {
|
|
3021
|
+
headers['Content-Type'] = 'application/json';
|
|
3022
|
+
}
|
|
3023
|
+
_context3.next = 6;
|
|
3024
|
+
return fetch(url, _objectSpread$5({
|
|
2902
3025
|
signal: abortSignal,
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
3026
|
+
method: method,
|
|
3027
|
+
headers: headers
|
|
3028
|
+
}, options !== null && options !== void 0 && options.body ? {
|
|
3029
|
+
body: JSON.stringify(options.body)
|
|
3030
|
+
} : {}));
|
|
3031
|
+
case 6:
|
|
2908
3032
|
response = _context3.sent;
|
|
2909
3033
|
if (response.ok) {
|
|
2910
|
-
_context3.next =
|
|
3034
|
+
_context3.next = 11;
|
|
2911
3035
|
break;
|
|
2912
3036
|
}
|
|
2913
3037
|
if (!(response.status === 408)) {
|
|
2914
|
-
_context3.next =
|
|
3038
|
+
_context3.next = 10;
|
|
2915
3039
|
break;
|
|
2916
3040
|
}
|
|
2917
3041
|
throw {
|
|
2918
3042
|
name: 'TimeoutError',
|
|
2919
3043
|
message: 'A timeout occurred'
|
|
2920
3044
|
};
|
|
2921
|
-
case
|
|
3045
|
+
case 10:
|
|
2922
3046
|
throw new Error(response.statusText);
|
|
2923
|
-
case
|
|
2924
|
-
_context3.next =
|
|
3047
|
+
case 11:
|
|
3048
|
+
_context3.next = 13;
|
|
2925
3049
|
return response.json();
|
|
2926
|
-
case
|
|
3050
|
+
case 13:
|
|
2927
3051
|
data = _context3.sent;
|
|
2928
3052
|
if (!(data && data.data !== undefined)) {
|
|
2929
|
-
_context3.next =
|
|
3053
|
+
_context3.next = 18;
|
|
2930
3054
|
break;
|
|
2931
3055
|
}
|
|
2932
3056
|
return _context3.abrupt("return", data);
|
|
2933
|
-
case
|
|
3057
|
+
case 18:
|
|
2934
3058
|
if (!data) {
|
|
2935
|
-
_context3.next =
|
|
3059
|
+
_context3.next = 20;
|
|
2936
3060
|
break;
|
|
2937
3061
|
}
|
|
2938
3062
|
return _context3.abrupt("return", {
|
|
2939
3063
|
data: Array.isArray(data) ? data : [],
|
|
2940
3064
|
total: Array.isArray(data) ? data.length : 0
|
|
2941
3065
|
});
|
|
2942
|
-
case 17:
|
|
2943
|
-
throw new Error('Unexpected response format');
|
|
2944
3066
|
case 20:
|
|
2945
|
-
|
|
3067
|
+
throw new Error('Unexpected response format');
|
|
3068
|
+
case 23:
|
|
3069
|
+
_context3.prev = 23;
|
|
2946
3070
|
_context3.t0 = _context3["catch"](0);
|
|
2947
3071
|
if (!(_context3.t0.name === 'AbortError')) {
|
|
2948
|
-
_context3.next =
|
|
3072
|
+
_context3.next = 27;
|
|
2949
3073
|
break;
|
|
2950
3074
|
}
|
|
2951
3075
|
return _context3.abrupt("return", {
|
|
2952
3076
|
data: [],
|
|
2953
3077
|
total: 0
|
|
2954
3078
|
});
|
|
2955
|
-
case
|
|
3079
|
+
case 27:
|
|
2956
3080
|
throw _context3.t0;
|
|
2957
|
-
case
|
|
3081
|
+
case 28:
|
|
2958
3082
|
case "end":
|
|
2959
3083
|
return _context3.stop();
|
|
2960
3084
|
}
|
|
2961
|
-
}, _callee2, null, [[0,
|
|
3085
|
+
}, _callee2, null, [[0, 23]]);
|
|
2962
3086
|
}));
|
|
2963
3087
|
return _fetchData.apply(this, arguments);
|
|
2964
3088
|
}
|
|
@@ -3150,7 +3274,7 @@ function useApiInterface(_ref) {
|
|
|
3150
3274
|
var _useReducer = useReducer(reducer, {
|
|
3151
3275
|
data: [],
|
|
3152
3276
|
total: 0,
|
|
3153
|
-
loading:
|
|
3277
|
+
loading: true,
|
|
3154
3278
|
custom: {}
|
|
3155
3279
|
}),
|
|
3156
3280
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
@@ -3699,9 +3823,13 @@ var useSelection = function useSelection(hooks) {
|
|
|
3699
3823
|
|
|
3700
3824
|
hooks.useInstance.push(function (instance) {
|
|
3701
3825
|
var selectedRootRows = useMemo(function () {
|
|
3702
|
-
|
|
3826
|
+
var selected = instance.selectedFlatRows.filter(function (row) {
|
|
3703
3827
|
return row.depth == 0;
|
|
3704
3828
|
});
|
|
3829
|
+
instance.onRowSelectionChange(selected.map(function (row) {
|
|
3830
|
+
return row.id;
|
|
3831
|
+
}));
|
|
3832
|
+
return selected;
|
|
3705
3833
|
}, [instance.selectedFlatRows]);
|
|
3706
3834
|
Object.assign(instance, {
|
|
3707
3835
|
selectedRootRows: selectedRootRows
|
|
@@ -3749,7 +3877,10 @@ function Grid(_ref) {
|
|
|
3749
3877
|
prepareRowHook = _ref.prepareRow,
|
|
3750
3878
|
customElement = _ref.customElement,
|
|
3751
3879
|
noData = _ref.noData,
|
|
3752
|
-
forceNewData = _ref.forceNewData
|
|
3880
|
+
forceNewData = _ref.forceNewData,
|
|
3881
|
+
toolbarActionsVisibleCount = _ref.toolbarActionsVisibleCount,
|
|
3882
|
+
_ref$toolbarActionsPo = _ref.toolbarActionsPosition,
|
|
3883
|
+
toolbarActionsPosition = _ref$toolbarActionsPo === void 0 ? 'right' : _ref$toolbarActionsPo;
|
|
3753
3884
|
var classes = useStyles();
|
|
3754
3885
|
var _useTranslation = useTranslation(),
|
|
3755
3886
|
t = _useTranslation.t;
|
|
@@ -3827,7 +3958,11 @@ function Grid(_ref) {
|
|
|
3827
3958
|
groupBy: parsedOptions.groupBy || [],
|
|
3828
3959
|
sortBy: parsedOptions.sortBy || [],
|
|
3829
3960
|
pageSize: ((_parsedOptions$pagina2 = parsedOptions.pagination) === null || _parsedOptions$pagina2 === void 0 ? void 0 : _parsedOptions$pagina2.defaultPageSize) || 20,
|
|
3830
|
-
hiddenColumns: parsedOptions.hiddenColumns
|
|
3961
|
+
hiddenColumns: parsedOptions.hiddenColumns,
|
|
3962
|
+
selectedRowIds: selected ? selected.reduce(function (acc, idx) {
|
|
3963
|
+
acc[idx] = true;
|
|
3964
|
+
return acc;
|
|
3965
|
+
}, {}) : {}
|
|
3831
3966
|
},
|
|
3832
3967
|
manualFilters: options.apiInterface.filterServerSide,
|
|
3833
3968
|
manualGlobalFilter: options.apiInterface.filterServerSide,
|
|
@@ -3858,6 +3993,12 @@ function Grid(_ref) {
|
|
|
3858
3993
|
onNew: onInternalNew,
|
|
3859
3994
|
onEdit: onInternalEdit,
|
|
3860
3995
|
onDelete: onInternalDelete,
|
|
3996
|
+
onRowSelectionChange: useCallback(function (selected) {
|
|
3997
|
+
if (isLoading) return;
|
|
3998
|
+
onSelect(selected.map(function (idx) {
|
|
3999
|
+
return data[parseInt(idx)];
|
|
4000
|
+
}));
|
|
4001
|
+
}, [data]),
|
|
3861
4002
|
custom: custom
|
|
3862
4003
|
}, useFilters, useGlobalFilter, useGroupBy, useSortBy, useExpanded, usePagination, useSelection, useEditActions, useHightlight, function (hooks) {
|
|
3863
4004
|
hooks.getCellProps.push(function (props, meta) {
|
|
@@ -3929,9 +4070,9 @@ function Grid(_ref) {
|
|
|
3929
4070
|
toggleAllRowsExpanded = _useTable.toggleAllRowsExpanded,
|
|
3930
4071
|
toggleRowSelected = _useTable.toggleRowSelected,
|
|
3931
4072
|
toggleAllRowsSelected = _useTable.toggleAllRowsSelected,
|
|
3932
|
-
selectedFlatRows = _useTable.selectedFlatRows
|
|
3933
|
-
|
|
3934
|
-
flatRows = _useTable.flatRows,
|
|
4073
|
+
selectedFlatRows = _useTable.selectedFlatRows;
|
|
4074
|
+
_useTable.selectedRootRows;
|
|
4075
|
+
var flatRows = _useTable.flatRows,
|
|
3935
4076
|
_useTable$state = _useTable.state,
|
|
3936
4077
|
pageIndex = _useTable$state.pageIndex,
|
|
3937
4078
|
pageSize = _useTable$state.pageSize,
|
|
@@ -3952,23 +4093,16 @@ function Grid(_ref) {
|
|
|
3952
4093
|
});
|
|
3953
4094
|
}, [pageIndex, pageSize, globalFilter, filters, sortBy]);
|
|
3954
4095
|
useEffect(function () {
|
|
3955
|
-
if (options.selectable && selected) {
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
4096
|
+
if (options.selectable && selected && !isLoading) {
|
|
4097
|
+
// Sync the selection state with the external selected prop
|
|
4098
|
+
flatRows.forEach(function (r) {
|
|
4099
|
+
var shouldBeSelected = selected.includes(r.id);
|
|
4100
|
+
if (r.isSelected !== shouldBeSelected) {
|
|
4101
|
+
toggleRowSelected(r.id, shouldBeSelected);
|
|
4102
|
+
}
|
|
3960
4103
|
});
|
|
3961
4104
|
}
|
|
3962
|
-
}, [selected, options.selectable]);
|
|
3963
|
-
useEffect(function () {
|
|
3964
|
-
if (options.selectable) {
|
|
3965
|
-
onSelect(selectedRootRows.filter(function (r) {
|
|
3966
|
-
return !r.isGrouped;
|
|
3967
|
-
}).map(function (r) {
|
|
3968
|
-
return r.original;
|
|
3969
|
-
}));
|
|
3970
|
-
}
|
|
3971
|
-
}, [selectedRootRows, options.selectable]);
|
|
4105
|
+
}, [selected, options.selectable, flatRows, isLoading]);
|
|
3972
4106
|
useEffect(function () {
|
|
3973
4107
|
if (options.apiInterface.filterServerSide && pageIndex > total / pageSize) {
|
|
3974
4108
|
gotoPage(0);
|
|
@@ -4053,21 +4187,29 @@ function Grid(_ref) {
|
|
|
4053
4187
|
children: h.render('Filter')
|
|
4054
4188
|
}, h.id);
|
|
4055
4189
|
}),
|
|
4190
|
+
actionsVisibleCount: toolbarActionsVisibleCount,
|
|
4191
|
+
actionsPosition: toolbarActionsPosition,
|
|
4192
|
+
hasSelection: selectedFlatRows.length > 0,
|
|
4056
4193
|
actions: toolbarActions === null || toolbarActions === void 0 ? void 0 : toolbarActions.map(function (a) {
|
|
4057
4194
|
var selectedItems = selectedFlatRows.map(function (r) {
|
|
4058
4195
|
return r.original;
|
|
4059
4196
|
});
|
|
4060
|
-
var
|
|
4061
|
-
var actionDisabled = a.disabled ? a.disabled(selectedItems) : false;
|
|
4062
|
-
var isDisabled = noSelection || actionDisabled;
|
|
4197
|
+
var isDisabled = a.disabled ? a.disabled(selectedItems) : false;
|
|
4063
4198
|
return {
|
|
4064
4199
|
label: a.label,
|
|
4065
4200
|
selected: a.selected,
|
|
4066
4201
|
onClick: function onClick(e) {
|
|
4067
4202
|
var selectedRows = _toConsumableArray(selectedFlatRows);
|
|
4068
|
-
var removeSelectedItems = function removeSelectedItems() {
|
|
4203
|
+
var removeSelectedItems = function removeSelectedItems(itemsToRemove) {
|
|
4204
|
+
var rowsToDelete = selectedRows;
|
|
4205
|
+
if (itemsToRemove && itemsToRemove.length > 0) {
|
|
4206
|
+
rowsToDelete = selectedRows.filter(function (r) {
|
|
4207
|
+
return itemsToRemove.includes(r.original);
|
|
4208
|
+
});
|
|
4209
|
+
}
|
|
4210
|
+
|
|
4069
4211
|
// Get indices in reverse order to avoid index shifting issues
|
|
4070
|
-
var indices =
|
|
4212
|
+
var indices = rowsToDelete.map(function (r) {
|
|
4071
4213
|
return r.index;
|
|
4072
4214
|
}).sort(function (a, b) {
|
|
4073
4215
|
return b - a;
|
|
@@ -4075,14 +4217,20 @@ function Grid(_ref) {
|
|
|
4075
4217
|
indices.forEach(function (index) {
|
|
4076
4218
|
return deleteData(index);
|
|
4077
4219
|
});
|
|
4078
|
-
|
|
4220
|
+
if (!itemsToRemove || itemsToRemove.length === selectedRows.length || rowsToDelete.length === selectedRows.length) {
|
|
4221
|
+
toggleAllRowsSelected(false);
|
|
4222
|
+
} else {
|
|
4223
|
+
rowsToDelete.forEach(function (r) {
|
|
4224
|
+
return toggleRowSelected(r.id, false);
|
|
4225
|
+
});
|
|
4226
|
+
}
|
|
4079
4227
|
};
|
|
4080
4228
|
a.onClick(selectedRows.map(function (r) {
|
|
4081
4229
|
return r.original;
|
|
4082
4230
|
}), e, removeSelectedItems);
|
|
4083
4231
|
},
|
|
4084
4232
|
disabled: isDisabled,
|
|
4085
|
-
tooltip:
|
|
4233
|
+
tooltip: isDisabled && a.disabledTooltip ? a.disabledTooltip : undefined
|
|
4086
4234
|
};
|
|
4087
4235
|
}),
|
|
4088
4236
|
onViewSwitch: setView,
|
|
@@ -4093,7 +4241,7 @@ function Grid(_ref) {
|
|
|
4093
4241
|
}), error && /*#__PURE__*/jsx(Alert, {
|
|
4094
4242
|
severity: "error",
|
|
4095
4243
|
children: "".concat(t('grid.error'), " (").concat(error, ")") + ' --- ' + DivaUtils.formatDate(new Date(), true, undefined, true) + (DivaUtils.getCurrentTraceId() ? ' --- ' + t('modal.errorcode') + ': ' + DivaUtils.getCurrentTraceId() : '')
|
|
4096
|
-
}), view === 'Gallery' && /*#__PURE__*/jsx(Gallery, _objectSpread({}, galleryProps)), view == 'Table' && /*#__PURE__*/jsx(
|
|
4244
|
+
}), view === 'Gallery' && /*#__PURE__*/jsx(Gallery, _objectSpread({}, galleryProps)), view == 'Table' && /*#__PURE__*/jsx(Table$1, _objectSpread({}, tableProps)), !isLoading && rows.length < 1 && (noData ? noData : /*#__PURE__*/jsx(NoData, {
|
|
4097
4245
|
hasToolbar: !noToolbar
|
|
4098
4246
|
})), parsedOptions.pagination && !parsedOptions.pagination.hide && /*#__PURE__*/jsx(TablePagination, {
|
|
4099
4247
|
ref: ref,
|