@m4l/components 0.1.27 → 0.1.28

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 (93) hide show
  1. package/assets/Logo/index.228dcb5a.js +42 -35
  2. package/commonjs.565e6834.js +5 -5
  3. package/components/CommonActions/components/ActionCancel/index.e498eeb2.js +17 -0
  4. package/components/CommonActions/components/ActionFormCancel/index.4ff0ad73.js +64 -0
  5. package/components/CommonActions/components/ActionFormIntro/index.ca4d2674.js +28 -22
  6. package/components/CommonActions/components/ActionIntro/index.60ef7bd7.js +18 -0
  7. package/components/CommonActions/components/Actions/index.0645e30f.js +867 -0
  8. package/components/DataGrid/index.76d8fd25.js +1075 -0
  9. package/components/DynamicFilter/index.342ba5fe.js +1577 -0
  10. package/components/ErrorLabel/index.c8615f16.js +13 -12
  11. package/components/Icon/index.619c31c4.js +65 -53
  12. package/components/Image/index.93d5f37f.js +190 -0
  13. package/components/Loadable/index.f5518558.js +8 -8
  14. package/components/ModalDialog/index.9ea10764.js +184 -0
  15. package/components/NoItemSelected/{index.9609a7f7.js → index.46d2f632.js} +52 -41
  16. package/components/ObjectLogs/index.f941fb79.js +288 -0
  17. package/components/Page/index.4237c241.js +22 -20
  18. package/components/PaperForm/index.ec9cb8c9.js +66 -59
  19. package/components/Period/index.2941fbda.js +249 -0
  20. package/components/PropertyValue/index.dfcfe1ba.js +95 -65
  21. package/components/Resizeable/index.45995d2b.js +19 -19
  22. package/components/ScrollBar/index.39eeb2de.js +26 -21
  23. package/components/ScrollToTop/index.e06f98f6.js +8 -7
  24. package/components/SplitLayout/index.4032673d.js +35 -33
  25. package/components/animate/LoadingScreen/index.1d0c4307.js +33 -33
  26. package/components/animate/MotionContainer/index.8d9f9d80.js +25 -22
  27. package/components/animate/MotionLazyContainer/index.572dd012.js +10 -10
  28. package/components/animate/features.0fbf41e1.js +3 -3
  29. package/components/animate/variants/bounce.784aaaaa.js +16 -13
  30. package/components/animate/variants/container.11f82b76.js +8 -6
  31. package/components/animate/variants/fade.b561c0fc.js +32 -28
  32. package/components/animate/variants/transition.bd46b9ce.js +17 -12
  33. package/components/formatters/BooleanFormatter/index.8da35c9c.js +46 -33
  34. package/components/formatters/DateFormatter/index.1b9baacc.js +49 -37
  35. package/components/formatters/index.689a8086.js +119 -0
  36. package/components/hook-form/RHFAutocomplete/index.59a68f9f.js +224 -0
  37. package/components/hook-form/RHFAutocompleteAsync/index.c3083062.js +87 -0
  38. package/components/hook-form/RHFCheckbox/index.6dcec9e2.js +49 -39
  39. package/components/hook-form/RHFDateTime/index.9231a7c7.js +69 -56
  40. package/components/hook-form/RHFMultiCheckbox/index.2680b3b6.js +23 -23
  41. package/components/hook-form/RHFPeriod/index.64a228d5.js +55 -0
  42. package/components/hook-form/RHFRadioGroup/index.b3335e13.js +29 -29
  43. package/components/hook-form/RHFSelect/index.b6ca8bb2.js +24 -24
  44. package/components/hook-form/RHFTextField/index.f9aaaa90.js +110 -93
  45. package/components/hook-form/RHFUpload/{index.ec4d5326.js → index.d5cc7c13.js} +151 -130
  46. package/components/mui_extended/Accordion/index.a02ac6ae.js +73 -69
  47. package/components/mui_extended/Avatar/index.fe06afd7.js +44 -34
  48. package/components/mui_extended/BoxIcon/index.e638ecc8.js +10 -10
  49. package/components/mui_extended/Breadcrumbs/index.5e37d903.js +49 -44
  50. package/components/mui_extended/Button/index.53b56958.js +178 -0
  51. package/components/mui_extended/CircularProgress/index.ad569afd.js +8 -6
  52. package/components/mui_extended/IconButton/index.a321e5cb.js +82 -67
  53. package/components/mui_extended/LinkWithRoute/index.16436ab8.js +25 -21
  54. package/components/mui_extended/Pager/index.c0865b70.js +141 -0
  55. package/components/mui_extended/Popover/index.705275a4.js +278 -0
  56. package/components/mui_extended/Tab/index.e0653a0a.js +25 -21
  57. package/components/mui_extended/Typography/index.e5494696.js +25 -21
  58. package/contexts/ModalContext/index.b92fa565.js +153 -0
  59. package/contexts/ModalContext/{components → subcomponents}/ContentConfirm/index.d.ts +0 -0
  60. package/contexts/ModalContext/{components → subcomponents}/ContentConfirm/styles.d.ts +0 -0
  61. package/contexts/ModalContext/{components → subcomponents}/ContentConfirm/types.d.ts +0 -0
  62. package/contexts/RHFormContext/index.b142190a.js +63 -0
  63. package/hooks/useFormAddEdit/index.d4845f1a.js +40 -22
  64. package/hooks/useModal/index.5fee01a3.js +11 -0
  65. package/index.js +153 -153
  66. package/package.json +2 -1
  67. package/react-data-grid.d46d625e.js +2206 -1663
  68. package/react-draggable.20e95c61.js +800 -553
  69. package/react-json-view.f56a7f8e.js +2344 -2340
  70. package/react-resizable.5277deaf.js +470 -298
  71. package/react-splitter-layout.7810ac1b.js +130 -128
  72. package/utils/index.214d9542.js +500 -354
  73. package/components/CommonActions/components/ActionCancel/index.431160ba.js +0 -17
  74. package/components/CommonActions/components/ActionFormCancel/index.6a0f34aa.js +0 -49
  75. package/components/CommonActions/components/ActionIntro/index.85557b90.js +0 -18
  76. package/components/CommonActions/components/Actions/index.edeb05c2.js +0 -742
  77. package/components/DataGrid/index.2ce9da7d.js +0 -894
  78. package/components/DynamicFilter/index.e1d4a948.js +0 -1157
  79. package/components/Image/index.c9da2d5a.js +0 -152
  80. package/components/ModalDialog/index.ad61757f.js +0 -168
  81. package/components/ObjectLogs/index.6ebaec71.js +0 -266
  82. package/components/Period/index.81de7941.js +0 -175
  83. package/components/contexts/RHFormContext/index.33dba822.js +0 -56
  84. package/components/formatters/index.c2a9b55d.js +0 -106
  85. package/components/hook-form/RHFAutocomplete/index.5eee9d7c.js +0 -174
  86. package/components/hook-form/RHFAutocompleteAsync/index.757b5080.js +0 -65
  87. package/components/hook-form/RHFPeriod/index.e08fb1ab.js +0 -51
  88. package/components/mui_extended/Button/index.51dae0bb.js +0 -144
  89. package/components/mui_extended/Pager/index.1dc45f5e.js +0 -126
  90. package/components/mui_extended/Popover/index.cb2ccc66.js +0 -252
  91. package/contexts/ModalContext/index.9ebc793c.js +0 -136
  92. package/hooks/useModal/index.34f5978e.js +0 -11
  93. package/node_modules.168cb897.js +0 -55
