@m4l/layouts 9.1.13 → 9.1.15

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 (44) hide show
  1. package/components/ModuleDetailTabs/useModuleDatailTabs.d.ts +83 -83
  2. package/hooks/index.d.ts +1 -0
  3. package/hooks/useDynamicAccordions/useBaseAccordions.js +2 -2
  4. package/hooks/useDynamicPaperForm/index.d.ts +2 -0
  5. package/hooks/useDynamicPaperForm/index.js +1 -0
  6. package/hooks/useDynamicPaperForm/types.d.ts +25 -0
  7. package/hooks/useDynamicPaperForm/useDynamicPaperForm.d.ts +9 -0
  8. package/hooks/useDynamicPaperForm/useDynamicPaperForm.js +55 -0
  9. package/index.js +5 -2
  10. package/layouts/MasterDetailLayout/MasterDetailLayout.js +15 -18
  11. package/layouts/MasterDetailLayout/constants.d.ts +2 -0
  12. package/layouts/MasterDetailLayout/constants.js +6 -0
  13. package/layouts/MasterDetailLayout/contexts/MasterDetailContext/index.js +14 -5
  14. package/layouts/MasterDetailLayout/contexts/MasterDetailContext/store.d.ts +16 -0
  15. package/layouts/MasterDetailLayout/contexts/MasterDetailContext/store.js +50 -0
  16. package/layouts/MasterDetailLayout/contexts/MasterDetailContext/types.d.ts +28 -0
  17. package/layouts/MasterDetailLayout/dicctionary.d.ts +6 -2
  18. package/layouts/MasterDetailLayout/dicctionary.js +8 -3
  19. package/layouts/MasterDetailLayout/helpers/getTotalModuleActions.d.ts +5 -0
  20. package/layouts/MasterDetailLayout/helpers/getTotalModuleActions.js +8 -0
  21. package/layouts/MasterDetailLayout/icons.d.ts +5 -0
  22. package/layouts/MasterDetailLayout/icons.js +8 -0
  23. package/layouts/MasterDetailLayout/slots/MasterDetailLayoutEnum.d.ts +3 -0
  24. package/layouts/MasterDetailLayout/slots/MasterDetailLayoutEnum.js +7 -0
  25. package/layouts/MasterDetailLayout/slots/MasterDetailLayoutSlot.d.ts +1 -0
  26. package/layouts/MasterDetailLayout/slots/MasterDetailLayoutSlot.js +11 -0
  27. package/layouts/MasterDetailLayout/styles.d.ts +2 -1
  28. package/layouts/MasterDetailLayout/styles.js +37 -5
  29. package/layouts/MasterDetailLayout/tests/MasterDetailLayout.test.d.ts +1 -0
  30. package/layouts/MasterDetailLayout/types.d.ts +6 -0
  31. package/layouts/ModuleLayout/contexts/ModuleContext/store.js +3 -1
  32. package/package.json +1 -1
  33. package/storybook/layouts/MasterDetailLayout/MasterDetailLayout.stories.d.ts +6 -0
  34. package/storybook/layouts/MasterDetailLayout/moks/mokData.d.ts +7 -0
  35. package/storybook/layouts/MasterDetailLayout/subcomponents/RenderMasterDetailLayout.d.ts +6 -0
  36. package/test/constants.d.ts +0 -2
  37. package/test/mocks.d.ts +2 -0
  38. package/commonjs/index.js +0 -7
  39. package/layouts/MasterDetailLayout/classes/constants.d.ts +0 -1
  40. package/layouts/MasterDetailLayout/classes/constants.js +0 -4
  41. package/layouts/MasterDetailLayout/classes/index.d.ts +0 -9
  42. package/layouts/MasterDetailLayout/classes/index.js +0 -23
  43. package/layouts/MasterDetailLayout/classes/types.d.ts +0 -6
  44. package/not_recognized/index.js +0 -963
@@ -19,118 +19,118 @@ export declare function useModuleDetailTabs<T extends Record<string, any> = Reco
19
19
  size?: Extract<import('@m4l/styles').Sizes, "small" | "medium"> | undefined;
20
20
  children?: null | undefined;
