@measured/puck 0.18.0-canary.e2139f5 → 0.18.0-canary.f1dec0e
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +22 -9
- package/dist/index.mjs +22 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -3588,9 +3588,20 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3588
3588
|
};
|
3589
3589
|
}
|
3590
3590
|
);
|
3591
|
+
const {
|
3592
|
+
state: {
|
3593
|
+
ui: { isDragging }
|
3594
|
+
}
|
3595
|
+
} = useAppContext();
|
3591
3596
|
const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
|
3597
|
+
const [localPreview, setLocalPreview] = (0, import_react27.useState)(
|
3598
|
+
preview
|
3599
|
+
);
|
3592
3600
|
const updateContent = useRenderedCallback(
|
3593
|
-
(content2, preview2) => {
|
3601
|
+
(content2, preview2, isDragging2) => {
|
3602
|
+
if (isDragging2 && !previewExists) {
|
3603
|
+
return;
|
3604
|
+
}
|
3594
3605
|
if (preview2) {
|
3595
3606
|
if (preview2.type === "insert") {
|
3596
3607
|
setContentWithPreview(
|
@@ -3620,13 +3631,14 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3620
3631
|
previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
|
3621
3632
|
);
|
3622
3633
|
}
|
3634
|
+
setLocalPreview(preview2);
|
3623
3635
|
},
|
3624
3636
|
[draggedItemId, previewExists]
|
3625
3637
|
);
|
3626
3638
|
(0, import_react27.useEffect)(() => {
|
3627
|
-
updateContent(content, preview);
|
3628
|
-
}, [content, preview]);
|
3629
|
-
return contentWithPreview;
|
3639
|
+
updateContent(content, preview, isDragging);
|
3640
|
+
}, [content, preview, isDragging]);
|
3641
|
+
return [contentWithPreview, localPreview];
|
3630
3642
|
};
|
3631
3643
|
|
3632
3644
|
// components/DropZone/lib/use-drag-axis.ts
|
@@ -3706,8 +3718,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3706
3718
|
isDeepestZone,
|
3707
3719
|
inNextDeepestArea,
|
3708
3720
|
draggedComponentType,
|
3709
|
-
userIsDragging
|
3710
|
-
preview
|
3721
|
+
userIsDragging
|
3711
3722
|
} = useContextStore(ZoneStoreContext, (s) => {
|
3712
3723
|
var _a, _b, _c;
|
3713
3724
|
return {
|
@@ -3715,8 +3726,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3715
3726
|
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
3716
3727
|
draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
|
3717
3728
|
draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
|
3718
|
-
userIsDragging: !!s.draggedItem
|
3719
|
-
preview: s.previewIndex[zoneCompound]
|
3729
|
+
userIsDragging: !!s.draggedItem
|
3720
3730
|
};
|
3721
3731
|
});
|
3722
3732
|
const { itemSelector } = appContext2.state.ui;
|
@@ -3782,7 +3792,10 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
|
|
3782
3792
|
if (isEnabled) {
|
3783
3793
|
isEnabled = acceptsTarget(draggedComponentType);
|
3784
3794
|
}
|
3785
|
-
const contentWithPreview = useContentWithPreview(
|
3795
|
+
const [contentWithPreview, preview] = useContentWithPreview(
|
3796
|
+
content,
|
3797
|
+
zoneCompound
|
3798
|
+
);
|
3786
3799
|
const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3787
3800
|
const droppableConfig = {
|
3788
3801
|
id: zoneCompound,
|
package/dist/index.mjs
CHANGED
@@ -3431,9 +3431,20 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3431
3431
|
};
|
3432
3432
|
}
|
3433
3433
|
);
|
3434
|
+
const {
|
3435
|
+
state: {
|
3436
|
+
ui: { isDragging }
|
3437
|
+
}
|
3438
|
+
} = useAppContext();
|
3434
3439
|
const [contentWithPreview, setContentWithPreview] = useState15(content);
|
3440
|
+
const [localPreview, setLocalPreview] = useState15(
|
3441
|
+
preview
|
3442
|
+
);
|
3435
3443
|
const updateContent = useRenderedCallback(
|
3436
|
-
(content2, preview2) => {
|
3444
|
+
(content2, preview2, isDragging2) => {
|
3445
|
+
if (isDragging2 && !previewExists) {
|
3446
|
+
return;
|
3447
|
+
}
|
3437
3448
|
if (preview2) {
|
3438
3449
|
if (preview2.type === "insert") {
|
3439
3450
|
setContentWithPreview(
|
@@ -3463,13 +3474,14 @@ var useContentWithPreview = (content, zoneCompound) => {
|
|
3463
3474
|
previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
|
3464
3475
|
);
|
3465
3476
|
}
|
3477
|
+
setLocalPreview(preview2);
|
3466
3478
|
},
|
3467
3479
|
[draggedItemId, previewExists]
|
3468
3480
|
);
|
3469
3481
|
useEffect12(() => {
|
3470
|
-
updateContent(content, preview);
|
3471
|
-
}, [content, preview]);
|
3472
|
-
return contentWithPreview;
|
3482
|
+
updateContent(content, preview, isDragging);
|
3483
|
+
}, [content, preview, isDragging]);
|
3484
|
+
return [contentWithPreview, localPreview];
|
3473
3485
|
};
|
3474
3486
|
|
3475
3487
|
// components/DropZone/lib/use-drag-axis.ts
|
@@ -3549,8 +3561,7 @@ var DropZoneEdit = forwardRef3(
|
|
3549
3561
|
isDeepestZone,
|
3550
3562
|
inNextDeepestArea,
|
3551
3563
|
draggedComponentType,
|
3552
|
-
userIsDragging
|
3553
|
-
preview
|
3564
|
+
userIsDragging
|
3554
3565
|
} = useContextStore(ZoneStoreContext, (s) => {
|
3555
3566
|
var _a, _b, _c;
|
3556
3567
|
return {
|
@@ -3558,8 +3569,7 @@ var DropZoneEdit = forwardRef3(
|
|
3558
3569
|
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
3559
3570
|
draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
|
3560
3571
|
draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
|
3561
|
-
userIsDragging: !!s.draggedItem
|
3562
|
-
preview: s.previewIndex[zoneCompound]
|
3572
|
+
userIsDragging: !!s.draggedItem
|
3563
3573
|
};
|
3564
3574
|
});
|
3565
3575
|
const { itemSelector } = appContext2.state.ui;
|
@@ -3625,7 +3635,10 @@ var DropZoneEdit = forwardRef3(
|
|
3625
3635
|
if (isEnabled) {
|
3626
3636
|
isEnabled = acceptsTarget(draggedComponentType);
|
3627
3637
|
}
|
3628
|
-
const contentWithPreview = useContentWithPreview(
|
3638
|
+
const [contentWithPreview, preview] = useContentWithPreview(
|
3639
|
+
content,
|
3640
|
+
zoneCompound
|
3641
|
+
);
|
3629
3642
|
const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
|
3630
3643
|
const droppableConfig = {
|
3631
3644
|
id: zoneCompound,
|
package/package.json
CHANGED