@measured/puck 0.19.0-canary.61c8658 → 0.19.0-canary.706ea0c1

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
@@ -311,7 +311,7 @@ init_react_import();
311
311
  var styles_module_default2 = { "InputWrapper": "_InputWrapper_g5w3n_1", "Input-label": "_Input-label_g5w3n_5", "Input-labelIcon": "_Input-labelIcon_g5w3n_14", "Input-disabledIcon": "_Input-disabledIcon_g5w3n_21", "Input-input": "_Input-input_g5w3n_26", "Input": "_Input_g5w3n_1", "Input--readOnly": "_Input--readOnly_g5w3n_74", "Input-radioGroupItems": "_Input-radioGroupItems_g5w3n_85", "Input-radio": "_Input-radio_g5w3n_85", "Input-radioInner": "_Input-radioInner_g5w3n_102", "Input-radioInput": "_Input-radioInput_g5w3n_147" };
312
312
 
313
313
  // components/AutoField/index.tsx
314
- var import_react24 = require("react");
314
+ var import_react23 = require("react");
315
315
 
316
316
  // components/AutoField/fields/index.tsx
317
317
  init_react_import();
@@ -771,7 +771,7 @@ var IconButton = ({
771
771
  };
772
772
 
773
773
  // components/AutoField/fields/ArrayField/index.tsx
774
- var import_react16 = require("react");
774
+ var import_react15 = require("react");
775
775
 
776
776
  // components/DragIcon/index.tsx
777
777
  init_react_import();
@@ -2098,7 +2098,6 @@ function useAppStoreApi() {
2098
2098
  // components/Sortable/index.tsx
2099
2099
  init_react_import();
2100
2100
  var import_react13 = require("@dnd-kit/react");
2101
- var import_react14 = require("react");
2102
2101
 
2103
2102
  // lib/dnd/dnd-kit/safe.ts
2104
2103
  init_react_import();
@@ -2121,7 +2120,8 @@ function useDraggableSafe(input) {
2121
2120
  function useSortableSafe(input) {
2122
2121
  if (typeof window === "undefined") {
2123
2122
  return { ref: () => {
2124
- }, status: "idle" };
2123
+ }, status: "idle", handleRef: () => {
2124
+ } };
2125
2125
  }
2126
2126
  return (0, import_sortable.useSortable)(input);
2127
2127
  }
@@ -2145,6 +2145,7 @@ var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
2145
2145
  this.listeners = new import_utilities.Listeners();
2146
2146
  this.cleanup = /* @__PURE__ */ new Set();
2147
2147
  this.source = void 0;
2148
+ this.started = false;
2148
2149
  __privateAdd(this, _clearTimeout);
2149
2150
  this.handleCancel = this.handleCancel.bind(this);
2150
2151
  this.handlePointerUp = this.handlePointerUp.bind(this);
@@ -2302,6 +2303,12 @@ var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
2302
2303
  if (!status.idle) {
2303
2304
  const canceled = !status.initialized;
2304
2305
  this.manager.actions.stop({ canceled });
2306
+ } else if (this.started) {
2307
+ setTimeout(() => {
2308
+ if (!this.manager.dragOperation.status.idle) {
2309
+ this.manager.actions.stop({ canceled: false });
2310
+ }
2311
+ }, 10);
2305
2312
  }
2306
2313
  this.cleanup.forEach((cleanup) => cleanup());
2307
2314
  this.cleanup.clear();
@@ -2316,12 +2323,13 @@ var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
2316
2323
  var _a;
2317
2324
  const { manager, initialCoordinates } = this;
2318
2325
  (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2319
- if (!initialCoordinates || manager.dragOperation.status.initialized) {
2326
+ if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
2320
2327
  return;
2321
2328
  }
2322
2329
  if (event.defaultPrevented) {
2323
2330
  return;
2324
2331
  }
2332
+ this.started = true;
2325
2333
  event.preventDefault();
2326
2334
  (0, import_state2.batch)(() => {
2327
2335
  manager.actions.setDragSource(source.id);
@@ -2349,6 +2357,9 @@ var _PointerSensor = class _PointerSensor extends import_abstract.Sensor {
2349
2357
  ]);
2350
2358
  ownerDocument.body.setPointerCapture(event.pointerId);
2351
2359
  this.cleanup.add(unbind);
2360
+ this.cleanup.add(() => {
2361
+ this.started = false;
2362
+ });
2352
2363
  }
2353
2364
  handleDragStart(event) {
2354
2365
  const { target } = event;
@@ -2396,23 +2407,26 @@ function patchWindow(window2) {
2396
2407
 
2397
2408
  // lib/dnd/use-sensors.ts
2398
2409
  var import_utilities2 = require("@dnd-kit/dom/utilities");
2399
- var useSensors = () => {
2410
+ var useSensors = ({
2411
+ other,
2412
+ mouse,
2413
+ touch
2414
+ } = {
2415
+ touch: { delay: { value: 200, tolerance: 10 } },
2416
+ other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
2417
+ }) => {
2400
2418
  const [sensors] = (0, import_react12.useState)(() => [
2401
2419
  PointerSensor.configure({
2402
2420
  activationConstraints(event, source) {
2403
2421
  var _a;
2404
2422
  const { pointerType, target } = event;
2405
2423
  if (pointerType === "mouse" && (0, import_utilities2.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
2406
- return void 0;
2424
+ return mouse;
2407
2425
  }
2408
- const delay = { value: 200, tolerance: 10 };
2409
2426
  if (pointerType === "touch") {
2410
- return { delay };
2427
+ return touch;
2411
2428
  }
2412
- return {
2413
- delay,
2414
- distance: { value: 5 }
2415
- };
2429
+ return other;
2416
2430
  }
2417
2431
  })
2418
2432
  ]);
@@ -2755,31 +2769,27 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2755
2769
  };
2756
2770
 
2757
2771
  // components/Sortable/index.tsx
2758
- var import_modifiers = require("@dnd-kit/dom/modifiers");
2759
2772
  var import_jsx_runtime5 = require("react/jsx-runtime");
2760
2773
  var SortableProvider = ({
2761
- container,
2762
2774
  children,
2763
2775
  onDragStart,
2764
2776
  onDragEnd,
2765
2777
  onMove
2766
2778
  }) => {
2767
- const [move, setMove] = (0, import_react14.useState)({ source: -1, target: -1 });
2768
- const sensors = useSensors();
2779
+ const sensors = useSensors({
2780
+ mouse: { distance: { value: 5 } }
2781
+ });
2769
2782
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2770
2783
  import_react13.DragDropProvider,
2771
2784
  {
2772
2785
  sensors,
2773
- modifiers: [
2774
- import_modifiers.RestrictToElement.configure({
2775
- element() {
2776
- return container.current;
2777
- }
2778
- })
2779
- ],
2780
- onDragStart,
2786
+ onDragStart: (event) => {
2787
+ var _a, _b;
2788
+ return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
2789
+ },
2781
2790
  onDragOver: (event, manager) => {
2782
2791
  var _a, _b;
2792
+ event.preventDefault();
2783
2793
  const { operation } = event;
2784
2794
  const { source, target } = operation;
2785
2795
  if (!source || !target) return;
@@ -2787,14 +2797,14 @@ var SortableProvider = ({
2787
2797
  let targetIndex = target.data.index;
2788
2798
  const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
2789
2799
  if (sourceIndex !== targetIndex && source.id !== target.id) {
2790
- const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
2800
+ const collisionPosition = collisionData.direction === "up" ? "before" : "after";
2791
2801
  if (targetIndex >= sourceIndex) {
2792
2802
  targetIndex = targetIndex - 1;
2793
2803
  }
2794
2804
  if (collisionPosition === "after") {
2795
2805
  targetIndex = targetIndex + 1;
2796
2806
  }
2797
- setMove({
2807
+ onMove({
2798
2808
  source: sourceIndex,
2799
2809
  target: targetIndex
2800
2810
  });
@@ -2802,12 +2812,8 @@ var SortableProvider = ({
2802
2812
  },
2803
2813
  onDragEnd: () => {
2804
2814
  setTimeout(() => {
2805
- if (move.source !== -1 && move.target !== -1) {
2806
- onMove(move);
2807
- }
2808
2815
  onDragEnd();
2809
2816
  }, 250);
2810
- setMove({ source: -1, target: -1 });
2811
2817
  },
2812
2818
  children
2813
2819
  }
@@ -2820,7 +2826,11 @@ var Sortable = ({
2820
2826
  children,
2821
2827
  type = "item"
2822
2828
  }) => {
2823
- const { ref: sortableRef, status } = useSortableSafe({
2829
+ const {
2830
+ ref: sortableRef,
2831
+ status,
2832
+ handleRef
2833
+ } = useSortableSafe({
2824
2834
  id,
2825
2835
  type,
2826
2836
  index,
@@ -2828,16 +2838,16 @@ var Sortable = ({
2828
2838
  data: { index },
2829
2839
  collisionDetector: createDynamicCollisionDetector("y")
2830
2840
  });
2831
- return children({ status, ref: sortableRef });
2841
+ return children({ status, ref: sortableRef, handleRef });
2832
2842
  };
2833
2843
 
2834
2844
  // components/AutoField/context.tsx
2835
2845
  init_react_import();
2836
- var import_react15 = require("react");
2846
+ var import_react14 = require("react");
2837
2847
  var import_jsx_runtime6 = require("react/jsx-runtime");
2838
- var NestedFieldContext = (0, import_react15.createContext)({});
2848
+ var NestedFieldContext = (0, import_react14.createContext)({});
2839
2849
  var useNestedFieldContext = () => {
2840
- const context = (0, import_react15.useContext)(NestedFieldContext);
2850
+ const context = (0, import_react14.useContext)(NestedFieldContext);
2841
2851
  return __spreadProps(__spreadValues({}, context), {
2842
2852
  readOnlyFields: context.readOnlyFields || {}
2843
2853
  });
@@ -2851,7 +2861,7 @@ var NestedFieldProvider = ({
2851
2861
  }) => {
2852
2862
  const subPath = `${name}.${subName}`;
2853
2863
  const wildcardSubPath = `${wildcardName}.${subName}`;
2854
- const subReadOnlyFields = (0, import_react15.useMemo)(
2864
+ const subReadOnlyFields = (0, import_react14.useMemo)(
2855
2865
  () => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
2856
2866
  const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
2857
2867
  if (isLocal) {
@@ -2904,12 +2914,14 @@ var ArrayField = ({
2904
2914
  }),
2905
2915
  openId: ""
2906
2916
  };
2907
- const [localState, setLocalState] = (0, import_react16.useState)({ arrayState, value });
2908
- (0, import_react16.useEffect)(() => {
2909
- setLocalState({ arrayState, value });
2910
- }, [value, thisArrayState]);
2917
+ const [localState, setLocalState] = (0, import_react15.useState)({ arrayState, value });
2918
+ (0, import_react15.useEffect)(() => {
2919
+ var _a;
2920
+ const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
2921
+ setLocalState({ arrayState: _arrayState, value });
2922
+ }, [value]);
2911
2923
  const appStore = useAppStoreApi();
2912
- const mapArrayStateToUi = (0, import_react16.useCallback)(
2924
+ const mapArrayStateToUi = (0, import_react15.useCallback)(
2913
2925
  (partialArrayState) => {
2914
2926
  const state = appStore.getState().state;
2915
2927
  return {
@@ -2920,13 +2932,13 @@ var ArrayField = ({
2920
2932
  },
2921
2933
  [arrayState, appStore]
2922
2934
  );
2923
- const getHighestIndex = (0, import_react16.useCallback)(() => {
2935
+ const getHighestIndex = (0, import_react15.useCallback)(() => {
2924
2936
  return arrayState.items.reduce(
2925
2937
  (acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
2926
2938
  -1
2927
2939
  );
2928
2940
  }, [arrayState]);
2929
- const regenerateArrayState = (0, import_react16.useCallback)(
2941
+ const regenerateArrayState = (0, import_react15.useCallback)(
2930
2942
  (value2) => {
2931
2943
  let highestIndex = getHighestIndex();
2932
2944
  const newItems = Array.from(value2 || []).map((item, idx) => {
@@ -2945,17 +2957,18 @@ var ArrayField = ({
2945
2957
  },
2946
2958
  [arrayState]
2947
2959
  );
2948
- (0, import_react16.useEffect)(() => {
2960
+ (0, import_react15.useEffect)(() => {
2949
2961
  if (arrayState.items.length > 0) {
2950
2962
  setUi(mapArrayStateToUi(arrayState));
2951
2963
  }
2952
2964
  }, []);
2953
- const [isDragging, setIsDragging] = (0, import_react16.useState)(false);
2954
- const dndContainerRef = (0, import_react16.useRef)(null);
2965
+ const [draggedItem, setDraggedItem] = (0, import_react15.useState)("");
2966
+ const isDragging = !!draggedItem;
2955
2967
  const canEdit = useAppStore(
2956
2968
  (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
2957
2969
  );
2958
2970
  const forceReadOnly = !canEdit;
2971
+ const valueRef = (0, import_react15.useRef)(value);
2959
2972
  if (field.type !== "array" || !field.arrayFields) {
2960
2973
  return null;
2961
2974
  }
@@ -2970,11 +2983,16 @@ var ArrayField = ({
2970
2983
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2971
2984
  SortableProvider,
2972
2985
  {
2973
- container: dndContainerRef,
2974
- onDragStart: () => setIsDragging(true),
2975
- onDragEnd: () => setIsDragging(false),
2986
+ onDragStart: (id2) => setDraggedItem(id2),
2987
+ onDragEnd: () => {
2988
+ setDraggedItem("");
2989
+ onChange(valueRef.current);
2990
+ },
2976
2991
  onMove: (move) => {
2977
- const newValue = reorder(value, move.source, move.target);
2992
+ if (arrayState.items[move.source]._arrayId !== draggedItem) {
2993
+ return;
2994
+ }
2995
+ const newValue = reorder(localState.value, move.source, move.target);
2978
2996
  const newArrayStateItems = reorder(
2979
2997
  arrayState.items,
2980
2998
  move.source,
@@ -2987,11 +3005,11 @@ var ArrayField = ({
2987
3005
  })
2988
3006
  };
2989
3007
  setUi(newUi, false);
2990
- onChange(newValue, newUi);
2991
3008
  setLocalState({
2992
3009
  value: newValue,
2993
3010
  arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
2994
3011
  });
3012
+ valueRef.current = newValue;
2995
3013
  },
2996
3014
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
2997
3015
  "div",
@@ -3001,172 +3019,156 @@ var ArrayField = ({
3001
3019
  addDisabled
3002
3020
  }),
3003
3021
  children: [
3004
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3005
- "div",
3006
- {
3007
- ref: dndContainerRef,
3008
- className: getClassName5("inner"),
3009
- "data-dnd-container": true,
3010
- children: localState.arrayState.items.map((item, i) => {
3011
- const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
3012
- const data = Array.from(localState.value || [])[i] || {};
3013
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3014
- Sortable,
3022
+ localState.arrayState.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
3023
+ const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
3024
+ const data = Array.from(localState.value || [])[i] || {};
3025
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3026
+ Sortable,
3027
+ {
3028
+ id: _arrayId,
3029
+ index: i,
3030
+ disabled: readOnly,
3031
+ children: ({ status, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3032
+ "div",
3015
3033
  {
3016
- id: _arrayId,
3017
- index: i,
3018
- disabled: readOnly,
3019
- children: ({ status, ref }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3020
- "div",
3021
- {
3022
- ref,
3023
- className: getClassNameItem({
3024
- isExpanded: arrayState.openId === _arrayId,
3025
- isDragging: status === "dragging",
3026
- readOnly
3027
- }),
3028
- children: [
3029
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3030
- "div",
3031
- {
3032
- onClick: (e) => {
3033
- if (isDragging) return;
3034
- e.preventDefault();
3035
- e.stopPropagation();
3036
- if (arrayState.openId === _arrayId) {
3037
- setUi(
3038
- mapArrayStateToUi({
3039
- openId: ""
3040
- })
3041
- );
3042
- } else {
3043
- setUi(
3044
- mapArrayStateToUi({
3045
- openId: _arrayId
3046
- })
3047
- );
3048
- }
3049
- },
3050
- className: getClassNameItem("summary"),
3051
- children: [
3052
- field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
3053
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("rhs"), children: [
3054
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("actions"), children: [
3055
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3056
- IconButton,
3057
- {
3058
- type: "button",
3059
- disabled: !!addDisabled,
3060
- onClick: (e) => {
3061
- e.stopPropagation();
3062
- const existingValue = [...value || []];
3063
- existingValue.splice(
3064
- i,
3065
- 0,
3066
- existingValue[i]
3067
- );
3068
- onChange(
3069
- existingValue,
3070
- mapArrayStateToUi(
3071
- regenerateArrayState(existingValue)
3072
- )
3073
- );
3074
- },
3075
- title: "Duplicate",
3076
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
3077
- }
3078
- ) }),
3079
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3080
- IconButton,
3081
- {
3082
- type: "button",
3083
- disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
3084
- onClick: (e) => {
3085
- e.stopPropagation();
3086
- const existingValue = [...value || []];
3087
- const existingItems = [
3088
- ...arrayState.items || []
3089
- ];
3090
- existingValue.splice(i, 1);
3091
- existingItems.splice(i, 1);
3092
- onChange(
3093
- existingValue,
3094
- mapArrayStateToUi({
3095
- items: existingItems
3096
- })
3097
- );
3098
- },
3099
- title: "Delete",
3100
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 })
3101
- }
3102
- ) })
3103
- ] }),
3104
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DragIcon, {}) })
3105
- ] })
3106
- ]
3034
+ ref,
3035
+ className: getClassNameItem({
3036
+ isExpanded: arrayState.openId === _arrayId,
3037
+ isDragging: status === "dragging",
3038
+ readOnly
3039
+ }),
3040
+ children: [
3041
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3042
+ "div",
3043
+ {
3044
+ ref: handleRef,
3045
+ onClick: (e) => {
3046
+ if (isDragging) return;
3047
+ e.preventDefault();
3048
+ e.stopPropagation();
3049
+ if (arrayState.openId === _arrayId) {
3050
+ setUi(
3051
+ mapArrayStateToUi({
3052
+ openId: ""
3053
+ })
3054
+ );
3055
+ } else {
3056
+ setUi(
3057
+ mapArrayStateToUi({
3058
+ openId: _arrayId
3059
+ })
3060
+ );
3107
3061
  }
3108
- ),
3109
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3110
- "fieldset",
3111
- {
3112
- className: getClassNameItem("fieldset"),
3113
- onPointerDownCapture: (e) => {
3114
- e.stopPropagation();
3115
- },
3116
- children: Object.keys(field.arrayFields).map((subName) => {
3117
- const subField = field.arrayFields[subName];
3118
- const indexName = `${name}[${i}]`;
3119
- const subPath = `${indexName}.${subName}`;
3120
- const localIndexName = `${localName}[${i}]`;
3121
- const localWildcardName = `${localName}[*]`;
3122
- const localSubPath = `${localIndexName}.${subName}`;
3123
- const localWildcardSubPath = `${localWildcardName}.${subName}`;
3124
- const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
3125
- const label2 = subField.label || subName;
3126
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3127
- NestedFieldProvider,
3062
+ },
3063
+ className: getClassNameItem("summary"),
3064
+ children: [
3065
+ field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
3066
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("rhs"), children: [
3067
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("actions"), children: [
3068
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3069
+ IconButton,
3070
+ {
3071
+ type: "button",
3072
+ disabled: !!addDisabled,
3073
+ onClick: (e) => {
3074
+ e.stopPropagation();
3075
+ const existingValue = [...value || []];
3076
+ existingValue.splice(
3077
+ i,
3078
+ 0,
3079
+ existingValue[i]
3080
+ );
3081
+ const newUi = mapArrayStateToUi(
3082
+ regenerateArrayState(existingValue)
3083
+ );
3084
+ setUi(newUi, false);
3085
+ onChange(existingValue);
3086
+ },
3087
+ title: "Duplicate",
3088
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
3089
+ }
3090
+ ) }),
3091
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3092
+ IconButton,
3128
3093
  {
3129
- name: localIndexName,
3130
- wildcardName: localWildcardName,
3131
- subName,
3132
- readOnlyFields,
3133
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3134
- AutoFieldPrivate,
3135
- {
3136
- name: subPath,
3137
- label: label2,
3138
- id: `${_arrayId}_${subName}`,
3139
- readOnly: subReadOnly,
3140
- field: __spreadProps(__spreadValues({}, subField), {
3141
- label: label2
3142
- // May be used by custom fields
3094
+ type: "button",
3095
+ disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
3096
+ onClick: (e) => {
3097
+ e.stopPropagation();
3098
+ const existingValue = [...value || []];
3099
+ const existingItems = [
3100
+ ...arrayState.items || []
3101
+ ];
3102
+ existingValue.splice(i, 1);
3103
+ existingItems.splice(i, 1);
3104
+ setUi(
3105
+ mapArrayStateToUi({
3106
+ items: existingItems
3143
3107
  }),
3144
- value: data[subName],
3145
- onChange: (val, ui) => {
3146
- onChange(
3147
- replace(value, i, __spreadProps(__spreadValues({}, data), {
3148
- [subName]: val
3149
- })),
3150
- ui
3151
- );
3152
- }
3153
- }
3154
- )
3155
- },
3156
- subPath
3157
- );
3158
- })
3159
- }
3160
- ) })
3161
- ]
3162
- }
3163
- )
3164
- },
3165
- _arrayId
3166
- );
3167
- })
3168
- }
3169
- ),
3108
+ false
3109
+ );
3110
+ onChange(existingValue);
3111
+ },
3112
+ title: "Delete",
3113
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 })
3114
+ }
3115
+ ) })
3116
+ ] }),
3117
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DragIcon, {}) })
3118
+ ] })
3119
+ ]
3120
+ }
3121
+ ),
3122
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
3123
+ const subField = field.arrayFields[subName];
3124
+ const indexName = `${name}[${i}]`;
3125
+ const subPath = `${indexName}.${subName}`;
3126
+ const localIndexName = `${localName}[${i}]`;
3127
+ const localWildcardName = `${localName}[*]`;
3128
+ const localSubPath = `${localIndexName}.${subName}`;
3129
+ const localWildcardSubPath = `${localWildcardName}.${subName}`;
3130
+ const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
3131
+ const label2 = subField.label || subName;
3132
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3133
+ NestedFieldProvider,
3134
+ {
3135
+ name: localIndexName,
3136
+ wildcardName: localWildcardName,
3137
+ subName,
3138
+ readOnlyFields,
3139
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3140
+ AutoFieldPrivate,
3141
+ {
3142
+ name: subPath,
3143
+ label: label2,
3144
+ id: `${_arrayId}_${subName}`,
3145
+ readOnly: subReadOnly,
3146
+ field: __spreadProps(__spreadValues({}, subField), {
3147
+ label: label2
3148
+ // May be used by custom fields
3149
+ }),
3150
+ value: data[subName],
3151
+ onChange: (val, ui) => {
3152
+ onChange(
3153
+ replace(value, i, __spreadProps(__spreadValues({}, data), {
3154
+ [subName]: val
3155
+ })),
3156
+ ui
3157
+ );
3158
+ }
3159
+ }
3160
+ )
3161
+ },
3162
+ subPath
3163
+ );
3164
+ }) }) })
3165
+ ]
3166
+ }
3167
+ )
3168
+ },
3169
+ _arrayId
3170
+ );
3171
+ }) }),
3170
3172
  !addDisabled && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3171