21
21
  ref?: ((instance: HTMLDivElement | null) => void | import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import('react').DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import('react').RefObject<HTMLDivElement> | null | undefined;
22
- title?: string | undefined | undefined;
22
+ title?: string | undefined;
23
23
  component?: React.ElementType | undefined;
24
- id?: string | undefined | undefined;
24
+ id?: string | undefined;
25
25
  disabled?: boolean | undefined;
26
26
  action?: React.Ref<import('@mui/material').ButtonBaseActions> | undefined;
27
- hidden?: boolean | undefined | undefined;
27
+ hidden?: boolean | undefined;
28
28
  color?: Extract<import('@m4l/styles').ComponentPalletColor, "default"> | undefined;
29
- content?: string | undefined | undefined;
29
+ content?: string | undefined;
30
30
  style?: React.CSSProperties | undefined;
31
- translate?: "yes" | "no" | undefined | undefined;
31
+ translate?: "yes" | "no" | undefined;
32
32
  urlIcon?: string | undefined;
33
- lang?: string | undefined | undefined;
34
- slot?: string | undefined | undefined;
35
- dir?: string | undefined | undefined;
33
+ lang?: string | undefined;
34
+ slot?: string | undefined;
35
+ dir?: string | undefined;
36
36
  className?: string | undefined;
37
37
  classes?: (Partial<import('@mui/material').TabClasses> & Partial<import('@mui/material').ClassNameMap<never>>) | undefined;
38
38
  sx?: import('@mui/system').SxProps<import('@mui/material').Theme> | undefined;
39
39
  key?: import('react').Key | null | undefined;
40
- defaultChecked?: boolean | undefined | undefined;
40
+ defaultChecked?: boolean | undefined;
41
41
  defaultValue?: string | number | readonly string[] | undefined;
42
- suppressContentEditableWarning?: boolean | undefined | undefined;
43
- suppressHydrationWarning?: boolean | undefined | undefined;
44
- accessKey?: string | undefined | undefined;
45
- autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {}) | undefined;
46
- autoFocus?: boolean | undefined | undefined;
47
- contentEditable?: "inherit" | (boolean | "false" | "true") | "plaintext-only" | undefined;
48
- contextMenu?: string | undefined | undefined;
42
+ suppressContentEditableWarning?: boolean | undefined;
43
+ suppressHydrationWarning?: boolean | undefined;
44
+ accessKey?: string | undefined;
45
+ autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
46
+ autoFocus?: boolean | undefined;
47
+ contentEditable?: (boolean | "false" | "true") | "inherit" | "plaintext-only" | undefined;
48
+ contextMenu?: string | undefined;
49
49
  draggable?: (boolean | "false" | "true") | undefined;
50
- enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined | undefined;
51
- nonce?: string | undefined | undefined;
50
+ enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
51
+ nonce?: string | undefined;
52
52
  spellCheck?: (boolean | "false" | "true") | undefined;
53
53
  tabIndex?: NonNullable<React.HTMLAttributes<any>["tabIndex"]> | undefined;
54
- radioGroup?: string | undefined | undefined;
54
+ radioGroup?: string | undefined;
55
55
  role?: import('react').AriaRole | undefined;
56
- about?: string | undefined | undefined;
57
- datatype?: string | undefined | undefined;
56
+ about?: string | undefined;
57
+ datatype?: string | undefined;
58
58
  inlist?: any;
59
- prefix?: string | undefined | undefined;
60
- property?: string | undefined | undefined;
61
- rel?: string | undefined | undefined;
62
- resource?: string | undefined | undefined;
63
- rev?: string | undefined | undefined;
64
- typeof?: string | undefined | undefined;
65
- vocab?: string | undefined | undefined;
66
- autoCorrect?: string | undefined | undefined;
67
- autoSave?: string | undefined | undefined;
68
- itemProp?: string | undefined | undefined;
69
- itemScope?: boolean | undefined | undefined;
70
- itemType?: string | undefined | undefined;
71
- itemID?: string | undefined | undefined;
72
- itemRef?: string | undefined | undefined;
73
- results?: number | undefined | undefined;
74
- security?: string | undefined | undefined;
75
- unselectable?: "on" | "off" | undefined | undefined;
76
- inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
77
- is?: string | undefined | undefined;
78
- "aria-activedescendant"?: string | undefined | undefined;
59
+ prefix?: string | undefined;
60
+ property?: string | undefined;
61
+ rel?: string | undefined;
62
+ resource?: string | undefined;
63
+ rev?: string | undefined;
64
+ typeof?: string | undefined;
65
+ vocab?: string | undefined;
66
+ autoCorrect?: string | undefined;
67
+ autoSave?: string | undefined;
68
+ itemProp?: string | undefined;
69
+ itemScope?: boolean | undefined;
70
+ itemType?: string | undefined;
71
+ itemID?: string | undefined;
72
+ itemRef?: string | undefined;
73
+ results?: number | undefined;
74
+ security?: string | undefined;
75
+ unselectable?: "on" | "off" | undefined;
76
+ inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
77
+ is?: string | undefined;
78
+ "aria-activedescendant"?: string | undefined;
79
79
  "aria-atomic"?: (boolean | "false" | "true") | undefined;
