@m4l/layouts 0.0.19 → 0.0.22

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.
@@ -4,8 +4,6 @@ export interface MasterDetailContextStateProps {
4
4
  masterSelection?: MasterSelecion;
5
5
  }
6
6
  export interface MasterDetailProviderProps {
7
- masterSelection: MasterSelecion;
8
- setMasterSelection: (newMasterSelecion: MasterSelecion) => void;
9
7
  children: ReactNode;
10
8
  }
11
9
  export interface MasterDetailContextProps extends MasterDetailContextStateProps {
@@ -1,4 +1,4 @@
1
- import { createContext, useCallback, useState, useRef, useMemo } from "react";
1
+ import { createContext, useState, useRef, useCallback, useMemo } from "react";
2
2
  import { voidFunction, useEnvironment } from "@m4l/core";
3
3
  import { SplitLayout } from "@m4l/components";
4
4
  import { g as getModuleLayoutComponentsDictionary, a as ModuleLayout } from "../ModuleLayout/index.js";
@@ -24,17 +24,13 @@ const initialState = {
24
24
  const MasterDetailContext = createContext(initialState);
25
25
  function MasterDetailProvider(props) {
26
26
  const {
27
- children,
28
- masterSelection,
29
- setMasterSelection
27
+ children
30
28
  } = props;
31
- const onChangeMasterSelection = useCallback((newMasterSelection) => {
32
- setMasterSelection(newMasterSelection);
33
- }, [setMasterSelection]);
29
+ const [masterSelection, setMasterSelection] = useState(void 0);
34
30
  return /* @__PURE__ */ jsx(MasterDetailContext.Provider, {
35
31
  value: {
36
32
  masterSelection,
37
- onChangeMasterSelection
33
+ onChangeMasterSelection: setMasterSelection
38
34
  },
39
35
  children
40
36
  });
@@ -64,7 +60,7 @@ function MasterDetailLayout(props) {
64
60
  moduleId,
65
61
  moduleNameField,
66
62
  detailComponent,
67
- initialModuleActions: moduleActions,
63
+ moduleActions,
68
64
  urlIcon,
69
65
  masterComponent,
70
66
  componentsDictionary,
@@ -78,7 +74,6 @@ function MasterDetailLayout(props) {
78
74
  const [splitPosition, setSplitPosition] = useState("vertical");
79
75
  const isDesktop = useResponsiveDesktop();
80
76
  const moduleLayoutRef = useRef(null);
81
- const [masterSelection, setMasterSelection] = useState(void 0);
82
77
  const onChangePostionInternal = (newPostion) => {
83
78
  const newSplitActions = [...initialSplitActions];
84
79
  for (let i = 0; i < newSplitActions.length; i++) {
@@ -142,23 +137,24 @@ function MasterDetailLayout(props) {
142
137
  return actions;
143
138
  }, [splitActions, moduleActions, isDesktop, viewDetailAction]);
144
139
  const finalComponentsDictionary = useMemo(() => componentsDictionary.concat(getMasterDetailLayoutComponentsDictionary()), [componentsDictionary]);
145
- return /* @__PURE__ */ jsx(MasterDetailProvider, {
146
- masterSelection,
147
- setMasterSelection,
148
- children: /* @__PURE__ */ jsx(ModuleLayout, {
149
- ref: moduleLayoutRef,
150
- moduleId,
151
- moduleNameField,
152
- urlIcon,
153
- initialModuleActions: finalModuleActions,
154
- privileges,
155
- componentsDictionary: finalComponentsDictionary,
156
- breadcrumbLinks,
157
- children: /* @__PURE__ */ jsx(SplitLayout, {
158
- splitPosition: isDesktop ? splitPosition : "none",
159
- firstPart: masterComponent,
160
- secondPart: detailComponent
161
- })
140
+ const memonizedSplit = useMemo(() => {
141
+ return /* @__PURE__ */ jsx(SplitLayout, {
142
+ splitPosition: isDesktop ? splitPosition : "none",
143
+ firstPart: masterComponent,
144
+ secondPart: detailComponent
145
+ });
146
+ }, [isDesktop, splitPosition, masterComponent, detailComponent]);
147
+ return /* @__PURE__ */ jsx(ModuleLayout, {
148
+ ref: moduleLayoutRef,
149
+ moduleId,
150
+ moduleNameField,
151
+ urlIcon,
152
+ moduleActions: finalModuleActions,
153
+ privileges,
154
+ componentsDictionary: finalComponentsDictionary,
155
+ breadcrumbLinks,
156
+ children: /* @__PURE__ */ jsx(MasterDetailProvider, {
157
+ children: memonizedSplit
162
158
  })
163
159
  });
164
160
  }
@@ -6,5 +6,4 @@ export interface ContainerProps {
6
6
  export interface MasterDetailLayoutProps extends Omit<ModuleLayoutProps, 'children'> {
7
7
  masterComponent: ((props?: any) => JSX.Element) | ReactNode;
8
8
  detailComponent: ((props?: any) => JSX.Element) | ReactNode;
9
- onChangeSelected?: (row: any[]) => void;
10
9
  }
@@ -336,7 +336,7 @@ const ModuleLayout = forwardRef((props, ref) => {
336
336
  const {
337
337
  moduleId,
338
338
  moduleNameField = "module_name",
339
- initialModuleActions,
339
+ moduleActions: initialModuleActions,
340
340
  urlIcon,
341
341
  children,
342
342
  componentsDictionary,
@@ -21,7 +21,7 @@ export interface ModuleLayoutProps extends HeaderProps {
21
21
  moduleNameField?: string;
22
22
  privileges: string[];
23
23
  breadcrumbLinks: TLink[];
24
- initialModuleActions: ModuleAction[];
24
+ moduleActions: ModuleAction[];
25
25
  componentsDictionary: string[];
26
26
  children: ReactNode;
27
27
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@m4l/layouts",
3
3
  "private": false,
4
- "version": "0.0.19",
4
+ "version": "0.0.22",
5
5
  "license": "UNLICENSED",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -14,7 +14,7 @@
14
14
  "format": "npm run prettier:fix && npm run lint:fix"
15
15
  },
16
16
  "dependencies": {
17
- "@m4l/components": "^0.0.40",
17
+ "@m4l/components": "^0.0.41",
18
18
  "react": "^17.0.0 || 18.x",
19
19
  "react-dom": "^18.0.0"
20
20
  },