@bwp-web/canvas 1.0.0 → 1.1.0
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/README.md +307 -0
- package/dist/hooks/useEditCanvas.d.ts +2 -2
- package/dist/hooks/useViewCanvas.d.ts +2 -2
- package/dist/index.cjs +203 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +208 -91
- package/dist/index.js.map +1 -1
- package/dist/overlay/FixedSizeContent.d.ts.map +1 -1
- package/dist/overlay/ObjectOverlay.d.ts +4 -0
- package/dist/overlay/ObjectOverlay.d.ts.map +1 -1
- package/dist/overlay/OverlayBadge.d.ts +2 -2
- package/dist/overlay/OverlayBadge.d.ts.map +1 -1
- package/dist/overlay/OverlayContainer.d.ts +43 -0
- package/dist/overlay/OverlayContainer.d.ts.map +1 -0
- package/dist/overlay/OverlayContent.d.ts +2 -2
- package/dist/overlay/OverlayContent.d.ts.map +1 -1
- package/dist/overlay/index.d.ts +2 -0
- package/dist/overlay/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export type { ViewCanvasProviderProps, ViewCanvasContextValue, ViewCanvasViewpor
|
|
|
20
20
|
export { useCanvasRef } from './context';
|
|
21
21
|
export { ObjectOverlay } from './overlay';
|
|
22
22
|
export type { ObjectOverlayProps } from './overlay';
|
|
23
|
+
export { OverlayContainer } from './overlay';
|
|
24
|
+
export type { OverlayContainerProps } from './overlay';
|
|
23
25
|
export { OverlayContent } from './overlay';
|
|
24
26
|
export type { OverlayContentProps } from './overlay';
|
|
25
27
|
export { FixedSizeContent } from './overlay';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,sBAAsB,CAAC;AAG9B,OAAO,EA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D,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGhE,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,UAAU,EACV,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,6BAA6B,EAC7B,uBAAuB,GACxB,MAAM,UAAU,CAAC;AAKlB,OAAO,EACL,MAAM,IAAI,YAAY,EACtB,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,OAAO,EACP,KAAK,EACL,IAAI,GACL,MAAM,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3451,10 +3451,66 @@ function useViewCanvasState() {
|
|
|
3451
3451
|
}
|
|
3452
3452
|
|
|
3453
3453
|
// src/overlay/ObjectOverlay.tsx
|
|
3454
|
-
import { useEffect as
|
|
3455
|
-
import { Stack } from "@mui/material";
|
|
3454
|
+
import { useEffect as useEffect8, useRef as useRef8 } from "react";
|
|
3455
|
+
import { Stack as Stack2 } from "@mui/material";
|
|
3456
3456
|
import { util as util4 } from "fabric";
|
|
3457
|
+
|
|
3458
|
+
// src/overlay/OverlayContainer.tsx
|
|
3459
|
+
import {
|
|
3460
|
+
createContext as createContext4,
|
|
3461
|
+
useContext as useContext4,
|
|
3462
|
+
useEffect as useEffect7,
|
|
3463
|
+
useRef as useRef7
|
|
3464
|
+
} from "react";
|
|
3465
|
+
import { Stack } from "@mui/material";
|
|
3457
3466
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
3467
|
+
var OverlayContainerContext = createContext4(false);
|
|
3468
|
+
function useIsInsideOverlayContainer() {
|
|
3469
|
+
return useContext4(OverlayContainerContext);
|
|
3470
|
+
}
|
|
3471
|
+
function OverlayContainer({
|
|
3472
|
+
canvasRef: canvasRefProp,
|
|
3473
|
+
children
|
|
3474
|
+
}) {
|
|
3475
|
+
const contextCanvasRef = useCanvasRef();
|
|
3476
|
+
const canvasRef = canvasRefProp ?? contextCanvasRef;
|
|
3477
|
+
const containerRef = useRef7(null);
|
|
3478
|
+
useEffect7(() => {
|
|
3479
|
+
const canvas = canvasRef?.current;
|
|
3480
|
+
const el = containerRef.current;
|
|
3481
|
+
if (!canvas || !el) return;
|
|
3482
|
+
function updateContainer() {
|
|
3483
|
+
if (!canvas || !el) return;
|
|
3484
|
+
const vt = canvas.viewportTransform;
|
|
3485
|
+
if (!vt) return;
|
|
3486
|
+
el.style.transform = `translate(${vt[4]}px, ${vt[5]}px)`;
|
|
3487
|
+
}
|
|
3488
|
+
updateContainer();
|
|
3489
|
+
canvas.on("after:render", updateContainer);
|
|
3490
|
+
return () => {
|
|
3491
|
+
canvas.off("after:render", updateContainer);
|
|
3492
|
+
};
|
|
3493
|
+
}, [canvasRef]);
|
|
3494
|
+
return /* @__PURE__ */ jsx4(OverlayContainerContext.Provider, { value: true, children: /* @__PURE__ */ jsx4(
|
|
3495
|
+
Stack,
|
|
3496
|
+
{
|
|
3497
|
+
ref: containerRef,
|
|
3498
|
+
sx: {
|
|
3499
|
+
position: "absolute",
|
|
3500
|
+
left: 0,
|
|
3501
|
+
top: 0,
|
|
3502
|
+
width: "100%",
|
|
3503
|
+
height: "100%",
|
|
3504
|
+
pointerEvents: "none",
|
|
3505
|
+
willChange: "transform"
|
|
3506
|
+
},
|
|
3507
|
+
children
|
|
3508
|
+
}
|
|
3509
|
+
) });
|
|
3510
|
+
}
|
|
3511
|
+
|
|
3512
|
+
// src/overlay/ObjectOverlay.tsx
|
|
3513
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
3458
3514
|
function ObjectOverlay({
|
|
3459
3515
|
canvasRef: canvasRefProp,
|
|
3460
3516
|
object,
|
|
@@ -3464,8 +3520,10 @@ function ObjectOverlay({
|
|
|
3464
3520
|
}) {
|
|
3465
3521
|
const contextCanvasRef = useCanvasRef();
|
|
3466
3522
|
const canvasRef = canvasRefProp ?? contextCanvasRef;
|
|
3467
|
-
const
|
|
3468
|
-
|
|
3523
|
+
const insideContainer = useIsInsideOverlayContainer();
|
|
3524
|
+
const stackRef = useRef8(null);
|
|
3525
|
+
const prev = useRef8({ transform: "", w: "", h: "" });
|
|
3526
|
+
useEffect8(() => {
|
|
3469
3527
|
const canvas = canvasRef?.current;
|
|
3470
3528
|
if (!canvas || !object) return;
|
|
3471
3529
|
function update() {
|
|
@@ -3477,15 +3535,32 @@ function ObjectOverlay({
|
|
|
3477
3535
|
const center = object.getCenterPoint();
|
|
3478
3536
|
const actualWidth = (object.width ?? 0) * (object.scaleX ?? 1);
|
|
3479
3537
|
const actualHeight = (object.height ?? 0) * (object.scaleY ?? 1);
|
|
3480
|
-
const screenCoords = util4.transformPoint(center, vt);
|
|
3481
3538
|
const screenWidth = actualWidth * zoom;
|
|
3482
3539
|
const screenHeight = actualHeight * zoom;
|
|
3483
3540
|
const angle = object.angle ?? 0;
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3541
|
+
let tx;
|
|
3542
|
+
let ty;
|
|
3543
|
+
if (insideContainer) {
|
|
3544
|
+
tx = center.x * zoom - screenWidth / 2;
|
|
3545
|
+
ty = center.y * zoom - screenHeight / 2;
|
|
3546
|
+
} else {
|
|
3547
|
+
const screenCoords = util4.transformPoint(center, vt);
|
|
3548
|
+
tx = screenCoords.x - screenWidth / 2;
|
|
3549
|
+
ty = screenCoords.y - screenHeight / 2;
|
|
3550
|
+
}
|
|
3551
|
+
const transform = angle !== 0 ? `translate(${tx}px, ${ty}px) rotate(${angle}deg)` : `translate(${tx}px, ${ty}px)`;
|
|
3552
|
+
if (transform !== prev.current.transform) {
|
|
3553
|
+
el.style.transform = transform;
|
|
3554
|
+
prev.current.transform = transform;
|
|
3555
|
+
}
|
|
3556
|
+
const w = `${screenWidth}px`;
|
|
3557
|
+
const h = `${screenHeight}px`;
|
|
3558
|
+
if (prev.current.w !== w || prev.current.h !== h) {
|
|
3559
|
+
el.style.width = w;
|
|
3560
|
+
el.style.height = h;
|
|
3561
|
+
prev.current.w = w;
|
|
3562
|
+
prev.current.h = h;
|
|
3563
|
+
}
|
|
3489
3564
|
}
|
|
3490
3565
|
update();
|
|
3491
3566
|
canvas.on("after:render", update);
|
|
@@ -3497,19 +3572,23 @@ function ObjectOverlay({
|
|
|
3497
3572
|
object.off("moving", update);
|
|
3498
3573
|
object.off("scaling", update);
|
|
3499
3574
|
object.off("rotating", update);
|
|
3575
|
+
prev.current = { transform: "", w: "", h: "" };
|
|
3500
3576
|
};
|
|
3501
|
-
}, [canvasRef, object]);
|
|
3577
|
+
}, [canvasRef, object, insideContainer]);
|
|
3502
3578
|
if (!object) return null;
|
|
3503
|
-
return /* @__PURE__ */
|
|
3504
|
-
|
|
3579
|
+
return /* @__PURE__ */ jsx5(
|
|
3580
|
+
Stack2,
|
|
3505
3581
|
{
|
|
3506
3582
|
ref: stackRef,
|
|
3507
3583
|
sx: {
|
|
3508
3584
|
position: "absolute",
|
|
3585
|
+
left: 0,
|
|
3586
|
+
top: 0,
|
|
3509
3587
|
pointerEvents: "none",
|
|
3510
3588
|
alignItems: "center",
|
|
3511
3589
|
justifyContent: "center",
|
|
3512
3590
|
zIndex: 1,
|
|
3591
|
+
willChange: "transform",
|
|
3513
3592
|
...sx
|
|
3514
3593
|
},
|
|
3515
3594
|
...rest,
|
|
@@ -3519,28 +3598,28 @@ function ObjectOverlay({
|
|
|
3519
3598
|
}
|
|
3520
3599
|
|
|
3521
3600
|
// src/overlay/OverlayContent.tsx
|
|
3522
|
-
import { Stack as
|
|
3523
|
-
import { useEffect as
|
|
3524
|
-
import { jsx as
|
|
3601
|
+
import { Stack as Stack3 } from "@mui/material";
|
|
3602
|
+
import { useEffect as useEffect9, useRef as useRef9 } from "react";
|
|
3603
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
3525
3604
|
function OverlayContent({
|
|
3526
3605
|
children,
|
|
3527
|
-
padding =
|
|
3606
|
+
padding = 6,
|
|
3528
3607
|
maxScale = 2,
|
|
3529
3608
|
sx,
|
|
3530
3609
|
...rest
|
|
3531
3610
|
}) {
|
|
3532
|
-
const outerRef =
|
|
3533
|
-
const innerRef =
|
|
3534
|
-
|
|
3611
|
+
const outerRef = useRef9(null);
|
|
3612
|
+
const innerRef = useRef9(null);
|
|
3613
|
+
useEffect9(() => {
|
|
3535
3614
|
const outer = outerRef.current;
|
|
3536
3615
|
const inner = innerRef.current;
|
|
3537
3616
|
if (!outer || !inner) return;
|
|
3617
|
+
let natW = 0;
|
|
3618
|
+
let natH = 0;
|
|
3538
3619
|
function fit() {
|
|
3539
3620
|
if (!outer || !inner) return;
|
|
3540
3621
|
const containerW = outer.clientWidth;
|
|
3541
3622
|
const containerH = outer.clientHeight;
|
|
3542
|
-
const natW = inner.scrollWidth;
|
|
3543
|
-
const natH = inner.scrollHeight;
|
|
3544
3623
|
if (natW === 0 || natH === 0 || containerW <= 0 || containerH <= 0) {
|
|
3545
3624
|
inner.style.transform = "";
|
|
3546
3625
|
inner.style.removeProperty("--overlay-scale");
|
|
@@ -3554,14 +3633,25 @@ function OverlayContent({
|
|
|
3554
3633
|
inner.style.transform = `scale(${scale})`;
|
|
3555
3634
|
inner.style.setProperty("--overlay-scale", String(scale));
|
|
3556
3635
|
}
|
|
3557
|
-
const observer = new ResizeObserver(
|
|
3636
|
+
const observer = new ResizeObserver((entries) => {
|
|
3637
|
+
for (const entry of entries) {
|
|
3638
|
+
if (entry.target === inner) {
|
|
3639
|
+
natW = inner.scrollWidth;
|
|
3640
|
+
natH = inner.scrollHeight;
|
|
3641
|
+
break;
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
fit();
|
|
3645
|
+
});
|
|
3558
3646
|
observer.observe(outer);
|
|
3559
3647
|
observer.observe(inner);
|
|
3648
|
+
natW = inner.scrollWidth;
|
|
3649
|
+
natH = inner.scrollHeight;
|
|
3560
3650
|
fit();
|
|
3561
3651
|
return () => observer.disconnect();
|
|
3562
3652
|
}, [padding, maxScale]);
|
|
3563
|
-
return /* @__PURE__ */
|
|
3564
|
-
|
|
3653
|
+
return /* @__PURE__ */ jsx6(
|
|
3654
|
+
Stack3,
|
|
3565
3655
|
{
|
|
3566
3656
|
ref: outerRef,
|
|
3567
3657
|
sx: {
|
|
@@ -3573,8 +3663,8 @@ function OverlayContent({
|
|
|
3573
3663
|
...sx
|
|
3574
3664
|
},
|
|
3575
3665
|
...rest,
|
|
3576
|
-
children: /* @__PURE__ */
|
|
3577
|
-
|
|
3666
|
+
children: /* @__PURE__ */ jsx6(
|
|
3667
|
+
Stack3,
|
|
3578
3668
|
{
|
|
3579
3669
|
ref: innerRef,
|
|
3580
3670
|
sx: {
|
|
@@ -3591,9 +3681,9 @@ function OverlayContent({
|
|
|
3591
3681
|
}
|
|
3592
3682
|
|
|
3593
3683
|
// src/overlay/FixedSizeContent.tsx
|
|
3594
|
-
import { Stack as
|
|
3595
|
-
import { useEffect as
|
|
3596
|
-
import { jsx as
|
|
3684
|
+
import { Stack as Stack4 } from "@mui/material";
|
|
3685
|
+
import { useEffect as useEffect10, useRef as useRef10 } from "react";
|
|
3686
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
3597
3687
|
function FixedSizeContent({
|
|
3598
3688
|
children,
|
|
3599
3689
|
hideOnOverflow = true,
|
|
@@ -3601,9 +3691,9 @@ function FixedSizeContent({
|
|
|
3601
3691
|
sx,
|
|
3602
3692
|
...rest
|
|
3603
3693
|
}) {
|
|
3604
|
-
const ref =
|
|
3605
|
-
const totalContentHeightRef =
|
|
3606
|
-
|
|
3694
|
+
const ref = useRef10(null);
|
|
3695
|
+
const totalContentHeightRef = useRef10(0);
|
|
3696
|
+
useEffect10(() => {
|
|
3607
3697
|
const el = ref.current;
|
|
3608
3698
|
if (!el) return;
|
|
3609
3699
|
let clipAncestor = el.parentElement;
|
|
@@ -3614,34 +3704,45 @@ function FixedSizeContent({
|
|
|
3614
3704
|
if (!clipAncestor) return;
|
|
3615
3705
|
const ancestor = clipAncestor;
|
|
3616
3706
|
totalContentHeightRef.current = el.parentElement?.scrollHeight ?? 0;
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
}
|
|
3630
|
-
} else if (!fits && el.style.display !== "none") {
|
|
3707
|
+
let rafId = 0;
|
|
3708
|
+
function doCheck() {
|
|
3709
|
+
if (!el) return;
|
|
3710
|
+
const containerW = ancestor.clientWidth;
|
|
3711
|
+
const containerH = ancestor.clientHeight;
|
|
3712
|
+
el.style.maxWidth = `${Math.max(0, containerW - truncationPadding * 2)}px`;
|
|
3713
|
+
if (!hideOnOverflow) return;
|
|
3714
|
+
const fits = containerH >= totalContentHeightRef.current;
|
|
3715
|
+
if (fits && el.style.display === "none") {
|
|
3716
|
+
el.style.display = "";
|
|
3717
|
+
totalContentHeightRef.current = el.parentElement?.scrollHeight ?? 0;
|
|
3718
|
+
if (containerH < totalContentHeightRef.current) {
|
|
3631
3719
|
el.style.display = "none";
|
|
3632
3720
|
}
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3721
|
+
} else if (!fits && el.style.display !== "none") {
|
|
3722
|
+
el.style.display = "none";
|
|
3723
|
+
}
|
|
3724
|
+
if (el.style.display !== "none") {
|
|
3725
|
+
totalContentHeightRef.current = el.parentElement?.scrollHeight ?? 0;
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
function scheduleCheck() {
|
|
3729
|
+
if (!rafId) {
|
|
3730
|
+
rafId = requestAnimationFrame(() => {
|
|
3731
|
+
rafId = 0;
|
|
3732
|
+
doCheck();
|
|
3733
|
+
});
|
|
3734
|
+
}
|
|
3637
3735
|
}
|
|
3638
|
-
const observer = new ResizeObserver(
|
|
3736
|
+
const observer = new ResizeObserver(scheduleCheck);
|
|
3639
3737
|
observer.observe(ancestor);
|
|
3640
|
-
|
|
3641
|
-
return () =>
|
|
3738
|
+
scheduleCheck();
|
|
3739
|
+
return () => {
|
|
3740
|
+
if (rafId) cancelAnimationFrame(rafId);
|
|
3741
|
+
observer.disconnect();
|
|
3742
|
+
};
|
|
3642
3743
|
}, [hideOnOverflow, truncationPadding]);
|
|
3643
|
-
return /* @__PURE__ */
|
|
3644
|
-
|
|
3744
|
+
return /* @__PURE__ */ jsx7(
|
|
3745
|
+
Stack4,
|
|
3645
3746
|
{
|
|
3646
3747
|
ref,
|
|
3647
3748
|
sx: {
|
|
@@ -3665,9 +3766,9 @@ function FixedSizeContent({
|
|
|
3665
3766
|
}
|
|
3666
3767
|
|
|
3667
3768
|
// src/overlay/OverlayBadge.tsx
|
|
3668
|
-
import { Stack as
|
|
3669
|
-
import { useEffect as
|
|
3670
|
-
import { jsx as
|
|
3769
|
+
import { Stack as Stack5 } from "@mui/material";
|
|
3770
|
+
import { useEffect as useEffect11, useRef as useRef11 } from "react";
|
|
3771
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
3671
3772
|
function toPx(v) {
|
|
3672
3773
|
if (v === void 0) return void 0;
|
|
3673
3774
|
return typeof v === "number" ? `${v}px` : v;
|
|
@@ -3697,10 +3798,19 @@ function ellipsePosition(angleDeg) {
|
|
|
3697
3798
|
function toNum(v) {
|
|
3698
3799
|
return typeof v === "number" ? v : 0;
|
|
3699
3800
|
}
|
|
3801
|
+
function readOverlayScale(el) {
|
|
3802
|
+
let node = el.parentElement;
|
|
3803
|
+
while (node) {
|
|
3804
|
+
const val = node.style.getPropertyValue("--overlay-scale");
|
|
3805
|
+
if (val) return parseFloat(val) || 1;
|
|
3806
|
+
node = node.parentElement;
|
|
3807
|
+
}
|
|
3808
|
+
return 1;
|
|
3809
|
+
}
|
|
3700
3810
|
function OverlayBadge({
|
|
3701
3811
|
children,
|
|
3702
|
-
maxScale =
|
|
3703
|
-
minScale = 0.
|
|
3812
|
+
maxScale = 1.5,
|
|
3813
|
+
minScale = 0.5,
|
|
3704
3814
|
top,
|
|
3705
3815
|
right,
|
|
3706
3816
|
bottom,
|
|
@@ -3709,41 +3819,47 @@ function OverlayBadge({
|
|
|
3709
3819
|
sx,
|
|
3710
3820
|
...rest
|
|
3711
3821
|
}) {
|
|
3712
|
-
const ref =
|
|
3713
|
-
const baseSize =
|
|
3714
|
-
|
|
3822
|
+
const ref = useRef11(null);
|
|
3823
|
+
const baseSize = useRef11(null);
|
|
3824
|
+
useEffect11(() => {
|
|
3715
3825
|
const el = ref.current;
|
|
3716
3826
|
if (!el) return;
|
|
3717
3827
|
const ancestor = el.parentElement;
|
|
3718
3828
|
if (!ancestor) return;
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
const scale = `scale(${ownScale / overlayScale})`;
|
|
3740
|
-
el.style.transform = circular ? `translate(-50%, -50%) ${scale}` : scale;
|
|
3741
|
-
});
|
|
3829
|
+
let rafId = 0;
|
|
3830
|
+
function doUpdate() {
|
|
3831
|
+
if (!el || !ancestor) return;
|
|
3832
|
+
const containerW = ancestor.clientWidth;
|
|
3833
|
+
const containerH = ancestor.clientHeight;
|
|
3834
|
+
if (containerW <= 0 || containerH <= 0) {
|
|
3835
|
+
el.style.transform = "";
|
|
3836
|
+
return;
|
|
3837
|
+
}
|
|
3838
|
+
if (!baseSize.current) {
|
|
3839
|
+
baseSize.current = { w: containerW, h: containerH };
|
|
3840
|
+
}
|
|
3841
|
+
const ratio = Math.min(
|
|
3842
|
+
containerW / baseSize.current.w,
|
|
3843
|
+
containerH / baseSize.current.h
|
|
3844
|
+
);
|
|
3845
|
+
const ownScale = Math.max(minScale, Math.min(ratio, maxScale));
|
|
3846
|
+
const overlayScale = readOverlayScale(el);
|
|
3847
|
+
const scale = `scale(${ownScale / overlayScale})`;
|
|
3848
|
+
el.style.transform = circular ? `translate(-50%, -50%) ${scale}` : scale;
|
|
3742
3849
|
}
|
|
3743
|
-
|
|
3850
|
+
function scheduleUpdate() {
|
|
3851
|
+
if (!rafId) {
|
|
3852
|
+
rafId = requestAnimationFrame(() => {
|
|
3853
|
+
rafId = 0;
|
|
3854
|
+
doUpdate();
|
|
3855
|
+
});
|
|
3856
|
+
}
|
|
3857
|
+
}
|
|
3858
|
+
const observer = new ResizeObserver(scheduleUpdate);
|
|
3744
3859
|
observer.observe(ancestor);
|
|
3745
|
-
|
|
3860
|
+
scheduleUpdate();
|
|
3746
3861
|
return () => {
|
|
3862
|
+
if (rafId) cancelAnimationFrame(rafId);
|
|
3747
3863
|
observer.disconnect();
|
|
3748
3864
|
baseSize.current = null;
|
|
3749
3865
|
};
|
|
@@ -3763,8 +3879,8 @@ function OverlayBadge({
|
|
|
3763
3879
|
bottom: toPx(bottom),
|
|
3764
3880
|
left: toPx(left)
|
|
3765
3881
|
};
|
|
3766
|
-
return /* @__PURE__ */
|
|
3767
|
-
|
|
3882
|
+
return /* @__PURE__ */ jsx8(
|
|
3883
|
+
Stack5,
|
|
3768
3884
|
{
|
|
3769
3885
|
ref,
|
|
3770
3886
|
sx: {
|
|
@@ -3808,6 +3924,7 @@ export {
|
|
|
3808
3924
|
FixedSizeContent,
|
|
3809
3925
|
ObjectOverlay,
|
|
3810
3926
|
OverlayBadge,
|
|
3927
|
+
OverlayContainer,
|
|
3811
3928
|
OverlayContent,
|
|
3812
3929
|
Point9 as Point,
|
|
3813
3930
|
Polygon5 as Polygon,
|