80
- "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined | undefined;
81
- "aria-braillelabel"?: string | undefined | undefined;
82
- "aria-brailleroledescription"?: string | undefined | undefined;
80
+ "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
81
+ "aria-braillelabel"?: string | undefined;
82
+ "aria-brailleroledescription"?: string | undefined;
83
83
  "aria-busy"?: (boolean | "false" | "true") | undefined;
84
- "aria-checked"?: boolean | "false" | "mixed" | "true" | undefined | undefined;
85
- "aria-colcount"?: number | undefined | undefined;
86
- "aria-colindex"?: number | undefined | undefined;
87
- "aria-colindextext"?: string | undefined | undefined;
88
- "aria-colspan"?: number | undefined | undefined;
89
- "aria-controls"?: string | undefined | undefined;
90
- "aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined | undefined;
91
- "aria-describedby"?: string | undefined | undefined;
92
- "aria-description"?: string | undefined | undefined;
93
- "aria-details"?: string | undefined | undefined;
84
+ "aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
85
+ "aria-colcount"?: number | undefined;
86
+ "aria-colindex"?: number | undefined;
87
+ "aria-colindextext"?: string | undefined;
88
+ "aria-colspan"?: number | undefined;
89
+ "aria-controls"?: string | undefined;
90
+ "aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
91
+ "aria-describedby"?: string | undefined;
92
+ "aria-description"?: string | undefined;
93
+ "aria-details"?: string | undefined;
94
94
  "aria-disabled"?: (boolean | "false" | "true") | undefined;
95
- "aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined | undefined;
96
- "aria-errormessage"?: string | undefined | undefined;
95
+ "aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
96
+ "aria-errormessage"?: string | undefined;
97
97
  "aria-expanded"?: (boolean | "false" | "true") | undefined;
98
- "aria-flowto"?: string | undefined | undefined;
98
+ "aria-flowto"?: string | undefined;
99
99
  "aria-grabbed"?: (boolean | "false" | "true") | undefined;
100
- "aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined | undefined;
100
+ "aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
101
101
  "aria-hidden"?: (boolean | "false" | "true") | undefined;
102
- "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined | undefined;
103
- "aria-keyshortcuts"?: string | undefined | undefined;
104
- "aria-label"?: string | undefined | undefined;
105
- "aria-labelledby"?: string | undefined | undefined;
106
- "aria-level"?: number | undefined | undefined;
107
- "aria-live"?: "off" | "assertive" | "polite" | undefined | undefined;
102
+ "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
103
+ "aria-keyshortcuts"?: string | undefined;
104
+ "aria-label"?: string | undefined;
105
+ "aria-labelledby"?: string | undefined;
106
+ "aria-level"?: number | undefined;
107
+ "aria-live"?: "off" | "assertive" | "polite" | undefined;
108
108
  "aria-modal"?: (boolean | "false" | "true") | undefined;
109
109
  "aria-multiline"?: (boolean | "false" | "true") | undefined;
110
110
  "aria-multiselectable"?: (boolean | "false" | "true") | undefined;
111
- "aria-orientation"?: "horizontal" | "vertical" | undefined | undefined;
112
- "aria-owns"?: string | undefined | undefined;
113
- "aria-placeholder"?: string | undefined | undefined;
114
- "aria-posinset"?: number | undefined | undefined;
115
- "aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined | undefined;
111
+ "aria-orientation"?: "horizontal" | "vertical" | undefined;
112
+ "aria-owns"?: string | undefined;
113
+ "aria-placeholder"?: string | undefined;
114
+ "aria-posinset"?: number | undefined;
115
+ "aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
116
116
  "aria-readonly"?: (boolean | "false" | "true") | undefined;
117
- "aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined | undefined;
117
+ "aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined;
118
118
  "aria-required"?: (boolean | "false" | "true") | undefined;
119
- "aria-roledescription"?: string | undefined | undefined;
120
- "aria-rowcount"?: number | undefined | undefined;
121
- "aria-rowindex"?: number | undefined | undefined;
122
- "aria-rowindextext"?: string | undefined | undefined;
123
- "aria-rowspan"?: number | undefined | undefined;
119
+ "aria-roledescription"?: string | undefined;
120
+ "aria-rowcount"?: number | undefined;
121
+ "aria-rowindex"?: number | undefined;
122
+ "aria-rowindextext"?: string | undefined;
123
+ "aria-rowspan"?: number | undefined;
124
124
  "aria-selected"?: (boolean | "false" | "true") | undefined;
