@m4l/layouts 9.2.1 → 9.3.0
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/.storybook/utils/getStylesColorsByMode.d.ts +98 -70
- package/components/DynamicTabs/DynamicTabs.js +1 -1
- package/components/ModuleDetailTabs/ModuleDetailTabs.js +2 -2
- package/components/ModuleDetailTabs/index.d.ts +1 -1
- package/components/ModuleDetailTabs/useModuleDatailTabs.js +3 -2
- package/hooks/index.d.ts +1 -1
- package/hooks/useFormAddEdit/dictionary.d.ts +1 -0
- package/hooks/useFormAddEdit/index.d.ts +1 -0
- package/hooks/useFormAddEdit/types.d.ts +27 -0
- package/hooks/useFormAddEdit/useFormAddEdit.d.ts +11 -0
- package/hooks/useFormAddEdit/useFormAddEdit.js +79 -0
- package/hooks/useFormAddEdit/useFormAddEdit.test.d.ts +1 -0
- package/index.d.ts +0 -1
- package/index.js +10 -13
- package/layouts/MasterDetailLayout/MasterDetailLayout.js +9 -8
- package/layouts/MasterDetailLayout/types.d.ts +2 -0
- package/package.json +1 -1
- package/storybook/layouts/MasterDetailLayout/MasterDetailLayout.stories.d.ts +1 -0
- package/storybook/layouts/MasterDetailLayout/subcomponents/RenderMasterDetailLayout.d.ts +5 -1
- package/contexts/AuthContext/index.d.ts +0 -7
- package/contexts/AuthContext/index.js +0 -142
- package/contexts/AuthContext/types.d.ts +0 -51
- package/contexts/AuthContext/types.js +0 -9
- package/contexts/index.d.ts +0 -1
- package/hooks/useAuth/index.d.ts +0 -5
- package/hooks/useAuth/index.js +0 -12
- /package/{contexts → hooks/useFormAddEdit}/index.js +0 -0
|
@@ -53,6 +53,8 @@ export declare const colorsLight: {
|
|
|
53
53
|
readonly surface: string;
|
|
54
54
|
readonly hover: string;
|
|
55
55
|
readonly backdrop: string;
|
|
56
|
+
readonly base: string;
|
|
57
|
+
readonly blur: string;
|
|
56
58
|
readonly paper: "#000";
|
|
57
59
|
};
|
|
58
60
|
readonly chips: {
|
|
@@ -62,35 +64,40 @@ export declare const colorsLight: {
|
|
|
62
64
|
readonly warning: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
63
65
|
readonly default: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
64
66
|
readonly forest: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
67
|
+
readonly pink: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
68
|
+
readonly orange: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
69
|
+
readonly candy: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
70
|
+
readonly persianGreen: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
71
|
+
readonly aqua: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
65
72
|
readonly disabled: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
66
73
|
readonly primary: {
|
|
67
74
|
readonly outlined: {
|
|
68
|
-
readonly color:
|
|
69
|
-
readonly backgroundColor:
|
|
70
|
-
readonly backgroundHover:
|
|
71
|
-
readonly backgroundActive:
|
|
72
|
-
readonly colorTone:
|
|
73
|
-
readonly backgroundColorTone:
|
|
74
|
-
readonly backgroundHoverTone:
|
|
75
|
-
readonly backgroundActiveTone:
|
|
75
|
+
readonly color: string;
|
|
76
|
+
readonly backgroundColor: string;
|
|
77
|
+
readonly backgroundHover: string;
|
|
78
|
+
readonly backgroundActive: string;
|
|
79
|
+
readonly colorTone: string;
|
|
80
|
+
readonly backgroundColorTone: string;
|
|
81
|
+
readonly backgroundHoverTone: string;
|
|
82
|
+
readonly backgroundActiveTone: string;
|
|
76
83
|
};
|
|
77
84
|
readonly contained: {
|
|
78
|
-
readonly color:
|
|
79
|
-
readonly backgroundColor:
|
|
80
|
-
readonly backgroundHover:
|
|
81
|
-
readonly backgroundActive:
|
|
82
|
-
readonly colorTone:
|
|
83
|
-
readonly backgroundColorTone:
|
|
84
|
-
readonly backgroundHoverTone:
|
|
85
|
-
readonly backgroundActiveTone:
|
|
85
|
+
readonly color: string;
|
|
86
|
+
readonly backgroundColor: string;
|
|
87
|
+
readonly backgroundHover: string;
|
|
88
|
+
readonly backgroundActive: string;
|
|
89
|
+
readonly colorTone: string;
|
|
90
|
+
readonly backgroundColorTone: string;
|
|
91
|
+
readonly backgroundHoverTone: string;
|
|
92
|
+
readonly backgroundActiveTone: string;
|
|
86
93
|
};
|
|
87
94
|
};
|
|
88
95
|
};
|
|
89
96
|
readonly border: {
|
|
90
97
|
readonly main: string;
|
|
98
|
+
readonly dens: string;
|
|
91
99
|
readonly default: string;
|
|
92
100
|
readonly secondary: string;
|
|
93
|
-
readonly dens: string;
|
|
94
101
|
readonly disabled: string;
|
|
95
102
|
readonly error: string;
|
|
96
103
|
};
|
|
@@ -238,6 +245,8 @@ export declare const colorsLight: {
|
|
|
238
245
|
readonly surface: string;
|
|
239
246
|
readonly hover: string;
|
|
240
247
|
readonly backdrop: string;
|
|
248
|
+
readonly base: string;
|
|
249
|
+
readonly blur: string;
|
|
241
250
|
readonly paper: "#000";
|
|
242
251
|
};
|
|
243
252
|
readonly chips: {
|
|
@@ -247,35 +256,40 @@ export declare const colorsLight: {
|
|
|
247
256
|
readonly warning: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
248
257
|
readonly default: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
249
258
|
readonly forest: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
259
|
+
readonly pink: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
260
|
+
readonly orange: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
261
|
+
readonly candy: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
262
|
+
readonly persianGreen: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
263
|
+
readonly aqua: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
250
264
|
readonly disabled: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
251
265
|
readonly primary: {
|
|
252
266
|
readonly outlined: {
|
|
253
|
-
readonly color:
|
|
254
|
-
readonly backgroundColor:
|
|
255
|
-
readonly backgroundHover:
|
|
256
|
-
readonly backgroundActive:
|
|
257
|
-
readonly colorTone:
|
|
258
|
-
readonly backgroundColorTone:
|
|
259
|
-
readonly backgroundHoverTone:
|
|
260
|
-
readonly backgroundActiveTone:
|
|
267
|
+
readonly color: string;
|
|
268
|
+
readonly backgroundColor: string;
|
|
269
|
+
readonly backgroundHover: string;
|
|
270
|
+
readonly backgroundActive: string;
|
|
271
|
+
readonly colorTone: string;
|
|
272
|
+
readonly backgroundColorTone: string;
|
|
273
|
+
readonly backgroundHoverTone: string;
|
|
274
|
+
readonly backgroundActiveTone: string;
|
|
261
275
|
};
|
|
262
276
|
readonly contained: {
|
|
263
|
-
readonly color:
|
|
264
|
-
readonly backgroundColor:
|
|
265
|
-
readonly backgroundHover:
|
|
266
|
-
readonly backgroundActive:
|
|
267
|
-
readonly colorTone:
|
|
268
|
-
readonly backgroundColorTone:
|
|
269
|
-
readonly backgroundHoverTone:
|
|
270
|
-
readonly backgroundActiveTone:
|
|
277
|
+
readonly color: string;
|
|
278
|
+
readonly backgroundColor: string;
|
|
279
|
+
readonly backgroundHover: string;
|
|
280
|
+
readonly backgroundActive: string;
|
|
281
|
+
readonly colorTone: string;
|
|
282
|
+
readonly backgroundColorTone: string;
|
|
283
|
+
readonly backgroundHoverTone: string;
|
|
284
|
+
readonly backgroundActiveTone: string;
|
|
271
285
|
};
|
|
272
286
|
};
|
|
273
287
|
};
|
|
274
288
|
readonly border: {
|
|
275
289
|
readonly main: string;
|
|
276
|
-
readonly default: string;
|
|
277
|
-
readonly secondary: string;
|
|
278
290
|
readonly dens: string;
|
|
291
|
+
readonly default: string | undefined;
|
|
292
|
+
readonly secondary: string;
|
|
279
293
|
readonly disabled: string;
|
|
280
294
|
readonly error: string;
|
|
281
295
|
};
|
|
@@ -424,6 +438,8 @@ export declare const colorsDark: {
|
|
|
424
438
|
readonly surface: string;
|
|
425
439
|
readonly hover: string;
|
|
426
440
|
readonly backdrop: string;
|
|
441
|
+
readonly base: string;
|
|
442
|
+
readonly blur: string;
|
|
427
443
|
readonly paper: "#000";
|
|
428
444
|
};
|
|
429
445
|
readonly chips: {
|
|
@@ -433,35 +449,40 @@ export declare const colorsDark: {
|
|
|
433
449
|
readonly warning: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
434
450
|
readonly default: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
435
451
|
readonly forest: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
452
|
+
readonly pink: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
453
|
+
readonly orange: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
454
|
+
readonly candy: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
455
|
+
readonly persianGreen: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
456
|
+
readonly aqua: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
436
457
|
readonly disabled: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
437
458
|
readonly primary: {
|
|
438
459
|
readonly outlined: {
|
|
439
|
-
readonly color:
|
|
440
|
-
readonly backgroundColor:
|
|
441
|
-
readonly backgroundHover:
|
|
442
|
-
readonly backgroundActive:
|
|
443
|
-
readonly colorTone:
|
|
444
|
-
readonly backgroundColorTone:
|
|
445
|
-
readonly backgroundHoverTone:
|
|
446
|
-
readonly backgroundActiveTone:
|
|
460
|
+
readonly color: string;
|
|
461
|
+
readonly backgroundColor: string;
|
|
462
|
+
readonly backgroundHover: string;
|
|
463
|
+
readonly backgroundActive: string;
|
|
464
|
+
readonly colorTone: string;
|
|
465
|
+
readonly backgroundColorTone: string;
|
|
466
|
+
readonly backgroundHoverTone: string;
|
|
467
|
+
readonly backgroundActiveTone: string;
|
|
447
468
|
};
|
|
448
469
|
readonly contained: {
|
|
449
|
-
readonly color:
|
|
450
|
-
readonly backgroundColor:
|
|
451
|
-
readonly backgroundHover:
|
|
452
|
-
readonly backgroundActive:
|
|
453
|
-
readonly colorTone:
|
|
454
|
-
readonly backgroundColorTone:
|
|
455
|
-
readonly backgroundHoverTone:
|
|
456
|
-
readonly backgroundActiveTone:
|
|
470
|
+
readonly color: string;
|
|
471
|
+
readonly backgroundColor: string;
|
|
472
|
+
readonly backgroundHover: string;
|
|
473
|
+
readonly backgroundActive: string;
|
|
474
|
+
readonly colorTone: string;
|
|
475
|
+
readonly backgroundColorTone: string;
|
|
476
|
+
readonly backgroundHoverTone: string;
|
|
477
|
+
readonly backgroundActiveTone: string;
|
|
457
478
|
};
|
|
458
479
|
};
|
|
459
480
|
};
|
|
460
481
|
readonly border: {
|
|
461
482
|
readonly main: string;
|
|
483
|
+
readonly dens: string;
|
|
462
484
|
readonly default: string;
|
|
463
485
|
readonly secondary: string;
|
|
464
|
-
readonly dens: string;
|
|
465
486
|
readonly disabled: string;
|
|
466
487
|
readonly error: string;
|
|
467
488
|
};
|
|
@@ -609,6 +630,8 @@ export declare const colorsDark: {
|
|
|
609
630
|
readonly surface: string;
|
|
610
631
|
readonly hover: string;
|
|
611
632
|
readonly backdrop: string;
|
|
633
|
+
readonly base: string;
|
|
634
|
+
readonly blur: string;
|
|
612
635
|
readonly paper: "#000";
|
|
613
636
|
};
|
|
614
637
|
readonly chips: {
|
|
@@ -618,35 +641,40 @@ export declare const colorsDark: {
|
|
|
618
641
|
readonly warning: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
619
642
|
readonly default: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
620
643
|
readonly forest: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
644
|
+
readonly pink: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
645
|
+
readonly orange: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
646
|
+
readonly candy: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
647
|
+
readonly persianGreen: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
648
|
+
readonly aqua: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
621
649
|
readonly disabled: Record<import('@m4l/styles').ChipColorVariant, import('@m4l/styles').ChipColor>;
|
|
622
650
|
readonly primary: {
|
|
623
651
|
readonly outlined: {
|
|
624
|
-
readonly color:
|
|
625
|
-
readonly backgroundColor:
|
|
626
|
-
readonly backgroundHover:
|
|
627
|
-
readonly backgroundActive:
|
|
628
|
-
readonly colorTone:
|
|
629
|
-
readonly backgroundColorTone:
|
|
630
|
-
readonly backgroundHoverTone:
|
|
631
|
-
readonly backgroundActiveTone:
|
|
652
|
+
readonly color: string;
|
|
653
|
+
readonly backgroundColor: string;
|
|
654
|
+
readonly backgroundHover: string;
|
|
655
|
+
readonly backgroundActive: string;
|
|
656
|
+
readonly colorTone: string;
|
|
657
|
+
readonly backgroundColorTone: string;
|
|
658
|
+
readonly backgroundHoverTone: string;
|
|
659
|
+
readonly backgroundActiveTone: string;
|
|
632
660
|
};
|
|
633
661
|
readonly contained: {
|
|
634
|
-
readonly color:
|
|
635
|
-
readonly backgroundColor:
|
|
636
|
-
readonly backgroundHover:
|
|
637
|
-
readonly backgroundActive:
|
|
638
|
-
readonly colorTone:
|
|
639
|
-
readonly backgroundColorTone:
|
|
640
|
-
readonly backgroundHoverTone:
|
|
641
|
-
readonly backgroundActiveTone:
|
|
662
|
+
readonly color: string;
|
|
663
|
+
readonly backgroundColor: string;
|
|
664
|
+
readonly backgroundHover: string;
|
|
665
|
+
readonly backgroundActive: string;
|
|
666
|
+
readonly colorTone: string;
|
|
667
|
+
readonly backgroundColorTone: string;
|
|
668
|
+
readonly backgroundHoverTone: string;
|
|
669
|
+
readonly backgroundActiveTone: string;
|
|
642
670
|
};
|
|
643
671
|
};
|
|
644
672
|
};
|
|
645
673
|
readonly border: {
|
|
646
674
|
readonly main: string;
|
|
647
|
-
readonly default: string;
|
|
648
|
-
readonly secondary: string;
|
|
649
675
|
readonly dens: string;
|
|
676
|
+
readonly default: string | undefined;
|
|
677
|
+
readonly secondary: string;
|
|
650
678
|
readonly disabled: string;
|
|
651
679
|
readonly error: string;
|
|
652
680
|
};
|
|
@@ -16,7 +16,7 @@ function DynamicTabs(props) {
|
|
|
16
16
|
onChange: (_e, value) => handleChangeTab(value),
|
|
17
17
|
children: finalTabs.map((tab) => {
|
|
18
18
|
const { value, tabProps } = tab;
|
|
19
|
-
return /* @__PURE__ */ jsx(Tab, { value,
|
|
19
|
+
return /* @__PURE__ */ jsx(Tab, { value, ...tabProps }, value);
|
|
20
20
|
})
|
|
21
21
|
}
|
|
22
22
|
),
|
|
@@ -19,8 +19,8 @@ function ModuleDetailTabs(props) {
|
|
|
19
19
|
allowScrollButtonsMobile: true,
|
|
20
20
|
onChange: (_e, value) => handleChangeTab(value),
|
|
21
21
|
children: finalTabs.map((tab) => {
|
|
22
|
-
const { value, label } = tab;
|
|
23
|
-
return /* @__PURE__ */ jsx(Tab, { value, label }, value);
|
|
22
|
+
const { value, label, icon } = tab;
|
|
23
|
+
return /* @__PURE__ */ jsx(Tab, { value, label, icon }, value);
|
|
24
24
|
})
|
|
25
25
|
}
|
|
26
26
|
),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { ModuleDetailTabs } from './ModuleDetailTabs';
|
|
2
|
-
export type { ModuleDatailTab, ModuleDetailObjectLogs, ModuleDetailTabContent, ModuleDetailTabsProps } from './types';
|
|
2
|
+
export type { ModuleDatailTab, ModuleDetailObjectLogs, ModuleDetailOtherObjectLogs, ModuleDetailM4LObjectLogs, ModuleDetailTabContent, ModuleDetailTabsProps } from './types';
|
|
@@ -38,13 +38,14 @@ function useModuleDetailTabs(props) {
|
|
|
38
38
|
value: "objectLogs",
|
|
39
39
|
tabContent: ObjectLogs,
|
|
40
40
|
unmountable: false,
|
|
41
|
-
componentProps
|
|
41
|
+
componentProps,
|
|
42
|
+
icon: "/main/na/icons/i_common_master_detail_layout_detail_tab_logs"
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
return arrTabs.map((tab) => ({
|
|
45
46
|
...tab,
|
|
46
47
|
unmountable: tab.unmountable === void 0 ? true : tab.unmountable,
|
|
47
|
-
icon: typeof tab.icon === "string" ? /* @__PURE__ */ jsx(Icon, { src: `${urlAssetsPrefix}
|
|
48
|
+
icon: typeof tab.icon === "string" ? /* @__PURE__ */ jsx(Icon, { src: `${urlAssetsPrefix}${tab.icon}` }) : tab.icon,
|
|
48
49
|
label: tab.dictionaryId ? getLabel(tab.dictionaryId) : void 0
|
|
49
50
|
}));
|
|
50
51
|
}, [masterSelection, tabs, objectLogsProps, urlAssetsPrefix, getLabel]);
|
package/hooks/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getformAddEditDictionary: () => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useFormAddEdit';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { NetworkProps } from '@m4l/core';
|
|
2
|
+
import { FieldValues } from 'react-hook-form';
|
|
3
|
+
export type ResponseEndpoint<TEndpointValues = FieldValues> = {
|
|
4
|
+
data: TEndpointValues;
|
|
5
|
+
};
|
|
6
|
+
export interface UseFormAddEditProps<TValues = FieldValues, TEndpointValues = FieldValues> {
|
|
7
|
+
/**
|
|
8
|
+
* Id del objeto, si se define, se llama al endpoint para obtener los datos
|
|
9
|
+
*/
|
|
10
|
+
objectId?: number | string;
|
|
11
|
+
/**
|
|
12
|
+
* Valores iniciales del formulario
|
|
13
|
+
*/
|
|
14
|
+
initialValues: TValues;
|
|
15
|
+
/**
|
|
16
|
+
* Funcion para formatear los datos del endpoint
|
|
17
|
+
*/
|
|
18
|
+
formatDataEndpoint?: (response: ResponseEndpoint<TEndpointValues>) => TValues;
|
|
19
|
+
/**
|
|
20
|
+
* Si se define en true, no se llama al endpoint
|
|
21
|
+
*/
|
|
22
|
+
omitCallEnpoint?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Props para llamar al networkOperation
|
|
25
|
+
*/
|
|
26
|
+
networkProps: NetworkProps;
|
|
27
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UseFormAddEditProps } from './types';
|
|
2
|
+
import { FormStatusLoad } from '@m4l/components';
|
|
3
|
+
import { FieldValues } from 'react-hook-form';
|
|
4
|
+
/**
|
|
5
|
+
* TODO: Documentar
|
|
6
|
+
*/
|
|
7
|
+
export declare function useFormAddEdit<TValues extends FieldValues = FieldValues, TEndpointValues extends FieldValues = FieldValues>(props: UseFormAddEditProps<TValues, TEndpointValues>): {
|
|
8
|
+
formValues: TValues;
|
|
9
|
+
statusLoad: FormStatusLoad;
|
|
10
|
+
refresh: () => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useNetwork, useFlagsStore, useModuleDictionary } from "@m4l/core";
|
|
3
|
+
import { useState, useCallback, useEffect } from "react";
|
|
4
|
+
import { useModal, WindowConfirm } from "@m4l/components";
|
|
5
|
+
function useFormAddEdit(props) {
|
|
6
|
+
const {
|
|
7
|
+
initialValues,
|
|
8
|
+
objectId,
|
|
9
|
+
networkProps,
|
|
10
|
+
formatDataEndpoint,
|
|
11
|
+
omitCallEnpoint = false
|
|
12
|
+
} = props;
|
|
13
|
+
const { openModal, closeModal } = useModal();
|
|
14
|
+
const [formValues, setFormValues] = useState(initialValues);
|
|
15
|
+
const [statusLoad, setStatusLoad] = useState(
|
|
16
|
+
objectId === void 0 ? "new" : "edit"
|
|
17
|
+
);
|
|
18
|
+
const { networkOperation } = useNetwork();
|
|
19
|
+
const addFlag = useFlagsStore((state) => state.flagsActions.addFlag);
|
|
20
|
+
const { getLabel } = useModuleDictionary();
|
|
21
|
+
const refresh = useCallback(() => {
|
|
22
|
+
if (statusLoad === "ready") {
|
|
23
|
+
setStatusLoad("edit");
|
|
24
|
+
}
|
|
25
|
+
}, [statusLoad]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
let mounted = true;
|
|
28
|
+
if (statusLoad === "edit") {
|
|
29
|
+
if (omitCallEnpoint) {
|
|
30
|
+
addFlag("form_loaded");
|
|
31
|
+
setStatusLoad("ready");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
networkOperation(networkProps).then(
|
|
35
|
+
(response) => {
|
|
36
|
+
if (mounted) {
|
|
37
|
+
if (formatDataEndpoint) {
|
|
38
|
+
setFormValues(formatDataEndpoint(response));
|
|
39
|
+
} else {
|
|
40
|
+
setFormValues(response.data);
|
|
41
|
+
}
|
|
42
|
+
setStatusLoad("reload_values_provider");
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
() => {
|
|
46
|
+
setStatusLoad("error");
|
|
47
|
+
openModal({
|
|
48
|
+
window: /* @__PURE__ */ jsx(
|
|
49
|
+
WindowConfirm,
|
|
50
|
+
{
|
|
51
|
+
variant: "error",
|
|
52
|
+
title: getLabel("form_add_edit.label_error_title"),
|
|
53
|
+
msg: getLabel("form_add_edit.error_authorization_message"),
|
|
54
|
+
onClickIntro: () => closeModal()
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
variant: "delete"
|
|
58
|
+
});
|
|
59
|
+
addFlag("form_loaded");
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
} else if (statusLoad === "new" || statusLoad === "reload_values_provider") {
|
|
63
|
+
addFlag("form_loaded");
|
|
64
|
+
setStatusLoad("ready");
|
|
65
|
+
}
|
|
66
|
+
return () => {
|
|
67
|
+
mounted = false;
|
|
68
|
+
};
|
|
69
|
+
}, [statusLoad]);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (statusLoad === "ready" && objectId !== void 0) {
|
|
72
|
+
setStatusLoad("edit");
|
|
73
|
+
}
|
|
74
|
+
}, [objectId]);
|
|
75
|
+
return { formValues, statusLoad, refresh };
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
useFormAddEdit as u
|
|
79
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -3,7 +3,6 @@ import { M } from "./components/MFNoAuthApp/index.js";
|
|
|
3
3
|
import { M as M2 } from "./components/MFHostApp/MFHostApp.js";
|
|
4
4
|
import { M as M3 } from "./components/ModuleDetailTabs/ModuleDetailTabs.js";
|
|
5
5
|
import { D } from "./components/DynamicTabs/DynamicTabs.js";
|
|
6
|
-
import { A, a } from "./contexts/AuthContext/index.js";
|
|
7
6
|
import { M as M4 } from "./layouts/ModuleLayout/ModuleLayout.js";
|
|
8
7
|
import { N } from "./layouts/NoAuthModuleLayout/index.js";
|
|
9
8
|
import { d, g } from "./layouts/ModuleLayout/dicctionary.js";
|
|
@@ -11,15 +10,13 @@ import { M as M5 } from "./layouts/MasterDetailLayout/MasterDetailLayout.js";
|
|
|
11
10
|
import { g as g2 } from "./layouts/MasterDetailLayout/dicctionary.js";
|
|
12
11
|
import { d as d2, g as g3 } from "./layouts/NoAuthModuleLayout/dicctionary.js";
|
|
13
12
|
import { u } from "./hooks/useMasterDetail/index.js";
|
|
14
|
-
import { u as u2 } from "./hooks/
|
|
15
|
-
import { u as u3 } from "./hooks/
|
|
16
|
-
import { u as u4 } from "./hooks/
|
|
17
|
-
import {
|
|
18
|
-
import { u as u6 } from "./hooks/
|
|
13
|
+
import { u as u2 } from "./hooks/useModule/index.js";
|
|
14
|
+
import { u as u3 } from "./hooks/useDynamicAccordions/useDynamicAccordions.js";
|
|
15
|
+
import { c, u as u4 } from "./hooks/useDynamicPaperForm/useDynamicPaperForm.js";
|
|
16
|
+
import { u as u5 } from "./hooks/useNetworkActionConfirm/useNetworkActionConfirm.js";
|
|
17
|
+
import { u as u6 } from "./hooks/useFormAddEdit/useFormAddEdit.js";
|
|
19
18
|
import { c as c2 } from "./utils/createAppMF.js";
|
|
20
19
|
export {
|
|
21
|
-
A as AuthContext,
|
|
22
|
-
a as AuthProvider,
|
|
23
20
|
D as DynamicTabs,
|
|
24
21
|
L as LIMIT_RECORDS_500_CONFIG,
|
|
25
22
|
M2 as MFHostApp,
|
|
@@ -35,10 +32,10 @@ export {
|
|
|
35
32
|
g2 as getMasterDetailLayoutComponentsDictionary,
|
|
36
33
|
g as getModuleLayoutComponentsDictionary,
|
|
37
34
|
g3 as getNoAuthModuleLayoutComponentsDictionary,
|
|
38
|
-
|
|
39
|
-
u4 as
|
|
40
|
-
|
|
35
|
+
u3 as useDynamicAccordions,
|
|
36
|
+
u4 as useDynamicPaperForm,
|
|
37
|
+
u6 as useFormAddEdit,
|
|
41
38
|
u as useMasterDetail,
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
u2 as useModule,
|
|
40
|
+
u5 as useNetworkActionConfirm
|
|
44
41
|
};
|
|
@@ -16,15 +16,16 @@ function MasterDetailLayout(props) {
|
|
|
16
16
|
masterComponent,
|
|
17
17
|
detailComponent,
|
|
18
18
|
moduleActions,
|
|
19
|
-
version
|
|
19
|
+
version,
|
|
20
|
+
splitPosition
|
|
20
21
|
} = props;
|
|
21
22
|
const { host_static_assets, environment_assets } = useEnvironment();
|
|
22
|
-
const [
|
|
23
|
+
const [splitPositionState, setSplitPositionState] = useState(splitPosition ?? "vertical");
|
|
23
24
|
const isMobile = useIsMobile();
|
|
24
25
|
const moduleLayoutRef = useRef(null);
|
|
25
26
|
const { getLabel } = useModuleDictionary();
|
|
26
27
|
const onChangePostionInternal = useCallback((newPostion) => {
|
|
27
|
-
|
|
28
|
+
setSplitPositionState(newPostion);
|
|
28
29
|
}, []);
|
|
29
30
|
const splitActions = useMemo(
|
|
30
31
|
() => [
|
|
@@ -35,7 +36,7 @@ function MasterDetailLayout(props) {
|
|
|
35
36
|
label: getLabel(dictionary.LABEL_SPLIT_VERTICAL),
|
|
36
37
|
tag: "vertical",
|
|
37
38
|
className: "splitactions",
|
|
38
|
-
disabled:
|
|
39
|
+
disabled: splitPositionState === "vertical",
|
|
39
40
|
key: "vertical"
|
|
40
41
|
},
|
|
41
42
|
{
|
|
@@ -45,7 +46,7 @@ function MasterDetailLayout(props) {
|
|
|
45
46
|
label: getLabel(dictionary.LABEL_SPLIT_HORIZONTAL),
|
|
46
47
|
tag: "horizontal",
|
|
47
48
|
className: "splitactions",
|
|
48
|
-
disabled:
|
|
49
|
+
disabled: splitPositionState === "horizontal",
|
|
49
50
|
key: "horizontal"
|
|
50
51
|
},
|
|
51
52
|
{
|
|
@@ -55,11 +56,11 @@ function MasterDetailLayout(props) {
|
|
|
55
56
|
label: getLabel(dictionary.LABEL_NO_SPLIT),
|
|
56
57
|
tag: "none",
|
|
57
58
|
className: "splitactions",
|
|
58
|
-
disabled:
|
|
59
|
+
disabled: splitPositionState === "none",
|
|
59
60
|
key: "none"
|
|
60
61
|
}
|
|
61
62
|
],
|
|
62
|
-
[getLabel,
|
|
63
|
+
[getLabel, splitPositionState, environment_assets, host_static_assets, onChangePostionInternal]
|
|
63
64
|
);
|
|
64
65
|
const onClickViewDetail = useCallback(() => {
|
|
65
66
|
moduleLayoutRef.current?.openModal({
|
|
@@ -95,7 +96,7 @@ function MasterDetailLayout(props) {
|
|
|
95
96
|
children: /* @__PURE__ */ jsx(
|
|
96
97
|
SplitLayout,
|
|
97
98
|
{
|
|
98
|
-
splitPosition: isMobile ? "none" :
|
|
99
|
+
splitPosition: isMobile ? "none" : splitPositionState,
|
|
99
100
|
firstPart: masterComponent,
|
|
100
101
|
secondPart: detailComponent
|
|
101
102
|
}
|
|
@@ -4,10 +4,12 @@ import { OverridesStyleRules } from '@mui/material/styles/overrides';
|
|
|
4
4
|
import { MasterDetailLayoutSlots } from './slots/MasterDetailLayoutEnum';
|
|
5
5
|
import { MASTER_DETAIL_LAYOUT_PREFIX } from './constants';
|
|
6
6
|
import { Theme } from '@mui/material/styles';
|
|
7
|
+
import { SplitPosition } from '@m4l/components';
|
|
7
8
|
export interface ContainerProps {
|
|
8
9
|
vertical: boolean;
|
|
9
10
|
}
|
|
10
11
|
export interface MasterDetailLayoutProps extends Omit<ModuleLayoutProps, 'children'> {
|
|
12
|
+
splitPosition?: SplitPosition;
|
|
11
13
|
masterComponent: ((props?: any) => JSX.Element) | ReactNode;
|
|
12
14
|
detailComponent: ((props?: any) => JSX.Element) | ReactNode;
|
|
13
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import { SplitPosition } from '@m4l/components';
|
|
2
|
+
interface RenderMasterDetailLayoutProps {
|
|
3
|
+
splitPosition?: SplitPosition;
|
|
4
|
+
}
|
|
1
5
|
/**
|
|
2
6
|
* Render para utilizar el componente ModuleLayout
|
|
3
7
|
* en AreasViewer en el storybook
|
|
4
8
|
*/
|
|
5
|
-
declare const RenderMasterDetailLayout: () => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare const RenderMasterDetailLayout: (props: RenderMasterDetailLayoutProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
10
|
export default RenderMasterDetailLayout;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AuthProviderProps, SessionContextType } from './types';
|
|
2
|
-
declare const AuthContext: import('react').Context<SessionContextType | null>;
|
|
3
|
-
/**
|
|
4
|
-
* Proveedor de autenticación
|
|
5
|
-
*/
|
|
6
|
-
declare function AuthProvider(props: AuthProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export { AuthContext, AuthProvider };
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useReducer, useEffect } from "react";
|
|
3
|
-
import { useHostTools, useNetwork, useEnvironment, useLocalStorageWithListener, EmitEvents, getLocalStorage, setLocalStorage } from "@m4l/core";
|
|
4
|
-
import { E as EnumTypes } from "./types.js";
|
|
5
|
-
const initialState = {
|
|
6
|
-
isAuthenticated: false,
|
|
7
|
-
isInitialized: false,
|
|
8
|
-
user: null
|
|
9
|
-
};
|
|
10
|
-
const JWTReducer = (state, action) => {
|
|
11
|
-
switch (action.type) {
|
|
12
|
-
case "INITIALIZE":
|
|
13
|
-
return {
|
|
14
|
-
isAuthenticated: action.payload.isAuthenticated,
|
|
15
|
-
isInitialized: true,
|
|
16
|
-
user: action.payload.user
|
|
17
|
-
};
|
|
18
|
-
case "LOGIN":
|
|
19
|
-
return {
|
|
20
|
-
...state,
|
|
21
|
-
isAuthenticated: true,
|
|
22
|
-
user: action.payload.user
|
|
23
|
-
};
|
|
24
|
-
case "LOGOUT":
|
|
25
|
-
return {
|
|
26
|
-
...state,
|
|
27
|
-
isAuthenticated: false,
|
|
28
|
-
user: null
|
|
29
|
-
};
|
|
30
|
-
default:
|
|
31
|
-
return state;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
const AuthContext = createContext(null);
|
|
35
|
-
function dispatchInitial(dispatch) {
|
|
36
|
-
dispatch({
|
|
37
|
-
type: EnumTypes.Initial,
|
|
38
|
-
payload: {
|
|
39
|
-
isAuthenticated: false,
|
|
40
|
-
user: null
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
function AuthProvider(props) {
|
|
45
|
-
const { children } = props;
|
|
46
|
-
const [state, dispatch] = useReducer(JWTReducer, initialState);
|
|
47
|
-
const { events_add_listener } = useHostTools();
|
|
48
|
-
const { networkOperation } = useNetwork();
|
|
49
|
-
const { domain_token } = useEnvironment();
|
|
50
|
-
const [nextValSession, setNextValSession] = useLocalStorageWithListener(
|
|
51
|
-
//Variable para saber si ha cambiado la session en otro navegador
|
|
52
|
-
"vSession",
|
|
53
|
-
(/* @__PURE__ */ new Date()).getTime() + ""
|
|
54
|
-
);
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
const initialize = async () => {
|
|
57
|
-
networkOperation({
|
|
58
|
-
method: "GET",
|
|
59
|
-
endPoint: `auth/login`,
|
|
60
|
-
parms: { user_data: true },
|
|
61
|
-
checkUnAuthorized: false
|
|
62
|
-
}).then((response) => {
|
|
63
|
-
dispatch({
|
|
64
|
-
type: EnumTypes.Initial,
|
|
65
|
-
payload: {
|
|
66
|
-
isAuthenticated: true,
|
|
67
|
-
user: response.user
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
const useSaved = getLocalStorage("userData", {
|
|
71
|
-
email: response.user.email,
|
|
72
|
-
remember: true
|
|
73
|
-
});
|
|
74
|
-
if (useSaved?.email !== response.user.email) {
|
|
75
|
-
setLocalStorage("userData", { email: response.user.email }, true);
|
|
76
|
-
}
|
|
77
|
-
}).catch(() => {
|
|
78
|
-
dispatchInitial(dispatch);
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
initialize();
|
|
82
|
-
}, [nextValSession]);
|
|
83
|
-
const login = async (email, password, remember) => {
|
|
84
|
-
await networkOperation({
|
|
85
|
-
endPoint: `auth/login`,
|
|
86
|
-
method: "POST",
|
|
87
|
-
data: {
|
|
88
|
-
email,
|
|
89
|
-
password,
|
|
90
|
-
domain_token
|
|
91
|
-
}
|
|
92
|
-
}).then((response) => {
|
|
93
|
-
const user = response.data;
|
|
94
|
-
if (remember) {
|
|
95
|
-
setLocalStorage("userData", { email, remember });
|
|
96
|
-
} else {
|
|
97
|
-
setLocalStorage("userData", { email: "", remember });
|
|
98
|
-
}
|
|
99
|
-
dispatch({
|
|
100
|
-
type: EnumTypes.Login,
|
|
101
|
-
payload: {
|
|
102
|
-
user
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
setNextValSession((/* @__PURE__ */ new Date()).getTime() + "");
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
const logout = async (isAuthenticated) => {
|
|
109
|
-
if (isAuthenticated) {
|
|
110
|
-
await networkOperation({
|
|
111
|
-
endPoint: `auth/logout`,
|
|
112
|
-
method: "POST"
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
dispatch({ type: EnumTypes.Logout });
|
|
116
|
-
setNextValSession((/* @__PURE__ */ new Date()).getTime() + "");
|
|
117
|
-
};
|
|
118
|
-
const onNetserviceUnautorized = () => {
|
|
119
|
-
logout(false);
|
|
120
|
-
};
|
|
121
|
-
useEffect(() => {
|
|
122
|
-
events_add_listener(
|
|
123
|
-
EmitEvents.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED,
|
|
124
|
-
onNetserviceUnautorized
|
|
125
|
-
);
|
|
126
|
-
}, []);
|
|
127
|
-
return /* @__PURE__ */ jsx(
|
|
128
|
-
AuthContext.Provider,
|
|
129
|
-
{
|
|
130
|
-
value: {
|
|
131
|
-
...state,
|
|
132
|
-
login,
|
|
133
|
-
logout
|
|
134
|
-
},
|
|
135
|
-
children
|
|
136
|
-
}
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
export {
|
|
140
|
-
AuthContext as A,
|
|
141
|
-
AuthProvider as a
|
|
142
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { DomainCountry, Maybe } from '@m4l/core';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
export declare enum EnumTypes {
|
|
4
|
-
Initial = "INITIALIZE",
|
|
5
|
-
Login = "LOGIN",
|
|
6
|
-
Logout = "LOGOUT"
|
|
7
|
-
}
|
|
8
|
-
export type AuthProviderProps = {
|
|
9
|
-
children: ReactNode;
|
|
10
|
-
};
|
|
11
|
-
export type ActionMap<M extends {
|
|
12
|
-
[index: string]: any;
|
|
13
|
-
}> = {
|
|
14
|
-
[Key in keyof M]: M[Key] extends undefined ? {
|
|
15
|
-
type: Key;
|
|
16
|
-
} : {
|
|
17
|
-
type: Key;
|
|
18
|
-
payload: M[Key];
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export type SessionAuthPayload = {
|
|
22
|
-
[EnumTypes.Initial]: {
|
|
23
|
-
isAuthenticated: boolean;
|
|
24
|
-
user: AuthUser;
|
|
25
|
-
};
|
|
26
|
-
[EnumTypes.Login]: {
|
|
27
|
-
user: AuthUser;
|
|
28
|
-
};
|
|
29
|
-
[EnumTypes.Logout]: undefined;
|
|
30
|
-
};
|
|
31
|
-
export type SessionActions = ActionMap<SessionAuthPayload>[keyof ActionMap<SessionAuthPayload>];
|
|
32
|
-
export interface User {
|
|
33
|
-
email: string;
|
|
34
|
-
id: number;
|
|
35
|
-
first_name: string;
|
|
36
|
-
last_name: string;
|
|
37
|
-
account_id: number;
|
|
38
|
-
domain_country: DomainCountry;
|
|
39
|
-
avatar_url?: Maybe<string>;
|
|
40
|
-
user_type_id?: number;
|
|
41
|
-
}
|
|
42
|
-
export type AuthUser = Maybe<User>;
|
|
43
|
-
export type AuthState = {
|
|
44
|
-
isAuthenticated: boolean;
|
|
45
|
-
isInitialized: boolean;
|
|
46
|
-
user: AuthUser;
|
|
47
|
-
};
|
|
48
|
-
export interface SessionContextType extends AuthState {
|
|
49
|
-
login: (email: string, password: string, remember: boolean) => object | undefined;
|
|
50
|
-
logout: (isAuthenticated: boolean) => Promise<void>;
|
|
51
|
-
}
|
package/contexts/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './AuthContext';
|
package/hooks/useAuth/index.d.ts
DELETED
package/hooks/useAuth/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { A as AuthContext } from "../../contexts/AuthContext/index.js";
|
|
3
|
-
const useAuth = () => {
|
|
4
|
-
const context = useContext(AuthContext);
|
|
5
|
-
if (!context) {
|
|
6
|
-
throw new Error("Auth context must be use inside AuthProvider");
|
|
7
|
-
}
|
|
8
|
-
return context;
|
|
9
|
-
};
|
|
10
|
-
export {
|
|
11
|
-
useAuth as u
|
|
12
|
-
};
|
|
File without changes
|