@synerise/ds-panels-resizer 1.0.36 → 1.0.38
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/CHANGELOG.md +8 -0
- package/dist/PanelResizer.styles.d.ts +1 -1
- package/dist/PanelResizer.styles.js +6 -7
- package/dist/PanelsResizer.d.ts +2 -2
- package/dist/PanelsResizer.js +55 -67
- package/dist/Resizer/Resizer.d.ts +1 -1
- package/dist/Resizer/Resizer.js +11 -18
- package/dist/Resizer/Resizer.styles.d.ts +2 -2
- package/dist/Resizer/Resizer.styles.js +10 -20
- package/dist/Resizer/index.js +4 -1
- package/dist/index.js +4 -1
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/dist/utils/calculatePanelsWidth.js +22 -15
- package/dist/utils/index.js +8 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.38](https://github.com/Synerise/synerise-design/compare/@synerise/ds-panels-resizer@1.0.37...@synerise/ds-panels-resizer@1.0.38) (2026-04-01)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-panels-resizer
|
|
9
|
+
|
|
10
|
+
## [1.0.37](https://github.com/Synerise/synerise-design/compare/@synerise/ds-panels-resizer@1.0.36...@synerise/ds-panels-resizer@1.0.37) (2026-03-24)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @synerise/ds-panels-resizer
|
|
13
|
+
|
|
6
14
|
## [1.0.36](https://github.com/Synerise/synerise-design/compare/@synerise/ds-panels-resizer@1.0.35...@synerise/ds-panels-resizer@1.0.36) (2026-03-20)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @synerise/ds-panels-resizer
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import styled, { css } from
|
|
2
|
-
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
const PanelsResizerContainer = /* @__PURE__ */ styled.div.withConfig({
|
|
3
3
|
displayName: "PanelResizerstyles__PanelsResizerContainer",
|
|
4
4
|
componentId: "sc-d1bdei-0"
|
|
5
|
-
})(["display:flex;flex-direction:", ";", " overflow:hidden;"],
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
5
|
+
})(["display:flex;flex-direction:", ";", " overflow:hidden;"], (props) => props.isHorizontal ? "column" : "row", (props) => props.isHorizontal ? css(["width:-webkit-fill-available;"]) : css(["flex:1;height:-webkit-fill-available;"]));
|
|
6
|
+
export {
|
|
7
|
+
PanelsResizerContainer
|
|
8
|
+
};
|
package/dist/PanelsResizer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React,
|
|
2
|
-
import {
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { InitialVectorOptions } from './utils';
|
|
3
3
|
type PanelsResizerProps = {
|
|
4
4
|
leftPanel: ReactNode;
|
|
5
5
|
rightPanel: ReactNode;
|
package/dist/PanelsResizer.js
CHANGED
|
@@ -1,85 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { Resizer } from
|
|
5
|
-
import { calculateLeftPanelHeight, calculateLeftPanelWidth, calculateRightPanelHeight, calculateRightPanelWidth
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
vector = _useState2[0],
|
|
19
|
-
setVector = _useState2[1];
|
|
20
|
-
var startClientXRef = useRef(0);
|
|
21
|
-
useEffect(function () {
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState, useEffect, useCallback } from "react";
|
|
3
|
+
import { PanelsResizerContainer } from "./PanelResizer.styles.js";
|
|
4
|
+
import { Resizer } from "./Resizer/Resizer.js";
|
|
5
|
+
import { getInitialVector, calculateLeftPanelHeight, calculateLeftPanelWidth, calculateRightPanelHeight, calculateRightPanelWidth } from "./utils/calculatePanelsWidth.js";
|
|
6
|
+
const PanelsResizer = ({
|
|
7
|
+
leftPanel,
|
|
8
|
+
rightPanel,
|
|
9
|
+
initial,
|
|
10
|
+
scrollable,
|
|
11
|
+
isHorizontal = false
|
|
12
|
+
}) => {
|
|
13
|
+
const containerRef = useRef(null);
|
|
14
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
15
|
+
const [vector, setVector] = useState(0);
|
|
16
|
+
const startClientXRef = useRef(0);
|
|
17
|
+
useEffect(() => {
|
|
22
18
|
if (containerRef.current) {
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
const containerWidth = isHorizontal ? containerRef.current.offsetHeight : containerRef.current.offsetWidth;
|
|
20
|
+
const initialVector = getInitialVector(initial, containerWidth);
|
|
25
21
|
setVector(initialVector);
|
|
26
22
|
}
|
|
27
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
23
|
}, []);
|
|
29
|
-
|
|
24
|
+
const handleMouseMove = useCallback((event) => {
|
|
30
25
|
if (!isResizing) {
|
|
31
26
|
return;
|
|
32
27
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
setVector(
|
|
36
|
-
return prevVector !== null ? prevVector + deltaX : deltaX;
|
|
37
|
-
});
|
|
28
|
+
const eventClientX = isHorizontal ? event.clientY : event.clientX;
|
|
29
|
+
const deltaX = eventClientX - startClientXRef.current;
|
|
30
|
+
setVector((prevVector) => prevVector !== null ? prevVector + deltaX : deltaX);
|
|
38
31
|
startClientXRef.current = eventClientX;
|
|
39
32
|
}, [isResizing]);
|
|
40
|
-
|
|
33
|
+
const handleMouseUpOrLeave = useCallback(() => {
|
|
41
34
|
if (!isResizing) {
|
|
42
35
|
return;
|
|
43
36
|
}
|
|
44
37
|
setIsResizing(false);
|
|
45
38
|
}, [isResizing]);
|
|
46
|
-
|
|
39
|
+
const handleMouseDownOnResizer = useCallback((event) => {
|
|
47
40
|
event.preventDefault();
|
|
48
41
|
setIsResizing(true);
|
|
49
42
|
startClientXRef.current = isHorizontal ? event.clientY : event.clientX;
|
|
50
43
|
}, []);
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
} :
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}, scrollable ? {
|
|
82
|
-
overflow: 'auto'
|
|
83
|
-
} : {})
|
|
84
|
-
}, rightPanel));
|
|
85
|
-
};
|
|
44
|
+
return /* @__PURE__ */ jsxs(PanelsResizerContainer, { ref: containerRef, "data-testid": "panels-resizer-container", onMouseUp: handleMouseUpOrLeave, onMouseMove: handleMouseMove, onMouseLeave: handleMouseUpOrLeave, isHorizontal, children: [
|
|
45
|
+
/* @__PURE__ */ jsx("div", { "data-testid": "left-panel-wrapper", style: {
|
|
46
|
+
...isHorizontal ? {
|
|
47
|
+
height: calculateLeftPanelHeight(vector)
|
|
48
|
+
} : {
|
|
49
|
+
width: calculateLeftPanelWidth(vector)
|
|
50
|
+
},
|
|
51
|
+
pointerEvents: isResizing ? "none" : "auto",
|
|
52
|
+
...scrollable ? {
|
|
53
|
+
overflow: "auto"
|
|
54
|
+
} : {}
|
|
55
|
+
}, children: leftPanel }),
|
|
56
|
+
/* @__PURE__ */ jsx(Resizer, { onMouseDown: handleMouseDownOnResizer, isHorizontal }),
|
|
57
|
+
/* @__PURE__ */ jsx("div", { "data-testid": "right-panel-wrapper", style: {
|
|
58
|
+
...isHorizontal ? {
|
|
59
|
+
height: calculateRightPanelHeight(vector)
|
|
60
|
+
} : {
|
|
61
|
+
width: calculateRightPanelWidth(vector)
|
|
62
|
+
},
|
|
63
|
+
pointerEvents: isResizing ? "none" : "auto",
|
|
64
|
+
zIndex: 4,
|
|
65
|
+
...scrollable ? {
|
|
66
|
+
overflow: "auto"
|
|
67
|
+
} : {}
|
|
68
|
+
}, children: rightPanel })
|
|
69
|
+
] });
|
|
70
|
+
};
|
|
71
|
+
export {
|
|
72
|
+
PanelsResizer
|
|
73
|
+
};
|
package/dist/Resizer/Resizer.js
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DragHandleM } from
|
|
3
|
-
import { Handler, HandlerIcon } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
isHorizontal: isHorizontal
|
|
13
|
-
}, /*#__PURE__*/React.createElement(HandlerIcon, {
|
|
14
|
-
component: /*#__PURE__*/React.createElement(DragHandleM, null),
|
|
15
|
-
size: HANDLER_WIDTH,
|
|
16
|
-
isHorizontal: isHorizontal
|
|
17
|
-
}));
|
|
18
|
-
};
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DragHandleM } from "@synerise/ds-icon";
|
|
3
|
+
import { Handler, HandlerIcon } from "./Resizer.styles.js";
|
|
4
|
+
const HANDLER_WIDTH = 16;
|
|
5
|
+
const Resizer = ({
|
|
6
|
+
onMouseDown,
|
|
7
|
+
isHorizontal = false
|
|
8
|
+
}) => /* @__PURE__ */ jsx(Handler, { "data-testid": "resizer-handler", onMouseDown, isHorizontal, children: /* @__PURE__ */ jsx(HandlerIcon, { component: /* @__PURE__ */ jsx(DragHandleM, {}), size: HANDLER_WIDTH, isHorizontal }) });
|
|
9
|
+
export {
|
|
10
|
+
Resizer
|
|
11
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const Handler: import(
|
|
1
|
+
import { StyledIcon } from '@synerise/ds-icon';
|
|
2
|
+
export declare const Handler: import('styled-components').StyledComponent<"div", any, {
|
|
3
3
|
isHorizontal: boolean;
|
|
4
4
|
}, never>;
|
|
5
5
|
export declare const HandlerIcon: StyledIcon<{
|
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
import styled, { css } from
|
|
2
|
-
import Icon from
|
|
3
|
-
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import Icon from "@synerise/ds-icon";
|
|
3
|
+
const Handler = /* @__PURE__ */ styled.div.withConfig({
|
|
4
4
|
displayName: "Resizerstyles__Handler",
|
|
5
5
|
componentId: "sc-s3ii80-0"
|
|
6
|
-
})(["display:flex;align-items:center;", " flex-grow:1;z-index:5;background-color:", ";&:hover{", " background-color:", ";}"],
|
|
7
|
-
|
|
8
|
-
}, function (props) {
|
|
9
|
-
return props.theme.palette['grey-200'];
|
|
10
|
-
}, function (props) {
|
|
11
|
-
return props.isHorizontal ? css(["cursor:ns-resize;"]) : css(["cursor:ew-resize;"]);
|
|
12
|
-
}, function (props) {
|
|
13
|
-
return props.theme.palette['blue-100'];
|
|
14
|
-
});
|
|
15
|
-
export var HandlerIcon = styled(Icon).withConfig({
|
|
6
|
+
})(["display:flex;align-items:center;", " flex-grow:1;z-index:5;background-color:", ";&:hover{", " background-color:", ";}"], (props) => props.isHorizontal ? css(["width:100%;height:16px;justify-content:center;"]) : css(["height:100%;width:16px;"]), (props) => props.theme.palette["grey-200"], (props) => props.isHorizontal ? css(["cursor:ns-resize;"]) : css(["cursor:ew-resize;"]), (props) => props.theme.palette["blue-100"]);
|
|
7
|
+
const HandlerIcon = /* @__PURE__ */ styled(Icon).withConfig({
|
|
16
8
|
displayName: "Resizerstyles__HandlerIcon",
|
|
17
9
|
componentId: "sc-s3ii80-1"
|
|
18
|
-
})(["svg{fill:", ";", "}&:hover{color:", ";}"],
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
return props.theme.palette['blue-600'];
|
|
24
|
-
});
|
|
10
|
+
})(["svg{fill:", ";", "}&:hover{color:", ";}"], (props) => props.theme.palette["grey-600"], (props) => props.isHorizontal && css(["-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg);"]), (props) => props.theme.palette["blue-600"]);
|
|
11
|
+
export {
|
|
12
|
+
Handler,
|
|
13
|
+
HandlerIcon
|
|
14
|
+
};
|
package/dist/Resizer/index.js
CHANGED
package/dist/index.js
CHANGED
package/dist/modules.d.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "@testing-library/jest-dom/extend-expect";
|
|
File without changes
|
|
@@ -1,27 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
const getInitialVector = (options, containerWidth) => {
|
|
2
2
|
if (!options) {
|
|
3
3
|
return 0;
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
if (
|
|
5
|
+
const half = containerWidth / 2;
|
|
6
|
+
if ("leftPanel" in options) {
|
|
7
7
|
return options.leftPanel - half;
|
|
8
8
|
}
|
|
9
|
-
if (
|
|
9
|
+
if ("rightPanel" in options) {
|
|
10
10
|
return half - options.rightPanel;
|
|
11
11
|
}
|
|
12
12
|
return 0;
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return
|
|
14
|
+
const HALF_WIDTH = "50%";
|
|
15
|
+
const calculateLeftPanelWidth = (vector) => {
|
|
16
|
+
return `calc(${HALF_WIDTH} + ${vector}px)`;
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
return
|
|
18
|
+
const calculateRightPanelWidth = (vector) => {
|
|
19
|
+
return `calc(${HALF_WIDTH} - ${vector}px)`;
|
|
20
20
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return
|
|
21
|
+
const HALF_HEIGHT = "50vh";
|
|
22
|
+
const calculateLeftPanelHeight = (vector) => {
|
|
23
|
+
return `calc(${HALF_HEIGHT} + ${vector}px)`;
|
|
24
|
+
};
|
|
25
|
+
const calculateRightPanelHeight = (vector) => {
|
|
26
|
+
return `calc(${HALF_HEIGHT} - ${vector}px)`;
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
calculateLeftPanelHeight,
|
|
30
|
+
calculateLeftPanelWidth,
|
|
31
|
+
calculateRightPanelHeight,
|
|
32
|
+
calculateRightPanelWidth,
|
|
33
|
+
getInitialVector
|
|
24
34
|
};
|
|
25
|
-
export var calculateRightPanelHeight = function calculateRightPanelHeight(vector) {
|
|
26
|
-
return "calc(" + HALF_HEIGHT + " - " + vector + "px)";
|
|
27
|
-
};
|
package/dist/utils/index.js
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { calculateLeftPanelHeight, calculateLeftPanelWidth, calculateRightPanelHeight, calculateRightPanelWidth, getInitialVector } from "./calculatePanelsWidth.js";
|
|
2
|
+
export {
|
|
3
|
+
calculateLeftPanelHeight,
|
|
4
|
+
calculateLeftPanelWidth,
|
|
5
|
+
calculateRightPanelHeight,
|
|
6
|
+
calculateRightPanelWidth,
|
|
7
|
+
getInitialVector
|
|
8
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-panels-resizer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.38",
|
|
4
4
|
"description": "PanelResizer UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "
|
|
19
|
+
"build": "vite build",
|
|
20
20
|
"build:css": "node ../../../scripts/style/less.js",
|
|
21
21
|
"build:js": "babel --delete-dir-on-start --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
|
|
22
|
-
"build:watch": "
|
|
22
|
+
"build:watch": "vite build --watch",
|
|
23
23
|
"defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
|
|
24
24
|
"pack:ci": "pnpm pack --pack-destination ../../storybook/storybook-static/static",
|
|
25
25
|
"prepublish": "pnpm run build",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
],
|
|
36
36
|
"types": "dist/index.d.ts",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@synerise/ds-icon": "^1.15.
|
|
38
|
+
"@synerise/ds-icon": "^1.15.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@synerise/ds-core": "*",
|
|
42
42
|
"react": ">=16.9.0 <= 18.3.1",
|
|
43
43
|
"styled-components": "^5.3.3"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "c2384982c3533a31eb5e5e0408f8dcecb2b0f399"
|
|
46
46
|
}
|