@m4l/components 0.0.45 → 0.0.48

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 (51) hide show
  1. package/dist/components/CommonActions/components/ActionCancel/index.d.ts +3 -0
  2. package/dist/components/CommonActions/components/ActionCancel/index.js +14 -0
  3. package/dist/components/CommonActions/components/ActionFormCancel/index.d.ts +3 -0
  4. package/dist/components/CommonActions/components/ActionFormCancel/index.js +62 -0
  5. package/dist/components/CommonActions/components/ActionFormCancel/types.d.ts +6 -0
  6. package/dist/components/CommonActions/components/ActionFormIntro/index.d.ts +3 -0
  7. package/dist/components/CommonActions/components/ActionFormIntro/index.js +34 -0
  8. package/dist/components/CommonActions/components/ActionIntro/index.d.ts +3 -0
  9. package/dist/components/CommonActions/components/ActionIntro/index.js +16 -0
  10. package/dist/components/CommonActions/components/Actions/index.d.ts +3 -0
  11. package/dist/components/CommonActions/components/Actions/index.js +980 -0
  12. package/dist/components/CommonActions/components/Actions/styles.d.ts +2 -0
  13. package/dist/components/CommonActions/components/Actions/types.d.ts +6 -0
  14. package/dist/components/CommonActions/context/index.d.ts +5 -0
  15. package/dist/components/CommonActions/context/types.d.ts +9 -0
  16. package/dist/components/{FormActions → CommonActions}/dictionary.d.ts +1 -1
  17. package/dist/components/CommonActions/index.d.ts +6 -0
  18. package/dist/components/DataGrid/index.js +8 -648
  19. package/dist/components/DynamicFilter/components/fieldstypes/DateTimeFilter/index.d.ts +2 -1
  20. package/dist/components/DynamicFilter/components/fieldstypes/factory.d.ts +2 -1
  21. package/dist/components/DynamicFilter/index.js +21 -17
  22. package/dist/components/Icon/index.js +14 -12
  23. package/dist/components/ModalDialog/components/Header/types.d.ts +2 -2
  24. package/dist/components/ModalDialog/index.js +20 -20
  25. package/dist/components/ModalDialog/types.d.ts +2 -2
  26. package/dist/components/ObjectLogs/index.js +3 -6
  27. package/dist/components/SplitLayout/index.js +0 -1
  28. package/dist/components/formatters/DateFormatter/index.js +10 -8
  29. package/dist/components/hook-form/FormProvider/index.js +6 -116
  30. package/dist/components/hook-form/RHFTextField/index.d.ts +1 -1
  31. package/dist/components/index.d.ts +2 -2
  32. package/dist/components/mui_extended/Button/index.d.ts +3 -0
  33. package/dist/components/mui_extended/Button/styles.d.ts +12 -0
  34. package/dist/components/mui_extended/Button/types.d.ts +2 -0
  35. package/dist/components/mui_extended/IconButton/index.d.ts +0 -1
  36. package/dist/components/mui_extended/IconButton/index.js +23 -16
  37. package/dist/components/mui_extended/Pager/index.js +1 -66
  38. package/dist/contexts/ModalContext/components/ContentConfirm/types.d.ts +3 -3
  39. package/dist/contexts/ModalContext/index.js +12 -9
  40. package/dist/contexts/ModalContext/types.d.ts +5 -6
  41. package/dist/index.js +6 -3
  42. package/dist/react-lazy-load-image-component.js +197 -173
  43. package/dist/utils/index.d.ts +3 -3
  44. package/dist/utils/types.d.ts +1 -0
  45. package/dist/vendor.js +32 -11
  46. package/package.json +4 -5
  47. package/dist/components/FormActions/index.d.ts +0 -3
  48. package/dist/components/FormActions/index.js +0 -51
  49. package/dist/components/FormActions/styles.d.ts +0 -2
  50. package/dist/components/FormActions/types.d.ts +0 -7
  51. package/dist/components/mui_extended/MenuActions/index.js +0 -111