@@ -0,0 +1,867 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { styled } from "@mui/material/styles";
3
+ import { useEnvironment, useModuleDictionary } from "@m4l/core";
4
+ import { IconButton, Tooltip, MenuItem, Skeleton, Checkbox } from "@mui/material";
5
+ import "@mui/material/Button";
6
+ import "react-hook-form";
7
+ import "react-router-dom";
8
+ import { useState, useMemo, forwardRef, useRef, useImperativeHandle, useEffect, useCallback } from "react";
9
+ import "../../../../contexts/ModalContext/index.b92fa565.js";
10
+ import "@mui/lab";
11
+ import { I as IconButton$1 } from "../../../mui_extended/IconButton/index.a321e5cb.js";
12
+ import { u as useBase, a as useFilters, O as OriginalDataGridWrapperStyled } from "../../../DataGrid/index.76d8fd25.js";
13
+ import { P as Pager } from "../../../mui_extended/Pager/index.c0865b70.js";
14
+ import { D as DataGrid$1 } from "../../../../react-data-grid.d46d625e.js";
15
+ import { u as useModal } from "../../../../hooks/useModal/index.5fee01a3.js";
16
+ import { A as ActionCancel } from "../ActionCancel/index.e498eeb2.js";
17
+ import { A as ActionIntro } from "../ActionIntro/index.60ef7bd7.js";
18
+ import { P as Popover } from "../../../mui_extended/Popover/index.705275a4.js";
19
+ import { I as Icon } from "../../../Icon/index.619c31c4.js";
20
+ import { useResponsiveDesktop } from "@m4l/graphics";
21
+ const WrapperStandarActions = styled("div")(({
22
+ theme
23
+ }) => ({
24
+ paddingTop: theme.spacing(3),
25
+ margin: theme.spacing(0, 1.5),
26
+ display: "flex",
27
+ flexDirection: "row",
28
+ justifyContent: "flex-end",
29
+ "& > button": {
30
+ marginLeft: "10px"
31
+ }
32
+ }));
33
+ const Actions$1 = (props) => {
34
+ const {
35
+ children
36
+ } = props;
37
+ return /* @__PURE__ */ jsx(WrapperStandarActions, {
38
+ id: "WrapperStandarActions",
39
+ children
40
+ });
41
+ };
42
+ function getCommonActionsDictionary() {
43
+ return ["common_actions"];
44
+ }
45
+ const defaultCommonActionsDictionary = {
46
+ common_actions: {
47
+ cancel: "Cancel",
48
+ intro: "Intro",
49
+ confirm_quit_title: "Confirm",
50
+ confirm_quit_msg: "Are your sure exit?"
51
+ }
52
+ };
53
+ const WrapperMenuActions = styled(IconButton)(() => ({}));
54
+ const LabelMemuItem = styled("div")(({
55
+ theme
56
+ }) => ({
57
+ height: "22px",
58
+ marginLeft: theme.spacing(1.5),
59
+ display: "flex",
60
+ alignItems: "center"
61
+ }));
62
+ function MenuActions(props) {
63
+ const {
64
+ menuActions,
65
+ objItem = {},
66
+ urlIcon,
67
+ toolTip = "",
68
+ marginTop = -1,
69
+ marginBottom,
70
+ marginLeft,
71
+ marginRight,
72
+ width = 200,
73
+ arrowType: arrow = "right-top",
74
+ ...other
75
+ } = props;
76
+ const {
77
+ host_static_assets,
78
+ environment_assets
79
+ } = useEnvironment();
80
+ const {
81
+ getLabel
82
+ } = useModuleDictionary();
83
+ const [open, setOpen] = useState(null);
84
+ const handleOpen = (event) => {
85
+ setOpen(event.currentTarget);
86
+ };
87
+ const urlFinalIcon = useMemo(() => {
88
+ if (urlIcon)
89
+ return urlIcon;
90
+ return `${host_static_assets}/${environment_assets}/frontend/commons/assets/icons/more_vertical.svg`;
91
+ }, [urlIcon, host_static_assets, environment_assets]);
92
+ const handleClose = () => {
93
+ setOpen(null);
94
+ };
95
+ const handleClick = (menuAction) => {
96
+ setOpen(null);
97
+ menuAction.onClick();
98
+ };
99
+ const finalActions = useMemo(() => {
100
+ let ret;
101
+ if (typeof menuActions !== "function") {
102
+ ret = menuActions;
103
+ } else {
104
+ ret = menuActions(objItem);
105
+ }
106
+ return ret;
107
+ }, [menuActions, objItem]);
108
+ return /* @__PURE__ */ jsxs(Fragment, {
109
+ children: [/* @__PURE__ */ jsx(Tooltip, {
110
+ title: toolTip,
111
+ children: /* @__PURE__ */ jsx(WrapperMenuActions, {
112
+ id: "WrapperMenuActions",
113
+ size: "small",
114
+ onClick: handleOpen,
115
+ children: /* @__PURE__ */ jsx(Icon, {
116
+ src: urlFinalIcon
117
+ })
118
+ })
119
+ }), /* @__PURE__ */ jsx(Popover, {
120
+ id: "Popover",
121
+ open: Boolean(open),
122
+ anchorEl: open,
123
+ onClose: handleClose,
124
+ arrowType: arrow,
125
+ sx: {
126
+ marginTop,
127
+ marginBottom,
128
+ marginLeft,
129
+ marginRight,
130
+ width,
131
+ "& .MuiMenuItem-root": {
132
+ px: 1,
133
+ typography: "body2",
134
+ borderRadius: 0.75
135
+ }
136
+ },
137
+ ...other,
138
+ children: open && finalActions.map((menuAction, index) => /* @__PURE__ */ jsxs(MenuItem, {
139
+ dense: true,
140
+ onClick: () => handleClick(menuAction),
141
+ sx: {
142
+ color: menuAction.color ?? "text.main"
143
+ },
144
+ disabled: menuAction.disabled,
145
+ children: [/* @__PURE__ */ jsx(Icon, {
146
+ src: menuAction.urlIcon
147
+ }), /* @__PURE__ */ jsx(LabelMemuItem, {
148
+ children: getLabel(menuAction.dictionaryField)
149
+ })]
150
+ }, `menu_action_${index}`))
151
+ })]
152
+ });
153
+ }
154
+ const WrapperPagerActions = styled("div")(({ theme }) => ({
155
+ width: "100%",
156
+ justifyContent: "center",
157
+ display: "flex",
158
+ marginLeft: 0,
159
+ [theme.breakpoints.up("sm")]: {
160
+ display: "flex",
161
+ alignItems: "center",
162
+ marginLeft: theme.spacing(3)
163
+ }
164
+ }));
165
+ function PagerActions(props) {
166
+ const {
167
+ count,
168
+ page,
169
+ rowsPerPage,
170
+ onPageChange
171
+ } = props;
172
+ const {
173
+ host_static_assets,
174
+ environment_assets
175
+ } = useEnvironment();
176
+ const handleFirstPageButtonClick = (event) => {
177
+ onPageChange(event, 0);
178
+ };
179
+ const handleBackButtonClick = (event) => {
180
+ onPageChange(event, page - 1);
181
+ };
182
+ const handleNextButtonClick = (event) => {
183
+ onPageChange(event, page + 1);
184
+ };
185
+ const handleLastPageButtonClick = (event) => {
186
+ onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
187
+ };
188
+ return /* @__PURE__ */ jsxs(WrapperPagerActions, {
189
+ id: "WrapperPagerActions",
190
+ children: [/* @__PURE__ */ jsx(IconButton$1, {
191
+ id: "test_bruce",
192
+ dictionaryTooltip: "pager.first",
193
+ onClick: handleFirstPageButtonClick,
194
+ disabled: page === 0,
195
+ "aria-label": "first page",
196
+ src: `${host_static_assets}/${environment_assets}/frontend/components/pager/assets/icons/first.svg`
197
+ }), /* @__PURE__ */ jsx(IconButton$1, {
198
+ dictionaryTooltip: "pager.previous",
199
+ onClick: handleBackButtonClick,
200
+ disabled: page === 0,
201
+ "aria-label": "first page",
202
+ src: `${host_static_assets}/${environment_assets}/frontend/components/pager/assets/icons/previous.svg`
203
+ }), /* @__PURE__ */ jsx(IconButton$1, {
204
+ dictionaryTooltip: "pager.next",
205
+ onClick: handleNextButtonClick,
206
+ disabled: page >= Math.ceil(count / rowsPerPage) - 1,
207
+ "aria-label": "next page",
208
+ src: `${host_static_assets}/${environment_assets}/frontend/components/pager/assets/icons/next.svg`
209
+ }), /* @__PURE__ */ jsx(IconButton$1, {
210
+ dictionaryTooltip: "pager.last",
211
+ onClick: handleLastPageButtonClick,
212
+ disabled: page >= Math.ceil(count / rowsPerPage) - 1,
213
+ "aria-label": "last page",
214
+ src: `${host_static_assets}/${environment_assets}/frontend/components/pager/assets/icons/last.svg`
215
+ })]
216
+ });
217
+ }
218
+ const ACTIONS_COLUMN_KEY = "actions-row";
219
+ function ActionsFormatter(props) {
220
+ const {
221
+ rowActionsGetter
222
+ } = useBase();
223
+ if (rowActionsGetter === void 0) {
224
+ return /* @__PURE__ */ jsx(Fragment, {});
225
+ }
226
+ return /* @__PURE__ */ jsx(MenuActions, {
227
+ arrowType: "top-left",
228
+ objItem: props.row,
229
+ menuActions: rowActionsGetter,
230
+ marginTop: 1,
231
+ marginLeft: "-11px",
232
+ anchorOrigin: {
233
+ vertical: "bottom",
234
+ horizontal: "left"
235
+ },
236
+ transformOrigin: {
237
+ vertical: "top",
238
+ horizontal: "left"
239
+ }
240
+ });
241
+ }
242
+ const ActionsColumn = {
243
+ key: ACTIONS_COLUMN_KEY,
244
+ name: "Actions",
245
+ width: 60,
246
+ withFilter: false,
247
+ resizable: true,
248
+ sortable: false,
249
+ frozen: true,
250
+ type: "custom",
251
+ formatter: ActionsFormatter
252
+ };
253
+ const SKTWrapperFilter = styled("div")(({
254
+ theme
255
+ }) => ({
256
+ display: "flex",
257
+ justifyContent: "center",
258
+ alignItems: "center",
259
+ minWidth: theme.spacing(3.75),
260
+ height: theme.spacing(3.75)
261
+ }));
262
+ function Filter() {
263
+ const {
264
+ isSkeleton
265
+ } = useBase();
266
+ const {
267
+ activeFilters,
268
+ setActiveFilters
269
+ } = useFilters();
270
+ const {
271
+ host_static_assets,
272
+ environment_assets
273
+ } = useEnvironment();
274
+ const toggleIcon = () => {
275
+ setActiveFilters(!activeFilters);
276
+ };
277
+ if (isSkeleton) {
278
+ return /* @__PURE__ */ jsx(SKTWrapperFilter, {
279
+ children: /* @__PURE__ */ jsx(Skeleton, {
280
+ variant: "circular",
281
+ width: 20,
282
+ height: 20
283
+ })
284
+ });
285
+ }
286
+ return /* @__PURE__ */ jsx(IconButton$1, {
287
+ dictionaryTooltip: activeFilters ? "data_grid.tooltip_filter_hide" : "data_grid.tooltip_filter_show",
288
+ onClick: toggleIcon,
289
+ "aria-label": "filter",
290
+ src: `${host_static_assets}/${environment_assets}/frontend/components/data_grid/assets/icons/filter.svg`
291
+ });
292
+ }
293
+ const WrapperColumnsConfig = styled("div")(({ theme }) => ({
294
+ color: theme.palette.text.primary,
295
+ position: "relative",
296
+ display: "flex",
297
+ flexDirection: "column",
298
+ height: "100%",
299
+ width: "100%"
300
+ }));
301
+ styled("div")(({ theme }) => ({
302
+ color: theme.palette.text.primary,
303
+ fontSize: theme.typography.h4.fontSize
304
+ }));
305
+ const DivSelColumns = styled("div")(({ theme }) => ({
306
+ ...theme.typography.subtitle2,
307
+ color: theme.palette.text.primary,
308
+ padding: `${theme.spacing(3)} ${theme.spacing(1)}`
309
+ }));
310
+ const WrapperDataGrid = styled("div")(() => ({
311
+ position: "relative",
312
+ display: "flex",
313
+ flexDirection: "column",
314
+ flexGrow: 1
315
+ }));
316
+ styled("div")(() => ({
317
+ display: "flex",
318
+ flexDirection: "row"
319
+ }));
320
+ const ColumnActions = styled("div")(({ theme }) => ({
321
+ paddingTop: theme.spacing(3),
322
+ display: "flex",
323
+ flexDirection: "row"
324
+ }));
325
+ styled("div")(({ theme }) => ({
326
+ paddingTop: theme.spacing(3),
327
+ display: "flex",
328
+ flexDirection: "row",
329
+ justifyContent: "flex-end",
330
+ "& > button": {
331
+ marginLeft: "10px"
332
+ }
333
+ }));
334
+ function FormatterColumn({
335
+ row,
336
+ onRowChange,
337
+ column
338
+ }) {
339
+ const handleChange = () => {
340
+ const newRow = {
341
+ ...row
342
+ };
343
+ newRow[column.key] = !row[column.key];
344
+ onRowChange(newRow);
345
+ };
346
+ return /* @__PURE__ */ jsx(Checkbox, {
347
+ size: "small",
348
+ checked: row[column.key],
349
+ onChange: handleChange
350
+ });
351
+ }
352
+ function getRowsFromColumnsConfig(columnsConfig) {
353
+ return columnsConfig.filter((column) => !column.hidden).map((column) => ({
354
+ key: column.key,
355
+ name: column.name,
356
+ visible: column.visible === void 0 ? true : column.visible,
357
+ frozen: column.frozen === void 0 ? false : column.frozen,
358
+ originalIndex: column.orginalIndex,
359
+ originalFrozen: column.originalFrozen,
360
+ originalVisible: column.originalVisible
361
+ }));
362
+ }
363
+ const ColumnsConfig = forwardRef((props, ref) => {
364
+ const refdata_grid = useRef(null);
365
+ const {
366
+ onCloseSettings,
367
+ columnsConfig,
368
+ onChangeColumnsConfig
369
+ } = props;
370
+ const {
371
+ getLabel
372
+ } = useModuleDictionary();
373
+ const [isInit, setIsInit] = useState(true);
374
+ const [rows, setRows] = useState(getRowsFromColumnsConfig(columnsConfig));
375
+ const [selRows, setSelRows] = useState(() => /* @__PURE__ */ new Set());
376
+ const divRef = useRef(null);
377
+ const {
378
+ host_static_assets,
379
+ environment_assets
380
+ } = useEnvironment();
381
+ useImperativeHandle(ref, () => ({
382
+ onClickIntro: handleIntro,
383
+ current: divRef.current
384
+ }));
385
+ const columnsdata_grid = useMemo(() => [{
386
+ key: "name",
387
+ name: getLabel("data_grid.settings_column_name"),
388
+ width: 200,
389
+ resizable: true,
390
+ type: "string"
391
+ }, {
392
+ key: "originalIndex",
393
+ name: getLabel("data_grid.settings_column_position"),
394
+ width: 50,
395
+ type: "number",
396
+ cellClass: "rdg-cell-align-center"
397
+ }, {
398
+ key: "visible",
399
+ name: getLabel("data_grid.settings_column_visible"),
400
+ width: 80,
401
+ type: "boolean",
402
+ formatter: FormatterColumn,
403
+ cellClass: "rdg-cell-align-center"
404
+ }, {
405
+ key: "frozen",
406
+ name: getLabel("data_grid.settings_column_frozen"),
407
+ width: 80,
408
+ type: "boolean",
409
+ formatter: FormatterColumn,
410
+ cellClass: "rdg-cell-align-center"
411
+ }], [getLabel]);
412
+ const checkAll = () => {
413
+ setRows(rows.map((row) => ({
414
+ ...row,
415
+ visible: true
416
+ })));
417
+ };
418
+ const unCheckAll = () => {
419
+ setRows(rows.map((row) => ({
420
+ ...row,
421
+ visible: false
422
+ })));
423
+ };
424
+ const restoreAll = () => {
425
+ setRows(rows.map((row) => ({
426
+ ...row,
427
+ visible: row.originalVisible,
428
+ frozen: row.originalFrozen,
429
+ index: row.originalIndex
430
+ })).sort((a, b) => a.index - b.index));
431
+ };
432
+ useEffect(() => {
433
+ if (isInit === false) {
434
+ setRows(getRowsFromColumnsConfig(columnsConfig));
435
+ }
436
+ setIsInit(false);
437
+ }, [columnsConfig]);
438
+ const rowSelectedIndex = useMemo(() => {
439
+ let rowIndex = -1;
440
+ if (selRows.size !== 1)
441
+ return rowIndex;
442
+ const iterator = selRows.entries();
443
+ const entry = iterator.next().value[1];
444
+ rowIndex = rows.findIndex((row) => row.key === entry);
445
+ return rowIndex;
446
+ }, [rows, selRows]);
447
+ const handleMoveFirst = () => {
448
+ if (rowSelectedIndex === -1)
449
+ return -1;
450
+ const newRows = [...rows];
451
+ newRows.splice(rowSelectedIndex, 1);
452
+ newRows.splice(0, 0, rows[rowSelectedIndex]);
453
+ refdata_grid.current?.selectCell({
454
+ idx: 0,
455
+ rowIdx: 0
456
+ });
457
+ setRows(newRows);
458
+ };
459
+ const handleMoveLast = () => {
460
+ if (rowSelectedIndex === -1)
461
+ return -1;
462
+ const newRows = [...rows];
463
+ newRows.splice(rowSelectedIndex, 1);
464
+ newRows.splice(newRows.length, 0, rows[rowSelectedIndex]);
465
+ refdata_grid.current?.selectCell({
466
+ idx: 0,
467
+ rowIdx: newRows.length - 1
468
+ });
469
+ setRows(newRows);
470
+ };
471
+ const handleMoveUpDownd = (position) => {
472
+ if (rowSelectedIndex === -1)
473
+ return -1;
474
+ const newRows = [...rows];
475
+ const element = newRows[rowSelectedIndex];
476
+ newRows.splice(rowSelectedIndex, 1);
477
+ newRows.splice(rowSelectedIndex + position, 0, element);
478
+ refdata_grid.current?.selectCell({
479
+ idx: 0,
480
+ rowIdx: rowSelectedIndex + position
481
+ });
482
+ setRows(newRows);
483
+ };
484
+ const getColumnConfigByKey = (key) => {
485
+ const rowIndexFinded = rows.findIndex((row) => row.key === key);
486
+ if (rowIndexFinded > -1) {
487
+ return {
488
+ visible: rows[rowIndexFinded].visible,
489
+ frozen: rows[rowIndexFinded].frozen
490
+ };
491
+ }
492
+ return void 0;
493
+ };
494
+ const getRowIndex = (column) => {
495
+ const rowIndexFinded = rows.findIndex((row) => row.key === column.key);
496
+ if (rowIndexFinded > -1) {
497
+ return rowIndexFinded;
498
+ }
499
+ return columnsConfig.findIndex((columnConfig) => columnConfig.key === column.key);
500
+ };
501
+ const handleIntro = () => {
502
+ const newColumnsConfig = columnsConfig.map((columnConfig) => {
503
+ const newColumnConfig = {
504
+ ...columnConfig
505
+ };
506
+ if (!columnConfig.hidden) {
507
+ const columnConfigRow = getColumnConfigByKey(columnConfig.key);
508
+ if (columnConfigRow) {
509
+ newColumnConfig.visible = columnConfigRow.visible;
510
+ newColumnConfig.frozen = columnConfigRow.frozen;
511
+ }
512
+ }
513
+ return newColumnConfig;
514
+ }).sort((a, b) => getRowIndex(a) - getRowIndex(b));
515
+ onChangeColumnsConfig(newColumnsConfig);
516
+ onCloseSettings();
517
+ };
518
+ const onInternalSelectedRowsChange = () => {
519
+ };
520
+ const onInternalRowsChange = (newRows) => {
521
+ setRows(newRows);
522
+ };
523
+ const onRowClick = (row) => {
524
+ if (selRows.has(row.key))
525
+ return;
526
+ const mySet = /* @__PURE__ */ new Set([row.key]);
527
+ setSelRows(mySet);
528
+ };
529
+ return /* @__PURE__ */ jsxs(WrapperColumnsConfig, {
530
+ id: "WrapperColumnsConfig",
531
+ ref: divRef,
532
+ children: [/* @__PURE__ */ jsx(DivSelColumns, {
533
+ id: "divInfo",
534
+ children: getLabel("data_grid.settings_sel_columns")
535
+ }), /* @__PURE__ */ jsx(WrapperDataGrid, {
536
+ id: "WrapperDataGrid",
537
+ children: /* @__PURE__ */ jsx(OriginalDataGridWrapperStyled, {
538
+ id: "Originaldata_gridWrapperStyled",
539
+ children: /* @__PURE__ */ jsx(DataGrid$1, {
540
+ className: "fill-data_grid rdg-light",
541
+ ref: refdata_grid,
542
+ columns: columnsdata_grid,
543
+ rows,
544
+ onRowsChange: onInternalRowsChange,
545
+ selectedRows: selRows,
546
+ onSelectedRowsChange: onInternalSelectedRowsChange,
547
+ onRowClick,
548
+ rowKeyGetter: (row) => row.key,
549
+ cellNavigationMode: "CHANGE_ROW",
550
+ defaultColumnOptions: {
551
+ resizable: true,
552
+ sortable: true
553
+ }
554
+ })
555
+ })
556
+ }), /* @__PURE__ */ jsxs(ColumnActions, {
557
+ children: [/* @__PURE__ */ jsx(IconButton$1, {
558
+ dictionaryTooltip: "data_grid.settings_move_first",
559
+ onClick: handleMoveFirst,
560
+ "aria-label": "move first place",
561
+ disabled: rowSelectedIndex < 1,
562
+ src: `${host_static_assets}/${environment_assets}/frontend/components/data_grid/assets/icons/move_first_place.svg`
563
+ }), /* @__PURE__ */ jsx(IconButton$1, {
564
+ dictionaryTooltip: "data_grid.settings_move_up",
565
+ onClick: () => handleMoveUpDownd(-1),
566
+ "aria-label": "move up place",
567
+ disabled: rowSelectedIndex < 1,
568
+ src: `${host_static_assets}/${environment_assets}/frontend/components/data_grid/assets/icons/move_up_place.svg`
569
+ }), /* @__PURE__ */ jsx(IconButton$1, {
570
+ dictionaryTooltip: "data_grid.settings_move_last",
571
+ onClick: handleMoveLast,
572
+ "aria-label": "move last place",
573
+ disabled: !!(rowSelectedIndex === rows.length - 1 || rowSelectedIndex === -1),
574
+ src: `${host_static_assets}/${environment_assets}/frontend/components/data_grid/assets/icons/move_last_place.svg`
575
+ }), /* @__PURE__ */ jsx(IconButton$1, {
576
+ dictionaryTooltip: "data_grid.settings_move_down",
577
+ onClick: () => handleMoveUpDownd(1),
578
+ "aria-label": "move down place",
579
+ disabled: !!(rowSelectedIndex === rows.length - 1 || rowSelectedIndex === -1),
580
+ src: `${host_static_assets}/${environment_assets}/frontend/components/data_grid/assets/icons/move_down_place.svg`
581
+ }), /* @__PURE__ */ jsx(IconButton$1, {
582
+ dictionaryTooltip: "data_grid.settings_visible_all",
583
+ onClick: checkAll,
584
+ "aria-label": "check visible all",
585
+ src: `${host_static_assets}/${environment_assets}/frontend/components/data_grid/assets/icons/check_all.svg`
586
+ }), /* @__PURE__ */ jsx(IconButton$1, {
587
+ dictionaryTooltip: "data_grid.settings_no_visible_all",
588
+ onClick: unCheckAll,
589
+ "aria-label": "un check all",
590
+ src: `${host_static_assets}/${environment_assets}/frontend/components/data_grid/assets/icons/uncheck_all.svg`
591
+ }), /* @__PURE__ */ jsx(IconButton$1, {
592
+ dictionaryTooltip: "data_grid.settings_restore",
593
+ onClick: restoreAll,
594
+ "aria-label": "Restore columns",
595
+ src: `${host_static_assets}/${environment_assets}/frontend/components/data_grid/assets/icons/restore_columns.svg`
596
+ })]
597
+ })]
598
+ });
599
+ });
600
+ ColumnsConfig.displayName = "ColumnsConfig";
601
+ const SKTWrapperColumnsSettings = styled("div")(({ theme }) => ({
602
+ display: "flex",
603
+ justifyContent: "center",
604
+ alignItems: "center",
605
+ minWidth: theme.spacing(3.75),
606
+ height: theme.spacing(3.75)
607
+ }));
608
+ function Settings() {
609
+ const {
610
+ openModal,
611
+ closeModal
612
+ } = useModal();
613
+ const {
614
+ columnsConfig,
615
+ onChangeColumnsConfig,
616
+ isSkeleton
617
+ } = useBase();
618
+ const {
619
+ getLabel
620
+ } = useModuleDictionary();
621
+ const {
622
+ host_static_assets,
623
+ environment_assets
624
+ } = useEnvironment();
625
+ const ref = useRef(null);
626
+ const onCloseSettings = useCallback(() => {
627
+ closeModal();
628
+ }, [closeModal]);
629
+ const onClickIntro = useCallback(() => {
630
+ if (ref.current?.onClickIntro) {
631
+ ref.current?.onClickIntro();
632
+ }
633
+ }, []);
634
+ const onClickSettings = useCallback(() => {
635
+ openModal({
636
+ onQueryClose: () => closeModal(),
637
+ title: getLabel("data_grid.settings_title"),
638
+ initialWidth: 500,
639
+ initialHeigth: 680,
640
+ contentComponent: /* @__PURE__ */ jsx(ColumnsConfig, {
641
+ ref,
642
+ columnsConfig,
643
+ onChangeColumnsConfig,
644
+ onCloseSettings
645
+ }),
646
+ actions: /* @__PURE__ */ jsxs(Fragment, {
647
+ children: [/* @__PURE__ */ jsx(ActionCancel, {
648
+ onClick: closeModal
649
+ }), /* @__PURE__ */ jsx(ActionIntro, {
650
+ onClick: onClickIntro
651
+ })]
652
+ })
653
+ });
654
+ }, [closeModal, columnsConfig, getLabel, onChangeColumnsConfig, onCloseSettings, openModal, onClickIntro]);
655
+ if (isSkeleton) {
656
+ return /* @__PURE__ */ jsx(SKTWrapperColumnsSettings, {
657
+ children: /* @__PURE__ */ jsx(Skeleton, {
658
+ variant: "circular",
659
+ width: 20,
660
+ height: 20
661
+ })
662
+ });
663
+ }
664
+ return /* @__PURE__ */ jsx(IconButton$1, {
665
+ dictionaryTooltip: "data_grid.tooltip_settings",
666
+ onClick: onClickSettings,
667
+ "aria-label": "settings",
668
+ src: `${host_static_assets}/${environment_assets}/frontend/components/data_grid/assets/icons/configuration.svg`
669
+ });
670
+ }
671
+ const Container = styled("div")(() => ({
672
+ display: "flex",
673
+ alignItems: "center"
674
+ }));
675
+ const RowsLabel = styled("span")(() => ({}));
676
+ const InsetLabel = styled("span")(({ theme }) => ({
677
+ marginLeft: theme.spacing(2),
678
+ paddingTop: "2px",
679
+ paddingBottom: "2px",
680
+ paddingLeft: "4px",
681
+ paddingRight: "4px",
682
+ border: `1px solid ${theme.palette.divider}`
683
+ }));
684
+ function RowsCount() {
685
+ const {
686
+ rowsCount,
687
+ isSkeleton
688
+ } = useBase();
689
+ const {
690
+ getLabel
691
+ } = useModuleDictionary();
692
+ if (isSkeleton) {
693
+ return /* @__PURE__ */ jsxs(Container, {
694
+ children: [/* @__PURE__ */ jsx(RowsLabel, {
695
+ children: /* @__PURE__ */ jsx(Skeleton, {
696
+ variant: "text",
697
+ width: "40px",
698
+ height: "16px"
699
+ })
700
+ }), /* @__PURE__ */ jsx(InsetLabel, {
701
+ children: /* @__PURE__ */ jsx(Skeleton, {
702
+ variant: "text",
703
+ width: "20px",
704
+ height: "16px"
705
+ })
706
+ })]
707
+ });
708
+ }
709
+ return /* @__PURE__ */ jsxs(Container, {
710
+ className: "rows-count",
711
+ id: "RowsCount",
712
+ children: [/* @__PURE__ */ jsx(RowsLabel, {
713
+ children: getLabel("data_grid.rows")
714
+ }), /* @__PURE__ */ jsx(InsetLabel, {
715
+ children: rowsCount
716
+ })]
717
+ });
718
+ }
719
+ const WrapperDensity = styled("div")(({ theme }) => ({
720
+ marginLeft: 0,
721
+ [theme.breakpoints.up("sm")]: {
722
+ marginLeft: theme.spacing(3)
723
+ }
724
+ }));
725
+ const SKTWrapperDensity = styled("div")(({ theme }) => ({
726
+ display: "flex",
727
+ justifyContent: "center",
728
+ alignItems: "center",
729
+ minWidth: theme.spacing(3.75),
730
+ height: theme.spacing(3.75)
731
+ }));
732
+ function Density() {
733
+ const {
734
+ host_static_assets,
735
+ environment_assets
736
+ } = useEnvironment();
737
+ const {
738
+ rowHeights,
739
+ currentRowHeightVariant,
740
+ setRowHeightVariant,
741
+ isSkeleton
742
+ } = useBase();
743
+ const {
744
+ getLabel
745
+ } = useModuleDictionary();
746
+ const menuActions = useMemo(() => {
747
+ if (typeof rowHeights === "number") {
748
+ return [];
749
+ }
750
+ return [{
751
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/data_grid/assets/icons/compact.svg`,
752
+ onClick: () => setRowHeightVariant("compact"),
753
+ disabled: currentRowHeightVariant === "compact",
754
+ dictionaryField: "data_grid.density_compact"
755
+ }, {
756
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/data_grid/assets/icons/standard.svg`,
757
+ onClick: () => setRowHeightVariant("standard"),
758
+ disabled: currentRowHeightVariant === "standard",
759
+ dictionaryField: "data_grid.density_standard"
760
+ }, {
761
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/data_grid/assets/icons/confortable.svg`,
762
+ onClick: () => setRowHeightVariant("confortable"),
763
+ disabled: currentRowHeightVariant === "confortable",
764
+ dictionaryField: "data_grid.density_confortable"
765
+ }];
766
+ }, [rowHeights, currentRowHeightVariant, setRowHeightVariant, host_static_assets, environment_assets]);
767
+ const currenViewIcon = useMemo(() => {
768
+ if (currentRowHeightVariant === "compact") {
769
+ return `${host_static_assets}/${environment_assets}/frontend/components/data_grid/assets/icons/compact.svg`;
770
+ }
771
+ if (currentRowHeightVariant === "standard") {
772
+ return `${host_static_assets}/${environment_assets}/frontend/components/data_grid/assets/icons/standard.svg`;
773
+ }
774
+ return `${host_static_assets}/${environment_assets}/frontend/components/data_grid/assets/icons/confortable.svg`;
775
+ }, [currentRowHeightVariant, host_static_assets, environment_assets]);
776
+ if (menuActions.length === 0) {
777
+ return /* @__PURE__ */ jsx(Fragment, {});
778
+ }
779
+ if (isSkeleton) {
780
+ return /* @__PURE__ */ jsx(SKTWrapperDensity, {
781
+ children: /* @__PURE__ */ jsx(Skeleton, {
782
+ variant: "circular",
783
+ width: "20px",
784
+ height: "20px"
785
+ })
786
+ });
787
+ }
788
+ return /* @__PURE__ */ jsx(WrapperDensity, {
789
+ id: "WrapperDensity",
790
+ children: /* @__PURE__ */ jsx(MenuActions, {
791
+ arrowType: "right-top",
792
+ anchorOrigin: {
793
+ vertical: "top",
794
+ horizontal: "left"
795
+ },
796
+ transformOrigin: {
797
+ vertical: "top",
798
+ horizontal: "right"
799
+ },
800
+ menuActions,
801
+ urlIcon: currenViewIcon,
802
+ toolTip: getLabel("data_grid.tooltip_density")
803
+ })
804
+ });
805
+ }
806
+ const WrapperActions = styled("div")(({ theme }) => ({
807
+ ...theme.typography.caption,
808
+ position: "absolute",
809
+ left: "0px",
810
+ right: "0px",
811
+ top: "0px",
812
+ height: theme.spacing(5.5),
813
+ padding: 0,
814
+ display: "flex",
815
+ flexDirection: "row",
816
+ alignItems: "center",
817
+ justifyContent: "flex-end",
818
+ [theme.breakpoints.up("sm")]: {
819
+ padding: theme.spacing(0, 1.5)
820
+ },
821
+ "&.with-no-pager .rows-count": {
822
+ flexGrow: 1
823
+ },
824
+ "& .MuiTablePagination-root": {
825
+ flexGrow: 1,
826
+ display: "flex",
827
+ justifyContent: "center",
828
+ overflow: "hidden"
829
+ }
830
+ }));
831
+ function Actions(props) {
832
+ const isDesktop = useResponsiveDesktop();
833
+ const {
834
+ rowHeights,
835
+ isSkeleton
836
+ } = useBase();
837
+ const {
838
+ withRowsCount = true,
839
+ withPager = true,
840
+ pagerOptions,
841
+ withSettings = true,
842
+ settingsProps,
843
+ withLocalFilters
844
+ } = props;
845
+ return /* @__PURE__ */ jsxs(WrapperActions, {
846
+ id: "WrapperActions",
847
+ className: withPager && pagerOptions ? "with-pager" : "with-no-pager",
848
+ children: [withRowsCount && isDesktop && /* @__PURE__ */ jsx(RowsCount, {}), withPager && pagerOptions && /* @__PURE__ */ jsx(Pager, {
849
+ ...pagerOptions,
850
+ totalRecords: pagerOptions.totalRecords,
851
+ isSkeleton,
852
+ isDesktop
853
+ }), typeof rowHeights !== "number" && /* @__PURE__ */ jsx(Density, {}), withLocalFilters && /* @__PURE__ */ jsx(Filter, {}), withSettings && /* @__PURE__ */ jsx(Settings, {
854
+ ...settingsProps
855
+ })]
856
+ });
857
+ }
858
+ export {
859
+ ActionsColumn as A,
860
+ LabelMemuItem as L,
861
+ MenuActions as M,
862
+ PagerActions as P,
863
+ Actions as a,
864
+ Actions$1 as b,
865
+ defaultCommonActionsDictionary as d,
866
+ getCommonActionsDictionary as g
867
+ };