@m4l/layouts 0.1.8 → 0.1.9

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,390 +0,0 @@
1
- import { BoxIcon, Breadcrumbs as Breadcrumbs$1, MenuActions, useModal, ModalProvider, getModalDialogComponentsDictionary } from "@m4l/components";
2
- import { createContext, useState, useMemo, forwardRef, useRef, useImperativeHandle } from "react";
3
- import { styled, useTheme } from "@mui/material/styles";
4
- import { voidFunction, useModuleDictionary, useFlagsPresent, FlagsProvider, ModuleDictionaryProvider, ModuleSkeletonProvider, ModulePrivilegesProvider } from "@m4l/core";
5
- import { Skeleton, Typography, IconButton } from "@mui/material";
6
- import { useResponsiveDesktop } from "@m4l/graphics";
7
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
8
- import { u as useModule } from "../../hooks/useModule/index.js";
9
- const WrapperModule = styled("div")(() => ({
10
- display: "flex",
11
- flexDirection: "column",
12
- position: "absolute",
13
- margin: "12px",
14
- left: "0px",
15
- right: "0px",
16
- top: "0px",
17
- bottom: "0px",
18
- overflow: "hidden"
19
- }));
20
- const ModuleContent = styled("div")(({
21
- theme
22
- }) => ({
23
- display: "flex",
24
- position: "relative",
25
- marginTop: theme.spacing(2),
26
- flexGrow: "1",
27
- overflow: "hidden"
28
- }));
29
- const Container = styled("div")(({
30
- theme
31
- }) => ({
32
- display: "flex",
33
- position: "relative",
34
- paddingTop: theme.spacing(2),
35
- paddingBottom: theme.spacing(2),
36
- borderBottom: `1px solid ${theme.palette.divider}`,
37
- height: "72px",
38
- overflow: "hidden",
39
- alignItems: "center",
40
- " > span": {
41
- marginRight: "12px"
42
- },
43
- "& > h5": {
44
- paddingRight: theme.spacing(3),
45
- borderRight: `1px solid ${theme.palette.divider}`
46
- },
47
- " > nav": {
48
- marginRight: "12px",
49
- flexGrow: 1
50
- },
51
- "& .splitactions.Mui-disabled": {
52
- color: theme.palette.primary.main
53
- },
54
- "& svg ": {
55
- width: "20px",
56
- height: "20px"
57
- }
58
- }));
59
- const Wrapper = styled("div")(({
60
- theme
61
- }) => ({
62
- display: "flex",
63
- justifyContent: "space-between",
64
- padding: `${theme.spacing(2)} 0`,
65
- borderBottom: `1px solid ${theme.palette.divider}`,
66
- height: "auto",
67
- [theme.breakpoints.up("sm")]: {
68
- height: theme.spacing(9)
69
- }
70
- }));
71
- const ModuleTitleContent = styled("div")(({
72
- theme
73
- }) => ({
74
- display: "grid",
75
- gridTemplateColumns: "auto",
76
- gridGap: theme.spacing(1.75),
77
- alignItems: "center",
78
- width: "auto",
79
- height: "auto",
80
- [theme.breakpoints.up("sm")]: {
81
- gridTemplateColumns: "repeat(3, auto)"
82
- }
83
- }));
84
- const ModuleTitle = styled("div")(({
85
- theme
86
- }) => ({
87
- display: "grid",
88
- gridTemplateColumns: `${theme.spacing(3)} auto`,
89
- gridGap: theme.spacing(2),
90
- alignItems: "center",
91
- width: "auto",
92
- height: "auto"
93
- }));
94
- const Separator = styled("div")(({
95
- theme
96
- }) => ({
97
- display: "none",
98
- alignItems: "center",
99
- width: "1px",
100
- background: theme.palette.divider,
101
- height: "100%",
102
- margin: `0 ${theme.spacing(2)}`,
103
- [theme.breakpoints.up("sm")]: {
104
- display: "flex"
105
- }
106
- }));
107
- const Breadcrumbs = styled("div")(({
108
- theme
109
- }) => ({
110
- display: "grid",
111
- alignItems: "center",
112
- gridTemplateColumns: `repeat(3, auto)`,
113
- gridGap: theme.spacing(2)
114
- }));
115
- const ModuleActions = styled("div")(({
116
- theme
117
- }) => ({
118
- display: "grid",
119
- gridTemplateColumns: "auto",
120
- alignItems: "center",
121
- width: "auto",
122
- height: "auto",
123
- [theme.breakpoints.up("sm")]: {
124
- gridTemplateColumns: `repeat(3, ${theme.spacing(3)})`,
125
- gridGap: theme.spacing(2)
126
- }
127
- }));
128
- function SKTModuleHeader() {
129
- const isDesktop = useResponsiveDesktop();
130
- return /* @__PURE__ */ jsxs(Wrapper, {
131
- children: [/* @__PURE__ */ jsxs(ModuleTitleContent, {
132
- children: [/* @__PURE__ */ jsxs(ModuleTitle, {
133
- children: [/* @__PURE__ */ jsx(Skeleton, {
134
- variant: "circular",
135
- width: 24,
136
- height: 24
137
- }), /* @__PURE__ */ jsx(Skeleton, {
138
- variant: "text",
139
- width: 120,
140
- height: 14
141
- })]
142
- }), /* @__PURE__ */ jsx(Separator, {}), /* @__PURE__ */ jsxs(Breadcrumbs, {
143
- children: [/* @__PURE__ */ jsx(Skeleton, {
144
- variant: "text",
145
- width: 68,
146
- height: 14
147
- }), /* @__PURE__ */ jsx(Skeleton, {
148
- variant: "circular",
149
- width: 4,
150
- height: 4
151
- }), /* @__PURE__ */ jsx(Skeleton, {
152
- variant: "text",
153
- width: 68,
154
- height: 14
155
- })]
156
- })]
157
- }), /* @__PURE__ */ jsx(ModuleActions, {
158
- children: isDesktop ? /* @__PURE__ */ jsxs(Fragment, {
159
- children: [/* @__PURE__ */ jsx(Skeleton, {
160
- variant: "circular",
161
- width: 24,
162
- height: 24
163
- }), /* @__PURE__ */ jsx(Skeleton, {
164
- variant: "circular",
165
- width: 24,
166
- height: 24
167
- }), /* @__PURE__ */ jsx(Skeleton, {
168
- variant: "circular",
169
- width: 24,
170
- height: 24
171
- })]
172
- }) : /* @__PURE__ */ jsx(Skeleton, {
173
- variant: "circular",
174
- width: 24,
175
- height: 24
176
- })
177
- })]
178
- });
179
- }
180
- const initialState = {
181
- moduleId: "",
182
- moduleNameField: "module_name",
183
- urlIcon: "",
184
- moduleActions: [],
185
- dynamicActions: [],
186
- setDynamicActions: voidFunction,
187
- breadcrumbLinks: []
188
- };
189
- const ModuleContext = createContext(initialState);
190
- function ModuleProvider(props) {
191
- const {
192
- children,
193
- initialModuleActions,
194
- moduleId,
195
- moduleNameField,
196
- urlIcon,
197
- breadcrumbLinks
198
- } = props;
199
- const [configOptions] = useState(() => ({
200
- moduleId,
201
- urlIcon,
202
- moduleNameField,
203
- dictionary: void 0,
204
- breadcrumbLinks
205
- }));
206
- const [dynamicActions, setDynamicActions] = useState([]);
207
- const finalModuleActions = useMemo(() => initialModuleActions.concat(dynamicActions), [initialModuleActions, dynamicActions]);
208
- return /* @__PURE__ */ jsx(ModuleContext.Provider, {
209
- value: {
210
- moduleActions: finalModuleActions,
211
- dynamicActions,
212
- setDynamicActions,
213
- moduleId: configOptions.moduleId,
214
- moduleNameField: configOptions.moduleNameField,
215
- urlIcon: configOptions.urlIcon,
216
- breadcrumbLinks: configOptions.breadcrumbLinks
217
- },
218
- children
219
- });
220
- }
221
- function getMenuActions(isDesktop, moduleActions) {
222
- let menuActions = [...moduleActions.filter((action) => action.visibility !== "allways")];
223
- if (isDesktop !== void 0 && isDesktop) {
224
- menuActions = menuActions.filter((action) => action.visibility === "normal");
225
- }
226
- return menuActions;
227
- }
228
- function getMainActions(isDesktop, moduleActions) {
229
- let mainActions = [];
230
- if (isDesktop !== void 0 && isDesktop) {
231
- mainActions = mainActions.concat(moduleActions.filter((action) => action.visibility === "main"));
232
- }
233
- mainActions = mainActions.concat(moduleActions.filter((action) => action.visibility === "allways"));
234
- return mainActions;
235
- }
236
- function Header() {
237
- const {
238
- moduleActions,
239
- moduleNameField,
240
- breadcrumbLinks,
241
- urlIcon
242
- } = useModule();
243
- const {
244
- getLabel
245
- } = useModuleDictionary();
246
- const theme = useTheme();
247
- const isDesktop = useResponsiveDesktop();
248
- const isSkeleton = !useFlagsPresent(["dictionary_loaded"]);
249
- const menuActions = useMemo(
250
- () => getMenuActions(isDesktop, moduleActions),
251
- [moduleActions, isDesktop]
252
- );
253
- const mainActions = useMemo(() => {
254
- return getMainActions(isDesktop, moduleActions);
255
- }, [moduleActions, isDesktop]);
256
- if (isSkeleton) {
257
- return /* @__PURE__ */ jsx(SKTModuleHeader, {});
258
- }
259
- return /* @__PURE__ */ jsxs(Container, {
260
- id: "Header",
261
- children: [/* @__PURE__ */ jsx(BoxIcon, {
262
- src: urlIcon,
263
- sx: {
264
- color: theme.palette.primary.main
265
- }
266
- }), /* @__PURE__ */ jsx(Typography, {
267
- variant: "h5",
268
- sx: {
269
- maxWidth: 260,
270
- overflow: "hidden",
271
- whiteSpace: "nowrap",
272
- color: "text.primary",
273
- marginRight: "24px",
274
- textOverflow: "ellipsis"
275
- },
276
- children: getLabel(moduleNameField)
277
- }), /* @__PURE__ */ jsx(Breadcrumbs$1, {
278
- links: breadcrumbLinks
279
- }), mainActions.map((mainAction, index) => {
280
- const description = getLabel(mainAction.dictionaryField);
281
- if (!mainAction.component) {
282
- return /* @__PURE__ */ jsx(IconButton, {
283
- className: mainAction.className,
284
- onClick: mainAction.onClick,
285
- "aria-label": `${description}`,
286
- disabled: mainAction.disabled,
287
- children: /* @__PURE__ */ jsx(BoxIcon, {
288
- src: mainAction.urlIcon,
289
- sx: {
290
- width: 18,
291
- height: 18
292
- }
293
- })
294
- }, `main_action_${index}`);
295
- }
296
- return /* @__PURE__ */ jsx(mainAction.component, {
297
- description,
298
- onClick: mainAction.onClick
299
- }, `main_action_${index}`);
300
- }), menuActions.length > 0 && /* @__PURE__ */ jsx(MenuActions, {
301
- arrow: "right-top",
302
- marginTop: "-11px",
303
- anchorOrigin: {
304
- vertical: "top",
305
- horizontal: "left"
306
- },
307
- transformOrigin: {
308
- vertical: "top",
309
- horizontal: "right"
310
- },
311
- menuActions
312
- })]
313
- });
314
- }
315
- const Module = forwardRef((props, ref) => {
316
- const {
317
- children
318
- } = props;
319
- const {
320
- openModal
321
- } = useModal();
322
- const divRef = useRef(null);
323
- useImperativeHandle(ref, () => ({
324
- openModal,
325
- current: divRef.current
326
- }));
327
- return /* @__PURE__ */ jsxs(WrapperModule, {
328
- id: "WrapperModule",
329
- ref: divRef,
330
- children: [/* @__PURE__ */ jsx(Header, {}), /* @__PURE__ */ jsx(ModuleContent, {
331
- id: "ModuleContent",
332
- children
333
- })]
334
- });
335
- });
336
- Module.displayName = "Module";
337
- const ModuleLayout = forwardRef((props, ref) => {
338
- const {
339
- moduleId,
340
- moduleNameField = "module_name",
341
- moduleActions: initialModuleActions,
342
- urlIcon,
343
- children,
344
- componentsDictionary,
345
- breadcrumbLinks,
346
- privileges,
347
- skeletonFlags
348
- } = props;
349
- const moduleRef = useRef(null);
350
- const openModal = (modalOpenProps) => {
351
- moduleRef.current?.openModal(modalOpenProps);
352
- };
353
- useImperativeHandle(ref, () => ({
354
- openModal,
355
- current: moduleRef.current
356
- }));
357
- return /* @__PURE__ */ jsx(FlagsProvider, {
358
- children: /* @__PURE__ */ jsx(ModuleDictionaryProvider, {
359
- moduleId,
360
- componentsDictionary,
361
- children: /* @__PURE__ */ jsx(ModuleSkeletonProvider, {
362
- flags: skeletonFlags,
363
- children: /* @__PURE__ */ jsx(ModulePrivilegesProvider, {
364
- queryPrivileges: privileges,
365
- children: /* @__PURE__ */ jsx(ModuleProvider, {
366
- moduleId,
367
- urlIcon,
368
- moduleNameField,
369
- initialModuleActions,
370
- breadcrumbLinks,
371
- children: /* @__PURE__ */ jsx(ModalProvider, {
372
- children: /* @__PURE__ */ jsx(Module, {
373
- ref: moduleRef,
374
- children
375
- })
376
- })
377
- })
378
- })
379
- })
380
- })
381
- });
382
- });
383
- ModuleLayout.displayName = "ModuleLayout";
384
- function getModuleLayoutComponentsDictionary() {
385
- return ["module_layout"].concat(getModalDialogComponentsDictionary());
386
- }
387
- const defaultModuleLayoutDictionary = {
388
- module_layout: {}
389
- };
390
- export { ModuleContext as M, ModuleLayout as a, defaultModuleLayoutDictionary as d, getModuleLayoutComponentsDictionary as g };
@@ -1,192 +0,0 @@
1
- import { useResponsive, useLocales } from "@m4l/graphics";
2
- import { Page, CompanyLogo, LanguagePopover, Typography, Image } from "@m4l/components";
3
- import { Card, Container, Stack } from "@mui/material";
4
- import { styled } from "@mui/material/styles";
5
- import { useModuleDictionary, useFlagsPresent, FlagsProvider, DomainProvider, ModuleDictionaryProvider, ModuleSkeletonProvider } from "@m4l/core";
6
- import { jsx, jsxs } from "react/jsx-runtime";
7
- const RootStyle = styled("div")(({
8
- theme
9
- }) => ({
10
- [theme.breakpoints.up("md")]: {
11
- display: "flex"
12
- }
13
- }));
14
- const HeaderStyle = styled("header")(({
15
- theme
16
- }) => ({
17
- top: 0,
18
- zIndex: 9,
19
- lineHeight: 0,
20
- width: "100%",
21
- display: "flex",
22
- alignItems: "center",
23
- position: "absolute",
24
- padding: theme.spacing(2, 2, 0, 2),
25
- justifyContent: "space-between",
26
- [theme.breakpoints.up("md")]: {
27
- alignItems: "flex-start",
28
- padding: theme.spacing(7, 7, 0, 7)
29
- }
30
- }));
31
- const SectionStyle = styled(Card)(({
32
- theme
33
- }) => ({
34
- width: "100%",
35
- maxWidth: 464,
36
- display: "flex",
37
- flexDirection: "column",
38
- justifyContent: "center",
39
- margin: theme.spacing(2, 0, 2, 2),
40
- "& > div:nth-of-type(2)": {
41
- maxHeight: "348px"
42
- }
43
- }));
44
- const ContentStyle = styled("div")(({
45
- theme
46
- }) => ({
47
- maxWidth: 480,
48
- margin: "auto",
49
- display: "flex",
50
- minHeight: "100vh",
51
- flexDirection: "column",
52
- justifyContent: "center",
53
- padding: theme.spacing(12, 0)
54
- }));
55
- const TitleContainer = styled("div")(({
56
- theme
57
- }) => ({
58
- padding: theme.spacing(0, 5)
59
- }));
60
- const ModuleTitleContainer = styled("div")(({
61
- theme
62
- }) => ({
63
- width: "100%",
64
- display: "grid",
65
- gridTemplateColumns: "1fr",
66
- gridGap: theme.spacing(1)
67
- }));
68
- const ModuleWrapper = (props) => {
69
- const {
70
- children
71
- } = props;
72
- const {
73
- getLabel,
74
- getModuleLabel
75
- } = useModuleDictionary();
76
- const mdUp = useResponsive("up", "md");
77
- const isSkeleton = !useFlagsPresent(["dictionary_loaded"]);
78
- return /* @__PURE__ */ jsx(Page, {
79
- title: getModuleLabel(),
80
- children: /* @__PURE__ */ jsxs(RootStyle, {
81
- children: [/* @__PURE__ */ jsxs(HeaderStyle, {
82
- id: "HeaderStyle",
83
- children: [/* @__PURE__ */ jsx(CompanyLogo, {
84
- size: mdUp ? "normal" : "small",
85
- isSkeleton
86
- }), /* @__PURE__ */ jsx(LanguagePopover, {})]
87
- }), mdUp && /* @__PURE__ */ jsxs(SectionStyle, {
88
- id: "SectionStyle",
89
- children: [/* @__PURE__ */ jsx(TitleContainer, {
90
- id: "module_leyend",
91
- children: /* @__PURE__ */ jsx(Typography, {
92
- variant: "h3",
93
- sx: {
94
- px: 5,
95
- mt: 10,
96
- mb: 5
97
- },
98
- skeletonProps: {
99
- isSkeleton,
100
- width: "30%",
101
- height: "18px"
102
- },
103
- children: getLabel("module_leyend")
104
- })
105
- }), /* @__PURE__ */ jsx(Image, {
106
- isSkeleton,
107
- width: "100%",
108
- height: "auto",
109
- src: "https://s3.amazonaws.com/static.made4labs/environment_assetss/d1/frontend/domain/host/login/assets/img/illustration_login.png",
110
- alt: "illustration module",
111
- effect: "opacity"
112
- })]
113
- }), /* @__PURE__ */ jsx(Container, {
114
- maxWidth: "sm",
115
- id: "formContainer",
116
- children: /* @__PURE__ */ jsxs(ContentStyle, {
117
- children: [/* @__PURE__ */ jsx(Stack, {
118
- direction: "row",
119
- alignItems: "center",
120
- sx: {
121
- mb: 5
122
- },
123
- children: /* @__PURE__ */ jsxs(ModuleTitleContainer, {
124
- children: [/* @__PURE__ */ jsx(Typography, {
125
- variant: "h4",
126
- skeletonProps: {
127
- isSkeleton,
128
- width: "35%",
129
- height: "36px"
130
- },
131
- children: getModuleLabel()
132
- }), /* @__PURE__ */ jsx(Typography, {
133
- sx: {
134
- color: "text.secondary"
135
- },
136
- skeletonProps: {
137
- isSkeleton,
138
- width: "60%",
139
- height: "21px"
140
- },
141
- children: getLabel("module_description")
142
- })]
143
- })
144
- }), children]
145
- })
146
- })]
147
- })
148
- });
149
- };
150
- const NoAuthModuleLayout = (props) => {
151
- const {
152
- moduleId,
153
- moduleName,
154
- children,
155
- componentsDictionary,
156
- skeletonFlags
157
- } = props;
158
- const {
159
- currentLang
160
- } = useLocales();
161
- const finalSkeletonFlags = skeletonFlags;
162
- if (finalSkeletonFlags.findIndex((f) => f === "dictionary_loaded") < 0) {
163
- finalSkeletonFlags.push("dictionary_loaded");
164
- }
165
- if (finalSkeletonFlags.findIndex((f) => f === "domain_loaded") < 0) {
166
- finalSkeletonFlags.push("domain_loaded");
167
- }
168
- return /* @__PURE__ */ jsx(FlagsProvider, {
169
- children: /* @__PURE__ */ jsx(DomainProvider, {
170
- children: /* @__PURE__ */ jsx(ModuleDictionaryProvider, {
171
- isAuth: false,
172
- moduleId,
173
- moduleName,
174
- componentsDictionary,
175
- currentLang: currentLang.value,
176
- children: /* @__PURE__ */ jsx(ModuleSkeletonProvider, {
177
- flags: finalSkeletonFlags,
178
- children: /* @__PURE__ */ jsx(ModuleWrapper, {
179
- children
180
- })
181
- })
182
- })
183
- })
184
- });
185
- };
186
- function getNoAuthModuleLayoutComponentsDictionary() {
187
- return ["no_auth_module_layout"];
188
- }
189
- const defaultNoAuthModuleLayoutDictionary = {
190
- no_auth_module_layout: {}
191
- };
192
- export { NoAuthModuleLayout as N, defaultNoAuthModuleLayoutDictionary as d, getNoAuthModuleLayoutComponentsDictionary as g };