hi-tm 0.21.3 → 0.21.4
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.
|
@@ -12,7 +12,8 @@ interface DeleteConfirmationModalProps {
|
|
|
12
12
|
btnText: string;
|
|
13
13
|
btnDeleteText: string;
|
|
14
14
|
type: 'submit' | 'button';
|
|
15
|
+
/** Kept for backward compatibility; the cancel button now has a fixed neutral style. */
|
|
15
16
|
buttonClassStyle: 'dangerBtn' | 'successBtn' | 'warningBtn' | 'infoBtn' | 'primaryBtn' | 'secondaryBtn';
|
|
16
17
|
}
|
|
17
|
-
declare const DeleteConfirmationModal: ({ isOpen, onClose, onConfirm,
|
|
18
|
+
declare const DeleteConfirmationModal: ({ isOpen, onClose, onConfirm, btnDisabled, btnText, type, text, btnDeleteText, }: DeleteConfirmationModalProps) => React.JSX.Element | null;
|
|
18
19
|
export default DeleteConfirmationModal;
|
|
@@ -32,37 +32,60 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const Button_1 = __importDefault(require("../../../components/Inputs/Buttons/Button"));
|
|
40
36
|
const react_1 = __importStar(require("react"));
|
|
41
|
-
const DeleteConfirmationModal = ({ isOpen, onClose, onConfirm,
|
|
37
|
+
const DeleteConfirmationModal = ({ isOpen, onClose, onConfirm, btnDisabled, btnText, type, text, btnDeleteText, }) => {
|
|
42
38
|
const modalRef = (0, react_1.useRef)(null);
|
|
39
|
+
const cancelRef = (0, react_1.useRef)(null);
|
|
40
|
+
const [isVisible, setIsVisible] = (0, react_1.useState)(false);
|
|
41
|
+
const titleId = (0, react_1.useId)();
|
|
42
|
+
const descriptionId = (0, react_1.useId)();
|
|
43
|
+
// Keep the latest onClose without re-binding listeners on every parent render.
|
|
44
|
+
const onCloseRef = (0, react_1.useRef)(onClose);
|
|
45
|
+
onCloseRef.current = onClose;
|
|
43
46
|
(0, react_1.useEffect)(() => {
|
|
47
|
+
if (!isOpen) {
|
|
48
|
+
setIsVisible(false);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const frame = requestAnimationFrame(() => setIsVisible(true));
|
|
52
|
+
cancelRef.current?.focus();
|
|
53
|
+
const previousOverflow = document.body.style.overflow;
|
|
54
|
+
document.body.style.overflow = 'hidden';
|
|
44
55
|
const handleClickOutside = (event) => {
|
|
45
56
|
if (modalRef.current && !modalRef.current.contains(event.target)) {
|
|
46
|
-
|
|
57
|
+
onCloseRef.current();
|
|
47
58
|
}
|
|
48
59
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
const handleKeyDown = (event) => {
|
|
61
|
+
if (event.key === 'Escape')
|
|
62
|
+
onCloseRef.current();
|
|
63
|
+
};
|
|
64
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
65
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
52
66
|
return () => {
|
|
67
|
+
cancelAnimationFrame(frame);
|
|
68
|
+
document.body.style.overflow = previousOverflow;
|
|
53
69
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
70
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
54
71
|
};
|
|
55
|
-
}, [isOpen
|
|
72
|
+
}, [isOpen]);
|
|
56
73
|
if (!isOpen)
|
|
57
74
|
return null;
|
|
58
|
-
return (react_1.default.createElement("div", { className:
|
|
59
|
-
react_1.default.createElement("div", { ref: modalRef,
|
|
60
|
-
react_1.default.createElement("
|
|
61
|
-
" ",
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
return (react_1.default.createElement("div", { className: `fixed inset-0 z-[9999] flex items-center justify-center bg-[#212121]/30 p-4 backdrop-blur-[2px] transition-opacity duration-200 ${isVisible ? 'opacity-100' : 'opacity-0'}` },
|
|
76
|
+
react_1.default.createElement("div", { ref: modalRef, role: "alertdialog", "aria-modal": "true", "aria-labelledby": titleId, "aria-describedby": descriptionId, className: `w-full max-w-sm rounded-2xl border border-[#E9E9F0] bg-white p-6 shadow-[0_12px_40px_rgba(75,77,98,0.18)] transition-all duration-200 ease-out ${isVisible ? 'translate-y-0 scale-100 opacity-100' : 'translate-y-2 scale-95 opacity-0'}` },
|
|
77
|
+
react_1.default.createElement("div", { className: "flex flex-col items-center text-center" },
|
|
78
|
+
react_1.default.createElement("div", { className: "mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-[#f7ddd8]" },
|
|
79
|
+
react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", className: "h-7 w-7 text-[#ba2520]", "aria-hidden": "true" },
|
|
80
|
+
react_1.default.createElement("path", { d: "M3 6h18" }),
|
|
81
|
+
react_1.default.createElement("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }),
|
|
82
|
+
react_1.default.createElement("path", { d: "M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6" }),
|
|
83
|
+
react_1.default.createElement("path", { d: "M10 11v6" }),
|
|
84
|
+
react_1.default.createElement("path", { d: "M14 11v6" }))),
|
|
85
|
+
react_1.default.createElement("h3", { id: titleId, className: "mb-2 text-lg font-bold text-[#212121]" }, text.titleText),
|
|
86
|
+
react_1.default.createElement("div", { id: descriptionId, className: "text-sm leading-7 text-[#737589]" }, text.confirmationText)),
|
|
87
|
+
react_1.default.createElement("div", { className: "mt-6 flex gap-3" },
|
|
88
|
+
react_1.default.createElement("button", { ref: cancelRef, type: type, disabled: btnDisabled, onClick: onClose, className: "h-11 flex-1 rounded-xl border border-[#E9E9F0] bg-white text-sm font-medium text-[#4B4D62] transition-colors hover:bg-[#F5F6F9] focus:outline-none focus-visible:ring-2 focus-visible:ring-[#d1d5db] focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50" }, btnText),
|
|
89
|
+
react_1.default.createElement("button", { type: "button", disabled: btnDisabled, onClick: onConfirm, className: "h-11 flex-1 rounded-xl bg-[#ba2520] text-sm font-medium text-white transition-colors hover:bg-[#9e1f1b] focus:outline-none focus-visible:ring-2 focus-visible:ring-[#ba2520]/40 focus-visible:ring-offset-2 active:bg-[#861a17] disabled:cursor-not-allowed disabled:opacity-50" }, btnDeleteText)))));
|
|
67
90
|
};
|
|
68
91
|
exports.default = DeleteConfirmationModal;
|