@measured/puck 0.19.0-canary.020071e → 0.19.0-canary.0308d24

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
@@ -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, useRef, useState as useState4 } from "react";
679
+ import { useCallback as useCallback2, useEffect as useEffect6, 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();
@@ -2567,16 +2566,13 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2567
2566
  };
2568
2567
 
2569
2568
  // components/Sortable/index.tsx
2570
- import { RestrictToElement } from "@dnd-kit/dom/modifiers";
2571
2569
  import { jsx as jsx5 } from "react/jsx-runtime";
2572
2570
  var SortableProvider = ({
2573
- container,
2574
2571
  children,
2575
2572
  onDragStart,
2576
2573
  onDragEnd,
2577
2574
  onMove
2578
2575
  }) => {
2579
- const [move, setMove] = useState3({ source: -1, target: -1 });
2580
2576
  const sensors = useSensors({
2581
2577
  mouse: { distance: { value: 5 } }
2582
2578
  });
@@ -2584,16 +2580,13 @@ var SortableProvider = ({
2584
2580
  DragDropProvider,
2585
2581
  {
2586
2582
  sensors,
2587
- modifiers: [
2588
- RestrictToElement.configure({
2589
- element() {
2590
- return container.current;
2591
- }
2592
- })
2593
- ],
2594
- onDragStart,
2583
+ onDragStart: (event) => {
2584
+ var _a, _b;
2585
+ return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
2586
+ },
2595
2587
  onDragOver: (event, manager) => {
2596
2588
  var _a, _b;
2589
+ event.preventDefault();
2597
2590
  const { operation } = event;
2598
2591
  const { source, target } = operation;
2599
2592
  if (!source || !target) return;
@@ -2601,14 +2594,14 @@ var SortableProvider = ({
2601
2594
  let targetIndex = target.data.index;
2602
2595
  const collisionData = (_b = (_a = manager.dragOperation.data) == null ? void 0 : _a.collisionMap) == null ? void 0 : _b[target.id];
2603
2596
  if (sourceIndex !== targetIndex && source.id !== target.id) {
2604
- const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
2597
+ const collisionPosition = collisionData.direction === "up" ? "before" : "after";
2605
2598
  if (targetIndex >= sourceIndex) {
2606
2599
  targetIndex = targetIndex - 1;
2607
2600
  }
2608
2601
  if (collisionPosition === "after") {
2609
2602
  targetIndex = targetIndex + 1;
2610
2603
  }
2611
- setMove({
2604
+ onMove({
2612
2605
  source: sourceIndex,
2613
2606
  target: targetIndex
2614
2607
  });
@@ -2616,12 +2609,8 @@ var SortableProvider = ({
2616
2609
  },
2617
2610
  onDragEnd: () => {
2618
2611
  setTimeout(() => {
2619
- if (move.source !== -1 && move.target !== -1) {
2620
- onMove(move);
2621
- }
2622
2612
  onDragEnd();
2623
2613
  }, 250);
2624
- setMove({ source: -1, target: -1 });
2625
2614
  },
2626
2615
  children
2627
2616
  }
@@ -2722,10 +2711,12 @@ var ArrayField = ({
2722
2711
  }),
2723
2712
  openId: ""
2724
2713
  };
2725
- const [localState, setLocalState] = useState4({ arrayState, value });
2714
+ const [localState, setLocalState] = useState3({ arrayState, value });
2726
2715
  useEffect6(() => {
2727
- setLocalState({ arrayState, value });
2728
- }, [value, thisArrayState]);
2716
+ var _a;
2717
+ const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
2718
+ setLocalState({ arrayState: _arrayState, value });
2719
+ }, [value]);
2729
2720
  const appStore = useAppStoreApi();
2730
2721
  const mapArrayStateToUi = useCallback2(
2731
2722
  (partialArrayState) => {
@@ -2768,8 +2759,8 @@ var ArrayField = ({
2768
2759
  setUi(mapArrayStateToUi(arrayState));
2769
2760
  }
2770
2761
  }, []);
2771
- const [isDragging, setIsDragging] = useState4(false);
2772
- const dndContainerRef = useRef(null);
2762
+ const [draggedItem, setDraggedItem] = useState3("");
2763
+ const isDragging = !!draggedItem;
2773
2764
  const canEdit = useAppStore(
2774
2765
  (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
2775
2766
  );
@@ -2788,11 +2779,16 @@ var ArrayField = ({
2788
2779
  children: /* @__PURE__ */ jsx7(
2789
2780
  SortableProvider,
2790
2781
  {
2791
- container: dndContainerRef,
2792
- onDragStart: () => setIsDragging(true),
2793
- onDragEnd: () => setIsDragging(false),
2782
+ onDragStart: (id2) => setDraggedItem(id2),
2783
+ onDragEnd: () => {
2784
+ setDraggedItem("");
2785
+ onChange(localState.value);
2786
+ },
2794
2787
  onMove: (move) => {
2795
- const newValue = reorder(value, move.source, move.target);
2788
+ if (arrayState.items[move.source]._arrayId !== draggedItem) {
2789
+ return;
2790
+ }
2791
+ const newValue = reorder(localState.value, move.source, move.target);
2796
2792
  const newArrayStateItems = reorder(
2797
2793
  arrayState.items,
2798
2794
  move.source,
@@ -2805,7 +2801,6 @@ var ArrayField = ({
2805
2801
  })
2806
2802
  };
2807
2803
  setUi(newUi, false);
2808
- onChange(newValue, newUi);
2809
2804
  setLocalState({
2810
2805
  value: newValue,
2811
2806
  arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
@@ -2819,164 +2814,156 @@ var ArrayField = ({
2819
2814
  addDisabled
2820
2815
  }),
2821
2816
  children: [
2822
- localState.arrayState.items.length > 0 && /* @__PURE__ */ jsx7(
2823
- "div",
2824
- {
2825
- ref: dndContainerRef,
2826
- className: getClassName5("inner"),
2827
- "data-dnd-container": true,
2828
- children: localState.arrayState.items.map((item, i) => {
2829
- const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
2830
- const data = Array.from(localState.value || [])[i] || {};
2831
- return /* @__PURE__ */ jsx7(
2832
- Sortable,
2817
+ localState.arrayState.items.length > 0 && /* @__PURE__ */ jsx7("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
2818
+ const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
2819
+ const data = Array.from(localState.value || [])[i] || {};
2820
+ return /* @__PURE__ */ jsx7(
2821
+ Sortable,
2822
+ {
2823
+ id: _arrayId,
2824
+ index: i,
2825
+ disabled: readOnly,
2826
+ children: ({ status, ref, handleRef }) => /* @__PURE__ */ jsxs3(
2827
+ "div",
2833
2828
  {
2834
- id: _arrayId,
2835
- index: i,
2836
- disabled: readOnly,
2837
- children: ({ status, ref, handleRef }) => /* @__PURE__ */ jsxs3(
2838
- "div",
2839
- {
2840
- ref,
2841
- className: getClassNameItem({
2842
- isExpanded: arrayState.openId === _arrayId,
2843
- isDragging: status === "dragging",
2844
- readOnly
2845
- }),
2846
- children: [
2847
- /* @__PURE__ */ jsxs3(
2848
- "div",
2849
- {
2850
- ref: handleRef,
2851
- onClick: (e) => {
2852
- if (isDragging) return;
2853
- e.preventDefault();
2854
- e.stopPropagation();
2855
- if (arrayState.openId === _arrayId) {
2856
- setUi(
2857
- mapArrayStateToUi({
2858
- openId: ""
2859
- })
2860
- );
2861
- } else {
2862
- setUi(
2863
- mapArrayStateToUi({
2864
- openId: _arrayId
2865
- })
2866
- );
2867
- }
2868
- },
2869
- className: getClassNameItem("summary"),
2870
- children: [
2871
- field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
2872
- /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("rhs"), children: [
2873
- !readOnly && /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("actions"), children: [
2874
- /* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
2875
- IconButton,
2876
- {
2877
- type: "button",
2878
- disabled: !!addDisabled,
2879
- onClick: (e) => {
2880
- e.stopPropagation();
2881
- const existingValue = [...value || []];
2882
- existingValue.splice(
2883
- i,
2884
- 0,
2885
- existingValue[i]
2886
- );
2887
- onChange(
2888
- existingValue,
2889
- mapArrayStateToUi(
2890
- regenerateArrayState(existingValue)
2891
- )
2892
- );
2893
- },
2894
- title: "Duplicate",
2895
- children: /* @__PURE__ */ jsx7(Copy, { size: 16 })
2896
- }
2897
- ) }),
2898
- /* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
2899
- IconButton,
2900
- {
2901
- type: "button",
2902
- disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
2903
- onClick: (e) => {
2904
- e.stopPropagation();
2905
- const existingValue = [...value || []];
2906
- const existingItems = [
2907
- ...arrayState.items || []
2908
- ];
2909
- existingValue.splice(i, 1);
2910
- existingItems.splice(i, 1);
2911
- onChange(
2912
- existingValue,
2913
- mapArrayStateToUi({
2914
- items: existingItems
2915
- })
2916
- );
2917
- },
2918
- title: "Delete",
2919
- children: /* @__PURE__ */ jsx7(Trash, { size: 16 })
2920
- }
2921
- ) })
2922
- ] }),
2923
- /* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(DragIcon, {}) })
2924
- ] })
2925
- ]
2829
+ ref,
2830
+ className: getClassNameItem({
2831
+ isExpanded: arrayState.openId === _arrayId,
2832
+ isDragging: status === "dragging",
2833
+ readOnly
2834
+ }),
2835
+ children: [
2836
+ /* @__PURE__ */ jsxs3(
2837
+ "div",
2838
+ {
2839
+ ref: handleRef,
2840
+ onClick: (e) => {
2841
+ if (isDragging) return;
2842
+ e.preventDefault();
2843
+ e.stopPropagation();
2844
+ if (arrayState.openId === _arrayId) {
2845
+ setUi(
2846
+ mapArrayStateToUi({
2847
+ openId: ""
2848
+ })
2849
+ );
2850
+ } else {
2851
+ setUi(
2852
+ mapArrayStateToUi({
2853
+ openId: _arrayId
2854
+ })
2855
+ );
2926
2856
  }
2927
- ),
2928
- /* @__PURE__ */ jsx7("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx7("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
2929
- const subField = field.arrayFields[subName];
2930
- const indexName = `${name}[${i}]`;
2931
- const subPath = `${indexName}.${subName}`;
2932
- const localIndexName = `${localName}[${i}]`;
2933
- const localWildcardName = `${localName}[*]`;
2934
- const localSubPath = `${localIndexName}.${subName}`;
2935
- const localWildcardSubPath = `${localWildcardName}.${subName}`;
2936
- const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
2937
- const label2 = subField.label || subName;
2938
- return /* @__PURE__ */ jsx7(
2939
- NestedFieldProvider,
2940
- {
2941
- name: localIndexName,
2942
- wildcardName: localWildcardName,
2943
- subName,
2944
- readOnlyFields,
2945
- children: /* @__PURE__ */ jsx7(
2946
- AutoFieldPrivate,
2857
+ },
2858
+ className: getClassNameItem("summary"),
2859
+ children: [
2860
+ field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
2861
+ /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("rhs"), children: [
2862
+ !readOnly && /* @__PURE__ */ jsxs3("div", { className: getClassNameItem("actions"), children: [
2863
+ /* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
2864
+ IconButton,
2947
2865
  {
2948
- name: subPath,
2949
- label: label2,
2950
- id: `${_arrayId}_${subName}`,
2951
- readOnly: subReadOnly,
2952
- field: __spreadProps(__spreadValues({}, subField), {
2953
- label: label2
2954
- // May be used by custom fields
2955
- }),
2956
- value: data[subName],
2957
- onChange: (val, ui) => {
2958
- onChange(
2959
- replace(value, i, __spreadProps(__spreadValues({}, data), {
2960
- [subName]: val
2961
- })),
2962
- ui
2866
+ type: "button",
2867
+ disabled: !!addDisabled,
2868
+ onClick: (e) => {
2869
+ e.stopPropagation();
2870
+ const existingValue = [...value || []];
2871
+ existingValue.splice(
2872
+ i,
2873
+ 0,
2874
+ existingValue[i]
2875
+ );
2876
+ const newUi = mapArrayStateToUi(
2877
+ regenerateArrayState(existingValue)
2963
2878
  );
2964
- }
2879
+ setUi(newUi, false);
2880
+ onChange(existingValue);
2881
+ },
2882
+ title: "Duplicate",
2883
+ children: /* @__PURE__ */ jsx7(Copy, { size: 16 })
2965
2884
  }
2966
- )
2967
- },
2968
- subPath
2969
- );
2970
- }) }) })
2971
- ]
2972
- }
2973
- )
2974
- },
2975
- _arrayId
2976
- );
2977
- })
2978
- }
2979
- ),
2885
+ ) }),
2886
+ /* @__PURE__ */ jsx7("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx7(
2887
+ IconButton,
2888
+ {
2889
+ type: "button",
2890
+ disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
2891
+ onClick: (e) => {
2892
+ e.stopPropagation();
2893
+ const existingValue = [...value || []];
2894
+ const existingItems = [
2895
+ ...arrayState.items || []
2896
+ ];
2897
+ existingValue.splice(i, 1);
2898
+ existingItems.splice(i, 1);
2899
+ setUi(
2900
+ mapArrayStateToUi({
2901
+ items: existingItems
2902
+ }),
2903
+ false
2904
+ );
2905
+ onChange(existingValue);
2906
+ },
2907
+ title: "Delete",
2908
+ children: /* @__PURE__ */ jsx7(Trash, { size: 16 })
2909
+ }
2910
+ ) })
2911
+ ] }),
2912
+ /* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(DragIcon, {}) })
2913
+ ] })
2914
+ ]
2915
+ }
2916
+ ),
2917
+ /* @__PURE__ */ jsx7("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx7("fieldset", { className: getClassNameItem("fieldset"), 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,
2929
+ {
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
+ }
2962
+ )
2963
+ },
2964
+ _arrayId
2965
+ );
2966
+ }) }),
2980
2967
  !addDisabled && /* @__PURE__ */ jsx7(
2981
2968
  "button",
2982
2969
  {
@@ -2990,7 +2977,8 @@ var ArrayField = ({
2990
2977
  field.defaultItemProps || {}
2991
2978
  ];
2992
2979
  const newArrayState = regenerateArrayState(newValue);
2993
- onChange(newValue, mapArrayStateToUi(newArrayState));
2980
+ setUi(mapArrayStateToUi(newArrayState), false);
2981
+ onChange(newValue);
2994
2982
  },
2995
2983
  children: /* @__PURE__ */ jsx7(Plus, { size: 21 })
2996
2984
  }
@@ -3074,7 +3062,7 @@ init_react_import();
3074
3062
  import {
3075
3063
  useMemo as useMemo2,
3076
3064
  useEffect as useEffect9,
3077
- useState as useState7,
3065
+ useState as useState6,
3078
3066
  useCallback as useCallback3,
3079
3067
  isValidElement
3080
3068
  } from "react";
@@ -3085,7 +3073,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
3085
3073
 
3086
3074
  // components/Modal/index.tsx
3087
3075
  init_react_import();
3088
- import { useEffect as useEffect7, useState as useState5 } from "react";
3076
+ import { useEffect as useEffect7, useState as useState4 } from "react";
3089
3077
 
3090
3078
  // css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
3091
3079
  init_react_import();
@@ -3100,7 +3088,7 @@ var Modal = ({
3100
3088
  onClose,
3101
3089
  isOpen
3102
3090
  }) => {
3103
- const [rootEl, setRootEl] = useState5(null);
3091
+ const [rootEl, setRootEl] = useState4(null);
3104
3092
  useEffect7(() => {
3105
3093
  setRootEl(document.getElementById("puck-portal-root"));
3106
3094
  }, []);
@@ -3148,7 +3136,7 @@ init_react_import();
3148
3136
 
3149
3137
  // components/Button/Button.tsx
3150
3138
  init_react_import();
3151
- import { useEffect as useEffect8, useState as useState6 } from "react";
3139
+ import { useEffect as useEffect8, useState as useState5 } from "react";
3152
3140
 
3153
3141
  // css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
3154
3142
  init_react_import();
@@ -3198,7 +3186,7 @@ var Button = (_a) => {
3198
3186
  "size",
3199
3187
  "loading"
3200
3188
  ]);
3201
- const [loading, setLoading] = useState6(loadingProp);
3189
+ const [loading, setLoading] = useState5(loadingProp);
3202
3190
  useEffect8(() => setLoading(loadingProp), [loadingProp]);
3203
3191
  const ElementType = href ? "a" : type ? "button" : "span";
3204
3192
  const dataAttrs = filterDataAttrs(props);
@@ -3254,12 +3242,12 @@ var ExternalInput = ({
3254
3242
  mapRow = (val) => val,
3255
3243
  filterFields
3256
3244
  } = field || {};
3257
- const [data, setData] = useState7([]);
3258
- const [isOpen, setOpen] = useState7(false);
3259
- const [isLoading, setIsLoading] = useState7(true);
3245
+ const [data, setData] = useState6([]);
3246
+ const [isOpen, setOpen] = useState6(false);
3247
+ const [isLoading, setIsLoading] = useState6(true);
3260
3248
  const hasFilterFields = !!filterFields;
3261
- const [filters, setFilters] = useState7(field.initialFilters || {});
3262
- const [filtersToggled, setFiltersToggled] = useState7(hasFilterFields);
3249
+ const [filters, setFilters] = useState6(field.initialFilters || {});
3250
+ const [filtersToggled, setFiltersToggled] = useState6(hasFilterFields);
3263
3251
  const mappedData = useMemo2(() => {
3264
3252
  return data.map(mapRow);
3265
3253
  }, [data]);
@@ -3274,7 +3262,7 @@ var ExternalInput = ({
3274
3262
  }
3275
3263
  return Array.from(validKeys);
3276
3264
  }, [mappedData]);
3277
- const [searchQuery, setSearchQuery] = useState7(field.initialQuery || "");
3265
+ const [searchQuery, setSearchQuery] = useState6(field.initialQuery || "");
3278
3266
  const search = useCallback3(
3279
3267
  (query, filters2) => __async(void 0, null, function* () {
3280
3268
  setIsLoading(true);
@@ -3763,12 +3751,12 @@ var ObjectField = ({
3763
3751
 
3764
3752
  // lib/use-safe-id.ts
3765
3753
  init_react_import();
3766
- import React2, { useState as useState8 } from "react";
3754
+ import React2, { useState as useState7 } from "react";
3767
3755
  var useSafeId = () => {
3768
3756
  if (typeof React2.useId !== "undefined") {
3769
3757
  return React2.useId();
3770
3758
  }
3771
- const [id] = useState8(generateId());
3759
+ const [id] = useState7(generateId());
3772
3760
  return id;
3773
3761
  };
3774
3762
 
@@ -3921,7 +3909,7 @@ function AutoFieldInternal(props) {
3921
3909
  function AutoFieldPrivate(props) {
3922
3910
  const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
3923
3911
  const { value, onChange } = props;
3924
- const [localValue, setLocalValue] = useState9(value);
3912
+ const [localValue, setLocalValue] = useState8(value);
3925
3913
  const onChangeLocal = useCallback4(
3926
3914
  (val, ui) => {
3927
3915
  setLocalValue(val);
@@ -3961,7 +3949,7 @@ init_react_import();
3961
3949
  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" };
3962
3950
 
3963
3951
  // components/Drawer/index.tsx
3964
- import { useMemo as useMemo9, useState as useState16 } from "react";
3952
+ import { useMemo as useMemo9, useState as useState15 } from "react";
3965
3953
 
3966
3954
  // components/DragDropContext/index.tsx
3967
3955
  init_react_import();
@@ -3972,7 +3960,7 @@ import {
3972
3960
  useContext as useContext7,
3973
3961
  useEffect as useEffect17,
3974
3962
  useRef as useRef4,
3975
- useState as useState15
3963
+ useState as useState14
3976
3964
  } from "react";
3977
3965
  import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
3978
3966
 
@@ -3995,7 +3983,7 @@ import {
3995
3983
  useEffect as useEffect12,
3996
3984
  useMemo as useMemo7,
3997
3985
  useRef as useRef2,
3998
- useState as useState11
3986
+ useState as useState10
3999
3987
  } from "react";
4000
3988
 
4001
3989
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
@@ -4030,7 +4018,7 @@ import {
4030
4018
  createContext as createContext3,
4031
4019
  useCallback as useCallback5,
4032
4020
  useMemo as useMemo6,
4033
- useState as useState10
4021
+ useState as useState9
4034
4022
  } from "react";
4035
4023
  import { createStore as createStore2 } from "zustand";
4036
4024
  import { Fragment as Fragment5, jsx as jsx19 } from "react/jsx-runtime";
@@ -4055,8 +4043,8 @@ var DropZoneProvider = ({
4055
4043
  children,
4056
4044
  value
4057
4045
  }) => {
4058
- const [hoveringComponent, setHoveringComponent] = useState10();
4059
- const [activeZones, setActiveZones] = useState10({});
4046
+ const [hoveringComponent, setHoveringComponent] = useState9();
4047
+ const [activeZones, setActiveZones] = useState9({});
4060
4048
  const dispatch = useAppStore((s) => s.dispatch);
4061
4049
  const registerZone = useCallback5(
4062
4050
  (zoneCompound) => {
@@ -4164,7 +4152,7 @@ var DraggableComponent = ({
4164
4152
  const dispatch = useAppStore((s) => s.dispatch);
4165
4153
  const iframe = useAppStore((s) => s.iframe);
4166
4154
  const ctx = useContext5(dropZoneContext);
4167
- const [localZones, setLocalZones] = useState11({});
4155
+ const [localZones, setLocalZones] = useState10({});
4168
4156
  const registerLocalZone = useCallback6(
4169
4157
  (zoneCompound2, active) => {
4170
4158
  var _a;
@@ -4205,7 +4193,7 @@ var DraggableComponent = ({
4205
4193
  );
4206
4194
  const canCollide = permissions.drag || userIsDragging;
4207
4195
  const disabled = !isEnabled || !canCollide;
4208
- const [dragAxis, setDragAxis] = useState11(userDragAxis || autoDragAxis);
4196
+ const [dragAxis, setDragAxis] = useState10(userDragAxis || autoDragAxis);
4209
4197
  const { ref: sortableRef, status } = useSortableSafe({
4210
4198
  id,
4211
4199
  index,
@@ -4241,7 +4229,7 @@ var DraggableComponent = ({
4241
4229
  },
4242
4230
  [sortableRef]
4243
4231
  );
4244
- const [portalEl, setPortalEl] = useState11();
4232
+ const [portalEl, setPortalEl] = useState10();
4245
4233
  useEffect12(() => {
4246
4234
  var _a, _b, _c;
4247
4235
  setPortalEl(
@@ -4268,7 +4256,7 @@ var DraggableComponent = ({
4268
4256
  };
4269
4257
  return style2;
4270
4258
  }, [ref.current]);
4271
- const [style, setStyle] = useState11();
4259
+ const [style, setStyle] = useState10();
4272
4260
  const sync = useCallback6(() => {
4273
4261
  setStyle(getStyle());
4274
4262
  }, [ref.current, iframe]);
@@ -4337,7 +4325,7 @@ var DraggableComponent = ({
4337
4325
  zone: zoneCompound
4338
4326
  });
4339
4327
  }, [index, zoneCompound]);
4340
- const [hover, setHover] = useState11(false);
4328
+ const [hover, setHover] = useState10(false);
4341
4329
  const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
4342
4330
  useEffect12(() => {
4343
4331
  if (!ref.current) {
@@ -4398,7 +4386,7 @@ var DraggableComponent = ({
4398
4386
  };
4399
4387
  }
4400
4388
  }, [disabled, ref]);
4401
- const [isVisible, setIsVisible] = useState11(false);
4389
+ const [isVisible, setIsVisible] = useState10(false);
4402
4390
  useEffect12(() => {
4403
4391
  sync();
4404
4392
  if ((isSelected || hover || indicativeHover) && !userIsDragging) {
@@ -4525,15 +4513,15 @@ var styles_module_default12 = { "DropZone": "_DropZone_kmkdc_1", "DropZone--isAc
4525
4513
 
4526
4514
  // components/DropZone/lib/use-min-empty-height.ts
4527
4515
  init_react_import();
4528
- import { useEffect as useEffect13, useState as useState12 } from "react";
4516
+ import { useEffect as useEffect13, useState as useState11 } from "react";
4529
4517
  var useMinEmptyHeight = ({
4530
4518
  zoneCompound,
4531
4519
  userMinEmptyHeight,
4532
4520
  ref
4533
4521
  }) => {
4534
4522
  const appStore = useAppStoreApi();
4535
- const [prevHeight, setPrevHeight] = useState12(0);
4536
- const [isAnimating, setIsAnimating] = useState12(false);
4523
+ const [prevHeight, setPrevHeight] = useState11(0);
4524
+ const [isAnimating, setIsAnimating] = useState11(false);
4537
4525
  const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
4538
4526
  var _a, _b;
4539
4527
  return {
@@ -4579,7 +4567,7 @@ function assignRefs(refs, node) {
4579
4567
 
4580
4568
  // components/DropZone/lib/use-content-with-preview.ts
4581
4569
  init_react_import();
4582
- import { useEffect as useEffect14, useState as useState13 } from "react";
4570
+ import { useEffect as useEffect14, useState as useState12 } from "react";
4583
4571
 
4584
4572
  // lib/dnd/use-rendered-callback.ts
4585
4573
  init_react_import();
@@ -4610,8 +4598,8 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4610
4598
  }
4611
4599
  );
4612
4600
  const isDragging = useAppStore((s) => s.state.ui.isDragging);
4613
- const [contentIdsWithPreview, setContentIdsWithPreview] = useState13(contentIds);
4614
- const [localPreview, setLocalPreview] = useState13(
4601
+ const [contentIdsWithPreview, setContentIdsWithPreview] = useState12(contentIds);
4602
+ const [localPreview, setLocalPreview] = useState12(
4615
4603
  preview
4616
4604
  );
4617
4605
  const updateContent = useRenderedCallback(
@@ -4654,13 +4642,13 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
4654
4642
 
4655
4643
  // components/DropZone/lib/use-drag-axis.ts
4656
4644
  init_react_import();
4657
- import { useCallback as useCallback8, useEffect as useEffect15, useState as useState14 } from "react";
4645
+ import { useCallback as useCallback8, useEffect as useEffect15, useState as useState13 } from "react";
4658
4646
  var GRID_DRAG_AXIS = "dynamic";
4659
4647
  var FLEX_ROW_DRAG_AXIS = "x";
4660
4648
  var DEFAULT_DRAG_AXIS = "y";
4661
4649
  var useDragAxis = (ref, collisionAxis) => {
4662
4650
  const status = useAppStore((s) => s.status);
4663
- const [dragAxis, setDragAxis] = useState14(
4651
+ const [dragAxis, setDragAxis] = useState13(
4664
4652
  collisionAxis || DEFAULT_DRAG_AXIS
4665
4653
  );
4666
4654
  const calculateDragAxis = useCallback8(() => {
@@ -5443,7 +5431,7 @@ var DragDropContextClient = ({
5443
5431
  const id = useSafeId();
5444
5432
  const debouncedParamsRef = useRef4(null);
5445
5433
  const tempDisableFallback = useTempDisableFallback(100);
5446
- const [zoneStore] = useState15(
5434
+ const [zoneStore] = useState14(
5447
5435
  () => createStore3(() => ({
5448
5436
  zoneDepthIndex: {},
5449
5437
  nextZoneDepthIndex: {},
@@ -5512,7 +5500,7 @@ var DragDropContextClient = ({
5512
5500
  );
5513
5501
  }
5514
5502
  }, []);
5515
- const [plugins] = useState15(() => [
5503
+ const [plugins] = useState14(() => [
5516
5504
  ...disableAutoScroll ? defaultPreset.plugins.filter((plugin) => plugin !== AutoScroller) : defaultPreset.plugins,
5517
5505
  createNestedDroppablePlugin(
5518
5506
  {
@@ -5560,7 +5548,7 @@ var DragDropContextClient = ({
5560
5548
  )
5561
5549
  ]);
5562
5550
  const sensors = useSensors();
5563
- const [dragListeners, setDragListeners] = useState15({});
5551
+ const [dragListeners, setDragListeners] = useState14({});
5564
5552
  const dragMode = useRef4(null);
5565
5553
  const initialSelector = useRef4(void 0);
5566
5554
  return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
@@ -5855,7 +5843,7 @@ var DrawerItem = ({
5855
5843
  isDragDisabled
5856
5844
  }) => {
5857
5845
  const resolvedId = id || name;
5858
- const [dynamicId, setDynamicId] = useState16(generateId(resolvedId));
5846
+ const [dynamicId, setDynamicId] = useState15(generateId(resolvedId));
5859
5847
  if (typeof index !== "undefined") {
5860
5848
  console.error(
5861
5849
  "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
@@ -5922,7 +5910,7 @@ import {
5922
5910
  useContext as useContext11,
5923
5911
  useEffect as useEffect25,
5924
5912
  useMemo as useMemo18,
5925
- useState as useState23
5913
+ useState as useState22
5926
5914
  } from "react";
5927
5915
 
5928
5916
  // components/SidebarSection/index.tsx
@@ -6222,7 +6210,7 @@ init_react_import();
6222
6210
 
6223
6211
  // lib/use-component-list.tsx
6224
6212
  init_react_import();
6225
- import { useEffect as useEffect18, useState as useState17 } from "react";
6213
+ import { useEffect as useEffect18, useState as useState16 } from "react";
6226
6214
 
6227
6215
  // components/ComponentList/index.tsx
6228
6216
  init_react_import();
@@ -6293,7 +6281,7 @@ ComponentList.Item = ComponentListItem;
6293
6281
  // lib/use-component-list.tsx
6294
6282
  import { jsx as jsx29 } from "react/jsx-runtime";
6295
6283
  var useComponentList = () => {
6296
- const [componentList, setComponentList] = useState17();
6284
+ const [componentList, setComponentList] = useState16();
6297
6285
  const config = useAppStore((s) => s.config);
6298
6286
  const uiComponentList = useAppStore((s) => s.state.ui.componentList);
6299
6287
  useEffect18(() => {
@@ -6384,7 +6372,7 @@ import {
6384
6372
  createContext as createContext5,
6385
6373
  useContext as useContext8,
6386
6374
  useEffect as useEffect19,
6387
- useState as useState18
6375
+ useState as useState17
6388
6376
  } from "react";
6389
6377
  import hash from "object-hash";
6390
6378
  import { createPortal as createPortal3 } from "react-dom";
@@ -6612,10 +6600,10 @@ function AutoFrame(_a) {
6612
6600
  "onNotReady",
6613
6601
  "frameRef"
6614
6602
  ]);
6615
- const [loaded, setLoaded] = useState18(false);
6616
- const [ctx, setCtx] = useState18({});
6617
- const [mountTarget, setMountTarget] = useState18();
6618
- const [stylesLoaded, setStylesLoaded] = useState18(false);
6603
+ const [loaded, setLoaded] = useState17(false);
6604
+ const [ctx, setCtx] = useState17({});
6605
+ const [mountTarget, setMountTarget] = useState17();
6606
+ const [stylesLoaded, setStylesLoaded] = useState17(false);
6619
6607
  useEffect19(() => {
6620
6608
  var _a2;
6621
6609
  if (frameRef.current) {
@@ -7161,12 +7149,12 @@ import {
7161
7149
  useEffect as useEffect22,
7162
7150
  useMemo as useMemo16,
7163
7151
  useRef as useRef6,
7164
- useState as useState20
7152
+ useState as useState19
7165
7153
  } from "react";
7166
7154
 
7167
7155
  // components/ViewportControls/index.tsx
7168
7156
  init_react_import();
7169
- import { useEffect as useEffect21, useMemo as useMemo15, useState as useState19 } from "react";
7157
+ import { useEffect as useEffect21, useMemo as useMemo15, useState as useState18 } from "react";
7170
7158
 
7171
7159
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7172
7160
  init_react_import();
@@ -7189,7 +7177,7 @@ var ViewportButton = ({
7189
7177
  onClick
7190
7178
  }) => {
7191
7179
  const viewports = useAppStore((s) => s.state.ui.viewports);
7192
- const [isActive, setIsActive] = useState19(false);
7180
+ const [isActive, setIsActive] = useState18(false);
7193
7181
  useEffect21(() => {
7194
7182
  setIsActive(width === viewports.current.width);
7195
7183
  }, [width, viewports.current.width]);
@@ -7374,7 +7362,7 @@ var Canvas = () => {
7374
7362
  }))
7375
7363
  );
7376
7364
  const frameRef = useRef6(null);
7377
- const [showTransition, setShowTransition] = useState20(false);
7365
+ const [showTransition, setShowTransition] = useState19(false);
7378
7366
  const defaultRender = useMemo16(() => {
7379
7367
  const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment13, { children });
7380
7368
  return PuckDefault;
@@ -7433,7 +7421,7 @@ var Canvas = () => {
7433
7421
  window.removeEventListener("resize", cb);
7434
7422
  };
7435
7423
  }, []);
7436
- const [showLoader, setShowLoader] = useState20(false);
7424
+ const [showLoader, setShowLoader] = useState19(false);
7437
7425
  useEffect22(() => {
7438
7426
  setTimeout(() => {
7439
7427
  setShowLoader(true);
@@ -7563,10 +7551,10 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment14, { chil
7563
7551
 
7564
7552
  // lib/use-inject-css.ts
7565
7553
  init_react_import();
7566
- import { useEffect as useEffect23, useState as useState21 } from "react";
7554
+ import { useEffect as useEffect23, useState as useState20 } from "react";
7567
7555
  var styles = ``;
7568
7556
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7569
- const [el, setEl] = useState21();
7557
+ const [el, setEl] = useState20();
7570
7558
  useEffect23(() => {
7571
7559
  setEl(document.createElement("style"));
7572
7560
  }, []);
@@ -7608,7 +7596,7 @@ var usePreviewModeHotkeys = () => {
7608
7596
 
7609
7597
  // lib/use-puck.ts
7610
7598
  init_react_import();
7611
- import { createContext as createContext6, useContext as useContext10, useEffect as useEffect24, useState as useState22 } from "react";
7599
+ import { createContext as createContext6, useContext as useContext10, useEffect as useEffect24, useState as useState21 } from "react";
7612
7600
  import { createStore as createStore4, useStore as useStore3 } from "zustand";
7613
7601
  var generateUsePuck = (store) => {
7614
7602
  const history = {
@@ -7637,7 +7625,7 @@ var UsePuckStoreContext = createContext6(
7637
7625
  null
7638
7626
  );
7639
7627
  var useRegisterUsePuckStore = (appStore) => {
7640
- const [usePuckStore] = useState22(
7628
+ const [usePuckStore] = useState21(
7641
7629
  () => createStore4(() => generateUsePuck(appStore.getState()))
7642
7630
  );
7643
7631
  useEffect24(() => {
@@ -7719,7 +7707,7 @@ function PuckProvider({ children }) {
7719
7707
  enabled: true,
7720
7708
  waitForStyles: true
7721
7709
  }, _iframe);
7722
- const [generatedAppState] = useState23(() => {
7710
+ const [generatedAppState] = useState22(() => {
7723
7711
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
7724
7712
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
7725
7713
  let clientUiState = {};
@@ -7812,7 +7800,7 @@ function PuckProvider({ children }) {
7812
7800
  onAction,
7813
7801
  metadata
7814
7802
  ]);
7815
- const [appStore] = useState23(() => createAppStore(generateAppStore()));
7803
+ const [appStore] = useState22(() => createAppStore(generateAppStore()));
7816
7804
  useEffect25(() => {
7817
7805
  appStore.setState(__spreadValues({}, generateAppStore()));
7818
7806
  }, [
@@ -7865,7 +7853,7 @@ function PuckLayout({ children }) {
7865
7853
  const rightSideBarVisible = useAppStore(
7866
7854
  (s) => s.state.ui.rightSideBarVisible
7867
7855
  );
7868
- const [menuOpen, setMenuOpen] = useState23(false);
7856
+ const [menuOpen, setMenuOpen] = useState22(false);
7869
7857
  const appStore = useAppStoreApi();
7870
7858
  useEffect25(() => {
7871
7859
  return appStore.subscribe((s) => {
@@ -7955,7 +7943,7 @@ function PuckLayout({ children }) {
7955
7943
  () => overrides.headerActions || defaultHeaderActionsRender,
7956
7944
  [overrides]
7957
7945
  );
7958
- const [mounted, setMounted] = useState23(false);
7946
+ const [mounted, setMounted] = useState22(false);
7959
7947
  useEffect25(() => {
7960
7948
  setMounted(true);
7961
7949
  }, []);