@measured/puck 0.19.0-canary.de23f9d → 0.19.0-canary.f96dc87b

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.mjs CHANGED
@@ -8,7 +8,6 @@ import {
8
8
  __spreadProps,
9
9
  __spreadValues,
10
10
  __toESM,
11
- defaultData,
12
11
  getChanged,
13
12
  init_react_import,
14
13
  resolveAllData,
@@ -17,8 +16,9 @@ import {
17
16
  rootAreaId,
18
17
  rootDroppableId,
19
18
  rootZone,
20
- setupZone
21
- } from "./chunk-T6VJEBJD.mjs";
19
+ setupZone,
20
+ transformProps
21
+ } from "./chunk-7N5DRY4G.mjs";
22
22
 
23
23
  // ../../node_modules/classnames/index.js
24
24
  var require_classnames = __commonJS({
@@ -215,7 +215,7 @@ import {
215
215
  useContext as useContext3,
216
216
  useEffect as useEffect11,
217
217
  useMemo as useMemo5,
218
- useState as useState9
218
+ useState as useState8
219
219
  } from "react";
220
220
 
221
221
  // components/AutoField/fields/index.tsx
@@ -676,7 +676,7 @@ var IconButton = ({
676
676
  };
677
677
 
678
678
  // components/AutoField/fields/ArrayField/index.tsx
679
- import { useCallback as useCallback2, useEffect as useEffect6, useState as useState4 } from "react";
679
+ import { useCallback as useCallback2, useEffect as useEffect6, useRef, useState as useState3 } from "react";
680
680
 
681
681
  // components/DragIcon/index.tsx
682
682
  init_react_import();
@@ -1891,7 +1891,6 @@ function useAppStoreApi() {
1891
1891
  // components/Sortable/index.tsx
1892
1892
  init_react_import();
1893
1893
  import { DragDropProvider } from "@dnd-kit/react";
1894
- import { useState as useState3 } from "react";
1895
1894
 
1896
1895
  // lib/dnd/dnd-kit/safe.ts
1897
1896
  init_react_import();
@@ -1917,7 +1916,8 @@ function useDraggableSafe(input) {
1917
1916
  function useSortableSafe(input) {
1918
1917
  if (typeof window === "undefined") {
1919
1918
  return { ref: () => {
1920
- }, status: "idle" };
1919
+ }, status: "idle", handleRef: () => {
1920
+ } };
1921
1921
  }
1922
1922
  return useSortable(input);
1923
1923
  }
@@ -1950,6 +1950,7 @@ var _PointerSensor = class _PointerSensor extends Sensor {
1950
1950
  this.listeners = new Listeners();
1951
1951
  this.cleanup = /* @__PURE__ */ new Set();
1952
1952
  this.source = void 0;
1953
+ this.started = false;
1953
1954
  __privateAdd(this, _clearTimeout);
1954
1955
  this.handleCancel = this.handleCancel.bind(this);
1955
1956
  this.handlePointerUp = this.handlePointerUp.bind(this);
@@ -2107,6 +2108,12 @@ var _PointerSensor = class _PointerSensor extends Sensor {
2107
2108
  if (!status.idle) {
2108
2109
  const canceled = !status.initialized;
2109
2110
  this.manager.actions.stop({ canceled });
2111
+ } else if (this.started) {
2112
+ setTimeout(() => {
2113
+ if (!this.manager.dragOperation.status.idle) {
2114
+ this.manager.actions.stop({ canceled: false });
2115
+ }
2116
+ }, 10);
2110
2117
  }
2111
2118
  this.cleanup.forEach((cleanup) => cleanup());
2112
2119
  this.cleanup.clear();
@@ -2121,12 +2128,13 @@ var _PointerSensor = class _PointerSensor extends Sensor {
2121
2128
  var _a;
2122
2129
  const { manager, initialCoordinates } = this;
2123
2130
  (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2124
- if (!initialCoordinates || manager.dragOperation.status.initialized) {
2131
+ if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
2125
2132
  return;
2126
2133
  }
2127
2134
  if (event.defaultPrevented) {
2128
2135
  return;
2129
2136
  }
2137
+ this.started = true;
2130
2138
  event.preventDefault();
2131
2139
  batch(() => {
2132
2140
  manager.actions.setDragSource(source.id);
@@ -2154,6 +2162,9 @@ var _PointerSensor = class _PointerSensor extends Sensor {
2154
2162
  ]);
2155
2163
  ownerDocument.body.setPointerCapture(event.pointerId);
2156
2164
  this.cleanup.add(unbind);
2165
+ this.cleanup.add(() => {
2166
+ this.started = false;
2167
+ });
2157
2168
  }
2158
2169
  handleDragStart(event) {
2159
2170
  const { target } = event;
@@ -2201,23 +2212,26 @@ function patchWindow(window2) {
2201
2212
 
2202
2213
  // lib/dnd/use-sensors.ts
2203
2214
  import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
2204
- var useSensors = () => {
2215
+ var useSensors = ({
2216
+ other,
2217
+ mouse,
2218
+ touch
2219
+ } = {
2220
+ touch: { delay: { value: 200, tolerance: 10 } },
2221
+ other: { delay: { value: 200, tolerance: 10 }, distance: { value: 5 } }
2222
+ }) => {
2205
2223
  const [sensors] = useState2(() => [
2206
2224
  PointerSensor.configure({
2207
2225
  activationConstraints(event, source) {
2208
2226
  var _a;
2209
2227
  const { pointerType, target } = event;
2210
2228
  if (pointerType === "mouse" && isElement2(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
2211
- return void 0;
2229
+ return mouse;
2212
2230
  }
2213
- const delay = { value: 200, tolerance: 10 };
2214
2231
  if (pointerType === "touch") {
2215
- return { delay };
2232
+ return touch;
2216
2233
  }
2217
- return {
2218
- delay,
2219
- distance: { value: 5 }
2220
- };
2234
+ return other;
2221
2235
  }
2222
2236
  })
2223
2237
  ]);
@@ -2563,7 +2577,6 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2563
2577
  };
2564
2578
 
2565
2579
  // components/Sortable/index.tsx
2566
- import { RestrictToElement } from "@dnd-kit/dom/modifiers";
2567
2580
  import { jsx as jsx5 } from "react/jsx-runtime";
2568
2581
  var SortableProvider = ({
2569
2582
  children,
@@ -2571,22 +2584,20 @@ var SortableProvider = ({
2571
2584
  onDragEnd,
2572
2585
  onMove
2573
2586
  }) => {
2574
- const [move, setMove] = useState3({ source: -1, target: -1 });
2575
- const sensors = useSensors();
2587
+ const sensors = useSensors({
2588
+ mouse: { distance: { value: 5 } }
2589
+ });
2576
2590
  return /* @__PURE__ */ jsx5(
2577
2591
  DragDropProvider,
2578
2592
  {
2579
2593
  sensors,
2580
- modifiers: [
2581
- RestrictToElement.configure({
2582
- element() {
2583
- return document.querySelector("[data-dnd-container]");
2584
- }
2585
- })
2586
- ],
2587
- onDragStart,
2594
+ onDragStart: (event) => {
2595
+ var _a, _b;
2596
+ return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
2597
+ },
2588
2598
  onDragOver: (event, manager) => {
2589
2599
  var _a, _b;
2600
+ event.preventDefault();
2590
2601
  const { operation } = event;
2591
2602
  const { source, target } = operation;
2592
2603
  if (!source || !target) return;
@@ -2594,14 +2605,14 @@ var SortableProvider = ({
2594
2605
  let targetIndex = target.data.index;
2595
2606
  const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
2596
2607
  if (sourceIndex !== targetIndex && source.id !== target.id) {
2597
- const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
2608
+ const collisionPosition = collisionData.direction === "up" ? "before" : "after";
2598
2609
  if (targetIndex >= sourceIndex) {
2599
2610
  targetIndex = targetIndex - 1;
2600
2611
  }
2601
2612
  if (collisionPosition === "after") {
2602
2613
  targetIndex = targetIndex + 1;
2603
2614
  }
2604
- setMove({
2615
+ onMove({
2605
2616
  source: sourceIndex,
2606
2617
  target: targetIndex
2607
2618
  });
@@ -2609,12 +2620,8 @@ var SortableProvider = ({
2609
2620
  },
2610
2621
  onDragEnd: () => {
2611
2622
  setTimeout(() => {
2612
- if (move.source !== -1 && move.target !== -1) {
2613
- onMove(move);
2614
- }
2615
2623
  onDragEnd();
2616
2624
  }, 250);
2617
- setMove({ source: -1, target: -1 });
2618
2625
  },
2619
2626
  children
2620
2627
  }
@@ -2627,7 +2634,11 @@ var Sortable = ({
2627
2634
  children,
2628
2635
  type = "item"
2629
2636
  }) => {
2630
- const { ref: sortableRef, status } = useSortableSafe({
2637
+ const {
2638
+ ref: sortableRef,
2639
+ status,
2640
+ handleRef
2641
+ } = useSortableSafe({
2631
2642
  id,
2632
2643
  type,
2633
2644
  index,
@@ -2635,7 +2646,7 @@ var Sortable = ({
2635
2646
  data: { index },
2636
2647
  collisionDetector: createDynamicCollisionDetector("y")
2637
2648
  });
2638
- return children({ status, ref: sortableRef });
2649
+ return children({ status, ref: sortableRef, handleRef });
2639
2650
  };
2640
2651
 
2641
2652
  // components/AutoField/context.tsx
@@ -2693,6 +2704,7 @@ var ArrayField = ({
2693
2704
  value: _value,
2694
2705
  name,
2695
2706
  label,
2707
+ labelIcon,
2696
2708
  readOnly,
2697
2709
  id,
2698
2710
  Label: Label2 = (props) => /* @__PURE__ */ jsx7("div", __spreadValues({}, props))
@@ -2710,10 +2722,12 @@ var ArrayField = ({
2710
2722
  }),
2711
2723
  openId: ""
2712
2724
  };
2713
- const [localState, setLocalState] = useState4({ arrayState, value });
2725
+ const [localState, setLocalState] = useState3({ arrayState, value });
2714
2726
  useEffect6(() => {
2715
- setLocalState({ arrayState, value });
2716
- }, [value, thisArrayState]);
2727
+ var _a;
2728
+ const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
2729
+ setLocalState({ arrayState: _arrayState, value });
2730
+ }, [value]);
2717
2731
  const appStore = useAppStoreApi();
2718
2732
  const mapArrayStateToUi = useCallback2(
2719
2733
  (partialArrayState) => {
@@ -2756,11 +2770,13 @@ var ArrayField = ({
2756
2770
  setUi(mapArrayStateToUi(arrayState));
2757
2771
  }
2758
2772
  }, []);
2759
- const [isDragging, setIsDragging] = useState4(false);
2773
+ const [draggedItem, setDraggedItem] = useState3("");
2774
+ const isDragging = !!draggedItem;
2760
2775
  const canEdit = useAppStore(
2761
2776
  (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
2762
2777
  );
2763
2778
  const forceReadOnly = !canEdit;
2779
+ const valueRef = useRef(value);
2764
2780
  if (field.type !== "array" || !field.arrayFields) {
2765
2781
  return null;
2766
2782
  }
@@ -2769,16 +2785,22 @@ var ArrayField = ({
2769
2785
  Label2,
2770
2786
  {
2771
2787
  label: label || name,
2772
- icon: /* @__PURE__ */ jsx7(List, { size: 16 }),
2788
+ icon: labelIcon || /* @__PURE__ */ jsx7(List, { size: 16 }),
2773
2789
  el: "div",
2774
2790
  readOnly,
2775
2791
  children: /* @__PURE__ */ jsx7(
2776
2792
  SortableProvider,
2777
2793
  {
2778
- onDragStart: () => setIsDragging(true),
2779
- onDragEnd: () => setIsDragging(false),
2794
+ onDragStart: (id2) => setDraggedItem(id2),
2795
+ onDragEnd: () => {
2796
+ setDraggedItem("");
2797
+ onChange(valueRef.current);
2798
+ },
2780
2799
  onMove: (move) => {
2781
- const newValue = reorder(value, move.source, move.target);
2800
+ if (arrayState.items[move.source]._arrayId !== draggedItem) {
2801
+ return;
2802
+ }
2803
+ const newValue = reorder(localState.value, move.source, move.target);
2782
2804
  const newArrayStateItems = reorder(
2783
2805
  arrayState.items,
2784
2806
  move.source,
@@ -2791,11 +2813,11 @@ var ArrayField = ({
2791
2813
  })
2792
2814
  };
2793
2815
  setUi(newUi, false);
2794
- onChange(newValue, newUi);
2795
2816
  setLocalState({
2796
2817
  value: newValue,
2797
2818
  arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
2798
2819
  });
2820
+ valueRef.current = newValue;
2799
2821
  },
2800
2822
  children: /* @__PURE__ */ jsxs3(
2801
2823
  "div",
@@ -2804,11 +2826,8 @@ var ArrayField = ({
2804
2826
  hasItems: Array.isArray(value) && value.length > 0,
2805
2827
  addDisabled
2806
2828
  }),
2807
- onClick: (e) => {
2808
- e.preventDefault();
2809
- },
2810
2829
  children: [
2811
- /* @__PURE__ */ jsx7("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
2830
+ localState.arrayState.items.length > 0 && /* @__PURE__ */ jsx7("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
2812
2831
  const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
2813
2832
  const data = Array.from(localState.value || [])[i] || {};
2814
2833
  return /* @__PURE__ */ jsx7(
@@ -2817,7 +2836,7 @@ var ArrayField = ({
2817
2836
  id: _arrayId,
2818
2837
  index: i,
2819
2838
  disabled: readOnly,
2820
- children: ({ status, ref }) => /* @__PURE__ */ jsxs3(
2839
+ children: ({ status, ref, handleRef }) => /* @__PURE__ */ jsxs3(
2821
2840
  "div",
2822
2841
  {
2823
2842
  ref,
@@ -2830,6 +2849,7 @@ var ArrayField = ({
2830
2849
  /* @__PURE__ */ jsxs3(
2831
2850
  "div",
2832
2851
  {
2852
+ ref: handleRef,
2833
2853
  onClick: (e) => {
2834
2854
  if (isDragging) return;
2835
2855
  e.preventDefault();
@@ -2866,12 +2886,11 @@ var ArrayField = ({
2866
2886
  0,
2867
2887
  existingValue[i]
2868
2888
  );
2869
- onChange(
2870
- existingValue,
2871
- mapArrayStateToUi(
2872
- regenerateArrayState(existingValue)
2873
- )
2889
+ const newUi = mapArrayStateToUi(
2890
+ regenerateArrayState(existingValue)
2874
2891
  );
2892
+ setUi(newUi, false);
2893
+ onChange(existingValue);
2875
2894
  },
2876
2895
  title: "Duplicate",
2877
2896
  children: /* @__PURE__ */ jsx7(Copy, { size: 16 })
@@ -2890,12 +2909,13 @@ var ArrayField = ({
2890
2909
  ];
2891
2910
  existingValue.splice(i, 1);
2892
2911
  existingItems.splice(i, 1);
2893
- onChange(
2894
- existingValue,
2912
+ setUi(
2895
2913
  mapArrayStateToUi({
2896
2914
  items: existingItems
2897
- })
2915
+ }),
2916
+ false
2898
2917
  );
2918
+ onChange(existingValue);
2899
2919
  },
2900
2920
  title: "Delete",
2901
2921
  children: /* @__PURE__ */ jsx7(Trash, { size: 16 })
@@ -2907,58 +2927,49 @@ var ArrayField = ({
2907
2927
  ]
2908
2928
  }
2909
2929
  ),
2910
- /* @__PURE__ */ jsx7("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx7(
2911
- "fieldset",
2912
- {
2913
- className: getClassNameItem("fieldset"),
2914
- onPointerDownCapture: (e) => {
2915
- e.stopPropagation();
2916
- },
2917
- children: Object.keys(field.arrayFields).map((subName) => {
2918
- const subField = field.arrayFields[subName];
2919
- const indexName = `${name}[${i}]`;
2920
- const subPath = `${indexName}.${subName}`;
2921
- const localIndexName = `${localName}[${i}]`;
2922
- const localWildcardName = `${localName}[*]`;
2923
- const localSubPath = `${localIndexName}.${subName}`;
2924
- const localWildcardSubPath = `${localWildcardName}.${subName}`;
2925
- const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
2926
- const label2 = subField.label || subName;
2927
- return /* @__PURE__ */ jsx7(
2928
- NestedFieldProvider,
2930
+ /* @__PURE__ */ jsx7("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx7("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
2931
+ const subField = field.arrayFields[subName];
2932
+ const indexName = `${name}[${i}]`;
2933
+ const subPath = `${indexName}.${subName}`;
2934
+ const localIndexName = `${localName}[${i}]`;
2935
+ const localWildcardName = `${localName}[*]`;
2936
+ const localSubPath = `${localIndexName}.${subName}`;
2937
+ const localWildcardSubPath = `${localWildcardName}.${subName}`;
2938
+ const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
2939
+ const label2 = subField.label || subName;
2940
+ return /* @__PURE__ */ jsx7(
2941
+ NestedFieldProvider,
2942
+ {
2943
+ name: localIndexName,
2944
+ wildcardName: localWildcardName,
2945
+ subName,
2946
+ readOnlyFields,
2947
+ children: /* @__PURE__ */ jsx7(
2948
+ AutoFieldPrivate,
2929
2949
  {
2930
- name: localIndexName,
2931
- wildcardName: localWildcardName,
2932
- subName,
2933
- readOnlyFields,
2934
- children: /* @__PURE__ */ jsx7(
2935
- AutoFieldPrivate,
2936
- {
2937
- name: subPath,
2938
- label: label2,
2939
- id: `${_arrayId}_${subName}`,
2940
- readOnly: subReadOnly,
2941
- field: __spreadProps(__spreadValues({}, subField), {
2942
- label: label2
2943
- // May be used by custom fields
2944
- }),
2945
- value: data[subName],
2946
- onChange: (val, ui) => {
2947
- onChange(
2948
- replace(value, i, __spreadProps(__spreadValues({}, data), {
2949
- [subName]: val
2950
- })),
2951
- ui
2952
- );
2953
- }
2954
- }
2955
- )
2956
- },
2957
- subPath
2958
- );
2959
- })
2960
- }
2961
- ) })
2950
+ name: subPath,
2951
+ label: label2,
2952
+ id: `${_arrayId}_${subName}`,
2953
+ readOnly: subReadOnly,
2954
+ field: __spreadProps(__spreadValues({}, subField), {
2955
+ label: label2
2956
+ // May be used by custom fields
2957
+ }),
2958
+ value: data[subName],
2959
+ onChange: (val, ui) => {
2960
+ onChange(
2961
+ replace(value, i, __spreadProps(__spreadValues({}, data), {
2962
+ [subName]: val
2963
+ })),
2964
+ ui
2965
+ );
2966
+ }
2967
+ }
2968
+ )
2969
+ },
2970
+ subPath
2971
+ );
2972
+ }) }) })
2962
2973
  ]
2963
2974
  }
2964
2975
  )
@@ -2979,7 +2990,8 @@ var ArrayField = ({
2979
2990
  field.defaultItemProps || {}
2980
2991
  ];
2981
2992
  const newArrayState = regenerateArrayState(newValue);
2982
- onChange(newValue, mapArrayStateToUi(newArrayState));
2993
+ setUi(mapArrayStateToUi(newArrayState), false);
2994
+ onChange(newValue);
2983
2995
  },
2984
2996
  children: /* @__PURE__ */ jsx7(Plus, { size: 21 })
2985
2997
  }
@@ -3004,6 +3016,7 @@ var DefaultField = ({
3004
3016
  value: _value,
3005
3017
  name,
3006
3018
  label,
3019
+ labelIcon,
3007
3020
  Label: Label2,
3008
3021
  id
3009
3022
  }) => {
@@ -3012,7 +3025,7 @@ var DefaultField = ({
3012
3025
  Label2,
3013
3026
  {
3014
3027
  label: label || name,
3015
- icon: /* @__PURE__ */ jsxs4(Fragment2, { children: [
3028
+ icon: labelIcon || /* @__PURE__ */ jsxs4(Fragment2, { children: [
3016
3029
  field.type === "text" && /* @__PURE__ */ jsx8(Type, { size: 16 }),
3017
3030
  field.type === "number" && /* @__PURE__ */ jsx8(Hash, { size: 16 })
3018
3031
  ] }),
@@ -3062,7 +3075,7 @@ init_react_import();
3062
3075
  import {
3063
3076
  useMemo as useMemo2,
3064
3077
  useEffect as useEffect9,
3065
- useState as useState7,
3078
+ useState as useState6,
3066
3079
  useCallback as useCallback3,
3067
3080
  isValidElement
3068
3081
  } from "react";
@@ -3073,7 +3086,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
3073
3086
 
3074
3087
  // components/Modal/index.tsx
3075
3088
  init_react_import();
3076
- import { useEffect as useEffect7, useState as useState5 } from "react";
3089
+ import { useEffect as useEffect7, useState as useState4 } from "react";
3077
3090
 
3078
3091
  // css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
3079
3092
  init_react_import();
@@ -3088,7 +3101,7 @@ var Modal = ({
3088
3101
  onClose,
3089
3102
  isOpen
3090
3103
  }) => {
3091
- const [rootEl, setRootEl] = useState5(null);
3104
+ const [rootEl, setRootEl] = useState4(null);
3092
3105
  useEffect7(() => {
3093
3106
  setRootEl(document.getElementById("puck-portal-root"));
3094
3107
  }, []);
@@ -3136,7 +3149,7 @@ init_react_import();
3136
3149
 
3137
3150
  // components/Button/Button.tsx
3138
3151
  init_react_import();
3139
- import { useEffect as useEffect8, useState as useState6 } from "react";
3152
+ import { useEffect as useEffect8, useState as useState5 } from "react";
3140
3153
 
3141
3154
  // css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
3142
3155
  init_react_import();
@@ -3186,7 +3199,7 @@ var Button = (_a) => {
3186
3199
  "size",
3187
3200
  "loading"
3188
3201
  ]);
3189
- const [loading, setLoading] = useState6(loadingProp);
3202
+ const [loading, setLoading] = useState5(loadingProp);
3190
3203
  useEffect8(() => setLoading(loadingProp), [loadingProp]);
3191
3204
  const ElementType = href ? "a" : type ? "button" : "span";
3192
3205
  const dataAttrs = filterDataAttrs(props);
@@ -3242,12 +3255,12 @@ var ExternalInput = ({
3242
3255
  mapRow = (val) => val,
3243
3256
  filterFields
3244
3257
  } = field || {};
3245
- const [data, setData] = useState7([]);
3246
- const [isOpen, setOpen] = useState7(false);
3247
- const [isLoading, setIsLoading] = useState7(true);
3258
+ const [data, setData] = useState6([]);
3259
+ const [isOpen, setOpen] = useState6(false);
3260
+ const [isLoading, setIsLoading] = useState6(true);
3248
3261
  const hasFilterFields = !!filterFields;
3249
- const [filters, setFilters] = useState7(field.initialFilters || {});
3250
- const [filtersToggled, setFiltersToggled] = useState7(hasFilterFields);
3262
+ const [filters, setFilters] = useState6(field.initialFilters || {});
3263
+ const [filtersToggled, setFiltersToggled] = useState6(hasFilterFields);
3251
3264
  const mappedData = useMemo2(() => {
3252
3265
  return data.map(mapRow);
3253
3266
  }, [data]);
@@ -3262,7 +3275,7 @@ var ExternalInput = ({
3262
3275
  }
3263
3276
  return Array.from(validKeys);
3264
3277
  }, [mappedData]);
3265
- const [searchQuery, setSearchQuery] = useState7(field.initialQuery || "");
3278
+ const [searchQuery, setSearchQuery] = useState6(field.initialQuery || "");
3266
3279
  const search = useCallback3(
3267
3280
  (query, filters2) => __async(void 0, null, function* () {
3268
3281
  setIsLoading(true);
@@ -3448,6 +3461,7 @@ var ExternalField = ({
3448
3461
  value,
3449
3462
  name,
3450
3463
  label,
3464
+ labelIcon,
3451
3465
  Label: Label2,
3452
3466
  id,
3453
3467
  readOnly
@@ -3465,27 +3479,35 @@ var ExternalField = ({
3465
3479
  if (field.type !== "external") {
3466
3480
  return null;
3467
3481
  }
3468
- return /* @__PURE__ */ jsx13(Label2, { label: label || name, icon: /* @__PURE__ */ jsx13(Link, { size: 16 }), el: "div", children: /* @__PURE__ */ jsx13(
3469
- ExternalInput,
3482
+ return /* @__PURE__ */ jsx13(
3483
+ Label2,
3470
3484
  {
3471
- name,
3472
- field: __spreadProps(__spreadValues({}, validField), {
3473
- // DEPRECATED
3474
- placeholder: ((_a = deprecatedField.adaptor) == null ? void 0 : _a.name) ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder || "Select data",
3475
- mapProp: ((_b = deprecatedField.adaptor) == null ? void 0 : _b.mapProp) || validField.mapProp,
3476
- mapRow: validField.mapRow,
3477
- fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(void 0, null, function* () {
3478
- return yield deprecatedField.adaptor.fetchList(
3479
- deprecatedField.adaptorParams
3480
- );
3481
- }) : validField.fetchList
3482
- }),
3483
- onChange,
3484
- value,
3485
- id,
3486
- readOnly
3485
+ label: label || name,
3486
+ icon: labelIcon || /* @__PURE__ */ jsx13(Link, { size: 16 }),
3487
+ el: "div",
3488
+ children: /* @__PURE__ */ jsx13(
3489
+ ExternalInput,
3490
+ {
3491
+ name,
3492
+ field: __spreadProps(__spreadValues({}, validField), {
3493
+ // DEPRECATED
3494
+ placeholder: ((_a = deprecatedField.adaptor) == null ? void 0 : _a.name) ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder || "Select data",
3495
+ mapProp: ((_b = deprecatedField.adaptor) == null ? void 0 : _b.mapProp) || validField.mapProp,
3496
+ mapRow: validField.mapRow,
3497
+ fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(void 0, null, function* () {
3498
+ return yield deprecatedField.adaptor.fetchList(
3499
+ deprecatedField.adaptorParams
3500
+ );
3501
+ }) : validField.fetchList
3502
+ }),
3503
+ onChange,
3504
+ value,
3505
+ id,
3506
+ readOnly
3507
+ }
3508
+ )
3487
3509
  }
3488
- ) });
3510
+ );
3489
3511
  };
3490
3512
 
3491
3513
  // components/AutoField/fields/RadioField/index.tsx
@@ -3514,6 +3536,7 @@ var RadioField = ({
3514
3536
  name,
3515
3537
  id,
3516
3538
  label,
3539
+ labelIcon,
3517
3540
  Label: Label2
3518
3541
  }) => {
3519
3542
  const flatOptions = useMemo3(
@@ -3526,7 +3549,7 @@ var RadioField = ({
3526
3549
  return /* @__PURE__ */ jsx14(
3527
3550
  Label2,
3528
3551
  {
3529
- icon: /* @__PURE__ */ jsx14(CircleCheckBig, { size: 16 }),
3552
+ icon: labelIcon || /* @__PURE__ */ jsx14(CircleCheckBig, { size: 16 }),
3530
3553
  label: label || name,
3531
3554
  readOnly,
3532
3555
  el: "div",
@@ -3573,6 +3596,7 @@ var SelectField = ({
3573
3596
  field,
3574
3597
  onChange,
3575
3598
  label,
3599
+ labelIcon,
3576
3600
  Label: Label2,
3577
3601
  value,
3578
3602
  name,
@@ -3590,7 +3614,7 @@ var SelectField = ({
3590
3614
  Label2,
3591
3615
  {
3592
3616
  label: label || name,
3593
- icon: /* @__PURE__ */ jsx15(ChevronDown, { size: 16 }),
3617
+ icon: labelIcon || /* @__PURE__ */ jsx15(ChevronDown, { size: 16 }),
3594
3618
  readOnly,
3595
3619
  children: /* @__PURE__ */ jsx15(
3596
3620
  "select",
@@ -3634,24 +3658,33 @@ var TextareaField = ({
3634
3658
  value,
3635
3659
  name,
3636
3660
  label,
3661
+ labelIcon,
3637
3662
  Label: Label2,
3638
3663
  id
3639
3664
  }) => {
3640
- return /* @__PURE__ */ jsx16(Label2, { label: label || name, icon: /* @__PURE__ */ jsx16(Type, { size: 16 }), readOnly, children: /* @__PURE__ */ jsx16(
3641
- "textarea",
3665
+ return /* @__PURE__ */ jsx16(
3666
+ Label2,
3642
3667
  {
3643
- id,
3644
- className: getClassName13("input"),
3645
- autoComplete: "off",
3646
- name,
3647
- value: typeof value === "undefined" ? "" : value,
3648
- onChange: (e) => onChange(e.currentTarget.value),
3668
+ label: label || name,
3669
+ icon: labelIcon || /* @__PURE__ */ jsx16(Type, { size: 16 }),
3649
3670
  readOnly,
3650
- tabIndex: readOnly ? -1 : void 0,
3651
- rows: 5,
3652
- placeholder: field.type === "textarea" ? field.placeholder : void 0
3671
+ children: /* @__PURE__ */ jsx16(
3672
+ "textarea",
3673
+ {
3674
+ id,
3675
+ className: getClassName13("input"),
3676
+ autoComplete: "off",
3677
+ name,
3678
+ value: typeof value === "undefined" ? "" : value,
3679
+ onChange: (e) => onChange(e.currentTarget.value),
3680
+ readOnly,
3681
+ tabIndex: readOnly ? -1 : void 0,
3682
+ rows: 5,
3683
+ placeholder: field.type === "textarea" ? field.placeholder : void 0
3684
+ }
3685
+ )
3653
3686
  }
3654
- ) });
3687
+ );
3655
3688
  };
3656
3689
 
3657
3690
  // components/AutoField/fields/ObjectField/index.tsx
@@ -3670,6 +3703,7 @@ var ObjectField = ({
3670
3703
  value,
3671
3704
  name,
3672
3705
  label,
3706
+ labelIcon,
3673
3707
  Label: Label2,
3674
3708
  readOnly,
3675
3709
  id
@@ -3683,7 +3717,7 @@ var ObjectField = ({
3683
3717
  Label2,
3684
3718
  {
3685
3719
  label: label || name,
3686
- icon: /* @__PURE__ */ jsx17(EllipsisVertical, { size: 16 }),
3720
+ icon: labelIcon || /* @__PURE__ */ jsx17(EllipsisVertical, { size: 16 }),
3687
3721
  el: "div",
3688
3722
  readOnly,
3689
3723
  children: /* @__PURE__ */ jsx17("div", { className: getClassName14(), children: /* @__PURE__ */ jsx17("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
@@ -3730,12 +3764,12 @@ var ObjectField = ({
3730
3764
 
3731
3765
  // lib/use-safe-id.ts
3732
3766
  init_react_import();
3733
- import React2, { useState as useState8 } from "react";
3767
+ import React2, { useState as useState7 } from "react";
3734
3768
  var useSafeId = () => {
3735
3769
  if (typeof React2.useId !== "undefined") {
3736
3770
  return React2.useId();
3737
3771
  }
3738
- const [id] = useState8(generateId());
3772
+ const [id] = useState7(generateId());
3739
3773
  return id;
3740
3774
  };
3741
3775
 
@@ -3800,6 +3834,7 @@ function AutoFieldInternal(props) {
3800
3834
  const { id, Label: Label2 = FieldLabelInternal } = props;
3801
3835
  const field = props.field;
3802
3836
  const label = field.label;
3837
+ const labelIcon = field.labelIcon;
3803
3838
  const defaultId = useSafeId();
3804
3839
  const resolvedId = id || defaultId;
3805
3840
  const defaultFields = {
@@ -3825,6 +3860,7 @@ function AutoFieldInternal(props) {
3825
3860
  const mergedProps = __spreadProps(__spreadValues({}, props), {
3826
3861
  field,
3827
3862
  label,
3863
+ labelIcon,
3828
3864
  Label: Label2,
3829
3865
  id: resolvedId
3830
3866
  });
@@ -3886,11 +3922,14 @@ function AutoFieldInternal(props) {
3886
3922
  function AutoFieldPrivate(props) {
3887
3923
  const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
3888
3924
  const { value, onChange } = props;
3889
- const [localValue, setLocalValue] = useState9(value);
3890
- const onChangeLocal = useCallback4((val, ui) => {
3891
- setLocalValue(val);
3892
- onChange(val, ui);
3893
- }, []);
3925
+ const [localValue, setLocalValue] = useState8(value);
3926
+ const onChangeLocal = useCallback4(
3927
+ (val, ui) => {
3928
+ setLocalValue(val);
3929
+ onChange(val, ui);
3930
+ },
3931
+ [onChange]
3932
+ );
3894
3933
  useEffect11(() => {
3895
3934
  if (!isFocused) {
3896
3935
  setLocalValue(value);
@@ -3923,7 +3962,7 @@ init_react_import();
3923
3962
  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" };
3924
3963
 
3925
3964
  // components/Drawer/index.tsx
3926
- import { useId as useId2, useMemo as useMemo9, useState as useState16 } from "react";
3965
+ import { useMemo as useMemo9, useState as useState15 } from "react";
3927
3966
 
3928
3967
  // components/DragDropContext/index.tsx
3929
3968
  init_react_import();
@@ -3933,9 +3972,8 @@ import {
3933
3972
  useCallback as useCallback10,
3934
3973
  useContext as useContext7,
3935
3974
  useEffect as useEffect17,
3936
- useId,
3937
- useRef as useRef3,
3938
- useState as useState15
3975
+ useRef as useRef4,
3976
+ useState as useState14
3939
3977
  } from "react";
3940
3978
  import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
3941
3979
 
@@ -3947,7 +3985,7 @@ import {
3947
3985
  useContext as useContext6,
3948
3986
  useEffect as useEffect16,
3949
3987
  useMemo as useMemo8,
3950
- useRef as useRef2
3988
+ useRef as useRef3
3951
3989
  } from "react";
3952
3990
 
3953
3991
  // components/DraggableComponent/index.tsx
@@ -3957,8 +3995,8 @@ import {
3957
3995
  useContext as useContext5,
3958
3996
  useEffect as useEffect12,
3959
3997
  useMemo as useMemo7,
3960
- useRef,
3961
- useState as useState11
3998
+ useRef as useRef2,
3999
+ useState as useState10
3962
4000
  } from "react";
3963
4001
 
3964
4002
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
@@ -3993,7 +4031,7 @@ import {
3993
4031
  createContext as createContext3,
3994
4032
  useCallback as useCallback5,
3995
4033
  useMemo as useMemo6,
3996
- useState as useState10
4034
+ useState as useState9
3997
4035
  } from "react";
3998
4036
  import { createStore as createStore2 } from "zustand";
3999
4037
  import { Fragment as Fragment5, jsx as jsx19 } from "react/jsx-runtime";
@@ -4018,8 +4056,8 @@ var DropZoneProvider = ({
4018
4056
  children,
4019
4057
  value
4020
4058
  }) => {
4021
- const [hoveringComponent, setHoveringComponent] = useState10();
4022
- const [activeZones, setActiveZones] = useState10({});
4059
+ const [hoveringComponent, setHoveringComponent] = useState9();
4060
+ const [activeZones, setActiveZones] = useState9({});
4023
4061
  const dispatch = useAppStore((s) => s.dispatch);
4024
4062
  const registerZone = useCallback5(
4025
4063
  (zoneCompound) => {
@@ -4127,7 +4165,7 @@ var DraggableComponent = ({
4127
4165
  const dispatch = useAppStore((s) => s.dispatch);
4128
4166
  const iframe = useAppStore((s) => s.iframe);
4129
4167
  const ctx = useContext5(dropZoneContext);
4130
- const [localZones, setLocalZones] = useState11({});
4168
+ const [localZones, setLocalZones] = useState10({});
4131
4169
  const registerLocalZone = useCallback6(
4132
4170
  (zoneCompound2, active) => {
4133
4171
  var _a;
@@ -4168,7 +4206,7 @@ var DraggableComponent = ({
4168
4206
  );
4169
4207
  const canCollide = permissions.drag || userIsDragging;
4170
4208
  const disabled = !isEnabled || !canCollide;
4171
- const [dragAxis, setDragAxis] = useState11(userDragAxis || autoDragAxis);
4209
+ const [dragAxis, setDragAxis] = useState10(userDragAxis || autoDragAxis);
4172
4210
  const { ref: sortableRef, status } = useSortableSafe({
4173
4211
  id,
4174
4212
  index,
@@ -4194,7 +4232,7 @@ var DraggableComponent = ({
4194
4232
  }
4195
4233
  });
4196
4234
  const thisIsDragging = status === "dragging";
4197
- const ref = useRef(null);
4235
+ const ref = useRef2(null);
4198
4236
  const refSetter = useCallback6(
4199
4237
  (el) => {
4200
4238
  sortableRef(el);
@@ -4204,7 +4242,7 @@ var DraggableComponent = ({
4204
4242
  },
4205
4243
  [sortableRef]
4206
4244
  );
4207
- const [portalEl, setPortalEl] = useState11();
4245
+ const [portalEl, setPortalEl] = useState10();
4208
4246
  useEffect12(() => {
4209
4247
  var _a, _b, _c;
4210
4248
  setPortalEl(
@@ -4231,7 +4269,7 @@ var DraggableComponent = ({
4231
4269
  };
4232
4270
  return style2;
4233
4271
  }, [ref.current]);
4234
- const [style, setStyle] = useState11();
4272
+ const [style, setStyle] = useState10();
4235
4273
  const sync = useCallback6(() => {
4236
4274
  setStyle(getStyle());
4237
4275
  }, [ref.current, iframe]);
@@ -4300,7 +4338,7 @@ var DraggableComponent = ({
4300
4338
  zone: zoneCompound
4301
4339
  });
4302
4340
  }, [index, zoneCompound]);
4303
- const [hover, setHover] = useState11(false);
4341
+ const [hover, setHover] = useState10(false);
4304
4342
  const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
4305
4343
  useEffect12(() => {
4306
4344
  if (!ref.current) {
@@ -4361,7 +4399,7 @@ var DraggableComponent = ({
4361
4399
  };
4362
4400
  }
4363
4401
  }, [disabled, ref]);
4364
- const [isVisible, setIsVisible] = useState11(false);
4402
+ const [isVisible, setIsVisible] = useState10(false);
4365
4403
  useEffect12(() => {
4366
4404
  sync();
4367
4405
  if ((isSelected || hover || indicativeHover) && !userIsDragging) {
@@ -4378,10 +4416,18 @@ var DraggableComponent = ({
4378
4416
  const rect = el.getBoundingClientRect();
4379
4417
  const diffLeft = rect.x;
4380
4418
  const exceedsBoundsLeft = diffLeft < 0;
4419
+ const diffTop = rect.y;
4420
+ const exceedsBoundsTop = diffTop < 0;
4381
4421
  if (exceedsBoundsLeft) {
4382
4422
  el.style.transformOrigin = "left top";
4383
4423
  el.style.left = "0px";
4384
4424
  }
4425
+ if (exceedsBoundsTop) {
4426
+ el.style.top = "12px";
4427
+ if (!exceedsBoundsLeft) {
4428
+ el.style.transformOrigin = "right top";
4429
+ }
4430
+ }
4385
4431
  }
4386
4432
  }
4387
4433
  },
@@ -4480,15 +4526,15 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
4480
4526
 
4481
4527
  // components/DropZone/lib/use-min-empty-height.ts
4482
4528
  init_react_import();
4483
- import { useEffect as useEffect13, useState as useState12 } from "react";
4529
+ import { useEffect as useEffect13, useState as useState11 } from "react";
4484
4530
  var useMinEmptyHeight = ({
4485
4531
  zoneCompound,
4486
4532
  userMinEmptyHeight,
4487
4533
  ref
4488
4534
  }) => {
4489
4535
  const appStore = useAppStoreApi();
4490
- const [prevHeight, setPrevHeight] = useState12(0);
4491
- const [isAnimating, setIsAnimating] = useState12(false);
4536
+ const [prevHeight, setPrevHeight] = useState11(0);
4537
+ const [isAnimating, setIsAnimating] = useState11(false);
4492
4538
  const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
4493
4539
  var _a, _b;
4494
4540
  return {
@@ -4534,7 +4580,7 @@ function assignRefs(refs, node) {
4534
4580
 
4535
4581
  // components/DropZone/lib/use-content-with-preview.ts
4536
4582
  init_react_import();
4537
- import { useEffect as useEffect14, useState as useState13 } from "react";
4583
+ import { useEffect as useEffect14, useState as useState12 } from "react";
4538
4584
 
4539
4585
  // lib/dnd/use-rendered-callback.ts
4540
4586
  init_react_import();
@@ -4565,8 +4611,8 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4565
4611
  }
4566
4612
  );
4567
4613
  const isDragging = useAppStore((s) => s.state.ui.isDragging);
4568
- const [contentIdsWithPreview, setContentIdsWithPreview] = useState13(contentIds);
4569
- const [localPreview, setLocalPreview] = useState13(
4614
+ const [contentIdsWithPreview, setContentIdsWithPreview] = useState12(contentIds);
4615
+ const [localPreview, setLocalPreview] = useState12(
4570
4616
  preview
4571
4617
  );
4572
4618
  const updateContent = useRenderedCallback(
@@ -4609,13 +4655,13 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4609
4655
 
4610
4656
  // components/DropZone/lib/use-drag-axis.ts
4611
4657
  init_react_import();
4612
- import { useCallback as useCallback8, useEffect as useEffect15, useState as useState14 } from "react";
4658
+ import { useCallback as useCallback8, useEffect as useEffect15, useState as useState13 } from "react";
4613
4659
  var GRID_DRAG_AXIS = "dynamic";
4614
4660
  var FLEX_ROW_DRAG_AXIS = "x";
4615
4661
  var DEFAULT_DRAG_AXIS = "y";
4616
4662
  var useDragAxis = (ref, collisionAxis) => {
4617
4663
  const status = useAppStore((s) => s.status);
4618
- const [dragAxis, setDragAxis] = useState14(
4664
+ const [dragAxis, setDragAxis] = useState13(
4619
4665
  collisionAxis || DEFAULT_DRAG_AXIS
4620
4666
  );
4621
4667
  const calculateDragAxis = useCallback8(() => {
@@ -4871,7 +4917,7 @@ var DropZoneEdit = forwardRef3(
4871
4917
  return content.map(({ props }) => props.id);
4872
4918
  })
4873
4919
  );
4874
- const ref = useRef2(null);
4920
+ const ref = useRef3(null);
4875
4921
  const acceptsTarget = useCallback9(
4876
4922
  (componentType) => {
4877
4923
  if (!componentType) {
@@ -5373,7 +5419,7 @@ function useDragListener(type, fn, deps = []) {
5373
5419
  }
5374
5420
  var AREA_CHANGE_DEBOUNCE_MS = 100;
5375
5421
  var useTempDisableFallback = (timeout3) => {
5376
- const lastFallbackDisable = useRef3(null);
5422
+ const lastFallbackDisable = useRef4(null);
5377
5423
  return useCallback10((manager) => {
5378
5424
  collisionStore.setState({ fallbackEnabled: false });
5379
5425
  const fallbackId = generateId();
@@ -5395,10 +5441,10 @@ var DragDropContextClient = ({
5395
5441
  const resolveData2 = useAppStore((s) => s.resolveData);
5396
5442
  const metadata = useAppStore((s) => s.metadata);
5397
5443
  const appStore = useAppStoreApi();
5398
- const id = useId();
5399
- const debouncedParamsRef = useRef3(null);
5444
+ const id = useSafeId();
5445
+ const debouncedParamsRef = useRef4(null);
5400
5446
  const tempDisableFallback = useTempDisableFallback(100);
5401
- const [zoneStore] = useState15(
5447
+ const [zoneStore] = useState14(
5402
5448
  () => createStore3(() => ({
5403
5449
  zoneDepthIndex: {},
5404
5450
  nextZoneDepthIndex: {},
@@ -5467,7 +5513,7 @@ var DragDropContextClient = ({
5467
5513
  );
5468
5514
  }
5469
5515
  }, []);
5470
- const [plugins] = useState15(() => [
5516
+ const [plugins] = useState14(() => [
5471
5517
  ...disableAutoScroll ? defaultPreset.plugins.filter((plugin) => plugin !== AutoScroller) : defaultPreset.plugins,
5472
5518
  createNestedDroppablePlugin(
5473
5519
  {
@@ -5515,9 +5561,9 @@ var DragDropContextClient = ({
5515
5561
  )
5516
5562
  ]);
5517
5563
  const sensors = useSensors();
5518
- const [dragListeners, setDragListeners] = useState15({});
5519
- const dragMode = useRef3(null);
5520
- const initialSelector = useRef3(void 0);
5564
+ const [dragListeners, setDragListeners] = useState14({});
5565
+ const dragMode = useRef4(null);
5566
+ const initialSelector = useRef4(void 0);
5521
5567
  return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
5522
5568
  dragListenerContext.Provider,
5523
5569
  {
@@ -5810,7 +5856,7 @@ var DrawerItem = ({
5810
5856
  isDragDisabled
5811
5857
  }) => {
5812
5858
  const resolvedId = id || name;
5813
- const [dynamicId, setDynamicId] = useState16(generateId(resolvedId));
5859
+ const [dynamicId, setDynamicId] = useState15(generateId(resolvedId));
5814
5860
  if (typeof index !== "undefined") {
5815
5861
  console.error(
5816
5862
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -5849,7 +5895,7 @@ var Drawer = ({
5849
5895
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
5850
5896
  );
5851
5897
  }
5852
- const id = useId2();
5898
+ const id = useSafeId();
5853
5899
  const { ref } = useDroppableSafe({
5854
5900
  id,
5855
5901
  type: "void",
@@ -5877,7 +5923,7 @@ import {
5877
5923
  useContext as useContext11,
5878
5924
  useEffect as useEffect25,
5879
5925
  useMemo as useMemo18,
5880
- useState as useState23
5926
+ useState as useState22
5881
5927
  } from "react";
5882
5928
 
5883
5929
  // components/SidebarSection/index.tsx
@@ -6177,7 +6223,7 @@ init_react_import();
6177
6223
 
6178
6224
  // lib/use-component-list.tsx
6179
6225
  init_react_import();
6180
- import { useEffect as useEffect18, useState as useState17 } from "react";
6226
+ import { useEffect as useEffect18, useState as useState16 } from "react";
6181
6227
 
6182
6228
  // components/ComponentList/index.tsx
6183
6229
  init_react_import();
@@ -6248,7 +6294,7 @@ ComponentList.Item = ComponentListItem;
6248
6294
  // lib/use-component-list.tsx
6249
6295
  import { jsx as jsx29 } from "react/jsx-runtime";
6250
6296
  var useComponentList = () => {
6251
- const [componentList, setComponentList] = useState17();
6297
+ const [componentList, setComponentList] = useState16();
6252
6298
  const config = useAppStore((s) => s.config);
6253
6299
  const uiComponentList = useAppStore((s) => s.state.ui.componentList);
6254
6300
  useEffect18(() => {
@@ -6331,7 +6377,7 @@ var Components = () => {
6331
6377
 
6332
6378
  // components/Puck/components/Preview/index.tsx
6333
6379
  init_react_import();
6334
- import { useCallback as useCallback12, useEffect as useEffect20, useRef as useRef4, useMemo as useMemo13 } from "react";
6380
+ import { useCallback as useCallback12, useEffect as useEffect20, useRef as useRef5, useMemo as useMemo13 } from "react";
6335
6381
 
6336
6382
  // components/AutoFrame/index.tsx
6337
6383
  init_react_import();
@@ -6339,7 +6385,7 @@ import {
6339
6385
  createContext as createContext5,
6340
6386
  useContext as useContext8,
6341
6387
  useEffect as useEffect19,
6342
- useState as useState18
6388
+ useState as useState17
6343
6389
  } from "react";
6344
6390
  import hash from "object-hash";
6345
6391
  import { createPortal as createPortal3 } from "react-dom";
@@ -6567,10 +6613,10 @@ function AutoFrame(_a) {
6567
6613
  "onNotReady",
6568
6614
  "frameRef"
6569
6615
  ]);
6570
- const [loaded, setLoaded] = useState18(false);
6571
- const [ctx, setCtx] = useState18({});
6572
- const [mountTarget, setMountTarget] = useState18();
6573
- const [stylesLoaded, setStylesLoaded] = useState18(false);
6616
+ const [loaded, setLoaded] = useState17(false);
6617
+ const [ctx, setCtx] = useState17({});
6618
+ const [mountTarget, setMountTarget] = useState17();
6619
+ const [stylesLoaded, setStylesLoaded] = useState17(false);
6574
6620
  useEffect19(() => {
6575
6621
  var _a2;
6576
6622
  if (frameRef.current) {
@@ -6683,7 +6729,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
6683
6729
  );
6684
6730
  const Frame = useMemo13(() => overrides.iframe, [overrides]);
6685
6731
  const rootProps = root.props || root;
6686
- const ref = useRef4(null);
6732
+ const ref = useRef5(null);
6687
6733
  useBubbleIframeEvents(ref);
6688
6734
  const inner = !renderData ? /* @__PURE__ */ jsx32(
6689
6735
  Page,
@@ -7115,13 +7161,13 @@ import {
7115
7161
  useCallback as useCallback14,
7116
7162
  useEffect as useEffect22,
7117
7163
  useMemo as useMemo16,
7118
- useRef as useRef5,
7119
- useState as useState20
7164
+ useRef as useRef6,
7165
+ useState as useState19
7120
7166
  } from "react";
7121
7167
 
7122
7168
  // components/ViewportControls/index.tsx
7123
7169
  init_react_import();
7124
- import { useEffect as useEffect21, useMemo as useMemo15, useState as useState19 } from "react";
7170
+ import { useEffect as useEffect21, useMemo as useMemo15, useState as useState18 } from "react";
7125
7171
 
7126
7172
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7127
7173
  init_react_import();
@@ -7144,7 +7190,7 @@ var ViewportButton = ({
7144
7190
  onClick
7145
7191
  }) => {
7146
7192
  const viewports = useAppStore((s) => s.state.ui.viewports);
7147
- const [isActive, setIsActive] = useState19(false);
7193
+ const [isActive, setIsActive] = useState18(false);
7148
7194
  useEffect21(() => {
7149
7195
  setIsActive(width === viewports.current.width);
7150
7196
  }, [width, viewports.current.width]);
@@ -7328,8 +7374,8 @@ var Canvas = () => {
7328
7374
  viewports: s.state.ui.viewports
7329
7375
  }))
7330
7376
  );
7331
- const frameRef = useRef5(null);
7332
- const [showTransition, setShowTransition] = useState20(false);
7377
+ const frameRef = useRef6(null);
7378
+ const [showTransition, setShowTransition] = useState19(false);
7333
7379
  const defaultRender = useMemo16(() => {
7334
7380
  const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment13, { children });
7335
7381
  return PuckDefault;
@@ -7388,7 +7434,7 @@ var Canvas = () => {
7388
7434
  window.removeEventListener("resize", cb);
7389
7435
  };
7390
7436
  }, []);
7391
- const [showLoader, setShowLoader] = useState20(false);
7437
+ const [showLoader, setShowLoader] = useState19(false);
7392
7438
  useEffect22(() => {
7393
7439
  setTimeout(() => {
7394
7440
  setShowLoader(true);
@@ -7518,10 +7564,10 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment14, { chil
7518
7564
 
7519
7565
  // lib/use-inject-css.ts
7520
7566
  init_react_import();
7521
- import { useEffect as useEffect23, useState as useState21 } from "react";
7567
+ import { useEffect as useEffect23, useState as useState20 } from "react";
7522
7568
  var styles = ``;
7523
7569
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7524
- const [el, setEl] = useState21();
7570
+ const [el, setEl] = useState20();
7525
7571
  useEffect23(() => {
7526
7572
  setEl(document.createElement("style"));
7527
7573
  }, []);
@@ -7563,7 +7609,7 @@ var usePreviewModeHotkeys = () => {
7563
7609
 
7564
7610
  // lib/use-puck.ts
7565
7611
  init_react_import();
7566
- import { createContext as createContext6, useContext as useContext10, useEffect as useEffect24, useState as useState22 } from "react";
7612
+ import { createContext as createContext6, useContext as useContext10, useEffect as useEffect24, useState as useState21 } from "react";
7567
7613
  import { createStore as createStore4, useStore as useStore3 } from "zustand";
7568
7614
  var generateUsePuck = (store) => {
7569
7615
  const history = {
@@ -7592,7 +7638,7 @@ var UsePuckStoreContext = createContext6(
7592
7638
  null
7593
7639
  );
7594
7640
  var useRegisterUsePuckStore = (appStore) => {
7595
- const [usePuckStore] = useState22(
7641
+ const [usePuckStore] = useState21(
7596
7642
  () => createStore4(() => generateUsePuck(appStore.getState()))
7597
7643
  );
7598
7644
  useEffect24(() => {
@@ -7674,7 +7720,7 @@ function PuckProvider({ children }) {
7674
7720
  enabled: true,
7675
7721
  waitForStyles: true
7676
7722
  }, _iframe);
7677
- const [generatedAppState] = useState23(() => {
7723
+ const [generatedAppState] = useState22(() => {
7678
7724
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
7679
7725
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
7680
7726
  let clientUiState = {};
@@ -7767,7 +7813,7 @@ function PuckProvider({ children }) {
7767
7813
  onAction,
7768
7814
  metadata
7769
7815
  ]);
7770
- const [appStore] = useState23(() => createAppStore(generateAppStore()));
7816
+ const [appStore] = useState22(() => createAppStore(generateAppStore()));
7771
7817
  useEffect25(() => {
7772
7818
  appStore.setState(__spreadValues({}, generateAppStore()));
7773
7819
  }, [
@@ -7797,7 +7843,7 @@ function PuckProvider({ children }) {
7797
7843
  const { state, resolveData: resolveData2 } = appStore.getState();
7798
7844
  resolveData2(state);
7799
7845
  }, []);
7800
- return /* @__PURE__ */ jsx38(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx38(UsePuckStoreContext, { value: uPuckStore, children }) });
7846
+ return /* @__PURE__ */ jsx38(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx38(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
7801
7847
  }
7802
7848
  function PuckLayout({ children }) {
7803
7849
  const {
@@ -7820,7 +7866,7 @@ function PuckLayout({ children }) {
7820
7866
  const rightSideBarVisible = useAppStore(
7821
7867
  (s) => s.state.ui.rightSideBarVisible
7822
7868
  );
7823
- const [menuOpen, setMenuOpen] = useState23(false);
7869
+ const [menuOpen, setMenuOpen] = useState22(false);
7824
7870
  const appStore = useAppStoreApi();
7825
7871
  useEffect25(() => {
7826
7872
  return appStore.subscribe((s) => {
@@ -7910,7 +7956,7 @@ function PuckLayout({ children }) {
7910
7956
  () => overrides.headerActions || defaultHeaderActionsRender,
7911
7957
  [overrides]
7912
7958
  );
7913
- const [mounted, setMounted] = useState23(false);
7959
+ const [mounted, setMounted] = useState22(false);
7914
7960
  useEffect25(() => {
7915
7961
  setMounted(true);
7916
7962
  }, []);
@@ -8075,40 +8121,6 @@ var migrations = [
8075
8121
  function migrate(data) {
8076
8122
  return migrations == null ? void 0 : migrations.reduce((acc, migration) => migration(acc), data);
8077
8123
  }
8078
-
8079
- // lib/transform-props.ts
8080
- init_react_import();
8081
- function transformProps(data, propTransforms) {
8082
- const mapItem = (item) => {
8083
- if (propTransforms[item.type]) {
8084
- return __spreadProps(__spreadValues({}, item), {
8085
- props: propTransforms[item.type](item.props)
8086
- });
8087
- }
8088
- return item;
8089
- };
8090
- const defaultedData = defaultData(data);
8091
- const rootProps = defaultedData.root.props || defaultedData.root;
8092
- let newRoot = __spreadValues({}, defaultedData.root);
8093
- if (propTransforms["root"]) {
8094
- if (defaultedData.root.props) {
8095
- newRoot.props = propTransforms["root"](rootProps);
8096
- } else {
8097
- newRoot = propTransforms["root"](rootProps);
8098
- }
8099
- }
8100
- const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
8101
- root: newRoot,
8102
- content: defaultedData.content.map(mapItem),
8103
- zones: Object.keys(data.zones || {}).reduce(
8104
- (acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
8105
- [zoneKey]: data.zones[zoneKey].map(mapItem)
8106
- }),
8107
- {}
8108
- )
8109
- });
8110
- return afterPropTransforms;
8111
- }
8112
8124
  export {
8113
8125
  Action,
8114
8126
  ActionBar,