publ-echo 0.0.1
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/README.md +29 -0
- package/bin/cli.js +8 -0
- package/bitbucket-pipelines.yml +35 -0
- package/package.json +51 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/src/App.tsx +28 -0
- package/src/examples/ReactGridLayout/ReactGridLayoutShowcase01.tsx +80 -0
- package/src/examples/ReactGridLayout/index.ts +1 -0
- package/src/examples/ResponsiveGridLayout/ResponsiveGridLayoutShowcase01.tsx +114 -0
- package/src/examples/ResponsiveGridLayout/index.ts +1 -0
- package/src/examples/index.ts +2 -0
- package/src/examples/utils.ts +15 -0
- package/src/index.tsx +21 -0
- package/src/lib/Draggable/Draggable.tsx +303 -0
- package/src/lib/Draggable/DraggableCore.tsx +352 -0
- package/src/lib/Draggable/constants.ts +12 -0
- package/src/lib/Draggable/index.ts +2 -0
- package/src/lib/Draggable/types.ts +74 -0
- package/src/lib/Draggable/utils/domHelpers.ts +284 -0
- package/src/lib/Draggable/utils/getPrefix.ts +42 -0
- package/src/lib/Draggable/utils/positionHelpers.ts +49 -0
- package/src/lib/Draggable/utils/types.ts +41 -0
- package/src/lib/Draggable/utils/validationHelpers.ts +23 -0
- package/src/lib/GridItem/GridItem.tsx +493 -0
- package/src/lib/GridItem/index.ts +1 -0
- package/src/lib/GridItem/types.ts +121 -0
- package/src/lib/GridItem/utils/calculateUtils.ts +173 -0
- package/src/lib/GridLayoutEditor/ReactGridLayout.tsx +662 -0
- package/src/lib/GridLayoutEditor/ResponsiveGridLayout.tsx +204 -0
- package/src/lib/GridLayoutEditor/index.ts +9 -0
- package/src/lib/GridLayoutEditor/styles/styles.css +133 -0
- package/src/lib/GridLayoutEditor/types.ts +199 -0
- package/src/lib/GridLayoutEditor/utils/renderHelpers.ts +737 -0
- package/src/lib/GridLayoutEditor/utils/responsiveUtils.ts +111 -0
- package/src/lib/PreviewGLE/ReactGridLayoutPreview.tsx +46 -0
- package/src/lib/PreviewGLE/ResponsiveGridLayoutPreview.tsx +54 -0
- package/src/lib/PreviewGLE/index.ts +2 -0
- package/src/lib/Resizable/Resizable.tsx +323 -0
- package/src/lib/Resizable/ResizableBox.tsx +109 -0
- package/src/lib/Resizable/index.ts +1 -0
- package/src/lib/Resizable/styles/styles.css +76 -0
- package/src/lib/Resizable/types.ts +96 -0
- package/src/lib/Resizable/utils/cloneElement.ts +15 -0
- package/src/lib/components/WidthProvider.tsx +71 -0
- package/src/lib/components/index.ts +1 -0
- package/src/lib/components/types.ts +19 -0
- package/src/lib/index.ts +4 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/reportWebVitals.ts +15 -0
- package/src/setupTests.ts +5 -0
- package/src/utils/types.ts +3 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
.react-resizable {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.react-resizable-handle {
|
|
6
|
+
position: absolute;
|
|
7
|
+
width: 20px;
|
|
8
|
+
height: 20px;
|
|
9
|
+
background-repeat: no-repeat;
|
|
10
|
+
background-origin: content-box;
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+");
|
|
13
|
+
background-position: bottom right;
|
|
14
|
+
padding: 0 3px 3px 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.react-resizable-handle-sw {
|
|
18
|
+
bottom: 0;
|
|
19
|
+
left: 0;
|
|
20
|
+
cursor: sw-resize;
|
|
21
|
+
transform: rotate(90deg);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.react-resizable-handle-se {
|
|
25
|
+
bottom: 0;
|
|
26
|
+
right: 0;
|
|
27
|
+
cursor: se-resize;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.react-resizable-handle-nw {
|
|
31
|
+
top: 0;
|
|
32
|
+
left: 0;
|
|
33
|
+
cursor: nw-resize;
|
|
34
|
+
transform: rotate(180deg);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.react-resizable-handle-ne {
|
|
38
|
+
top: 0;
|
|
39
|
+
right: 0;
|
|
40
|
+
cursor: ne-resize;
|
|
41
|
+
transform: rotate(270deg);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.react-resizable-handle-w,
|
|
45
|
+
.react-resizable-handle-e {
|
|
46
|
+
top: 50%;
|
|
47
|
+
margin-top: -10px;
|
|
48
|
+
cursor: ew-resize;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.react-resizable-handle-w {
|
|
52
|
+
left: 0;
|
|
53
|
+
transform: rotate(135deg);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.react-resizable-handle-e {
|
|
57
|
+
right: 0;
|
|
58
|
+
transform: rotate(315deg);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.react-resizable-handle-n,
|
|
62
|
+
.react-resizable-handle-s {
|
|
63
|
+
left: 50%;
|
|
64
|
+
margin-left: -10px;
|
|
65
|
+
cursor: ns-resize;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.react-resizable-handle-n {
|
|
69
|
+
top: 0;
|
|
70
|
+
transform: rotate(225deg);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.react-resizable-handle-s {
|
|
74
|
+
bottom: 0;
|
|
75
|
+
transform: rotate(45deg);
|
|
76
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { CSSProperties, ReactElement, Ref, SyntheticEvent } from "react";
|
|
2
|
+
import { DraggableCoreDefaultProps } from "../Draggable/types";
|
|
3
|
+
|
|
4
|
+
export type ReactRef<T> = {
|
|
5
|
+
current: T | null;
|
|
6
|
+
};
|
|
7
|
+
export type Axis = "both" | "x" | "y" | "none";
|
|
8
|
+
export type ResizeHandleAxis =
|
|
9
|
+
| "s"
|
|
10
|
+
| "w"
|
|
11
|
+
| "e"
|
|
12
|
+
| "n"
|
|
13
|
+
| "sw"
|
|
14
|
+
| "nw"
|
|
15
|
+
| "se"
|
|
16
|
+
| "ne";
|
|
17
|
+
export type ResizableBoxState = {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
propsWidth: number;
|
|
21
|
+
propsHeight: number;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type DragCallbackData = {
|
|
25
|
+
node: HTMLElement;
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
deltaX: number;
|
|
29
|
+
deltaY: number;
|
|
30
|
+
lastX: number;
|
|
31
|
+
lastY: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type ResizeCallbackData = {
|
|
35
|
+
node: HTMLElement;
|
|
36
|
+
size: { width: number; height: number; top: number; left: number };
|
|
37
|
+
handle: ResizeHandleAxis;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// <Resizable>
|
|
41
|
+
export type ResizableDefaultProps = {
|
|
42
|
+
axis: Axis;
|
|
43
|
+
handleSize: [number, number];
|
|
44
|
+
lockAspectRatio: boolean;
|
|
45
|
+
minConstraints: [number, number];
|
|
46
|
+
maxConstraints: [number, number];
|
|
47
|
+
resizeHandles: ResizeHandleAxis[];
|
|
48
|
+
transformScale: number;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type ResizableProps = {
|
|
52
|
+
top?: number;
|
|
53
|
+
left?: number;
|
|
54
|
+
children?: ReactElement<any>;
|
|
55
|
+
axis?: Axis;
|
|
56
|
+
className?: string;
|
|
57
|
+
draggableOpts?: Partial<DraggableCoreDefaultProps>;
|
|
58
|
+
handle?: ResizeHandleType;
|
|
59
|
+
onResizeStop?: (e: SyntheticEvent<any>, data: ResizeCallbackData) => any;
|
|
60
|
+
onResizeStart?: (e: SyntheticEvent<any>, data: ResizeCallbackData) => any;
|
|
61
|
+
onResize?: (e: SyntheticEvent<any>, data: ResizeCallbackData) => any;
|
|
62
|
+
handleSize?: [number, number];
|
|
63
|
+
lockAspectRatio?: boolean;
|
|
64
|
+
minConstraints?: [number, number];
|
|
65
|
+
maxConstraints?: [number, number];
|
|
66
|
+
resizeHandles?: ResizeHandleAxis[];
|
|
67
|
+
transformScale?: number;
|
|
68
|
+
style?: CSSProperties;
|
|
69
|
+
width: number;
|
|
70
|
+
height: number;
|
|
71
|
+
};
|
|
72
|
+
// react-draggable에서는 아래와 같은 타입입니다. 현재 echo에서는 width와 height를 필수값입니다.
|
|
73
|
+
// & (
|
|
74
|
+
// | {
|
|
75
|
+
// width: number;
|
|
76
|
+
// height?: number;
|
|
77
|
+
// axis: "x";
|
|
78
|
+
// }
|
|
79
|
+
// | {
|
|
80
|
+
// width?: number;
|
|
81
|
+
// height: number;
|
|
82
|
+
// axis: "y";
|
|
83
|
+
// }
|
|
84
|
+
// | {
|
|
85
|
+
// width: number;
|
|
86
|
+
// height: number;
|
|
87
|
+
// axis?: "both";
|
|
88
|
+
// }
|
|
89
|
+
// );
|
|
90
|
+
|
|
91
|
+
export type ResizeHandleType =
|
|
92
|
+
| ReactElement<any>
|
|
93
|
+
| ((
|
|
94
|
+
resizeHandleAxis: ResizeHandleAxis,
|
|
95
|
+
ref: Ref<HTMLElement>
|
|
96
|
+
) => ReactElement<any>);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { PropsWithChildren, ReactElement } from "react";
|
|
2
|
+
|
|
3
|
+
export function cloneElement(
|
|
4
|
+
element: ReactElement<any>,
|
|
5
|
+
props: PropsWithChildren<any>
|
|
6
|
+
): ReactElement<any> {
|
|
7
|
+
if (props.style && element.props.style) {
|
|
8
|
+
props.style = { ...element.props.style, ...props.style };
|
|
9
|
+
}
|
|
10
|
+
if (props.className && element.props.className) {
|
|
11
|
+
props.className = `${element.props.className} ${props.className}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return React.cloneElement(element, props);
|
|
15
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import React, { useRef, useState, useEffect } from "react";
|
|
4
|
+
|
|
5
|
+
type WPState = {
|
|
6
|
+
width: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type ComposedProps<Config> = {
|
|
10
|
+
measureBeforeMount?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: Object;
|
|
13
|
+
width?: number;
|
|
14
|
+
} & Config;
|
|
15
|
+
|
|
16
|
+
const layoutClassName = "react-grid-layout";
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* A simple HOC that provides facility for listening to container resizes.
|
|
20
|
+
*/
|
|
21
|
+
const WidthProvider = <Config,>(
|
|
22
|
+
ComposedComponent: React.ComponentType<Config>
|
|
23
|
+
) => {
|
|
24
|
+
return (props: ComposedProps<Config>) => {
|
|
25
|
+
const elementRef = useRef<HTMLDivElement>(null);
|
|
26
|
+
const mounted = useRef(false);
|
|
27
|
+
const [state, setState] = useState<WPState>({
|
|
28
|
+
width: props.width ?? 1280,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const { measureBeforeMount = false } = props;
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (mounted.current) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
mounted.current = true;
|
|
38
|
+
|
|
39
|
+
window.addEventListener("resize", onWindowResize);
|
|
40
|
+
|
|
41
|
+
onWindowResize();
|
|
42
|
+
return () => {
|
|
43
|
+
mounted.current = false;
|
|
44
|
+
window.removeEventListener("resize", onWindowResize);
|
|
45
|
+
};
|
|
46
|
+
}, []);
|
|
47
|
+
|
|
48
|
+
const onWindowResize = () => {
|
|
49
|
+
if (!mounted.current) return;
|
|
50
|
+
const node = elementRef.current;
|
|
51
|
+
|
|
52
|
+
if (node instanceof HTMLElement && node.offsetWidth) {
|
|
53
|
+
setState({ width: node.offsetWidth });
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
if (measureBeforeMount && !mounted.current) {
|
|
58
|
+
return (
|
|
59
|
+
<div
|
|
60
|
+
className={classNames(props.className, layoutClassName)}
|
|
61
|
+
style={props.style}
|
|
62
|
+
ref={elementRef}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return <ComposedComponent {...props} innerRef={elementRef} {...state} />;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default WidthProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as WidthProvider } from "./WidthProvider";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
|
|
3
|
+
export type WidthProviderProps = {
|
|
4
|
+
measureBeforeMount: boolean;
|
|
5
|
+
className?: string;
|
|
6
|
+
style?: Object;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type WidthProviderState = {
|
|
10
|
+
width: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type WidthProviderRef = {
|
|
14
|
+
innerRef?: RefObject<HTMLDivElement>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type ComposedProps = WidthProviderProps &
|
|
18
|
+
WidthProviderState &
|
|
19
|
+
WidthProviderRef;
|
package/src/lib/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="react-scripts" />
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReportHandler } from 'web-vitals';
|
|
2
|
+
|
|
3
|
+
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
|
4
|
+
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
5
|
+
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
|
6
|
+
getCLS(onPerfEntry);
|
|
7
|
+
getFID(onPerfEntry);
|
|
8
|
+
getFCP(onPerfEntry);
|
|
9
|
+
getLCP(onPerfEntry);
|
|
10
|
+
getTTFB(onPerfEntry);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default reportWebVitals;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"lib": [
|
|
5
|
+
"dom",
|
|
6
|
+
"dom.iterable",
|
|
7
|
+
"esnext"
|
|
8
|
+
],
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"allowSyntheticDefaultImports": true,
|
|
13
|
+
"strict": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"noFallthroughCasesInSwitch": true,
|
|
16
|
+
"module": "esnext",
|
|
17
|
+
"moduleResolution": "node",
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"isolatedModules": true,
|
|
20
|
+
"noEmit": true,
|
|
21
|
+
"jsx": "react-jsx"
|
|
22
|
+
},
|
|
23
|
+
"include": [
|
|
24
|
+
"src"
|
|
25
|
+
]
|
|
26
|
+
}
|