@soyfri/shared-library 2.0.0-beta.9 → 2.0.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/Button-C17mExpd.cjs.map +1 -1
- package/Button-UkkP-bNw.js.map +1 -1
- package/README.md +182 -150
- package/components/ActionMenu/ActionMenu.cjs +52 -52
- package/components/ActionMenu/ActionMenu.cjs.map +1 -1
- package/components/ActionMenu/ActionMenu.d.ts +20 -36
- package/components/ActionMenu/ActionMenu.js +55 -55
- package/components/ActionMenu/ActionMenu.js.map +1 -1
- package/components/ActionMenu/index.d.ts +2 -2
- package/components/AppBar/AppBar.cjs +2 -219
- package/components/AppBar/AppBar.cjs.map +1 -1
- package/components/AppBar/AppBar.d.ts +6 -6
- package/components/AppBar/AppBar.js +5 -222
- package/components/AppBar/AppBar.js.map +1 -1
- package/components/AppBar/index.d.ts +0 -6
- package/components/Autocomplete/Autocomplete.cjs +93 -94
- package/components/Autocomplete/Autocomplete.cjs.map +1 -1
- package/components/Autocomplete/Autocomplete.d.ts +29 -26
- package/components/Autocomplete/Autocomplete.definitions.d.ts +2 -1
- package/components/Autocomplete/Autocomplete.helpers.d.ts +12 -8
- package/components/Autocomplete/Autocomplete.js +94 -95
- package/components/Autocomplete/Autocomplete.js.map +1 -1
- package/components/Autocomplete/_parts/AutocompleteChips.d.ts +7 -6
- package/components/Autocomplete/_parts/AutocompleteOption.d.ts +10 -13
- package/components/Autocomplete/index.d.ts +1 -1
- package/components/Avatar/Avatar.cjs +17 -18
- package/components/Avatar/Avatar.cjs.map +1 -1
- package/components/Avatar/Avatar.js +17 -18
- package/components/Avatar/Avatar.js.map +1 -1
- package/components/Avatar/index.d.ts +1 -0
- package/components/Button/Button.d.ts +5 -5
- package/components/Button/index.d.ts +1 -0
- package/components/Card/Card.cjs +3 -92
- package/components/Card/Card.cjs.map +1 -1
- package/components/Card/Card.d.ts +3 -50
- package/components/Card/Card.js +5 -94
- package/components/Card/Card.js.map +1 -1
- package/components/Card/Card.sx.d.ts +3 -6
- package/components/Card/index.d.ts +1 -1
- package/components/Checkbox/Checkbox.cjs +189 -0
- package/components/Checkbox/Checkbox.cjs.map +1 -0
- package/components/Checkbox/Checkbox.d.ts +55 -0
- package/components/Checkbox/Checkbox.js +189 -0
- package/components/Checkbox/Checkbox.js.map +1 -0
- package/components/Checkbox/Checkbox.sx.d.ts +13 -0
- package/components/Checkbox/index.d.ts +2 -0
- package/components/Checkbox.d.ts +6 -0
- package/components/Chip/Chip.cjs +2 -1
- package/components/Chip/Chip.cjs.map +1 -1
- package/components/Chip/Chip.js +2 -1
- package/components/Chip/Chip.js.map +1 -1
- package/components/Chip/index.d.ts +2 -1
- package/components/Chip.d.ts +4 -0
- package/components/DatePicker/DatePicker.cjs +40 -63
- package/components/DatePicker/DatePicker.cjs.map +1 -1
- package/components/DatePicker/DatePicker.d.ts +1 -13
- package/components/DatePicker/DatePicker.js +36 -59
- package/components/DatePicker/DatePicker.js.map +1 -1
- package/components/DatePicker/index.d.ts +1 -1
- package/components/DateTimePicker/DateTimePicker.cjs +58 -82
- package/components/DateTimePicker/DateTimePicker.cjs.map +1 -1
- package/components/DateTimePicker/DateTimePicker.d.ts +9 -17
- package/components/DateTimePicker/DateTimePicker.definitions.d.ts +2 -0
- package/components/DateTimePicker/DateTimePicker.helpers.d.ts +4 -2
- package/components/DateTimePicker/DateTimePicker.js +54 -78
- package/components/DateTimePicker/DateTimePicker.js.map +1 -1
- package/components/DateTimePicker/index.d.ts +1 -1
- package/components/Drawer/Drawer.cjs +12 -6
- package/components/Drawer/Drawer.cjs.map +1 -1
- package/components/Drawer/Drawer.d.ts +3 -1
- package/components/Drawer/Drawer.js +13 -7
- package/components/Drawer/Drawer.js.map +1 -1
- package/components/Drawer/DrawerItem.d.ts +6 -1
- package/components/Gallery/Gallery.cjs +154 -79
- package/components/Gallery/Gallery.cjs.map +1 -1
- package/components/Gallery/Gallery.d.ts +25 -9
- package/components/Gallery/Gallery.js +154 -79
- package/components/Gallery/Gallery.js.map +1 -1
- package/components/Gallery/GalleryLightbox.d.ts +6 -10
- package/components/Gallery/GalleryMain.d.ts +3 -7
- package/components/Gallery/GalleryThumbnails.d.ts +7 -11
- package/components/Gallery/index.d.ts +2 -1
- package/components/Gallery.d.ts +4 -0
- package/components/Icon/Icon.cjs +6 -8
- package/components/Icon/Icon.cjs.map +1 -1
- package/components/Icon/Icon.d.ts +11 -17
- package/components/Icon/Icon.js +6 -8
- package/components/Icon/Icon.js.map +1 -1
- package/components/Icon/index.d.ts +2 -1
- package/components/Icon.d.ts +4 -0
- package/components/Input/Input.cjs +26 -13
- package/components/Input/Input.cjs.map +1 -1
- package/components/Input/Input.d.ts +9 -2
- package/components/Input/Input.helpers.d.ts +3 -3
- package/components/Input/Input.js +23 -10
- package/components/Input/Input.js.map +1 -1
- package/components/Input/index.d.ts +1 -1
- package/components/InputGroup/InputGroup.cjs +23 -22
- package/components/InputGroup/InputGroup.cjs.map +1 -1
- package/components/InputGroup/InputGroup.d.ts +4 -4
- package/components/InputGroup/InputGroup.js +22 -21
- package/components/InputGroup/InputGroup.js.map +1 -1
- package/components/InputGroup/index.d.ts +2 -1
- package/components/InputGroup.d.ts +4 -0
- package/components/Modal/Modal.cjs +127 -98
- package/components/Modal/Modal.cjs.map +1 -1
- package/components/Modal/Modal.d.ts +20 -5
- package/components/Modal/Modal.js +130 -101
- package/components/Modal/Modal.js.map +1 -1
- package/components/Modal/ModalBody.d.ts +6 -1
- package/components/Modal/ModalFooter.d.ts +4 -4
- package/components/Modal/ModalHeader.d.ts +6 -1
- package/components/Modal/index.d.ts +4 -2
- package/components/Modal.d.ts +4 -0
- package/components/RadioGroup/RadioGroup.cjs +9 -7
- package/components/RadioGroup/RadioGroup.cjs.map +1 -1
- package/components/RadioGroup/RadioGroup.d.ts +9 -3
- package/components/RadioGroup/RadioGroup.js +9 -7
- package/components/RadioGroup/RadioGroup.js.map +1 -1
- package/components/RadioGroup/index.d.ts +1 -1
- package/components/Select/Select.cjs +129 -264
- package/components/Select/Select.cjs.map +1 -1
- package/components/Select/Select.d.ts +35 -20
- package/components/Select/Select.helpers.d.ts +6 -19
- package/components/Select/Select.js +134 -269
- package/components/Select/Select.js.map +1 -1
- package/components/Select/index.d.ts +1 -1
- package/components/Stat/Stat.cjs +2 -2
- package/components/Stat/Stat.cjs.map +1 -1
- package/components/Stat/Stat.js +2 -2
- package/components/Stat/Stat.js.map +1 -1
- package/components/Stat/index.d.ts +2 -1
- package/components/Stat.d.ts +4 -0
- package/components/StatusMessage/StatusMessage.cjs +84 -55
- package/components/StatusMessage/StatusMessage.cjs.map +1 -1
- package/components/StatusMessage/StatusMessage.d.ts +20 -36
- package/components/StatusMessage/StatusMessage.js +86 -57
- package/components/StatusMessage/StatusMessage.js.map +1 -1
- package/components/StatusMessage/StatusMessageContext.d.ts +16 -0
- package/components/StatusMessage/index.d.ts +4 -1
- package/components/StatusMessage.d.ts +4 -0
- package/components/Stepper/Stepper.cjs +289 -55
- package/components/Stepper/Stepper.cjs.map +1 -1
- package/components/Stepper/Stepper.d.ts +9 -20
- package/components/Stepper/Stepper.js +291 -57
- package/components/Stepper/Stepper.js.map +1 -1
- package/{hooks/Wizard/WizardContext.d.ts → components/Stepper/StepperContext.d.ts} +29 -23
- package/components/Stepper/_hooks/useHorizontalScroll.d.ts +19 -0
- package/components/Stepper/_parts/StepperScrollArrow.d.ts +19 -0
- package/components/Stepper/index.d.ts +6 -2
- package/components/Stepper.d.ts +4 -0
- package/components/Switch/Switch.cjs +5 -2
- package/components/Switch/Switch.cjs.map +1 -1
- package/components/Switch/Switch.d.ts +7 -2
- package/components/Switch/Switch.js +5 -2
- package/components/Switch/Switch.js.map +1 -1
- package/components/Tabs/Tabs.cjs +45 -29
- package/components/Tabs/Tabs.cjs.map +1 -1
- package/components/Tabs/Tabs.d.ts +21 -16
- package/components/Tabs/Tabs.js +46 -30
- package/components/Tabs/Tabs.js.map +1 -1
- package/components/Tabs/index.d.ts +4 -2
- package/components/Tabs.d.ts +4 -0
- package/components/Timeline/Timeline.cjs +3 -2
- package/components/Timeline/Timeline.cjs.map +1 -1
- package/components/Timeline/Timeline.d.ts +4 -8
- package/components/Timeline/Timeline.js +3 -2
- package/components/Timeline/Timeline.js.map +1 -1
- package/components/Timeline/index.d.ts +4 -2
- package/components/Timeline.d.ts +4 -0
- package/components/_shared/mergeSx.d.ts +7 -0
- package/{formField.sx-DfVbMe0V.js → formField.sx-8_QRnKxv.js} +2 -11
- package/formField.sx-8_QRnKxv.js.map +1 -0
- package/{formField.sx-CQ1mbk9M.cjs → formField.sx-BAX7KwMR.cjs} +10 -19
- package/formField.sx-BAX7KwMR.cjs.map +1 -0
- package/index.cjs +31 -2
- package/index.cjs.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +16 -2
- package/index.js.map +1 -1
- package/mergeSx-BXoNZjB_.js +10 -0
- package/mergeSx-BXoNZjB_.js.map +1 -0
- package/mergeSx-Dbccoo_H.cjs +9 -0
- package/mergeSx-Dbccoo_H.cjs.map +1 -0
- package/mui.d.ts +3 -2
- package/package.json +6 -16
- package/theme/componentStyles.d.ts +1 -1
- package/tokens-BRrcP_p_.js +21 -0
- package/tokens-BRrcP_p_.js.map +1 -0
- package/tokens-jaWWNk39.cjs +20 -0
- package/tokens-jaWWNk39.cjs.map +1 -0
- package/utils/index.d.ts +2 -0
- package/{components/ScrollTopButton → utils}/scrollToTop.d.ts +6 -7
- package/components/AppBar/AppBarBrand.d.ts +0 -31
- package/components/AppBar/AppBarUserMenu.d.ts +0 -65
- package/components/Autocomplete/Autocomplete.types.d.ts +0 -1
- package/components/DatePicker/DatePicker.types.d.ts +0 -1
- package/components/DateTimePicker/DateTimePicker.types.d.ts +0 -1
- package/components/Input/Input.types.d.ts +0 -1
- package/components/PageLoader/PageLoader.cjs +0 -61
- package/components/PageLoader/PageLoader.cjs.map +0 -1
- package/components/PageLoader/PageLoader.d.ts +0 -38
- package/components/PageLoader/PageLoader.js +0 -61
- package/components/PageLoader/PageLoader.js.map +0 -1
- package/components/PageLoader/index.d.ts +0 -2
- package/components/PageLoader.d.ts +0 -6
- package/components/RadioGroup/RadioGroup.types.d.ts +0 -1
- package/components/ScrollTopButton/ScrollTopButton.cjs +0 -79
- package/components/ScrollTopButton/ScrollTopButton.cjs.map +0 -1
- package/components/ScrollTopButton/ScrollTopButton.d.ts +0 -48
- package/components/ScrollTopButton/ScrollTopButton.js +0 -79
- package/components/ScrollTopButton/ScrollTopButton.js.map +0 -1
- package/components/ScrollTopButton/index.d.ts +0 -4
- package/components/ScrollTopButton.d.ts +0 -6
- package/components/Select/Select.definitions.d.ts +0 -17
- package/components/Select/Select.types.d.ts +0 -1
- package/components/Select/_parts/SelectSearchHeader.d.ts +0 -15
- package/components/Select/_parts/SelectValue.d.ts +0 -22
- package/formField.sx-CQ1mbk9M.cjs.map +0 -1
- package/formField.sx-DfVbMe0V.js.map +0 -1
- package/hooks/Wizard/Wizard.cjs +0 -7
- package/hooks/Wizard/Wizard.cjs.map +0 -1
- package/hooks/Wizard/Wizard.js +0 -7
- package/hooks/Wizard/Wizard.js.map +0 -1
- package/hooks/Wizard/index.d.ts +0 -3
- package/hooks/Wizard/useWizard.d.ts +0 -9
- package/hooks/Wizard.d.ts +0 -2
- package/useWizard-CWdIxZzX.cjs +0 -94
- package/useWizard-CWdIxZzX.cjs.map +0 -1
- package/useWizard-CWq--C3o.js +0 -95
- package/useWizard-CWq--C3o.js.map +0 -1
- /package/{styles.css → index.css} +0 -0
|
@@ -17,27 +17,16 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
20
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
33
|
-
import
|
|
34
|
-
import { Box, Stack,
|
|
21
|
+
import { forwardRef, useState, useId, useImperativeHandle, Children, isValidElement, cloneElement } from "react";
|
|
22
|
+
import { Box, Stack, Typography, useTheme, useMediaQuery, Modal as Modal$1, Paper } from "@mui/material";
|
|
35
23
|
import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
|
|
36
24
|
import WarningAmberIcon from "@mui/icons-material/WarningAmber";
|
|
37
25
|
import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
|
|
38
26
|
import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutline";
|
|
27
|
+
import { B as Button } from "../../Button-UkkP-bNw.js";
|
|
28
|
+
import { m as mergeSx } from "../../mergeSx-BXoNZjB_.js";
|
|
39
29
|
const ModalFooter = ({
|
|
40
|
-
// Renombrado
|
|
41
30
|
children,
|
|
42
31
|
showCloseButton = true,
|
|
43
32
|
closeButtonText = "Cerrar",
|
|
@@ -45,42 +34,74 @@ const ModalFooter = ({
|
|
|
45
34
|
onClose,
|
|
46
35
|
actions = []
|
|
47
36
|
}) => {
|
|
48
|
-
return /* @__PURE__ */ jsxs(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
37
|
+
return /* @__PURE__ */ jsxs(
|
|
38
|
+
Box,
|
|
39
|
+
{
|
|
40
|
+
sx: {
|
|
41
|
+
padding: 2,
|
|
42
|
+
borderTop: (theme) => `1px solid ${theme.palette.divider}`,
|
|
43
|
+
display: "flex",
|
|
44
|
+
justifyContent: "flex-end",
|
|
45
|
+
gap: 1
|
|
46
|
+
},
|
|
47
|
+
children: [
|
|
48
|
+
children,
|
|
49
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, children: [
|
|
50
|
+
showCloseButton && /* @__PURE__ */ jsx(
|
|
51
|
+
Button,
|
|
52
|
+
{
|
|
53
|
+
onClick: onClose,
|
|
54
|
+
disabled: closeButtonDisabled,
|
|
55
|
+
variant: "outlined",
|
|
56
|
+
color: "secondary",
|
|
57
|
+
children: closeButtonText
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
actions.map((action) => {
|
|
61
|
+
const { buttonProps, text, onClick, disabled, variant, color } = action;
|
|
62
|
+
return /* @__PURE__ */ jsx(
|
|
63
|
+
Button,
|
|
64
|
+
__spreadProps(__spreadValues({
|
|
65
|
+
onClick,
|
|
66
|
+
disabled,
|
|
67
|
+
variant: variant || "contained",
|
|
68
|
+
color: color || "primary"
|
|
69
|
+
}, buttonProps), {
|
|
70
|
+
children: text
|
|
71
|
+
}),
|
|
72
|
+
text
|
|
73
|
+
);
|
|
74
|
+
})
|
|
75
|
+
] })
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
ModalFooter.displayName = "ModalFooter";
|
|
81
|
+
const ModalHeader = ({ children, id }) => {
|
|
82
|
+
return /* @__PURE__ */ jsx(
|
|
83
|
+
Box,
|
|
84
|
+
{
|
|
85
|
+
sx: {
|
|
86
|
+
padding: 2,
|
|
87
|
+
borderBottom: (theme) => `1px solid ${theme.palette.divider}`,
|
|
88
|
+
display: "flex",
|
|
89
|
+
alignItems: "center",
|
|
90
|
+
justifyContent: "space-between"
|
|
91
|
+
},
|
|
92
|
+
children: /* @__PURE__ */ jsx(Typography, { id, variant: "h6", component: "h2", children })
|
|
93
|
+
}
|
|
94
|
+
);
|
|
78
95
|
};
|
|
79
|
-
|
|
80
|
-
|
|
96
|
+
ModalHeader.displayName = "ModalHeader";
|
|
97
|
+
const ModalBody = ({ children, id }) => {
|
|
98
|
+
return /* @__PURE__ */ jsx(Box, { id, sx: { padding: 2, overflowY: "auto", flexGrow: 1 }, children });
|
|
81
99
|
};
|
|
82
|
-
|
|
83
|
-
|
|
100
|
+
ModalBody.displayName = "ModalBody";
|
|
101
|
+
const isModalSlot = (child, Component, displayName) => {
|
|
102
|
+
if (child.type === Component) return true;
|
|
103
|
+
const type = child.type;
|
|
104
|
+
return (type == null ? void 0 : type.displayName) === displayName;
|
|
84
105
|
};
|
|
85
106
|
const modalStyle = {
|
|
86
107
|
position: "absolute",
|
|
@@ -97,22 +118,22 @@ const severityConfig = {
|
|
|
97
118
|
info: {
|
|
98
119
|
color: "primary",
|
|
99
120
|
icon: /* @__PURE__ */ jsx(InfoOutlinedIcon, { sx: { fontSize: 48 } }),
|
|
100
|
-
|
|
121
|
+
paletteKey: "primary"
|
|
101
122
|
},
|
|
102
123
|
warning: {
|
|
103
124
|
color: "warning",
|
|
104
125
|
icon: /* @__PURE__ */ jsx(WarningAmberIcon, { sx: { fontSize: 48 } }),
|
|
105
|
-
|
|
126
|
+
paletteKey: "warning"
|
|
106
127
|
},
|
|
107
128
|
error: {
|
|
108
129
|
color: "error",
|
|
109
130
|
icon: /* @__PURE__ */ jsx(ErrorOutlineIcon, { sx: { fontSize: 48 } }),
|
|
110
|
-
|
|
131
|
+
paletteKey: "error"
|
|
111
132
|
},
|
|
112
133
|
success: {
|
|
113
134
|
color: "success",
|
|
114
135
|
icon: /* @__PURE__ */ jsx(CheckCircleOutlineIcon, { sx: { fontSize: 48 } }),
|
|
115
|
-
|
|
136
|
+
paletteKey: "success"
|
|
116
137
|
}
|
|
117
138
|
};
|
|
118
139
|
const Modal = forwardRef(
|
|
@@ -127,7 +148,12 @@ const Modal = forwardRef(
|
|
|
127
148
|
closeButtonDisabled = false,
|
|
128
149
|
actions = [],
|
|
129
150
|
maxWidth = "sm",
|
|
151
|
+
hiddenHeader = false,
|
|
152
|
+
hiddenBody = false,
|
|
130
153
|
hiddenFooter = false,
|
|
154
|
+
sx,
|
|
155
|
+
paperSx,
|
|
156
|
+
className,
|
|
131
157
|
// Props del modo confirm
|
|
132
158
|
onConfirm,
|
|
133
159
|
confirmText = "Confirmar",
|
|
@@ -137,6 +163,8 @@ const Modal = forwardRef(
|
|
|
137
163
|
}, ref) => {
|
|
138
164
|
const [internalOpen, setInternalOpen] = useState(false);
|
|
139
165
|
const [confirmLoading, setConfirmLoading] = useState(false);
|
|
166
|
+
const titleId = useId();
|
|
167
|
+
const descId = useId();
|
|
140
168
|
const isOpen = controlledOpen !== void 0 ? controlledOpen : internalOpen;
|
|
141
169
|
useImperativeHandle(ref, () => ({
|
|
142
170
|
open: () => setInternalOpen(true),
|
|
@@ -154,15 +182,19 @@ const Modal = forwardRef(
|
|
|
154
182
|
handleCloseInternal();
|
|
155
183
|
return;
|
|
156
184
|
}
|
|
185
|
+
const result = onConfirm();
|
|
186
|
+
if (!(result instanceof Promise)) {
|
|
187
|
+
handleCloseInternal();
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
setConfirmLoading(true);
|
|
157
191
|
try {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
192
|
+
await result;
|
|
193
|
+
handleCloseInternal();
|
|
194
|
+
} catch (err) {
|
|
195
|
+
console.error("Modal onConfirm failed:", err);
|
|
163
196
|
} finally {
|
|
164
197
|
setConfirmLoading(false);
|
|
165
|
-
handleCloseInternal();
|
|
166
198
|
}
|
|
167
199
|
};
|
|
168
200
|
const theme = useTheme();
|
|
@@ -183,9 +215,11 @@ const Modal = forwardRef(
|
|
|
183
215
|
case false:
|
|
184
216
|
return "auto";
|
|
185
217
|
default:
|
|
186
|
-
return 500;
|
|
218
|
+
return typeof maxWidth === "string" ? maxWidth : 500;
|
|
187
219
|
}
|
|
188
220
|
};
|
|
221
|
+
const paperBaseSx = __spreadProps(__spreadValues({}, modalStyle), { width: getWidth() });
|
|
222
|
+
const mergedPaperSx = mergeSx(paperBaseSx, paperSx);
|
|
189
223
|
if (mode === "confirm") {
|
|
190
224
|
const config = severityConfig[severity];
|
|
191
225
|
const message = confirmMessage != null ? confirmMessage : children;
|
|
@@ -194,9 +228,11 @@ const Modal = forwardRef(
|
|
|
194
228
|
{
|
|
195
229
|
open: isOpen,
|
|
196
230
|
onClose: handleCloseInternal,
|
|
197
|
-
"aria-labelledby":
|
|
231
|
+
"aria-labelledby": title ? titleId : void 0,
|
|
232
|
+
"aria-describedby": message ? descId : void 0,
|
|
198
233
|
closeAfterTransition: true,
|
|
199
|
-
|
|
234
|
+
sx,
|
|
235
|
+
children: /* @__PURE__ */ jsxs(Paper, { className, sx: mergedPaperSx, children: [
|
|
200
236
|
/* @__PURE__ */ jsxs(Stack, { spacing: 2.5, sx: { p: 3, alignItems: "center", textAlign: "center" }, children: [
|
|
201
237
|
/* @__PURE__ */ jsx(
|
|
202
238
|
Box,
|
|
@@ -205,8 +241,8 @@ const Modal = forwardRef(
|
|
|
205
241
|
width: 72,
|
|
206
242
|
height: 72,
|
|
207
243
|
borderRadius: "50%",
|
|
208
|
-
backgroundColor: (t) => t.palette[
|
|
209
|
-
color: (t) => t.palette[
|
|
244
|
+
backgroundColor: (t) => t.palette[config.paletteKey].light,
|
|
245
|
+
color: (t) => t.palette[config.paletteKey].dark,
|
|
210
246
|
display: "flex",
|
|
211
247
|
alignItems: "center",
|
|
212
248
|
justifyContent: "center",
|
|
@@ -215,8 +251,8 @@ const Modal = forwardRef(
|
|
|
215
251
|
children: config.icon
|
|
216
252
|
}
|
|
217
253
|
),
|
|
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 })
|
|
254
|
+
title && /* @__PURE__ */ jsx(Typography, { id: titleId, variant: "h6", component: "h2", sx: { fontWeight: 700 }, children: title }),
|
|
255
|
+
message && /* @__PURE__ */ jsx(Typography, { id: descId, variant: "body2", color: "text.secondary", children: message })
|
|
220
256
|
] }),
|
|
221
257
|
/* @__PURE__ */ jsx(
|
|
222
258
|
ModalFooter,
|
|
@@ -244,35 +280,25 @@ const Modal = forwardRef(
|
|
|
244
280
|
let header = null;
|
|
245
281
|
let body = null;
|
|
246
282
|
let footer = null;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
"actions"
|
|
267
|
-
]);
|
|
268
|
-
footer = React__default.cloneElement(footerChild, __spreadValues({
|
|
269
|
-
showCloseButton,
|
|
270
|
-
closeButtonText,
|
|
271
|
-
closeButtonDisabled,
|
|
272
|
-
onClose: handleCloseInternal,
|
|
273
|
-
actions
|
|
274
|
-
}, restOfFooterProps));
|
|
275
|
-
}
|
|
283
|
+
Children.forEach(children, (child) => {
|
|
284
|
+
var _a, _b, _c, _d, _e;
|
|
285
|
+
if (!isValidElement(child)) return;
|
|
286
|
+
if (isModalSlot(child, ModalHeader, "ModalHeader")) {
|
|
287
|
+
const headerChild = child;
|
|
288
|
+
header = cloneElement(headerChild, __spreadValues({ id: titleId }, headerChild.props));
|
|
289
|
+
} else if (isModalSlot(child, ModalBody, "ModalBody")) {
|
|
290
|
+
const bodyChild = child;
|
|
291
|
+
body = cloneElement(bodyChild, __spreadValues({ id: descId }, bodyChild.props));
|
|
292
|
+
} else if (isModalSlot(child, ModalFooter, "ModalFooter")) {
|
|
293
|
+
const footerChild = child;
|
|
294
|
+
const childProps = footerChild.props;
|
|
295
|
+
footer = cloneElement(footerChild, {
|
|
296
|
+
showCloseButton: (_a = childProps.showCloseButton) != null ? _a : showCloseButton,
|
|
297
|
+
closeButtonText: (_b = childProps.closeButtonText) != null ? _b : closeButtonText,
|
|
298
|
+
closeButtonDisabled: (_c = childProps.closeButtonDisabled) != null ? _c : closeButtonDisabled,
|
|
299
|
+
onClose: (_d = childProps.onClose) != null ? _d : handleCloseInternal,
|
|
300
|
+
actions: (_e = childProps.actions) != null ? _e : actions
|
|
301
|
+
});
|
|
276
302
|
}
|
|
277
303
|
});
|
|
278
304
|
if (!footer && !hiddenFooter) {
|
|
@@ -288,8 +314,8 @@ const Modal = forwardRef(
|
|
|
288
314
|
);
|
|
289
315
|
}
|
|
290
316
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
291
|
-
header || title && /* @__PURE__ */ jsx(ModalHeader, { children: title }),
|
|
292
|
-
body,
|
|
317
|
+
!hiddenHeader && (header || title && /* @__PURE__ */ jsx(ModalHeader, { id: titleId, children: title })),
|
|
318
|
+
!hiddenBody && body,
|
|
293
319
|
footer
|
|
294
320
|
] });
|
|
295
321
|
};
|
|
@@ -298,14 +324,16 @@ const Modal = forwardRef(
|
|
|
298
324
|
{
|
|
299
325
|
open: isOpen,
|
|
300
326
|
onClose: handleCloseInternal,
|
|
301
|
-
"aria-labelledby":
|
|
302
|
-
"aria-describedby":
|
|
327
|
+
"aria-labelledby": titleId,
|
|
328
|
+
"aria-describedby": descId,
|
|
303
329
|
closeAfterTransition: true,
|
|
304
|
-
|
|
330
|
+
sx,
|
|
331
|
+
children: /* @__PURE__ */ jsx(Paper, { className, sx: mergedPaperSx, children: renderChildren() })
|
|
305
332
|
}
|
|
306
333
|
);
|
|
307
334
|
}
|
|
308
335
|
);
|
|
336
|
+
Modal.displayName = "Modal";
|
|
309
337
|
const ModalWithStatics = Modal;
|
|
310
338
|
ModalWithStatics.Header = ModalHeader;
|
|
311
339
|
ModalWithStatics.Body = ModalBody;
|
|
@@ -314,6 +342,7 @@ export {
|
|
|
314
342
|
ModalWithStatics as Modal,
|
|
315
343
|
ModalBody,
|
|
316
344
|
ModalFooter,
|
|
317
|
-
ModalHeader
|
|
345
|
+
ModalHeader,
|
|
346
|
+
ModalWithStatics as default
|
|
318
347
|
};
|
|
319
348
|
//# 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 * 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,OAA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,MACF,CAAC;AAED,UAAI,CAAC,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;"}
|
|
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, Stack } from '@mui/material';\nimport type { ButtonProps as MuiButtonProps } from '@mui/material/Button';\n\nimport { Button } from '../Button';\n\n// Interfaz para acciones personalizadas (se mantiene aquí)\nexport interface ModalAction {\n text: string;\n onClick?: () => void;\n disabled?: boolean;\n variant?: MuiButtonProps['variant'];\n color?: MuiButtonProps['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<MuiButtonProps> & { form?: string };\n}\n\nexport interface ModalFooterProps {\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> = ({\n children,\n showCloseButton = true,\n closeButtonText = 'Cerrar',\n closeButtonDisabled = false,\n onClose,\n actions = [],\n}) => {\n return (\n <Box\n sx={{\n padding: 2,\n borderTop: (theme) => `1px solid ${theme.palette.divider}`,\n display: 'flex',\n justifyContent: 'flex-end',\n gap: 1,\n }}\n >\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) => {\n const { buttonProps, text, onClick, disabled, variant, color } = action;\n return (\n <Button\n key={text}\n onClick={onClick}\n disabled={disabled}\n variant={variant || 'contained'}\n color={color || 'primary'}\n {...(buttonProps as any)}\n >\n {text}\n </Button>\n );\n })}\n </Stack>\n </Box>\n );\n};\n\nModalFooter.displayName = 'ModalFooter';\n\nexport default ModalFooter;\n","import React from 'react';\nimport { Box, Typography } from '@mui/material';\n\nexport interface ModalHeaderProps {\n children: React.ReactNode;\n /**\n * ID del elemento — usado para `aria-labelledby` del Modal. Se setea\n * automáticamente cuando el header se renderiza dentro de `<Modal>`.\n */\n id?: string;\n}\n\nexport const ModalHeader: React.FC<ModalHeaderProps> = ({ children, id }) => {\n return (\n <Box\n sx={{\n padding: 2,\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n }}\n >\n <Typography id={id} variant=\"h6\" component=\"h2\">\n {children}\n </Typography>\n </Box>\n );\n};\n\nModalHeader.displayName = 'ModalHeader';\n\nexport default ModalHeader;\n","import React from 'react';\nimport { Box } from '@mui/material';\n\nexport interface ModalBodyProps {\n children: React.ReactNode;\n /**\n * ID del elemento — usado para `aria-describedby` del Modal. Se setea\n * automáticamente cuando el body se renderiza dentro de `<Modal>`.\n */\n id?: string;\n}\n\nexport const ModalBody: React.FC<ModalBodyProps> = ({ children, id }) => {\n return (\n <Box id={id} sx={{ padding: 2, overflowY: 'auto', flexGrow: 1 }}>\n {children}\n </Box>\n );\n};\n\nModalBody.displayName = 'ModalBody';\n\nexport default ModalBody;\n","import {\n Children,\n cloneElement,\n forwardRef,\n isValidElement,\n useId,\n useImperativeHandle,\n useState,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport {\n Modal as MuiModal,\n Paper,\n useMediaQuery,\n useTheme,\n Box,\n Stack,\n Typography,\n} from '@mui/material';\nimport type { SxProps, Theme } from '@mui/material/styles';\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 { ModalFooter, type ModalAction, type ModalFooterProps } from './ModalFooter';\nimport { ModalHeader } from './ModalHeader';\nimport { ModalBody } from './ModalBody';\nimport { mergeSx } from '../_shared/mergeSx';\n\n// Detección robusta de sub-componentes — funciona con wrappers / HMR que\n// rompen la igualdad de referencia (`child.type === ModalHeader`).\nconst isModalSlot = (\n child: ReactElement,\n Component: unknown,\n displayName: string,\n): boolean => {\n if (child.type === Component) return true;\n const type = child.type as { displayName?: string };\n return type?.displayName === displayName;\n};\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\nexport interface 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 /** Oculta el header (incluso si hay `title` o se pasa un `<Modal.Header>`). */\n hiddenHeader?: boolean;\n /** Oculta el body (incluso si se pasa un `<Modal.Body>`). */\n hiddenBody?: boolean;\n /** Oculta el footer (incluso si se pasa un `<Modal.Footer>` o `actions`). */\n hiddenFooter?: boolean;\n /** sx del Modal root (MuiModal). */\n sx?: SxProps<Theme>;\n /** sx del Paper interno (contenedor visual). Se mergea sobre el default. */\n paperSx?: SxProps<Theme>;\n /** className del Paper interno. */\n className?: string;\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 * Si la promesa **rechaza**, el modal queda abierto para que el consumer\n * pueda mostrar el error en su UI. El modal se cierra solo en éxito.\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; paletteKey: 'primary' | 'warning' | 'error' | 'success' }\n> = {\n info: {\n color: 'primary',\n icon: <InfoOutlinedIcon sx={{ fontSize: 48 }} />,\n paletteKey: 'primary',\n },\n warning: {\n color: 'warning',\n icon: <WarningAmberIcon sx={{ fontSize: 48 }} />,\n paletteKey: 'warning',\n },\n error: {\n color: 'error',\n icon: <ErrorOutlineIcon sx={{ fontSize: 48 }} />,\n paletteKey: 'error',\n },\n success: {\n color: 'success',\n icon: <CheckCircleOutlineIcon sx={{ fontSize: 48 }} />,\n paletteKey: 'success',\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 hiddenHeader = false,\n hiddenBody = false,\n hiddenFooter = false,\n sx,\n paperSx,\n className,\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 // IDs estables para a11y: `aria-labelledby` y `aria-describedby`.\n const titleId = useId();\n const descId = useId();\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 const result = onConfirm();\n if (!(result instanceof Promise)) {\n handleCloseInternal();\n return;\n }\n setConfirmLoading(true);\n try {\n await result;\n handleCloseInternal();\n } catch (err) {\n // No cerrar el modal en caso de error — el consumer es responsable\n // de mostrar un estado de error en su UI. Logueamos para trazabilidad\n // en dev.\n // eslint-disable-next-line no-console\n console.error('Modal onConfirm failed:', err);\n } finally {\n setConfirmLoading(false);\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 // Soporta string custom: `maxWidth=\"600px\"` se pasa tal cual.\n return typeof maxWidth === 'string' ? maxWidth : 500;\n }\n };\n\n // Base sx del Paper + width responsive; el consumer puede pisarlos via `paperSx`.\n const paperBaseSx: SxProps<Theme> = { ...modalStyle, width: getWidth() };\n const mergedPaperSx = mergeSx(paperBaseSx, paperSx);\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={title ? titleId : undefined}\n aria-describedby={message ? descId : undefined}\n closeAfterTransition\n sx={sx}\n >\n <Paper className={className} sx={mergedPaperSx}>\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) => t.palette[config.paletteKey].light,\n color: (t) => t.palette[config.paletteKey].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 id={titleId} variant=\"h6\" component=\"h2\" sx={{ fontWeight: 700 }}>\n {title}\n </Typography>\n )}\n {message && (\n <Typography id={descId} 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 (compuesto) ─────────────────────────────────\n const renderChildren = () => {\n let header: ReactNode | null = null;\n let body: ReactNode | null = null;\n let footer: ReactNode | null = null;\n\n Children.forEach(children, (child) => {\n if (!isValidElement(child)) return;\n\n if (isModalSlot(child, ModalHeader, 'ModalHeader')) {\n const headerChild = child as ReactElement<{ id?: string }>;\n header = cloneElement(headerChild, { id: titleId, ...headerChild.props });\n } else if (isModalSlot(child, ModalBody, 'ModalBody')) {\n const bodyChild = child as ReactElement<{ id?: string }>;\n body = cloneElement(bodyChild, { id: descId, ...bodyChild.props });\n } else if (isModalSlot(child, ModalFooter, 'ModalFooter')) {\n const footerChild = child as ReactElement<ModalFooterProps>;\n // Props del child ganan sobre los del Modal padre: si el consumer\n // declara `<Modal.Footer showCloseButton={false}>`, ese valor se\n // respeta. Solo los que vengan `undefined` caen al default del padre.\n const childProps = footerChild.props;\n footer = cloneElement(footerChild, {\n showCloseButton: childProps.showCloseButton ?? showCloseButton,\n closeButtonText: childProps.closeButtonText ?? closeButtonText,\n closeButtonDisabled: childProps.closeButtonDisabled ?? closeButtonDisabled,\n onClose: childProps.onClose ?? handleCloseInternal,\n actions: childProps.actions ?? actions,\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 {!hiddenHeader && (header || (title && <ModalHeader id={titleId}>{title}</ModalHeader>))}\n {!hiddenBody && body}\n {footer}\n </>\n );\n };\n\n return (\n <MuiModal\n open={isOpen}\n onClose={handleCloseInternal}\n aria-labelledby={titleId}\n aria-describedby={descId}\n closeAfterTransition\n sx={sx}\n >\n <Paper className={className} sx={mergedPaperSx}>\n {renderChildren()}\n </Paper>\n </MuiModal>\n );\n },\n);\n\nModal.displayName = 'Modal';\n\n// Define los sub-componentes como propiedades estáticas con tipos explícitos\ntype ModalComponent = ReturnType<typeof forwardRef<ModalRef, ModalProps>> & {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BO,MAAM,cAA0C,CAAC;AAAA,EACtD;AAAA,EACA,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,sBAAsB;AAAA,EACtB;AAAA,EACA,UAAU,CAAA;AACZ,MAAM;AACJ,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAI;AAAA,QACF,SAAS;AAAA,QACT,WAAW,CAAC,UAAU,aAAa,MAAM,QAAQ,OAAO;AAAA,QACxD,SAAS;AAAA,QACT,gBAAgB;AAAA,QAChB,KAAK;AAAA,MAAA;AAAA,MAGN,UAAA;AAAA,QAAA;AAAA,QACD,qBAAC,OAAA,EAAM,WAAU,OAAM,SAAS,GAC7B,UAAA;AAAA,UAAA,mBACC;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,UAAU;AAAA,cACV,SAAQ;AAAA,cACR,OAAM;AAAA,cAEL,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,UAGJ,QAAQ,IAAI,CAAC,WAAW;AACvB,kBAAM,EAAE,aAAa,MAAM,SAAS,UAAU,SAAS,UAAU;AACjE,mBACE;AAAA,cAAC;AAAA,cAAA;A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
|
|
2
|
-
interface ModalBodyProps {
|
|
2
|
+
export interface ModalBodyProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
|
+
/**
|
|
5
|
+
* ID del elemento — usado para `aria-describedby` del Modal. Se setea
|
|
6
|
+
* automáticamente cuando el body se renderiza dentro de `<Modal>`.
|
|
7
|
+
*/
|
|
8
|
+
id?: string;
|
|
4
9
|
}
|
|
5
10
|
export declare const ModalBody: React.FC<ModalBodyProps>;
|
|
6
11
|
export default ModalBody;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { ButtonProps } from '@mui/material/Button';
|
|
2
|
+
import { ButtonProps as MuiButtonProps } from '@mui/material/Button';
|
|
3
3
|
export interface ModalAction {
|
|
4
4
|
text: string;
|
|
5
5
|
onClick?: () => void;
|
|
6
6
|
disabled?: boolean;
|
|
7
|
-
variant?:
|
|
8
|
-
color?:
|
|
7
|
+
variant?: MuiButtonProps['variant'];
|
|
8
|
+
color?: MuiButtonProps['color'];
|
|
9
9
|
/**
|
|
10
10
|
* Props adicionales que se forwardean al `<Button>` interno. Útil para casos
|
|
11
11
|
* avanzados como conectar el botón con un `<form id="...">` externo usando
|
|
12
12
|
* `buttonProps={{ type: 'submit', form: 'my-form-id' }}`.
|
|
13
13
|
*/
|
|
14
|
-
buttonProps?: Partial<
|
|
14
|
+
buttonProps?: Partial<MuiButtonProps> & {
|
|
15
15
|
form?: string;
|
|
16
16
|
};
|
|
17
17
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
interface ModalHeaderProps {
|
|
2
|
+
export interface ModalHeaderProps {
|
|
3
3
|
children: React.ReactNode;
|
|
4
|
+
/**
|
|
5
|
+
* ID del elemento — usado para `aria-labelledby` del Modal. Se setea
|
|
6
|
+
* automáticamente cuando el header se renderiza dentro de `<Modal>`.
|
|
7
|
+
*/
|
|
8
|
+
id?: string;
|
|
4
9
|
}
|
|
5
10
|
export declare const ModalHeader: React.FC<ModalHeaderProps>;
|
|
6
11
|
export default ModalHeader;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export { default as Modal } from './Modal';
|
|
2
|
-
export type { ModalRef, ModalMode, ModalSeverity } from './Modal';
|
|
1
|
+
export { default, default as Modal } from './Modal';
|
|
2
|
+
export type { ModalProps, ModalRef, ModalMode, ModalSeverity } from './Modal';
|
|
3
3
|
export { ModalHeader } from './ModalHeader';
|
|
4
|
+
export type { ModalHeaderProps } from './ModalHeader';
|
|
4
5
|
export { ModalBody } from './ModalBody';
|
|
6
|
+
export type { ModalBodyProps } from './ModalBody';
|
|
5
7
|
export { ModalFooter } from './ModalFooter';
|
|
6
8
|
export type { ModalAction, ModalFooterProps } from './ModalFooter';
|
package/components/Modal.d.ts
CHANGED
|
@@ -107,9 +107,9 @@ const RadioGroup = (props) => {
|
|
|
107
107
|
const buildSx = (effectiveError) => [
|
|
108
108
|
buildRadioGroupSx({ bordered, borderRadius, error: effectiveError }),
|
|
109
109
|
...presetSx ? [presetSx] : [],
|
|
110
|
-
...Array.isArray(sx) ? sx : [sx]
|
|
110
|
+
...Array.isArray(sx) ? sx : sx ? [sx] : []
|
|
111
111
|
];
|
|
112
|
-
const renderOptions = (
|
|
112
|
+
const renderOptions = (fieldName) => options.map((opt) => {
|
|
113
113
|
var _a2;
|
|
114
114
|
const inputId = (_a2 = opt.id) != null ? _a2 : `${fieldName != null ? fieldName : "radio"}-${opt.value}`;
|
|
115
115
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -125,14 +125,13 @@ const RadioGroup = (props) => {
|
|
|
125
125
|
}
|
|
126
126
|
),
|
|
127
127
|
label: opt.label,
|
|
128
|
-
checked: currentValue === opt.value,
|
|
129
128
|
disabled: disabled || opt.disabled
|
|
130
129
|
},
|
|
131
130
|
inputId
|
|
132
131
|
);
|
|
133
132
|
});
|
|
134
133
|
if ("control" in props && props.control) {
|
|
135
|
-
const { name: name2, control, validation } = props;
|
|
134
|
+
const { name: name2, control, validation, onValueChange } = props;
|
|
136
135
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
137
136
|
reactHookForm.Controller,
|
|
138
137
|
{
|
|
@@ -160,8 +159,11 @@ const RadioGroup = (props) => {
|
|
|
160
159
|
name: field.name,
|
|
161
160
|
value: (_b = field.value) != null ? _b : "",
|
|
162
161
|
onBlur: field.onBlur,
|
|
163
|
-
onChange: (_e, value2) =>
|
|
164
|
-
|
|
162
|
+
onChange: (_e, value2) => {
|
|
163
|
+
field.onChange(value2);
|
|
164
|
+
onValueChange == null ? void 0 : onValueChange(value2);
|
|
165
|
+
},
|
|
166
|
+
children: renderOptions(field.name)
|
|
165
167
|
})
|
|
166
168
|
),
|
|
167
169
|
finalHelperText && /* @__PURE__ */ jsxRuntime.jsx(material.FormHelperText, { children: finalHelperText })
|
|
@@ -189,7 +191,7 @@ const RadioGroup = (props) => {
|
|
|
189
191
|
name,
|
|
190
192
|
value: value != null ? value : "",
|
|
191
193
|
onChange: (_e, next) => onChange(next),
|
|
192
|
-
children: renderOptions(
|
|
194
|
+
children: renderOptions(name)
|
|
193
195
|
})
|
|
194
196
|
),
|
|
195
197
|
helperText && /* @__PURE__ */ jsxRuntime.jsx(material.FormHelperText, { children: helperText })
|