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