125
- "aria-setsize"?: number | undefined | undefined;
126
- "aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined | undefined;
127
- "aria-valuemax"?: number | undefined | undefined;
128
- "aria-valuemin"?: number | undefined | undefined;
129
- "aria-valuenow"?: number | undefined | undefined;
130
- "aria-valuetext"?: string | undefined | undefined;
125
+ "aria-setsize"?: number | undefined;
126
+ "aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
127
+ "aria-valuemax"?: number | undefined;
128
+ "aria-valuemin"?: number | undefined;
129
+ "aria-valuenow"?: number | undefined;
130
+ "aria-valuetext"?: string | undefined;
131
131
  dangerouslySetInnerHTML?: {
132
132
  __html: string | TrustedHTML;
133
- } | undefined | undefined;
133
+ } | undefined;
134
134
  onCopy?: import('react').ClipboardEventHandler<HTMLDivElement> | undefined;
135
135
  onCopyCapture?: import('react').ClipboardEventHandler<HTMLDivElement> | undefined;
136
136
  onCut?: import('react').ClipboardEventHandler<HTMLDivElement> | undefined;
@@ -302,7 +302,7 @@ export declare function useModuleDetailTabs<T extends Record<string, any> = Reco
302
302
  touchRippleRef?: React.Ref<import('@mui/material/ButtonBase/TouchRipple').TouchRippleActions> | undefined;
303
303
  disableFocusRipple?: boolean | undefined;
304
304
  dataTestId?: string | undefined;
305
- iconPosition?: "top" | "bottom" | "start" | "end" | undefined;
305
+ iconPosition?: ("top" | "bottom" | "start" | "end") | undefined;
306
306
  wrapped?: boolean | undefined;
307
307
  }[];
308
308
  handleChangeTab: (newValue: string) => void;
package/hooks/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from './useMasterDetail';
2
2
  export * from './useAuth';
3
3
  export * from './useModule';
4
4
  export * from './useDynamicAccordions';
5
+ export * from './useDynamicPaperForm';
@@ -17,14 +17,14 @@ function useBaseAccordions(props) {
17
17
  },
18
18
  children: accordion.properties.map((property) => {
19
19
  const value = property.getValue(data, endPointData);
20
- return value ? /* @__PURE__ */ jsx(
20
+ return /* @__PURE__ */ jsx(
21
21
  PropertyValue,
22
22
  {
23
23
  property: getLabel(property.dictionaryId),
24
24
  value
25
25
  },
26
26
  property.dictionaryId
27
- ) : null;
27
+ );
28
28
  })
29
29
  },
30
30
  accordion.dictionaryId
