@measured/puck 0.19.0-canary.84a836b → 0.19.0-canary.a931e6b

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,7 +2769,6 @@ 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
2774
  children,
@@ -2763,22 +2776,20 @@ var SortableProvider = ({
2763
2776
  onDragEnd,
2764
2777
  onMove
2765
2778
  }) => {
2766
- const [move, setMove] = (0, import_react14.useState)({ source: -1, target: -1 });
2767
- const sensors = useSensors();
2779
+ const sensors = useSensors({
2780
+ mouse: { distance: { value: 5 } }
2781
+ });
2768
2782
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2769
2783
  import_react13.DragDropProvider,
2770
2784
  {
2771
2785
  sensors,
2772
- modifiers: [
2773
- import_modifiers.RestrictToElement.configure({
2774
- element() {
2775
- return document.querySelector("[data-dnd-container]");
2776
- }
2777
- })
2778
- ],
2779
- 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
+ },
2780
2790
  onDragOver: (event, manager) => {
2781
2791
  var _a, _b;
2792
+ event.preventDefault();
2782
2793
  const { operation } = event;
2783
2794
  const { source, target } = operation;
2784
2795
  if (!source || !target) return;
@@ -2786,14 +2797,14 @@ var SortableProvider = ({
2786
2797
  let targetIndex = target.data.index;
2787
2798
  const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
2788
2799
  if (sourceIndex !== targetIndex && source.id !== target.id) {
2789
- const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
2800
+ const collisionPosition = collisionData.direction === "up" ? "before" : "after";
2790
2801
  if (targetIndex >= sourceIndex) {
2791
2802
  targetIndex = targetIndex - 1;
2792
2803
  }
2793
2804
  if (collisionPosition === "after") {
2794
2805
  targetIndex = targetIndex + 1;
2795
2806
  }
2796
- setMove({
2807
+ onMove({
2797
2808
  source: sourceIndex,
2798
2809
  target: targetIndex
2799
2810
  });
@@ -2801,12 +2812,8 @@ var SortableProvider = ({
2801
2812
  },
2802
2813
  onDragEnd: () => {
2803
2814
  setTimeout(() => {
2804
- if (move.source !== -1 && move.target !== -1) {
2805
- onMove(move);
2806
- }
2807
2815
  onDragEnd();
2808
2816
  }, 250);
2809
- setMove({ source: -1, target: -1 });
2810
2817
  },
2811
2818
  children
2812
2819
  }
@@ -2819,7 +2826,11 @@ var Sortable = ({
2819
2826
  children,
2820
2827
  type = "item"
2821
2828
  }) => {
2822
- const { ref: sortableRef, status } = useSortableSafe({
2829
+ const {
2830
+ ref: sortableRef,
2831
+ status,
2832
+ handleRef
2833
+ } = useSortableSafe({
2823
2834
  id,
2824
2835
  type,
2825
2836
  index,
@@ -2827,16 +2838,16 @@ var Sortable = ({
2827
2838
  data: { index },
2828
2839
  collisionDetector: createDynamicCollisionDetector("y")
2829
2840
  });
2830
- return children({ status, ref: sortableRef });
2841
+ return children({ status, ref: sortableRef, handleRef });
2831
2842
  };
2832
2843
 
2833
2844
  // components/AutoField/context.tsx
2834
2845
  init_react_import();
2835
- var import_react15 = require("react");
2846
+ var import_react14 = require("react");
2836
2847
  var import_jsx_runtime6 = require("react/jsx-runtime");
2837
- var NestedFieldContext = (0, import_react15.createContext)({});
2848
+ var NestedFieldContext = (0, import_react14.createContext)({});
2838
2849
  var useNestedFieldContext = () => {
2839
- const context = (0, import_react15.useContext)(NestedFieldContext);
2850
+ const context = (0, import_react14.useContext)(NestedFieldContext);
2840
2851
  return __spreadProps(__spreadValues({}, context), {
2841
2852
  readOnlyFields: context.readOnlyFields || {}
2842
2853
  });
@@ -2850,7 +2861,7 @@ var NestedFieldProvider = ({
2850
2861
  }) => {
2851
2862
  const subPath = `${name}.${subName}`;
2852
2863
  const wildcardSubPath = `${wildcardName}.${subName}`;
2853
- const subReadOnlyFields = (0, import_react15.useMemo)(
2864
+ const subReadOnlyFields = (0, import_react14.useMemo)(
2854
2865
  () => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
2855
2866
  const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
2856
2867
  if (isLocal) {
@@ -2885,6 +2896,7 @@ var ArrayField = ({
2885
2896
  value: _value,
2886
2897
  name,
2887
2898
  label,
2899
+ labelIcon,
2888
2900
  readOnly,
2889
2901
  id,
2890
2902
  Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", __spreadValues({}, props))
@@ -2902,12 +2914,14 @@ var ArrayField = ({
2902
2914
  }),
2903
2915
  openId: ""
2904
2916
  };
2905
- const [localState, setLocalState] = (0, import_react16.useState)({ arrayState, value });
2906
- (0, import_react16.useEffect)(() => {
2907
- setLocalState({ arrayState, value });
2908
- }, [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]);
2909
2923
  const appStore = useAppStoreApi();
2910
- const mapArrayStateToUi = (0, import_react16.useCallback)(
2924
+ const mapArrayStateToUi = (0, import_react15.useCallback)(
2911
2925
  (partialArrayState) => {
2912
2926
  const state = appStore.getState().state;
2913
2927
  return {
@@ -2918,13 +2932,13 @@ var ArrayField = ({
2918
2932
  },
2919
2933
  [arrayState, appStore]
2920
2934
  );
2921
- const getHighestIndex = (0, import_react16.useCallback)(() => {
2935
+ const getHighestIndex = (0, import_react15.useCallback)(() => {
2922
2936
  return arrayState.items.reduce(
2923
2937
  (acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
2924
2938
  -1
2925
2939
  );
2926
2940
  }, [arrayState]);
2927
- const regenerateArrayState = (0, import_react16.useCallback)(
2941
+ const regenerateArrayState = (0, import_react15.useCallback)(
2928
2942
  (value2) => {
2929
2943
  let highestIndex = getHighestIndex();
2930
2944
  const newItems = Array.from(value2 || []).map((item, idx) => {
@@ -2943,16 +2957,18 @@ var ArrayField = ({
2943
2957
  },
2944
2958
  [arrayState]
2945
2959
  );
2946
- (0, import_react16.useEffect)(() => {
2960
+ (0, import_react15.useEffect)(() => {
2947
2961
  if (arrayState.items.length > 0) {
2948
2962
  setUi(mapArrayStateToUi(arrayState));
2949
2963
  }
2950
2964
  }, []);
2951
- const [isDragging, setIsDragging] = (0, import_react16.useState)(false);
2965
+ const [draggedItem, setDraggedItem] = (0, import_react15.useState)("");
2966
+ const isDragging = !!draggedItem;
2952
2967
  const canEdit = useAppStore(
2953
2968
  (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
2954
2969
  );
2955
2970
  const forceReadOnly = !canEdit;
2971
+ const valueRef = (0, import_react15.useRef)(value);
2956
2972
  if (field.type !== "array" || !field.arrayFields) {
2957
2973
  return null;
2958
2974
  }
@@ -2961,16 +2977,22 @@ var ArrayField = ({
2961
2977
  Label2,
2962
2978
  {
2963
2979
  label: label || name,
2964
- icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(List, { size: 16 }),
2980
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(List, { size: 16 }),
2965
2981
  el: "div",
2966
2982
  readOnly,
2967
2983
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2968
2984
  SortableProvider,
2969
2985
  {
2970
- onDragStart: () => setIsDragging(true),
2971
- onDragEnd: () => setIsDragging(false),
2986
+ onDragStart: (id2) => setDraggedItem(id2),
2987
+ onDragEnd: () => {
2988
+ setDraggedItem("");
2989
+ onChange(valueRef.current);
2990
+ },
2972
2991
  onMove: (move) => {
2973
- 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);
2974
2996
  const newArrayStateItems = reorder(
2975
2997
  arrayState.items,
2976
2998
  move.source,
@@ -2983,11 +3005,11 @@ var ArrayField = ({
2983
3005
  })
2984
3006
  };
2985
3007
  setUi(newUi, false);
2986
- onChange(newValue, newUi);
2987
3008
  setLocalState({
2988
3009
  value: newValue,
2989
3010
  arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
2990
3011
  });
3012
+ valueRef.current = newValue;
2991
3013
  },
2992
3014
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
2993
3015
  "div",
@@ -2997,7 +3019,7 @@ var ArrayField = ({
2997
3019
  addDisabled
2998
3020
  }),
2999
3021
  children: [
3000
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
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) => {
3001
3023
  const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
3002
3024
  const data = Array.from(localState.value || [])[i] || {};
3003
3025
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
@@ -3006,7 +3028,7 @@ var ArrayField = ({
3006
3028
  id: _arrayId,
3007
3029
  index: i,
3008
3030
  disabled: readOnly,
3009
- children: ({ status, ref }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3031
+ children: ({ status, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3010
3032
  "div",
3011
3033
  {
3012
3034
  ref,
@@ -3019,6 +3041,7 @@ var ArrayField = ({
3019
3041
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3020
3042
  "div",
3021
3043
  {
3044
+ ref: handleRef,
3022
3045
  onClick: (e) => {
3023
3046
  if (isDragging) return;
3024
3047
  e.preventDefault();
@@ -3055,12 +3078,11 @@ var ArrayField = ({
3055
3078
  0,
3056
3079
  existingValue[i]
3057
3080
  );
3058
- onChange(
3059
- existingValue,
3060
- mapArrayStateToUi(
3061
- regenerateArrayState(existingValue)
3062
- )
3081
+ const newUi = mapArrayStateToUi(
3082
+ regenerateArrayState(existingValue)
3063
3083
  );
3084
+ setUi(newUi, false);
3085
+ onChange(existingValue);
3064
3086
  },
3065
3087
  title: "Duplicate",
3066
3088
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
@@ -3079,12 +3101,13 @@ var ArrayField = ({
3079
3101
  ];
3080
3102
  existingValue.splice(i, 1);
3081
3103
  existingItems.splice(i, 1);
3082
- onChange(
3083
- existingValue,
3104
+ setUi(
3084
3105
  mapArrayStateToUi({
3085
3106
  items: existingItems
3086
- })
3107
+ }),
3108
+ false
3087
3109
  );
3110
+ onChange(existingValue);
3088
3111
  },
3089
3112
  title: "Delete",
3090
3113
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 })
@@ -3096,58 +3119,49 @@ var ArrayField = ({
3096
3119
  ]
3097
3120
  }
3098
3121
  ),
3099
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3100
- "fieldset",
3101
- {
3102
- className: getClassNameItem("fieldset"),
3103
- onPointerDownCapture: (e) => {
3104
- e.stopPropagation();
3105
- },
3106
- children: Object.keys(field.arrayFields).map((subName) => {
3107
- const subField = field.arrayFields[subName];
3108
- const indexName = `${name}[${i}]`;
3109
- const subPath = `${indexName}.${subName}`;
3110
- const localIndexName = `${localName}[${i}]`;
3111
- const localWildcardName = `${localName}[*]`;
3112
- const localSubPath = `${localIndexName}.${subName}`;
3113
- const localWildcardSubPath = `${localWildcardName}.${subName}`;
3114
- const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
3115
- const label2 = subField.label || subName;
3116
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3117
- NestedFieldProvider,
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,
3118
3141
  {
3119
- name: localIndexName,
3120
- wildcardName: localWildcardName,
3121
- subName,
3122
- readOnlyFields,
3123
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3124
- AutoFieldPrivate,
3125
- {
3126
- name: subPath,
3127
- label: label2,
3128
- id: `${_arrayId}_${subName}`,
3129
- readOnly: subReadOnly,
3130
- field: __spreadProps(__spreadValues({}, subField), {
3131
- label: label2
3132
- // May be used by custom fields
3133
- }),
3134
- value: data[subName],
3135
- onChange: (val, ui) => {
3136
- onChange(
3137
- replace(value, i, __spreadProps(__spreadValues({}, data), {
3138
- [subName]: val
3139
- })),
3140
- ui
3141
- );
3142
- }
3143
- }
3144
- )
3145
- },
3146
- subPath
3147
- );
3148
- })
3149
- }
3150
- ) })
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
+ }) }) })
3151
3165
  ]
3152
3166
  }
3153
3167
  )
@@ -3168,7 +3182,8 @@ var ArrayField = ({
3168
3182
  field.defaultItemProps || {}
3169
3183
  ];
3170
3184
  const newArrayState = regenerateArrayState(newValue);
3171
- onChange(newValue, mapArrayStateToUi(newArrayState));
3185
+ setUi(mapArrayStateToUi(newArrayState), false);
3186
+ onChange(newValue);
3172
3187
  },
3173
3188
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Plus, { size: 21 })
3174
3189
  }
@@ -3193,6 +3208,7 @@ var DefaultField = ({
3193
3208
  value: _value,
3194
3209
  name,
3195
3210
  label,
3211
+ labelIcon,
3196
3212
  Label: Label2,
3197
3213
  id
3198
3214
  }) => {
@@ -3201,7 +3217,7 @@ var DefaultField = ({
3201
3217
  Label2,
3202
3218
  {
3203
3219
  label: label || name,
3204
- icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
3220
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
3205
3221
  field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Type, { size: 16 }),
3206
3222
  field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Hash, { size: 16 })
3207
3223
  ] }),
@@ -3244,11 +3260,11 @@ var DefaultField = ({
3244
3260
 
3245
3261
  // components/AutoField/fields/ExternalField/index.tsx
3246
3262
  init_react_import();
3247
- var import_react20 = require("react");
3263
+ var import_react19 = require("react");
3248
3264
 
3249
3265
  // components/ExternalInput/index.tsx
3250
3266
  init_react_import();
3251
- var import_react19 = require("react");
3267
+ var import_react18 = require("react");
3252
3268
 
3253
3269
  // css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
3254
3270
  init_react_import();
@@ -3256,7 +3272,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
3256
3272
 
3257
3273
  // components/Modal/index.tsx
3258
3274
  init_react_import();
3259
- var import_react17 = require("react");
3275
+ var import_react16 = require("react");
3260
3276
 
3261
3277
  // css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
3262
3278
  init_react_import();
@@ -3271,8 +3287,8 @@ var Modal = ({
3271
3287
  onClose,
3272
3288
  isOpen
3273
3289
  }) => {
3274
- const [rootEl, setRootEl] = (0, import_react17.useState)(null);
3275
- (0, import_react17.useEffect)(() => {
3290
+ const [rootEl, setRootEl] = (0, import_react16.useState)(null);
3291
+ (0, import_react16.useEffect)(() => {
3276
3292
  setRootEl(document.getElementById("puck-portal-root"));
3277
3293
  }, []);
3278
3294
  if (!rootEl) {
@@ -3319,7 +3335,7 @@ init_react_import();
3319
3335
 
3320
3336
  // components/Button/Button.tsx
3321
3337
  init_react_import();
3322
- var import_react18 = require("react");
3338
+ var import_react17 = require("react");
3323
3339
 
3324
3340
  // css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
3325
3341
  init_react_import();
@@ -3369,8 +3385,8 @@ var Button = (_a) => {
3369
3385
  "size",
3370
3386
  "loading"
3371
3387
  ]);
3372
- const [loading, setLoading] = (0, import_react18.useState)(loadingProp);
3373
- (0, import_react18.useEffect)(() => setLoading(loadingProp), [loadingProp]);
3388
+ const [loading, setLoading] = (0, import_react17.useState)(loadingProp);
3389
+ (0, import_react17.useEffect)(() => setLoading(loadingProp), [loadingProp]);
3374
3390
  const ElementType = href ? "a" : type ? "button" : "span";
3375
3391
  const dataAttrs = filterDataAttrs(props);
3376
3392
  const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
@@ -3425,28 +3441,28 @@ var ExternalInput = ({
3425
3441
  mapRow = (val) => val,
3426
3442
  filterFields
3427
3443
  } = field || {};
3428
- const [data, setData] = (0, import_react19.useState)([]);
3429
- const [isOpen, setOpen] = (0, import_react19.useState)(false);
3430
- 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);
3431
3447
  const hasFilterFields = !!filterFields;
3432
- const [filters, setFilters] = (0, import_react19.useState)(field.initialFilters || {});
3433
- const [filtersToggled, setFiltersToggled] = (0, import_react19.useState)(hasFilterFields);
3434
- 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)(() => {
3435
3451
  return data.map(mapRow);
3436
3452
  }, [data]);
3437
- const keys = (0, import_react19.useMemo)(() => {
3453
+ const keys = (0, import_react18.useMemo)(() => {
3438
3454
  const validKeys = /* @__PURE__ */ new Set();
3439
3455
  for (const item of mappedData) {
3440
3456
  for (const key of Object.keys(item)) {
3441
- 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])) {
3442
3458
  validKeys.add(key);
3443
3459
  }
3444
3460
  }
3445
3461
  }
3446
3462
  return Array.from(validKeys);
3447
3463
  }, [mappedData]);
3448
- const [searchQuery, setSearchQuery] = (0, import_react19.useState)(field.initialQuery || "");
3449
- const search = (0, import_react19.useCallback)(
3464
+ const [searchQuery, setSearchQuery] = (0, import_react18.useState)(field.initialQuery || "");
3465
+ const search = (0, import_react18.useCallback)(
3450
3466
  (query, filters2) => __async(void 0, null, function* () {
3451
3467
  setIsLoading(true);
3452
3468
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
@@ -3459,7 +3475,7 @@ var ExternalInput = ({
3459
3475
  }),
3460
3476
  [id, field]
3461
3477
  );
3462
- const Footer = (0, import_react19.useCallback)(
3478
+ const Footer = (0, import_react18.useCallback)(
3463
3479
  (props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
3464
3480
  props.items.length,
3465
3481
  " result",
@@ -3467,7 +3483,7 @@ var ExternalInput = ({
3467
3483
  ] }),
3468
3484
  [field.renderFooter]
3469
3485
  );
3470
- (0, import_react19.useEffect)(() => {
3486
+ (0, import_react18.useEffect)(() => {
3471
3487
  search(searchQuery, filters);
3472
3488
  }, []);
3473
3489
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
@@ -3631,6 +3647,7 @@ var ExternalField = ({
3631
3647
  value,
3632
3648
  name,
3633
3649
  label,
3650
+ labelIcon,
3634
3651
  Label: Label2,
3635
3652
  id,
3636
3653
  readOnly
@@ -3638,7 +3655,7 @@ var ExternalField = ({
3638
3655
  var _a, _b, _c;
3639
3656
  const validField = field;
3640
3657
  const deprecatedField = field;
3641
- (0, import_react20.useEffect)(() => {
3658
+ (0, import_react19.useEffect)(() => {
3642
3659
  if (deprecatedField.adaptor) {
3643
3660
  console.error(
3644
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."
@@ -3648,32 +3665,40 @@ var ExternalField = ({
3648
3665
  if (field.type !== "external") {
3649
3666
  return null;
3650
3667
  }
3651
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Label2, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3652
- ExternalInput,
3668
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3669
+ Label2,
3653
3670
  {
3654
- name,
3655
- field: __spreadProps(__spreadValues({}, validField), {
3656
- // DEPRECATED
3657
- placeholder: ((_a = deprecatedField.adaptor) == null ? void 0 : _a.name) ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder || "Select data",
3658
- mapProp: ((_b = deprecatedField.adaptor) == null ? void 0 : _b.mapProp) || validField.mapProp,
3659
- mapRow: validField.mapRow,
3660
- fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(void 0, null, function* () {
3661
- return yield deprecatedField.adaptor.fetchList(
3662
- deprecatedField.adaptorParams
3663
- );
3664
- }) : validField.fetchList
3665
- }),
3666
- onChange,
3667
- value,
3668
- id,
3669
- readOnly
3671
+ label: label || name,
3672
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: 16 }),
3673
+ el: "div",
3674
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3675
+ ExternalInput,
3676
+ {
3677
+ name,
3678
+ field: __spreadProps(__spreadValues({}, validField), {
3679
+ // DEPRECATED
3680
+ placeholder: ((_a = deprecatedField.adaptor) == null ? void 0 : _a.name) ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder || "Select data",
3681
+ mapProp: ((_b = deprecatedField.adaptor) == null ? void 0 : _b.mapProp) || validField.mapProp,
3682
+ mapRow: validField.mapRow,
3683
+ fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(void 0, null, function* () {
3684
+ return yield deprecatedField.adaptor.fetchList(
3685
+ deprecatedField.adaptorParams
3686
+ );
3687
+ }) : validField.fetchList
3688
+ }),
3689
+ onChange,
3690
+ value,
3691
+ id,
3692
+ readOnly
3693
+ }
3694
+ )
3670
3695
  }
3671
- ) });
3696
+ );
3672
3697
  };
3673
3698
 
3674
3699
  // components/AutoField/fields/RadioField/index.tsx
3675
3700
  init_react_import();
3676
- var import_react21 = require("react");
3701
+ var import_react20 = require("react");
3677
3702
 
3678
3703
  // lib/safe-json-parse.ts
3679
3704
  init_react_import();
@@ -3697,9 +3722,10 @@ var RadioField = ({
3697
3722
  name,
3698
3723
  id,
3699
3724
  label,
3725
+ labelIcon,
3700
3726
  Label: Label2
3701
3727
  }) => {
3702
- const flatOptions = (0, import_react21.useMemo)(
3728
+ const flatOptions = (0, import_react20.useMemo)(
3703
3729
  () => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
3704
3730
  [field]
3705
3731
  );
@@ -3709,7 +3735,7 @@ var RadioField = ({
3709
3735
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3710
3736
  Label2,
3711
3737
  {
3712
- icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CircleCheckBig, { size: 16 }),
3738
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CircleCheckBig, { size: 16 }),
3713
3739
  label: label || name,
3714
3740
  readOnly,
3715
3741
  el: "div",
@@ -3749,20 +3775,21 @@ var RadioField = ({
3749
3775
 
3750
3776
  // components/AutoField/fields/SelectField/index.tsx
3751
3777
  init_react_import();
3752
- var import_react22 = require("react");
3778
+ var import_react21 = require("react");
3753
3779
  var import_jsx_runtime15 = require("react/jsx-runtime");
3754
3780
  var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
3755
3781
  var SelectField = ({
3756
3782
  field,
3757
3783
  onChange,
3758
3784
  label,
3785
+ labelIcon,
3759
3786
  Label: Label2,
3760
3787
  value,
3761
3788
  name,
3762
3789
  readOnly,
3763
3790
  id
3764
3791
  }) => {
3765
- const flatOptions = (0, import_react22.useMemo)(
3792
+ const flatOptions = (0, import_react21.useMemo)(
3766
3793
  () => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
3767
3794
  [field]
3768
3795
  );
@@ -3773,7 +3800,7 @@ var SelectField = ({
3773
3800
  Label2,
3774
3801
  {
3775
3802
  label: label || name,
3776
- icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChevronDown, { size: 16 }),
3803
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChevronDown, { size: 16 }),
3777
3804
  readOnly,
3778
3805
  children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3779
3806
  "select",
@@ -3817,24 +3844,33 @@ var TextareaField = ({
3817
3844
  value,
3818
3845
  name,
3819
3846
  label,
3847
+ labelIcon,
3820
3848
  Label: Label2,
3821
3849
  id
3822
3850
  }) => {
3823
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label2, { label: label || name, icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3824
- "textarea",
3851
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3852
+ Label2,
3825
3853
  {
3826
- id,
3827
- className: getClassName13("input"),
3828
- autoComplete: "off",
3829
- name,
3830
- value: typeof value === "undefined" ? "" : value,
3831
- onChange: (e) => onChange(e.currentTarget.value),
3854
+ label: label || name,
3855
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Type, { size: 16 }),
3832
3856
  readOnly,
3833
- tabIndex: readOnly ? -1 : void 0,
3834
- rows: 5,
3835
- placeholder: field.type === "textarea" ? field.placeholder : void 0
3857
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3858
+ "textarea",
3859
+ {
3860
+ id,
3861
+ className: getClassName13("input"),
3862
+ autoComplete: "off",
3863
+ name,
3864
+ value: typeof value === "undefined" ? "" : value,
3865
+ onChange: (e) => onChange(e.currentTarget.value),
3866
+ readOnly,
3867
+ tabIndex: readOnly ? -1 : void 0,
3868
+ rows: 5,
3869
+ placeholder: field.type === "textarea" ? field.placeholder : void 0
3870
+ }
3871
+ )
3836
3872
  }
3837
- ) });
3873
+ );
3838
3874
  };
3839
3875
 
3840
3876
  // components/AutoField/fields/ObjectField/index.tsx
@@ -3853,6 +3889,7 @@ var ObjectField = ({
3853
3889
  value,
3854
3890
  name,
3855
3891
  label,
3892
+ labelIcon,
3856
3893
  Label: Label2,
3857
3894
  readOnly,
3858
3895
  id
@@ -3866,7 +3903,7 @@ var ObjectField = ({
3866
3903
  Label2,
3867
3904
  {
3868
3905
  label: label || name,
3869
- icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EllipsisVertical, { size: 16 }),
3906
+ icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EllipsisVertical, { size: 16 }),
3870
3907
  el: "div",
3871
3908
  readOnly,
3872
3909
  children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
@@ -3913,12 +3950,12 @@ var ObjectField = ({
3913
3950
 
3914
3951
  // lib/use-safe-id.ts
3915
3952
  init_react_import();
3916
- var import_react23 = __toESM(require("react"));
3953
+ var import_react22 = __toESM(require("react"));
3917
3954
  var useSafeId = () => {
3918
- if (typeof import_react23.default.useId !== "undefined") {
3919
- return import_react23.default.useId();
3955
+ if (typeof import_react22.default.useId !== "undefined") {
3956
+ return import_react22.default.useId();
3920
3957
  }
3921
- const [id] = (0, import_react23.useState)(generateId());
3958
+ const [id] = (0, import_react22.useState)(generateId());
3922
3959
  return id;
3923
3960
  };
3924
3961
 
@@ -3952,7 +3989,7 @@ var FieldLabelInternal = ({
3952
3989
  readOnly
3953
3990
  }) => {
3954
3991
  const overrides = useAppStore((s) => s.overrides);
3955
- const Wrapper = (0, import_react24.useMemo)(
3992
+ const Wrapper = (0, import_react23.useMemo)(
3956
3993
  () => overrides.fieldLabel || FieldLabel,
3957
3994
  [overrides]
3958
3995
  );
@@ -3979,10 +4016,11 @@ function AutoFieldInternal(props) {
3979
4016
  var _a2;
3980
4017
  return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
3981
4018
  });
3982
- const nestedFieldContext = (0, import_react24.useContext)(NestedFieldContext);
4019
+ const nestedFieldContext = (0, import_react23.useContext)(NestedFieldContext);
3983
4020
  const { id, Label: Label2 = FieldLabelInternal } = props;
3984
4021
  const field = props.field;
3985
4022
  const label = field.label;
4023
+ const labelIcon = field.labelIcon;
3986
4024
  const defaultId = useSafeId();
3987
4025
  const resolvedId = id || defaultId;
3988
4026
  const defaultFields = {
@@ -4008,10 +4046,11 @@ function AutoFieldInternal(props) {
4008
4046
  const mergedProps = __spreadProps(__spreadValues({}, props), {
4009
4047
  field,
4010
4048
  label,
4049
+ labelIcon,
4011
4050
  Label: Label2,
4012
4051
  id: resolvedId
4013
4052
  });
4014
- const onFocus = (0, import_react24.useCallback)(
4053
+ const onFocus = (0, import_react23.useCallback)(
4015
4054
  (e) => {
4016
4055
  if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
4017
4056
  e.stopPropagation();
@@ -4025,7 +4064,7 @@ function AutoFieldInternal(props) {
4025
4064
  },
4026
4065
  [mergedProps.name]
4027
4066
  );
4028
- const onBlur = (0, import_react24.useCallback)((e) => {
4067
+ const onBlur = (0, import_react23.useCallback)((e) => {
4029
4068
  if ("name" in e.target) {
4030
4069
  dispatch({
4031
4070
  type: "setUi",
@@ -4069,12 +4108,15 @@ function AutoFieldInternal(props) {
4069
4108
  function AutoFieldPrivate(props) {
4070
4109
  const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
4071
4110
  const { value, onChange } = props;
4072
- const [localValue, setLocalValue] = (0, import_react24.useState)(value);
4073
- const onChangeLocal = (0, import_react24.useCallback)((val, ui) => {
4074
- setLocalValue(val);
4075
- onChange(val, ui);
4076
- }, []);
4077
- (0, import_react24.useEffect)(() => {
4111
+ const [localValue, setLocalValue] = (0, import_react23.useState)(value);
4112
+ const onChangeLocal = (0, import_react23.useCallback)(
4113
+ (val, ui) => {
4114
+ setLocalValue(val);
4115
+ onChange(val, ui);
4116
+ },
4117
+ [onChange]
4118
+ );
4119
+ (0, import_react23.useEffect)(() => {
4078
4120
  if (!isFocused) {
4079
4121
  setLocalValue(value);
4080
4122
  }
@@ -4086,7 +4128,7 @@ function AutoFieldPrivate(props) {
4086
4128
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
4087
4129
  }
4088
4130
  function AutoField(props) {
4089
- const DefaultLabel = (0, import_react24.useMemo)(() => {
4131
+ const DefaultLabel = (0, import_react23.useMemo)(() => {
4090
4132
  const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4091
4133
  "div",
4092
4134
  __spreadProps(__spreadValues({}, labelProps), {
@@ -4106,21 +4148,21 @@ init_react_import();
4106
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" };
4107
4149
 
4108
4150
  // components/Drawer/index.tsx
4109
- var import_react37 = require("react");
4151
+ var import_react36 = require("react");
4110
4152
 
4111
4153
  // components/DragDropContext/index.tsx
4112
4154
  init_react_import();
4113
- var import_react35 = require("@dnd-kit/react");
4114
- var import_react36 = require("react");
4155
+ var import_react34 = require("@dnd-kit/react");
4156
+ var import_react35 = require("react");
4115
4157
  var import_dom = require("@dnd-kit/dom");
4116
4158
 
4117
4159
  // components/DropZone/index.tsx
4118
4160
  init_react_import();
4119
- var import_react34 = require("react");
4161
+ var import_react33 = require("react");
4120
4162
 
4121
4163
  // components/DraggableComponent/index.tsx
4122
4164
  init_react_import();
4123
- var import_react27 = require("react");
4165
+ var import_react26 = require("react");
4124
4166
 
4125
4167
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
4126
4168
  init_react_import();
@@ -4150,11 +4192,11 @@ function getDeepScrollPosition(element) {
4150
4192
 
4151
4193
  // components/DropZone/context.tsx
4152
4194
  init_react_import();
4153
- var import_react25 = require("react");
4195
+ var import_react24 = require("react");
4154
4196
  var import_zustand3 = require("zustand");
4155
4197
  var import_jsx_runtime19 = require("react/jsx-runtime");
4156
- var dropZoneContext = (0, import_react25.createContext)(null);
4157
- var ZoneStoreContext = (0, import_react25.createContext)(
4198
+ var dropZoneContext = (0, import_react24.createContext)(null);
4199
+ var ZoneStoreContext = (0, import_react24.createContext)(
4158
4200
  (0, import_zustand3.createStore)(() => ({
4159
4201
  zoneDepthIndex: {},
4160
4202
  nextZoneDepthIndex: {},
@@ -4174,10 +4216,10 @@ var DropZoneProvider = ({
4174
4216
  children,
4175
4217
  value
4176
4218
  }) => {
4177
- const [hoveringComponent, setHoveringComponent] = (0, import_react25.useState)();
4178
- const [activeZones, setActiveZones] = (0, import_react25.useState)({});
4219
+ const [hoveringComponent, setHoveringComponent] = (0, import_react24.useState)();
4220
+ const [activeZones, setActiveZones] = (0, import_react24.useState)({});
4179
4221
  const dispatch = useAppStore((s) => s.dispatch);
4180
- const registerZone = (0, import_react25.useCallback)(
4222
+ const registerZone = (0, import_react24.useCallback)(
4181
4223
  (zoneCompound) => {
4182
4224
  if (!dispatch) {
4183
4225
  return;
@@ -4190,7 +4232,7 @@ var DropZoneProvider = ({
4190
4232
  },
4191
4233
  [setActiveZones, dispatch]
4192
4234
  );
4193
- const unregisterZone = (0, import_react25.useCallback)(
4235
+ const unregisterZone = (0, import_react24.useCallback)(
4194
4236
  (zoneCompound) => {
4195
4237
  if (!dispatch) {
4196
4238
  return;
@@ -4205,7 +4247,7 @@ var DropZoneProvider = ({
4205
4247
  },
4206
4248
  [setActiveZones, dispatch]
4207
4249
  );
4208
- const memoValue = (0, import_react25.useMemo)(
4250
+ const memoValue = (0, import_react24.useMemo)(
4209
4251
  () => __spreadValues({
4210
4252
  hoveringComponent,
4211
4253
  setHoveringComponent,
@@ -4220,11 +4262,11 @@ var DropZoneProvider = ({
4220
4262
 
4221
4263
  // lib/use-context-store.ts
4222
4264
  init_react_import();
4223
- var import_react26 = require("react");
4265
+ var import_react25 = require("react");
4224
4266
  var import_zustand4 = require("zustand");
4225
4267
  var import_shallow = require("zustand/react/shallow");
4226
4268
  function useContextStore(context, selector) {
4227
- const store = (0, import_react26.useContext)(context);
4269
+ const store = (0, import_react25.useContext)(context);
4228
4270
  if (!store) {
4229
4271
  throw new Error("useContextStore must be used inside context");
4230
4272
  }
@@ -4282,9 +4324,9 @@ var DraggableComponent = ({
4282
4324
  );
4283
4325
  const dispatch = useAppStore((s) => s.dispatch);
4284
4326
  const iframe = useAppStore((s) => s.iframe);
4285
- const ctx = (0, import_react27.useContext)(dropZoneContext);
4286
- const [localZones, setLocalZones] = (0, import_react27.useState)({});
4287
- 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)(
4288
4330
  (zoneCompound2, active) => {
4289
4331
  var _a;
4290
4332
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -4294,7 +4336,7 @@ var DraggableComponent = ({
4294
4336
  },
4295
4337
  [setLocalZones]
4296
4338
  );
4297
- const unregisterLocalZone = (0, import_react27.useCallback)(
4339
+ const unregisterLocalZone = (0, import_react26.useCallback)(
4298
4340
  (zoneCompound2) => {
4299
4341
  var _a;
4300
4342
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -4324,7 +4366,7 @@ var DraggableComponent = ({
4324
4366
  );
4325
4367
  const canCollide = permissions.drag || userIsDragging;
4326
4368
  const disabled = !isEnabled || !canCollide;
4327
- const [dragAxis, setDragAxis] = (0, import_react27.useState)(userDragAxis || autoDragAxis);
4369
+ const [dragAxis, setDragAxis] = (0, import_react26.useState)(userDragAxis || autoDragAxis);
4328
4370
  const { ref: sortableRef, status } = useSortableSafe({
4329
4371
  id,
4330
4372
  index,
@@ -4350,8 +4392,8 @@ var DraggableComponent = ({
4350
4392
  }
4351
4393
  });
4352
4394
  const thisIsDragging = status === "dragging";
4353
- const ref = (0, import_react27.useRef)(null);
4354
- const refSetter = (0, import_react27.useCallback)(
4395
+ const ref = (0, import_react26.useRef)(null);
4396
+ const refSetter = (0, import_react26.useCallback)(
4355
4397
  (el) => {
4356
4398
  sortableRef(el);
4357
4399
  if (el) {
@@ -4360,14 +4402,14 @@ var DraggableComponent = ({
4360
4402
  },
4361
4403
  [sortableRef]
4362
4404
  );
4363
- const [portalEl, setPortalEl] = (0, import_react27.useState)();
4364
- (0, import_react27.useEffect)(() => {
4405
+ const [portalEl, setPortalEl] = (0, import_react26.useState)();
4406
+ (0, import_react26.useEffect)(() => {
4365
4407
  var _a, _b, _c;
4366
4408
  setPortalEl(
4367
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
4368
4410
  );
4369
4411
  }, [iframe.enabled, ref.current]);
4370
- const getStyle = (0, import_react27.useCallback)(() => {
4412
+ const getStyle = (0, import_react26.useCallback)(() => {
4371
4413
  var _a, _b, _c;
4372
4414
  if (!ref.current) return;
4373
4415
  const rect = ref.current.getBoundingClientRect();
@@ -4387,11 +4429,11 @@ var DraggableComponent = ({
4387
4429
  };
4388
4430
  return style2;
4389
4431
  }, [ref.current]);
4390
- const [style, setStyle] = (0, import_react27.useState)();
4391
- const sync = (0, import_react27.useCallback)(() => {
4432
+ const [style, setStyle] = (0, import_react26.useState)();
4433
+ const sync = (0, import_react26.useCallback)(() => {
4392
4434
  setStyle(getStyle());
4393
4435
  }, [ref.current, iframe]);
4394
- (0, import_react27.useEffect)(() => {
4436
+ (0, import_react26.useEffect)(() => {
4395
4437
  if (ref.current && !userIsDragging) {
4396
4438
  const observer = new ResizeObserver(sync);
4397
4439
  observer.observe(ref.current);
@@ -4401,18 +4443,18 @@ var DraggableComponent = ({
4401
4443
  }
4402
4444
  }, [ref.current, userIsDragging]);
4403
4445
  const registerNode = useAppStore((s) => s.nodes.registerNode);
4404
- (0, import_react27.useEffect)(() => {
4446
+ (0, import_react26.useEffect)(() => {
4405
4447
  var _a;
4406
4448
  registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
4407
4449
  return () => {
4408
4450
  registerNode(id, { methods: { sync: () => null }, element: null });
4409
4451
  };
4410
4452
  }, [id, zoneCompound, index, componentType, sync]);
4411
- const CustomActionBar = (0, import_react27.useMemo)(
4453
+ const CustomActionBar = (0, import_react26.useMemo)(
4412
4454
  () => overrides.actionBar || DefaultActionBar,
4413
4455
  [overrides.actionBar]
4414
4456
  );
4415
- const onClick = (0, import_react27.useCallback)(
4457
+ const onClick = (0, import_react26.useCallback)(
4416
4458
  (e) => {
4417
4459
  e.stopPropagation();
4418
4460
  dispatch({
@@ -4425,7 +4467,7 @@ var DraggableComponent = ({
4425
4467
  [index, zoneCompound, id]
4426
4468
  );
4427
4469
  const appStore = useAppStoreApi();
4428
- const onSelectParent = (0, import_react27.useCallback)(() => {
4470
+ const onSelectParent = (0, import_react26.useCallback)(() => {
4429
4471
  const { nodes } = appStore.getState().nodes;
4430
4472
  const node = nodes[id];
4431
4473
  const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
@@ -4442,23 +4484,23 @@ var DraggableComponent = ({
4442
4484
  }
4443
4485
  });
4444
4486
  }, [ctx, path]);
4445
- const onDuplicate = (0, import_react27.useCallback)(() => {
4487
+ const onDuplicate = (0, import_react26.useCallback)(() => {
4446
4488
  dispatch({
4447
4489
  type: "duplicate",
4448
4490
  sourceIndex: index,
4449
4491
  sourceZone: zoneCompound
4450
4492
  });
4451
4493
  }, [index, zoneCompound]);
4452
- const onDelete = (0, import_react27.useCallback)(() => {
4494
+ const onDelete = (0, import_react26.useCallback)(() => {
4453
4495
  dispatch({
4454
4496
  type: "remove",
4455
4497
  index,
4456
4498
  zone: zoneCompound
4457
4499
  });
4458
4500
  }, [index, zoneCompound]);
4459
- const [hover, setHover] = (0, import_react27.useState)(false);
4501
+ const [hover, setHover] = (0, import_react26.useState)(false);
4460
4502
  const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
4461
- (0, import_react27.useEffect)(() => {
4503
+ (0, import_react26.useEffect)(() => {
4462
4504
  if (!ref.current) {
4463
4505
  return;
4464
4506
  }
@@ -4508,7 +4550,7 @@ var DraggableComponent = ({
4508
4550
  thisIsDragging,
4509
4551
  inDroppableZone
4510
4552
  ]);
4511
- (0, import_react27.useEffect)(() => {
4553
+ (0, import_react26.useEffect)(() => {
4512
4554
  if (ref.current && disabled) {
4513
4555
  ref.current.setAttribute("data-puck-disabled", "");
4514
4556
  return () => {
@@ -4517,8 +4559,8 @@ var DraggableComponent = ({
4517
4559
  };
4518
4560
  }
4519
4561
  }, [disabled, ref]);
4520
- const [isVisible, setIsVisible] = (0, import_react27.useState)(false);
4521
- (0, import_react27.useEffect)(() => {
4562
+ const [isVisible, setIsVisible] = (0, import_react26.useState)(false);
4563
+ (0, import_react26.useEffect)(() => {
4522
4564
  sync();
4523
4565
  if ((isSelected || hover || indicativeHover) && !userIsDragging) {
4524
4566
  setIsVisible(true);
@@ -4526,7 +4568,7 @@ var DraggableComponent = ({
4526
4568
  setIsVisible(false);
4527
4569
  }
4528
4570
  }, [isSelected, hover, indicativeHover, iframe, userIsDragging]);
4529
- const syncActionsPosition = (0, import_react27.useCallback)(
4571
+ const syncActionsPosition = (0, import_react26.useCallback)(
4530
4572
  (el) => {
4531
4573
  if (el) {
4532
4574
  const view = el.ownerDocument.defaultView;
@@ -4534,16 +4576,24 @@ var DraggableComponent = ({
4534
4576
  const rect = el.getBoundingClientRect();
4535
4577
  const diffLeft = rect.x;
4536
4578
  const exceedsBoundsLeft = diffLeft < 0;
4579
+ const diffTop = rect.y;
4580
+ const exceedsBoundsTop = diffTop < 0;
4537
4581
  if (exceedsBoundsLeft) {
4538
4582
  el.style.transformOrigin = "left top";
4539
4583
  el.style.left = "0px";
4540
4584
  }
4585
+ if (exceedsBoundsTop) {
4586
+ el.style.top = "12px";
4587
+ if (!exceedsBoundsLeft) {
4588
+ el.style.transformOrigin = "right top";
4589
+ }
4590
+ }
4541
4591
  }
4542
4592
  }
4543
4593
  },
4544
4594
  [zoom]
4545
4595
  );
4546
- (0, import_react27.useEffect)(() => {
4596
+ (0, import_react26.useEffect)(() => {
4547
4597
  if (userDragAxis) {
4548
4598
  setDragAxis(userDragAxis);
4549
4599
  return;
@@ -4636,15 +4686,15 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
4636
4686
 
4637
4687
  // components/DropZone/lib/use-min-empty-height.ts
4638
4688
  init_react_import();
4639
- var import_react28 = require("react");
4689
+ var import_react27 = require("react");
4640
4690
  var useMinEmptyHeight = ({
4641
4691
  zoneCompound,
4642
4692
  userMinEmptyHeight,
4643
4693
  ref
4644
4694
  }) => {
4645
4695
  const appStore = useAppStoreApi();
4646
- const [prevHeight, setPrevHeight] = (0, import_react28.useState)(0);
4647
- 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);
4648
4698
  const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
4649
4699
  var _a, _b;
4650
4700
  return {
@@ -4652,7 +4702,7 @@ var useMinEmptyHeight = ({
4652
4702
  isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
4653
4703
  };
4654
4704
  });
4655
- (0, import_react28.useEffect)(() => {
4705
+ (0, import_react27.useEffect)(() => {
4656
4706
  if (draggedItem && ref.current) {
4657
4707
  if (isZone) {
4658
4708
  const rect = ref.current.getBoundingClientRect();
@@ -4690,15 +4740,15 @@ function assignRefs(refs, node) {
4690
4740
 
4691
4741
  // components/DropZone/lib/use-content-with-preview.ts
4692
4742
  init_react_import();
4693
- var import_react31 = require("react");
4743
+ var import_react30 = require("react");
4694
4744
 
4695
4745
  // lib/dnd/use-rendered-callback.ts
4696
4746
  init_react_import();
4697
- var import_react29 = require("@dnd-kit/react");
4698
- var import_react30 = require("react");
4747
+ var import_react28 = require("@dnd-kit/react");
4748
+ var import_react29 = require("react");
4699
4749
  function useRenderedCallback(callback, deps) {
4700
- const manager = (0, import_react29.useDragDropManager)();
4701
- return (0, import_react30.useCallback)(
4750
+ const manager = (0, import_react28.useDragDropManager)();
4751
+ return (0, import_react29.useCallback)(
4702
4752
  (...args) => __async(this, null, function* () {
4703
4753
  yield manager == null ? void 0 : manager.renderer.rendering;
4704
4754
  return callback(...args);
@@ -4721,8 +4771,8 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4721
4771
  }
4722
4772
  );
4723
4773
  const isDragging = useAppStore((s) => s.state.ui.isDragging);
4724
- const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react31.useState)(contentIds);
4725
- const [localPreview, setLocalPreview] = (0, import_react31.useState)(
4774
+ const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react30.useState)(contentIds);
4775
+ const [localPreview, setLocalPreview] = (0, import_react30.useState)(
4726
4776
  preview
4727
4777
  );
4728
4778
  const updateContent = useRenderedCallback(
@@ -4757,7 +4807,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4757
4807
  },
4758
4808
  [draggedItemId, previewExists]
4759
4809
  );
4760
- (0, import_react31.useEffect)(() => {
4810
+ (0, import_react30.useEffect)(() => {
4761
4811
  updateContent(contentIds, preview, isDragging);
4762
4812
  }, [contentIds, preview, isDragging]);
4763
4813
  return [contentIdsWithPreview, localPreview];
@@ -4765,16 +4815,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4765
4815
 
4766
4816
  // components/DropZone/lib/use-drag-axis.ts
4767
4817
  init_react_import();
4768
- var import_react32 = require("react");
4818
+ var import_react31 = require("react");
4769
4819
  var GRID_DRAG_AXIS = "dynamic";
4770
4820
  var FLEX_ROW_DRAG_AXIS = "x";
4771
4821
  var DEFAULT_DRAG_AXIS = "y";
4772
4822
  var useDragAxis = (ref, collisionAxis) => {
4773
4823
  const status = useAppStore((s) => s.status);
4774
- const [dragAxis, setDragAxis] = (0, import_react32.useState)(
4824
+ const [dragAxis, setDragAxis] = (0, import_react31.useState)(
4775
4825
  collisionAxis || DEFAULT_DRAG_AXIS
4776
4826
  );
4777
- const calculateDragAxis = (0, import_react32.useCallback)(() => {
4827
+ const calculateDragAxis = (0, import_react31.useCallback)(() => {
4778
4828
  if (ref.current) {
4779
4829
  const computedStyle = window.getComputedStyle(ref.current);
4780
4830
  if (computedStyle.display === "grid") {
@@ -4786,7 +4836,7 @@ var useDragAxis = (ref, collisionAxis) => {
4786
4836
  }
4787
4837
  }
4788
4838
  }, [ref.current]);
4789
- (0, import_react32.useEffect)(() => {
4839
+ (0, import_react31.useEffect)(() => {
4790
4840
  const onViewportChange = () => {
4791
4841
  calculateDragAxis();
4792
4842
  };
@@ -4795,7 +4845,7 @@ var useDragAxis = (ref, collisionAxis) => {
4795
4845
  window.removeEventListener("viewportchange", onViewportChange);
4796
4846
  };
4797
4847
  }, []);
4798
- (0, import_react32.useEffect)(calculateDragAxis, [status, collisionAxis]);
4848
+ (0, import_react31.useEffect)(calculateDragAxis, [status, collisionAxis]);
4799
4849
  return [dragAxis, calculateDragAxis];
4800
4850
  };
4801
4851
 
@@ -4804,9 +4854,9 @@ var import_shallow3 = require("zustand/react/shallow");
4804
4854
 
4805
4855
  // components/Render/index.tsx
4806
4856
  init_react_import();
4807
- var import_react33 = __toESM(require("react"));
4857
+ var import_react32 = __toESM(require("react"));
4808
4858
  var import_jsx_runtime21 = require("react/jsx-runtime");
4809
- var renderContext = import_react33.default.createContext({
4859
+ var renderContext = import_react32.default.createContext({
4810
4860
  config: { components: {} },
4811
4861
  data: { root: {}, content: [] },
4812
4862
  metadata: {}
@@ -4885,7 +4935,7 @@ var DropZoneChild = ({
4885
4935
  dragRef: null,
4886
4936
  metadata
4887
4937
  };
4888
- const ctx = (0, import_react34.useContext)(dropZoneContext);
4938
+ const ctx = (0, import_react33.useContext)(dropZoneContext);
4889
4939
  const { depth } = ctx;
4890
4940
  const contentItem = useAppStore(
4891
4941
  (0, import_shallow3.useShallow)((s) => {
@@ -4914,7 +4964,7 @@ var DropZoneChild = ({
4914
4964
  }
4915
4965
  );
4916
4966
  let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
4917
- const renderPreview = (0, import_react34.useMemo)(
4967
+ const renderPreview = (0, import_react33.useMemo)(
4918
4968
  () => function Preview4() {
4919
4969
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
4920
4970
  },
@@ -4961,7 +5011,7 @@ var DropZoneChild = ({
4961
5011
  }
4962
5012
  );
4963
5013
  };
4964
- var DropZoneEdit = (0, import_react34.forwardRef)(
5014
+ var DropZoneEdit = (0, import_react33.forwardRef)(
4965
5015
  function DropZoneEditInternal({
4966
5016
  zone,
4967
5017
  allow,
@@ -4971,7 +5021,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
4971
5021
  minEmptyHeight: userMinEmptyHeight = 128,
4972
5022
  collisionAxis
4973
5023
  }, userRef) {
4974
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5024
+ const ctx = (0, import_react33.useContext)(dropZoneContext);
4975
5025
  const {
4976
5026
  // These all need setting via context
4977
5027
  areaId,
@@ -5008,7 +5058,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5008
5058
  userIsDragging: !!s.draggedItem
5009
5059
  };
5010
5060
  });
5011
- (0, import_react34.useEffect)(() => {
5061
+ (0, import_react33.useEffect)(() => {
5012
5062
  if (ctx == null ? void 0 : ctx.registerZone) {
5013
5063
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5014
5064
  }
@@ -5027,8 +5077,8 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5027
5077
  return content.map(({ props }) => props.id);
5028
5078
  })
5029
5079
  );
5030
- const ref = (0, import_react34.useRef)(null);
5031
- const acceptsTarget = (0, import_react34.useCallback)(
5080
+ const ref = (0, import_react33.useRef)(null);
5081
+ const acceptsTarget = (0, import_react33.useCallback)(
5032
5082
  (componentType) => {
5033
5083
  if (!componentType) {
5034
5084
  return true;
@@ -5050,7 +5100,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5050
5100
  },
5051
5101
  [allow, disallow]
5052
5102
  );
5053
- (0, import_react34.useEffect)(() => {
5103
+ (0, import_react33.useEffect)(() => {
5054
5104
  if (registerLocalZone) {
5055
5105
  registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
5056
5106
  }
@@ -5140,14 +5190,14 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5140
5190
  }
5141
5191
  );
5142
5192
  var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
5143
- var DropZoneRender = (0, import_react34.forwardRef)(
5193
+ var DropZoneRender = (0, import_react33.forwardRef)(
5144
5194
  function DropZoneRenderInternal({ className, style, zone }, ref) {
5145
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5195
+ const ctx = (0, import_react33.useContext)(dropZoneContext);
5146
5196
  const { areaId = "root" } = ctx || {};
5147
- const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
5197
+ const { config, data, metadata } = (0, import_react33.useContext)(renderContext);
5148
5198
  let zoneCompound = rootDroppableId;
5149
5199
  let content = (data == null ? void 0 : data.content) || [];
5150
- (0, import_react34.useEffect)(() => {
5200
+ (0, import_react33.useEffect)(() => {
5151
5201
  if (ctx == null ? void 0 : ctx.registerZone) {
5152
5202
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5153
5203
  }
@@ -5192,9 +5242,9 @@ var DropZoneRender = (0, import_react34.forwardRef)(
5192
5242
  }
5193
5243
  );
5194
5244
  var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZone, __spreadValues({}, props));
5195
- var DropZone = (0, import_react34.forwardRef)(
5245
+ var DropZone = (0, import_react33.forwardRef)(
5196
5246
  function DropZone2(props, ref) {
5197
- const ctx = (0, import_react34.useContext)(dropZoneContext);
5247
+ const ctx = (0, import_react33.useContext)(dropZoneContext);
5198
5248
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
5199
5249
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
5200
5250
  }
@@ -5514,12 +5564,12 @@ function getDeepDir(el) {
5514
5564
  // components/DragDropContext/index.tsx
5515
5565
  var import_jsx_runtime23 = require("react/jsx-runtime");
5516
5566
  var DEBUG3 = false;
5517
- var dragListenerContext = (0, import_react36.createContext)({
5567
+ var dragListenerContext = (0, import_react35.createContext)({
5518
5568
  dragListeners: {}
5519
5569
  });
5520
5570
  function useDragListener(type, fn, deps = []) {
5521
- const { setDragListeners } = (0, import_react36.useContext)(dragListenerContext);
5522
- (0, import_react36.useEffect)(() => {
5571
+ const { setDragListeners } = (0, import_react35.useContext)(dragListenerContext);
5572
+ (0, import_react35.useEffect)(() => {
5523
5573
  if (setDragListeners) {
5524
5574
  setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
5525
5575
  [type]: [...old[type] || [], fn]
@@ -5529,8 +5579,8 @@ function useDragListener(type, fn, deps = []) {
5529
5579
  }
5530
5580
  var AREA_CHANGE_DEBOUNCE_MS = 100;
5531
5581
  var useTempDisableFallback = (timeout3) => {
5532
- const lastFallbackDisable = (0, import_react36.useRef)(null);
5533
- return (0, import_react36.useCallback)((manager) => {
5582
+ const lastFallbackDisable = (0, import_react35.useRef)(null);
5583
+ return (0, import_react35.useCallback)((manager) => {
5534
5584
  collisionStore.setState({ fallbackEnabled: false });
5535
5585
  const fallbackId = generateId();
5536
5586
  lastFallbackDisable.current = fallbackId;
@@ -5551,10 +5601,10 @@ var DragDropContextClient = ({
5551
5601
  const resolveData2 = useAppStore((s) => s.resolveData);
5552
5602
  const metadata = useAppStore((s) => s.metadata);
5553
5603
  const appStore = useAppStoreApi();
5554
- const id = (0, import_react36.useId)();
5555
- const debouncedParamsRef = (0, import_react36.useRef)(null);
5604
+ const id = useSafeId();
5605
+ const debouncedParamsRef = (0, import_react35.useRef)(null);
5556
5606
  const tempDisableFallback = useTempDisableFallback(100);
5557
- const [zoneStore] = (0, import_react36.useState)(
5607
+ const [zoneStore] = (0, import_react35.useState)(
5558
5608
  () => (0, import_zustand5.createStore)(() => ({
5559
5609
  zoneDepthIndex: {},
5560
5610
  nextZoneDepthIndex: {},
@@ -5564,7 +5614,7 @@ var DragDropContextClient = ({
5564
5614
  previewIndex: {}
5565
5615
  }))
5566
5616
  );
5567
- const getChanged2 = (0, import_react36.useCallback)(
5617
+ const getChanged2 = (0, import_react35.useCallback)(
5568
5618
  (params, id2) => {
5569
5619
  const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
5570
5620
  const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
@@ -5585,7 +5635,7 @@ var DragDropContextClient = ({
5585
5635
  },
5586
5636
  [zoneStore]
5587
5637
  );
5588
- const setDeepestAndCollide = (0, import_react36.useCallback)(
5638
+ const setDeepestAndCollide = (0, import_react35.useCallback)(
5589
5639
  (params, manager) => {
5590
5640
  const { zoneChanged, areaChanged } = getChanged2(params, id);
5591
5641
  if (!zoneChanged && !areaChanged) return;
@@ -5609,7 +5659,7 @@ var DragDropContextClient = ({
5609
5659
  setDeepestDb.cancel();
5610
5660
  debouncedParamsRef.current = null;
5611
5661
  };
5612
- (0, import_react36.useEffect)(() => {
5662
+ (0, import_react35.useEffect)(() => {
5613
5663
  if (DEBUG3) {
5614
5664
  zoneStore.subscribe(
5615
5665
  (s) => {
@@ -5623,7 +5673,7 @@ var DragDropContextClient = ({
5623
5673
  );
5624
5674
  }
5625
5675
  }, []);
5626
- const [plugins] = (0, import_react36.useState)(() => [
5676
+ const [plugins] = (0, import_react35.useState)(() => [
5627
5677
  ...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
5628
5678
  createNestedDroppablePlugin(
5629
5679
  {
@@ -5671,9 +5721,9 @@ var DragDropContextClient = ({
5671
5721
  )
5672
5722
  ]);
5673
5723
  const sensors = useSensors();
5674
- const [dragListeners, setDragListeners] = (0, import_react36.useState)({});
5675
- const dragMode = (0, import_react36.useRef)(null);
5676
- 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);
5677
5727
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5678
5728
  dragListenerContext.Provider,
5679
5729
  {
@@ -5682,7 +5732,7 @@ var DragDropContextClient = ({
5682
5732
  setDragListeners
5683
5733
  },
5684
5734
  children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5685
- import_react35.DragDropProvider,
5735
+ import_react34.DragDropProvider,
5686
5736
  {
5687
5737
  plugins,
5688
5738
  sensors,
@@ -5912,7 +5962,7 @@ var DrawerItemInner = ({
5912
5962
  dragRef,
5913
5963
  isDragDisabled
5914
5964
  }) => {
5915
- const CustomInner = (0, import_react37.useMemo)(
5965
+ const CustomInner = (0, import_react36.useMemo)(
5916
5966
  () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
5917
5967
  [children]
5918
5968
  );
@@ -5966,7 +6016,7 @@ var DrawerItem = ({
5966
6016
  isDragDisabled
5967
6017
  }) => {
5968
6018
  const resolvedId = id || name;
5969
- const [dynamicId, setDynamicId] = (0, import_react37.useState)(generateId(resolvedId));
6019
+ const [dynamicId, setDynamicId] = (0, import_react36.useState)(generateId(resolvedId));
5970
6020
  if (typeof index !== "undefined") {
5971
6021
  console.error(
5972
6022
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -6005,7 +6055,7 @@ var Drawer = ({
6005
6055
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
6006
6056
  );
6007
6057
  }
6008
- const id = (0, import_react37.useId)();
6058
+ const id = useSafeId();
6009
6059
  const { ref } = useDroppableSafe({
6010
6060
  id,
6011
6061
  type: "void",
@@ -6027,7 +6077,7 @@ Drawer.Item = DrawerItem;
6027
6077
 
6028
6078
  // components/Puck/index.tsx
6029
6079
  init_react_import();
6030
- var import_react52 = require("react");
6080
+ var import_react51 = require("react");
6031
6081
 
6032
6082
  // components/SidebarSection/index.tsx
6033
6083
  init_react_import();
@@ -6038,7 +6088,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
6038
6088
 
6039
6089
  // lib/use-breadcrumbs.ts
6040
6090
  init_react_import();
6041
- var import_react38 = require("react");
6091
+ var import_react37 = require("react");
6042
6092
  var useBreadcrumbs = (renderCount) => {
6043
6093
  const selectedId = useAppStore((s) => {
6044
6094
  var _a;
@@ -6050,7 +6100,7 @@ var useBreadcrumbs = (renderCount) => {
6050
6100
  return (_a = s.nodes.nodes[selectedId]) == null ? void 0 : _a.path;
6051
6101
  });
6052
6102
  const appStore = useAppStoreApi();
6053
- return (0, import_react38.useMemo)(() => {
6103
+ return (0, import_react37.useMemo)(() => {
6054
6104
  const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
6055
6105
  var _a, _b;
6056
6106
  const [componentId] = zoneCompound.split(":");
@@ -6175,7 +6225,7 @@ init_react_import();
6175
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" };
6176
6226
 
6177
6227
  // components/Puck/components/Fields/index.tsx
6178
- var import_react39 = require("react");
6228
+ var import_react38 = require("react");
6179
6229
  var import_shallow4 = require("zustand/react/shallow");
6180
6230
  var import_jsx_runtime27 = require("react/jsx-runtime");
6181
6231
  var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
@@ -6270,7 +6320,7 @@ var FieldsChild = ({ fieldName }) => {
6270
6320
  })
6271
6321
  );
6272
6322
  const appStore = useAppStoreApi();
6273
- const onChange = (0, import_react39.useCallback)(createOnChange(fieldName, appStore), [
6323
+ const onChange = (0, import_react38.useCallback)(createOnChange(fieldName, appStore), [
6274
6324
  fieldName
6275
6325
  ]);
6276
6326
  if (!field || !id) return null;
@@ -6305,7 +6355,7 @@ var Fields = ({ wrapFields = true }) => {
6305
6355
  (0, import_shallow4.useShallow)((s) => Object.keys(s.fields.fields))
6306
6356
  );
6307
6357
  const isLoading = fieldsLoading || componentResolving;
6308
- const Wrapper = (0, import_react39.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6358
+ const Wrapper = (0, import_react38.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
6309
6359
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
6310
6360
  "form",
6311
6361
  {
@@ -6326,7 +6376,7 @@ init_react_import();
6326
6376
 
6327
6377
  // lib/use-component-list.tsx
6328
6378
  init_react_import();
6329
- var import_react40 = require("react");
6379
+ var import_react39 = require("react");
6330
6380
 
6331
6381
  // components/ComponentList/index.tsx
6332
6382
  init_react_import();
@@ -6397,10 +6447,10 @@ ComponentList.Item = ComponentListItem;
6397
6447
  // lib/use-component-list.tsx
6398
6448
  var import_jsx_runtime29 = require("react/jsx-runtime");
6399
6449
  var useComponentList = () => {
6400
- const [componentList, setComponentList] = (0, import_react40.useState)();
6450
+ const [componentList, setComponentList] = (0, import_react39.useState)();
6401
6451
  const config = useAppStore((s) => s.config);
6402
6452
  const uiComponentList = useAppStore((s) => s.state.ui.componentList);
6403
- (0, import_react40.useEffect)(() => {
6453
+ (0, import_react39.useEffect)(() => {
6404
6454
  var _a, _b, _c;
6405
6455
  if (Object.keys(uiComponentList).length > 0) {
6406
6456
  const matchedComponents = [];
@@ -6469,22 +6519,22 @@ var useComponentList = () => {
6469
6519
  };
6470
6520
 
6471
6521
  // components/Puck/components/Components/index.tsx
6472
- var import_react41 = require("react");
6522
+ var import_react40 = require("react");
6473
6523
  var import_jsx_runtime30 = require("react/jsx-runtime");
6474
6524
  var Components = () => {
6475
6525
  const overrides = useAppStore((s) => s.overrides);
6476
6526
  const componentList = useComponentList();
6477
- const Wrapper = (0, import_react41.useMemo)(() => overrides.components || "div", [overrides]);
6527
+ const Wrapper = (0, import_react40.useMemo)(() => overrides.components || "div", [overrides]);
6478
6528
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
6479
6529
  };
6480
6530
 
6481
6531
  // components/Puck/components/Preview/index.tsx
6482
6532
  init_react_import();
6483
- var import_react43 = require("react");
6533
+ var import_react42 = require("react");
6484
6534
 
6485
6535
  // components/AutoFrame/index.tsx
6486
6536
  init_react_import();
6487
- var import_react42 = require("react");
6537
+ var import_react41 = require("react");
6488
6538
  var import_object_hash = __toESM(require("object-hash"));
6489
6539
  var import_react_dom3 = require("react-dom");
6490
6540
  var import_jsx_runtime31 = require("react/jsx-runtime");
@@ -6530,7 +6580,7 @@ var CopyHostStyles = ({
6530
6580
  onStylesLoaded = () => null
6531
6581
  }) => {
6532
6582
  const { document: doc, window: win } = useFrame();
6533
- (0, import_react42.useEffect)(() => {
6583
+ (0, import_react41.useEffect)(() => {
6534
6584
  if (!win || !doc) {
6535
6585
  return () => {
6536
6586
  };
@@ -6689,8 +6739,8 @@ var CopyHostStyles = ({
6689
6739
  }, []);
6690
6740
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
6691
6741
  };
6692
- var autoFrameContext = (0, import_react42.createContext)({});
6693
- var useFrame = () => (0, import_react42.useContext)(autoFrameContext);
6742
+ var autoFrameContext = (0, import_react41.createContext)({});
6743
+ var useFrame = () => (0, import_react41.useContext)(autoFrameContext);
6694
6744
  function AutoFrame(_a) {
6695
6745
  var _b = _a, {
6696
6746
  children,
@@ -6711,11 +6761,11 @@ function AutoFrame(_a) {
6711
6761
  "onNotReady",
6712
6762
  "frameRef"
6713
6763
  ]);
6714
- const [loaded, setLoaded] = (0, import_react42.useState)(false);
6715
- const [ctx, setCtx] = (0, import_react42.useState)({});
6716
- const [mountTarget, setMountTarget] = (0, import_react42.useState)();
6717
- const [stylesLoaded, setStylesLoaded] = (0, import_react42.useState)(false);
6718
- (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)(() => {
6719
6769
  var _a2;
6720
6770
  if (frameRef.current) {
6721
6771
  const doc = frameRef.current.contentDocument;
@@ -6767,7 +6817,7 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
6767
6817
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
6768
6818
  var useBubbleIframeEvents = (ref) => {
6769
6819
  const status = useAppStore((s) => s.status);
6770
- (0, import_react43.useEffect)(() => {
6820
+ (0, import_react42.useEffect)(() => {
6771
6821
  if (ref.current && status === "READY") {
6772
6822
  const iframe = ref.current;
6773
6823
  const handlePointerMove = (event) => {
@@ -6816,7 +6866,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
6816
6866
  const renderData = useAppStore(
6817
6867
  (s) => s.state.ui.previewMode === "edit" ? null : s.state.data
6818
6868
  );
6819
- const Page = (0, import_react43.useCallback)(
6869
+ const Page = (0, import_react42.useCallback)(
6820
6870
  (pageProps) => {
6821
6871
  var _a, _b;
6822
6872
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
@@ -6825,9 +6875,9 @@ var Preview3 = ({ id = "puck-preview" }) => {
6825
6875
  },
6826
6876
  [config.root]
6827
6877
  );
6828
- const Frame = (0, import_react43.useMemo)(() => overrides.iframe, [overrides]);
6878
+ const Frame = (0, import_react42.useMemo)(() => overrides.iframe, [overrides]);
6829
6879
  const rootProps = root.props || root;
6830
- const ref = (0, import_react43.useRef)(null);
6880
+ const ref = (0, import_react42.useRef)(null);
6831
6881
  useBubbleIframeEvents(ref);
6832
6882
  const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6833
6883
  Page,
@@ -6842,7 +6892,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
6842
6892
  children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZonePure, { zone: rootDroppableId })
6843
6893
  })
6844
6894
  ) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Render, { data: renderData, config });
6845
- (0, import_react43.useEffect)(() => {
6895
+ (0, import_react42.useEffect)(() => {
6846
6896
  if (!iframe.enabled) {
6847
6897
  setStatus("READY");
6848
6898
  }
@@ -6933,7 +6983,7 @@ var scrollIntoView = (el) => {
6933
6983
  };
6934
6984
 
6935
6985
  // components/LayerTree/index.tsx
6936
- var import_react44 = require("react");
6986
+ var import_react43 = require("react");
6937
6987
 
6938
6988
  // lib/on-scroll-end.ts
6939
6989
  init_react_import();
@@ -6968,7 +7018,7 @@ var LayerTree = ({
6968
7018
  label
6969
7019
  }) => {
6970
7020
  const zones = data.zones || {};
6971
- const ctx = (0, import_react44.useContext)(dropZoneContext);
7021
+ const ctx = (0, import_react43.useContext)(dropZoneContext);
6972
7022
  const nodes = useAppStore((s) => s.nodes.nodes);
6973
7023
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
6974
7024
  label && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
@@ -7080,7 +7130,7 @@ var LayerTree = ({
7080
7130
  };
7081
7131
 
7082
7132
  // components/Puck/components/Outline/index.tsx
7083
- var import_react45 = require("react");
7133
+ var import_react44 = require("react");
7084
7134
  var import_jsx_runtime34 = require("react/jsx-runtime");
7085
7135
  var Outline = () => {
7086
7136
  const state = useAppStore((s) => s.state);
@@ -7089,7 +7139,7 @@ var Outline = () => {
7089
7139
  const { data, ui } = state;
7090
7140
  const { itemSelector } = ui;
7091
7141
  const appStore = useAppStoreApi();
7092
- const setItemSelector = (0, import_react45.useCallback)(
7142
+ const setItemSelector = (0, import_react44.useCallback)(
7093
7143
  (newItemSelector) => {
7094
7144
  const { dispatch } = appStore.getState();
7095
7145
  dispatch({
@@ -7099,7 +7149,7 @@ var Outline = () => {
7099
7149
  },
7100
7150
  [appStore]
7101
7151
  );
7102
- const Wrapper = (0, import_react45.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7152
+ const Wrapper = (0, import_react44.useMemo)(() => outlineOverride || "div", [outlineOverride]);
7103
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: [
7104
7154
  (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
7105
7155
  LayerTree,
@@ -7255,11 +7305,11 @@ var getBox = function getBox2(el) {
7255
7305
  };
7256
7306
 
7257
7307
  // components/Puck/components/Canvas/index.tsx
7258
- var import_react47 = require("react");
7308
+ var import_react46 = require("react");
7259
7309
 
7260
7310
  // components/ViewportControls/index.tsx
7261
7311
  init_react_import();
7262
- var import_react46 = require("react");
7312
+ var import_react45 = require("react");
7263
7313
 
7264
7314
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7265
7315
  init_react_import();
@@ -7282,8 +7332,8 @@ var ViewportButton = ({
7282
7332
  onClick
7283
7333
  }) => {
7284
7334
  const viewports = useAppStore((s) => s.state.ui.viewports);
7285
- const [isActive, setIsActive] = (0, import_react46.useState)(false);
7286
- (0, import_react46.useEffect)(() => {
7335
+ const [isActive, setIsActive] = (0, import_react45.useState)(false);
7336
+ (0, import_react45.useEffect)(() => {
7287
7337
  setIsActive(width === viewports.current.width);
7288
7338
  }, [width, viewports.current.width]);
7289
7339
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
@@ -7319,7 +7369,7 @@ var ViewportControls = ({
7319
7369
  const defaultsContainAutoZoom = defaultZoomOptions.find(
7320
7370
  (option) => option.value === autoZoom
7321
7371
  );
7322
- const zoomOptions = (0, import_react46.useMemo)(
7372
+ const zoomOptions = (0, import_react45.useMemo)(
7323
7373
  () => [
7324
7374
  ...defaultZoomOptions,
7325
7375
  ...defaultsContainAutoZoom ? [] : [
@@ -7466,17 +7516,17 @@ var Canvas = () => {
7466
7516
  viewports: s.state.ui.viewports
7467
7517
  }))
7468
7518
  );
7469
- const frameRef = (0, import_react47.useRef)(null);
7470
- const [showTransition, setShowTransition] = (0, import_react47.useState)(false);
7471
- 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)(() => {
7472
7522
  const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children });
7473
7523
  return PuckDefault;
7474
7524
  }, []);
7475
- const CustomPreview = (0, import_react47.useMemo)(
7525
+ const CustomPreview = (0, import_react46.useMemo)(
7476
7526
  () => overrides.preview || defaultRender,
7477
7527
  [overrides]
7478
7528
  );
7479
- const getFrameDimensions = (0, import_react47.useCallback)(() => {
7529
+ const getFrameDimensions = (0, import_react46.useCallback)(() => {
7480
7530
  if (frameRef.current) {
7481
7531
  const frame = frameRef.current;
7482
7532
  const box = getBox(frame);
@@ -7484,7 +7534,7 @@ var Canvas = () => {
7484
7534
  }
7485
7535
  return { width: 0, height: 0 };
7486
7536
  }, [frameRef]);
7487
- const resetAutoZoom = (0, import_react47.useCallback)(
7537
+ const resetAutoZoom = (0, import_react46.useCallback)(
7488
7538
  (newViewports = viewports) => {
7489
7539
  if (frameRef.current) {
7490
7540
  setZoomConfig(
@@ -7498,11 +7548,11 @@ var Canvas = () => {
7498
7548
  },
7499
7549
  [frameRef, zoomConfig, viewports]
7500
7550
  );
7501
- (0, import_react47.useEffect)(() => {
7551
+ (0, import_react46.useEffect)(() => {
7502
7552
  setShowTransition(false);
7503
7553
  resetAutoZoom(viewports);
7504
7554
  }, [frameRef, leftSideBarVisible, rightSideBarVisible]);
7505
- (0, import_react47.useEffect)(() => {
7555
+ (0, import_react46.useEffect)(() => {
7506
7556
  const { height: frameHeight } = getFrameDimensions();
7507
7557
  if (viewports.current.height === "auto") {
7508
7558
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -7510,13 +7560,13 @@ var Canvas = () => {
7510
7560
  }));
7511
7561
  }
7512
7562
  }, [zoomConfig.zoom]);
7513
- (0, import_react47.useEffect)(() => {
7563
+ (0, import_react46.useEffect)(() => {
7514
7564
  if (ZOOM_ON_CHANGE) {
7515
7565
  setShowTransition(true);
7516
7566
  resetAutoZoom(viewports);
7517
7567
  }
7518
7568
  }, [viewports.current.width]);
7519
- (0, import_react47.useEffect)(() => {
7569
+ (0, import_react46.useEffect)(() => {
7520
7570
  const cb = () => {
7521
7571
  setShowTransition(false);
7522
7572
  resetAutoZoom();
@@ -7526,8 +7576,8 @@ var Canvas = () => {
7526
7576
  window.removeEventListener("resize", cb);
7527
7577
  };
7528
7578
  }, []);
7529
- const [showLoader, setShowLoader] = (0, import_react47.useState)(false);
7530
- (0, import_react47.useEffect)(() => {
7579
+ const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
7580
+ (0, import_react46.useEffect)(() => {
7531
7581
  setTimeout(() => {
7532
7582
  setShowLoader(true);
7533
7583
  }, 500);
@@ -7605,7 +7655,7 @@ var Canvas = () => {
7605
7655
 
7606
7656
  // lib/use-loaded-overrides.ts
7607
7657
  init_react_import();
7608
- var import_react48 = require("react");
7658
+ var import_react47 = require("react");
7609
7659
 
7610
7660
  // lib/load-overrides.ts
7611
7661
  init_react_import();
@@ -7644,7 +7694,7 @@ var useLoadedOverrides = ({
7644
7694
  overrides,
7645
7695
  plugins
7646
7696
  }) => {
7647
- return (0, import_react48.useMemo)(() => {
7697
+ return (0, import_react47.useMemo)(() => {
7648
7698
  return loadOverrides({ overrides, plugins });
7649
7699
  }, [plugins, overrides]);
7650
7700
  };
@@ -7656,14 +7706,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37
7656
7706
 
7657
7707
  // lib/use-inject-css.ts
7658
7708
  init_react_import();
7659
- var import_react49 = require("react");
7709
+ var import_react48 = require("react");
7660
7710
  var styles = ``;
7661
7711
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7662
- const [el, setEl] = (0, import_react49.useState)();
7663
- (0, import_react49.useEffect)(() => {
7712
+ const [el, setEl] = (0, import_react48.useState)();
7713
+ (0, import_react48.useEffect)(() => {
7664
7714
  setEl(document.createElement("style"));
7665
7715
  }, []);
7666
- (0, import_react49.useEffect)(() => {
7716
+ (0, import_react48.useEffect)(() => {
7667
7717
  var _a;
7668
7718
  if (!el || typeof window === "undefined") {
7669
7719
  return;
@@ -7683,10 +7733,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
7683
7733
 
7684
7734
  // lib/use-preview-mode-hotkeys.ts
7685
7735
  init_react_import();
7686
- var import_react50 = require("react");
7736
+ var import_react49 = require("react");
7687
7737
  var usePreviewModeHotkeys = () => {
7688
7738
  const appStore = useAppStoreApi();
7689
- const toggleInteractive = (0, import_react50.useCallback)(() => {
7739
+ const toggleInteractive = (0, import_react49.useCallback)(() => {
7690
7740
  const dispatch = appStore.getState().dispatch;
7691
7741
  dispatch({
7692
7742
  type: "setUi",
@@ -7701,7 +7751,7 @@ var usePreviewModeHotkeys = () => {
7701
7751
 
7702
7752
  // lib/use-puck.ts
7703
7753
  init_react_import();
7704
- var import_react51 = require("react");
7754
+ var import_react50 = require("react");
7705
7755
  var import_zustand6 = require("zustand");
7706
7756
  var generateUsePuck = (store) => {
7707
7757
  const history = {
@@ -7726,14 +7776,14 @@ var generateUsePuck = (store) => {
7726
7776
  const get = () => storeData;
7727
7777
  return __spreadProps(__spreadValues({}, storeData), { get });
7728
7778
  };
7729
- var UsePuckStoreContext = (0, import_react51.createContext)(
7779
+ var UsePuckStoreContext = (0, import_react50.createContext)(
7730
7780
  null
7731
7781
  );
7732
7782
  var useRegisterUsePuckStore = (appStore) => {
7733
- const [usePuckStore] = (0, import_react51.useState)(
7783
+ const [usePuckStore] = (0, import_react50.useState)(
7734
7784
  () => (0, import_zustand6.createStore)(() => generateUsePuck(appStore.getState()))
7735
7785
  );
7736
- (0, import_react51.useEffect)(() => {
7786
+ (0, import_react50.useEffect)(() => {
7737
7787
  return appStore.subscribe(
7738
7788
  (store) => {
7739
7789
  const pickedStore = {
@@ -7755,7 +7805,7 @@ var useRegisterUsePuckStore = (appStore) => {
7755
7805
  };
7756
7806
  function createUsePuck() {
7757
7807
  return function usePuck2(selector) {
7758
- const usePuckApi = (0, import_react51.useContext)(UsePuckStoreContext);
7808
+ const usePuckApi = (0, import_react50.useContext)(UsePuckStoreContext);
7759
7809
  if (!usePuckApi) {
7760
7810
  throw new Error("usePuck must be used inside <Puck>.");
7761
7811
  }
@@ -7767,7 +7817,7 @@ function createUsePuck() {
7767
7817
  };
7768
7818
  }
7769
7819
  function usePuck() {
7770
- (0, import_react51.useEffect)(() => {
7820
+ (0, import_react50.useEffect)(() => {
7771
7821
  console.warn(
7772
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."
7773
7823
  );
@@ -7788,11 +7838,11 @@ var FieldSideBar = () => {
7788
7838
  );
7789
7839
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Fields, {}) });
7790
7840
  };
7791
- var propsContext = (0, import_react52.createContext)({});
7841
+ var propsContext = (0, import_react51.createContext)({});
7792
7842
  function PropsProvider(props) {
7793
7843
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(propsContext.Provider, { value: props, children: props.children });
7794
7844
  }
7795
- var usePropsContext = () => (0, import_react52.useContext)(propsContext);
7845
+ var usePropsContext = () => (0, import_react51.useContext)(propsContext);
7796
7846
  function PuckProvider({ children }) {
7797
7847
  const {
7798
7848
  config,
@@ -7812,7 +7862,7 @@ function PuckProvider({ children }) {
7812
7862
  enabled: true,
7813
7863
  waitForStyles: true
7814
7864
  }, _iframe);
7815
- const [generatedAppState] = (0, import_react52.useState)(() => {
7865
+ const [generatedAppState] = (0, import_react51.useState)(() => {
7816
7866
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
7817
7867
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
7818
7868
  let clientUiState = {};
@@ -7884,7 +7934,7 @@ function PuckProvider({ children }) {
7884
7934
  overrides,
7885
7935
  plugins
7886
7936
  });
7887
- const generateAppStore = (0, import_react52.useCallback)(() => {
7937
+ const generateAppStore = (0, import_react51.useCallback)(() => {
7888
7938
  return {
7889
7939
  state: initialAppState,
7890
7940
  config,
@@ -7905,8 +7955,8 @@ function PuckProvider({ children }) {
7905
7955
  onAction,
7906
7956
  metadata
7907
7957
  ]);
7908
- const [appStore] = (0, import_react52.useState)(() => createAppStore(generateAppStore()));
7909
- (0, import_react52.useEffect)(() => {
7958
+ const [appStore] = (0, import_react51.useState)(() => createAppStore(generateAppStore()));
7959
+ (0, import_react51.useEffect)(() => {
7910
7960
  appStore.setState(__spreadValues({}, generateAppStore()));
7911
7961
  }, [
7912
7962
  initialAppState,
@@ -7923,7 +7973,7 @@ function PuckProvider({ children }) {
7923
7973
  index: initialHistoryIndex,
7924
7974
  initialAppState
7925
7975
  });
7926
- (0, import_react52.useEffect)(() => {
7976
+ (0, import_react51.useEffect)(() => {
7927
7977
  appStore.subscribe((s) => {
7928
7978
  if (onChange) onChange(s.state.data);
7929
7979
  });
@@ -7931,11 +7981,11 @@ function PuckProvider({ children }) {
7931
7981
  useRegisterNodesSlice(appStore);
7932
7982
  useRegisterPermissionsSlice(appStore, permissions);
7933
7983
  const uPuckStore = useRegisterUsePuckStore(appStore);
7934
- (0, import_react52.useEffect)(() => {
7984
+ (0, import_react51.useEffect)(() => {
7935
7985
  const { state, resolveData: resolveData2 } = appStore.getState();
7936
7986
  resolveData2(state);
7937
7987
  }, []);
7938
- 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 }) });
7939
7989
  }
7940
7990
  function PuckLayout({ children }) {
7941
7991
  const {
@@ -7958,9 +8008,9 @@ function PuckLayout({ children }) {
7958
8008
  const rightSideBarVisible = useAppStore(
7959
8009
  (s) => s.state.ui.rightSideBarVisible
7960
8010
  );
7961
- const [menuOpen, setMenuOpen] = (0, import_react52.useState)(false);
8011
+ const [menuOpen, setMenuOpen] = (0, import_react51.useState)(false);
7962
8012
  const appStore = useAppStoreApi();
7963
- (0, import_react52.useEffect)(() => {
8013
+ (0, import_react51.useEffect)(() => {
7964
8014
  return appStore.subscribe((s) => {
7965
8015
  if (onChange) onChange(s.state.data);
7966
8016
  });
@@ -7969,7 +8019,7 @@ function PuckLayout({ children }) {
7969
8019
  (s) => s.state.data.root.props || s.state.data.root.props
7970
8020
  );
7971
8021
  const dispatch = useAppStore((s) => s.dispatch);
7972
- const toggleSidebars = (0, import_react52.useCallback)(
8022
+ const toggleSidebars = (0, import_react51.useCallback)(
7973
8023
  (sidebar) => {
7974
8024
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7975
8025
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -7983,7 +8033,7 @@ function PuckLayout({ children }) {
7983
8033
  },
7984
8034
  [dispatch, leftSideBarVisible, rightSideBarVisible]
7985
8035
  );
7986
- (0, import_react52.useEffect)(() => {
8036
+ (0, import_react51.useEffect)(() => {
7987
8037
  if (!window.matchMedia("(min-width: 638px)").matches) {
7988
8038
  dispatch({
7989
8039
  type: "setUi",
@@ -8006,7 +8056,7 @@ function PuckLayout({ children }) {
8006
8056
  window.removeEventListener("resize", handleResize);
8007
8057
  };
8008
8058
  }, []);
8009
- const defaultHeaderRender = (0, import_react52.useMemo)(() => {
8059
+ const defaultHeaderRender = (0, import_react51.useMemo)(() => {
8010
8060
  if (renderHeader) {
8011
8061
  console.warn(
8012
8062
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -8021,7 +8071,7 @@ function PuckLayout({ children }) {
8021
8071
  }
8022
8072
  return DefaultOverride;
8023
8073
  }, [renderHeader]);
8024
- const defaultHeaderActionsRender = (0, import_react52.useMemo)(() => {
8074
+ const defaultHeaderActionsRender = (0, import_react51.useMemo)(() => {
8025
8075
  if (renderHeaderActions) {
8026
8076
  console.warn(
8027
8077
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
@@ -8036,25 +8086,25 @@ function PuckLayout({ children }) {
8036
8086
  return DefaultOverride;
8037
8087
  }, [renderHeader]);
8038
8088
  const overrides = useAppStore((s) => s.overrides);
8039
- const CustomPuck = (0, import_react52.useMemo)(
8089
+ const CustomPuck = (0, import_react51.useMemo)(
8040
8090
  () => overrides.puck || DefaultOverride,
8041
8091
  [overrides]
8042
8092
  );
8043
- const CustomHeader = (0, import_react52.useMemo)(
8093
+ const CustomHeader = (0, import_react51.useMemo)(
8044
8094
  () => overrides.header || defaultHeaderRender,
8045
8095
  [overrides]
8046
8096
  );
8047
- const CustomHeaderActions = (0, import_react52.useMemo)(
8097
+ const CustomHeaderActions = (0, import_react51.useMemo)(
8048
8098
  () => overrides.headerActions || defaultHeaderActionsRender,
8049
8099
  [overrides]
8050
8100
  );
8051
- const [mounted, setMounted] = (0, import_react52.useState)(false);
8052
- (0, import_react52.useEffect)(() => {
8101
+ const [mounted, setMounted] = (0, import_react51.useState)(false);
8102
+ (0, import_react51.useEffect)(() => {
8053
8103
  setMounted(true);
8054
8104
  }, []);
8055
8105
  const ready = useAppStore((s) => s.status === "READY");
8056
8106
  useMonitorHotkeys();
8057
- (0, import_react52.useEffect)(() => {
8107
+ (0, import_react51.useEffect)(() => {
8058
8108
  if (ready && iframe.enabled) {
8059
8109
  const frameDoc = getFrame();
8060
8110
  if (frameDoc) {