@measured/puck 0.21.0-canary.7dca3a5a → 0.21.0-canary.7ed9655b

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.
@@ -25,7 +25,7 @@ import {
25
25
  walkAppState,
26
26
  walkField,
27
27
  walkTree
28
- } from "./chunk-6SIKCDJJ.mjs";
28
+ } from "./chunk-IDP5ATXM.mjs";
29
29
 
30
30
  // ../../node_modules/classnames/index.js
31
31
  var require_classnames = __commonJS({
@@ -1071,29 +1071,37 @@ var flattenData = (state, config) => {
1071
1071
 
1072
1072
  // store/slices/permissions.ts
1073
1073
  var createPermissionsSlice = (set, get) => {
1074
- const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
1074
+ const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
1075
1075
  const { state, permissions, config } = get();
1076
1076
  const { cache, globalPermissions } = permissions;
1077
- const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
1078
- var _a, _b, _c;
1077
+ const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
1078
+ var _a, _b;
1079
1079
  const { config: config2, state: appState, setComponentLoading } = get();
1080
+ const itemCache = cache[item2.props.id];
1081
+ const nodes = appState.indexes.nodes;
1082
+ const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
1083
+ const parentNode = parentId ? nodes[parentId] : null;
1084
+ const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
1080
1085
  const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
1081
1086
  if (!componentConfig) {
1082
1087
  return;
1083
1088
  }
1084
1089
  const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
1085
1090
  if (componentConfig.resolvePermissions) {
1086
- const changed = getChanged(item2, (_a = cache[item2.props.id]) == null ? void 0 : _a.lastData);
1087
- if (Object.values(changed).some((el) => el === true) || force2) {
1091
+ const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
1092
+ const propsChanged = Object.values(changed).some((el) => el === true);
1093
+ const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
1094
+ if (propsChanged || parentChanged || force2) {
1088
1095
  const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
1089
1096
  const resolvedPermissions = yield componentConfig.resolvePermissions(
1090
1097
  item2,
1091
1098
  {
1092
1099
  changed,
1093
- lastPermissions: ((_b = cache[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
1100
+ lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
1094
1101
  permissions: initialPermissions,
1095
1102
  appState: makeStatePublic(appState),
1096
- lastData: ((_c = cache[item2.props.id]) == null ? void 0 : _c.lastData) || null
1103
+ lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
1104
+ parent: parentData
1097
1105
  }
1098
1106
  );
1099
1107
  const latest = get().permissions;
@@ -1101,6 +1109,7 @@ var createPermissionsSlice = (set, get) => {
1101
1109
  permissions: __spreadProps(__spreadValues({}, latest), {
1102
1110
  cache: __spreadProps(__spreadValues({}, latest.cache), {
1103
1111
  [item2.props.id]: {
1112
+ lastParentId: parentId,
1104
1113
  lastData: item2,
1105
1114
  lastPermissions: resolvedPermissions
1106
1115
  }
@@ -1114,9 +1123,9 @@ var createPermissionsSlice = (set, get) => {
1114
1123
  }
1115
1124
  }
1116
1125
  });
1117
- const resolveDataForRoot = (force2 = false) => {
1126
+ const resolvePermissionsForRoot = (force2 = false) => {
1118
1127
  const { state: appState } = get();
1119
- resolveDataForItem(
1128
+ resolvePermissionsForItem(
1120
1129
  // Shim the root data in by conforming to component data shape
1121
1130
  {
1122
1131
  type: "root",
@@ -1127,16 +1136,16 @@ var createPermissionsSlice = (set, get) => {
1127
1136
  };
1128
1137
  const { item, type, root } = params;
1129
1138
  if (item) {
1130
- yield resolveDataForItem(item, force);
1139
+ yield resolvePermissionsForItem(item, force);
1131
1140
  } else if (type) {
1132
- flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
1133
- yield resolveDataForItem(item2, force);
1141
+ flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
1142
+ yield resolvePermissionsForItem(item2, force);
1134
1143
  }));
1135
1144
  } else if (root) {
1136
- resolveDataForRoot(force);
1145
+ resolvePermissionsForRoot(force);
1137
1146
  } else {
1138
- flattenData(state, config).map((item2) => __async(void 0, null, function* () {
1139
- yield resolveDataForItem(item2, force);
1147
+ flattenData(state, config).map((item2) => __async(null, null, function* () {
1148
+ yield resolvePermissionsForItem(item2, force);
1140
1149
  }));
1141
1150
  }
1142
1151
  });
@@ -1216,7 +1225,7 @@ var createFieldsSlice = (_set, _get) => {
1216
1225
  };
1217
1226
  var useRegisterFieldsSlice = (appStore, id) => {
1218
1227
  const resolveFields = useCallback(
1219
- (reset) => __async(void 0, null, function* () {
1228
+ (reset) => __async(null, null, function* () {
1220
1229
  var _a, _b;
1221
1230
  const { fields, lastResolvedData } = appStore.getState().fields;
1222
1231
  const metadata = appStore.getState().metadata;
@@ -1417,7 +1426,7 @@ var createAppStore = (initialAppStore) => create2()(
1417
1426
  const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
1418
1427
  return __spreadProps(__spreadValues({}, s), { state, selectedItem });
1419
1428
  }),
1420
- resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
1429
+ resolveComponentData: (componentData, trigger) => __async(null, null, function* () {
1421
1430
  const { config, metadata, setComponentLoading, permissions } = get();
1422
1431
  const timeouts = {};
1423
1432
  return yield resolveComponentData(
@@ -1428,7 +1437,7 @@ var createAppStore = (initialAppStore) => create2()(
1428
1437
  const id = "id" in item.props ? item.props.id : "root";
1429
1438
  timeouts[id] = setComponentLoading(id, true, 50);
1430
1439
  },
1431
- (item) => __async(void 0, null, function* () {
1440
+ (item) => __async(null, null, function* () {
1432
1441
  const id = "id" in item.props ? item.props.id : "root";
1433
1442
  if ("type" in item) {
1434
1443
  yield permissions.refreshPermissions({ item });
@@ -1440,7 +1449,7 @@ var createAppStore = (initialAppStore) => create2()(
1440
1449
  trigger
1441
1450
  );
1442
1451
  }),
1443
- resolveAndCommitData: () => __async(void 0, null, function* () {
1452
+ resolveAndCommitData: () => __async(null, null, function* () {
1444
1453
  const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
1445
1454
  walkAppState(
1446
1455
  state,
@@ -1837,7 +1846,7 @@ var styles_module_default3 = { "InputWrapper": "_InputWrapper_bsxfo_1", "Input-l
1837
1846
 
1838
1847
  // components/AutoField/index.tsx
1839
1848
  import {
1840
- useCallback as useCallback4,
1849
+ useCallback as useCallback5,
1841
1850
  useContext as useContext3,
1842
1851
  useEffect as useEffect10,
1843
1852
  useMemo as useMemo3,
@@ -2250,7 +2259,13 @@ var ZoomOut = createLucideIcon("ZoomOut", [
2250
2259
  init_react_import();
2251
2260
 
2252
2261
  // components/AutoField/fields/ArrayField/index.tsx
2253
- import { useCallback as useCallback2, useEffect as useEffect6, useRef, useState as useState4 } from "react";
2262
+ import {
2263
+ memo as memo2,
2264
+ useCallback as useCallback2,
2265
+ useEffect as useEffect6,
2266
+ useRef,
2267
+ useState as useState4
2268
+ } from "react";
2254
2269
 
2255
2270
  // components/DragIcon/index.tsx
2256
2271
  init_react_import();
@@ -2528,7 +2543,7 @@ var collisionStore = createStore(() => ({
2528
2543
 
2529
2544
  // lib/dnd/collision/dynamic/index.ts
2530
2545
  var flushNext = "";
2531
- var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
2546
+ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => ((input) => {
2532
2547
  var _a, _b, _c, _d, _e;
2533
2548
  const { dragOperation, droppable } = input;
2534
2549
  const { position } = dragOperation;
@@ -2621,7 +2636,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2621
2636
  }
2622
2637
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
2623
2638
  return null;
2624
- };
2639
+ });
2625
2640
 
2626
2641
  // components/Sortable/index.tsx
2627
2642
  import { useSortable } from "@dnd-kit/react/sortable";
@@ -2743,89 +2758,250 @@ var NestedFieldProvider = ({
2743
2758
  );
2744
2759
  };
2745
2760
 
2761
+ // lib/data/get-deep.ts
2762
+ init_react_import();
2763
+ var getDeep = (node, path) => {
2764
+ const pathParts = path.split(".");
2765
+ return pathParts.reduce((acc, item) => {
2766
+ if (!acc) return;
2767
+ const [prop, indexStr] = item.replace("]", "").split("[");
2768
+ const val = acc[prop];
2769
+ if (indexStr && val) {
2770
+ return val[parseInt(indexStr)];
2771
+ }
2772
+ return val;
2773
+ }, node);
2774
+ };
2775
+
2776
+ // components/AutoField/subfield.tsx
2777
+ init_react_import();
2778
+ import { memo } from "react";
2779
+ import { jsx as jsx8 } from "react/jsx-runtime";
2780
+ var SubFieldInternal = ({
2781
+ field,
2782
+ id,
2783
+ index,
2784
+ name,
2785
+ subName,
2786
+ localName,
2787
+ onChange,
2788
+ forceReadOnly,
2789
+ value
2790
+ }) => {
2791
+ const indexName = typeof index !== "undefined" ? `${name}[${index}]` : name;
2792
+ const subPath = name ? `${indexName}.${subName}` : subName;
2793
+ const localIndexName = typeof index !== "undefined" ? `${localName}[${index}]` : localName != null ? localName : subName;
2794
+ const localWildcardName = typeof index !== "undefined" ? `${localName}[*]` : localName;
2795
+ const localSubPath = `${localIndexName}.${subName}`;
2796
+ const localWildcardSubPath = `${localWildcardName}.${subName}`;
2797
+ const { readOnlyFields } = useNestedFieldContext();
2798
+ const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
2799
+ const label = field.label || subName;
2800
+ return /* @__PURE__ */ jsx8(
2801
+ NestedFieldProvider,
2802
+ {
2803
+ name: localIndexName,
2804
+ wildcardName: localWildcardName,
2805
+ subName,
2806
+ readOnlyFields,
2807
+ children: /* @__PURE__ */ jsx8(
2808
+ AutoFieldPrivate,
2809
+ {
2810
+ name: subPath,
2811
+ label,
2812
+ id,
2813
+ readOnly: subReadOnly,
2814
+ field: __spreadProps(__spreadValues({}, field), {
2815
+ label
2816
+ // May be used by custom fields
2817
+ }),
2818
+ onChange: (val, ui) => {
2819
+ onChange(val, ui, subName);
2820
+ },
2821
+ value: typeof value !== "undefined" ? getDeep(value, subPath) : void 0
2822
+ }
2823
+ )
2824
+ },
2825
+ subPath
2826
+ );
2827
+ };
2828
+ var SubField = memo(SubFieldInternal);
2829
+
2746
2830
  // components/AutoField/fields/ArrayField/index.tsx
2747
- import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
2831
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal());
2832
+ import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
2748
2833
  var getClassName6 = get_class_name_factory_default("ArrayField", styles_module_default4);
2749
2834
  var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default4);
2835
+ var ArrayFieldItemInternal = ({
2836
+ id,
2837
+ arrayId,
2838
+ index,
2839
+ dragIndex,
2840
+ originalIndex,
2841
+ field,
2842
+ onChange,
2843
+ onToggleExpand,
2844
+ readOnly,
2845
+ actions,
2846
+ name,
2847
+ localName,
2848
+ getValue,
2849
+ value
2850
+ }) => {
2851
+ const isExpanded = useAppStore((s) => {
2852
+ var _a;
2853
+ return ((_a = s.state.ui.arrayState[arrayId]) == null ? void 0 : _a.openId) === id;
2854
+ });
2855
+ const itemSummary = useAppStore(() => {
2856
+ const data = value != null ? value : getValue();
2857
+ if (data && field.getItemSummary) {
2858
+ return field.getItemSummary(data, index);
2859
+ }
2860
+ return `Item #${originalIndex}`;
2861
+ });
2862
+ const canEdit = useAppStore(
2863
+ (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
2864
+ );
2865
+ return /* @__PURE__ */ jsx9(Sortable, { id, index: dragIndex, disabled: readOnly, children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ jsxs4(
2866
+ "div",
2867
+ {
2868
+ ref,
2869
+ className: getClassNameItem({
2870
+ isExpanded,
2871
+ isDragging,
2872
+ readOnly
2873
+ }),
2874
+ children: [
2875
+ /* @__PURE__ */ jsxs4(
2876
+ "div",
2877
+ {
2878
+ ref: handleRef,
2879
+ onClick: (e) => {
2880
+ if (isDragging) return;
2881
+ e.preventDefault();
2882
+ e.stopPropagation();
2883
+ onToggleExpand(id, isExpanded);
2884
+ },
2885
+ className: getClassNameItem("summary"),
2886
+ children: [
2887
+ itemSummary,
2888
+ /* @__PURE__ */ jsxs4("div", { className: getClassNameItem("rhs"), children: [
2889
+ !readOnly && /* @__PURE__ */ jsx9("div", { className: getClassNameItem("actions"), children: actions }),
2890
+ /* @__PURE__ */ jsx9("div", { children: /* @__PURE__ */ jsx9(DragIcon, {}) })
2891
+ ] })
2892
+ ]
2893
+ }
2894
+ ),
2895
+ /* @__PURE__ */ jsx9("div", { className: getClassNameItem("body"), children: isExpanded && /* @__PURE__ */ jsx9("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
2896
+ const subField = field.arrayFields[subName];
2897
+ return /* @__PURE__ */ jsx9(
2898
+ SubField,
2899
+ {
2900
+ id: `${id}_${subName}`,
2901
+ name,
2902
+ subName,
2903
+ localName,
2904
+ index,
2905
+ field: subField,
2906
+ onChange,
2907
+ forceReadOnly: !canEdit,
2908
+ value: value == null ? void 0 : value[index]
2909
+ },
2910
+ subName
2911
+ );
2912
+ }) }) })
2913
+ ]
2914
+ }
2915
+ ) }, id);
2916
+ };
2917
+ var ArrayFieldItem = memo2(ArrayFieldItemInternal);
2750
2918
  var ArrayField = ({
2751
2919
  field,
2752
2920
  onChange,
2753
- value: _value,
2754
2921
  name,
2755
2922
  label,
2756
2923
  labelIcon,
2757
2924
  readOnly,
2758
2925
  id,
2759
- Label: Label2 = (props) => /* @__PURE__ */ jsx8("div", __spreadValues({}, props))
2926
+ Label: Label2 = (props) => /* @__PURE__ */ jsx9("div", __spreadValues({}, props)),
2927
+ value
2760
2928
  }) => {
2761
- const thisArrayState = useAppStore((s) => s.state.ui.arrayState[id]);
2762
2929
  const setUi = useAppStore((s) => s.setUi);
2763
- const { readOnlyFields, localName = name } = useNestedFieldContext();
2764
- const value = _value;
2765
- const arrayState = thisArrayState || {
2766
- items: Array.from(value || []).map((item, idx) => {
2767
- return {
2768
- _originalIndex: idx,
2769
- _arrayId: `${id}-${idx}`
2770
- };
2771
- }),
2772
- openId: ""
2773
- };
2774
- const [localState, setLocalState] = useState4({ arrayState, value });
2775
- useEffect6(() => {
2930
+ const appStoreApi = useAppStoreApi();
2931
+ const { localName = name } = useNestedFieldContext();
2932
+ const getValue = useCallback2(() => {
2933
+ var _a, _b;
2934
+ if (typeof value !== "undefined") return value;
2935
+ const { selectedItem } = appStoreApi.getState();
2936
+ const props = (_a = name ? selectedItem == null ? void 0 : selectedItem.props : {}) != null ? _a : {};
2937
+ return name ? (_b = getDeep(props, name)) != null ? _b : [] : [];
2938
+ }, [appStoreApi, name, value]);
2939
+ const getArrayState = useCallback2(() => {
2776
2940
  var _a;
2777
- const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
2778
- setLocalState({ arrayState: _arrayState, value });
2779
- }, [value]);
2941
+ const { state } = appStoreApi.getState();
2942
+ const thisState = state.ui.arrayState[id];
2943
+ if ((_a = thisState == null ? void 0 : thisState.items) == null ? void 0 : _a.length) return thisState;
2944
+ const value2 = getValue();
2945
+ return {
2946
+ items: Array.from(value2 || []).map((item, idx) => {
2947
+ return {
2948
+ _originalIndex: idx,
2949
+ _currentIndex: idx,
2950
+ _arrayId: `${id}-${idx}`
2951
+ };
2952
+ }),
2953
+ openId: ""
2954
+ };
2955
+ }, [appStoreApi, id, getValue]);
2956
+ const numItems = useAppStore((s) => {
2957
+ var _a, _b;
2958
+ const { selectedItem } = s;
2959
+ const props = (_a = name ? selectedItem == null ? void 0 : selectedItem.props : {}) != null ? _a : {};
2960
+ return (name ? (_b = getDeep(props, name)) != null ? _b : [] : []).length;
2961
+ });
2962
+ const [mirror, setLocalState] = useState4(getArrayState());
2780
2963
  const appStore = useAppStoreApi();
2781
2964
  const mapArrayStateToUi = useCallback2(
2782
2965
  (partialArrayState) => {
2783
2966
  const state = appStore.getState().state;
2784
2967
  return {
2785
2968
  arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
2786
- [id]: __spreadValues(__spreadValues({}, arrayState), partialArrayState)
2969
+ [id]: __spreadValues(__spreadValues({}, getArrayState()), partialArrayState)
2787
2970
  })
2788
2971
  };
2789
2972
  },
2790
- [arrayState, appStore]
2973
+ [appStore]
2791
2974
  );
2792
2975
  const getHighestIndex = useCallback2(() => {
2793
- return arrayState.items.reduce(
2976
+ return getArrayState().items.reduce(
2794
2977
  (acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
2795
2978
  -1
2796
2979
  );
2797
- }, [arrayState]);
2798
- const regenerateArrayState = useCallback2(
2799
- (value2) => {
2800
- let highestIndex = getHighestIndex();
2801
- const newItems = Array.from(value2 || []).map((item, idx) => {
2802
- var _a;
2803
- const arrayStateItem = arrayState.items[idx];
2804
- const newItem = {
2805
- _originalIndex: typeof (arrayStateItem == null ? void 0 : arrayStateItem._originalIndex) !== "undefined" ? arrayStateItem._originalIndex : highestIndex + 1,
2806
- _arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || `${id}-${highestIndex + 1}`
2807
- };
2808
- if (newItem._originalIndex > highestIndex) {
2809
- highestIndex = newItem._originalIndex;
2810
- }
2811
- return newItem;
2812
- });
2813
- return __spreadProps(__spreadValues({}, arrayState), { items: newItems });
2814
- },
2815
- [arrayState]
2816
- );
2817
- useEffect6(() => {
2818
- if (arrayState.items.length > 0) {
2819
- setUi(mapArrayStateToUi(arrayState));
2820
- }
2980
+ }, []);
2981
+ const regenerateArrayState = useCallback2((value2) => {
2982
+ let highestIndex = getHighestIndex();
2983
+ const arrayState = getArrayState();
2984
+ const newItems = Array.from(value2 || []).map((item, idx) => {
2985
+ var _a, _b, _c;
2986
+ const arrayStateItem = arrayState.items[idx];
2987
+ const newItem = {
2988
+ _originalIndex: (_a = arrayStateItem == null ? void 0 : arrayStateItem._originalIndex) != null ? _a : highestIndex + 1,
2989
+ _currentIndex: (_b = arrayStateItem == null ? void 0 : arrayStateItem._currentIndex) != null ? _b : idx,
2990
+ _arrayId: ((_c = arrayState.items[idx]) == null ? void 0 : _c._arrayId) || `${id}-${highestIndex + 1}`
2991
+ };
2992
+ if (newItem._originalIndex > highestIndex) {
2993
+ highestIndex = newItem._originalIndex;
2994
+ }
2995
+ return newItem;
2996
+ });
2997
+ return __spreadProps(__spreadValues({}, arrayState), { items: newItems });
2821
2998
  }, []);
2822
2999
  const [draggedItem, setDraggedItem] = useState4("");
2823
3000
  const isDraggingAny = !!draggedItem;
2824
- const canEdit = useAppStore(
2825
- (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
2826
- );
2827
- const forceReadOnly = !canEdit;
2828
- const valueRef = useRef(value);
3001
+ const valueRef = useRef([]);
3002
+ useEffect6(() => {
3003
+ valueRef.current = getValue();
3004
+ }, []);
2829
3005
  const uniqifyItem = useCallback2(
2830
3006
  (val) => {
2831
3007
  if (field.type !== "array" || !field.arrayFields) return;
@@ -2844,30 +3020,96 @@ var ArrayField = ({
2844
3020
  },
2845
3021
  [appStore, field]
2846
3022
  );
3023
+ const syncCurrentIndexes = useCallback2(() => {
3024
+ const arrayState = getArrayState();
3025
+ const newArrayStateItems = arrayState.items.map((item, index) => __spreadProps(__spreadValues({}, item), {
3026
+ _currentIndex: index
3027
+ }));
3028
+ setLocalState(__spreadProps(__spreadValues({}, arrayState), {
3029
+ items: newArrayStateItems
3030
+ }));
3031
+ const state = appStore.getState().state;
3032
+ const newUi = {
3033
+ arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
3034
+ [id]: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
3035
+ })
3036
+ };
3037
+ setUi(newUi, false);
3038
+ }, []);
3039
+ const updateValue = useCallback2(
3040
+ (newValue) => {
3041
+ const newArrayState = regenerateArrayState(newValue);
3042
+ setUi(mapArrayStateToUi(newArrayState), false);
3043
+ onChange(newValue);
3044
+ setLocalState(newArrayState);
3045
+ },
3046
+ [regenerateArrayState, setUi, mapArrayStateToUi, onChange, setLocalState]
3047
+ );
3048
+ const reset = useCallback2(
3049
+ (value2) => {
3050
+ valueRef.current = value2;
3051
+ const newArrayState = regenerateArrayState(valueRef.current);
3052
+ if (!(0, import_fast_deep_equal.default)(newArrayState, getArrayState())) {
3053
+ setUi(mapArrayStateToUi(newArrayState), false);
3054
+ setLocalState(newArrayState);
3055
+ }
3056
+ },
3057
+ [
3058
+ regenerateArrayState,
3059
+ mapArrayStateToUi,
3060
+ setUi,
3061
+ setLocalState,
3062
+ getArrayState
3063
+ ]
3064
+ );
3065
+ useEffect6(() => {
3066
+ if (value) return;
3067
+ return appStoreApi.subscribe(
3068
+ ({ selectedItem }) => {
3069
+ var _a;
3070
+ const props = (_a = name ? selectedItem == null ? void 0 : selectedItem.props : {}) != null ? _a : {};
3071
+ return name ? getDeep(props, name) : [];
3072
+ },
3073
+ (val) => {
3074
+ if (!(0, import_fast_deep_equal.default)(val, valueRef.current)) {
3075
+ reset(val);
3076
+ }
3077
+ }
3078
+ );
3079
+ }, [appStoreApi, name, value]);
3080
+ useEffect6(() => {
3081
+ reset(getValue());
3082
+ }, [reset, getValue, name]);
2847
3083
  if (field.type !== "array" || !field.arrayFields) {
2848
3084
  return null;
2849
3085
  }
2850
- const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
2851
- return /* @__PURE__ */ jsx8(
3086
+ const addDisabled = field.max !== void 0 && mirror.items.length >= field.max || readOnly;
3087
+ return /* @__PURE__ */ jsx9(
2852
3088
  Label2,
2853
3089
  {
2854
3090
  label: label || name,
2855
- icon: labelIcon || /* @__PURE__ */ jsx8(List, { size: 16 }),
3091
+ icon: labelIcon || /* @__PURE__ */ jsx9(List, { size: 16 }),
2856
3092
  el: "div",
2857
3093
  readOnly,
2858
- children: /* @__PURE__ */ jsx8(
3094
+ children: /* @__PURE__ */ jsx9(
2859
3095
  SortableProvider,
2860
3096
  {
2861
- onDragStart: (id2) => setDraggedItem(id2),
3097
+ onDragStart: (id2) => {
3098
+ valueRef.current = getValue();
3099
+ setDraggedItem(id2);
3100
+ syncCurrentIndexes();
3101
+ },
2862
3102
  onDragEnd: () => {
2863
3103
  setDraggedItem("");
2864
3104
  onChange(valueRef.current);
3105
+ syncCurrentIndexes();
2865
3106
  },
2866
3107
  onMove: (move) => {
3108
+ const arrayState = getArrayState();
2867
3109
  if (arrayState.items[move.source]._arrayId !== draggedItem) {
2868
3110
  return;
2869
3111
  }
2870
- const newValue = reorder(localState.value, move.source, move.target);
3112
+ const newValue = reorder(valueRef.current, move.source, move.target);
2871
3113
  const newArrayStateItems = reorder(
2872
3114
  arrayState.items,
2873
3115
  move.source,
@@ -2880,172 +3122,107 @@ var ArrayField = ({
2880
3122
  })
2881
3123
  };
2882
3124
  setUi(newUi, false);
2883
- setLocalState({
2884
- value: newValue,
2885
- arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
2886
- });
3125
+ setLocalState(__spreadProps(__spreadValues({}, arrayState), {
3126
+ items: newArrayStateItems
3127
+ }));
2887
3128
  valueRef.current = newValue;
2888
3129
  },
2889
3130
  children: /* @__PURE__ */ jsxs4(
2890
3131
  "div",
2891
3132
  {
2892
3133
  className: getClassName6({
2893
- hasItems: Array.isArray(value) && value.length > 0,
3134
+ hasItems: numItems > 0,
2894
3135
  addDisabled
2895
3136
  }),
2896
3137
  children: [
2897
- localState.arrayState.items.length > 0 && /* @__PURE__ */ jsx8("div", { className: getClassName6("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
2898
- const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
2899
- const data = Array.from(localState.value || [])[i] || {};
2900
- return /* @__PURE__ */ jsx8(
2901
- Sortable,
3138
+ mirror.items.length > 0 && /* @__PURE__ */ jsx9("div", { className: getClassName6("inner"), "data-dnd-container": true, children: mirror.items.map((item, index) => {
3139
+ const {
3140
+ _arrayId = `${id}-${index}`,
3141
+ _originalIndex = index,
3142
+ _currentIndex = index
3143
+ } = item;
3144
+ return /* @__PURE__ */ jsx9(
3145
+ ArrayFieldItem,
2902
3146
  {
3147
+ index: _currentIndex,
3148
+ dragIndex: index,
3149
+ originalIndex: _originalIndex,
3150
+ arrayId: id,
2903
3151
  id: _arrayId,
2904
- index: i,
2905
- disabled: readOnly,
2906
- children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ jsxs4(
2907
- "div",
2908
- {
2909
- ref,
2910
- className: getClassNameItem({
2911
- isExpanded: arrayState.openId === _arrayId,
2912
- isDragging,
2913
- readOnly
2914
- }),
2915
- children: [
2916
- /* @__PURE__ */ jsxs4(
2917
- "div",
2918
- {
2919
- ref: handleRef,
2920
- onClick: (e) => {
2921
- if (isDragging) return;
2922
- e.preventDefault();
2923
- e.stopPropagation();
2924
- if (arrayState.openId === _arrayId) {
2925
- setUi(
2926
- mapArrayStateToUi({
2927
- openId: ""
2928
- })
2929
- );
2930
- } else {
2931
- setUi(
2932
- mapArrayStateToUi({
2933
- openId: _arrayId
2934
- })
2935
- );
2936
- }
2937
- },
2938
- className: getClassNameItem("summary"),
2939
- children: [
2940
- field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
2941
- /* @__PURE__ */ jsxs4("div", { className: getClassNameItem("rhs"), children: [
2942
- !readOnly && /* @__PURE__ */ jsxs4("div", { className: getClassNameItem("actions"), children: [
2943
- /* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
2944
- IconButton,
2945
- {
2946
- type: "button",
2947
- disabled: !!addDisabled,
2948
- onClick: (e) => {
2949
- e.stopPropagation();
2950
- const existingValue = [...value || []];
2951
- const newItem = uniqifyItem(
2952
- existingValue[i]
2953
- );
2954
- existingValue.splice(i, 0, newItem);
2955
- const newUi = mapArrayStateToUi(
2956
- regenerateArrayState(existingValue)
2957
- );
2958
- setUi(newUi, false);
2959
- onChange(existingValue);
2960
- },
2961
- title: "Duplicate",
2962
- children: /* @__PURE__ */ jsx8(Copy, { size: 16 })
2963
- }
2964
- ) }),
2965
- /* @__PURE__ */ jsx8("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx8(
2966
- IconButton,
2967
- {
2968
- type: "button",
2969
- disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
2970
- onClick: (e) => {
2971
- e.stopPropagation();
2972
- const existingValue = [...value || []];
2973
- const existingItems = [
2974
- ...arrayState.items || []
2975
- ];
2976
- existingValue.splice(i, 1);
2977
- existingItems.splice(i, 1);
2978
- setUi(
2979
- mapArrayStateToUi({
2980
- items: existingItems
2981
- }),
2982
- false
2983
- );
2984
- onChange(existingValue);
2985
- },
2986
- title: "Delete",
2987
- children: /* @__PURE__ */ jsx8(Trash, { size: 16 })
2988
- }
2989
- ) })
2990
- ] }),
2991
- /* @__PURE__ */ jsx8("div", { children: /* @__PURE__ */ jsx8(DragIcon, {}) })
2992
- ] })
2993
- ]
2994
- }
2995
- ),
2996
- /* @__PURE__ */ jsx8("div", { className: getClassNameItem("body"), children: arrayState.openId === _arrayId && /* @__PURE__ */ jsx8("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map(
2997
- (subName) => {
2998
- const subField = field.arrayFields[subName];
2999
- const indexName = `${name}[${i}]`;
3000
- const subPath = `${indexName}.${subName}`;
3001
- const localIndexName = `${localName}[${i}]`;
3002
- const localWildcardName = `${localName}[*]`;
3003
- const localSubPath = `${localIndexName}.${subName}`;
3004
- const localWildcardSubPath = `${localWildcardName}.${subName}`;
3005
- const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
3006
- const label2 = subField.label || subName;
3007
- return /* @__PURE__ */ jsx8(
3008
- NestedFieldProvider,
3009
- {
3010
- name: localIndexName,
3011
- wildcardName: localWildcardName,
3012
- subName,
3013
- readOnlyFields,
3014
- children: /* @__PURE__ */ jsx8(
3015
- AutoFieldPrivate,
3016
- {
3017
- name: subPath,
3018
- label: label2,
3019
- id: `${_arrayId}_${subName}`,
3020
- readOnly: subReadOnly,
3021
- field: __spreadProps(__spreadValues({}, subField), {
3022
- label: label2
3023
- // May be used by custom fields
3024
- }),
3025
- value: data[subName],
3026
- onChange: (val, ui) => {
3027
- onChange(
3028
- replace(value, i, __spreadProps(__spreadValues({}, data), {
3029
- [subName]: val
3030
- })),
3031
- ui
3032
- );
3033
- }
3034
- }
3035
- )
3036
- },
3037
- subPath
3038
- );
3039
- }
3040
- ) }) })
3041
- ]
3152
+ readOnly,
3153
+ field,
3154
+ name,
3155
+ localName,
3156
+ value,
3157
+ getValue: () => {
3158
+ const value2 = getValue();
3159
+ return value2[_currentIndex];
3160
+ },
3161
+ onChange: (val, ui, subName) => {
3162
+ const value2 = getValue();
3163
+ const data = Array.from(value2 || [])[index] || {};
3164
+ onChange(
3165
+ replace(value2, index, __spreadProps(__spreadValues({}, data), {
3166
+ [subName]: val
3167
+ })),
3168
+ ui
3169
+ );
3170
+ },
3171
+ onToggleExpand: (id2, isExpanded) => {
3172
+ if (isExpanded) {
3173
+ setUi(
3174
+ mapArrayStateToUi({
3175
+ openId: ""
3176
+ })
3177
+ );
3178
+ } else {
3179
+ setUi(
3180
+ mapArrayStateToUi({
3181
+ openId: id2
3182
+ })
3183
+ );
3042
3184
  }
3043
- )
3185
+ },
3186
+ actions: /* @__PURE__ */ jsxs4(Fragment2, { children: [
3187
+ /* @__PURE__ */ jsx9("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx9(
3188
+ IconButton,
3189
+ {
3190
+ type: "button",
3191
+ disabled: !!addDisabled,
3192
+ onClick: (e) => {
3193
+ e.stopPropagation();
3194
+ const value2 = getValue();
3195
+ const existingValue = [...value2 || []];
3196
+ const newItem = uniqifyItem(existingValue[index]);
3197
+ existingValue.splice(index, 0, newItem);
3198
+ updateValue(existingValue);
3199
+ },
3200
+ title: "Duplicate",
3201
+ children: /* @__PURE__ */ jsx9(Copy, { size: 16 })
3202
+ }
3203
+ ) }),
3204
+ /* @__PURE__ */ jsx9("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ jsx9(
3205
+ IconButton,
3206
+ {
3207
+ type: "button",
3208
+ disabled: field.min !== void 0 && field.min >= mirror.items.length,
3209
+ onClick: (e) => {
3210
+ e.stopPropagation();
3211
+ const value2 = getValue();
3212
+ const existingValue = [...value2 || []];
3213
+ existingValue.splice(index, 1);
3214
+ updateValue(existingValue);
3215
+ },
3216
+ title: "Delete",
3217
+ children: /* @__PURE__ */ jsx9(Trash, { size: 16 })
3218
+ }
3219
+ ) })
3220
+ ] })
3044
3221
  },
3045
3222
  _arrayId
3046
3223
  );
3047
3224
  }) }),
3048
- !addDisabled && /* @__PURE__ */ jsx8(
3225
+ !addDisabled && /* @__PURE__ */ jsx9(
3049
3226
  "button",
3050
3227
  {
3051
3228
  type: "button",
@@ -3053,18 +3230,17 @@ var ArrayField = ({
3053
3230
  onClick: () => {
3054
3231
  var _a;
3055
3232
  if (isDraggingAny) return;
3056
- const existingValue = value || [];
3233
+ const value2 = getValue();
3234
+ const existingValue = value2 || [];
3057
3235
  const defaultProps = typeof field.defaultItemProps === "function" ? field.defaultItemProps(existingValue.length) : (_a = field.defaultItemProps) != null ? _a : {};
3058
3236
  const newItem = defaultSlots(
3059
3237
  uniqifyItem(defaultProps),
3060
3238
  field.arrayFields
3061
3239
  );
3062
3240
  const newValue = [...existingValue, newItem];
3063
- const newArrayState = regenerateArrayState(newValue);
3064
- setUi(mapArrayStateToUi(newArrayState), false);
3065
- onChange(newValue);
3241
+ updateValue(newValue);
3066
3242
  },
3067
- children: /* @__PURE__ */ jsx8(Plus, { size: 21 })
3243
+ children: /* @__PURE__ */ jsx9(Plus, { size: 21 })
3068
3244
  }
3069
3245
  )
3070
3246
  ]
@@ -3078,7 +3254,7 @@ var ArrayField = ({
3078
3254
 
3079
3255
  // components/AutoField/fields/DefaultField/index.tsx
3080
3256
  init_react_import();
3081
- import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
3257
+ import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
3082
3258
  var getClassName7 = get_class_name_factory_default("Input", styles_module_default3);
3083
3259
  var DefaultField = ({
3084
3260
  field,
@@ -3092,16 +3268,16 @@ var DefaultField = ({
3092
3268
  id
3093
3269
  }) => {
3094
3270
  const value = _value;
3095
- return /* @__PURE__ */ jsx9(
3271
+ return /* @__PURE__ */ jsx10(
3096
3272
  Label2,
3097
3273
  {
3098
3274
  label: label || name,
3099
- icon: labelIcon || /* @__PURE__ */ jsxs5(Fragment2, { children: [
3100
- field.type === "text" && /* @__PURE__ */ jsx9(Type, { size: 16 }),
3101
- field.type === "number" && /* @__PURE__ */ jsx9(Hash, { size: 16 })
3275
+ icon: labelIcon || /* @__PURE__ */ jsxs5(Fragment3, { children: [
3276
+ field.type === "text" && /* @__PURE__ */ jsx10(Type, { size: 16 }),
3277
+ field.type === "number" && /* @__PURE__ */ jsx10(Hash, { size: 16 })
3102
3278
  ] }),
3103
3279
  readOnly,
3104
- children: /* @__PURE__ */ jsx9(
3280
+ children: /* @__PURE__ */ jsx10(
3105
3281
  "input",
3106
3282
  {
3107
3283
  className: getClassName7("input"),
@@ -3165,7 +3341,7 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
3165
3341
 
3166
3342
  // components/Modal/index.tsx
3167
3343
  import { createPortal } from "react-dom";
3168
- import { jsx as jsx10 } from "react/jsx-runtime";
3344
+ import { jsx as jsx11 } from "react/jsx-runtime";
3169
3345
  var getClassName8 = get_class_name_factory_default("Modal", styles_module_default7);
3170
3346
  var Modal = ({
3171
3347
  children,
@@ -3177,10 +3353,10 @@ var Modal = ({
3177
3353
  setRootEl(document.getElementById("puck-portal-root"));
3178
3354
  }, []);
3179
3355
  if (!rootEl) {
3180
- return /* @__PURE__ */ jsx10("div", {});
3356
+ return /* @__PURE__ */ jsx11("div", {});
3181
3357
  }
3182
3358
  return createPortal(
3183
- /* @__PURE__ */ jsx10("div", { className: getClassName8({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx10(
3359
+ /* @__PURE__ */ jsx11("div", { className: getClassName8({ isOpen }), onClick: onClose, children: /* @__PURE__ */ jsx11(
3184
3360
  "div",
3185
3361
  {
3186
3362
  className: getClassName8("inner"),
@@ -3200,11 +3376,11 @@ init_react_import();
3200
3376
  var styles_module_default8 = { "Heading": "_Heading_qxrry_1", "Heading--xxxxl": "_Heading--xxxxl_qxrry_12", "Heading--xxxl": "_Heading--xxxl_qxrry_18", "Heading--xxl": "_Heading--xxl_qxrry_22", "Heading--xl": "_Heading--xl_qxrry_26", "Heading--l": "_Heading--l_qxrry_30", "Heading--m": "_Heading--m_qxrry_34", "Heading--s": "_Heading--s_qxrry_38", "Heading--xs": "_Heading--xs_qxrry_42" };
3201
3377
 
3202
3378
  // components/Heading/index.tsx
3203
- import { jsx as jsx11 } from "react/jsx-runtime";
3379
+ import { jsx as jsx12 } from "react/jsx-runtime";
3204
3380
  var getClassName9 = get_class_name_factory_default("Heading", styles_module_default8);
3205
3381
  var Heading = ({ children, rank, size = "m" }) => {
3206
3382
  const Tag = rank ? `h${rank}` : "span";
3207
- return /* @__PURE__ */ jsx11(
3383
+ return /* @__PURE__ */ jsx12(
3208
3384
  Tag,
3209
3385
  {
3210
3386
  className: getClassName9({
@@ -3219,7 +3395,7 @@ var Heading = ({ children, rank, size = "m" }) => {
3219
3395
  init_react_import();
3220
3396
 
3221
3397
  // components/ExternalInput/index.tsx
3222
- import { Fragment as Fragment3, jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
3398
+ import { Fragment as Fragment4, jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
3223
3399
  var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
3224
3400
  var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
3225
3401
  var dataCache = {};
@@ -3260,7 +3436,7 @@ var ExternalInput = ({
3260
3436
  }, [mappedData]);
3261
3437
  const [searchQuery, setSearchQuery] = useState6(field.initialQuery || "");
3262
3438
  const search = useCallback3(
3263
- (query, filters2) => __async(void 0, null, function* () {
3439
+ (query, filters2) => __async(null, null, function* () {
3264
3440
  setIsLoading(true);
3265
3441
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
3266
3442
  let listData;
@@ -3301,20 +3477,20 @@ var ExternalInput = ({
3301
3477
  id,
3302
3478
  children: [
3303
3479
  /* @__PURE__ */ jsxs6("div", { className: getClassName10("actions"), children: [
3304
- /* @__PURE__ */ jsx12(
3480
+ /* @__PURE__ */ jsx13(
3305
3481
  "button",
3306
3482
  {
3307
3483
  type: "button",
3308
3484
  onClick: () => setOpen(true),
3309
3485
  className: getClassName10("button"),
3310
3486
  disabled: readOnly,
3311
- children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ jsxs6(Fragment3, { children: [
3312
- /* @__PURE__ */ jsx12(Link, { size: "16" }),
3313
- /* @__PURE__ */ jsx12("span", { children: field.placeholder })
3487
+ children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ jsxs6(Fragment4, { children: [
3488
+ /* @__PURE__ */ jsx13(Link, { size: "16" }),
3489
+ /* @__PURE__ */ jsx13("span", { children: field.placeholder })
3314
3490
  ] })
3315
3491
  }
3316
3492
  ),
3317
- value && /* @__PURE__ */ jsx12(
3493
+ value && /* @__PURE__ */ jsx13(
3318
3494
  "button",
3319
3495
  {
3320
3496
  type: "button",
@@ -3323,11 +3499,11 @@ var ExternalInput = ({
3323
3499
  onChange(null);
3324
3500
  },
3325
3501
  disabled: readOnly,
3326
- children: /* @__PURE__ */ jsx12(LockOpen, { size: 16 })
3502
+ children: /* @__PURE__ */ jsx13(LockOpen, { size: 16 })
3327
3503
  }
3328
3504
  )
3329
3505
  ] }),
3330
- /* @__PURE__ */ jsx12(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs6(
3506
+ /* @__PURE__ */ jsx13(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ jsxs6(
3331
3507
  "form",
3332
3508
  {
3333
3509
  className: getClassNameModal({
@@ -3342,11 +3518,11 @@ var ExternalInput = ({
3342
3518
  search(searchQuery, filters);
3343
3519
  },
3344
3520
  children: [
3345
- /* @__PURE__ */ jsx12("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchForm"), children: [
3521
+ /* @__PURE__ */ jsx13("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchForm"), children: [
3346
3522
  /* @__PURE__ */ jsxs6("label", { className: getClassNameModal("search"), children: [
3347
- /* @__PURE__ */ jsx12("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
3348
- /* @__PURE__ */ jsx12("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ jsx12(Search, { size: "18" }) }),
3349
- /* @__PURE__ */ jsx12(
3523
+ /* @__PURE__ */ jsx13("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
3524
+ /* @__PURE__ */ jsx13("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ jsx13(Search, { size: "18" }) }),
3525
+ /* @__PURE__ */ jsx13(
3350
3526
  "input",
3351
3527
  {
3352
3528
  className: getClassNameModal("searchInput"),
@@ -3362,8 +3538,8 @@ var ExternalInput = ({
3362
3538
  )
3363
3539
  ] }),
3364
3540
  /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("searchActions"), children: [
3365
- /* @__PURE__ */ jsx12(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
3366
- hasFilterFields && /* @__PURE__ */ jsx12("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ jsx12(
3541
+ /* @__PURE__ */ jsx13(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
3542
+ hasFilterFields && /* @__PURE__ */ jsx13("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ jsx13(
3367
3543
  IconButton,
3368
3544
  {
3369
3545
  type: "button",
@@ -3373,19 +3549,19 @@ var ExternalInput = ({
3373
3549
  e.stopPropagation();
3374
3550
  setFiltersToggled(!filtersToggled);
3375
3551
  },
3376
- children: /* @__PURE__ */ jsx12(SlidersHorizontal, { size: 20 })
3552
+ children: /* @__PURE__ */ jsx13(SlidersHorizontal, { size: 20 })
3377
3553
  }
3378
3554
  ) })
3379
3555
  ] })
3380
- ] }) : /* @__PURE__ */ jsx12(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
3556
+ ] }) : /* @__PURE__ */ jsx13(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
3381
3557
  /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("grid"), children: [
3382
- hasFilterFields && /* @__PURE__ */ jsx12("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
3558
+ hasFilterFields && /* @__PURE__ */ jsx13("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
3383
3559
  const filterField = filterFields[fieldName];
3384
- return /* @__PURE__ */ jsx12(
3560
+ return /* @__PURE__ */ jsx13(
3385
3561
  "div",
3386
3562
  {
3387
3563
  className: getClassNameModal("field"),
3388
- children: /* @__PURE__ */ jsx12(
3564
+ children: /* @__PURE__ */ jsx13(
3389
3565
  AutoFieldPrivate,
3390
3566
  {
3391
3567
  field: filterField,
@@ -3394,11 +3570,13 @@ var ExternalInput = ({
3394
3570
  label: filterField.label || fieldName,
3395
3571
  value: filters[fieldName],
3396
3572
  onChange: (value2) => {
3397
- const newFilters = __spreadProps(__spreadValues({}, filters), {
3398
- [fieldName]: value2
3573
+ setFilters((filters2) => {
3574
+ const newFilters = __spreadProps(__spreadValues({}, filters2), {
3575
+ [fieldName]: value2
3576
+ });
3577
+ search(searchQuery, newFilters);
3578
+ return newFilters;
3399
3579
  });
3400
- setFilters(newFilters);
3401
- search(searchQuery, newFilters);
3402
3580
  }
3403
3581
  }
3404
3582
  )
@@ -3408,7 +3586,7 @@ var ExternalInput = ({
3408
3586
  }) }),
3409
3587
  /* @__PURE__ */ jsxs6("div", { className: getClassNameModal("tableWrapper"), children: [
3410
3588
  /* @__PURE__ */ jsxs6("table", { className: getClassNameModal("table"), children: [
3411
- /* @__PURE__ */ jsx12("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ jsx12("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ jsx12(
3589
+ /* @__PURE__ */ jsx13("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ jsx13("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ jsx13(
3412
3590
  "th",
3413
3591
  {
3414
3592
  className: getClassNameModal("th"),
@@ -3417,8 +3595,8 @@ var ExternalInput = ({
3417
3595
  },
3418
3596
  key
3419
3597
  )) }) }),
3420
- /* @__PURE__ */ jsx12("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
3421
- return /* @__PURE__ */ jsx12(
3598
+ /* @__PURE__ */ jsx13("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
3599
+ return /* @__PURE__ */ jsx13(
3422
3600
  "tr",
3423
3601
  {
3424
3602
  style: { whiteSpace: "nowrap" },
@@ -3427,16 +3605,16 @@ var ExternalInput = ({
3427
3605
  onChange(mapProp(data[i]));
3428
3606
  setOpen(false);
3429
3607
  },
3430
- children: keys.map((key) => /* @__PURE__ */ jsx12("td", { className: getClassNameModal("td"), children: item[key] }, key))
3608
+ children: keys.map((key) => /* @__PURE__ */ jsx13("td", { className: getClassNameModal("td"), children: item[key] }, key))
3431
3609
  },
3432
3610
  i
3433
3611
  );
3434
3612
  }) })
3435
3613
  ] }),
3436
- /* @__PURE__ */ jsx12("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ jsx12(Loader, { size: 24 }) })
3614
+ /* @__PURE__ */ jsx13("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ jsx13(Loader, { size: 24 }) })
3437
3615
  ] })
3438
3616
  ] }),
3439
- /* @__PURE__ */ jsx12("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ jsx12(Footer, { items: mappedData }) })
3617
+ /* @__PURE__ */ jsx13("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ jsx13(Footer, { items: mappedData }) })
3440
3618
  ]
3441
3619
  }
3442
3620
  ) })
@@ -3446,7 +3624,7 @@ var ExternalInput = ({
3446
3624
  };
3447
3625
 
3448
3626
  // components/AutoField/fields/ExternalField/index.tsx
3449
- import { jsx as jsx13 } from "react/jsx-runtime";
3627
+ import { jsx as jsx14 } from "react/jsx-runtime";
3450
3628
  var ExternalField = ({
3451
3629
  field,
3452
3630
  onChange,
@@ -3471,13 +3649,13 @@ var ExternalField = ({
3471
3649
  if (field.type !== "external") {
3472
3650
  return null;
3473
3651
  }
3474
- return /* @__PURE__ */ jsx13(
3652
+ return /* @__PURE__ */ jsx14(
3475
3653
  Label2,
3476
3654
  {
3477
3655
  label: label || name,
3478
- icon: labelIcon || /* @__PURE__ */ jsx13(Link, { size: 16 }),
3656
+ icon: labelIcon || /* @__PURE__ */ jsx14(Link, { size: 16 }),
3479
3657
  el: "div",
3480
- children: /* @__PURE__ */ jsx13(
3658
+ children: /* @__PURE__ */ jsx14(
3481
3659
  ExternalInput,
3482
3660
  {
3483
3661
  name,
@@ -3486,7 +3664,7 @@ var ExternalField = ({
3486
3664
  placeholder: ((_a = deprecatedField.adaptor) == null ? void 0 : _a.name) ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder || "Select data",
3487
3665
  mapProp: ((_b = deprecatedField.adaptor) == null ? void 0 : _b.mapProp) || validField.mapProp,
3488
3666
  mapRow: validField.mapRow,
3489
- fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(void 0, null, function* () {
3667
+ fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(null, null, function* () {
3490
3668
  return yield deprecatedField.adaptor.fetchList(
3491
3669
  deprecatedField.adaptorParams
3492
3670
  );
@@ -3504,7 +3682,7 @@ var ExternalField = ({
3504
3682
 
3505
3683
  // components/AutoField/fields/RadioField/index.tsx
3506
3684
  init_react_import();
3507
- import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
3685
+ import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
3508
3686
  var getClassName11 = get_class_name_factory_default("Input", styles_module_default3);
3509
3687
  var RadioField = ({
3510
3688
  field,
@@ -3520,21 +3698,21 @@ var RadioField = ({
3520
3698
  if (field.type !== "radio" || !field.options) {
3521
3699
  return null;
3522
3700
  }
3523
- return /* @__PURE__ */ jsx14(
3701
+ return /* @__PURE__ */ jsx15(
3524
3702
  Label2,
3525
3703
  {
3526
- icon: labelIcon || /* @__PURE__ */ jsx14(CircleCheckBig, { size: 16 }),
3704
+ icon: labelIcon || /* @__PURE__ */ jsx15(CircleCheckBig, { size: 16 }),
3527
3705
  label: label || name,
3528
3706
  readOnly,
3529
3707
  el: "div",
3530
- children: /* @__PURE__ */ jsx14("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => {
3708
+ children: /* @__PURE__ */ jsx15("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => {
3531
3709
  var _a;
3532
3710
  return /* @__PURE__ */ jsxs7(
3533
3711
  "label",
3534
3712
  {
3535
3713
  className: getClassName11("radio"),
3536
3714
  children: [
3537
- /* @__PURE__ */ jsx14(
3715
+ /* @__PURE__ */ jsx15(
3538
3716
  "input",
3539
3717
  {
3540
3718
  type: "radio",
@@ -3548,7 +3726,7 @@ var RadioField = ({
3548
3726
  checked: value === option.value
3549
3727
  }
3550
3728
  ),
3551
- /* @__PURE__ */ jsx14("div", { className: getClassName11("radioInner"), children: option.label || ((_a = option.value) == null ? void 0 : _a.toString()) })
3729
+ /* @__PURE__ */ jsx15("div", { className: getClassName11("radioInner"), children: option.label || ((_a = option.value) == null ? void 0 : _a.toString()) })
3552
3730
  ]
3553
3731
  },
3554
3732
  option.label + option.value
@@ -3560,7 +3738,7 @@ var RadioField = ({
3560
3738
 
3561
3739
  // components/AutoField/fields/SelectField/index.tsx
3562
3740
  init_react_import();
3563
- import { jsx as jsx15 } from "react/jsx-runtime";
3741
+ import { jsx as jsx16 } from "react/jsx-runtime";
3564
3742
  var getClassName12 = get_class_name_factory_default("Input", styles_module_default3);
3565
3743
  var SelectField = ({
3566
3744
  field,
@@ -3576,13 +3754,13 @@ var SelectField = ({
3576
3754
  if (field.type !== "select" || !field.options) {
3577
3755
  return null;
3578
3756
  }
3579
- return /* @__PURE__ */ jsx15(
3757
+ return /* @__PURE__ */ jsx16(
3580
3758
  Label2,
3581
3759
  {
3582
3760
  label: label || name,
3583
- icon: labelIcon || /* @__PURE__ */ jsx15(ChevronDown, { size: 16 }),
3761
+ icon: labelIcon || /* @__PURE__ */ jsx16(ChevronDown, { size: 16 }),
3584
3762
  readOnly,
3585
- children: /* @__PURE__ */ jsx15(
3763
+ children: /* @__PURE__ */ jsx16(
3586
3764
  "select",
3587
3765
  {
3588
3766
  id,
@@ -3593,7 +3771,7 @@ var SelectField = ({
3593
3771
  onChange(JSON.parse(e.target.value).value);
3594
3772
  },
3595
3773
  value: JSON.stringify({ value }),
3596
- children: field.options.map((option) => /* @__PURE__ */ jsx15(
3774
+ children: field.options.map((option) => /* @__PURE__ */ jsx16(
3597
3775
  "option",
3598
3776
  {
3599
3777
  label: option.label,
@@ -3609,7 +3787,7 @@ var SelectField = ({
3609
3787
 
3610
3788
  // components/AutoField/fields/TextareaField/index.tsx
3611
3789
  init_react_import();
3612
- import { jsx as jsx16 } from "react/jsx-runtime";
3790
+ import { jsx as jsx17 } from "react/jsx-runtime";
3613
3791
  var getClassName13 = get_class_name_factory_default("Input", styles_module_default3);
3614
3792
  var TextareaField = ({
3615
3793
  field,
@@ -3622,13 +3800,13 @@ var TextareaField = ({
3622
3800
  Label: Label2,
3623
3801
  id
3624
3802
  }) => {
3625
- return /* @__PURE__ */ jsx16(
3803
+ return /* @__PURE__ */ jsx17(
3626
3804
  Label2,
3627
3805
  {
3628
3806
  label: label || name,
3629
- icon: labelIcon || /* @__PURE__ */ jsx16(Type, { size: 16 }),
3807
+ icon: labelIcon || /* @__PURE__ */ jsx17(Type, { size: 16 }),
3630
3808
  readOnly,
3631
- children: /* @__PURE__ */ jsx16(
3809
+ children: /* @__PURE__ */ jsx17(
3632
3810
  "textarea",
3633
3811
  {
3634
3812
  id,
@@ -3655,64 +3833,59 @@ init_react_import();
3655
3833
  var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
3656
3834
 
3657
3835
  // components/AutoField/fields/ObjectField/index.tsx
3658
- import { jsx as jsx17 } from "react/jsx-runtime";
3836
+ import { useCallback as useCallback4 } from "react";
3837
+ import { jsx as jsx18 } from "react/jsx-runtime";
3659
3838
  var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
3660
3839
  var ObjectField = ({
3661
3840
  field,
3662
3841
  onChange,
3663
- value,
3664
3842
  name,
3665
3843
  label,
3666
3844
  labelIcon,
3667
3845
  Label: Label2,
3668
3846
  readOnly,
3669
- id
3847
+ id,
3848
+ value
3670
3849
  }) => {
3671
- const { readOnlyFields, localName = name } = useNestedFieldContext();
3850
+ const { localName = name } = useNestedFieldContext();
3851
+ const appStoreApi = useAppStoreApi();
3852
+ const canEdit = useAppStore(
3853
+ (s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
3854
+ );
3855
+ const getValue = useCallback4(() => {
3856
+ var _a;
3857
+ if (typeof value !== "undefined") return value;
3858
+ const { selectedItem } = appStoreApi.getState();
3859
+ const props = (_a = name ? selectedItem == null ? void 0 : selectedItem.props : {}) != null ? _a : {};
3860
+ return name ? getDeep(props, name) : {};
3861
+ }, [appStoreApi, name, value]);
3672
3862
  if (field.type !== "object" || !field.objectFields) {
3673
3863
  return null;
3674
3864
  }
3675
- const data = value || {};
3676
- return /* @__PURE__ */ jsx17(
3865
+ return /* @__PURE__ */ jsx18(
3677
3866
  Label2,
3678
3867
  {
3679
3868
  label: label || name,
3680
- icon: labelIcon || /* @__PURE__ */ jsx17(EllipsisVertical, { size: 16 }),
3869
+ icon: labelIcon || /* @__PURE__ */ jsx18(EllipsisVertical, { size: 16 }),
3681
3870
  el: "div",
3682
3871
  readOnly,
3683
- children: /* @__PURE__ */ jsx17("div", { className: getClassName14(), children: /* @__PURE__ */ jsx17("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
3872
+ children: /* @__PURE__ */ jsx18("div", { className: getClassName14(), children: /* @__PURE__ */ jsx18("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
3684
3873
  const subField = field.objectFields[subName];
3685
3874
  const subPath = `${localName}.${subName}`;
3686
- const subReadOnly = readOnly ? readOnly : readOnlyFields[subPath];
3687
- const label2 = subField.label || subName;
3688
- return /* @__PURE__ */ jsx17(
3689
- NestedFieldProvider,
3875
+ return /* @__PURE__ */ jsx18(
3876
+ SubField,
3690
3877
  {
3691
- name: localName || id,
3878
+ id: `${id}_${subName}`,
3879
+ name,
3692
3880
  subName,
3693
- readOnlyFields,
3694
- children: /* @__PURE__ */ jsx17(
3695
- AutoFieldPrivate,
3696
- {
3697
- name: subPath,
3698
- label: subPath,
3699
- id: `${id}_${subName}`,
3700
- readOnly: subReadOnly,
3701
- field: __spreadProps(__spreadValues({}, subField), {
3702
- label: label2
3703
- // May be used by custom fields
3704
- }),
3705
- value: data[subName],
3706
- onChange: (val, ui) => {
3707
- onChange(
3708
- __spreadProps(__spreadValues({}, data), {
3709
- [subName]: val
3710
- }),
3711
- ui
3712
- );
3713
- }
3714
- }
3715
- )
3881
+ localName,
3882
+ field: subField,
3883
+ forceReadOnly: !canEdit,
3884
+ value,
3885
+ onChange: (subValue, ui, subName2) => {
3886
+ const value2 = getValue();
3887
+ onChange(__spreadProps(__spreadValues({}, value2), { [subName2]: subValue }), ui);
3888
+ }
3716
3889
  },
3717
3890
  subPath
3718
3891
  );
@@ -3733,7 +3906,8 @@ var useSafeId = () => {
3733
3906
  };
3734
3907
 
3735
3908
  // components/AutoField/index.tsx
3736
- import { Fragment as Fragment4, jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
3909
+ import { useShallow } from "zustand/react/shallow";
3910
+ import { Fragment as Fragment5, jsx as jsx19, jsxs as jsxs8 } from "react/jsx-runtime";
3737
3911
  var getClassName15 = get_class_name_factory_default("Input", styles_module_default3);
3738
3912
  var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default3);
3739
3913
  var FieldLabel = ({
@@ -3747,9 +3921,9 @@ var FieldLabel = ({
3747
3921
  const El = el;
3748
3922
  return /* @__PURE__ */ jsxs8(El, { className, children: [
3749
3923
  /* @__PURE__ */ jsxs8("div", { className: getClassName15("label"), children: [
3750
- icon ? /* @__PURE__ */ jsx18("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ jsx18(Fragment4, {}),
3924
+ icon ? /* @__PURE__ */ jsx19("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ jsx19(Fragment5, {}),
3751
3925
  label,
3752
- readOnly && /* @__PURE__ */ jsx18("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ jsx18(Lock, { size: "12" }) })
3926
+ readOnly && /* @__PURE__ */ jsx19("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ jsx19(Lock, { size: "12" }) })
3753
3927
  ] }),
3754
3928
  children
3755
3929
  ] });
@@ -3767,9 +3941,9 @@ var FieldLabelInternal = ({
3767
3941
  [overrides]
3768
3942
  );
3769
3943
  if (!label) {
3770
- return /* @__PURE__ */ jsx18(Fragment4, { children });
3944
+ return /* @__PURE__ */ jsx19(Fragment5, { children });
3771
3945
  }
3772
- return /* @__PURE__ */ jsx18(
3946
+ return /* @__PURE__ */ jsx19(
3773
3947
  Wrapper,
3774
3948
  {
3775
3949
  label,
@@ -3795,10 +3969,10 @@ function AutoFieldInternal(props) {
3795
3969
  var _a;
3796
3970
  const dispatch = useAppStore((s) => s.dispatch);
3797
3971
  const overrides = useAppStore((s) => s.overrides);
3798
- const readOnly = useAppStore((s) => {
3972
+ const readOnly = useAppStore(useShallow((s) => {
3799
3973
  var _a2;
3800
3974
  return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
3801
- });
3975
+ }));
3802
3976
  const nestedFieldContext = useContext3(NestedFieldContext);
3803
3977
  const { id, Label: Label2 = FieldLabelInternal } = props;
3804
3978
  const field = props.field;
@@ -3832,7 +4006,7 @@ function AutoFieldInternal(props) {
3832
4006
  }),
3833
4007
  [props, field, label, labelIcon, Label2, resolvedId]
3834
4008
  );
3835
- const onFocus = useCallback4(
4009
+ const onFocus = useCallback5(
3836
4010
  (e) => {
3837
4011
  if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
3838
4012
  e.stopPropagation();
@@ -3846,7 +4020,7 @@ function AutoFieldInternal(props) {
3846
4020
  },
3847
4021
  [mergedProps.name]
3848
4022
  );
3849
- const onBlur = useCallback4((e) => {
4023
+ const onBlur = useCallback5((e) => {
3850
4024
  if ("name" in e.target) {
3851
4025
  dispatch({
3852
4026
  type: "setUi",
@@ -3862,6 +4036,7 @@ function AutoFieldInternal(props) {
3862
4036
  }
3863
4037
  return (_props) => null;
3864
4038
  }, [field.type]);
4039
+ const fieldKey = field.type === "custom" ? field.key : void 0;
3865
4040
  let FieldComponent = useMemo3(() => {
3866
4041
  if (field.type === "custom") {
3867
4042
  if (!field.render) {
@@ -3871,7 +4046,7 @@ function AutoFieldInternal(props) {
3871
4046
  } else if (field.type !== "slot") {
3872
4047
  return render[field.type];
3873
4048
  }
3874
- }, [field.type, render]);
4049
+ }, [field.type, fieldKey, render]);
3875
4050
  const { visible = true } = props.field;
3876
4051
  if (!visible) {
3877
4052
  return null;
@@ -3882,14 +4057,14 @@ function AutoFieldInternal(props) {
3882
4057
  if (!FieldComponent) {
3883
4058
  throw new Error(`Field type for ${field.type} did not exist.`);
3884
4059
  }
3885
- return /* @__PURE__ */ jsx18(
4060
+ return /* @__PURE__ */ jsx19(
3886
4061
  NestedFieldContext.Provider,
3887
4062
  {
3888
4063
  value: {
3889
4064
  readOnlyFields: nestedFieldContext.readOnlyFields || readOnly || {},
3890
4065
  localName: (_a = nestedFieldContext.localName) != null ? _a : mergedProps.name
3891
4066
  },
3892
- children: /* @__PURE__ */ jsx18(
4067
+ children: /* @__PURE__ */ jsx19(
3893
4068
  "div",
3894
4069
  {
3895
4070
  className: getClassNameWrapper(),
@@ -3898,7 +4073,7 @@ function AutoFieldInternal(props) {
3898
4073
  onClick: (e) => {
3899
4074
  e.stopPropagation();
3900
4075
  },
3901
- children: /* @__PURE__ */ jsx18(FieldComponent, __spreadProps(__spreadValues({}, mergedProps), { children: /* @__PURE__ */ jsx18(Children, __spreadValues({}, mergedProps)) }))
4076
+ children: /* @__PURE__ */ jsx19(FieldComponent, __spreadProps(__spreadValues({}, mergedProps), { children: /* @__PURE__ */ jsx19(Children, __spreadValues({}, mergedProps)) }))
3902
4077
  }
3903
4078
  )
3904
4079
  }
@@ -3906,14 +4081,30 @@ function AutoFieldInternal(props) {
3906
4081
  }
3907
4082
  function AutoFieldPrivate(props) {
3908
4083
  const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
3909
- const { value, onChange } = props;
4084
+ const { onChange } = props;
4085
+ const value = useAppStore((s) => {
4086
+ if (typeof props.value !== "undefined") return props.value;
4087
+ const { name, field } = props;
4088
+ if (!name) return;
4089
+ const excludedFields = ["array", "object"];
4090
+ if (!excludedFields.includes(field.type)) {
4091
+ const rootProps = s.state.data.root.props || s.state.data.root;
4092
+ const props2 = s.selectedItem ? s.selectedItem.props : rootProps;
4093
+ if (props2) {
4094
+ return getDeep(props2, name);
4095
+ }
4096
+ }
4097
+ });
3910
4098
  const [localValue, setLocalValue] = useState8(value);
3911
- const onChangeLocal = useCallback4(
4099
+ const onChangeLocal = useCallback5(
3912
4100
  (val, ui) => {
3913
- setLocalValue(val);
4101
+ const excludedFields = ["array", "object"];
4102
+ if (!excludedFields.includes(props.field.type)) {
4103
+ setLocalValue(val);
4104
+ }
3914
4105
  onChange(val, ui);
3915
4106
  },
3916
- [onChange]
4107
+ [props.field.type]
3917
4108
  );
3918
4109
  useEffect10(() => {
3919
4110
  if (!isFocused) {
@@ -3927,15 +4118,19 @@ function AutoFieldPrivate(props) {
3927
4118
  }
3928
4119
  }
3929
4120
  }, [isFocused, value, localValue]);
3930
- const localProps = {
3931
- value: localValue,
3932
- onChange: onChangeLocal
3933
- };
3934
- return /* @__PURE__ */ jsx18(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
4121
+ const localProps = useMemo3(
4122
+ () => ({
4123
+ // localValue is sometimes undefined when using outside of Fields context
4124
+ value: localValue != null ? localValue : value,
4125
+ onChange: onChangeLocal
4126
+ }),
4127
+ [value, localValue, onChangeLocal]
4128
+ );
4129
+ return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
3935
4130
  }
3936
4131
  function AutoField(props) {
3937
4132
  const DefaultLabel = useMemo3(() => {
3938
- const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx18(
4133
+ const DefaultLabel2 = (labelProps) => /* @__PURE__ */ jsx19(
3939
4134
  "div",
3940
4135
  __spreadProps(__spreadValues({}, labelProps), {
3941
4136
  className: getClassName15({ readOnly: props.readOnly })
@@ -3946,7 +4141,7 @@ function AutoField(props) {
3946
4141
  if (props.field.type === "slot") {
3947
4142
  return null;
3948
4143
  }
3949
- return /* @__PURE__ */ jsx18(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
4144
+ return /* @__PURE__ */ jsx19(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
3950
4145
  }
3951
4146
 
3952
4147
  // components/Render/index.tsx
@@ -3956,8 +4151,8 @@ init_react_import();
3956
4151
  init_react_import();
3957
4152
  import {
3958
4153
  forwardRef as forwardRef3,
3959
- memo as memo2,
3960
- useCallback as useCallback11,
4154
+ memo as memo4,
4155
+ useCallback as useCallback12,
3961
4156
  useContext as useContext8,
3962
4157
  useEffect as useEffect18,
3963
4158
  useMemo as useMemo8,
@@ -3967,7 +4162,7 @@ import {
3967
4162
  // components/DraggableComponent/index.tsx
3968
4163
  init_react_import();
3969
4164
  import {
3970
- useCallback as useCallback7,
4165
+ useCallback as useCallback8,
3971
4166
  useContext as useContext5,
3972
4167
  useEffect as useEffect12,
3973
4168
  useMemo as useMemo5,
@@ -4006,11 +4201,11 @@ function getDeepScrollPosition(element) {
4006
4201
  init_react_import();
4007
4202
  import {
4008
4203
  createContext as createContext3,
4009
- useCallback as useCallback5,
4204
+ useCallback as useCallback6,
4010
4205
  useMemo as useMemo4
4011
4206
  } from "react";
4012
4207
  import { createStore as createStore2 } from "zustand";
4013
- import { Fragment as Fragment5, jsx as jsx19 } from "react/jsx-runtime";
4208
+ import { Fragment as Fragment6, jsx as jsx20 } from "react/jsx-runtime";
4014
4209
  var dropZoneContext = createContext3(null);
4015
4210
  var ZoneStoreContext = createContext3(
4016
4211
  createStore2(() => ({
@@ -4028,14 +4223,14 @@ var ZoneStoreProvider = ({
4028
4223
  children,
4029
4224
  store
4030
4225
  }) => {
4031
- return /* @__PURE__ */ jsx19(ZoneStoreContext.Provider, { value: store, children });
4226
+ return /* @__PURE__ */ jsx20(ZoneStoreContext.Provider, { value: store, children });
4032
4227
  };
4033
4228
  var DropZoneProvider = ({
4034
4229
  children,
4035
4230
  value
4036
4231
  }) => {
4037
4232
  const dispatch = useAppStore((s) => s.dispatch);
4038
- const registerZone = useCallback5(
4233
+ const registerZone = useCallback6(
4039
4234
  (zoneCompound) => {
4040
4235
  dispatch({
4041
4236
  type: "registerZone",
@@ -4050,11 +4245,11 @@ var DropZoneProvider = ({
4050
4245
  }, value),
4051
4246
  [value]
4052
4247
  );
4053
- return /* @__PURE__ */ jsx19(Fragment5, { children: memoValue && /* @__PURE__ */ jsx19(dropZoneContext.Provider, { value: memoValue, children }) });
4248
+ return /* @__PURE__ */ jsx20(Fragment6, { children: memoValue && /* @__PURE__ */ jsx20(dropZoneContext.Provider, { value: memoValue, children }) });
4054
4249
  };
4055
4250
 
4056
4251
  // components/DraggableComponent/index.tsx
4057
- import { useShallow as useShallow2 } from "zustand/react/shallow";
4252
+ import { useShallow as useShallow3 } from "zustand/react/shallow";
4058
4253
  import { useSortable as useSortable2 } from "@dnd-kit/react/sortable";
4059
4254
 
4060
4255
  // lib/accumulate-transform.ts
@@ -4076,21 +4271,21 @@ function accumulateTransform(el) {
4076
4271
  init_react_import();
4077
4272
  import { useContext as useContext4 } from "react";
4078
4273
  import { useStore as useStore2 } from "zustand";
4079
- import { useShallow } from "zustand/react/shallow";
4274
+ import { useShallow as useShallow2 } from "zustand/react/shallow";
4080
4275
  function useContextStore(context, selector) {
4081
4276
  const store = useContext4(context);
4082
4277
  if (!store) {
4083
4278
  throw new Error("useContextStore must be used inside context");
4084
4279
  }
4085
- return useStore2(store, useShallow(selector));
4280
+ return useStore2(store, useShallow2(selector));
4086
4281
  }
4087
4282
 
4088
4283
  // lib/dnd/use-on-drag-finished.ts
4089
4284
  init_react_import();
4090
- import { useCallback as useCallback6 } from "react";
4285
+ import { useCallback as useCallback7 } from "react";
4091
4286
  var useOnDragFinished = (cb, deps = []) => {
4092
4287
  const appStore = useAppStoreApi();
4093
- return useCallback6(() => {
4288
+ return useCallback7(() => {
4094
4289
  let dispose = () => {
4095
4290
  };
4096
4291
  const processDragging = (isDragging2) => {
@@ -4118,7 +4313,7 @@ var useOnDragFinished = (cb, deps = []) => {
4118
4313
  };
4119
4314
 
4120
4315
  // components/DraggableComponent/index.tsx
4121
- import { Fragment as Fragment6, jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
4316
+ import { Fragment as Fragment7, jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
4122
4317
  var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default10);
4123
4318
  var DEBUG2 = false;
4124
4319
  var space = 8;
@@ -4132,13 +4327,13 @@ var DefaultActionBar = ({
4132
4327
  }) => /* @__PURE__ */ jsxs9(ActionBar, { children: [
4133
4328
  /* @__PURE__ */ jsxs9(ActionBar.Group, { children: [
4134
4329
  parentAction,
4135
- label && /* @__PURE__ */ jsx20(ActionBar.Label, { label })
4330
+ label && /* @__PURE__ */ jsx21(ActionBar.Label, { label })
4136
4331
  ] }),
4137
- /* @__PURE__ */ jsx20(ActionBar.Group, { children })
4332
+ /* @__PURE__ */ jsx21(ActionBar.Group, { children })
4138
4333
  ] });
4139
4334
  var DefaultOverlay = ({
4140
4335
  children
4141
- }) => /* @__PURE__ */ jsx20(Fragment6, { children });
4336
+ }) => /* @__PURE__ */ jsx21(Fragment7, { children });
4142
4337
  var DraggableComponent = ({
4143
4338
  children,
4144
4339
  depth,
@@ -4165,7 +4360,7 @@ var DraggableComponent = ({
4165
4360
  const iframe = useAppStore((s) => s.iframe);
4166
4361
  const ctx = useContext5(dropZoneContext);
4167
4362
  const [localZones, setLocalZones] = useState10({});
4168
- const registerLocalZone = useCallback7(
4363
+ const registerLocalZone = useCallback8(
4169
4364
  (zoneCompound2, active) => {
4170
4365
  var _a;
4171
4366
  (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
@@ -4175,7 +4370,7 @@ var DraggableComponent = ({
4175
4370
  },
4176
4371
  [setLocalZones]
4177
4372
  );
4178
- const unregisterLocalZone = useCallback7(
4373
+ const unregisterLocalZone = useCallback8(
4179
4374
  (zoneCompound2) => {
4180
4375
  var _a;
4181
4376
  (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
@@ -4188,12 +4383,12 @@ var DraggableComponent = ({
4188
4383
  [setLocalZones]
4189
4384
  );
4190
4385
  const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
4191
- const path = useAppStore(useShallow2((s) => {
4386
+ const path = useAppStore(useShallow3((s) => {
4192
4387
  var _a;
4193
4388
  return (_a = s.state.indexes.nodes[id]) == null ? void 0 : _a.path;
4194
4389
  }));
4195
4390
  const permissions = useAppStore(
4196
- useShallow2((s) => {
4391
+ useShallow3((s) => {
4197
4392
  const item = getItem({ index, zone: zoneCompound }, s.state);
4198
4393
  return s.permissions.getPermissions({ item });
4199
4394
  })
@@ -4251,7 +4446,7 @@ var DraggableComponent = ({
4251
4446
  }, [permissions.drag, zoneCompound]);
4252
4447
  const [, setRerender] = useState10(0);
4253
4448
  const ref = useRef2(null);
4254
- const refSetter = useCallback7(
4449
+ const refSetter = useCallback8(
4255
4450
  (el) => {
4256
4451
  sortableRef(el);
4257
4452
  if (ref.current !== el) {
@@ -4268,7 +4463,7 @@ var DraggableComponent = ({
4268
4463
  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
4269
4464
  );
4270
4465
  }, [iframe.enabled, ref.current]);
4271
- const getStyle = useCallback7(() => {
4466
+ const getStyle = useCallback8(() => {
4272
4467
  var _a, _b, _c;
4273
4468
  if (!ref.current) return;
4274
4469
  const rect = ref.current.getBoundingClientRect();
@@ -4294,7 +4489,7 @@ var DraggableComponent = ({
4294
4489
  return style2;
4295
4490
  }, [ref.current]);
4296
4491
  const [style, setStyle] = useState10();
4297
- const sync = useCallback7(() => {
4492
+ const sync = useCallback8(() => {
4298
4493
  setStyle(getStyle());
4299
4494
  }, [ref.current, iframe]);
4300
4495
  useEffect12(() => {
@@ -4307,10 +4502,10 @@ var DraggableComponent = ({
4307
4502
  }
4308
4503
  }, [ref.current]);
4309
4504
  const registerNode = useAppStore((s) => s.nodes.registerNode);
4310
- const hideOverlay = useCallback7(() => {
4505
+ const hideOverlay = useCallback8(() => {
4311
4506
  setIsVisible(false);
4312
4507
  }, []);
4313
- const showOverlay = useCallback7(() => {
4508
+ const showOverlay = useCallback8(() => {
4314
4509
  setIsVisible(true);
4315
4510
  }, []);
4316
4511
  useEffect12(() => {
@@ -4338,7 +4533,7 @@ var DraggableComponent = ({
4338
4533
  () => overrides.componentOverlay || DefaultOverlay,
4339
4534
  [overrides.componentOverlay]
4340
4535
  );
4341
- const onClick = useCallback7(
4536
+ const onClick = useCallback8(
4342
4537
  (e) => {
4343
4538
  const el = e.target;
4344
4539
  if (!el.closest("[data-puck-overlay-portal]")) {
@@ -4363,7 +4558,7 @@ var DraggableComponent = ({
4363
4558
  [index, zoneCompound, id, isSelected]
4364
4559
  );
4365
4560
  const appStore = useAppStoreApi();
4366
- const onSelectParent = useCallback7(() => {
4561
+ const onSelectParent = useCallback8(() => {
4367
4562
  const { nodes, zones } = appStore.getState().state.indexes;
4368
4563
  const node = nodes[id];
4369
4564
  const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
@@ -4384,14 +4579,14 @@ var DraggableComponent = ({
4384
4579
  }
4385
4580
  });
4386
4581
  }, [ctx, path]);
4387
- const onDuplicate = useCallback7(() => {
4582
+ const onDuplicate = useCallback8(() => {
4388
4583
  dispatch({
4389
4584
  type: "duplicate",
4390
4585
  sourceIndex: index,
4391
4586
  sourceZone: zoneCompound
4392
4587
  });
4393
4588
  }, [index, zoneCompound]);
4394
- const onDelete = useCallback7(() => {
4589
+ const onDelete = useCallback8(() => {
4395
4590
  dispatch({
4396
4591
  type: "remove",
4397
4592
  index,
@@ -4481,7 +4676,7 @@ var DraggableComponent = ({
4481
4676
  useEffect12(() => {
4482
4677
  if (thisWasDragging) return onDragFinished();
4483
4678
  }, [thisWasDragging, onDragFinished]);
4484
- const syncActionsPosition = useCallback7(
4679
+ const syncActionsPosition = useCallback8(
4485
4680
  (el) => {
4486
4681
  if (el) {
4487
4682
  const view = el.ownerDocument.defaultView;
@@ -4521,7 +4716,7 @@ var DraggableComponent = ({
4521
4716
  setDragAxis(autoDragAxis);
4522
4717
  }, [ref, userDragAxis, autoDragAxis]);
4523
4718
  const parentAction = useMemo5(
4524
- () => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ jsx20(CornerLeftUp, { size: 16 }) }),
4719
+ () => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ jsx21(CornerLeftUp, { size: 16 }) }),
4525
4720
  [ctx == null ? void 0 : ctx.areaId]
4526
4721
  );
4527
4722
  const nextContextValue = useMemo5(
@@ -4557,15 +4752,15 @@ var DraggableComponent = ({
4557
4752
  "data-puck-overlay": true,
4558
4753
  children: [
4559
4754
  debug,
4560
- isLoading && /* @__PURE__ */ jsx20("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx20(Loader, {}) }),
4561
- /* @__PURE__ */ jsx20(
4755
+ isLoading && /* @__PURE__ */ jsx21("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx21(Loader, {}) }),
4756
+ /* @__PURE__ */ jsx21(
4562
4757
  "div",
4563
4758
  {
4564
4759
  className: getClassName16("actionsOverlay"),
4565
4760
  style: {
4566
4761
  top: actionsOverlayTop / zoom
4567
4762
  },
4568
- children: /* @__PURE__ */ jsx20(
4763
+ children: /* @__PURE__ */ jsx21(
4569
4764
  "div",
4570
4765
  {
4571
4766
  className: getClassName16("actions"),
@@ -4583,8 +4778,8 @@ var DraggableComponent = ({
4583
4778
  parentAction,
4584
4779
  label: DEBUG2 ? id : label,
4585
4780
  children: [
4586
- permissions.duplicate && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx20(Copy, { size: 16 }) }),
4587
- permissions.delete && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx20(Trash, { size: 16 }) })
4781
+ permissions.duplicate && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx21(Copy, { size: 16 }) }),
4782
+ permissions.delete && /* @__PURE__ */ jsx21(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx21(Trash, { size: 16 }) })
4588
4783
  ]
4589
4784
  }
4590
4785
  )
@@ -4592,14 +4787,14 @@ var DraggableComponent = ({
4592
4787
  )
4593
4788
  }
4594
4789
  ),
4595
- /* @__PURE__ */ jsx20("div", { className: getClassName16("overlayWrapper"), children: /* @__PURE__ */ jsx20(
4790
+ /* @__PURE__ */ jsx21("div", { className: getClassName16("overlayWrapper"), children: /* @__PURE__ */ jsx21(
4596
4791
  CustomOverlay,
4597
4792
  {
4598
4793
  componentId: id,
4599
4794
  componentType,
4600
4795
  hover,
4601
4796
  isSelected,
4602
- children: /* @__PURE__ */ jsx20("div", { className: getClassName16("overlay") })
4797
+ children: /* @__PURE__ */ jsx21("div", { className: getClassName16("overlay") })
4603
4798
  }
4604
4799
  ) })
4605
4800
  ]
@@ -4633,7 +4828,7 @@ init_react_import();
4633
4828
  import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
4634
4829
  import {
4635
4830
  createContext as createContext4,
4636
- useCallback as useCallback8,
4831
+ useCallback as useCallback9,
4637
4832
  useContext as useContext6,
4638
4833
  useEffect as useEffect13,
4639
4834
  useMemo as useMemo6,
@@ -4920,7 +5115,20 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
4920
5115
 
4921
5116
  // lib/insert-component.ts
4922
5117
  init_react_import();
4923
- var insertComponent = (componentType, zone, index, appStore) => __async(void 0, null, function* () {
5118
+
5119
+ // lib/get-selector-for-id.ts
5120
+ init_react_import();
5121
+ var getSelectorForId = (state, id) => {
5122
+ const node = state.indexes.nodes[id];
5123
+ if (!node) return;
5124
+ const zoneCompound = `${node.parentId}:${node.zone}`;
5125
+ const index = state.indexes.zones[zoneCompound].contentIds.indexOf(id);
5126
+ return { zone: zoneCompound, index };
5127
+ };
5128
+
5129
+ // lib/insert-component.ts
5130
+ var insertComponent = (componentType, zone, index, appStore) => __async(null, null, function* () {
5131
+ const { getState } = appStore;
4924
5132
  const id = generateId(componentType);
4925
5133
  const insertActionData = {
4926
5134
  type: "insert",
@@ -4929,8 +5137,9 @@ var insertComponent = (componentType, zone, index, appStore) => __async(void 0,
4929
5137
  destinationZone: zone,
4930
5138
  id
4931
5139
  };
4932
- const { state, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
4933
- const insertedState = insertAction(state, insertActionData, appStore);
5140
+ const stateBefore = getState().state;
5141
+ const insertedState = insertAction(stateBefore, insertActionData, getState());
5142
+ const dispatch = getState().dispatch;
4934
5143
  dispatch(__spreadProps(__spreadValues({}, insertActionData), {
4935
5144
  // Dispatch insert rather set, as user's may rely on this via onAction
4936
5145
  // We must always record history here so the insert is added to user history
@@ -4938,23 +5147,21 @@ var insertComponent = (componentType, zone, index, appStore) => __async(void 0,
4938
5147
  // entries on insert - one for the initial insert, and one when the data resolves
4939
5148
  recordHistory: true
4940
5149
  }));
4941
- const itemSelector = {
4942
- index,
4943
- zone
4944
- };
5150
+ const itemSelector = { index, zone };
4945
5151
  dispatch({ type: "setUi", ui: { itemSelector } });
4946
5152
  const itemData = getItem(itemSelector, insertedState);
4947
- if (itemData) {
4948
- const resolved = yield resolveComponentData2(itemData, "insert");
4949
- if (resolved.didChange) {
4950
- dispatch({
4951
- type: "replace",
4952
- destinationZone: itemSelector.zone,
4953
- destinationIndex: itemSelector.index,
4954
- data: resolved.node
4955
- });
4956
- }
4957
- }
5153
+ if (!itemData) return;
5154
+ const resolveComponentData2 = getState().resolveComponentData;
5155
+ const resolved = yield resolveComponentData2(itemData, "insert");
5156
+ if (!resolved.didChange) return;
5157
+ const latestItemSelector = getSelectorForId(getState().state, id);
5158
+ if (!latestItemSelector) return;
5159
+ dispatch({
5160
+ type: "replace",
5161
+ destinationZone: latestItemSelector.zone,
5162
+ destinationIndex: latestItemSelector.index,
5163
+ data: resolved.node
5164
+ });
4958
5165
  });
4959
5166
 
4960
5167
  // components/DragDropContext/index.tsx
@@ -4974,7 +5181,7 @@ function getDeepDir(el) {
4974
5181
 
4975
5182
  // components/DragDropContext/index.tsx
4976
5183
  import { effect } from "@dnd-kit/state";
4977
- import { jsx as jsx21 } from "react/jsx-runtime";
5184
+ import { jsx as jsx22 } from "react/jsx-runtime";
4978
5185
  var DEBUG3 = false;
4979
5186
  var dragListenerContext = createContext4({
4980
5187
  dragListeners: {}
@@ -4992,7 +5199,7 @@ function useDragListener(type, fn, deps = []) {
4992
5199
  var AREA_CHANGE_DEBOUNCE_MS = 100;
4993
5200
  var useTempDisableFallback = (timeout3) => {
4994
5201
  const lastFallbackDisable = useRef3(null);
4995
- return useCallback8((manager) => {
5202
+ return useCallback9((manager) => {
4996
5203
  collisionStore.setState({ fallbackEnabled: false });
4997
5204
  const fallbackId = generateId();
4998
5205
  lastFallbackDisable.current = fallbackId;
@@ -5025,7 +5232,7 @@ var DragDropContextClient = ({
5025
5232
  hoveringComponent: null
5026
5233
  }))
5027
5234
  );
5028
- const getChanged2 = useCallback8(
5235
+ const getChanged2 = useCallback9(
5029
5236
  (params) => {
5030
5237
  const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
5031
5238
  const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
@@ -5046,7 +5253,7 @@ var DragDropContextClient = ({
5046
5253
  },
5047
5254
  [zoneStore]
5048
5255
  );
5049
- const setDeepestAndCollide = useCallback8(
5256
+ const setDeepestAndCollide = useCallback9(
5050
5257
  (params, manager) => {
5051
5258
  const { zoneChanged, areaChanged } = getChanged2(params);
5052
5259
  if (!zoneChanged && !areaChanged) return;
@@ -5143,14 +5350,14 @@ var DragDropContextClient = ({
5143
5350
  }),
5144
5351
  []
5145
5352
  );
5146
- return /* @__PURE__ */ jsx21(
5353
+ return /* @__PURE__ */ jsx22(
5147
5354
  dragListenerContext.Provider,
5148
5355
  {
5149
5356
  value: {
5150
5357
  dragListeners,
5151
5358
  setDragListeners
5152
5359
  },
5153
- children: /* @__PURE__ */ jsx21(
5360
+ children: /* @__PURE__ */ jsx22(
5154
5361
  DragDropProvider2,
5155
5362
  {
5156
5363
  plugins,
@@ -5191,7 +5398,7 @@ var DragDropContextClient = ({
5191
5398
  thisPreview.componentType,
5192
5399
  thisPreview.zone,
5193
5400
  thisPreview.index,
5194
- appStore.getState()
5401
+ appStore
5195
5402
  );
5196
5403
  } else if (initialSelector.current) {
5197
5404
  dispatch({
@@ -5366,7 +5573,7 @@ var DragDropContextClient = ({
5366
5573
  const entryEl = (_d = getFrame()) == null ? void 0 : _d.querySelector("[data-puck-entry]");
5367
5574
  entryEl == null ? void 0 : entryEl.setAttribute("data-puck-dragging", "true");
5368
5575
  },
5369
- children: /* @__PURE__ */ jsx21(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx21(DropZoneProvider, { value: nextContextValue, children }) })
5576
+ children: /* @__PURE__ */ jsx22(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx22(DropZoneProvider, { value: nextContextValue, children }) })
5370
5577
  }
5371
5578
  )
5372
5579
  }
@@ -5380,12 +5587,12 @@ var DragDropContext = ({
5380
5587
  if (status === "LOADING") {
5381
5588
  return children;
5382
5589
  }
5383
- return /* @__PURE__ */ jsx21(DragDropContextClient, { disableAutoScroll, children });
5590
+ return /* @__PURE__ */ jsx22(DragDropContextClient, { disableAutoScroll, children });
5384
5591
  };
5385
5592
 
5386
5593
  // components/Drawer/index.tsx
5387
5594
  import { useDraggable, useDroppable } from "@dnd-kit/react";
5388
- import { jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
5595
+ import { jsx as jsx23, jsxs as jsxs10 } from "react/jsx-runtime";
5389
5596
  var getClassName17 = get_class_name_factory_default("Drawer", styles_module_default12);
5390
5597
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default12);
5391
5598
  var DrawerItemInner = ({
@@ -5396,10 +5603,10 @@ var DrawerItemInner = ({
5396
5603
  isDragDisabled
5397
5604
  }) => {
5398
5605
  const CustomInner = useMemo7(
5399
- () => children || (({ children: children2 }) => /* @__PURE__ */ jsx22("div", { className: getClassNameItem2("default"), children: children2 })),
5606
+ () => children || (({ children: children2 }) => /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("default"), children: children2 })),
5400
5607
  [children]
5401
5608
  );
5402
- return /* @__PURE__ */ jsx22(
5609
+ return /* @__PURE__ */ jsx23(
5403
5610
  "div",
5404
5611
  {
5405
5612
  className: getClassNameItem2({ disabled: isDragDisabled }),
@@ -5407,9 +5614,9 @@ var DrawerItemInner = ({
5407
5614
  onMouseDown: (e) => e.preventDefault(),
5408
5615
  "data-testid": dragRef ? `drawer-item:${name}` : "",
5409
5616
  "data-puck-drawer-item": true,
5410
- children: /* @__PURE__ */ jsx22(CustomInner, { name, children: /* @__PURE__ */ jsx22("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs10("div", { className: getClassNameItem2("draggable"), children: [
5411
- /* @__PURE__ */ jsx22("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
5412
- /* @__PURE__ */ jsx22("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx22(DragIcon, {}) })
5617
+ children: /* @__PURE__ */ jsx23(CustomInner, { name, children: /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs10("div", { className: getClassNameItem2("draggable"), children: [
5618
+ /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
5619
+ /* @__PURE__ */ jsx23("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx23(DragIcon, {}) })
5413
5620
  ] }) }) })
5414
5621
  }
5415
5622
  );
@@ -5428,8 +5635,8 @@ var DrawerItemDraggable = ({
5428
5635
  type: "drawer"
5429
5636
  });
5430
5637
  return /* @__PURE__ */ jsxs10("div", { className: getClassName17("draggable"), children: [
5431
- /* @__PURE__ */ jsx22("div", { className: getClassName17("draggableBg"), children: /* @__PURE__ */ jsx22(DrawerItemInner, { name, label, children }) }),
5432
- /* @__PURE__ */ jsx22("div", { className: getClassName17("draggableFg"), children: /* @__PURE__ */ jsx22(
5638
+ /* @__PURE__ */ jsx23("div", { className: getClassName17("draggableBg"), children: /* @__PURE__ */ jsx23(DrawerItemInner, { name, label, children }) }),
5639
+ /* @__PURE__ */ jsx23("div", { className: getClassName17("draggableFg"), children: /* @__PURE__ */ jsx23(
5433
5640
  DrawerItemInner,
5434
5641
  {
5435
5642
  name,
@@ -5463,7 +5670,7 @@ var DrawerItem = ({
5463
5670
  },
5464
5671
  [resolvedId]
5465
5672
  );
5466
- return /* @__PURE__ */ jsx22("div", { children: /* @__PURE__ */ jsx22(
5673
+ return /* @__PURE__ */ jsx23("div", { children: /* @__PURE__ */ jsx23(
5467
5674
  DrawerItemDraggable,
5468
5675
  {
5469
5676
  name,
@@ -5496,7 +5703,7 @@ var Drawer = ({
5496
5703
  collisionPriority: 0
5497
5704
  // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
5498
5705
  });
5499
- return /* @__PURE__ */ jsx22(
5706
+ return /* @__PURE__ */ jsx23(
5500
5707
  "div",
5501
5708
  {
5502
5709
  className: getClassName17(),
@@ -5575,7 +5782,8 @@ var useMinEmptyHeight = ({
5575
5782
  }
5576
5783
  }
5577
5784
  }, [ref.current, draggedItem, onDragFinished]);
5578
- return [prevHeight || userMinEmptyHeight, isAnimating];
5785
+ const returnedMinHeight = isNaN(Number(userMinEmptyHeight)) ? userMinEmptyHeight : `${userMinEmptyHeight}px`;
5786
+ return [prevHeight ? `${prevHeight}px` : returnedMinHeight, isAnimating];
5579
5787
  };
5580
5788
 
5581
5789
  // lib/assign-refs.ts
@@ -5600,11 +5808,11 @@ import { useContext as useContext7, useEffect as useEffect15, useState as useSta
5600
5808
  // lib/dnd/use-rendered-callback.ts
5601
5809
  init_react_import();
5602
5810
  import { useDragDropManager } from "@dnd-kit/react";
5603
- import { useCallback as useCallback9 } from "react";
5811
+ import { useCallback as useCallback10 } from "react";
5604
5812
  function useRenderedCallback(callback, deps) {
5605
5813
  const manager = useDragDropManager();
5606
- return useCallback9(
5607
- (...args) => __async(this, null, function* () {
5814
+ return useCallback10(
5815
+ (...args) => __async(null, null, function* () {
5608
5816
  yield manager == null ? void 0 : manager.renderer.rendering;
5609
5817
  return callback(...args);
5610
5818
  }),
@@ -5674,7 +5882,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
5674
5882
 
5675
5883
  // components/DropZone/lib/use-drag-axis.ts
5676
5884
  init_react_import();
5677
- import { useCallback as useCallback10, useEffect as useEffect16, useState as useState15 } from "react";
5885
+ import { useCallback as useCallback11, useEffect as useEffect16, useState as useState15 } from "react";
5678
5886
  var GRID_DRAG_AXIS = "dynamic";
5679
5887
  var FLEX_ROW_DRAG_AXIS = "x";
5680
5888
  var DEFAULT_DRAG_AXIS = "y";
@@ -5683,7 +5891,7 @@ var useDragAxis = (ref, collisionAxis) => {
5683
5891
  const [dragAxis, setDragAxis] = useState15(
5684
5892
  collisionAxis || DEFAULT_DRAG_AXIS
5685
5893
  );
5686
- const calculateDragAxis = useCallback10(() => {
5894
+ const calculateDragAxis = useCallback11(() => {
5687
5895
  if (ref.current) {
5688
5896
  const computedStyle = window.getComputedStyle(ref.current);
5689
5897
  if (computedStyle.display === "grid") {
@@ -5709,12 +5917,12 @@ var useDragAxis = (ref, collisionAxis) => {
5709
5917
  };
5710
5918
 
5711
5919
  // components/DropZone/index.tsx
5712
- import { useShallow as useShallow4 } from "zustand/react/shallow";
5920
+ import { useShallow as useShallow5 } from "zustand/react/shallow";
5713
5921
 
5714
5922
  // components/SlotRender/index.tsx
5715
5923
  init_react_import();
5716
- import { useShallow as useShallow3 } from "zustand/react/shallow";
5717
- import { jsx as jsx23 } from "react/jsx-runtime";
5924
+ import { useShallow as useShallow4 } from "zustand/react/shallow";
5925
+ import { jsx as jsx24 } from "react/jsx-runtime";
5718
5926
  var ContextSlotRender = ({
5719
5927
  componentId,
5720
5928
  zone
@@ -5722,14 +5930,14 @@ var ContextSlotRender = ({
5722
5930
  const config = useAppStore((s) => s.config);
5723
5931
  const metadata = useAppStore((s) => s.metadata);
5724
5932
  const slotContent = useAppStore(
5725
- useShallow3((s) => {
5933
+ useShallow4((s) => {
5726
5934
  var _a, _b;
5727
5935
  const indexes = s.state.indexes;
5728
5936
  const contentIds = (_b = (_a = indexes.zones[`${componentId}:${zone}`]) == null ? void 0 : _a.contentIds) != null ? _b : [];
5729
5937
  return contentIds.map((contentId) => indexes.nodes[contentId].flatData);
5730
5938
  })
5731
5939
  );
5732
- return /* @__PURE__ */ jsx23(
5940
+ return /* @__PURE__ */ jsx24(
5733
5941
  SlotRenderPure,
5734
5942
  {
5735
5943
  content: slotContent,
@@ -5745,7 +5953,7 @@ init_react_import();
5745
5953
 
5746
5954
  // components/InlineTextField/index.tsx
5747
5955
  init_react_import();
5748
- import { memo, useEffect as useEffect17, useRef as useRef5, useState as useState16 } from "react";
5956
+ import { memo as memo3, useEffect as useEffect17, useRef as useRef5, useState as useState16 } from "react";
5749
5957
 
5750
5958
  // lib/overlay-portal/index.tsx
5751
5959
  init_react_import();
@@ -5833,18 +6041,8 @@ function setDeep(node, path, newVal) {
5833
6041
  return __spreadValues(__spreadValues({}, node), newNode);
5834
6042
  }
5835
6043
 
5836
- // lib/get-selector-for-id.ts
5837
- init_react_import();
5838
- var getSelectorForId = (state, id) => {
5839
- const node = state.indexes.nodes[id];
5840
- if (!node) return;
5841
- const zoneCompound = `${node.parentId}:${node.zone}`;
5842
- const index = state.indexes.zones[zoneCompound].contentIds.indexOf(id);
5843
- return { zone: zoneCompound, index };
5844
- };
5845
-
5846
6044
  // components/InlineTextField/index.tsx
5847
- import { jsx as jsx24 } from "react/jsx-runtime";
6045
+ import { jsx as jsx25 } from "react/jsx-runtime";
5848
6046
  var getClassName18 = get_class_name_factory_default("InlineTextField", styles_module_default13);
5849
6047
  var InlineTextFieldInternal = ({
5850
6048
  propPath,
@@ -5871,7 +6069,7 @@ var InlineTextFieldInternal = ({
5871
6069
  ref.current.replaceChildren(value);
5872
6070
  }
5873
6071
  const cleanupPortal = registerOverlayPortal(ref.current);
5874
- const handleInput = (e) => __async(void 0, null, function* () {
6072
+ const handleInput = (e) => __async(null, null, function* () {
5875
6073
  var _a2;
5876
6074
  const appStore2 = appStoreApi.getState();
5877
6075
  const node = appStore2.state.indexes.nodes[componentId];
@@ -5905,7 +6103,7 @@ var InlineTextFieldInternal = ({
5905
6103
  }, [appStoreApi, ref.current, value, disableLineBreaks]);
5906
6104
  const [isHovering, setIsHovering] = useState16(false);
5907
6105
  const [isFocused, setIsFocused] = useState16(false);
5908
- return /* @__PURE__ */ jsx24(
6106
+ return /* @__PURE__ */ jsx25(
5909
6107
  "span",
5910
6108
  {
5911
6109
  className: getClassName18(),
@@ -5941,14 +6139,14 @@ var InlineTextFieldInternal = ({
5941
6139
  }
5942
6140
  );
5943
6141
  };
5944
- var InlineTextField = memo(InlineTextFieldInternal);
6142
+ var InlineTextField = memo3(InlineTextFieldInternal);
5945
6143
 
5946
6144
  // lib/field-transforms/default-transforms/inline-text-transform.tsx
5947
- import { jsx as jsx25 } from "react/jsx-runtime";
6145
+ import { jsx as jsx26 } from "react/jsx-runtime";
5948
6146
  var getInlineTextTransform = () => ({
5949
6147
  text: ({ value, componentId, field, propPath, isReadOnly }) => {
5950
6148
  if (field.contentEditable) {
5951
- return /* @__PURE__ */ jsx25(
6149
+ return /* @__PURE__ */ jsx26(
5952
6150
  InlineTextField,
5953
6151
  {
5954
6152
  propPath,
@@ -5963,7 +6161,7 @@ var getInlineTextTransform = () => ({
5963
6161
  },
5964
6162
  textarea: ({ value, componentId, field, propPath, isReadOnly }) => {
5965
6163
  if (field.contentEditable) {
5966
- return /* @__PURE__ */ jsx25(
6164
+ return /* @__PURE__ */ jsx26(
5967
6165
  InlineTextField,
5968
6166
  {
5969
6167
  propPath,
@@ -5977,7 +6175,7 @@ var getInlineTextTransform = () => ({
5977
6175
  },
5978
6176
  custom: ({ value, componentId, field, propPath, isReadOnly }) => {
5979
6177
  if (field.contentEditable && typeof value === "string") {
5980
- return /* @__PURE__ */ jsx25(
6178
+ return /* @__PURE__ */ jsx26(
5981
6179
  InlineTextField,
5982
6180
  {
5983
6181
  propPath,
@@ -5992,11 +6190,11 @@ var getInlineTextTransform = () => ({
5992
6190
  });
5993
6191
 
5994
6192
  // components/DropZone/index.tsx
5995
- import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs11 } from "react/jsx-runtime";
6193
+ import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs11 } from "react/jsx-runtime";
5996
6194
  var getClassName19 = get_class_name_factory_default("DropZone", styles_module_default11);
5997
6195
  var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
5998
6196
  var RENDER_DEBUG = false;
5999
- var DropZoneEditPure = (props) => /* @__PURE__ */ jsx26(DropZoneEdit, __spreadValues({}, props));
6197
+ var DropZoneEditPure = (props) => /* @__PURE__ */ jsx27(DropZoneEdit, __spreadValues({}, props));
6000
6198
  var DropZoneChild = ({
6001
6199
  zoneCompound,
6002
6200
  componentId,
@@ -6011,7 +6209,7 @@ var DropZoneChild = ({
6011
6209
  const { depth = 1 } = ctx != null ? ctx : {};
6012
6210
  const zoneStore = useContext8(ZoneStoreContext);
6013
6211
  const nodeProps = useAppStore(
6014
- useShallow4((s) => {
6212
+ useShallow5((s) => {
6015
6213
  var _a2;
6016
6214
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
6017
6215
  })
@@ -6023,7 +6221,7 @@ var DropZoneChild = ({
6023
6221
  }
6024
6222
  );
6025
6223
  const nodeReadOnly = useAppStore(
6026
- useShallow4((s) => {
6224
+ useShallow5((s) => {
6027
6225
  var _a2;
6028
6226
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
6029
6227
  })
@@ -6080,10 +6278,10 @@ var DropZoneChild = ({
6080
6278
  if (item && "element" in item && item.element) {
6081
6279
  return (
6082
6280
  // Safe to use this since the HTML is set by the user
6083
- /* @__PURE__ */ jsx26("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
6281
+ /* @__PURE__ */ jsx27("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
6084
6282
  );
6085
6283
  }
6086
- return /* @__PURE__ */ jsx26(DrawerItemInner, { name: label, children: (_a2 = overrides.componentItem) != null ? _a2 : overrides.drawerItem });
6284
+ return /* @__PURE__ */ jsx27(DrawerItemInner, { name: label, children: (_a2 = overrides.componentItem) != null ? _a2 : overrides.drawerItem });
6087
6285
  },
6088
6286
  [componentId, label, overrides]
6089
6287
  );
@@ -6106,7 +6304,7 @@ var DropZoneChild = ({
6106
6304
  const plugins = useAppStore((s) => s.plugins);
6107
6305
  const userFieldTransforms = useAppStore((s) => s.fieldTransforms);
6108
6306
  const combinedFieldTransforms = useMemo8(
6109
- () => __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, getSlotTransform(DropZoneEditPure, (slotProps) => /* @__PURE__ */ jsx26(ContextSlotRender, { componentId, zone: slotProps.zone }))), getInlineTextTransform()), plugins.reduce(
6307
+ () => __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, getSlotTransform(DropZoneEditPure, (slotProps) => /* @__PURE__ */ jsx27(ContextSlotRender, { componentId, zone: slotProps.zone }))), getInlineTextTransform()), plugins.reduce(
6110
6308
  (acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
6111
6309
  {}
6112
6310
  )), userFieldTransforms),
@@ -6129,7 +6327,7 @@ var DropZoneChild = ({
6129
6327
  if (isInserting) {
6130
6328
  Render2 = renderPreview;
6131
6329
  }
6132
- return /* @__PURE__ */ jsx26(
6330
+ return /* @__PURE__ */ jsx27(
6133
6331
  DraggableComponent,
6134
6332
  {
6135
6333
  id: componentId,
@@ -6143,18 +6341,18 @@ var DropZoneChild = ({
6143
6341
  autoDragAxis: dragAxis,
6144
6342
  userDragAxis: collisionAxis,
6145
6343
  inDroppableZone,
6146
- children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ jsx26(Fragment7, { children: /* @__PURE__ */ jsx26(
6344
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ jsx27(Fragment8, { children: /* @__PURE__ */ jsx27(
6147
6345
  Render2,
6148
6346
  __spreadProps(__spreadValues({}, transformedProps), {
6149
6347
  puck: __spreadProps(__spreadValues({}, transformedProps.puck), {
6150
6348
  dragRef
6151
6349
  })
6152
6350
  })
6153
- ) }) : /* @__PURE__ */ jsx26("div", { ref: dragRef, children: /* @__PURE__ */ jsx26(Render2, __spreadValues({}, transformedProps)) })
6351
+ ) }) : /* @__PURE__ */ jsx27("div", { ref: dragRef, children: /* @__PURE__ */ jsx27(Render2, __spreadValues({}, transformedProps)) })
6154
6352
  }
6155
6353
  );
6156
6354
  };
6157
- var DropZoneChildMemo = memo2(DropZoneChild);
6355
+ var DropZoneChildMemo = memo4(DropZoneChild);
6158
6356
  var DropZoneEdit = forwardRef3(
6159
6357
  function DropZoneEditInternal({
6160
6358
  zone,
@@ -6162,8 +6360,9 @@ var DropZoneEdit = forwardRef3(
6162
6360
  disallow,
6163
6361
  style,
6164
6362
  className,
6165
- minEmptyHeight: userMinEmptyHeight = 128,
6166
- collisionAxis
6363
+ minEmptyHeight: userMinEmptyHeight = "128px",
6364
+ collisionAxis,
6365
+ as
6167
6366
  }, userRef) {
6168
6367
  const ctx = useContext8(dropZoneContext);
6169
6368
  const appStoreApi = useAppStoreApi();
@@ -6175,7 +6374,7 @@ var DropZoneEdit = forwardRef3(
6175
6374
  unregisterLocalZone
6176
6375
  } = ctx != null ? ctx : {};
6177
6376
  const path = useAppStore(
6178
- useShallow4((s) => {
6377
+ useShallow5((s) => {
6179
6378
  var _a;
6180
6379
  return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
6181
6380
  })
@@ -6192,13 +6391,13 @@ var DropZoneEdit = forwardRef3(
6192
6391
  (s) => s.nextAreaDepthIndex[areaId || ""]
6193
6392
  );
6194
6393
  const zoneContentIds = useAppStore(
6195
- useShallow4((s) => {
6394
+ useShallow5((s) => {
6196
6395
  var _a;
6197
6396
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
6198
6397
  })
6199
6398
  );
6200
6399
  const zoneType = useAppStore(
6201
- useShallow4((s) => {
6400
+ useShallow5((s) => {
6202
6401
  var _a;
6203
6402
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
6204
6403
  })
@@ -6223,7 +6422,7 @@ var DropZoneEdit = forwardRef3(
6223
6422
  return zoneContentIds || [];
6224
6423
  }, [zoneContentIds]);
6225
6424
  const ref = useRef6(null);
6226
- const acceptsTarget = useCallback11(
6425
+ const acceptsTarget = useCallback12(
6227
6426
  (componentType) => {
6228
6427
  if (!componentType) {
6229
6428
  return true;
@@ -6306,8 +6505,9 @@ var DropZoneEdit = forwardRef3(
6306
6505
  userMinEmptyHeight,
6307
6506
  ref
6308
6507
  });
6309
- return /* @__PURE__ */ jsx26(
6310
- "div",
6508
+ const El = as != null ? as : "div";
6509
+ return /* @__PURE__ */ jsx27(
6510
+ El,
6311
6511
  {
6312
6512
  className: `${getClassName19({
6313
6513
  isRootZone,
@@ -6323,11 +6523,11 @@ var DropZoneEdit = forwardRef3(
6323
6523
  "data-testid": `dropzone:${zoneCompound}`,
6324
6524
  "data-puck-dropzone": zoneCompound,
6325
6525
  style: __spreadProps(__spreadValues({}, style), {
6326
- "--min-empty-height": `${minEmptyHeight}px`,
6526
+ "--min-empty-height": minEmptyHeight,
6327
6527
  backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
6328
6528
  }),
6329
6529
  children: contentIdsWithPreview.map((componentId, i) => {
6330
- return /* @__PURE__ */ jsx26(
6530
+ return /* @__PURE__ */ jsx27(
6331
6531
  DropZoneChildMemo,
6332
6532
  {
6333
6533
  zoneCompound,
@@ -6350,7 +6550,7 @@ var DropZoneRenderItem = ({
6350
6550
  metadata
6351
6551
  }) => {
6352
6552
  const Component = config.components[item.type];
6353
- const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ jsx26(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
6553
+ const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ jsx27(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
6354
6554
  const nextContextValue = useMemo8(
6355
6555
  () => ({
6356
6556
  areaId: props.id,
@@ -6358,7 +6558,7 @@ var DropZoneRenderItem = ({
6358
6558
  }),
6359
6559
  [props]
6360
6560
  );
6361
- return /* @__PURE__ */ jsx26(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx26(
6561
+ return /* @__PURE__ */ jsx27(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx27(
6362
6562
  Component.render,
6363
6563
  __spreadProps(__spreadValues({}, props), {
6364
6564
  puck: __spreadProps(__spreadValues({}, props.puck), {
@@ -6368,9 +6568,9 @@ var DropZoneRenderItem = ({
6368
6568
  })
6369
6569
  ) }, props.id);
6370
6570
  };
6371
- var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx26(DropZoneRender, __spreadValues({}, props));
6571
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx27(DropZoneRender, __spreadValues({}, props));
6372
6572
  var DropZoneRender = forwardRef3(
6373
- function DropZoneRenderInternal({ className, style, zone }, ref) {
6573
+ function DropZoneRenderInternal({ className, style, zone, as }, ref) {
6374
6574
  const ctx = useContext8(dropZoneContext);
6375
6575
  const { areaId = "root" } = ctx || {};
6376
6576
  const { config, data, metadata } = useContext8(renderContext);
@@ -6383,16 +6583,17 @@ var DropZoneRender = forwardRef3(
6383
6583
  }
6384
6584
  }
6385
6585
  }, [content]);
6586
+ const El = as != null ? as : "div";
6386
6587
  if (!data || !config) {
6387
6588
  return null;
6388
6589
  }
6389
6590
  if (zoneCompound !== rootDroppableId) {
6390
6591
  content = setupZone(data, zoneCompound).zones[zoneCompound];
6391
6592
  }
6392
- return /* @__PURE__ */ jsx26("div", { className, style, ref, children: content.map((item) => {
6593
+ return /* @__PURE__ */ jsx27(El, { className, style, ref, children: content.map((item) => {
6393
6594
  const Component = config.components[item.type];
6394
6595
  if (Component) {
6395
- return /* @__PURE__ */ jsx26(
6596
+ return /* @__PURE__ */ jsx27(
6396
6597
  DropZoneRenderItem,
6397
6598
  {
6398
6599
  config,
@@ -6406,20 +6607,20 @@ var DropZoneRender = forwardRef3(
6406
6607
  }) });
6407
6608
  }
6408
6609
  );
6409
- var DropZonePure = (props) => /* @__PURE__ */ jsx26(DropZone, __spreadValues({}, props));
6610
+ var DropZonePure = (props) => /* @__PURE__ */ jsx27(DropZone, __spreadValues({}, props));
6410
6611
  var DropZone = forwardRef3(
6411
6612
  function DropZone2(props, ref) {
6412
6613
  const ctx = useContext8(dropZoneContext);
6413
6614
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
6414
- return /* @__PURE__ */ jsx26(Fragment7, { children: /* @__PURE__ */ jsx26(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
6615
+ return /* @__PURE__ */ jsx27(Fragment8, { children: /* @__PURE__ */ jsx27(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
6415
6616
  }
6416
- return /* @__PURE__ */ jsx26(Fragment7, { children: /* @__PURE__ */ jsx26(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
6617
+ return /* @__PURE__ */ jsx27(Fragment8, { children: /* @__PURE__ */ jsx27(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
6417
6618
  }
6418
6619
  );
6419
6620
 
6420
6621
  // components/Render/index.tsx
6421
6622
  import React3, { useMemo as useMemo9 } from "react";
6422
- import { jsx as jsx27 } from "react/jsx-runtime";
6623
+ import { jsx as jsx28 } from "react/jsx-runtime";
6423
6624
  var renderContext = React3.createContext({
6424
6625
  config: { components: {} },
6425
6626
  data: { root: {}, content: [] },
@@ -6451,7 +6652,7 @@ function Render({
6451
6652
  const propsWithSlots = useSlots(
6452
6653
  config,
6453
6654
  { type: "root", props: pageProps },
6454
- (props) => /* @__PURE__ */ jsx27(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
6655
+ (props) => /* @__PURE__ */ jsx28(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
6455
6656
  );
6456
6657
  const nextContextValue = useMemo9(
6457
6658
  () => ({
@@ -6461,9 +6662,9 @@ function Render({
6461
6662
  []
6462
6663
  );
6463
6664
  if ((_a = config.root) == null ? void 0 : _a.render) {
6464
- return /* @__PURE__ */ jsx27(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx27(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx27(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ jsx27(DropZoneRenderPure, { zone: rootZone }) })) }) });
6665
+ return /* @__PURE__ */ jsx28(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx28(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx28(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ jsx28(DropZoneRenderPure, { zone: rootZone }) })) }) });
6465
6666
  }
6466
- return /* @__PURE__ */ jsx27(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx27(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx27(DropZoneRenderPure, { zone: rootZone }) }) });
6667
+ return /* @__PURE__ */ jsx28(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx28(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx28(DropZoneRenderPure, { zone: rootZone }) }) });
6467
6668
  }
6468
6669
 
6469
6670
  // lib/use-puck.ts
@@ -6491,7 +6692,15 @@ var generateUsePuck = (store) => {
6491
6692
  selectedItem: store.selectedItem || null,
6492
6693
  getItemBySelector: (selector) => getItem(selector, store.state),
6493
6694
  getItemById: (id) => store.state.indexes.nodes[id].data,
6494
- getSelectorForId: (id) => getSelectorForId(store.state, id)
6695
+ getSelectorForId: (id) => getSelectorForId(store.state, id),
6696
+ getParentById: (id) => {
6697
+ const node = store.state.indexes.nodes[id];
6698
+ const parentId = node.parentId;
6699
+ if (parentId === null) return;
6700
+ const parentNode = store.state.indexes.nodes[parentId];
6701
+ if (!parentNode) return;
6702
+ return parentNode.data;
6703
+ }
6495
6704
  };
6496
6705
  return storeData;
6497
6706
  };
@@ -6532,7 +6741,7 @@ function createUsePuck() {
6532
6741
  }
6533
6742
  const result = useStore3(
6534
6743
  usePuckApi,
6535
- selector != null ? selector : (s) => s
6744
+ selector != null ? selector : ((s) => s)
6536
6745
  );
6537
6746
  return result;
6538
6747
  };
@@ -6572,7 +6781,7 @@ var styles_module_default14 = { "ComponentList": "_ComponentList_1rrlt_1", "Comp
6572
6781
 
6573
6782
  // components/ComponentList/index.tsx
6574
6783
  import { useEffect as useEffect20 } from "react";
6575
- import { jsx as jsx28, jsxs as jsxs12 } from "react/jsx-runtime";
6784
+ import { jsx as jsx29, jsxs as jsxs12 } from "react/jsx-runtime";
6576
6785
  var getClassName20 = get_class_name_factory_default("ComponentList", styles_module_default14);
6577
6786
  var ComponentListItem = ({
6578
6787
  name,
@@ -6592,7 +6801,7 @@ var ComponentListItem = ({
6592
6801
  );
6593
6802
  }
6594
6803
  }, [overrides]);
6595
- return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
6804
+ return /* @__PURE__ */ jsx29(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
6596
6805
  };
6597
6806
  var ComponentList = ({
6598
6807
  children,
@@ -6618,14 +6827,14 @@ var ComponentList = ({
6618
6827
  }),
6619
6828
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
6620
6829
  children: [
6621
- /* @__PURE__ */ jsx28("div", { children: title }),
6622
- /* @__PURE__ */ jsx28("div", { className: getClassName20("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
6830
+ /* @__PURE__ */ jsx29("div", { children: title }),
6831
+ /* @__PURE__ */ jsx29("div", { className: getClassName20("titleIcon"), children: expanded ? /* @__PURE__ */ jsx29(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx29(ChevronDown, { size: 12 }) })
6623
6832
  ]
6624
6833
  }
6625
6834
  ),
6626
- /* @__PURE__ */ jsx28("div", { className: getClassName20("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6835
+ /* @__PURE__ */ jsx29("div", { className: getClassName20("content"), children: /* @__PURE__ */ jsx29(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6627
6836
  var _a;
6628
- return /* @__PURE__ */ jsx28(
6837
+ return /* @__PURE__ */ jsx29(
6629
6838
  ComponentListItem,
6630
6839
  {
6631
6840
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -6639,7 +6848,7 @@ var ComponentList = ({
6639
6848
  ComponentList.Item = ComponentListItem;
6640
6849
 
6641
6850
  // lib/use-component-list.tsx
6642
- import { jsx as jsx29 } from "react/jsx-runtime";
6851
+ import { jsx as jsx30 } from "react/jsx-runtime";
6643
6852
  var useComponentList = () => {
6644
6853
  const [componentList, setComponentList] = useState18();
6645
6854
  const config = useAppStore((s) => s.config);
@@ -6660,7 +6869,7 @@ var useComponentList = () => {
6660
6869
  if (category.visible === false) {
6661
6870
  return null;
6662
6871
  }
6663
- return /* @__PURE__ */ jsx29(
6872
+ return /* @__PURE__ */ jsx30(
6664
6873
  ComponentList,
6665
6874
  {
6666
6875
  id: categoryKey,
@@ -6668,7 +6877,7 @@ var useComponentList = () => {
6668
6877
  children: category.components.map((componentName, i) => {
6669
6878
  var _a2;
6670
6879
  const componentConf = config.components[componentName] || {};
6671
- return /* @__PURE__ */ jsx29(
6880
+ return /* @__PURE__ */ jsx30(
6672
6881
  ComponentList.Item,
6673
6882
  {
6674
6883
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -6688,7 +6897,7 @@ var useComponentList = () => {
6688
6897
  );
6689
6898
  if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
6690
6899
  _componentList.push(
6691
- /* @__PURE__ */ jsx29(
6900
+ /* @__PURE__ */ jsx30(
6692
6901
  ComponentList,
6693
6902
  {
6694
6903
  id: "other",
@@ -6696,7 +6905,7 @@ var useComponentList = () => {
6696
6905
  children: remainingComponents.map((componentName, i) => {
6697
6906
  var _a2;
6698
6907
  const componentConf = config.components[componentName] || {};
6699
- return /* @__PURE__ */ jsx29(
6908
+ return /* @__PURE__ */ jsx30(
6700
6909
  ComponentList.Item,
6701
6910
  {
6702
6911
  name: componentName,
@@ -6725,7 +6934,7 @@ init_react_import();
6725
6934
  var styles_module_default15 = { "Components": "_Components_3pbdy_1" };
6726
6935
 
6727
6936
  // components/Puck/components/Components/index.tsx
6728
- import { jsx as jsx30 } from "react/jsx-runtime";
6937
+ import { jsx as jsx31 } from "react/jsx-runtime";
6729
6938
  var getClassName21 = get_class_name_factory_default("Components", styles_module_default15);
6730
6939
  var Components = () => {
6731
6940
  const overrides = useAppStore((s) => s.overrides);
@@ -6738,16 +6947,16 @@ var Components = () => {
6738
6947
  }
6739
6948
  return overrides.components || overrides.drawer || "div";
6740
6949
  }, [overrides]);
6741
- return /* @__PURE__ */ jsx30("div", { className: getClassName21(), children: /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) }) });
6950
+ return /* @__PURE__ */ jsx31("div", { className: getClassName21(), children: /* @__PURE__ */ jsx31(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx31(ComponentList, { id: "all" }) }) });
6742
6951
  };
6743
6952
 
6744
6953
  // plugins/blocks/index.tsx
6745
- import { jsx as jsx31 } from "react/jsx-runtime";
6954
+ import { jsx as jsx32 } from "react/jsx-runtime";
6746
6955
  var blocksPlugin = () => ({
6747
6956
  name: "blocks",
6748
6957
  label: "Blocks",
6749
6958
  render: Components,
6750
- icon: /* @__PURE__ */ jsx31(Hammer, {})
6959
+ icon: /* @__PURE__ */ jsx32(Hammer, {})
6751
6960
  });
6752
6961
 
6753
6962
  // plugins/outline/index.tsx
@@ -6775,7 +6984,7 @@ var scrollIntoView = (el) => {
6775
6984
  };
6776
6985
 
6777
6986
  // components/LayerTree/index.tsx
6778
- import { useCallback as useCallback12, useContext as useContext10 } from "react";
6987
+ import { useCallback as useCallback13, useContext as useContext10 } from "react";
6779
6988
 
6780
6989
  // lib/on-scroll-end.ts
6781
6990
  init_react_import();
@@ -6797,8 +7006,8 @@ var onScrollEnd = (frame, cb) => {
6797
7006
  };
6798
7007
 
6799
7008
  // components/LayerTree/index.tsx
6800
- import { useShallow as useShallow5 } from "zustand/react/shallow";
6801
- import { Fragment as Fragment8, jsx as jsx32, jsxs as jsxs13 } from "react/jsx-runtime";
7009
+ import { useShallow as useShallow6 } from "zustand/react/shallow";
7010
+ import { Fragment as Fragment9, jsx as jsx33, jsxs as jsxs13 } from "react/jsx-runtime";
6802
7011
  var getClassName22 = get_class_name_factory_default("LayerTree", styles_module_default16);
6803
7012
  var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default16);
6804
7013
  var Layer = ({
@@ -6810,7 +7019,7 @@ var Layer = ({
6810
7019
  const config = useAppStore((s) => s.config);
6811
7020
  const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
6812
7021
  const dispatch = useAppStore((s) => s.dispatch);
6813
- const setItemSelector = useCallback12(
7022
+ const setItemSelector = useCallback13(
6814
7023
  (itemSelector2) => {
6815
7024
  dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
6816
7025
  },
@@ -6823,7 +7032,7 @@ var Layer = ({
6823
7032
  const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
6824
7033
  const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
6825
7034
  const zonesForItem = useAppStore(
6826
- useShallow5(
7035
+ useShallow6(
6827
7036
  (s) => Object.keys(s.state.indexes.zones).filter(
6828
7037
  (z) => z.split(":")[0] === itemId
6829
7038
  )
@@ -6855,7 +7064,7 @@ var Layer = ({
6855
7064
  childIsSelected
6856
7065
  }),
6857
7066
  children: [
6858
- /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs13(
7067
+ /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs13(
6859
7068
  "button",
6860
7069
  {
6861
7070
  type: "button",
@@ -6893,22 +7102,22 @@ var Layer = ({
6893
7102
  zoneStore.setState({ hoveringComponent: null });
6894
7103
  },
6895
7104
  children: [
6896
- containsZone && /* @__PURE__ */ jsx32(
7105
+ containsZone && /* @__PURE__ */ jsx33(
6897
7106
  "div",
6898
7107
  {
6899
7108
  className: getClassNameLayer("chevron"),
6900
7109
  title: isSelected ? "Collapse" : "Expand",
6901
- children: /* @__PURE__ */ jsx32(ChevronDown, { size: "12" })
7110
+ children: /* @__PURE__ */ jsx33(ChevronDown, { size: "12" })
6902
7111
  }
6903
7112
  ),
6904
7113
  /* @__PURE__ */ jsxs13("div", { className: getClassNameLayer("title"), children: [
6905
- /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ jsx32(Type, { size: "16" }) : /* @__PURE__ */ jsx32(LayoutGrid, { size: "16" }) }),
6906
- /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("name"), children: label })
7114
+ /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ jsx33(Type, { size: "16" }) : /* @__PURE__ */ jsx33(LayoutGrid, { size: "16" }) }),
7115
+ /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("name"), children: label })
6907
7116
  ] })
6908
7117
  ]
6909
7118
  }
6910
7119
  ) }),
6911
- containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx32(LayerTree, { zoneCompound: subzone }) }, subzone))
7120
+ containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx33(LayerTree, { zoneCompound: subzone }) }, subzone))
6912
7121
  ]
6913
7122
  }
6914
7123
  );
@@ -6927,22 +7136,22 @@ var LayerTree = ({
6927
7136
  return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
6928
7137
  });
6929
7138
  const contentIds = useAppStore(
6930
- useShallow5(
7139
+ useShallow6(
6931
7140
  (s) => {
6932
7141
  var _a, _b;
6933
7142
  return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
6934
7143
  }
6935
7144
  )
6936
7145
  );
6937
- return /* @__PURE__ */ jsxs13(Fragment8, { children: [
7146
+ return /* @__PURE__ */ jsxs13(Fragment9, { children: [
6938
7147
  label && /* @__PURE__ */ jsxs13("div", { className: getClassName22("zoneTitle"), children: [
6939
- /* @__PURE__ */ jsx32("div", { className: getClassName22("zoneIcon"), children: /* @__PURE__ */ jsx32(Layers, { size: "16" }) }),
7148
+ /* @__PURE__ */ jsx33("div", { className: getClassName22("zoneIcon"), children: /* @__PURE__ */ jsx33(Layers, { size: "16" }) }),
6940
7149
  label
6941
7150
  ] }),
6942
7151
  /* @__PURE__ */ jsxs13("ul", { className: getClassName22(), children: [
6943
- contentIds.length === 0 && /* @__PURE__ */ jsx32("div", { className: getClassName22("helper"), children: "No items" }),
7152
+ contentIds.length === 0 && /* @__PURE__ */ jsx33("div", { className: getClassName22("helper"), children: "No items" }),
6944
7153
  contentIds.map((itemId, i) => {
6945
- return /* @__PURE__ */ jsx32(
7154
+ return /* @__PURE__ */ jsx33(
6946
7155
  Layer,
6947
7156
  {
6948
7157
  index: i,
@@ -6968,22 +7177,22 @@ var findZonesForArea = (state, area) => {
6968
7177
  };
6969
7178
 
6970
7179
  // components/Puck/components/Outline/index.tsx
6971
- import { useShallow as useShallow6 } from "zustand/react/shallow";
7180
+ import { useShallow as useShallow7 } from "zustand/react/shallow";
6972
7181
 
6973
7182
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Outline/styles.module.css#css-module
6974
7183
  init_react_import();
6975
7184
  var styles_module_default17 = { "Outline": "_Outline_cvjlj_1" };
6976
7185
 
6977
7186
  // components/Puck/components/Outline/index.tsx
6978
- import { jsx as jsx33 } from "react/jsx-runtime";
7187
+ import { jsx as jsx34 } from "react/jsx-runtime";
6979
7188
  var getClassName23 = get_class_name_factory_default("Outline", styles_module_default17);
6980
7189
  var Outline = () => {
6981
7190
  const outlineOverride = useAppStore((s) => s.overrides.outline);
6982
7191
  const rootZones = useAppStore(
6983
- useShallow6((s) => findZonesForArea(s.state, "root"))
7192
+ useShallow7((s) => findZonesForArea(s.state, "root"))
6984
7193
  );
6985
7194
  const Wrapper = useMemo11(() => outlineOverride || "div", [outlineOverride]);
6986
- return /* @__PURE__ */ jsx33("div", { className: getClassName23(), children: /* @__PURE__ */ jsx33(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx33(
7195
+ return /* @__PURE__ */ jsx34("div", { className: getClassName23(), children: /* @__PURE__ */ jsx34(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx34(
6987
7196
  LayerTree,
6988
7197
  {
6989
7198
  label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
@@ -6994,12 +7203,12 @@ var Outline = () => {
6994
7203
  };
6995
7204
 
6996
7205
  // plugins/outline/index.tsx
6997
- import { jsx as jsx34 } from "react/jsx-runtime";
7206
+ import { jsx as jsx35 } from "react/jsx-runtime";
6998
7207
  var outlinePlugin = () => ({
6999
7208
  name: "outline",
7000
7209
  label: "Outline",
7001
7210
  render: Outline,
7002
- icon: /* @__PURE__ */ jsx34(Layers, {})
7211
+ icon: /* @__PURE__ */ jsx35(Layers, {})
7003
7212
  });
7004
7213
 
7005
7214
  // plugins/fields/index.tsx
@@ -7057,7 +7266,7 @@ var useBreadcrumbs = (renderCount) => {
7057
7266
  };
7058
7267
 
7059
7268
  // components/Breadcrumbs/index.tsx
7060
- import { jsx as jsx35, jsxs as jsxs14 } from "react/jsx-runtime";
7269
+ import { jsx as jsx36, jsxs as jsxs14 } from "react/jsx-runtime";
7061
7270
  var getClassName24 = get_class_name_factory_default("Breadcrumbs", styles_module_default18);
7062
7271
  var Breadcrumbs = ({
7063
7272
  children,
@@ -7067,7 +7276,7 @@ var Breadcrumbs = ({
7067
7276
  const breadcrumbs = useBreadcrumbs(numParents);
7068
7277
  return /* @__PURE__ */ jsxs14("div", { className: getClassName24(), children: [
7069
7278
  breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs14("div", { className: getClassName24("breadcrumb"), children: [
7070
- /* @__PURE__ */ jsx35(
7279
+ /* @__PURE__ */ jsx36(
7071
7280
  "button",
7072
7281
  {
7073
7282
  type: "button",
@@ -7076,7 +7285,7 @@ var Breadcrumbs = ({
7076
7285
  children: breadcrumb.label
7077
7286
  }
7078
7287
  ),
7079
- /* @__PURE__ */ jsx35(ChevronRight, { size: 16 })
7288
+ /* @__PURE__ */ jsx36(ChevronRight, { size: 16 })
7080
7289
  ] }, i)),
7081
7290
  children
7082
7291
  ] });
@@ -7090,98 +7299,92 @@ init_react_import();
7090
7299
  var styles_module_default19 = { "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" };
7091
7300
 
7092
7301
  // components/Puck/components/Fields/index.tsx
7093
- import { memo as memo3, useCallback as useCallback13, useMemo as useMemo13 } from "react";
7094
- import { useShallow as useShallow7 } from "zustand/react/shallow";
7095
- import { Fragment as Fragment9, jsx as jsx36, jsxs as jsxs15 } from "react/jsx-runtime";
7302
+ import { memo as memo5, useCallback as useCallback14, useMemo as useMemo13 } from "react";
7303
+ import { useShallow as useShallow8 } from "zustand/react/shallow";
7304
+ import { Fragment as Fragment10, jsx as jsx37, jsxs as jsxs15 } from "react/jsx-runtime";
7096
7305
  var getClassName25 = get_class_name_factory_default("PuckFields", styles_module_default19);
7097
7306
  var DefaultFields = ({
7098
7307
  children
7099
7308
  }) => {
7100
- return /* @__PURE__ */ jsx36(Fragment9, { children });
7309
+ return /* @__PURE__ */ jsx37(Fragment10, { children });
7101
7310
  };
7102
- var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
7103
- let currentProps;
7311
+ var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(null, null, function* () {
7104
7312
  const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
7105
7313
  const { data, ui } = state;
7106
7314
  const { itemSelector } = ui;
7107
7315
  const rootProps = data.root.props || data.root;
7108
- if (selectedItem) {
7109
- currentProps = selectedItem.props;
7110
- } else {
7111
- currentProps = rootProps;
7112
- }
7113
- const newProps = __spreadProps(__spreadValues({}, currentProps), {
7114
- [fieldName]: value
7115
- });
7316
+ const currentProps = selectedItem ? selectedItem.props : rootProps;
7317
+ const newProps = __spreadProps(__spreadValues({}, currentProps), { [fieldName]: value });
7116
7318
  if (selectedItem && itemSelector) {
7319
+ const resolved = yield resolveComponentData2(
7320
+ __spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
7321
+ "replace"
7322
+ );
7323
+ const latestSelector = getSelectorForId(
7324
+ appStore.getState().state,
7325
+ selectedItem.props.id
7326
+ );
7327
+ if (!latestSelector) return;
7117
7328
  dispatch({
7118
7329
  type: "replace",
7119
- destinationIndex: itemSelector.index,
7120
- destinationZone: itemSelector.zone || rootDroppableId,
7121
- data: (yield resolveComponentData2(
7122
- __spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
7330
+ destinationIndex: latestSelector.index,
7331
+ destinationZone: latestSelector.zone || rootDroppableId,
7332
+ data: resolved.node,
7333
+ ui: updatedUi
7334
+ });
7335
+ return;
7336
+ }
7337
+ if (data.root.props) {
7338
+ dispatch({
7339
+ type: "replaceRoot",
7340
+ root: (yield resolveComponentData2(
7341
+ __spreadProps(__spreadValues({}, data.root), { props: newProps }),
7123
7342
  "replace"
7124
7343
  )).node,
7125
- ui: updatedUi
7344
+ ui: __spreadValues(__spreadValues({}, ui), updatedUi),
7345
+ recordHistory: true
7126
7346
  });
7127
- } else {
7128
- if (data.root.props) {
7129
- dispatch({
7130
- type: "replaceRoot",
7131
- root: (yield resolveComponentData2(
7132
- __spreadProps(__spreadValues({}, data.root), { props: newProps }),
7133
- "replace"
7134
- )).node,
7135
- ui: __spreadValues(__spreadValues({}, ui), updatedUi),
7136
- recordHistory: true
7137
- });
7138
- } else {
7139
- dispatch({
7140
- type: "setData",
7141
- data: { root: newProps }
7142
- });
7143
- }
7347
+ return;
7144
7348
  }
7349
+ dispatch({
7350
+ type: "setData",
7351
+ data: { root: newProps }
7352
+ });
7145
7353
  });
7146
7354
  var FieldsChild = ({ fieldName }) => {
7147
7355
  const field = useAppStore((s) => s.fields.fields[fieldName]);
7148
7356
  const isReadOnly = useAppStore(
7149
7357
  (s) => ((s.selectedItem ? s.selectedItem.readOnly : s.state.data.root.readOnly) || {})[fieldName]
7150
7358
  );
7151
- const value = useAppStore((s) => {
7152
- const rootProps = s.state.data.root.props || s.state.data.root;
7153
- return s.selectedItem ? s.selectedItem.props[fieldName] : rootProps[fieldName];
7154
- });
7155
7359
  const id = useAppStore((s) => {
7156
7360
  if (!field) return null;
7157
7361
  return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
7158
7362
  });
7159
7363
  const permissions = useAppStore(
7160
- useShallow7((s) => {
7364
+ useShallow8((s) => {
7161
7365
  const { selectedItem, permissions: permissions2 } = s;
7162
7366
  return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
7163
7367
  })
7164
7368
  );
7165
7369
  const appStore = useAppStoreApi();
7166
- const onChange = useCallback13(createOnChange(fieldName, appStore), [
7370
+ const onChange = useCallback14(createOnChange(fieldName, appStore), [
7167
7371
  fieldName
7168
7372
  ]);
7169
7373
  const { visible = true } = field != null ? field : {};
7170
7374
  if (!field || !id || !visible) return null;
7171
7375
  if (field.type === "slot") return null;
7172
- return /* @__PURE__ */ jsx36("div", { className: getClassName25("field"), children: /* @__PURE__ */ jsx36(
7376
+ return /* @__PURE__ */ jsx37("div", { className: getClassName25("field"), children: /* @__PURE__ */ jsx37(
7173
7377
  AutoFieldPrivate,
7174
7378
  {
7175
7379
  field,
7176
7380
  name: fieldName,
7177
7381
  id,
7178
7382
  readOnly: !permissions.edit || isReadOnly,
7179
- value,
7180
7383
  onChange
7181
7384
  }
7182
7385
  ) }, id);
7183
7386
  };
7184
- var FieldsChildMemo = memo3(FieldsChild);
7387
+ var FieldsChildMemo = memo5(FieldsChild);
7185
7388
  var FieldsInternal = ({ wrapFields = true }) => {
7186
7389
  const overrides = useAppStore((s) => s.overrides);
7187
7390
  const componentResolving = useAppStore((s) => {
@@ -7189,7 +7392,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
7189
7392
  const loadingCount = s.selectedItem ? (_a = s.componentState[s.selectedItem.props.id]) == null ? void 0 : _a.loadingCount : (_b = s.componentState["root"]) == null ? void 0 : _b.loadingCount;
7190
7393
  return (loadingCount != null ? loadingCount : 0) > 0;
7191
7394
  });
7192
- const itemSelector = useAppStore(useShallow7((s) => s.state.ui.itemSelector));
7395
+ const itemSelector = useAppStore(useShallow8((s) => s.state.ui.itemSelector));
7193
7396
  const id = useAppStore((s) => {
7194
7397
  var _a;
7195
7398
  return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
@@ -7198,7 +7401,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
7198
7401
  useRegisterFieldsSlice(appStore, id);
7199
7402
  const fieldsLoading = useAppStore((s) => s.fields.loading);
7200
7403
  const fieldNames = useAppStore(
7201
- useShallow7((s) => {
7404
+ useShallow8((s) => {
7202
7405
  if (s.fields.id === id) {
7203
7406
  return Object.keys(s.fields.fields);
7204
7407
  }
@@ -7215,20 +7418,20 @@ var FieldsInternal = ({ wrapFields = true }) => {
7215
7418
  e.preventDefault();
7216
7419
  },
7217
7420
  children: [
7218
- /* @__PURE__ */ jsx36(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx36(FieldsChildMemo, { fieldName }, fieldName)) }),
7219
- isLoading && /* @__PURE__ */ jsx36("div", { className: getClassName25("loadingOverlay"), children: /* @__PURE__ */ jsx36("div", { className: getClassName25("loadingOverlayInner"), children: /* @__PURE__ */ jsx36(Loader, { size: 16 }) }) })
7421
+ /* @__PURE__ */ jsx37(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx37(FieldsChildMemo, { fieldName }, fieldName)) }),
7422
+ isLoading && /* @__PURE__ */ jsx37("div", { className: getClassName25("loadingOverlay"), children: /* @__PURE__ */ jsx37("div", { className: getClassName25("loadingOverlayInner"), children: /* @__PURE__ */ jsx37(Loader, { size: 16 }) }) })
7220
7423
  ]
7221
7424
  }
7222
7425
  );
7223
7426
  };
7224
- var Fields = memo3(FieldsInternal);
7427
+ var Fields = memo5(FieldsInternal);
7225
7428
 
7226
7429
  // css-module:/home/runner/work/puck/puck/packages/core/plugins/fields/styles.module.css#css-module
7227
7430
  init_react_import();
7228
7431
  var styles_module_default20 = { "FieldsPlugin": "_FieldsPlugin_nd930_1", "FieldsPlugin-header": "_FieldsPlugin-header_nd930_7" };
7229
7432
 
7230
7433
  // plugins/fields/index.tsx
7231
- import { jsx as jsx37, jsxs as jsxs16 } from "react/jsx-runtime";
7434
+ import { jsx as jsx38, jsxs as jsxs16 } from "react/jsx-runtime";
7232
7435
  var getClassName26 = get_class_name_factory_default("FieldsPlugin", styles_module_default20);
7233
7436
  var CurrentTitle = () => {
7234
7437
  const label = useAppStore((s) => {
@@ -7242,10 +7445,10 @@ var fieldsPlugin = ({ mobileOnly = true } = {}) => ({
7242
7445
  name: "fields",
7243
7446
  label: "Fields",
7244
7447
  render: () => /* @__PURE__ */ jsxs16("div", { className: getClassName26(), children: [
7245
- /* @__PURE__ */ jsx37("div", { className: getClassName26("header"), children: /* @__PURE__ */ jsx37(Breadcrumbs, { numParents: 2, children: /* @__PURE__ */ jsx37(CurrentTitle, {}) }) }),
7246
- /* @__PURE__ */ jsx37(Fields, {})
7448
+ /* @__PURE__ */ jsx38("div", { className: getClassName26("header"), children: /* @__PURE__ */ jsx38(Breadcrumbs, { numParents: 2, children: /* @__PURE__ */ jsx38(CurrentTitle, {}) }) }),
7449
+ /* @__PURE__ */ jsx38(Fields, {})
7247
7450
  ] }),
7248
- icon: /* @__PURE__ */ jsx37(RectangleEllipsis, {}),
7451
+ icon: /* @__PURE__ */ jsx38(RectangleEllipsis, {}),
7249
7452
  mobileOnly
7250
7453
  });
7251
7454
 
@@ -7253,7 +7456,7 @@ var fieldsPlugin = ({ mobileOnly = true } = {}) => ({
7253
7456
  init_react_import();
7254
7457
  import {
7255
7458
  createContext as createContext8,
7256
- useCallback as useCallback21,
7459
+ useCallback as useCallback22,
7257
7460
  useContext as useContext13,
7258
7461
  useEffect as useEffect30,
7259
7462
  useMemo as useMemo21,
@@ -7263,7 +7466,7 @@ import {
7263
7466
 
7264
7467
  // components/Puck/components/Preview/index.tsx
7265
7468
  init_react_import();
7266
- import { useCallback as useCallback14, useEffect as useEffect23, useRef as useRef7, useMemo as useMemo14 } from "react";
7469
+ import { useCallback as useCallback15, useEffect as useEffect23, useRef as useRef7, useMemo as useMemo14 } from "react";
7267
7470
 
7268
7471
  // components/AutoFrame/index.tsx
7269
7472
  init_react_import();
@@ -7275,7 +7478,7 @@ import {
7275
7478
  } from "react";
7276
7479
  import hash from "object-hash";
7277
7480
  import { createPortal as createPortal3 } from "react-dom";
7278
- import { Fragment as Fragment10, jsx as jsx38 } from "react/jsx-runtime";
7481
+ import { Fragment as Fragment11, jsx as jsx39 } from "react/jsx-runtime";
7279
7482
  var styleSelector = 'style, link[rel="stylesheet"]';
7280
7483
  var collectStyles = (doc) => {
7281
7484
  const collected = [];
@@ -7333,7 +7536,7 @@ var CopyHostStyles = ({
7333
7536
  let elements = [];
7334
7537
  const hashes = {};
7335
7538
  const lookupEl = (el) => elements.findIndex((elementMap) => elementMap.original === el);
7336
- const mirrorEl = (el, inlineStyles = false) => __async(void 0, null, function* () {
7539
+ const mirrorEl = (el, inlineStyles = false) => __async(null, null, function* () {
7337
7540
  let mirror;
7338
7541
  if (el.nodeName === "LINK" && inlineStyles) {
7339
7542
  mirror = document.createElement("style");
@@ -7365,7 +7568,7 @@ var CopyHostStyles = ({
7365
7568
  }
7366
7569
  return mirror;
7367
7570
  });
7368
- const addEl = (el) => __async(void 0, null, function* () {
7571
+ const addEl = (el) => __async(null, null, function* () {
7369
7572
  const index = lookupEl(el);
7370
7573
  if (index > -1) {
7371
7574
  if (debug)
@@ -7438,7 +7641,7 @@ var CopyHostStyles = ({
7438
7641
  const parentBody = parentDocument.getElementsByTagName("body")[0];
7439
7642
  syncAttributes(parentBody, doc.body);
7440
7643
  Promise.all(
7441
- collectedStyles.map((styleNode, i) => __async(void 0, null, function* () {
7644
+ collectedStyles.map((styleNode, i) => __async(null, null, function* () {
7442
7645
  if (styleNode.nodeName === "LINK") {
7443
7646
  const linkHref = styleNode.href;
7444
7647
  if (hrefs.indexOf(linkHref) > -1) {
@@ -7482,7 +7685,7 @@ var CopyHostStyles = ({
7482
7685
  observer.disconnect();
7483
7686
  };
7484
7687
  }, []);
7485
- return /* @__PURE__ */ jsx38(Fragment10, { children });
7688
+ return /* @__PURE__ */ jsx39(Fragment11, { children });
7486
7689
  };
7487
7690
  var autoFrameContext = createContext6({});
7488
7691
  var useFrame = () => useContext11(autoFrameContext);
@@ -7529,7 +7732,7 @@ function AutoFrame(_a) {
7529
7732
  }
7530
7733
  }
7531
7734
  }, [frameRef, loaded, stylesLoaded]);
7532
- return /* @__PURE__ */ jsx38(
7735
+ return /* @__PURE__ */ jsx39(
7533
7736
  "iframe",
7534
7737
  __spreadProps(__spreadValues({}, props), {
7535
7738
  className,
@@ -7539,7 +7742,7 @@ function AutoFrame(_a) {
7539
7742
  onLoad: () => {
7540
7743
  setLoaded(true);
7541
7744
  },
7542
- children: /* @__PURE__ */ jsx38(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx38(
7745
+ children: /* @__PURE__ */ jsx39(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx39(
7543
7746
  CopyHostStyles,
7544
7747
  {
7545
7748
  debug,
@@ -7558,7 +7761,7 @@ init_react_import();
7558
7761
  var styles_module_default21 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
7559
7762
 
7560
7763
  // components/Puck/components/Preview/index.tsx
7561
- import { Fragment as Fragment11, jsx as jsx39 } from "react/jsx-runtime";
7764
+ import { Fragment as Fragment12, jsx as jsx40 } from "react/jsx-runtime";
7562
7765
  var getClassName27 = get_class_name_factory_default("PuckPreview", styles_module_default21);
7563
7766
  var useBubbleIframeEvents = (ref) => {
7564
7767
  const status = useAppStore((s) => s.status);
@@ -7611,7 +7814,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
7611
7814
  const renderData = useAppStore(
7612
7815
  (s) => s.state.ui.previewMode === "edit" ? null : s.state.data
7613
7816
  );
7614
- const Page = useCallback14(
7817
+ const Page = useCallback15(
7615
7818
  (pageProps) => {
7616
7819
  var _a, _b;
7617
7820
  const propsWithSlots = useSlots(
@@ -7621,7 +7824,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
7621
7824
  );
7622
7825
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
7623
7826
  id: "puck-root"
7624
- }, propsWithSlots)) : /* @__PURE__ */ jsx39(Fragment11, { children: propsWithSlots.children });
7827
+ }, propsWithSlots)) : /* @__PURE__ */ jsx40(Fragment12, { children: propsWithSlots.children });
7625
7828
  },
7626
7829
  [config]
7627
7830
  );
@@ -7629,7 +7832,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
7629
7832
  const rootProps = root.props || root;
7630
7833
  const ref = useRef7(null);
7631
7834
  useBubbleIframeEvents(ref);
7632
- const inner = !renderData ? /* @__PURE__ */ jsx39(
7835
+ const inner = !renderData ? /* @__PURE__ */ jsx40(
7633
7836
  Page,
7634
7837
  __spreadProps(__spreadValues({}, rootProps), {
7635
7838
  puck: {
@@ -7639,15 +7842,15 @@ var Preview2 = ({ id = "puck-preview" }) => {
7639
7842
  metadata
7640
7843
  },
7641
7844
  editMode: true,
7642
- children: /* @__PURE__ */ jsx39(DropZonePure, { zone: rootDroppableId })
7845
+ children: /* @__PURE__ */ jsx40(DropZonePure, { zone: rootDroppableId })
7643
7846
  })
7644
- ) : /* @__PURE__ */ jsx39(Render, { data: renderData, config, metadata });
7847
+ ) : /* @__PURE__ */ jsx40(Render, { data: renderData, config, metadata });
7645
7848
  useEffect23(() => {
7646
7849
  if (!iframe.enabled) {
7647
7850
  setStatus("READY");
7648
7851
  }
7649
7852
  }, [iframe.enabled]);
7650
- return /* @__PURE__ */ jsx39(
7853
+ return /* @__PURE__ */ jsx40(
7651
7854
  "div",
7652
7855
  {
7653
7856
  className: getClassName27(),
@@ -7659,7 +7862,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
7659
7862
  dispatch({ type: "setUi", ui: { itemSelector: null } });
7660
7863
  }
7661
7864
  },
7662
- children: iframe.enabled ? /* @__PURE__ */ jsx39(
7865
+ children: iframe.enabled ? /* @__PURE__ */ jsx40(
7663
7866
  AutoFrame_default,
7664
7867
  {
7665
7868
  id: "preview-frame",
@@ -7672,14 +7875,14 @@ var Preview2 = ({ id = "puck-preview" }) => {
7672
7875
  setStatus("MOUNTED");
7673
7876
  },
7674
7877
  frameRef: ref,
7675
- children: /* @__PURE__ */ jsx39(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7878
+ children: /* @__PURE__ */ jsx40(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
7676
7879
  if (Frame) {
7677
- return /* @__PURE__ */ jsx39(Frame, { document: document2, children: inner });
7880
+ return /* @__PURE__ */ jsx40(Frame, { document: document2, children: inner });
7678
7881
  }
7679
7882
  return inner;
7680
7883
  } })
7681
7884
  }
7682
- ) : /* @__PURE__ */ jsx39(
7885
+ ) : /* @__PURE__ */ jsx40(
7683
7886
  "div",
7684
7887
  {
7685
7888
  id: "preview-frame",
@@ -7743,7 +7946,7 @@ var useLoadedOverrides = ({
7743
7946
  };
7744
7947
 
7745
7948
  // components/Puck/index.tsx
7746
- var import_fast_deep_equal = __toESM(require_fast_deep_equal());
7949
+ var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
7747
7950
 
7748
7951
  // components/Puck/components/Layout/index.tsx
7749
7952
  init_react_import();
@@ -7751,7 +7954,7 @@ import { useEffect as useEffect29, useMemo as useMemo20, useState as useState25
7751
7954
 
7752
7955
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Layout/styles.module.css#css-module
7753
7956
  init_react_import();
7754
- var styles_module_default22 = { "Puck": "_Puck_hv23j_19", "Puck-portal": "_Puck-portal_hv23j_31", "PuckLayout": "_PuckLayout_hv23j_36", "PuckLayout-inner": "_PuckLayout-inner_hv23j_40", "PuckLayout--mounted": "_PuckLayout--mounted_hv23j_73", "PuckLayout--mobilePanelHeightToggle": "_PuckLayout--mobilePanelHeightToggle_hv23j_77", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_hv23j_77", "PuckLayout--isExpanded": "_PuckLayout--isExpanded_hv23j_83", "PuckLayout--mobilePanelHeightMinContent": "_PuckLayout--mobilePanelHeightMinContent_hv23j_101", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_hv23j_128", "PuckLayout-mounted": "_PuckLayout-mounted_hv23j_147", "PuckLayout-nav": "_PuckLayout-nav_hv23j_188", "PuckLayout-header": "_PuckLayout-header_hv23j_204", "PuckPluginTab": "_PuckPluginTab_hv23j_218", "PuckPluginTab--visible": "_PuckPluginTab--visible_hv23j_224", "PuckPluginTab-body": "_PuckPluginTab-body_hv23j_229" };
7957
+ var styles_module_default22 = { "Puck": "_Puck_lqzmv_19", "Puck-portal": "_Puck-portal_lqzmv_32", "PuckLayout": "_PuckLayout_lqzmv_37", "PuckLayout-inner": "_PuckLayout-inner_lqzmv_41", "PuckLayout--mounted": "_PuckLayout--mounted_lqzmv_74", "PuckLayout--mobilePanelHeightToggle": "_PuckLayout--mobilePanelHeightToggle_lqzmv_78", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_lqzmv_78", "PuckLayout--isExpanded": "_PuckLayout--isExpanded_lqzmv_84", "PuckLayout--mobilePanelHeightMinContent": "_PuckLayout--mobilePanelHeightMinContent_lqzmv_102", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_lqzmv_129", "PuckLayout-mounted": "_PuckLayout-mounted_lqzmv_148", "PuckLayout-nav": "_PuckLayout-nav_lqzmv_189", "PuckLayout-header": "_PuckLayout-header_lqzmv_205", "PuckPluginTab": "_PuckPluginTab_lqzmv_219", "PuckPluginTab--visible": "_PuckPluginTab--visible_lqzmv_225", "PuckPluginTab-body": "_PuckPluginTab-body_lqzmv_230" };
7755
7958
 
7756
7959
  // lib/use-inject-css.ts
7757
7960
  init_react_import();
@@ -7782,15 +7985,15 @@ var useInjectGlobalCss = (iframeEnabled) => {
7782
7985
 
7783
7986
  // components/DefaultOverride/index.tsx
7784
7987
  init_react_import();
7785
- import { Fragment as Fragment12, jsx as jsx40 } from "react/jsx-runtime";
7786
- var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx40(Fragment12, { children });
7988
+ import { Fragment as Fragment13, jsx as jsx41 } from "react/jsx-runtime";
7989
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx41(Fragment13, { children });
7787
7990
 
7788
7991
  // lib/use-preview-mode-hotkeys.ts
7789
7992
  init_react_import();
7790
- import { useCallback as useCallback15 } from "react";
7993
+ import { useCallback as useCallback16 } from "react";
7791
7994
  var usePreviewModeHotkeys = () => {
7792
7995
  const appStore = useAppStoreApi();
7793
- const toggleInteractive = useCallback15(() => {
7996
+ const toggleInteractive = useCallback16(() => {
7794
7997
  const dispatch = appStore.getState().dispatch;
7795
7998
  dispatch({
7796
7999
  type: "setUi",
@@ -7805,7 +8008,7 @@ var usePreviewModeHotkeys = () => {
7805
8008
 
7806
8009
  // components/Puck/components/Header/index.tsx
7807
8010
  init_react_import();
7808
- import { memo as memo4, useCallback as useCallback16, useMemo as useMemo16, useState as useState21 } from "react";
8011
+ import { memo as memo6, useCallback as useCallback17, useMemo as useMemo16, useState as useState21 } from "react";
7809
8012
 
7810
8013
  // components/MenuBar/index.tsx
7811
8014
  init_react_import();
@@ -7815,7 +8018,7 @@ init_react_import();
7815
8018
  var styles_module_default23 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
7816
8019
 
7817
8020
  // components/MenuBar/index.tsx
7818
- import { Fragment as Fragment13, jsx as jsx41, jsxs as jsxs17 } from "react/jsx-runtime";
8021
+ import { Fragment as Fragment14, jsx as jsx42, jsxs as jsxs17 } from "react/jsx-runtime";
7819
8022
  var getClassName28 = get_class_name_factory_default("MenuBar", styles_module_default23);
7820
8023
  function MenuBar({
7821
8024
  menuOpen = false,
@@ -7826,7 +8029,7 @@ function MenuBar({
7826
8029
  const forward = useAppStore((s) => s.history.forward);
7827
8030
  const hasFuture = useAppStore((s) => s.history.hasFuture());
7828
8031
  const hasPast = useAppStore((s) => s.history.hasPast());
7829
- return /* @__PURE__ */ jsx41(
8032
+ return /* @__PURE__ */ jsx42(
7830
8033
  "div",
7831
8034
  {
7832
8035
  className: getClassName28({ menuOpen }),
@@ -7842,28 +8045,28 @@ function MenuBar({
7842
8045
  },
7843
8046
  children: /* @__PURE__ */ jsxs17("div", { className: getClassName28("inner"), children: [
7844
8047
  /* @__PURE__ */ jsxs17("div", { className: getClassName28("history"), children: [
7845
- /* @__PURE__ */ jsx41(
8048
+ /* @__PURE__ */ jsx42(
7846
8049
  IconButton,
7847
8050
  {
7848
8051
  type: "button",
7849
8052
  title: "undo",
7850
8053
  disabled: !hasPast,
7851
8054
  onClick: back,
7852
- children: /* @__PURE__ */ jsx41(Undo2, { size: 21 })
8055
+ children: /* @__PURE__ */ jsx42(Undo2, { size: 21 })
7853
8056
  }
7854
8057
  ),
7855
- /* @__PURE__ */ jsx41(
8058
+ /* @__PURE__ */ jsx42(
7856
8059
  IconButton,
7857
8060
  {
7858
8061
  type: "button",
7859
8062
  title: "redo",
7860
8063
  disabled: !hasFuture,
7861
8064
  onClick: forward,
7862
- children: /* @__PURE__ */ jsx41(Redo2, { size: 21 })
8065
+ children: /* @__PURE__ */ jsx42(Redo2, { size: 21 })
7863
8066
  }
7864
8067
  )
7865
8068
  ] }),
7866
- /* @__PURE__ */ jsx41(Fragment13, { children: renderHeaderActions && renderHeaderActions() })
8069
+ /* @__PURE__ */ jsx42(Fragment14, { children: renderHeaderActions && renderHeaderActions() })
7867
8070
  ] })
7868
8071
  }
7869
8072
  );
@@ -7874,7 +8077,7 @@ init_react_import();
7874
8077
  var styles_module_default24 = { "PuckHeader": "_PuckHeader_1bhmt_1", "PuckHeader-inner": "_PuckHeader-inner_1bhmt_16", "PuckHeader-toggle": "_PuckHeader-toggle_1bhmt_32", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_1bhmt_39", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_1bhmt_39", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_1bhmt_40", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_1bhmt_40", "PuckHeader-title": "_PuckHeader-title_1bhmt_56", "PuckHeader-path": "_PuckHeader-path_1bhmt_60", "PuckHeader-tools": "_PuckHeader-tools_1bhmt_67", "PuckHeader-menuButton": "_PuckHeader-menuButton_1bhmt_73", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_1bhmt_78" };
7875
8078
 
7876
8079
  // components/Puck/components/Header/index.tsx
7877
- import { Fragment as Fragment14, jsx as jsx42, jsxs as jsxs18 } from "react/jsx-runtime";
8080
+ import { Fragment as Fragment15, jsx as jsx43, jsxs as jsxs18 } from "react/jsx-runtime";
7878
8081
  var getClassName29 = get_class_name_factory_default("PuckHeader", styles_module_default24);
7879
8082
  var HeaderInner = () => {
7880
8083
  const {
@@ -7896,7 +8099,7 @@ var HeaderInner = () => {
7896
8099
  var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
7897
8100
  const Comp = renderHeader;
7898
8101
  const appState = useAppStore((s) => s.state);
7899
- return /* @__PURE__ */ jsx42(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
8102
+ return /* @__PURE__ */ jsx43(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7900
8103
  };
7901
8104
  return RenderHeader;
7902
8105
  }
@@ -7910,7 +8113,7 @@ var HeaderInner = () => {
7910
8113
  const RenderHeader = (props) => {
7911
8114
  const Comp = renderHeaderActions;
7912
8115
  const appState = useAppStore((s) => s.state);
7913
- return /* @__PURE__ */ jsx42(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
8116
+ return /* @__PURE__ */ jsx43(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7914
8117
  };
7915
8118
  return RenderHeader;
7916
8119
  }
@@ -7932,7 +8135,7 @@ var HeaderInner = () => {
7932
8135
  const rightSideBarVisible = useAppStore(
7933
8136
  (s) => s.state.ui.rightSideBarVisible
7934
8137
  );
7935
- const toggleSidebars = useCallback16(
8138
+ const toggleSidebars = useCallback17(
7936
8139
  (sidebar) => {
7937
8140
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7938
8141
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -7946,27 +8149,27 @@ var HeaderInner = () => {
7946
8149
  },
7947
8150
  [dispatch, leftSideBarVisible, rightSideBarVisible]
7948
8151
  );
7949
- return /* @__PURE__ */ jsx42(
8152
+ return /* @__PURE__ */ jsx43(
7950
8153
  CustomHeader,
7951
8154
  {
7952
- actions: /* @__PURE__ */ jsx42(Fragment14, { children: /* @__PURE__ */ jsx42(CustomHeaderActions, { children: /* @__PURE__ */ jsx42(
8155
+ actions: /* @__PURE__ */ jsx43(Fragment15, { children: /* @__PURE__ */ jsx43(CustomHeaderActions, { children: /* @__PURE__ */ jsx43(
7953
8156
  Button,
7954
8157
  {
7955
8158
  onClick: () => {
7956
8159
  const data = appStore.getState().state.data;
7957
8160
  onPublish && onPublish(data);
7958
8161
  },
7959
- icon: /* @__PURE__ */ jsx42(Globe, { size: "14px" }),
8162
+ icon: /* @__PURE__ */ jsx43(Globe, { size: "14px" }),
7960
8163
  children: "Publish"
7961
8164
  }
7962
8165
  ) }) }),
7963
- children: /* @__PURE__ */ jsx42(
8166
+ children: /* @__PURE__ */ jsx43(
7964
8167
  "header",
7965
8168
  {
7966
8169
  className: getClassName29({ leftSideBarVisible, rightSideBarVisible }),
7967
8170
  children: /* @__PURE__ */ jsxs18("div", { className: getClassName29("inner"), children: [
7968
8171
  /* @__PURE__ */ jsxs18("div", { className: getClassName29("toggle"), children: [
7969
- /* @__PURE__ */ jsx42("div", { className: getClassName29("leftSideBarToggle"), children: /* @__PURE__ */ jsx42(
8172
+ /* @__PURE__ */ jsx43("div", { className: getClassName29("leftSideBarToggle"), children: /* @__PURE__ */ jsx43(
7970
8173
  IconButton,
7971
8174
  {
7972
8175
  type: "button",
@@ -7974,10 +8177,10 @@ var HeaderInner = () => {
7974
8177
  toggleSidebars("left");
7975
8178
  },
7976
8179
  title: "Toggle left sidebar",
7977
- children: /* @__PURE__ */ jsx42(PanelLeft, { focusable: "false" })
8180
+ children: /* @__PURE__ */ jsx43(PanelLeft, { focusable: "false" })
7978
8181
  }
7979
8182
  ) }),
7980
- /* @__PURE__ */ jsx42("div", { className: getClassName29("rightSideBarToggle"), children: /* @__PURE__ */ jsx42(
8183
+ /* @__PURE__ */ jsx43("div", { className: getClassName29("rightSideBarToggle"), children: /* @__PURE__ */ jsx43(
7981
8184
  IconButton,
7982
8185
  {
7983
8186
  type: "button",
@@ -7985,19 +8188,19 @@ var HeaderInner = () => {
7985
8188
  toggleSidebars("right");
7986
8189
  },
7987
8190
  title: "Toggle right sidebar",
7988
- children: /* @__PURE__ */ jsx42(PanelRight, { focusable: "false" })
8191
+ children: /* @__PURE__ */ jsx43(PanelRight, { focusable: "false" })
7989
8192
  }
7990
8193
  ) })
7991
8194
  ] }),
7992
- /* @__PURE__ */ jsx42("div", { className: getClassName29("title"), children: /* @__PURE__ */ jsxs18(Heading, { rank: "2", size: "xs", children: [
8195
+ /* @__PURE__ */ jsx43("div", { className: getClassName29("title"), children: /* @__PURE__ */ jsxs18(Heading, { rank: "2", size: "xs", children: [
7993
8196
  headerTitle || rootTitle || "Page",
7994
- headerPath && /* @__PURE__ */ jsxs18(Fragment14, { children: [
8197
+ headerPath && /* @__PURE__ */ jsxs18(Fragment15, { children: [
7995
8198
  " ",
7996
- /* @__PURE__ */ jsx42("code", { className: getClassName29("path"), children: headerPath })
8199
+ /* @__PURE__ */ jsx43("code", { className: getClassName29("path"), children: headerPath })
7997
8200
  ] })
7998
8201
  ] }) }),
7999
8202
  /* @__PURE__ */ jsxs18("div", { className: getClassName29("tools"), children: [
8000
- /* @__PURE__ */ jsx42("div", { className: getClassName29("menuButton"), children: /* @__PURE__ */ jsx42(
8203
+ /* @__PURE__ */ jsx43("div", { className: getClassName29("menuButton"), children: /* @__PURE__ */ jsx43(
8001
8204
  IconButton,
8002
8205
  {
8003
8206
  type: "button",
@@ -8005,23 +8208,23 @@ var HeaderInner = () => {
8005
8208
  return setMenuOpen(!menuOpen);
8006
8209
  },
8007
8210
  title: "Toggle menu bar",
8008
- children: menuOpen ? /* @__PURE__ */ jsx42(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx42(ChevronDown, { focusable: "false" })
8211
+ children: menuOpen ? /* @__PURE__ */ jsx43(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx43(ChevronDown, { focusable: "false" })
8009
8212
  }
8010
8213
  ) }),
8011
- /* @__PURE__ */ jsx42(
8214
+ /* @__PURE__ */ jsx43(
8012
8215
  MenuBar,
8013
8216
  {
8014
8217
  dispatch,
8015
8218
  onPublish,
8016
8219
  menuOpen,
8017
- renderHeaderActions: () => /* @__PURE__ */ jsx42(CustomHeaderActions, { children: /* @__PURE__ */ jsx42(
8220
+ renderHeaderActions: () => /* @__PURE__ */ jsx43(CustomHeaderActions, { children: /* @__PURE__ */ jsx43(
8018
8221
  Button,
8019
8222
  {
8020
8223
  onClick: () => {
8021
8224
  const data = appStore.getState().state.data;
8022
8225
  onPublish && onPublish(data);
8023
8226
  },
8024
- icon: /* @__PURE__ */ jsx42(Globe, { size: "14px" }),
8227
+ icon: /* @__PURE__ */ jsx43(Globe, { size: "14px" }),
8025
8228
  children: "Publish"
8026
8229
  }
8027
8230
  ) }),
@@ -8035,7 +8238,7 @@ var HeaderInner = () => {
8035
8238
  }
8036
8239
  );
8037
8240
  };
8038
- var Header = memo4(HeaderInner);
8241
+ var Header = memo6(HeaderInner);
8039
8242
 
8040
8243
  // components/SidebarSection/index.tsx
8041
8244
  init_react_import();
@@ -8045,7 +8248,7 @@ init_react_import();
8045
8248
  var styles_module_default25 = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
8046
8249
 
8047
8250
  // components/SidebarSection/index.tsx
8048
- import { jsx as jsx43, jsxs as jsxs19 } from "react/jsx-runtime";
8251
+ import { jsx as jsx44, jsxs as jsxs19 } from "react/jsx-runtime";
8049
8252
  var getClassName30 = get_class_name_factory_default("SidebarSection", styles_module_default25);
8050
8253
  var SidebarSection = ({
8051
8254
  children,
@@ -8062,12 +8265,12 @@ var SidebarSection = ({
8062
8265
  className: getClassName30({ noBorderTop, noPadding }),
8063
8266
  style: { background },
8064
8267
  children: [
8065
- /* @__PURE__ */ jsx43("div", { className: getClassName30("title"), children: /* @__PURE__ */ jsxs19("div", { className: getClassName30("breadcrumbs"), children: [
8066
- showBreadcrumbs && /* @__PURE__ */ jsx43(Breadcrumbs, {}),
8067
- /* @__PURE__ */ jsx43("div", { className: getClassName30("heading"), children: /* @__PURE__ */ jsx43(Heading, { rank: "2", size: "xs", children: title }) })
8268
+ /* @__PURE__ */ jsx44("div", { className: getClassName30("title"), children: /* @__PURE__ */ jsxs19("div", { className: getClassName30("breadcrumbs"), children: [
8269
+ showBreadcrumbs && /* @__PURE__ */ jsx44(Breadcrumbs, {}),
8270
+ /* @__PURE__ */ jsx44("div", { className: getClassName30("heading"), children: /* @__PURE__ */ jsx44(Heading, { rank: "2", size: "xs", children: title }) })
8068
8271
  ] }) }),
8069
- /* @__PURE__ */ jsx43("div", { className: getClassName30("content"), children }),
8070
- isLoading && /* @__PURE__ */ jsx43("div", { className: getClassName30("loadingOverlay"), children: /* @__PURE__ */ jsx43(Loader, { size: 32 }) })
8272
+ /* @__PURE__ */ jsx44("div", { className: getClassName30("content"), children }),
8273
+ isLoading && /* @__PURE__ */ jsx44("div", { className: getClassName30("loadingOverlay"), children: /* @__PURE__ */ jsx44(Loader, { size: 32 }) })
8071
8274
  ]
8072
8275
  }
8073
8276
  );
@@ -8076,7 +8279,7 @@ var SidebarSection = ({
8076
8279
  // components/Puck/components/Canvas/index.tsx
8077
8280
  init_react_import();
8078
8281
  import {
8079
- useCallback as useCallback17,
8282
+ useCallback as useCallback18,
8080
8283
  useEffect as useEffect26,
8081
8284
  useMemo as useMemo19,
8082
8285
  useRef as useRef9,
@@ -8092,12 +8295,12 @@ init_react_import();
8092
8295
  var styles_module_default26 = { "ViewportControls": "_ViewportControls_e3unb_1", "ViewportControls--fullScreen": "_ViewportControls--fullScreen_e3unb_5", "ViewportControls-toggleButton": "_ViewportControls-toggleButton_e3unb_14", "ViewportControls--isExpanded": "_ViewportControls--isExpanded_e3unb_38", "ViewportControls-actions": "_ViewportControls-actions_e3unb_42", "ViewportControls-actionsInner": "_ViewportControls-actionsInner_e3unb_46", "ViewportControls-divider": "_ViewportControls-divider_e3unb_75", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_e3unb_81", "ViewportControls-zoom": "_ViewportControls-zoom_e3unb_81", "ViewportButton-inner": "_ViewportButton-inner_e3unb_111", "ViewportButton--isActive": "_ViewportButton--isActive_e3unb_119" };
8093
8296
 
8094
8297
  // components/ViewportControls/index.tsx
8095
- import { jsx as jsx44, jsxs as jsxs20 } from "react/jsx-runtime";
8298
+ import { jsx as jsx45, jsxs as jsxs20 } from "react/jsx-runtime";
8096
8299
  var icons = {
8097
- Smartphone: /* @__PURE__ */ jsx44(Smartphone, { size: 16 }),
8098
- Tablet: /* @__PURE__ */ jsx44(Tablet, { size: 16 }),
8099
- Monitor: /* @__PURE__ */ jsx44(Monitor, { size: 16 }),
8100
- FullWidth: /* @__PURE__ */ jsx44(Expand, { size: 16 })
8300
+ Smartphone: /* @__PURE__ */ jsx45(Smartphone, { size: 16 }),
8301
+ Tablet: /* @__PURE__ */ jsx45(Tablet, { size: 16 }),
8302
+ Monitor: /* @__PURE__ */ jsx45(Monitor, { size: 16 }),
8303
+ FullWidth: /* @__PURE__ */ jsx45(Expand, { size: 16 })
8101
8304
  };
8102
8305
  var getClassName31 = get_class_name_factory_default("ViewportControls", styles_module_default26);
8103
8306
  var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default26);
@@ -8108,7 +8311,7 @@ var ActionButton = ({
8108
8311
  isActive,
8109
8312
  disabled
8110
8313
  }) => {
8111
- return /* @__PURE__ */ jsx44("span", { className: getClassNameButton({ isActive }), suppressHydrationWarning: true, children: /* @__PURE__ */ jsx44(
8314
+ return /* @__PURE__ */ jsx45("span", { className: getClassNameButton({ isActive }), suppressHydrationWarning: true, children: /* @__PURE__ */ jsx45(
8112
8315
  IconButton,
8113
8316
  {
8114
8317
  type: "button",
@@ -8116,7 +8319,7 @@ var ActionButton = ({
8116
8319
  disabled: disabled || isActive,
8117
8320
  onClick,
8118
8321
  suppressHydrationWarning: true,
8119
- children: /* @__PURE__ */ jsx44("span", { className: getClassNameButton("inner"), children })
8322
+ children: /* @__PURE__ */ jsx45("span", { className: getClassNameButton("inner"), children })
8120
8323
  }
8121
8324
  ) });
8122
8325
  };
@@ -8167,8 +8370,8 @@ var ViewportControls = ({
8167
8370
  className: getClassName31({ isExpanded, fullScreen }),
8168
8371
  suppressHydrationWarning: true,
8169
8372
  children: [
8170
- /* @__PURE__ */ jsx44("div", { className: getClassName31("actions"), children: /* @__PURE__ */ jsxs20("div", { className: getClassName31("actionsInner"), children: [
8171
- viewports.map((viewport, i) => /* @__PURE__ */ jsx44(
8373
+ /* @__PURE__ */ jsx45("div", { className: getClassName31("actions"), children: /* @__PURE__ */ jsxs20("div", { className: getClassName31("actionsInner"), children: [
8374
+ viewports.map((viewport, i) => /* @__PURE__ */ jsx45(
8172
8375
  ActionButton,
8173
8376
  {
8174
8377
  title: viewport.label ? `Switch to ${viewport.label} viewport` : "Switch viewport",
@@ -8181,8 +8384,8 @@ var ViewportControls = ({
8181
8384
  },
8182
8385
  i
8183
8386
  )),
8184
- /* @__PURE__ */ jsx44("div", { className: getClassName31("divider") }),
8185
- /* @__PURE__ */ jsx44(
8387
+ /* @__PURE__ */ jsx45("div", { className: getClassName31("divider") }),
8388
+ /* @__PURE__ */ jsx45(
8186
8389
  ActionButton,
8187
8390
  {
8188
8391
  title: "Zoom viewport out",
@@ -8196,10 +8399,10 @@ var ViewportControls = ({
8196
8399
  )].value
8197
8400
  );
8198
8401
  },
8199
- children: /* @__PURE__ */ jsx44(ZoomOut, { size: 16 })
8402
+ children: /* @__PURE__ */ jsx45(ZoomOut, { size: 16 })
8200
8403
  }
8201
8404
  ),
8202
- /* @__PURE__ */ jsx44(
8405
+ /* @__PURE__ */ jsx45(
8203
8406
  ActionButton,
8204
8407
  {
8205
8408
  title: "Zoom viewport in",
@@ -8213,12 +8416,12 @@ var ViewportControls = ({
8213
8416
  )].value
8214
8417
  );
8215
8418
  },
8216
- children: /* @__PURE__ */ jsx44(ZoomIn, { size: 16 })
8419
+ children: /* @__PURE__ */ jsx45(ZoomIn, { size: 16 })
8217
8420
  }
8218
8421
  ),
8219
8422
  /* @__PURE__ */ jsxs20("div", { className: getClassName31("zoom"), children: [
8220
- /* @__PURE__ */ jsx44("div", { className: getClassName31("divider") }),
8221
- /* @__PURE__ */ jsx44(
8423
+ /* @__PURE__ */ jsx45("div", { className: getClassName31("divider") }),
8424
+ /* @__PURE__ */ jsx45(
8222
8425
  "select",
8223
8426
  {
8224
8427
  className: getClassName31("zoomSelect"),
@@ -8229,7 +8432,7 @@ var ViewportControls = ({
8229
8432
  onChange: (e) => {
8230
8433
  onZoom(parseFloat(e.currentTarget.value));
8231
8434
  },
8232
- children: zoomOptions.map((option) => /* @__PURE__ */ jsx44(
8435
+ children: zoomOptions.map((option) => /* @__PURE__ */ jsx45(
8233
8436
  "option",
8234
8437
  {
8235
8438
  value: option.value,
@@ -8241,13 +8444,13 @@ var ViewportControls = ({
8241
8444
  )
8242
8445
  ] })
8243
8446
  ] }) }),
8244
- /* @__PURE__ */ jsx44(
8447
+ /* @__PURE__ */ jsx45(
8245
8448
  "button",
8246
8449
  {
8247
8450
  className: getClassName31("toggleButton"),
8248
8451
  title: "Toggle viewport menu",
8249
8452
  onClick: () => setIsExpanded((s) => !s),
8250
- children: isExpanded ? /* @__PURE__ */ jsx44(X, { size: 16 }) : /* @__PURE__ */ jsx44(Monitor, { size: 16 })
8453
+ children: isExpanded ? /* @__PURE__ */ jsx45(X, { size: 16 }) : /* @__PURE__ */ jsx45(Monitor, { size: 16 })
8251
8454
  }
8252
8455
  )
8253
8456
  ]
@@ -8260,7 +8463,7 @@ init_react_import();
8260
8463
  var styles_module_default27 = { "PuckCanvas": "_PuckCanvas_t6s9b_1", "PuckCanvas-controls": "_PuckCanvas-controls_t6s9b_17", "PuckCanvas--fullScreen": "_PuckCanvas--fullScreen_t6s9b_22", "PuckCanvas-inner": "_PuckCanvas-inner_t6s9b_33", "PuckCanvas-root": "_PuckCanvas-root_t6s9b_42", "PuckCanvas--ready": "_PuckCanvas--ready_t6s9b_67", "PuckCanvas-loader": "_PuckCanvas-loader_t6s9b_72", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_t6s9b_82" };
8261
8464
 
8262
8465
  // components/Puck/components/Canvas/index.tsx
8263
- import { useShallow as useShallow8 } from "zustand/react/shallow";
8466
+ import { useShallow as useShallow9 } from "zustand/react/shallow";
8264
8467
 
8265
8468
  // lib/frame-context.tsx
8266
8469
  init_react_import();
@@ -8270,7 +8473,7 @@ import {
8270
8473
  useRef as useRef8,
8271
8474
  useMemo as useMemo18
8272
8475
  } from "react";
8273
- import { jsx as jsx45 } from "react/jsx-runtime";
8476
+ import { jsx as jsx46 } from "react/jsx-runtime";
8274
8477
  var FrameContext = createContext7(null);
8275
8478
  var FrameProvider = ({
8276
8479
  children
@@ -8282,7 +8485,7 @@ var FrameProvider = ({
8282
8485
  }),
8283
8486
  []
8284
8487
  );
8285
- return /* @__PURE__ */ jsx45(FrameContext.Provider, { value, children });
8488
+ return /* @__PURE__ */ jsx46(FrameContext.Provider, { value, children });
8286
8489
  };
8287
8490
  var useCanvasFrame = () => {
8288
8491
  const context = useContext12(FrameContext);
@@ -8293,7 +8496,7 @@ var useCanvasFrame = () => {
8293
8496
  };
8294
8497
 
8295
8498
  // components/Puck/components/Canvas/index.tsx
8296
- import { Fragment as Fragment15, jsx as jsx46, jsxs as jsxs21 } from "react/jsx-runtime";
8499
+ import { Fragment as Fragment16, jsx as jsx47, jsxs as jsxs21 } from "react/jsx-runtime";
8297
8500
  var getClassName32 = get_class_name_factory_default("PuckCanvas", styles_module_default27);
8298
8501
  var ZOOM_ON_CHANGE = true;
8299
8502
  var TRANSITION_DURATION = 150;
@@ -8310,7 +8513,7 @@ var Canvas = () => {
8310
8513
  status,
8311
8514
  iframe
8312
8515
  } = useAppStore(
8313
- useShallow8((s) => ({
8516
+ useShallow9((s) => ({
8314
8517
  dispatch: s.dispatch,
8315
8518
  overrides: s.overrides,
8316
8519
  setUi: s.setUi,
@@ -8327,7 +8530,7 @@ var Canvas = () => {
8327
8530
  rightSideBarWidth,
8328
8531
  viewports
8329
8532
  } = useAppStore(
8330
- useShallow8((s) => ({
8533
+ useShallow9((s) => ({
8331
8534
  leftSideBarVisible: s.state.ui.leftSideBarVisible,
8332
8535
  rightSideBarVisible: s.state.ui.rightSideBarVisible,
8333
8536
  leftSideBarWidth: s.state.ui.leftSideBarWidth,
@@ -8338,14 +8541,14 @@ var Canvas = () => {
8338
8541
  const [showTransition, setShowTransition] = useState23(false);
8339
8542
  const isResizingRef = useRef9(false);
8340
8543
  const defaultRender = useMemo19(() => {
8341
- const PuckDefault = ({ children }) => /* @__PURE__ */ jsx46(Fragment15, { children });
8544
+ const PuckDefault = ({ children }) => /* @__PURE__ */ jsx47(Fragment16, { children });
8342
8545
  return PuckDefault;
8343
8546
  }, []);
8344
8547
  const CustomPreview = useMemo19(
8345
8548
  () => overrides.preview || defaultRender,
8346
8549
  [overrides]
8347
8550
  );
8348
- const getFrameDimensions = useCallback17(() => {
8551
+ const getFrameDimensions = useCallback18(() => {
8349
8552
  if (frameRef.current) {
8350
8553
  const frame = frameRef.current;
8351
8554
  const box = getBox(frame);
@@ -8413,7 +8616,7 @@ var Canvas = () => {
8413
8616
  }
8414
8617
  },
8415
8618
  children: [
8416
- viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx46("div", { className: getClassName32("controls"), children: /* @__PURE__ */ jsx46(
8619
+ viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx47("div", { className: getClassName32("controls"), children: /* @__PURE__ */ jsx47(
8417
8620
  ViewportControls,
8418
8621
  {
8419
8622
  fullScreen: _experimentalFullScreenCanvas,
@@ -8444,7 +8647,7 @@ var Canvas = () => {
8444
8647
  }
8445
8648
  ) }),
8446
8649
  /* @__PURE__ */ jsxs21("div", { className: getClassName32("inner"), ref: frameRef, children: [
8447
- /* @__PURE__ */ jsx46(
8650
+ /* @__PURE__ */ jsx47(
8448
8651
  "div",
8449
8652
  {
8450
8653
  className: getClassName32("root"),
@@ -8461,10 +8664,10 @@ var Canvas = () => {
8461
8664
  setShowTransition(false);
8462
8665
  isResizingRef.current = false;
8463
8666
  },
8464
- children: /* @__PURE__ */ jsx46(CustomPreview, { children: /* @__PURE__ */ jsx46(Preview2, {}) })
8667
+ children: /* @__PURE__ */ jsx47(CustomPreview, { children: /* @__PURE__ */ jsx47(Preview2, {}) })
8465
8668
  }
8466
8669
  ),
8467
- /* @__PURE__ */ jsx46("div", { className: getClassName32("loader"), children: /* @__PURE__ */ jsx46(Loader, { size: 24 }) })
8670
+ /* @__PURE__ */ jsx47("div", { className: getClassName32("loader"), children: /* @__PURE__ */ jsx47(Loader, { size: 24 }) })
8468
8671
  ] })
8469
8672
  ]
8470
8673
  }
@@ -8473,7 +8676,7 @@ var Canvas = () => {
8473
8676
 
8474
8677
  // lib/use-sidebar-resize.ts
8475
8678
  init_react_import();
8476
- import { useCallback as useCallback18, useEffect as useEffect27, useRef as useRef10, useState as useState24 } from "react";
8679
+ import { useCallback as useCallback19, useEffect as useEffect27, useRef as useRef10, useState as useState24 } from "react";
8477
8680
  function useSidebarResize(position, dispatch) {
8478
8681
  const [width, setWidth] = useState24(null);
8479
8682
  const sidebarRef = useRef10(null);
@@ -8510,7 +8713,7 @@ function useSidebarResize(position, dispatch) {
8510
8713
  setWidth(storeWidth);
8511
8714
  }
8512
8715
  }, [storeWidth]);
8513
- const handleResizeEnd = useCallback18(
8716
+ const handleResizeEnd = useCallback19(
8514
8717
  (width2) => {
8515
8718
  dispatch({
8516
8719
  type: "setUi",
@@ -8557,14 +8760,14 @@ init_react_import();
8557
8760
 
8558
8761
  // components/Puck/components/ResizeHandle/index.tsx
8559
8762
  init_react_import();
8560
- import { useCallback as useCallback19, useRef as useRef11 } from "react";
8763
+ import { useCallback as useCallback20, useRef as useRef11 } from "react";
8561
8764
 
8562
8765
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
8563
8766
  init_react_import();
8564
8767
  var styles_module_default28 = { "ResizeHandle": "_ResizeHandle_144bf_2", "ResizeHandle--left": "_ResizeHandle--left_144bf_16", "ResizeHandle--right": "_ResizeHandle--right_144bf_20" };
8565
8768
 
8566
8769
  // components/Puck/components/ResizeHandle/index.tsx
8567
- import { jsx as jsx47 } from "react/jsx-runtime";
8770
+ import { jsx as jsx48 } from "react/jsx-runtime";
8568
8771
  var getClassName33 = get_class_name_factory_default("ResizeHandle", styles_module_default28);
8569
8772
  var ResizeHandle = ({
8570
8773
  position,
@@ -8578,7 +8781,7 @@ var ResizeHandle = ({
8578
8781
  const isDragging = useRef11(false);
8579
8782
  const startX = useRef11(0);
8580
8783
  const startWidth = useRef11(0);
8581
- const handleMouseMove = useCallback19(
8784
+ const handleMouseMove = useCallback20(
8582
8785
  (e) => {
8583
8786
  if (!isDragging.current) return;
8584
8787
  const delta = e.clientX - startX.current;
@@ -8589,7 +8792,7 @@ var ResizeHandle = ({
8589
8792
  },
8590
8793
  [onResize, position]
8591
8794
  );
8592
- const handleMouseUp = useCallback19(() => {
8795
+ const handleMouseUp = useCallback20(() => {
8593
8796
  var _a;
8594
8797
  if (!isDragging.current) return;
8595
8798
  isDragging.current = false;
@@ -8605,7 +8808,7 @@ var ResizeHandle = ({
8605
8808
  onResizeEnd(finalWidth);
8606
8809
  resetAutoZoom();
8607
8810
  }, [onResizeEnd]);
8608
- const handleMouseDown = useCallback19(
8811
+ const handleMouseDown = useCallback20(
8609
8812
  (e) => {
8610
8813
  var _a;
8611
8814
  isDragging.current = true;
@@ -8623,7 +8826,7 @@ var ResizeHandle = ({
8623
8826
  },
8624
8827
  [position, handleMouseMove, handleMouseUp]
8625
8828
  );
8626
- return /* @__PURE__ */ jsx47(
8829
+ return /* @__PURE__ */ jsx48(
8627
8830
  "div",
8628
8831
  {
8629
8832
  ref: handleRef,
@@ -8638,7 +8841,7 @@ init_react_import();
8638
8841
  var styles_module_default29 = { "Sidebar": "_Sidebar_o396p_1", "Sidebar--isVisible": "_Sidebar--isVisible_o396p_9", "Sidebar--left": "_Sidebar--left_o396p_13", "Sidebar--right": "_Sidebar--right_o396p_25", "Sidebar-resizeHandle": "_Sidebar-resizeHandle_o396p_37" };
8639
8842
 
8640
8843
  // components/Puck/components/Sidebar/index.tsx
8641
- import { Fragment as Fragment16, jsx as jsx48, jsxs as jsxs22 } from "react/jsx-runtime";
8844
+ import { Fragment as Fragment17, jsx as jsx49, jsxs as jsxs22 } from "react/jsx-runtime";
8642
8845
  var getClassName34 = get_class_name_factory_default("Sidebar", styles_module_default29);
8643
8846
  var Sidebar = ({
8644
8847
  position,
@@ -8648,8 +8851,8 @@ var Sidebar = ({
8648
8851
  onResizeEnd,
8649
8852
  children
8650
8853
  }) => {
8651
- return /* @__PURE__ */ jsxs22(Fragment16, { children: [
8652
- /* @__PURE__ */ jsx48(
8854
+ return /* @__PURE__ */ jsxs22(Fragment17, { children: [
8855
+ /* @__PURE__ */ jsx49(
8653
8856
  "div",
8654
8857
  {
8655
8858
  ref: sidebarRef,
@@ -8657,7 +8860,7 @@ var Sidebar = ({
8657
8860
  children
8658
8861
  }
8659
8862
  ),
8660
- /* @__PURE__ */ jsx48("div", { className: `${getClassName34("resizeHandle")}`, children: /* @__PURE__ */ jsx48(
8863
+ /* @__PURE__ */ jsx49("div", { className: `${getClassName34("resizeHandle")}`, children: /* @__PURE__ */ jsx49(
8661
8864
  ResizeHandle,
8662
8865
  {
8663
8866
  position,
@@ -8671,7 +8874,7 @@ var Sidebar = ({
8671
8874
 
8672
8875
  // lib/use-delete-hotkeys.ts
8673
8876
  init_react_import();
8674
- import { useCallback as useCallback20 } from "react";
8877
+ import { useCallback as useCallback21 } from "react";
8675
8878
  var isElementVisible = (element) => {
8676
8879
  let current = element;
8677
8880
  while (current && current !== document.body) {
@@ -8706,7 +8909,7 @@ var shouldBlockDeleteHotkey = (e) => {
8706
8909
  };
8707
8910
  var useDeleteHotkeys = () => {
8708
8911
  const appStore = useAppStoreApi();
8709
- const deleteSelectedComponent = useCallback20(
8912
+ const deleteSelectedComponent = useCallback21(
8710
8913
  (e) => {
8711
8914
  var _a;
8712
8915
  if (shouldBlockDeleteHotkey(e)) {
@@ -8738,7 +8941,7 @@ init_react_import();
8738
8941
  var styles_module_default30 = { "Nav": "_Nav_3nnxc_1", "Nav-list": "_Nav-list_3nnxc_5", "Nav-mobileActions": "_Nav-mobileActions_3nnxc_23", "NavItem-link": "_NavItem-link_3nnxc_38", "NavItem": "_NavItem_3nnxc_38", "NavItem-linkIcon": "_NavItem-linkIcon_3nnxc_88", "NavItem--active": "_NavItem--active_3nnxc_93", "NavItem--mobileOnly": "_NavItem--mobileOnly_3nnxc_120" };
8739
8942
 
8740
8943
  // components/Puck/components/Nav/index.tsx
8741
- import { jsx as jsx49, jsxs as jsxs23 } from "react/jsx-runtime";
8944
+ import { jsx as jsx50, jsxs as jsxs23 } from "react/jsx-runtime";
8742
8945
  var getClassName35 = get_class_name_factory_default("Nav", styles_module_default30);
8743
8946
  var getClassNameItem3 = get_class_name_factory_default("NavItem", styles_module_default30);
8744
8947
  var MenuItem = ({
@@ -8748,9 +8951,9 @@ var MenuItem = ({
8748
8951
  isActive,
8749
8952
  mobileOnly
8750
8953
  }) => {
8751
- return /* @__PURE__ */ jsx49("li", { className: getClassNameItem3({ active: isActive, mobileOnly }), children: onClick && /* @__PURE__ */ jsxs23("div", { className: getClassNameItem3("link"), onClick, children: [
8752
- icon && /* @__PURE__ */ jsx49("span", { className: getClassNameItem3("linkIcon"), children: icon }),
8753
- /* @__PURE__ */ jsx49("span", { className: getClassNameItem3("linkLabel"), children: label })
8954
+ return /* @__PURE__ */ jsx50("li", { className: getClassNameItem3({ active: isActive, mobileOnly }), children: onClick && /* @__PURE__ */ jsxs23("div", { className: getClassNameItem3("link"), onClick, children: [
8955
+ icon && /* @__PURE__ */ jsx50("span", { className: getClassNameItem3("linkIcon"), children: icon }),
8956
+ /* @__PURE__ */ jsx50("span", { className: getClassNameItem3("linkLabel"), children: label })
8754
8957
  ] }) });
8755
8958
  };
8756
8959
  var Nav = ({
@@ -8758,13 +8961,13 @@ var Nav = ({
8758
8961
  mobileActions
8759
8962
  }) => {
8760
8963
  return /* @__PURE__ */ jsxs23("nav", { className: getClassName35(), children: [
8761
- /* @__PURE__ */ jsx49("ul", { className: getClassName35("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ jsx49(MenuItem, __spreadValues({}, item), key)) }),
8762
- mobileActions && /* @__PURE__ */ jsx49("div", { className: getClassName35("mobileActions"), children: mobileActions })
8964
+ /* @__PURE__ */ jsx50("ul", { className: getClassName35("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ jsx50(MenuItem, __spreadValues({}, item), key)) }),
8965
+ mobileActions && /* @__PURE__ */ jsx50("div", { className: getClassName35("mobileActions"), children: mobileActions })
8763
8966
  ] });
8764
8967
  };
8765
8968
 
8766
8969
  // components/Puck/components/Layout/index.tsx
8767
- import { jsx as jsx50, jsxs as jsxs24 } from "react/jsx-runtime";
8970
+ import { jsx as jsx51, jsxs as jsxs24 } from "react/jsx-runtime";
8768
8971
  var getClassName36 = get_class_name_factory_default("Puck", styles_module_default22);
8769
8972
  var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default22);
8770
8973
  var getPluginTabClassName = get_class_name_factory_default("PuckPluginTab", styles_module_default22);
@@ -8775,14 +8978,14 @@ var FieldSideBar = () => {
8775
8978
  return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
8776
8979
  }
8777
8980
  );
8778
- return /* @__PURE__ */ jsx50(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx50(Fields, {}) });
8981
+ return /* @__PURE__ */ jsx51(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx51(Fields, {}) });
8779
8982
  };
8780
8983
  var PluginTab = ({
8781
8984
  children,
8782
8985
  visible,
8783
8986
  mobileOnly
8784
8987
  }) => {
8785
- return /* @__PURE__ */ jsx50("div", { className: getPluginTabClassName({ visible, mobileOnly }), children: /* @__PURE__ */ jsx50("div", { className: getPluginTabClassName("body"), children }) });
8988
+ return /* @__PURE__ */ jsx51("div", { className: getPluginTabClassName({ visible, mobileOnly }), children: /* @__PURE__ */ jsx51("div", { className: getPluginTabClassName("body"), children }) });
8786
8989
  };
8787
8990
  var Layout = ({ children }) => {
8788
8991
  const {
@@ -8790,7 +8993,7 @@ var Layout = ({ children }) => {
8790
8993
  dnd,
8791
8994
  initialHistory: _initialHistory,
8792
8995
  plugins,
8793
- height = "100dvh"
8996
+ height
8794
8997
  } = usePropsContext();
8795
8998
  const iframe = useMemo20(
8796
8999
  () => __spreadValues({
@@ -8894,7 +9097,7 @@ var Layout = ({ children }) => {
8894
9097
  }
8895
9098
  details[plugin.name] = {
8896
9099
  label: (_a = plugin.label) != null ? _a : plugin.name,
8897
- icon: (_b = plugin.icon) != null ? _b : /* @__PURE__ */ jsx50(ToyBrick, {}),
9100
+ icon: (_b = plugin.icon) != null ? _b : /* @__PURE__ */ jsx51(ToyBrick, {}),
8898
9101
  onClick: () => {
8899
9102
  var _a2;
8900
9103
  setMobilePanelHeightMode((_a2 = plugin.mobilePanelHeight) != null ? _a2 : "toggle");
@@ -8934,99 +9137,92 @@ var Layout = ({ children }) => {
8934
9137
  return (_a = s.state.ui.mobilePanelExpanded) != null ? _a : false;
8935
9138
  }
8936
9139
  );
8937
- return /* @__PURE__ */ jsxs24(
8938
- "div",
8939
- {
8940
- className: `Puck ${getClassName36()}`,
8941
- style: { height },
8942
- id: instanceId,
8943
- children: [
8944
- /* @__PURE__ */ jsx50(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx50(CustomPuck, { children: children || /* @__PURE__ */ jsx50(FrameProvider, { children: /* @__PURE__ */ jsx50(
9140
+ return /* @__PURE__ */ jsxs24("div", { className: `Puck ${getClassName36()}`, id: instanceId, children: [
9141
+ /* @__PURE__ */ jsx51(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx51(CustomPuck, { children: children || /* @__PURE__ */ jsx51(FrameProvider, { children: /* @__PURE__ */ jsx51(
9142
+ "div",
9143
+ {
9144
+ className: getLayoutClassName({
9145
+ leftSideBarVisible,
9146
+ mounted,
9147
+ rightSideBarVisible: !hasDesktopFieldsPlugin && rightSideBarVisible,
9148
+ isExpanded: mobilePanelExpanded,
9149
+ mobilePanelHeightToggle: mobilePanelHeightMode === "toggle",
9150
+ mobilePanelHeightMinContent: mobilePanelHeightMode === "min-content"
9151
+ }),
9152
+ style: { height },
9153
+ children: /* @__PURE__ */ jsxs24(
8945
9154
  "div",
8946
9155
  {
8947
- className: getLayoutClassName({
8948
- leftSideBarVisible,
8949
- mounted,
8950
- rightSideBarVisible: !hasDesktopFieldsPlugin && rightSideBarVisible,
8951
- isExpanded: mobilePanelExpanded,
8952
- mobilePanelHeightToggle: mobilePanelHeightMode === "toggle",
8953
- mobilePanelHeightMinContent: mobilePanelHeightMode === "min-content"
8954
- }),
8955
- children: /* @__PURE__ */ jsxs24(
8956
- "div",
8957
- {
8958
- className: getLayoutClassName("inner"),
8959
- style: layoutOptions,
8960
- children: [
8961
- /* @__PURE__ */ jsx50("div", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsx50(Header, {}) }),
8962
- /* @__PURE__ */ jsx50("div", { className: getLayoutClassName("nav"), children: /* @__PURE__ */ jsx50(
8963
- Nav,
8964
- {
8965
- items: pluginItems,
8966
- mobileActions: leftSideBarVisible && mobilePanelHeightMode === "toggle" && /* @__PURE__ */ jsx50(
8967
- IconButton,
8968
- {
8969
- type: "button",
8970
- title: "maximize",
8971
- onClick: () => {
8972
- setUi({
8973
- mobilePanelExpanded: !mobilePanelExpanded
8974
- });
8975
- },
8976
- children: mobilePanelExpanded ? /* @__PURE__ */ jsx50(Minimize2, { size: 21 }) : /* @__PURE__ */ jsx50(Maximize2, { size: 21 })
8977
- }
8978
- )
8979
- }
8980
- ) }),
8981
- /* @__PURE__ */ jsx50(
8982
- Sidebar,
8983
- {
8984
- position: "left",
8985
- sidebarRef: leftSidebarRef,
8986
- isVisible: leftSideBarVisible,
8987
- onResize: setLeftWidth,
8988
- onResizeEnd: handleLeftSidebarResizeEnd,
8989
- children: Object.entries(pluginItems).map(
8990
- ([id, { mobileOnly, render: Render2, label }]) => /* @__PURE__ */ jsx50(
8991
- PluginTab,
8992
- {
8993
- visible: currentPlugin === id,
8994
- mobileOnly,
8995
- children: /* @__PURE__ */ jsx50(Render2, {})
8996
- },
8997
- id
8998
- )
8999
- )
9000
- }
9001
- ),
9002
- /* @__PURE__ */ jsx50(Canvas, {}),
9003
- !hasDesktopFieldsPlugin && /* @__PURE__ */ jsx50(
9004
- Sidebar,
9156
+ className: getLayoutClassName("inner"),
9157
+ style: layoutOptions,
9158
+ children: [
9159
+ /* @__PURE__ */ jsx51("div", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsx51(Header, {}) }),
9160
+ /* @__PURE__ */ jsx51("div", { className: getLayoutClassName("nav"), children: /* @__PURE__ */ jsx51(
9161
+ Nav,
9162
+ {
9163
+ items: pluginItems,
9164
+ mobileActions: leftSideBarVisible && mobilePanelHeightMode === "toggle" && /* @__PURE__ */ jsx51(
9165
+ IconButton,
9005
9166
  {
9006
- position: "right",
9007
- sidebarRef: rightSidebarRef,
9008
- isVisible: rightSideBarVisible,
9009
- onResize: setRightWidth,
9010
- onResizeEnd: handleRightSidebarResizeEnd,
9011
- children: /* @__PURE__ */ jsx50(FieldSideBar, {})
9167
+ type: "button",
9168
+ title: "maximize",
9169
+ onClick: () => {
9170
+ setUi({
9171
+ mobilePanelExpanded: !mobilePanelExpanded
9172
+ });
9173
+ },
9174
+ children: mobilePanelExpanded ? /* @__PURE__ */ jsx51(Minimize2, { size: 21 }) : /* @__PURE__ */ jsx51(Maximize2, { size: 21 })
9012
9175
  }
9013
9176
  )
9014
- ]
9015
- }
9016
- )
9177
+ }
9178
+ ) }),
9179
+ /* @__PURE__ */ jsx51(
9180
+ Sidebar,
9181
+ {
9182
+ position: "left",
9183
+ sidebarRef: leftSidebarRef,
9184
+ isVisible: leftSideBarVisible,
9185
+ onResize: setLeftWidth,
9186
+ onResizeEnd: handleLeftSidebarResizeEnd,
9187
+ children: Object.entries(pluginItems).map(
9188
+ ([id, { mobileOnly, render: Render2, label }]) => /* @__PURE__ */ jsx51(
9189
+ PluginTab,
9190
+ {
9191
+ visible: currentPlugin === id,
9192
+ mobileOnly,
9193
+ children: /* @__PURE__ */ jsx51(Render2, {})
9194
+ },
9195
+ id
9196
+ )
9197
+ )
9198
+ }
9199
+ ),
9200
+ /* @__PURE__ */ jsx51(Canvas, {}),
9201
+ !hasDesktopFieldsPlugin && /* @__PURE__ */ jsx51(
9202
+ Sidebar,
9203
+ {
9204
+ position: "right",
9205
+ sidebarRef: rightSidebarRef,
9206
+ isVisible: rightSideBarVisible,
9207
+ onResize: setRightWidth,
9208
+ onResizeEnd: handleRightSidebarResizeEnd,
9209
+ children: /* @__PURE__ */ jsx51(FieldSideBar, {})
9210
+ }
9211
+ )
9212
+ ]
9017
9213
  }
9018
- ) }) }) }),
9019
- /* @__PURE__ */ jsx50("div", { id: "puck-portal-root", className: getClassName36("portal") })
9020
- ]
9021
- }
9022
- );
9214
+ )
9215
+ }
9216
+ ) }) }) }),
9217
+ /* @__PURE__ */ jsx51("div", { id: "puck-portal-root", className: getClassName36("portal") })
9218
+ ] });
9023
9219
  };
9024
9220
 
9025
9221
  // components/Puck/index.tsx
9026
- import { jsx as jsx51 } from "react/jsx-runtime";
9222
+ import { jsx as jsx52 } from "react/jsx-runtime";
9027
9223
  var propsContext = createContext8({});
9028
9224
  function PropsProvider(props) {
9029
- return /* @__PURE__ */ jsx51(propsContext.Provider, { value: props, children: props.children });
9225
+ return /* @__PURE__ */ jsx52(propsContext.Provider, { value: props, children: props.children });
9030
9226
  }
9031
9227
  var usePropsContext = () => useContext13(propsContext);
9032
9228
  function PuckProvider({ children }) {
@@ -9140,7 +9336,12 @@ function PuckProvider({ children }) {
9140
9336
  });
9141
9337
  })
9142
9338
  );
9143
- const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || blendedHistories.length - 1;
9339
+ const initialHistoryIndex = useMemo21(() => {
9340
+ if ((_initialHistory == null ? void 0 : _initialHistory.index) !== void 0 && (_initialHistory == null ? void 0 : _initialHistory.index) >= 0 && (_initialHistory == null ? void 0 : _initialHistory.index) < blendedHistories.length) {
9341
+ return _initialHistory == null ? void 0 : _initialHistory.index;
9342
+ }
9343
+ return blendedHistories.length - 1;
9344
+ }, []);
9144
9345
  const initialAppState = blendedHistories[initialHistoryIndex].state;
9145
9346
  const loadedOverrides = useLoadedOverrides({
9146
9347
  overrides,
@@ -9155,7 +9356,7 @@ function PuckProvider({ children }) {
9155
9356
  return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
9156
9357
  }, [fieldTransforms, plugins]);
9157
9358
  const instanceId = useSafeId();
9158
- const generateAppStore = useCallback21(
9359
+ const generateAppStore = useCallback22(
9159
9360
  (state) => {
9160
9361
  return {
9161
9362
  instanceId,
@@ -9206,7 +9407,7 @@ function PuckProvider({ children }) {
9206
9407
  (s) => s.state.data,
9207
9408
  (data) => {
9208
9409
  if (onChange) {
9209
- if ((0, import_fast_deep_equal.default)(data, previousData.current)) return;
9410
+ if ((0, import_fast_deep_equal2.default)(data, previousData.current)) return;
9210
9411
  onChange(data);
9211
9412
  previousData.current = data;
9212
9413
  }
@@ -9219,10 +9420,10 @@ function PuckProvider({ children }) {
9219
9420
  const { resolveAndCommitData } = appStore.getState();
9220
9421
  resolveAndCommitData();
9221
9422
  }, []);
9222
- return /* @__PURE__ */ jsx51(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx51(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
9423
+ return /* @__PURE__ */ jsx52(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx52(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
9223
9424
  }
9224
9425
  function Puck(props) {
9225
- return /* @__PURE__ */ jsx51(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx51(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx51(Layout, { children: props.children }) })) }));
9426
+ return /* @__PURE__ */ jsx52(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx52(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx52(Layout, { children: props.children }) })) }));
9226
9427
  }
9227
9428
  Puck.Components = Components;
9228
9429
  Puck.Fields = Fields;
@@ -9299,325 +9500,45 @@ classnames/index.js:
9299
9500
  *)
9300
9501
 
9301
9502
  lucide-react/dist/esm/shared/src/utils.js:
9302
- (**
9303
- * @license lucide-react v0.468.0 - ISC
9304
- *
9305
- * This source code is licensed under the ISC license.
9306
- * See the LICENSE file in the root directory of this source tree.
9307
- *)
9308
-
9309
9503
  lucide-react/dist/esm/defaultAttributes.js:
9310
- (**
9311
- * @license lucide-react v0.468.0 - ISC
9312
- *
9313
- * This source code is licensed under the ISC license.
9314
- * See the LICENSE file in the root directory of this source tree.
9315
- *)
9316
-
9317
9504
  lucide-react/dist/esm/Icon.js:
9318
- (**
9319
- * @license lucide-react v0.468.0 - ISC
9320
- *
9321
- * This source code is licensed under the ISC license.
9322
- * See the LICENSE file in the root directory of this source tree.
9323
- *)
9324
-
9325
9505
  lucide-react/dist/esm/createLucideIcon.js:
9326
- (**
9327
- * @license lucide-react v0.468.0 - ISC
9328
- *
9329
- * This source code is licensed under the ISC license.
9330
- * See the LICENSE file in the root directory of this source tree.
9331
- *)
9332
-
9333
9506
  lucide-react/dist/esm/icons/chevron-down.js:
9334
- (**
9335
- * @license lucide-react v0.468.0 - ISC
9336
- *
9337
- * This source code is licensed under the ISC license.
9338
- * See the LICENSE file in the root directory of this source tree.
9339
- *)
9340
-
9341
9507
  lucide-react/dist/esm/icons/chevron-right.js:
9342
- (**
9343
- * @license lucide-react v0.468.0 - ISC
9344
- *
9345
- * This source code is licensed under the ISC license.
9346
- * See the LICENSE file in the root directory of this source tree.
9347
- *)
9348
-
9349
9508
  lucide-react/dist/esm/icons/chevron-up.js:
9350
- (**
9351
- * @license lucide-react v0.468.0 - ISC
9352
- *
9353
- * This source code is licensed under the ISC license.
9354
- * See the LICENSE file in the root directory of this source tree.
9355
- *)
9356
-
9357
9509
  lucide-react/dist/esm/icons/circle-check-big.js:
9358
- (**
9359
- * @license lucide-react v0.468.0 - ISC
9360
- *
9361
- * This source code is licensed under the ISC license.
9362
- * See the LICENSE file in the root directory of this source tree.
9363
- *)
9364
-
9365
9510
  lucide-react/dist/esm/icons/copy.js:
9366
- (**
9367
- * @license lucide-react v0.468.0 - ISC
9368
- *
9369
- * This source code is licensed under the ISC license.
9370
- * See the LICENSE file in the root directory of this source tree.
9371
- *)
9372
-
9373
9511
  lucide-react/dist/esm/icons/corner-left-up.js:
9374
- (**
9375
- * @license lucide-react v0.468.0 - ISC
9376
- *
9377
- * This source code is licensed under the ISC license.
9378
- * See the LICENSE file in the root directory of this source tree.
9379
- *)
9380
-
9381
9512
  lucide-react/dist/esm/icons/ellipsis-vertical.js:
9382
- (**
9383
- * @license lucide-react v0.468.0 - ISC
9384
- *
9385
- * This source code is licensed under the ISC license.
9386
- * See the LICENSE file in the root directory of this source tree.
9387
- *)
9388
-
9389
9513
  lucide-react/dist/esm/icons/expand.js:
9390
- (**
9391
- * @license lucide-react v0.468.0 - ISC
9392
- *
9393
- * This source code is licensed under the ISC license.
9394
- * See the LICENSE file in the root directory of this source tree.
9395
- *)
9396
-
9397
9514
  lucide-react/dist/esm/icons/globe.js:
9398
- (**
9399
- * @license lucide-react v0.468.0 - ISC
9400
- *
9401
- * This source code is licensed under the ISC license.
9402
- * See the LICENSE file in the root directory of this source tree.
9403
- *)
9404
-
9405
9515
  lucide-react/dist/esm/icons/hammer.js:
9406
- (**
9407
- * @license lucide-react v0.468.0 - ISC
9408
- *
9409
- * This source code is licensed under the ISC license.
9410
- * See the LICENSE file in the root directory of this source tree.
9411
- *)
9412
-
9413
9516
  lucide-react/dist/esm/icons/hash.js:
9414
- (**
9415
- * @license lucide-react v0.468.0 - ISC
9416
- *
9417
- * This source code is licensed under the ISC license.
9418
- * See the LICENSE file in the root directory of this source tree.
9419
- *)
9420
-
9421
9517
  lucide-react/dist/esm/icons/layers.js:
9422
- (**
9423
- * @license lucide-react v0.468.0 - ISC
9424
- *
9425
- * This source code is licensed under the ISC license.
9426
- * See the LICENSE file in the root directory of this source tree.
9427
- *)
9428
-
9429
9518
  lucide-react/dist/esm/icons/layout-grid.js:
9430
- (**
9431
- * @license lucide-react v0.468.0 - ISC
9432
- *
9433
- * This source code is licensed under the ISC license.
9434
- * See the LICENSE file in the root directory of this source tree.
9435
- *)
9436
-
9437
9519
  lucide-react/dist/esm/icons/link.js:
9438
- (**
9439
- * @license lucide-react v0.468.0 - ISC
9440
- *
9441
- * This source code is licensed under the ISC license.
9442
- * See the LICENSE file in the root directory of this source tree.
9443
- *)
9444
-
9445
9520
  lucide-react/dist/esm/icons/list.js:
9446
- (**
9447
- * @license lucide-react v0.468.0 - ISC
9448
- *
9449
- * This source code is licensed under the ISC license.
9450
- * See the LICENSE file in the root directory of this source tree.
9451
- *)
9452
-
9453
9521
  lucide-react/dist/esm/icons/lock-open.js:
9454
- (**
9455
- * @license lucide-react v0.468.0 - ISC
9456
- *
9457
- * This source code is licensed under the ISC license.
9458
- * See the LICENSE file in the root directory of this source tree.
9459
- *)
9460
-
9461
9522
  lucide-react/dist/esm/icons/lock.js:
9462
- (**
9463
- * @license lucide-react v0.468.0 - ISC
9464
- *
9465
- * This source code is licensed under the ISC license.
9466
- * See the LICENSE file in the root directory of this source tree.
9467
- *)
9468
-
9469
9523
  lucide-react/dist/esm/icons/maximize-2.js:
9470
- (**
9471
- * @license lucide-react v0.468.0 - ISC
9472
- *
9473
- * This source code is licensed under the ISC license.
9474
- * See the LICENSE file in the root directory of this source tree.
9475
- *)
9476
-
9477
9524
  lucide-react/dist/esm/icons/minimize-2.js:
9478
- (**
9479
- * @license lucide-react v0.468.0 - ISC
9480
- *
9481
- * This source code is licensed under the ISC license.
9482
- * See the LICENSE file in the root directory of this source tree.
9483
- *)
9484
-
9485
9525
  lucide-react/dist/esm/icons/monitor.js:
9486
- (**
9487
- * @license lucide-react v0.468.0 - ISC
9488
- *
9489
- * This source code is licensed under the ISC license.
9490
- * See the LICENSE file in the root directory of this source tree.
9491
- *)
9492
-
9493
9526
  lucide-react/dist/esm/icons/panel-left.js:
9494
- (**
9495
- * @license lucide-react v0.468.0 - ISC
9496
- *
9497
- * This source code is licensed under the ISC license.
9498
- * See the LICENSE file in the root directory of this source tree.
9499
- *)
9500
-
9501
9527
  lucide-react/dist/esm/icons/panel-right.js:
9502
- (**
9503
- * @license lucide-react v0.468.0 - ISC
9504
- *
9505
- * This source code is licensed under the ISC license.
9506
- * See the LICENSE file in the root directory of this source tree.
9507
- *)
9508
-
9509
9528
  lucide-react/dist/esm/icons/plus.js:
9510
- (**
9511
- * @license lucide-react v0.468.0 - ISC
9512
- *
9513
- * This source code is licensed under the ISC license.
9514
- * See the LICENSE file in the root directory of this source tree.
9515
- *)
9516
-
9517
9529
  lucide-react/dist/esm/icons/rectangle-ellipsis.js:
9518
- (**
9519
- * @license lucide-react v0.468.0 - ISC
9520
- *
9521
- * This source code is licensed under the ISC license.
9522
- * See the LICENSE file in the root directory of this source tree.
9523
- *)
9524
-
9525
9530
  lucide-react/dist/esm/icons/redo-2.js:
9526
- (**
9527
- * @license lucide-react v0.468.0 - ISC
9528
- *
9529
- * This source code is licensed under the ISC license.
9530
- * See the LICENSE file in the root directory of this source tree.
9531
- *)
9532
-
9533
9531
  lucide-react/dist/esm/icons/search.js:
9534
- (**
9535
- * @license lucide-react v0.468.0 - ISC
9536
- *
9537
- * This source code is licensed under the ISC license.
9538
- * See the LICENSE file in the root directory of this source tree.
9539
- *)
9540
-
9541
9532
  lucide-react/dist/esm/icons/sliders-horizontal.js:
9542
- (**
9543
- * @license lucide-react v0.468.0 - ISC
9544
- *
9545
- * This source code is licensed under the ISC license.
9546
- * See the LICENSE file in the root directory of this source tree.
9547
- *)
9548
-
9549
9533
  lucide-react/dist/esm/icons/smartphone.js:
9550
- (**
9551
- * @license lucide-react v0.468.0 - ISC
9552
- *
9553
- * This source code is licensed under the ISC license.
9554
- * See the LICENSE file in the root directory of this source tree.
9555
- *)
9556
-
9557
9534
  lucide-react/dist/esm/icons/tablet.js:
9558
- (**
9559
- * @license lucide-react v0.468.0 - ISC
9560
- *
9561
- * This source code is licensed under the ISC license.
9562
- * See the LICENSE file in the root directory of this source tree.
9563
- *)
9564
-
9565
9535
  lucide-react/dist/esm/icons/toy-brick.js:
9566
- (**
9567
- * @license lucide-react v0.468.0 - ISC
9568
- *
9569
- * This source code is licensed under the ISC license.
9570
- * See the LICENSE file in the root directory of this source tree.
9571
- *)
9572
-
9573
9536
  lucide-react/dist/esm/icons/trash.js:
9574
- (**
9575
- * @license lucide-react v0.468.0 - ISC
9576
- *
9577
- * This source code is licensed under the ISC license.
9578
- * See the LICENSE file in the root directory of this source tree.
9579
- *)
9580
-
9581
9537
  lucide-react/dist/esm/icons/type.js:
9582
- (**
9583
- * @license lucide-react v0.468.0 - ISC
9584
- *
9585
- * This source code is licensed under the ISC license.
9586
- * See the LICENSE file in the root directory of this source tree.
9587
- *)
9588
-
9589
9538
  lucide-react/dist/esm/icons/undo-2.js:
9590
- (**
9591
- * @license lucide-react v0.468.0 - ISC
9592
- *
9593
- * This source code is licensed under the ISC license.
9594
- * See the LICENSE file in the root directory of this source tree.
9595
- *)
9596
-
9597
9539
  lucide-react/dist/esm/icons/x.js:
9598
- (**
9599
- * @license lucide-react v0.468.0 - ISC
9600
- *
9601
- * This source code is licensed under the ISC license.
9602
- * See the LICENSE file in the root directory of this source tree.
9603
- *)
9604
-
9605
9540
  lucide-react/dist/esm/icons/zoom-in.js:
9606
- (**
9607
- * @license lucide-react v0.468.0 - ISC
9608
- *
9609
- * This source code is licensed under the ISC license.
9610
- * See the LICENSE file in the root directory of this source tree.
9611
- *)
9612
-
9613
9541
  lucide-react/dist/esm/icons/zoom-out.js:
9614
- (**
9615
- * @license lucide-react v0.468.0 - ISC
9616
- *
9617
- * This source code is licensed under the ISC license.
9618
- * See the LICENSE file in the root directory of this source tree.
9619
- *)
9620
-
9621
9542
  lucide-react/dist/esm/lucide-react.js:
9622
9543
  (**
9623
9544
  * @license lucide-react v0.468.0 - ISC