@max-ts/kit 1.10.3 → 1.10.4
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/lib/components/ScalableContainer/ScalableContainer.d.ts.map +1 -1
- package/lib/components/ScalableContainer/useLogic.d.ts +1 -0
- package/lib/components/ScalableContainer/useLogic.d.ts.map +1 -1
- package/lib/index.mjs +40 -10
- package/lib/stories/ScalableContainer.stories.d.ts +1 -0
- package/lib/stories/ScalableContainer.stories.d.ts.map +1 -1
- package/lib/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalableContainer.d.ts","sourceRoot":"","sources":["../../../src/components/ScalableContainer/ScalableContainer.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAGtD,iBAAS,iBAAiB,CAAC,EAC1B,YAAgB,EAChB,QAAc,EACd,QAAY,EACZ,WAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,QAAQ,EACR,KAAK,EACL,GAAG,KAAK,EACR,EAAE,sBAAsB,+
|
|
1
|
+
{"version":3,"file":"ScalableContainer.d.ts","sourceRoot":"","sources":["../../../src/components/ScalableContainer/ScalableContainer.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAGtD,iBAAS,iBAAiB,CAAC,EAC1B,YAAgB,EAChB,QAAc,EACd,QAAY,EACZ,WAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,QAAQ,EACR,KAAK,EACL,GAAG,KAAK,EACR,EAAE,sBAAsB,+BAmGxB;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -6,6 +6,7 @@ export declare function useLogic({ initialScale, minScale, maxScale, onScaleChan
|
|
|
6
6
|
transition: string;
|
|
7
7
|
};
|
|
8
8
|
cursor: string;
|
|
9
|
+
handleClickCapture: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
9
10
|
handlePointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;
|
|
10
11
|
handlePointerEnd: (event: React.PointerEvent<HTMLDivElement>) => void;
|
|
11
12
|
handlePointerMove: (event: React.PointerEvent<HTMLDivElement>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLogic.d.ts","sourceRoot":"","sources":["../../../src/components/ScalableContainer/useLogic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEX,sBAAsB,EACtB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"useLogic.d.ts","sourceRoot":"","sources":["../../../src/components/ScalableContainer/useLogic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEX,sBAAsB,EACtB,MAAM,SAAS,CAAC;AAQjB,KAAK,cAAc,GAAG,IAAI,CACzB,sBAAsB,EACpB,cAAc,GACd,UAAU,GACV,UAAU,GACV,gBAAgB,GAChB,mBAAmB,CACrB,CAAC;AAuBF,wBAAgB,QAAQ,CAAC,EACxB,YAAgB,EAChB,QAAc,EACd,QAAY,EACZ,cAAc,EACd,iBAAiB,GACjB,EAAE,cAAc;;;;;;gCAyIP,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC;+BAjFhC,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC;8BAyDlC,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC;+BAjClC,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC;;6BAiFlC,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC;8BAbhC,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC;;;;;;;EAoGzC"}
|
package/lib/index.mjs
CHANGED
|
@@ -4542,6 +4542,7 @@ const DEFAULT_POSITION = {
|
|
|
4542
4542
|
y: 0
|
|
4543
4543
|
};
|
|
4544
4544
|
const OVERLAY_TIMEOUT = 1500;
|
|
4545
|
+
const DRAG_THRESHOLD = 4;
|
|
4545
4546
|
const ZOOM_FACTOR = 1.5;
|
|
4546
4547
|
const WHEEL_ZOOM_FACTOR = 0.05;
|
|
4547
4548
|
function clampScale(value, minScale, maxScale) {
|
|
@@ -4554,7 +4555,7 @@ function getDistance(firstTouch, secondTouch) {
|
|
|
4554
4555
|
}
|
|
4555
4556
|
function shouldSkipDragStart(target) {
|
|
4556
4557
|
if (!(target instanceof Element)) return false;
|
|
4557
|
-
return Boolean(target.closest('button, a, input, textarea, select, label, path, summary, [role="button"], [contenteditable="true"]'));
|
|
4558
|
+
return Boolean(target.closest('button, a, input, textarea, select, label, path, circle, ellipse, polygon, polyline, line, summary, [role="button"], [contenteditable="true"], [data-scalable-container-interactive]'));
|
|
4558
4559
|
}
|
|
4559
4560
|
function ScalableContainer_useLogic_useLogic({ initialScale = 1, minScale = 0.1, maxScale = 4, onScaleChanged, onPositionChanged }) {
|
|
4560
4561
|
const initialClampedScale = clampScale(initialScale, minScale, maxScale);
|
|
@@ -4565,6 +4566,9 @@ function ScalableContainer_useLogic_useLogic({ initialScale = 1, minScale = 0.1,
|
|
|
4565
4566
|
const scaleRef = useRef(initialClampedScale);
|
|
4566
4567
|
const positionRef = useRef(DEFAULT_POSITION);
|
|
4567
4568
|
const dragStartRef = useRef(DEFAULT_POSITION);
|
|
4569
|
+
const dragOriginRef = useRef(DEFAULT_POSITION);
|
|
4570
|
+
const isDraggingRef = useRef(false);
|
|
4571
|
+
const didDragRef = useRef(false);
|
|
4568
4572
|
const activePointersRef = useRef(new Map());
|
|
4569
4573
|
const initialPinchDistanceRef = useRef(0);
|
|
4570
4574
|
const initialPinchScaleRef = useRef(initialClampedScale);
|
|
@@ -4608,13 +4612,15 @@ function ScalableContainer_useLogic_useLogic({ initialScale = 1, minScale = 0.1,
|
|
|
4608
4612
|
const handlePointerDown = useCallback((event)=>{
|
|
4609
4613
|
if ('mouse' === event.pointerType && 0 !== event.button) return;
|
|
4610
4614
|
if (shouldSkipDragStart(event.target)) return;
|
|
4611
|
-
event.currentTarget.setPointerCapture(event.pointerId);
|
|
4612
4615
|
activePointersRef.current.set(event.pointerId, {
|
|
4613
4616
|
x: event.clientX,
|
|
4614
4617
|
y: event.clientY
|
|
4615
4618
|
});
|
|
4616
4619
|
if (1 === activePointersRef.current.size) {
|
|
4617
|
-
|
|
4620
|
+
dragOriginRef.current = {
|
|
4621
|
+
x: event.clientX,
|
|
4622
|
+
y: event.clientY
|
|
4623
|
+
};
|
|
4618
4624
|
dragStartRef.current = {
|
|
4619
4625
|
x: event.clientX - positionRef.current.x,
|
|
4620
4626
|
y: event.clientY - positionRef.current.y
|
|
@@ -4627,10 +4633,21 @@ function ScalableContainer_useLogic_useLogic({ initialScale = 1, minScale = 0.1,
|
|
|
4627
4633
|
x: event.clientX,
|
|
4628
4634
|
y: event.clientY
|
|
4629
4635
|
});
|
|
4630
|
-
if (1 === activePointersRef.current.size)
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4636
|
+
if (1 === activePointersRef.current.size) {
|
|
4637
|
+
if (!isDraggingRef.current) {
|
|
4638
|
+
const deltaX = event.clientX - dragOriginRef.current.x;
|
|
4639
|
+
const deltaY = event.clientY - dragOriginRef.current.y;
|
|
4640
|
+
if (Math.sqrt(deltaX * deltaX + deltaY * deltaY) < DRAG_THRESHOLD) return;
|
|
4641
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
4642
|
+
isDraggingRef.current = true;
|
|
4643
|
+
didDragRef.current = true;
|
|
4644
|
+
setIsDragging(true);
|
|
4645
|
+
}
|
|
4646
|
+
setPosition({
|
|
4647
|
+
x: event.clientX - dragStartRef.current.x,
|
|
4648
|
+
y: event.clientY - dragStartRef.current.y
|
|
4649
|
+
});
|
|
4650
|
+
}
|
|
4634
4651
|
}, [
|
|
4635
4652
|
setPosition
|
|
4636
4653
|
]);
|
|
@@ -4638,12 +4655,23 @@ function ScalableContainer_useLogic_useLogic({ initialScale = 1, minScale = 0.1,
|
|
|
4638
4655
|
activePointersRef.current.delete(event.pointerId);
|
|
4639
4656
|
const remainingPointer = activePointersRef.current.values().next().value;
|
|
4640
4657
|
if (remainingPointer) {
|
|
4658
|
+
dragOriginRef.current = remainingPointer;
|
|
4641
4659
|
dragStartRef.current = {
|
|
4642
4660
|
x: remainingPointer.x - positionRef.current.x,
|
|
4643
4661
|
y: remainingPointer.y - positionRef.current.y
|
|
4644
4662
|
};
|
|
4645
|
-
|
|
4646
|
-
|
|
4663
|
+
}
|
|
4664
|
+
isDraggingRef.current = false;
|
|
4665
|
+
setIsDragging(false);
|
|
4666
|
+
window.setTimeout(()=>{
|
|
4667
|
+
didDragRef.current = false;
|
|
4668
|
+
});
|
|
4669
|
+
}, []);
|
|
4670
|
+
const handleClickCapture = useCallback((event)=>{
|
|
4671
|
+
if (!didDragRef.current) return;
|
|
4672
|
+
event.preventDefault();
|
|
4673
|
+
event.stopPropagation();
|
|
4674
|
+
didDragRef.current = false;
|
|
4647
4675
|
}, []);
|
|
4648
4676
|
const handleTouchStart = useCallback((event)=>{
|
|
4649
4677
|
if (2 !== event.touches.length) return;
|
|
@@ -4706,6 +4734,7 @@ function ScalableContainer_useLogic_useLogic({ initialScale = 1, minScale = 0.1,
|
|
|
4706
4734
|
transition: isDragging ? 'none' : 'transform 0.1s ease-out'
|
|
4707
4735
|
},
|
|
4708
4736
|
cursor: isDragging ? 'grabbing' : 'grab',
|
|
4737
|
+
handleClickCapture,
|
|
4709
4738
|
handlePointerDown,
|
|
4710
4739
|
handlePointerEnd,
|
|
4711
4740
|
handlePointerMove,
|
|
@@ -4721,7 +4750,7 @@ function ScalableContainer_useLogic_useLogic({ initialScale = 1, minScale = 0.1,
|
|
|
4721
4750
|
};
|
|
4722
4751
|
}
|
|
4723
4752
|
function ScalableContainer({ initialScale = 1, minScale = 0.1, maxScale = 4, showToolbar = false, onScaleChanged, onPositionChanged, onWheel, className, children, style, ...props }) {
|
|
4724
|
-
const { contentStyle, cursor, handlePointerDown, handlePointerEnd, handlePointerMove, handleTouchEnd, handleTouchMove, handleTouchStart, modifierKey, reset, showOverlay, viewportRef, zoomIn, zoomOut } = ScalableContainer_useLogic_useLogic({
|
|
4753
|
+
const { contentStyle, cursor, handleClickCapture, handlePointerDown, handlePointerEnd, handlePointerMove, handleTouchEnd, handleTouchMove, handleTouchStart, modifierKey, reset, showOverlay, viewportRef, zoomIn, zoomOut } = ScalableContainer_useLogic_useLogic({
|
|
4725
4754
|
initialScale,
|
|
4726
4755
|
minScale,
|
|
4727
4756
|
maxScale,
|
|
@@ -4794,6 +4823,7 @@ function ScalableContainer({ initialScale = 1, minScale = 0.1, maxScale = 4, sho
|
|
|
4794
4823
|
"data-slot": "scalable-container-content",
|
|
4795
4824
|
className: ScalableContainer_styles_css_content,
|
|
4796
4825
|
style: contentStyle,
|
|
4826
|
+
onClickCapture: handleClickCapture,
|
|
4797
4827
|
onPointerDown: handlePointerDown,
|
|
4798
4828
|
onPointerMove: handlePointerMove,
|
|
4799
4829
|
onPointerUp: handlePointerEnd,
|
|
@@ -11,4 +11,5 @@ export default _default;
|
|
|
11
11
|
export declare function Basic(): import("react").JSX.Element;
|
|
12
12
|
export declare function WithToolbar(): import("react").JSX.Element;
|
|
13
13
|
export declare function InsideScrollablePage(): import("react").JSX.Element;
|
|
14
|
+
export declare function InteractiveContent(): import("react").JSX.Element;
|
|
14
15
|
//# sourceMappingURL=ScalableContainer.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalableContainer.stories.d.ts","sourceRoot":"","sources":["../../src/stories/ScalableContainer.stories.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;;;;;;;;;AAGjD,wBAO2C;AAqB3C,wBAAgB,KAAK,gCAYpB;AAED,wBAAgB,WAAW,gCA2B1B;AAED,wBAAgB,oBAAoB,gCAoBnC"}
|
|
1
|
+
{"version":3,"file":"ScalableContainer.stories.d.ts","sourceRoot":"","sources":["../../src/stories/ScalableContainer.stories.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;;;;;;;;;AAGjD,wBAO2C;AAqB3C,wBAAgB,KAAK,gCAYpB;AAED,wBAAgB,WAAW,gCA2B1B;AAED,wBAAgB,oBAAoB,gCAoBnC;AAED,wBAAgB,kBAAkB,gCAyCjC"}
|
package/lib/styles.css
CHANGED
|
@@ -2713,7 +2713,7 @@ a.outline__1af895x4:hover {
|
|
|
2713
2713
|
.style__uma6hu0 {
|
|
2714
2714
|
padding: var(--spacing-1) var(--spacing-2);
|
|
2715
2715
|
width: 100%;
|
|
2716
|
-
font-weight: var(--fontWeight-
|
|
2716
|
+
font-weight: var(--fontWeight-medium);
|
|
2717
2717
|
font-size: var(--fontSize-sm);
|
|
2718
2718
|
overflow-wrap: break-word;
|
|
2719
2719
|
background-color: var(--colors-background-paper);
|