@m4l/components 0.0.2 → 0.0.5

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.
Files changed (82) hide show
  1. package/dist/commonjs.js +5 -1
  2. package/dist/components/DataGrid/components/Actions/components/Density/index.d.ts +2 -0
  3. package/dist/components/DataGrid/components/Actions/components/Density/styles.d.ts +3 -0
  4. package/dist/components/DataGrid/components/Actions/components/Filter/index.d.ts +2 -0
  5. package/dist/components/DataGrid/components/Actions/components/Filter/styles.d.ts +2 -0
  6. package/dist/components/DataGrid/components/Actions/components/RowsCount/index.d.ts +2 -0
  7. package/dist/components/DataGrid/components/Actions/components/RowsCount/styles.d.ts +4 -0
  8. package/dist/components/DataGrid/components/Actions/components/Settings/ColumnsConfig/components/FormatterColumn/index.d.ts +4 -0
  9. package/dist/components/DataGrid/components/Actions/components/Settings/ColumnsConfig/index.d.ts +3 -0
  10. package/dist/components/DataGrid/components/Actions/components/Settings/ColumnsConfig/styles.d.ts +8 -0
  11. package/dist/components/DataGrid/components/Actions/components/Settings/ColumnsConfig/types.d.ts +25 -0
  12. package/dist/components/DataGrid/components/Actions/components/Settings/index.d.ts +2 -0
  13. package/dist/components/DataGrid/components/Actions/components/Settings/styles.d.ts +2 -0
  14. package/dist/components/DataGrid/components/Actions/components/Settings/types.d.ts +2 -0
  15. package/dist/components/DataGrid/components/Actions/index.d.ts +3 -0
  16. package/dist/components/DataGrid/components/Actions/styles.d.ts +2 -0
  17. package/dist/components/DataGrid/components/Actions/types.d.ts +11 -0
  18. package/dist/components/DataGrid/components/Table/components/ActionsColumn.d.ts +4 -0
  19. package/dist/components/DataGrid/components/Table/components/CheckboxFormatter.d.ts +3 -0
  20. package/dist/components/DataGrid/components/Table/components/CustomIcons.d.ts +15 -0
  21. package/dist/components/DataGrid/components/Table/components/DraggableHeaderRenderer.d.ts +6 -0
  22. package/dist/components/DataGrid/components/Table/components/SelectColumn.d.ts +4 -0
  23. package/dist/components/DataGrid/components/Table/components/SkeletonFormatter/index.d.ts +2 -0
  24. package/dist/components/DataGrid/components/Table/components/SkeletonFormatter/styles.d.ts +2 -0
  25. package/dist/components/DataGrid/components/Table/hooks/getDragHeaderRenderer.d.ts +3 -0
  26. package/dist/components/DataGrid/components/Table/hooks/useFocusRef.d.ts +5 -0
  27. package/dist/components/DataGrid/components/Table/hooks/useSortColumnsRows.d.ts +8 -0
  28. package/dist/components/DataGrid/components/Table/index.d.ts +3 -0
  29. package/dist/components/DataGrid/components/Table/styles.d.ts +3 -0
  30. package/dist/components/DataGrid/contexts/BaseContext/index.d.ts +5 -0
  31. package/dist/components/DataGrid/contexts/BaseContext/types.d.ts +51 -0
  32. package/dist/components/DataGrid/contexts/FilterContext/index.d.ts +9 -0
  33. package/dist/components/DataGrid/contexts/FilterContext/types.d.ts +11 -0
  34. package/dist/components/DataGrid/formatters/DateFormatter/index.d.ts +3 -0
  35. package/dist/components/DataGrid/formatters/DateFormatter/types.d.ts +6 -0
  36. package/dist/components/DataGrid/hooks/useBase.d.ts +1 -0
  37. package/dist/components/DataGrid/hooks/useFilters.d.ts +1 -0
  38. package/dist/components/DataGrid/index.d.ts +3 -0
  39. package/dist/components/DataGrid/index.js +1623 -0
  40. package/dist/components/DataGrid/styles.d.ts +3 -0
  41. package/dist/components/DataGrid/types.d.ts +56 -0
  42. package/dist/components/FormActions/dictionary.d.ts +3 -0
  43. package/dist/components/FormActions/index.js +4 -1
  44. package/dist/components/ModalDialog/dictionary.d.ts +3 -0
  45. package/dist/components/ModalDialog/index.js +10 -3
  46. package/dist/components/ObjectLogs/components/DetailDialog/index.d.ts +3 -0
  47. package/dist/components/ObjectLogs/components/DetailDialog/styles.d.ts +3 -0
  48. package/dist/components/ObjectLogs/components/DetailDialog/types.d.ts +3 -0
  49. package/dist/components/ObjectLogs/components/DetailFormatter/index.d.ts +3 -0
  50. package/dist/components/ObjectLogs/components/DetailFormatter/types.d.ts +3 -0
  51. package/dist/components/ObjectLogs/index.d.ts +3 -0
  52. package/dist/components/ObjectLogs/index.js +283 -0
  53. package/dist/components/ObjectLogs/styles.d.ts +4 -0
  54. package/dist/components/ObjectLogs/types.d.ts +18 -0
  55. package/dist/components/index.d.ts +4 -0
  56. package/dist/components/mui_extended/IconButton/index.d.ts +5 -0
  57. package/dist/components/mui_extended/IconButton/index.js +37 -0
  58. package/dist/components/mui_extended/IconButton/types.d.ts +5 -0
  59. package/dist/components/mui_extended/MenuActions/index.d.ts +2 -1
  60. package/dist/components/mui_extended/MenuActions/styles.d.ts +2 -2
  61. package/dist/components/mui_extended/Pager/components/PagerActions/index.d.ts +3 -0
  62. package/dist/components/mui_extended/Pager/components/PagerActions/styles.d.ts +2 -0
  63. package/dist/components/mui_extended/Pager/components/PagerActions/types.d.ts +7 -0
  64. package/dist/components/mui_extended/Pager/dicctionary.d.ts +3 -0
  65. package/dist/components/mui_extended/Pager/index.d.ts +4 -0
  66. package/dist/components/mui_extended/Pager/index.js +201 -0
  67. package/dist/components/mui_extended/Pager/styles.d.ts +6 -0
  68. package/dist/components/mui_extended/Pager/types.d.ts +13 -0
  69. package/dist/components/mui_extended/index.d.ts +5 -1
  70. package/dist/contexts/ModalContext/index.js +113 -19
  71. package/dist/contexts/index.d.ts +2 -0
  72. package/dist/hooks/useModal/index.d.ts +1 -1
  73. package/dist/hooks/usePaginate.d.ts +15 -0
  74. package/dist/index.d.ts +2 -0
  75. package/dist/index.js +21 -9
  76. package/dist/react-data-grid.js +2652 -0
  77. package/dist/react-draggable.js +2 -2
  78. package/dist/react-json-view.js +2764 -0
  79. package/dist/vendor.js +79 -4
  80. package/package.json +15 -3
  81. package/dist/prop-types.js +0 -1
  82. package/dist/react.js +0 -2
