publ-echo 0.1.0
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/package.json +66 -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/examples/Showcase.tsx +71 -0
- package/src/examples/Showcase01.tsx +7 -0
- package/src/examples/utils.ts +15 -0
- package/src/index.tsx +30 -0
- package/src/lib/Draggable/Draggable.tsx +19 -0
- package/src/lib/GridItem/GridItem.tsx +7 -0
- package/src/lib/GridItem/types.ts +38 -0
- package/src/lib/GridItemTemp.tsx +36 -0
- package/src/lib/RGLTemp.tsx +30 -0
- package/src/lib/ReactGridLayout.tsx +8 -0
- package/src/lib/ReactGridLayoutTypes.ts +86 -0
- package/src/lib/Resizable/Resizable.tsx +42 -0
- package/src/lib/ResponsiveReactGridLayout.tsx +54 -0
- package/src/lib/index.ts +2 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/reportWebVitals.ts +15 -0
- package/src/setupTests.ts +5 -0
- package/tsconfig.json +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# README #
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get your application up and running.
|
|
4
|
+
|
|
5
|
+
### What is this repository for? ###
|
|
6
|
+
|
|
7
|
+
* Quick summary
|
|
8
|
+
* Version
|
|
9
|
+
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
|
10
|
+
|
|
11
|
+
### How do I get set up? ###
|
|
12
|
+
|
|
13
|
+
* Summary of set up
|
|
14
|
+
* Configuration
|
|
15
|
+
* Dependencies
|
|
16
|
+
* Database configuration
|
|
17
|
+
* How to run tests
|
|
18
|
+
* Deployment instructions
|
|
19
|
+
|
|
20
|
+
### Contribution guidelines ###
|
|
21
|
+
|
|
22
|
+
* Writing tests
|
|
23
|
+
* Code review
|
|
24
|
+
* Other guidelines
|
|
25
|
+
|
|
26
|
+
### Who do I talk to? ###
|
|
27
|
+
|
|
28
|
+
* Repo owner or admin
|
|
29
|
+
* Other community or team contact
|
package/bin/cli.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "publ-echo",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
7
|
+
"@testing-library/react": "^13.4.0",
|
|
8
|
+
"@testing-library/user-event": "^13.5.0",
|
|
9
|
+
"@types/jest": "^27.5.2",
|
|
10
|
+
"@types/node": "^16.18.32",
|
|
11
|
+
"@types/react": "^18.2.6",
|
|
12
|
+
"@types/react-dom": "^18.2.4",
|
|
13
|
+
"commander": "^10.0.1",
|
|
14
|
+
"react": "^18.2.0",
|
|
15
|
+
"react-dom": "^18.2.0",
|
|
16
|
+
"react-scripts": "5.0.1",
|
|
17
|
+
"typescript": "^4.9.5",
|
|
18
|
+
"web-vitals": "^2.1.4"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"start": "react-scripts start",
|
|
22
|
+
"build": "react-scripts build",
|
|
23
|
+
"test": "react-scripts test",
|
|
24
|
+
"eject": "react-scripts eject"
|
|
25
|
+
},
|
|
26
|
+
"eslintConfig": {
|
|
27
|
+
"extends": [
|
|
28
|
+
"react-app",
|
|
29
|
+
"react-app/jest"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"browserslist": {
|
|
33
|
+
"production": [
|
|
34
|
+
">0.2%",
|
|
35
|
+
"not dead",
|
|
36
|
+
"not op_mini all"
|
|
37
|
+
],
|
|
38
|
+
"development": [
|
|
39
|
+
"last 1 chrome version",
|
|
40
|
+
"last 1 firefox version",
|
|
41
|
+
"last 1 safari version"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/lodash": "^4.14.194",
|
|
46
|
+
"@types/styled-components": "^5.1.26",
|
|
47
|
+
"lodash": "^4.17.21",
|
|
48
|
+
"styled-components": "^5.3.10"
|
|
49
|
+
},
|
|
50
|
+
"description": "This README would normally document whatever steps are necessary to get your application up and running.",
|
|
51
|
+
"main": "index.js",
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+ssh://git@bitbucket.org/publ-kit/publ-echo.git"
|
|
55
|
+
},
|
|
56
|
+
"keywords": [],
|
|
57
|
+
"author": "",
|
|
58
|
+
"bin": {
|
|
59
|
+
"log-run": "bin/cli.js"
|
|
60
|
+
},
|
|
61
|
+
"license": "ISC",
|
|
62
|
+
"bugs": {
|
|
63
|
+
"url": "https://bitbucket.org/publ-kit/publ-echo/issues"
|
|
64
|
+
},
|
|
65
|
+
"homepage": "https://bitbucket.org/publ-kit/publ-echo#readme"
|
|
66
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<meta name="theme-color" content="#000000" />
|
|
8
|
+
<meta
|
|
9
|
+
name="description"
|
|
10
|
+
content="Web site created using create-react-app"
|
|
11
|
+
/>
|
|
12
|
+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
13
|
+
<!--
|
|
14
|
+
manifest.json provides metadata used when your web app is installed on a
|
|
15
|
+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
16
|
+
-->
|
|
17
|
+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
18
|
+
<!--
|
|
19
|
+
Notice the use of %PUBLIC_URL% in the tags above.
|
|
20
|
+
It will be replaced with the URL of the `public` folder during the build.
|
|
21
|
+
Only files inside the `public` folder can be referenced from the HTML.
|
|
22
|
+
|
|
23
|
+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
24
|
+
work correctly both with client-side routing and a non-root public URL.
|
|
25
|
+
Learn how to configure a non-root public URL by running `npm run build`.
|
|
26
|
+
-->
|
|
27
|
+
<title>React App</title>
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
31
|
+
<div id="root"></div>
|
|
32
|
+
<!--
|
|
33
|
+
This HTML file is a template.
|
|
34
|
+
If you open it directly in the browser, you will see an empty page.
|
|
35
|
+
|
|
36
|
+
You can add webfonts, meta tags, or analytics to this file.
|
|
37
|
+
The build step will place the bundled scripts into the <body> tag.
|
|
38
|
+
|
|
39
|
+
To begin the development, run `npm start` or `yarn start`.
|
|
40
|
+
To create a production bundle, use `npm run build` or `yarn build`.
|
|
41
|
+
-->
|
|
42
|
+
</body>
|
|
43
|
+
</html>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"short_name": "React App",
|
|
3
|
+
"name": "Create React App Sample",
|
|
4
|
+
"icons": [
|
|
5
|
+
{
|
|
6
|
+
"src": "favicon.ico",
|
|
7
|
+
"sizes": "64x64 32x32 24x24 16x16",
|
|
8
|
+
"type": "image/x-icon"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"src": "logo192.png",
|
|
12
|
+
"type": "image/png",
|
|
13
|
+
"sizes": "192x192"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"src": "logo512.png",
|
|
17
|
+
"type": "image/png",
|
|
18
|
+
"sizes": "512x512"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"start_url": ".",
|
|
22
|
+
"display": "standalone",
|
|
23
|
+
"theme_color": "#000000",
|
|
24
|
+
"background_color": "#ffffff"
|
|
25
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { generateLayout } from "./utils";
|
|
3
|
+
import { ReactGridLayout, ResponsiveGridLayout } from "../lib";
|
|
4
|
+
import { CompactType, Layout } from "../lib/ReactGridLayoutTypes";
|
|
5
|
+
import _ from "lodash";
|
|
6
|
+
import { Props } from "../lib/ResponsiveReactGridLayout";
|
|
7
|
+
|
|
8
|
+
export type props = {
|
|
9
|
+
className: string;
|
|
10
|
+
cols: Props["cols"];
|
|
11
|
+
onLayoutChange: Function;
|
|
12
|
+
rowHeight: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const defaultProps = {
|
|
16
|
+
className: "layout",
|
|
17
|
+
rowHeight: 30,
|
|
18
|
+
onLayoutChange: function () {},
|
|
19
|
+
cols: { lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function Showcase({ ...props } = defaultProps) {
|
|
23
|
+
const [currentBreakpoint, setCurrentBreakpoint] = useState("lg");
|
|
24
|
+
const [compactType, setCompactType] = useState<CompactType>("vertical");
|
|
25
|
+
const [mounted, setMounted] = useState(false);
|
|
26
|
+
const [layouts, setLayouts] = useState<{ [key: string]: Layout }>({
|
|
27
|
+
lg: generateLayout(),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
function generateDOM() {
|
|
31
|
+
return _.map(layouts.lg, function (l, i) {
|
|
32
|
+
return (
|
|
33
|
+
<div key={i} className={l.static ? "static" : ""}>
|
|
34
|
+
{l.static ? (
|
|
35
|
+
<span
|
|
36
|
+
className="text"
|
|
37
|
+
title="This item is static and cannot be removed or resized."
|
|
38
|
+
>
|
|
39
|
+
Static - {i}
|
|
40
|
+
</span>
|
|
41
|
+
) : (
|
|
42
|
+
<span className="text">{i}</span>
|
|
43
|
+
)}
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<ResponsiveGridLayout
|
|
51
|
+
{...props}
|
|
52
|
+
allowOverlap={true}
|
|
53
|
+
layouts={layouts}
|
|
54
|
+
onBreakpointChange={() => ({})}
|
|
55
|
+
onLayoutChange={() => ({})}
|
|
56
|
+
onDrop={() => ({})}
|
|
57
|
+
// WidthProvider option
|
|
58
|
+
// measureBeforeMount={false}
|
|
59
|
+
// I like to have it animate on mount. If you don't, delete `useCSSTransforms` (it's default `true`)
|
|
60
|
+
// and set `measureBeforeMount={true}`.
|
|
61
|
+
useCSSTransforms={mounted}
|
|
62
|
+
compactType={compactType}
|
|
63
|
+
preventCollision={!compactType}
|
|
64
|
+
// ov={true}
|
|
65
|
+
>
|
|
66
|
+
{generateDOM()}
|
|
67
|
+
</ResponsiveGridLayout>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default Showcase;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import _ from "lodash";
|
|
2
|
+
|
|
3
|
+
export function generateLayout() {
|
|
4
|
+
return _.map(_.range(0, 25), function (item, i) {
|
|
5
|
+
var y = Math.ceil(Math.random() * 4) + 1;
|
|
6
|
+
return {
|
|
7
|
+
x: Math.round(Math.random() * 5) * 2,
|
|
8
|
+
y: Math.floor(i / 6) * y,
|
|
9
|
+
w: 2,
|
|
10
|
+
h: y,
|
|
11
|
+
i: i.toString(),
|
|
12
|
+
static: Math.random() < 0.05,
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ReactDOM from "react-dom/client";
|
|
3
|
+
import reportWebVitals from "./reportWebVitals";
|
|
4
|
+
import { ReactGridLayout } from "./lib";
|
|
5
|
+
import Showcase from "./examples/Showcase";
|
|
6
|
+
import RGLTemp from "./lib/RGLTemp";
|
|
7
|
+
|
|
8
|
+
const root = ReactDOM.createRoot(
|
|
9
|
+
document.getElementById("root") as HTMLElement
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
root.render(
|
|
13
|
+
<React.StrictMode>
|
|
14
|
+
{/* <Showcase
|
|
15
|
+
className={"hello"}
|
|
16
|
+
rowHeight={100}
|
|
17
|
+
onLayoutChange={() => ({})}
|
|
18
|
+
cols={{ lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 }}
|
|
19
|
+
/> */}
|
|
20
|
+
<RGLTemp>
|
|
21
|
+
<div>1</div>
|
|
22
|
+
<div>20</div>
|
|
23
|
+
</RGLTemp>
|
|
24
|
+
</React.StrictMode>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// If you want to start measuring performance in your app, pass a function
|
|
28
|
+
// to log results (for example: reportWebVitals(console.log))
|
|
29
|
+
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
30
|
+
reportWebVitals();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
|
2
|
+
|
|
3
|
+
type Props = {
|
|
4
|
+
children: PropsWithChildren<any>;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const Draggable: React.FC<Props> = ({ children }) => {
|
|
8
|
+
const onDrag = () => {
|
|
9
|
+
console.log("draggable dragging");
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<div draggable onDrag={onDrag}>
|
|
14
|
+
{children}
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default Draggable;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type GridItemProps = {
|
|
2
|
+
children: React.ReactElement;
|
|
3
|
+
cols: number;
|
|
4
|
+
containerWidth: number;
|
|
5
|
+
margin: [number, number];
|
|
6
|
+
containerPadding: [number, number];
|
|
7
|
+
rowHeight: number;
|
|
8
|
+
maxRows: number;
|
|
9
|
+
isDraggable: boolean;
|
|
10
|
+
isResizable: boolean;
|
|
11
|
+
isStatic?: boolean;
|
|
12
|
+
useCSSTransforms?: boolean;
|
|
13
|
+
usePercentages?: boolean;
|
|
14
|
+
|
|
15
|
+
className: string;
|
|
16
|
+
style?: Object;
|
|
17
|
+
// Draggability
|
|
18
|
+
cancel: string;
|
|
19
|
+
handle: string;
|
|
20
|
+
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
w: number;
|
|
24
|
+
h: number;
|
|
25
|
+
|
|
26
|
+
minW: number;
|
|
27
|
+
maxW: number;
|
|
28
|
+
minH: number;
|
|
29
|
+
maxH: number;
|
|
30
|
+
i: string;
|
|
31
|
+
|
|
32
|
+
onDrag?: GridItemCallback<GridDragEvent>;
|
|
33
|
+
onDragStart?: GridItemCallback<GridDragEvent>;
|
|
34
|
+
onDragStop?: GridItemCallback<GridDragEvent>;
|
|
35
|
+
onResize?: GridItemCallback<GridResizeEvent>;
|
|
36
|
+
onResizeStart?: GridItemCallback<GridResizeEvent>;
|
|
37
|
+
onResizeStop?: GridItemCallback<GridResizeEvent>;
|
|
38
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { PropsWithChildren, ReactElement } from "react";
|
|
2
|
+
import Resizable from "./Resizable/Resizable";
|
|
3
|
+
import Draggable from "./Draggable/Draggable";
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
children: PropsWithChildren<any>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const GridItemTemp: React.FC<Props> = ({ children }): ReactElement<any> => {
|
|
10
|
+
const onResize = () => {
|
|
11
|
+
console.log("onResize");
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const mixinResizable = (child: ReactElement<any>) => {
|
|
15
|
+
return <Resizable onResize={onResize}>{child}</Resizable>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const mixinDraggable = (child: ReactElement<any>): ReactElement<any> => {
|
|
19
|
+
return <Draggable>{child}</Draggable>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// NOTE: before render
|
|
23
|
+
|
|
24
|
+
const child = React.Children.only(children);
|
|
25
|
+
let newChild: any = React.cloneElement(child, {
|
|
26
|
+
className: "classname",
|
|
27
|
+
style: { ...child.props.style },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
newChild = mixinResizable(newChild);
|
|
31
|
+
newChild = mixinDraggable(newChild);
|
|
32
|
+
|
|
33
|
+
return newChild;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default GridItemTemp;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { PropsWithChildren } from "react";
|
|
3
|
+
import GridItemTemp from "./GridItemTemp";
|
|
4
|
+
|
|
5
|
+
type ReactGridLayoutProps = {
|
|
6
|
+
children: PropsWithChildren<any>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const RGLTemp: React.FC<ReactGridLayoutProps> = ({ children }) => {
|
|
10
|
+
const processGridItem = (child: { children?: React.ReactNode }) => {
|
|
11
|
+
return <GridItemTemp>{child}</GridItemTemp>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const placeholder = () => {
|
|
15
|
+
return (
|
|
16
|
+
<GridItemTemp>
|
|
17
|
+
<div>placeholder</div>
|
|
18
|
+
</GridItemTemp>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div>
|
|
24
|
+
{React.Children.map(children, (child) => processGridItem(child))}
|
|
25
|
+
{placeholder()}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default RGLTemp;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { CSSProperties, Ref } from "react";
|
|
2
|
+
|
|
3
|
+
export type CompactType = "vertical" | "horizontal";
|
|
4
|
+
|
|
5
|
+
type LayoutItem = {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
w: number;
|
|
9
|
+
h: number;
|
|
10
|
+
i: string;
|
|
11
|
+
minW?: number;
|
|
12
|
+
minH?: number;
|
|
13
|
+
maxW?: number;
|
|
14
|
+
maxH?: number;
|
|
15
|
+
static?: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type Layout = LayoutItem[];
|
|
19
|
+
|
|
20
|
+
type EventCallback = (
|
|
21
|
+
layout: Layout,
|
|
22
|
+
oldItem: LayoutItem | undefined,
|
|
23
|
+
newItem: LayoutItem,
|
|
24
|
+
placeholder: LayoutItem,
|
|
25
|
+
e: MouseEvent | TouchEvent,
|
|
26
|
+
element: HTMLElement
|
|
27
|
+
) => void;
|
|
28
|
+
|
|
29
|
+
type ResizeHandleAxis = "s" | "w" | "e" | "n" | "sw" | "nw" | "se" | "ne";
|
|
30
|
+
|
|
31
|
+
type ResizeHandle = "s" | "w" | "e" | "n" | "sw" | "nw" | "se" | "ne" | "all";
|
|
32
|
+
|
|
33
|
+
type DragOverEvent = {
|
|
34
|
+
e: DragEvent;
|
|
35
|
+
node: HTMLElement;
|
|
36
|
+
newItem: LayoutItem;
|
|
37
|
+
prevItem: LayoutItem;
|
|
38
|
+
plhItem: LayoutItem;
|
|
39
|
+
plhNodes: HTMLElement[];
|
|
40
|
+
initX: number;
|
|
41
|
+
initY: number;
|
|
42
|
+
dragEnter: boolean;
|
|
43
|
+
dragMove: boolean;
|
|
44
|
+
dragLeave: boolean;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type ReactGridLayoutProps = {
|
|
48
|
+
className: string;
|
|
49
|
+
style: CSSProperties;
|
|
50
|
+
width: number;
|
|
51
|
+
autoSize: boolean;
|
|
52
|
+
cols: number;
|
|
53
|
+
draggableCancel: string;
|
|
54
|
+
draggableHandle: string;
|
|
55
|
+
verticalCompact: boolean;
|
|
56
|
+
compactType: CompactType;
|
|
57
|
+
layout: Layout;
|
|
58
|
+
margin: [number, number];
|
|
59
|
+
containerPadding: [number, number] | null;
|
|
60
|
+
rowHeight: number;
|
|
61
|
+
maxRows: number;
|
|
62
|
+
isBounded: boolean;
|
|
63
|
+
isDraggable: boolean;
|
|
64
|
+
isResizable: boolean;
|
|
65
|
+
isDroppable: boolean;
|
|
66
|
+
preventCollision: boolean;
|
|
67
|
+
useCSSTransforms: boolean;
|
|
68
|
+
transformScale: number;
|
|
69
|
+
droppingItem: Partial<LayoutItem>;
|
|
70
|
+
resizeHandles: ResizeHandleAxis[];
|
|
71
|
+
resizeHandle?: ResizeHandle;
|
|
72
|
+
allowOverlap: boolean;
|
|
73
|
+
onLayoutChange: (layout: Layout) => void;
|
|
74
|
+
onDrag: EventCallback;
|
|
75
|
+
onDragStart: EventCallback;
|
|
76
|
+
onDragStop: EventCallback;
|
|
77
|
+
onResize: EventCallback;
|
|
78
|
+
onResizeStart: EventCallback;
|
|
79
|
+
onResizeStop: EventCallback;
|
|
80
|
+
onDropDragOver: (
|
|
81
|
+
e: DragOverEvent
|
|
82
|
+
) => ({ w?: number; h?: number } | false) | null;
|
|
83
|
+
onDrop: (layout: Layout, item: LayoutItem | null, e: Event) => void;
|
|
84
|
+
children: JSX.Element[];
|
|
85
|
+
innerRef?: Ref<HTMLDivElement>;
|
|
86
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
children: PropsWithChildren<any>;
|
|
6
|
+
onResize: () => void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const Resizable: React.FC<Props> = ({ children, onResize }) => {
|
|
10
|
+
const onClickResize = () => {
|
|
11
|
+
console.log("resizable clicked");
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<S_ResizableWrapper>
|
|
16
|
+
<S_Child onClick={onClickResize}>{children}</S_Child>
|
|
17
|
+
<S_Handle draggable onDrag={onResize}>
|
|
18
|
+
🍋
|
|
19
|
+
</S_Handle>
|
|
20
|
+
</S_ResizableWrapper>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const S_Child = styled.div`
|
|
25
|
+
width: 100%;
|
|
26
|
+
height: 100%;
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
const S_ResizableWrapper = styled.div`
|
|
30
|
+
position: relative;
|
|
31
|
+
width: 100px;
|
|
32
|
+
height: 100px;
|
|
33
|
+
border: 1px solid red;
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
const S_Handle = styled.div`
|
|
37
|
+
position: absolute;
|
|
38
|
+
bottom: 0;
|
|
39
|
+
right: 0;
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
export default Resizable;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ReactGridLayoutProps } from "./ReactGridLayoutTypes";
|
|
3
|
+
|
|
4
|
+
type Breakpoints<Breakpoint extends string> = { [key in Breakpoint]: number };
|
|
5
|
+
|
|
6
|
+
type ResponsiveLayout<Breakpoint extends string> = {
|
|
7
|
+
[key in Breakpoint]: Layout[];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type Layout = {
|
|
11
|
+
i: string;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
w: number;
|
|
15
|
+
h: number;
|
|
16
|
+
minW?: number;
|
|
17
|
+
maxW?: number;
|
|
18
|
+
minH?: number;
|
|
19
|
+
maxH?: number;
|
|
20
|
+
moved?: boolean;
|
|
21
|
+
static?: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type OnLayoutChangeCallback = (layout: Layout[]) => void;
|
|
25
|
+
|
|
26
|
+
export type Props<Breakpoint extends string = string> = Omit<
|
|
27
|
+
ReactGridLayoutProps,
|
|
28
|
+
"cols"
|
|
29
|
+
> & {
|
|
30
|
+
breakpoint?: Breakpoint | null;
|
|
31
|
+
breakpoints: Breakpoints<Breakpoint>;
|
|
32
|
+
cols: { [key in Breakpoint]: number };
|
|
33
|
+
layouts: ResponsiveLayout<Breakpoint>;
|
|
34
|
+
width: number;
|
|
35
|
+
margin: { [key in Breakpoint]: [number, number] } | [number, number];
|
|
36
|
+
containerPadding:
|
|
37
|
+
| { [key in Breakpoint]: [number, number] }
|
|
38
|
+
| [number, number]
|
|
39
|
+
| null;
|
|
40
|
+
onBreakpointChange: (breakpoint: Breakpoint, cols: number) => void;
|
|
41
|
+
onLayoutChange: OnLayoutChangeCallback;
|
|
42
|
+
onWidthChange: (
|
|
43
|
+
containerWidth: number,
|
|
44
|
+
margin: [number, number],
|
|
45
|
+
cols: number,
|
|
46
|
+
containerPadding: [number, number] | null
|
|
47
|
+
) => void;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const ResponsiveReactGridLayout: React.FC<Partial<Props>> = ({ children }) => {
|
|
51
|
+
return <>{children}</>;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default ResponsiveReactGridLayout;
|
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
|
+
}
|