@measured/puck 0.19.0-canary.8d459e4e → 0.19.0-canary.91cb9cee

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/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
  });
@@ -1047,15 +1041,113 @@ var getIdsForParent = (zoneCompound, state) => {
1047
1041
  return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
1048
1042
  };
1049
1043
 
1044
+ // lib/data/populate-ids.ts
1045
+ init_react_import();
1046
+
1047
+ // lib/data/walk-tree.ts
1048
+ init_react_import();
1049
+
1050
+ // lib/data/map-slots.ts
1051
+ init_react_import();
1052
+ function mapSlotsAsync(_0, _1) {
1053
+ return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
1054
+ const props = __spreadValues({}, item.props);
1055
+ const propKeys = Object.keys(props);
1056
+ for (let i = 0; i < propKeys.length; i++) {
1057
+ const propKey = propKeys[i];
1058
+ const itemType = "type" in item ? item.type : "root";
1059
+ if (isSlot2(itemType, propKey, props[propKey])) {
1060
+ const content = props[propKey];
1061
+ const mappedContent = recursive ? yield Promise.all(
1062
+ content.map((item2) => __async(this, null, function* () {
1063
+ return yield mapSlotsAsync(item2, map, recursive, isSlot2);
1064
+ }))
1065
+ ) : content;
1066
+ props[propKey] = yield map(mappedContent, propKey);
1067
+ }
1068
+ }
1069
+ return __spreadProps(__spreadValues({}, item), { props });
1070
+ });
1071
+ }
1072
+ function mapSlotsSync(item, map, isSlot2 = isSlot) {
1073
+ var _a, _b;
1074
+ const props = __spreadValues({}, item.props);
1075
+ const propKeys = Object.keys(props);
1076
+ for (let i = 0; i < propKeys.length; i++) {
1077
+ const propKey = propKeys[i];
1078
+ const itemType = "type" in item ? item.type : "root";
1079
+ if (isSlot2(itemType, propKey, props[propKey])) {
1080
+ const content = props[propKey];
1081
+ const mappedContent = content.map((item2) => {
1082
+ return mapSlotsSync(item2, map, isSlot2);
1083
+ });
1084
+ props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
1085
+ }
1086
+ }
1087
+ return __spreadProps(__spreadValues({}, item), { props });
1088
+ }
1089
+
1090
+ // lib/data/walk-tree.ts
1091
+ function walkTree(data, config, callbackFn) {
1092
+ var _a, _b;
1093
+ const isSlot2 = createIsSlotConfig(config);
1094
+ const walkItem = (item) => {
1095
+ return mapSlotsSync(
1096
+ item,
1097
+ (content, parentId, propName) => callbackFn(content, { parentId, propName }),
1098
+ isSlot2
1099
+ );
1100
+ };
1101
+ if ("props" in data) {
1102
+ return walkItem(data);
1103
+ }
1104
+ const _data = data;
1105
+ const zones = (_a = _data.zones) != null ? _a : {};
1106
+ const mappedContent = _data.content.map(walkItem);
1107
+ return {
1108
+ root: walkItem(_data.root),
1109
+ content: (_b = callbackFn(mappedContent, {
1110
+ parentId: "root",
1111
+ propName: "default-zone"
1112
+ })) != null ? _b : mappedContent,
1113
+ zones: Object.keys(zones).reduce(
1114
+ (acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
1115
+ [zoneCompound]: zones[zoneCompound].map(walkItem)
1116
+ }),
1117
+ {}
1118
+ )
1119
+ };
1120
+ }
1121
+
1122
+ // lib/data/populate-ids.ts
1123
+ var populateIds = (data, config, override = false) => {
1124
+ const id = generateId(data.type);
1125
+ return walkTree(
1126
+ __spreadProps(__spreadValues({}, data), {
1127
+ props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
1128
+ }),
1129
+ config,
1130
+ (contents) => contents.map((item) => {
1131
+ const id2 = generateId(item.type);
1132
+ return __spreadProps(__spreadValues({}, item), {
1133
+ props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
1134
+ });
1135
+ })
1136
+ );
1137
+ };
1138
+
1050
1139
  // reducer/actions/insert.ts
1051
1140
  function insertAction(state, action, appStore) {
1052
1141
  const id = action.id || generateId(action.componentType);
1053
- const emptyComponentData = {
1054
- type: action.componentType,
1055
- props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
1056
- id
1057
- })
1058
- };
1142
+ const emptyComponentData = populateIds(
1143
+ {
1144
+ type: action.componentType,
1145
+ props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
1146
+ id
1147
+ })
1148
+ },
1149
+ appStore.config
1150
+ );
1059
1151
  const [parentId] = action.destinationZone.split(":");
1060
1152
  const idsInPath = getIdsForParent(action.destinationZone, state);