3173
  "button",
3172
3174
  {
@@ -3180,7 +3182,8 @@ var ArrayField = ({
3180
3182
  field.defaultItemProps || {}
3181
3183
  ];
3182
3184
  const newArrayState = regenerateArrayState(newValue);
3183
- onChange(newValue, mapArrayStateToUi(newArrayState));
3185
+ setUi(mapArrayStateToUi(newArrayState), false);
3186
+ onChange(newValue);
3184
3187
  },
3185
3188
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Plus, { size: 21 })
3186
3189
  }
@@ -3257,11 +3260,11 @@ var DefaultField = ({
3257
3260
 
3258
3261
  // components/AutoField/fields/ExternalField/index.tsx
3259
3262
  init_react_import();
3260
- var import_react20 = require("react");
3263
+ var import_react19 = require("react");
3261
3264
 
3262
3265
  // components/ExternalInput/index.tsx
3263
3266
  init_react_import();
3264
- var import_react19 = require("react");
3267
+ var import_react18 = require("react");
3265
3268
 
3266
3269
  // css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
3267
3270
  init_react_import();
@@ -3269,7 +3272,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
3269
3272
 
3270
3273
  // components/Modal/index.tsx
3271
3274
  init_react_import();
3272
- var import_react17 = require("react");
3275
+ var import_react16 = require("react");
3273
3276
 
3274
3277
  // css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
3275
3278
  init_react_import();
@@ -3284,8 +3287,8 @@ var Modal = ({
3284
3287
  onClose,
3285
3288
  isOpen
3286
3289
  }) => {
3287
- const [rootEl, setRootEl] = (0, import_react17.useState)(null);
3288
- (0, import_react17.useEffect)(() => {
3290
+ const [rootEl, setRootEl] = (0, import_react16.useState)(null);
3291
+ (0, import_react16.useEffect)(() => {
3289
3292
  setRootEl(document.getElementById("puck-portal-root"));
3290
3293
  }, []);
3291
3294
  if (!rootEl) {
@@ -3332,7 +3335,7 @@ init_react_import();
3332
3335
 
3333
3336
  // components/Button/Button.tsx
3334
3337
  init_react_import();
3335
- var import_react18 = require("react");
3338
+ var import_react17 = require("react");
3336
3339
 
3337
3340
  // css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
3338
3341
  init_react_import();
@@ -3382,8 +3385,8 @@ var Button = (_a) => {
3382
3385
  "size",
3383
3386
  "loading"
3384
3387
  ]);
3385
- const [loading, setLoading] = (0, import_react18.useState)(loadingProp);
3386
- (0, import_react18.useEffect)(() => setLoading(loadingProp), [loadingProp]);
3388
+ const [loading, setLoading] = (0, import_react17.useState)(loadingProp);
3389
+ (0, import_react17.useEffect)(() => setLoading(loadingProp), [loadingProp]);
3387
3390
  const ElementType = href ? "a" : type ? "button" : "span";
3388
3391
  const dataAttrs = filterDataAttrs(props);
3389
3392
  const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
@@ -3438,28 +3441,28 @@ var ExternalInput = ({
3438
3441
  mapRow = (val) => val,
3439
3442
  filterFields
3440
3443
  } = field || {};
3441
- const [data, setData] = (0, import_react19.useState)([]);
3442
- const [isOpen, setOpen] = (0, import_react19.useState)(false);
3443
- const [isLoading, setIsLoading] = (0, import_react19.useState)(true);
3444
+ const [data, setData] = (0, import_react18.useState)([]);
3445
+ const [isOpen, setOpen] = (0, import_react18.useState)(false);
3446
+ const [isLoading, setIsLoading] = (0, import_react18.useState)(true);
3444
3447
  const hasFilterFields = !!filterFields;
3445
- const [filters, setFilters] = (0, import_react19.useState)(field.initialFilters || {});
3446
- const [filtersToggled, setFiltersToggled] = (0, import_react19.useState)(hasFilterFields);
3447
- const mappedData = (0, import_react19.useMemo)(() => {
3448
+ const [filters, setFilters] = (0, import_react18.useState)(field.initialFilters || {});
3449
+ const [filtersToggled, setFiltersToggled] = (0, import_react18.useState)(hasFilterFields);
3450
+ const mappedData = (0, import_react18.useMemo)(() => {
3448
3451
  return data.map(mapRow);
3449
3452
  }, [data]);
3450
- const keys = (0, import_react19.useMemo)(() => {
3453
+ const keys = (0, import_react18.useMemo)(() => {
3451
3454
  const validKeys = /* @__PURE__ */ new Set();
3452
3455
  for (const item of mappedData) {
3453
3456
  for (const key of Object.keys(item)) {
3454
- if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react19.isValidElement)(item[key])) {
3457
+ if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react18.isValidElement)(item[key])) {
3455
3458
  validKeys.add(key);
3456
3459
  }
3457
3460
  }
3458
3461
  }
3459
3462
  return Array.from(validKeys);
3460
3463
  }, [mappedData]);
3461
- const [searchQuery, setSearchQuery] = (0, import_react19.useState)(field.initialQuery || "");
3462
- const search = (0, import_react19.useCallback)(
3464
+ const [searchQuery, setSearchQuery] = (0, import_react18.useState)(field.initialQuery || "");
3465
+ const search = (0, import_react18.useCallback)(
3463
3466
  (query, filters2) => __async(void 0, null, function* () {
3464
3467
  setIsLoading(true);
3465
3468
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
@@ -3472,7 +3475,7 @@ var ExternalInput = ({
3472
3475
  }),
3473
3476
  [id, field]
3474
3477
  );
3475
- const Footer = (0, import_react19.useCallback)(
3478
+ const Footer = (0, import_react18.useCallback)(
3476
3479
  (props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
3477
3480
  props.items.length,
3478
3481
  " result",
@@ -3480,7 +3483,7 @@ var ExternalInput = ({
3480
3483
  ] }),
3481
3484
  [field.renderFooter]
3482
3485
  );
3483
- (0, import_react19.useEffect)(() => {
3486
+ (0, import_react18.useEffect)(() => {
3484
3487
  search(searchQuery, filters);
3485
3488
  }, []);
3486
3489
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
@@ -3652,7 +3655,7 @@ var ExternalField = ({
3652
3655
  var _a, _b, _c;
3653
3656
  const validField = field;
3654
3657
  const deprecatedField = field;
3655
- (0, import_react20.useEffect)(() => {
3658
+ (0, import_react19.useEffect)(() => {
3656
3659
  if (deprecatedField.adaptor) {
3657
3660
  console.error(
3658
3661
  "Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
@@ -3695,7 +3698,7 @@ var ExternalField = ({
3695
3698
 
3696
3699
  // components/AutoField/fields/RadioField/index.tsx
3697
3700
  init_react_import();
3698
- var import_react21 = require("react");
3701
+ var import_react20 = require("react");
3699
3702
 
3700
3703
  // lib/safe-json-parse.ts
3701
3704
  init_react_import();
@@ -3722,7 +3725,7 @@ var RadioField = ({
3722
3725
  labelIcon,
3723
3726
  Label: Label2
3724
3727
  }) => {
3725
- const flatOptions = (0, import_react21.useMemo)(
3728
+ const flatOptions = (0, import_react20.useMemo)(
3726
3729
  () => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
3727
3730
  [field]
3728
3731
  );
@@ -3772,7 +3775,7 @@ var RadioField = ({
3772
3775
 
3773
3776
  // components/AutoField/fields/SelectField/index.tsx
3774
3777
  init_react_import();
3775
- var import_react22 = require("react");
3778
+ var import_react21 = require("react");
3776
3779
  var import_jsx_runtime15 = require("react/jsx-runtime");
3777
3780
  var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
3778
3781
  var SelectField = ({
@@ -3786,7 +3789,7 @@ var SelectField = ({
3786
3789
  readOnly,
3787
3790
  id
3788
3791
  }) => {
3789
- const flatOptions = (0, import_react22.useMemo)(
3792
+ const flatOptions = (0, import_react21.useMemo)(
3790
3793
  () => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
3791
3794
  [field]
3792
3795
  );
@@ -3947,12 +3950,12 @@ var ObjectField = ({
3947
3950
 
3948
3951
  // lib/use-safe-id.ts
3949
3952
  init_react_import();
3950
- var import_react23 = __toESM(require("react"));
3953
+ var import_react22 = __toESM(require("react"));
3951
3954
  var useSafeId = () => {
3952
- if (typeof import_react23.default.useId !== "undefined") {
3953
- return import_react23.default.useId();
3955
+ if (typeof import_react22.default.useId !== "undefined") {
3956
+ return import_react22.default.useId();
3954
3957
  }
3955
- const [id] = (0, import_react23.useState)(generateId());
3958
+ const [id] = (0, import_react22.useState)(generateId());
3956
3959
  return id;
3957
3960
  };
3958
3961
 
@@ -3986,7 +3989,7 @@ var FieldLabelInternal = ({
3986
3989
  readOnly
3987
3990
  }) => {
3988
3991
  const overrides = useAppStore((s) => s.overrides);
3989
- const Wrapper = (0, import_react24.useMemo)(
3992
+ const Wrapper = (0, import_react23.useMemo)(
3990
3993
  () => overrides.fieldLabel || FieldLabel,
3991
3994
  [overrides]
3992
3995
  );
@@ -4013,7 +4016,7 @@ function AutoFieldInternal(props) {
4013
4016
  var _a2;
4014
4017
  return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
4015
4018
  });
4016
- const nestedFieldContext = (0, import_react24.useContext)(NestedFieldContext);
4019
+ const nestedFieldContext = (0, import_react23.useContext)(NestedFieldContext);
4017
4020
  const { id, Label: Label2 = FieldLabelInternal } = props;
4018
4021
  const field = props.field;
4019
4022
  const label = field.label;
@@ -4047,7 +4050,7 @@ function AutoFieldInternal(props) {
4047
4050
  Label: Label2,
4048
4051
  id: resolvedId
4049
4052
  });
4050
- const onFocus = (0, import_react24.useCallback)(
4053
+ const onFocus = (0, import_react23.useCallback)(
4051
4054
  (e) => {
4052
4055
  if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
4053
4056
  e.stopPropagation();
@@ -4061,7 +4064,7 @@ function AutoFieldInternal(props) {
4061
4064
  },
4062
4065
  [mergedProps.name]
4063
4066
  );
4064
- const onBlur = (0, import_react24.useCallback)((e) => {
4067
+ const onBlur = (0, import_react23.useCallback)((e) => {
4065
4068
  if ("name" in e.target) {
4066
4069
  dispatch({
4067
4070
  type: "setUi",
@@ -4105,15 +4108,15 @@ function AutoFieldInternal(props) {
4105
4108
  function AutoFieldPrivate(props) {
4106
4109
  const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
4107
4110
  const { value, onChange } = props;
4108
- const [localValue, setLocalValue] = (0, import_react24.useState)(value);
4109
- const onChangeLocal = (0, import_react24.useCallback)(
4111
+ const [localValue, setLocalValue] = (0, import_react23.useState)(value);
4112
+ const onChangeLocal = (0, import_react23.useCallback)(
4110
4113
  (val, ui) => {
4111
4114
  setLocalValue(val);
4112
4115
  onChange(val, ui);
4113
4116
  },
4114
4117
  [onChange]
4115
4118
  );
4116
- (0, import_react24.useEffect)(() => {
4119
+ (0, import_react23.useEffect)(() => {
4117
4120
  if (!isFocused) {
4118
4121
  setLocalValue(value);
4119
4122
  }
@@ -4125,7 +4128,7 @@ function AutoFieldPrivate(props) {
4125
4128
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
4126
4129
  }
4127
4130
  function AutoField(props) {
4128
- const DefaultLabel = (0, import_react24.useMemo)(() => {
4131
+ const DefaultLabel = (0, import_react23.useMemo)(() => {
4129
4132
  const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4130
4133
  "div",
4131
4134
  __spreadProps(__spreadValues({}, labelProps), {
@@ -4145,21 +4148,21 @@ init_react_import();
4145
4148
  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" };
4146
4149
 
4147
4150
  // components/Drawer/index.tsx
4148
- var import_react37 = require("react");
4151
+ var import_react36 = require("react");
4149
4152
 
4150
4153
  // components/DragDropContext/index.tsx
4151
4154
  init_react_import();
4152
- var import_react35 = require("@dnd-kit/react");
4153
- var import_react36 = require("react");
4155
+ var import_react34 = require("@dnd-kit/react");
4156
+ var import_react35 = require("react");
4154
4157
  var import_dom = require("@dnd-kit/dom");
4155
4158
 
4156
4159
  // components/DropZone/index.tsx
4157
4160
  init_react_import();
4158
- var import_react34 = require("react");
4161
+ var import_react33 = require("react");
4159
4162
 
4160
4163
  // components/DraggableComponent/index.tsx
4161
4164
  init_react_import();
4162
- var import_react27 = require("react");
4165
+ var import_react26 = require("react");
4163
4166
 
4164
4167
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
4165
4168
  init_react_import();
@@ -4189,11 +4192,11 @@ function getDeepScrollPosition(element) {
4189
4192
 
4190
4193
  // components/DropZone/context.tsx
4191
4194
  init_react_import();
4192
- var import_react25 = require("react");
4195
+ var import_react24 = require("react");
4193
4196
  var import_zustand3 = require("zustand");
4194
4197
  var import_jsx_runtime19 = require("react/jsx-runtime");
4195
- var dropZoneContext = (0, import_react25.createContext)(null);
4196
- var ZoneStoreContext = (0, import_react25.createContext)(
4198
+ var dropZoneContext = (0, import_react24.createContext)(null);
4199
+ var ZoneStoreContext = (0, import_react24.createContext)(
4197
4200
  (0, import_zustand3.createStore)(() => ({
4198
4201
  zoneDepthIndex: {},
4199
4202
  nextZoneDepthIndex: {},
@@ -4213,10 +4216,10 @@ var DropZoneProvider = ({
4213
4216
  children,
4214
4217
  value
4215
4218
  }) => {
4216
- const [hoveringComponent, setHoveringComponent] = (0, import_react25.useState)();
4217
- const [activeZones, setActiveZones] = (0, import_react25.useState)({});
4219
+ const [hoveringComponent, setHoveringComponent] = (0, import_react24.useState)();
4220
+ const [activeZones, setActiveZones] = (0, import_react24.useState)({});
4218
4221
  const dispatch = useAppStore((s) => s.dispatch);
4219
- const registerZone = (0, import_react25.useCallback)(
4222
+ const registerZone = (0, import_react24.useCallback)(
4220
4223
  (zoneCompound) => {
4221
4224
  if (!dispatch) {
4222
4225
  return;
@@ -4229,7 +4232,7 @@ var DropZoneProvider = ({
4229
4232
  },
4230
4233
  [setActiveZones, dispatch]
4231
4234
  );
4232
- const unregisterZone = (0, import_react25.useCallback)(
4235
+ const unregisterZone = (0, import_react24.useCallback)(
4233
4236
  (zoneCompound) => {
4234
4237
  if (!dispatch) {
4235
4238
  return;
@@ -4244,7 +4247,7 @@ var DropZoneProvider = ({
4244
4247
  },
4245
4248
  [setActiveZones, dispatch]
4246
4249
  );
4247
- const memoValue = (0, import_react25.useMemo)(
4250
+ const memoValue = (0, import_react24.useMemo)(
4248
4251
  () => __spreadValues({
4249
4252
  hoveringComponent,
4250
4253
  setHoveringComponent,
@@ -4259,11 +4262,11 @@ var DropZoneProvider = ({
4259
4262
 
4260
4263
  // lib/use-context-store.ts
4261
4264
  init_react_import();
4262
- var import_react26 = require("react");
4265
+ var import_react25 = require("react");
4263
4266
  var import_zustand4 = require("zustand");
4264
4267
  var import_shallow = require("zustand/react/shallow");
4265
4268
  function useContextStore(context, selector) {
4266
- const store = (0, import_react26.useContext)(context);
4269
+ const store = (0, import_react25.useContext)(context);
4267
4270
  if (!store) {
4268
4271
  throw new Error("useContextStore must be used inside context");
4269
4272
  }
@@ -4321,9 +4324,9 @@ var DraggableComponent = ({
4321
4324
  );
4322
4325
  const dispatch = useAppStore((s) => s.dispatch);
4323
4326
  const iframe = useAppStore((s) => s.iframe);
4324
- const ctx = (0, import_react27.useContext)(dropZoneContext);
4325
- const [localZones, setLocalZones] = (0, import_react27.useState)({});
4326
- const registerLocalZone = (0, import_react27.useCallback)(
4327
+ const ctx = (0, import_react26.useContext)(dropZoneContext);
4328
+ const [localZones, setLocalZones] = (0, import_react26.useState)({});
4329
+ const registerLocalZone = (0, import_react26.useCallback)(
4327
4330
  (zoneCompound2, active) => {
4328
4331
  var _a;
4329
4332
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -4333,7 +4336,7 @@ var DraggableComponent = ({
4333
4336
  },
4334
4337
  [setLocalZones]
4335
4338
  );
4336
- const unregisterLocalZone = (0, import_react27.useCallback)(
4339
+ const unregisterLocalZone = (0, import_react26.useCallback)(
4337
4340
  (zoneCompound2) => {
4338
4341
  var _a;
4339
4342
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -4363,7 +4366,7 @@ var DraggableComponent = ({
4363
4366
  );
4364
4367
  const canCollide = permissions.drag || userIsDragging;
4365
4368
  const disabled = !isEnabled || !canCollide;
4366
- const [dragAxis, setDragAxis] = (0, import_react27.useState)(userDragAxis || autoDragAxis);
4369
+ const [dragAxis, setDragAxis] = (0, import_react26.useState)(userDragAxis || autoDragAxis);
4367
4370
  const { ref: sortableRef, status } = useSortableSafe({
4368
4371
  id,
4369
4372
  index,
@@ -4389,8 +4392,8 @@ var DraggableComponent = ({
4389
4392
  }
4390
4393
  });
4391
4394
  const thisIsDragging = status === "dragging";
4392
- const ref = (0, import_react27.useRef)(null);
4393
- const refSetter = (0, import_react27.useCallback)(
4395
+ const ref = (0, import_react26.useRef)(null);
4396
+ const refSetter = (0, import_react26.useCallback)(
4394
4397
  (el) => {
4395
4398
  sortableRef(el);
4396
4399
  if (el) {
@@ -4399,14 +4402,14 @@ var DraggableComponent = ({
4399
4402
  },
4400
4403
  [sortableRef]
4401
4404
  );
4402
- const [portalEl, setPortalEl] = (0, import_react27.useState)();
4403
- (0, import_react27.useEffect)(() => {
4405
+ const [portalEl, setPortalEl] = (0, import_react26.useState)();
4406
+ (0, import_react26.useEffect)(() => {
4404
4407
  var _a, _b, _c;
4405
4408
  setPortalEl(
4406
4409
  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
4407
4410
  );
4408
4411
  }, [iframe.enabled, ref.current]);
4409
- const getStyle = (0, import_react27.useCallback)(() => {
4412
+ const getStyle = (0, import_react26.useCallback)(() => {
4410
4413
  var _a, _b, _c;
4411
4414
  if (!ref.current) return;
4412
4415
  const rect = ref.current.getBoundingClientRect();
@@ -4426,11 +4429,11 @@ var DraggableComponent = ({
4426
4429
  };
4427
4430
  return style2;
4428
4431
  }, [ref.current]);
4429
- const [style, setStyle] = (0, import_react27.useState)();
4430
- const sync = (0, import_react27.useCallback)(() => {
4432
+ const [style, setStyle] = (0, import_react26.useState)();
4433
+ const sync = (0, import_react26.useCallback)(() => {
4431
4434
  setStyle(getStyle());
4432
4435
  }, [ref.current, iframe]);
4433
- (0, import_react27.useEffect)(() => {
4436
+ (0, import_react26.useEffect)(() => {
4434
4437
  if (ref.current && !userIsDragging) {
4435
4438
  const observer = new ResizeObserver(sync);
4436
4439
  observer.observe(ref.current);
@@ -4440,18 +4443,18 @@ var DraggableComponent = ({
4440
4443
  }
4441
4444
  }, [ref.current, userIsDragging]);
4442
4445
  const registerNode = useAppStore((s) => s.nodes.registerNode);
4443
- (0, import_react27.useEffect)(() => {
4446
+ (0, import_react26.useEffect)(() => {
4444
4447
  var _a;
4445
4448
  registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
4446
4449
  return () => {
4447
4450
  registerNode(id, { methods: { sync: () => null }, element: null });
4448
4451
  };
4449
4452
  }, [id, zoneCompound, index, componentType, sync]);
4450
- const CustomActionBar = (0, import_react27.useMemo)(
4453
+ const CustomActionBar = (0, import_react26.useMemo)(
4451
4454
  () => overrides.actionBar || DefaultActionBar,
4452
4455
  [overrides.actionBar]
4453
4456
  );
4454
- const onClick = (0, import_react27.useCallback)(
4457
+ const onClick = (0, import_react26.useCallback)(
4455
4458
  (e) => {
4456
4459
  e.stopPropagation();
4457
4460
  dispatch({
@@ -4464,7 +4467,7 @@ var DraggableComponent = ({
4464
4467
  [index, zoneCompound, id]
4465
4468
  );
4466
4469
  const appStore = useAppStoreApi();
4467
- const onSelectParent = (0, import_react27.useCallback)(() => {
4470
+ const onSelectParent = (0, import_react26.useCallback)(() => {
4468
4471
  const { nodes } = appStore.getState().nodes;
4469
4472
  const node = nodes[id];
4470
4473
  const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
@@ -4481,23 +4484,23 @@ var DraggableComponent = ({
4481
4484
  }
4482
4485
  });
4483
4486
  }, [ctx, path]);
4484
- const onDuplicate = (0, import_react27.useCallback)(() => {
4487
+ const onDuplicate = (0, import_react26.useCallback)(() => {
4485
4488
  dispatch({
4486
4489
  type: "duplicate",
4487
4490
  sourceIndex: index,
4488
4491
  sourceZone: zoneCompound
4489
4492
  });
4490
4493
  }, [index, zoneCompound]);
4491
- const onDelete = (0, import_react27.useCallback)(() => {
4494
+ const onDelete = (0, import_react26.useCallback)(() => {
4492
4495
  dispatch({
4493
4496
  type: "remove",
4494
4497
  index,
4495
4498
  zone: zoneCompound
4496
4499
  });
4497
4500
  }, [index, zoneCompound]);
4498
- const [hover, setHover] = (0, import_react27.useState)(false);
4501
+ const [hover, setHover] = (0, import_react26.useState)(false);
4499
4502
  const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
4500
- (0, import_react27.useEffect)(() => {
4503
+ (0, import_react26.useEffect)(() => {
4501
4504
  if (!ref.current) {
4502
4505
  return;
4503
4506
  }
@@ -4547,7 +4550,7 @@ var DraggableComponent = ({
4547
4550
  thisIsDragging,
4548
4551
  inDroppableZone
4549
4552
  ]);
4550
- (0, import_react27.useEffect)(() => {
4553
+ (0, import_react26.useEffect)(() => {
4551
4554
  if (ref.current && disabled) {
4552
4555
  ref.current.setAttribute("data-puck-disabled", "");
4553
4556
  return () => {
@@ -4556,8 +4559,8 @@ var DraggableComponent = ({
4556
4559
  };
4557
4560
  }
4558
4561
  }, [disabled, ref]);
4559
- const [isVisible, setIsVisible] = (0, import_react27.useState)(false);
4560
- (0, import_react27.useEffect)(() => {
4562
+ const [isVisible, setIsVisible] = (0, import_react26.useState)(false);
4563
+ (0, import_react26.useEffect)(() => {
4561
4564
  sync();
4562
4565
  if ((isSelected || hover || indicativeHover) && !userIsDragging) {
4563
4566
  setIsVisible(true);
@@ -4565,7 +4568,7 @@ var DraggableComponent = ({
4565
4568
  setIsVisible(false);
4566
4569
  }
4567
4570
  }, [isSelected, hover, indicativeHover, iframe, userIsDragging]);
4568
- const syncActionsPosition = (0, import_react27.useCallback)(
4571
+ const syncActionsPosition = (0, import_react26.useCallback)(
4569
4572
  (el) => {
4570
4573
  if (el) {
4571
4574
  const view = el.ownerDocument.defaultView;
@@ -4573,16 +4576,24 @@ var DraggableComponent = ({
4573
4576
  const rect = el.getBoundingClientRect();
4574
4577
  const diffLeft = rect.x;
4575
4578
  const exceedsBoundsLeft = diffLeft < 0;
4579
+ const diffTop = rect.y;
4580
+ const exceedsBoundsTop = diffTop < 0;
4576
4581
  if (exceedsBoundsLeft) {
4577
4582
  el.style.transformOrigin = "left top";
4578
4583
  el.style.left = "0px";
4579
4584
  }
4585
+ if (exceedsBoundsTop) {
4586
+ el.style.top = "12px";
4587
+ if (!exceedsBoundsLeft) {
4588
+ el.style.transformOrigin = "right top";
4589
+ }
4590
+ }
4580
4591
  }
4581
4592
  }
4582
4593
  },
4583
4594
  [zoom]
4584
4595
  );
4585
- (0, import_react27.useEffect)(() => {
4596
+ (0, import_react26.useEffect)(() => {
4586
4597
  if (userDragAxis) {
4587
4598
  setDragAxis(userDragAxis);
4588
4599
  return;
@@ -4675,15 +4686,15 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
4675
4686
 
4676
4687
  // components/DropZone/lib/use-min-empty-height.ts
4677
4688
  init_react_import();
4678
- var import_react28 = require("react");
4689
+ var import_react27 = require("react");
4679
4690
  var useMinEmptyHeight = ({
4680
4691
  zoneCompound,
4681
4692
  userMinEmptyHeight,
4682
4693
  ref
4683
4694
  }) => {
4684
4695
  const appStore = useAppStoreApi();
4685
- const [prevHeight, setPrevHeight] = (0, import_react28.useState)(0);
4686
- const [isAnimating, setIsAnimating] = (0, import_react28.useState)(false);
4696
+ const [prevHeight, setPrevHeight] = (0, import_react27.useState)(0);
4697
+ const [isAnimating, setIsAnimating] = (0, import_react27.useState)(false);
4687
4698
  const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
4688
4699
  var _a, _b;
4689
4700
  return {
@@ -4691,7 +4702,7 @@ var useMinEmptyHeight = ({
4691
4702
  isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
4692
4703
  };
4693
4704
  });
4694
- (0, import_react28.useEffect)(() => {
4705
+ (0, import_react27.useEffect)(() => {
4695
4706
  if (draggedItem && ref.current) {
4696
4707
  if (isZone) {
4697
4708
  const rect = ref.current.getBoundingClientRect();
@@ -4729,15 +4740,15 @@ function assignRefs(refs, node) {
4729
4740
 
4730
4741
  // components/DropZone/lib/use-content-with-preview.ts
4731
4742
  init_react_import();
4732
- var import_react31 = require("react");
4743
+ var import_react30 = require("react");
4733
4744
 
4734
4745
  // lib/dnd/use-rendered-callback.ts
4735
4746
  init_react_import();
4736
- var import_react29 = require("@dnd-kit/react");
4737
- var import_react30 = require("react");
4747
+ var import_react28 = require("@dnd-kit/react");
4748
+ var import_react29 = require("react");
4738
4749
  function useRenderedCallback(callback, deps) {
4739
- const manager = (0, import_react29.useDragDropManager)();
4740
- return (0, import_react30.useCallback)(
4750
+ const manager = (0, import_react28.useDragDropManager)();
4751
+ return (0, import_react29.useCallback)(
4741
4752
  (...args) => __async(this, null, function* () {
4742
4753
  yield manager == null ? void 0 : manager.renderer.rendering;
4743
4754
  return callback(...args);
@@ -4760,8 +4771,8 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4760
4771
  }
4761
4772
  );
4762
4773
  const isDragging = useAppStore((s) => s.state.ui.isDragging);
4763
- const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react31.useState)(contentIds);
4764
- const [localPreview, setLocalPreview] = (0, import_react31.useState)(
4774
+ const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react30.useState)(contentIds);
4775
+ const [localPreview, setLocalPreview] = (0, import_react30.useState)(
4765
4776
  preview
4766
4777
  );
4767
4778
  const updateContent = useRenderedCallback(
@@ -4796,7 +4807,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4796
4807
  },
4797
4808
  [draggedItemId, previewExists]
4798
4809
  );
4799
- (0, import_react31.useEffect)(() => {
4810
+ (0, import_react30.useEffect)(() => {
4800
4811
  updateContent(contentIds, preview, isDragging);
4801
4812
  }, [contentIds, preview, isDragging]);
4802
4813
  return [contentIdsWithPreview, localPreview];
@@ -4804,16 +4815,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4804
4815
 
4805
4816
  // components/DropZone/lib/use-drag-axis.ts
4806
4817
  init_react_import();
4807
- var import_react32 = require("react");
4818
+ var import_react31 = require("react");
4808
4819
  var GRID_DRAG_AXIS = "dynamic";
4809
4820
  var FLEX_ROW_DRAG_AXIS = "x";
4810
4821
  var DEFAULT_DRAG_AXIS = "y";
4811
4822
  var useDragAxis = (ref, collisionAxis) => {
4812
4823
  const status = useAppStore((s) => s.status);
4813
- const [dragAxis, setDragAxis] = (0, import_react32.useState)(
4824
+ const [dragAxis, setDragAxis] = (0, import_react31.useState)(
4814
4825
  collisionAxis || DEFAULT_DRAG_AXIS
4815
4826
  );
4816
- const calculateDragAxis = (0, import_react32.useCallback)(() => {
4827
+ const calculateDragAxis = (0, import_react31.useCallback)(() => {
4817
4828
  if (ref.current) {
4818
4829
  const computedStyle = window.getComputedStyle(ref.current);
4819
4830
  if (computedStyle.display === "grid") {
@@ -4825,7 +4836,7 @@ var useDragAxis = (ref, collisionAxis) => {
4825
4836
  }
4826
4837
  }
4827
4838
  }, [ref.current]);
4828
- (0, import_react32.useEffect)(() => {
4839
+ (0, import_react31.useEffect)(() => {
4829
4840
  const onViewportChange = () => {
4830
4841
  calculateDragAxis();
4831
4842
  };
@@ -4834,7 +4845,7 @@ var useDragAxis = (ref, collisionAxis) => {
4834
4845
  window.removeEventListener("viewportchange", onViewportChange);
4835
4846
  };
4836
4847
  }, []);
4837
- (0, import_react32.useEffect)(calculateDragAxis, [status, collisionAxis]);
4848
+ (0, import_react31.useEffect)(calculateDragAxis, [status, collisionAxis]);
4838
4849
  return [dragAxis, calculateDragAxis];
4839
4850
  };
4840
4851
 
@@ -4843,9 +4854,9 @@ var import_shallow3 = require("zustand/react/shallow");
4843
4854
 
4844
4855
  // components/Render/index.tsx
4845
4856
  init_react_import();
4846
- var import_react33 = __toESM(require("react"));
4857
+ var import_react32 = __toESM(require("react"));
4847
4858
  var import_jsx_runtime21 = require("react/jsx-runtime");
4848
- var renderContext = import_react33.default.createContext({
4859
+ var renderContext = import_react32.default.createContext({
4849
4860
  config: { components: {} },
4850
4861
  data: { root: {}, content: [] },
4851
4862
  metadata: {}
@@ -4924,7 +4935,7 @@ var DropZoneChild = ({
4924
4935
  dragRef: null,
4925
4936
  metadata
4926
4937
  };
4927
- const ctx = (0, import_react34.useContext)(dropZoneContext);
4938
+ const ctx = (0, import_react33.useContext)(dropZoneContext);
4928
4939
  const { depth } = ctx;
4929
4940
  const contentItem = useAppStore(
4930
4941
  (0, import_shallow3.useShallow)((s) => {
@@ -4953,7 +4964,7 @@ var DropZoneChild = ({
4953
4964
  }
4954
4965
  );
4955
4966
  let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
4956
- const renderPreview = (0, import_react34.useMemo)(
4967
+ const renderPreview = (0, import_react33.useMemo)(
4957
4968
  () => function Preview4() {
4958
4969
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
4959
4970
  },
@@ -5000,7 +5011,7 @@ var DropZoneChild = ({
5000
5011
  }
5001
5012
  );
5002
5013
  };
5003
- var DropZoneEdit = (0, import_react34.forwardRef)(
5014
+ var DropZoneEdit = (0, import_react33.forwardRef)(
5004
5015
  function DropZoneEditInternal({
5005
5016
  zone,
5006
5017
  allow,
@@ -5010,7 +5021,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5010
5021
  minEmptyHeight: userMinEmptyHeight = 128,
5011
5022
  collisionAxis
5012
5023
  }, userRef) {
5013
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5024
+ const ctx = (0, import_react33.useContext)(dropZoneContext);
5014
5025
  const {
5015
5026
  // These all need setting via context
5016
5027
  areaId,
@@ -5047,7 +5058,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5047
5058
  userIsDragging: !!s.draggedItem
5048
5059
  };
5049
5060
  });
5050
- (0, import_react34.useEffect)(() => {
5061
+ (0, import_react33.useEffect)(() => {
5051
5062
  if (ctx == null ? void 0 : ctx.registerZone) {
5052
5063
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5053
5064
  }
@@ -5066,8 +5077,8 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5066
5077
  return content.map(({ props }) => props.id);
5067
5078
  })
5068
5079
  );
5069
- const ref = (0, import_react34.useRef)(null);
5070
- const acceptsTarget = (0, import_react34.useCallback)(
5080
+ const ref = (0, import_react33.useRef)(null);
5081
+ const acceptsTarget = (0, import_react33.useCallback)(
5071
5082
  (componentType) => {
5072
5083
  if (!componentType) {
5073
5084
  return true;
@@ -5089,7 +5100,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5089
5100
  },
5090
5101
  [allow, disallow]
5091
5102
  );
5092
- (0, import_react34.useEffect)(() => {
5103
+ (0, import_react33.useEffect)(() => {
5093
5104
  if (registerLocalZone) {
5094
5105
  registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
5095
5106
  }
@@ -5179,14 +5190,14 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5179
5190
  }
5180
5191
  );
5181
5192
  var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
5182
- var DropZoneRender = (0, import_react34.forwardRef)(
5193
+ var DropZoneRender = (0, import_react33.forwardRef)(
5183
5194
  function DropZoneRenderInternal({ className, style, zone }, ref) {
5184
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5195
+ const ctx = (0, import_react33.useContext)(dropZoneContext);
5185
5196
  const { areaId = "root" } = ctx || {};
5186
- const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
5197
+ const { config, data, metadata } = (0, import_react33.useContext)(renderContext);
5187
5198
  let zoneCompound = rootDroppableId;
5188
5199
  let content = (data == null ? void 0 : data.content) || [];
5189
- (0, import_react34.useEffect)(() => {
5200
+ (0, import_react33.useEffect)(() => {
5190
5201
  if (ctx == null ? void 0 : ctx.registerZone) {
5191
5202
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5192
5203
  }
@@ -5231,9 +5242,9 @@ var DropZoneRender = (0, import_react34.forwardRef)(
5231
5242
  }
5232
5243
  );
5233
5244
  var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZone, __spreadValues({}, props));
5234
- var DropZone = (0, import_react34.forwardRef)(
5245
+ var DropZone = (0, import_react33.forwardRef)(
5235
5246
  function DropZone2(props, ref) {
5236
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5247
+ const ctx = (0, import_react33.useContext)(dropZoneContext);
5237
5248
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
5238
5249
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
5239
5250
  }
@@ -5553,12 +5564,12 @@ function getDeepDir(el) {
5553
5564
  // components/DragDropContext/index.tsx
5554
5565
  var import_jsx_runtime23 = require("react/jsx-runtime");
5555
5566
  var DEBUG3 = false;
5556
- var dragListenerContext = (0, import_react36.createContext)({
5567
+ var dragListenerContext = (0, import_react35.createContext)({
5557
5568
  dragListeners: {}
5558
5569
  });
5559
5570
  function useDragListener(type, fn, deps = []) {
5560
- const { setDragListeners } = (0, import_react36.useContext)(dragListenerContext);
5561
- (0, import_react36.useEffect)(() => {
5571
+ const { setDragListeners } = (0, import_react35.useContext)(dragListenerContext);
5572
+ (0, import_react35.useEffect)(() => {
5562
5573
  if (setDragListeners) {
5563
5574
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
5564
5575
  [type]: [...old[type] || [], fn]
@@ -5568,8 +5579,8 @@ function useDragListener(type, fn, deps = []) {
5568
5579
  }
5569
5580
  var AREA_CHANGE_DEBOUNCE_MS = 100;
5570
5581
  var useTempDisableFallback = (timeout3) => {
5571
- const lastFallbackDisable = (0, import_react36.useRef)(null);
5572
- return (0, import_react36.useCallback)((manager) => {
5582
+ const lastFallbackDisable = (0, import_react35.useRef)(null);
5583
+ return (0, import_react35.useCallback)((manager) => {
5573
5584
  collisionStore.setState({ fallbackEnabled: false });
5574
5585
  const fallbackId = generateId();
5575
5586
  lastFallbackDisable.current = fallbackId;
@@ -5591,9 +5602,9 @@ var DragDropContextClient = ({
5591
5602
  const metadata = useAppStore((s) => s.metadata);
5592
5603
  const appStore = useAppStoreApi();
5593
5604
  const id = useSafeId();
5594
- const debouncedParamsRef = (0, import_react36.useRef)(null);
5605
+ const debouncedParamsRef = (0, import_react35.useRef)(null);
5595
5606
  const tempDisableFallback = useTempDisableFallback(100);
5596
- const [zoneStore] = (0, import_react36.useState)(
5607
+ const [zoneStore] = (0, import_react35.useState)(
5597
5608
  () => (0, import_zustand5.createStore)(() => ({
5598
5609
  zoneDepthIndex: {},
5599
5610
  nextZoneDepthIndex: {},
@@ -5603,7 +5614,7 @@ var DragDropContextClient = ({
5603
5614
  previewIndex: {}
5604
5615
  }))
5605
5616
  );
5606
- const getChanged2 = (0, import_react36.useCallback)(
5617
+ const getChanged2 = (0, import_react35.useCallback)(
5607
5618
  (params, id2) => {
5608
5619
  const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
5609
5620
  const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
@@ -5624,7 +5635,7 @@ var DragDropContextClient = ({
5624
5635
  },
5625
5636
  [zoneStore]
5626
5637
  );
5627
- const setDeepestAndCollide = (0, import_react36.useCallback)(
5638
+ const setDeepestAndCollide = (0, import_react35.useCallback)(
5628
5639
  (params, manager) => {
5629
5640
  const { zoneChanged, areaChanged } = getChanged2(params, id);
5630
5641
  if (!zoneChanged && !areaChanged) return;
@@ -5648,7 +5659,7 @@ var DragDropContextClient = ({
5648
5659
  setDeepestDb.cancel();
5649
5660
  debouncedParamsRef.current = null;
5650
5661
  };
5651
- (0, import_react36.useEffect)(() => {
5662
+ (0, import_react35.useEffect)(() => {
5652
5663
  if (DEBUG3) {
5653
5664
  zoneStore.subscribe(
5654
5665
  (s) => {
@@ -5662,7 +5673,7 @@ var DragDropContextClient = ({
5662
5673
  );
5663
5674
  }
5664
5675
  }, []);
5665
- const [plugins] = (0, import_react36.useState)(() => [
5676
+ const [plugins] = (0, import_react35.useState)(() => [
5666
5677
  ...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
5667
5678
  createNestedDroppablePlugin(
5668
5679
  {
@@ -5710,9 +5721,9 @@ var DragDropContextClient = ({
5710
5721
  )
5711
5722
  ]);
5712
5723
  const sensors = useSensors();
5713
- const [dragListeners, setDragListeners] = (0, import_react36.useState)({});
5714
- const dragMode = (0, import_react36.useRef)(null);
5715
- const initialSelector = (0, import_react36.useRef)(void 0);
5724
+ const [dragListeners, setDragListeners] = (0, import_react35.useState)({});
5725
+ const dragMode = (0, import_react35.useRef)(null);
5726
+ const initialSelector = (0, import_react35.useRef)(void 0);
5716
5727
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5717
5728
  dragListenerContext.Provider,
5718
5729
  {
@@ -5721,7 +5732,7 @@ var DragDropContextClient = ({
5721
5732
  setDragListeners
5722
5733
  },
5723
5734
  children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5724
- import_react35.DragDropProvider,
5735
+ import_react34.DragDropProvider,
5725
5736
  {
5726
5737
  plugins,
5727
5738
  sensors,
@@ -5951,7 +5962,7 @@ var DrawerItemInner = ({
5951
5962
  dragRef,
5952
5963
  isDragDisabled
5953
5964
  }) => {
5954
- const CustomInner = (0, import_react37.useMemo)(
5965
+ const CustomInner = (0, import_react36.useMemo)(
5955
5966
  () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
5956
5967
  [children]
5957
5968
  );
@@ -6005,7 +6016,7 @@ var DrawerItem = ({
6005
6016
  isDragDisabled
6006
6017
  }) => {
6007
6018
  const resolvedId = id || name;
6008
- const [dynamicId, setDynamicId] = (0, import_react37.useState)(generateId(resolvedId));
6019
+ const [dynamicId, setDynamicId] = (0, import_react36.useState)(generateId(resolvedId));
6009
6020
  if (typeof index !== "undefined") {
6010
6021
  console.error(
6011
6022
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -6066,7 +6077,7 @@ Drawer.Item = DrawerItem;
6066
6077
 
6067
6078
  // components/Puck/index.tsx
6068
6079
  init_react_import();
6069
- var import_react52 = require("react");
6080
+ var import_react51 = require("react");
6070
6081
 
6071
6082
  // components/SidebarSection/index.tsx
6072
6083
  init_react_import();
@@ -6077,7 +6088,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
6077
6088
 
6078
6089
  // lib/use-breadcrumbs.ts
6079
6090
  init_react_import();
6080
- var import_react38 = require("react");
6091
+ var import_react37 = require("react");
6081
6092
  var useBreadcrumbs = (renderCount) => {
6082
6093
  const selectedId = useAppStore((s) => {
6083
6094
  var _a;
@@ -6089,7 +6100,7 @@ var useBreadcrumbs = (renderCount) => {
6089
6100
  return (_a = s.nodes.nodes[selectedId]) == null ? void 0 : _a.path;
6090
6101
  });
6091
6102
  const appStore = useAppStoreApi();
6092
- return (0, import_react38.useMemo)(() => {
6103
+ return (0, import_react37.useMemo)(() => {
6093
6104
  const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
6094
6105
  var _a, _b;
6095
6106
  const [componentId] = zoneCompound.split(":");
@@ -6214,7 +6225,7 @@ init_react_import();
6214
6225
  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" };
6215
6226
 
6216
6227
  // components/Puck/components/Fields/index.tsx
6217
- var import_react39 = require("react");
6228
+ var import_react38 = require("react");
6218
6229
  var import_shallow4 = require("zustand/react/shallow");
6219
6230
  var import_jsx_runtime27 = require("react/jsx-runtime");
6220
6231
  var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
@@ -6309,7 +6320,7 @@ var FieldsChild = ({ fieldName }) => {
6309
6320
  })
6310
6321
  );
6311
6322
  const appStore = useAppStoreApi();
6312
- const onChange = (0, import_react39.useCallback)(createOnChange(fieldName, appStore), [
6323
+ const onChange = (0, import_react38.useCallback)(createOnChange(fieldName, appStore), [
6313
6324
  fieldName
6314
6325
  ]);
6315
6326
  if (!field || !id) return null;
@@ -6344,7 +6355,7 @@ var Fields = ({ wrapFields = true }) => {
6344
6355
  (0, import_shallow4.useShallow)((s) => Object.keys(s.fields.fields))
6345
6356
  );
6346
6357
  const isLoading = fieldsLoading || componentResolving;
6347
- const Wrapper = (0, import_react39.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6358
+ const Wrapper = (0, import_react38.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6348
6359
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
6349
6360
  "form",
6350
6361
  {
@@ -6365,7 +6376,7 @@ init_react_import();
6365
6376
 
6366
6377
  // lib/use-component-list.tsx
6367
6378
  init_react_import();
6368
- var import_react40 = require("react");
6379
+ var import_react39 = require("react");
6369
6380
 
6370
6381
  // components/ComponentList/index.tsx
6371
6382
  init_react_import();
@@ -6436,10 +6447,10 @@ ComponentList.Item = ComponentListItem;
6436
6447
  // lib/use-component-list.tsx
6437
6448
  var import_jsx_runtime29 = require("react/jsx-runtime");
6438
6449
  var useComponentList = () => {
6439
- const [componentList, setComponentList] = (0, import_react40.useState)();
6450
+ const [componentList, setComponentList] = (0, import_react39.useState)();
6440
6451
  const config = useAppStore((s) => s.config);
6441
6452
  const uiComponentList = useAppStore((s) => s.state.ui.componentList);
6442
- (0, import_react40.useEffect)(() => {
6453
+ (0, import_react39.useEffect)(() => {
6443
6454
  var _a, _b, _c;
6444
6455
  if (Object.keys(uiComponentList).length > 0) {
6445
6456
  const matchedComponents = [];
@@ -6508,22 +6519,22 @@ var useComponentList = () => {
6508
6519
  };
6509
6520
 
6510
6521
  // components/Puck/components/Components/index.tsx
6511
- var import_react41 = require("react");
6522
+ var import_react40 = require("react");
6512
6523
  var import_jsx_runtime30 = require("react/jsx-runtime");
6513
6524
  var Components = () => {
6514
6525
  const overrides = useAppStore((s) => s.overrides);
6515
6526
  const componentList = useComponentList();
6516
- const Wrapper = (0, import_react41.useMemo)(() => overrides.components || "div", [overrides]);
6527
+ const Wrapper = (0, import_react40.useMemo)(() => overrides.components || "div", [overrides]);
6517
6528
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
6518
6529
  };
6519
6530
 
6520
6531
  // components/Puck/components/Preview/index.tsx
6521
6532
  init_react_import();
6522
- var import_react43 = require("react");
6533
+ var import_react42 = require("react");
6523
6534
 
6524
6535
  // components/AutoFrame/index.tsx
6525
6536
  init_react_import();
6526
- var import_react42 = require("react");
6537
+ var import_react41 = require("react");
6527
6538
  var import_object_hash = __toESM(require("object-hash"));
6528
6539
  var import_react_dom3 = require("react-dom");
6529
6540
  var import_jsx_runtime31 = require("react/jsx-runtime");
@@ -6569,7 +6580,7 @@ var CopyHostStyles = ({
6569
6580
  onStylesLoaded = () => null
6570
6581
  }) => {
6571
6582
  const { document: doc, window: win } = useFrame();
6572
- (0, import_react42.useEffect)(() => {
6583
+ (0, import_react41.useEffect)(() => {
6573
6584
  if (!win || !doc) {
6574
6585
  return () => {
6575
6586
  };
@@ -6728,8 +6739,8 @@ var CopyHostStyles = ({
6728
6739
  }, []);
6729
6740
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
6730
6741
  };
6731
- var autoFrameContext = (0, import_react42.createContext)({});
6732
- var useFrame = () => (0, import_react42.useContext)(autoFrameContext);
6742
+ var autoFrameContext = (0, import_react41.createContext)({});
6743
+ var useFrame = () => (0, import_react41.useContext)(autoFrameContext);
6733
6744
  function AutoFrame(_a) {
6734
6745
  var _b = _a, {
6735
6746
  children,
@@ -6750,11 +6761,11 @@ function AutoFrame(_a) {
6750
6761
  "onNotReady",
6751
6762
  "frameRef"
6752
6763
  ]);
6753
- const [loaded, setLoaded] = (0, import_react42.useState)(false);
6754
- const [ctx, setCtx] = (0, import_react42.useState)({});
6755
- const [mountTarget, setMountTarget] = (0, import_react42.useState)();
6756
- const [stylesLoaded, setStylesLoaded] = (0, import_react42.useState)(false);
6757
- (0, import_react42.useEffect)(() => {
6764
+ const [loaded, setLoaded] = (0, import_react41.useState)(false);
6765
+ const [ctx, setCtx] = (0, import_react41.useState)({});
6766
+ const [mountTarget, setMountTarget] = (0, import_react41.useState)();
6767
+ const [stylesLoaded, setStylesLoaded] = (0, import_react41.useState)(false);
6768
+ (0, import_react41.useEffect)(() => {
6758
6769
  var _a2;
6759
6770
  if (frameRef.current) {
6760
6771
  const doc = frameRef.current.contentDocument;
@@ -6806,7 +6817,7 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
6806
6817
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
6807
6818
  var useBubbleIframeEvents = (ref) => {
6808
6819
  const status = useAppStore((s) => s.status);
6809
- (0, import_react43.useEffect)(() => {
6820
+ (0, import_react42.useEffect)(() => {
6810
6821
  if (ref.current && status === "READY") {
6811
6822
  const iframe = ref.current;
6812
6823
  const handlePointerMove = (event) => {
@@ -6855,7 +6866,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
6855
6866
  const renderData = useAppStore(
6856
6867
  (s) => s.state.ui.previewMode === "edit" ? null : s.state.data
6857
6868
  );
6858
- const Page = (0, import_react43.useCallback)(
6869
+ const Page = (0, import_react42.useCallback)(
6859
6870
  (pageProps) => {
6860
6871
  var _a, _b;
6861
6872
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
@@ -6864,9 +6875,9 @@ var Preview3 = ({ id = "puck-preview" }) => {
6864
6875
  },
6865
6876
  [config.root]
6866
6877
  );
6867
- const Frame = (0, import_react43.useMemo)(() => overrides.iframe, [overrides]);
6878
+ const Frame = (0, import_react42.useMemo)(() => overrides.iframe, [overrides]);
6868
6879
  const rootProps = root.props || root;
6869
- const ref = (0, import_react43.useRef)(null);
6880
+ const ref = (0, import_react42.useRef)(null);
6870
6881
  useBubbleIframeEvents(ref);
6871
6882
  const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6872
6883
  Page,
@@ -6881,7 +6892,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
6881
6892
  children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZonePure, { zone: rootDroppableId })
6882
6893
  })
6883
6894
  ) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Render, { data: renderData, config });
6884
- (0, import_react43.useEffect)(() => {
6895
+ (0, import_react42.useEffect)(() => {
6885
6896
  if (!iframe.enabled) {
6886
6897
  setStatus("READY");
6887
6898
  }
@@ -6972,7 +6983,7 @@ var scrollIntoView = (el) => {
6972
6983
  };
6973
6984
 
6974
6985
  // components/LayerTree/index.tsx
6975
- var import_react44 = require("react");
6986
+ var import_react43 = require("react");
6976
6987
 
6977
6988
  // lib/on-scroll-end.ts
6978
6989
  init_react_import();
@@ -7007,7 +7018,7 @@ var LayerTree = ({
7007
7018
  label
7008
7019
  }) => {
7009
7020
  const zones = data.zones || {};
7010
- const ctx = (0, import_react44.useContext)(dropZoneContext);
7021
+ const ctx = (0, import_react43.useContext)(dropZoneContext);
7011
7022
  const nodes = useAppStore((s) => s.nodes.nodes);
7012
7023
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
7013
7024
  label && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
@@ -7119,7 +7130,7 @@ var LayerTree = ({
7119
7130
  };
7120
7131
 
7121
7132
  // components/Puck/components/Outline/index.tsx
7122
- var import_react45 = require("react");
7133
+ var import_react44 = require("react");
7123
7134
  var import_jsx_runtime34 = require("react/jsx-runtime");
7124
7135
  var Outline = () => {
7125
7136
  const state = useAppStore((s) => s.state);
@@ -7128,7 +7139,7 @@ var Outline = () => {
7128
7139
  const { data, ui } = state;
7129
7140
  const { itemSelector } = ui;
7130
7141
  const appStore = useAppStoreApi();
7131
- const setItemSelector = (0, import_react45.useCallback)(
7142
+ const setItemSelector = (0, import_react44.useCallback)(
7132
7143
  (newItemSelector) => {
7133
7144
  const { dispatch } = appStore.getState();
7134
7145
  dispatch({
@@ -7138,7 +7149,7 @@ var Outline = () => {
7138
7149
  },
7139
7150
  [appStore]
7140
7151
  );
7141
- const Wrapper = (0, import_react45.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7152
+ const Wrapper = (0, import_react44.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7142
7153
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
7143
7154
  (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7144
7155
  LayerTree,
@@ -7294,11 +7305,11 @@ var getBox = function getBox2(el) {
7294
7305
  };
7295
7306
 
7296
7307
  // components/Puck/components/Canvas/index.tsx
7297
- var import_react47 = require("react");
7308
+ var import_react46 = require("react");
7298
7309
 
7299
7310
  // components/ViewportControls/index.tsx
7300
7311
  init_react_import();
7301
- var import_react46 = require("react");
7312
+ var import_react45 = require("react");
7302
7313
 
7303
7314
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7304
7315
  init_react_import();
@@ -7321,8 +7332,8 @@ var ViewportButton = ({
7321
7332
  onClick
7322
7333
  }) => {
7323
7334
  const viewports = useAppStore((s) => s.state.ui.viewports);
7324
- const [isActive, setIsActive] = (0, import_react46.useState)(false);
7325
- (0, import_react46.useEffect)(() => {
7335
+ const [isActive, setIsActive] = (0, import_react45.useState)(false);
7336
+ (0, import_react45.useEffect)(() => {
7326
7337
  setIsActive(width === viewports.current.width);
7327
7338
  }, [width, viewports.current.width]);
7328
7339
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
@@ -7358,7 +7369,7 @@ var ViewportControls = ({
7358
7369
  const defaultsContainAutoZoom = defaultZoomOptions.find(
7359
7370
  (option) => option.value === autoZoom
7360
7371
  );
7361
- const zoomOptions = (0, import_react46.useMemo)(
7372
+ const zoomOptions = (0, import_react45.useMemo)(
7362
7373
  () => [
7363
7374
  ...defaultZoomOptions,
7364
7375
  ...defaultsContainAutoZoom ? [] : [
@@ -7505,17 +7516,17 @@ var Canvas = () => {
7505
7516
  viewports: s.state.ui.viewports
7506
7517
  }))
7507
7518
  );
7508
- const frameRef = (0, import_react47.useRef)(null);
7509
- const [showTransition, setShowTransition] = (0, import_react47.useState)(false);
7510
- const defaultRender = (0, import_react47.useMemo)(() => {
7519
+ const frameRef = (0, import_react46.useRef)(null);
7520
+ const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
7521
+ const defaultRender = (0, import_react46.useMemo)(() => {
7511
7522
  const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children });
7512
7523
  return PuckDefault;
7513
7524
  }, []);
7514
- const CustomPreview = (0, import_react47.useMemo)(
7525
+ const CustomPreview = (0, import_react46.useMemo)(
7515
7526
  () => overrides.preview || defaultRender,
7516
7527
  [overrides]
7517
7528
  );
7518
- const getFrameDimensions = (0, import_react47.useCallback)(() => {
7529
+ const getFrameDimensions = (0, import_react46.useCallback)(() => {
7519
7530
  if (frameRef.current) {
7520
7531
  const frame = frameRef.current;
7521
7532
  const box = getBox(frame);
@@ -7523,7 +7534,7 @@ var Canvas = () => {
7523
7534
  }
7524
7535
  return { width: 0, height: 0 };
7525
7536
  }, [frameRef]);
7526
- const resetAutoZoom = (0, import_react47.useCallback)(
7537
+ const resetAutoZoom = (0, import_react46.useCallback)(
7527
7538
  (newViewports = viewports) => {
7528
7539
  if (frameRef.current) {
7529
7540
  setZoomConfig(
@@ -7537,11 +7548,11 @@ var Canvas = () => {
7537
7548
  },
7538
7549
  [frameRef, zoomConfig, viewports]
7539
7550
  );
7540
- (0, import_react47.useEffect)(() => {
7551
+ (0, import_react46.useEffect)(() => {
7541
7552
  setShowTransition(false);
7542
7553
  resetAutoZoom(viewports);
7543
7554
  }, [frameRef, leftSideBarVisible, rightSideBarVisible]);
7544
- (0, import_react47.useEffect)(() => {
7555
+ (0, import_react46.useEffect)(() => {
7545
7556
  const { height: frameHeight } = getFrameDimensions();
7546
7557
  if (viewports.current.height === "auto") {
7547
7558
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -7549,13 +7560,13 @@ var Canvas = () => {
7549
7560
  }));
7550
7561
  }
7551
7562
  }, [zoomConfig.zoom]);
7552
- (0, import_react47.useEffect)(() => {
7563
+ (0, import_react46.useEffect)(() => {
7553
7564
  if (ZOOM_ON_CHANGE) {
7554
7565
  setShowTransition(true);
7555
7566
  resetAutoZoom(viewports);
7556
7567
  }
7557
7568
  }, [viewports.current.width]);
7558
- (0, import_react47.useEffect)(() => {
7569
+ (0, import_react46.useEffect)(() => {
7559
7570
  const cb = () => {
7560
7571
  setShowTransition(false);
7561
7572
  resetAutoZoom();
@@ -7565,8 +7576,8 @@ var Canvas = () => {
7565
7576
  window.removeEventListener("resize", cb);
7566
7577
  };
7567
7578
  }, []);
7568
- const [showLoader, setShowLoader] = (0, import_react47.useState)(false);
7569
- (0, import_react47.useEffect)(() => {
7579
+ const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
7580
+ (0, import_react46.useEffect)(() => {
7570
7581
  setTimeout(() => {
7571
7582
  setShowLoader(true);
7572
7583
  }, 500);
@@ -7644,7 +7655,7 @@ var Canvas = () => {
7644
7655
 
7645
7656
  // lib/use-loaded-overrides.ts
7646
7657
  init_react_import();
7647
- var import_react48 = require("react");
7658
+ var import_react47 = require("react");
7648
7659
 
7649
7660
  // lib/load-overrides.ts
7650
7661
  init_react_import();
@@ -7683,7 +7694,7 @@ var useLoadedOverrides = ({
7683
7694
  overrides,
7684
7695
  plugins
7685
7696
  }) => {
7686
- return (0, import_react48.useMemo)(() => {
7697
+ return (0, import_react47.useMemo)(() => {
7687
7698
  return loadOverrides({ overrides, plugins });
7688
7699
  }, [plugins, overrides]);
7689
7700
  };
@@ -7695,14 +7706,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37
7695
7706
 
7696
7707
  // lib/use-inject-css.ts
7697
7708
  init_react_import();
7698
- var import_react49 = require("react");
7709
+ var import_react48 = require("react");
7699
7710
  var styles = ``;
7700
7711
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7701
- const [el, setEl] = (0, import_react49.useState)();
7702
- (0, import_react49.useEffect)(() => {
7712
+ const [el, setEl] = (0, import_react48.useState)();
7713
+ (0, import_react48.useEffect)(() => {
7703
7714
  setEl(document.createElement("style"));
7704
7715
  }, []);
7705
- (0, import_react49.useEffect)(() => {
7716
+ (0, import_react48.useEffect)(() => {
7706
7717
  var _a;
7707
7718
  if (!el || typeof window === "undefined") {
7708
7719
  return;
@@ -7722,10 +7733,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
7722
7733
 
7723
7734
  // lib/use-preview-mode-hotkeys.ts
7724
7735
  init_react_import();
7725
- var import_react50 = require("react");
7736
+ var import_react49 = require("react");
7726
7737
  var usePreviewModeHotkeys = () => {
7727
7738
  const appStore = useAppStoreApi();
7728
- const toggleInteractive = (0, import_react50.useCallback)(() => {
7739
+ const toggleInteractive = (0, import_react49.useCallback)(() => {
7729
7740
  const dispatch = appStore.getState().dispatch;
7730
7741
  dispatch({
7731
7742
  type: "setUi",
@@ -7740,7 +7751,7 @@ var usePreviewModeHotkeys = () => {
7740
7751
 
7741
7752
  // lib/use-puck.ts
7742
7753
  init_react_import();
7743
- var import_react51 = require("react");
7754
+ var import_react50 = require("react");
7744
7755
  var import_zustand6 = require("zustand");
7745
7756
  var generateUsePuck = (store) => {
7746
7757
  const history = {
@@ -7765,14 +7776,14 @@ var generateUsePuck = (store) => {
7765
7776
  const get = () => storeData;
7766
7777
  return __spreadProps(__spreadValues({}, storeData), { get });
7767
7778
  };
7768
- var UsePuckStoreContext = (0, import_react51.createContext)(
7779
+ var UsePuckStoreContext = (0, import_react50.createContext)(
7769
7780
  null
7770
7781
  );
7771
7782
  var useRegisterUsePuckStore = (appStore) => {
7772
- const [usePuckStore] = (0, import_react51.useState)(
7783
+ const [usePuckStore] = (0, import_react50.useState)(
7773
7784
  () => (0, import_zustand6.createStore)(() => generateUsePuck(appStore.getState()))
7774
7785
  );
7775
- (0, import_react51.useEffect)(() => {
7786
+ (0, import_react50.useEffect)(() => {
7776
7787
  return appStore.subscribe(
7777
7788
  (store) => {
7778
7789
  const pickedStore = {
@@ -7794,7 +7805,7 @@ var useRegisterUsePuckStore = (appStore) => {
7794
7805
  };
7795
7806
  function createUsePuck() {
7796
7807
  return function usePuck2(selector) {
7797
- const usePuckApi = (0, import_react51.useContext)(UsePuckStoreContext);
7808
+ const usePuckApi = (0, import_react50.useContext)(UsePuckStoreContext);
7798
7809
  if (!usePuckApi) {
7799
7810
  throw new Error("usePuck must be used inside <Puck>.");
7800
7811
  }
@@ -7806,7 +7817,7 @@ function createUsePuck() {
7806
7817
  };
7807
7818
  }
7808
7819
  function usePuck() {
7809
- (0, import_react51.useEffect)(() => {
7820
+ (0, import_react50.useEffect)(() => {
7810
7821
  console.warn(
7811
7822
  "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."
7812
7823
  );
@@ -7827,11 +7838,11 @@ var FieldSideBar = () => {
7827
7838
  );
7828
7839
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Fields, {}) });
7829
7840
  };
7830
- var propsContext = (0, import_react52.createContext)({});
7841
+ var propsContext = (0, import_react51.createContext)({});
7831
7842
  function PropsProvider(props) {
7832
7843
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(propsContext.Provider, { value: props, children: props.children });
7833
7844
  }
7834
- var usePropsContext = () => (0, import_react52.useContext)(propsContext);
7845
+ var usePropsContext = () => (0, import_react51.useContext)(propsContext);
7835
7846
  function PuckProvider({ children }) {
7836
7847
  const {
7837
7848
  config,
@@ -7851,7 +7862,7 @@ function PuckProvider({ children }) {
7851
7862
  enabled: true,
7852
7863
  waitForStyles: true
7853
7864
  }, _iframe);
7854
- const [generatedAppState] = (0, import_react52.useState)(() => {
7865
+ const [generatedAppState] = (0, import_react51.useState)(() => {
7855
7866
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
7856
7867
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
7857
7868
  let clientUiState = {};
@@ -7923,7 +7934,7 @@ function PuckProvider({ children }) {
7923
7934
  overrides,
7924
7935
  plugins
7925
7936
  });
7926
- const generateAppStore = (0, import_react52.useCallback)(() => {
7937
+ const generateAppStore = (0, import_react51.useCallback)(() => {
7927
7938
  return {
7928
7939
  state: initialAppState,
7929
7940
  config,
@@ -7944,8 +7955,8 @@ function PuckProvider({ children }) {
7944
7955
  onAction,
7945
7956
  metadata
7946
7957
  ]);
7947
- const [appStore] = (0, import_react52.useState)(() => createAppStore(generateAppStore()));
7948
- (0, import_react52.useEffect)(() => {
7958
+ const [appStore] = (0, import_react51.useState)(() => createAppStore(generateAppStore()));
7959
+ (0, import_react51.useEffect)(() => {
7949
7960
  appStore.setState(__spreadValues({}, generateAppStore()));
7950
7961
  }, [
7951
7962
  initialAppState,
@@ -7962,7 +7973,7 @@ function PuckProvider({ children }) {
7962
7973
  index: initialHistoryIndex,
7963
7974
  initialAppState
7964
7975
  });
7965
- (0, import_react52.useEffect)(() => {
7976
+ (0, import_react51.useEffect)(() => {
7966
7977
  appStore.subscribe((s) => {
7967
7978
  if (onChange) onChange(s.state.data);
7968
7979
  });
@@ -7970,11 +7981,11 @@ function PuckProvider({ children }) {
7970
7981
  useRegisterNodesSlice(appStore);
7971
7982
  useRegisterPermissionsSlice(appStore, permissions);
7972
7983
  const uPuckStore = useRegisterUsePuckStore(appStore);
7973
- (0, import_react52.useEffect)(() => {
7984
+ (0, import_react51.useEffect)(() => {
7974
7985
  const { state, resolveData: resolveData2 } = appStore.getState();
7975
7986
  resolveData2(state);
7976
7987
  }, []);
7977
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(UsePuckStoreContext, { value: uPuckStore, children }) });
7988
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
7978
7989
  }
7979
7990
  function PuckLayout({ children }) {
7980
7991
  const {
@@ -7997,9 +8008,9 @@ function PuckLayout({ children }) {
7997
8008
  const rightSideBarVisible = useAppStore(
7998
8009
  (s) => s.state.ui.rightSideBarVisible
7999
8010
  );
8000
- const [menuOpen, setMenuOpen] = (0, import_react52.useState)(false);
8011
+ const [menuOpen, setMenuOpen] = (0, import_react51.useState)(false);
8001
8012
  const appStore = useAppStoreApi();
8002
- (0, import_react52.useEffect)(() => {
8013
+ (0, import_react51.useEffect)(() => {
8003
8014
  return appStore.subscribe((s) => {
8004
8015
  if (onChange) onChange(s.state.data);
8005
8016
  });
@@ -8008,7 +8019,7 @@ function PuckLayout({ children }) {
8008
8019
  (s) => s.state.data.root.props || s.state.data.root.props
8009
8020
  );
8010
8021
  const dispatch = useAppStore((s) => s.dispatch);
8011
- const toggleSidebars = (0, import_react52.useCallback)(
8022
+ const toggleSidebars = (0, import_react51.useCallback)(
8012
8023
  (sidebar) => {
8013
8024
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8014
8025
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -8022,7 +8033,7 @@ function PuckLayout({ children }) {
8022
8033
  },
8023
8034
  [dispatch, leftSideBarVisible, rightSideBarVisible]
8024
8035
  );
8025
- (0, import_react52.useEffect)(() => {
8036
+ (0, import_react51.useEffect)(() => {
8026
8037
  if (!window.matchMedia("(min-width: 638px)").matches) {
8027
8038
  dispatch({
8028
8039
  type: "setUi",
@@ -8045,7 +8056,7 @@ function PuckLayout({ children }) {
8045
8056
  window.removeEventListener("resize", handleResize);
8046
8057
  };
8047
8058
  }, []);
8048
- const defaultHeaderRender = (0, import_react52.useMemo)(() => {
8059
+ const defaultHeaderRender = (0, import_react51.useMemo)(() => {
8049
8060
  if (renderHeader) {
8050
8061
  console.warn(
8051
8062
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -8060,7 +8071,7 @@ function PuckLayout({ children }) {
8060
8071
  }
8061
8072
  return DefaultOverride;
8062
8073
  }, [renderHeader]);
8063
- const defaultHeaderActionsRender = (0, import_react52.useMemo)(() => {
8074
+ const defaultHeaderActionsRender = (0, import_react51.useMemo)(() => {
8064
8075
  if (renderHeaderActions) {
8065
8076
  console.warn(
8066
8077
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
@@ -8075,25 +8086,25 @@ function PuckLayout({ children }) {
8075
8086
  return DefaultOverride;
8076
8087
  }, [renderHeader]);
8077
8088
  const overrides = useAppStore((s) => s.overrides);
8078
- const CustomPuck = (0, import_react52.useMemo)(
8089
+ const CustomPuck = (0, import_react51.useMemo)(
8079
8090
  () => overrides.puck || DefaultOverride,
8080
8091
  [overrides]
8081
8092
  );
8082
- const CustomHeader = (0, import_react52.useMemo)(
8093
+ const CustomHeader = (0, import_react51.useMemo)(
8083
8094
  () => overrides.header || defaultHeaderRender,
8084
8095
  [overrides]
8085
8096
  );
8086
- const CustomHeaderActions = (0, import_react52.useMemo)(
8097
+ const CustomHeaderActions = (0, import_react51.useMemo)(
8087
8098
  () => overrides.headerActions || defaultHeaderActionsRender,
8088
8099
  [overrides]
8089
8100
  );
8090
- const [mounted, setMounted] = (0, import_react52.useState)(false);
8091
- (0, import_react52.useEffect)(() => {
8101
+ const [mounted, setMounted] = (0, import_react51.useState)(false);
8102
+ (0, import_react51.useEffect)(() => {
8092
8103
  setMounted(true);
8093
8104
  }, []);
8094
8105
  const ready = useAppStore((s) => s.status === "READY");
8095
8106
  useMonitorHotkeys();
8096
- (0, import_react52.useEffect)(() => {
8107
+ (0, import_react51.useEffect)(() => {
8097
8108
  if (ready && iframe.enabled) {
8098
8109
  const frameDoc = getFrame();
8099
8110
  if (frameDoc) {