@bouko/react 3.2.1 → 3.2.2
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.
|
@@ -2,8 +2,9 @@ type Props = {
|
|
|
2
2
|
style?: string;
|
|
3
3
|
min: number;
|
|
4
4
|
max: number;
|
|
5
|
+
minWidth?: number;
|
|
5
6
|
update: (min: number, size: number) => void;
|
|
6
7
|
children: React.ReactNode;
|
|
7
8
|
};
|
|
8
|
-
export default function RnD({ style, min, max, update, children }: Props): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default function RnD({ style, min, max, minWidth, update, children }: Props): import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Rnd as RndBase } from "react-rnd";
|
|
3
3
|
import { cn } from "@bouko/style";
|
|
4
|
-
export default function RnD({ style, min, max, update, children }) {
|
|
4
|
+
export default function RnD({ style, min, max, minWidth, update, children }) {
|
|
5
5
|
const gapSize = max - min;
|
|
6
6
|
const handleResize = (x, width) => {
|
|
7
7
|
update(x, width);
|
|
@@ -9,12 +9,12 @@ export default function RnD({ style, min, max, update, children }) {
|
|
|
9
9
|
const handleDrag = (x) => {
|
|
10
10
|
update(x, gapSize);
|
|
11
11
|
};
|
|
12
|
-
return (_jsx(RndBase, { ...opts(min, max), className: cn("flex! justify-center items-center overflow-hidden", style), size: { width: gapSize, height: "100%" }, position: { x: min, y: 0 }, onResize: (e, dir, ref, d, pos) => handleResize(pos.x, ref.offsetWidth), onDragStop: (e, d) => handleDrag(d.x), children: children }));
|
|
12
|
+
return (_jsx(RndBase, { ...opts(min, max, minWidth), className: cn("flex! justify-center items-center overflow-hidden", style), size: { width: gapSize, height: "100%" }, position: { x: min, y: 0 }, onResize: (e, dir, ref, d, pos) => handleResize(pos.x, ref.offsetWidth), onDragStop: (e, d) => handleDrag(d.x), children: children }));
|
|
13
13
|
}
|
|
14
|
-
const opts = (min, max) => ({
|
|
14
|
+
const opts = (min, max, minWidth) => ({
|
|
15
15
|
bounds: "parent",
|
|
16
16
|
axis: "x",
|
|
17
|
-
minWidth: 30,
|
|
17
|
+
minWidth: minWidth || 30,
|
|
18
18
|
default: {
|
|
19
19
|
x: min,
|
|
20
20
|
y: 0,
|