@soyfri/shared-library 1.5.0 → 2.0.0-beta.0
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/components/ActionMenu/ActionMenu.cjs +107 -0
- package/dist/components/ActionMenu/ActionMenu.cjs.map +1 -0
- package/dist/components/ActionMenu/ActionMenu.d.ts +60 -0
- package/dist/components/ActionMenu/ActionMenu.js +107 -0
- package/dist/components/ActionMenu/ActionMenu.js.map +1 -0
- package/dist/components/ActionMenu/index.d.ts +2 -0
- package/dist/components/ActionMenu.d.ts +6 -0
- package/dist/components/AppBar/AppBar.cjs +346 -0
- package/dist/components/AppBar/AppBar.cjs.map +1 -0
- package/dist/components/AppBar/AppBar.d.ts +55 -0
- package/dist/components/AppBar/AppBar.js +346 -0
- package/dist/components/AppBar/AppBar.js.map +1 -0
- package/dist/components/AppBar/AppBar.sx.d.ts +12 -0
- package/dist/components/AppBar/AppBarBrand.d.ts +31 -0
- package/dist/components/AppBar/AppBarContext.d.ts +18 -0
- package/dist/components/AppBar/AppBarMenuToggle.d.ts +39 -0
- package/dist/components/AppBar/AppBarUserMenu.d.ts +65 -0
- package/dist/components/AppBar/index.d.ts +12 -0
- package/dist/components/AppBar.d.ts +6 -0
- package/dist/components/Autocomplete/Autocomplete.cjs +259 -54
- package/dist/components/Autocomplete/Autocomplete.cjs.map +1 -1
- package/dist/components/Autocomplete/Autocomplete.d.ts +64 -9
- package/dist/components/Autocomplete/Autocomplete.definitions.d.ts +6 -0
- package/dist/components/Autocomplete/Autocomplete.helpers.d.ts +18 -0
- package/dist/components/Autocomplete/Autocomplete.js +261 -56
- package/dist/components/Autocomplete/Autocomplete.js.map +1 -1
- package/dist/components/Autocomplete/Autocomplete.sx.d.ts +7 -0
- package/dist/components/Autocomplete/Autocomplete.types.d.ts +1 -0
- package/dist/components/Autocomplete/_parts/AutocompleteChips.d.ts +19 -0
- package/dist/components/Autocomplete/_parts/AutocompleteLoader.d.ts +9 -0
- package/dist/components/Autocomplete/_parts/AutocompleteOption.d.ts +19 -0
- package/dist/components/Autocomplete/index.d.ts +2 -1
- package/dist/components/Autocomplete.d.ts +4 -0
- package/dist/components/Avatar/Avatar.cjs +116 -79
- package/dist/components/Avatar/Avatar.cjs.map +1 -1
- package/dist/components/Avatar/Avatar.d.ts +16 -2
- package/dist/components/Avatar/Avatar.definitions.d.ts +11 -0
- package/dist/components/Avatar/Avatar.js +117 -80
- package/dist/components/Avatar/Avatar.js.map +1 -1
- package/dist/components/Card/Card.cjs +168 -9
- package/dist/components/Card/Card.cjs.map +1 -1
- package/dist/components/Card/Card.d.ts +78 -8
- package/dist/components/Card/Card.js +170 -11
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/Card/Card.sx.d.ts +17 -0
- package/dist/components/Card/index.d.ts +4 -1
- package/dist/components/Card.d.ts +4 -0
- package/dist/components/DatePicker/DatePicker.cjs +201 -3
- package/dist/components/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +47 -9
- package/dist/components/DatePicker/DatePicker.definitions.d.ts +1 -0
- package/dist/components/DatePicker/DatePicker.helpers.d.ts +7 -0
- package/dist/components/DatePicker/DatePicker.js +200 -2
- package/dist/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/DatePicker/DatePicker.sx.d.ts +9 -0
- package/dist/components/DatePicker/DatePicker.types.d.ts +1 -0
- package/dist/components/DatePicker/index.d.ts +2 -1
- package/dist/components/DatePicker.d.ts +4 -0
- package/dist/components/DateTimePicker/DateTimePicker.cjs +152 -138
- package/dist/components/DateTimePicker/DateTimePicker.cjs.map +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +46 -9
- package/dist/components/DateTimePicker/DateTimePicker.definitions.d.ts +1 -0
- package/dist/components/DateTimePicker/DateTimePicker.helpers.d.ts +11 -0
- package/dist/components/DateTimePicker/DateTimePicker.js +152 -138
- package/dist/components/DateTimePicker/DateTimePicker.js.map +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.sx.d.ts +7 -0
- package/dist/components/DateTimePicker/DateTimePicker.types.d.ts +1 -0
- package/dist/components/DateTimePicker/index.d.ts +2 -1
- package/dist/components/DateTimePicker.d.ts +4 -0
- package/dist/components/Drawer/Drawer.cjs +271 -0
- package/dist/components/Drawer/Drawer.cjs.map +1 -0
- package/dist/components/Drawer/Drawer.d.ts +51 -0
- package/dist/components/Drawer/Drawer.js +271 -0
- package/dist/components/Drawer/Drawer.js.map +1 -0
- package/dist/components/Drawer/Drawer.sx.d.ts +23 -0
- package/dist/components/Drawer/DrawerContext.d.ts +18 -0
- package/dist/components/Drawer/DrawerItem.d.ts +35 -0
- package/dist/components/Drawer/index.d.ts +6 -0
- package/dist/components/Drawer.d.ts +6 -0
- package/dist/components/Icon/Icon.cjs +44 -3
- package/dist/components/Icon/Icon.cjs.map +1 -1
- package/dist/components/Icon/Icon.d.ts +34 -1
- package/dist/components/Icon/Icon.js +44 -3
- package/dist/components/Icon/Icon.js.map +1 -1
- package/dist/components/Input/Input.cjs +173 -3
- package/dist/components/Input/Input.cjs.map +1 -1
- package/dist/components/Input/Input.d.ts +20 -15
- package/dist/components/Input/Input.definitions.d.ts +5 -2
- package/dist/components/Input/Input.helpers.d.ts +14 -0
- package/dist/components/Input/Input.js +172 -2
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Input/Input.sx.d.ts +8 -0
- package/dist/components/Input/Input.types.d.ts +1 -0
- package/dist/components/Input/index.d.ts +2 -1
- package/dist/components/Input.d.ts +4 -0
- package/dist/components/InputGroup/InputGroup.cjs +104 -91
- package/dist/components/InputGroup/InputGroup.cjs.map +1 -1
- package/dist/components/InputGroup/InputGroup.d.ts +37 -1
- package/dist/components/InputGroup/InputGroup.definitions.d.ts +6 -0
- package/dist/components/InputGroup/InputGroup.js +106 -93
- package/dist/components/InputGroup/InputGroup.js.map +1 -1
- package/dist/components/Modal/Modal.cjs +226 -116
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.d.ts +38 -2
- package/dist/components/Modal/Modal.js +227 -117
- package/dist/components/Modal/Modal.js.map +1 -1
- package/dist/components/Modal/ModalFooter.d.ts +9 -1
- package/dist/components/Modal/index.d.ts +5 -0
- package/dist/components/PageLoader/PageLoader.cjs +61 -0
- package/dist/components/PageLoader/PageLoader.cjs.map +1 -0
- package/dist/components/PageLoader/PageLoader.d.ts +38 -0
- package/dist/components/PageLoader/PageLoader.js +61 -0
- package/dist/components/PageLoader/PageLoader.js.map +1 -0
- package/dist/components/PageLoader/index.d.ts +2 -0
- package/dist/components/PageLoader.d.ts +6 -0
- package/dist/components/ScrollTopButton/ScrollTopButton.cjs +79 -0
- package/dist/components/ScrollTopButton/ScrollTopButton.cjs.map +1 -0
- package/dist/components/ScrollTopButton/ScrollTopButton.d.ts +48 -0
- package/dist/components/ScrollTopButton/ScrollTopButton.js +79 -0
- package/dist/components/ScrollTopButton/ScrollTopButton.js.map +1 -0
- package/dist/components/ScrollTopButton/index.d.ts +4 -0
- package/dist/components/ScrollTopButton/scrollToTop.d.ts +29 -0
- package/dist/components/ScrollTopButton.d.ts +6 -0
- package/dist/components/Select/Select.cjs +446 -4
- package/dist/components/Select/Select.cjs.map +1 -1
- package/dist/components/Select/Select.d.ts +33 -13
- package/dist/components/Select/Select.definitions.d.ts +3 -0
- package/dist/components/Select/Select.helpers.d.ts +28 -0
- package/dist/components/Select/Select.js +445 -3
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/Select.sx.d.ts +7 -0
- package/dist/components/Select/Select.types.d.ts +1 -0
- package/dist/components/Select/_parts/SelectMenuItem.d.ts +20 -0
- package/dist/components/Select/_parts/SelectSearchHeader.d.ts +15 -0
- package/dist/components/Select/_parts/SelectValue.d.ts +22 -0
- package/dist/components/Select/index.d.ts +2 -1
- package/dist/components/Select.d.ts +4 -0
- package/dist/components/Stat/Stat.cjs +1 -1
- package/dist/components/Stat/Stat.js +1 -1
- package/dist/components/Stepper/Stepper.cjs +4 -1
- package/dist/components/Stepper/Stepper.cjs.map +1 -1
- package/dist/components/Stepper/Stepper.d.ts +5 -0
- package/dist/components/Stepper/Stepper.js +4 -1
- package/dist/components/Stepper/Stepper.js.map +1 -1
- package/dist/components/_shared/formField.sx.d.ts +33 -0
- package/dist/components/_shared/resolvePreset.d.ts +18 -0
- package/dist/formField.sx-CQ1mbk9M.cjs +76 -0
- package/dist/formField.sx-CQ1mbk9M.cjs.map +1 -0
- package/dist/formField.sx-DfVbMe0V.js +77 -0
- package/dist/formField.sx-DfVbMe0V.js.map +1 -0
- package/dist/hooks/Wizard/Wizard.cjs +7 -0
- package/dist/hooks/Wizard/Wizard.cjs.map +1 -0
- package/dist/hooks/Wizard/Wizard.js +7 -0
- package/dist/hooks/Wizard/Wizard.js.map +1 -0
- package/dist/hooks/Wizard/WizardContext.d.ts +67 -0
- package/dist/hooks/Wizard/index.d.ts +3 -0
- package/dist/hooks/Wizard/useWizard.d.ts +9 -0
- package/dist/hooks/Wizard.d.ts +2 -0
- package/dist/index.cjs +99 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +31 -2
- package/dist/index.js.map +1 -1
- package/dist/mui.d.ts +5 -0
- package/dist/resolvePreset-B-IB0ehH.js +15 -0
- package/dist/resolvePreset-B-IB0ehH.js.map +1 -0
- package/dist/resolvePreset-CT3kU-K2.cjs +14 -0
- package/dist/resolvePreset-CT3kU-K2.cjs.map +1 -0
- package/dist/styles.css +3 -112
- package/dist/theme/componentStyles.d.ts +32 -0
- package/dist/theme/tokens.d.ts +28 -0
- package/dist/useWizard-CWdIxZzX.cjs +94 -0
- package/dist/useWizard-CWdIxZzX.cjs.map +1 -0
- package/dist/useWizard-CWq--C3o.js +95 -0
- package/dist/useWizard-CWq--C3o.js.map +1 -0
- package/package.json +1 -1
- package/src/components/ActionMenu/ActionMenu.stories.tsx +230 -0
- package/src/components/ActionMenu/ActionMenu.tsx +174 -0
- package/src/components/ActionMenu/index.ts +2 -0
- package/src/components/AppBar/AppBar.stories.tsx +272 -0
- package/src/components/AppBar/AppBar.sx.ts +32 -0
- package/src/components/AppBar/AppBar.tsx +123 -0
- package/src/components/AppBar/AppBarBrand.tsx +120 -0
- package/src/components/AppBar/AppBarContext.ts +25 -0
- package/src/components/AppBar/AppBarMenuToggle.tsx +90 -0
- package/src/components/AppBar/AppBarUserMenu.tsx +217 -0
- package/src/components/AppBar/index.ts +25 -0
- package/src/components/Autocomplete/Autocomplete.definitions.ts +223 -0
- package/src/components/Autocomplete/Autocomplete.helpers.ts +60 -0
- package/src/components/Autocomplete/Autocomplete.stories.tsx +363 -2
- package/src/components/Autocomplete/Autocomplete.sx.ts +30 -0
- package/src/components/Autocomplete/Autocomplete.tsx +312 -90
- package/src/components/Autocomplete/Autocomplete.types.ts +13 -0
- package/src/components/Autocomplete/_parts/AutocompleteChips.tsx +55 -0
- package/src/components/Autocomplete/_parts/AutocompleteLoader.tsx +17 -0
- package/src/components/Autocomplete/_parts/AutocompleteOption.tsx +31 -0
- package/src/components/Autocomplete/index.ts +12 -1
- package/src/components/Avatar/Avatar.definitions.ts +162 -0
- package/src/components/Avatar/Avatar.stories.tsx +205 -1
- package/src/components/Avatar/Avatar.tsx +166 -103
- package/src/components/Card/Card.stories.tsx +205 -16
- package/src/components/Card/Card.sx.ts +104 -0
- package/src/components/Card/Card.tsx +191 -35
- package/src/components/Card/index.ts +9 -1
- package/src/components/DatePicker/DatePicker.definitions.ts +24 -1
- package/src/components/DatePicker/DatePicker.helpers.ts +24 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +29 -2
- package/src/components/DatePicker/DatePicker.sx.ts +33 -0
- package/src/components/DatePicker/DatePicker.tsx +163 -139
- package/src/components/DatePicker/DatePicker.types.ts +10 -0
- package/src/components/DatePicker/index.ts +9 -1
- package/src/components/DateTimePicker/DateTimePicker.definitions.ts +24 -0
- package/src/components/DateTimePicker/DateTimePicker.helpers.ts +38 -0
- package/src/components/DateTimePicker/DateTimePicker.stories.tsx +29 -1
- package/src/components/DateTimePicker/DateTimePicker.sx.ts +30 -0
- package/src/components/DateTimePicker/DateTimePicker.tsx +200 -166
- package/src/components/DateTimePicker/DateTimePicker.types.ts +10 -0
- package/src/components/DateTimePicker/index.ts +9 -1
- package/src/components/Drawer/Drawer.stories.tsx +270 -0
- package/src/components/Drawer/Drawer.sx.ts +106 -0
- package/src/components/Drawer/Drawer.tsx +214 -0
- package/src/components/Drawer/DrawerContext.ts +26 -0
- package/src/components/Drawer/DrawerItem.tsx +110 -0
- package/src/components/Drawer/index.ts +10 -0
- package/src/components/Flyout/Flyout.stories.tsx +26 -18
- package/src/components/Icon/Icon.stories.tsx +68 -1
- package/src/components/Icon/Icon.tsx +87 -6
- package/src/components/Input/Input.definitions.ts +74 -2
- package/src/components/Input/Input.helpers.ts +49 -0
- package/src/components/Input/Input.stories.tsx +116 -4
- package/src/components/Input/Input.sx.ts +42 -0
- package/src/components/Input/Input.tsx +117 -162
- package/src/components/Input/Input.types.ts +10 -0
- package/src/components/Input/index.ts +9 -1
- package/src/components/InputGroup/InputGroup.definitions.ts +158 -0
- package/src/components/InputGroup/InputGroup.stories.tsx +159 -28
- package/src/components/InputGroup/InputGroup.tsx +159 -116
- package/src/components/Modal/Modal.stories.tsx +434 -6
- package/src/components/Modal/Modal.tsx +303 -121
- package/src/components/Modal/ModalFooter.tsx +22 -12
- package/src/components/Modal/index.ts +6 -1
- package/src/components/PageLoader/PageLoader.stories.tsx +217 -0
- package/src/components/PageLoader/PageLoader.tsx +96 -0
- package/src/components/PageLoader/index.ts +2 -0
- package/src/components/ScrollTopButton/ScrollTopButton.stories.tsx +158 -0
- package/src/components/ScrollTopButton/ScrollTopButton.tsx +135 -0
- package/src/components/ScrollTopButton/index.ts +8 -0
- package/src/components/ScrollTopButton/scrollToTop.ts +37 -0
- package/src/components/Select/Select.definitions.ts +114 -0
- package/src/components/Select/Select.helpers.ts +71 -0
- package/src/components/Select/Select.stories.tsx +126 -8
- package/src/components/Select/Select.sx.ts +14 -0
- package/src/components/Select/Select.tsx +246 -285
- package/src/components/Select/Select.types.ts +15 -0
- package/src/components/Select/_parts/SelectMenuItem.tsx +40 -0
- package/src/components/Select/_parts/SelectSearchHeader.tsx +51 -0
- package/src/components/Select/_parts/SelectValue.tsx +96 -0
- package/src/components/Select/index.ts +14 -1
- package/src/components/Stepper/Stepper.tsx +17 -1
- package/src/components/Tooltip/Tooltip.stories.tsx +15 -3
- package/src/components/_shared/formField.sx.ts +118 -0
- package/src/components/_shared/resolvePreset.ts +35 -0
- package/src/hooks/Wizard/Wizard.stories.tsx +301 -0
- package/src/hooks/Wizard/WizardContext.tsx +166 -0
- package/src/hooks/Wizard/index.ts +6 -0
- package/src/hooks/Wizard/useWizard.ts +13 -0
- package/src/index.ts +17 -1
- package/src/mui.ts +44 -0
- package/src/theme/componentStyles.ts +47 -0
- package/src/theme/tokens.ts +43 -0
- package/dist/DatePicker-BSNboVhN.js +0 -201
- package/dist/DatePicker-BSNboVhN.js.map +0 -1
- package/dist/DatePicker-BoqxWAhj.cjs +0 -200
- package/dist/DatePicker-BoqxWAhj.cjs.map +0 -1
- package/dist/Input-DFHs7cJ_.js +0 -171
- package/dist/Input-DFHs7cJ_.js.map +0 -1
- package/dist/Input-c8MwNNPg.cjs +0 -170
- package/dist/Input-c8MwNNPg.cjs.map +0 -1
- package/dist/Select-BO2N56sm.cjs +0 -411
- package/dist/Select-BO2N56sm.cjs.map +0 -1
- package/dist/Select-BcLkyHSE.js +0 -412
- package/dist/Select-BcLkyHSE.js.map +0 -1
- package/dist/index.css +0 -3
|
@@ -32,6 +32,10 @@ var __objRest = (source, exclude) => {
|
|
|
32
32
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
33
33
|
import React__default, { forwardRef, useState, useImperativeHandle } from "react";
|
|
34
34
|
import { Box, Stack, Button, Typography, useTheme, useMediaQuery, Modal as Modal$1, Paper } from "@mui/material";
|
|
35
|
+
import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
|
|
36
|
+
import WarningAmberIcon from "@mui/icons-material/WarningAmber";
|
|
37
|
+
import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
|
|
38
|
+
import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutline";
|
|
35
39
|
const ModalFooter = ({
|
|
36
40
|
// Renombrado
|
|
37
41
|
children,
|
|
@@ -54,17 +58,21 @@ const ModalFooter = ({
|
|
|
54
58
|
children: closeButtonText
|
|
55
59
|
}
|
|
56
60
|
),
|
|
57
|
-
actions.map((action, index) =>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
actions.map((action, index) => {
|
|
62
|
+
const { buttonProps } = action;
|
|
63
|
+
return /* @__PURE__ */ jsx(
|
|
64
|
+
Button,
|
|
65
|
+
__spreadProps(__spreadValues({
|
|
66
|
+
onClick: action.onClick,
|
|
67
|
+
disabled: action.disabled,
|
|
68
|
+
variant: action.variant || "contained",
|
|
69
|
+
color: action.color || "primary"
|
|
70
|
+
}, buttonProps), {
|
|
71
|
+
children: action.text
|
|
72
|
+
}),
|
|
73
|
+
index
|
|
74
|
+
);
|
|
75
|
+
})
|
|
68
76
|
] })
|
|
69
77
|
] });
|
|
70
78
|
};
|
|
@@ -85,125 +93,227 @@ const modalStyle = {
|
|
|
85
93
|
flexDirection: "column",
|
|
86
94
|
outline: "none"
|
|
87
95
|
};
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
const severityConfig = {
|
|
97
|
+
info: {
|
|
98
|
+
color: "primary",
|
|
99
|
+
icon: /* @__PURE__ */ jsx(InfoOutlinedIcon, { sx: { fontSize: 48 } }),
|
|
100
|
+
bg: "primary.light"
|
|
101
|
+
},
|
|
102
|
+
warning: {
|
|
103
|
+
color: "warning",
|
|
104
|
+
icon: /* @__PURE__ */ jsx(WarningAmberIcon, { sx: { fontSize: 48 } }),
|
|
105
|
+
bg: "warning.light"
|
|
106
|
+
},
|
|
107
|
+
error: {
|
|
108
|
+
color: "error",
|
|
109
|
+
icon: /* @__PURE__ */ jsx(ErrorOutlineIcon, { sx: { fontSize: 48 } }),
|
|
110
|
+
bg: "error.light"
|
|
111
|
+
},
|
|
112
|
+
success: {
|
|
113
|
+
color: "success",
|
|
114
|
+
icon: /* @__PURE__ */ jsx(CheckCircleOutlineIcon, { sx: { fontSize: 48 } }),
|
|
115
|
+
bg: "success.light"
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const Modal = forwardRef(
|
|
119
|
+
({
|
|
120
|
+
mode = "default",
|
|
121
|
+
open: controlledOpen,
|
|
122
|
+
onClose: controlledOnClose,
|
|
123
|
+
title,
|
|
124
|
+
children,
|
|
125
|
+
showCloseButton = true,
|
|
126
|
+
closeButtonText = "Cerrar",
|
|
127
|
+
closeButtonDisabled = false,
|
|
128
|
+
actions = [],
|
|
129
|
+
maxWidth = "sm",
|
|
130
|
+
hiddenFooter = false,
|
|
131
|
+
// Props del modo confirm
|
|
132
|
+
onConfirm,
|
|
133
|
+
confirmText = "Confirmar",
|
|
134
|
+
confirmDisabled = false,
|
|
135
|
+
severity = "info",
|
|
136
|
+
confirmMessage
|
|
137
|
+
}, ref) => {
|
|
138
|
+
const [internalOpen, setInternalOpen] = useState(false);
|
|
139
|
+
const [confirmLoading, setConfirmLoading] = useState(false);
|
|
140
|
+
const isOpen = controlledOpen !== void 0 ? controlledOpen : internalOpen;
|
|
141
|
+
useImperativeHandle(ref, () => ({
|
|
142
|
+
open: () => setInternalOpen(true),
|
|
143
|
+
close: () => {
|
|
144
|
+
setInternalOpen(false);
|
|
145
|
+
controlledOnClose == null ? void 0 : controlledOnClose();
|
|
146
|
+
}
|
|
147
|
+
}));
|
|
148
|
+
const handleCloseInternal = () => {
|
|
107
149
|
setInternalOpen(false);
|
|
108
150
|
controlledOnClose == null ? void 0 : controlledOnClose();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
case "xs":
|
|
121
|
-
return 300;
|
|
122
|
-
case "sm":
|
|
123
|
-
return 500;
|
|
124
|
-
case "md":
|
|
125
|
-
return 700;
|
|
126
|
-
case "lg":
|
|
127
|
-
return 900;
|
|
128
|
-
case "xl":
|
|
129
|
-
return 1100;
|
|
130
|
-
case false:
|
|
131
|
-
return "auto";
|
|
132
|
-
default:
|
|
133
|
-
return 500;
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
const renderChildren = () => {
|
|
137
|
-
let header = null;
|
|
138
|
-
let body = null;
|
|
139
|
-
let footer = null;
|
|
140
|
-
React__default.Children.forEach(children, (child) => {
|
|
141
|
-
if (React__default.isValidElement(child)) {
|
|
142
|
-
if (child.type === ModalHeader) {
|
|
143
|
-
header = child;
|
|
144
|
-
} else if (child.type === ModalBody) {
|
|
145
|
-
body = child;
|
|
146
|
-
} else if (child.type === ModalFooter) {
|
|
147
|
-
const footerChild = child;
|
|
148
|
-
const _a = footerChild.props, {
|
|
149
|
-
showCloseButton: childShowCloseButton,
|
|
150
|
-
closeButtonText: childCloseButtonText,
|
|
151
|
-
closeButtonDisabled: childCloseButtonDisabled,
|
|
152
|
-
onClose: childOnClose,
|
|
153
|
-
actions: childActions
|
|
154
|
-
} = _a, restOfFooterProps = __objRest(_a, [
|
|
155
|
-
"showCloseButton",
|
|
156
|
-
"closeButtonText",
|
|
157
|
-
"closeButtonDisabled",
|
|
158
|
-
"onClose",
|
|
159
|
-
"actions"
|
|
160
|
-
]);
|
|
161
|
-
footer = React__default.cloneElement(footerChild, __spreadValues({
|
|
162
|
-
showCloseButton,
|
|
163
|
-
closeButtonText,
|
|
164
|
-
closeButtonDisabled,
|
|
165
|
-
onClose: handleCloseInternal,
|
|
166
|
-
// Usa la función de cierre interna
|
|
167
|
-
actions
|
|
168
|
-
}, restOfFooterProps));
|
|
151
|
+
};
|
|
152
|
+
const handleConfirm = async () => {
|
|
153
|
+
if (!onConfirm) {
|
|
154
|
+
handleCloseInternal();
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
const result = onConfirm();
|
|
159
|
+
if (result instanceof Promise) {
|
|
160
|
+
setConfirmLoading(true);
|
|
161
|
+
await result;
|
|
169
162
|
}
|
|
163
|
+
} finally {
|
|
164
|
+
setConfirmLoading(false);
|
|
165
|
+
handleCloseInternal();
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const theme = useTheme();
|
|
169
|
+
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
|
170
|
+
const getWidth = () => {
|
|
171
|
+
if (isMobile) return "95%";
|
|
172
|
+
switch (maxWidth) {
|
|
173
|
+
case "xs":
|
|
174
|
+
return 300;
|
|
175
|
+
case "sm":
|
|
176
|
+
return 500;
|
|
177
|
+
case "md":
|
|
178
|
+
return 700;
|
|
179
|
+
case "lg":
|
|
180
|
+
return 900;
|
|
181
|
+
case "xl":
|
|
182
|
+
return 1100;
|
|
183
|
+
case false:
|
|
184
|
+
return "auto";
|
|
185
|
+
default:
|
|
186
|
+
return 500;
|
|
170
187
|
}
|
|
171
|
-
}
|
|
172
|
-
if (
|
|
173
|
-
|
|
174
|
-
|
|
188
|
+
};
|
|
189
|
+
if (mode === "confirm") {
|
|
190
|
+
const config = severityConfig[severity];
|
|
191
|
+
const message = confirmMessage != null ? confirmMessage : children;
|
|
192
|
+
return /* @__PURE__ */ jsx(
|
|
193
|
+
Modal$1,
|
|
175
194
|
{
|
|
176
|
-
|
|
177
|
-
closeButtonText,
|
|
178
|
-
closeButtonDisabled,
|
|
195
|
+
open: isOpen,
|
|
179
196
|
onClose: handleCloseInternal,
|
|
180
|
-
|
|
197
|
+
"aria-labelledby": "modal-title",
|
|
198
|
+
closeAfterTransition: true,
|
|
199
|
+
children: /* @__PURE__ */ jsxs(Paper, { sx: __spreadProps(__spreadValues({}, modalStyle), { width: getWidth() }), children: [
|
|
200
|
+
/* @__PURE__ */ jsxs(Stack, { spacing: 2.5, sx: { p: 3, alignItems: "center", textAlign: "center" }, children: [
|
|
201
|
+
/* @__PURE__ */ jsx(
|
|
202
|
+
Box,
|
|
203
|
+
{
|
|
204
|
+
sx: {
|
|
205
|
+
width: 72,
|
|
206
|
+
height: 72,
|
|
207
|
+
borderRadius: "50%",
|
|
208
|
+
backgroundColor: (t) => t.palette[severity === "info" ? "primary" : severity].light,
|
|
209
|
+
color: (t) => t.palette[severity === "info" ? "primary" : severity].dark,
|
|
210
|
+
display: "flex",
|
|
211
|
+
alignItems: "center",
|
|
212
|
+
justifyContent: "center",
|
|
213
|
+
opacity: 0.9
|
|
214
|
+
},
|
|
215
|
+
children: config.icon
|
|
216
|
+
}
|
|
217
|
+
),
|
|
218
|
+
title && /* @__PURE__ */ jsx(Typography, { variant: "h6", component: "h2", sx: { fontWeight: 700 }, children: title }),
|
|
219
|
+
message && /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: message })
|
|
220
|
+
] }),
|
|
221
|
+
/* @__PURE__ */ jsx(
|
|
222
|
+
ModalFooter,
|
|
223
|
+
{
|
|
224
|
+
showCloseButton,
|
|
225
|
+
closeButtonText,
|
|
226
|
+
closeButtonDisabled: closeButtonDisabled || confirmLoading,
|
|
227
|
+
onClose: handleCloseInternal,
|
|
228
|
+
actions: [
|
|
229
|
+
{
|
|
230
|
+
text: confirmText,
|
|
231
|
+
onClick: handleConfirm,
|
|
232
|
+
disabled: confirmDisabled || confirmLoading,
|
|
233
|
+
variant: "contained",
|
|
234
|
+
color: config.color
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
] })
|
|
181
240
|
}
|
|
182
241
|
);
|
|
183
242
|
}
|
|
184
|
-
|
|
185
|
-
header
|
|
186
|
-
body
|
|
187
|
-
footer
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
243
|
+
const renderChildren = () => {
|
|
244
|
+
let header = null;
|
|
245
|
+
let body = null;
|
|
246
|
+
let footer = null;
|
|
247
|
+
React__default.Children.forEach(children, (child) => {
|
|
248
|
+
if (React__default.isValidElement(child)) {
|
|
249
|
+
if (child.type === ModalHeader) {
|
|
250
|
+
header = child;
|
|
251
|
+
} else if (child.type === ModalBody) {
|
|
252
|
+
body = child;
|
|
253
|
+
} else if (child.type === ModalFooter) {
|
|
254
|
+
const footerChild = child;
|
|
255
|
+
const _a = footerChild.props, {
|
|
256
|
+
showCloseButton: childShowCloseButton,
|
|
257
|
+
closeButtonText: childCloseButtonText,
|
|
258
|
+
closeButtonDisabled: childCloseButtonDisabled,
|
|
259
|
+
onClose: childOnClose,
|
|
260
|
+
actions: childActions
|
|
261
|
+
} = _a, restOfFooterProps = __objRest(_a, [
|
|
262
|
+
"showCloseButton",
|
|
263
|
+
"closeButtonText",
|
|
264
|
+
"closeButtonDisabled",
|
|
265
|
+
"onClose",
|
|
266
|
+
"actions"
|
|
267
|
+
]);
|
|
268
|
+
footer = React__default.cloneElement(footerChild, __spreadValues({
|
|
269
|
+
showCloseButton,
|
|
270
|
+
closeButtonText,
|
|
271
|
+
closeButtonDisabled,
|
|
272
|
+
onClose: handleCloseInternal,
|
|
273
|
+
actions
|
|
274
|
+
}, restOfFooterProps));
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
if (!footer && !hiddenFooter) {
|
|
279
|
+
footer = /* @__PURE__ */ jsx(
|
|
280
|
+
ModalFooter,
|
|
281
|
+
{
|
|
282
|
+
showCloseButton,
|
|
283
|
+
closeButtonText,
|
|
284
|
+
closeButtonDisabled,
|
|
285
|
+
onClose: handleCloseInternal,
|
|
286
|
+
actions
|
|
287
|
+
}
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
291
|
+
header || title && /* @__PURE__ */ jsx(ModalHeader, { children: title }),
|
|
292
|
+
body,
|
|
293
|
+
footer
|
|
294
|
+
] });
|
|
295
|
+
};
|
|
296
|
+
return /* @__PURE__ */ jsx(
|
|
297
|
+
Modal$1,
|
|
298
|
+
{
|
|
299
|
+
open: isOpen,
|
|
300
|
+
onClose: handleCloseInternal,
|
|
301
|
+
"aria-labelledby": "modal-title",
|
|
302
|
+
"aria-describedby": "modal-description",
|
|
303
|
+
closeAfterTransition: true,
|
|
304
|
+
children: /* @__PURE__ */ jsx(Paper, { sx: __spreadProps(__spreadValues({}, modalStyle), { width: getWidth() }), children: renderChildren() })
|
|
305
|
+
}
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
);
|
|
202
309
|
const ModalWithStatics = Modal;
|
|
203
310
|
ModalWithStatics.Header = ModalHeader;
|
|
204
311
|
ModalWithStatics.Body = ModalBody;
|
|
205
312
|
ModalWithStatics.Footer = ModalFooter;
|
|
206
313
|
export {
|
|
207
|
-
ModalWithStatics as Modal
|
|
314
|
+
ModalWithStatics as Modal,
|
|
315
|
+
ModalBody,
|
|
316
|
+
ModalFooter,
|
|
317
|
+
ModalHeader
|
|
208
318
|
};
|
|
209
319
|
//# sourceMappingURL=Modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sources":["../../../src/components/Modal/ModalFooter.tsx","../../../src/components/Modal/ModalHeader.tsx","../../../src/components/Modal/ModalBody.tsx","../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import React from 'react';\nimport { Box, Button, Stack } from '@mui/material';\nimport { ButtonProps } from '@mui/material/Button';\n\n// Interfaz para acciones personalizadas (se mantiene aquí)\nexport interface ModalAction {\n text: string;\n onClick: () => void;\n disabled?: boolean;\n variant?: ButtonProps['variant'];\n color?: ButtonProps['color'];\n}\n\nexport interface ModalFooterProps { // Renombrado\n children?: React.ReactNode;\n showCloseButton?: boolean;\n closeButtonText?: string;\n closeButtonDisabled?: boolean;\n onClose: () => void;\n actions?: ModalAction[];\n}\n\nexport const ModalFooter: React.FC<ModalFooterProps> = ({ // Renombrado\n children,\n showCloseButton = true,\n closeButtonText = \"Cerrar\",\n closeButtonDisabled = false,\n onClose,\n actions = [],\n}) => {\n return (\n <Box sx={{ padding: 2, borderTop: '1px solid #e0e0e0', display: 'flex', justifyContent: 'flex-end', gap: 1 }}>\n {children}\n <Stack direction=\"row\" spacing={1}>\n {showCloseButton && (\n <Button\n onClick={onClose}\n disabled={closeButtonDisabled}\n variant=\"outlined\"\n color=\"secondary\"\n >\n {closeButtonText}\n </Button>\n )}\n {actions.map((action, index) => (\n <Button\n key={index}\n onClick={action.onClick}\n disabled={action.disabled}\n variant={action.variant || 'contained'}\n color={action.color || 'primary'}\n >\n {action.text}\n </Button>\n ))}\n </Stack>\n </Box>\n );\n};\n\nexport default ModalFooter;","import React from 'react';\nimport { Box, Typography } from '@mui/material';\n\ninterface ModalHeaderProps { // Renombrado\n children: React.ReactNode;\n}\n\nexport const ModalHeader: React.FC<ModalHeaderProps> = ({ children }) => { // Renombrado\n return (\n <Box sx={{ padding: 2, borderBottom: '1px solid #e0e0e0', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>\n <Typography variant=\"h6\" component=\"h2\">\n {children}\n </Typography>\n </Box>\n );\n};\n\nexport default ModalHeader;","import React from 'react';\nimport { Box } from '@mui/material';\n\ninterface ModalBodyProps { // Renombrado\n children: React.ReactNode;\n}\n\nexport const ModalBody: React.FC<ModalBodyProps> = ({ children }) => { // Renombrado\n return (\n <Box sx={{ padding: 2, overflowY: 'auto', flexGrow: 1 }}>\n {children}\n </Box>\n );\n};\n\nexport default ModalBody;","import React, { useState, useImperativeHandle, forwardRef } from 'react'; // 👈 Importa useImperativeHandle y forwardRef\nimport { Modal as MuiModal, Box, Paper, useTheme, useMediaQuery } from '@mui/material';\n\nimport { DialogProps } from '@mui/material/Dialog';\nimport { ModalAction, ModalFooter, ModalFooterProps } from './ModalFooter';\nimport { ModalHeader } from './ModalHeader';\nimport { ModalBody } from './ModalBody';\n\n// Define la interfaz para los métodos que el padre puede llamar a través de la ref\nexport interface ModalRef {\n open: () => void;\n close: () => void;\n}\n\ninterface ModalProps {\n // La prop 'open' ahora es opcional si se usa con ref, pero aún puede ser controlada externamente\n open?: boolean;\n onClose?: () => void; // 'onClose' ahora es opcional ya que el modal puede cerrarse internamente\n title?: string;\n children: React.ReactNode;\n showCloseButton?: boolean;\n closeButtonText?: string;\n closeButtonDisabled?: boolean;\n actions?: ModalAction[];\n maxWidth?: DialogProps['maxWidth'];\n hiddenFooter?: boolean\n}\n\nconst modalStyle = {\n position: 'absolute' as 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n width: '90%',\n maxHeight: '90vh',\n display: 'flex',\n flexDirection: 'column',\n outline: 'none',\n};\n\n// Envuelve el componente en forwardRef\nexport const Modal = forwardRef<ModalRef, ModalProps>(({\n open: controlledOpen, // Renombra la prop 'open' si se pasa externamente\n onClose: controlledOnClose, // Renombra la prop 'onClose' si se pasa externamente\n title,\n children,\n showCloseButton = true,\n closeButtonText = \"Cerrar\",\n closeButtonDisabled = false,\n actions = [],\n maxWidth = 'sm',\n hiddenFooter = false,\n}, ref) => { // Recibe la ref\n // Estado interno para gestionar la visibilidad si no es controlado externamente\n const [internalOpen, setInternalOpen] = useState(false);\n\n // Determina si el modal está abierto, priorizando la prop externa\n const isOpen = controlledOpen !== undefined ? controlledOpen : internalOpen;\n\n // Expone métodos 'open' y 'close' a través de la ref\n useImperativeHandle(ref, () => ({\n open: () => setInternalOpen(true),\n close: () => {\n setInternalOpen(false);\n controlledOnClose?.(); // Llama al onClose externo si existe\n },\n }));\n\n const handleCloseInternal = () => {\n setInternalOpen(false);\n controlledOnClose?.(); // Llama al onClose externo si existe\n };\n\n const theme = useTheme();\n const isMobile = useMediaQuery(theme.breakpoints.down('sm'));\n\n const getWidth = () => {\n if (isMobile) return '95%';\n switch (maxWidth) {\n case 'xs': return 300;\n case 'sm': return 500;\n case 'md': return 700;\n case 'lg': return 900;\n case 'xl': return 1100;\n case false: return 'auto';\n default: return 500;\n }\n };\n\n const renderChildren = () => {\n let header: React.ReactNode | null = null;\n let body: React.ReactNode | null = null;\n let footer: React.ReactNode | null = null;\n\n React.Children.forEach(children, (child) => {\n if (React.isValidElement(child)) {\n if (child.type === ModalHeader) {\n header = child;\n } else if (child.type === ModalBody) {\n body = child;\n } else if (child.type === ModalFooter) {\n const footerChild = child as React.ReactElement<ModalFooterProps>;\n const {\n showCloseButton: childShowCloseButton,\n closeButtonText: childCloseButtonText,\n closeButtonDisabled: childCloseButtonDisabled,\n onClose: childOnClose,\n actions: childActions,\n ...restOfFooterProps\n } = footerChild.props;\n\n footer = React.cloneElement(footerChild, {\n showCloseButton,\n closeButtonText,\n closeButtonDisabled,\n onClose: handleCloseInternal, // Usa la función de cierre interna\n actions,\n ...restOfFooterProps,\n });\n }\n }\n });\n\n if (!footer && !hiddenFooter) {\n footer = (\n <ModalFooter\n showCloseButton={showCloseButton}\n closeButtonText={closeButtonText}\n closeButtonDisabled={closeButtonDisabled}\n onClose={handleCloseInternal} // Usa la función de cierre interna\n actions={actions}\n />\n );\n }\n\n return (\n <>\n {header || (title && <ModalHeader>{title}</ModalHeader>)}\n {body}\n {footer}\n </>\n );\n };\n\n return (\n <MuiModal\n open={isOpen} // Usa el estado de visibilidad determinado\n onClose={handleCloseInternal} // Usa la función de cierre interna\n aria-labelledby=\"modal-title\"\n aria-describedby=\"modal-description\"\n closeAfterTransition\n >\n <Paper sx={{ ...modalStyle, width: getWidth() }}>\n {renderChildren()}\n </Paper>\n </MuiModal>\n );\n});\n\n// Define los sub-componentes como propiedades estáticas con tipos explícitos\ntype ModalComponent = React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<ModalRef>> & {\n Header: typeof ModalHeader;\n Body: typeof ModalBody;\n Footer: typeof ModalFooter;\n};\n\nconst ModalWithStatics = Modal as ModalComponent;\n\nModalWithStatics.Header = ModalHeader;\nModalWithStatics.Body = ModalBody;\nModalWithStatics.Footer = ModalFooter;\n\nexport default ModalWithStatics;"],"names":["React","MuiModal"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBO,MAAM,cAA0C,CAAC;AAAA;AAAA,EACtD;AAAA,EACA,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,sBAAsB;AAAA,EACtB;AAAA,EACA,UAAU,CAAA;AACZ,MAAM;AACJ,SACE,qBAAC,KAAA,EAAI,IAAI,EAAE,SAAS,GAAG,WAAW,qBAAqB,SAAS,QAAQ,gBAAgB,YAAY,KAAK,KACtG,UAAA;AAAA,IAAA;AAAA,IACD,qBAAC,OAAA,EAAM,WAAU,OAAM,SAAS,GAC7B,UAAA;AAAA,MAAA,mBACC;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,SAAS;AAAA,UACT,UAAU;AAAA,UACV,SAAQ;AAAA,UACR,OAAM;AAAA,UAEL,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MAGJ,QAAQ,IAAI,CAAC,QAAQ,UACpB;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,SAAS,OAAO;AAAA,UAChB,UAAU,OAAO;AAAA,UACjB,SAAS,OAAO,WAAW;AAAA,UAC3B,OAAO,OAAO,SAAS;AAAA,UAEtB,UAAA,OAAO;AAAA,QAAA;AAAA,QANH;AAAA,MAAA,CAQR;AAAA,IAAA,EAAA,CACH;AAAA,EAAA,GACF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AA,IAACC;AAAAA,IAAA;AAAA,MACC,MAAM;AAAA,MACN,SAAS;AAAA,MACT,mBAAgB;AAAA,MAChB,oBAAiB;AAAA,MACjB,sBAAoB;AAAA,MAEpB,UAAA,oBAAC,OAAA,EAAM,IAAI,iCAAK,aAAL,EAAiB,OAAO,SAAA,EAAS,IACzC,UAAA,eAAA,EAAe,CAClB;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC;AASD,MAAM,mBAAmB;AAEzB,iBAAiB,SAAS;AAC1B,iBAAiB,OAAO;AACxB,iBAAiB,SAAS;"}
|
|
1
|
+
{"version":3,"file":"Modal.js","sources":["../../../src/components/Modal/ModalFooter.tsx","../../../src/components/Modal/ModalHeader.tsx","../../../src/components/Modal/ModalBody.tsx","../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import React from 'react';\nimport { Box, Button, Stack } from '@mui/material';\nimport { ButtonProps } from '@mui/material/Button';\n\n// Interfaz para acciones personalizadas (se mantiene aquí)\nexport interface ModalAction {\n text: string;\n onClick?: () => void;\n disabled?: boolean;\n variant?: ButtonProps['variant'];\n color?: ButtonProps['color'];\n /**\n * Props adicionales que se forwardean al `<Button>` interno. Útil para casos\n * avanzados como conectar el botón con un `<form id=\"...\">` externo usando\n * `buttonProps={{ type: 'submit', form: 'my-form-id' }}`.\n */\n buttonProps?: Partial<ButtonProps> & { form?: string };\n}\n\nexport interface ModalFooterProps { // Renombrado\n children?: React.ReactNode;\n showCloseButton?: boolean;\n closeButtonText?: string;\n closeButtonDisabled?: boolean;\n onClose: () => void;\n actions?: ModalAction[];\n}\n\nexport const ModalFooter: React.FC<ModalFooterProps> = ({ // Renombrado\n children,\n showCloseButton = true,\n closeButtonText = \"Cerrar\",\n closeButtonDisabled = false,\n onClose,\n actions = [],\n}) => {\n return (\n <Box sx={{ padding: 2, borderTop: '1px solid #e0e0e0', display: 'flex', justifyContent: 'flex-end', gap: 1 }}>\n {children}\n <Stack direction=\"row\" spacing={1}>\n {showCloseButton && (\n <Button\n onClick={onClose}\n disabled={closeButtonDisabled}\n variant=\"outlined\"\n color=\"secondary\"\n >\n {closeButtonText}\n </Button>\n )}\n {actions.map((action, index) => {\n const { buttonProps } = action;\n return (\n <Button\n key={index}\n onClick={action.onClick}\n disabled={action.disabled}\n variant={action.variant || 'contained'}\n color={action.color || 'primary'}\n {...(buttonProps as any)}\n >\n {action.text}\n </Button>\n );\n })}\n </Stack>\n </Box>\n );\n};\n\nexport default ModalFooter;","import React from 'react';\nimport { Box, Typography } from '@mui/material';\n\ninterface ModalHeaderProps { // Renombrado\n children: React.ReactNode;\n}\n\nexport const ModalHeader: React.FC<ModalHeaderProps> = ({ children }) => { // Renombrado\n return (\n <Box sx={{ padding: 2, borderBottom: '1px solid #e0e0e0', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>\n <Typography variant=\"h6\" component=\"h2\">\n {children}\n </Typography>\n </Box>\n );\n};\n\nexport default ModalHeader;","import React from 'react';\nimport { Box } from '@mui/material';\n\ninterface ModalBodyProps { // Renombrado\n children: React.ReactNode;\n}\n\nexport const ModalBody: React.FC<ModalBodyProps> = ({ children }) => { // Renombrado\n return (\n <Box sx={{ padding: 2, overflowY: 'auto', flexGrow: 1 }}>\n {children}\n </Box>\n );\n};\n\nexport default ModalBody;","import React, {\n useState,\n useImperativeHandle,\n forwardRef,\n type ReactNode,\n} from 'react';\nimport {\n Modal as MuiModal,\n Paper,\n useTheme,\n useMediaQuery,\n Box,\n Stack,\n Typography,\n} from '@mui/material';\nimport InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';\nimport WarningAmberIcon from '@mui/icons-material/WarningAmber';\nimport ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';\nimport CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline';\n\nimport type { DialogProps } from '@mui/material/Dialog';\nimport { ModalAction, ModalFooter, ModalFooterProps } from './ModalFooter';\nimport { ModalHeader } from './ModalHeader';\nimport { ModalBody } from './ModalBody';\n\n// Define la interfaz para los métodos que el padre puede llamar a través de la ref\nexport interface ModalRef {\n open: () => void;\n close: () => void;\n}\n\nexport type ModalMode = 'default' | 'confirm';\nexport type ModalSeverity = 'info' | 'warning' | 'error' | 'success';\n\ninterface ModalProps {\n /**\n * Modo del modal.\n * - `default` (default): modal genérico con slots `Header`/`Body`/`Footer` y\n * `actions` custom.\n * - `confirm`: reemplaza al `ConfirmModal` legacy. Renderiza un layout\n * focalizado con icono por severidad, mensaje y botones \"Cancelar\" /\n * \"Confirmar\".\n */\n mode?: ModalMode;\n\n // ── Props comunes ────────────────────────────────────────────────────\n /** Controlado externamente. Omitir si se usa vía ref. */\n open?: boolean;\n /** Callback al cerrar. También se dispara al confirmar/cancelar. */\n onClose?: () => void;\n title?: string;\n children?: ReactNode;\n showCloseButton?: boolean;\n closeButtonText?: string;\n closeButtonDisabled?: boolean;\n actions?: ModalAction[];\n maxWidth?: DialogProps['maxWidth'];\n hiddenFooter?: boolean;\n\n // ── Props del modo confirm ───────────────────────────────────────────\n /**\n * Callback de confirmación. Soporta promesa — si devuelve `Promise`, el\n * botón muestra estado `disabled` mientras resuelve.\n */\n onConfirm?: () => void | Promise<void>;\n /** Texto del botón primario en modo `confirm`. Default: \"Confirmar\". */\n confirmText?: string;\n /** Deshabilita el botón de confirmar. */\n confirmDisabled?: boolean;\n /**\n * Severidad visual en modo `confirm`. Controla el icono y el color del\n * botón de confirmación.\n * - `info` (default): primary\n * - `warning`: warning (amarillo)\n * - `error`: error (rojo) — típico para \"Eliminar\"\n * - `success`: success (verde) — típico para \"Aprobar\"\n */\n severity?: ModalSeverity;\n /**\n * Mensaje del confirm. Puede ser string o cualquier ReactNode. Si se omite,\n * se usa `children`.\n */\n confirmMessage?: ReactNode;\n}\n\nconst modalStyle = {\n position: 'absolute' as const,\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n width: '90%',\n maxHeight: '90vh',\n display: 'flex',\n flexDirection: 'column' as const,\n outline: 'none',\n};\n\nconst severityConfig: Record<\n ModalSeverity,\n { color: ModalAction['color']; icon: ReactNode; bg: string }\n> = {\n info: {\n color: 'primary',\n icon: <InfoOutlinedIcon sx={{ fontSize: 48 }} />,\n bg: 'primary.light',\n },\n warning: {\n color: 'warning',\n icon: <WarningAmberIcon sx={{ fontSize: 48 }} />,\n bg: 'warning.light',\n },\n error: {\n color: 'error',\n icon: <ErrorOutlineIcon sx={{ fontSize: 48 }} />,\n bg: 'error.light',\n },\n success: {\n color: 'success',\n icon: <CheckCircleOutlineIcon sx={{ fontSize: 48 }} />,\n bg: 'success.light',\n },\n};\n\nexport const Modal = forwardRef<ModalRef, ModalProps>(\n (\n {\n mode = 'default',\n open: controlledOpen,\n onClose: controlledOnClose,\n title,\n children,\n showCloseButton = true,\n closeButtonText = 'Cerrar',\n closeButtonDisabled = false,\n actions = [],\n maxWidth = 'sm',\n hiddenFooter = false,\n\n // Props del modo confirm\n onConfirm,\n confirmText = 'Confirmar',\n confirmDisabled = false,\n severity = 'info',\n confirmMessage,\n },\n ref,\n ) => {\n const [internalOpen, setInternalOpen] = useState(false);\n const [confirmLoading, setConfirmLoading] = useState(false);\n\n const isOpen = controlledOpen !== undefined ? controlledOpen : internalOpen;\n\n useImperativeHandle(ref, () => ({\n open: () => setInternalOpen(true),\n close: () => {\n setInternalOpen(false);\n controlledOnClose?.();\n },\n }));\n\n const handleCloseInternal = () => {\n setInternalOpen(false);\n controlledOnClose?.();\n };\n\n const handleConfirm = async () => {\n if (!onConfirm) {\n handleCloseInternal();\n return;\n }\n try {\n const result = onConfirm();\n if (result instanceof Promise) {\n setConfirmLoading(true);\n await result;\n }\n } finally {\n setConfirmLoading(false);\n handleCloseInternal();\n }\n };\n\n const theme = useTheme();\n const isMobile = useMediaQuery(theme.breakpoints.down('sm'));\n\n const getWidth = () => {\n if (isMobile) return '95%';\n switch (maxWidth) {\n case 'xs':\n return 300;\n case 'sm':\n return 500;\n case 'md':\n return 700;\n case 'lg':\n return 900;\n case 'xl':\n return 1100;\n case false:\n return 'auto';\n default:\n return 500;\n }\n };\n\n // ── Render modo CONFIRM ─────────────────────────────────────────────\n if (mode === 'confirm') {\n const config = severityConfig[severity];\n const message = confirmMessage ?? children;\n\n return (\n <MuiModal\n open={isOpen}\n onClose={handleCloseInternal}\n aria-labelledby=\"modal-title\"\n closeAfterTransition\n >\n <Paper sx={{ ...modalStyle, width: getWidth() }}>\n <Stack spacing={2.5} sx={{ p: 3, alignItems: 'center', textAlign: 'center' }}>\n <Box\n sx={{\n width: 72,\n height: 72,\n borderRadius: '50%',\n backgroundColor: (t) =>\n t.palette[severity === 'info' ? 'primary' : severity].light,\n color: (t) =>\n t.palette[severity === 'info' ? 'primary' : severity].dark,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n opacity: 0.9,\n }}\n >\n {config.icon}\n </Box>\n {title && (\n <Typography variant=\"h6\" component=\"h2\" sx={{ fontWeight: 700 }}>\n {title}\n </Typography>\n )}\n {message && (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {message}\n </Typography>\n )}\n </Stack>\n <ModalFooter\n showCloseButton={showCloseButton}\n closeButtonText={closeButtonText}\n closeButtonDisabled={closeButtonDisabled || confirmLoading}\n onClose={handleCloseInternal}\n actions={[\n {\n text: confirmText,\n onClick: handleConfirm,\n disabled: confirmDisabled || confirmLoading,\n variant: 'contained',\n color: config.color,\n },\n ]}\n />\n </Paper>\n </MuiModal>\n );\n }\n\n // ── Render modo DEFAULT (legacy) ────────────────────────────────────\n const renderChildren = () => {\n let header: ReactNode | null = null;\n let body: ReactNode | null = null;\n let footer: ReactNode | null = null;\n\n React.Children.forEach(children, (child) => {\n if (React.isValidElement(child)) {\n if (child.type === ModalHeader) {\n header = child;\n } else if (child.type === ModalBody) {\n body = child;\n } else if (child.type === ModalFooter) {\n const footerChild = child as React.ReactElement<ModalFooterProps>;\n const {\n showCloseButton: childShowCloseButton,\n closeButtonText: childCloseButtonText,\n closeButtonDisabled: childCloseButtonDisabled,\n onClose: childOnClose,\n actions: childActions,\n ...restOfFooterProps\n } = footerChild.props;\n\n footer = React.cloneElement(footerChild, {\n showCloseButton,\n closeButtonText,\n closeButtonDisabled,\n onClose: handleCloseInternal,\n actions,\n ...restOfFooterProps,\n });\n }\n }\n });\n\n if (!footer && !hiddenFooter) {\n footer = (\n <ModalFooter\n showCloseButton={showCloseButton}\n closeButtonText={closeButtonText}\n closeButtonDisabled={closeButtonDisabled}\n onClose={handleCloseInternal}\n actions={actions}\n />\n );\n }\n\n return (\n <>\n {header || (title && <ModalHeader>{title}</ModalHeader>)}\n {body}\n {footer}\n </>\n );\n };\n\n return (\n <MuiModal\n open={isOpen}\n onClose={handleCloseInternal}\n aria-labelledby=\"modal-title\"\n aria-describedby=\"modal-description\"\n closeAfterTransition\n >\n <Paper sx={{ ...modalStyle, width: getWidth() }}>\n {renderChildren()}\n </Paper>\n </MuiModal>\n );\n },\n);\n\n// Define los sub-componentes como propiedades estáticas con tipos explícitos\ntype ModalComponent = React.ForwardRefExoticComponent<\n ModalProps & React.RefAttributes<ModalRef>\n> & {\n Header: typeof ModalHeader;\n Body: typeof ModalBody;\n Footer: typeof ModalFooter;\n};\n\nconst ModalWithStatics = Modal as ModalComponent;\n\nModalWithStatics.Header = ModalHeader;\nModalWithStatics.Body = ModalBody;\nModalWithStatics.Footer = ModalFooter;\n\nexport default ModalWithStatics;\n"],"names":["MuiModal","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAM,cAA0C,CAAC;AAAA;AAAA,EACtD;AAAA,EACA,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,sBAAsB;AAAA,EACtB;AAAA,EACA,UAAU,CAAA;AACZ,MAAM;AACJ,SACE,qBAAC,KAAA,EAAI,IAAI,EAAE,SAAS,GAAG,WAAW,qBAAqB,SAAS,QAAQ,gBAAgB,YAAY,KAAK,KACtG,UAAA;AAAA,IAAA;AAAA,IACD,qBAAC,OAAA,EAAM,WAAU,OAAM,SAAS,GAC7B,UAAA;AAA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AC,UAAU,CAAC,cAAc;AAC5B,iBACE;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA,SAAS;AAAA,YACT;AAAA,UAAA;AAAA,QAAA;AAAA,MAGN;AAEA,aACE,qBAAA,UAAA,EACG,UAAA;AAAA,QAAA,UAAW,SAAS,oBAAC,aAAA,EAAa,UAAA,OAAM;AAAA,QACxC;AAAA,QACA;AAAA,MAAA,GACH;AAAA,IAEJ;AAEA,WACE;AAAA,MAACD;AAAAA,MAAA;AAAA,QACC,MAAM;AAAA,QACN,SAAS;AAAA,QACT,mBAAgB;AAAA,QAChB,oBAAiB;AAAA,QACjB,sBAAoB;AAAA,QAEpB,UAAA,oBAAC,OAAA,EAAM,IAAI,iCAAK,aAAL,EAAiB,OAAO,SAAA,EAAS,IACzC,UAAA,eAAA,EAAe,CAClB;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAWA,MAAM,mBAAmB;AAEzB,iBAAiB,SAAS;AAC1B,iBAAiB,OAAO;AACxB,iBAAiB,SAAS;"}
|
|
@@ -2,10 +2,18 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { ButtonProps } from '@mui/material/Button';
|
|
3
3
|
export interface ModalAction {
|
|
4
4
|
text: string;
|
|
5
|
-
onClick
|
|
5
|
+
onClick?: () => void;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
variant?: ButtonProps['variant'];
|
|
8
8
|
color?: ButtonProps['color'];
|
|
9
|
+
/**
|
|
10
|
+
* Props adicionales que se forwardean al `<Button>` interno. Útil para casos
|
|
11
|
+
* avanzados como conectar el botón con un `<form id="...">` externo usando
|
|
12
|
+
* `buttonProps={{ type: 'submit', form: 'my-form-id' }}`.
|
|
13
|
+
*/
|
|
14
|
+
buttonProps?: Partial<ButtonProps> & {
|
|
15
|
+
form?: string;
|
|
16
|
+
};
|
|
9
17
|
}
|
|
10
18
|
export interface ModalFooterProps {
|
|
11
19
|
children?: React.ReactNode;
|
|
@@ -1 +1,6 @@
|
|
|
1
1
|
export { default as Modal } from './Modal';
|
|
2
|
+
export type { ModalRef, ModalMode, ModalSeverity } from './Modal';
|
|
3
|
+
export { ModalHeader } from './ModalHeader';
|
|
4
|
+
export { ModalBody } from './ModalBody';
|
|
5
|
+
export { ModalFooter } from './ModalFooter';
|
|
6
|
+
export type { ModalAction, ModalFooterProps } from './ModalFooter';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __spreadValues = (a, b) => {
|
|
8
|
+
for (var prop in b || (b = {}))
|
|
9
|
+
if (__hasOwnProp.call(b, prop))
|
|
10
|
+
__defNormalProp(a, prop, b[prop]);
|
|
11
|
+
if (__getOwnPropSymbols)
|
|
12
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
13
|
+
if (__propIsEnum.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
}
|
|
16
|
+
return a;
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
19
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
20
|
+
const material = require("@mui/material");
|
|
21
|
+
function PageLoader({
|
|
22
|
+
fullscreen = true,
|
|
23
|
+
message,
|
|
24
|
+
logo,
|
|
25
|
+
size = 48,
|
|
26
|
+
open = true,
|
|
27
|
+
backdropColor,
|
|
28
|
+
sx,
|
|
29
|
+
className
|
|
30
|
+
}) {
|
|
31
|
+
const rootSx = [
|
|
32
|
+
(theme) => __spreadValues({
|
|
33
|
+
display: "flex",
|
|
34
|
+
flexDirection: "column",
|
|
35
|
+
alignItems: "center",
|
|
36
|
+
justifyContent: "center",
|
|
37
|
+
gap: 2
|
|
38
|
+
}, fullscreen ? {
|
|
39
|
+
position: "fixed",
|
|
40
|
+
inset: 0,
|
|
41
|
+
zIndex: theme.zIndex.modal + 10,
|
|
42
|
+
backgroundColor: backdropColor != null ? backdropColor : theme.palette.background.default
|
|
43
|
+
} : {
|
|
44
|
+
width: "100%",
|
|
45
|
+
minHeight: 160
|
|
46
|
+
}),
|
|
47
|
+
...Array.isArray(sx) ? sx : sx ? [sx] : []
|
|
48
|
+
];
|
|
49
|
+
const content = /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { className, sx: rootSx, role: "status", "aria-live": "polite", children: [
|
|
50
|
+
logo && /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { mb: 1 }, children: logo }),
|
|
51
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size, thickness: 4 }),
|
|
52
|
+
message && /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body2", color: "text.secondary", children: message })
|
|
53
|
+
] });
|
|
54
|
+
if (!fullscreen) {
|
|
55
|
+
return open ? content : null;
|
|
56
|
+
}
|
|
57
|
+
return /* @__PURE__ */ jsxRuntime.jsx(material.Fade, { in: open, timeout: { enter: 0, exit: 200 }, unmountOnExit: true, children: content });
|
|
58
|
+
}
|
|
59
|
+
exports.PageLoader = PageLoader;
|
|
60
|
+
exports.default = PageLoader;
|
|
61
|
+
//# sourceMappingURL=PageLoader.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageLoader.cjs","sources":["../../../src/components/PageLoader/PageLoader.tsx"],"sourcesContent":["import React, { type ReactNode } from 'react';\nimport { Box, CircularProgress, Typography, Fade } from '@mui/material';\nimport type { SxProps, Theme } from '@mui/material/styles';\n\nexport interface PageLoaderProps {\n /**\n * Si es true, muestra el loader ocupando toda la ventana (fixed, 100vh/vw)\n * con backdrop. Default: true.\n */\n fullscreen?: boolean;\n /** Texto bajo el spinner. */\n message?: ReactNode;\n /** Logo/imagen opcional arriba del spinner. */\n logo?: ReactNode;\n /** Tamaño del spinner en px. Default: 48. */\n size?: number;\n /**\n * Control explícito. Si es undefined, el loader se muestra apenas se monta.\n * Útil para fades.\n */\n open?: boolean;\n /** Color del backdrop (solo fullscreen). Default: usa theme.palette.background.default. */\n backdropColor?: string;\n /** sx del root. */\n sx?: SxProps<Theme>;\n className?: string;\n}\n\n/**\n * Loader full-page o inline. Reemplaza el `LayoutSplashScreen` de Metronic.\n *\n * ```tsx\n * // Splash de arranque\n * <PageLoader logo={<img src={logo} />} message=\"Cargando...\" />\n *\n * // Loader local dentro de una card\n * <PageLoader fullscreen={false} size={32} />\n * ```\n */\nexport function PageLoader({\n fullscreen = true,\n message,\n logo,\n size = 48,\n open = true,\n backdropColor,\n sx,\n className,\n}: PageLoaderProps) {\n const rootSx: SxProps<Theme> = [\n (theme) => ({\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 2,\n ...(fullscreen\n ? {\n position: 'fixed',\n inset: 0,\n zIndex: theme.zIndex.modal + 10,\n backgroundColor:\n backdropColor ?? theme.palette.background.default,\n }\n : {\n width: '100%',\n minHeight: 160,\n }),\n }),\n ...(Array.isArray(sx) ? sx : sx ? [sx] : []),\n ];\n\n const content = (\n <Box className={className} sx={rootSx} role=\"status\" aria-live=\"polite\">\n {logo && <Box sx={{ mb: 1 }}>{logo}</Box>}\n <CircularProgress size={size} thickness={4} />\n {message && (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {message}\n </Typography>\n )}\n </Box>\n );\n\n if (!fullscreen) {\n return open ? content : null;\n }\n\n return (\n <Fade in={open} timeout={{ enter: 0, exit: 200 }} unmountOnExit>\n {content}\n </Fade>\n );\n}\n\nexport default PageLoader;\n"],"names":["Box","jsx","CircularProgress","Typography","Fade"],"mappings":";;;;;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les';
|
|
3
|
+
export interface PageLoaderProps {
|
|
4
|
+
/**
|
|
5
|
+
* Si es true, muestra el loader ocupando toda la ventana (fixed, 100vh/vw)
|
|
6
|
+
* con backdrop. Default: true.
|
|
7
|
+
*/
|
|
8
|
+
fullscreen?: boolean;
|
|
9
|
+
/** Texto bajo el spinner. */
|
|
10
|
+
message?: ReactNode;
|
|
11
|
+
/** Logo/imagen opcional arriba del spinner. */
|
|
12
|
+
logo?: ReactNode;
|
|
13
|
+
/** Tamaño del spinner en px. Default: 48. */
|
|
14
|
+
size?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Control explícito. Si es undefined, el loader se muestra apenas se monta.
|
|
17
|
+
* Útil para fades.
|
|
18
|
+
*/
|
|
19
|
+
open?: boolean;
|
|
20
|
+
/** Color del backdrop (solo fullscreen). Default: usa theme.palette.background.default. */
|
|
21
|
+
backdropColor?: string;
|
|
22
|
+
/** sx del root. */
|
|
23
|
+
sx?: SxProps<Theme>;
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Loader full-page o inline. Reemplaza el `LayoutSplashScreen` de Metronic.
|
|
28
|
+
*
|
|
29
|
+
* ```tsx
|
|
30
|
+
* // Splash de arranque
|
|
31
|
+
* <PageLoader logo={<img src={logo} />} message="Cargando..." />
|
|
32
|
+
*
|
|
33
|
+
* // Loader local dentro de una card
|
|
34
|
+
* <PageLoader fullscreen={false} size={32} />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function PageLoader({ fullscreen, message, logo, size, open, backdropColor, sx, className, }: PageLoaderProps): import("react/jsx-runtime").JSX.Element | null;
|
|
38
|
+
export default PageLoader;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
18
|
+
import { Fade, Box, CircularProgress, Typography } from "@mui/material";
|
|
19
|
+
function PageLoader({
|
|
20
|
+
fullscreen = true,
|
|
21
|
+
message,
|
|
22
|
+
logo,
|
|
23
|
+
size = 48,
|
|
24
|
+
open = true,
|
|
25
|
+
backdropColor,
|
|
26
|
+
sx,
|
|
27
|
+
className
|
|
28
|
+
}) {
|
|
29
|
+
const rootSx = [
|
|
30
|
+
(theme) => __spreadValues({
|
|
31
|
+
display: "flex",
|
|
32
|
+
flexDirection: "column",
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
justifyContent: "center",
|
|
35
|
+
gap: 2
|
|
36
|
+
}, fullscreen ? {
|
|
37
|
+
position: "fixed",
|
|
38
|
+
inset: 0,
|
|
39
|
+
zIndex: theme.zIndex.modal + 10,
|
|
40
|
+
backgroundColor: backdropColor != null ? backdropColor : theme.palette.background.default
|
|
41
|
+
} : {
|
|
42
|
+
width: "100%",
|
|
43
|
+
minHeight: 160
|
|
44
|
+
}),
|
|
45
|
+
...Array.isArray(sx) ? sx : sx ? [sx] : []
|
|
46
|
+
];
|
|
47
|
+
const content = /* @__PURE__ */ jsxs(Box, { className, sx: rootSx, role: "status", "aria-live": "polite", children: [
|
|
48
|
+
logo && /* @__PURE__ */ jsx(Box, { sx: { mb: 1 }, children: logo }),
|
|
49
|
+
/* @__PURE__ */ jsx(CircularProgress, { size, thickness: 4 }),
|
|
50
|
+
message && /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: message })
|
|
51
|
+
] });
|
|
52
|
+
if (!fullscreen) {
|
|
53
|
+
return open ? content : null;
|
|
54
|
+
}
|
|
55
|
+
return /* @__PURE__ */ jsx(Fade, { in: open, timeout: { enter: 0, exit: 200 }, unmountOnExit: true, children: content });
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
PageLoader,
|
|
59
|
+
PageLoader as default
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=PageLoader.js.map
|