@@ -0,0 +1,2 @@
1
+ export * from './useDynamicPaperForm';
2
+ export type { PropertyValueField } from './types';
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,25 @@
1
+ interface PropertyValueFieldBase {
2
+ name: string;
3
+ type: 'RHFTexfField' | 'component';
4
+ label: string;
5
+ mandatory?: boolean;
6
+ }
7
+ interface PropertyValueRHFTexfField extends PropertyValueFieldBase {
8
+ type: 'RHFTexfField';
9
+ readOnly?: boolean;
10
+ disabled?: boolean;
11
+ textFieldType?: React.InputHTMLAttributes<unknown>['type'];
12
+ }
13
+ export interface PropertyValueOtherComponent<T extends React.ComponentType<any>> extends PropertyValueFieldBase {
14
+ type: 'component';
15
+ component: T;
16
+ componentProps: React.ComponentProps<T>;
17
+ }
18
+ export type PropertyValueField = PropertyValueRHFTexfField | PropertyValueOtherComponent<any>;
19
+ export type UseDynamicPaperFormProps = {
20
+ fields: PropertyValueField[];
21
+ title: string;
22
+ urlIcon: string;
23
+ isForm: boolean;
24
+ };
25
+ export {};
@@ -0,0 +1,9 @@
1
+ import { PropertyValueOtherComponent, UseDynamicPaperFormProps } from './types';
2
+ /**
3
+ * Factory function to create a component field
4
+ */
5
+ export declare function createComponentField<T extends React.ComponentType<any>>(params: PropertyValueOtherComponent<T>): PropertyValueOtherComponent<T>;
6
+ /**
7
+ * Datos de ubicación
8
+ */
9
+ export declare function useDynamicPaperForm(props: UseDynamicPaperFormProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,55 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { PaperForm, RHFTextField, PropertyValue } from "@m4l/components";
3
+ import { useModuleDictionary } from "@m4l/core";
4
+ function createComponentField(params) {
5
+ return params;
6
+ }
7
+ function useDynamicPaperForm(props) {
8
+ const { getLabel } = useModuleDictionary();
9
+ const { fields, title, urlIcon, isForm } = props;
10
+ return /* @__PURE__ */ jsx(
11
+ PaperForm,
12
+ {
13
+ urlIcon,
14
+ title,
15
+ isForm,
16
+ children: fields.map((field) => {
17
+ let component;
18
+ if (field.type === "RHFTexfField") {
19
+ component = /* @__PURE__ */ jsx(
20
+ RHFTextField,
21
+ {
22
+ name: field.name,
23
+ disabled: field.disabled,
24
+ type: field.textFieldType,
25
+ InputProps: {
26
+ readOnly: field.readOnly
27
+ }
28
+ },
29
+ field.name
30
+ );
31
+ } else {
32
+ component = /* @__PURE__ */ jsx(field.component, { ...field.componentProps });
33
+ }
34
+ return /* @__PURE__ */ jsx(
35
+ PropertyValue,
36
+ {
37
+ property: getLabel(`${field.label}`),
38
+ isForm: true,
39
+ propertyWidth: 150,
40
+ mandatory: field.mandatory,
41
+ mandatoryMessage: "*",
42
+ value: component,
43
+ dataTestId: field.name,
44
+ semanticWidth: "fullWidth"
45
+ },
46
+ field.name
47
+ );
48
+ })
49
+ }
50
+ );
51
+ }
52
+ export {
53
+ createComponentField as c,
54
+ useDynamicPaperForm as u
55
+ };
package/index.js CHANGED
@@ -12,7 +12,8 @@ import { u } from "./hooks/useMasterDetail/index.js";
12
12
  import { u as u2 } from "./hooks/useAuth/index.js";
13
13
  import { u as u3 } from "./hooks/useModule/index.js";
14
14
  import { u as u4 } from "./hooks/useDynamicAccordions/useDynamicAccordions.js";
15
- import { c } from "./utils/createAppMF.js";
15
+ import { c, u as u5 } from "./hooks/useDynamicPaperForm/useDynamicPaperForm.js";
16
+ import { c as c2 } from "./utils/createAppMF.js";
16
17
  export {
17
18
  A as AuthContext,
18
19
  a as AuthProvider,
@@ -22,7 +23,8 @@ export {
22
23
  M3 as ModuleDetailTabs,
23
24
  M4 as ModuleLayout,
24
25
  N as NoAuthModuleLayout,
25
- c as createAppMF,
26
+ c2 as createAppMF,
27
+ c as createComponentField,
26
28
  d as defaultModuleLayoutDictionary,
27
29
  d2 as defaultNoAuthModuleLayoutDictionary,
28
30
  g2 as getMasterDetailLayoutComponentsDictionary,
@@ -30,6 +32,7 @@ export {
30
32
  g3 as getNoAuthModuleLayoutComponentsDictionary,
31
33
  u2 as useAuth,
32
34
  u4 as useDynamicAccordions,
35
+ u5 as useDynamicPaperForm,
33
36
  u as useMasterDetail,
34
37
  u3 as useModule
35
38
  };
@@ -1,17 +1,15 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useState, useRef, useCallback, useMemo } from "react";
3
3
  import { useEnvironment, useModuleDictionary } from "@m4l/core";
4
- import { WindowBase, SplitLayout } from "@m4l/components";
4
+ import { WindowBase, getComponentSlotRoot, SplitLayout } from "@m4l/components";
5
5
  import { M as ModuleLayout } from "../ModuleLayout/ModuleLayout.js";
6
6
  import { a as MasterDetailProvider } from "./contexts/MasterDetailContext/index.js";
7
7
  import { useIsMobile } from "@m4l/graphics";
8
- import { g as getMasterDetailLayoutUtilityClasses } from "./classes/index.js";
9
- import { M as MasterDetailLayoutRoot } from "./styles.js";
10
- function getTotalModuleActions(splitActions, moduleActions = []) {
11
- let totalActions = [...splitActions];
12
- totalActions = moduleActions.concat(totalActions);
13
- return totalActions;
14
- }
8
+ import { i as icons } from "./icons.js";
9
+ import { d as dictionary } from "./dicctionary.js";
10
+ import { M as MasterDetailLayoutRootStyled } from "./slots/MasterDetailLayoutSlot.js";
11
+ import { M as MASTER_DETAIL_LAYOUT_PREFIX } from "./constants.js";
12
+ import { g as getTotalModuleActions } from "./helpers/getTotalModuleActions.js";
15
13
  function MasterDetailLayout(props) {
16
14
  const {
17
15
  moduleId,
@@ -19,7 +17,6 @@ function MasterDetailLayout(props) {
19
17
  detailComponent,
20
18
  moduleActions,
21
19
  version
22
- // defaultDictionary,
23
20
  } = props;
24
21
  const { host_static_assets, environment_assets } = useEnvironment();
25
22
  const [splitPosition, setSplitPosition] = useState("vertical");
@@ -32,30 +29,30 @@ function MasterDetailLayout(props) {
32
29
  const splitActions = useMemo(
33
30
  () => [
34
31
  {
35
- iconUrl: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/split_vertical.svg`,
32
+ iconUrl: `${host_static_assets}/${environment_assets}/${icons.splitVertical}`,
36
33
  onClick: () => onChangePostionInternal("vertical"),
37
34
  visibility: "main",
38
- label: getLabel("master_detail_layout.split_vertical"),
35
+ label: getLabel(dictionary.LABEL_SPLIT_VERTICAL),
39
36
  tag: "vertical",
40
37
  className: "splitactions",
41
38
  disabled: splitPosition === "vertical",
42
39
  key: "vertical"
43
40
  },
44
41
  {
45
- iconUrl: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/split_horizontal.svg`,
42
+ iconUrl: `${host_static_assets}/${environment_assets}/${icons.splitHorizontal}`,
46
43
  onClick: () => onChangePostionInternal("horizontal"),
47
44
  visibility: "main",
48
- label: getLabel("master_detail_layout.split_horizontal"),
45
+ label: getLabel(dictionary.LABEL_SPLIT_HORIZONTAL),
49
46
  tag: "horizontal",
50
47
  className: "splitactions",
51
48
  disabled: splitPosition === "horizontal",
52
49
  key: "horizontal"
53
50
  },
54
51
  {
55
- iconUrl: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/no_split.svg`,
52
+ iconUrl: `${host_static_assets}/${environment_assets}/${icons.noSplit}`,
56
53
  onClick: () => onChangePostionInternal("none"),
57
54
  visibility: "main",
58
- label: getLabel("master_detail_layout.no_split"),
55
+ label: getLabel(dictionary.LABEL_NO_SPLIT),
59
56
  tag: "none",
60
57
  className: "splitactions",
61
58
  disabled: splitPosition === "none",
@@ -71,7 +68,7 @@ function MasterDetailLayout(props) {
71
68
  window: /* @__PURE__ */ jsx(
72
69
  WindowBase,
73
70
  {
74
- title: getLabel("master_detail_layout.view_detail"),
71
+ title: getLabel(dictionary.LABEL_VIEW_DETAIL),
75
72
  onClose: () => {
76
73
  moduleLayoutRef.current?.closeModal();
77
74
  },
@@ -87,8 +84,8 @@ function MasterDetailLayout(props) {
87
84
  );
88
85
  return actions;
89
86
  }, [splitActions, moduleActions]);
90
- const classes = getMasterDetailLayoutUtilityClasses();
91
- return /* @__PURE__ */ jsx(MasterDetailProvider, { onClickViewDetail, children: /* @__PURE__ */ jsx(MasterDetailLayoutRoot, { className: classes.root, children: /* @__PURE__ */ jsx(
87
+ const classRoot = getComponentSlotRoot(MASTER_DETAIL_LAYOUT_PREFIX);
88
+ return /* @__PURE__ */ jsx(MasterDetailProvider, { onClickViewDetail, children: /* @__PURE__ */ jsx(MasterDetailLayoutRootStyled, { className: classRoot, children: /* @__PURE__ */ jsx(
92
89
  ModuleLayout,
93
90
  {
94
91
  ref: moduleLayoutRef,
@@ -0,0 +1,2 @@
1
+ export declare const MASTER_DETAIL_LAYOUT_PREFIX = "M4LMasterDetailLayout";
2
+ export declare const MASTER_DETAIL_LAYOUT_STORE_ID = "M4LMasterDetailLayoutStore";
@@ -0,0 +1,6 @@
1
+ const MASTER_DETAIL_LAYOUT_PREFIX = "M4LMasterDetailLayout";
2
+ const MASTER_DETAIL_LAYOUT_STORE_ID = "M4LMasterDetailLayoutStore";
3
+ export {
4
+ MASTER_DETAIL_LAYOUT_PREFIX as M,
5
+ MASTER_DETAIL_LAYOUT_STORE_ID as a
6
+ };
@@ -1,6 +1,8 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { createContext, useState } from "react";
2
+ import { createContext, useRef } from "react";
3
3
  import { voidFunction } from "@m4l/core";
4
+ import { c as createMasterDetailLayoutStore } from "./store.js";
5
+ import { useStore } from "zustand";
4
6
  const initialState = {
5
7
  masterSelection: void 0,
6
8
  onChangeMasterSelection: voidFunction,
@@ -11,17 +13,24 @@ const initialState = {
11
13
  const MasterDetailContext = createContext(initialState);
12
14
  function MasterDetailProvider(props) {
13
15
  const { children, onClickViewDetail } = props;
14
- const [masterSelection, setMasterSelection] = useState(void 0);
15
- const [refreshMaster, setRefreshMaster] = useState(voidFunction);
16
+ const masterDetailLayoutStoreRef = useRef();
17
+ if (!masterDetailLayoutStoreRef.current) {
18
+ masterDetailLayoutStoreRef.current = createMasterDetailLayoutStore({
19
+ masterSelection: void 0,
20
+ refreshMaster: voidFunction
21
+ });
22
+ }
23
+ const store = useStore(masterDetailLayoutStoreRef.current, (state) => state);
24
+ const { masterSelection, updateMasterSelection, updateRefreshMaster, refreshMaster } = store;
16
25
  return /* @__PURE__ */ jsx(
17
26
  MasterDetailContext.Provider,
18
27
  {
19
28
  value: {
20
29
  masterSelection,
21
- onChangeMasterSelection: setMasterSelection,
30
+ onChangeMasterSelection: updateMasterSelection,
22
31
  onClickViewDetail,
23
32
  refreshMaster,
24
- setRefreshMaster
33
+ setRefreshMaster: updateRefreshMaster
25
34
  },
26
35
  children
27
36
  }
@@ -0,0 +1,16 @@
1
+ import { MasterDetailLayoutState, MasterDetailLayoutStateWithActions } from './types';
2
+ /**
3
+ * Crea el Store para ModuleLayout.
4
+ * Este store se encarga de manejar el estado del layout de módulo.
5
+ * @param props Las props iniciales del store.
6
+ */
7
+ export declare const createMasterDetailLayoutStore: (initProps: MasterDetailLayoutState, storeDevtoolsEnabled?: boolean) => import('zustand').UseBoundStore<Omit<Omit<import('zustand').StoreApi<MasterDetailLayoutStateWithActions>, "setState"> & {
8
+ setState<A extends string | {
9
+ type: unknown;
10
+ }>(partial: MasterDetailLayoutStateWithActions | Partial<MasterDetailLayoutStateWithActions> | ((state: MasterDetailLayoutStateWithActions) => MasterDetailLayoutStateWithActions | Partial<MasterDetailLayoutStateWithActions>), replace?: boolean | undefined, action?: A | undefined): void;
11
+ }, "setState"> & {
12
+ setState(nextStateOrUpdater: MasterDetailLayoutStateWithActions | Partial<MasterDetailLayoutStateWithActions> | ((state: import('immer/dist/internal').WritableDraft<MasterDetailLayoutStateWithActions>) => void), shouldReplace?: boolean | undefined, action?: string | {
13
+ type: unknown;
14
+ } | undefined): void;
15
+ }>;
16
+ export type MasterDetailLayoutStore = ReturnType<typeof createMasterDetailLayoutStore>;
@@ -0,0 +1,50 @@
1
+ import { create } from "zustand";
2
+ import { devtools } from "zustand/middleware";
3
+ import { immer } from "zustand/middleware/immer";
4
+ import { a as MASTER_DETAIL_LAYOUT_STORE_ID } from "../../constants.js";
5
+ const createDevtools = (immerMiddlewere, config) => {
6
+ const { enabled = false } = config;
7
+ if (enabled && process.env.NODE_ENV === "development") {
8
+ return devtools(immerMiddlewere, config);
9
+ }
10
+ return immerMiddlewere;
11
+ };
12
+ const createMasterDetailLayoutStore = (initProps, storeDevtoolsEnabled = false) => {
13
+ const { refreshMaster, masterSelection } = initProps;
14
+ const startProps = {
15
+ refreshMaster,
16
+ masterSelection
17
+ };
18
+ return create(
19
+ createDevtools(
20
+ immer((set) => ({
21
+ ...startProps,
22
+ /**
23
+ * Initilize the store
24
+ */
25
+ init: () => {
26
+ },
27
+ /**
28
+ * Update the master selection
29
+ */
30
+ updateMasterSelection: (newMasterSelection) => {
31
+ set((state) => {
32
+ state.masterSelection = newMasterSelection;
33
+ });
34
+ },
35
+ /**
36
+ * Update the refresh master
37
+ */
38
+ updateRefreshMaster: (callback) => {
39
+ set((state) => {
40
+ state.refreshMaster = callback;
41
+ });
42
+ }
43
+ })),
44
+ { name: `${MASTER_DETAIL_LAYOUT_STORE_ID}: ${initProps.storeId}`, enabled: storeDevtoolsEnabled }
45
+ )
46
+ );
47
+ };
48
+ export {
49
+ createMasterDetailLayoutStore as c
50
+ };
@@ -6,9 +6,37 @@ export interface MasterDetailContextStateProps {
6
6
  export interface MasterDetailProviderProps {
7
7
  children: ReactNode;
8
8
  onClickViewDetail: () => void;
9
+ /**
10
+ * "storeDevtoolsEnabled" enable store devtools
11
+ */
12
+ storeDevtoolsEnabled?: boolean;
13
+ /**
14
+ * "storeId" store identifier
15
+ */
16
+ storeId?: string;
9
17
  }
10
18
  export interface MasterDetailContextProps extends MasterDetailContextStateProps, Pick<MasterDetailProviderProps, 'onClickViewDetail'> {
11
19
  onChangeMasterSelection: (newMasterSelection: MasterSelecion) => void;
12
20
  refreshMaster: () => void;
13
21
  setRefreshMaster: (callback: () => void) => void;
14
22
  }
23
+ export interface MasterDetailLayoutState extends Pick<MasterDetailContextStateProps, 'masterSelection'>, Pick<MasterDetailProviderProps, 'storeId'> {
24
+ /**
25
+ * Refresh master: Action to refresh data inthe master component
26
+ */
27
+ refreshMaster: () => void;
28
+ }
29
+ export interface MasterDetailLayoutStateWithActions extends MasterDetailLayoutState {
30
+ /**
31
+ * Initialize MasterDetailLayout store.
32
+ */
33
+ init: () => void;
34
+ /**
35
+ * Update MasterDetailLayout store.
36
+ */
37
+ updateMasterSelection: (newMasterSelection: MasterSelecion) => void;
38
+ /**
39
+ * Update MasterDetailLayout store.
40
+ */
41
+ updateRefreshMaster: (callback: () => void) => void;
42
+ }
@@ -1,3 +1,7 @@
1
- import { Dictionary } from '@m4l/core';
2
1
  export declare function getMasterDetailLayoutComponentsDictionary(): string[];
3
- export declare const defaultMasterDetailDictionary: Dictionary;
2
+ export declare const dictionary: {
3
+ LABEL_SPLIT_VERTICAL: string;
4
+ LABEL_SPLIT_HORIZONTAL: string;
5
+ LABEL_NO_SPLIT: string;
6
+ LABEL_VIEW_DETAIL: string;
7
+ };
@@ -1,8 +1,13 @@
1
- import { g as getModuleLayoutComponentsDictionary } from "../ModuleLayout/dicctionary.js";
2
- import { getNoItemSelectedComponentsDictionary } from "@m4l/components";
3
1
  function getMasterDetailLayoutComponentsDictionary() {
4
- return ["master_detail_layout"].concat(getModuleLayoutComponentsDictionary()).concat(getNoItemSelectedComponentsDictionary());
2
+ return ["master_detail_layout"];
5
3
  }
4
+ const dictionary = {
5
+ LABEL_SPLIT_VERTICAL: `${getMasterDetailLayoutComponentsDictionary()[0]}.split_vertical`,
6
+ LABEL_SPLIT_HORIZONTAL: `${getMasterDetailLayoutComponentsDictionary()[0]}.split_horizontal`,
7
+ LABEL_NO_SPLIT: `${getMasterDetailLayoutComponentsDictionary()[0]}.no_split`,
8
+ LABEL_VIEW_DETAIL: `${getMasterDetailLayoutComponentsDictionary()[0]}.view_detail`
9
+ };
6
10
  export {
11
+ dictionary as d,
7
12
  getMasterDetailLayoutComponentsDictionary as g
8
13
  };