@m4l/layouts 0.1.39 → 0.1.41

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 (32) hide show
  1. package/components/BaseModule/index.6309486a.js +24 -24
  2. package/components/MFHostApp/index.420c2626.js +58 -58
  3. package/components/MFIsolationApp/index.e36cf308.js +137 -117
  4. package/contexts/AuthContext/index.6f966215.js +118 -88
  5. package/hooks/index.33191825.js +4 -0
  6. package/hooks/useAuth/index.cb6a3420.js +7 -7
  7. package/hooks/useMasterDetail/index.be4908d9.js +6 -0
  8. package/hooks/useModule/index.b5f598b1.js +11 -0
  9. package/index.js +29 -27
  10. package/layouts/MasterDetailLayout/classes/constants.d.ts +1 -0
  11. package/layouts/MasterDetailLayout/classes/index.d.ts +6 -0
  12. package/layouts/MasterDetailLayout/classes/types.d.ts +6 -0
  13. package/layouts/MasterDetailLayout/index.fe6ac47b.js +163 -0
  14. package/layouts/MasterDetailLayout/styles.d.ts +2 -0
  15. package/layouts/ModuleLayout/classes/constants.d.ts +1 -0
  16. package/layouts/ModuleLayout/classes/index.d.ts +7 -0
  17. package/layouts/ModuleLayout/classes/types.d.ts +7 -0
  18. package/layouts/ModuleLayout/index.e7218171.js +122 -0
  19. package/layouts/ModuleLayout/subcomponents/InnerModule/styles.d.ts +1 -2
  20. package/layouts/NoAuthModuleLayout/index.2808fa44.js +379 -0
  21. package/layouts/index.96a3745e.js +8 -0
  22. package/layouts/index.d.ts +2 -2
  23. package/package.json +2 -1
  24. package/hooks/index.a0c767ed.js +0 -4
  25. package/hooks/useMasterDetail/index.927c0c26.js +0 -6
  26. package/hooks/useModule/index.edcd7b28.js +0 -11
  27. package/layouts/MasterDetailLayout/index.bca0fce5.js +0 -118
  28. package/layouts/ModuleLayout/index.850f7dcf.js +0 -103
  29. package/layouts/NoAuthModuleLayout/index.eabf38c1.js +0 -345
  30. package/layouts/index.07aacf57.js +0 -8
  31. /package/layouts/MasterDetailLayout/{index.d.ts → MasterDetailLayout.d.ts} +0 -0
  32. /package/layouts/ModuleLayout/{index.d.ts → ModuleLayout.d.ts} +0 -0
