@rnaga/wp-next-ui 1.0.6 → 1.0.7
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/DraggableBox.d.ts +5 -1
- package/DraggableBox.d.ts.map +1 -1
- package/DraggableBox.js +11 -3
- package/package.json +1 -1
package/DraggableBox.d.ts
CHANGED
|
@@ -10,13 +10,17 @@
|
|
|
10
10
|
* - size: Sets the Typography size ("small" | "medium").
|
|
11
11
|
* - targetRef: Reference to an element whose relative position determines the box's initial placement.
|
|
12
12
|
* - sx: Style overrides for the outer Box wrapping the content.
|
|
13
|
-
* - slotSxProps: Style overrides for the header and
|
|
13
|
+
* - slotSxProps: Style overrides for the header, title, and border (width, color).
|
|
14
14
|
*/
|
|
15
15
|
import React, { RefObject } from "react";
|
|
16
16
|
import { SxProps } from "@mui/material";
|
|
17
17
|
type SlotSxProps = {
|
|
18
18
|
header?: SxProps;
|
|
19
19
|
title?: SxProps;
|
|
20
|
+
border?: {
|
|
21
|
+
width?: number;
|
|
22
|
+
color?: string;
|
|
23
|
+
};
|
|
20
24
|
};
|
|
21
25
|
export declare const DraggableBox: (props: {
|
|
22
26
|
children: React.ReactNode;
|
package/DraggableBox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DraggableBox.d.ts","sourceRoot":"","sources":["../src/DraggableBox.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,EACZ,SAAS,EAKV,MAAM,OAAO,CAAC;AACf,OAAO,EAAmB,OAAO,EAAE,MAAM,eAAe,CAAC;AAOzD,KAAK,WAAW,GAAG;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"DraggableBox.d.ts","sourceRoot":"","sources":["../src/DraggableBox.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,EACZ,SAAS,EAKV,MAAM,OAAO,CAAC;AACf,OAAO,EAAmB,OAAO,EAAE,MAAM,eAAe,CAAC;AAOzD,KAAK,WAAW,GAAG;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC1B,SAAS,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC1C,GAAG,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACpC,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC9B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,4CA0bA,CAAC"}
|
package/DraggableBox.js
CHANGED
|
@@ -11,7 +11,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
11
11
|
* - size: Sets the Typography size ("small" | "medium").
|
|
12
12
|
* - targetRef: Reference to an element whose relative position determines the box's initial placement.
|
|
13
13
|
* - sx: Style overrides for the outer Box wrapping the content.
|
|
14
|
-
* - slotSxProps: Style overrides for the header and
|
|
14
|
+
* - slotSxProps: Style overrides for the header, title, and border (width, color).
|
|
15
15
|
*/
|
|
16
16
|
import { useCallback, useEffect, useRef, useState, } from "react";
|
|
17
17
|
import { Box, IconButton } from "@mui/material";
|
|
@@ -37,7 +37,12 @@ export const DraggableBox = (props) => {
|
|
|
37
37
|
// Determines if the box is currently being resized and from which direction
|
|
38
38
|
const [isResizing, setIsResizing] = useState(null);
|
|
39
39
|
// Stores the initial mouse position when resizing starts
|
|
40
|
-
const [resizeStart, setResizeStart] = useState({
|
|
40
|
+
const [resizeStart, setResizeStart] = useState({
|
|
41
|
+
x: 0,
|
|
42
|
+
y: 0,
|
|
43
|
+
width: 0,
|
|
44
|
+
height: 0,
|
|
45
|
+
});
|
|
41
46
|
/**
|
|
42
47
|
* Ensures the new position is within the browser window bounds.
|
|
43
48
|
* Returns null if the position would place the box partially off-screen.
|
|
@@ -240,8 +245,11 @@ export const DraggableBox = (props) => {
|
|
|
240
245
|
height: boxSize.height || "auto",
|
|
241
246
|
zIndex: 1000 + zIndexLayer,
|
|
242
247
|
bgcolor: "background.paper",
|
|
243
|
-
borderRadius:
|
|
248
|
+
borderRadius: 1,
|
|
244
249
|
p: 1,
|
|
250
|
+
border: `${slotSxProps?.border?.width ?? 1}px solid`,
|
|
251
|
+
borderColor: slotSxProps?.border?.color ?? "grey.500",
|
|
252
|
+
transform: "translateZ(0)",
|
|
245
253
|
...sx,
|
|
246
254
|
}, children: [_jsxs(Box, { sx: {
|
|
247
255
|
height: 30,
|