@m4l/components 0.0.2 → 0.0.3
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.
- package/dist/contexts/ModalContext/index.js +113 -19
- package/dist/contexts/index.d.ts +2 -0
- package/dist/hooks/useModal/index.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -4
- package/dist/vendor.js +1 -0
- package/package.json +1 -1
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import { voidFunction } from "@m4l/core";
|
|
3
|
-
import "@mui/material/
|
|
4
|
-
import "react/jsx-runtime";
|
|
5
|
-
import { createContext } from "react";
|
|
1
|
+
import { createContext, useState } from "react";
|
|
2
|
+
import { useEnvironment, voidFunction } from "@m4l/core";
|
|
3
|
+
import Typography from "@mui/material/Typography";
|
|
6
4
|
import { styled } from "@mui/material/styles";
|
|
7
|
-
import "
|
|
8
|
-
import "
|
|
9
|
-
import "../../components/ModalDialog/index.js";
|
|
10
|
-
|
|
11
|
-
import "@mui/material/useMediaQuery";
|
|
12
|
-
import "../../components/mui_extended/MenuPopover/index.js";
|
|
13
|
-
import "react-router-dom";
|
|
14
|
-
import "../../components/mui_extended/MenuActions/index.js";
|
|
15
|
-
import "../../components/FormActions/index.js";
|
|
16
|
-
styled("div")(() => ({
|
|
5
|
+
import { B as BoxIcon } from "../../components/mui_extended/BoxIcon/index.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { M as ModalDialog } from "../../components/ModalDialog/index.js";
|
|
8
|
+
const WrapperContentConfirm = styled("div")(() => ({
|
|
17
9
|
display: "flex",
|
|
18
10
|
flexDirection: "column",
|
|
19
11
|
height: "100%"
|
|
20
12
|
}));
|
|
21
|
-
styled("div")(({
|
|
13
|
+
const ModalContent = styled("div")(({
|
|
22
14
|
theme
|
|
23
15
|
}) => ({
|
|
24
16
|
display: "flex",
|
|
@@ -33,7 +25,7 @@ styled("div")(({
|
|
|
33
25
|
gridTemplateColumns: "1fr 1fr"
|
|
34
26
|
}
|
|
35
27
|
}));
|
|
36
|
-
styled("div")(({
|
|
28
|
+
const IllustrationContainer = styled("div")(({
|
|
37
29
|
theme,
|
|
38
30
|
variant
|
|
39
31
|
}) => ({
|
|
@@ -44,10 +36,42 @@ styled("div")(({
|
|
|
44
36
|
background: variant === "warning" ? theme.palette.warning.main : variant === "delete" ? theme.palette.error.main : variant === "info" ? theme.palette.info.main : "theme.palette.text.primary"
|
|
45
37
|
}
|
|
46
38
|
}));
|
|
47
|
-
styled("div")(() => ({
|
|
39
|
+
const MessageContainer = styled("div")(() => ({
|
|
48
40
|
display: "flex",
|
|
49
41
|
alignItems: "center"
|
|
50
42
|
}));
|
|
43
|
+
const ContentConfirm = (props) => {
|
|
44
|
+
const {
|
|
45
|
+
variant = "info",
|
|
46
|
+
msg = "Are you sure you want to perform this action? Once complete, the information will be deleted."
|
|
47
|
+
} = props;
|
|
48
|
+
const {
|
|
49
|
+
host_static_assets,
|
|
50
|
+
environment
|
|
51
|
+
} = useEnvironment();
|
|
52
|
+
const illustrationWarning = `${host_static_assets}/${environment}/frontend/components/dialog/assets/icons/illustration_confirm_warning.svg`;
|
|
53
|
+
const illustrationError = `${host_static_assets}/${environment}/frontend/components/dialog/assets/icons/illustration_confirm_danger.svg`;
|
|
54
|
+
const illustrationInfo = `${host_static_assets}/${environment}/frontend/components/dialog/assets/icons/illustration_confirm_info.svg`;
|
|
55
|
+
return /* @__PURE__ */ jsx(WrapperContentConfirm, {
|
|
56
|
+
children: /* @__PURE__ */ jsxs(ModalContent, {
|
|
57
|
+
children: [/* @__PURE__ */ jsx(IllustrationContainer, {
|
|
58
|
+
variant,
|
|
59
|
+
children: /* @__PURE__ */ jsx(BoxIcon, {
|
|
60
|
+
src: variant === "warning" ? illustrationWarning : variant === "delete" ? illustrationError : illustrationInfo,
|
|
61
|
+
sx: {
|
|
62
|
+
width: "230px",
|
|
63
|
+
height: "194px"
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
}), /* @__PURE__ */ jsx(MessageContainer, {
|
|
67
|
+
children: /* @__PURE__ */ jsx(Typography, {
|
|
68
|
+
variant: "body1",
|
|
69
|
+
children: msg
|
|
70
|
+
})
|
|
71
|
+
})]
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
};
|
|
51
75
|
const initialState = {
|
|
52
76
|
initialWidth: 600,
|
|
53
77
|
initialHeigth: 400,
|
|
@@ -65,4 +89,74 @@ const initialState = {
|
|
|
65
89
|
title: ""
|
|
66
90
|
};
|
|
67
91
|
const ModalContext = createContext(initialState);
|
|
68
|
-
|
|
92
|
+
function ModalProvider({
|
|
93
|
+
children
|
|
94
|
+
}) {
|
|
95
|
+
const [modalOptions, setModalOptions] = useState({
|
|
96
|
+
open: initialState.open,
|
|
97
|
+
withClose: true,
|
|
98
|
+
onQueryClose: voidFunction,
|
|
99
|
+
title: "",
|
|
100
|
+
iconComponent: void 0,
|
|
101
|
+
contentComponent: void 0,
|
|
102
|
+
actionComponents: void 0,
|
|
103
|
+
standardActions: void 0,
|
|
104
|
+
variant: void 0
|
|
105
|
+
});
|
|
106
|
+
const [hasChanges, setHasChanges] = useState(false);
|
|
107
|
+
const openModal = (modalOpenProps) => {
|
|
108
|
+
setModalOptions({
|
|
109
|
+
open: true,
|
|
110
|
+
...modalOpenProps
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
const openModalConfirm = (modalOpenConfirmProps) => {
|
|
114
|
+
const {
|
|
115
|
+
variant = "warning",
|
|
116
|
+
title,
|
|
117
|
+
msg,
|
|
118
|
+
onClickIntro,
|
|
119
|
+
onClickCancel
|
|
120
|
+
} = modalOpenConfirmProps;
|
|
121
|
+
const onClickIntroClose = () => {
|
|
122
|
+
onClickIntro && onClickIntro();
|
|
123
|
+
closeModal();
|
|
124
|
+
};
|
|
125
|
+
setModalOptions({
|
|
126
|
+
open: true,
|
|
127
|
+
title,
|
|
128
|
+
variant,
|
|
129
|
+
contentComponent: /* @__PURE__ */ jsx(ContentConfirm, {
|
|
130
|
+
variant,
|
|
131
|
+
msg
|
|
132
|
+
}),
|
|
133
|
+
standardActions: {
|
|
134
|
+
withCancel: true,
|
|
135
|
+
onClickIntro: onClickIntroClose,
|
|
136
|
+
onClickCancel
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
const closeModal = () => {
|
|
141
|
+
setModalOptions((last) => ({
|
|
142
|
+
...last,
|
|
143
|
+
open: false
|
|
144
|
+
}));
|
|
145
|
+
setHasChanges(false);
|
|
146
|
+
};
|
|
147
|
+
const setChanges = () => {
|
|
148
|
+
setHasChanges(true);
|
|
149
|
+
};
|
|
150
|
+
return /* @__PURE__ */ jsxs(ModalContext.Provider, {
|
|
151
|
+
value: {
|
|
152
|
+
...modalOptions,
|
|
153
|
+
openModal,
|
|
154
|
+
openModalConfirm,
|
|
155
|
+
closeModal,
|
|
156
|
+
hasChanges,
|
|
157
|
+
setChanges
|
|
158
|
+
},
|
|
159
|
+
children: [children, /* @__PURE__ */ jsx(ModalDialog, {})]
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
export { ModalContext as M, ModalProvider as a };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useModal: () => import("
|
|
1
|
+
export declare const useModal: () => import("../..").ModalContextProps;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -6,6 +6,8 @@ export { F as FormActions } from "./components/FormActions/index.js";
|
|
|
6
6
|
export { M as ModalDialog } from "./components/ModalDialog/index.js";
|
|
7
7
|
export { R as Resizeable } from "./components/Resizeable/index.js";
|
|
8
8
|
export { S as SplitLayout } from "./components/SplitLayout/index.js";
|
|
9
|
+
export { M as ModalContext, a as ModalProvider } from "./contexts/ModalContext/index.js";
|
|
10
|
+
export { u as useModal } from "./hooks/useModal/index.js";
|
|
9
11
|
import "@mui/material/Box";
|
|
10
12
|
import "react/jsx-runtime";
|
|
11
13
|
import "@mui/material/styles";
|
|
@@ -17,11 +19,9 @@ import "./react-draggable.js";
|
|
|
17
19
|
import "prop-types";
|
|
18
20
|
import "react-dom";
|
|
19
21
|
import "clsx";
|
|
20
|
-
import "./hooks/useModal/index.js";
|
|
21
|
-
import "./contexts/ModalContext/index.js";
|
|
22
|
-
import "@mui/material/Typography";
|
|
23
|
-
import "@mui/material/useMediaQuery";
|
|
24
22
|
import "./vendor.js";
|
|
23
|
+
import "@mui/material/useMediaQuery";
|
|
25
24
|
import "./react-splitter-layout.js";
|
|
26
25
|
import "./commonjs.js";
|
|
27
26
|
import "./react-resizable.js";
|
|
27
|
+
import "@mui/material/Typography";
|
package/dist/vendor.js
CHANGED
|
@@ -17,6 +17,7 @@ import "./react-splitter-layout.js";
|
|
|
17
17
|
import "./components/SplitLayout/index.js";
|
|
18
18
|
import "./components/mui_extended/BoxIcon/index.js";
|
|
19
19
|
import "./components/mui_extended/Breadcrumbs/index.js";
|
|
20
|
+
import "./hooks/useModal/index.js";
|
|
20
21
|
function useResponsive(query, key, start, end) {
|
|
21
22
|
const theme = useTheme();
|
|
22
23
|
const mediaUp = useMediaQuery(theme.breakpoints.up(key));
|