@@ -1,27 +1,27 @@
1
- import { ModalProvider as s } from "@m4l/components";
2
- import { FlagsProvider as u, ModuleDictionaryProvider as c, ModuleSkeletonProvider as m, ModulePrivilegesProvider as a } from "@m4l/core";
3
- import { jsx as e } from "react/jsx-runtime";
4
- function h(r) {
1
+ import { ModalProvider } from "@m4l/components";
2
+ import { FlagsProvider, ModuleDictionaryProvider, ModuleSkeletonProvider, ModulePrivilegesProvider } from "@m4l/core";
3
+ import { jsx } from "react/jsx-runtime";
4
+ function BaseModule(props) {
5
5
  const {
6
- children: o,
7
- moduleId: i,
8
- moduleNameField: l,
9
- skeletonFlags: d,
10
- privileges: n,
11
- componentsDictionary: t
12
- } = r;
13
- return /* @__PURE__ */ e(u, {
14
- children: /* @__PURE__ */ e(c, {
15
- isAuth: !0,
16
- moduleId: i,
17
- moduleNameField: l,
18
- componentsDictionary: t,
19
- children: /* @__PURE__ */ e(m, {
20
- flags: d,
21
- children: /* @__PURE__ */ e(a, {
22
- queryPrivileges: n,
23
- children: /* @__PURE__ */ e(s, {
24
- children: o
6
+ children,
7
+ moduleId,
8
+ moduleNameField,
9
+ skeletonFlags,
10
+ privileges,
11
+ componentsDictionary
12
+ } = props;
13
+ return /* @__PURE__ */ jsx(FlagsProvider, {
14
+ children: /* @__PURE__ */ jsx(ModuleDictionaryProvider, {
15
+ isAuth: true,
16
+ moduleId,
17
+ moduleNameField,
18
+ componentsDictionary,
19
+ children: /* @__PURE__ */ jsx(ModuleSkeletonProvider, {
20
+ flags: skeletonFlags,
21
+ children: /* @__PURE__ */ jsx(ModulePrivilegesProvider, {
22
+ queryPrivileges: privileges,
23
+ children: /* @__PURE__ */ jsx(ModalProvider, {
24
+ children
25
25
  })
26
26
  })
27
27
  })
@@ -29,5 +29,5 @@ function h(r) {
29
29
  });
30
30
  }
31
31
  export {
32
- h as B
32
+ BaseModule as B
33
33
  };
@@ -1,61 +1,61 @@
1
- import { unstable_HistoryRouter as p } from "react-router-dom";
2
- import { EnvironmentProvider as v, HostToolsProvider as M, NetworkProvider as P, DomainCountryProvider as f } from "@m4l/core";
3
- import { LocalesProvider as b, HostThemeProvider as T, FormatterProvider as g } from "@m4l/graphics";
4
- import { WindowToolsMFProvider as E, DynamicMFParmsProvider as H } from "@m4l/components";
5
- import { B as _ } from "../BaseModule/index.6309486a.js";
6
- import { jsx as r } from "react/jsx-runtime";
7
- function L(t) {
1
+ import { unstable_HistoryRouter } from "react-router-dom";
2
+ import { EnvironmentProvider, HostToolsProvider, NetworkProvider, DomainCountryProvider } from "@m4l/core";
3
+ import { LocalesProvider, HostThemeProvider, FormatterProvider } from "@m4l/graphics";
4
+ import { WindowToolsMFProvider, DynamicMFParmsProvider } from "@m4l/components";
5
+ import { B as BaseModule } from "../BaseModule/index.6309486a.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ function MFHostApp(props) {
8
8
  const {
9
- children: n,
10
- currentLocale: d,
11
- hostTheme: m,
12
- environment: s,
13
- hostTools: e,
14
- axiosOperation: c,
15
- formatters: o,
16
- moduleId: l,
17
- moduleNameField: a,
18
- skeletonFlags: u,
19
- privileges: h,
20
- componentsDictionary: y,
21
- dynamicMFStore: i,
22
- windowTools: F
23
- } = t;
24
- return /* @__PURE__ */ r(v, {
25
- ...s,
26
- children: /* @__PURE__ */ r(M, {
27
- ...e,
28
- children: /* @__PURE__ */ r(P, {
29
- axiosOperation: c,
30
- children: /* @__PURE__ */ r(b, {
31
- isMicroFrontEnd: !0,
32
- localeHost: d,
33
- children: /* @__PURE__ */ r(T, {
34
- isMicroFrontEnd: !0,
35
- ...m,
36
- children: /* @__PURE__ */ r(p, {
37
- history: e.history,
38
- children: /* @__PURE__ */ r(f, {
39
- isMicroFrontEnd: !0,
40
- id: i?.getState().dynamicMFParameters?.id || 1,
41
- currency: o.currencyFormatter.code,
42
- currency_decimal_digits: o.currencyFormatter.decimalDigits,
43
- decimal_symbol: o.numberFormatter.decimalSymbol,
44
- thousands_symbol: o.numberFormatter.thousandsSymbol,
45
- children: /* @__PURE__ */ r(_, {
46
- moduleId: l,
47
- moduleNameField: a,
48
- componentsDictionary: y,
49
- skeletonFlags: u,
50
- privileges: h,
51
- children: /* @__PURE__ */ r(g, {
52
- isMicroFrontEnd: !0,
53
- ...o,
54
- children: /* @__PURE__ */ r(E, {
55
- ...F,
56
- children: /* @__PURE__ */ r(H, {
57
- store: i,
58
- children: n
9
+ children,
10
+ currentLocale,
11
+ hostTheme,
12
+ environment,
13
+ hostTools,
14
+ axiosOperation,
15
+ formatters,
16
+ moduleId,
17
+ moduleNameField,
18
+ skeletonFlags,
19
+ privileges,
20
+ componentsDictionary,
21
+ dynamicMFStore,
22
+ windowTools
23
+ } = props;
24
+ return /* @__PURE__ */ jsx(EnvironmentProvider, {
25
+ ...environment,
26
+ children: /* @__PURE__ */ jsx(HostToolsProvider, {
27
+ ...hostTools,
28
+ children: /* @__PURE__ */ jsx(NetworkProvider, {
29
+ axiosOperation,
30
+ children: /* @__PURE__ */ jsx(LocalesProvider, {
31
+ isMicroFrontEnd: true,
32
+ localeHost: currentLocale,
33
+ children: /* @__PURE__ */ jsx(HostThemeProvider, {
34
+ isMicroFrontEnd: true,
35
+ ...hostTheme,
36
+ children: /* @__PURE__ */ jsx(unstable_HistoryRouter, {
37
+ history: hostTools.history,
38
+ children: /* @__PURE__ */ jsx(DomainCountryProvider, {
39
+ isMicroFrontEnd: true,
40
+ id: dynamicMFStore?.getState().dynamicMFParameters?.id || 1,
41
+ currency: formatters.currencyFormatter.code,
42
+ currency_decimal_digits: formatters.currencyFormatter.decimalDigits,
43
+ decimal_symbol: formatters.numberFormatter.decimalSymbol,
44
+ thousands_symbol: formatters.numberFormatter.thousandsSymbol,
45
+ children: /* @__PURE__ */ jsx(BaseModule, {
46
+ moduleId,
47
+ moduleNameField,
48
+ componentsDictionary,
49
+ skeletonFlags,
50
+ privileges,
51
+ children: /* @__PURE__ */ jsx(FormatterProvider, {
52
+ isMicroFrontEnd: true,
53
+ ...formatters,
54
+ children: /* @__PURE__ */ jsx(WindowToolsMFProvider, {
55
+ ...windowTools,
56
+ children: /* @__PURE__ */ jsx(DynamicMFParmsProvider, {
57
+ store: dynamicMFStore,
58
+ children
59
59
  })
60
60
  })
61
61
  })
@@ -69,5 +69,5 @@ function L(t) {
69
69
  });
70
70
  }
71
71
  export {
72
- L as M
72
+ MFHostApp as M
73
73
  };
@@ -1,145 +1,165 @@
1
- import { useEffect as T, useMemo as _, useCallback as f } from "react";
2
- import { unstable_HistoryRouter as x } from "react-router-dom";
3
- import { ToastContainer as D, toast as S } from "react-toastify";
4
- import { HostThemeProvider as H, GlobalStyles as O, FormatterProvider as B, LocalesProvider as I, getLocaleFromNetwork as j } from "@m4l/graphics";
5
- import { A as U } from "../../contexts/AuthContext/index.6f966215.js";
6
- import { DomainCountryProvider as z, EnvironmentProvider as G, HostToolsProvider as R, NetworkProvider as q, axiosOperation as J } from "@m4l/core";
7
- import { createBrowserHistory as K } from "history";
8
- import Q from "eventemitter3";
9
- import { format as V } from "date-fns";
10
- import { defaultThemeOptions as W, fnComponentsOverrides as X } from "@m4l/styles";
11
- import { u as Y } from "../../hooks/useAuth/index.cb6a3420.js";
12
- import { jsx as r, jsxs as Z } from "react/jsx-runtime";
13
- import y from "nprogress";
14
- import { B as $ } from "../BaseModule/index.6309486a.js";
15
- import { AreasProvider as oo } from "@m4l/components";
16
- function ro(m) {
1
+ import { useEffect, useMemo, useCallback } from "react";
2
+ import { unstable_HistoryRouter } from "react-router-dom";
3
+ import { ToastContainer, toast } from "react-toastify";
4
+ import { HostThemeProvider, GlobalStyles, FormatterProvider, LocalesProvider, getLocaleFromNetwork } from "@m4l/graphics";
5
+ import { A as AuthProvider } from "../../contexts/AuthContext/index.6f966215.js";
6
+ import { DomainCountryProvider, EnvironmentProvider, HostToolsProvider, NetworkProvider, axiosOperation } from "@m4l/core";
7
+ import { createBrowserHistory } from "history";
8
+ import EventEmitter from "eventemitter3";
9
+ import { format } from "date-fns";
10
+ import { defaultThemeOptions, fnComponentsOverrides } from "@m4l/styles";
11
+ import { u as useAuth } from "../../hooks/useAuth/index.cb6a3420.js";
12
+ import { jsx, jsxs } from "react/jsx-runtime";
13
+ import NProgress from "nprogress";
14
+ import { B as BaseModule } from "../BaseModule/index.6309486a.js";
15
+ import { AreasProvider } from "@m4l/components";
16
+ function MFAuthApp(props) {
17
17
  const {
18
- children: a,
19
- user: d,
20
- pwd: l
21
- } = m, {
22
- isAuthenticated: n,
23
- isInitialized: c,
24
- login: u,
25
- user: e
26
- } = Y();
27
- if (T(() => {
28
- c && n === !1 && u(d, l, !1);
29
- }, [c, n]), !n)
30
- return /* @__PURE__ */ r("div", {
18
+ children,
19
+ user,
20
+ pwd
21
+ } = props;
22
+ const {
23
+ isAuthenticated,
24
+ isInitialized,
25
+ login,
26
+ user: authUser
27
+ } = useAuth();
28
+ useEffect(() => {
29
+ if (isInitialized && isAuthenticated === false) {
30
+ login(user, pwd, false);
31
+ }
32
+ }, [isInitialized, isAuthenticated]);
33
+ if (!isAuthenticated)
34
+ return /* @__PURE__ */ jsx("div", {
31
35
  children: "Pendiente x atenticar"
32
36
  });
33
- const o = {
37
+ const domianCountry = {
34
38
  id: 1,
35
39
  currency: "USD",
36
40
  currency_decimal_digits: 2,
37
41
  decimal_symbol: ".",
38
42
  thousands_symbol: ","
39
43
  };
40
- return e?.domain_country && (o.id = e?.domain_country.id ?? o.id, o.currency = e?.domain_country.currency ?? o.currency, o.currency_decimal_digits = e?.domain_country.currency_decimal_digits ?? o.currency_decimal_digits, o.decimal_symbol = e?.domain_country.decimal_symbol ?? o.decimal_symbol, o.thousands_symbol = e?.domain_country?.thousands_symbol ?? o.thousands_symbol), /* @__PURE__ */ Z(H, {
41
- hostThemeOptions: W,
42
- fnComponentsOverrides: X,
43
- isMicroFrontEnd: !0,
44
- children: [/* @__PURE__ */ r(D, {}), /* @__PURE__ */ r(O, {}), /* @__PURE__ */ r(z, {
45
- ...o,
46
- isMicroFrontEnd: !1,
47
- children: /* @__PURE__ */ r(B, {
48
- isMicroFrontEnd: !1,
44
+ if (authUser?.domain_country) {
45
+ domianCountry.id = authUser?.domain_country.id ?? domianCountry.id;
46
+ domianCountry.currency = authUser?.domain_country.currency ?? domianCountry.currency;
47
+ domianCountry.currency_decimal_digits = authUser?.domain_country.currency_decimal_digits ?? domianCountry.currency_decimal_digits;
48
+ domianCountry.decimal_symbol = authUser?.domain_country.decimal_symbol ?? domianCountry.decimal_symbol;
49
+ domianCountry.thousands_symbol = authUser?.domain_country?.thousands_symbol ?? domianCountry.thousands_symbol;
50
+ }
51
+ return /* @__PURE__ */ jsxs(HostThemeProvider, {
52
+ hostThemeOptions: defaultThemeOptions,
53
+ fnComponentsOverrides,
54
+ isMicroFrontEnd: true,
55
+ children: [/* @__PURE__ */ jsx(ToastContainer, {}), /* @__PURE__ */ jsx(GlobalStyles, {}), /* @__PURE__ */ jsx(DomainCountryProvider, {
56
+ ...domianCountry,
57
+ isMicroFrontEnd: false,
58
+ children: /* @__PURE__ */ jsx(FormatterProvider, {
59
+ isMicroFrontEnd: false,
49
60
  dateFormatter: {
50
- formatDate: V
61
+ formatDate: format
51
62
  },
52
63
  currencyFormatter: {
53
- code: o.currency,
54
- decimalDigits: o.currency_decimal_digits
64
+ code: domianCountry.currency,
65
+ decimalDigits: domianCountry.currency_decimal_digits
55
66
  },
56
- children: a
67
+ children
57
68
  })
58
69
  })]
59
70
  });
60
71
  }
61
- const h = K({
72
+ const history = createBrowserHistory({
62
73
  window
63
74
  });
64
- function vo(m) {
75
+ function MFIsolationApp(props) {
65
76
  const {
66
- children: a,
67
- user: d,
68
- pwd: l,
69
- host_api_local: n,
70
- host_api_remote: c,
71
- host_static_assets: u,
72
- environment_assets: e,
73
- moduleId: o,
74
- skeletonFlags: p,
75
- moduleNameField: v,
76
- privileges: g,
77
- componentsDictionary: F,
78
- onLoad: w,
79
- activeAreasNetwork: P = !1,
80
- activeCookiesFromNetwork: b = !1
81
- } = m, i = _(() => new Q(), []), k = f((t, s) => {
82
- i.on(t, s);
83
- }, [i]), A = f((t, s) => {
84
- if (s === null) {
85
- i.removeListener(t);
77
+ children,
78
+ user,
79
+ pwd,
80
+ host_api_local,
81
+ host_api_remote,
82
+ host_static_assets,
83
+ environment_assets,
84
+ moduleId,
85
+ skeletonFlags,
86
+ moduleNameField,
87
+ privileges,
88
+ componentsDictionary,
89
+ onLoad,
90
+ activeAreasNetwork = false,
91
+ activeCookiesFromNetwork = false
92
+ } = props;
93
+ const eventEmitter = useMemo(() => new EventEmitter(), []);
94
+ const events_add_listener = useCallback((eventName, handler) => {
95
+ eventEmitter.on(eventName, handler);
96
+ }, [eventEmitter]);
97
+ const events_remove_listener = useCallback((eventName, handler) => {
98
+ if (handler === null) {
99
+ eventEmitter.removeListener(eventName);
86
100
  return;
87
101
  }
88
- i.removeListener(t, s);
89
- }, [i]), E = f((t, s) => {
90
- i.emit(t, s);
91
- }, [i]), M = () => {
92
- y.configure({
93
- showSpinner: !0
94
- }), y.start();
95
- }, L = () => {
96
- y.done();
97
- }, C = _(() => ({
102
+ eventEmitter.removeListener(eventName, handler);
103
+ }, [eventEmitter]);
104
+ const events_emit = useCallback((eventName, arg) => {
105
+ eventEmitter.emit(eventName, arg);
106
+ }, [eventEmitter]);
107
+ const startProgress = () => {
108
+ NProgress.configure({
109
+ showSpinner: true
110
+ });
111
+ NProgress.start();
112
+ };
113
+ const stopProgress = () => {
114
+ NProgress.done();
115
+ };
116
+ const environment = useMemo(() => ({
98
117
  host: "",
99
- isLocalhost: !0,
118
+ isLocalhost: true,
100
119
  domain_token: "lab1",
101
- host_api_local: n,
102
- host_api_remote: c,
103
- host_static_assets: u,
104
- environment_assets: e
105
- }), []), N = _(() => ({
106
- history: h,
107
- toast: S,
108
- startProgress: M,
109
- stopProgress: L,
110
- events_add_listener: k,
111
- events_remove_listener: A,
112
- events_emit: E
120
+ host_api_local,
121
+ host_api_remote,
122
+ host_static_assets,
123
+ environment_assets
124
+ }), []);
125
+ const hostTools = useMemo(() => ({
126
+ history,
127
+ toast,
128
+ startProgress,
129
+ stopProgress,
130
+ events_add_listener,
131
+ events_remove_listener,
132
+ events_emit
113
133
  }), []);
114
- return /* @__PURE__ */ r(G, {
115
- ...C,
116
- children: /* @__PURE__ */ r(R, {
117
- ...N,
118
- children: /* @__PURE__ */ r(q, {
119
- axiosOperation: J,
120
- children: /* @__PURE__ */ r(x, {
121
- history: h,
122
- children: /* @__PURE__ */ r(I, {
123
- isMicroFrontEnd: !1,
124
- getLocaleFromNetwork: j,
125
- children: /* @__PURE__ */ r(U, {
126
- children: /* @__PURE__ */ r(ro, {
127
- user: d,
128
- pwd: l,
129
- children: /* @__PURE__ */ r($, {
130
- moduleId: o,
131
- privileges: g,
132
- skeletonFlags: p,
133
- componentsDictionary: F,
134
- moduleNameField: v,
135
- children: /* @__PURE__ */ r(oo, {
136
- onLoad: w,
137
- loadAreasFromNetwork: P,
138
- loadCookiesFromNetwork: b,
139
- onSelectLayout: (t) => {
140
- console.log("onSelectLayout", t);
134
+ return /* @__PURE__ */ jsx(EnvironmentProvider, {
135
+ ...environment,
136
+ children: /* @__PURE__ */ jsx(HostToolsProvider, {
137
+ ...hostTools,
138
+ children: /* @__PURE__ */ jsx(NetworkProvider, {
139
+ axiosOperation,
140
+ children: /* @__PURE__ */ jsx(unstable_HistoryRouter, {
141
+ history,
142
+ children: /* @__PURE__ */ jsx(LocalesProvider, {
143
+ isMicroFrontEnd: false,
144
+ getLocaleFromNetwork,
145
+ children: /* @__PURE__ */ jsx(AuthProvider, {
146
+ children: /* @__PURE__ */ jsx(MFAuthApp, {
147
+ user,
148
+ pwd,
149
+ children: /* @__PURE__ */ jsx(BaseModule, {
150
+ moduleId,
151
+ privileges,
152
+ skeletonFlags,
153
+ componentsDictionary,
154
+ moduleNameField,
155
+ children: /* @__PURE__ */ jsx(AreasProvider, {
156
+ onLoad,
157
+ loadAreasFromNetwork: activeAreasNetwork,
158
+ loadCookiesFromNetwork: activeCookiesFromNetwork,
159
+ onSelectLayout: (modId) => {
160
+ console.log("onSelectLayout", modId);
141
161
  },
142
- children: a
162
+ children
143
163
  })
144
164
  })
145
165
  })
@@ -151,5 +171,5 @@ function vo(m) {
151
171
  });
152
172
  }
153
173
  export {
154
- vo as M
174
+ MFIsolationApp as M
155
175
  };