@m4l/components 0.0.0 → 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.
Files changed (40) hide show
  1. package/dist/commonjs.js +5 -0
  2. package/dist/components/FormActions/index.d.ts +3 -0
  3. package/dist/components/FormActions/index.js +41 -0
  4. package/dist/components/FormActions/styles.d.ts +2 -0
  5. package/dist/components/FormActions/types.d.ts +7 -0
  6. package/dist/components/ModalDialog/components/Header/index.d.ts +3 -0
  7. package/dist/components/ModalDialog/components/Header/types.d.ts +9 -0
  8. package/dist/components/ModalDialog/index.d.ts +2 -0
  9. package/dist/components/ModalDialog/index.js +174 -0
  10. package/dist/components/ModalDialog/styles.d.ts +9 -0
  11. package/dist/components/ModalDialog/types.d.ts +5 -0
  12. package/dist/components/Resizeable/index.d.ts +3 -0
  13. package/dist/components/Resizeable/index.js +92 -0
  14. package/dist/components/Resizeable/styles.d.ts +5 -0
  15. package/dist/components/Resizeable/types.d.ts +8 -0
  16. package/dist/components/SplitLayout/index.d.ts +3 -0
  17. package/dist/components/SplitLayout/index.js +130 -0
  18. package/dist/components/SplitLayout/styles.d.ts +4 -0
  19. package/dist/components/SplitLayout/types.d.ts +9 -0
  20. package/dist/components/index.d.ts +5 -0
  21. package/dist/components/mui_extended/MenuActions/styles.d.ts +2 -2
  22. package/dist/contexts/ModalContext/components/ContentConfirm/index.d.ts +3 -0
  23. package/dist/contexts/ModalContext/components/ContentConfirm/styles.d.ts +6 -0
  24. package/dist/contexts/ModalContext/components/ContentConfirm/types.d.ts +8 -0
  25. package/dist/contexts/ModalContext/index.d.ts +5 -0
  26. package/dist/contexts/ModalContext/index.js +162 -0
  27. package/dist/contexts/ModalContext/types.d.ts +42 -0
  28. package/dist/contexts/index.d.ts +2 -0
  29. package/dist/hooks/useModal/index.d.ts +1 -0
  30. package/dist/hooks/useModal/index.js +4 -0
  31. package/dist/hooks/useResponsive.d.ts +8 -0
  32. package/dist/index.d.ts +3 -1
  33. package/dist/index.js +22 -6
  34. package/dist/prop-types.js +1 -0
  35. package/dist/react-draggable.js +1435 -0
  36. package/dist/react-resizable.js +594 -0
  37. package/dist/react-splitter-layout.js +165 -0
  38. package/dist/react.js +2 -0
  39. package/dist/vendor.js +44 -0
  40. package/package.json +11 -2