@@ -0,0 +1,980 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { useNavigate } from "react-router-dom";
3
+ import { createContext, useCallback, useState, useMemo, forwardRef, useRef, useImperativeHandle, useEffect } from "react";
4
+ import { useFormContext, useFormState } from "react-hook-form";
5
+ import { useModuleDictionary, useFlagsPresent, useEnvironment } from "@m4l/core";
6
+ import { LoadingButton } from "@mui/lab";
7
+ import { Skeleton, Button, IconButton, Tooltip, MenuItem, Checkbox } from "@mui/material";
8
+ import { styled } from "@mui/material/styles";
9
+ import { u as useModal } from "../../../../hooks/useModal/index.js";
10
+ import { I as IconButton$1 } from "../../../mui_extended/IconButton/index.js";
11
+ import { u as useBase, a as useFilters, O as OriginalGridWrapperStyled } from "../../../DataGrid/index.js";
12
+ import { P as Pager } from "../../../mui_extended/Pager/index.js";
13
+ import { D as DataGrid$1 } from "../../../../react-data-grid.js";
14
+ import { A as ActionCancel } from "../ActionCancel/index.js";
15
+ import { A as ActionIntro } from "../ActionIntro/index.js";
16
+ import { M as MenuPopover } from "../../../mui_extended/MenuPopover/index.js";
17
+ import { I as Icon } from "../../../Icon/index.js";
18
+ import { useResponsiveDesktop } from "@m4l/graphics";
19
+ import "@mui/material/Button";
20
+ import "../../../../vendor.js";
21
+ import "../../../../contexts/ModalContext/index.js";
22
+ const WrapperFormActions = styled("div")(({
23
+ theme
24
+ }) => ({
25
+ paddingTop: theme.spacing(3),
26
+ marginRight: theme.spacing(1.5),
27
+ display: "flex",
28
+ flexDirection: "row",
29
+ justifyContent: "flex-end",
30
+ "& > button": {
31
+ marginLeft: "10px"
32
+ },
33
+ "& .MuiLoadingButton-root ": {
34
+ minWidth: "80px"
35
+ }
36
+ }));
37
+ const WrapperSKTFormActions = styled("div")(({
38
+ theme
39
+ }) => ({
40
+ display: "grid",
41
+ gridTemplateColumns: "auto auto",
42
+ margin: "0px",
43
+ gridGap: `${theme.spacing(3)}`,
44
+ justifyContent: "flex-end",
45
+ paddingTop: `${theme.spacing(3)}`,
46
+ borderTop: `1px solid ${theme.palette.divider}`,
47
+ [theme.breakpoints.up("sm")]: {
48
+ margin: `0 ${theme.spacing(4.5)}`
49
+ }
50
+ }));
51
+ const initialState = {
52
+ variantColor: "primary"
53
+ };
54
+ const CommonActionsContext = createContext(initialState);
55
+ function CommonActionsProvider(props) {
56
+ const {
57
+ children,
58
+ variantColor
59
+ } = props;
60
+ return /* @__PURE__ */ jsx(CommonActionsContext.Provider, {
61
+ value: {
62
+ variantColor
63
+ },
64
+ children
65
+ });
66
+ }
67
+ const WrapperStandarActions = styled("div")(({
68
+ theme
69
+ }) => ({
70
+ paddingTop: theme.spacing(3),
71
+ display: "flex",
72
+ flexDirection: "row",
73
+ justifyContent: "flex-end",
74
+ "& > button": {
75
+ marginLeft: "10px"
76
+ }
77
+ }));
78
+ const Actions$1 = (props) => {
79
+ const {
80
+ children,
81
+ variantColor = "primary"
82
+ } = props;
83
+ return /* @__PURE__ */ jsx(WrapperStandarActions, {
84
+ id: "WrapperStandarActions",
85
+ children: /* @__PURE__ */ jsx(CommonActionsProvider, {
86
+ variantColor,
87
+ children
88
+ })
89
+ });
90
+ };
91
+ function SKTFormActions() {
92
+ return /* @__PURE__ */ jsxs(WrapperSKTFormActions, {
93
+ children: [/* @__PURE__ */ jsx(Skeleton, {
94
+ variant: "text",
95
+ width: 57,
96
+ height: 30
97
+ }), /* @__PURE__ */ jsx(Skeleton, {
98
+ variant: "text",
99
+ width: 57,
100
+ height: 30
101
+ })]
102
+ });
103
+ }
104
+ function FormActions(props) {
105
+ const {
106
+ withIntro,
107
+ urlCancel
108
+ } = props;
109
+ const navigate = useNavigate();
110
+ const {
111
+ getLabel
112
+ } = useModuleDictionary();
113
+ const isSkeleton = !useFlagsPresent(["dictionary_loaded", "form_loaded"]);
114
+ const {
115
+ openModalConfirm
116
+ } = useModal();
117
+ const {
118
+ control
119
+ } = useFormContext();
120
+ const {
121
+ isDirty,
122
+ isSubmitting
123
+ } = useFormState({
124
+ control
125
+ });
126
+ const onConfirmCancel = useCallback(() => {
127
+ if (typeof urlCancel === "number") {
128
+ navigate(urlCancel);
129
+ }
130
+ if (urlCancel && typeof urlCancel === "undefined") {
131
+ navigate(urlCancel, {
132
+ replace: false
133
+ });
134
+ }
135
+ }, [navigate, urlCancel]);
136
+ const onClickCancel = useCallback(() => {
137
+ if (isDirty) {
138
+ openModalConfirm({
139
+ variant: "warning",
140
+ title: getLabel("form_provider.confirm_quit_title"),
141
+ msg: getLabel("form_provider.confirm_quit_msg"),
142
+ onClickIntro: onConfirmCancel
143
+ });
144
+ } else {
145
+ onConfirmCancel();
146
+ }
147
+ }, [getLabel, isDirty, onConfirmCancel, openModalConfirm]);
148
+ if (isSkeleton) {
149
+ return /* @__PURE__ */ jsx(SKTFormActions, {});
150
+ }
151
+ return /* @__PURE__ */ jsxs(WrapperFormActions, {
152
+ children: [urlCancel && /* @__PURE__ */ jsx(Button, {
153
+ variant: "outlined",
154
+ color: "inherit",
155
+ onClick: onClickCancel,
156
+ children: getLabel("actions.action_cancel")
157
+ }), withIntro && /* @__PURE__ */ jsx(LoadingButton, {
158
+ variant: "contained",
159
+ type: "submit",
160
+ loading: isSubmitting,
161
+ children: getLabel("actions.action_accept")
162
+ })]
163
+ });
164
+ }
165
+ const WrapperMenuActions = styled(IconButton)(() => ({}));
166
+ const LabelMemuItem = styled("div")(({
167
+ theme
168
+ }) => ({
169
+ height: "22px",
170
+ marginLeft: theme.spacing(1.5),
171
+ display: "flex",
172
+ alignItems: "center"
173
+ }));
174
+ function MenuActions(props) {
175
+ const {
176
+ menuActions,
177
+ objItem = {},
178
+ urlIcon,
179
+ toolTip = "",
180
+ marginTop = -1,
181
+ marginBottom,
182
+ marginLeft,
183
+ marginRight,
184
+ width = 200,
185
+ arrow = "right-top",
186
+ ...other
187
+ } = props;
188
+ const {
189
+ host_static_assets,
190
+ environment_assets
191
+ } = useEnvironment();
192
+ const {
193
+ getLabel
194
+ } = useModuleDictionary();
195
+ const [open, setOpen] = useState(null);
196
+ const handleOpen = (event) => {
197
+ setOpen(event.currentTarget);
198
+ };
199
+ const urlFinalIcon = useMemo(() => {
200
+ if (urlIcon)
201
+ return urlIcon;
202
+ return `${host_static_assets}/${environment_assets}/frontend/commons/assets/icons/more_vertical.svg`;
203
+ }, [urlIcon, host_static_assets, environment_assets]);
204
+ const handleClose = () => {
205
+ setOpen(null);
206
+ };
207
+ const handleClick = (menuAction) => {
208
+ setOpen(null);
209
+ menuAction.onClick();
210
+ };
211
+ const finalActions = useMemo(() => {
212
+ let ret;
213
+ if (typeof menuActions !== "function") {
214
+ ret = menuActions;
215
+ } else {
216
+ ret = menuActions(objItem);
217
+ }
218
+ return ret;
219
+ }, [menuActions, objItem]);
220
+ return /* @__PURE__ */ jsxs(Fragment, {
221
+ children: [/* @__PURE__ */ jsx(Tooltip, {
222
+ title: toolTip,
223
+ children: /* @__PURE__ */ jsx(WrapperMenuActions, {
224
+ id: "WrapperMenuActions",
225
+ size: "small",
226
+ onClick: handleOpen,
227
+ children: /* @__PURE__ */ jsx(Icon, {
228
+ src: urlFinalIcon,
229
+ width: 16,
230
+ height: 16
231
+ })
232
+ })
233
+ }), /* @__PURE__ */ jsx(MenuPopover, {
234
+ id: "MenuPopover",
235
+ open: Boolean(open),
236
+ anchorEl: open,
237
+ onClose: handleClose,
238
+ arrow,
239
+ sx: {
240
+ marginTop,
241
+ marginBottom,
242
+ marginLeft,
243
+ marginRight,
244
+ width,
245
+ "& .MuiMenuItem-root": {
246
+ px: 1,
247
+ typography: "body2",
248
+ borderRadius: 0.75
249
+ }
250
+ },
251
+ ...other,
252
+ children: open && finalActions.map((menuAction, index) => /* @__PURE__ */ jsxs(MenuItem, {
253
+ dense: true,
254
+ onClick: () => handleClick(menuAction),
255
+ sx: {
256
+ color: menuAction.color ? menuAction.color : "text.main"
257
+ },
258
+ disabled: menuAction.disabled,
259
+ children: [/* @__PURE__ */ jsx(Icon, {
260
+ src: menuAction.urlIcon
261
+ }), /* @__PURE__ */ jsx(LabelMemuItem, {
262
+ children: getLabel(menuAction.dictionaryField)
263
+ })]
264
+ }, `menu_action_${index}`))
265
+ })]
266
+ });
267
+ }
268
+ const WrapperPagerActions = styled("div")(({ theme }) => ({
269
+ width: "100%",
270
+ justifyContent: "center",
271
+ display: "flex",
272
+ marginLeft: 0,
273
+ [theme.breakpoints.up("sm")]: {
274
+ display: "flex",
275
+ alignItems: "center",
276
+ marginLeft: theme.spacing(3)
277
+ }
278
+ }));
279
+ function PagerActions(props) {
280
+ const {
281
+ count,
282
+ page,
283
+ rowsPerPage,
284
+ onPageChange
285
+ } = props;
286
+ const {
287
+ host_static_assets,
288
+ environment_assets
289
+ } = useEnvironment();
290
+ const handleFirstPageButtonClick = (event) => {
291
+ onPageChange(event, 0);
292
+ };
293
+ const handleBackButtonClick = (event) => {
294
+ onPageChange(event, page - 1);
295
+ };
296
+ const handleNextButtonClick = (event) => {
297
+ onPageChange(event, page + 1);
298
+ };
299
+ const handleLastPageButtonClick = (event) => {
300
+ onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
301
+ };
302
+ return /* @__PURE__ */ jsxs(WrapperPagerActions, {
303
+ id: "WrapperPagerActions",
304
+ children: [/* @__PURE__ */ jsx(IconButton$1, {
305
+ id: "test_bruce",
306
+ dictionaryTooltip: "pager.first",
307
+ onClick: handleFirstPageButtonClick,
308
+ disabled: page === 0,
309
+ "aria-label": "first page",
310
+ src: `${host_static_assets}/${environment_assets}/frontend/components/pager/assets/icons/first.svg`
311
+ }), /* @__PURE__ */ jsx(IconButton$1, {
312
+ dictionaryTooltip: "pager.previous",
313
+ onClick: handleBackButtonClick,
314
+ disabled: page === 0,
315
+ "aria-label": "first page",
316
+ src: `${host_static_assets}/${environment_assets}/frontend/components/pager/assets/icons/previous.svg`
317
+ }), /* @__PURE__ */ jsx(IconButton$1, {
318
+ dictionaryTooltip: "pager.next",
319
+ onClick: handleNextButtonClick,
320
+ disabled: page >= Math.ceil(count / rowsPerPage) - 1,
321
+ "aria-label": "next page",
322
+ src: `${host_static_assets}/${environment_assets}/frontend/components/pager/assets/icons/next.svg`
323
+ }), /* @__PURE__ */ jsx(IconButton$1, {
324
+ dictionaryTooltip: "pager.last",
325
+ onClick: handleLastPageButtonClick,
326
+ disabled: page >= Math.ceil(count / rowsPerPage) - 1,
327
+ "aria-label": "last page",
328
+ src: `${host_static_assets}/${environment_assets}/frontend/components/pager/assets/icons/last.svg`
329
+ })]
330
+ });
331
+ }
332
+ const ACTIONS_COLUMN_KEY = "actions-row";
333
+ function ActionsFormatter(props) {
334
+ const {
335
+ rowActionsGetter
336
+ } = useBase();
337
+ if (rowActionsGetter === void 0) {
338
+ return /* @__PURE__ */ jsx(Fragment, {});
339
+ }
340
+ return /* @__PURE__ */ jsx(MenuActions, {
341
+ arrow: "top-left",
342
+ objItem: props.row,
343
+ menuActions: rowActionsGetter,
344
+ marginTop: 1,
345
+ marginLeft: "-11px",
346
+ anchorOrigin: {
347
+ vertical: "bottom",
348
+ horizontal: "left"
349
+ },
350
+ transformOrigin: {
351
+ vertical: "top",
352
+ horizontal: "left"
353
+ }
354
+ });
355
+ }
356
+ const ActionsColumn = {
357
+ key: ACTIONS_COLUMN_KEY,
358
+ name: "Actions",
359
+ width: 60,
360
+ withFilter: false,
361
+ resizable: true,
362
+ sortable: false,
363
+ frozen: true,
364
+ type: "custom",
365
+ formatter: ActionsFormatter
366
+ };
367
+ const SKTWrapperFilter = styled("div")(({
368
+ theme
369
+ }) => ({
370
+ display: "flex",
371
+ justifyContent: "center",
372
+ alignItems: "center",
373
+ minWidth: theme.spacing(3.75),
374
+ height: theme.spacing(3.75)
375
+ }));
376
+ function Filter() {
377
+ const {
378
+ isSkeleton
379
+ } = useBase();
380
+ const {
381
+ activeFilters,
382
+ setActiveFilters
383
+ } = useFilters();
384
+ const {
385
+ host_static_assets,
386
+ environment_assets
387
+ } = useEnvironment();
388
+ const toggleIcon = () => {
389
+ setActiveFilters(!activeFilters);
390
+ };
391
+ if (isSkeleton) {
392
+ return /* @__PURE__ */ jsx(SKTWrapperFilter, {
393
+ children: /* @__PURE__ */ jsx(Skeleton, {
394
+ variant: "circular",
395
+ width: 20,
396
+ height: 20
397
+ })
398
+ });
399
+ }
400
+ return /* @__PURE__ */ jsx(IconButton$1, {
401
+ dictionaryTooltip: activeFilters ? "grid.filter_hide" : "grid.filter_show",
402
+ onClick: toggleIcon,
403
+ "aria-label": "filter",
404
+ src: `${host_static_assets}/${environment_assets}/frontend/components/grid/assets/icons/filter.svg`
405
+ });
406
+ }
407
+ const WrapperColumnsConfig = styled("div")(({ theme }) => ({
408
+ color: theme.palette.text.primary,
409
+ position: "relative",
410
+ display: "flex",
411
+ flexDirection: "column",
412
+ height: "100%",
413
+ width: "100%"
414
+ }));
415
+ styled("div")(({ theme }) => ({
416
+ color: theme.palette.text.primary,
417
+ fontSize: theme.typography.h4.fontSize
418
+ }));
419
+ const DivSelColumns = styled("div")(({ theme }) => ({
420
+ ...theme.typography.subtitle2,
421
+ color: theme.palette.text.primary,
422
+ padding: `${theme.spacing(3)} ${theme.spacing(1)}`
423
+ }));
424
+ const WrapperGrid = styled("div")(() => ({
425
+ position: "relative",
426
+ display: "flex",
427
+ flexDirection: "column",
428
+ flexGrow: 1
429
+ }));
430
+ styled("div")(() => ({
431
+ display: "flex",
432
+ flexDirection: "row"
433
+ }));
434
+ const ColumnActions = styled("div")(({ theme }) => ({
435
+ paddingTop: theme.spacing(3),
436
+ display: "flex",
437
+ flexDirection: "row"
438
+ }));
439
+ styled("div")(({ theme }) => ({
440
+ paddingTop: theme.spacing(3),
441
+ display: "flex",
442
+ flexDirection: "row",
443
+ justifyContent: "flex-end",
444
+ "& > button": {
445
+ marginLeft: "10px"
446
+ }
447
+ }));
448
+ function FormatterColumn({
449
+ row,
450
+ onRowChange,
451
+ column
452
+ }) {
453
+ const handleChange = () => {
454
+ const newRow = {
455
+ ...row
456
+ };
457
+ newRow[column.key] = !row[column.key];
458
+ onRowChange(newRow);
459
+ };
460
+ return /* @__PURE__ */ jsx(Checkbox, {
461
+ size: "small",
462
+ checked: row[column.key],
463
+ onChange: handleChange
464
+ });
465
+ }
466
+ function getRowsFromColumnsConfig(columnsConfig) {
467
+ return columnsConfig.filter((column) => !column.hidden).map((column) => ({
468
+ key: column.key,
469
+ name: column.name,
470
+ visible: column.visible === void 0 ? true : column.visible,
471
+ frozen: column.frozen === void 0 ? false : column.frozen,
472
+ originalIndex: column.orginalIndex,
473
+ originalFrozen: column.originalFrozen,
474
+ originalVisible: column.originalVisible
475
+ }));
476
+ }
477
+ const ColumnsConfig = forwardRef((props, ref) => {
478
+ const refGrid = useRef(null);
479
+ const {
480
+ onCloseSettings,
481
+ columnsConfig,
482
+ onChangeColumnsConfig
483
+ } = props;
484
+ const {
485
+ getLabel
486
+ } = useModuleDictionary();
487
+ const [isInit, setIsInit] = useState(true);
488
+ const [rows, setRows] = useState(getRowsFromColumnsConfig(columnsConfig));
489
+ const [selRows, setSelRows] = useState(() => /* @__PURE__ */ new Set());
490
+ const divRef = useRef(null);
491
+ const {
492
+ host_static_assets,
493
+ environment_assets
494
+ } = useEnvironment();
495
+ useImperativeHandle(ref, () => ({
496
+ onClickIntro: handleIntro,
497
+ current: divRef.current
498
+ }));
499
+ const columnsGrid = useMemo(() => [{
500
+ key: "name",
501
+ name: getLabel("grid.settings_column_name"),
502
+ width: 200,
503
+ resizable: true,
504
+ type: "text"
505
+ }, {
506
+ key: "originalIndex",
507
+ name: getLabel("grid.settings_column_position"),
508
+ width: 50,
509
+ type: "number",
510
+ cellClass: "rdg-cell-align-center"
511
+ }, {
512
+ key: "visible",
513
+ name: getLabel("grid.settings_column_visible"),
514
+ width: 80,
515
+ type: "boolean",
516
+ formatter: FormatterColumn,
517
+ cellClass: "rdg-cell-align-center"
518
+ }, {
519
+ key: "frozen",
520
+ name: getLabel("grid.settings_column_frozen"),
521
+ width: 80,
522
+ type: "boolean",
523
+ formatter: FormatterColumn,
524
+ cellClass: "rdg-cell-align-center"
525
+ }], [getLabel]);
526
+ const checkAll = () => {
527
+ setRows(rows.map((row) => ({
528
+ ...row,
529
+ visible: true
530
+ })));
531
+ };
532
+ const unCheckAll = () => {
533
+ setRows(rows.map((row) => ({
534
+ ...row,
535
+ visible: false
536
+ })));
537
+ };
538
+ const restoreAll = () => {
539
+ setRows(rows.map((row) => ({
540
+ ...row,
541
+ visible: row.originalVisible,
542
+ frozen: row.originalFrozen,
543
+ index: row.originalIndex
544
+ })).sort((a, b) => a.index - b.index));
545
+ };
546
+ useEffect(() => {
547
+ if (isInit === false) {
548
+ setRows(getRowsFromColumnsConfig(columnsConfig));
549
+ }
550
+ setIsInit(false);
551
+ }, [columnsConfig]);
552
+ const rowSelectedIndex = useMemo(() => {
553
+ let rowIndex = -1;
554
+ if (selRows.size !== 1)
555
+ return rowIndex;
556
+ const iterator = selRows.entries();
557
+ const entry = iterator.next().value[1];
558
+ rowIndex = rows.findIndex((row) => row.key === entry);
559
+ return rowIndex;
560
+ }, [rows, selRows]);
561
+ const handleMoveFirst = () => {
562
+ if (rowSelectedIndex === -1)
563
+ return -1;
564
+ const newRows = [...rows];
565
+ newRows.splice(rowSelectedIndex, 1);
566
+ newRows.splice(0, 0, rows[rowSelectedIndex]);
567
+ refGrid.current?.selectCell({
568
+ idx: 0,
569
+ rowIdx: 0
570
+ });
571
+ setRows(newRows);
572
+ };
573
+ const handleMoveLast = () => {
574
+ if (rowSelectedIndex === -1)
575
+ return -1;
576
+ const newRows = [...rows];
577
+ newRows.splice(rowSelectedIndex, 1);
578
+ newRows.splice(newRows.length, 0, rows[rowSelectedIndex]);
579
+ refGrid.current?.selectCell({
580
+ idx: 0,
581
+ rowIdx: newRows.length - 1
582
+ });
583
+ setRows(newRows);
584
+ };
585
+ const handleMoveUpDownd = (position) => {
586
+ if (rowSelectedIndex === -1)
587
+ return -1;
588
+ const newRows = [...rows];
589
+ const element = newRows[rowSelectedIndex];
590
+ newRows.splice(rowSelectedIndex, 1);
591
+ newRows.splice(rowSelectedIndex + position, 0, element);
592
+ refGrid.current?.selectCell({
593
+ idx: 0,
594
+ rowIdx: rowSelectedIndex + position
595
+ });
596
+ setRows(newRows);
597
+ };
598
+ const getColumnConfigByKey = (key) => {
599
+ const rowIndexFinded = rows.findIndex((row) => row.key === key);
600
+ if (rowIndexFinded > -1) {
601
+ return {
602
+ visible: rows[rowIndexFinded].visible,
603
+ frozen: rows[rowIndexFinded].frozen
604
+ };
605
+ }
606
+ return void 0;
607
+ };
608
+ const getRowIndex = (column) => {
609
+ const rowIndexFinded = rows.findIndex((row) => row.key === column.key);
610
+ if (rowIndexFinded > -1) {
611
+ return rowIndexFinded;
612
+ }
613
+ return columnsConfig.findIndex((columnConfig) => columnConfig.key === column.key);
614
+ };
615
+ const handleIntro = () => {
616
+ const newColumnsConfig = columnsConfig.map((columnConfig) => {
617
+ const newColumnConfig = {
618
+ ...columnConfig
619
+ };
620
+ if (!columnConfig.hidden) {
621
+ const columnConfigRow = getColumnConfigByKey(columnConfig.key);
622
+ if (columnConfigRow) {
623
+ newColumnConfig.visible = columnConfigRow.visible;
624
+ newColumnConfig.frozen = columnConfigRow.frozen;
625
+ }
626
+ }
627
+ return newColumnConfig;
628
+ }).sort((a, b) => getRowIndex(a) - getRowIndex(b));
629
+ onChangeColumnsConfig(newColumnsConfig);
630
+ onCloseSettings();
631
+ };
632
+ const onInternalSelectedRowsChange = () => {
633
+ };
634
+ const onInternalRowsChange = (newRows) => {
635
+ setRows(newRows);
636
+ };
637
+ const onRowClick = (row) => {
638
+ if (selRows.has(row.key))
639
+ return;
640
+ const mySet = /* @__PURE__ */ new Set([row.key]);
641
+ setSelRows(mySet);
642
+ };
643
+ return /* @__PURE__ */ jsxs(WrapperColumnsConfig, {
644
+ id: "WrapperColumnsConfig",
645
+ ref: divRef,
646
+ children: [/* @__PURE__ */ jsx(DivSelColumns, {
647
+ id: "divInfo",
648
+ children: getLabel("grid.settings_sel_columns")
649
+ }), /* @__PURE__ */ jsx(WrapperGrid, {
650
+ id: "WrapperGrid",
651
+ children: /* @__PURE__ */ jsx(OriginalGridWrapperStyled, {
652
+ id: "OriginalGridWrapperStyled",
653
+ children: /* @__PURE__ */ jsx(DataGrid$1, {
654
+ className: "fill-grid rdg-light",
655
+ ref: refGrid,
656
+ columns: columnsGrid,
657
+ rows,
658
+ onRowsChange: onInternalRowsChange,
659
+ selectedRows: selRows,
660
+ onSelectedRowsChange: onInternalSelectedRowsChange,
661
+ onRowClick,
662
+ rowKeyGetter: (row) => row.key,
663
+ cellNavigationMode: "CHANGE_ROW",
664
+ defaultColumnOptions: {
665
+ resizable: true,
666
+ sortable: true
667
+ }
668
+ })
669
+ })
670
+ }), /* @__PURE__ */ jsxs(ColumnActions, {
671
+ children: [/* @__PURE__ */ jsx(IconButton$1, {
672
+ dictionaryTooltip: "grid.settings_move_first",
673
+ onClick: handleMoveFirst,
674
+ "aria-label": "move first place",
675
+ disabled: rowSelectedIndex < 1,
676
+ src: `${host_static_assets}/${environment_assets}/frontend/components/grid/assets/icons/move_first_place.svg`
677
+ }), /* @__PURE__ */ jsx(IconButton$1, {
678
+ dictionaryTooltip: "grid.settings_move_up",
679
+ onClick: () => handleMoveUpDownd(-1),
680
+ "aria-label": "move up place",
681
+ disabled: rowSelectedIndex < 1,
682
+ src: `${host_static_assets}/${environment_assets}/frontend/components/grid/assets/icons/move_up_place.svg`
683
+ }), /* @__PURE__ */ jsx(IconButton$1, {
684
+ dictionaryTooltip: "grid.settings_move_last",
685
+ onClick: handleMoveLast,
686
+ "aria-label": "move last place",
687
+ disabled: !!(rowSelectedIndex === rows.length - 1 || rowSelectedIndex === -1),
688
+ src: `${host_static_assets}/${environment_assets}/frontend/components/grid/assets/icons/move_last_place.svg`
689
+ }), /* @__PURE__ */ jsx(IconButton$1, {
690
+ dictionaryTooltip: "grid.settings_move_down",
691
+ onClick: () => handleMoveUpDownd(1),
692
+ "aria-label": "move down place",
693
+ disabled: !!(rowSelectedIndex === rows.length - 1 || rowSelectedIndex === -1),
694
+ src: `${host_static_assets}/${environment_assets}/frontend/components/grid/assets/icons/move_down_place.svg`
695
+ }), /* @__PURE__ */ jsx(IconButton$1, {
696
+ dictionaryTooltip: "grid.settings_visible_all",
697
+ onClick: checkAll,
698
+ "aria-label": "check visible all",
699
+ src: `${host_static_assets}/${environment_assets}/frontend/components/grid/assets/icons/check_all.svg`
700
+ }), /* @__PURE__ */ jsx(IconButton$1, {
701
+ dictionaryTooltip: "grid.settings_no_visible_all",
702
+ onClick: unCheckAll,
703
+ "aria-label": "un check all",
704
+ src: `${host_static_assets}/${environment_assets}/frontend/components/grid/assets/icons/uncheck_all.svg`
705
+ }), /* @__PURE__ */ jsx(IconButton$1, {
706
+ dictionaryTooltip: "grid.settings_restore",
707
+ onClick: restoreAll,
708
+ "aria-label": "Restore columns",
709
+ src: `${host_static_assets}/${environment_assets}/frontend/components/grid/assets/icons/restore_columns.svg`
710
+ })]
711
+ })]
712
+ });
713
+ });
714
+ ColumnsConfig.displayName = "ColumnsConfig";
715
+ const SKTWrapperColumnsSettings = styled("div")(({ theme }) => ({
716
+ display: "flex",
717
+ justifyContent: "center",
718
+ alignItems: "center",
719
+ minWidth: theme.spacing(3.75),
720
+ height: theme.spacing(3.75)
721
+ }));
722
+ function Settings() {
723
+ const {
724
+ openModal,
725
+ closeModal
726
+ } = useModal();
727
+ const {
728
+ columnsConfig,
729
+ onChangeColumnsConfig,
730
+ isSkeleton
731
+ } = useBase();
732
+ const {
733
+ getLabel
734
+ } = useModuleDictionary();
735
+ const {
736
+ host_static_assets,
737
+ environment_assets
738
+ } = useEnvironment();
739
+ const ref = useRef(null);
740
+ const onCloseSettings = useCallback(() => {
741
+ closeModal();
742
+ }, [closeModal]);
743
+ const onClickIntro = useCallback(() => {
744
+ if (ref.current?.onClickIntro) {
745
+ ref.current?.onClickIntro();
746
+ }
747
+ }, []);
748
+ const onClickSettings = useCallback(() => {
749
+ openModal({
750
+ onQueryClose: () => closeModal(),
751
+ title: "grid.settings_tooltip",
752
+ initialWidth: 500,
753
+ initialHeigth: 680,
754
+ contentComponent: /* @__PURE__ */ jsx(ColumnsConfig, {
755
+ ref,
756
+ columnsConfig,
757
+ onChangeColumnsConfig,
758
+ onCloseSettings
759
+ }),
760
+ actions: /* @__PURE__ */ jsxs(Fragment, {
761
+ children: [/* @__PURE__ */ jsx(ActionCancel, {
762
+ onClick: closeModal
763
+ }), /* @__PURE__ */ jsx(ActionIntro, {
764
+ onClick: onClickIntro
765
+ })]
766
+ })
767
+ });
768
+ }, [closeModal, columnsConfig, getLabel, onChangeColumnsConfig, onCloseSettings, openModal, onClickIntro]);
769
+ if (isSkeleton) {
770
+ return /* @__PURE__ */ jsx(SKTWrapperColumnsSettings, {
771
+ children: /* @__PURE__ */ jsx(Skeleton, {
772
+ variant: "circular",
773
+ width: 20,
774
+ height: 20
775
+ })
776
+ });
777
+ }
778
+ return /* @__PURE__ */ jsx(IconButton$1, {
779
+ dictionaryTooltip: "grid.settings_tooltip",
780
+ onClick: onClickSettings,
781
+ "aria-label": "settings",
782
+ src: `${host_static_assets}/${environment_assets}/frontend/components/grid/assets/icons/configuration.svg`
783
+ });
784
+ }
785
+ const Container = styled("div")(() => ({
786
+ display: "flex",
787
+ alignItems: "center"
788
+ }));
789
+ const RowsLabel = styled("span")(() => ({}));
790
+ const InsetLabel = styled("span")(({ theme }) => ({
791
+ marginLeft: theme.spacing(2),
792
+ paddingTop: "2px",
793
+ paddingBottom: "2px",
794
+ paddingLeft: "4px",
795
+ paddingRight: "4px",
796
+ border: `1px solid ${theme.palette.divider}`
797
+ }));
798
+ function RowsCount() {
799
+ const {
800
+ rowsCount,
801
+ isSkeleton
802
+ } = useBase();
803
+ const {
804
+ getLabel
805
+ } = useModuleDictionary();
806
+ if (isSkeleton) {
807
+ return /* @__PURE__ */ jsxs(Container, {
808
+ children: [/* @__PURE__ */ jsx(RowsLabel, {
809
+ children: /* @__PURE__ */ jsx(Skeleton, {
810
+ variant: "text",
811
+ width: "40px",
812
+ height: "16px"
813
+ })
814
+ }), /* @__PURE__ */ jsx(InsetLabel, {
815
+ children: /* @__PURE__ */ jsx(Skeleton, {
816
+ variant: "text",
817
+ width: "20px",
818
+ height: "16px"
819
+ })
820
+ })]
821
+ });
822
+ }
823
+ return /* @__PURE__ */ jsxs(Container, {
824
+ className: "rows-count",
825
+ id: "RowsCount",
826
+ children: [/* @__PURE__ */ jsx(RowsLabel, {
827
+ children: getLabel("grid.rows")
828
+ }), /* @__PURE__ */ jsx(InsetLabel, {
829
+ children: rowsCount
830
+ })]
831
+ });
832
+ }
833
+ const WrapperDensity = styled("div")(({ theme }) => ({
834
+ marginLeft: 0,
835
+ [theme.breakpoints.up("sm")]: {
836
+ marginLeft: theme.spacing(3)
837
+ }
838
+ }));
839
+ const SKTWrapperDensity = styled("div")(({ theme }) => ({
840
+ display: "flex",
841
+ justifyContent: "center",
842
+ alignItems: "center",
843
+ minWidth: theme.spacing(3.75),
844
+ height: theme.spacing(3.75)
845
+ }));
846
+ function Density() {
847
+ const {
848
+ host_static_assets,
849
+ environment_assets
850
+ } = useEnvironment();
851
+ const {
852
+ rowHeights,
853
+ currentRowHeightVariant,
854
+ setRowHeightVariant,
855
+ isSkeleton
856
+ } = useBase();
857
+ const {
858
+ getLabel
859
+ } = useModuleDictionary();
860
+ const menuActions = useMemo(() => {
861
+ if (typeof rowHeights === "number") {
862
+ return [];
863
+ }
864
+ return [{
865
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/grid/assets/icons/compact.svg`,
866
+ onClick: () => setRowHeightVariant("compact"),
867
+ disabled: currentRowHeightVariant === "compact",
868
+ dictionaryField: "grid.density_compact"
869
+ }, {
870
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/grid/assets/icons/standard.svg`,
871
+ onClick: () => setRowHeightVariant("standard"),
872
+ disabled: currentRowHeightVariant === "standard",
873
+ dictionaryField: "grid.density_standard"
874
+ }, {
875
+ urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/grid/assets/icons/confortable.svg`,
876
+ onClick: () => setRowHeightVariant("confortable"),
877
+ disabled: currentRowHeightVariant === "confortable",
878
+ dictionaryField: "grid.density_confortable"
879
+ }];
880
+ }, [rowHeights, currentRowHeightVariant, setRowHeightVariant, host_static_assets, environment_assets]);
881
+ const currenViewIcon = useMemo(() => {
882
+ if (currentRowHeightVariant === "compact") {
883
+ return `${host_static_assets}/${environment_assets}/frontend/components/grid/assets/icons/compact.svg`;
884
+ }
885
+ if (currentRowHeightVariant === "standard") {
886
+ return `${host_static_assets}/${environment_assets}/frontend/components/grid/assets/icons/standard.svg`;
887
+ }
888
+ return `${host_static_assets}/${environment_assets}/frontend/components/grid/assets/icons/confortable.svg`;
889
+ }, [currentRowHeightVariant, host_static_assets, environment_assets]);
890
+ if (menuActions.length === 0) {
891
+ return /* @__PURE__ */ jsx(Fragment, {});
892
+ }
893
+ if (isSkeleton) {
894
+ return /* @__PURE__ */ jsx(SKTWrapperDensity, {
895
+ children: /* @__PURE__ */ jsx(Skeleton, {
896
+ variant: "circular",
897
+ width: "20px",
898
+ height: "20px"
899
+ })
900
+ });
901
+ }
902
+ return /* @__PURE__ */ jsx(WrapperDensity, {
903
+ id: "WrapperDensity",
904
+ children: /* @__PURE__ */ jsx(MenuActions, {
905
+ arrow: "right-top",
906
+ anchorOrigin: {
907
+ vertical: "top",
908
+ horizontal: "left"
909
+ },
910
+ transformOrigin: {
911
+ vertical: "top",
912
+ horizontal: "right"
913
+ },
914
+ menuActions,
915
+ urlIcon: currenViewIcon,
916
+ toolTip: getLabel("grid.density_tooltip")
917
+ })
918
+ });
919
+ }
920
+ const WrapperActions = styled("div")(({ theme }) => ({
921
+ ...theme.typography.caption,
922
+ position: "absolute",
923
+ left: "0px",
924
+ right: "0px",
925
+ top: "0px",
926
+ height: theme.spacing(5.5),
927
+ padding: 0,
928
+ display: "flex",
929
+ flexDirection: "row",
930
+ alignItems: "center",
931
+ justifyContent: "flex-end",
932
+ [theme.breakpoints.up("sm")]: {
933
+ padding: theme.spacing(0, 1.5)
934
+ },
935
+ "&.with-no-pager .rows-count": {
936
+ flexGrow: 1
937
+ },
938
+ "& .MuiTablePagination-root": {
939
+ flexGrow: 1,
940
+ display: "flex",
941
+ justifyContent: "center",
942
+ overflow: "hidden"
943
+ }
944
+ }));
945
+ function Actions(props) {
946
+ const isDesktop = useResponsiveDesktop();
947
+ const {
948
+ rowHeights,
949
+ isSkeleton
950
+ } = useBase();
951
+ const {
952
+ withRowsCount = true,
953
+ withPager = true,
954
+ pagerOptions,
955
+ withSettings = true,
956
+ settingsProps,
957
+ withLocalFilters
958
+ } = props;
959
+ return /* @__PURE__ */ jsxs(WrapperActions, {
960
+ id: "WrapperActions",
961
+ className: withPager && pagerOptions ? "with-pager" : "with-no-pager",
962
+ children: [withRowsCount && isDesktop && /* @__PURE__ */ jsx(RowsCount, {}), withPager && pagerOptions && /* @__PURE__ */ jsx(Pager, {
963
+ ...pagerOptions,
964
+ totalRecords: pagerOptions.totalRecords,
965
+ isSkeleton
966
+ }), typeof rowHeights !== "number" && /* @__PURE__ */ jsx(Density, {}), withLocalFilters && /* @__PURE__ */ jsx(Filter, {}), withSettings && /* @__PURE__ */ jsx(Settings, {
967
+ ...settingsProps
968
+ })]
969
+ });
970
+ }
971
+ function getStandardActionsDictionary() {
972
+ return ["common_actions"];
973
+ }
974
+ const defaultActionsDictionary = {
975
+ common_actions: {
976
+ cancel: "Cancel",
977
+ intro: "Intro"
978
+ }
979
+ };
980
+ export { ActionsColumn as A, FormActions as F, LabelMemuItem as L, MenuActions as M, PagerActions as P, Actions as a, Actions$1 as b, defaultActionsDictionary as d, getStandardActionsDictionary as g };