publ-echo 0.0.19 → 0.0.21
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.
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ReactElement } from "react";
|
|
1
3
|
import { PropsWithChildren } from "../types";
|
|
2
4
|
import { ReactGridLayoutProps } from "./types";
|
|
3
|
-
declare const ReactGridLayout: ({ children, ...props }: PropsWithChildren<ReactGridLayoutProps>) =>
|
|
5
|
+
declare const ReactGridLayout: ({ children, ...props }: PropsWithChildren<ReactGridLayoutProps>) => React.ReactElement;
|
|
4
6
|
export default ReactGridLayout;
|
|
@@ -26,26 +26,36 @@ var WidthProvider = function (ComposedComponent) {
|
|
|
26
26
|
width: (_a = props.width) !== null && _a !== void 0 ? _a : 1280,
|
|
27
27
|
}), state = _b[0], setState = _b[1];
|
|
28
28
|
var _c = props.measureBeforeMount, measureBeforeMount = _c === void 0 ? false : _c;
|
|
29
|
+
// useEffect(() => {
|
|
30
|
+
// if (mounted.current) {
|
|
31
|
+
// return;
|
|
32
|
+
// }
|
|
33
|
+
// mounted.current = true;
|
|
34
|
+
// window.addEventListener("resize", onWindowResize);
|
|
35
|
+
// onWindowResize();
|
|
36
|
+
// return () => {
|
|
37
|
+
// mounted.current = false;
|
|
38
|
+
// window.removeEventListener("resize", onWindowResize);
|
|
39
|
+
// };
|
|
40
|
+
// }, []);
|
|
29
41
|
useEffect(function () {
|
|
30
|
-
if (
|
|
42
|
+
if (!elementRef.current)
|
|
31
43
|
return;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
};
|
|
44
|
+
var resizeObserver = new ResizeObserver(function (callback) {
|
|
45
|
+
var object = callback[0];
|
|
46
|
+
var width = object.contentRect.width;
|
|
47
|
+
setState({ width: width });
|
|
48
|
+
});
|
|
49
|
+
resizeObserver.observe(elementRef.current);
|
|
50
|
+
return function () { return resizeObserver.disconnect(); };
|
|
51
|
+
}, [elementRef]);
|
|
52
|
+
// const onWindowResize = () => {
|
|
53
|
+
// if (!mounted.current) return;
|
|
54
|
+
// const node = elementRef.current;
|
|
55
|
+
// if (node instanceof HTMLElement && node.offsetWidth) {
|
|
56
|
+
// setState({ width: node.offsetWidth });
|
|
57
|
+
// }
|
|
58
|
+
// };
|
|
49
59
|
if (measureBeforeMount && !mounted.current) {
|
|
50
60
|
return (_jsx("div", { className: classNames(props.className, layoutClassName), style: props.style, ref: elementRef }));
|
|
51
61
|
}
|