ehscan-react-components 0.1.14 → 0.1.15
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/Window.d.ts +1 -0
- package/dist/Window.js +1 -81
- package/package.json +1 -1
package/dist/Window.d.ts
CHANGED
package/dist/Window.js
CHANGED
|
@@ -1,87 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// import React, { useRef, useEffect, useState } from "react";
|
|
3
|
-
// import { useDraggable } from "./tools/useDraggable"; // adjust path as needed
|
|
4
|
-
// export interface WindowProps {
|
|
5
|
-
// trackMove?: (args?: any) => void;
|
|
6
|
-
// open: boolean;
|
|
7
|
-
// initialPosition?: { x: number; y: number };
|
|
8
|
-
// initialWidth?: number;
|
|
9
|
-
// initialBodyPadding?: number;
|
|
10
|
-
// header?: React.ReactNode;
|
|
11
|
-
// body?: React.ReactNode;
|
|
12
|
-
// footer?: React.ReactNode;
|
|
13
|
-
// onClose?: () => void;
|
|
14
|
-
// }
|
|
15
|
-
// export default function Window({
|
|
16
|
-
// trackMove,
|
|
17
|
-
// open,
|
|
18
|
-
// initialPosition = { x: 600, y: 100 },
|
|
19
|
-
// initialWidth = 400,
|
|
20
|
-
// initialBodyPadding = 20,
|
|
21
|
-
// header,
|
|
22
|
-
// body,
|
|
23
|
-
// footer,
|
|
24
|
-
// onClose,
|
|
25
|
-
// }: WindowProps) {
|
|
26
|
-
// const targetRef = useRef<HTMLDivElement>(null);
|
|
27
|
-
// const headerRef = useRef<HTMLDivElement>(null);
|
|
28
|
-
// const resizeHandleRef = useRef<HTMLDivElement>(null);
|
|
29
|
-
// const bodyRef = useRef<HTMLDivElement>(null);
|
|
30
|
-
// const footerRef = useRef<HTMLDivElement>(null);
|
|
31
|
-
// const [maxHeight] = useState("auto");
|
|
32
|
-
// const [bodyPadding] = useState(initialBodyPadding);
|
|
33
|
-
// const [windowWidth] = useState(initialWidth);
|
|
34
|
-
// useDraggable(open, targetRef, headerRef, bodyRef, resizeHandleRef, bodyPadding, trackMove);
|
|
35
|
-
// useEffect(() => { //init
|
|
36
|
-
// if (!bodyRef.current || !targetRef.current || !headerRef.current) return;
|
|
37
|
-
// const headerHeight = headerRef.current.offsetHeight;
|
|
38
|
-
// const topPosition = targetRef.current.getBoundingClientRect().top;
|
|
39
|
-
// const availableHeight = window.innerHeight - topPosition - 20; // 20px bottom margin
|
|
40
|
-
// const bodyMaxHeight = Math.max(100, availableHeight - headerHeight - 2 * bodyPadding);
|
|
41
|
-
// bodyRef.current.style.maxHeight = `${bodyMaxHeight}px`;
|
|
42
|
-
// bodyRef.current.style.overflowY = "auto";
|
|
43
|
-
// }, [bodyPadding]);
|
|
44
|
-
// const [fadeIn, setFadeIn] = useState(false)
|
|
45
|
-
// useEffect(() => {
|
|
46
|
-
// if (open === undefined) return;
|
|
47
|
-
// setTimeout(() => {
|
|
48
|
-
// setFadeIn(open)
|
|
49
|
-
// }, 0)
|
|
50
|
-
// }, [open])
|
|
51
|
-
// if (!open) return null;
|
|
52
|
-
// return (
|
|
53
|
-
// <div ref={targetRef} className={`ext-window${fadeIn ? ' fadein' : ''}`} style={{ left: `${initialPosition.x}px`, top: `${initialPosition.y}px`, minWidth: `${windowWidth}px` }}>
|
|
54
|
-
// {/* Header */}
|
|
55
|
-
// <div ref={headerRef} className="ext-window-header">
|
|
56
|
-
// {header ?? (
|
|
57
|
-
// <>
|
|
58
|
-
// <div className="ext-window-drag-handle">||</div>
|
|
59
|
-
// <div className="ext-window-header-title">Header</div>
|
|
60
|
-
// <div onClick={onClose}>close</div>
|
|
61
|
-
// </>
|
|
62
|
-
// )}
|
|
63
|
-
// </div>
|
|
64
|
-
// {/* Body */}
|
|
65
|
-
// <div
|
|
66
|
-
// ref={bodyRef}
|
|
67
|
-
// className="ext-window-body _ewb"
|
|
68
|
-
// style={{ padding: `${bodyPadding}px` }}
|
|
69
|
-
// >
|
|
70
|
-
// {body ?? <>Body</>}
|
|
71
|
-
// </div>
|
|
72
|
-
// {/* Footer */}
|
|
73
|
-
// {footer && (
|
|
74
|
-
// <div ref={footerRef} className="ext-window-footer">
|
|
75
|
-
// {footer}
|
|
76
|
-
// </div>
|
|
77
|
-
// )}
|
|
78
|
-
// {/* Resize handle */}
|
|
79
|
-
// <div className="resize-handle" ref={resizeHandleRef} />
|
|
80
|
-
// </div>
|
|
81
|
-
// );
|
|
82
|
-
// }
|
|
83
2
|
import { useRef, useEffect, useState } from "react";
|
|
84
3
|
import { useDraggable } from "./tools/useDraggable"; // adjust path as needed
|
|
4
|
+
import './style/window.css';
|
|
85
5
|
export const Window = ({ trackMove, open, initialPosition = { x: 600, y: 100 }, initialWidth = 400, initialBodyPadding = 20, header, body, footer, onClose, }) => {
|
|
86
6
|
const targetRef = useRef(null);
|
|
87
7
|
const headerRef = useRef(null);
|