@m4l/layouts 0.1.8 → 0.1.10

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.
@@ -0,0 +1,178 @@
1
+ import { useResponsive as u, useLocales as h } from "@m4l/graphics";
2
+ import { Page as g, CompanyLogo as y, LanguagePopover as f, Typography as m, Image as x } from "@m4l/components";
3
+ import { Card as v, Container as _, Stack as C } from "@mui/material";
4
+ import { styled as i } from "@mui/material/styles";
5
+ import { useModuleDictionary as S, useFlagsPresent as k, FlagsProvider as w, DomainProvider as L, ModuleDictionaryProvider as P, ModuleSkeletonProvider as b } from "@m4l/core";
6
+ import { jsx as t, jsxs as d } from "react/jsx-runtime";
7
+ const M = i("div")(({
8
+ theme: e
9
+ }) => ({
10
+ [e.breakpoints.up("md")]: {
11
+ display: "flex"
12
+ }
13
+ })), D = i("header")(({
14
+ theme: e
15
+ }) => ({
16
+ top: 0,
17
+ zIndex: 9,
18
+ lineHeight: 0,
19
+ width: "100%",
20
+ display: "flex",
21
+ alignItems: "center",
22
+ position: "absolute",
23
+ padding: e.spacing(2, 2, 0, 2),
24
+ justifyContent: "space-between",
25
+ [e.breakpoints.up("md")]: {
26
+ alignItems: "flex-start",
27
+ padding: e.spacing(7, 7, 0, 7)
28
+ }
29
+ })), I = i(v)(({
30
+ theme: e
31
+ }) => ({
32
+ width: "100%",
33
+ maxWidth: 464,
34
+ display: "flex",
35
+ flexDirection: "column",
36
+ justifyContent: "center",
37
+ margin: e.spacing(2, 0, 2, 2),
38
+ "& > div:nth-of-type(2)": {
39
+ maxHeight: "348px"
40
+ }
41
+ })), j = i("div")(({
42
+ theme: e
43
+ }) => ({
44
+ maxWidth: 480,
45
+ margin: "auto",
46
+ display: "flex",
47
+ minHeight: "100vh",
48
+ flexDirection: "column",
49
+ justifyContent: "center",
50
+ padding: e.spacing(12, 0)
51
+ })), H = i("div")(({
52
+ theme: e
53
+ }) => ({
54
+ padding: e.spacing(0, 5)
55
+ })), N = i("div")(({
56
+ theme: e
57
+ }) => ({
58
+ width: "100%",
59
+ display: "grid",
60
+ gridTemplateColumns: "1fr",
61
+ gridGap: e.spacing(1)
62
+ })), A = (e) => {
63
+ const {
64
+ children: s
65
+ } = e, {
66
+ getLabel: a,
67
+ getModuleLabel: l
68
+ } = S(), r = u("up", "md"), n = !k(["dictionary_loaded"]);
69
+ return /* @__PURE__ */ t(g, {
70
+ title: l(),
71
+ children: /* @__PURE__ */ d(M, {
72
+ children: [/* @__PURE__ */ d(D, {
73
+ id: "HeaderStyle",
74
+ children: [/* @__PURE__ */ t(y, {
75
+ size: r ? "normal" : "small",
76
+ isSkeleton: n
77
+ }), /* @__PURE__ */ t(f, {})]
78
+ }), r && /* @__PURE__ */ d(I, {
79
+ id: "SectionStyle",
80
+ children: [/* @__PURE__ */ t(H, {
81
+ id: "module_leyend",
82
+ children: /* @__PURE__ */ t(m, {
83
+ variant: "h3",
84
+ sx: {
85
+ px: 5,
86
+ mt: 10,
87
+ mb: 5
88
+ },
89
+ skeletonProps: {
90
+ isSkeleton: n,
91
+ width: "30%",
92
+ height: "18px"
93
+ },
94
+ children: a("module_leyend")
95
+ })
96
+ }), /* @__PURE__ */ t(x, {
97
+ isSkeleton: n,
98
+ width: "100%",
99
+ height: "auto",
100
+ src: "https://s3.amazonaws.com/static.made4labs/environment_assetss/d1/frontend/domain/host/login/assets/img/illustration_login.png",
101
+ alt: "illustration module",
102
+ effect: "opacity"
103
+ })]
104
+ }), /* @__PURE__ */ t(_, {
105
+ maxWidth: "sm",
106
+ id: "formContainer",
107
+ children: /* @__PURE__ */ d(j, {
108
+ children: [/* @__PURE__ */ t(C, {
109
+ direction: "row",
110
+ alignItems: "center",
111
+ sx: {
112
+ mb: 5
113
+ },
114
+ children: /* @__PURE__ */ d(N, {
115
+ children: [/* @__PURE__ */ t(m, {
116
+ variant: "h4",
117
+ skeletonProps: {
118
+ isSkeleton: n,
119
+ width: "35%",
120
+ height: "36px"
121
+ },
122
+ children: l()
123
+ }), /* @__PURE__ */ t(m, {
124
+ sx: {
125
+ color: "text.secondary"
126
+ },
127
+ skeletonProps: {
128
+ isSkeleton: n,
129
+ width: "60%",
130
+ height: "21px"
131
+ },
132
+ children: a("module_description")
133
+ })]
134
+ })
135
+ }), s]
136
+ })
137
+ })]
138
+ })
139
+ });
140
+ }, U = (e) => {
141
+ const {
142
+ moduleId: s,
143
+ moduleName: a,
144
+ children: l,
145
+ componentsDictionary: r,
146
+ skeletonFlags: n
147
+ } = e, {
148
+ currentLang: p
149
+ } = h(), o = n;
150
+ return o.findIndex((c) => c === "dictionary_loaded") < 0 && o.push("dictionary_loaded"), o.findIndex((c) => c === "domain_loaded") < 0 && o.push("domain_loaded"), /* @__PURE__ */ t(w, {
151
+ children: /* @__PURE__ */ t(L, {
152
+ children: /* @__PURE__ */ t(P, {
153
+ isAuth: !1,
154
+ moduleId: s,
155
+ moduleName: a,
156
+ componentsDictionary: r,
157
+ currentLang: p.value,
158
+ children: /* @__PURE__ */ t(b, {
159
+ flags: o,
160
+ children: /* @__PURE__ */ t(A, {
161
+ children: l
162
+ })
163
+ })
164
+ })
165
+ })
166
+ });
167
+ };
168
+ function q() {
169
+ return ["no_auth_module_layout"];
170
+ }
171
+ const B = {
172
+ no_auth_module_layout: {}
173
+ };
174
+ export {
175
+ U as N,
176
+ B as d,
177
+ q as g
178
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/layouts",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "license": "UNLICENSED",
5
5
  "dependencies": {
6
6
  "@m4l/components": "*",
@@ -1,4 +0,0 @@
1
- import { useContext } from "react";
2
- import { M as MasterDetailContext } from "../../layouts/MasterDetailLayout/index.js";
3
- const useMasterDetail = () => useContext(MasterDetailContext);
4
- export { useMasterDetail as u };
@@ -1,9 +0,0 @@
1
- import { useContext } from "react";
2
- import { M as ModuleContext } from "../../layouts/ModuleLayout/index.js";
3
- const useModule = () => {
4
- const context = useContext(ModuleContext);
5
- if (!context)
6
- throw new Error("useModule context must be use inside ModuleContext");
7
- return context;
8
- };
9
- export { useModule as u };
@@ -1,160 +0,0 @@
1
- import { createContext, useState, useRef, useCallback, useMemo } from "react";
2
- import { voidFunction, useEnvironment } from "@m4l/core";
3
- import { SplitLayout } from "@m4l/components";
4
- import { g as getModuleLayoutComponentsDictionary, a as ModuleLayout } from "../ModuleLayout/index.js";
5
- import { jsx } from "react/jsx-runtime";
6
- import { useResponsiveDesktop } from "@m4l/graphics";
7
- import { Button } from "@mui/material";
8
- import { u as useMasterDetail } from "../../hooks/useMasterDetail/index.js";
9
- function getMasterDetailLayoutComponentsDictionary() {
10
- return ["master_detail_layout"].concat(getModuleLayoutComponentsDictionary());
11
- }
12
- const defaultMasterDetailDictionary = {
13
- master_detail_layout: {
14
- split_vertical: "Split vertically",
15
- split_horizontal: "Split horizontally",
16
- no_split: "No split",
17
- view_detail: "View detail"
18
- }
19
- };
20
- const initialState = {
21
- masterSelection: void 0,
22
- onChangeMasterSelection: voidFunction
23
- };
24
- const MasterDetailContext = createContext(initialState);
25
- function MasterDetailProvider(props) {
26
- const {
27
- children
28
- } = props;
29
- const [masterSelection, setMasterSelection] = useState(void 0);
30
- return /* @__PURE__ */ jsx(MasterDetailContext.Provider, {
31
- value: {
32
- masterSelection,
33
- onChangeMasterSelection: setMasterSelection
34
- },
35
- children
36
- });
37
- }
38
- function ButtonDetail(props) {
39
- const {
40
- masterSelection
41
- } = useMasterDetail();
42
- const {
43
- onClick,
44
- description
45
- } = props;
46
- return /* @__PURE__ */ jsx(Button, {
47
- onClick,
48
- variant: "outlined",
49
- disabled: masterSelection === void 0 ? true : false,
50
- children: description
51
- }, "miDetail");
52
- }
53
- function getTotalModuleActions(splitActions, moduleActions, viewDetailAction, isDesktop) {
54
- let totalActions = isDesktop !== void 0 && isDesktop ? [...splitActions] : [viewDetailAction];
55
- totalActions = moduleActions.concat(totalActions);
56
- return totalActions;
57
- }
58
- function MasterDetailLayout(props) {
59
- const {
60
- moduleId,
61
- moduleNameField,
62
- detailComponent,
63
- moduleActions,
64
- urlIcon,
65
- masterComponent,
66
- componentsDictionary,
67
- breadcrumbLinks,
68
- privileges,
69
- skeletonFlags
70
- } = props;
71
- const {
72
- host_static_assets,
73
- environment_assets
74
- } = useEnvironment();
75
- const [splitPosition, setSplitPosition] = useState("vertical");
76
- const isDesktop = useResponsiveDesktop();
77
- const moduleLayoutRef = useRef(null);
78
- const onChangePostionInternal = (newPostion) => {
79
- const newSplitActions = [...initialSplitActions];
80
- for (let i = 0; i < newSplitActions.length; i++) {
81
- newSplitActions[i].disabled = false;
82
- if (newSplitActions[i].tag === newPostion) {
83
- newSplitActions[i].disabled = true;
84
- }
85
- }
86
- setSplitActions(newSplitActions);
87
- setSplitPosition(newPostion);
88
- };
89
- const initialSplitActions = [{
90
- urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/split_vertical.svg`,
91
- onClick: () => onChangePostionInternal("vertical"),
92
- disabled: true,
93
- visibility: "main",
94
- dictionaryField: "master_detail_layout.split_vertical",
95
- tag: "vertical",
96
- className: "splitactions"
97
- }, {
98
- urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/split_horizontal.svg`,
99
- onClick: () => onChangePostionInternal("horizontal"),
100
- disabled: false,
101
- visibility: "main",
102
- dictionaryField: "master_detail_layout.split_horizontal",
103
- tag: "horizontal",
104
- className: "splitactions"
105
- }, {
106
- urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/no_split.svg`,
107
- onClick: () => onChangePostionInternal("none"),
108
- disabled: false,
109
- visibility: "main",
110
- dictionaryField: "master_detail_layout.no_split",
111
- tag: "none",
112
- className: "splitactions"
113
- }];
114
- const onClickViewDetail = useCallback(() => {
115
- moduleLayoutRef.current?.openModal({
116
- title: "master_detail_layout.view_detail",
117
- initialWidth: 500,
118
- initialHeigth: 680,
119
- contentComponent: detailComponent,
120
- actions: void 0
121
- });
122
- }, [detailComponent]);
123
- const viewDetailAction = useMemo(() => {
124
- return {
125
- urlIcon: `${host_static_assets}/${environment_assets}/frontend/components/masterdetaillayout/assets/icons/view_detail.svg`,
126
- onClick: onClickViewDetail,
127
- disabled: false,
128
- visibility: "allways",
129
- dictionaryField: "master_detail_layout.view_detail",
130
- tag: "none",
131
- className: "",
132
- component: ButtonDetail
133
- };
134
- }, [environment_assets, onClickViewDetail]);
135
- const [splitActions, setSplitActions] = useState(initialSplitActions);
136
- const finalModuleActions = useMemo(() => {
137
- const actions = getTotalModuleActions(splitActions, moduleActions, viewDetailAction, isDesktop);
138
- return actions;
139
- }, [splitActions, moduleActions, isDesktop, viewDetailAction]);
140
- const finalComponentsDictionary = useMemo(() => componentsDictionary.concat(getMasterDetailLayoutComponentsDictionary()), [componentsDictionary]);
141
- return /* @__PURE__ */ jsx(MasterDetailProvider, {
142
- children: /* @__PURE__ */ jsx(ModuleLayout, {
143
- ref: moduleLayoutRef,
144
- moduleId,
145
- moduleNameField,
146
- urlIcon,
147
- moduleActions: finalModuleActions,
148
- privileges,
149
- skeletonFlags,
150
- componentsDictionary: finalComponentsDictionary,
151
- breadcrumbLinks,
152
- children: /* @__PURE__ */ jsx(SplitLayout, {
153
- splitPosition: isDesktop ? splitPosition : "none",
154
- firstPart: masterComponent,
155
- secondPart: detailComponent
156
- })
157
- })
158
- });
159
- }
160
- export { MasterDetailContext as M, MasterDetailLayout as a, defaultMasterDetailDictionary as d, getMasterDetailLayoutComponentsDictionary as g };