1061
1153
  return walkAppState(
@@ -1096,25 +1188,26 @@ var replaceAction = (state, action, appStore) => {
1096
1188
  `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
1097
1189
  );
1098
1190
  }
1191
+ const data = populateIds(action.data, appStore.config);
1099
1192
  return walkAppState(
1100
1193
  state,
1101
1194
  appStore.config,
1102
1195
  (content, zoneCompound) => {
1103
1196
  const newContent = [...content];
1104
1197
  if (zoneCompound === action.destinationZone) {
1105
- newContent[action.destinationIndex] = action.data;
1198
+ newContent[action.destinationIndex] = data;
1106
1199
  }
1107
1200
  return newContent;
1108
1201
  },
1109
1202
  (childItem, path) => {
1110
1203
  const pathIds = path.map((p) => p.split(":")[0]);
1111
- if (childItem.props.id === action.data.props.id) {
1112
- return action.data;
1204
+ if (childItem.props.id === data.props.id) {
1205
+ return data;
1113
1206
  } else if (childItem.props.id === parentId) {
1114
1207
  return childItem;
1115
1208
  } else if (idsInPath.indexOf(childItem.props.id) > -1) {
1116
1209
  return childItem;
1117
- } else if (pathIds.indexOf(action.data.props.id) > -1) {
1210
+ } else if (pathIds.indexOf(data.props.id) > -1) {
1118
1211
  return childItem;
1119
1212
  }
1120
1213
  return null;
@@ -1733,7 +1826,11 @@ var createNodesSlice = (set, get) => ({
1733
1826
  const s = get().nodes;
1734
1827
  const emptyNode = {
1735
1828
  id,
1736
- methods: { sync: () => null },
1829
+ methods: {
1830
+ sync: () => null,
1831
+ hideOverlay: () => null,
1832
+ showOverlay: () => null
1833
+ },
1737
1834
  element: null
1738
1835
  };
1739
1836
  const existingNode = s.nodes[id];
@@ -1935,7 +2032,8 @@ var createFieldsSlice = (_set, _get) => {
1935
2032
  return {
1936
2033
  fields: {},
1937
2034
  loading: false,
1938
- lastResolvedData: {}
2035
+ lastResolvedData: {},
2036
+ id: void 0
1939
2037
  };
1940
2038
  };
1941
2039
  var useRegisterFieldsSlice = (appStore, id) => {
@@ -1956,7 +2054,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
1956
2054
  let lastFields = fields;
1957
2055
  if (reset) {
1958
2056
  appStore.setState((s) => ({
1959
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
2057
+ fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
1960
2058
  }));
1961
2059
  lastFields = defaultFields;
1962
2060
  }
@@ -1984,12 +2082,13 @@ var useRegisterFieldsSlice = (appStore, id) => {
1984
2082
  fields: {
1985
2083
  fields: newFields,
1986
2084
  loading: false,
1987
- lastResolvedData: componentData
2085
+ lastResolvedData: componentData,
2086
+ id
1988
2087
  }
1989
2088
  });
1990
2089
  } else {
1991
2090
  appStore.setState((s) => ({
1992
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
2091
+ fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
1993
2092
  }));
1994
2093
  }
1995
2094
  }),
@@ -2006,48 +2105,6 @@ var useRegisterFieldsSlice = (appStore, id) => {
2006
2105
 
2007
2106
  // lib/resolve-component-data.ts
2008
2107
  init_react_import();
2009
-
2010
- // lib/data/map-slots.ts
2011
- init_react_import();
2012
- function mapSlotsAsync(_0, _1) {
2013
- return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
2014
- const props = __spreadValues({}, item.props);
2015
- const propKeys = Object.keys(props);
2016
- for (let i = 0; i < propKeys.length; i++) {
2017
- const propKey = propKeys[i];
2018
- const itemType = "type" in item ? item.type : "root";
2019
- if (isSlot2(itemType, propKey, props[propKey])) {
2020
- const content = props[propKey];
2021
- const mappedContent = recursive ? yield Promise.all(
2022
- content.map((item2) => __async(this, null, function* () {
2023
- return yield mapSlotsAsync(item2, map, recursive, isSlot2);
2024
- }))
2025
- ) : content;
2026
- props[propKey] = yield map(mappedContent, propKey);
2027
- }
2028
- }
2029
- return __spreadProps(__spreadValues({}, item), { props });
2030
- });
2031
- }
2032
- function mapSlotsSync(item, map, isSlot2 = isSlot) {
2033
- var _a, _b;
2034
- const props = __spreadValues({}, item.props);
2035
- const propKeys = Object.keys(props);
2036
- for (let i = 0; i < propKeys.length; i++) {
2037
- const propKey = propKeys[i];
2038
- const itemType = "type" in item ? item.type : "root";
2039
- if (isSlot2(itemType, propKey, props[propKey])) {
2040
- const content = props[propKey];
2041
- const mappedContent = content.map((item2) => {
2042
- return mapSlotsSync(item2, map, isSlot2);
2043
- });
2044
- props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
2045
- }
2046
- }
2047
- return __spreadProps(__spreadValues({}, item), { props });
2048
- }
2049
-
2050
- // lib/resolve-component-data.ts
2051
2108
  var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
2052
2109
  var cache = { lastChange: {} };
2053
2110
  var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
@@ -2127,7 +2184,8 @@ var toRoot = (item) => {
2127
2184
  return { props: {}, readOnly };
2128
2185
  };
2129
2186
 
2130
- // store/index.ts
2187
+ // store/default-app-state.ts
2188
+ init_react_import();
2131
2189
  var defaultAppState = {
2132
2190
  data: { content: [], root: {}, zones: {} },
2133
2191
  ui: {
@@ -2153,6 +2211,8 @@ var defaultAppState = {
2153
2211
  zones: {}
2154
2212
  }
2155
2213
  };
2214
+
2215
+ // store/index.ts
2156
2216
  var defaultPageFields = {
2157
2217
  title: { type: "text" }
2158
2218
  };
@@ -2341,314 +2401,11 @@ function useAppStoreApi() {
2341
2401
  init_react_import();
2342
2402
  var import_react12 = require("@dnd-kit/react");
2343
2403
 
2344
- // lib/dnd/dnd-kit/safe.ts
2345
- init_react_import();
2346
- var import_react10 = require("@dnd-kit/react");
2347
- var import_sortable = require("@dnd-kit/react/sortable");
2348
- function useDroppableSafe(input) {
2349
- if (typeof window === "undefined") {
2350
- return { ref: () => {
2351
- } };
2352
- }
2353
- return (0, import_react10.useDroppable)(input);
2354
- }
2355
- function useDraggableSafe(input) {
2356
- if (typeof window === "undefined") {
2357
- return { ref: () => {
2358
- } };
2359
- }
2360
- return (0, import_react10.useDraggable)(input);
2361
- }
2362
- function useSortableSafe(input) {
2363
- if (typeof window === "undefined") {
2364
- return { ref: () => {
2365
- }, status: "idle", handleRef: () => {
2366
- } };
2367
- }
2368
- return (0, import_sortable.useSortable)(input);
2369
- }
2370
-
2371
2404
  // lib/dnd/use-sensors.ts
2372
2405
  init_react_import();
2373
- var import_react11 = require("react");
2374
-
2375
- // lib/dnd/PointerSensor.ts
2376
- init_react_import();
2377
- var import_state = require("@dnd-kit/state");
2378
- var import_abstract = require("@dnd-kit/abstract");
2379
- var import_geometry = require("@dnd-kit/geometry");
2406
+ var import_react10 = require("react");
2407
+ var import_react11 = require("@dnd-kit/react");
2380
2408
  var import_utilities = require("@dnd-kit/dom/utilities");
2381
- var _clearTimeout;
2382
- var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
2383
- constructor(manager, options) {
2384
- super(manager);
2385
- this.manager = manager;
2386
- this.options = options;
2387
- this.listeners = new import_utilities.Listeners();
2388
- this.cleanup = /* @__PURE__ */ new Set();
2389
- this.source = void 0;
2390
- this.started = false;
2391
- __privateAdd(this, _clearTimeout);
2392
- this.handleCancel = this.handleCancel.bind(this);
2393
- this.handlePointerUp = this.handlePointerUp.bind(this);
2394
- this.handleKeyDown = this.handleKeyDown.bind(this);
2395
- (0, import_state.effect)(() => {
2396
- const unbindGlobal = this.bindGlobal(options != null ? options : {});
2397
- return () => {
2398
- unbindGlobal();
2399
- };
2400
- });
2401
- }
2402
- bind(source, options = this.options) {
2403
- const unbind = (0, import_state.effect)(() => {
2404
- var _a;
2405
- const target = (_a = source.handle) != null ? _a : source.element;
2406
- const listener = (event) => {
2407
- if ((0, import_utilities.isPointerEvent)(event)) {
2408
- this.handlePointerDown(event, source, options);
2409
- }
2410
- };
2411
- if (target) {
2412
- patchWindow(target.ownerDocument.defaultView);
2413
- target.addEventListener("pointerdown", listener);
2414
- return () => {
2415
- target.removeEventListener("pointerdown", listener);
2416
- };
2417
- }
2418
- });
2419
- return unbind;
2420
- }
2421
- bindGlobal(options) {
2422
- const documents = /* @__PURE__ */ new Set();
2423
- for (const draggable of this.manager.registry.draggables.value) {
2424
- if (draggable.element) {
2425
- documents.add((0, import_utilities.getDocument)(draggable.element));
2426
- }
2427
- }
2428
- for (const droppable of this.manager.registry.droppables.value) {
2429
- if (droppable.element) {
2430
- documents.add((0, import_utilities.getDocument)(droppable.element));
2431
- }
2432
- }
2433
- const unbindFns = Array.from(documents).map(
2434
- (doc) => this.listeners.bind(doc, [
2435
- {
2436
- type: "pointermove",
2437
- listener: (event) => this.handlePointerMove(event, doc, options)
2438
- },
2439
- {
2440
- type: "pointerup",
2441
- listener: this.handlePointerUp,
2442
- options: {
2443
- capture: true
2444
- }
2445
- },
2446
- {
2447
- // Cancel activation if there is a competing Drag and Drop interaction
2448
- type: "dragstart",
2449
- listener: this.handleDragStart
2450
- }
2451
- ])
2452
- );
2453
- return () => {
2454
- unbindFns.forEach((unbind) => unbind());
2455
- };
2456
- }
2457
- handlePointerDown(event, source, options = {}) {
2458
- if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
2459
- return;
2460
- }
2461
- const offset = (0, import_utilities.getFrameTransform)(source.element);
2462
- this.initialCoordinates = {
2463
- x: event.clientX * offset.scaleX + offset.x,
2464
- y: event.clientY * offset.scaleY + offset.y
2465
- };
2466
- this.source = source;
2467
- const { activationConstraints } = options;
2468
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
2469
- event.stopImmediatePropagation();
2470
- if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
2471
- this.handleStart(source, event);
2472
- } else {
2473
- const { delay } = constraints;
2474
- if (delay) {
2475
- const timeout3 = setTimeout(
2476
- () => this.handleStart(source, event),
2477
- delay.value
2478
- );
2479
- __privateSet(this, _clearTimeout, () => {
2480
- clearTimeout(timeout3);
2481
- __privateSet(this, _clearTimeout, void 0);
2482
- });
2483
- }
2484
- }
2485
- const cleanup = () => {
2486
- var _a;
2487
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2488
- this.initialCoordinates = void 0;
2489
- this.source = void 0;
2490
- };
2491
- this.cleanup.add(cleanup);
2492
- }
2493
- handlePointerMove(event, doc, options) {
2494
- if (!this.source) {
2495
- return;
2496
- }
2497
- const ownerDocument = this.source.element && (0, import_utilities.getDocument)(this.source.element);
2498
- if (doc !== ownerDocument) {
2499
- return;
2500
- }
2501
- const coordinates = {
2502
- x: event.clientX,
2503
- y: event.clientY
2504
- };
2505
- const offset = (0, import_utilities.getFrameTransform)(this.source.element);
2506
- coordinates.x = coordinates.x * offset.scaleX + offset.x;
2507
- coordinates.y = coordinates.y * offset.scaleY + offset.y;
2508
- if (this.manager.dragOperation.status.dragging) {
2509
- event.preventDefault();
2510
- event.stopPropagation();
2511
- this.manager.actions.move({ to: coordinates });
2512
- return;
2513
- }
2514
- if (!this.initialCoordinates) {
2515
- return;
2516
- }
2517
- const delta = {
2518
- x: coordinates.x - this.initialCoordinates.x,
2519
- y: coordinates.y - this.initialCoordinates.y
2520
- };
2521
- const { activationConstraints } = options;
2522
- const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
2523
- const { distance, delay } = constraints != null ? constraints : {};
2524
- if (distance) {
2525
- if (distance.tolerance != null && (0, import_geometry.exceedsDistance)(delta, distance.tolerance)) {
2526
- return this.handleCancel();
2527
- }
2528
- if ((0, import_geometry.exceedsDistance)(delta, distance.value)) {
2529
- return this.handleStart(this.source, event);
2530
- }
2531
- }
2532
- if (delay) {
2533
- if ((0, import_geometry.exceedsDistance)(delta, delay.tolerance)) {
2534
- return this.handleCancel();
2535
- }
2536
- }
2537
- }
2538
- handlePointerUp(event) {
2539
- if (!this.source) {
2540
- return;
2541
- }
2542
- event.preventDefault();
2543
- event.stopPropagation();
2544
- const { status } = this.manager.dragOperation;
2545
- if (!status.idle) {
2546
- const canceled = !status.initialized;
2547
- this.manager.actions.stop({ canceled });
2548
- } else if (this.started) {
2549
- setTimeout(() => {
2550
- if (!this.manager.dragOperation.status.idle) {
2551
- this.manager.actions.stop({ canceled: false });
2552
- }
2553
- }, 10);
2554
- }
2555
- this.cleanup.forEach((cleanup) => cleanup());
2556
- this.cleanup.clear();
2557
- }
2558
- handleKeyDown(event) {
2559
- if (event.key === "Escape") {
2560
- event.preventDefault();
2561
- this.handleCancel();
2562
- }
2563
- }
2564
- handleStart(source, event) {
2565
- var _a;
2566
- const { manager, initialCoordinates } = this;
2567
- (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2568
- if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
2569
- return;
2570
- }
2571
- if (event.defaultPrevented) {
2572
- return;
2573
- }
2574
- this.started = true;
2575
- event.preventDefault();
2576
- (0, import_state.batch)(() => {
2577
- manager.actions.setDragSource(source.id);
2578
- manager.actions.start({ coordinates: initialCoordinates, event });
2579
- });
2580
- const ownerDocument = (0, import_utilities.getDocument)(event.target);
2581
- const unbind = this.listeners.bind(ownerDocument, [
2582
- {
2583
- // Prevent scrolling on touch devices
2584
- type: "touchmove",
2585
- listener: preventDefault,
2586
- options: {
2587
- passive: false
2588
- }
2589
- },
2590
- {
2591
- // Prevent click events
2592
- type: "click",
2593
- listener: preventDefault
2594
- },
2595
- {
2596
- type: "keydown",
2597
- listener: this.handleKeyDown
2598
- }
2599
- ]);
2600
- ownerDocument.body.setPointerCapture(event.pointerId);
2601
- this.cleanup.add(unbind);
2602
- this.cleanup.add(() => {
2603
- this.started = false;
2604
- });
2605
- }
2606
- handleDragStart(event) {
2607
- const { target } = event;
2608
- if (!(0, import_utilities.isElement)(target)) {
2609
- return;
2610
- }
2611
- const isNativeDraggable = (0, import_utilities.isHTMLElement)(target) && target.draggable && target.getAttribute("draggable") === "true";
2612
- if (isNativeDraggable) {
2613
- this.handleCancel();
2614
- } else {
2615
- preventDefault(event);
2616
- }
2617
- }
2618
- handleCancel() {
2619
- const { dragOperation } = this.manager;
2620
- if (dragOperation.status.initialized) {
2621
- this.manager.actions.stop({ canceled: true });
2622
- }
2623
- this.cleanup.forEach((cleanup) => cleanup());
2624
- this.cleanup.clear();
2625
- }
2626
- destroy() {
2627
- this.listeners.clear();
2628
- }
2629
- };
2630
- _clearTimeout = new WeakMap();
2631
- _PointerSensor.configure = (0, import_abstract.configurator)(_PointerSensor);
2632
- var PointerSensor = _PointerSensor;
2633
- function preventDefault(event) {
2634
- event.preventDefault();
2635
- }
2636
- function noop() {
2637
- }
2638
- var windows = /* @__PURE__ */ new WeakSet();
2639
- function patchWindow(window2) {
2640
- if (!window2 || windows.has(window2)) {
2641
- return;
2642
- }
2643
- window2.addEventListener("touchmove", noop, {
2644
- capture: false,
2645
- passive: false
2646
- });
2647
- windows.add(window2);
2648
- }
2649
-
2650
- // lib/dnd/use-sensors.ts
2651
- var import_utilities2 = require("@dnd-kit/dom/utilities");
2652
2409
  var useSensors = ({
2653
2410
  other,
2654
2411
  mouse,
@@ -2657,12 +2414,12 @@ var useSensors = ({
2657
2414
  touch: { delay: { value: 200, tolerance: 10 } },
2658
2415
  other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
2659
2416
  }) => {
2660
- const [sensors] = (0, import_react11.useState)(() => [
2661
- PointerSensor.configure({
2417
+ const [sensors] = (0, import_react10.useState)(() => [
2418
+ import_react11.PointerSensor.configure({
2662
2419
  activationConstraints(event, source) {
2663
2420
  var _a;
2664
2421
  const { pointerType, target } = event;
2665
- if (pointerType === "mouse" && (0, import_utilities2.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
2422
+ if (pointerType === "mouse" && (0, import_utilities.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
2666
2423
  return mouse;
2667
2424
  }
2668
2425
  if (pointerType === "touch") {
@@ -2677,11 +2434,11 @@ var useSensors = ({
2677
2434
 
2678
2435
  // lib/dnd/collision/dynamic/index.ts
2679
2436
  init_react_import();
2680
- var import_abstract9 = require("@dnd-kit/abstract");
2437
+ var import_abstract8 = require("@dnd-kit/abstract");
2681
2438
 
2682
2439
  // lib/dnd/collision/directional/index.ts
2683
2440
  init_react_import();
2684
- var import_abstract2 = require("@dnd-kit/abstract");
2441
+ var import_abstract = require("@dnd-kit/abstract");
2685
2442
 
2686
2443
  // lib/dnd/collision/collision-debug.ts
2687
2444
  init_react_import();
@@ -2759,7 +2516,7 @@ var directionalCollision = (input, previous) => {
2759
2516
  return {
2760
2517
  id: droppable.id,
2761
2518
  value: 1,
2762
- type: import_abstract2.CollisionType.Collision
2519
+ type: import_abstract.CollisionType.Collision
2763
2520
  };
2764
2521
  }
2765
2522
  return null;
@@ -2801,7 +2558,7 @@ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0)
2801
2558
 
2802
2559
  // lib/dnd/collision/dynamic/track-movement-interval.ts
2803
2560
  init_react_import();
2804
- var import_geometry2 = require("@dnd-kit/geometry");
2561
+ var import_geometry = require("@dnd-kit/geometry");
2805
2562
  var INTERVAL_SENSITIVITY = 10;
2806
2563
  var intervalCache = {
2807
2564
  current: { x: 0, y: 0 },
@@ -2817,13 +2574,15 @@ var trackMovementInterval = (point, dragAxis = "dynamic") => {
2817
2574
  };
2818
2575
  intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
2819
2576
  if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
2820
- intervalCache.previous = import_geometry2.Point.from(point);
2577
+ intervalCache.previous = import_geometry.Point.from(point);
2821
2578
  }
2822
2579
  return intervalCache;
2823
2580
  };
2824
2581
 
2825
2582
  // ../../node_modules/@dnd-kit/collision/dist/index.js
2826
2583
  init_react_import();
2584
+ var import_abstract2 = require("@dnd-kit/abstract");
2585
+ var import_geometry2 = require("@dnd-kit/geometry");
2827
2586
  var import_abstract3 = require("@dnd-kit/abstract");
2828
2587
  var import_geometry3 = require("@dnd-kit/geometry");
2829
2588
  var import_abstract4 = require("@dnd-kit/abstract");
@@ -2834,8 +2593,6 @@ var import_abstract6 = require("@dnd-kit/abstract");
2834
2593
  var import_geometry6 = require("@dnd-kit/geometry");
2835
2594
  var import_abstract7 = require("@dnd-kit/abstract");
2836
2595
  var import_geometry7 = require("@dnd-kit/geometry");
2837
- var import_abstract8 = require("@dnd-kit/abstract");
2838
- var import_geometry8 = require("@dnd-kit/geometry");
2839
2596
  var pointerIntersection = ({
2840
2597
  dragOperation,
2841
2598
  droppable
@@ -2849,12 +2606,12 @@ var pointerIntersection = ({
2849
2606
  return null;
2850
2607
  }
2851
2608
  if (droppable.shape.containsPoint(pointerCoordinates)) {
2852
- const distance = import_geometry3.Point.distance(droppable.shape.center, pointerCoordinates);
2609
+ const distance = import_geometry2.Point.distance(droppable.shape.center, pointerCoordinates);
2853
2610
  return {
2854
2611
  id,
2855
2612
  value: 1 / distance,
2856
- type: import_abstract3.CollisionType.PointerIntersection,
2857
- priority: import_abstract3.CollisionPriority.High
2613
+ type: import_abstract2.CollisionType.PointerIntersection,
2614
+ priority: import_abstract2.CollisionPriority.High
2858
2615
  };
2859
2616
  }
2860
2617
  return null;
@@ -2865,31 +2622,15 @@ var closestCorners = (input) => {
2865
2622
  if (!droppable.shape) {
2866
2623
  return null;
2867
2624
  }
2868
- const { left, top, right, bottom } = droppable.shape.boundingRectangle;
2869
- const corners = [
2870
- {
2871
- x: left,
2872
- y: top
2873
- },
2874
- {
2875
- x: right,
2876
- y: top
2877
- },
2878
- {
2879
- x: left,
2880
- y: bottom
2881
- },
2882
- {
2883
- x: right,
2884
- y: bottom
2885
- }
2886
- ];
2887
- const distance = corners.reduce(
2888
- (acc, corner) => {
2625
+ const shapeCorners = shape ? import_geometry4.Rectangle.from(shape.current.boundingRectangle).corners : void 0;
2626
+ const distance = import_geometry4.Rectangle.from(
2627
+ droppable.shape.boundingRectangle
2628
+ ).corners.reduce(
2629
+ (acc, corner, index) => {
2889
2630
  var _a;
2890
- return acc + import_geometry5.Point.distance(
2891
- import_geometry5.Point.from(corner),
2892
- (_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
2631
+ return acc + import_geometry4.Point.distance(
2632
+ import_geometry4.Point.from(corner),
2633
+ (_a = shapeCorners == null ? void 0 : shapeCorners[index]) != null ? _a : position.current
2893
2634
  );
2894
2635
  },
2895
2636
  0
@@ -2898,8 +2639,8 @@ var closestCorners = (input) => {
2898
2639
  return {
2899
2640
  id: droppable.id,
2900
2641
  value: 1 / value,
2901
- type: import_abstract5.CollisionType.Collision,
2902
- priority: import_abstract5.CollisionPriority.Normal
2642
+ type: import_abstract4.CollisionType.Collision,
2643
+ priority: import_abstract4.CollisionPriority.Normal
2903
2644
  };
2904
2645
  };
2905
2646
 
@@ -2924,12 +2665,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2924
2665
  const { center: dragCenter } = dragShape;
2925
2666
  const { fallbackEnabled } = collisionStore.getState();
2926
2667
  const interval = trackMovementInterval(position.current, dragAxis);
2927
- dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
2928
- direction: interval.direction
2929
- });
2930
- const collisionMap = dragOperation.data.collisionMap || {};
2931
- dragOperation.data.collisionMap = collisionMap;
2932
- collisionMap[droppable.id] = {
2668
+ const data = {
2933
2669
  direction: interval.direction
2934
2670
  };
2935
2671
  const { center: dropCenter } = dropShape;
@@ -2944,7 +2680,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2944
2680
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
2945
2681
  if (collision) {
2946
2682
  return __spreadProps(__spreadValues({}, collision), {
2947
- priority: import_abstract9.CollisionPriority.Highest
2683
+ priority: import_abstract8.CollisionPriority.Highest,
2684
+ data
2948
2685
  });
2949
2686
  }
2950
2687
  }
@@ -2961,12 +2698,12 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2961
2698
  const collision = {
2962
2699
  id: droppable.id,
2963
2700
  value: intersectionRatio,
2964
- priority: import_abstract9.CollisionPriority.High,
2965
- type: import_abstract9.CollisionType.Collision
2701
+ priority: import_abstract8.CollisionPriority.High,
2702
+ type: import_abstract8.CollisionType.Collision
2966
2703
  };
2967
2704
  const shouldFlushId = flushNext === droppable.id;
2968
2705
  flushNext = "";
2969
- return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
2706
+ return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id, data });
2970
2707
  }
2971
2708
  if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2972
2709
  const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
@@ -2978,9 +2715,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2978
2715
  x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
2979
2716
  y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
2980
2717
  });
2981
- collisionMap[droppable.id] = {
2982
- direction
2983
- };
2718
+ data.direction = direction;
2984
2719
  if (intersectionArea) {
2985
2720
  collisionDebug(
2986
2721
  dragCenter,
@@ -2991,7 +2726,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2991
2726
  );
2992
2727
  flushNext = droppable.id;
2993
2728
  return __spreadProps(__spreadValues({}, fallbackCollision), {
2994
- priority: import_abstract9.CollisionPriority.Low
2729
+ priority: import_abstract8.CollisionPriority.Low,
2730
+ data
2995
2731
  });
2996
2732
  }
2997
2733
  collisionDebug(
@@ -3001,16 +2737,19 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
3001
2737
  "orange",
3002
2738
  direction || ""
3003
2739
  );
3004
- return __spreadProps(__spreadValues({}, fallbackCollision), { priority: import_abstract9.CollisionPriority.Lowest });
2740
+ return __spreadProps(__spreadValues({}, fallbackCollision), {
2741
+ priority: import_abstract8.CollisionPriority.Lowest,
2742
+ data
2743
+ });
3005
2744
  }
3006
2745
  }
3007
2746
  }
3008
2747
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
3009
- delete collisionMap[droppable.id];
3010
2748
  return null;
3011
2749
  };
3012
2750
 
3013
2751
  // components/Sortable/index.tsx
2752
+ var import_sortable = require("@dnd-kit/react/sortable");
3014
2753
  var import_jsx_runtime5 = require("react/jsx-runtime");
3015
2754
  var SortableProvider = ({
3016
2755
  children,
@@ -3030,16 +2769,16 @@ var SortableProvider = ({
3030
2769
  return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
3031
2770
  },
3032
2771
  onDragOver: (event, manager) => {
3033
- var _a, _b;
2772
+ var _a;
3034
2773
  event.preventDefault();
3035
2774
  const { operation } = event;
3036
2775
  const { source, target } = operation;
3037
2776
  if (!source || !target) return;
3038
2777
  let sourceIndex = source.data.index;
3039
2778
  let targetIndex = target.data.index;
3040
- const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
2779
+ const collisionData = (_a = manager.collisionObserver.collisions[0]) == null ? void 0 : _a.data;
3041
2780
  if (sourceIndex !== targetIndex && source.id !== target.id) {
3042
- const collisionPosition = collisionData.direction === "up" ? "before" : "after";
2781
+ const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
3043
2782
  if (targetIndex >= sourceIndex) {
3044
2783
  targetIndex = targetIndex - 1;
3045
2784
  }
@@ -3070,9 +2809,10 @@ var Sortable = ({
3070
2809
  }) => {
3071
2810
  const {
3072
2811
  ref: sortableRef,
3073
- status,
2812
+ isDragging,
2813
+ isDropping,
3074
2814
  handleRef
3075
- } = useSortableSafe({
2815
+ } = (0, import_sortable.useSortable)({
3076
2816
  id,
3077
2817
  type,
3078
2818
  index,
@@ -3080,7 +2820,7 @@ var Sortable = ({
3080
2820
  data: { index },
3081
2821
  collisionDetector: createDynamicCollisionDetector("y")
3082
2822
  });
3083
- return children({ status, ref: sortableRef, handleRef });
2823
+ return children({ isDragging, isDropping, ref: sortableRef, handleRef });
3084
2824
  };
3085
2825
 
3086
2826
  // components/AutoField/context.tsx
@@ -3205,7 +2945,7 @@ var ArrayField = ({
3205
2945
  }
3206
2946
  }, []);
3207
2947
  const [draggedItem, setDraggedItem] = (0, import_react14.useState)("");
3208
- const isDragging = !!draggedItem;
2948
+ const isDraggingAny = !!draggedItem;
3209
2949
  const canEdit = useAppStore(
3210
2950
  (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
3211
2951
  );
@@ -3270,13 +3010,13 @@ var ArrayField = ({
3270
3010
  id: _arrayId,
3271
3011
  index: i,
3272
3012
  disabled: readOnly,
3273
- children: ({ status, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3013
+ children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3274
3014
  "div",
3275
3015
  {
3276
3016
  ref,
3277
3017
  className: getClassNameItem({
3278
3018
  isExpanded: arrayState.openId === _arrayId,
3279
- isDragging: status === "dragging",
3019
+ isDragging,
3280
3020
  readOnly
3281
3021
  }),
3282
3022
  children: [
@@ -3417,7 +3157,7 @@ var ArrayField = ({
3417
3157
  type: "button",
3418
3158
  className: getClassName5("addButton"),
3419
3159
  onClick: () => {
3420
- if (isDragging) return;
3160
+ if (isDraggingAny) return;
3421
3161
  const existingValue = value || [];
3422
3162
  const newValue = [
3423
3163
  ...existingValue,
@@ -4400,24 +4140,24 @@ init_react_import();
4400
4140
 
4401
4141
  // css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
4402
4142
  init_react_import();
4403
- var styles_module_default10 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
4143
+ 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" };
4404
4144
 
4405
4145
  // components/Drawer/index.tsx
4406
- var import_react37 = require("react");
4146
+ var import_react39 = require("react");
4407
4147
 
4408
4148
  // components/DragDropContext/index.tsx
4409
4149
  init_react_import();
4410
- var import_react35 = require("@dnd-kit/react");
4411
- var import_react36 = require("react");
4150
+ var import_react37 = require("@dnd-kit/react");
4151
+ var import_react38 = require("react");
4412
4152
  var import_dom = require("@dnd-kit/dom");
4413
4153
 
4414
4154
  // components/DropZone/index.tsx
4415
4155
  init_react_import();
4416
- var import_react34 = require("react");
4156
+ var import_react35 = require("react");
4417
4157
 
4418
4158
  // components/DraggableComponent/index.tsx
4419
4159
  init_react_import();
4420
- var import_react25 = require("react");
4160
+ var import_react26 = require("react");
4421
4161
 
4422
4162
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
4423
4163
  init_react_import();
@@ -4458,7 +4198,9 @@ var ZoneStoreContext = (0, import_react23.createContext)(
4458
4198
  areaDepthIndex: {},
4459
4199
  nextAreaDepthIndex: {},
4460
4200
  draggedItem: null,
4461
- previewIndex: {}
4201
+ previewIndex: {},
4202
+ enabledIndex: {},
4203
+ hoveringComponent: null
4462
4204
  }))
4463
4205
  );
4464
4206
  var ZoneStoreProvider = ({
@@ -4471,7 +4213,6 @@ var DropZoneProvider = ({
4471
4213
  children,
4472
4214
  value
4473
4215
  }) => {
4474
- const [hoveringComponent, setHoveringComponent] = (0, import_react23.useState)();
4475
4216
  const dispatch = useAppStore((s) => s.dispatch);
4476
4217
  const registerZone = (0, import_react23.useCallback)(
4477
4218
  (zoneCompound) => {
@@ -4493,16 +4234,33 @@ var DropZoneProvider = ({
4493
4234
  );
4494
4235
  const memoValue = (0, import_react23.useMemo)(
4495
4236
  () => __spreadValues({
4496
- hoveringComponent,
4497
- setHoveringComponent,
4498
4237
  registerZone,
4499
4238
  unregisterZone
4500
4239
  }, value),
4501
- [value, hoveringComponent]
4240
+ [value]
4502
4241
  );
4503
4242
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
4504
4243
  };
4505
4244
 
4245
+ // components/DraggableComponent/index.tsx
4246
+ var import_shallow2 = require("zustand/react/shallow");
4247
+ var import_sortable2 = require("@dnd-kit/react/sortable");
4248
+
4249
+ // lib/accumulate-transform.ts
4250
+ init_react_import();
4251
+ function accumulateTransform(el) {
4252
+ let matrix = new DOMMatrixReadOnly();
4253
+ let n = el.parentElement;
4254
+ while (n && n !== document.documentElement) {
4255
+ const t = getComputedStyle(n).transform;
4256
+ if (t && t !== "none") {
4257
+ matrix = new DOMMatrixReadOnly(t).multiply(matrix);
4258
+ }
4259
+ n = n.parentElement;
4260
+ }
4261
+ return { scaleX: matrix.a, scaleY: matrix.d };
4262
+ }
4263
+
4506
4264
  // lib/use-context-store.ts
4507
4265
  init_react_import();
4508
4266
  var import_react24 = require("react");
@@ -4516,8 +4274,39 @@ function useContextStore(context, selector) {
4516
4274
  return (0, import_zustand4.useStore)(store, (0, import_shallow.useShallow)(selector));
4517
4275
  }
4518
4276
 
4277
+ // lib/dnd/use-on-drag-finished.ts
4278
+ init_react_import();
4279
+ var import_react25 = require("react");
4280
+ var useOnDragFinished = (cb, deps = []) => {
4281
+ const appStore = useAppStoreApi();
4282
+ return (0, import_react25.useCallback)(() => {
4283
+ let dispose = () => {
4284
+ };
4285
+ const processDragging = (isDragging2) => {
4286
+ if (isDragging2) {
4287
+ cb(false);
4288
+ } else {
4289
+ setTimeout(() => {
4290
+ cb(true);
4291
+ }, 0);
4292
+ if (dispose) dispose();
4293
+ }
4294
+ };
4295
+ const isDragging = appStore.getState().state.ui.isDragging;
4296
+ processDragging(isDragging);
4297
+ if (isDragging) {
4298
+ dispose = appStore.subscribe(
4299
+ (s) => s.state.ui.isDragging,
4300
+ (isDragging2) => {
4301
+ processDragging(isDragging2);
4302
+ }
4303
+ );
4304
+ }
4305
+ return dispose;
4306
+ }, [appStore, ...deps]);
4307
+ };
4308
+
4519
4309
  // components/DraggableComponent/index.tsx
4520
- var import_shallow2 = require("zustand/react/shallow");
4521
4310
  var import_jsx_runtime20 = require("react/jsx-runtime");
4522
4311
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
4523
4312
  var DEBUG2 = false;
@@ -4547,7 +4336,6 @@ var DraggableComponent = ({
4547
4336
  isSelected = false,
4548
4337
  debug,
4549
4338
  label,
4550
- isEnabled,
4551
4339
  autoDragAxis,
4552
4340
  userDragAxis,
4553
4341
  inDroppableZone = true
@@ -4561,9 +4349,9 @@ var DraggableComponent = ({
4561
4349
  const overrides = useAppStore((s) => s.overrides);
4562
4350
  const dispatch = useAppStore((s) => s.dispatch);
4563
4351
  const iframe = useAppStore((s) => s.iframe);
4564
- const ctx = (0, import_react25.useContext)(dropZoneContext);
4565
- const [localZones, setLocalZones] = (0, import_react25.useState)({});
4566
- const registerLocalZone = (0, import_react25.useCallback)(
4352
+ const ctx = (0, import_react26.useContext)(dropZoneContext);
4353
+ const [localZones, setLocalZones] = (0, import_react26.useState)({});
4354
+ const registerLocalZone = (0, import_react26.useCallback)(
4567
4355
  (zoneCompound2, active) => {
4568
4356
  var _a;
4569
4357
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -4573,7 +4361,7 @@ var DraggableComponent = ({
4573
4361
  },
4574
4362
  [setLocalZones]
4575
4363
  );
4576
- const unregisterLocalZone = (0, import_react25.useCallback)(
4364
+ const unregisterLocalZone = (0, import_react26.useCallback)(
4577
4365
  (zoneCompound2) => {
4578
4366
  var _a;
4579
4367
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -4596,14 +4384,17 @@ var DraggableComponent = ({
4596
4384
  return s.permissions.getPermissions({ item });
4597
4385
  })
4598
4386
  );
4599
- const userIsDragging = useContextStore(
4600
- ZoneStoreContext,
4601
- (s) => !!s.draggedItem
4387
+ const zoneStore = (0, import_react26.useContext)(ZoneStoreContext);
4388
+ const [dragAxis, setDragAxis] = (0, import_react26.useState)(userDragAxis || autoDragAxis);
4389
+ const dynamicCollisionDetector = (0, import_react26.useMemo)(
4390
+ () => createDynamicCollisionDetector(dragAxis),
4391
+ [dragAxis]
4602
4392
  );
4603
- const canCollide = permissions.drag || userIsDragging;
4604
- const disabled = !isEnabled || !canCollide;
4605
- const [dragAxis, setDragAxis] = (0, import_react25.useState)(userDragAxis || autoDragAxis);
4606
- const { ref: sortableRef, status } = useSortableSafe({
4393
+ const {
4394
+ ref: sortableRef,
4395
+ isDragging: thisIsDragging,
4396
+ sortable
4397
+ } = (0, import_sortable2.useSortable)({
4607
4398
  id,
4608
4399
  index,
4609
4400
  group: zoneCompound,
@@ -4618,18 +4409,34 @@ var DraggableComponent = ({
4618
4409
  path: path || [],
4619
4410
  inDroppableZone
4620
4411
  },
4621
- collisionPriority: isEnabled ? depth : 0,
4622
- collisionDetector: createDynamicCollisionDetector(dragAxis),
4623
- disabled,
4412
+ collisionPriority: depth,
4413
+ collisionDetector: dynamicCollisionDetector,
4624
4414
  // "Out of the way" transition from react-beautiful-dnd
4625
4415
  transition: {
4626
4416
  duration: 200,
4627
4417
  easing: "cubic-bezier(0.2, 0, 0, 1)"
4628
- }
4418
+ },
4419
+ feedback: "clone"
4629
4420
  });
4630
- const thisIsDragging = status === "dragging";
4631
- const ref = (0, import_react25.useRef)(null);
4632
- const refSetter = (0, import_react25.useCallback)(
4421
+ (0, import_react26.useEffect)(() => {
4422
+ const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
4423
+ sortable.droppable.disabled = !isEnabled;
4424
+ sortable.draggable.disabled = !permissions.drag;
4425
+ const cleanup = zoneStore.subscribe((s) => {
4426
+ sortable.droppable.disabled = !s.enabledIndex[zoneCompound];
4427
+ });
4428
+ if (ref.current && !permissions.drag) {
4429
+ ref.current.setAttribute("data-puck-disabled", "");
4430
+ return () => {
4431
+ var _a;
4432
+ (_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
4433
+ cleanup();
4434
+ };
4435
+ }
4436
+ return cleanup;
4437
+ }, [permissions.drag, zoneCompound]);
4438
+ const ref = (0, import_react26.useRef)(null);
4439
+ const refSetter = (0, import_react26.useCallback)(
4633
4440
  (el) => {
4634
4441
  sortableRef(el);
4635
4442
  if (el) {
@@ -4638,14 +4445,14 @@ var DraggableComponent = ({
4638
4445
  },
4639
4446
  [sortableRef]
4640
4447
  );
4641
- const [portalEl, setPortalEl] = (0, import_react25.useState)();
4642
- (0, import_react25.useEffect)(() => {
4448
+ const [portalEl, setPortalEl] = (0, import_react26.useState)();
4449
+ (0, import_react26.useEffect)(() => {
4643
4450
  var _a, _b, _c;
4644
4451
  setPortalEl(
4645
4452
  iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
4646
4453
  );
4647
4454
  }, [iframe.enabled, ref.current]);
4648
- const getStyle = (0, import_react25.useCallback)(() => {
4455
+ const getStyle = (0, import_react26.useCallback)(() => {
4649
4456
  var _a, _b, _c;
4650
4457
  if (!ref.current) return;
4651
4458
  const rect = ref.current.getBoundingClientRect();
@@ -4657,40 +4464,61 @@ var DraggableComponent = ({
4657
4464
  x: deepScrollPosition.x - portalScroll.x - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _b : 0),
4658
4465
  y: deepScrollPosition.y - portalScroll.y - ((_c = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _c : 0)
4659
4466
  };
4467
+ const untransformed = {
4468
+ height: ref.current.offsetHeight,
4469
+ width: ref.current.offsetWidth
4470
+ };
4471
+ const transform = accumulateTransform(ref.current);
4660
4472
  const style2 = {
4661
- left: `${rect.left + scroll.x}px`,
4662
- top: `${rect.top + scroll.y}px`,
4663
- height: `${rect.height}px`,
4664
- width: `${rect.width}px`
4473
+ left: `${(rect.left + scroll.x) / transform.scaleX}px`,
4474
+ top: `${(rect.top + scroll.y) / transform.scaleY}px`,
4475
+ height: `${untransformed.height}px`,
4476
+ width: `${untransformed.width}px`
4665
4477
  };
4666
4478
  return style2;
4667
4479
  }, [ref.current]);
4668
- const [style, setStyle] = (0, import_react25.useState)();
4669
- const sync = (0, import_react25.useCallback)(() => {
4480
+ const [style, setStyle] = (0, import_react26.useState)();
4481
+ const sync = (0, import_react26.useCallback)(() => {
4670
4482
  setStyle(getStyle());
4671
4483
  }, [ref.current, iframe]);
4672
- (0, import_react25.useEffect)(() => {
4673
- if (ref.current && !userIsDragging) {
4484
+ (0, import_react26.useEffect)(() => {
4485
+ if (ref.current) {
4674
4486
  const observer = new ResizeObserver(sync);
4675
4487
  observer.observe(ref.current);
4676
4488
  return () => {
4677
4489
  observer.disconnect();
4678
4490
  };
4679
4491
  }
4680
- }, [ref.current, userIsDragging]);
4492
+ }, [ref.current]);
4681
4493
  const registerNode = useAppStore((s) => s.nodes.registerNode);
4682
- (0, import_react25.useEffect)(() => {
4494
+ const hideOverlay = (0, import_react26.useCallback)(() => {
4495
+ setIsVisible(false);
4496
+ }, []);
4497
+ const showOverlay = (0, import_react26.useCallback)(() => {
4498
+ setIsVisible(true);
4499
+ }, []);
4500
+ (0, import_react26.useEffect)(() => {
4683
4501
  var _a;
4684
- registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
4502
+ registerNode(id, {
4503
+ methods: { sync, showOverlay, hideOverlay },
4504
+ element: (_a = ref.current) != null ? _a : null
4505
+ });
4685
4506
  return () => {
4686
- registerNode(id, { methods: { sync: () => null }, element: null });
4507
+ registerNode(id, {
4508
+ methods: {
4509
+ sync: () => null,
4510
+ hideOverlay: () => null,
4511
+ showOverlay: () => null
4512
+ },
4513
+ element: null
4514
+ });
4687
4515
  };
4688
4516
  }, [id, zoneCompound, index, componentType, sync]);
4689
- const CustomActionBar = (0, import_react25.useMemo)(
4517
+ const CustomActionBar = (0, import_react26.useMemo)(
4690
4518
  () => overrides.actionBar || DefaultActionBar,
4691
4519
  [overrides.actionBar]
4692
4520
  );
4693
- const onClick = (0, import_react25.useCallback)(
4521
+ const onClick = (0, import_react26.useCallback)(
4694
4522
  (e) => {
4695
4523
  e.stopPropagation();
4696
4524
  dispatch({
@@ -4703,7 +4531,7 @@ var DraggableComponent = ({
4703
4531
  [index, zoneCompound, id]
4704
4532
  );
4705
4533
  const appStore = useAppStoreApi();
4706
- const onSelectParent = (0, import_react25.useCallback)(() => {
4534
+ const onSelectParent = (0, import_react26.useCallback)(() => {
4707
4535
  const { nodes, zones } = appStore.getState().state.indexes;
4708
4536
  const node = nodes[id];
4709
4537
  const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
@@ -4724,28 +4552,32 @@ var DraggableComponent = ({
4724
4552
  }
4725
4553
  });
4726
4554
  }, [ctx, path]);
4727
- const onDuplicate = (0, import_react25.useCallback)(() => {
4555
+ const onDuplicate = (0, import_react26.useCallback)(() => {
4728
4556
  dispatch({
4729
4557
  type: "duplicate",
4730
4558
  sourceIndex: index,
4731
4559
  sourceZone: zoneCompound
4732
4560
  });
4733
4561
  }, [index, zoneCompound]);
4734
- const onDelete = (0, import_react25.useCallback)(() => {
4562
+ const onDelete = (0, import_react26.useCallback)(() => {
4735
4563
  dispatch({
4736
4564
  type: "remove",
4737
4565
  index,
4738
4566
  zone: zoneCompound
4739
4567
  });
4740
4568
  }, [index, zoneCompound]);
4741
- const [hover, setHover] = (0, import_react25.useState)(false);
4742
- const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
4743
- (0, import_react25.useEffect)(() => {
4569
+ const [hover, setHover] = (0, import_react26.useState)(false);
4570
+ const indicativeHover = useContextStore(
4571
+ ZoneStoreContext,
4572
+ (s) => s.hoveringComponent === id
4573
+ );
4574
+ (0, import_react26.useEffect)(() => {
4744
4575
  if (!ref.current) {
4745
4576
  return;
4746
4577
  }
4747
4578
  const el = ref.current;
4748
4579
  const _onMouseOver = (e) => {
4580
+ const userIsDragging = !!zoneStore.getState().draggedItem;
4749
4581
  if (userIsDragging) {
4750
4582
  if (thisIsDragging) {
4751
4583
  setHover(true);
@@ -4767,18 +4599,12 @@ var DraggableComponent = ({
4767
4599
  el.addEventListener("click", onClick);
4768
4600
  el.addEventListener("mouseover", _onMouseOver);
4769
4601
  el.addEventListener("mouseout", _onMouseOut);
4770
- if (thisIsDragging) {
4771
- el.setAttribute("data-puck-dragging", "");
4772
- } else {
4773
- el.removeAttribute("data-puck-dragging");
4774
- }
4775
4602
  return () => {
4776
4603
  el.removeAttribute("data-puck-component");
4777
4604
  el.removeAttribute("data-puck-dnd");
4778
4605
  el.removeEventListener("click", onClick);
4779
4606
  el.removeEventListener("mouseover", _onMouseOver);
4780
4607
  el.removeEventListener("mouseout", _onMouseOut);
4781
- el.removeAttribute("data-puck-dragging");
4782
4608
  };
4783
4609
  }, [
4784
4610
  ref,
@@ -4786,29 +4612,43 @@ var DraggableComponent = ({
4786
4612
  containsActiveZone,
4787
4613
  zoneCompound,
4788
4614
  id,
4789
- userIsDragging,
4790
4615
  thisIsDragging,
4791
4616
  inDroppableZone
4792
4617
  ]);
4793
- (0, import_react25.useEffect)(() => {
4794
- if (ref.current && disabled) {
4795
- ref.current.setAttribute("data-puck-disabled", "");
4796
- return () => {
4797
- var _a;
4798
- (_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
4799
- };
4800
- }
4801
- }, [disabled, ref]);
4802
- const [isVisible, setIsVisible] = (0, import_react25.useState)(false);
4803
- (0, import_react25.useEffect)(() => {
4804
- sync();
4805
- if ((isSelected || hover || indicativeHover) && !userIsDragging) {
4806
- setIsVisible(true);
4618
+ const [isVisible, setIsVisible] = (0, import_react26.useState)(false);
4619
+ const [dragFinished, setDragFinished] = (0, import_react26.useState)(true);
4620
+ const [_, startTransition] = (0, import_react26.useTransition)();
4621
+ (0, import_react26.useEffect)(() => {
4622
+ startTransition(() => {
4623
+ if (hover || indicativeHover || isSelected) {
4624
+ sync();
4625
+ setIsVisible(true);
4626
+ setThisWasDragging(false);
4627
+ } else {
4628
+ setIsVisible(false);
4629
+ }
4630
+ });
4631
+ }, [hover, indicativeHover, isSelected, iframe]);
4632
+ const [thisWasDragging, setThisWasDragging] = (0, import_react26.useState)(false);
4633
+ const onDragFinished = useOnDragFinished((finished) => {
4634
+ if (finished) {
4635
+ startTransition(() => {
4636
+ sync();
4637
+ setDragFinished(true);
4638
+ });
4807
4639
  } else {
4808
- setIsVisible(false);
4640
+ setDragFinished(false);
4641
+ }
4642
+ });
4643
+ (0, import_react26.useEffect)(() => {
4644
+ if (thisIsDragging) {
4645
+ setThisWasDragging(true);
4809
4646
  }
4810
- }, [isSelected, hover, indicativeHover, iframe, userIsDragging]);
4811
- const syncActionsPosition = (0, import_react25.useCallback)(
4647
+ }, [thisIsDragging]);
4648
+ (0, import_react26.useEffect)(() => {
4649
+ if (thisWasDragging) return onDragFinished();
4650
+ }, [thisWasDragging, onDragFinished]);
4651
+ const syncActionsPosition = (0, import_react26.useCallback)(
4812
4652
  (el) => {
4813
4653
  if (el) {
4814
4654
  const view = el.ownerDocument.defaultView;
@@ -4833,7 +4673,7 @@ var DraggableComponent = ({
4833
4673
  },
4834
4674
  [zoom]
4835
4675
  );
4836
- (0, import_react25.useEffect)(() => {
4676
+ (0, import_react26.useEffect)(() => {
4837
4677
  if (userDragAxis) {
4838
4678
  setDragAxis(userDragAxis);
4839
4679
  return;
@@ -4847,8 +4687,11 @@ var DraggableComponent = ({
4847
4687
  }
4848
4688
  setDragAxis(autoDragAxis);
4849
4689
  }, [ref, userDragAxis, autoDragAxis]);
4850
- const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CornerLeftUp, { size: 16 }) });
4851
- const nextContextValue = (0, import_react25.useMemo)(
4690
+ const parentAction = (0, import_react26.useMemo)(
4691
+ () => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CornerLeftUp, { size: 16 }) }),
4692
+ [ctx == null ? void 0 : ctx.areaId]
4693
+ );
4694
+ const nextContextValue = (0, import_react26.useMemo)(
4852
4695
  () => __spreadProps(__spreadValues({}, ctx), {
4853
4696
  areaId: id,
4854
4697
  zoneCompound,
@@ -4868,7 +4711,7 @@ var DraggableComponent = ({
4868
4711
  ]
4869
4712
  );
4870
4713
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
4871
- isVisible && (0, import_react_dom2.createPortal)(
4714
+ dragFinished && isVisible && (0, import_react_dom2.createPortal)(
4872
4715
  /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
4873
4716
  "div",
4874
4717
  {
@@ -4928,19 +4771,23 @@ var DraggableComponent = ({
4928
4771
 
4929
4772
  // css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
4930
4773
  init_react_import();
4931
- 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" };
4774
+ var styles_module_default12 = { "DropZone": "_DropZone_1i2sv_1", "DropZone--hasChildren": "_DropZone--hasChildren_1i2sv_11", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_1i2sv_24", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_1i2sv_25", "DropZone--isRootZone": "_DropZone--isRootZone_1i2sv_25", "DropZone--isDestination": "_DropZone--isDestination_1i2sv_35", "DropZone-item": "_DropZone-item_1i2sv_47", "DropZone-hitbox": "_DropZone-hitbox_1i2sv_51", "DropZone--isEnabled": "_DropZone--isEnabled_1i2sv_59", "DropZone--isAnimating": "_DropZone--isAnimating_1i2sv_68" };
4775
+
4776
+ // components/DropZone/index.tsx
4777
+ var import_react36 = require("@dnd-kit/react");
4932
4778
 
4933
4779
  // components/DropZone/lib/use-min-empty-height.ts
4934
4780
  init_react_import();
4935
- var import_react26 = require("react");
4781
+ var import_react27 = require("react");
4782
+ var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
4936
4783
  var useMinEmptyHeight = ({
4937
4784
  zoneCompound,
4938
4785
  userMinEmptyHeight,
4939
4786
  ref
4940
4787
  }) => {
4941
4788
  const appStore = useAppStoreApi();
4942
- const [prevHeight, setPrevHeight] = (0, import_react26.useState)(0);
4943
- const [isAnimating, setIsAnimating] = (0, import_react26.useState)(false);
4789
+ const [prevHeight, setPrevHeight] = (0, import_react27.useState)(0);
4790
+ const [isAnimating, setIsAnimating] = (0, import_react27.useState)(false);
4944
4791
  const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
4945
4792
  var _a, _b;
4946
4793
  return {
@@ -4948,32 +4795,52 @@ var useMinEmptyHeight = ({
4948
4795
  isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
4949
4796
  };
4950
4797
  });
4951
- (0, import_react26.useEffect)(() => {
4798
+ const numItems = (0, import_react27.useRef)(0);
4799
+ const onDragFinished = useOnDragFinished(
4800
+ (finished) => {
4801
+ var _a;
4802
+ if (finished) {
4803
+ const newNumItems = getNumItems(appStore, zoneCompound);
4804
+ setPrevHeight(0);
4805
+ if (newNumItems || numItems.current === 0) {
4806
+ setIsAnimating(false);
4807
+ return;
4808
+ }
4809
+ const selectedItem = appStore.getState().selectedItem;
4810
+ const zones = appStore.getState().state.indexes.zones;
4811
+ const nodes = appStore.getState().nodes;
4812
+ (_a = nodes.nodes[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.methods.hideOverlay();
4813
+ setTimeout(() => {
4814
+ var _a2;
4815
+ const contentIds = ((_a2 = zones[zoneCompound]) == null ? void 0 : _a2.contentIds) || [];
4816
+ contentIds.forEach((contentId) => {
4817
+ const node = nodes.nodes[contentId];
4818
+ node == null ? void 0 : node.methods.sync();
4819
+ });
4820
+ if (selectedItem) {
4821
+ setTimeout(() => {
4822
+ var _a3, _b;
4823
+ (_a3 = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _a3.methods.sync();
4824
+ (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.showOverlay();
4825
+ }, 200);
4826
+ }
4827
+ setIsAnimating(false);
4828
+ }, 100);
4829
+ }
4830
+ },
4831
+ [appStore, prevHeight, zoneCompound]
4832
+ );
4833
+ (0, import_react27.useEffect)(() => {
4952
4834
  if (draggedItem && ref.current) {
4953
4835
  if (isZone) {
4954
4836
  const rect = ref.current.getBoundingClientRect();
4837
+ numItems.current = getNumItems(appStore, zoneCompound);
4955
4838
  setPrevHeight(rect.height);
4956
4839
  setIsAnimating(true);
4957
- return;
4840
+ return onDragFinished();
4958
4841
  }
4959
4842
  }
4960
- setPrevHeight(0);
4961
- setTimeout(() => {
4962
- var _a, _b;
4963
- const zones = appStore.getState().state.indexes.zones;
4964
- const nodes = appStore.getState().nodes;
4965
- const selectedItem = appStore.getState().selectedItem;
4966
- const contentIds = ((_a = zones[zoneCompound]) == null ? void 0 : _a.contentIds) || [];
4967
- contentIds.forEach((contentId) => {
4968
- const node = nodes.nodes[contentId];
4969
- node == null ? void 0 : node.methods.sync();
4970
- });
4971
- if (selectedItem) {
4972
- (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.sync();
4973
- }
4974
- setIsAnimating(false);
4975
- }, 400);
4976
- }, [ref.current, draggedItem, zoneCompound]);
4843
+ }, [ref.current, draggedItem, onDragFinished]);
4977
4844
  return [prevHeight || userMinEmptyHeight, isAnimating];
4978
4845
  };
4979
4846
 
@@ -4994,15 +4861,15 @@ function assignRefs(refs, node) {
4994
4861
 
4995
4862
  // components/DropZone/lib/use-content-with-preview.ts
4996
4863
  init_react_import();
4997
- var import_react29 = require("react");
4864
+ var import_react30 = require("react");
4998
4865
 
4999
4866
  // lib/dnd/use-rendered-callback.ts
5000
4867
  init_react_import();
5001
- var import_react27 = require("@dnd-kit/react");
5002
- var import_react28 = require("react");
4868
+ var import_react28 = require("@dnd-kit/react");
4869
+ var import_react29 = require("react");
5003
4870
  function useRenderedCallback(callback, deps) {
5004
- const manager = (0, import_react27.useDragDropManager)();
5005
- return (0, import_react28.useCallback)(
4871
+ const manager = (0, import_react28.useDragDropManager)();
4872
+ return (0, import_react29.useCallback)(
5006
4873
  (...args) => __async(this, null, function* () {
5007
4874
  yield manager == null ? void 0 : manager.renderer.rendering;
5008
4875
  return callback(...args);
@@ -5013,27 +4880,21 @@ function useRenderedCallback(callback, deps) {
5013
4880
 
5014
4881
  // components/DropZone/lib/use-content-with-preview.ts
5015
4882
  var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5016
- const { draggedItemId, preview, previewExists } = useContextStore(
4883
+ const zoneStore = (0, import_react30.useContext)(ZoneStoreContext);
4884
+ const preview = useContextStore(
5017
4885
  ZoneStoreContext,
5018
- (s) => {
5019
- var _a;
5020
- return {
5021
- draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
5022
- preview: s.previewIndex[zoneCompound],
5023
- previewExists: Object.keys(s.previewIndex || {}).length > 0
5024
- };
5025
- }
4886
+ (s) => s.previewIndex[zoneCompound]
5026
4887
  );
5027
4888
  const isDragging = useAppStore((s) => s.state.ui.isDragging);
5028
- const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react29.useState)(contentIds);
5029
- const [localPreview, setLocalPreview] = (0, import_react29.useState)(
4889
+ const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react30.useState)(contentIds);
4890
+ const [localPreview, setLocalPreview] = (0, import_react30.useState)(
5030
4891
  preview
5031
4892
  );
5032
4893
  const updateContent = useRenderedCallback(
5033
- (contentIds2, preview2, isDragging2) => {
5034
- if (isDragging2 && !previewExists) {
5035
- return;
5036
- }
4894
+ (contentIds2, preview2) => {
4895
+ var _a;
4896
+ const s = zoneStore.getState();
4897
+ const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
5037
4898
  if (preview2) {
5038
4899
  if (preview2.type === "insert") {
5039
4900
  setContentIdsWithPreview(
@@ -5054,14 +4915,14 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5054
4915
  }
5055
4916
  } else {
5056
4917
  setContentIdsWithPreview(
5057
- previewExists ? contentIds2.filter((id) => id !== draggedItemId) : contentIds2
4918
+ contentIds2.filter((id) => id !== draggedItemId)
5058
4919
  );
5059
4920
  }
5060
4921
  setLocalPreview(preview2);
5061
4922
  },
5062
- [draggedItemId, previewExists]
4923
+ []
5063
4924
  );
5064
- (0, import_react29.useEffect)(() => {
4925
+ (0, import_react30.useEffect)(() => {
5065
4926
  updateContent(contentIds, preview, isDragging);
5066
4927
  }, [contentIds, preview, isDragging]);
5067
4928
  return [contentIdsWithPreview, localPreview];
@@ -5069,16 +4930,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5069
4930
 
5070
4931
  // components/DropZone/lib/use-drag-axis.ts
5071
4932
  init_react_import();
5072
- var import_react30 = require("react");
4933
+ var import_react31 = require("react");
5073
4934
  var GRID_DRAG_AXIS = "dynamic";
5074
4935
  var FLEX_ROW_DRAG_AXIS = "x";
5075
4936
  var DEFAULT_DRAG_AXIS = "y";
5076
4937
  var useDragAxis = (ref, collisionAxis) => {
5077
4938
  const status = useAppStore((s) => s.status);
5078
- const [dragAxis, setDragAxis] = (0, import_react30.useState)(
4939
+ const [dragAxis, setDragAxis] = (0, import_react31.useState)(
5079
4940
  collisionAxis || DEFAULT_DRAG_AXIS
5080
4941
  );
5081
- const calculateDragAxis = (0, import_react30.useCallback)(() => {
4942
+ const calculateDragAxis = (0, import_react31.useCallback)(() => {
5082
4943
  if (ref.current) {
5083
4944
  const computedStyle = window.getComputedStyle(ref.current);
5084
4945
  if (computedStyle.display === "grid") {
@@ -5090,7 +4951,7 @@ var useDragAxis = (ref, collisionAxis) => {
5090
4951
  }
5091
4952
  }
5092
4953
  }, [ref.current]);
5093
- (0, import_react30.useEffect)(() => {
4954
+ (0, import_react31.useEffect)(() => {
5094
4955
  const onViewportChange = () => {
5095
4956
  calculateDragAxis();
5096
4957
  };
@@ -5099,7 +4960,7 @@ var useDragAxis = (ref, collisionAxis) => {
5099
4960
  window.removeEventListener("viewportchange", onViewportChange);
5100
4961
  };
5101
4962
  }, []);
5102
- (0, import_react30.useEffect)(calculateDragAxis, [status, collisionAxis]);
4963
+ (0, import_react31.useEffect)(calculateDragAxis, [status, collisionAxis]);
5103
4964
  return [dragAxis, calculateDragAxis];
5104
4965
  };
5105
4966
 
@@ -5111,9 +4972,9 @@ init_react_import();
5111
4972
 
5112
4973
  // lib/use-slots.tsx
5113
4974
  init_react_import();
5114
- var import_react31 = require("react");
4975
+ var import_react32 = require("react");
5115
4976
  function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
5116
- const slotProps = (0, import_react31.useMemo)(() => {
4977
+ const slotProps = (0, import_react32.useMemo)(() => {
5117
4978
  if (!(config == null ? void 0 : config.fields)) return props;
5118
4979
  const slotProps2 = {};
5119
4980
  const fieldKeys = Object.keys(config.fields);
@@ -5135,18 +4996,22 @@ function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEd
5135
4996
  }
5136
4997
  return slotProps2;
5137
4998
  }, [config, readOnly, forceReadOnly]);
5138
- return __spreadValues(__spreadValues({}, props), slotProps);
4999
+ const mergedProps = (0, import_react32.useMemo)(
5000
+ () => __spreadValues(__spreadValues({}, props), slotProps),
5001
+ [props, slotProps]
5002
+ );
5003
+ return mergedProps;
5139
5004
  }
5140
5005
 
5141
5006
  // components/Render/index.tsx
5142
- var import_react33 = __toESM(require("react"));
5007
+ var import_react34 = __toESM(require("react"));
5143
5008
 
5144
5009
  // components/SlotRender/index.tsx
5145
5010
  init_react_import();
5146
5011
 
5147
5012
  // components/SlotRender/server.tsx
5148
5013
  init_react_import();
5149
- var import_react32 = require("react");
5014
+ var import_react33 = require("react");
5150
5015
 
5151
5016
  // components/ServerRender/index.tsx
5152
5017
  init_react_import();
@@ -5212,7 +5077,7 @@ var Item = ({
5212
5077
  })
5213
5078
  );
5214
5079
  };
5215
- var SlotRender = (0, import_react32.forwardRef)(
5080
+ var SlotRender = (0, import_react33.forwardRef)(
5216
5081
  function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
5217
5082
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
5218
5083
  if (!config.components[item.type]) {
@@ -5258,7 +5123,7 @@ var ContextSlotRender = ({
5258
5123
 
5259
5124
  // components/Render/index.tsx
5260
5125
  var import_jsx_runtime24 = require("react/jsx-runtime");
5261
- var renderContext = import_react33.default.createContext({
5126
+ var renderContext = import_react34.default.createContext({
5262
5127
  config: { components: {} },
5263
5128
  data: { root: {}, content: [] },
5264
5129
  metadata: {}
@@ -5287,7 +5152,7 @@ function Render({
5287
5152
  id: "puck-root"
5288
5153
  });
5289
5154
  const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
5290
- const nextContextValue = (0, import_react33.useMemo)(
5155
+ const nextContextValue = (0, import_react34.useMemo)(
5291
5156
  () => ({
5292
5157
  mode: "render",
5293
5158
  depth: 0
@@ -5309,17 +5174,16 @@ var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5309
5174
  var DropZoneChild = ({
5310
5175
  zoneCompound,
5311
5176
  componentId,
5312
- preview,
5313
5177
  index,
5314
- isEnabled,
5315
5178
  dragAxis,
5316
5179
  collisionAxis,
5317
5180
  inDroppableZone
5318
5181
  }) => {
5319
5182
  var _a, _b;
5320
5183
  const metadata = useAppStore((s) => s.metadata);
5321
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5184
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5322
5185
  const { depth = 1 } = ctx != null ? ctx : {};
5186
+ const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
5323
5187
  const nodeProps = useAppStore(
5324
5188
  (0, import_shallow3.useShallow)((s) => {
5325
5189
  var _a2;
@@ -5338,17 +5202,32 @@ var DropZoneChild = ({
5338
5202
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
5339
5203
  })
5340
5204
  );
5341
- const node = { type: nodeType, props: nodeProps };
5342
- const item = nodeProps ? node : (preview == null ? void 0 : preview.componentType) ? { type: preview.componentType, props: preview.props } : null;
5205
+ const item = (0, import_react35.useMemo)(() => {
5206
+ if (nodeProps) {
5207
+ return { type: nodeType, props: nodeProps };
5208
+ }
5209
+ const preview = zoneStore.getState().previewIndex[zoneCompound];
5210
+ if (componentId === (preview == null ? void 0 : preview.props.id)) {
5211
+ return {
5212
+ type: preview.componentType,
5213
+ props: preview.props,
5214
+ previewType: preview.type
5215
+ };
5216
+ }
5217
+ return null;
5218
+ }, [componentId, zoneCompound, nodeType, nodeProps]);
5343
5219
  const componentConfig = useAppStore(
5344
5220
  (s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
5345
5221
  );
5346
- const puckProps = {
5347
- renderDropZone: DropZoneEditPure,
5348
- isEditing: true,
5349
- dragRef: null,
5350
- metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
5351
- };
5222
+ const puckProps = (0, import_react35.useMemo)(
5223
+ () => ({
5224
+ renderDropZone: DropZoneEditPure,
5225
+ isEditing: true,
5226
+ dragRef: null,
5227
+ metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
5228
+ }),
5229
+ [metadata, componentConfig == null ? void 0 : componentConfig.metadata]
5230
+ );
5352
5231
  const overrides = useAppStore((s) => s.overrides);
5353
5232
  const isLoading = useAppStore(
5354
5233
  (s) => {
@@ -5363,13 +5242,13 @@ var DropZoneChild = ({
5363
5242
  }
5364
5243
  );
5365
5244
  let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
5366
- const renderPreview = (0, import_react34.useMemo)(
5367
- () => function Preview4() {
5245
+ const renderPreview = (0, import_react35.useMemo)(
5246
+ () => function Preview3() {
5368
5247
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
5369
5248
  },
5370
5249
  [componentId, label, overrides]
5371
5250
  );
5372
- const defaultsProps = (0, import_react34.useMemo)(
5251
+ const defaultsProps = (0, import_react35.useMemo)(
5373
5252
  () => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
5374
5253
  puck: puckProps,
5375
5254
  editMode: true
@@ -5391,8 +5270,8 @@ var DropZoneChild = ({
5391
5270
  item.type
5392
5271
  ] });
5393
5272
  let componentType = item.type;
5394
- const isPreview = componentId === (preview == null ? void 0 : preview.props.id) && preview.type === "insert";
5395
- if (isPreview) {
5273
+ const isInserting = item.previewType === "insert";
5274
+ if (isInserting) {
5396
5275
  Render2 = renderPreview;
5397
5276
  }
5398
5277
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
@@ -5406,11 +5285,10 @@ var DropZoneChild = ({
5406
5285
  isLoading,
5407
5286
  isSelected,
5408
5287
  label,
5409
- isEnabled,
5410
5288
  autoDragAxis: dragAxis,
5411
5289
  userDragAxis: collisionAxis,
5412
5290
  inDroppableZone,
5413
- children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isPreview ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5291
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
5414
5292
  Render2,
5415
5293
  __spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
5416
5294
  puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
@@ -5421,8 +5299,8 @@ var DropZoneChild = ({
5421
5299
  }
5422
5300
  );
5423
5301
  };
5424
- var DropZoneChildMemo = (0, import_react34.memo)(DropZoneChild);
5425
- var DropZoneEdit = (0, import_react34.forwardRef)(
5302
+ var DropZoneChildMemo = (0, import_react35.memo)(DropZoneChild);
5303
+ var DropZoneEdit = (0, import_react35.forwardRef)(
5426
5304
  function DropZoneEditInternal({
5427
5305
  zone,
5428
5306
  allow,
@@ -5432,7 +5310,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5432
5310
  minEmptyHeight: userMinEmptyHeight = 128,
5433
5311
  collisionAxis
5434
5312
  }, userRef) {
5435
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5313
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5436
5314
  const {
5437
5315
  // These all need setting via context
5438
5316
  areaId,
@@ -5453,20 +5331,10 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5453
5331
  }
5454
5332
  }
5455
5333
  const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
5456
- const {
5457
- isDeepestZone,
5458
- inNextDeepestArea,
5459
- draggedComponentType,
5460
- userIsDragging
5461
- } = useContextStore(ZoneStoreContext, (s) => {
5462
- var _a, _b;
5463
- return {
5464
- isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
5465
- inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
5466
- draggedComponentType: (_b = s.draggedItem) == null ? void 0 : _b.data.componentType,
5467
- userIsDragging: !!s.draggedItem
5468
- };
5469
- });
5334
+ const inNextDeepestArea = useContextStore(
5335
+ ZoneStoreContext,
5336
+ (s) => s.nextAreaDepthIndex[areaId || ""]
5337
+ );
5470
5338
  const zoneContentIds = useAppStore(
5471
5339
  (0, import_shallow3.useShallow)((s) => {
5472
5340
  var _a;
@@ -5479,13 +5347,8 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5479
5347
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
5480
5348
  })
5481
5349
  );
5482
- (0, import_react34.useEffect)(() => {
5350
+ (0, import_react35.useEffect)(() => {
5483
5351
  if (!zoneType || zoneType === "dropzone") {
5484
- if (zoneCompound !== rootDroppableId) {
5485
- console.warn(
5486
- "DropZones have been deprecated in favor of slot fields and will be removed in a future version of Puck. Please see the migration guide: https://www.puckeditor.com/docs/guides/migrations/dropzones-to-slots"
5487
- );
5488
- }
5489
5352
  if (ctx == null ? void 0 : ctx.registerZone) {
5490
5353
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5491
5354
  }
@@ -5496,11 +5359,20 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5496
5359
  };
5497
5360
  }
5498
5361
  }, [zoneType]);
5499
- const contentIds = (0, import_react34.useMemo)(() => {
5362
+ (0, import_react35.useEffect)(() => {
5363
+ if (zoneType === "dropzone") {
5364
+ if (zoneCompound !== rootDroppableId) {
5365
+ console.warn(
5366
+ "DropZones have been deprecated in favor of slot fields and will be removed in a future version of Puck. Please see the migration guide: https://www.puckeditor.com/docs/guides/migrations/dropzones-to-slots"
5367
+ );
5368
+ }
5369
+ }
5370
+ }, [zoneType]);
5371
+ const contentIds = (0, import_react35.useMemo)(() => {
5500
5372
  return zoneContentIds || [];
5501
5373
  }, [zoneContentIds]);
5502
- const ref = (0, import_react34.useRef)(null);
5503
- const acceptsTarget = (0, import_react34.useCallback)(
5374
+ const ref = (0, import_react35.useRef)(null);
5375
+ const acceptsTarget = (0, import_react35.useCallback)(
5504
5376
  (componentType) => {
5505
5377
  if (!componentType) {
5506
5378
  return true;
@@ -5522,29 +5394,44 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5522
5394
  },
5523
5395
  [allow, disallow]
5524
5396
  );
5525
- (0, import_react34.useEffect)(() => {
5397
+ const targetAccepted = useContextStore(ZoneStoreContext, (s) => {
5398
+ var _a;
5399
+ const draggedComponentType = (_a = s.draggedItem) == null ? void 0 : _a.data.componentType;
5400
+ return acceptsTarget(draggedComponentType);
5401
+ });
5402
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
5403
+ const isEnabled = useContextStore(ZoneStoreContext, (s) => {
5404
+ var _a;
5405
+ let _isEnabled = true;
5406
+ const isDeepestZone = (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false;
5407
+ _isEnabled = isDeepestZone;
5408
+ if (_isEnabled) {
5409
+ _isEnabled = targetAccepted;
5410
+ }
5411
+ return _isEnabled;
5412
+ });
5413
+ (0, import_react35.useEffect)(() => {
5526
5414
  if (registerLocalZone) {
5527
- registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
5415
+ registerLocalZone(zoneCompound, isEnabled);
5528
5416
  }
5529
5417
  return () => {
5530
5418
  if (unregisterLocalZone) {
5531
5419
  unregisterLocalZone(zoneCompound);
5532
5420
  }
5533
5421
  };
5534
- }, [draggedComponentType, zoneCompound]);
5535
- const hoveringOverArea = inNextDeepestArea || isRootZone;
5536
- let isEnabled = true;
5537
- if (userIsDragging) {
5538
- isEnabled = isDeepestZone;
5539
- }
5540
- if (isEnabled) {
5541
- isEnabled = acceptsTarget(draggedComponentType);
5542
- }
5422
+ }, [isEnabled, zoneCompound]);
5543
5423
  const [contentIdsWithPreview, preview] = useContentIdsWithPreview(
5544
5424
  contentIds,
5545
5425
  zoneCompound
5546
5426
  );
5547
5427
  const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
5428
+ const zoneStore = (0, import_react35.useContext)(ZoneStoreContext);
5429
+ (0, import_react35.useEffect)(() => {
5430
+ const { enabledIndex } = zoneStore.getState();
5431
+ zoneStore.setState({
5432
+ enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
5433
+ });
5434
+ }, [isEnabled, zoneStore, zoneCompound]);
5548
5435
  const droppableConfig = {
5549
5436
  id: zoneCompound,
5550
5437
  collisionPriority: isEnabled ? depth : 0,
@@ -5554,11 +5441,11 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5554
5441
  data: {
5555
5442
  areaId,
5556
5443
  depth,
5557
- isDroppableTarget: acceptsTarget(draggedComponentType),
5444
+ isDroppableTarget: targetAccepted,
5558
5445
  path: path || []
5559
5446
  }
5560
5447
  };
5561
- const { ref: dropRef } = useDroppableSafe(droppableConfig);
5448
+ const { ref: dropRef } = (0, import_react36.useDroppable)(droppableConfig);
5562
5449
  const isAreaSelected = useAppStore(
5563
5450
  (s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
5564
5451
  );
@@ -5573,7 +5460,6 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5573
5460
  {
5574
5461
  className: `${getClassName17({
5575
5462
  isRootZone,
5576
- userIsDragging,
5577
5463
  hoveringOverArea,
5578
5464
  isEnabled,
5579
5465
  isAreaSelected,
@@ -5595,12 +5481,10 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5595
5481
  {
5596
5482
  zoneCompound,
5597
5483
  componentId,
5598
- preview,
5599
5484
  dragAxis,
5600
- isEnabled,
5601
5485
  index: i,
5602
5486
  collisionAxis,
5603
- inDroppableZone: acceptsTarget(draggedComponentType)
5487
+ inDroppableZone: targetAccepted
5604
5488
  },
5605
5489
  componentId
5606
5490
  );
@@ -5616,7 +5500,7 @@ var DropZoneRenderItem = ({
5616
5500
  }) => {
5617
5501
  const Component = config.components[item.type];
5618
5502
  const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
5619
- const nextContextValue = (0, import_react34.useMemo)(
5503
+ const nextContextValue = (0, import_react35.useMemo)(
5620
5504
  () => ({
5621
5505
  areaId: props.id,
5622
5506
  depth: 1
@@ -5634,14 +5518,14 @@ var DropZoneRenderItem = ({
5634
5518
  ) }, props.id);
5635
5519
  };
5636
5520
  var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
5637
- var DropZoneRender2 = (0, import_react34.forwardRef)(
5521
+ var DropZoneRender2 = (0, import_react35.forwardRef)(
5638
5522
  function DropZoneRenderInternal({ className, style, zone }, ref) {
5639
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5523
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5640
5524
  const { areaId = "root" } = ctx || {};
5641
- const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
5525
+ const { config, data, metadata } = (0, import_react35.useContext)(renderContext);
5642
5526
  let zoneCompound = rootDroppableId;
5643
5527
  let content = (data == null ? void 0 : data.content) || [];
5644
- (0, import_react34.useEffect)(() => {
5528
+ (0, import_react35.useEffect)(() => {
5645
5529
  if (!content) {
5646
5530
  if (ctx == null ? void 0 : ctx.registerZone) {
5647
5531
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
@@ -5678,9 +5562,9 @@ var DropZoneRender2 = (0, import_react34.forwardRef)(
5678
5562
  }
5679
5563
  );
5680
5564
  var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
5681
- var DropZone = (0, import_react34.forwardRef)(
5565
+ var DropZone = (0, import_react35.forwardRef)(
5682
5566
  function DropZone2(props, ref) {
5683
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5567
+ const ctx = (0, import_react35.useContext)(dropZoneContext);
5684
5568
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
5685
5569
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
5686
5570
  }
@@ -5690,8 +5574,7 @@ var DropZone = (0, import_react34.forwardRef)(
5690
5574
 
5691
5575
  // lib/dnd/NestedDroppablePlugin.ts
5692
5576
  init_react_import();
5693
- var import_abstract10 = require("@dnd-kit/abstract");
5694
- var import_state2 = require("@dnd-kit/state");
5577
+ var import_abstract9 = require("@dnd-kit/abstract");
5695
5578
 
5696
5579
  // lib/throttle.ts
5697
5580
  init_react_import();
@@ -5740,7 +5623,7 @@ var GlobalPosition = class {
5740
5623
  var _a;
5741
5624
  this.target = target;
5742
5625
  this.original = original;
5743
- this.frameEl = document.querySelector("#preview-frame");
5626
+ this.frameEl = document.querySelector("iframe#preview-frame");
5744
5627
  if (this.frameEl) {
5745
5628
  this.frameRect = this.frameEl.getBoundingClientRect();
5746
5629
  this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
@@ -5820,6 +5703,7 @@ var getZoneId2 = (candidate) => {
5820
5703
  }
5821
5704
  return id;
5822
5705
  };
5706
+ var BUFFER = 6;
5823
5707
  var getPointerCollisions = (position, manager) => {
5824
5708
  const candidates = [];
5825
5709
  let elements = position.target.ownerDocument.elementsFromPoint(
@@ -5843,13 +5727,26 @@ var getPointerCollisions = (position, manager) => {
5843
5727
  for (let i = 0; i < elements.length; i++) {
5844
5728
  const element = elements[i];
5845
5729
  const dropzoneId = element.getAttribute("data-puck-dropzone");
5730
+ const id = element.getAttribute("data-puck-dnd");
5731
+ const isVoid = element.hasAttribute("data-puck-dnd-void");
5732
+ if (BUFFER && (dropzoneId || id) && !isVoid) {
5733
+ const box = element.getBoundingClientRect();
5734
+ const contractedBox = {
5735
+ left: box.left + BUFFER,
5736
+ right: box.right - BUFFER,
5737
+ top: box.top + BUFFER,
5738
+ bottom: box.bottom - BUFFER
5739
+ };
5740
+ if (position.frame.x < contractedBox.left || position.frame.x > contractedBox.right || position.frame.y > contractedBox.bottom || position.frame.y < contractedBox.top) {
5741
+ continue;
5742
+ }
5743
+ }
5846
5744
  if (dropzoneId) {
5847
5745
  const droppable = manager.registry.droppables.get(dropzoneId);
5848
5746
  if (droppable) {
5849
5747
  candidates.push(droppable);
5850
5748
  }
5851
5749
  }
5852
- const id = element.getAttribute("data-puck-dnd");
5853
5750
  if (id) {
5854
5751
  const droppable = manager.registry.droppables.get(id);
5855
5752
  if (droppable) {
@@ -5903,17 +5800,17 @@ var findDeepestCandidate = (position, manager) => {
5903
5800
  return { zone, area };
5904
5801
  }
5905
5802
  return {
5906
- zone: "default-zone",
5907
- area: null
5803
+ zone: rootDroppableId,
5804
+ area: rootAreaId
5908
5805
  };
5909
5806
  };
5910
- var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract10.Plugin {
5807
+ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends import_abstract9.Plugin {
5911
5808
  constructor(manager, options) {
5912
5809
  super(manager);
5913
5810
  if (typeof window === "undefined") {
5914
5811
  return;
5915
5812
  }
5916
- const cleanupEffect = (0, import_state2.effects)(() => {
5813
+ this.registerEffect(() => {
5917
5814
  const handleMove = (event) => {
5918
5815
  const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
5919
5816
  const position = new GlobalPosition(target, {
@@ -5937,12 +5834,12 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
5937
5834
  capture: true
5938
5835
  // dndkit's PointerSensor prevents propagation during drag
5939
5836
  });
5940
- this.destroy = () => {
5837
+ const cleanup = () => {
5941
5838
  document.body.removeEventListener("pointermove", handlePointerMove, {
5942
5839
  capture: true
5943
5840
  });
5944
- cleanupEffect();
5945
5841
  };
5842
+ return cleanup;
5946
5843
  });
5947
5844
  }
5948
5845
  };
@@ -6002,14 +5899,15 @@ function getDeepDir(el) {
6002
5899
  }
6003
5900
 
6004
5901
  // components/DragDropContext/index.tsx
5902
+ var import_state = require("@dnd-kit/state");
6005
5903
  var import_jsx_runtime26 = require("react/jsx-runtime");
6006
5904
  var DEBUG3 = false;
6007
- var dragListenerContext = (0, import_react36.createContext)({
5905
+ var dragListenerContext = (0, import_react38.createContext)({
6008
5906
  dragListeners: {}
6009
5907
  });
6010
5908
  function useDragListener(type, fn, deps = []) {
6011
- const { setDragListeners } = (0, import_react36.useContext)(dragListenerContext);
6012
- (0, import_react36.useEffect)(() => {
5909
+ const { setDragListeners } = (0, import_react38.useContext)(dragListenerContext);
5910
+ (0, import_react38.useEffect)(() => {
6013
5911
  if (setDragListeners) {
6014
5912
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
6015
5913
  [type]: [...old[type] || [], fn]
@@ -6019,8 +5917,8 @@ function useDragListener(type, fn, deps = []) {
6019
5917
  }
6020
5918
  var AREA_CHANGE_DEBOUNCE_MS = 100;
6021
5919
  var useTempDisableFallback = (timeout3) => {
6022
- const lastFallbackDisable = (0, import_react36.useRef)(null);
6023
- return (0, import_react36.useCallback)((manager) => {
5920
+ const lastFallbackDisable = (0, import_react38.useRef)(null);
5921
+ return (0, import_react38.useCallback)((manager) => {
6024
5922
  collisionStore.setState({ fallbackEnabled: false });
6025
5923
  const fallbackId = generateId();
6026
5924
  lastFallbackDisable.current = fallbackId;
@@ -6039,19 +5937,21 @@ var DragDropContextClient = ({
6039
5937
  const dispatch = useAppStore((s) => s.dispatch);
6040
5938
  const appStore = useAppStoreApi();
6041
5939
  const id = useSafeId();
6042
- const debouncedParamsRef = (0, import_react36.useRef)(null);
5940
+ const debouncedParamsRef = (0, import_react38.useRef)(null);
6043
5941
  const tempDisableFallback = useTempDisableFallback(100);
6044
- const [zoneStore] = (0, import_react36.useState)(
5942
+ const [zoneStore] = (0, import_react38.useState)(
6045
5943
  () => (0, import_zustand5.createStore)(() => ({
6046
5944
  zoneDepthIndex: {},
6047
5945
  nextZoneDepthIndex: {},
6048
5946
  areaDepthIndex: {},
6049
5947
  nextAreaDepthIndex: {},
6050
5948
  draggedItem: null,
6051
- previewIndex: {}
5949
+ previewIndex: {},
5950
+ enabledIndex: {},
5951
+ hoveringComponent: null
6052
5952
  }))
6053
5953
  );
6054
- const getChanged2 = (0, import_react36.useCallback)(
5954
+ const getChanged2 = (0, import_react38.useCallback)(
6055
5955
  (params, id2) => {
6056
5956
  const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
6057
5957
  const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
@@ -6072,7 +5972,7 @@ var DragDropContextClient = ({
6072
5972
  },
6073
5973
  [zoneStore]
6074
5974
  );
6075
- const setDeepestAndCollide = (0, import_react36.useCallback)(
5975
+ const setDeepestAndCollide = (0, import_react38.useCallback)(
6076
5976
  (params, manager) => {
6077
5977
  const { zoneChanged, areaChanged } = getChanged2(params, id);
6078
5978
  if (!zoneChanged && !areaChanged) return;
@@ -6096,7 +5996,7 @@ var DragDropContextClient = ({
6096
5996
  setDeepestDb.cancel();
6097
5997
  debouncedParamsRef.current = null;
6098
5998
  };
6099
- (0, import_react36.useEffect)(() => {
5999
+ (0, import_react38.useEffect)(() => {
6100
6000
  if (DEBUG3) {
6101
6001
  zoneStore.subscribe(
6102
6002
  (s) => {
@@ -6110,7 +6010,7 @@ var DragDropContextClient = ({
6110
6010
  );
6111
6011
  }
6112
6012
  }, []);
6113
- const [plugins] = (0, import_react36.useState)(() => [
6013
+ const [plugins] = (0, import_react38.useState)(() => [
6114
6014
  ...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
6115
6015
  createNestedDroppablePlugin(
6116
6016
  {
@@ -6158,10 +6058,10 @@ var DragDropContextClient = ({
6158
6058
  )
6159
6059
  ]);
6160
6060
  const sensors = useSensors();
6161
- const [dragListeners, setDragListeners] = (0, import_react36.useState)({});
6162
- const dragMode = (0, import_react36.useRef)(null);
6163
- const initialSelector = (0, import_react36.useRef)(void 0);
6164
- const nextContextValue = (0, import_react36.useMemo)(
6061
+ const [dragListeners, setDragListeners] = (0, import_react38.useState)({});
6062
+ const dragMode = (0, import_react38.useRef)(null);
6063
+ const initialSelector = (0, import_react38.useRef)(void 0);
6064
+ const nextContextValue = (0, import_react38.useMemo)(
6165
6065
  () => ({
6166
6066
  mode: "edit",
6167
6067
  areaId: "root",
@@ -6177,12 +6077,14 @@ var DragDropContextClient = ({
6177
6077
  setDragListeners
6178
6078
  },
6179
6079
  children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
6180
- import_react35.DragDropProvider,
6080
+ import_react37.DragDropProvider,
6181
6081
  {
6182
6082
  plugins,
6183
6083
  sensors,
6184
6084
  onDragEnd: (event, manager) => {
6185
- var _a;
6085
+ var _a, _b;
6086
+ const entryEl = (_a = getFrame()) == null ? void 0 : _a.querySelector("[data-puck-entry]");
6087
+ entryEl == null ? void 0 : entryEl.removeAttribute("data-puck-dragging");
6186
6088
  const { source, target } = event.operation;
6187
6089
  if (!source) {
6188
6090
  zoneStore.setState({ draggedItem: null });
@@ -6190,9 +6092,9 @@ var DragDropContextClient = ({
6190
6092
  }
6191
6093
  const { zone, index } = source.data;
6192
6094
  const { previewIndex = {} } = zoneStore.getState() || {};
6193
- const thisPreview = ((_a = previewIndex[zone]) == null ? void 0 : _a.props.id) === source.id ? previewIndex[zone] : null;
6194
- setTimeout(() => {
6195
- var _a2, _b;
6095
+ const thisPreview = ((_b = previewIndex[zone]) == null ? void 0 : _b.props.id) === source.id ? previewIndex[zone] : null;
6096
+ const onAnimationEnd = () => {
6097
+ var _a2, _b2;
6196
6098
  zoneStore.setState({ draggedItem: null });
6197
6099
  if (event.canceled || (target == null ? void 0 : target.type) === "void") {
6198
6100
  zoneStore.setState({ previewIndex: {} });
@@ -6228,23 +6130,28 @@ var DragDropContextClient = ({
6228
6130
  });
6229
6131
  }
6230
6132
  }
6231
- setTimeout(() => {
6232
- dispatch({
6233
- type: "setUi",
6234
- ui: {
6235
- itemSelector: { index, zone },
6236
- isDragging: false
6237
- },
6238
- recordHistory: true
6239
- });
6240
- }, 50);
6241
- (_b = dragListeners.dragend) == null ? void 0 : _b.forEach((fn) => {
6133
+ dispatch({
6134
+ type: "setUi",
6135
+ ui: {
6136
+ itemSelector: { index, zone },
6137
+ isDragging: false
6138
+ },
6139
+ recordHistory: true
6140
+ });
6141
+ (_b2 = dragListeners.dragend) == null ? void 0 : _b2.forEach((fn) => {
6242
6142
  fn(event, manager);
6243
6143
  });
6244
- }, 250);
6144
+ };
6145
+ let dispose;
6146
+ dispose = (0, import_state.effect)(() => {
6147
+ if (source.status === "idle") {
6148
+ onAnimationEnd();
6149
+ dispose == null ? void 0 : dispose();
6150
+ }
6151
+ });
6245
6152
  },
6246
6153
  onDragOver: (event, manager) => {
6247
- var _a, _b, _c, _d, _e;
6154
+ var _a, _b, _c, _d;
6248
6155
  event.preventDefault();
6249
6156
  const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
6250
6157
  if (!draggedItem) return;
@@ -6262,7 +6169,7 @@ var DragDropContextClient = ({
6262
6169
  const targetData = target.data;
6263
6170
  targetZone = targetData.zone;
6264
6171
  targetIndex = targetData.index;
6265
- const collisionData = (_c = (_b = manager.dragOperation.data) == null ? void 0 : _b.collisionMap) == null ? void 0 : _c[targetId];
6172
+ const collisionData = (_b = manager.collisionObserver.collisions[0]) == null ? void 0 : _b.data;
6266
6173
  const dir = getDeepDir(target.element);
6267
6174
  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";
6268
6175
  if (targetIndex >= sourceIndex && sourceZone === targetZone) {
@@ -6275,7 +6182,7 @@ var DragDropContextClient = ({
6275
6182
  targetZone = target.id.toString();
6276
6183
  targetIndex = 0;
6277
6184
  }
6278
- const path = ((_d = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _d.path) || [];
6185
+ const path = ((_c = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _c.path) || [];
6279
6186
  if (targetId === sourceId || path.find((path2) => {
6280
6187
  const [pathId] = path2.split(":");
6281
6188
  return pathId === sourceId;
@@ -6321,16 +6228,12 @@ var DragDropContextClient = ({
6321
6228
  });
6322
6229
  }
6323
6230
  }
6324
- (_e = dragListeners.dragover) == null ? void 0 : _e.forEach((fn) => {
6231
+ (_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
6325
6232
  fn(event, manager);
6326
6233
  });
6327
6234
  },
6328
6235
  onDragStart: (event, manager) => {
6329
6236
  var _a;
6330
- dispatch({
6331
- type: "setUi",
6332
- ui: { itemSelector: null, isDragging: true }
6333
- });
6334
6237
  const { source } = event.operation;
6335
6238
  if (source && source.type !== "void") {
6336
6239
  const sourceData = source.data;
@@ -6360,11 +6263,31 @@ var DragDropContextClient = ({
6360
6263
  });
6361
6264
  },
6362
6265
  onBeforeDragStart: (event) => {
6363
- var _a;
6364
- const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.data.type) === "drawer";
6266
+ var _a, _b, _c, _d;
6267
+ const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.type) === "drawer";
6365
6268
  dragMode.current = isNewComponent ? "new" : "existing";
6366
6269
  initialSelector.current = void 0;
6367
6270
  zoneStore.setState({ draggedItem: event.operation.source });
6271
+ if (((_b = appStore.getState().selectedItem) == null ? void 0 : _b.props.id) !== ((_c = event.operation.source) == null ? void 0 : _c.id)) {
6272
+ dispatch({
6273
+ type: "setUi",
6274
+ ui: {
6275
+ itemSelector: null,
6276
+ isDragging: true
6277
+ },
6278
+ recordHistory: false
6279
+ });
6280
+ } else {
6281
+ dispatch({
6282
+ type: "setUi",
6283
+ ui: {
6284
+ isDragging: true
6285
+ },
6286
+ recordHistory: false
6287
+ });
6288
+ }
6289
+ const entryEl = (_d = getFrame()) == null ? void 0 : _d.querySelector("[data-puck-entry]");
6290
+ entryEl == null ? void 0 : entryEl.setAttribute("data-puck-dragging", "true");
6368
6291
  },
6369
6292
  children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneProvider, { value: nextContextValue, children }) })
6370
6293
  }
@@ -6384,6 +6307,7 @@ var DragDropContext = ({
6384
6307
  };
6385
6308
 
6386
6309
  // components/Drawer/index.tsx
6310
+ var import_react40 = require("@dnd-kit/react");
6387
6311
  var import_jsx_runtime27 = require("react/jsx-runtime");
6388
6312
  var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
6389
6313
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
@@ -6394,7 +6318,7 @@ var DrawerItemInner = ({
6394
6318
  dragRef,
6395
6319
  isDragDisabled
6396
6320
  }) => {
6397
- const CustomInner = (0, import_react37.useMemo)(
6321
+ const CustomInner = (0, import_react39.useMemo)(
6398
6322
  () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
6399
6323
  [children]
6400
6324
  );
@@ -6420,10 +6344,11 @@ var DrawerItemDraggable = ({
6420
6344
  id,
6421
6345
  isDragDisabled
6422
6346
  }) => {
6423
- const { ref } = useDraggableSafe({
6347
+ const { ref } = (0, import_react40.useDraggable)({
6424
6348
  id,
6425
- data: { type: "drawer", componentType: name },
6426
- disabled: isDragDisabled
6349
+ data: { componentType: name },
6350
+ disabled: isDragDisabled,
6351
+ type: "drawer"
6427
6352
  });
6428
6353
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: getClassName18("draggable"), children: [
6429
6354
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DrawerItemInner, { name, label, children }) }),
@@ -6448,7 +6373,7 @@ var DrawerItem = ({
6448
6373
  isDragDisabled
6449
6374
  }) => {
6450
6375
  const resolvedId = id || name;
6451
- const [dynamicId, setDynamicId] = (0, import_react37.useState)(generateId(resolvedId));
6376
+ const [dynamicId, setDynamicId] = (0, import_react39.useState)(generateId(resolvedId));
6452
6377
  if (typeof index !== "undefined") {
6453
6378
  console.error(
6454
6379
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -6488,7 +6413,7 @@ var Drawer = ({
6488
6413
  );
6489
6414
  }
6490
6415
  const id = useSafeId();
6491
- const { ref } = useDroppableSafe({
6416
+ const { ref } = (0, import_react40.useDroppable)({
6492
6417
  id,
6493
6418
  type: "void",
6494
6419
  collisionPriority: 0
@@ -6501,6 +6426,7 @@ var Drawer = ({
6501
6426
  ref,
6502
6427
  "data-puck-dnd": id,
6503
6428
  "data-puck-drawer": true,
6429
+ "data-puck-dnd-void": true,
6504
6430
  children
6505
6431
  }
6506
6432
  );
@@ -6509,7 +6435,7 @@ Drawer.Item = DrawerItem;
6509
6435
 
6510
6436
  // components/Puck/index.tsx
6511
6437
  init_react_import();
6512
- var import_react52 = require("react");
6438
+ var import_react56 = require("react");
6513
6439
 
6514
6440
  // components/SidebarSection/index.tsx
6515
6441
  init_react_import();
@@ -6520,7 +6446,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
6520
6446
 
6521
6447
  // lib/use-breadcrumbs.ts
6522
6448
  init_react_import();
6523
- var import_react38 = require("react");
6449
+ var import_react41 = require("react");
6524
6450
  var useBreadcrumbs = (renderCount) => {
6525
6451
  const selectedId = useAppStore((s) => {
6526
6452
  var _a;
@@ -6532,7 +6458,7 @@ var useBreadcrumbs = (renderCount) => {
6532
6458
  return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
6533
6459
  });
6534
6460
  const appStore = useAppStoreApi();
6535
- return (0, import_react38.useMemo)(() => {
6461
+ return (0, import_react41.useMemo)(() => {
6536
6462
  const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
6537
6463
  var _a, _b, _c;
6538
6464
  const [componentId] = zoneCompound.split(":");
@@ -6604,70 +6530,26 @@ var SidebarSection = ({
6604
6530
  );
6605
6531
  };
6606
6532
 
6607
- // components/MenuBar/index.tsx
6608
- init_react_import();
6609
-
6610
- // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
6611
- init_react_import();
6612
- var styles_module_default14 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
6613
-
6614
- // components/MenuBar/index.tsx
6615
- var import_jsx_runtime29 = require("react/jsx-runtime");
6616
- var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
6617
- function MenuBar({
6618
- menuOpen = false,
6619
- renderHeaderActions,
6620
- setMenuOpen
6621
- }) {
6622
- const back = useAppStore((s) => s.history.back);
6623
- const forward = useAppStore((s) => s.history.forward);
6624
- const hasFuture = useAppStore((s) => s.history.hasFuture());
6625
- const hasPast = useAppStore((s) => s.history.hasPast());
6626
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6627
- "div",
6628
- {
6629
- className: getClassName20({ menuOpen }),
6630
- onClick: (event) => {
6631
- var _a;
6632
- const element = event.target;
6633
- if (window.matchMedia("(min-width: 638px)").matches) {
6634
- return;
6635
- }
6636
- if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
6637
- setMenuOpen(false);
6638
- }
6639
- },
6640
- children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("inner"), children: [
6641
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: getClassName20("history"), children: [
6642
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Undo2, { size: 21 }) }),
6643
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Redo2, { size: 21 }) })
6644
- ] }),
6645
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: renderHeaderActions && renderHeaderActions() })
6646
- ] })
6647
- }
6648
- );
6649
- }
6650
-
6651
6533
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
6652
6534
  init_react_import();
6653
- var styles_module_default15 = { "Puck": "_Puck_11o75_19", "Puck-portal": "_Puck-portal_11o75_24", "PuckLayout-inner": "_PuckLayout-inner_11o75_31", "PuckLayout--mounted": "_PuckLayout--mounted_11o75_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_11o75_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_11o75_53", "PuckLayout-mounted": "_PuckLayout-mounted_11o75_67", "PuckLayout": "_PuckLayout_11o75_31", "PuckLayout-header": "_PuckLayout-header_11o75_108", "PuckLayout-headerInner": "_PuckLayout-headerInner_11o75_117", "PuckLayout-headerToggle": "_PuckLayout-headerToggle_11o75_127", "PuckLayout-rightSideBarToggle": "_PuckLayout-rightSideBarToggle_11o75_134", "PuckLayout-leftSideBarToggle": "_PuckLayout-leftSideBarToggle_11o75_135", "PuckLayout-headerTitle": "_PuckLayout-headerTitle_11o75_139", "PuckLayout-headerPath": "_PuckLayout-headerPath_11o75_143", "PuckLayout-headerTools": "_PuckLayout-headerTools_11o75_150", "PuckLayout-menuButton": "_PuckLayout-menuButton_11o75_156", "PuckLayout--menuOpen": "_PuckLayout--menuOpen_11o75_161", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_11o75_135", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_11o75_134" };
6535
+ var styles_module_default14 = { "Puck": "_Puck_mc1k2_19", "Puck-portal": "_Puck-portal_mc1k2_24", "PuckLayout-inner": "_PuckLayout-inner_mc1k2_31", "PuckLayout--mounted": "_PuckLayout--mounted_mc1k2_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_mc1k2_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_mc1k2_53", "PuckLayout-mounted": "_PuckLayout-mounted_mc1k2_67", "PuckLayout": "_PuckLayout_mc1k2_31", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_mc1k2_108", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_mc1k2_117" };
6654
6536
 
6655
6537
  // components/Puck/components/Fields/index.tsx
6656
6538
  init_react_import();
6657
6539
 
6658
6540
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
6659
6541
  init_react_import();
6660
- 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" };
6542
+ var styles_module_default15 = { "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" };
6661
6543
 
6662
6544
  // components/Puck/components/Fields/index.tsx
6663
- var import_react39 = require("react");
6545
+ var import_react42 = require("react");
6664
6546
  var import_shallow4 = require("zustand/react/shallow");
6665
- var import_jsx_runtime30 = require("react/jsx-runtime");
6666
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
6547
+ var import_jsx_runtime29 = require("react/jsx-runtime");
6548
+ var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
6667
6549
  var DefaultFields = ({
6668
6550
  children
6669
6551
  }) => {
6670
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
6552
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children });
6671
6553
  };
6672
6554
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
6673
6555
  let currentProps;
@@ -6733,12 +6615,12 @@ var FieldsChild = ({ fieldName }) => {
6733
6615
  })
6734
6616
  );
6735
6617
  const appStore = useAppStoreApi();
6736
- const onChange = (0, import_react39.useCallback)(createOnChange(fieldName, appStore), [
6618
+ const onChange = (0, import_react42.useCallback)(createOnChange(fieldName, appStore), [
6737
6619
  fieldName
6738
6620
  ]);
6739
6621
  if (!field || !id) return null;
6740
6622
  if (field.type === "slot") return null;
6741
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6623
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("field"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6742
6624
  AutoFieldPrivate,
6743
6625
  {
6744
6626
  field,
@@ -6750,7 +6632,8 @@ var FieldsChild = ({ fieldName }) => {
6750
6632
  }
6751
6633
  ) }, id);
6752
6634
  };
6753
- var Fields = ({ wrapFields = true }) => {
6635
+ var FieldsChildMemo = (0, import_react42.memo)(FieldsChild);
6636
+ var FieldsInternal = ({ wrapFields = true }) => {
6754
6637
  const overrides = useAppStore((s) => s.overrides);
6755
6638
  const componentResolving = useAppStore((s) => {
6756
6639
  var _a, _b;
@@ -6766,42 +6649,48 @@ var Fields = ({ wrapFields = true }) => {
6766
6649
  useRegisterFieldsSlice(appStore, id);
6767
6650
  const fieldsLoading = useAppStore((s) => s.fields.loading);
6768
6651
  const fieldNames = useAppStore(
6769
- (0, import_shallow4.useShallow)((s) => Object.keys(s.fields.fields))
6652
+ (0, import_shallow4.useShallow)((s) => {
6653
+ if (s.fields.id === id) {
6654
+ return Object.keys(s.fields.fields);
6655
+ }
6656
+ return [];
6657
+ })
6770
6658
  );
6771
6659
  const isLoading = fieldsLoading || componentResolving;
6772
- const Wrapper = (0, import_react39.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6773
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
6660
+ const Wrapper = (0, import_react42.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6661
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
6774
6662
  "form",
6775
6663
  {
6776
- className: getClassName21({ wrapFields }),
6664
+ className: getClassName20({ wrapFields }),
6777
6665
  onSubmit: (e) => {
6778
6666
  e.preventDefault();
6779
6667
  },
6780
6668
  children: [
6781
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(FieldsChild, { fieldName }, fieldName)) }),
6782
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Loader, { size: 16 }) }) })
6669
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(FieldsChildMemo, { fieldName }, fieldName)) }),
6670
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getClassName20("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Loader, { size: 16 }) }) })
6783
6671
  ]
6784
6672
  }
6785
6673
  );
6786
6674
  };
6675
+ var Fields = (0, import_react42.memo)(FieldsInternal);
6787
6676
 
6788
6677
  // components/Puck/components/Components/index.tsx
6789
6678
  init_react_import();
6790
6679
 
6791
6680
  // lib/use-component-list.tsx
6792
6681
  init_react_import();
6793
- var import_react40 = require("react");
6682
+ var import_react43 = require("react");
6794
6683
 
6795
6684
  // components/ComponentList/index.tsx
6796
6685
  init_react_import();
6797
6686
 
6798
6687
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
6799
6688
  init_react_import();
6800
- var styles_module_default17 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
6689
+ var styles_module_default16 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
6801
6690
 
6802
6691
  // components/ComponentList/index.tsx
6803
- var import_jsx_runtime31 = require("react/jsx-runtime");
6804
- var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
6692
+ var import_jsx_runtime30 = require("react/jsx-runtime");
6693
+ var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default16);
6805
6694
  var ComponentListItem = ({
6806
6695
  name,
6807
6696
  label
@@ -6812,7 +6701,7 @@ var ComponentListItem = ({
6812
6701
  type: name
6813
6702
  }).insert
6814
6703
  );
6815
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6704
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6816
6705
  };
6817
6706
  var ComponentList = ({
6818
6707
  children,
@@ -6823,12 +6712,12 @@ var ComponentList = ({
6823
6712
  const setUi = useAppStore((s) => s.setUi);
6824
6713
  const componentList = useAppStore((s) => s.state.ui.componentList);
6825
6714
  const { expanded = true } = componentList[id] || {};
6826
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassName22({ isExpanded: expanded }), children: [
6827
- title && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
6715
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: getClassName21({ isExpanded: expanded }), children: [
6716
+ title && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
6828
6717
  "button",
6829
6718
  {
6830
6719
  type: "button",
6831
- className: getClassName22("title"),
6720
+ className: getClassName21("title"),
6832
6721
  onClick: () => setUi({
6833
6722
  componentList: __spreadProps(__spreadValues({}, componentList), {
6834
6723
  [id]: __spreadProps(__spreadValues({}, componentList[id]), {
@@ -6838,14 +6727,14 @@ var ComponentList = ({
6838
6727
  }),
6839
6728
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
6840
6729
  children: [
6841
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { children: title }),
6842
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronDown, { size: 12 }) })
6730
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { children: title }),
6731
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("titleIcon"), children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronUp, { size: 12 }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ChevronDown, { size: 12 }) })
6843
6732
  ]
6844
6733
  }
6845
6734
  ),
6846
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("content"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6735
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName21("content"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6847
6736
  var _a;
6848
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6737
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6849
6738
  ComponentListItem,
6850
6739
  {
6851
6740
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -6859,12 +6748,12 @@ var ComponentList = ({
6859
6748
  ComponentList.Item = ComponentListItem;
6860
6749
 
6861
6750
  // lib/use-component-list.tsx
6862
- var import_jsx_runtime32 = require("react/jsx-runtime");
6751
+ var import_jsx_runtime31 = require("react/jsx-runtime");
6863
6752
  var useComponentList = () => {
6864
- const [componentList, setComponentList] = (0, import_react40.useState)();
6753
+ const [componentList, setComponentList] = (0, import_react43.useState)();
6865
6754
  const config = useAppStore((s) => s.config);
6866
6755
  const uiComponentList = useAppStore((s) => s.state.ui.componentList);
6867
- (0, import_react40.useEffect)(() => {
6756
+ (0, import_react43.useEffect)(() => {
6868
6757
  var _a, _b, _c;
6869
6758
  if (Object.keys(uiComponentList).length > 0) {
6870
6759
  const matchedComponents = [];
@@ -6874,7 +6763,7 @@ var useComponentList = () => {
6874
6763
  if (category.visible === false || !category.components) {
6875
6764
  return null;
6876
6765
  }
6877
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6766
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6878
6767
  ComponentList,
6879
6768
  {
6880
6769
  id: categoryKey,
@@ -6883,7 +6772,7 @@ var useComponentList = () => {
6883
6772
  var _a2;
6884
6773
  matchedComponents.push(componentName);
6885
6774
  const componentConf = config.components[componentName] || {};
6886
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6775
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6887
6776
  ComponentList.Item,
6888
6777
  {
6889
6778
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -6903,7 +6792,7 @@ var useComponentList = () => {
6903
6792
  );
6904
6793
  if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
6905
6794
  _componentList.push(
6906
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6795
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6907
6796
  ComponentList,
6908
6797
  {
6909
6798
  id: "other",
@@ -6911,7 +6800,7 @@ var useComponentList = () => {
6911
6800
  children: remainingComponents.map((componentName, i) => {
6912
6801
  var _a2;
6913
6802
  const componentConf = config.components[componentName] || {};
6914
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6803
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6915
6804
  ComponentList.Item,
6916
6805
  {
6917
6806
  name: componentName,
@@ -6933,25 +6822,25 @@ var useComponentList = () => {
6933
6822
  };
6934
6823
 
6935
6824
  // components/Puck/components/Components/index.tsx
6936
- var import_react41 = require("react");
6937
- var import_jsx_runtime33 = require("react/jsx-runtime");
6825
+ var import_react44 = require("react");
6826
+ var import_jsx_runtime32 = require("react/jsx-runtime");
6938
6827
  var Components = () => {
6939
6828
  const overrides = useAppStore((s) => s.overrides);
6940
6829
  const componentList = useComponentList();
6941
- const Wrapper = (0, import_react41.useMemo)(() => overrides.components || "div", [overrides]);
6942
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ComponentList, { id: "all" }) });
6830
+ const Wrapper = (0, import_react44.useMemo)(() => overrides.components || "div", [overrides]);
6831
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) });
6943
6832
  };
6944
6833
 
6945
6834
  // components/Puck/components/Preview/index.tsx
6946
6835
  init_react_import();
6947
- var import_react43 = require("react");
6836
+ var import_react46 = require("react");
6948
6837
 
6949
6838
  // components/AutoFrame/index.tsx
6950
6839
  init_react_import();
6951
- var import_react42 = require("react");
6840
+ var import_react45 = require("react");
6952
6841
  var import_object_hash = __toESM(require("object-hash"));
6953
6842
  var import_react_dom3 = require("react-dom");
6954
- var import_jsx_runtime34 = require("react/jsx-runtime");
6843
+ var import_jsx_runtime33 = require("react/jsx-runtime");
6955
6844
  var styleSelector = 'style, link[rel="stylesheet"]';
6956
6845
  var collectStyles = (doc) => {
6957
6846
  const collected = [];
@@ -6994,7 +6883,7 @@ var CopyHostStyles = ({
6994
6883
  onStylesLoaded = () => null
6995
6884
  }) => {
6996
6885
  const { document: doc, window: win } = useFrame();
6997
- (0, import_react42.useEffect)(() => {
6886
+ (0, import_react45.useEffect)(() => {
6998
6887
  if (!win || !doc) {
6999
6888
  return () => {
7000
6889
  };
@@ -7151,10 +7040,10 @@ var CopyHostStyles = ({
7151
7040
  observer.disconnect();
7152
7041
  };
7153
7042
  }, []);
7154
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children });
7043
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
7155
7044
  };
7156
- var autoFrameContext = (0, import_react42.createContext)({});
7157
- var useFrame = () => (0, import_react42.useContext)(autoFrameContext);
7045
+ var autoFrameContext = (0, import_react45.createContext)({});
7046
+ var useFrame = () => (0, import_react45.useContext)(autoFrameContext);
7158
7047
  function AutoFrame(_a) {
7159
7048
  var _b = _a, {
7160
7049
  children,
@@ -7175,11 +7064,11 @@ function AutoFrame(_a) {
7175
7064
  "onNotReady",
7176
7065
  "frameRef"
7177
7066
  ]);
7178
- const [loaded, setLoaded] = (0, import_react42.useState)(false);
7179
- const [ctx, setCtx] = (0, import_react42.useState)({});
7180
- const [mountTarget, setMountTarget] = (0, import_react42.useState)();
7181
- const [stylesLoaded, setStylesLoaded] = (0, import_react42.useState)(false);
7182
- (0, import_react42.useEffect)(() => {
7067
+ const [loaded, setLoaded] = (0, import_react45.useState)(false);
7068
+ const [ctx, setCtx] = (0, import_react45.useState)({});
7069
+ const [mountTarget, setMountTarget] = (0, import_react45.useState)();
7070
+ const [stylesLoaded, setStylesLoaded] = (0, import_react45.useState)(false);
7071
+ (0, import_react45.useEffect)(() => {
7183
7072
  var _a2;
7184
7073
  if (frameRef.current) {
7185
7074
  const doc = frameRef.current.contentDocument;
@@ -7198,7 +7087,7 @@ function AutoFrame(_a) {
7198
7087
  }
7199
7088
  }
7200
7089
  }, [frameRef, loaded, stylesLoaded]);
7201
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7090
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7202
7091
  "iframe",
7203
7092
  __spreadProps(__spreadValues({}, props), {
7204
7093
  className,
@@ -7208,7 +7097,7 @@ function AutoFrame(_a) {
7208
7097
  onLoad: () => {
7209
7098
  setLoaded(true);
7210
7099
  },
7211
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7100
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7212
7101
  CopyHostStyles,
7213
7102
  {
7214
7103
  debug,
@@ -7224,14 +7113,14 @@ var AutoFrame_default = AutoFrame;
7224
7113
 
7225
7114
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
7226
7115
  init_react_import();
7227
- var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7116
+ var styles_module_default17 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7228
7117
 
7229
7118
  // components/Puck/components/Preview/index.tsx
7230
- var import_jsx_runtime35 = require("react/jsx-runtime");
7231
- var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
7119
+ var import_jsx_runtime34 = require("react/jsx-runtime");
7120
+ var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
7232
7121
  var useBubbleIframeEvents = (ref) => {
7233
7122
  const status = useAppStore((s) => s.status);
7234
- (0, import_react43.useEffect)(() => {
7123
+ (0, import_react46.useEffect)(() => {
7235
7124
  if (ref.current && status === "READY") {
7236
7125
  const iframe = ref.current;
7237
7126
  const handlePointerMove = (event) => {
@@ -7269,7 +7158,7 @@ var useBubbleIframeEvents = (ref) => {
7269
7158
  }
7270
7159
  }, [status]);
7271
7160
  };
7272
- var Preview3 = ({ id = "puck-preview" }) => {
7161
+ var Preview2 = ({ id = "puck-preview" }) => {
7273
7162
  const dispatch = useAppStore((s) => s.dispatch);
7274
7163
  const root = useAppStore((s) => s.state.data.root);
7275
7164
  const config = useAppStore((s) => s.config);
@@ -7280,22 +7169,22 @@ var Preview3 = ({ id = "puck-preview" }) => {
7280
7169
  const renderData = useAppStore(
7281
7170
  (s) => s.state.ui.previewMode === "edit" ? null : s.state.data
7282
7171
  );
7283
- const Page = (0, import_react43.useCallback)(
7172
+ const Page = (0, import_react46.useCallback)(
7284
7173
  (pageProps) => {
7285
7174
  var _a, _b;
7286
7175
  const rootConfig = config.root;
7287
7176
  const propsWithSlots = useSlots(rootConfig, pageProps, DropZoneEditPure);
7288
7177
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
7289
7178
  id: "puck-root"
7290
- }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: propsWithSlots.children });
7179
+ }, propsWithSlots)) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children: propsWithSlots.children });
7291
7180
  },
7292
7181
  [config.root]
7293
7182
  );
7294
- const Frame = (0, import_react43.useMemo)(() => overrides.iframe, [overrides]);
7183
+ const Frame = (0, import_react46.useMemo)(() => overrides.iframe, [overrides]);
7295
7184
  const rootProps = root.props || root;
7296
- const ref = (0, import_react43.useRef)(null);
7185
+ const ref = (0, import_react46.useRef)(null);
7297
7186
  useBubbleIframeEvents(ref);
7298
- const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7187
+ const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7299
7188
  Page,
7300
7189
  __spreadProps(__spreadValues({}, rootProps), {
7301
7190
  puck: {
@@ -7305,28 +7194,28 @@ var Preview3 = ({ id = "puck-preview" }) => {
7305
7194
  metadata
7306
7195
  },
7307
7196
  editMode: true,
7308
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DropZonePure, { zone: rootDroppableId })
7197
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
7309
7198
  })
7310
- ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Render, { data: renderData, config });
7311
- (0, import_react43.useEffect)(() => {
7199
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config });
7200
+ (0, import_react46.useEffect)(() => {
7312
7201
  if (!iframe.enabled) {
7313
7202
  setStatus("READY");
7314
7203
  }
7315
7204
  }, [iframe.enabled]);
7316
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7205
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7317
7206
  "div",
7318
7207
  {
7319
- className: getClassName23(),
7208
+ className: getClassName22(),
7320
7209
  id,
7321
7210
  "data-puck-preview": true,
7322
7211
  onClick: () => {
7323
7212
  dispatch({ type: "setUi", ui: { itemSelector: null } });
7324
7213
  },
7325
- children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7214
+ children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7326
7215
  AutoFrame_default,
7327
7216
  {
7328
7217
  id: "preview-frame",
7329
- className: getClassName23("frame"),
7218
+ className: getClassName22("frame"),
7330
7219
  "data-rfd-iframe": true,
7331
7220
  onReady: () => {
7332
7221
  setStatus("READY");
@@ -7335,18 +7224,18 @@ var Preview3 = ({ id = "puck-preview" }) => {
7335
7224
  setStatus("MOUNTED");
7336
7225
  },
7337
7226
  frameRef: ref,
7338
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7227
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7339
7228
  if (Frame) {
7340
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Frame, { document: document2, children: inner });
7229
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Frame, { document: document2, children: inner });
7341
7230
  }
7342
7231
  return inner;
7343
7232
  } })
7344
7233
  }
7345
- ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7234
+ ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7346
7235
  "div",
7347
7236
  {
7348
7237
  id: "preview-frame",
7349
- className: getClassName23("frame"),
7238
+ className: getClassName22("frame"),
7350
7239
  ref,
7351
7240
  "data-puck-entry": true,
7352
7241
  children: inner
@@ -7364,7 +7253,7 @@ init_react_import();
7364
7253
 
7365
7254
  // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
7366
7255
  init_react_import();
7367
- var styles_module_default19 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
7256
+ var styles_module_default18 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
7368
7257
 
7369
7258
  // lib/scroll-into-view.ts
7370
7259
  init_react_import();
@@ -7378,7 +7267,7 @@ var scrollIntoView = (el) => {
7378
7267
  };
7379
7268
 
7380
7269
  // components/LayerTree/index.tsx
7381
- var import_react44 = require("react");
7270
+ var import_react47 = require("react");
7382
7271
 
7383
7272
  // lib/on-scroll-end.ts
7384
7273
  init_react_import();
@@ -7401,20 +7290,20 @@ var onScrollEnd = (frame, cb) => {
7401
7290
 
7402
7291
  // components/LayerTree/index.tsx
7403
7292
  var import_shallow5 = require("zustand/react/shallow");
7404
- var import_jsx_runtime36 = require("react/jsx-runtime");
7405
- var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
7406
- var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
7293
+ var import_jsx_runtime35 = require("react/jsx-runtime");
7294
+ var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
7295
+ var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
7407
7296
  var Layer = ({
7408
7297
  index,
7409
7298
  itemId,
7410
7299
  zoneCompound
7411
7300
  }) => {
7412
7301
  var _a;
7413
- const ctx = (0, import_react44.useContext)(dropZoneContext);
7302
+ const ctx = (0, import_react47.useContext)(dropZoneContext);
7414
7303
  const config = useAppStore((s) => s.config);
7415
7304
  const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
7416
7305
  const dispatch = useAppStore((s) => s.dispatch);
7417
- const setItemSelector = (0, import_react44.useCallback)(
7306
+ const setItemSelector = (0, import_react47.useCallback)(
7418
7307
  (itemSelector2) => {
7419
7308
  dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
7420
7309
  },
@@ -7434,9 +7323,11 @@ var Layer = ({
7434
7323
  )
7435
7324
  );
7436
7325
  const containsZone = zonesForItem.length > 0;
7437
- const { setHoveringComponent = () => {
7438
- }, hoveringComponent } = ctx || {};
7439
- const isHovering = hoveringComponent === itemId;
7326
+ const zoneStore = (0, import_react47.useContext)(ZoneStoreContext);
7327
+ const isHovering = useContextStore(
7328
+ ZoneStoreContext,
7329
+ (s) => s.hoveringComponent === itemId
7330
+ );
7440
7331
  const childIsSelected = useAppStore((s) => {
7441
7332
  var _a2, _b;
7442
7333
  const selectedData = s.state.indexes.nodes[(_a2 = s.selectedItem) == null ? void 0 : _a2.props.id];
@@ -7447,7 +7338,7 @@ var Layer = ({
7447
7338
  });
7448
7339
  const componentConfig = config.components[nodeData.data.type];
7449
7340
  const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
7450
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
7341
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
7451
7342
  "li",
7452
7343
  {
7453
7344
  className: getClassNameLayer({
@@ -7457,7 +7348,7 @@ var Layer = ({
7457
7348
  childIsSelected
7458
7349
  }),
7459
7350
  children: [
7460
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
7351
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
7461
7352
  "button",
7462
7353
  {
7463
7354
  type: "button",
@@ -7483,31 +7374,31 @@ var Layer = ({
7483
7374
  });
7484
7375
  });
7485
7376
  },
7486
- onMouseOver: (e) => {
7377
+ onMouseEnter: (e) => {
7487
7378
  e.stopPropagation();
7488
- setHoveringComponent(itemId);
7379
+ zoneStore.setState({ hoveringComponent: itemId });
7489
7380
  },
7490
- onMouseOut: (e) => {
7381
+ onMouseLeave: (e) => {
7491
7382
  e.stopPropagation();
7492
- setHoveringComponent(null);
7383
+ zoneStore.setState({ hoveringComponent: null });
7493
7384
  },
7494
7385
  children: [
7495
- containsZone && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7386
+ containsZone && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7496
7387
  "div",
7497
7388
  {
7498
7389
  className: getClassNameLayer("chevron"),
7499
7390
  title: isSelected ? "Collapse" : "Expand",
7500
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ChevronDown, { size: "12" })
7391
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ChevronDown, { size: "12" })
7501
7392
  }
7502
7393
  ),
7503
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassNameLayer("title"), children: [
7504
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayoutGrid, { size: "16" }) }),
7505
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("name"), children: label })
7394
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassNameLayer("title"), children: [
7395
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(LayoutGrid, { size: "16" }) }),
7396
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("name"), children: label })
7506
7397
  ] })
7507
7398
  ]
7508
7399
  }
7509
7400
  ) }),
7510
- containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
7401
+ containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
7511
7402
  ]
7512
7403
  }
7513
7404
  );
@@ -7525,15 +7416,15 @@ var LayerTree = ({
7525
7416
  }
7526
7417
  )
7527
7418
  );
7528
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
7529
- label && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
7530
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Layers, { size: "16" }) }),
7419
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
7420
+ label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName23("zoneTitle"), children: [
7421
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
7531
7422
  label
7532
7423
  ] }),
7533
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("ul", { className: getClassName24(), children: [
7534
- contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: getClassName24("helper"), children: "No items" }),
7424
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName23(), children: [
7425
+ contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("helper"), children: "No items" }),
7535
7426
  contentIds.map((itemId, i) => {
7536
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7427
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
7537
7428
  Layer,
7538
7429
  {
7539
7430
  index: i,
@@ -7548,7 +7439,7 @@ var LayerTree = ({
7548
7439
  };
7549
7440
 
7550
7441
  // components/Puck/components/Outline/index.tsx
7551
- var import_react45 = require("react");
7442
+ var import_react48 = require("react");
7552
7443
 
7553
7444
  // lib/data/find-zones-for-area.ts
7554
7445
  init_react_import();
@@ -7560,14 +7451,14 @@ var findZonesForArea = (state, area) => {
7560
7451
 
7561
7452
  // components/Puck/components/Outline/index.tsx
7562
7453
  var import_shallow6 = require("zustand/react/shallow");
7563
- var import_jsx_runtime37 = require("react/jsx-runtime");
7454
+ var import_jsx_runtime36 = require("react/jsx-runtime");
7564
7455
  var Outline = () => {
7565
7456
  const outlineOverride = useAppStore((s) => s.overrides.outline);
7566
7457
  const rootZones = useAppStore(
7567
7458
  (0, import_shallow6.useShallow)((s) => findZonesForArea(s.state, "root"))
7568
7459
  );
7569
- const Wrapper = (0, import_react45.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7570
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7460
+ const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7461
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
7571
7462
  LayerTree,
7572
7463
  {
7573
7464
  label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
@@ -7700,25 +7591,25 @@ var getBox = function getBox2(el) {
7700
7591
  };
7701
7592
 
7702
7593
  // components/Puck/components/Canvas/index.tsx
7703
- var import_react47 = require("react");
7594
+ var import_react50 = require("react");
7704
7595
 
7705
7596
  // components/ViewportControls/index.tsx
7706
7597
  init_react_import();
7707
- var import_react46 = require("react");
7598
+ var import_react49 = require("react");
7708
7599
 
7709
7600
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7710
7601
  init_react_import();
7711
- var styles_module_default20 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
7602
+ var styles_module_default19 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
7712
7603
 
7713
7604
  // components/ViewportControls/index.tsx
7714
- var import_jsx_runtime38 = require("react/jsx-runtime");
7605
+ var import_jsx_runtime37 = require("react/jsx-runtime");
7715
7606
  var icons = {
7716
- Smartphone: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Smartphone, { size: 16 }),
7717
- Tablet: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Tablet, { size: 16 }),
7718
- Monitor: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Monitor, { size: 16 })
7607
+ Smartphone: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Smartphone, { size: 16 }),
7608
+ Tablet: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Tablet, { size: 16 }),
7609
+ Monitor: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Monitor, { size: 16 })
7719
7610
  };
7720
- var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
7721
- var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
7611
+ var getClassName24 = get_class_name_factory_default("ViewportControls", styles_module_default19);
7612
+ var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default19);
7722
7613
  var ViewportButton = ({
7723
7614
  children,
7724
7615
  height = "auto",
@@ -7727,11 +7618,11 @@ var ViewportButton = ({
7727
7618
  onClick
7728
7619
  }) => {
7729
7620
  const viewports = useAppStore((s) => s.state.ui.viewports);
7730
- const [isActive, setIsActive] = (0, import_react46.useState)(false);
7731
- (0, import_react46.useEffect)(() => {
7621
+ const [isActive, setIsActive] = (0, import_react49.useState)(false);
7622
+ (0, import_react49.useEffect)(() => {
7732
7623
  setIsActive(width === viewports.current.width);
7733
7624
  }, [width, viewports.current.width]);
7734
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7625
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7735
7626
  IconButton,
7736
7627
  {
7737
7628
  title,
@@ -7740,7 +7631,7 @@ var ViewportButton = ({
7740
7631
  e.stopPropagation();
7741
7632
  onClick({ width, height });
7742
7633
  },
7743
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: getClassNameButton("inner"), children })
7634
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton("inner"), children })
7744
7635
  }
7745
7636
  ) });
7746
7637
  };
@@ -7764,7 +7655,7 @@ var ViewportControls = ({
7764
7655
  const defaultsContainAutoZoom = defaultZoomOptions.find(
7765
7656
  (option) => option.value === autoZoom
7766
7657
  );
7767
- const zoomOptions = (0, import_react46.useMemo)(
7658
+ const zoomOptions = (0, import_react49.useMemo)(
7768
7659
  () => [
7769
7660
  ...defaultZoomOptions,
7770
7661
  ...defaultsContainAutoZoom ? [] : [
@@ -7776,8 +7667,8 @@ var ViewportControls = ({
7776
7667
  ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
7777
7668
  [autoZoom]
7778
7669
  );
7779
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25(), children: [
7780
- viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7670
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName24(), children: [
7671
+ viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7781
7672
  ViewportButton,
7782
7673
  {
7783
7674
  height: viewport.height,
@@ -7788,8 +7679,8 @@ var ViewportControls = ({
7788
7679
  },
7789
7680
  i
7790
7681
  )),
7791
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
7792
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7682
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("divider") }),
7683
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7793
7684
  IconButton,
7794
7685
  {
7795
7686
  title: "Zoom viewport out",
@@ -7803,10 +7694,10 @@ var ViewportControls = ({
7803
7694
  )].value
7804
7695
  );
7805
7696
  },
7806
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomOut, { size: 16 })
7697
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ZoomOut, { size: 16 })
7807
7698
  }
7808
7699
  ),
7809
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7700
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7810
7701
  IconButton,
7811
7702
  {
7812
7703
  title: "Zoom viewport in",
@@ -7820,19 +7711,19 @@ var ViewportControls = ({
7820
7711
  )].value
7821
7712
  );
7822
7713
  },
7823
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ZoomIn, { size: 16 })
7714
+ children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ZoomIn, { size: 16 })
7824
7715
  }
7825
7716
  ),
7826
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("divider") }),
7827
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7717
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName24("divider") }),
7718
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7828
7719
  "select",
7829
7720
  {
7830
- className: getClassName25("zoomSelect"),
7721
+ className: getClassName24("zoomSelect"),
7831
7722
  value: zoom.toString(),
7832
7723
  onChange: (e) => {
7833
7724
  onZoom(parseFloat(e.currentTarget.value));
7834
7725
  },
7835
- children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7726
+ children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
7836
7727
  "option",
7837
7728
  {
7838
7729
  value: option.value,
@@ -7847,7 +7738,7 @@ var ViewportControls = ({
7847
7738
 
7848
7739
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
7849
7740
  init_react_import();
7850
- var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
7741
+ var styles_module_default20 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
7851
7742
 
7852
7743
  // lib/get-zoom-config.ts
7853
7744
  init_react_import();
@@ -7881,8 +7772,8 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
7881
7772
 
7882
7773
  // components/Puck/components/Canvas/index.tsx
7883
7774
  var import_shallow7 = require("zustand/react/shallow");
7884
- var import_jsx_runtime39 = require("react/jsx-runtime");
7885
- var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
7775
+ var import_jsx_runtime38 = require("react/jsx-runtime");
7776
+ var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
7886
7777
  var ZOOM_ON_CHANGE = true;
7887
7778
  var Canvas = () => {
7888
7779
  const {
@@ -7911,17 +7802,17 @@ var Canvas = () => {
7911
7802
  viewports: s.state.ui.viewports
7912
7803
  }))
7913
7804
  );
7914
- const frameRef = (0, import_react47.useRef)(null);
7915
- const [showTransition, setShowTransition] = (0, import_react47.useState)(false);
7916
- const defaultRender = (0, import_react47.useMemo)(() => {
7917
- const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
7805
+ const frameRef = (0, import_react50.useRef)(null);
7806
+ const [showTransition, setShowTransition] = (0, import_react50.useState)(false);
7807
+ const defaultRender = (0, import_react50.useMemo)(() => {
7808
+ const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
7918
7809
  return PuckDefault;
7919
7810
  }, []);
7920
- const CustomPreview = (0, import_react47.useMemo)(
7811
+ const CustomPreview = (0, import_react50.useMemo)(
7921
7812
  () => overrides.preview || defaultRender,
7922
7813
  [overrides]
7923
7814
  );
7924
- const getFrameDimensions = (0, import_react47.useCallback)(() => {
7815
+ const getFrameDimensions = (0, import_react50.useCallback)(() => {
7925
7816
  if (frameRef.current) {
7926
7817
  const frame = frameRef.current;
7927
7818
  const box = getBox(frame);
@@ -7929,7 +7820,7 @@ var Canvas = () => {
7929
7820
  }
7930
7821
  return { width: 0, height: 0 };
7931
7822
  }, [frameRef]);
7932
- const resetAutoZoom = (0, import_react47.useCallback)(
7823
+ const resetAutoZoom = (0, import_react50.useCallback)(
7933
7824
  (newViewports = viewports) => {
7934
7825
  if (frameRef.current) {
7935
7826
  setZoomConfig(
@@ -7943,11 +7834,11 @@ var Canvas = () => {
7943
7834
  },
7944
7835
  [frameRef, zoomConfig, viewports]
7945
7836
  );
7946
- (0, import_react47.useEffect)(() => {
7837
+ (0, import_react50.useEffect)(() => {
7947
7838
  setShowTransition(false);
7948
7839
  resetAutoZoom(viewports);
7949
7840
  }, [frameRef, leftSideBarVisible, rightSideBarVisible]);
7950
- (0, import_react47.useEffect)(() => {
7841
+ (0, import_react50.useEffect)(() => {
7951
7842
  const { height: frameHeight } = getFrameDimensions();
7952
7843
  if (viewports.current.height === "auto") {
7953
7844
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -7955,13 +7846,13 @@ var Canvas = () => {
7955
7846
  }));
7956
7847
  }
7957
7848
  }, [zoomConfig.zoom]);
7958
- (0, import_react47.useEffect)(() => {
7849
+ (0, import_react50.useEffect)(() => {
7959
7850
  if (ZOOM_ON_CHANGE) {
7960
7851
  setShowTransition(true);
7961
7852
  resetAutoZoom(viewports);
7962
7853
  }
7963
7854
  }, [viewports.current.width]);
7964
- (0, import_react47.useEffect)(() => {
7855
+ (0, import_react50.useEffect)(() => {
7965
7856
  const cb = () => {
7966
7857
  setShowTransition(false);
7967
7858
  resetAutoZoom();
@@ -7971,16 +7862,16 @@ var Canvas = () => {
7971
7862
  window.removeEventListener("resize", cb);
7972
7863
  };
7973
7864
  }, []);
7974
- const [showLoader, setShowLoader] = (0, import_react47.useState)(false);
7975
- (0, import_react47.useEffect)(() => {
7865
+ const [showLoader, setShowLoader] = (0, import_react50.useState)(false);
7866
+ (0, import_react50.useEffect)(() => {
7976
7867
  setTimeout(() => {
7977
7868
  setShowLoader(true);
7978
7869
  }, 500);
7979
7870
  }, []);
7980
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
7871
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
7981
7872
  "div",
7982
7873
  {
7983
- className: getClassName26({
7874
+ className: getClassName25({
7984
7875
  ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
7985
7876
  showLoader
7986
7877
  }),
@@ -7990,7 +7881,7 @@ var Canvas = () => {
7990
7881
  recordHistory: true
7991
7882
  }),
7992
7883
  children: [
7993
- viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7884
+ viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
7994
7885
  ViewportControls,
7995
7886
  {
7996
7887
  autoZoom: zoomConfig.autoZoom,
@@ -8016,11 +7907,11 @@ var Canvas = () => {
8016
7907
  }
8017
7908
  }
8018
7909
  ) }),
8019
- /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
8020
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
7910
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getClassName25("inner"), ref: frameRef, children: [
7911
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
8021
7912
  "div",
8022
7913
  {
8023
- className: getClassName26("root"),
7914
+ className: getClassName25("root"),
8024
7915
  style: {
8025
7916
  width: iframe.enabled ? viewports.current.width : "100%",
8026
7917
  height: zoomConfig.rootHeight,
@@ -8038,10 +7929,10 @@ var Canvas = () => {
8038
7929
  })
8039
7930
  );
8040
7931
  },
8041
- children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Preview3, {}) })
7932
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Preview2, {}) })
8042
7933
  }
8043
7934
  ),
8044
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Loader, { size: 24 }) })
7935
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getClassName25("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Loader, { size: 24 }) })
8045
7936
  ] })
8046
7937
  ]
8047
7938
  }
@@ -8050,7 +7941,7 @@ var Canvas = () => {
8050
7941
 
8051
7942
  // lib/use-loaded-overrides.ts
8052
7943
  init_react_import();
8053
- var import_react48 = require("react");
7944
+ var import_react51 = require("react");
8054
7945
 
8055
7946
  // lib/load-overrides.ts
8056
7947
  init_react_import();
@@ -8089,26 +7980,26 @@ var useLoadedOverrides = ({
8089
7980
  overrides,
8090
7981
  plugins
8091
7982
  }) => {
8092
- return (0, import_react48.useMemo)(() => {
7983
+ return (0, import_react51.useMemo)(() => {
8093
7984
  return loadOverrides({ overrides, plugins });
8094
7985
  }, [plugins, overrides]);
8095
7986
  };
8096
7987
 
8097
7988
  // components/DefaultOverride/index.tsx
8098
7989
  init_react_import();
8099
- var import_jsx_runtime40 = require("react/jsx-runtime");
8100
- var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children });
7990
+ var import_jsx_runtime39 = require("react/jsx-runtime");
7991
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
8101
7992
 
8102
7993
  // lib/use-inject-css.ts
8103
7994
  init_react_import();
8104
- var import_react49 = require("react");
7995
+ var import_react52 = require("react");
8105
7996
  var styles = ``;
8106
7997
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
8107
- const [el, setEl] = (0, import_react49.useState)();
8108
- (0, import_react49.useEffect)(() => {
7998
+ const [el, setEl] = (0, import_react52.useState)();
7999
+ (0, import_react52.useEffect)(() => {
8109
8000
  setEl(document.createElement("style"));
8110
8001
  }, []);
8111
- (0, import_react49.useEffect)(() => {
8002
+ (0, import_react52.useEffect)(() => {
8112
8003
  var _a;
8113
8004
  if (!el || typeof window === "undefined") {
8114
8005
  return;
@@ -8128,10 +8019,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
8128
8019
 
8129
8020
  // lib/use-preview-mode-hotkeys.ts
8130
8021
  init_react_import();
8131
- var import_react50 = require("react");
8022
+ var import_react53 = require("react");
8132
8023
  var usePreviewModeHotkeys = () => {
8133
8024
  const appStore = useAppStoreApi();
8134
- const toggleInteractive = (0, import_react50.useCallback)(() => {
8025
+ const toggleInteractive = (0, import_react53.useCallback)(() => {
8135
8026
  const dispatch = appStore.getState().dispatch;
8136
8027
  dispatch({
8137
8028
  type: "setUi",
@@ -8146,7 +8037,7 @@ var usePreviewModeHotkeys = () => {
8146
8037
 
8147
8038
  // lib/use-puck.ts
8148
8039
  init_react_import();
8149
- var import_react51 = require("react");
8040
+ var import_react54 = require("react");
8150
8041
  var import_zustand6 = require("zustand");
8151
8042
  var generateUsePuck = (store) => {
8152
8043
  const history = {
@@ -8180,7 +8071,7 @@ var generateUsePuck = (store) => {
8180
8071
  const get = () => storeData;
8181
8072
  return __spreadProps(__spreadValues({}, storeData), { get });
8182
8073
  };
8183
- var UsePuckStoreContext = (0, import_react51.createContext)(
8074
+ var UsePuckStoreContext = (0, import_react54.createContext)(
8184
8075
  null
8185
8076
  );
8186
8077
  var convertToPickedStore = (store) => {
@@ -8194,12 +8085,12 @@ var convertToPickedStore = (store) => {
8194
8085
  };
8195
8086
  };
8196
8087
  var useRegisterUsePuckStore = (appStore) => {
8197
- const [usePuckStore] = (0, import_react51.useState)(
8088
+ const [usePuckStore] = (0, import_react54.useState)(
8198
8089
  () => (0, import_zustand6.createStore)(
8199
8090
  () => generateUsePuck(convertToPickedStore(appStore.getState()))
8200
8091
  )
8201
8092
  );
8202
- (0, import_react51.useEffect)(() => {
8093
+ (0, import_react54.useEffect)(() => {
8203
8094
  return appStore.subscribe(
8204
8095
  (store) => convertToPickedStore(store),
8205
8096
  (pickedStore) => {
@@ -8211,7 +8102,7 @@ var useRegisterUsePuckStore = (appStore) => {
8211
8102
  };
8212
8103
  function createUsePuck() {
8213
8104
  return function usePuck2(selector) {
8214
- const usePuckApi = (0, import_react51.useContext)(UsePuckStoreContext);
8105
+ const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
8215
8106
  if (!usePuckApi) {
8216
8107
  throw new Error("usePuck must be used inside <Puck>.");
8217
8108
  }
@@ -8223,18 +8114,241 @@ function createUsePuck() {
8223
8114
  };
8224
8115
  }
8225
8116
  function usePuck() {
8226
- (0, import_react51.useEffect)(() => {
8117
+ (0, import_react54.useEffect)(() => {
8227
8118
  console.warn(
8228
8119
  "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."
8229
8120
  );
8230
8121
  }, []);
8231
8122
  return createUsePuck()((s) => s);
8232
8123
  }
8124
+ function useGetPuck() {
8125
+ const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
8126
+ if (!usePuckApi) {
8127
+ throw new Error("usePuckGet must be used inside <Puck>.");
8128
+ }
8129
+ return usePuckApi.getState;
8130
+ }
8233
8131
 
8234
8132
  // components/Puck/index.tsx
8133
+ var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
8134
+
8135
+ // components/Puck/components/Header/index.tsx
8136
+ init_react_import();
8137
+ var import_react55 = require("react");
8138
+
8139
+ // components/MenuBar/index.tsx
8140
+ init_react_import();
8141
+
8142
+ // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
8143
+ init_react_import();
8144
+ var styles_module_default21 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
8145
+
8146
+ // components/MenuBar/index.tsx
8147
+ var import_jsx_runtime40 = require("react/jsx-runtime");
8148
+ var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
8149
+ function MenuBar({
8150
+ menuOpen = false,
8151
+ renderHeaderActions,
8152
+ setMenuOpen
8153
+ }) {
8154
+ const back = useAppStore((s) => s.history.back);
8155
+ const forward = useAppStore((s) => s.history.forward);
8156
+ const hasFuture = useAppStore((s) => s.history.hasFuture());
8157
+ const hasPast = useAppStore((s) => s.history.hasPast());
8158
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
8159
+ "div",
8160
+ {
8161
+ className: getClassName26({ menuOpen }),
8162
+ onClick: (event) => {
8163
+ var _a;
8164
+ const element = event.target;
8165
+ if (window.matchMedia("(min-width: 638px)").matches) {
8166
+ return;
8167
+ }
8168
+ if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
8169
+ setMenuOpen(false);
8170
+ }
8171
+ },
8172
+ children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("inner"), children: [
8173
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getClassName26("history"), children: [
8174
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Undo2, { size: 21 }) }),
8175
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Redo2, { size: 21 }) })
8176
+ ] }),
8177
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children: renderHeaderActions && renderHeaderActions() })
8178
+ ] })
8179
+ }
8180
+ );
8181
+ }
8182
+
8183
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
8184
+ init_react_import();
8185
+ var styles_module_default22 = { "PuckHeader": "_PuckHeader_15xnq_1", "PuckHeader-inner": "_PuckHeader-inner_15xnq_10", "PuckHeader-toggle": "_PuckHeader-toggle_15xnq_20", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_15xnq_27", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_15xnq_27", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_15xnq_28", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_15xnq_28", "PuckHeader-title": "_PuckHeader-title_15xnq_32", "PuckHeader-path": "_PuckHeader-path_15xnq_36", "PuckHeader-tools": "_PuckHeader-tools_15xnq_43", "PuckHeader-menuButton": "_PuckHeader-menuButton_15xnq_49", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_15xnq_54" };
8186
+
8187
+ // components/Puck/components/Header/index.tsx
8235
8188
  var import_jsx_runtime41 = require("react/jsx-runtime");
8236
- var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
8237
- var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
8189
+ var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
8190
+ var HeaderInner = () => {
8191
+ const {
8192
+ onPublish,
8193
+ renderHeader,
8194
+ renderHeaderActions,
8195
+ headerTitle,
8196
+ headerPath,
8197
+ iframe: _iframe
8198
+ } = usePropsContext();
8199
+ const dispatch = useAppStore((s) => s.dispatch);
8200
+ const appStore = useAppStoreApi();
8201
+ const defaultHeaderRender = (0, import_react55.useMemo)(() => {
8202
+ if (renderHeader) {
8203
+ console.warn(
8204
+ "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
8205
+ );
8206
+ const RenderHeader = (_a) => {
8207
+ var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8208
+ const Comp = renderHeader;
8209
+ const appState = useAppStore((s) => s.state);
8210
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8211
+ };
8212
+ return RenderHeader;
8213
+ }
8214
+ return DefaultOverride;
8215
+ }, [renderHeader]);
8216
+ const defaultHeaderActionsRender = (0, import_react55.useMemo)(() => {
8217
+ if (renderHeaderActions) {
8218
+ console.warn(
8219
+ "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
8220
+ );
8221
+ const RenderHeader = (props) => {
8222
+ const Comp = renderHeaderActions;
8223
+ const appState = useAppStore((s) => s.state);
8224
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8225
+ };
8226
+ return RenderHeader;
8227
+ }
8228
+ return DefaultOverride;
8229
+ }, [renderHeader]);
8230
+ const CustomHeader = useAppStore(
8231
+ (s) => s.overrides.header || defaultHeaderRender
8232
+ );
8233
+ const CustomHeaderActions = useAppStore(
8234
+ (s) => s.overrides.headerActions || defaultHeaderActionsRender
8235
+ );
8236
+ const [menuOpen, setMenuOpen] = (0, import_react55.useState)(false);
8237
+ const rootTitle = useAppStore((s) => {
8238
+ var _a, _b;
8239
+ const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
8240
+ return (_b = rootData.props.title) != null ? _b : "";
8241
+ });
8242
+ const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8243
+ const rightSideBarVisible = useAppStore(
8244
+ (s) => s.state.ui.rightSideBarVisible
8245
+ );
8246
+ const toggleSidebars = (0, import_react55.useCallback)(
8247
+ (sidebar) => {
8248
+ const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8249
+ const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
8250
+ const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
8251
+ dispatch({
8252
+ type: "setUi",
8253
+ ui: __spreadValues({
8254
+ [`${sidebar}SideBarVisible`]: !sideBarVisible
8255
+ }, !widerViewport ? { [oppositeSideBar]: false } : {})
8256
+ });
8257
+ },
8258
+ [dispatch, leftSideBarVisible, rightSideBarVisible]
8259
+ );
8260
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8261
+ CustomHeader,
8262
+ {
8263
+ actions: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8264
+ Button,
8265
+ {
8266
+ onClick: () => {
8267
+ const data = appStore.getState().state.data;
8268
+ onPublish && onPublish(data);
8269
+ },
8270
+ icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8271
+ children: "Publish"
8272
+ }
8273
+ ) }) }),
8274
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8275
+ "header",
8276
+ {
8277
+ className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
8278
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("inner"), children: [
8279
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("toggle"), children: [
8280
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8281
+ IconButton,
8282
+ {
8283
+ onClick: () => {
8284
+ toggleSidebars("left");
8285
+ },
8286
+ title: "Toggle left sidebar",
8287
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelLeft, { focusable: "false" })
8288
+ }
8289
+ ) }),
8290
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8291
+ IconButton,
8292
+ {
8293
+ onClick: () => {
8294
+ toggleSidebars("right");
8295
+ },
8296
+ title: "Toggle right sidebar",
8297
+ children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelRight, { focusable: "false" })
8298
+ }
8299
+ ) })
8300
+ ] }),
8301
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("title"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Heading, { rank: "2", size: "xs", children: [
8302
+ headerTitle || rootTitle || "Page",
8303
+ headerPath && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
8304
+ " ",
8305
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("code", { className: getClassName27("path"), children: headerPath })
8306
+ ] })
8307
+ ] }) }),
8308
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName27("tools"), children: [
8309
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8310
+ IconButton,
8311
+ {
8312
+ onClick: () => {
8313
+ return setMenuOpen(!menuOpen);
8314
+ },
8315
+ title: "Toggle menu bar",
8316
+ children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
8317
+ }
8318
+ ) }),
8319
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8320
+ MenuBar,
8321
+ {
8322
+ dispatch,
8323
+ onPublish,
8324
+ menuOpen,
8325
+ renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8326
+ Button,
8327
+ {
8328
+ onClick: () => {
8329
+ const data = appStore.getState().state.data;
8330
+ onPublish && onPublish(data);
8331
+ },
8332
+ icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8333
+ children: "Publish"
8334
+ }
8335
+ ) }),
8336
+ setMenuOpen
8337
+ }
8338
+ )
8339
+ ] })
8340
+ ] })
8341
+ }
8342
+ )
8343
+ }
8344
+ );
8345
+ };
8346
+ var Header = (0, import_react55.memo)(HeaderInner);
8347
+
8348
+ // components/Puck/index.tsx
8349
+ var import_jsx_runtime42 = require("react/jsx-runtime");
8350
+ var getClassName28 = get_class_name_factory_default("Puck", styles_module_default14);
8351
+ var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
8238
8352
  var FieldSideBar = () => {
8239
8353
  const title = useAppStore(
8240
8354
  (s) => {
@@ -8242,13 +8356,13 @@ var FieldSideBar = () => {
8242
8356
  return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
8243
8357
  }
8244
8358
  );
8245
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Fields, {}) });
8359
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Fields, {}) });
8246
8360
  };
8247
- var propsContext = (0, import_react52.createContext)({});
8361
+ var propsContext = (0, import_react56.createContext)({});
8248
8362
  function PropsProvider(props) {
8249
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(propsContext.Provider, { value: props, children: props.children });
8363
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(propsContext.Provider, { value: props, children: props.children });
8250
8364
  }
8251
- var usePropsContext = () => (0, import_react52.useContext)(propsContext);
8365
+ var usePropsContext = () => (0, import_react56.useContext)(propsContext);
8252
8366
  function PuckProvider({ children }) {
8253
8367
  const {
8254
8368
  config,
@@ -8264,11 +8378,14 @@ function PuckProvider({ children }) {
8264
8378
  metadata,
8265
8379
  onAction
8266
8380
  } = usePropsContext();
8267
- const iframe = __spreadValues({
8268
- enabled: true,
8269
- waitForStyles: true
8270
- }, _iframe);
8271
- const [generatedAppState] = (0, import_react52.useState)(() => {
8381
+ const iframe = (0, import_react56.useMemo)(
8382
+ () => __spreadValues({
8383
+ enabled: true,
8384
+ waitForStyles: true
8385
+ }, _iframe),
8386
+ [_iframe]
8387
+ );
8388
+ const [generatedAppState] = (0, import_react56.useState)(() => {
8272
8389
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
8273
8390
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
8274
8391
  let clientUiState = {};
@@ -8328,7 +8445,7 @@ function PuckProvider({ children }) {
8328
8445
  return walkAppState(newAppState, config);
8329
8446
  });
8330
8447
  const { appendData = true } = _initialHistory || {};
8331
- const [blendedHistories] = (0, import_react52.useState)(
8448
+ const [blendedHistories] = (0, import_react56.useState)(
8332
8449
  [
8333
8450
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
8334
8451
  ...appendData ? [{ state: generatedAppState }] : []
@@ -8348,7 +8465,7 @@ function PuckProvider({ children }) {
8348
8465
  overrides,
8349
8466
  plugins
8350
8467
  });
8351
- const generateAppStore = (0, import_react52.useCallback)(
8468
+ const generateAppStore = (0, import_react56.useCallback)(
8352
8469
  (state) => {
8353
8470
  return {
8354
8471
  state,
@@ -8372,10 +8489,10 @@ function PuckProvider({ children }) {
8372
8489
  metadata
8373
8490
  ]
8374
8491
  );
8375
- const [appStore] = (0, import_react52.useState)(
8492
+ const [appStore] = (0, import_react56.useState)(
8376
8493
  () => createAppStore(generateAppStore(initialAppState))
8377
8494
  );
8378
- (0, import_react52.useEffect)(() => {
8495
+ (0, import_react56.useEffect)(() => {
8379
8496
  const state = appStore.getState().state;
8380
8497
  appStore.setState(__spreadValues({}, generateAppStore(state)));
8381
8498
  }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
@@ -8384,66 +8501,47 @@ function PuckProvider({ children }) {
8384
8501
  index: initialHistoryIndex,
8385
8502
  initialAppState
8386
8503
  });
8387
- (0, import_react52.useEffect)(() => {
8388
- appStore.subscribe((s) => {
8389
- if (onChange) onChange(s.state.data);
8390
- });
8504
+ const previousData = (0, import_react56.useRef)(null);
8505
+ (0, import_react56.useEffect)(() => {
8506
+ appStore.subscribe(
8507
+ (s) => s.state.data,
8508
+ (data) => {
8509
+ if (onChange) {
8510
+ if ((0, import_fast_deep_equal2.default)(data, previousData.current)) return;
8511
+ onChange(data);
8512
+ previousData.current = data;
8513
+ }
8514
+ }
8515
+ );
8391
8516
  }, []);
8392
8517
  useRegisterPermissionsSlice(appStore, permissions);
8393
8518
  const uPuckStore = useRegisterUsePuckStore(appStore);
8394
- (0, import_react52.useEffect)(() => {
8519
+ (0, import_react56.useEffect)(() => {
8395
8520
  const { resolveAndCommitData } = appStore.getState();
8396
8521
  resolveAndCommitData();
8397
8522
  }, []);
8398
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8523
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8399
8524
  }
8400
8525
  function PuckLayout({ children }) {
8401
8526
  const {
8402
- onChange,
8403
- onPublish,
8404
- renderHeader,
8405
- renderHeaderActions,
8406
- headerTitle,
8407
- headerPath,
8408
8527
  iframe: _iframe,
8409
8528
  dnd,
8410
8529
  initialHistory: _initialHistory
8411
8530
  } = usePropsContext();
8412
- const iframe = __spreadValues({
8413
- enabled: true,
8414
- waitForStyles: true
8415
- }, _iframe);
8531
+ const iframe = (0, import_react56.useMemo)(
8532
+ () => __spreadValues({
8533
+ enabled: true,
8534
+ waitForStyles: true
8535
+ }, _iframe),
8536
+ [_iframe]
8537
+ );
8416
8538
  useInjectGlobalCss(iframe.enabled);
8417
8539
  const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8418
8540
  const rightSideBarVisible = useAppStore(
8419
8541
  (s) => s.state.ui.rightSideBarVisible
8420
8542
  );
8421
- const [menuOpen, setMenuOpen] = (0, import_react52.useState)(false);
8422
- const appStore = useAppStoreApi();
8423
- (0, import_react52.useEffect)(() => {
8424
- return appStore.subscribe((s) => {
8425
- if (onChange) onChange(s.state.data);
8426
- });
8427
- }, [appStore]);
8428
- const rootProps = useAppStore(
8429
- (s) => s.state.data.root.props || s.state.data.root.props
8430
- );
8431
8543
  const dispatch = useAppStore((s) => s.dispatch);
8432
- const toggleSidebars = (0, import_react52.useCallback)(
8433
- (sidebar) => {
8434
- const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8435
- const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
8436
- const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
8437
- dispatch({
8438
- type: "setUi",
8439
- ui: __spreadValues({
8440
- [`${sidebar}SideBarVisible`]: !sideBarVisible
8441
- }, !widerViewport ? { [oppositeSideBar]: false } : {})
8442
- });
8443
- },
8444
- [dispatch, leftSideBarVisible, rightSideBarVisible]
8445
- );
8446
- (0, import_react52.useEffect)(() => {
8544
+ (0, import_react56.useEffect)(() => {
8447
8545
  if (!window.matchMedia("(min-width: 638px)").matches) {
8448
8546
  dispatch({
8449
8547
  type: "setUi",
@@ -8466,55 +8564,18 @@ function PuckLayout({ children }) {
8466
8564
  window.removeEventListener("resize", handleResize);
8467
8565
  };
8468
8566
  }, []);
8469
- const defaultHeaderRender = (0, import_react52.useMemo)(() => {
8470
- if (renderHeader) {
8471
- console.warn(
8472
- "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
8473
- );
8474
- const RenderHeader = (_a) => {
8475
- var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
8476
- const Comp = renderHeader;
8477
- const appState = useAppStore((s) => s.state);
8478
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8479
- };
8480
- return RenderHeader;
8481
- }
8482
- return DefaultOverride;
8483
- }, [renderHeader]);
8484
- const defaultHeaderActionsRender = (0, import_react52.useMemo)(() => {
8485
- if (renderHeaderActions) {
8486
- console.warn(
8487
- "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
8488
- );
8489
- const RenderHeader = (props) => {
8490
- const Comp = renderHeaderActions;
8491
- const appState = useAppStore((s) => s.state);
8492
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8493
- };
8494
- return RenderHeader;
8495
- }
8496
- return DefaultOverride;
8497
- }, [renderHeader]);
8498
8567
  const overrides = useAppStore((s) => s.overrides);
8499
- const CustomPuck = (0, import_react52.useMemo)(
8568
+ const CustomPuck = (0, import_react56.useMemo)(
8500
8569
  () => overrides.puck || DefaultOverride,
8501
8570
  [overrides]
8502
8571
  );
8503
- const CustomHeader = (0, import_react52.useMemo)(
8504
- () => overrides.header || defaultHeaderRender,
8505
- [overrides]
8506
- );
8507
- const CustomHeaderActions = (0, import_react52.useMemo)(
8508
- () => overrides.headerActions || defaultHeaderActionsRender,
8509
- [overrides]
8510
- );
8511
- const [mounted, setMounted] = (0, import_react52.useState)(false);
8512
- (0, import_react52.useEffect)(() => {
8572
+ const [mounted, setMounted] = (0, import_react56.useState)(false);
8573
+ (0, import_react56.useEffect)(() => {
8513
8574
  setMounted(true);
8514
8575
  }, []);
8515
8576
  const ready = useAppStore((s) => s.status === "READY");
8516
8577
  useMonitorHotkeys();
8517
- (0, import_react52.useEffect)(() => {
8578
+ (0, import_react56.useEffect)(() => {
8518
8579
  if (ready && iframe.enabled) {
8519
8580
  const frameDoc = getFrame();
8520
8581
  if (frameDoc) {
@@ -8523,133 +8584,36 @@ function PuckLayout({ children }) {
8523
8584
  }
8524
8585
  }, [ready, iframe.enabled]);
8525
8586
  usePreviewModeHotkeys();
8526
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: `Puck ${getClassName27()}`, children: [
8527
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8587
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: `Puck ${getClassName28()}`, children: [
8588
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8528
8589
  "div",
8529
8590
  {
8530
8591
  className: getLayoutClassName({
8531
8592
  leftSideBarVisible,
8532
- menuOpen,
8533
8593
  mounted,
8534
8594
  rightSideBarVisible
8535
8595
  }),
8536
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("inner"), children: [
8537
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8538
- CustomHeader,
8539
- {
8540
- actions: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8541
- Button,
8542
- {
8543
- onClick: () => {
8544
- const data = appStore.getState().state.data;
8545
- onPublish && onPublish(data);
8546
- },
8547
- icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8548
- children: "Publish"
8549
- }
8550
- ) }) }),
8551
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerInner"), children: [
8552
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerToggle"), children: [
8553
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8554
- "div",
8555
- {
8556
- className: getLayoutClassName("leftSideBarToggle"),
8557
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8558
- IconButton,
8559
- {
8560
- onClick: () => {
8561
- toggleSidebars("left");
8562
- },
8563
- title: "Toggle left sidebar",
8564
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelLeft, { focusable: "false" })
8565
- }
8566
- )
8567
- }
8568
- ),
8569
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8570
- "div",
8571
- {
8572
- className: getLayoutClassName("rightSideBarToggle"),
8573
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8574
- IconButton,
8575
- {
8576
- onClick: () => {
8577
- toggleSidebars("right");
8578
- },
8579
- title: "Toggle right sidebar",
8580
- children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelRight, { focusable: "false" })
8581
- }
8582
- )
8583
- }
8584
- )
8585
- ] }),
8586
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Heading, { rank: "2", size: "xs", children: [
8587
- headerTitle || (rootProps == null ? void 0 : rootProps.title) || "Page",
8588
- headerPath && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
8589
- " ",
8590
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8591
- "code",
8592
- {
8593
- className: getLayoutClassName("headerPath"),
8594
- children: headerPath
8595
- }
8596
- )
8597
- ] })
8598
- ] }) }),
8599
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("headerTools"), children: [
8600
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8601
- IconButton,
8602
- {
8603
- onClick: () => {
8604
- return setMenuOpen(!menuOpen);
8605
- },
8606
- title: "Toggle menu bar",
8607
- children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ChevronDown, { focusable: "false" })
8608
- }
8609
- ) }),
8610
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8611
- MenuBar,
8612
- {
8613
- dispatch,
8614
- onPublish,
8615
- menuOpen,
8616
- renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8617
- Button,
8618
- {
8619
- onClick: () => {
8620
- const data = appStore.getState().state.data;
8621
- onPublish && onPublish(data);
8622
- },
8623
- icon: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Globe, { size: "14px" }),
8624
- children: "Publish"
8625
- }
8626
- ) }),
8627
- setMenuOpen
8628
- }
8629
- )
8630
- ] })
8631
- ] }) })
8632
- }
8633
- ),
8634
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
8635
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Components, {}) }),
8636
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Outline, {}) })
8596
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getLayoutClassName("inner"), children: [
8597
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Header, {}),
8598
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getLayoutClassName("leftSideBar"), children: [
8599
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Components, {}) }),
8600
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Outline, {}) })
8637
8601
  ] }),
8638
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Canvas, {}),
8639
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(FieldSideBar, {}) })
8602
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Canvas, {}),
8603
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(FieldSideBar, {}) })
8640
8604
  ] })
8641
8605
  }
8642
8606
  ) }) }),
8643
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { id: "puck-portal-root", className: getClassName27("portal") })
8607
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { id: "puck-portal-root", className: getClassName28("portal") })
8644
8608
  ] });
8645
8609
  }
8646
8610
  function Puck(props) {
8647
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PuckLayout, __spreadValues({}, props)) })) }));
8611
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PuckLayout, __spreadValues({}, props)) })) }));
8648
8612
  }