@@ -0,0 +1,162 @@
1
+ import { createContext, useState } from "react";
2
+ import { useEnvironment, voidFunction } from "@m4l/core";
3
+ import Typography from "@mui/material/Typography";
4
+ import { styled } from "@mui/material/styles";
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")(() => ({
9
+ display: "flex",
10
+ flexDirection: "column",
11
+ height: "100%"
12
+ }));
13
+ const ModalContent = styled("div")(({
14
+ theme
15
+ }) => ({
16
+ display: "flex",
17
+ flexDirection: "column",
18
+ justifyContent: "center",
19
+ alignItems: "center",
20
+ gridGap: theme.spacing(5),
21
+ flexGrow: 1,
22
+ [theme.breakpoints.up("sm")]: {
23
+ display: "grid",
24
+ flexDirection: "row",
25
+ gridTemplateColumns: "1fr 1fr"
26
+ }
27
+ }));
28
+ const IllustrationContainer = styled("div")(({
29
+ theme,
30
+ variant
31
+ }) => ({
32
+ display: "flex",
33
+ justifyContent: "center",
34
+ alignItems: "center",
35
+ "& > span": {
36
+ background: variant === "warning" ? theme.palette.warning.main : variant === "delete" ? theme.palette.error.main : variant === "info" ? theme.palette.info.main : "theme.palette.text.primary"
37
+ }
38
+ }));
39
+ const MessageContainer = styled("div")(() => ({
40
+ display: "flex",
41
+ alignItems: "center"
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
+ };
75
+ const initialState = {
76
+ initialWidth: 600,
77
+ initialHeigth: 400,
78
+ open: false,
79
+ withClose: true,
80
+ onQueryClose: voidFunction,
81
+ iconComponent: void 0,
82
+ contentComponent: void 0,
83
+ actionComponents: void 0,
84
+ openModal: voidFunction,
85
+ openModalConfirm: voidFunction,
86
+ closeModal: voidFunction,
87
+ hasChanges: false,
88
+ setChanges: voidFunction,
89
+ title: ""
90
+ };
91
+ const ModalContext = createContext(initialState);
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 };
@@ -0,0 +1,42 @@
1
+ import { ReactNode } from 'react';
2
+ export declare type TProps = {
3
+ children: ReactNode;
4
+ };
5
+ export interface StandarActions {
6
+ withCancel?: boolean;
7
+ onClickIntro?: () => void;
8
+ onClickCancel?: () => void;
9
+ }
10
+ export declare type VariantModal = 'warning' | 'delete' | 'info';
11
+ export interface ModalOpenOptions {
12
+ initialWidth?: number;
13
+ initialHeigth?: number;
14
+ maxWidth?: number;
15
+ maxHeigth?: number;
16
+ withClose?: boolean;
17
+ onQueryClose?: () => void;
18
+ title: string;
19
+ iconComponent?: ReactNode;
20
+ contentComponent?: ((props?: any) => JSX.Element) | ReactNode;
21
+ actionComponents?: ReactNode[];
22
+ standardActions?: StandarActions;
23
+ }
24
+ export interface OpenModalConfirmProps {
25
+ title: string;
26
+ variant?: VariantModal;
27
+ titleAccept?: string;
28
+ msg: string;
29
+ onClickIntro?: () => void;
30
+ onClickCancel?: () => void;
31
+ }
32
+ export interface ModalState extends ModalOpenOptions {
33
+ open: boolean;
34
+ variant?: VariantModal;
35
+ }
36
+ export interface ModalContextProps extends ModalState {
37
+ openModal: (modalProps: ModalOpenOptions) => void;
38
+ openModalConfirm: (modalOpenProps: OpenModalConfirmProps) => void;
39
+ closeModal: () => void;
40
+ setChanges?: () => void;
41
+ hasChanges: boolean;
42
+ }
@@ -0,0 +1,2 @@
1
+ export * from './ModalContext/index';
2
+ export * from './ModalContext/types';
@@ -0,0 +1 @@
1
+ export declare const useModal: () => import("../..").ModalContextProps;
@@ -0,0 +1,4 @@
1
+ import { useContext } from "react";
2
+ import { M as ModalContext } from "../../contexts/ModalContext/index.js";
3
+ const useModal = () => useContext(ModalContext);
4
+ export { useModal as u };
@@ -0,0 +1,8 @@
1
+ import { Breakpoint } from '@mui/material';
2
+ declare type Query = 'up' | 'down' | 'between' | 'only';
3
+ declare type Key = Breakpoint | number;
4
+ declare type Start = Breakpoint | number;
5
+ declare type End = Breakpoint | number;
6
+ export declare function useResponsive(query: Query, key?: Key, start?: Start, end?: End): boolean | undefined;
7
+ export declare function useResponsiveDesktop(): boolean | undefined;
8
+ export {};
package/dist/index.d.ts CHANGED
@@ -1 +1,3 @@
1
- export * from './components/mui_extended';
1
+ export * from './components';
2
+ export * from './contexts';
3
+ export * from './hooks/useModal';
package/dist/index.js CHANGED
@@ -1,11 +1,27 @@
1
+ export { B as BoxIcon } from "./components/mui_extended/BoxIcon/index.js";
2
+ export { M as MenuPopover } from "./components/mui_extended/MenuPopover/index.js";
3
+ export { B as Breadcrumbs } from "./components/mui_extended/Breadcrumbs/index.js";
4
+ export { M as MenuActions } from "./components/mui_extended/MenuActions/index.js";
5
+ export { F as FormActions } from "./components/FormActions/index.js";
6
+ export { M as ModalDialog } from "./components/ModalDialog/index.js";
7
+ export { R as Resizeable } from "./components/Resizeable/index.js";
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";
1
11
  import "@mui/material/Box";
2
12
  import "react/jsx-runtime";
3
- export { M as MenuPopover } from "./components/mui_extended/MenuPopover/index.js";
13
+ import "@mui/material/styles";
14
+ import "@mui/material";
4
15
  import "react";
5
16
  import "@m4l/core";
6
- import "@mui/material";
7
17
  import "react-router-dom";
8
- export { M as MenuActions } from "./components/mui_extended/MenuActions/index.js";
9
- export { B as BoxIcon } from "./components/mui_extended/BoxIcon/index.js";
10
- export { B as Breadcrumbs } from "./components/mui_extended/Breadcrumbs/index.js";
11
- import "@mui/material/styles";
18
+ import "./react-draggable.js";
19
+ import "prop-types";
20
+ import "react-dom";
21
+ import "clsx";
22
+ import "./vendor.js";
23
+ import "@mui/material/useMediaQuery";
24
+ import "./react-splitter-layout.js";
25
+ import "./commonjs.js";
26
+ import "./react-resizable.js";
27
+ import "@mui/material/Typography";
@@ -0,0 +1 @@
1
+ import "prop-types";