@xwadex/fesd-next 0.3.44-beta.20 → 0.3.44-beta.21

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.
@@ -5,7 +5,7 @@ import { useDragResize, useCookies } from "../../hooks/index.js";
5
5
  import { DragResizeContext } from "./dragResizeContext";
6
6
  import { cn } from "../../utils/index.js";
7
7
  const DragResizeBase = (props) => {
8
- const { as, children, defaultWidth, defaultHeight, className, handlerClassName, resizeStore = true, resizeStoreKey, resizeStoreValue, active = true, direction = "width", minWidth = 500, maxWidth = 950, onInit, onResizeStart, onResizing, onResizeEnd, ...othersProps } = props;
8
+ const { as, children, defaultWidth, defaultHeight, className, handlerClassName, resizeStore = true, resizeStoreKey, resizeStoreValue, active = true, direction = "horizontal", minWidth = 500, maxWidth = 950, onInit, onResizeStart, onResizing, onResizeEnd, ...othersProps } = props;
9
9
  const RootComponent = as || "div";
10
10
  const [isActive, setActive] = useState(active);
11
11
  const { setCookies, deleteCookies } = useCookies();
@@ -4,7 +4,7 @@ export interface ResizeTypes {
4
4
  }
5
5
  export interface DragResizePropsTypes {
6
6
  active?: boolean;
7
- direction?: "width" | "height";
7
+ direction?: "horizontal" | "vertical";
8
8
  minWidth?: number;
9
9
  maxWidth?: number;
10
10
  minHeight?: number;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  //wade 2024.12.06
3
3
  import { useEffect, useRef, useState } from "react";
4
- export function useDragResize({ active = true, direction = "width", minWidth, maxWidth, minHeight, maxHeight, onInit, onResizeStart, onResizing, onResizeEnd }) {
4
+ export function useDragResize({ active = true, direction = "horizontal", minWidth, maxWidth, minHeight, maxHeight, onInit, onResizeStart, onResizing, onResizeEnd }) {
5
5
  const dragRef = useRef(null);
6
6
  const resizeRef = useRef(null);
7
7
  const [resize, setResize] = useState({ width: 0, height: 0 });
@@ -19,13 +19,18 @@ export function useDragResize({ active = true, direction = "width", minWidth, ma
19
19
  const rect = resizeRef.current.getBoundingClientRect();
20
20
  const resizeWidth = clientX - rect.left;
21
21
  const resizeHeight = clientY - rect.top;
22
- if ((minWidth && resizeWidth > minWidth) || (maxWidth && resizeWidth > maxWidth)) {
22
+ if (direction == "horizontal"
23
+ && (minWidth && resizeWidth >= minWidth)
24
+ && (maxWidth && resizeWidth <= maxWidth)) {
23
25
  resizeRef.current.style.width = resizeWidth + "px";
26
+ return { width: resizeWidth, height: undefined };
24
27
  }
25
- if ((minHeight && resizeWidth > minHeight) || (maxHeight && resizeWidth > maxHeight)) {
28
+ if (direction == "vertical"
29
+ && (minHeight && resizeWidth >= minHeight)
30
+ && (maxHeight && resizeWidth <= maxHeight)) {
26
31
  resizeRef.current.style.height = resizeHeight + "px";
32
+ return { width: undefined, height: resizeHeight };
27
33
  }
28
- return { width: resizeWidth, height: resizeHeight };
29
34
  };
30
35
  const onInitCallback = () => {
31
36
  const resizeValue = getResizeSizeValue();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xwadex/fesd-next",
3
- "version": "0.3.44-beta.20",
3
+ "version": "0.3.44-beta.21",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",