@@ -0,0 +1,1623 @@
1
+ import { styled, alpha } from "@mui/material/styles";
2
+ import { forwardRef, useRef, useLayoutEffect, createContext, useState, useContext, useEffect, useMemo, useCallback, useImperativeHandle } from "react";
3
+ import { S as SELECT_COLUMN_KEY, a as SelectCellFormatter, u as useRowSelection, H as HeaderRenderer, D as DataGrid$1 } from "../../react-data-grid.js";
4
+ import { useDrag, useDrop, DndProvider } from "react-dnd";
5
+ import { HTML5Backend } from "react-dnd-html5-backend";
6
+ import { SvgIcon, Checkbox, InputBase, Skeleton } from "@mui/material";
7
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
8
+ import { voidFunction, useModuleDictionary, useEnvironment } from "@m4l/core";
9
+ import { MenuActions } from "@mui_extended";
10
+ import { P as Pager } from "../mui_extended/Pager/index.js";
11
+ import { I as IconButton } from "../mui_extended/IconButton/index.js";
12
+ import { u as useModal } from "../../hooks/useModal/index.js";
13
+ import { M as MenuActions$1 } from "../mui_extended/MenuActions/index.js";
14
+ import { u as useResponsiveDesktop } from "../../vendor.js";
15
+ import { format } from "date-fns";
16
+ const WrapperGrid$1 = styled("div")(() => ({
17
+ display: "flex",
18
+ flexDirection: "column",
19
+ position: "absolute",
20
+ padding: "0px",
21
+ inset: "0px",
22
+ overflow: "hidden"
23
+ }));
24
+ const OriginalGridWrapperStyled = styled("div")(({
25
+ theme
26
+ }) => ({
27
+ position: "absolute",
28
+ bottom: "0px",
29
+ top: "0px",
30
+ left: "0px",
31
+ right: "0px",
32
+ "& .rdg ": {
33
+ userSelect: "initial",
34
+ height: "100%",
35
+ contentVisibility: "unset",
36
+ overflow: "scroll",
37
+ borderRadius: "5px",
38
+ "--rdg-grid-inline-size": "0px",
39
+ "--rdg-header-background-color": theme.palette.grid?.sectionHeader,
40
+ "--rdg-row-selected-background-color": theme.palette.mode === "light" ? theme.palette.primary.LightSelected : theme.palette.primary.DarkSelected,
41
+ "--rdg-row-hover-background-color": theme.palette.grid?.rowHover,
42
+ "--rdg-background-color": theme.palette.background.default,
43
+ "--rdg-selection-color": theme.palette.primary.main,
44
+ "--row-selected-hover-background-color": theme.palette.mode === "light" ? theme.palette.primary.LightSelectedHover : theme.palette.primary.DarkSelectedHover,
45
+ "--rdg-checkbox-color": theme.palette.primary.main,
46
+ "--rdg-checkbox-focus-color": alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity),
47
+ "--rdg-border-color": theme.palette.divider
48
+ },
49
+ "& .rdg::-webkit-scrollbar": {
50
+ width: "6px",
51
+ height: "6px",
52
+ borderRadius: "3px",
53
+ backgroundColor: "transparent"
54
+ },
55
+ "& .rdg::-webkit-scrollbar-track": {
56
+ backgroundColor: "transparent",
57
+ border: "0px solid transparent"
58
+ },
59
+ "& .rdg::-webkit-scrollbar-corner": {
60
+ backgroundColor: "transparent"
61
+ },
62
+ "& ::-webkit-scrollbar-thumb": {
63
+ borderRadius: "10px",
64
+ backgroundColor: theme.palette.divider,
65
+ border: "0px solid transparent"
66
+ },
67
+ '& [role="columnheader"]': {
68
+ justifyContent: "center",
69
+ alignItems: "center"
70
+ },
71
+ "& .rdg-cell": {
72
+ fontFamily: theme.typography.body2.fontFamily,
73
+ fontWeight: theme.typography.body2.fontWeight,
74
+ fontSize: theme.typography.body2.fontSize,
75
+ color: theme.palette.text.secondary,
76
+ borderBottom: `1px solid ${theme.palette.divider}`,
77
+ borderRight: `0px solid transparent`,
78
+ position: "relative",
79
+ "&.rdg-cell-frozen": {
80
+ position: "sticky"
81
+ },
82
+ "&:after": {
83
+ content: `""`,
84
+ borderRight: `1px solid ${theme.palette.divider}`,
85
+ position: "absolute",
86
+ right: "0px",
87
+ top: "25%",
88
+ bottom: "25%"
89
+ }
90
+ },
91
+ "& .rdg-cell.rdg-cell-align-left": {
92
+ textAlign: "left"
93
+ },
94
+ "& .rdg-cell.rdg-cell-align-center": {
95
+ textAlign: "center"
96
+ },
97
+ "& .rdg-cell.rdg-cell-align-right": {
98
+ textAlign: "right"
99
+ },
100
+ "& .rdg-row .rdg-cell-frozen-last:after": {
101
+ borderRight: `0px solid transparent`,
102
+ boxShadow: "none"
103
+ },
104
+ "& .rdg-row :last-child:after": {
105
+ borderRight: `0px solid transparent`
106
+ },
107
+ "& .rdg-header-row .rdg-cell": {
108
+ fontFamily: theme.typography.subtitle2.fontFamily,
109
+ fontWeight: theme.typography.subtitle2.fontWeight,
110
+ fontSize: theme.typography.subtitle2.fontSize,
111
+ color: theme.palette.text.primary,
112
+ borderRight: `0px solid transparent`,
113
+ boxShadow: "none",
114
+ "&.rdg-cell-frozen-last": {
115
+ "&:after": {
116
+ borderRight: `0px solid transparent`
117
+ },
118
+ boxShadow: "var(--rdg-frozen-cell-box-shadow)"
119
+ },
120
+ "& .rdg-sort-arrow": {
121
+ width: theme.spacing(1),
122
+ margin: `0 ${theme.spacing(0.5)}`
123
+ }
124
+ },
125
+ "& .rdg-header-row :last-child.rdg-cell": {
126
+ borderTopRightRadius: "5px",
127
+ "&:after": {
128
+ borderRight: `0px solid transparent`
129
+ }
130
+ },
131
+ "& .filter_cell_div": {
132
+ paddingLeft: theme.spacing(0.5),
133
+ paddingRight: theme.spacing(0.5)
134
+ },
135
+ "& .rdg-header-sort-cell": {
136
+ width: "100%",
137
+ flexGrow: "1",
138
+ alignItems: "center"
139
+ },
140
+ '& [aria-columnsort="ASC"]': {
141
+ borderTop: `2px solid ${theme.palette.primary.main}`
142
+ },
143
+ '& [aria-columnsort="DESC"]': {
144
+ borderBottom: `2px solid ${theme.palette.primary.main}`
145
+ }
146
+ }));
147
+ const WrapperTable = styled("div", {
148
+ shouldForwardProp: (prop) => prop !== "withActions"
149
+ })(({
150
+ withActions,
151
+ theme
152
+ }) => ({
153
+ display: "flex",
154
+ flexDirection: "column",
155
+ position: "absolute",
156
+ top: withActions ? theme.spacing(5.5) : "0px",
157
+ bottom: "0px",
158
+ left: "0px",
159
+ right: "0px",
160
+ overflow: "hidden"
161
+ }));
162
+ function CheckboxIcon(props) {
163
+ return /* @__PURE__ */ jsx(SvgIcon, {
164
+ ...props,
165
+ children: /* @__PURE__ */ jsx("path", {
166
+ d: "M17 3a4 4 0 014 4v10a4 4 0 01-4 4H7a4 4 0 01-4-4V7a4 4 0 014-4h10zm0 2H7a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2z"
167
+ })
168
+ });
169
+ }
170
+ function CheckboxCheckedIcon(props) {
171
+ return /* @__PURE__ */ jsx(SvgIcon, {
172
+ ...props,
173
+ children: /* @__PURE__ */ jsx("path", {
174
+ d: "M17 3a4 4 0 014 4v10a4 4 0 01-4 4H7a4 4 0 01-4-4V7a4 4 0 014-4h10zm-1.372 4.972a1.006 1.006 0 00-.928.388l-3.78 5-1.63-2.08a1.001 1.001 0 00-1.58 1.23l2.44 3.11a1 1 0 001.58-.01l4.57-6v-.03a1.006 1.006 0 00-.672-1.608z"
175
+ })
176
+ });
177
+ }
178
+ function CheckboxIndeterminateIcon(props) {
179
+ return /* @__PURE__ */ jsx(SvgIcon, {
180
+ ...props,
181
+ children: /* @__PURE__ */ jsx("path", {
182
+ d: "M17 3a4 4 0 014 4v10a4 4 0 01-4 4H7a4 4 0 01-4-4V7a4 4 0 014-4h10zm-1.75 8h-6.5a.75.75 0 00-.75.75v.5c0 .414.336.75.75.75h6.5a.75.75 0 00.75-.75v-.5a.75.75 0 00-.75-.75z"
183
+ })
184
+ });
185
+ }
186
+ const CheckboxFormatter = forwardRef(function CheckboxFormatter2({
187
+ onChange,
188
+ checked,
189
+ ...props
190
+ }, _ref) {
191
+ function handleChange(e) {
192
+ onChange(e.target.checked, e.nativeEvent.shiftKey);
193
+ }
194
+ return /* @__PURE__ */ jsx(Checkbox, {
195
+ checked,
196
+ size: "small",
197
+ icon: /* @__PURE__ */ jsx(CheckboxIcon, {}),
198
+ checkedIcon: /* @__PURE__ */ jsx(CheckboxCheckedIcon, {}),
199
+ indeterminateIcon: /* @__PURE__ */ jsx(CheckboxIndeterminateIcon, {}),
200
+ onChange: handleChange,
201
+ ...props
202
+ });
203
+ });
204
+ const filterColumnClassName = "filter-cell";
205
+ const filterHeight = 35;
206
+ function SelectFormatter(props) {
207
+ const [isRowSelected, onRowSelectionChange] = useRowSelection();
208
+ const onChange = (checked, isShiftClick) => {
209
+ onRowSelectionChange({
210
+ row: props.row,
211
+ checked,
212
+ isShiftClick
213
+ });
214
+ };
215
+ const cellFormater = SelectCellFormatter({
216
+ value: isRowSelected,
217
+ isCellSelected: props.isCellSelected,
218
+ onChange,
219
+ "aria-label": "Select"
220
+ });
221
+ return cellFormater;
222
+ }
223
+ function SelectGroupFormatter(props) {
224
+ const [isRowSelected, onRowSelectionChange] = useRowSelection();
225
+ const onChange = (checked) => {
226
+ onRowSelectionChange({
227
+ row: props.row,
228
+ checked,
229
+ isShiftClick: false
230
+ });
231
+ };
232
+ const cellFormater = SelectCellFormatter({
233
+ value: isRowSelected,
234
+ isCellSelected: props.isCellSelected,
235
+ onChange,
236
+ "aria-label": "Select Group"
237
+ });
238
+ return cellFormater;
239
+ }
240
+ const SelectColumn = {
241
+ key: SELECT_COLUMN_KEY,
242
+ name: "",
243
+ width: 60,
244
+ maxWidth: 60,
245
+ resizable: false,
246
+ sortable: false,
247
+ frozen: true,
248
+ type: "number",
249
+ headerRenderer: (props) => SelectCellFormatter({
250
+ "aria-label": "Select All",
251
+ isCellSelected: props.isCellSelected,
252
+ value: props.allRowsSelected,
253
+ onChange: props.onAllRowsSelectionChange
254
+ }),
255
+ formatter: SelectFormatter,
256
+ groupFormatter: SelectGroupFormatter
257
+ };
258
+ function useFocusRef(isSelected) {
259
+ const ref = useRef(null);
260
+ useLayoutEffect(() => {
261
+ if (!isSelected)
262
+ return;
263
+ ref.current?.focus({ preventScroll: true });
264
+ }, [isSelected]);
265
+ return {
266
+ ref,
267
+ tabIndex: isSelected ? 0 : -1
268
+ };
269
+ }
270
+ const initialState$1 = {
271
+ activeFilters: false,
272
+ setActiveFilters: voidFunction
273
+ };
274
+ const FilterContext = createContext(initialState$1);
275
+ function FilterProvider({
276
+ children,
277
+ initialActiveFilters
278
+ }) {
279
+ const [filterOptions, setFilterOptions] = useState({
280
+ activeFilters: initialActiveFilters
281
+ });
282
+ const onChangeFilter = (columnkey, value) => {
283
+ const newMap = filterOptions.filters ? new Map(filterOptions.filters) : /* @__PURE__ */ new Map();
284
+ if (value !== "") {
285
+ newMap.set(columnkey, value);
286
+ } else {
287
+ newMap.delete(columnkey);
288
+ }
289
+ setFilterOptions({
290
+ ...filterOptions,
291
+ filters: newMap
292
+ });
293
+ };
294
+ const setActiveFilters = (active) => {
295
+ if (active) {
296
+ setFilterOptions({
297
+ activeFilters: true,
298
+ filters: /* @__PURE__ */ new Map()
299
+ });
300
+ } else {
301
+ setFilterOptions({
302
+ activeFilters: false
303
+ });
304
+ }
305
+ };
306
+ return /* @__PURE__ */ jsx(FilterContext.Provider, {
307
+ value: {
308
+ ...filterOptions,
309
+ onChangeFilter,
310
+ setActiveFilters
311
+ },
312
+ children
313
+ });
314
+ }
315
+ const useFilters = () => useContext(FilterContext);
316
+ function DraggableHeaderRenderer(props) {
317
+ const {
318
+ onColumnsReorder,
319
+ column,
320
+ isCellSelected,
321
+ ...others
322
+ } = props;
323
+ const {
324
+ ref,
325
+ tabIndex
326
+ } = useFocusRef(isCellSelected);
327
+ const {
328
+ getLabel
329
+ } = useModuleDictionary();
330
+ const {
331
+ activeFilters,
332
+ filters,
333
+ onChangeFilter
334
+ } = useFilters();
335
+ const [filter, setFilter] = useState(filters?.get(column.key) || "");
336
+ const [{
337
+ isDragging
338
+ }, drag] = useDrag({
339
+ type: "COLUMN_DRAG",
340
+ item: {
341
+ key: column.key
342
+ },
343
+ collect: (monitor) => ({
344
+ isDragging: monitor.isDragging()
345
+ })
346
+ });
347
+ const [{
348
+ isOver
349
+ }, drop] = useDrop({
350
+ accept: "COLUMN_DRAG",
351
+ drop({
352
+ key
353
+ }) {
354
+ onColumnsReorder(key, column.key);
355
+ },
356
+ collect: (monitor) => ({
357
+ isOver: monitor.isOver(),
358
+ canDrop: monitor.canDrop()
359
+ })
360
+ });
361
+ const handleChange = (e) => {
362
+ if (activeFilters) {
363
+ if (onChangeFilter)
364
+ onChangeFilter(column.key, e.target.value);
365
+ }
366
+ setFilter(e.target.value);
367
+ };
368
+ useEffect(() => {
369
+ if (!activeFilters)
370
+ setFilter("");
371
+ }, [activeFilters]);
372
+ const newColumn = {
373
+ ...column
374
+ };
375
+ if (newColumn.withinHeaderRenderer) {
376
+ newColumn.name = newColumn.withinHeaderRenderer(props);
377
+ }
378
+ return /* @__PURE__ */ jsxs("div", {
379
+ ref: (newRef) => {
380
+ drag(newRef);
381
+ drop(newRef);
382
+ },
383
+ style: {
384
+ opacity: isDragging ? 0.5 : 1,
385
+ backgroundColor: isOver ? "#ececec" : void 0,
386
+ cursor: "move",
387
+ display: "flex",
388
+ flexDirection: "column",
389
+ lineHeight: "1",
390
+ height: "100%",
391
+ justifyContent: "center",
392
+ textAlign: "center"
393
+ },
394
+ children: [/* @__PURE__ */ jsx(HeaderRenderer, {
395
+ column: newColumn,
396
+ isCellSelected,
397
+ ...others
398
+ }), activeFilters && (column?.withFilter === void 0 || column.withFilter === true) && /* @__PURE__ */ jsx("div", {
399
+ className: "filter_cell_div",
400
+ style: {
401
+ borderTop: "1px solid var(--rdg-border-color)",
402
+ width: "100%",
403
+ display: "flex",
404
+ alignItems: "center",
405
+ height: `${filterHeight}px`
406
+ },
407
+ children: /* @__PURE__ */ jsx(InputBase, {
408
+ inputRef: ref,
409
+ placeholder: getLabel("grid.filter_holder"),
410
+ style: {
411
+ width: "100%",
412
+ paddingBottom: "2px",
413
+ border: "1px solid var(--rdg-border-color)"
414
+ },
415
+ tabIndex,
416
+ type: "text",
417
+ onChange: handleChange,
418
+ value: filter
419
+ })
420
+ })]
421
+ });
422
+ }
423
+ const getDragHeaderRenderer = (handleColumnsReorder) => {
424
+ function HeaderRenderer2(props) {
425
+ return /* @__PURE__ */ jsx(DraggableHeaderRenderer, {
426
+ ...props,
427
+ onColumnsReorder: handleColumnsReorder
428
+ });
429
+ }
430
+ return HeaderRenderer2;
431
+ };
432
+ const initialState = {
433
+ columnsWidths: /* @__PURE__ */ new Map(),
434
+ onChangeColumnsConfig: voidFunction,
435
+ onChangeColumnsOrder: voidFunction,
436
+ onChangeColumnWidth: voidFunction,
437
+ columnsConfig: [{
438
+ key: "string",
439
+ visible: true,
440
+ hidden: false,
441
+ index: 0,
442
+ frozen: true,
443
+ name: "string;",
444
+ orginalIndex: 0,
445
+ originalVisible: true,
446
+ originalFrozen: false
447
+ }],
448
+ isSkeleton: false,
449
+ rowsCount: 0,
450
+ setRowsCount: voidFunction,
451
+ rowHeights: 36,
452
+ currentRowHeight: 36,
453
+ currentRowHeaderHeight: 40,
454
+ currentRowHeightVariant: "compact",
455
+ setRowHeightVariant: voidFunction
456
+ };
457
+ const BaseContext = createContext(initialState);
458
+ const getColumnConfigByKey = (key, storeColumnsConfig) => {
459
+ let indexFind = -1;
460
+ return [storeColumnsConfig.find((column, index) => {
461
+ if (column.key === key) {
462
+ indexFind = index;
463
+ }
464
+ return column.key === key;
465
+ }), indexFind];
466
+ };
467
+ function getColumnsConfig(id, columns, remoteConfig = void 0) {
468
+ let columnsConfig;
469
+ if (remoteConfig) {
470
+ columnsConfig = remoteConfig.columnsConfig;
471
+ } else {
472
+ try {
473
+ const item = window.localStorage.getItem(`${id}_columns_config`);
474
+ columnsConfig = item !== null ? JSON.parse(item) : [];
475
+ } catch (e) {
476
+ columnsConfig = [];
477
+ }
478
+ }
479
+ return columns.map((column, index) => {
480
+ const [columnConfig = {
481
+ ...column
482
+ }, columnConfigIndex] = getColumnConfigByKey(column.key, columnsConfig);
483
+ return {
484
+ key: column.key,
485
+ name: column.name,
486
+ hidden: column.hidden === void 0 ? false : column.hidden,
487
+ index: columnConfigIndex > -1 ? columnConfigIndex : index,
488
+ visible: columnConfig.visible === void 0 ? true : columnConfig.visible,
489
+ frozen: columnConfig.frozen === void 0 ? false : columnConfig.frozen,
490
+ orginalIndex: index,
491
+ originalVisible: column.visible === void 0 ? true : column.visible,
492
+ originalFrozen: column.frozen === void 0 ? false : column.frozen
493
+ };
494
+ }).sort((a, b) => a.index - b.index);
495
+ }
496
+ function getColumnsWidth(id, columns, remoteConfig) {
497
+ const newMap = /* @__PURE__ */ new Map();
498
+ let storeColumnsWidth;
499
+ try {
500
+ const item = window.localStorage.getItem(`${id}_columns_width`);
501
+ storeColumnsWidth = item !== null ? new Map(JSON.parse(item)) : /* @__PURE__ */ new Map();
502
+ } catch (e) {
503
+ storeColumnsWidth = /* @__PURE__ */ new Map();
504
+ }
505
+ for (let i = 0; i < columns.length; i++) {
506
+ let width;
507
+ if (remoteConfig) {
508
+ try {
509
+ width = remoteConfig.columnsWidths.get(columns[i].key);
510
+ } catch (error) {
511
+ }
512
+ }
513
+ if (width === void 0) {
514
+ const storeWidth = storeColumnsWidth.get(columns[i].key);
515
+ if (typeof storeWidth === "number") {
516
+ width = storeWidth;
517
+ }
518
+ }
519
+ if (width !== void 0) {
520
+ newMap.set(columns[i].key, width);
521
+ }
522
+ }
523
+ return newMap;
524
+ }
525
+ function saveColumnsWidth(id, storeColumnsWidth) {
526
+ localStorage.setItem(`${id}_columns_width`, JSON.stringify([...storeColumnsWidth]));
527
+ }
528
+ function saveColumnsConfig(id, columnsConfig) {
529
+ localStorage.setItem(`${id}_columns_config`, JSON.stringify(columnsConfig));
530
+ }
531
+ function getIndexRowHeightVariant(variant) {
532
+ if (variant === "compact") {
533
+ return 0;
534
+ }
535
+ if (variant === "standard") {
536
+ return 1;
537
+ }
538
+ return 2;
539
+ }
540
+ function BaseProvider(props) {
541
+ const {
542
+ id,
543
+ children,
544
+ isSkeleton,
545
+ columns,
546
+ remoteConfig,
547
+ rowsCount,
548
+ rowActionsGetter,
549
+ rowHeights,
550
+ rowHeaderHeights,
551
+ initialRowHeightVariant
552
+ } = props;
553
+ const [columnsWidths, setColumnsWidths] = useState(/* @__PURE__ */ new Map());
554
+ const [columnsConfig, setColumnsConfigOptions] = useState(() => []);
555
+ const [rowsFilterCount, setRowFilterCount] = useState(rowsCount);
556
+ const [currentRowHeightVariant, setCurrentRowHeightVariant] = useState(() => {
557
+ if (typeof rowHeights !== typeof rowHeaderHeights) {
558
+ throw new Error("Must be same type rowheights and rowHeaderTypes");
559
+ }
560
+ if (typeof rowHeights === "number" && typeof rowHeaderHeights === "number") {
561
+ return {
562
+ rowHVariant: "compact",
563
+ rowHeight: rowHeights,
564
+ rowHeaderHeight: rowHeaderHeights
565
+ };
566
+ }
567
+ if (typeof rowHeights !== "number" && rowHeights.length !== 3) {
568
+ throw new Error("Must be 3 heights");
569
+ }
570
+ if (typeof rowHeaderHeights !== "number" && rowHeaderHeights.length !== 3) {
571
+ throw new Error("Must be 3 HeaderHeights");
572
+ }
573
+ return {
574
+ rowHVariant: initialRowHeightVariant,
575
+ rowHeight: typeof rowHeights !== "number" ? rowHeights[getIndexRowHeightVariant(initialRowHeightVariant)] : rowHeights,
576
+ rowHeaderHeight: typeof rowHeaderHeights !== "number" ? rowHeaderHeights[getIndexRowHeightVariant(initialRowHeightVariant)] : rowHeaderHeights
577
+ };
578
+ });
579
+ const finalRowHeights = useMemo(() => rowHeights, [rowHeights]);
580
+ let timerSaveColumns;
581
+ useEffect(() => {
582
+ }, [columnsConfig]);
583
+ useEffect(() => {
584
+ setColumnsWidths(getColumnsWidth(id, columns, remoteConfig));
585
+ setColumnsConfigOptions(getColumnsConfig(id, columns, remoteConfig));
586
+ }, [columns, id, remoteConfig]);
587
+ const onChangeColumnsConfig = useCallback((newColumnsConfig) => {
588
+ saveColumnsConfig(id, newColumnsConfig);
589
+ setColumnsConfigOptions(newColumnsConfig);
590
+ }, [setColumnsConfigOptions, id]);
591
+ const onChangeColumnsOrder = useCallback((sourceKey, targetKey) => {
592
+ if (sourceKey === targetKey)
593
+ return;
594
+ const sourceColumnIndex = columnsConfig.findIndex((c) => c.key === sourceKey);
595
+ const targetColumnIndex = columnsConfig.findIndex((c) => c.key === targetKey);
596
+ const reorderedColumnsConfig = [...columnsConfig];
597
+ reorderedColumnsConfig.splice(targetColumnIndex, 0, reorderedColumnsConfig.splice(sourceColumnIndex, 1)[0]);
598
+ onChangeColumnsConfig(reorderedColumnsConfig);
599
+ }, [columnsConfig, onChangeColumnsConfig]);
600
+ const onChangeColumnWidth = (columnKey, width) => {
601
+ columnsWidths.set(columnKey, Math.round(width));
602
+ if (timerSaveColumns) {
603
+ clearTimeout(timerSaveColumns);
604
+ }
605
+ timerSaveColumns = setTimeout(() => {
606
+ saveColumnsWidth(id, columnsWidths);
607
+ }, 500);
608
+ };
609
+ useEffect(() => {
610
+ setColumnsConfigOptions(getColumnsConfig(id, columns));
611
+ }, [columns]);
612
+ const setRowFilterCountInternal = (newRowsCount) => {
613
+ console.log("New setRowFilterCountInternal", newRowsCount);
614
+ setRowFilterCount(newRowsCount);
615
+ };
616
+ const setCurrentRowHeightInternal = useCallback((newVariant) => {
617
+ if (typeof rowHeights === "number" || typeof rowHeaderHeights === "number") {
618
+ throw new Error("Only use setCurrentRowHeight with vector rowHeights");
619
+ }
620
+ setCurrentRowHeightVariant({
621
+ rowHVariant: newVariant,
622
+ rowHeight: rowHeights[getIndexRowHeightVariant(newVariant)],
623
+ rowHeaderHeight: rowHeaderHeights[getIndexRowHeightVariant(newVariant)]
624
+ });
625
+ }, [setCurrentRowHeightVariant, rowHeights, rowHeaderHeights]);
626
+ return /* @__PURE__ */ jsx(BaseContext.Provider, {
627
+ value: {
628
+ isSkeleton,
629
+ columnsConfig,
630
+ columnsWidths,
631
+ onChangeColumnsConfig,
632
+ onChangeColumnsOrder,
633
+ onChangeColumnWidth,
634
+ rowsCount: rowsFilterCount,
635
+ setRowsCount: setRowFilterCountInternal,
636
+ rowActionsGetter,
637
+ currentRowHeightVariant: currentRowHeightVariant.rowHVariant,
638
+ currentRowHeight: currentRowHeightVariant.rowHeight,
639
+ currentRowHeaderHeight: currentRowHeightVariant.rowHeaderHeight,
640
+ rowHeights: finalRowHeights,
641
+ setRowHeightVariant: setCurrentRowHeightInternal
642
+ },
643
+ children
644
+ });
645
+ }
646
+ const useBase = () => useContext(BaseContext);
647
+ const ACTIONS_COLUMN_KEY = "actions-row";
648
+ function ActionsFormatter(props) {
649
+ const {
650
+ rowActionsGetter
651
+ } = useBase();
652
+ if (rowActionsGetter === void 0) {
653
+ return /* @__PURE__ */ jsx(Fragment, {});
654
+ }
655
+ return /* @__PURE__ */ jsx(MenuActions, {
656
+ arrow: "top-left",
657
+ objItem: props.row,
658
+ menuActions: rowActionsGetter,
659
+ marginTop: 1,
660
+ marginLeft: "-11px",
661
+ anchorOrigin: {
662
+ vertical: "bottom",
663
+ horizontal: "left"
664
+ },
665
+ transformOrigin: {
666
+ vertical: "top",
667
+ horizontal: "left"
668
+ }
669
+ });
670
+ }
671
+ const ActionsColumn = {
672
+ key: ACTIONS_COLUMN_KEY,
673
+ name: "Actions",
674
+ width: 60,
675
+ withFilter: false,
676
+ resizable: true,
677
+ sortable: false,
678
+ frozen: true,
679
+ type: "custom",
680
+ formatter: ActionsFormatter
681
+ };
682
+ const WrapperSkeleton = styled("div")(() => ({
683
+ display: "flex",
684
+ width: "100%",
685
+ height: "100%",
686
+ alignItems: "center"
687
+ }));
688
+ function SkeletonFormatter() {
689
+ return /* @__PURE__ */ jsx(WrapperSkeleton, {
690
+ children: /* @__PURE__ */ jsx(Skeleton, {
691
+ variant: "text",
692
+ width: "100%",
693
+ height: "12px"
694
+ })
695
+ });
696
+ }
697
+ function getComparator(columns, sortColumn) {
698
+ const column = columns.find((d) => d.key === sortColumn);
699
+ let typeOrder = "text";
700
+ if (column) {
701
+ typeOrder = column.type || "text";
702
+ }
703
+ switch (typeOrder) {
704
+ case "number":
705
+ return (a, b) => {
706
+ try {
707
+ return Number(a[sortColumn]) - Number(b[sortColumn]);
708
+ } catch (error) {
709
+ return -1;
710
+ }
711
+ };
712
+ default:
713
+ return (a, b) => {
714
+ try {
715
+ return a[sortColumn].toString().localeCompare(b[sortColumn].toString());
716
+ } catch (error) {
717
+ return -1;
718
+ }
719
+ };
720
+ }
721
+ }
722
+ const getColumIndex = (key, columnsConfig) => columnsConfig.findIndex((columnConfig) => columnConfig.key === key);
723
+ const getInOrderColumns = (columns, isMultipleRows, columnsConfig, columnsWidths, rowActionsGetter) => {
724
+ let filteredSortedColumns = columns.filter((column) => {
725
+ const columnConfigIndex = getColumIndex(column.key, columnsConfig);
726
+ const visible = columnConfigIndex > -1 ? columnsConfig[columnConfigIndex].visible : true;
727
+ return !column.hidden && visible;
728
+ }).sort((a, b) => getColumIndex(a.key, columnsConfig) - getColumIndex(b.key, columnsConfig)).map((columnSorted) => {
729
+ const columnConfigIndex = getColumIndex(columnSorted.key, columnsConfig);
730
+ return {
731
+ ...columnSorted,
732
+ frozen: columnConfigIndex > -1 ? columnsConfig[columnConfigIndex].frozen : true,
733
+ width: typeof columnsWidths.get(columnSorted.key) === "number" ? columnsWidths.get(columnSorted.key) : columnSorted.width
734
+ };
735
+ }).sort((a, b) => {
736
+ const order = (a.frozen === void 0 || a.frozen === false) === (b.frozen === void 0 || b.frozen === false) ? 0 : a.frozen ? -1 : 1;
737
+ return order;
738
+ });
739
+ if (rowActionsGetter) {
740
+ filteredSortedColumns = [ActionsColumn, ...filteredSortedColumns];
741
+ }
742
+ if (isMultipleRows) {
743
+ filteredSortedColumns = [SelectColumn, ...filteredSortedColumns];
744
+ }
745
+ return filteredSortedColumns;
746
+ };
747
+ const getAligByType = (columnType) => {
748
+ switch (columnType) {
749
+ case "text":
750
+ return "left";
751
+ case "date":
752
+ case "boolean":
753
+ case "custom":
754
+ return "center";
755
+ case "number":
756
+ return "right";
757
+ }
758
+ return "left";
759
+ };
760
+ const useSortColumnsRows = (sourceColumns, sourceRows, isMultipleRows) => {
761
+ const { columnsConfig, columnsWidths, onChangeColumnsOrder, rowActionsGetter, isSkeleton } = useBase();
762
+ const [columns, setColumns] = useState(() => []);
763
+ const [sortColumns, setSortColumns] = useState([]);
764
+ const { activeFilters, filters } = useFilters();
765
+ const findKeyInColumns = (key, cols) => {
766
+ const index = cols.findIndex((column) => key === column.key && column.hidden === false);
767
+ return index !== -1;
768
+ };
769
+ useEffect(() => {
770
+ setColumns(getInOrderColumns(sourceColumns, isMultipleRows, columnsConfig, columnsWidths, rowActionsGetter));
771
+ const finalSortedColumns = sortColumns.filter((sortColumn) => findKeyInColumns(sortColumn.columnKey, sourceColumns));
772
+ if (JSON.stringify(finalSortedColumns) !== JSON.stringify(sortColumns)) {
773
+ setSortColumns(finalSortedColumns);
774
+ }
775
+ }, [sourceColumns, columnsConfig, rowActionsGetter]);
776
+ const finalColumns = useMemo(() => {
777
+ console.log("useMemo useSortColumnsRows [finalColumns]", isSkeleton);
778
+ const DragAndDropHeaderRenderer = getDragHeaderRenderer(onChangeColumnsOrder);
779
+ return columns.map((c) => {
780
+ const newColumn = {
781
+ ...c,
782
+ cellClass: c.align !== void 0 ? `rdg-cell-align-${c.align}` : `rdg-cell-align-${getAligByType(c.type)}`
783
+ };
784
+ if (newColumn.key === SELECT_COLUMN_KEY || newColumn.isDraggable !== void 0 && newColumn.isDraggable === false)
785
+ return newColumn;
786
+ if (isSkeleton) {
787
+ newColumn.headerRenderer = SkeletonFormatter;
788
+ newColumn.formatter = SkeletonFormatter;
789
+ }
790
+ if (newColumn.headerRenderer) {
791
+ newColumn.withinHeaderRenderer = newColumn.headerRenderer;
792
+ }
793
+ if ((newColumn?.withFilter === void 0 || newColumn.withFilter === true) && activeFilters) {
794
+ newColumn.headerCellClass = filterColumnClassName;
795
+ }
796
+ newColumn.headerRenderer = DragAndDropHeaderRenderer;
797
+ return newColumn;
798
+ });
799
+ }, [isSkeleton, columns, activeFilters, onChangeColumnsOrder]);
800
+ const finalRows = useMemo(() => {
801
+ const nextRows = sourceRows.filter((r) => {
802
+ if (!filters || filters.size === 0)
803
+ return true;
804
+ const iterator = filters.entries();
805
+ let valReturn = true;
806
+ for (let i = 0; i < filters.size; i++) {
807
+ const entry = iterator.next().value;
808
+ const key = entry[0];
809
+ const value = `${entry[1]}`;
810
+ let valRow;
811
+ try {
812
+ valRow = `${r[key]}`;
813
+ } catch (error) {
814
+ continue;
815
+ }
816
+ valReturn = valReturn && valRow.includes(value);
817
+ if (!valReturn)
818
+ break;
819
+ }
820
+ return valReturn;
821
+ });
822
+ if (sortColumns.length === 0) {
823
+ return nextRows;
824
+ }
825
+ nextRows.sort((a, b) => {
826
+ for (const sort of sortColumns) {
827
+ const comparator = getComparator(columns, sort.columnKey);
828
+ const compResult = comparator(a, b);
829
+ if (compResult !== 0) {
830
+ return sort.direction === "ASC" ? compResult : -compResult;
831
+ }
832
+ }
833
+ return 0;
834
+ });
835
+ return nextRows;
836
+ }, [sourceRows, sortColumns, filters]);
837
+ return { finalColumns, sortColumns, setSortColumns, finalRows };
838
+ };
839
+ function Table(props) {
840
+ const {
841
+ isMultipleSelect = false,
842
+ columns,
843
+ rows,
844
+ withActions
845
+ } = props;
846
+ const {
847
+ finalColumns,
848
+ sortColumns,
849
+ setSortColumns,
850
+ finalRows
851
+ } = useSortColumnsRows(columns, rows, isMultipleSelect);
852
+ const {
853
+ activeFilters
854
+ } = useFilters();
855
+ const {
856
+ onChangeColumnWidth,
857
+ setRowsCount,
858
+ currentRowHeight,
859
+ currentRowHeaderHeight
860
+ } = useBase();
861
+ const [selectedRows, setSelectedRows] = useState(() => new Set(props.selectedRows));
862
+ useEffect(() => {
863
+ setSelectedRows(new Set(props.selectedRows));
864
+ }, [props.selectedRows]);
865
+ const refGrid = useRef(null);
866
+ const updateExternal = (mapRowsSelected) => {
867
+ if (props.onRowsSelectedChange) {
868
+ const rawRowsSelected = [];
869
+ if (mapRowsSelected.size > 0) {
870
+ const iterator = mapRowsSelected.entries();
871
+ for (let i = 0; i < mapRowsSelected.size; i++) {
872
+ const entry = iterator.next().value;
873
+ const key = entry[1];
874
+ const row = finalRows.find((frow) => props.rowKeyGetter(frow) === key);
875
+ if (row) {
876
+ rawRowsSelected.push(row);
877
+ }
878
+ }
879
+ }
880
+ props.onRowsSelectedChange(mapRowsSelected, rawRowsSelected);
881
+ }
882
+ };
883
+ const onInternalSelectedRowsChange = (mapRowsSelected) => {
884
+ setSelectedRows(mapRowsSelected);
885
+ updateExternal(mapRowsSelected);
886
+ };
887
+ const onRowClick = (row) => {
888
+ if (!isMultipleSelect) {
889
+ const mySet = /* @__PURE__ */ new Set([props.rowKeyGetter(row)]);
890
+ setSelectedRows(mySet);
891
+ updateExternal(mySet);
892
+ }
893
+ };
894
+ useEffect(() => {
895
+ let columnIndice = 0;
896
+ for (const column of finalColumns) {
897
+ const index = sortColumns.findIndex((sortColumn) => column.key === sortColumn.columnKey);
898
+ if (index !== -1) {
899
+ refGrid.current?.element?.querySelector(`[role="columnheader"][aria-colindex="${columnIndice + 1}"]`)?.setAttribute("aria-columnsort", `${sortColumns[index].direction}`);
900
+ } else {
901
+ refGrid.current?.element?.querySelector(`[role="columnheader"][aria-colindex="${columnIndice + 1}"]`)?.removeAttribute("aria-columnsort");
902
+ }
903
+ columnIndice++;
904
+ }
905
+ }, [sortColumns, finalColumns]);
906
+ useEffect(() => {
907
+ setRowsCount(finalRows.length);
908
+ }, [finalRows]);
909
+ const onColumnResize = (idx, width) => {
910
+ onChangeColumnWidth(finalColumns[idx].key, width);
911
+ };
912
+ const onChangeSort = (newSortColumns) => {
913
+ setSortColumns(newSortColumns);
914
+ };
915
+ return /* @__PURE__ */ jsx(WrapperTable, {
916
+ id: "WrapperTable",
917
+ withActions,
918
+ children: /* @__PURE__ */ jsx(OriginalGridWrapperStyled, {
919
+ id: "OriginalGridWrapperStyled",
920
+ children: /* @__PURE__ */ jsx(DndProvider, {
921
+ backend: HTML5Backend,
922
+ children: /* @__PURE__ */ jsx(DataGrid$1, {
923
+ className: "fill-grid rdg-light",
924
+ ref: refGrid,
925
+ headerRowHeight: activeFilters ? currentRowHeaderHeight + filterHeight : currentRowHeaderHeight,
926
+ columns: finalColumns,
927
+ sortColumns,
928
+ onSortColumnsChange: onChangeSort,
929
+ onColumnResize,
930
+ rows: finalRows,
931
+ selectedRows,
932
+ onSelectedRowsChange: onInternalSelectedRowsChange,
933
+ onRowClick,
934
+ rowHeight: currentRowHeight,
935
+ rowKeyGetter: props.rowKeyGetter,
936
+ cellNavigationMode: "LOOP_OVER_ROW",
937
+ components: {
938
+ checkboxFormatter: CheckboxFormatter
939
+ },
940
+ defaultColumnOptions: {
941
+ resizable: true,
942
+ sortable: true
943
+ }
944
+ })
945
+ })
946
+ })
947
+ });
948
+ }
949
+ const SKTWrapperFilter = styled("div")(({
950
+ theme
951
+ }) => ({
952
+ display: "flex",
953
+ justifyContent: "center",
954
+ alignItems: "center",
955
+ minWidth: theme.spacing(3.75),
956
+ height: theme.spacing(3.75)
957
+ }));
958
+ function Filter() {
959
+ const {
960
+ isSkeleton
961
+ } = useBase();
962
+ const {
963
+ activeFilters,
964
+ setActiveFilters
965
+ } = useFilters();
966
+ const {
967
+ host_static_assets,
968
+ environment
969
+ } = useEnvironment();
970
+ const toggleIcon = () => {
971
+ setActiveFilters(!activeFilters);
972
+ };
973
+ if (isSkeleton) {
974
+ return /* @__PURE__ */ jsx(SKTWrapperFilter, {
975
+ children: /* @__PURE__ */ jsx(Skeleton, {
976
+ variant: "circular",
977
+ width: 20,
978
+ height: 20
979
+ })
980
+ });
981
+ }
982
+ return /* @__PURE__ */ jsx(IconButton, {
983
+ dictionaryTooltip: activeFilters ? "grid.filter_hide" : "grid.filter_show",
984
+ onClick: toggleIcon,
985
+ "aria-label": "filter",
986
+ src: `${host_static_assets}/${environment}/frontend/components/grid/assets/icons/filter.svg`
987
+ });
988
+ }
989
+ const WrapperColumnsConfig = styled("div")(({ theme }) => ({
990
+ color: theme.palette.text.primary,
991
+ position: "relative",
992
+ display: "flex",
993
+ flexDirection: "column",
994
+ height: "100%",
995
+ width: "100%"
996
+ }));
997
+ styled("div")(({ theme }) => ({
998
+ color: theme.palette.text.primary,
999
+ fontSize: theme.typography.h4.fontSize
1000
+ }));
1001
+ const DivSelColumns = styled("div")(({ theme }) => ({
1002
+ ...theme.typography.subtitle2,
1003
+ color: theme.palette.text.primary,
1004
+ padding: `${theme.spacing(3)} ${theme.spacing(1)}`
1005
+ }));
1006
+ const WrapperGrid = styled("div")(() => ({
1007
+ position: "relative",
1008
+ display: "flex",
1009
+ flexDirection: "column",
1010
+ flexGrow: 1
1011
+ }));
1012
+ styled("div")(() => ({
1013
+ display: "flex",
1014
+ flexDirection: "row"
1015
+ }));
1016
+ const ColumnActions = styled("div")(({ theme }) => ({
1017
+ paddingTop: theme.spacing(3),
1018
+ display: "flex",
1019
+ flexDirection: "row"
1020
+ }));
1021
+ styled("div")(({ theme }) => ({
1022
+ paddingTop: theme.spacing(3),
1023
+ display: "flex",
1024
+ flexDirection: "row",
1025
+ justifyContent: "flex-end",
1026
+ "& > button": {
1027
+ marginLeft: "10px"
1028
+ }
1029
+ }));
1030
+ function FormatterColumn({
1031
+ row,
1032
+ onRowChange,
1033
+ column
1034
+ }) {
1035
+ const handleChange = () => {
1036
+ const newRow = {
1037
+ ...row
1038
+ };
1039
+ newRow[column.key] = !row[column.key];
1040
+ onRowChange(newRow);
1041
+ };
1042
+ return /* @__PURE__ */ jsx(Checkbox, {
1043
+ size: "small",
1044
+ checked: row[column.key],
1045
+ onChange: handleChange
1046
+ });
1047
+ }
1048
+ function getRowsFromColumnsConfig(columnsConfig) {
1049
+ return columnsConfig.filter((column) => !column.hidden).map((column) => ({
1050
+ key: column.key,
1051
+ name: column.name,
1052
+ visible: column.visible === void 0 ? true : column.visible,
1053
+ frozen: column.frozen === void 0 ? false : column.frozen,
1054
+ originalIndex: column.orginalIndex,
1055
+ originalFrozen: column.originalFrozen,
1056
+ originalVisible: column.originalVisible
1057
+ }));
1058
+ }
1059
+ const ColumnsConfig = forwardRef((props, ref) => {
1060
+ const refGrid = useRef(null);
1061
+ const {
1062
+ onCloseSettings,
1063
+ columnsConfig,
1064
+ onChangeColumnsConfig
1065
+ } = props;
1066
+ const {
1067
+ getLabel
1068
+ } = useModuleDictionary();
1069
+ const [isInit, setIsInit] = useState(true);
1070
+ const [rows, setRows] = useState(getRowsFromColumnsConfig(columnsConfig));
1071
+ const [selRows, setSelRows] = useState(() => /* @__PURE__ */ new Set());
1072
+ const divRef = useRef(null);
1073
+ useImperativeHandle(ref, () => ({
1074
+ onClickIntro: handleIntro,
1075
+ current: divRef.current
1076
+ }));
1077
+ const columnsGrid = useMemo(() => [{
1078
+ key: "name",
1079
+ name: getLabel("grid.settings_column_name"),
1080
+ width: 200,
1081
+ resizable: true,
1082
+ type: "text"
1083
+ }, {
1084
+ key: "originalIndex",
1085
+ name: getLabel("grid.settings_column_position"),
1086
+ width: 50,
1087
+ type: "number",
1088
+ cellClass: "rdg-cell-align-center"
1089
+ }, {
1090
+ key: "visible",
1091
+ name: getLabel("grid.settings_column_visible"),
1092
+ width: 80,
1093
+ type: "boolean",
1094
+ formatter: FormatterColumn,
1095
+ cellClass: "rdg-cell-align-center"
1096
+ }, {
1097
+ key: "frozen",
1098
+ name: getLabel("grid.settings_column_frozen"),
1099
+ width: 80,
1100
+ type: "boolean",
1101
+ formatter: FormatterColumn,
1102
+ cellClass: "rdg-cell-align-center"
1103
+ }], [getLabel]);
1104
+ const checkAll = () => {
1105
+ setRows(rows.map((row) => ({
1106
+ ...row,
1107
+ visible: true
1108
+ })));
1109
+ };
1110
+ const unCheckAll = () => {
1111
+ setRows(rows.map((row) => ({
1112
+ ...row,
1113
+ visible: false
1114
+ })));
1115
+ };
1116
+ const restoreAll = () => {
1117
+ setRows(rows.map((row) => ({
1118
+ ...row,
1119
+ visible: row.originalVisible,
1120
+ frozen: row.originalFrozen,
1121
+ index: row.originalIndex
1122
+ })).sort((a, b) => a.index - b.index));
1123
+ };
1124
+ useEffect(() => {
1125
+ if (isInit === false) {
1126
+ setRows(getRowsFromColumnsConfig(columnsConfig));
1127
+ }
1128
+ setIsInit(false);
1129
+ }, [columnsConfig]);
1130
+ const rowSelectedIndex = useMemo(() => {
1131
+ let rowIndex = -1;
1132
+ if (selRows.size !== 1)
1133
+ return rowIndex;
1134
+ const iterator = selRows.entries();
1135
+ const entry = iterator.next().value[1];
1136
+ rowIndex = rows.findIndex((row) => row.key === entry);
1137
+ return rowIndex;
1138
+ }, [rows, selRows]);
1139
+ const handleMoveFirst = () => {
1140
+ if (rowSelectedIndex === -1)
1141
+ return -1;
1142
+ const newRows = [...rows];
1143
+ newRows.splice(rowSelectedIndex, 1);
1144
+ newRows.splice(0, 0, rows[rowSelectedIndex]);
1145
+ refGrid.current?.selectCell({
1146
+ idx: 0,
1147
+ rowIdx: 0
1148
+ });
1149
+ setRows(newRows);
1150
+ };
1151
+ const handleMoveLast = () => {
1152
+ if (rowSelectedIndex === -1)
1153
+ return -1;
1154
+ const newRows = [...rows];
1155
+ newRows.splice(rowSelectedIndex, 1);
1156
+ newRows.splice(newRows.length, 0, rows[rowSelectedIndex]);
1157
+ refGrid.current?.selectCell({
1158
+ idx: 0,
1159
+ rowIdx: newRows.length - 1
1160
+ });
1161
+ setRows(newRows);
1162
+ };
1163
+ const handleMoveUpDownd = (position) => {
1164
+ if (rowSelectedIndex === -1)
1165
+ return -1;
1166
+ const newRows = [...rows];
1167
+ const element = newRows[rowSelectedIndex];
1168
+ newRows.splice(rowSelectedIndex, 1);
1169
+ newRows.splice(rowSelectedIndex + position, 0, element);
1170
+ refGrid.current?.selectCell({
1171
+ idx: 0,
1172
+ rowIdx: rowSelectedIndex + position
1173
+ });
1174
+ setRows(newRows);
1175
+ };
1176
+ const getColumnConfigByKey2 = (key) => {
1177
+ const rowIndexFinded = rows.findIndex((row) => row.key === key);
1178
+ if (rowIndexFinded > -1) {
1179
+ return {
1180
+ visible: rows[rowIndexFinded].visible,
1181
+ frozen: rows[rowIndexFinded].frozen
1182
+ };
1183
+ }
1184
+ return void 0;
1185
+ };
1186
+ const getRowIndex = (column) => {
1187
+ const rowIndexFinded = rows.findIndex((row) => row.key === column.key);
1188
+ if (rowIndexFinded > -1) {
1189
+ return rowIndexFinded;
1190
+ }
1191
+ return columnsConfig.findIndex((columnConfig) => columnConfig.key === column.key);
1192
+ };
1193
+ const handleIntro = () => {
1194
+ const newColumnsConfig = columnsConfig.map((columnConfig) => {
1195
+ const newColumnConfig = {
1196
+ ...columnConfig
1197
+ };
1198
+ if (!columnConfig.hidden) {
1199
+ const columnConfigRow = getColumnConfigByKey2(columnConfig.key);
1200
+ if (columnConfigRow) {
1201
+ newColumnConfig.visible = columnConfigRow.visible;
1202
+ newColumnConfig.frozen = columnConfigRow.frozen;
1203
+ }
1204
+ }
1205
+ return newColumnConfig;
1206
+ }).sort((a, b) => getRowIndex(a) - getRowIndex(b));
1207
+ onChangeColumnsConfig(newColumnsConfig);
1208
+ onCloseSettings();
1209
+ };
1210
+ const onInternalSelectedRowsChange = () => {
1211
+ };
1212
+ const onInternalRowsChange = (newRows) => {
1213
+ setRows(newRows);
1214
+ };
1215
+ const onRowClick = (row) => {
1216
+ if (selRows.has(row.key))
1217
+ return;
1218
+ const mySet = /* @__PURE__ */ new Set([row.key]);
1219
+ setSelRows(mySet);
1220
+ };
1221
+ return /* @__PURE__ */ jsxs(WrapperColumnsConfig, {
1222
+ id: "WrapperColumnsConfig",
1223
+ ref: divRef,
1224
+ children: [/* @__PURE__ */ jsx(DivSelColumns, {
1225
+ id: "divInfo",
1226
+ children: getLabel("grid.settings_sel_columns")
1227
+ }), /* @__PURE__ */ jsx(WrapperGrid, {
1228
+ id: "WrapperGrid",
1229
+ children: /* @__PURE__ */ jsx(OriginalGridWrapperStyled, {
1230
+ id: "OriginalGridWrapperStyled",
1231
+ children: /* @__PURE__ */ jsx(DataGrid$1, {
1232
+ className: "fill-grid rdg-light",
1233
+ ref: refGrid,
1234
+ columns: columnsGrid,
1235
+ rows,
1236
+ onRowsChange: onInternalRowsChange,
1237
+ selectedRows: selRows,
1238
+ onSelectedRowsChange: onInternalSelectedRowsChange,
1239
+ onRowClick,
1240
+ rowKeyGetter: (row) => row.key,
1241
+ cellNavigationMode: "CHANGE_ROW",
1242
+ defaultColumnOptions: {
1243
+ resizable: true,
1244
+ sortable: true
1245
+ }
1246
+ })
1247
+ })
1248
+ }), /* @__PURE__ */ jsxs(ColumnActions, {
1249
+ children: [/* @__PURE__ */ jsx(IconButton, {
1250
+ dictionaryTooltip: "grid.settings_move_first",
1251
+ onClick: handleMoveFirst,
1252
+ "aria-label": "move first place",
1253
+ disabled: rowSelectedIndex < 1,
1254
+ src: "components/grid/assets/icons/move_first_place.svg"
1255
+ }), /* @__PURE__ */ jsx(IconButton, {
1256
+ dictionaryTooltip: "grid.settings_move_up",
1257
+ onClick: () => handleMoveUpDownd(-1),
1258
+ "aria-label": "move up place",
1259
+ disabled: rowSelectedIndex < 1,
1260
+ src: "components/grid/assets/icons/move_up_place.svg"
1261
+ }), /* @__PURE__ */ jsx(IconButton, {
1262
+ dictionaryTooltip: "grid.settings_move_last",
1263
+ onClick: handleMoveLast,
1264
+ "aria-label": "move last place",
1265
+ disabled: !!(rowSelectedIndex === rows.length - 1 || rowSelectedIndex === -1),
1266
+ src: "components/grid/assets/icons/move_last_place.svg"
1267
+ }), /* @__PURE__ */ jsx(IconButton, {
1268
+ dictionaryTooltip: "grid.settings_move_down",
1269
+ onClick: () => handleMoveUpDownd(1),
1270
+ "aria-label": "move down place",
1271
+ disabled: !!(rowSelectedIndex === rows.length - 1 || rowSelectedIndex === -1),
1272
+ src: "components/grid/assets/icons/move_down_place.svg"
1273
+ }), /* @__PURE__ */ jsx(IconButton, {
1274
+ dictionaryTooltip: "grid.settings_visible_all",
1275
+ onClick: checkAll,
1276
+ "aria-label": "check visible all",
1277
+ src: "components/grid/assets/icons/check_all.svg"
1278
+ }), /* @__PURE__ */ jsx(IconButton, {
1279
+ dictionaryTooltip: "grid.settings_no_visible_all",
1280
+ onClick: unCheckAll,
1281
+ "aria-label": "un check all",
1282
+ src: "components/grid/assets/icons/uncheck_all.svg"
1283
+ }), /* @__PURE__ */ jsx(IconButton, {
1284
+ dictionaryTooltip: "grid.settings_restore",
1285
+ onClick: restoreAll,
1286
+ "aria-label": "Restore columns",
1287
+ src: "components/grid/assets/icons/restore_columns.svg"
1288
+ })]
1289
+ })]
1290
+ });
1291
+ });
1292
+ ColumnsConfig.displayName = "ColumnsConfig";
1293
+ const SKTWrapperColumnsSettings = styled("div")(({ theme }) => ({
1294
+ display: "flex",
1295
+ justifyContent: "center",
1296
+ alignItems: "center",
1297
+ minWidth: theme.spacing(3.75),
1298
+ height: theme.spacing(3.75)
1299
+ }));
1300
+ function Settings() {
1301
+ const {
1302
+ openModal,
1303
+ closeModal
1304
+ } = useModal();
1305
+ const {
1306
+ columnsConfig,
1307
+ onChangeColumnsConfig,
1308
+ isSkeleton
1309
+ } = useBase();
1310
+ const {
1311
+ getLabel
1312
+ } = useModuleDictionary();
1313
+ const {
1314
+ host_static_assets,
1315
+ environment
1316
+ } = useEnvironment();
1317
+ const ref = useRef(null);
1318
+ const onCloseSettings = useCallback(() => {
1319
+ closeModal();
1320
+ }, [closeModal]);
1321
+ const onClickIntro = useCallback(() => {
1322
+ if (ref.current?.onClickIntro) {
1323
+ ref.current?.onClickIntro();
1324
+ }
1325
+ }, []);
1326
+ const onClickSettings = useCallback(() => {
1327
+ openModal({
1328
+ onQueryClose: () => closeModal(),
1329
+ title: "grid.settings_tooltip",
1330
+ initialWidth: 500,
1331
+ initialHeigth: 680,
1332
+ contentComponent: /* @__PURE__ */ jsx(ColumnsConfig, {
1333
+ ref,
1334
+ columnsConfig,
1335
+ onChangeColumnsConfig,
1336
+ onCloseSettings
1337
+ }),
1338
+ actionComponents: void 0,
1339
+ standardActions: {
1340
+ withCancel: true,
1341
+ onClickIntro
1342
+ }
1343
+ });
1344
+ }, [closeModal, columnsConfig, getLabel, onChangeColumnsConfig, onCloseSettings, openModal, onClickIntro]);
1345
+ if (isSkeleton) {
1346
+ return /* @__PURE__ */ jsx(SKTWrapperColumnsSettings, {
1347
+ children: /* @__PURE__ */ jsx(Skeleton, {
1348
+ variant: "circular",
1349
+ width: 20,
1350
+ height: 20
1351
+ })
1352
+ });
1353
+ }
1354
+ return /* @__PURE__ */ jsx(IconButton, {
1355
+ dictionaryTooltip: "grid.settings_tooltip",
1356
+ onClick: onClickSettings,
1357
+ "aria-label": "settings",
1358
+ src: `${host_static_assets}/${environment}/frontend/components/grid/assets/icons/configuration.svg`
1359
+ });
1360
+ }
1361
+ const Container = styled("div")(() => ({
1362
+ display: "flex",
1363
+ alignItems: "center"
1364
+ }));
1365
+ const RowsLabel = styled("span")(() => ({}));
1366
+ const InsetLabel = styled("span")(({ theme }) => ({
1367
+ marginLeft: theme.spacing(2),
1368
+ paddingTop: "2px",
1369
+ paddingBottom: "2px",
1370
+ paddingLeft: "4px",
1371
+ paddingRight: "4px",
1372
+ border: `1px solid ${theme.palette.divider}`
1373
+ }));
1374
+ function RowsCount() {
1375
+ const {
1376
+ rowsCount,
1377
+ isSkeleton
1378
+ } = useBase();
1379
+ const {
1380
+ getLabel
1381
+ } = useModuleDictionary();
1382
+ if (isSkeleton) {
1383
+ return /* @__PURE__ */ jsxs(Container, {
1384
+ children: [/* @__PURE__ */ jsx(RowsLabel, {
1385
+ children: /* @__PURE__ */ jsx(Skeleton, {
1386
+ variant: "text",
1387
+ width: "40px",
1388
+ height: "16px"
1389
+ })
1390
+ }), /* @__PURE__ */ jsx(InsetLabel, {
1391
+ children: /* @__PURE__ */ jsx(Skeleton, {
1392
+ variant: "text",
1393
+ width: "20px",
1394
+ height: "16px"
1395
+ })
1396
+ })]
1397
+ });
1398
+ }
1399
+ return /* @__PURE__ */ jsxs(Container, {
1400
+ className: "rows-count",
1401
+ id: "RowsCount",
1402
+ children: [/* @__PURE__ */ jsx(RowsLabel, {
1403
+ children: getLabel("grid.rows")
1404
+ }), /* @__PURE__ */ jsx(InsetLabel, {
1405
+ children: rowsCount
1406
+ })]
1407
+ });
1408
+ }
1409
+ const WrapperDensity = styled("div")(({ theme }) => ({
1410
+ marginLeft: 0,
1411
+ [theme.breakpoints.up("sm")]: {
1412
+ marginLeft: theme.spacing(3)
1413
+ }
1414
+ }));
1415
+ const SKTWrapperDensity = styled("div")(({ theme }) => ({
1416
+ display: "flex",
1417
+ justifyContent: "center",
1418
+ alignItems: "center",
1419
+ minWidth: theme.spacing(3.75),
1420
+ height: theme.spacing(3.75)
1421
+ }));
1422
+ function Density() {
1423
+ const {
1424
+ host_static_assets,
1425
+ environment
1426
+ } = useEnvironment();
1427
+ const {
1428
+ rowHeights,
1429
+ currentRowHeightVariant,
1430
+ setRowHeightVariant,
1431
+ isSkeleton
1432
+ } = useBase();
1433
+ const {
1434
+ getLabel
1435
+ } = useModuleDictionary();
1436
+ const menuActions = useMemo(() => {
1437
+ if (typeof rowHeights === "number") {
1438
+ return [];
1439
+ }
1440
+ return [{
1441
+ urlIcon: `${host_static_assets}/${environment}/frontend/components/grid/assets/icons/compact.svg`,
1442
+ onClick: () => setRowHeightVariant("compact"),
1443
+ disabled: currentRowHeightVariant === "compact",
1444
+ dictionaryField: "grid.density_compact"
1445
+ }, {
1446
+ urlIcon: `${host_static_assets}/${environment}/frontend/components/grid/assets/icons/standard.svg`,
1447
+ onClick: () => setRowHeightVariant("standard"),
1448
+ disabled: currentRowHeightVariant === "standard",
1449
+ dictionaryField: "grid.density_standard"
1450
+ }, {
1451
+ urlIcon: `${host_static_assets}/${environment}/frontend/components/grid/assets/icons/confortable.svg`,
1452
+ onClick: () => setRowHeightVariant("confortable"),
1453
+ disabled: currentRowHeightVariant === "confortable",
1454
+ dictionaryField: "grid.density_confortable"
1455
+ }];
1456
+ }, [rowHeights, currentRowHeightVariant, setRowHeightVariant, host_static_assets, environment]);
1457
+ const currenViewIcon = useMemo(() => {
1458
+ if (currentRowHeightVariant === "compact") {
1459
+ return `${host_static_assets}/${environment}/frontend/components/grid/assets/icons/compact.svg`;
1460
+ }
1461
+ if (currentRowHeightVariant === "standard") {
1462
+ return `${host_static_assets}/${environment}/frontend/components/grid/assets/icons/standard.svg`;
1463
+ }
1464
+ return `${host_static_assets}/${environment}/frontend/components/grid/assets/icons/confortable.svg`;
1465
+ }, [currentRowHeightVariant, host_static_assets, environment]);
1466
+ if (menuActions.length === 0) {
1467
+ return /* @__PURE__ */ jsx(Fragment, {});
1468
+ }
1469
+ if (isSkeleton) {
1470
+ return /* @__PURE__ */ jsx(SKTWrapperDensity, {
1471
+ children: /* @__PURE__ */ jsx(Skeleton, {
1472
+ variant: "circular",
1473
+ width: "20px",
1474
+ height: "20px"
1475
+ })
1476
+ });
1477
+ }
1478
+ return /* @__PURE__ */ jsx(WrapperDensity, {
1479
+ id: "WrapperDensity",
1480
+ children: /* @__PURE__ */ jsx(MenuActions$1, {
1481
+ arrow: "right-top",
1482
+ anchorOrigin: {
1483
+ vertical: "top",
1484
+ horizontal: "left"
1485
+ },
1486
+ transformOrigin: {
1487
+ vertical: "top",
1488
+ horizontal: "right"
1489
+ },
1490
+ menuActions,
1491
+ urlIcon: currenViewIcon,
1492
+ toolTip: getLabel("grid.density_tooltip")
1493
+ })
1494
+ });
1495
+ }
1496
+ const WrapperActions = styled("div")(({ theme }) => ({
1497
+ ...theme.typography.caption,
1498
+ position: "absolute",
1499
+ left: "0px",
1500
+ right: "0px",
1501
+ top: "0px",
1502
+ height: theme.spacing(5.5),
1503
+ padding: 0,
1504
+ display: "flex",
1505
+ flexDirection: "row",
1506
+ alignItems: "center",
1507
+ justifyContent: "flex-end",
1508
+ [theme.breakpoints.up("sm")]: {
1509
+ padding: theme.spacing(0, 1.5)
1510
+ },
1511
+ "&.with-no-pager .rows-count": {
1512
+ flexGrow: 1
1513
+ },
1514
+ "& .MuiTablePagination-root": {
1515
+ flexGrow: 1,
1516
+ display: "flex",
1517
+ justifyContent: "center",
1518
+ overflow: "hidden"
1519
+ }
1520
+ }));
1521
+ function Actions(props) {
1522
+ const isDesktop = useResponsiveDesktop();
1523
+ const {
1524
+ rowHeights,
1525
+ isSkeleton
1526
+ } = useBase();
1527
+ const {
1528
+ withRowsCount = true,
1529
+ withPager = true,
1530
+ pagerOptions,
1531
+ withSettings = true,
1532
+ settingsProps,
1533
+ withLocalFilters
1534
+ } = props;
1535
+ return /* @__PURE__ */ jsxs(WrapperActions, {
1536
+ id: "WrapperActions",
1537
+ className: withPager && pagerOptions ? "with-pager" : "with-no-pager",
1538
+ children: [withRowsCount && isDesktop && /* @__PURE__ */ jsx(RowsCount, {}), withPager && pagerOptions && /* @__PURE__ */ jsx(Pager, {
1539
+ ...pagerOptions,
1540
+ totalRecords: pagerOptions.totalRecords,
1541
+ isSkeleton
1542
+ }), typeof rowHeights !== "number" && /* @__PURE__ */ jsx(Density, {}), withSettings && /* @__PURE__ */ jsx(Settings, {
1543
+ ...settingsProps
1544
+ }), withLocalFilters && /* @__PURE__ */ jsx(Filter, {})]
1545
+ });
1546
+ }
1547
+ function DataGrid(props) {
1548
+ const {
1549
+ isSkeleton = false,
1550
+ withActions = true,
1551
+ rows,
1552
+ columns,
1553
+ actionsProps,
1554
+ rowActionsGetter,
1555
+ rowHeaderHeights = [44, 63, 75],
1556
+ rowHeights = [36, 52, 67],
1557
+ initialRowHeightVariant = "compact"
1558
+ } = props;
1559
+ return /* @__PURE__ */ jsx(WrapperGrid$1, {
1560
+ id: `WrapperGrid_${props.id}`,
1561
+ children: /* @__PURE__ */ jsx(BaseProvider, {
1562
+ id: props.id,
1563
+ isSkeleton,
1564
+ columns: props.columns,
1565
+ rowHeights,
1566
+ rowHeaderHeights,
1567
+ initialRowHeightVariant,
1568
+ rowsCount: rows.length,
1569
+ rowActionsGetter,
1570
+ children: /* @__PURE__ */ jsxs(FilterProvider, {
1571
+ initialActiveFilters: false,
1572
+ children: [withActions && actionsProps && /* @__PURE__ */ jsx(Actions, {
1573
+ ...actionsProps
1574
+ }), /* @__PURE__ */ jsx(Table, {
1575
+ id: props.id,
1576
+ withActions,
1577
+ columns,
1578
+ rows,
1579
+ isMultipleSelect: props.isMultipleSelect,
1580
+ selectedRows: props.selectedRows,
1581
+ rowKeyGetter: props.rowKeyGetter,
1582
+ onRowsSelectedChange: props.onRowsSelectedChange
1583
+ })]
1584
+ })
1585
+ })
1586
+ });
1587
+ }
1588
+ function DateFormatter(props) {
1589
+ const {
1590
+ presentationType,
1591
+ dateTime,
1592
+ formatDate
1593
+ } = props;
1594
+ let finalFormat = formatDate || "yyyy-MM-dd HH:mm:ss";
1595
+ let result;
1596
+ let resultDate;
1597
+ if (presentationType === "date") {
1598
+ finalFormat = formatDate || "yyyy-MM-dd";
1599
+ } else if (presentationType === "time") {
1600
+ finalFormat = formatDate || "HH:mm:ss";
1601
+ }
1602
+ try {
1603
+ if (typeof dateTime === "number") {
1604
+ resultDate = new Date(dateTime);
1605
+ } else if (typeof dateTime === "string") {
1606
+ resultDate = new Date(Date.parse(dateTime));
1607
+ } else {
1608
+ resultDate = dateTime;
1609
+ }
1610
+ result = format(resultDate, finalFormat);
1611
+ } catch (e) {
1612
+ result = "err_typing";
1613
+ }
1614
+ return /* @__PURE__ */ jsx(Fragment, {
1615
+ children: result
1616
+ });
1617
+ }
1618
+ const initialPagerState = {
1619
+ page: 0,
1620
+ rowsPerPage: 25,
1621
+ totalRecords: 0
1622
+ };
1623
+ export { DateFormatter as D, DataGrid as a, initialPagerState as i };