UNPKG

infinity-forge

Version:
58 lines 3.83 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Modal = Modal; var jsx_runtime_1 = require("react/jsx-runtime"); var overlay_1 = require("../overlay/index.js"); var icons_1 = require("../../../ui/icons/index.js"); var hooks_1 = require("../../../ui/hooks/index.js"); var S = __importStar(require("./styles.js")); function Modal(_a) { var open = _a.open, onClose = _a.onClose, title = _a.title, children = _a.children, actions = _a.actions, message = _a.message, _b = _a.confirmText, confirmText = _b === void 0 ? 'Confirmar' : _b, onConfirm = _a.onConfirm, _c = _a.cancelText, cancelText = _c === void 0 ? 'Cancelar' : _c, onCancel = _a.onCancel, styles = _a.styles, hideCloseButton = _a.hideCloseButton, stylesContent = _a.stylesContent; var shouldRender = (0, hooks_1.useMountTransition)(open, 300); function handleConfirm() { onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(); } function handleCancel() { onCancel === null || onCancel === void 0 ? void 0 : onCancel(); onClose(); } if (!shouldRender) return null; return ((0, jsx_runtime_1.jsx)(overlay_1.Overlay, { onClick: handleCancel, isExiting: !open, children: (0, jsx_runtime_1.jsxs)(S.Modal, { style: styles, "$isExiting": !open, className: 'modal-content', onClick: function (e) { e.stopPropagation(); }, children: [(title || !hideCloseButton) && ((0, jsx_runtime_1.jsxs)("h2", { className: 'title', children: [(0, jsx_runtime_1.jsx)("span", { className: 'title_content', children: title && title }), !hideCloseButton && ((0, jsx_runtime_1.jsx)("button", { className: 'close-button', type: 'button', onClick: onClose, children: (0, jsx_runtime_1.jsx)(icons_1.Icon, { name: 'IconClose' }) }))] })), (0, jsx_runtime_1.jsxs)("div", { style: stylesContent, className: 'content_modal_infinity_forge', children: [message && (0, jsx_runtime_1.jsx)("p", { className: 'message', children: message }), children, actions && ((0, jsx_runtime_1.jsxs)("div", { className: 'actions_modal_infinity_forge', children: [onCancel && (0, jsx_runtime_1.jsx)("button", { onClick: handleCancel, children: cancelText }), onConfirm && (0, jsx_runtime_1.jsx)("button", { onClick: handleConfirm, children: confirmText }), actions && (0, jsx_runtime_1.jsx)("div", { className: 'custom_actions_modal_infinity_forge', children: actions })] }))] })] }) })); } //# sourceMappingURL=component.js.map