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.
Files changed (57) hide show
  1. package/README.md +29 -0
  2. package/bin/cli.js +8 -0
  3. package/bitbucket-pipelines.yml +35 -0
  4. package/package.json +51 -0
  5. package/public/favicon.ico +0 -0
  6. package/public/index.html +43 -0
  7. package/public/logo192.png +0 -0
  8. package/public/logo512.png +0 -0
  9. package/public/manifest.json +25 -0
  10. package/public/robots.txt +3 -0
  11. package/src/App.tsx +28 -0
  12. package/src/examples/ReactGridLayout/ReactGridLayoutShowcase01.tsx +80 -0
  13. package/src/examples/ReactGridLayout/index.ts +1 -0
  14. package/src/examples/ResponsiveGridLayout/ResponsiveGridLayoutShowcase01.tsx +114 -0
  15. package/src/examples/ResponsiveGridLayout/index.ts +1 -0
  16. package/src/examples/index.ts +2 -0
  17. package/src/examples/utils.ts +15 -0
  18. package/src/index.tsx +21 -0
  19. package/src/lib/Draggable/Draggable.tsx +303 -0
  20. package/src/lib/Draggable/DraggableCore.tsx +352 -0
  21. package/src/lib/Draggable/constants.ts +12 -0
  22. package/src/lib/Draggable/index.ts +2 -0
  23. package/src/lib/Draggable/types.ts +74 -0
  24. package/src/lib/Draggable/utils/domHelpers.ts +284 -0
  25. package/src/lib/Draggable/utils/getPrefix.ts +42 -0
  26. package/src/lib/Draggable/utils/positionHelpers.ts +49 -0
  27. package/src/lib/Draggable/utils/types.ts +41 -0
  28. package/src/lib/Draggable/utils/validationHelpers.ts +23 -0
  29. package/src/lib/GridItem/GridItem.tsx +493 -0
  30. package/src/lib/GridItem/index.ts +1 -0
  31. package/src/lib/GridItem/types.ts +121 -0
  32. package/src/lib/GridItem/utils/calculateUtils.ts +173 -0
  33. package/src/lib/GridLayoutEditor/ReactGridLayout.tsx +662 -0
  34. package/src/lib/GridLayoutEditor/ResponsiveGridLayout.tsx +204 -0
  35. package/src/lib/GridLayoutEditor/index.ts +9 -0
  36. package/src/lib/GridLayoutEditor/styles/styles.css +133 -0
  37. package/src/lib/GridLayoutEditor/types.ts +199 -0
  38. package/src/lib/GridLayoutEditor/utils/renderHelpers.ts +737 -0
  39. package/src/lib/GridLayoutEditor/utils/responsiveUtils.ts +111 -0
  40. package/src/lib/PreviewGLE/ReactGridLayoutPreview.tsx +46 -0
  41. package/src/lib/PreviewGLE/ResponsiveGridLayoutPreview.tsx +54 -0
  42. package/src/lib/PreviewGLE/index.ts +2 -0
  43. package/src/lib/Resizable/Resizable.tsx +323 -0
  44. package/src/lib/Resizable/ResizableBox.tsx +109 -0
  45. package/src/lib/Resizable/index.ts +1 -0
  46. package/src/lib/Resizable/styles/styles.css +76 -0
  47. package/src/lib/Resizable/types.ts +96 -0
  48. package/src/lib/Resizable/utils/cloneElement.ts +15 -0
  49. package/src/lib/components/WidthProvider.tsx +71 -0
  50. package/src/lib/components/index.ts +1 -0
  51. package/src/lib/components/types.ts +19 -0
  52. package/src/lib/index.ts +4 -0
  53. package/src/react-app-env.d.ts +1 -0
  54. package/src/reportWebVitals.ts +15 -0
  55. package/src/setupTests.ts +5 -0
  56. package/src/utils/types.ts +3 -0
  57. 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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { program } = require("commander");