8649
8613
  Puck.Components = Components;
8650
8614
  Puck.Fields = Fields;
8651
8615
  Puck.Outline = Outline;
8652
- Puck.Preview = Preview3;
8616
+ Puck.Preview = Preview2;
8653
8617
 
8654
8618
  // lib/migrate.ts
8655
8619
  init_react_import();
@@ -8684,7 +8648,7 @@ var migrations = [
8684
8648
  const [id, slotName] = zoneCompound.split(":");
8685
8649
  const nodeData = indexes.nodes[id].data;
8686
8650
  const componentType = nodeData.type;
8687
- const configForComponent = config.components[componentType];
8651
+ const configForComponent = id === "root" ? config.root : config.components[componentType];
8688
8652
  if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
8689
8653
  updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
8690
8654
  props: __spreadProps(__spreadValues({}, nodeData.props), {
@@ -8742,11 +8706,13 @@ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
8742
8706
  });
8743
8707
 
8744
8708
  // lib/transform-props.ts
8745
- function transformProps(data, propTransforms) {
8709
+ function transformProps(data, propTransforms, config = { components: {} }) {
8746
8710
  const mapItem = (item) => {
8747
8711
  if (propTransforms[item.type]) {
8748
8712
  return __spreadProps(__spreadValues({}, item), {
8749
- props: propTransforms[item.type](item.props)
8713
+ props: __spreadValues({
8714
+ id: item.props.id
8715
+ }, propTransforms[item.type](item.props))
8750
8716
  });
8751
8717
  }
8752
8718
  return item;
@@ -8755,23 +8721,18 @@ function transformProps(data, propTransforms) {
8755
8721
  const rootProps = defaultedData.root.props || defaultedData.root;
8756
8722
  let newRoot = __spreadValues({}, defaultedData.root);
8757
8723
  if (propTransforms["root"]) {
8758
- if (defaultedData.root.props) {
8759
- newRoot.props = propTransforms["root"](rootProps);
8760
- } else {
8761
- newRoot = propTransforms["root"](rootProps);
8762
- }
8724
+ newRoot.props = propTransforms["root"](rootProps);
8763
8725
  }
8764
- const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
8765
- root: newRoot,
8766
- content: defaultedData.content.map(mapItem),
8767
- zones: Object.keys(data.zones || {}).reduce(
8768
- (acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
8769
- [zoneKey]: data.zones[zoneKey].map(mapItem)
8770
- }),
8771
- {}
8772
- )
8773
- });
8774
- return afterPropTransforms;
8726
+ const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
8727
+ const updatedData = walkTree(
8728
+ dataWithUpdatedRoot,
8729
+ config,
8730
+ (content) => content.map(mapItem)
8731
+ );
8732
+ if (!defaultedData.root.props) {
8733
+ updatedData.root = updatedData.root.props;
8734
+ }
8735
+ return updatedData;
8775
8736
  }
8776
8737
 
8777
8738
  // lib/resolve-all-data.ts
@@ -8836,39 +8797,6 @@ function resolveAllData(_0, _1) {
8836
8797
  return dynamic;
8837
8798
  });
