@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.mjs
CHANGED
@@ -4,16 +4,14 @@ import {
|
|
4
4
|
__async,
|
5
5
|
__commonJS,
|
6
6
|
__objRest,
|
7
|
-
__privateAdd,
|
8
|
-
__privateGet,
|
9
|
-
__privateSet,
|
10
7
|
__spreadProps,
|
11
8
|
__spreadValues,
|
12
9
|
__toESM,
|
13
|
-
|
10
|
+
defaultAppState,
|
11
|
+
defaultViewports,
|
14
12
|
getChanged,
|
15
13
|
init_react_import,
|
16
|
-
|
14
|
+
migrate,
|
17
15
|
resolveAllData,
|
18
16
|
resolveComponentData,
|
19
17
|
rootAreaId,
|
@@ -22,8 +20,9 @@ import {
|
|
22
20
|
setupZone,
|
23
21
|
transformProps,
|
24
22
|
useSlots,
|
23
|
+
walkAppState,
|
25
24
|
walkTree
|
26
|
-
} from "./chunk-
|
25
|
+
} from "./chunk-DDGE2CCN.mjs";
|
27
26
|
|
28
27
|
// ../../node_modules/classnames/index.js
|
29
28
|
var require_classnames = __commonJS({
|
@@ -703,198 +702,6 @@ init_react_import();
|
|
703
702
|
|
704
703
|
// reducer/actions/set.ts
|
705
704
|
init_react_import();
|
706
|
-
|
707
|
-
// lib/data/walk-app-state.ts
|
708
|
-
init_react_import();
|
709
|
-
|
710
|
-
// lib/data/for-each-slot.ts
|
711
|
-
init_react_import();
|
712
|
-
var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
|
713
|
-
const props = item.props || {};
|
714
|
-
const propKeys = Object.keys(props);
|
715
|
-
for (let i = 0; i < propKeys.length; i++) {
|
716
|
-
const propKey = propKeys[i];
|
717
|
-
const itemType = "type" in item ? item.type : "root";
|
718
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
719
|
-
const content = props[propKey];
|
720
|
-
cb(props.id, propKey, content);
|
721
|
-
if (recursive) {
|
722
|
-
content.forEach(
|
723
|
-
(childItem) => __async(void 0, null, function* () {
|
724
|
-
return forEachSlot(childItem, cb, true, isSlot2);
|
725
|
-
})
|
726
|
-
);
|
727
|
-
}
|
728
|
-
}
|
729
|
-
}
|
730
|
-
};
|
731
|
-
|
732
|
-
// lib/data/for-related-zones.ts
|
733
|
-
init_react_import();
|
734
|
-
|
735
|
-
// lib/get-zone-id.ts
|
736
|
-
init_react_import();
|
737
|
-
var getZoneId = (zoneCompound) => {
|
738
|
-
if (!zoneCompound) {
|
739
|
-
return [];
|
740
|
-
}
|
741
|
-
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
742
|
-
return zoneCompound.split(":");
|
743
|
-
}
|
744
|
-
return [rootDroppableId, zoneCompound];
|
745
|
-
};
|
746
|
-
|
747
|
-
// lib/data/for-related-zones.ts
|
748
|
-
function forRelatedZones(item, data, cb, path = []) {
|
749
|
-
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
750
|
-
const [parentId] = getZoneId(zoneCompound);
|
751
|
-
if (parentId === item.props.id) {
|
752
|
-
cb(path, zoneCompound, content);
|
753
|
-
}
|
754
|
-
});
|
755
|
-
}
|
756
|
-
|
757
|
-
// lib/data/strip-slots.ts
|
758
|
-
init_react_import();
|
759
|
-
var stripSlots = (data) => {
|
760
|
-
return __spreadProps(__spreadValues({}, data), {
|
761
|
-
props: Object.entries(data.props).reduce(
|
762
|
-
(acc, [propKey, propVal]) => {
|
763
|
-
if (isSlot(propVal)) {
|
764
|
-
return acc;
|
765
|
-
}
|
766
|
-
return __spreadProps(__spreadValues({}, acc), { [propKey]: propVal });
|
767
|
-
},
|
768
|
-
{ id: data.props.id }
|
769
|
-
)
|
770
|
-
});
|
771
|
-
};
|
772
|
-
|
773
|
-
// lib/data/walk-app-state.ts
|
774
|
-
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
775
|
-
var _a;
|
776
|
-
let newZones = {};
|
777
|
-
const newZoneIndex = {};
|
778
|
-
const newNodeIndex = {};
|
779
|
-
const processContent = (path, zoneCompound, content, zoneType, newId) => {
|
780
|
-
var _a2;
|
781
|
-
const [parentId] = zoneCompound.split(":");
|
782
|
-
const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
|
783
|
-
const [_2, zone] = zoneCompound.split(":");
|
784
|
-
const newZoneCompound = `${newId || parentId}:${zone}`;
|
785
|
-
const newContent2 = mappedContent.map(
|
786
|
-
(zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
|
787
|
-
);
|
788
|
-
newZoneIndex[newZoneCompound] = {
|
789
|
-
contentIds: newContent2.map((item) => item.props.id),
|
790
|
-
type: zoneType
|
791
|
-
};
|
792
|
-
return [newZoneCompound, newContent2];
|
793
|
-
};
|
794
|
-
const processRelatedZones = (item, newId, initialPath) => {
|
795
|
-
forRelatedZones(
|
796
|
-
item,
|
797
|
-
state.data,
|
798
|
-
(relatedPath, relatedZoneCompound, relatedContent) => {
|
799
|
-
const [zoneCompound, newContent2] = processContent(
|
800
|
-
relatedPath,
|
801
|
-
relatedZoneCompound,
|
802
|
-
relatedContent,
|
803
|
-
"dropzone",
|
804
|
-
newId
|
805
|
-
);
|
806
|
-
newZones[zoneCompound] = newContent2;
|
807
|
-
},
|
808
|
-
initialPath
|
809
|
-
);
|
810
|
-
};
|
811
|
-
const processItem = (item, path, index) => {
|
812
|
-
const mappedItem = mapNodeOrSkip(item, path, index);
|
813
|
-
if (!mappedItem) return item;
|
814
|
-
const id = mappedItem.props.id;
|
815
|
-
const newProps = __spreadValues({}, mappedItem.props);
|
816
|
-
forEachSlot(
|
817
|
-
mappedItem,
|
818
|
-
(parentId2, slotId, content) => {
|
819
|
-
const zoneCompound = `${parentId2}:${slotId}`;
|
820
|
-
const [_2, newContent2] = processContent(
|
821
|
-
path,
|
822
|
-
zoneCompound,
|
823
|
-
content,
|
824
|
-
"slot",
|
825
|
-
parentId2
|
826
|
-
);
|
827
|
-
newProps[slotId] = newContent2;
|
828
|
-
},
|
829
|
-
false,
|
830
|
-
createIsSlotConfig(config)
|
831
|
-
);
|
832
|
-
processRelatedZones(item, id, path);
|
833
|
-
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
834
|
-
const thisZoneCompound = path[path.length - 1];
|
835
|
-
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
836
|
-
newNodeIndex[id] = {
|
837
|
-
data: newItem,
|
838
|
-
flatData: stripSlots(newItem),
|
839
|
-
path,
|
840
|
-
parentId,
|
841
|
-
zone
|
842
|
-
};
|
843
|
-
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
844
|
-
if (newProps.id === "root") {
|
845
|
-
delete finalData["type"];
|
846
|
-
delete finalData.props["id"];
|
847
|
-
}
|
848
|
-
return finalData;
|
849
|
-
};
|
850
|
-
const zones = state.data.zones || {};
|
851
|
-
const [_, newContent] = processContent(
|
852
|
-
[],
|
853
|
-
rootDroppableId,
|
854
|
-
state.data.content,
|
855
|
-
"root"
|
856
|
-
);
|
857
|
-
const processedContent = newContent;
|
858
|
-
const zonesAlreadyProcessed = Object.keys(newZones);
|
859
|
-
Object.keys(zones || {}).forEach((zoneCompound) => {
|
860
|
-
const [parentId] = zoneCompound.split(":");
|
861
|
-
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
862
|
-
return;
|
863
|
-
}
|
864
|
-
const [_2, newContent2] = processContent(
|
865
|
-
[rootDroppableId],
|
866
|
-
zoneCompound,
|
867
|
-
zones[zoneCompound],
|
868
|
-
"dropzone",
|
869
|
-
parentId
|
870
|
-
);
|
871
|
-
newZones[zoneCompound] = newContent2;
|
872
|
-
}, newZones);
|
873
|
-
const processedRoot = processItem(
|
874
|
-
{
|
875
|
-
type: "root",
|
876
|
-
props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
|
877
|
-
},
|
878
|
-
[],
|
879
|
-
-1
|
880
|
-
);
|
881
|
-
const root = __spreadProps(__spreadValues({}, state.data.root), {
|
882
|
-
props: processedRoot.props
|
883
|
-
});
|
884
|
-
return __spreadProps(__spreadValues({}, state), {
|
885
|
-
data: {
|
886
|
-
root,
|
887
|
-
content: processedContent,
|
888
|
-
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
889
|
-
},
|
890
|
-
indexes: {
|
891
|
-
nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
|
892
|
-
zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
|
893
|
-
}
|
894
|
-
});
|
895
|
-
}
|
896
|
-
|
897
|
-
// reducer/actions/set.ts
|
898
705
|
var setAction = (state, action, appStore) => {
|
899
706
|
if (typeof action.state === "object") {
|
900
707
|
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
@@ -1377,14 +1184,6 @@ function createReducer({
|
|
1377
1184
|
);
|
1378
1185
|
}
|
1379
1186
|
|
1380
|
-
// components/ViewportControls/default-viewports.ts
|
1381
|
-
init_react_import();
|
1382
|
-
var defaultViewports = [
|
1383
|
-
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
1384
|
-
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
1385
|
-
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
1386
|
-
];
|
1387
|
-
|
1388
1187
|
// store/index.ts
|
1389
1188
|
import { create as create2, useStore } from "zustand";
|
1390
1189
|
import { subscribeWithSelector as subscribeWithSelector2 } from "zustand/middleware";
|
@@ -1905,31 +1704,6 @@ var toRoot = (item) => {
|
|
1905
1704
|
};
|
1906
1705
|
|
1907
1706
|
// store/index.ts
|
1908
|
-
var defaultAppState = {
|
1909
|
-
data: { content: [], root: {}, zones: {} },
|
1910
|
-
ui: {
|
1911
|
-
leftSideBarVisible: true,
|
1912
|
-
rightSideBarVisible: true,
|
1913
|
-
arrayState: {},
|
1914
|
-
itemSelector: null,
|
1915
|
-
componentList: {},
|
1916
|
-
isDragging: false,
|
1917
|
-
previewMode: "edit",
|
1918
|
-
viewports: {
|
1919
|
-
current: {
|
1920
|
-
width: defaultViewports[0].width,
|
1921
|
-
height: defaultViewports[0].height || "auto"
|
1922
|
-
},
|
1923
|
-
options: [],
|
1924
|
-
controlsVisible: true
|
1925
|
-
},
|
1926
|
-
field: { focus: null }
|
1927
|
-
},
|
1928
|
-
indexes: {
|
1929
|
-
nodes: {},
|
1930
|
-
zones: {}
|
1931
|
-
}
|
1932
|
-
};
|
1933
1707
|
var defaultPageFields = {
|
1934
1708
|
title: { type: "text" }
|
1935
1709
|
};
|
@@ -2118,326 +1892,11 @@ function useAppStoreApi() {
|
|
2118
1892
|
init_react_import();
|
2119
1893
|
import { DragDropProvider } from "@dnd-kit/react";
|
2120
1894
|
|
2121
|
-
// lib/dnd/dnd-kit/safe.ts
|
2122
|
-
init_react_import();
|
2123
|
-
import {
|
2124
|
-
useDraggable,
|
2125
|
-
useDroppable
|
2126
|
-
} from "@dnd-kit/react";
|
2127
|
-
import { useSortable } from "@dnd-kit/react/sortable";
|
2128
|
-
function useDroppableSafe(input) {
|
2129
|
-
if (typeof window === "undefined") {
|
2130
|
-
return { ref: () => {
|
2131
|
-
} };
|
2132
|
-
}
|
2133
|
-
return useDroppable(input);
|
2134
|
-
}
|
2135
|
-
function useDraggableSafe(input) {
|
2136
|
-
if (typeof window === "undefined") {
|
2137
|
-
return { ref: () => {
|
2138
|
-
} };
|
2139
|
-
}
|
2140
|
-
return useDraggable(input);
|
2141
|
-
}
|
2142
|
-
function useSortableSafe(input) {
|
2143
|
-
if (typeof window === "undefined") {
|
2144
|
-
return { ref: () => {
|
2145
|
-
}, status: "idle", handleRef: () => {
|
2146
|
-
} };
|
2147
|
-
}
|
2148
|
-
return useSortable(input);
|
2149
|
-
}
|
2150
|
-
|
2151
1895
|
// lib/dnd/use-sensors.ts
|
2152
1896
|
init_react_import();
|
2153
1897
|
import { useState as useState2 } from "react";
|
2154
|
-
|
2155
|
-
|
2156
|
-
init_react_import();
|
2157
|
-
import { batch, effect } from "@dnd-kit/state";
|
2158
|
-
import { Sensor, configurator } from "@dnd-kit/abstract";
|
2159
|
-
import {
|
2160
|
-
exceedsDistance
|
2161
|
-
} from "@dnd-kit/geometry";
|
2162
|
-
import {
|
2163
|
-
getDocument,
|
2164
|
-
isElement,
|
2165
|
-
isHTMLElement,
|
2166
|
-
isPointerEvent,
|
2167
|
-
Listeners,
|
2168
|
-
getFrameTransform
|
2169
|
-
} from "@dnd-kit/dom/utilities";
|
2170
|
-
var _clearTimeout;
|
2171
|
-
var _PointerSensor = class _PointerSensor extends Sensor {
|
2172
|
-
constructor(manager, options) {
|
2173
|
-
super(manager);
|
2174
|
-
this.manager = manager;
|
2175
|
-
this.options = options;
|
2176
|
-
this.listeners = new Listeners();
|
2177
|
-
this.cleanup = /* @__PURE__ */ new Set();
|
2178
|
-
this.source = void 0;
|
2179
|
-
this.started = false;
|
2180
|
-
__privateAdd(this, _clearTimeout);
|
2181
|
-
this.handleCancel = this.handleCancel.bind(this);
|
2182
|
-
this.handlePointerUp = this.handlePointerUp.bind(this);
|
2183
|
-
this.handleKeyDown = this.handleKeyDown.bind(this);
|
2184
|
-
effect(() => {
|
2185
|
-
const unbindGlobal = this.bindGlobal(options != null ? options : {});
|
2186
|
-
return () => {
|
2187
|
-
unbindGlobal();
|
2188
|
-
};
|
2189
|
-
});
|
2190
|
-
}
|
2191
|
-
bind(source, options = this.options) {
|
2192
|
-
const unbind = effect(() => {
|
2193
|
-
var _a;
|
2194
|
-
const target = (_a = source.handle) != null ? _a : source.element;
|
2195
|
-
const listener = (event) => {
|
2196
|
-
if (isPointerEvent(event)) {
|
2197
|
-
this.handlePointerDown(event, source, options);
|
2198
|
-
}
|
2199
|
-
};
|
2200
|
-
if (target) {
|
2201
|
-
patchWindow(target.ownerDocument.defaultView);
|
2202
|
-
target.addEventListener("pointerdown", listener);
|
2203
|
-
return () => {
|
2204
|
-
target.removeEventListener("pointerdown", listener);
|
2205
|
-
};
|
2206
|
-
}
|
2207
|
-
});
|
2208
|
-
return unbind;
|
2209
|
-
}
|
2210
|
-
bindGlobal(options) {
|
2211
|
-
const documents = /* @__PURE__ */ new Set();
|
2212
|
-
for (const draggable of this.manager.registry.draggables.value) {
|
2213
|
-
if (draggable.element) {
|
2214
|
-
documents.add(getDocument(draggable.element));
|
2215
|
-
}
|
2216
|
-
}
|
2217
|
-
for (const droppable of this.manager.registry.droppables.value) {
|
2218
|
-
if (droppable.element) {
|
2219
|
-
documents.add(getDocument(droppable.element));
|
2220
|
-
}
|
2221
|
-
}
|
2222
|
-
const unbindFns = Array.from(documents).map(
|
2223
|
-
(doc) => this.listeners.bind(doc, [
|
2224
|
-
{
|
2225
|
-
type: "pointermove",
|
2226
|
-
listener: (event) => this.handlePointerMove(event, doc, options)
|
2227
|
-
},
|
2228
|
-
{
|
2229
|
-
type: "pointerup",
|
2230
|
-
listener: this.handlePointerUp,
|
2231
|
-
options: {
|
2232
|
-
capture: true
|
2233
|
-
}
|
2234
|
-
},
|
2235
|
-
{
|
2236
|
-
// Cancel activation if there is a competing Drag and Drop interaction
|
2237
|
-
type: "dragstart",
|
2238
|
-
listener: this.handleDragStart
|
2239
|
-
}
|
2240
|
-
])
|
2241
|
-
);
|
2242
|
-
return () => {
|
2243
|
-
unbindFns.forEach((unbind) => unbind());
|
2244
|
-
};
|
2245
|
-
}
|
2246
|
-
handlePointerDown(event, source, options = {}) {
|
2247
|
-
if (this.disabled || !event.isPrimary || event.button !== 0 || !isElement(event.target) || source.disabled) {
|
2248
|
-
return;
|
2249
|
-
}
|
2250
|
-
const offset = getFrameTransform(source.element);
|
2251
|
-
this.initialCoordinates = {
|
2252
|
-
x: event.clientX * offset.scaleX + offset.x,
|
2253
|
-
y: event.clientY * offset.scaleY + offset.y
|
2254
|
-
};
|
2255
|
-
this.source = source;
|
2256
|
-
const { activationConstraints } = options;
|
2257
|
-
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
|
2258
|
-
event.stopImmediatePropagation();
|
2259
|
-
if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
|
2260
|
-
this.handleStart(source, event);
|
2261
|
-
} else {
|
2262
|
-
const { delay } = constraints;
|
2263
|
-
if (delay) {
|
2264
|
-
const timeout3 = setTimeout(
|
2265
|
-
() => this.handleStart(source, event),
|
2266
|
-
delay.value
|
2267
|
-
);
|
2268
|
-
__privateSet(this, _clearTimeout, () => {
|
2269
|
-
clearTimeout(timeout3);
|
2270
|
-
__privateSet(this, _clearTimeout, void 0);
|
2271
|
-
});
|
2272
|
-
}
|
2273
|
-
}
|
2274
|
-
const cleanup = () => {
|
2275
|
-
var _a;
|
2276
|
-
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
2277
|
-
this.initialCoordinates = void 0;
|
2278
|
-
this.source = void 0;
|
2279
|
-
};
|
2280
|
-
this.cleanup.add(cleanup);
|
2281
|
-
}
|
2282
|
-
handlePointerMove(event, doc, options) {
|
2283
|
-
if (!this.source) {
|
2284
|
-
return;
|
2285
|
-
}
|
2286
|
-
const ownerDocument = this.source.element && getDocument(this.source.element);
|
2287
|
-
if (doc !== ownerDocument) {
|
2288
|
-
return;
|
2289
|
-
}
|
2290
|
-
const coordinates = {
|
2291
|
-
x: event.clientX,
|
2292
|
-
y: event.clientY
|
2293
|
-
};
|
2294
|
-
const offset = getFrameTransform(this.source.element);
|
2295
|
-
coordinates.x = coordinates.x * offset.scaleX + offset.x;
|
2296
|
-
coordinates.y = coordinates.y * offset.scaleY + offset.y;
|
2297
|
-
if (this.manager.dragOperation.status.dragging) {
|
2298
|
-
event.preventDefault();
|
2299
|
-
event.stopPropagation();
|
2300
|
-
this.manager.actions.move({ to: coordinates });
|
2301
|
-
return;
|
2302
|
-
}
|
2303
|
-
if (!this.initialCoordinates) {
|
2304
|
-
return;
|
2305
|
-
}
|
2306
|
-
const delta = {
|
2307
|
-
x: coordinates.x - this.initialCoordinates.x,
|
2308
|
-
y: coordinates.y - this.initialCoordinates.y
|
2309
|
-
};
|
2310
|
-
const { activationConstraints } = options;
|
2311
|
-
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
|
2312
|
-
const { distance, delay } = constraints != null ? constraints : {};
|
2313
|
-
if (distance) {
|
2314
|
-
if (distance.tolerance != null && exceedsDistance(delta, distance.tolerance)) {
|
2315
|
-
return this.handleCancel();
|
2316
|
-
}
|
2317
|
-
if (exceedsDistance(delta, distance.value)) {
|
2318
|
-
return this.handleStart(this.source, event);
|
2319
|
-
}
|
2320
|
-
}
|
2321
|
-
if (delay) {
|
2322
|
-
if (exceedsDistance(delta, delay.tolerance)) {
|
2323
|
-
return this.handleCancel();
|
2324
|
-
}
|
2325
|
-
}
|
2326
|
-
}
|
2327
|
-
handlePointerUp(event) {
|
2328
|
-
if (!this.source) {
|
2329
|
-
return;
|
2330
|
-
}
|
2331
|
-
event.preventDefault();
|
2332
|
-
event.stopPropagation();
|
2333
|
-
const { status } = this.manager.dragOperation;
|
2334
|
-
if (!status.idle) {
|
2335
|
-
const canceled = !status.initialized;
|
2336
|
-
this.manager.actions.stop({ canceled });
|
2337
|
-
} else if (this.started) {
|
2338
|
-
setTimeout(() => {
|
2339
|
-
if (!this.manager.dragOperation.status.idle) {
|
2340
|
-
this.manager.actions.stop({ canceled: false });
|
2341
|
-
}
|
2342
|
-
}, 10);
|
2343
|
-
}
|
2344
|
-
this.cleanup.forEach((cleanup) => cleanup());
|
2345
|
-
this.cleanup.clear();
|
2346
|
-
}
|
2347
|
-
handleKeyDown(event) {
|
2348
|
-
if (event.key === "Escape") {
|
2349
|
-
event.preventDefault();
|
2350
|
-
this.handleCancel();
|
2351
|
-
}
|
2352
|
-
}
|
2353
|
-
handleStart(source, event) {
|
2354
|
-
var _a;
|
2355
|
-
const { manager, initialCoordinates } = this;
|
2356
|
-
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
2357
|
-
if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
|
2358
|
-
return;
|
2359
|
-
}
|
2360
|
-
if (event.defaultPrevented) {
|
2361
|
-
return;
|
2362
|
-
}
|
2363
|
-
this.started = true;
|
2364
|
-
event.preventDefault();
|
2365
|
-
batch(() => {
|
2366
|
-
manager.actions.setDragSource(source.id);
|
2367
|
-
manager.actions.start({ coordinates: initialCoordinates, event });
|
2368
|
-
});
|
2369
|
-
const ownerDocument = getDocument(event.target);
|
2370
|
-
const unbind = this.listeners.bind(ownerDocument, [
|
2371
|
-
{
|
2372
|
-
// Prevent scrolling on touch devices
|
2373
|
-
type: "touchmove",
|
2374
|
-
listener: preventDefault,
|
2375
|
-
options: {
|
2376
|
-
passive: false
|
2377
|
-
}
|
2378
|
-
},
|
2379
|
-
{
|
2380
|
-
// Prevent click events
|
2381
|
-
type: "click",
|
2382
|
-
listener: preventDefault
|
2383
|
-
},
|
2384
|
-
{
|
2385
|
-
type: "keydown",
|
2386
|
-
listener: this.handleKeyDown
|
2387
|
-
}
|
2388
|
-
]);
|
2389
|
-
ownerDocument.body.setPointerCapture(event.pointerId);
|
2390
|
-
this.cleanup.add(unbind);
|
2391
|
-
this.cleanup.add(() => {
|
2392
|
-
this.started = false;
|
2393
|
-
});
|
2394
|
-
}
|
2395
|
-
handleDragStart(event) {
|
2396
|
-
const { target } = event;
|
2397
|
-
if (!isElement(target)) {
|
2398
|
-
return;
|
2399
|
-
}
|
2400
|
-
const isNativeDraggable = isHTMLElement(target) && target.draggable && target.getAttribute("draggable") === "true";
|
2401
|
-
if (isNativeDraggable) {
|
2402
|
-
this.handleCancel();
|
2403
|
-
} else {
|
2404
|
-
preventDefault(event);
|
2405
|
-
}
|
2406
|
-
}
|
2407
|
-
handleCancel() {
|
2408
|
-
const { dragOperation } = this.manager;
|
2409
|
-
if (dragOperation.status.initialized) {
|
2410
|
-
this.manager.actions.stop({ canceled: true });
|
2411
|
-
}
|
2412
|
-
this.cleanup.forEach((cleanup) => cleanup());
|
2413
|
-
this.cleanup.clear();
|
2414
|
-
}
|
2415
|
-
destroy() {
|
2416
|
-
this.listeners.clear();
|
2417
|
-
}
|
2418
|
-
};
|
2419
|
-
_clearTimeout = new WeakMap();
|
2420
|
-
_PointerSensor.configure = configurator(_PointerSensor);
|
2421
|
-
var PointerSensor = _PointerSensor;
|
2422
|
-
function preventDefault(event) {
|
2423
|
-
event.preventDefault();
|
2424
|
-
}
|
2425
|
-
function noop() {
|
2426
|
-
}
|
2427
|
-
var windows = /* @__PURE__ */ new WeakSet();
|
2428
|
-
function patchWindow(window2) {
|
2429
|
-
if (!window2 || windows.has(window2)) {
|
2430
|
-
return;
|
2431
|
-
}
|
2432
|
-
window2.addEventListener("touchmove", noop, {
|
2433
|
-
capture: false,
|
2434
|
-
passive: false
|
2435
|
-
});
|
2436
|
-
windows.add(window2);
|
2437
|
-
}
|
2438
|
-
|
2439
|
-
// lib/dnd/use-sensors.ts
|
2440
|
-
import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
|
1898
|
+
import { PointerSensor } from "@dnd-kit/react";
|
1899
|
+
import { isElement } from "@dnd-kit/dom/utilities";
|
2441
1900
|
var useSensors = ({
|
2442
1901
|
other,
|
2443
1902
|
mouse,
|
@@ -2451,7 +1910,7 @@ var useSensors = ({
|
|
2451
1910
|
activationConstraints(event, source) {
|
2452
1911
|
var _a;
|
2453
1912
|
const { pointerType, target } = event;
|
2454
|
-
if (pointerType === "mouse" &&
|
1913
|
+
if (pointerType === "mouse" && isElement(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
2455
1914
|
return mouse;
|
2456
1915
|
}
|
2457
1916
|
if (pointerType === "touch") {
|
@@ -2621,7 +2080,7 @@ import { Point as Point2 } from "@dnd-kit/geometry";
|
|
2621
2080
|
import { CollisionPriority as CollisionPriority2, CollisionType as CollisionType22 } from "@dnd-kit/abstract";
|
2622
2081
|
import { Point as Point22 } from "@dnd-kit/geometry";
|
2623
2082
|
import { CollisionPriority as CollisionPriority3, CollisionType as CollisionType3 } from "@dnd-kit/abstract";
|
2624
|
-
import { Point as Point3 } from "@dnd-kit/geometry";
|
2083
|
+
import { Point as Point3, Rectangle } from "@dnd-kit/geometry";
|
2625
2084
|
import { CollisionPriority as CollisionPriority4, CollisionType as CollisionType4 } from "@dnd-kit/abstract";
|
2626
2085
|
import { Point as Point4 } from "@dnd-kit/geometry";
|
2627
2086
|
import { CollisionPriority as CollisionPriority5, CollisionType as CollisionType5 } from "@dnd-kit/abstract";
|
@@ -2657,31 +2116,15 @@ var closestCorners = (input) => {
|
|
2657
2116
|
if (!droppable.shape) {
|
2658
2117
|
return null;
|
2659
2118
|
}
|
2660
|
-
const
|
2661
|
-
const
|
2662
|
-
|
2663
|
-
|
2664
|
-
|
2665
|
-
},
|
2666
|
-
{
|
2667
|
-
x: right,
|
2668
|
-
y: top
|
2669
|
-
},
|
2670
|
-
{
|
2671
|
-
x: left,
|
2672
|
-
y: bottom
|
2673
|
-
},
|
2674
|
-
{
|
2675
|
-
x: right,
|
2676
|
-
y: bottom
|
2677
|
-
}
|
2678
|
-
];
|
2679
|
-
const distance = corners.reduce(
|
2680
|
-
(acc, corner) => {
|
2119
|
+
const shapeCorners = shape ? Rectangle.from(shape.current.boundingRectangle).corners : void 0;
|
2120
|
+
const distance = Rectangle.from(
|
2121
|
+
droppable.shape.boundingRectangle
|
2122
|
+
).corners.reduce(
|
2123
|
+
(acc, corner, index) => {
|
2681
2124
|
var _a;
|
2682
2125
|
return acc + Point3.distance(
|
2683
2126
|
Point3.from(corner),
|
2684
|
-
(_a =
|
2127
|
+
(_a = shapeCorners == null ? void 0 : shapeCorners[index]) != null ? _a : position.current
|
2685
2128
|
);
|
2686
2129
|
},
|
2687
2130
|
0
|
@@ -2716,12 +2159,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2716
2159
|
const { center: dragCenter } = dragShape;
|
2717
2160
|
const { fallbackEnabled } = collisionStore.getState();
|
2718
2161
|
const interval = trackMovementInterval(position.current, dragAxis);
|
2719
|
-
|
2720
|
-
direction: interval.direction
|
2721
|
-
});
|
2722
|
-
const collisionMap = dragOperation.data.collisionMap || {};
|
2723
|
-
dragOperation.data.collisionMap = collisionMap;
|
2724
|
-
collisionMap[droppable.id] = {
|
2162
|
+
const data = {
|
2725
2163
|
direction: interval.direction
|
2726
2164
|
};
|
2727
2165
|
const { center: dropCenter } = dropShape;
|
@@ -2736,7 +2174,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2736
2174
|
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
|
2737
2175
|
if (collision) {
|
2738
2176
|
return __spreadProps(__spreadValues({}, collision), {
|
2739
|
-
priority: CollisionPriority7.Highest
|
2177
|
+
priority: CollisionPriority7.Highest,
|
2178
|
+
data
|
2740
2179
|
});
|
2741
2180
|
}
|
2742
2181
|
}
|
@@ -2758,7 +2197,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2758
2197
|
};
|
2759
2198
|
const shouldFlushId = flushNext === droppable.id;
|
2760
2199
|
flushNext = "";
|
2761
|
-
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2200
|
+
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id, data });
|
2762
2201
|
}
|
2763
2202
|
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2764
2203
|
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
@@ -2770,9 +2209,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2770
2209
|
x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
|
2771
2210
|
y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
|
2772
2211
|
});
|
2773
|
-
|
2774
|
-
direction
|
2775
|
-
};
|
2212
|
+
data.direction = direction;
|
2776
2213
|
if (intersectionArea) {
|
2777
2214
|
collisionDebug(
|
2778
2215
|
dragCenter,
|
@@ -2783,7 +2220,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2783
2220
|
);
|
2784
2221
|
flushNext = droppable.id;
|
2785
2222
|
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2786
|
-
priority: CollisionPriority7.Low
|
2223
|
+
priority: CollisionPriority7.Low,
|
2224
|
+
data
|
2787
2225
|
});
|
2788
2226
|
}
|
2789
2227
|
collisionDebug(
|
@@ -2793,16 +2231,19 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2793
2231
|
"orange",
|
2794
2232
|
direction || ""
|
2795
2233
|
);
|
2796
|
-
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2234
|
+
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2235
|
+
priority: CollisionPriority7.Lowest,
|
2236
|
+
data
|
2237
|
+
});
|
2797
2238
|
}
|
2798
2239
|
}
|
2799
2240
|
}
|
2800
2241
|
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
|
2801
|
-
delete collisionMap[droppable.id];
|
2802
2242
|
return null;
|
2803
2243
|
};
|
2804
2244
|
|
2805
2245
|
// components/Sortable/index.tsx
|
2246
|
+
import { useSortable } from "@dnd-kit/react/sortable";
|
2806
2247
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
2807
2248
|
var SortableProvider = ({
|
2808
2249
|
children,
|
@@ -2822,16 +2263,16 @@ var SortableProvider = ({
|
|
2822
2263
|
return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
|
2823
2264
|
},
|
2824
2265
|
onDragOver: (event, manager) => {
|
2825
|
-
var _a
|
2266
|
+
var _a;
|
2826
2267
|
event.preventDefault();
|
2827
2268
|
const { operation } = event;
|
2828
2269
|
const { source, target } = operation;
|
2829
2270
|
if (!source || !target) return;
|
2830
2271
|
let sourceIndex = source.data.index;
|
2831
2272
|
let targetIndex = target.data.index;
|
2832
|
-
const collisionData = (
|
2273
|
+
const collisionData = (_a = manager.collisionObserver.collisions[0]) == null ? void 0 : _a.data;
|
2833
2274
|
if (sourceIndex !== targetIndex && source.id !== target.id) {
|
2834
|
-
const collisionPosition = collisionData.direction === "up" ? "before" : "after";
|
2275
|
+
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
|
2835
2276
|
if (targetIndex >= sourceIndex) {
|
2836
2277
|
targetIndex = targetIndex - 1;
|
2837
2278
|
}
|
@@ -2862,9 +2303,10 @@ var Sortable = ({
|
|
2862
2303
|
}) => {
|
2863
2304
|
const {
|
2864
2305
|
ref: sortableRef,
|
2865
|
-
|
2306
|
+
isDragging,
|
2307
|
+
isDropping,
|
2866
2308
|
handleRef
|
2867
|
-
} =
|
2309
|
+
} = useSortable({
|
2868
2310
|
id,
|
2869
2311
|
type,
|
2870
2312
|
index,
|
@@ -2872,7 +2314,7 @@ var Sortable = ({
|
|
2872
2314
|
data: { index },
|
2873
2315
|
collisionDetector: createDynamicCollisionDetector("y")
|
2874
2316
|
});
|
2875
|
-
return children({
|
2317
|
+
return children({ isDragging, isDropping, ref: sortableRef, handleRef });
|
2876
2318
|
};
|
2877
2319
|
|
2878
2320
|
// components/AutoField/context.tsx
|
@@ -2997,7 +2439,7 @@ var ArrayField = ({
|
|
2997
2439
|
}
|
2998
2440
|
}, []);
|
2999
2441
|
const [draggedItem, setDraggedItem] = useState3("");
|
3000
|
-
const
|
2442
|
+
const isDraggingAny = !!draggedItem;
|
3001
2443
|
const canEdit = useAppStore(
|
3002
2444
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
3003
2445
|
);
|
@@ -3062,13 +2504,13 @@ var ArrayField = ({
|
|
3062
2504
|
id: _arrayId,
|
3063
2505
|
index: i,
|
3064
2506
|
disabled: readOnly,
|
3065
|
-
children: ({
|
2507
|
+
children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ jsxs3(
|
3066
2508
|
"div",
|
3067
2509
|
{
|
3068
2510
|
ref,
|
3069
2511
|
className: getClassNameItem({
|
3070
2512
|
isExpanded: arrayState.openId === _arrayId,
|
3071
|
-
isDragging
|
2513
|
+
isDragging,
|
3072
2514
|
readOnly
|
3073
2515
|
}),
|
3074
2516
|
children: [
|
@@ -3209,7 +2651,7 @@ var ArrayField = ({
|
|
3209
2651
|
type: "button",
|
3210
2652
|
className: getClassName5("addButton"),
|
3211
2653
|
onClick: () => {
|
3212
|
-
if (
|
2654
|
+
if (isDraggingAny) return;
|
3213
2655
|
const existingValue = value || [];
|
3214
2656
|
const newValue = [
|
3215
2657
|
...existingValue,
|
@@ -4344,6 +3786,7 @@ function useContextStore(context, selector) {
|
|
4344
3786
|
|
4345
3787
|
// components/DraggableComponent/index.tsx
|
4346
3788
|
import { useShallow as useShallow2 } from "zustand/react/shallow";
|
3789
|
+
import { useSortable as useSortable2 } from "@dnd-kit/react/sortable";
|
4347
3790
|
import { jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
|
4348
3791
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
4349
3792
|
var DEBUG2 = false;
|
@@ -4429,7 +3872,7 @@ var DraggableComponent = ({
|
|
4429
3872
|
const canCollide = permissions.drag || userIsDragging;
|
4430
3873
|
const disabled = !isEnabled || !canCollide;
|
4431
3874
|
const [dragAxis, setDragAxis] = useState10(userDragAxis || autoDragAxis);
|
4432
|
-
const { ref: sortableRef,
|
3875
|
+
const { ref: sortableRef, isDragging: thisIsDragging } = useSortable2({
|
4433
3876
|
id,
|
4434
3877
|
index,
|
4435
3878
|
group: zoneCompound,
|
@@ -4451,9 +3894,9 @@ var DraggableComponent = ({
|
|
4451
3894
|
transition: {
|
4452
3895
|
duration: 200,
|
4453
3896
|
easing: "cubic-bezier(0.2, 0, 0, 1)"
|
4454
|
-
}
|
3897
|
+
},
|
3898
|
+
feedback: "clone"
|
4455
3899
|
});
|
4456
|
-
const thisIsDragging = status === "dragging";
|
4457
3900
|
const ref = useRef2(null);
|
4458
3901
|
const refSetter = useCallback6(
|
4459
3902
|
(el) => {
|
@@ -4593,18 +4036,12 @@ var DraggableComponent = ({
|
|
4593
4036
|
el.addEventListener("click", onClick);
|
4594
4037
|
el.addEventListener("mouseover", _onMouseOver);
|
4595
4038
|
el.addEventListener("mouseout", _onMouseOut);
|
4596
|
-
if (thisIsDragging) {
|
4597
|
-
el.setAttribute("data-puck-dragging", "");
|
4598
|
-
} else {
|
4599
|
-
el.removeAttribute("data-puck-dragging");
|
4600
|
-
}
|
4601
4039
|
return () => {
|
4602
4040
|
el.removeAttribute("data-puck-component");
|
4603
4041
|
el.removeAttribute("data-puck-dnd");
|
4604
4042
|
el.removeEventListener("click", onClick);
|
4605
4043
|
el.removeEventListener("mouseover", _onMouseOver);
|
4606
4044
|
el.removeEventListener("mouseout", _onMouseOut);
|
4607
|
-
el.removeAttribute("data-puck-dragging");
|
4608
4045
|
};
|
4609
4046
|
}, [
|
4610
4047
|
ref,
|
@@ -4756,6 +4193,9 @@ var DraggableComponent = ({
|
|
4756
4193
|
init_react_import();
|
4757
4194
|
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" };
|
4758
4195
|
|
4196
|
+
// components/DropZone/index.tsx
|
4197
|
+
import { useDroppable } from "@dnd-kit/react";
|
4198
|
+
|
4759
4199
|
// components/DropZone/lib/use-min-empty-height.ts
|
4760
4200
|
init_react_import();
|
4761
4201
|
import { useEffect as useEffect12, useState as useState11 } from "react";
|
@@ -5268,7 +4708,7 @@ var DropZoneEdit = forwardRef3(
|
|
5268
4708
|
path: path || []
|
5269
4709
|
}
|
5270
4710
|
};
|
5271
|
-
const { ref: dropRef } =
|
4711
|
+
const { ref: dropRef } = useDroppable(droppableConfig);
|
5272
4712
|
const isAreaSelected = useAppStore(
|
5273
4713
|
(s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
|
5274
4714
|
);
|
@@ -5401,7 +4841,6 @@ var DropZone = forwardRef3(
|
|
5401
4841
|
// lib/dnd/NestedDroppablePlugin.ts
|
5402
4842
|
init_react_import();
|
5403
4843
|
import { Plugin } from "@dnd-kit/abstract";
|
5404
|
-
import { effects } from "@dnd-kit/state";
|
5405
4844
|
|
5406
4845
|
// lib/throttle.ts
|
5407
4846
|
init_react_import();
|
@@ -5515,7 +4954,7 @@ var depthSort = (candidates) => {
|
|
5515
4954
|
return 0;
|
5516
4955
|
});
|
5517
4956
|
};
|
5518
|
-
var
|
4957
|
+
var getZoneId = (candidate) => {
|
5519
4958
|
let id = candidate == null ? void 0 : candidate.id;
|
5520
4959
|
if (!candidate) return null;
|
5521
4960
|
if (candidate.type === "component") {
|
@@ -5555,7 +4994,8 @@ var getPointerCollisions = (position, manager) => {
|
|
5555
4994
|
const element = elements[i];
|
5556
4995
|
const dropzoneId = element.getAttribute("data-puck-dropzone");
|
5557
4996
|
const id = element.getAttribute("data-puck-dnd");
|
5558
|
-
|
4997
|
+
const isVoid = element.hasAttribute("data-puck-dnd-void");
|
4998
|
+
if (BUFFER && (dropzoneId || id) && !isVoid) {
|
5559
4999
|
const box = element.getBoundingClientRect();
|
5560
5000
|
const contractedBox = {
|
5561
5001
|
left: box.left + BUFFER,
|
@@ -5621,7 +5061,7 @@ var findDeepestCandidate = (position, manager) => {
|
|
5621
5061
|
return true;
|
5622
5062
|
});
|
5623
5063
|
filteredCandidates.reverse();
|
5624
|
-
const zone =
|
5064
|
+
const zone = getZoneId(filteredCandidates[0]);
|
5625
5065
|
const area = (_a = filteredCandidates[0]) == null ? void 0 : _a.data.areaId;
|
5626
5066
|
return { zone, area };
|
5627
5067
|
}
|
@@ -5636,7 +5076,7 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
5636
5076
|
if (typeof window === "undefined") {
|
5637
5077
|
return;
|
5638
5078
|
}
|
5639
|
-
|
5079
|
+
this.registerEffect(() => {
|
5640
5080
|
const handleMove = (event) => {
|
5641
5081
|
const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
|
5642
5082
|
const position = new GlobalPosition(target, {
|
@@ -5660,12 +5100,12 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
5660
5100
|
capture: true
|
5661
5101
|
// dndkit's PointerSensor prevents propagation during drag
|
5662
5102
|
});
|
5663
|
-
|
5103
|
+
const cleanup = () => {
|
5664
5104
|
document.body.removeEventListener("pointermove", handlePointerMove, {
|
5665
5105
|
capture: true
|
5666
5106
|
});
|
5667
|
-
cleanupEffect();
|
5668
5107
|
};
|
5108
|
+
return cleanup;
|
5669
5109
|
});
|
5670
5110
|
}
|
5671
5111
|
};
|
@@ -5967,7 +5407,7 @@ var DragDropContextClient = ({
|
|
5967
5407
|
}, 250);
|
5968
5408
|
},
|
5969
5409
|
onDragOver: (event, manager) => {
|
5970
|
-
var _a, _b, _c, _d
|
5410
|
+
var _a, _b, _c, _d;
|
5971
5411
|
event.preventDefault();
|
5972
5412
|
const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
|
5973
5413
|
if (!draggedItem) return;
|
@@ -5985,7 +5425,7 @@ var DragDropContextClient = ({
|
|
5985
5425
|
const targetData = target.data;
|
5986
5426
|
targetZone = targetData.zone;
|
5987
5427
|
targetIndex = targetData.index;
|
5988
|
-
const collisionData = (
|
5428
|
+
const collisionData = (_b = manager.collisionObserver.collisions[0]) == null ? void 0 : _b.data;
|
5989
5429
|
const dir = getDeepDir(target.element);
|
5990
5430
|
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";
|
5991
5431
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
@@ -5998,7 +5438,7 @@ var DragDropContextClient = ({
|
|
5998
5438
|
targetZone = target.id.toString();
|
5999
5439
|
targetIndex = 0;
|
6000
5440
|
}
|
6001
|
-
const path = ((
|
5441
|
+
const path = ((_c = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _c.path) || [];
|
6002
5442
|
if (targetId === sourceId || path.find((path2) => {
|
6003
5443
|
const [pathId] = path2.split(":");
|
6004
5444
|
return pathId === sourceId;
|
@@ -6044,16 +5484,12 @@ var DragDropContextClient = ({
|
|
6044
5484
|
});
|
6045
5485
|
}
|
6046
5486
|
}
|
6047
|
-
(
|
5487
|
+
(_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
|
6048
5488
|
fn(event, manager);
|
6049
5489
|
});
|
6050
5490
|
},
|
6051
5491
|
onDragStart: (event, manager) => {
|
6052
5492
|
var _a;
|
6053
|
-
dispatch({
|
6054
|
-
type: "setUi",
|
6055
|
-
ui: { itemSelector: null, isDragging: true }
|
6056
|
-
});
|
6057
5493
|
const { source } = event.operation;
|
6058
5494
|
if (source && source.type !== "void") {
|
6059
5495
|
const sourceData = source.data;
|
@@ -6084,10 +5520,17 @@ var DragDropContextClient = ({
|
|
6084
5520
|
},
|
6085
5521
|
onBeforeDragStart: (event) => {
|
6086
5522
|
var _a;
|
6087
|
-
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.
|
5523
|
+
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.type) === "drawer";
|
6088
5524
|
dragMode.current = isNewComponent ? "new" : "existing";
|
6089
5525
|
initialSelector.current = void 0;
|
6090
5526
|
zoneStore.setState({ draggedItem: event.operation.source });
|
5527
|
+
dispatch({
|
5528
|
+
type: "setUi",
|
5529
|
+
ui: {
|
5530
|
+
isDragging: true
|
5531
|
+
},
|
5532
|
+
recordHistory: false
|
5533
|
+
});
|
6091
5534
|
},
|
6092
5535
|
children: /* @__PURE__ */ jsx24(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx24(DropZoneProvider, { value: nextContextValue, children }) })
|
6093
5536
|
}
|
@@ -6107,6 +5550,7 @@ var DragDropContext = ({
|
|
6107
5550
|
};
|
6108
5551
|
|
6109
5552
|
// components/Drawer/index.tsx
|
5553
|
+
import { useDraggable, useDroppable as useDroppable2 } from "@dnd-kit/react";
|
6110
5554
|
import { jsx as jsx25, jsxs as jsxs11 } from "react/jsx-runtime";
|
6111
5555
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
6112
5556
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
@@ -6143,10 +5587,11 @@ var DrawerItemDraggable = ({
|
|
6143
5587
|
id,
|
6144
5588
|
isDragDisabled
|
6145
5589
|
}) => {
|
6146
|
-
const { ref } =
|
5590
|
+
const { ref } = useDraggable({
|
6147
5591
|
id,
|
6148
|
-
data: {
|
6149
|
-
disabled: isDragDisabled
|
5592
|
+
data: { componentType: name },
|
5593
|
+
disabled: isDragDisabled,
|
5594
|
+
type: "drawer"
|
6150
5595
|
});
|
6151
5596
|
return /* @__PURE__ */ jsxs11("div", { className: getClassName18("draggable"), children: [
|
6152
5597
|
/* @__PURE__ */ jsx25("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx25(DrawerItemInner, { name, label, children }) }),
|
@@ -6211,7 +5656,7 @@ var Drawer = ({
|
|
6211
5656
|
);
|
6212
5657
|
}
|
6213
5658
|
const id = useSafeId();
|
6214
|
-
const { ref } =
|
5659
|
+
const { ref } = useDroppable2({
|
6215
5660
|
id,
|
6216
5661
|
type: "void",
|
6217
5662
|
collisionPriority: 0
|
@@ -6224,6 +5669,7 @@ var Drawer = ({
|
|
6224
5669
|
ref,
|
6225
5670
|
"data-puck-dnd": id,
|
6226
5671
|
"data-puck-drawer": true,
|
5672
|
+
"data-puck-dnd-void": true,
|
6227
5673
|
children
|
6228
5674
|
}
|
6229
5675
|
);
|
@@ -7977,6 +7423,13 @@ function usePuck() {
|
|
7977
7423
|
}, []);
|
7978
7424
|
return createUsePuck()((s) => s);
|
7979
7425
|
}
|
7426
|
+
function useGetPuck() {
|
7427
|
+
const usePuckApi = useContext10(UsePuckStoreContext);
|
7428
|
+
if (!usePuckApi) {
|
7429
|
+
throw new Error("usePuckGet must be used inside <Puck>.");
|
7430
|
+
}
|
7431
|
+
return usePuckApi.getState;
|
7432
|
+
}
|
7980
7433
|
|
7981
7434
|
// components/Puck/index.tsx
|
7982
7435
|
import fdeq from "fast-deep-equal";
|
@@ -8400,86 +7853,6 @@ Puck.Components = Components;
|
|
8400
7853
|
Puck.Fields = Fields;
|
8401
7854
|
Puck.Outline = Outline;
|
8402
7855
|
Puck.Preview = Preview3;
|
8403
|
-
|
8404
|
-
// lib/migrate.ts
|
8405
|
-
init_react_import();
|
8406
|
-
var migrations = [
|
8407
|
-
// Migrate root to root.props
|
8408
|
-
(data) => {
|
8409
|
-
const rootProps = data.root.props || data.root;
|
8410
|
-
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
8411
|
-
console.warn(
|
8412
|
-
"Migration applied: Root props moved from `root` to `root.props`."
|
8413
|
-
);
|
8414
|
-
return __spreadProps(__spreadValues({}, data), {
|
8415
|
-
root: {
|
8416
|
-
props: __spreadValues({}, rootProps)
|
8417
|
-
}
|
8418
|
-
});
|
8419
|
-
}
|
8420
|
-
return data;
|
8421
|
-
},
|
8422
|
-
// Migrate zones to slots
|
8423
|
-
(data, config) => {
|
8424
|
-
var _a;
|
8425
|
-
if (!config) return data;
|
8426
|
-
console.log("Migrating DropZones to slots...");
|
8427
|
-
const updatedItems = {};
|
8428
|
-
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
8429
|
-
const { indexes } = walkAppState(appState, config);
|
8430
|
-
const deletedCompounds = [];
|
8431
|
-
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
8432
|
-
var _a2, _b;
|
8433
|
-
if (zoneType === "dropzone") {
|
8434
|
-
const [id, slotName] = zoneCompound.split(":");
|
8435
|
-
const nodeData = indexes.nodes[id].data;
|
8436
|
-
const componentType = nodeData.type;
|
8437
|
-
const configForComponent = config.components[componentType];
|
8438
|
-
if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
|
8439
|
-
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
8440
|
-
props: __spreadProps(__spreadValues({}, nodeData.props), {
|
8441
|
-
[slotName]: content
|
8442
|
-
})
|
8443
|
-
});
|
8444
|
-
deletedCompounds.push(zoneCompound);
|
8445
|
-
}
|
8446
|
-
return content;
|
8447
|
-
}
|
8448
|
-
return content;
|
8449
|
-
});
|
8450
|
-
const updated = walkAppState(
|
8451
|
-
appState,
|
8452
|
-
config,
|
8453
|
-
(content) => content,
|
8454
|
-
(item) => {
|
8455
|
-
var _a2;
|
8456
|
-
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
8457
|
-
}
|
8458
|
-
);
|
8459
|
-
deletedCompounds.forEach((zoneCompound) => {
|
8460
|
-
var _a2;
|
8461
|
-
const [_, propName] = zoneCompound.split(":");
|
8462
|
-
console.log(
|
8463
|
-
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
8464
|
-
);
|
8465
|
-
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
8466
|
-
});
|
8467
|
-
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
8468
|
-
const [_, propName] = zoneCompound.split(":");
|
8469
|
-
throw new Error(
|
8470
|
-
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
8471
|
-
);
|
8472
|
-
});
|
8473
|
-
delete updated.data.zones;
|
8474
|
-
return updated.data;
|
8475
|
-
}
|
8476
|
-
];
|
8477
|
-
function migrate(data, config) {
|
8478
|
-
return migrations == null ? void 0 : migrations.reduce(
|
8479
|
-
(acc, migration) => migration(acc, config),
|
8480
|
-
data
|
8481
|
-
);
|
8482
|
-
}
|
8483
7856
|
export {
|
8484
7857
|
Action,
|
8485
7858
|
ActionBar,
|
@@ -8499,6 +7872,7 @@ export {
|
|
8499
7872
|
renderContext,
|
8500
7873
|
resolveAllData,
|
8501
7874
|
transformProps,
|
7875
|
+
useGetPuck,
|
8502
7876
|
usePuck,
|
8503
7877
|
walkTree
|
8504
7878
|
};
|