@m4l/layouts 0.1.39 → 0.1.40

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.
@@ -1,8 +1,8 @@
1
- import { useModal as x, useWindowToolsMF as v, ModalProvider as g, getModalDialogComponentsDictionary as h } from "@m4l/components";
2
- import { forwardRef as p, useRef as m, useImperativeHandle as f, createContext as I, useState as a, useMemo as C, useEffect as A } from "react";
3
- import { styled as M } from "@mui/material/styles";
4
- import { jsx as t } from "react/jsx-runtime";
5
- const D = M("div")(() => ({
1
+ import { useModal, useWindowToolsMF, ModalProvider, getModalDialogComponentsDictionary } from "@m4l/components";
2
+ import { forwardRef, useRef, useImperativeHandle, createContext, useState, useMemo, useEffect } from "react";
3
+ import { styled } from "@mui/material/styles";
4
+ import { jsx } from "react/jsx-runtime";
5
+ const WrapperInnerModule = styled("div")(() => ({
6
6
  display: "flex",
7
7
  flexDirection: "column",
8
8
  position: "absolute",
@@ -12,92 +12,107 @@ const D = M("div")(() => ({
12
12
  top: "0px",
13
13
  bottom: "0px",
14
14
  overflow: "hidden"
15
- })), w = M("div")(({
16
- theme: o
15
+ }));
16
+ const ModuleContent = styled("div")(({
17
+ theme
17
18
  }) => ({
18
19
  display: "flex",
19
20
  position: "relative",
20
- marginTop: o.spacing(1),
21
+ marginTop: theme.spacing(1),
21
22
  justifyContent: "center",
22
23
  flexGrow: "1",
23
24
  overflow: "hidden"
24
- })), y = p((o, r) => {
25
+ }));
26
+ const InnerModule = forwardRef((props, ref) => {
25
27
  const {
26
- children: e
27
- } = o, {
28
- openModal: l
29
- } = x(), n = m(null);
30
- return f(r, () => ({
31
- openModal: l,
32
- current: n.current
33
- })), /* @__PURE__ */ t(D, {
28
+ children
29
+ } = props;
30
+ const {
31
+ openModal
32
+ } = useModal();
33
+ const divRef = useRef(null);
34
+ useImperativeHandle(ref, () => ({
35
+ openModal,
36
+ current: divRef.current
37
+ }));
38
+ return /* @__PURE__ */ jsx(WrapperInnerModule, {
34
39
  id: "WrapperInnerModule",
35
40
  className: "m4l_module_layout",
36
- ref: n,
37
- children: /* @__PURE__ */ t(w, {
41
+ ref: divRef,
42
+ children: /* @__PURE__ */ jsx(ModuleContent, {
38
43
  id: "ModuleContent",
39
- children: e
44
+ children
40
45
  })
41
46
  });
42
47
  });
43
- y.displayName = "InnerModule";
44
- const L = I(null);
45
- function R(o) {
48
+ InnerModule.displayName = "InnerModule";
49
+ const ModuleContext = createContext(null);
50
+ function ModuleProvider(props) {
46
51
  const {
47
- children: r,
48
- moduleActions: e,
49
- moduleId: l,
50
- version: n
51
- } = o, [u] = a(() => ({
52
- moduleId: l,
52
+ children,
53
+ moduleActions,
54
+ moduleId,
55
+ version
56
+ } = props;
57
+ const [configOptions] = useState(() => ({
58
+ moduleId,
53
59
  dictionary: void 0
54
- })), {
55
- setActions: d
56
- } = v(), [i, s] = a([]), c = C(() => (e || []).concat(i), [e, i]);
57
- return A(() => {
58
- d(c, n);
59
- }, [c]), /* @__PURE__ */ t(L.Provider, {
60
+ }));
61
+ const {
62
+ setActions
63
+ } = useWindowToolsMF();
64
+ const [dynamicActions, setDynamicActions] = useState([]);
65
+ const finalModuleActions = useMemo(() => {
66
+ return (moduleActions || []).concat(dynamicActions);
67
+ }, [moduleActions, dynamicActions]);
68
+ useEffect(() => {
69
+ setActions(finalModuleActions, version);
70
+ }, [finalModuleActions]);
71
+ return /* @__PURE__ */ jsx(ModuleContext.Provider, {
60
72
  value: {
61
- setDynamicActions: s,
62
- moduleId: u.moduleId
73
+ setDynamicActions,
74
+ moduleId: configOptions.moduleId
63
75
  },
64
- children: r
76
+ children
65
77
  });
66
78
  }
67
- const _ = p((o, r) => {
79
+ const ModuleLayout = forwardRef((props, ref) => {
68
80
  const {
69
- moduleId: e,
70
- moduleActions: l,
71
- version: n,
72
- children: u
73
- } = o, d = m(null), i = (s) => {
74
- d.current?.openModal(s);
81
+ moduleId,
82
+ moduleActions,
83
+ version,
84
+ children
85
+ } = props;
86
+ const moduleRef = useRef(null);
87
+ const openModal = (modalOpenProps) => {
88
+ moduleRef.current?.openModal(modalOpenProps);
75
89
  };
76
- return f(r, () => ({
77
- openModal: i,
78
- current: d.current
79
- })), /* @__PURE__ */ t(R, {
80
- moduleId: e,
81
- moduleActions: l,
82
- version: n,
83
- children: /* @__PURE__ */ t(g, {
84
- children: /* @__PURE__ */ t(y, {
85
- ref: d,
86
- children: u
90
+ useImperativeHandle(ref, () => ({
91
+ openModal,
92
+ current: moduleRef.current
93
+ }));
94
+ return /* @__PURE__ */ jsx(ModuleProvider, {
95
+ moduleId,
96
+ moduleActions,
97
+ version,
98
+ children: /* @__PURE__ */ jsx(ModalProvider, {
99
+ children: /* @__PURE__ */ jsx(InnerModule, {
100
+ ref: moduleRef,
101
+ children
87
102
  })
88
103
  })
89
104
  });
90
105
  });
91
- _.displayName = "ModuleLayout";
92
- function j() {
93
- return ["module_layout"].concat(h());
106
+ ModuleLayout.displayName = "ModuleLayout";
107
+ function getModuleLayoutComponentsDictionary() {
108
+ return ["module_layout"].concat(getModalDialogComponentsDictionary());
94
109
  }
95
- const T = {
110
+ const defaultModuleLayoutDictionary = {
96
111
  module_layout: {}
97
112
  };
98
113
  export {
99
- L as M,
100
- _ as a,
101
- T as d,
102
- j as g
114
+ ModuleContext as M,
115
+ ModuleLayout as a,
116
+ defaultModuleLayoutDictionary as d,
117
+ getModuleLayoutComponentsDictionary as g
103
118
  };