@synerise/ds-panels-resizer 1.0.34 → 1.0.36
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 +10 -0
- package/README.md +9 -8
- package/dist/PanelResizer.styles.d.ts +3 -1
- package/dist/PanelResizer.styles.js +6 -2
- package/dist/PanelsResizer.d.ts +2 -1
- package/dist/PanelsResizer.js +23 -12
- package/dist/Resizer/Resizer.d.ts +2 -1
- package/dist/Resizer/Resizer.js +6 -3
- package/dist/Resizer/Resizer.styles.d.ts +4 -2
- package/dist/Resizer/Resizer.styles.js +8 -4
- package/dist/utils/calculatePanelsWidth.d.ts +2 -0
- package/dist/utils/calculatePanelsWidth.js +7 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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.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
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-panels-resizer
|
|
9
|
+
|
|
10
|
+
## [1.0.35](https://github.com/Synerise/synerise-design/compare/@synerise/ds-panels-resizer@1.0.34...@synerise/ds-panels-resizer@1.0.35) (2026-02-26)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **panels-resizer:** horizontal panels resizer ([f7628d2](https://github.com/Synerise/synerise-design/commit/f7628d2d3640479dd8bf7ab625a8b87fed5f0ef0))
|
|
15
|
+
|
|
6
16
|
## [1.0.34](https://github.com/Synerise/synerise-design/compare/@synerise/ds-panels-resizer@1.0.33...@synerise/ds-panels-resizer@1.0.34) (2026-02-19)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @synerise/ds-panels-resizer
|
package/README.md
CHANGED
|
@@ -3,9 +3,9 @@ id: panels-resizer
|
|
|
3
3
|
title: PanelResizer
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
The `PanelsResizer` component allows you to create a layout with resizable
|
|
6
|
+
The `PanelsResizer` component allows you to create a layout with two resizable panels separated by a draggable resizer. Panels can be arranged side-by-side (default) or stacked top-and-bottom via the `isHorizontal` prop.
|
|
7
7
|
|
|
8
|
-
Users can adjust the
|
|
8
|
+
Users can adjust the size of the panels by dragging the resizer, providing a flexible and customizable interface.
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -37,9 +37,10 @@ const App = () => (
|
|
|
37
37
|
|
|
38
38
|
## API
|
|
39
39
|
|
|
40
|
-
| Property
|
|
41
|
-
|
|
|
42
|
-
| leftPanel
|
|
43
|
-
| rightPanel
|
|
44
|
-
| initial
|
|
45
|
-
| scrollable
|
|
40
|
+
| Property | Description | Type | Default |
|
|
41
|
+
| ------------ | ---------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | ------- |
|
|
42
|
+
| leftPanel | The content to display in the left (or top, when `isHorizontal`) panel. | React.ReactNode | --- |
|
|
43
|
+
| rightPanel | The content to display in the right (or bottom, when `isHorizontal`) panel. | React.ReactNode | --- |
|
|
44
|
+
| initial | Initial size of one panel in pixels. Converted to an offset from 50% at mount time. | { leftPanel: number } \| { rightPanel: number } | --- |
|
|
45
|
+
| scrollable | Whether the panels should be scrollable when their content overflows. | boolean | --- |
|
|
46
|
+
| isHorizontal | When `true`, panels are stacked top-and-bottom with a horizontal divider instead of the default side-by-side layout. | boolean | false |
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
2
|
export var PanelsResizerContainer = styled.div.withConfig({
|
|
3
3
|
displayName: "PanelResizerstyles__PanelsResizerContainer",
|
|
4
4
|
componentId: "sc-d1bdei-0"
|
|
5
|
-
})(["display:flex;flex:
|
|
5
|
+
})(["display:flex;flex-direction:", ";", " overflow:hidden;"], function (props) {
|
|
6
|
+
return props.isHorizontal ? 'column' : 'row';
|
|
7
|
+
}, function (props) {
|
|
8
|
+
return props.isHorizontal ? css(["width:-webkit-fill-available;"]) : css(["flex:1;height:-webkit-fill-available;"]);
|
|
9
|
+
});
|
package/dist/PanelsResizer.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ type PanelsResizerProps = {
|
|
|
5
5
|
rightPanel: ReactNode;
|
|
6
6
|
initial?: InitialVectorOptions;
|
|
7
7
|
scrollable?: boolean;
|
|
8
|
+
isHorizontal?: boolean;
|
|
8
9
|
};
|
|
9
|
-
export declare const PanelsResizer: ({ leftPanel, rightPanel, initial, scrollable, }: PanelsResizerProps) => React.JSX.Element;
|
|
10
|
+
export declare const PanelsResizer: ({ leftPanel, rightPanel, initial, scrollable, isHorizontal, }: PanelsResizerProps) => React.JSX.Element;
|
|
10
11
|
export {};
|
package/dist/PanelsResizer.js
CHANGED
|
@@ -2,12 +2,14 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
2
2
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import * as S from './PanelResizer.styles';
|
|
4
4
|
import { Resizer } from './Resizer';
|
|
5
|
-
import { calculateLeftPanelWidth, calculateRightPanelWidth, getInitialVector } from './utils';
|
|
5
|
+
import { calculateLeftPanelHeight, calculateLeftPanelWidth, calculateRightPanelHeight, calculateRightPanelWidth, getInitialVector } from './utils';
|
|
6
6
|
export var PanelsResizer = function PanelsResizer(_ref) {
|
|
7
7
|
var leftPanel = _ref.leftPanel,
|
|
8
8
|
rightPanel = _ref.rightPanel,
|
|
9
9
|
initial = _ref.initial,
|
|
10
|
-
scrollable = _ref.scrollable
|
|
10
|
+
scrollable = _ref.scrollable,
|
|
11
|
+
_ref$isHorizontal = _ref.isHorizontal,
|
|
12
|
+
isHorizontal = _ref$isHorizontal === void 0 ? false : _ref$isHorizontal;
|
|
11
13
|
var containerRef = useRef(null);
|
|
12
14
|
var _useState = useState(false),
|
|
13
15
|
isResizing = _useState[0],
|
|
@@ -18,7 +20,7 @@ export var PanelsResizer = function PanelsResizer(_ref) {
|
|
|
18
20
|
var startClientXRef = useRef(0);
|
|
19
21
|
useEffect(function () {
|
|
20
22
|
if (containerRef.current) {
|
|
21
|
-
var containerWidth = containerRef.current.offsetWidth;
|
|
23
|
+
var containerWidth = isHorizontal ? containerRef.current.offsetHeight : containerRef.current.offsetWidth;
|
|
22
24
|
var initialVector = getInitialVector(initial, containerWidth);
|
|
23
25
|
setVector(initialVector);
|
|
24
26
|
}
|
|
@@ -28,11 +30,12 @@ export var PanelsResizer = function PanelsResizer(_ref) {
|
|
|
28
30
|
if (!isResizing) {
|
|
29
31
|
return;
|
|
30
32
|
}
|
|
31
|
-
var
|
|
33
|
+
var eventClientX = isHorizontal ? event.clientY : event.clientX;
|
|
34
|
+
var deltaX = eventClientX - startClientXRef.current;
|
|
32
35
|
setVector(function (prevVector) {
|
|
33
36
|
return prevVector !== null ? prevVector + deltaX : deltaX;
|
|
34
37
|
});
|
|
35
|
-
startClientXRef.current =
|
|
38
|
+
startClientXRef.current = eventClientX;
|
|
36
39
|
}, [isResizing]);
|
|
37
40
|
var handleMouseUpOrLeave = useCallback(function () {
|
|
38
41
|
if (!isResizing) {
|
|
@@ -43,28 +46,36 @@ export var PanelsResizer = function PanelsResizer(_ref) {
|
|
|
43
46
|
var handleMouseDownOnResizer = useCallback(function (event) {
|
|
44
47
|
event.preventDefault();
|
|
45
48
|
setIsResizing(true);
|
|
46
|
-
startClientXRef.current = event.clientX;
|
|
49
|
+
startClientXRef.current = isHorizontal ? event.clientY : event.clientX;
|
|
47
50
|
}, []);
|
|
48
51
|
return /*#__PURE__*/React.createElement(S.PanelsResizerContainer, {
|
|
49
52
|
ref: containerRef,
|
|
50
53
|
"data-testid": "panels-resizer-container",
|
|
51
54
|
onMouseUp: handleMouseUpOrLeave,
|
|
52
55
|
onMouseMove: handleMouseMove,
|
|
53
|
-
onMouseLeave: handleMouseUpOrLeave
|
|
56
|
+
onMouseLeave: handleMouseUpOrLeave,
|
|
57
|
+
isHorizontal: isHorizontal
|
|
54
58
|
}, /*#__PURE__*/React.createElement("div", {
|
|
55
59
|
"data-testid": "left-panel-wrapper",
|
|
56
|
-
style: _extends({
|
|
57
|
-
|
|
60
|
+
style: _extends({}, isHorizontal ? {
|
|
61
|
+
height: calculateLeftPanelHeight(vector)
|
|
62
|
+
} : {
|
|
63
|
+
width: calculateLeftPanelWidth(vector)
|
|
64
|
+
}, {
|
|
58
65
|
pointerEvents: isResizing ? 'none' : 'auto'
|
|
59
66
|
}, scrollable ? {
|
|
60
67
|
overflow: 'auto'
|
|
61
68
|
} : {})
|
|
62
69
|
}, leftPanel), /*#__PURE__*/React.createElement(Resizer, {
|
|
63
|
-
onMouseDown: handleMouseDownOnResizer
|
|
70
|
+
onMouseDown: handleMouseDownOnResizer,
|
|
71
|
+
isHorizontal: isHorizontal
|
|
64
72
|
}), /*#__PURE__*/React.createElement("div", {
|
|
65
73
|
"data-testid": "right-panel-wrapper",
|
|
66
|
-
style: _extends({
|
|
67
|
-
|
|
74
|
+
style: _extends({}, isHorizontal ? {
|
|
75
|
+
height: calculateRightPanelHeight(vector)
|
|
76
|
+
} : {
|
|
77
|
+
width: calculateRightPanelWidth(vector)
|
|
78
|
+
}, {
|
|
68
79
|
pointerEvents: isResizing ? 'none' : 'auto',
|
|
69
80
|
zIndex: 4
|
|
70
81
|
}, scrollable ? {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { type MouseEvent } from 'react';
|
|
2
2
|
type ResizerProps = {
|
|
3
3
|
onMouseDown: (event: MouseEvent<HTMLDivElement>) => void;
|
|
4
|
+
isHorizontal?: boolean;
|
|
4
5
|
};
|
|
5
|
-
export declare const Resizer: ({ onMouseDown }: ResizerProps) => React.JSX.Element;
|
|
6
|
+
export declare const Resizer: ({ onMouseDown, isHorizontal, }: ResizerProps) => React.JSX.Element;
|
|
6
7
|
export {};
|
package/dist/Resizer/Resizer.js
CHANGED
|
@@ -3,13 +3,16 @@ import { DragHandleM } from '@synerise/ds-icon';
|
|
|
3
3
|
import { Handler, HandlerIcon } from './Resizer.styles';
|
|
4
4
|
var HANDLER_WIDTH = 16;
|
|
5
5
|
export var Resizer = function Resizer(_ref) {
|
|
6
|
-
var onMouseDown = _ref.onMouseDown
|
|
6
|
+
var onMouseDown = _ref.onMouseDown,
|
|
7
|
+
_ref$isHorizontal = _ref.isHorizontal,
|
|
8
|
+
isHorizontal = _ref$isHorizontal === void 0 ? false : _ref$isHorizontal;
|
|
7
9
|
return /*#__PURE__*/React.createElement(Handler, {
|
|
8
10
|
"data-testid": "resizer-handler",
|
|
9
11
|
onMouseDown: onMouseDown,
|
|
10
|
-
|
|
12
|
+
isHorizontal: isHorizontal
|
|
11
13
|
}, /*#__PURE__*/React.createElement(HandlerIcon, {
|
|
12
14
|
component: /*#__PURE__*/React.createElement(DragHandleM, null),
|
|
13
|
-
size: HANDLER_WIDTH
|
|
15
|
+
size: HANDLER_WIDTH,
|
|
16
|
+
isHorizontal: isHorizontal
|
|
14
17
|
}));
|
|
15
18
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type StyledIcon } from '@synerise/ds-icon';
|
|
2
2
|
export declare const Handler: import("styled-components").StyledComponent<"div", any, {
|
|
3
|
-
|
|
3
|
+
isHorizontal: boolean;
|
|
4
4
|
}, never>;
|
|
5
|
-
export declare const HandlerIcon: StyledIcon
|
|
5
|
+
export declare const HandlerIcon: StyledIcon<{
|
|
6
|
+
isHorizontal?: boolean;
|
|
7
|
+
}>;
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
2
|
import Icon from '@synerise/ds-icon';
|
|
3
3
|
export var Handler = styled.div.withConfig({
|
|
4
4
|
displayName: "Resizerstyles__Handler",
|
|
5
5
|
componentId: "sc-s3ii80-0"
|
|
6
|
-
})(["display:flex;align-items:center;
|
|
7
|
-
return props.width;
|
|
6
|
+
})(["display:flex;align-items:center;", " flex-grow:1;z-index:5;background-color:", ";&:hover{", " background-color:", ";}"], function (props) {
|
|
7
|
+
return props.isHorizontal ? css(["width:100%;height:16px;justify-content:center;"]) : css(["height:100%;width:16px;"]);
|
|
8
8
|
}, function (props) {
|
|
9
9
|
return props.theme.palette['grey-200'];
|
|
10
|
+
}, function (props) {
|
|
11
|
+
return props.isHorizontal ? css(["cursor:ns-resize;"]) : css(["cursor:ew-resize;"]);
|
|
10
12
|
}, function (props) {
|
|
11
13
|
return props.theme.palette['blue-100'];
|
|
12
14
|
});
|
|
13
15
|
export var HandlerIcon = styled(Icon).withConfig({
|
|
14
16
|
displayName: "Resizerstyles__HandlerIcon",
|
|
15
17
|
componentId: "sc-s3ii80-1"
|
|
16
|
-
})(["svg{fill:", ";}&:hover{color:", ";}"], function (props) {
|
|
18
|
+
})(["svg{fill:", ";", "}&:hover{color:", ";}"], function (props) {
|
|
17
19
|
return props.theme.palette['grey-600'];
|
|
20
|
+
}, function (props) {
|
|
21
|
+
return props.isHorizontal && css(["-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg);"]);
|
|
18
22
|
}, function (props) {
|
|
19
23
|
return props.theme.palette['blue-600'];
|
|
20
24
|
});
|
|
@@ -6,3 +6,5 @@ export type InitialVectorOptions = {
|
|
|
6
6
|
export declare const getInitialVector: (options: InitialVectorOptions | undefined, containerWidth: number) => number;
|
|
7
7
|
export declare const calculateLeftPanelWidth: (vector: number) => string;
|
|
8
8
|
export declare const calculateRightPanelWidth: (vector: number) => string;
|
|
9
|
+
export declare const calculateLeftPanelHeight: (vector: number) => string;
|
|
10
|
+
export declare const calculateRightPanelHeight: (vector: number) => string;
|
|
@@ -17,4 +17,11 @@ export var calculateLeftPanelWidth = function calculateLeftPanelWidth(vector) {
|
|
|
17
17
|
};
|
|
18
18
|
export var calculateRightPanelWidth = function calculateRightPanelWidth(vector) {
|
|
19
19
|
return "calc(" + HALF_WIDTH + " - " + vector + "px)";
|
|
20
|
+
};
|
|
21
|
+
var HALF_HEIGHT = '50vh';
|
|
22
|
+
export var calculateLeftPanelHeight = function calculateLeftPanelHeight(vector) {
|
|
23
|
+
return "calc(" + HALF_HEIGHT + " + " + vector + "px)";
|
|
24
|
+
};
|
|
25
|
+
export var calculateRightPanelHeight = function calculateRightPanelHeight(vector) {
|
|
26
|
+
return "calc(" + HALF_HEIGHT + " - " + vector + "px)";
|
|
20
27
|
};
|
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.36",
|
|
4
4
|
"description": "PanelResizer UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
],
|
|
36
36
|
"types": "dist/index.d.ts",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@synerise/ds-icon": "^1.
|
|
38
|
+
"@synerise/ds-icon": "^1.15.0"
|
|
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": "8efc031fa688c0b87c7b3915bae93546bb63bcac"
|
|
46
46
|
}
|