@kreativa/ui 0.1.4 → 0.1.5
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/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -84,8 +84,9 @@ interface ModalProps {
|
|
|
84
84
|
/**
|
|
85
85
|
* Modal component for displaying content in an overlay dialog.
|
|
86
86
|
* Handles backdrop click and Escape key to close.
|
|
87
|
+
* Uses a portal to render at document body level for proper overlay positioning.
|
|
87
88
|
*/
|
|
88
|
-
declare function Modal({ isOpen, onClose, title, children, maxWidth }: ModalProps):
|
|
89
|
+
declare function Modal({ isOpen, onClose, title, children, maxWidth }: ModalProps): react.ReactPortal | null;
|
|
89
90
|
|
|
90
91
|
interface FormInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
91
92
|
/** Label text displayed above the input */
|
package/dist/index.d.ts
CHANGED
|
@@ -84,8 +84,9 @@ interface ModalProps {
|
|
|
84
84
|
/**
|
|
85
85
|
* Modal component for displaying content in an overlay dialog.
|
|
86
86
|
* Handles backdrop click and Escape key to close.
|
|
87
|
+
* Uses a portal to render at document body level for proper overlay positioning.
|
|
87
88
|
*/
|
|
88
|
-
declare function Modal({ isOpen, onClose, title, children, maxWidth }: ModalProps):
|
|
89
|
+
declare function Modal({ isOpen, onClose, title, children, maxWidth }: ModalProps): react.ReactPortal | null;
|
|
89
90
|
|
|
90
91
|
interface FormInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
91
92
|
/** Label text displayed above the input */
|
package/dist/index.js
CHANGED
|
@@ -203,6 +203,7 @@ function EmptyState({ icon, title, description, action }) {
|
|
|
203
203
|
|
|
204
204
|
// src/components/Modal.tsx
|
|
205
205
|
var import_react2 = require("react");
|
|
206
|
+
var import_react_dom = require("react-dom");
|
|
206
207
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
207
208
|
var maxWidthClasses = {
|
|
208
209
|
sm: "max-w-sm",
|
|
@@ -212,6 +213,10 @@ var maxWidthClasses = {
|
|
|
212
213
|
"2xl": "max-w-2xl"
|
|
213
214
|
};
|
|
214
215
|
function Modal({ isOpen, onClose, title, children, maxWidth = "xl" }) {
|
|
216
|
+
const [mounted, setMounted] = (0, import_react2.useState)(false);
|
|
217
|
+
(0, import_react2.useEffect)(() => {
|
|
218
|
+
setMounted(true);
|
|
219
|
+
}, []);
|
|
215
220
|
(0, import_react2.useEffect)(() => {
|
|
216
221
|
const handleEscape = (e) => {
|
|
217
222
|
if (e.key === "Escape") {
|
|
@@ -227,8 +232,8 @@ function Modal({ isOpen, onClose, title, children, maxWidth = "xl" }) {
|
|
|
227
232
|
document.body.style.overflow = "";
|
|
228
233
|
};
|
|
229
234
|
}, [isOpen, onClose]);
|
|
230
|
-
if (!isOpen) return null;
|
|
231
|
-
|
|
235
|
+
if (!isOpen || !mounted) return null;
|
|
236
|
+
const modalContent = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
232
237
|
"div",
|
|
233
238
|
{
|
|
234
239
|
className: "fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",
|
|
@@ -249,6 +254,7 @@ function Modal({ isOpen, onClose, title, children, maxWidth = "xl" }) {
|
|
|
249
254
|
)
|
|
250
255
|
}
|
|
251
256
|
);
|
|
257
|
+
return (0, import_react_dom.createPortal)(modalContent, document.body);
|
|
252
258
|
}
|
|
253
259
|
|
|
254
260
|
// src/components/FormInput.tsx
|