8838
8799
  }
8839
-
8840
- // lib/data/walk-tree.ts
8841
- init_react_import();
8842
- function walkTree(data, config, callbackFn) {
8843
- var _a, _b;
8844
- const isSlot2 = createIsSlotConfig(config);
8845
- const walkItem = (item) => {
8846
- return mapSlotsSync(
8847
- item,
8848
- (content, parentId, propName) => callbackFn(content, { parentId, propName }),
8849
- isSlot2
8850
- );
8851
- };
8852
- if ("props" in data) {
8853
- return walkItem(data);
8854
- }
8855
- const _data = data;
8856
- const zones = (_a = _data.zones) != null ? _a : {};
8857
- const mappedContent = _data.content.map(walkItem);
8858
- return {
8859
- root: walkItem(_data.root),
8860
- content: (_b = callbackFn(mappedContent, {
8861
- parentId: "root",
8862
- propName: "default-zone"
8863
- })) != null ? _b : mappedContent,
8864
- zones: Object.keys(zones).reduce(
8865
- (acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
8866
- [zoneCompound]: zones[zoneCompound].map(walkItem)
8867
- }),
8868
- {}
8869
- )
8870
- };
8871
- }
8872
8800
  // Annotate the CommonJS export names for ESM import in node:
8873
8801
  0 && (module.exports = {
8874
8802
  Action,
@@ -8889,6 +8817,7 @@ function walkTree(data, config, callbackFn) {
8889
8817
  renderContext,
8890
8818
  resolveAllData,
8891
8819
  transformProps,
8820
+ useGetPuck,
8892
8821
  usePuck,
8893
8822
  walkTree
8894
8823
  });