4
+
5
+ // action
6
+ program.action((cmd) => console.log("✓ Running!!"));
7
+
8
+ program.parse(process.argv);
@@ -0,0 +1,35 @@
1
+ # This is an example Starter pipeline configuration
2
+ # Use a skeleton to build, test and deploy using manual and parallel steps
3
+ # -----
4
+ # You can specify a custom docker image from Docker Hub as your build environment.
5
+
6
+ image: atlassian/default-image:3
7
+
8
+ pipelines:
9
+ default:
10
+ - parallel:
11
+ - step:
12
+ name: 'Build and Test'
13
+ script:
14
+ - echo "Your build and test goes here..."
15
+ - step:
16
+ name: 'Lint'
17
+ script:
18
+ - echo "Your linting goes here..."
19
+ - step:
20
+ name: 'Security scan'
21
+ script:
22
+ - echo "Your security scan goes here..."
23
+
24
+ # The following deployment steps will be executed for each pipeline run. To configure your steps and conditionally deploy see https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/
25
+ - step:
26
+ name: 'Deployment to Staging'
27
+ deployment: staging
28
+ script:
29
+ - echo "Your deployment to staging script goes here..."
30
+ - step:
31
+ name: 'Deployment to Production'
32
+ deployment: production
33
+ trigger: 'manual'
34
+ script:
35
+ - echo "Your deployment to production script goes here..."
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "publ-echo",
3
+ "version": "0.0.1",
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
+ "classnames": "^2.3.2",
14
+ "commander": "^10.0.1",
15
+ "react": "^18.2.0",
16
+ "react-dom": "^18.2.0",
17
+ "react-scripts": "5.0.1",
18
+ "typescript": "^4.9.5",
19
+ "web-vitals": "^2.1.4"
20
+ },
21
+ "scripts": {
22
+ "start": "react-scripts start",
23
+ "build": "react-scripts build",
24
+ "test": "react-scripts test",
25
+ "eject": "react-scripts eject"
26
+ },
27
+ "eslintConfig": {
28
+ "extends": [
29
+ "react-app",
30
+ "react-app/jest"
31
+ ]
32
+ },
33
+ "browserslist": {
34
+ "production": [
35
+ ">0.2%",
36
+ "not dead",
37
+ "not op_mini all"
38
+ ],
39
+ "development": [
40
+ "last 1 chrome version",
41
+ "last 1 firefox version",
42
+ "last 1 safari version"
43
+ ]
44
+ },
45
+ "devDependencies": {
46
+ "@types/lodash": "^4.14.194",
47
+ "@types/styled-components": "^5.1.26",
48
+ "lodash": "^4.17.21",
49
+ "styled-components": "^5.3.10"
50
+ }
51
+ }
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,3 @@
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
3
+ Disallow:
package/src/App.tsx ADDED
@@ -0,0 +1,28 @@
1
+ import styled from "styled-components";
2
+ import {
3
+ ReactGridLayoutShowcase01,
4
+ ResponsiveGridLayoutShowcase01,
5
+ } from "./examples";
6
+
7
+ function App() {
8
+ // return (
9
+ // <S_GridLayoutWrapper>
10
+ // <ResponsiveGridLayoutShowcase01 />
11
+ // </S_GridLayoutWrapper>
12
+ // );
13
+ return (
14
+ <S_GridLayoutWrapper>
15
+ <ReactGridLayoutShowcase01 />
16
+ </S_GridLayoutWrapper>
17
+ );
18
+ }
19
+
20
+ const S_GridLayoutWrapper = styled.div`
21
+ background-color: yellow;
22
+
23
+ & > div {
24
+ background-color: lightgreen;
25
+ }
26
+ `;
27
+
28
+ export default App;
@@ -0,0 +1,80 @@
1
+ import { SyntheticEvent, useState } from "react";
2
+ import { generateLayout } from "../utils";
3
+ import { Layout } from "../../lib/GridLayoutEditor/types";
4
+
5
+ import styled from "styled-components";
6
+ import { ReactGridLayoutPreview } from "../../lib/PreviewGLE";
7
+ import ReactGridLayout from "../../lib/GridLayoutEditor/ReactGridLayout";
8
+ import { ResizeCallbackData } from "../../lib/Resizable/types";
9
+
10
+ const lay = generateLayout().slice(0, 2);
11
+
12
+ // NOTE - windowSize viewport에 맞게 Resize시키기 위한 Provider
13
+ // const Responsive = WidthProvider(ReactGridLayout);
14
+
15
+ function ReactGridLayoutShowcase01() {
16
+ const [layout, setLayout] = useState<Layout>(lay);
17
+ const [isOpenPreview, setIsOpenPreview] = useState(false);
18
+
19
+ const defaultProps = {
20
+ width: 1280,
21
+ // className: "layout",
22
+ items: 50,
23
+ cols: 12,
24
+ rowHeight: 50,
25
+ allowOverlap: true,
26
+ margin: [10, 10] as [number, number],
27
+ };
28
+
29
+ function onLayoutChange(newLayout: Layout) {
30
+ setLayout(newLayout);
31
+ }
32
+
33
+ const onResizeStartTemp = (
34
+ e: SyntheticEvent,
35
+ // { node, size }: { node: HTMLElement; size: Position }
36
+ { node, size }: ResizeCallbackData
37
+ ) => {
38
+ // Get new XY
39
+ return;
40
+ };
41
+
42
+ const onResizeTemp = (
43
+ e: SyntheticEvent,
44
+ // { node, size }: { node: HTMLElement; size: Position }
45
+ { node, size }: ResizeCallbackData
46
+ ) => {
47
+ return;
48
+ };
49
+
50
+ return (
51
+ <>
52
+ <button onClick={() => setIsOpenPreview(true)}>previewButton</button>
53
+ {!isOpenPreview && (
54
+ <ReactGridLayout
55
+ {...defaultProps}
56
+ layout={layout}
57
+ onLayoutChange={onLayoutChange}
58
+ resizeHandles={["nw", "e", "n", "ne", "s", "se", "sw", "w"]}
59
+ isHiddenVisibility
60
+ >
61
+ {layout.map((each) => (
62
+ <S_SampleBox key={each.i}>{each.i}</S_SampleBox>
63
+ ))}
64
+ </ReactGridLayout>
65
+ )}
66
+ {isOpenPreview && (
67
+ <ReactGridLayoutPreview layout={layout} props={defaultProps} />
68
+ )}
69
+ </>
70
+ );
71
+ }
72
+
73
+ const S_SampleBox = styled.div`
74
+ width: 100px;
75
+ height: 100px;
76
+ background-color: lightgray;
77
+ border: dodgerblue 1px solid;
78
+ `;
79
+
80
+ export default ReactGridLayoutShowcase01;
@@ -0,0 +1 @@
1
+ export { default as ReactGridLayoutShowcase01 } from "./ReactGridLayoutShowcase01";
@@ -0,0 +1,114 @@
1
+ import { useState } from "react";
2
+ import { generateLayout } from "../utils";
3
+ import _ from "lodash";
4
+ import {
5
+ CompactType,
6
+ Layout,
7
+ OnBreakpointChangeCallback,
8
+ OnLayoutChangeCallback,
9
+ OnWidthChangeCallback,
10
+ } from "../../lib/GridLayoutEditor/types";
11
+ import styled from "styled-components";
12
+ import { WidthProvider } from "../../lib/components";
13
+
14
+ import { ResponsiveGridLayoutPreview } from "../../lib/PreviewGLE";
15
+ import ResponsiveGridLayout from "../../lib/GridLayoutEditor/ResponsiveGridLayout";
16
+
17
+ // NOTE - windowSize viewport에 맞게 Resize시키기 위한 Provider
18
+ const Responsive = WidthProvider(ResponsiveGridLayout);
19
+
20
+ function ResponsiveGridLayoutShowcase01() {
21
+ const [currentBreakpoint, setCurrentBreakpoint] = useState("lg");
22
+ const [currentCompactType, setCurrentCompactType] =
23
+ useState<CompactType | null>("vertical");
24
+ const [mounted, setMounted] = useState(false);
25
+ const [layouts, setLayouts] = useState<{ [key: string]: Layout }>({
26
+ lg: generateLayout().slice(0, 1),
27
+ });
28
+
29
+ const [isOpenPreview, setIsOpenPreview] = useState(false);
30
+
31
+ const defaultProps = {
32
+ // className: "layout",
33
+ cols: { lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 },
34
+ rowHeight: 50,
35
+ allowOverlap: true,
36
+ margin: [10, 10] as [number, number],
37
+ };
38
+
39
+ const onLayoutChange: OnLayoutChangeCallback = ({ layout, layouts }) => {
40
+ setLayouts({ ...layouts });
41
+ };
42
+
43
+ const onBreakpointChange: OnBreakpointChangeCallback = (breakpoint) => {
44
+ setCurrentBreakpoint(breakpoint);
45
+ };
46
+
47
+ const onCompactTypeChange = () => {
48
+ const compactType =
49
+ currentCompactType === "horizontal"
50
+ ? "vertical"
51
+ : currentCompactType === "vertical"
52
+ ? null
53
+ : "horizontal";
54
+
55
+ setCurrentCompactType(compactType);
56
+ };
57
+
58
+ const onWidthChange: OnWidthChangeCallback = (
59
+ containerWidth,
60
+ margin,
61
+ cols,
62
+ containerPadding
63
+ ) => {
64
+ return;
65
+ };
66
+
67
+ function generateDOM() {
68
+ return _.map(layouts.lg, function (l, i) {
69
+ return (
70
+ <S_SampleBox key={i} className={l.static ? "static" : ""}>
71
+ {l.static ? (
72
+ <span
73
+ className="text"
74
+ title="This item is static and cannot be removed or resized."
75
+ >
76
+ Static - {i}
77
+ </span>
78
+ ) : (
79
+ <span className="text">{i}</span>
80
+ )}
81
+ </S_SampleBox>
82
+ );
83
+ });
84
+ }
85
+
86
+ // NOTE - window resize 적용된 Responsive
87
+ return (
88
+ <>
89
+ <button onClick={() => setIsOpenPreview(true)}>previewButton</button>
90
+ {!isOpenPreview && (
91
+ <Responsive
92
+ {...defaultProps}
93
+ layouts={layouts}
94
+ onLayoutChange={onLayoutChange}
95
+ resizeHandles={["nw", "e", "n", "ne", "s", "se", "sw", "w"]}
96
+ >
97
+ {generateDOM()}
98
+ </Responsive>
99
+ )}
100
+ {isOpenPreview && (
101
+ <ResponsiveGridLayoutPreview layouts={layouts} props={defaultProps} />
102
+ )}
103
+ </>
104
+ );
105
+ }
106
+
107
+ const S_SampleBox = styled.div`
108
+ width: 100px;
109
+ height: 100px;
110
+ background-color: lightgray;
111
+ border: dodgerblue 1px solid;
112
+ `;
113
+
114
+ export default ResponsiveGridLayoutShowcase01;
@@ -0,0 +1 @@
1
+ export { default as ResponsiveGridLayoutShowcase01 } from "./ResponsiveGridLayoutShowcase01";
@@ -0,0 +1,2 @@
1
+ export { default as ResponsiveGridLayoutShowcase01 } from "./ResponsiveGridLayout/ResponsiveGridLayoutShowcase01";
2
+ export { default as ReactGridLayoutShowcase01 } from "./ReactGridLayout/ReactGridLayoutShowcase01";
@@ -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,21 @@
1
+ import React from "react";
2
+ import ReactDOM from "react-dom/client";
3
+ import reportWebVitals from "./reportWebVitals";
4
+ import App from "./App";
5
+
6
+ const root = ReactDOM.createRoot(
7
+ document.getElementById("root") as HTMLElement
8
+ );
9
+
10
+ root.render(
11
+ <React.StrictMode>
12
+ <App />
13
+ </React.StrictMode>
14
+ );
15
+
16
+ // If you want to start measuring performance in your app, pass a function
17
+ // to log results (for example: reportWebVitals(console.log))
18
+ // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
19
+ reportWebVitals();
20
+
21
+ export * from "./lib";