@measured/puck 0.19.0-canary.5bf4fccf → 0.19.0-canary.6dc5101e
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/dist/{chunk-COT3ZFIM.mjs → chunk-DDGE2CCN.mjs} +329 -30
- package/dist/index.css +4 -4
- package/dist/index.d.mts +9 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.js +217 -531
- package/dist/index.mjs +80 -706
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +326 -33
- package/dist/rsc.mjs +3 -1
- package/dist/{walk-tree-CM-cu7GU.d.mts → walk-tree-DOB5QZVq.d.mts} +9 -7
- package/dist/{walk-tree-CM-cu7GU.d.ts → walk-tree-DOB5QZVq.d.ts} +9 -7
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -9,9 +9,6 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
9
|
var __getProtoOf = Object.getPrototypeOf;
|
10
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
11
11
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
12
|
-
var __typeError = (msg) => {
|
13
|
-
throw TypeError(msg);
|
14
|
-
};
|
15
12
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
16
13
|
var __spreadValues = (a, b) => {
|
17
14
|
for (var prop in b || (b = {}))
|
@@ -64,10 +61,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
64
61
|
mod
|
65
62
|
));
|
66
63
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
67
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
68
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
69
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
70
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
71
64
|
var __async = (__this, __arguments, generator) => {
|
72
65
|
return new Promise((resolve, reject) => {
|
73
66
|
var fulfilled = (value) => {
|
@@ -181,6 +174,7 @@ __export(core_exports, {
|
|
181
174
|
renderContext: () => renderContext,
|
182
175
|
resolveAllData: () => resolveAllData,
|
183
176
|
transformProps: () => transformProps,
|
177
|
+
useGetPuck: () => useGetPuck,
|
184
178
|
usePuck: () => usePuck,
|
185
179
|
walkTree: () => walkTree
|
186
180
|
});
|
@@ -2186,7 +2180,8 @@ var toRoot = (item) => {
|
|
2186
2180
|
return { props: {}, readOnly };
|
2187
2181
|
};
|
2188
2182
|
|
2189
|
-
// store/
|
2183
|
+
// store/default-app-state.ts
|
2184
|
+
init_react_import();
|
2190
2185
|
var defaultAppState = {
|
2191
2186
|
data: { content: [], root: {}, zones: {} },
|
2192
2187
|
ui: {
|
@@ -2212,6 +2207,8 @@ var defaultAppState = {
|
|
2212
2207
|
zones: {}
|
2213
2208
|
}
|
2214
2209
|
};
|
2210
|
+
|
2211
|
+
// store/index.ts
|
2215
2212
|
var defaultPageFields = {
|
2216
2213
|
title: { type: "text" }
|
2217
2214
|
};
|
@@ -2400,314 +2397,11 @@ function useAppStoreApi() {
|
|
2400
2397
|
init_react_import();
|
2401
2398
|
var import_react12 = require("@dnd-kit/react");
|
2402
2399
|
|
2403
|
-
// lib/dnd/dnd-kit/safe.ts
|
2404
|
-
init_react_import();
|
2405
|
-
var import_react10 = require("@dnd-kit/react");
|
2406
|
-
var import_sortable = require("@dnd-kit/react/sortable");
|
2407
|
-
function useDroppableSafe(input) {
|
2408
|
-
if (typeof window === "undefined") {
|
2409
|
-
return { ref: () => {
|
2410
|
-
} };
|
2411
|
-
}
|
2412
|
-
return (0, import_react10.useDroppable)(input);
|
2413
|
-
}
|
2414
|
-
function useDraggableSafe(input) {
|
2415
|
-
if (typeof window === "undefined") {
|
2416
|
-
return { ref: () => {
|
2417
|
-
} };
|
2418
|
-
}
|
2419
|
-
return (0, import_react10.useDraggable)(input);
|
2420
|
-
}
|
2421
|
-
function useSortableSafe(input) {
|
2422
|
-
if (typeof window === "undefined") {
|
2423
|
-
return { ref: () => {
|
2424
|
-
}, status: "idle", handleRef: () => {
|
2425
|
-
} };
|
2426
|
-
}
|
2427
|
-
return (0, import_sortable.useSortable)(input);
|
2428
|
-
}
|
2429
|
-
|
2430
2400
|
// lib/dnd/use-sensors.ts
|
2431
2401
|
init_react_import();
|
2432
|
-
var
|
2433
|
-
|
2434
|
-
// lib/dnd/PointerSensor.ts
|
2435
|
-
init_react_import();
|
2436
|
-
var import_state = require("@dnd-kit/state");
|
2437
|
-
var import_abstract = require("@dnd-kit/abstract");
|
2438
|
-
var import_geometry = require("@dnd-kit/geometry");
|
2402
|
+
var import_react10 = require("react");
|
2403
|
+
var import_react11 = require("@dnd-kit/react");
|
2439
2404
|
var import_utilities = require("@dnd-kit/dom/utilities");
|
2440
|
-
var _clearTimeout;
|
2441
|
-
var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
|
2442
|
-
constructor(manager, options) {
|
2443
|
-
super(manager);
|
2444
|
-
this.manager = manager;
|
2445
|
-
this.options = options;
|
2446
|
-
this.listeners = new import_utilities.Listeners();
|
2447
|
-
this.cleanup = /* @__PURE__ */ new Set();
|
2448
|
-
this.source = void 0;
|
2449
|
-
this.started = false;
|
2450
|
-
__privateAdd(this, _clearTimeout);
|
2451
|
-
this.handleCancel = this.handleCancel.bind(this);
|
2452
|
-
this.handlePointerUp = this.handlePointerUp.bind(this);
|
2453
|
-
this.handleKeyDown = this.handleKeyDown.bind(this);
|
2454
|
-
(0, import_state.effect)(() => {
|
2455
|
-
const unbindGlobal = this.bindGlobal(options != null ? options : {});
|
2456
|
-
return () => {
|
2457
|
-
unbindGlobal();
|
2458
|
-
};
|
2459
|
-
});
|
2460
|
-
}
|
2461
|
-
bind(source, options = this.options) {
|
2462
|
-
const unbind = (0, import_state.effect)(() => {
|
2463
|
-
var _a;
|
2464
|
-
const target = (_a = source.handle) != null ? _a : source.element;
|
2465
|
-
const listener = (event) => {
|
2466
|
-
if ((0, import_utilities.isPointerEvent)(event)) {
|
2467
|
-
this.handlePointerDown(event, source, options);
|
2468
|
-
}
|
2469
|
-
};
|
2470
|
-
if (target) {
|
2471
|
-
patchWindow(target.ownerDocument.defaultView);
|
2472
|
-
target.addEventListener("pointerdown", listener);
|
2473
|
-
return () => {
|
2474
|
-
target.removeEventListener("pointerdown", listener);
|
2475
|
-
};
|
2476
|
-
}
|
2477
|
-
});
|
2478
|
-
return unbind;
|
2479
|
-
}
|
2480
|
-
bindGlobal(options) {
|
2481
|
-
const documents = /* @__PURE__ */ new Set();
|
2482
|
-
for (const draggable of this.manager.registry.draggables.value) {
|
2483
|
-
if (draggable.element) {
|
2484
|
-
documents.add((0, import_utilities.getDocument)(draggable.element));
|
2485
|
-
}
|
2486
|
-
}
|
2487
|
-
for (const droppable of this.manager.registry.droppables.value) {
|
2488
|
-
if (droppable.element) {
|
2489
|
-
documents.add((0, import_utilities.getDocument)(droppable.element));
|
2490
|
-
}
|
2491
|
-
}
|
2492
|
-
const unbindFns = Array.from(documents).map(
|
2493
|
-
(doc) => this.listeners.bind(doc, [
|
2494
|
-
{
|
2495
|
-
type: "pointermove",
|
2496
|
-
listener: (event) => this.handlePointerMove(event, doc, options)
|
2497
|
-
},
|
2498
|
-
{
|
2499
|
-
type: "pointerup",
|
2500
|
-
listener: this.handlePointerUp,
|
2501
|
-
options: {
|
2502
|
-
capture: true
|
2503
|
-
}
|
2504
|
-
},
|
2505
|
-
{
|
2506
|
-
// Cancel activation if there is a competing Drag and Drop interaction
|
2507
|
-
type: "dragstart",
|
2508
|
-
listener: this.handleDragStart
|
2509
|
-
}
|
2510
|
-
])
|
2511
|
-
);
|
2512
|
-
return () => {
|
2513
|
-
unbindFns.forEach((unbind) => unbind());
|
2514
|
-
};
|
2515
|
-
}
|
2516
|
-
handlePointerDown(event, source, options = {}) {
|
2517
|
-
if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
|
2518
|
-
return;
|
2519
|
-
}
|
2520
|
-
const offset = (0, import_utilities.getFrameTransform)(source.element);
|
2521
|
-
this.initialCoordinates = {
|
2522
|
-
x: event.clientX * offset.scaleX + offset.x,
|
2523
|
-
y: event.clientY * offset.scaleY + offset.y
|
2524
|
-
};
|
2525
|
-
this.source = source;
|
2526
|
-
const { activationConstraints } = options;
|
2527
|
-
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
|
2528
|
-
event.stopImmediatePropagation();
|
2529
|
-
if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
|
2530
|
-
this.handleStart(source, event);
|
2531
|
-
} else {
|
2532
|
-
const { delay } = constraints;
|
2533
|
-
if (delay) {
|
2534
|
-
const timeout3 = setTimeout(
|
2535
|
-
() => this.handleStart(source, event),
|
2536
|
-
delay.value
|
2537
|
-
);
|
2538
|
-
__privateSet(this, _clearTimeout, () => {
|
2539
|
-
clearTimeout(timeout3);
|
2540
|
-
__privateSet(this, _clearTimeout, void 0);
|
2541
|
-
});
|
2542
|
-
}
|
2543
|
-
}
|
2544
|
-
const cleanup = () => {
|
2545
|
-
var _a;
|
2546
|
-
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
2547
|
-
this.initialCoordinates = void 0;
|
2548
|
-
this.source = void 0;
|
2549
|
-
};
|
2550
|
-
this.cleanup.add(cleanup);
|
2551
|
-
}
|
2552
|
-
handlePointerMove(event, doc, options) {
|
2553
|
-
if (!this.source) {
|
2554
|
-
return;
|
2555
|
-
}
|
2556
|
-
const ownerDocument = this.source.element && (0, import_utilities.getDocument)(this.source.element);
|
2557
|
-
if (doc !== ownerDocument) {
|
2558
|
-
return;
|
2559
|
-
}
|
2560
|
-
const coordinates = {
|
2561
|
-
x: event.clientX,
|
2562
|
-
y: event.clientY
|
2563
|
-
};
|
2564
|
-
const offset = (0, import_utilities.getFrameTransform)(this.source.element);
|
2565
|
-
coordinates.x = coordinates.x * offset.scaleX + offset.x;
|
2566
|
-
coordinates.y = coordinates.y * offset.scaleY + offset.y;
|
2567
|
-
if (this.manager.dragOperation.status.dragging) {
|
2568
|
-
event.preventDefault();
|
2569
|
-
event.stopPropagation();
|
2570
|
-
this.manager.actions.move({ to: coordinates });
|
2571
|
-
return;
|
2572
|
-
}
|
2573
|
-
if (!this.initialCoordinates) {
|
2574
|
-
return;
|
2575
|
-
}
|
2576
|
-
const delta = {
|
2577
|
-
x: coordinates.x - this.initialCoordinates.x,
|
2578
|
-
y: coordinates.y - this.initialCoordinates.y
|
2579
|
-
};
|
2580
|
-
const { activationConstraints } = options;
|
2581
|
-
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
|
2582
|
-
const { distance, delay } = constraints != null ? constraints : {};
|
2583
|
-
if (distance) {
|
2584
|
-
if (distance.tolerance != null && (0, import_geometry.exceedsDistance)(delta, distance.tolerance)) {
|
2585
|
-
return this.handleCancel();
|
2586
|
-
}
|
2587
|
-
if ((0, import_geometry.exceedsDistance)(delta, distance.value)) {
|
2588
|
-
return this.handleStart(this.source, event);
|
2589
|
-
}
|
2590
|
-
}
|
2591
|
-
if (delay) {
|
2592
|
-
if ((0, import_geometry.exceedsDistance)(delta, delay.tolerance)) {
|
2593
|
-
return this.handleCancel();
|
2594
|
-
}
|
2595
|
-
}
|
2596
|
-
}
|
2597
|
-
handlePointerUp(event) {
|
2598
|
-
if (!this.source) {
|
2599
|
-
return;
|
2600
|
-
}
|
2601
|
-
event.preventDefault();
|
2602
|
-
event.stopPropagation();
|
2603
|
-
const { status } = this.manager.dragOperation;
|
2604
|
-
if (!status.idle) {
|
2605
|
-
const canceled = !status.initialized;
|
2606
|
-
this.manager.actions.stop({ canceled });
|
2607
|
-
} else if (this.started) {
|
2608
|
-
setTimeout(() => {
|
2609
|
-
if (!this.manager.dragOperation.status.idle) {
|
2610
|
-
this.manager.actions.stop({ canceled: false });
|
2611
|
-
}
|
2612
|
-
}, 10);
|
2613
|
-
}
|
2614
|
-
this.cleanup.forEach((cleanup) => cleanup());
|
2615
|
-
this.cleanup.clear();
|
2616
|
-
}
|
2617
|
-
handleKeyDown(event) {
|
2618
|
-
if (event.key === "Escape") {
|
2619
|
-
event.preventDefault();
|
2620
|
-
this.handleCancel();
|
2621
|
-
}
|
2622
|
-
}
|
2623
|
-
handleStart(source, event) {
|
2624
|
-
var _a;
|
2625
|
-
const { manager, initialCoordinates } = this;
|
2626
|
-
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
2627
|
-
if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
|
2628
|
-
return;
|
2629
|
-
}
|
2630
|
-
if (event.defaultPrevented) {
|
2631
|
-
return;
|
2632
|
-
}
|
2633
|
-
this.started = true;
|
2634
|
-
event.preventDefault();
|
2635
|
-
(0, import_state.batch)(() => {
|
2636
|
-
manager.actions.setDragSource(source.id);
|
2637
|
-
manager.actions.start({ coordinates: initialCoordinates, event });
|
2638
|
-
});
|
2639
|
-
const ownerDocument = (0, import_utilities.getDocument)(event.target);
|
2640
|
-
const unbind = this.listeners.bind(ownerDocument, [
|
2641
|
-
{
|
2642
|
-
// Prevent scrolling on touch devices
|
2643
|
-
type: "touchmove",
|
2644
|
-
listener: preventDefault,
|
2645
|
-
options: {
|
2646
|
-
passive: false
|
2647
|
-
}
|
2648
|
-
},
|
2649
|
-
{
|
2650
|
-
// Prevent click events
|
2651
|
-
type: "click",
|
2652
|
-
listener: preventDefault
|
2653
|
-
},
|
2654
|
-
{
|
2655
|
-
type: "keydown",
|
2656
|
-
listener: this.handleKeyDown
|
2657
|
-
}
|
2658
|
-
]);
|
2659
|
-
ownerDocument.body.setPointerCapture(event.pointerId);
|
2660
|
-
this.cleanup.add(unbind);
|
2661
|
-
this.cleanup.add(() => {
|
2662
|
-
this.started = false;
|
2663
|
-
});
|
2664
|
-
}
|
2665
|
-
handleDragStart(event) {
|
2666
|
-
const { target } = event;
|
2667
|
-
if (!(0, import_utilities.isElement)(target)) {
|
2668
|
-
return;
|
2669
|
-
}
|
2670
|
-
const isNativeDraggable = (0, import_utilities.isHTMLElement)(target) && target.draggable && target.getAttribute("draggable") === "true";
|
2671
|
-
if (isNativeDraggable) {
|
2672
|
-
this.handleCancel();
|
2673
|
-
} else {
|
2674
|
-
preventDefault(event);
|
2675
|
-
}
|
2676
|
-
}
|
2677
|
-
handleCancel() {
|
2678
|
-
const { dragOperation } = this.manager;
|
2679
|
-
if (dragOperation.status.initialized) {
|
2680
|
-
this.manager.actions.stop({ canceled: true });
|
2681
|
-
}
|
2682
|
-
this.cleanup.forEach((cleanup) => cleanup());
|
2683
|
-
this.cleanup.clear();
|
2684
|
-
}
|
2685
|
-
destroy() {
|
2686
|
-
this.listeners.clear();
|
2687
|
-
}
|
2688
|
-
};
|
2689
|
-
_clearTimeout = new WeakMap();
|
2690
|
-
_PointerSensor.configure = (0, import_abstract.configurator)(_PointerSensor);
|
2691
|
-
var PointerSensor = _PointerSensor;
|
2692
|
-
function preventDefault(event) {
|
2693
|
-
event.preventDefault();
|
2694
|
-
}
|
2695
|
-
function noop() {
|
2696
|
-
}
|
2697
|
-
var windows = /* @__PURE__ */ new WeakSet();
|
2698
|
-
function patchWindow(window2) {
|
2699
|
-
if (!window2 || windows.has(window2)) {
|
2700
|
-
return;
|
2701
|
-
}
|
2702
|
-
window2.addEventListener("touchmove", noop, {
|
2703
|
-
capture: false,
|
2704
|
-
passive: false
|
2705
|
-
});
|
2706
|
-
windows.add(window2);
|
2707
|
-
}
|
2708
|
-
|
2709
|
-
// lib/dnd/use-sensors.ts
|
2710
|
-
var import_utilities2 = require("@dnd-kit/dom/utilities");
|
2711
2405
|
var useSensors = ({
|
2712
2406
|
other,
|
2713
2407
|
mouse,
|
@@ -2716,12 +2410,12 @@ var useSensors = ({
|
|
2716
2410
|
touch: { delay: { value: 200, tolerance: 10 } },
|
2717
2411
|
other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
|
2718
2412
|
}) => {
|
2719
|
-
const [sensors] = (0,
|
2720
|
-
PointerSensor.configure({
|
2413
|
+
const [sensors] = (0, import_react10.useState)(() => [
|
2414
|
+
import_react11.PointerSensor.configure({
|
2721
2415
|
activationConstraints(event, source) {
|
2722
2416
|
var _a;
|
2723
2417
|
const { pointerType, target } = event;
|
2724
|
-
if (pointerType === "mouse" && (0,
|
2418
|
+
if (pointerType === "mouse" && (0, import_utilities.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
2725
2419
|
return mouse;
|
2726
2420
|
}
|
2727
2421
|
if (pointerType === "touch") {
|
@@ -2736,11 +2430,11 @@ var useSensors = ({
|
|
2736
2430
|
|
2737
2431
|
// lib/dnd/collision/dynamic/index.ts
|
2738
2432
|
init_react_import();
|
2739
|
-
var
|
2433
|
+
var import_abstract8 = require("@dnd-kit/abstract");
|
2740
2434
|
|
2741
2435
|
// lib/dnd/collision/directional/index.ts
|
2742
2436
|
init_react_import();
|
2743
|
-
var
|
2437
|
+
var import_abstract = require("@dnd-kit/abstract");
|
2744
2438
|
|
2745
2439
|
// lib/dnd/collision/collision-debug.ts
|
2746
2440
|
init_react_import();
|
@@ -2818,7 +2512,7 @@ var directionalCollision = (input, previous) => {
|
|
2818
2512
|
return {
|
2819
2513
|
id: droppable.id,
|
2820
2514
|
value: 1,
|
2821
|
-
type:
|
2515
|
+
type: import_abstract.CollisionType.Collision
|
2822
2516
|
};
|
2823
2517
|
}
|
2824
2518
|
return null;
|
@@ -2860,7 +2554,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
|
|
2860
2554
|
|
2861
2555
|
// lib/dnd/collision/dynamic/track-movement-interval.ts
|
2862
2556
|
init_react_import();
|
2863
|
-
var
|
2557
|
+
var import_geometry = require("@dnd-kit/geometry");
|
2864
2558
|
var INTERVAL_SENSITIVITY = 10;
|
2865
2559
|
var intervalCache = {
|
2866
2560
|
current: { x: 0, y: 0 },
|
@@ -2876,13 +2570,15 @@ var trackMovementInterval = (point, dragAxis = "dynamic") => {
|
|
2876
2570
|
};
|
2877
2571
|
intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
|
2878
2572
|
if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
|
2879
|
-
intervalCache.previous =
|
2573
|
+
intervalCache.previous = import_geometry.Point.from(point);
|
2880
2574
|
}
|
2881
2575
|
return intervalCache;
|
2882
2576
|
};
|
2883
2577
|
|
2884
2578
|
// ../../node_modules/@dnd-kit/collision/dist/index.js
|
2885
2579
|
init_react_import();
|
2580
|
+
var import_abstract2 = require("@dnd-kit/abstract");
|
2581
|
+
var import_geometry2 = require("@dnd-kit/geometry");
|
2886
2582
|
var import_abstract3 = require("@dnd-kit/abstract");
|
2887
2583
|
var import_geometry3 = require("@dnd-kit/geometry");
|
2888
2584
|
var import_abstract4 = require("@dnd-kit/abstract");
|
@@ -2893,8 +2589,6 @@ var import_abstract6 = require("@dnd-kit/abstract");
|
|
2893
2589
|
var import_geometry6 = require("@dnd-kit/geometry");
|
2894
2590
|
var import_abstract7 = require("@dnd-kit/abstract");
|
2895
2591
|
var import_geometry7 = require("@dnd-kit/geometry");
|
2896
|
-
var import_abstract8 = require("@dnd-kit/abstract");
|
2897
|
-
var import_geometry8 = require("@dnd-kit/geometry");
|
2898
2592
|
var pointerIntersection = ({
|
2899
2593
|
dragOperation,
|
2900
2594
|
droppable
|
@@ -2908,12 +2602,12 @@ var pointerIntersection = ({
|
|
2908
2602
|
return null;
|
2909
2603
|
}
|
2910
2604
|
if (droppable.shape.containsPoint(pointerCoordinates)) {
|
2911
|
-
const distance =
|
2605
|
+
const distance = import_geometry2.Point.distance(droppable.shape.center, pointerCoordinates);
|
2912
2606
|
return {
|
2913
2607
|
id,
|
2914
2608
|
value: 1 / distance,
|
2915
|
-
type:
|
2916
|
-
priority:
|
2609
|
+
type: import_abstract2.CollisionType.PointerIntersection,
|
2610
|
+
priority: import_abstract2.CollisionPriority.High
|
2917
2611
|
};
|
2918
2612
|
}
|
2919
2613
|
return null;
|
@@ -2924,31 +2618,15 @@ var closestCorners = (input) => {
|
|
2924
2618
|
if (!droppable.shape) {
|
2925
2619
|
return null;
|
2926
2620
|
}
|
2927
|
-
const
|
2928
|
-
const
|
2929
|
-
|
2930
|
-
|
2931
|
-
|
2932
|
-
},
|
2933
|
-
{
|
2934
|
-
x: right,
|
2935
|
-
y: top
|
2936
|
-
},
|
2937
|
-
{
|
2938
|
-
x: left,
|
2939
|
-
y: bottom
|
2940
|
-
},
|
2941
|
-
{
|
2942
|
-
x: right,
|
2943
|
-
y: bottom
|
2944
|
-
}
|
2945
|
-
];
|
2946
|
-
const distance = corners.reduce(
|
2947
|
-
(acc, corner) => {
|
2621
|
+
const shapeCorners = shape ? import_geometry4.Rectangle.from(shape.current.boundingRectangle).corners : void 0;
|
2622
|
+
const distance = import_geometry4.Rectangle.from(
|
2623
|
+
droppable.shape.boundingRectangle
|
2624
|
+
).corners.reduce(
|
2625
|
+
(acc, corner, index) => {
|
2948
2626
|
var _a;
|
2949
|
-
return acc +
|
2950
|
-
|
2951
|
-
(_a =
|
2627
|
+
return acc + import_geometry4.Point.distance(
|
2628
|
+
import_geometry4.Point.from(corner),
|
2629
|
+
(_a = shapeCorners == null ? void 0 : shapeCorners[index]) != null ? _a : position.current
|
2952
2630
|
);
|
2953
2631
|
},
|
2954
2632
|
0
|
@@ -2957,8 +2635,8 @@ var closestCorners = (input) => {
|
|
2957
2635
|
return {
|
2958
2636
|
id: droppable.id,
|
2959
2637
|
value: 1 / value,
|
2960
|
-
type:
|
2961
|
-
priority:
|
2638
|
+
type: import_abstract4.CollisionType.Collision,
|
2639
|
+
priority: import_abstract4.CollisionPriority.Normal
|
2962
2640
|
};
|
2963
2641
|
};
|
2964
2642
|
|
@@ -2983,12 +2661,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2983
2661
|
const { center: dragCenter } = dragShape;
|
2984
2662
|
const { fallbackEnabled } = collisionStore.getState();
|
2985
2663
|
const interval = trackMovementInterval(position.current, dragAxis);
|
2986
|
-
|
2987
|
-
direction: interval.direction
|
2988
|
-
});
|
2989
|
-
const collisionMap = dragOperation.data.collisionMap || {};
|
2990
|
-
dragOperation.data.collisionMap = collisionMap;
|
2991
|
-
collisionMap[droppable.id] = {
|
2664
|
+
const data = {
|
2992
2665
|
direction: interval.direction
|
2993
2666
|
};
|
2994
2667
|
const { center: dropCenter } = dropShape;
|
@@ -3003,7 +2676,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
3003
2676
|
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
|
3004
2677
|
if (collision) {
|
3005
2678
|
return __spreadProps(__spreadValues({}, collision), {
|
3006
|
-
priority:
|
2679
|
+
priority: import_abstract8.CollisionPriority.Highest,
|
2680
|
+
data
|
3007
2681
|
});
|
3008
2682
|
}
|
3009
2683
|
}
|
@@ -3020,12 +2694,12 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
3020
2694
|
const collision = {
|
3021
2695
|
id: droppable.id,
|
3022
2696
|
value: intersectionRatio,
|
3023
|
-
priority:
|
3024
|
-
type:
|
2697
|
+
priority: import_abstract8.CollisionPriority.High,
|
2698
|
+
type: import_abstract8.CollisionType.Collision
|
3025
2699
|
};
|
3026
2700
|
const shouldFlushId = flushNext === droppable.id;
|
3027
2701
|
flushNext = "";
|
3028
|
-
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2702
|
+
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id, data });
|
3029
2703
|
}
|
3030
2704
|
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
3031
2705
|
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
@@ -3037,9 +2711,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
3037
2711
|
x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
|
3038
2712
|
y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
|
3039
2713
|
});
|
3040
|
-
|
3041
|
-
direction
|
3042
|
-
};
|
2714
|
+
data.direction = direction;
|
3043
2715
|
if (intersectionArea) {
|
3044
2716
|
collisionDebug(
|
3045
2717
|
dragCenter,
|
@@ -3050,7 +2722,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
3050
2722
|
);
|
3051
2723
|
flushNext = droppable.id;
|
3052
2724
|
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
3053
|
-
priority:
|
2725
|
+
priority: import_abstract8.CollisionPriority.Low,
|
2726
|
+
data
|
3054
2727
|
});
|
3055
2728
|
}
|
3056
2729
|
collisionDebug(
|
@@ -3060,16 +2733,19 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
3060
2733
|
"orange",
|
3061
2734
|
direction || ""
|
3062
2735
|
);
|
3063
|
-
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2736
|
+
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2737
|
+
priority: import_abstract8.CollisionPriority.Lowest,
|
2738
|
+
data
|
2739
|
+
});
|
3064
2740
|
}
|
3065
2741
|
}
|
3066
2742
|
}
|
3067
2743
|
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
|
3068
|
-
delete collisionMap[droppable.id];
|
3069
2744
|
return null;
|
3070
2745
|
};
|
3071
2746
|
|
3072
2747
|
// components/Sortable/index.tsx
|
2748
|
+
var import_sortable = require("@dnd-kit/react/sortable");
|
3073
2749
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
3074
2750
|
var SortableProvider = ({
|
3075
2751
|
children,
|
@@ -3089,16 +2765,16 @@ var SortableProvider = ({
|
|
3089
2765
|
return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
|
3090
2766
|
},
|
3091
2767
|
onDragOver: (event, manager) => {
|
3092
|
-
var _a
|
2768
|
+
var _a;
|
3093
2769
|
event.preventDefault();
|
3094
2770
|
const { operation } = event;
|
3095
2771
|
const { source, target } = operation;
|
3096
2772
|
if (!source || !target) return;
|
3097
2773
|
let sourceIndex = source.data.index;
|
3098
2774
|
let targetIndex = target.data.index;
|
3099
|
-
const collisionData = (
|
2775
|
+
const collisionData = (_a = manager.collisionObserver.collisions[0]) == null ? void 0 : _a.data;
|
3100
2776
|
if (sourceIndex !== targetIndex && source.id !== target.id) {
|
3101
|
-
const collisionPosition = collisionData.direction === "up" ? "before" : "after";
|
2777
|
+
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
|
3102
2778
|
if (targetIndex >= sourceIndex) {
|
3103
2779
|
targetIndex = targetIndex - 1;
|
3104
2780
|
}
|
@@ -3129,9 +2805,10 @@ var Sortable = ({
|
|
3129
2805
|
}) => {
|
3130
2806
|
const {
|
3131
2807
|
ref: sortableRef,
|
3132
|
-
|
2808
|
+
isDragging,
|
2809
|
+
isDropping,
|
3133
2810
|
handleRef
|
3134
|
-
} =
|
2811
|
+
} = (0, import_sortable.useSortable)({
|
3135
2812
|
id,
|
3136
2813
|
type,
|
3137
2814
|
index,
|
@@ -3139,7 +2816,7 @@ var Sortable = ({
|
|
3139
2816
|
data: { index },
|
3140
2817
|
collisionDetector: createDynamicCollisionDetector("y")
|
3141
2818
|
});
|
3142
|
-
return children({
|
2819
|
+
return children({ isDragging, isDropping, ref: sortableRef, handleRef });
|
3143
2820
|
};
|
3144
2821
|
|
3145
2822
|
// components/AutoField/context.tsx
|
@@ -3264,7 +2941,7 @@ var ArrayField = ({
|
|
3264
2941
|
}
|
3265
2942
|
}, []);
|
3266
2943
|
const [draggedItem, setDraggedItem] = (0, import_react14.useState)("");
|
3267
|
-
const
|
2944
|
+
const isDraggingAny = !!draggedItem;
|
3268
2945
|
const canEdit = useAppStore(
|
3269
2946
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
3270
2947
|
);
|
@@ -3329,13 +3006,13 @@ var ArrayField = ({
|
|
3329
3006
|
id: _arrayId,
|
3330
3007
|
index: i,
|
3331
3008
|
disabled: readOnly,
|
3332
|
-
children: ({
|
3009
|
+
children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
3333
3010
|
"div",
|
3334
3011
|
{
|
3335
3012
|
ref,
|
3336
3013
|
className: getClassNameItem({
|
3337
3014
|
isExpanded: arrayState.openId === _arrayId,
|
3338
|
-
isDragging
|
3015
|
+
isDragging,
|
3339
3016
|
readOnly
|
3340
3017
|
}),
|
3341
3018
|
children: [
|
@@ -3476,7 +3153,7 @@ var ArrayField = ({
|
|
3476
3153
|
type: "button",
|
3477
3154
|
className: getClassName5("addButton"),
|
3478
3155
|
onClick: () => {
|
3479
|
-
if (
|
3156
|
+
if (isDraggingAny) return;
|
3480
3157
|
const existingValue = value || [];
|
3481
3158
|
const newValue = [
|
3482
3159
|
...existingValue,
|
@@ -4462,12 +4139,12 @@ init_react_import();
|
|
4462
4139
|
var styles_module_default10 = { "Drawer": "_Drawer_pl7z0_1", "Drawer-draggable": "_Drawer-draggable_pl7z0_8", "Drawer-draggableBg": "_Drawer-draggableBg_pl7z0_12", "DrawerItem-draggable": "_DrawerItem-draggable_pl7z0_22", "DrawerItem--disabled": "_DrawerItem--disabled_pl7z0_35", "DrawerItem": "_DrawerItem_pl7z0_22", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_pl7z0_45", "DrawerItem-name": "_DrawerItem-name_pl7z0_63" };
|
4463
4140
|
|
4464
4141
|
// components/Drawer/index.tsx
|
4465
|
-
var
|
4142
|
+
var import_react38 = require("react");
|
4466
4143
|
|
4467
4144
|
// components/DragDropContext/index.tsx
|
4468
4145
|
init_react_import();
|
4469
|
-
var
|
4470
|
-
var
|
4146
|
+
var import_react36 = require("@dnd-kit/react");
|
4147
|
+
var import_react37 = require("react");
|
4471
4148
|
var import_dom = require("@dnd-kit/dom");
|
4472
4149
|
|
4473
4150
|
// components/DropZone/index.tsx
|
@@ -4577,6 +4254,7 @@ function useContextStore(context, selector) {
|
|
4577
4254
|
|
4578
4255
|
// components/DraggableComponent/index.tsx
|
4579
4256
|
var import_shallow2 = require("zustand/react/shallow");
|
4257
|
+
var import_sortable2 = require("@dnd-kit/react/sortable");
|
4580
4258
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
4581
4259
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
4582
4260
|
var DEBUG2 = false;
|
@@ -4662,7 +4340,7 @@ var DraggableComponent = ({
|
|
4662
4340
|
const canCollide = permissions.drag || userIsDragging;
|
4663
4341
|
const disabled = !isEnabled || !canCollide;
|
4664
4342
|
const [dragAxis, setDragAxis] = (0, import_react25.useState)(userDragAxis || autoDragAxis);
|
4665
|
-
const { ref: sortableRef,
|
4343
|
+
const { ref: sortableRef, isDragging: thisIsDragging } = (0, import_sortable2.useSortable)({
|
4666
4344
|
id,
|
4667
4345
|
index,
|
4668
4346
|
group: zoneCompound,
|
@@ -4684,9 +4362,9 @@ var DraggableComponent = ({
|
|
4684
4362
|
transition: {
|
4685
4363
|
duration: 200,
|
4686
4364
|
easing: "cubic-bezier(0.2, 0, 0, 1)"
|
4687
|
-
}
|
4365
|
+
},
|
4366
|
+
feedback: "clone"
|
4688
4367
|
});
|
4689
|
-
const thisIsDragging = status === "dragging";
|
4690
4368
|
const ref = (0, import_react25.useRef)(null);
|
4691
4369
|
const refSetter = (0, import_react25.useCallback)(
|
4692
4370
|
(el) => {
|
@@ -4826,18 +4504,12 @@ var DraggableComponent = ({
|
|
4826
4504
|
el.addEventListener("click", onClick);
|
4827
4505
|
el.addEventListener("mouseover", _onMouseOver);
|
4828
4506
|
el.addEventListener("mouseout", _onMouseOut);
|
4829
|
-
if (thisIsDragging) {
|
4830
|
-
el.setAttribute("data-puck-dragging", "");
|
4831
|
-
} else {
|
4832
|
-
el.removeAttribute("data-puck-dragging");
|
4833
|
-
}
|
4834
4507
|
return () => {
|
4835
4508
|
el.removeAttribute("data-puck-component");
|
4836
4509
|
el.removeAttribute("data-puck-dnd");
|
4837
4510
|
el.removeEventListener("click", onClick);
|
4838
4511
|
el.removeEventListener("mouseover", _onMouseOver);
|
4839
4512
|
el.removeEventListener("mouseout", _onMouseOut);
|
4840
|
-
el.removeAttribute("data-puck-dragging");
|
4841
4513
|
};
|
4842
4514
|
}, [
|
4843
4515
|
ref,
|
@@ -4989,6 +4661,9 @@ var DraggableComponent = ({
|
|
4989
4661
|
init_react_import();
|
4990
4662
|
var styles_module_default12 = { "DropZone": "_DropZone_3dmev_1", "DropZone--hasChildren": "_DropZone--hasChildren_3dmev_11", "DropZone--userIsDragging": "_DropZone--userIsDragging_3dmev_19", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_3dmev_23", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_3dmev_24", "DropZone--isRootZone": "_DropZone--isRootZone_3dmev_24", "DropZone--isDestination": "_DropZone--isDestination_3dmev_34", "DropZone-item": "_DropZone-item_3dmev_46", "DropZone-hitbox": "_DropZone-hitbox_3dmev_50", "DropZone--isEnabled": "_DropZone--isEnabled_3dmev_58", "DropZone--isAnimating": "_DropZone--isAnimating_3dmev_67" };
|
4991
4663
|
|
4664
|
+
// components/DropZone/index.tsx
|
4665
|
+
var import_react35 = require("@dnd-kit/react");
|
4666
|
+
|
4992
4667
|
// components/DropZone/lib/use-min-empty-height.ts
|
4993
4668
|
init_react_import();
|
4994
4669
|
var import_react26 = require("react");
|
@@ -5621,7 +5296,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5621
5296
|
path: path || []
|
5622
5297
|
}
|
5623
5298
|
};
|
5624
|
-
const { ref: dropRef } =
|
5299
|
+
const { ref: dropRef } = (0, import_react35.useDroppable)(droppableConfig);
|
5625
5300
|
const isAreaSelected = useAppStore(
|
5626
5301
|
(s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
|
5627
5302
|
);
|
@@ -5753,8 +5428,7 @@ var DropZone = (0, import_react34.forwardRef)(
|
|
5753
5428
|
|
5754
5429
|
// lib/dnd/NestedDroppablePlugin.ts
|
5755
5430
|
init_react_import();
|
5756
|
-
var
|
5757
|
-
var import_state2 = require("@dnd-kit/state");
|
5431
|
+
var import_abstract9 = require("@dnd-kit/abstract");
|
5758
5432
|
|
5759
5433
|
// lib/throttle.ts
|
5760
5434
|
init_react_import();
|
@@ -5908,7 +5582,8 @@ var getPointerCollisions = (position, manager) => {
|
|
5908
5582
|
const element = elements[i];
|
5909
5583
|
const dropzoneId = element.getAttribute("data-puck-dropzone");
|
5910
5584
|
const id = element.getAttribute("data-puck-dnd");
|
5911
|
-
|
5585
|
+
const isVoid = element.hasAttribute("data-puck-dnd-void");
|
5586
|
+
if (BUFFER && (dropzoneId || id) && !isVoid) {
|
5912
5587
|
const box = element.getBoundingClientRect();
|
5913
5588
|
const contractedBox = {
|
5914
5589
|
left: box.left + BUFFER,
|
@@ -5983,13 +5658,13 @@ var findDeepestCandidate = (position, manager) => {
|
|
5983
5658
|
area: rootAreaId
|
5984
5659
|
};
|
5985
5660
|
};
|
5986
|
-
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends
|
5661
|
+
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
|
5987
5662
|
constructor(manager, options) {
|
5988
5663
|
super(manager);
|
5989
5664
|
if (typeof window === "undefined") {
|
5990
5665
|
return;
|
5991
5666
|
}
|
5992
|
-
|
5667
|
+
this.registerEffect(() => {
|
5993
5668
|
const handleMove = (event) => {
|
5994
5669
|
const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
|
5995
5670
|
const position = new GlobalPosition(target, {
|
@@ -6013,12 +5688,12 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
6013
5688
|
capture: true
|
6014
5689
|
// dndkit's PointerSensor prevents propagation during drag
|
6015
5690
|
});
|
6016
|
-
|
5691
|
+
const cleanup = () => {
|
6017
5692
|
document.body.removeEventListener("pointermove", handlePointerMove, {
|
6018
5693
|
capture: true
|
6019
5694
|
});
|
6020
|
-
cleanupEffect();
|
6021
5695
|
};
|
5696
|
+
return cleanup;
|
6022
5697
|
});
|
6023
5698
|
}
|
6024
5699
|
};
|
@@ -6080,12 +5755,12 @@ function getDeepDir(el) {
|
|
6080
5755
|
// components/DragDropContext/index.tsx
|
6081
5756
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
6082
5757
|
var DEBUG3 = false;
|
6083
|
-
var dragListenerContext = (0,
|
5758
|
+
var dragListenerContext = (0, import_react37.createContext)({
|
6084
5759
|
dragListeners: {}
|
6085
5760
|
});
|
6086
5761
|
function useDragListener(type, fn, deps = []) {
|
6087
|
-
const { setDragListeners } = (0,
|
6088
|
-
(0,
|
5762
|
+
const { setDragListeners } = (0, import_react37.useContext)(dragListenerContext);
|
5763
|
+
(0, import_react37.useEffect)(() => {
|
6089
5764
|
if (setDragListeners) {
|
6090
5765
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
6091
5766
|
[type]: [...old[type] || [], fn]
|
@@ -6095,8 +5770,8 @@ function useDragListener(type, fn, deps = []) {
|
|
6095
5770
|
}
|
6096
5771
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
6097
5772
|
var useTempDisableFallback = (timeout3) => {
|
6098
|
-
const lastFallbackDisable = (0,
|
6099
|
-
return (0,
|
5773
|
+
const lastFallbackDisable = (0, import_react37.useRef)(null);
|
5774
|
+
return (0, import_react37.useCallback)((manager) => {
|
6100
5775
|
collisionStore.setState({ fallbackEnabled: false });
|
6101
5776
|
const fallbackId = generateId();
|
6102
5777
|
lastFallbackDisable.current = fallbackId;
|
@@ -6115,9 +5790,9 @@ var DragDropContextClient = ({
|
|
6115
5790
|
const dispatch = useAppStore((s) => s.dispatch);
|
6116
5791
|
const appStore = useAppStoreApi();
|
6117
5792
|
const id = useSafeId();
|
6118
|
-
const debouncedParamsRef = (0,
|
5793
|
+
const debouncedParamsRef = (0, import_react37.useRef)(null);
|
6119
5794
|
const tempDisableFallback = useTempDisableFallback(100);
|
6120
|
-
const [zoneStore] = (0,
|
5795
|
+
const [zoneStore] = (0, import_react37.useState)(
|
6121
5796
|
() => (0, import_zustand5.createStore)(() => ({
|
6122
5797
|
zoneDepthIndex: {},
|
6123
5798
|
nextZoneDepthIndex: {},
|
@@ -6127,7 +5802,7 @@ var DragDropContextClient = ({
|
|
6127
5802
|
previewIndex: {}
|
6128
5803
|
}))
|
6129
5804
|
);
|
6130
|
-
const getChanged2 = (0,
|
5805
|
+
const getChanged2 = (0, import_react37.useCallback)(
|
6131
5806
|
(params, id2) => {
|
6132
5807
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
6133
5808
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -6148,7 +5823,7 @@ var DragDropContextClient = ({
|
|
6148
5823
|
},
|
6149
5824
|
[zoneStore]
|
6150
5825
|
);
|
6151
|
-
const setDeepestAndCollide = (0,
|
5826
|
+
const setDeepestAndCollide = (0, import_react37.useCallback)(
|
6152
5827
|
(params, manager) => {
|
6153
5828
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
6154
5829
|
if (!zoneChanged && !areaChanged) return;
|
@@ -6172,7 +5847,7 @@ var DragDropContextClient = ({
|
|
6172
5847
|
setDeepestDb.cancel();
|
6173
5848
|
debouncedParamsRef.current = null;
|
6174
5849
|
};
|
6175
|
-
(0,
|
5850
|
+
(0, import_react37.useEffect)(() => {
|
6176
5851
|
if (DEBUG3) {
|
6177
5852
|
zoneStore.subscribe(
|
6178
5853
|
(s) => {
|
@@ -6186,7 +5861,7 @@ var DragDropContextClient = ({
|
|
6186
5861
|
);
|
6187
5862
|
}
|
6188
5863
|
}, []);
|
6189
|
-
const [plugins] = (0,
|
5864
|
+
const [plugins] = (0, import_react37.useState)(() => [
|
6190
5865
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
6191
5866
|
createNestedDroppablePlugin(
|
6192
5867
|
{
|
@@ -6234,10 +5909,10 @@ var DragDropContextClient = ({
|
|
6234
5909
|
)
|
6235
5910
|
]);
|
6236
5911
|
const sensors = useSensors();
|
6237
|
-
const [dragListeners, setDragListeners] = (0,
|
6238
|
-
const dragMode = (0,
|
6239
|
-
const initialSelector = (0,
|
6240
|
-
const nextContextValue = (0,
|
5912
|
+
const [dragListeners, setDragListeners] = (0, import_react37.useState)({});
|
5913
|
+
const dragMode = (0, import_react37.useRef)(null);
|
5914
|
+
const initialSelector = (0, import_react37.useRef)(void 0);
|
5915
|
+
const nextContextValue = (0, import_react37.useMemo)(
|
6241
5916
|
() => ({
|
6242
5917
|
mode: "edit",
|
6243
5918
|
areaId: "root",
|
@@ -6253,7 +5928,7 @@ var DragDropContextClient = ({
|
|
6253
5928
|
setDragListeners
|
6254
5929
|
},
|
6255
5930
|
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
6256
|
-
|
5931
|
+
import_react36.DragDropProvider,
|
6257
5932
|
{
|
6258
5933
|
plugins,
|
6259
5934
|
sensors,
|
@@ -6320,7 +5995,7 @@ var DragDropContextClient = ({
|
|
6320
5995
|
}, 250);
|
6321
5996
|
},
|
6322
5997
|
onDragOver: (event, manager) => {
|
6323
|
-
var _a, _b, _c, _d
|
5998
|
+
var _a, _b, _c, _d;
|
6324
5999
|
event.preventDefault();
|
6325
6000
|
const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
|
6326
6001
|
if (!draggedItem) return;
|
@@ -6338,7 +6013,7 @@ var DragDropContextClient = ({
|
|
6338
6013
|
const targetData = target.data;
|
6339
6014
|
targetZone = targetData.zone;
|
6340
6015
|
targetIndex = targetData.index;
|
6341
|
-
const collisionData = (
|
6016
|
+
const collisionData = (_b = manager.collisionObserver.collisions[0]) == null ? void 0 : _b.data;
|
6342
6017
|
const dir = getDeepDir(target.element);
|
6343
6018
|
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || dir === "ltr" && (collisionData == null ? void 0 : collisionData.direction) === "left" || dir === "rtl" && (collisionData == null ? void 0 : collisionData.direction) === "right" ? "before" : "after";
|
6344
6019
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
@@ -6351,7 +6026,7 @@ var DragDropContextClient = ({
|
|
6351
6026
|
targetZone = target.id.toString();
|
6352
6027
|
targetIndex = 0;
|
6353
6028
|
}
|
6354
|
-
const path = ((
|
6029
|
+
const path = ((_c = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _c.path) || [];
|
6355
6030
|
if (targetId === sourceId || path.find((path2) => {
|
6356
6031
|
const [pathId] = path2.split(":");
|
6357
6032
|
return pathId === sourceId;
|
@@ -6397,16 +6072,12 @@ var DragDropContextClient = ({
|
|
6397
6072
|
});
|
6398
6073
|
}
|
6399
6074
|
}
|
6400
|
-
(
|
6075
|
+
(_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
|
6401
6076
|
fn(event, manager);
|
6402
6077
|
});
|
6403
6078
|
},
|
6404
6079
|
onDragStart: (event, manager) => {
|
6405
6080
|
var _a;
|
6406
|
-
dispatch({
|
6407
|
-
type: "setUi",
|
6408
|
-
ui: { itemSelector: null, isDragging: true }
|
6409
|
-
});
|
6410
6081
|
const { source } = event.operation;
|
6411
6082
|
if (source && source.type !== "void") {
|
6412
6083
|
const sourceData = source.data;
|
@@ -6437,10 +6108,17 @@ var DragDropContextClient = ({
|
|
6437
6108
|
},
|
6438
6109
|
onBeforeDragStart: (event) => {
|
6439
6110
|
var _a;
|
6440
|
-
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.
|
6111
|
+
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.type) === "drawer";
|
6441
6112
|
dragMode.current = isNewComponent ? "new" : "existing";
|
6442
6113
|
initialSelector.current = void 0;
|
6443
6114
|
zoneStore.setState({ draggedItem: event.operation.source });
|
6115
|
+
dispatch({
|
6116
|
+
type: "setUi",
|
6117
|
+
ui: {
|
6118
|
+
isDragging: true
|
6119
|
+
},
|
6120
|
+
recordHistory: false
|
6121
|
+
});
|
6444
6122
|
},
|
6445
6123
|
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneProvider, { value: nextContextValue, children }) })
|
6446
6124
|
}
|
@@ -6460,6 +6138,7 @@ var DragDropContext = ({
|
|
6460
6138
|
};
|
6461
6139
|
|
6462
6140
|
// components/Drawer/index.tsx
|
6141
|
+
var import_react39 = require("@dnd-kit/react");
|
6463
6142
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
6464
6143
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
6465
6144
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
@@ -6470,7 +6149,7 @@ var DrawerItemInner = ({
|
|
6470
6149
|
dragRef,
|
6471
6150
|
isDragDisabled
|
6472
6151
|
}) => {
|
6473
|
-
const CustomInner = (0,
|
6152
|
+
const CustomInner = (0, import_react38.useMemo)(
|
6474
6153
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
6475
6154
|
[children]
|
6476
6155
|
);
|
@@ -6496,10 +6175,11 @@ var DrawerItemDraggable = ({
|
|
6496
6175
|
id,
|
6497
6176
|
isDragDisabled
|
6498
6177
|
}) => {
|
6499
|
-
const { ref } =
|
6178
|
+
const { ref } = (0, import_react39.useDraggable)({
|
6500
6179
|
id,
|
6501
|
-
data: {
|
6502
|
-
disabled: isDragDisabled
|
6180
|
+
data: { componentType: name },
|
6181
|
+
disabled: isDragDisabled,
|
6182
|
+
type: "drawer"
|
6503
6183
|
});
|
6504
6184
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName18("draggable"), children: [
|
6505
6185
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DrawerItemInner, { name, label, children }) }),
|
@@ -6524,7 +6204,7 @@ var DrawerItem = ({
|
|
6524
6204
|
isDragDisabled
|
6525
6205
|
}) => {
|
6526
6206
|
const resolvedId = id || name;
|
6527
|
-
const [dynamicId, setDynamicId] = (0,
|
6207
|
+
const [dynamicId, setDynamicId] = (0, import_react38.useState)(generateId(resolvedId));
|
6528
6208
|
if (typeof index !== "undefined") {
|
6529
6209
|
console.error(
|
6530
6210
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
@@ -6564,7 +6244,7 @@ var Drawer = ({
|
|
6564
6244
|
);
|
6565
6245
|
}
|
6566
6246
|
const id = useSafeId();
|
6567
|
-
const { ref } =
|
6247
|
+
const { ref } = (0, import_react39.useDroppable)({
|
6568
6248
|
id,
|
6569
6249
|
type: "void",
|
6570
6250
|
collisionPriority: 0
|
@@ -6577,6 +6257,7 @@ var Drawer = ({
|
|
6577
6257
|
ref,
|
6578
6258
|
"data-puck-dnd": id,
|
6579
6259
|
"data-puck-drawer": true,
|
6260
|
+
"data-puck-dnd-void": true,
|
6580
6261
|
children
|
6581
6262
|
}
|
6582
6263
|
);
|
@@ -6585,7 +6266,7 @@ Drawer.Item = DrawerItem;
|
|
6585
6266
|
|
6586
6267
|
// components/Puck/index.tsx
|
6587
6268
|
init_react_import();
|
6588
|
-
var
|
6269
|
+
var import_react54 = require("react");
|
6589
6270
|
|
6590
6271
|
// components/SidebarSection/index.tsx
|
6591
6272
|
init_react_import();
|
@@ -6596,7 +6277,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
6596
6277
|
|
6597
6278
|
// lib/use-breadcrumbs.ts
|
6598
6279
|
init_react_import();
|
6599
|
-
var
|
6280
|
+
var import_react40 = require("react");
|
6600
6281
|
var useBreadcrumbs = (renderCount) => {
|
6601
6282
|
const selectedId = useAppStore((s) => {
|
6602
6283
|
var _a;
|
@@ -6608,7 +6289,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
6608
6289
|
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
6609
6290
|
});
|
6610
6291
|
const appStore = useAppStoreApi();
|
6611
|
-
return (0,
|
6292
|
+
return (0, import_react40.useMemo)(() => {
|
6612
6293
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
6613
6294
|
var _a, _b, _c;
|
6614
6295
|
const [componentId] = zoneCompound.split(":");
|
@@ -6736,7 +6417,7 @@ init_react_import();
|
|
6736
6417
|
var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
6737
6418
|
|
6738
6419
|
// components/Puck/components/Fields/index.tsx
|
6739
|
-
var
|
6420
|
+
var import_react41 = require("react");
|
6740
6421
|
var import_shallow4 = require("zustand/react/shallow");
|
6741
6422
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
6742
6423
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
@@ -6809,7 +6490,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
6809
6490
|
})
|
6810
6491
|
);
|
6811
6492
|
const appStore = useAppStoreApi();
|
6812
|
-
const onChange = (0,
|
6493
|
+
const onChange = (0, import_react41.useCallback)(createOnChange(fieldName, appStore), [
|
6813
6494
|
fieldName
|
6814
6495
|
]);
|
6815
6496
|
if (!field || !id) return null;
|
@@ -6850,7 +6531,7 @@ var Fields = ({ wrapFields = true }) => {
|
|
6850
6531
|
})
|
6851
6532
|
);
|
6852
6533
|
const isLoading = fieldsLoading || componentResolving;
|
6853
|
-
const Wrapper = (0,
|
6534
|
+
const Wrapper = (0, import_react41.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
6854
6535
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
6855
6536
|
"form",
|
6856
6537
|
{
|
@@ -6871,7 +6552,7 @@ init_react_import();
|
|
6871
6552
|
|
6872
6553
|
// lib/use-component-list.tsx
|
6873
6554
|
init_react_import();
|
6874
|
-
var
|
6555
|
+
var import_react42 = require("react");
|
6875
6556
|
|
6876
6557
|
// components/ComponentList/index.tsx
|
6877
6558
|
init_react_import();
|
@@ -6942,10 +6623,10 @@ ComponentList.Item = ComponentListItem;
|
|
6942
6623
|
// lib/use-component-list.tsx
|
6943
6624
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
6944
6625
|
var useComponentList = () => {
|
6945
|
-
const [componentList, setComponentList] = (0,
|
6626
|
+
const [componentList, setComponentList] = (0, import_react42.useState)();
|
6946
6627
|
const config = useAppStore((s) => s.config);
|
6947
6628
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
6948
|
-
(0,
|
6629
|
+
(0, import_react42.useEffect)(() => {
|
6949
6630
|
var _a, _b, _c;
|
6950
6631
|
if (Object.keys(uiComponentList).length > 0) {
|
6951
6632
|
const matchedComponents = [];
|
@@ -7014,22 +6695,22 @@ var useComponentList = () => {
|
|
7014
6695
|
};
|
7015
6696
|
|
7016
6697
|
// components/Puck/components/Components/index.tsx
|
7017
|
-
var
|
6698
|
+
var import_react43 = require("react");
|
7018
6699
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
7019
6700
|
var Components = () => {
|
7020
6701
|
const overrides = useAppStore((s) => s.overrides);
|
7021
6702
|
const componentList = useComponentList();
|
7022
|
-
const Wrapper = (0,
|
6703
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.components || "div", [overrides]);
|
7023
6704
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ComponentList, { id: "all" }) });
|
7024
6705
|
};
|
7025
6706
|
|
7026
6707
|
// components/Puck/components/Preview/index.tsx
|
7027
6708
|
init_react_import();
|
7028
|
-
var
|
6709
|
+
var import_react45 = require("react");
|
7029
6710
|
|
7030
6711
|
// components/AutoFrame/index.tsx
|
7031
6712
|
init_react_import();
|
7032
|
-
var
|
6713
|
+
var import_react44 = require("react");
|
7033
6714
|
var import_object_hash = __toESM(require("object-hash"));
|
7034
6715
|
var import_react_dom3 = require("react-dom");
|
7035
6716
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
@@ -7075,7 +6756,7 @@ var CopyHostStyles = ({
|
|
7075
6756
|
onStylesLoaded = () => null
|
7076
6757
|
}) => {
|
7077
6758
|
const { document: doc, window: win } = useFrame();
|
7078
|
-
(0,
|
6759
|
+
(0, import_react44.useEffect)(() => {
|
7079
6760
|
if (!win || !doc) {
|
7080
6761
|
return () => {
|
7081
6762
|
};
|
@@ -7234,8 +6915,8 @@ var CopyHostStyles = ({
|
|
7234
6915
|
}, []);
|
7235
6916
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children });
|
7236
6917
|
};
|
7237
|
-
var autoFrameContext = (0,
|
7238
|
-
var useFrame = () => (0,
|
6918
|
+
var autoFrameContext = (0, import_react44.createContext)({});
|
6919
|
+
var useFrame = () => (0, import_react44.useContext)(autoFrameContext);
|
7239
6920
|
function AutoFrame(_a) {
|
7240
6921
|
var _b = _a, {
|
7241
6922
|
children,
|
@@ -7256,11 +6937,11 @@ function AutoFrame(_a) {
|
|
7256
6937
|
"onNotReady",
|
7257
6938
|
"frameRef"
|
7258
6939
|
]);
|
7259
|
-
const [loaded, setLoaded] = (0,
|
7260
|
-
const [ctx, setCtx] = (0,
|
7261
|
-
const [mountTarget, setMountTarget] = (0,
|
7262
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
7263
|
-
(0,
|
6940
|
+
const [loaded, setLoaded] = (0, import_react44.useState)(false);
|
6941
|
+
const [ctx, setCtx] = (0, import_react44.useState)({});
|
6942
|
+
const [mountTarget, setMountTarget] = (0, import_react44.useState)();
|
6943
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react44.useState)(false);
|
6944
|
+
(0, import_react44.useEffect)(() => {
|
7264
6945
|
var _a2;
|
7265
6946
|
if (frameRef.current) {
|
7266
6947
|
const doc = frameRef.current.contentDocument;
|
@@ -7312,7 +6993,7 @@ var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
7312
6993
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
7313
6994
|
var useBubbleIframeEvents = (ref) => {
|
7314
6995
|
const status = useAppStore((s) => s.status);
|
7315
|
-
(0,
|
6996
|
+
(0, import_react45.useEffect)(() => {
|
7316
6997
|
if (ref.current && status === "READY") {
|
7317
6998
|
const iframe = ref.current;
|
7318
6999
|
const handlePointerMove = (event) => {
|
@@ -7361,7 +7042,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7361
7042
|
const renderData = useAppStore(
|
7362
7043
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
7363
7044
|
);
|
7364
|
-
const Page = (0,
|
7045
|
+
const Page = (0, import_react45.useCallback)(
|
7365
7046
|
(pageProps) => {
|
7366
7047
|
var _a, _b;
|
7367
7048
|
const rootConfig = config.root;
|
@@ -7372,9 +7053,9 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7372
7053
|
},
|
7373
7054
|
[config.root]
|
7374
7055
|
);
|
7375
|
-
const Frame = (0,
|
7056
|
+
const Frame = (0, import_react45.useMemo)(() => overrides.iframe, [overrides]);
|
7376
7057
|
const rootProps = root.props || root;
|
7377
|
-
const ref = (0,
|
7058
|
+
const ref = (0, import_react45.useRef)(null);
|
7378
7059
|
useBubbleIframeEvents(ref);
|
7379
7060
|
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
7380
7061
|
Page,
|
@@ -7389,7 +7070,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7389
7070
|
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DropZonePure, { zone: rootDroppableId })
|
7390
7071
|
})
|
7391
7072
|
) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Render, { data: renderData, config });
|
7392
|
-
(0,
|
7073
|
+
(0, import_react45.useEffect)(() => {
|
7393
7074
|
if (!iframe.enabled) {
|
7394
7075
|
setStatus("READY");
|
7395
7076
|
}
|
@@ -7459,7 +7140,7 @@ var scrollIntoView = (el) => {
|
|
7459
7140
|
};
|
7460
7141
|
|
7461
7142
|
// components/LayerTree/index.tsx
|
7462
|
-
var
|
7143
|
+
var import_react46 = require("react");
|
7463
7144
|
|
7464
7145
|
// lib/on-scroll-end.ts
|
7465
7146
|
init_react_import();
|
@@ -7491,11 +7172,11 @@ var Layer = ({
|
|
7491
7172
|
zoneCompound
|
7492
7173
|
}) => {
|
7493
7174
|
var _a;
|
7494
|
-
const ctx = (0,
|
7175
|
+
const ctx = (0, import_react46.useContext)(dropZoneContext);
|
7495
7176
|
const config = useAppStore((s) => s.config);
|
7496
7177
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
7497
7178
|
const dispatch = useAppStore((s) => s.dispatch);
|
7498
|
-
const setItemSelector = (0,
|
7179
|
+
const setItemSelector = (0, import_react46.useCallback)(
|
7499
7180
|
(itemSelector2) => {
|
7500
7181
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
7501
7182
|
},
|
@@ -7629,7 +7310,7 @@ var LayerTree = ({
|
|
7629
7310
|
};
|
7630
7311
|
|
7631
7312
|
// components/Puck/components/Outline/index.tsx
|
7632
|
-
var
|
7313
|
+
var import_react47 = require("react");
|
7633
7314
|
|
7634
7315
|
// lib/data/find-zones-for-area.ts
|
7635
7316
|
init_react_import();
|
@@ -7647,7 +7328,7 @@ var Outline = () => {
|
|
7647
7328
|
const rootZones = useAppStore(
|
7648
7329
|
(0, import_shallow6.useShallow)((s) => findZonesForArea(s.state, "root"))
|
7649
7330
|
);
|
7650
|
-
const Wrapper = (0,
|
7331
|
+
const Wrapper = (0, import_react47.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
7651
7332
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
7652
7333
|
LayerTree,
|
7653
7334
|
{
|
@@ -7781,11 +7462,11 @@ var getBox = function getBox2(el) {
|
|
7781
7462
|
};
|
7782
7463
|
|
7783
7464
|
// components/Puck/components/Canvas/index.tsx
|
7784
|
-
var
|
7465
|
+
var import_react49 = require("react");
|
7785
7466
|
|
7786
7467
|
// components/ViewportControls/index.tsx
|
7787
7468
|
init_react_import();
|
7788
|
-
var
|
7469
|
+
var import_react48 = require("react");
|
7789
7470
|
|
7790
7471
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7791
7472
|
init_react_import();
|
@@ -7808,8 +7489,8 @@ var ViewportButton = ({
|
|
7808
7489
|
onClick
|
7809
7490
|
}) => {
|
7810
7491
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
7811
|
-
const [isActive, setIsActive] = (0,
|
7812
|
-
(0,
|
7492
|
+
const [isActive, setIsActive] = (0, import_react48.useState)(false);
|
7493
|
+
(0, import_react48.useEffect)(() => {
|
7813
7494
|
setIsActive(width === viewports.current.width);
|
7814
7495
|
}, [width, viewports.current.width]);
|
7815
7496
|
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
@@ -7845,7 +7526,7 @@ var ViewportControls = ({
|
|
7845
7526
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7846
7527
|
(option) => option.value === autoZoom
|
7847
7528
|
);
|
7848
|
-
const zoomOptions = (0,
|
7529
|
+
const zoomOptions = (0, import_react48.useMemo)(
|
7849
7530
|
() => [
|
7850
7531
|
...defaultZoomOptions,
|
7851
7532
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7992,17 +7673,17 @@ var Canvas = () => {
|
|
7992
7673
|
viewports: s.state.ui.viewports
|
7993
7674
|
}))
|
7994
7675
|
);
|
7995
|
-
const frameRef = (0,
|
7996
|
-
const [showTransition, setShowTransition] = (0,
|
7997
|
-
const defaultRender = (0,
|
7676
|
+
const frameRef = (0, import_react49.useRef)(null);
|
7677
|
+
const [showTransition, setShowTransition] = (0, import_react49.useState)(false);
|
7678
|
+
const defaultRender = (0, import_react49.useMemo)(() => {
|
7998
7679
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
|
7999
7680
|
return PuckDefault;
|
8000
7681
|
}, []);
|
8001
|
-
const CustomPreview = (0,
|
7682
|
+
const CustomPreview = (0, import_react49.useMemo)(
|
8002
7683
|
() => overrides.preview || defaultRender,
|
8003
7684
|
[overrides]
|
8004
7685
|
);
|
8005
|
-
const getFrameDimensions = (0,
|
7686
|
+
const getFrameDimensions = (0, import_react49.useCallback)(() => {
|
8006
7687
|
if (frameRef.current) {
|
8007
7688
|
const frame = frameRef.current;
|
8008
7689
|
const box = getBox(frame);
|
@@ -8010,7 +7691,7 @@ var Canvas = () => {
|
|
8010
7691
|
}
|
8011
7692
|
return { width: 0, height: 0 };
|
8012
7693
|
}, [frameRef]);
|
8013
|
-
const resetAutoZoom = (0,
|
7694
|
+
const resetAutoZoom = (0, import_react49.useCallback)(
|
8014
7695
|
(newViewports = viewports) => {
|
8015
7696
|
if (frameRef.current) {
|
8016
7697
|
setZoomConfig(
|
@@ -8024,11 +7705,11 @@ var Canvas = () => {
|
|
8024
7705
|
},
|
8025
7706
|
[frameRef, zoomConfig, viewports]
|
8026
7707
|
);
|
8027
|
-
(0,
|
7708
|
+
(0, import_react49.useEffect)(() => {
|
8028
7709
|
setShowTransition(false);
|
8029
7710
|
resetAutoZoom(viewports);
|
8030
7711
|
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
8031
|
-
(0,
|
7712
|
+
(0, import_react49.useEffect)(() => {
|
8032
7713
|
const { height: frameHeight } = getFrameDimensions();
|
8033
7714
|
if (viewports.current.height === "auto") {
|
8034
7715
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -8036,13 +7717,13 @@ var Canvas = () => {
|
|
8036
7717
|
}));
|
8037
7718
|
}
|
8038
7719
|
}, [zoomConfig.zoom]);
|
8039
|
-
(0,
|
7720
|
+
(0, import_react49.useEffect)(() => {
|
8040
7721
|
if (ZOOM_ON_CHANGE) {
|
8041
7722
|
setShowTransition(true);
|
8042
7723
|
resetAutoZoom(viewports);
|
8043
7724
|
}
|
8044
7725
|
}, [viewports.current.width]);
|
8045
|
-
(0,
|
7726
|
+
(0, import_react49.useEffect)(() => {
|
8046
7727
|
const cb = () => {
|
8047
7728
|
setShowTransition(false);
|
8048
7729
|
resetAutoZoom();
|
@@ -8052,8 +7733,8 @@ var Canvas = () => {
|
|
8052
7733
|
window.removeEventListener("resize", cb);
|
8053
7734
|
};
|
8054
7735
|
}, []);
|
8055
|
-
const [showLoader, setShowLoader] = (0,
|
8056
|
-
(0,
|
7736
|
+
const [showLoader, setShowLoader] = (0, import_react49.useState)(false);
|
7737
|
+
(0, import_react49.useEffect)(() => {
|
8057
7738
|
setTimeout(() => {
|
8058
7739
|
setShowLoader(true);
|
8059
7740
|
}, 500);
|
@@ -8131,7 +7812,7 @@ var Canvas = () => {
|
|
8131
7812
|
|
8132
7813
|
// lib/use-loaded-overrides.ts
|
8133
7814
|
init_react_import();
|
8134
|
-
var
|
7815
|
+
var import_react50 = require("react");
|
8135
7816
|
|
8136
7817
|
// lib/load-overrides.ts
|
8137
7818
|
init_react_import();
|
@@ -8170,7 +7851,7 @@ var useLoadedOverrides = ({
|
|
8170
7851
|
overrides,
|
8171
7852
|
plugins
|
8172
7853
|
}) => {
|
8173
|
-
return (0,
|
7854
|
+
return (0, import_react50.useMemo)(() => {
|
8174
7855
|
return loadOverrides({ overrides, plugins });
|
8175
7856
|
}, [plugins, overrides]);
|
8176
7857
|
};
|
@@ -8182,14 +7863,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40
|
|
8182
7863
|
|
8183
7864
|
// lib/use-inject-css.ts
|
8184
7865
|
init_react_import();
|
8185
|
-
var
|
7866
|
+
var import_react51 = require("react");
|
8186
7867
|
var styles = ``;
|
8187
7868
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
8188
|
-
const [el, setEl] = (0,
|
8189
|
-
(0,
|
7869
|
+
const [el, setEl] = (0, import_react51.useState)();
|
7870
|
+
(0, import_react51.useEffect)(() => {
|
8190
7871
|
setEl(document.createElement("style"));
|
8191
7872
|
}, []);
|
8192
|
-
(0,
|
7873
|
+
(0, import_react51.useEffect)(() => {
|
8193
7874
|
var _a;
|
8194
7875
|
if (!el || typeof window === "undefined") {
|
8195
7876
|
return;
|
@@ -8209,10 +7890,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
8209
7890
|
|
8210
7891
|
// lib/use-preview-mode-hotkeys.ts
|
8211
7892
|
init_react_import();
|
8212
|
-
var
|
7893
|
+
var import_react52 = require("react");
|
8213
7894
|
var usePreviewModeHotkeys = () => {
|
8214
7895
|
const appStore = useAppStoreApi();
|
8215
|
-
const toggleInteractive = (0,
|
7896
|
+
const toggleInteractive = (0, import_react52.useCallback)(() => {
|
8216
7897
|
const dispatch = appStore.getState().dispatch;
|
8217
7898
|
dispatch({
|
8218
7899
|
type: "setUi",
|
@@ -8227,7 +7908,7 @@ var usePreviewModeHotkeys = () => {
|
|
8227
7908
|
|
8228
7909
|
// lib/use-puck.ts
|
8229
7910
|
init_react_import();
|
8230
|
-
var
|
7911
|
+
var import_react53 = require("react");
|
8231
7912
|
var import_zustand6 = require("zustand");
|
8232
7913
|
var generateUsePuck = (store) => {
|
8233
7914
|
const history = {
|
@@ -8261,7 +7942,7 @@ var generateUsePuck = (store) => {
|
|
8261
7942
|
const get = () => storeData;
|
8262
7943
|
return __spreadProps(__spreadValues({}, storeData), { get });
|
8263
7944
|
};
|
8264
|
-
var UsePuckStoreContext = (0,
|
7945
|
+
var UsePuckStoreContext = (0, import_react53.createContext)(
|
8265
7946
|
null
|
8266
7947
|
);
|
8267
7948
|
var convertToPickedStore = (store) => {
|
@@ -8275,12 +7956,12 @@ var convertToPickedStore = (store) => {
|
|
8275
7956
|
};
|
8276
7957
|
};
|
8277
7958
|
var useRegisterUsePuckStore = (appStore) => {
|
8278
|
-
const [usePuckStore] = (0,
|
7959
|
+
const [usePuckStore] = (0, import_react53.useState)(
|
8279
7960
|
() => (0, import_zustand6.createStore)(
|
8280
7961
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
8281
7962
|
)
|
8282
7963
|
);
|
8283
|
-
(0,
|
7964
|
+
(0, import_react53.useEffect)(() => {
|
8284
7965
|
return appStore.subscribe(
|
8285
7966
|
(store) => convertToPickedStore(store),
|
8286
7967
|
(pickedStore) => {
|
@@ -8292,7 +7973,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
8292
7973
|
};
|
8293
7974
|
function createUsePuck() {
|
8294
7975
|
return function usePuck2(selector) {
|
8295
|
-
const usePuckApi = (0,
|
7976
|
+
const usePuckApi = (0, import_react53.useContext)(UsePuckStoreContext);
|
8296
7977
|
if (!usePuckApi) {
|
8297
7978
|
throw new Error("usePuck must be used inside <Puck>.");
|
8298
7979
|
}
|
@@ -8304,13 +7985,20 @@ function createUsePuck() {
|
|
8304
7985
|
};
|
8305
7986
|
}
|
8306
7987
|
function usePuck() {
|
8307
|
-
(0,
|
7988
|
+
(0, import_react53.useEffect)(() => {
|
8308
7989
|
console.warn(
|
8309
7990
|
"You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
|
8310
7991
|
);
|
8311
7992
|
}, []);
|
8312
7993
|
return createUsePuck()((s) => s);
|
8313
7994
|
}
|
7995
|
+
function useGetPuck() {
|
7996
|
+
const usePuckApi = (0, import_react53.useContext)(UsePuckStoreContext);
|
7997
|
+
if (!usePuckApi) {
|
7998
|
+
throw new Error("usePuckGet must be used inside <Puck>.");
|
7999
|
+
}
|
8000
|
+
return usePuckApi.getState;
|
8001
|
+
}
|
8314
8002
|
|
8315
8003
|
// components/Puck/index.tsx
|
8316
8004
|
var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
|
@@ -8326,11 +8014,11 @@ var FieldSideBar = () => {
|
|
8326
8014
|
);
|
8327
8015
|
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Fields, {}) });
|
8328
8016
|
};
|
8329
|
-
var propsContext = (0,
|
8017
|
+
var propsContext = (0, import_react54.createContext)({});
|
8330
8018
|
function PropsProvider(props) {
|
8331
8019
|
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(propsContext.Provider, { value: props, children: props.children });
|
8332
8020
|
}
|
8333
|
-
var usePropsContext = () => (0,
|
8021
|
+
var usePropsContext = () => (0, import_react54.useContext)(propsContext);
|
8334
8022
|
function PuckProvider({ children }) {
|
8335
8023
|
const {
|
8336
8024
|
config,
|
@@ -8350,7 +8038,7 @@ function PuckProvider({ children }) {
|
|
8350
8038
|
enabled: true,
|
8351
8039
|
waitForStyles: true
|
8352
8040
|
}, _iframe);
|
8353
|
-
const [generatedAppState] = (0,
|
8041
|
+
const [generatedAppState] = (0, import_react54.useState)(() => {
|
8354
8042
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
8355
8043
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
8356
8044
|
let clientUiState = {};
|
@@ -8410,7 +8098,7 @@ function PuckProvider({ children }) {
|
|
8410
8098
|
return walkAppState(newAppState, config);
|
8411
8099
|
});
|
8412
8100
|
const { appendData = true } = _initialHistory || {};
|
8413
|
-
const [blendedHistories] = (0,
|
8101
|
+
const [blendedHistories] = (0, import_react54.useState)(
|
8414
8102
|
[
|
8415
8103
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
8416
8104
|
...appendData ? [{ state: generatedAppState }] : []
|
@@ -8430,7 +8118,7 @@ function PuckProvider({ children }) {
|
|
8430
8118
|
overrides,
|
8431
8119
|
plugins
|
8432
8120
|
});
|
8433
|
-
const generateAppStore = (0,
|
8121
|
+
const generateAppStore = (0, import_react54.useCallback)(
|
8434
8122
|
(state) => {
|
8435
8123
|
return {
|
8436
8124
|
state,
|
@@ -8454,10 +8142,10 @@ function PuckProvider({ children }) {
|
|
8454
8142
|
metadata
|
8455
8143
|
]
|
8456
8144
|
);
|
8457
|
-
const [appStore] = (0,
|
8145
|
+
const [appStore] = (0, import_react54.useState)(
|
8458
8146
|
() => createAppStore(generateAppStore(initialAppState))
|
8459
8147
|
);
|
8460
|
-
(0,
|
8148
|
+
(0, import_react54.useEffect)(() => {
|
8461
8149
|
const state = appStore.getState().state;
|
8462
8150
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
8463
8151
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
@@ -8466,8 +8154,8 @@ function PuckProvider({ children }) {
|
|
8466
8154
|
index: initialHistoryIndex,
|
8467
8155
|
initialAppState
|
8468
8156
|
});
|
8469
|
-
const previousData = (0,
|
8470
|
-
(0,
|
8157
|
+
const previousData = (0, import_react54.useRef)(null);
|
8158
|
+
(0, import_react54.useEffect)(() => {
|
8471
8159
|
appStore.subscribe(
|
8472
8160
|
(s) => s.state.data,
|
8473
8161
|
(data) => {
|
@@ -8481,7 +8169,7 @@ function PuckProvider({ children }) {
|
|
8481
8169
|
}, []);
|
8482
8170
|
useRegisterPermissionsSlice(appStore, permissions);
|
8483
8171
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
8484
|
-
(0,
|
8172
|
+
(0, import_react54.useEffect)(() => {
|
8485
8173
|
const { resolveAndCommitData } = appStore.getState();
|
8486
8174
|
resolveAndCommitData();
|
8487
8175
|
}, []);
|
@@ -8507,13 +8195,13 @@ function PuckLayout({ children }) {
|
|
8507
8195
|
const rightSideBarVisible = useAppStore(
|
8508
8196
|
(s) => s.state.ui.rightSideBarVisible
|
8509
8197
|
);
|
8510
|
-
const [menuOpen, setMenuOpen] = (0,
|
8198
|
+
const [menuOpen, setMenuOpen] = (0, import_react54.useState)(false);
|
8511
8199
|
const appStore = useAppStoreApi();
|
8512
8200
|
const rootProps = useAppStore(
|
8513
8201
|
(s) => s.state.data.root.props || s.state.data.root.props
|
8514
8202
|
);
|
8515
8203
|
const dispatch = useAppStore((s) => s.dispatch);
|
8516
|
-
const toggleSidebars = (0,
|
8204
|
+
const toggleSidebars = (0, import_react54.useCallback)(
|
8517
8205
|
(sidebar) => {
|
8518
8206
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
8519
8207
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -8527,7 +8215,7 @@ function PuckLayout({ children }) {
|
|
8527
8215
|
},
|
8528
8216
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
8529
8217
|
);
|
8530
|
-
(0,
|
8218
|
+
(0, import_react54.useEffect)(() => {
|
8531
8219
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
8532
8220
|
dispatch({
|
8533
8221
|
type: "setUi",
|
@@ -8550,7 +8238,7 @@ function PuckLayout({ children }) {
|
|
8550
8238
|
window.removeEventListener("resize", handleResize);
|
8551
8239
|
};
|
8552
8240
|
}, []);
|
8553
|
-
const defaultHeaderRender = (0,
|
8241
|
+
const defaultHeaderRender = (0, import_react54.useMemo)(() => {
|
8554
8242
|
if (renderHeader) {
|
8555
8243
|
console.warn(
|
8556
8244
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -8565,7 +8253,7 @@ function PuckLayout({ children }) {
|
|
8565
8253
|
}
|
8566
8254
|
return DefaultOverride;
|
8567
8255
|
}, [renderHeader]);
|
8568
|
-
const defaultHeaderActionsRender = (0,
|
8256
|
+
const defaultHeaderActionsRender = (0, import_react54.useMemo)(() => {
|
8569
8257
|
if (renderHeaderActions) {
|
8570
8258
|
console.warn(
|
8571
8259
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -8580,25 +8268,25 @@ function PuckLayout({ children }) {
|
|
8580
8268
|
return DefaultOverride;
|
8581
8269
|
}, [renderHeader]);
|
8582
8270
|
const overrides = useAppStore((s) => s.overrides);
|
8583
|
-
const CustomPuck = (0,
|
8271
|
+
const CustomPuck = (0, import_react54.useMemo)(
|
8584
8272
|
() => overrides.puck || DefaultOverride,
|
8585
8273
|
[overrides]
|
8586
8274
|
);
|
8587
|
-
const CustomHeader = (0,
|
8275
|
+
const CustomHeader = (0, import_react54.useMemo)(
|
8588
8276
|
() => overrides.header || defaultHeaderRender,
|
8589
8277
|
[overrides]
|
8590
8278
|
);
|
8591
|
-
const CustomHeaderActions = (0,
|
8279
|
+
const CustomHeaderActions = (0, import_react54.useMemo)(
|
8592
8280
|
() => overrides.headerActions || defaultHeaderActionsRender,
|
8593
8281
|
[overrides]
|
8594
8282
|
);
|
8595
|
-
const [mounted, setMounted] = (0,
|
8596
|
-
(0,
|
8283
|
+
const [mounted, setMounted] = (0, import_react54.useState)(false);
|
8284
|
+
(0, import_react54.useEffect)(() => {
|
8597
8285
|
setMounted(true);
|
8598
8286
|
}, []);
|
8599
8287
|
const ready = useAppStore((s) => s.status === "READY");
|
8600
8288
|
useMonitorHotkeys();
|
8601
|
-
(0,
|
8289
|
+
(0, import_react54.useEffect)(() => {
|
8602
8290
|
if (ready && iframe.enabled) {
|
8603
8291
|
const frameDoc = getFrame();
|
8604
8292
|
if (frameDoc) {
|
@@ -8768,7 +8456,7 @@ var migrations = [
|
|
8768
8456
|
const [id, slotName] = zoneCompound.split(":");
|
8769
8457
|
const nodeData = indexes.nodes[id].data;
|
8770
8458
|
const componentType = nodeData.type;
|
8771
|
-
const configForComponent = config.components[componentType];
|
8459
|
+
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
8772
8460
|
if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
|
8773
8461
|
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
8774
8462
|
props: __spreadProps(__spreadValues({}, nodeData.props), {
|
@@ -8826,11 +8514,13 @@ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
8826
8514
|
});
|
8827
8515
|
|
8828
8516
|
// lib/transform-props.ts
|
8829
|
-
function transformProps(data, propTransforms) {
|
8517
|
+
function transformProps(data, propTransforms, config = { components: {} }) {
|
8830
8518
|
const mapItem = (item) => {
|
8831
8519
|
if (propTransforms[item.type]) {
|
8832
8520
|
return __spreadProps(__spreadValues({}, item), {
|
8833
|
-
props:
|
8521
|
+
props: __spreadValues({
|
8522
|
+
id: item.props.id
|
8523
|
+
}, propTransforms[item.type](item.props))
|
8834
8524
|
});
|
8835
8525
|
}
|
8836
8526
|
return item;
|
@@ -8839,23 +8529,18 @@ function transformProps(data, propTransforms) {
|
|
8839
8529
|
const rootProps = defaultedData.root.props || defaultedData.root;
|
8840
8530
|
let newRoot = __spreadValues({}, defaultedData.root);
|
8841
8531
|
if (propTransforms["root"]) {
|
8842
|
-
|
8843
|
-
newRoot.props = propTransforms["root"](rootProps);
|
8844
|
-
} else {
|
8845
|
-
newRoot = propTransforms["root"](rootProps);
|
8846
|
-
}
|
8532
|
+
newRoot.props = propTransforms["root"](rootProps);
|
8847
8533
|
}
|
8848
|
-
const
|
8849
|
-
|
8850
|
-
|
8851
|
-
|
8852
|
-
|
8853
|
-
|
8854
|
-
|
8855
|
-
|
8856
|
-
|
8857
|
-
|
8858
|
-
return afterPropTransforms;
|
8534
|
+
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
8535
|
+
const updatedData = walkTree(
|
8536
|
+
dataWithUpdatedRoot,
|
8537
|
+
config,
|
8538
|
+
(content) => content.map(mapItem)
|
8539
|
+
);
|
8540
|
+
if (!defaultedData.root.props) {
|
8541
|
+
updatedData.root = updatedData.root.props;
|
8542
|
+
}
|
8543
|
+
return updatedData;
|
8859
8544
|
}
|
8860
8545
|
|
8861
8546
|
// lib/resolve-all-data.ts
|
@@ -8940,6 +8625,7 @@ function resolveAllData(_0, _1) {
|
|
8940
8625
|
renderContext,
|
8941
8626
|
resolveAllData,
|
8942
8627
|
transformProps,
|
8628
|
+
useGetPuck,
|
8943
8629
|
usePuck,
|
8944
8630
|
walkTree
|
8945
8631
|
});
|