@measured/puck 0.17.0-canary.f71da6d → 0.17.0-canary.fe9321f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -99,35 +99,45 @@ var require_classnames = __commonJS({
99
99
  (function() {
100
100
  "use strict";
101
101
  var hasOwn = {}.hasOwnProperty;
102
- var nativeCodeString = "[native code]";
103
102
  function classNames() {
104
- var classes = [];
103
+ var classes = "";
105
104
  for (var i = 0; i < arguments.length; i++) {
106
105
  var arg = arguments[i];
107
- if (!arg) continue;
108
- var argType = typeof arg;
109
- if (argType === "string" || argType === "number") {
110
- classes.push(arg);
111
- } else if (Array.isArray(arg)) {
112
- if (arg.length) {
113
- var inner = classNames.apply(null, arg);
114
- if (inner) {
115
- classes.push(inner);
116
- }
117
- }
118
- } else if (argType === "object") {
119
- if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
120
- classes.push(arg.toString());
121
- continue;
122
- }
123
- for (var key in arg) {
124
- if (hasOwn.call(arg, key) && arg[key]) {
125
- classes.push(key);
126
- }
127
- }
106
+ if (arg) {
107
+ classes = appendClass(classes, parseValue(arg));
108
+ }
109
+ }
110
+ return classes;
111
+ }
112
+ function parseValue(arg) {
113
+ if (typeof arg === "string" || typeof arg === "number") {
114
+ return arg;
115
+ }
116
+ if (typeof arg !== "object") {
117
+ return "";
118
+ }
119
+ if (Array.isArray(arg)) {
120
+ return classNames.apply(null, arg);
121
+ }
122
+ if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
123
+ return arg.toString();
124
+ }
125
+ var classes = "";
126
+ for (var key in arg) {
127
+ if (hasOwn.call(arg, key) && arg[key]) {
128
+ classes = appendClass(classes, key);
128
129
  }
129
130
  }
130
- return classes.join(" ");
131
+ return classes;
132
+ }
133
+ function appendClass(value, newClass) {
134
+ if (!newClass) {
135
+ return value;
136
+ }
137
+ if (value) {
138
+ return value + " " + newClass;
139
+ }
140
+ return value + newClass;
131
141
  }
132
142
  if (typeof module2 !== "undefined" && module2.exports) {
133
143
  classNames.default = classNames;
@@ -279,7 +289,7 @@ init_react_import();
279
289
  var styles_module_default2 = { "InputWrapper": "_InputWrapper_1l5m8_1", "Input": "_Input_1l5m8_1", "Input-label": "_Input-label_1l5m8_26", "Input-labelIcon": "_Input-labelIcon_1l5m8_35", "Input-disabledIcon": "_Input-disabledIcon_1l5m8_42", "Input-input": "_Input-input_1l5m8_47", "Input--readOnly": "_Input--readOnly_1l5m8_91", "Input-radioGroupItems": "_Input-radioGroupItems_1l5m8_102", "Input-radio": "_Input-radio_1l5m8_102", "Input-radioInner": "_Input-radioInner_1l5m8_119", "Input-radioInput": "_Input-radioInput_1l5m8_164" };
280
290
 
281
291
  // components/AutoField/index.tsx
282
- var import_react13 = require("react");
292
+ var import_react15 = require("react");
283
293
 
284
294
  // components/AutoField/fields/index.tsx
285
295
  init_react_import();
@@ -1637,6 +1647,7 @@ var DefaultField = ({
1637
1647
  className: getClassName6("input"),
1638
1648
  autoComplete: "off",
1639
1649
  type: field.type,
1650
+ title: label || name,
1640
1651
  name,
1641
1652
  value: typeof value === "undefined" ? "" : value.toString(),
1642
1653
  onChange: (e) => {
@@ -2051,6 +2062,20 @@ var ExternalField = ({
2051
2062
 
2052
2063
  // components/AutoField/fields/RadioField/index.tsx
2053
2064
  init_react_import();
2065
+ var import_react12 = require("react");
2066
+
2067
+ // lib/safe-json-parse.ts
2068
+ init_react_import();
2069
+ var safeJsonParse = (str) => {
2070
+ try {
2071
+ const jsonValue = JSON.parse(str);
2072
+ return jsonValue;
2073
+ } catch (e) {
2074
+ return str;
2075
+ }
2076
+ };
2077
+
2078
+ // components/AutoField/fields/RadioField/index.tsx
2054
2079
  var import_jsx_runtime16 = require("react/jsx-runtime");
2055
2080
  var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
2056
2081
  var RadioField = ({
@@ -2063,6 +2088,10 @@ var RadioField = ({
2063
2088
  label,
2064
2089
  Label
2065
2090
  }) => {
2091
+ const flatOptions = (0, import_react12.useMemo)(
2092
+ () => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
2093
+ [field]
2094
+ );
2066
2095
  if (field.type !== "radio" || !field.options) {
2067
2096
  return null;
2068
2097
  }
@@ -2086,11 +2115,12 @@ var RadioField = ({
2086
2115
  value: option.value,
2087
2116
  name,
2088
2117
  onChange: (e) => {
2089
- if (e.currentTarget.value === "true" || e.currentTarget.value === "false") {
2090
- onChange(JSON.parse(e.currentTarget.value));
2091
- return;
2118
+ const jsonValue = safeJsonParse(e.target.value) || e.target.value;
2119
+ if (flatOptions.indexOf(jsonValue) > -1) {
2120
+ onChange(jsonValue);
2121
+ } else {
2122
+ onChange(e.target.value);
2092
2123
  }
2093
- onChange(e.currentTarget.value);
2094
2124
  },
2095
2125
  disabled: readOnly,
2096
2126
  checked: value === option.value
@@ -2107,6 +2137,7 @@ var RadioField = ({
2107
2137
 
2108
2138
  // components/AutoField/fields/SelectField/index.tsx
2109
2139
  init_react_import();
2140
+ var import_react13 = require("react");
2110
2141
  var import_jsx_runtime17 = require("react/jsx-runtime");
2111
2142
  var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
2112
2143
  var SelectField = ({
@@ -2119,6 +2150,10 @@ var SelectField = ({
2119
2150
  readOnly,
2120
2151
  id
2121
2152
  }) => {
2153
+ const flatOptions = (0, import_react13.useMemo)(
2154
+ () => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
2155
+ [field]
2156
+ );
2122
2157
  if (field.type !== "select" || !field.options) {
2123
2158
  return null;
2124
2159
  }
@@ -2132,14 +2167,16 @@ var SelectField = ({
2132
2167
  "select",
2133
2168
  {
2134
2169
  id,
2170
+ title: label || name,
2135
2171
  className: getClassName12("input"),
2136
2172
  disabled: readOnly,
2137
2173
  onChange: (e) => {
2138
- if (e.currentTarget.value === "true" || e.currentTarget.value === "false") {
2139
- onChange(JSON.parse(e.currentTarget.value));
2140
- return;
2174
+ const jsonValue = safeJsonParse(e.target.value) || e.target.value;
2175
+ if (flatOptions.indexOf(jsonValue) > -1) {
2176
+ onChange(jsonValue);
2177
+ } else {
2178
+ onChange(e.target.value);
2141
2179
  }
2142
- onChange(e.currentTarget.value);
2143
2180
  },
2144
2181
  value,
2145
2182
  children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
@@ -2253,7 +2290,7 @@ var ObjectField = ({
2253
2290
 
2254
2291
  // lib/use-safe-id.ts
2255
2292
  init_react_import();
2256
- var import_react12 = __toESM(require("react"));
2293
+ var import_react14 = __toESM(require("react"));
2257
2294
 
2258
2295
  // lib/generate-id.ts
2259
2296
  init_react_import();
@@ -2262,10 +2299,10 @@ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, impor
2262
2299
 
2263
2300
  // lib/use-safe-id.ts
2264
2301
  var useSafeId = () => {
2265
- if (typeof import_react12.default.useId !== "undefined") {
2266
- return import_react12.default.useId();
2302
+ if (typeof import_react14.default.useId !== "undefined") {
2303
+ return import_react14.default.useId();
2267
2304
  }
2268
- const [id] = (0, import_react12.useState)(generateId());
2305
+ const [id] = (0, import_react14.useState)(generateId());
2269
2306
  return id;
2270
2307
  };
2271
2308
 
@@ -2299,7 +2336,7 @@ var FieldLabelInternal2 = ({
2299
2336
  readOnly
2300
2337
  }) => {
2301
2338
  const { overrides } = useAppContext();
2302
- const Wrapper = (0, import_react13.useMemo)(
2339
+ const Wrapper = (0, import_react15.useMemo)(
2303
2340
  () => overrides.fieldLabel || FieldLabel,
2304
2341
  [overrides]
2305
2342
  );
@@ -2352,7 +2389,7 @@ function AutoFieldInternal(props) {
2352
2389
  Label,
2353
2390
  id: resolvedId
2354
2391
  });
2355
- const onFocus = (0, import_react13.useCallback)(
2392
+ const onFocus = (0, import_react15.useCallback)(
2356
2393
  (e) => {
2357
2394
  if (mergedProps.name && e.target.nodeName === "INPUT") {
2358
2395
  e.stopPropagation();
@@ -2366,7 +2403,7 @@ function AutoFieldInternal(props) {
2366
2403
  },
2367
2404
  [mergedProps.name]
2368
2405
  );
2369
- const onBlur = (0, import_react13.useCallback)((e) => {
2406
+ const onBlur = (0, import_react15.useCallback)((e) => {
2370
2407
  if ("name" in e.target) {
2371
2408
  dispatch({
2372
2409
  type: "setUi",
@@ -2385,12 +2422,23 @@ function AutoFieldInternal(props) {
2385
2422
  }
2386
2423
  const children = defaultFields[field.type](mergedProps);
2387
2424
  const Render2 = render[field.type];
2388
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children })) });
2425
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2426
+ "div",
2427
+ {
2428
+ className: getClassNameWrapper(),
2429
+ onFocus,
2430
+ onBlur,
2431
+ onClick: (e) => {
2432
+ e.stopPropagation();
2433
+ },
2434
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
2435
+ }
2436
+ );
2389
2437
  }
2390
2438
  function AutoFieldPrivate(props) {
2391
2439
  const { state } = useAppContext();
2392
2440
  const { value, onChange } = props;
2393
- const [localValue, setLocalValue] = (0, import_react13.useState)(value);
2441
+ const [localValue, setLocalValue] = (0, import_react15.useState)(value);
2394
2442
  const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
2395
2443
  (val, ui) => {
2396
2444
  onChange(val, ui);
@@ -2398,11 +2446,11 @@ function AutoFieldPrivate(props) {
2398
2446
  50,
2399
2447
  { leading: true }
2400
2448
  );
2401
- const onChangeLocal = (0, import_react13.useCallback)((val, ui) => {
2449
+ const onChangeLocal = (0, import_react15.useCallback)((val, ui) => {
2402
2450
  setLocalValue(val);
2403
2451
  onChangeDb(val, ui);
2404
2452
  }, []);
2405
- (0, import_react13.useEffect)(() => {
2453
+ (0, import_react15.useEffect)(() => {
2406
2454
  if (state.ui.field.focus !== props.name) {
2407
2455
  setLocalValue(value);
2408
2456
  }
@@ -2414,7 +2462,7 @@ function AutoFieldPrivate(props) {
2414
2462
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
2415
2463
  }
2416
2464
  function AutoField(props) {
2417
- const DefaultLabel = (0, import_react13.useMemo)(() => {
2465
+ const DefaultLabel = (0, import_react15.useMemo)(() => {
2418
2466
  const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2419
2467
  "div",
2420
2468
  __spreadProps(__spreadValues({}, labelProps), {
@@ -2434,11 +2482,11 @@ init_react_import();
2434
2482
  var styles_module_default10 = { "Drawer": "_Drawer_1oa7v_1", "DrawerItem--disabled": "_DrawerItem--disabled_1oa7v_5", "DrawerItem-draggable": "_DrawerItem-draggable_1oa7v_5", "DrawerItem-default": "_DrawerItem-default_1oa7v_11", "DrawerItem-draggableWrapper": "_DrawerItem-draggableWrapper_1oa7v_11", "DrawerItem": "_DrawerItem_1oa7v_5", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_1oa7v_36", "DrawerItem-name": "_DrawerItem-name_1oa7v_54" };
2435
2483
 
2436
2484
  // components/Drawer/index.tsx
2437
- var import_react14 = require("react");
2485
+ var import_react16 = require("react");
2438
2486
  var import_jsx_runtime21 = require("react/jsx-runtime");
2439
2487
  var getClassName16 = get_class_name_factory_default("Drawer", styles_module_default10);
2440
2488
  var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
2441
- var drawerContext = (0, import_react14.createContext)({
2489
+ var drawerContext = (0, import_react16.createContext)({
2442
2490
  droppableId: ""
2443
2491
  });
2444
2492
  var DrawerDraggable = ({
@@ -2469,9 +2517,9 @@ var DrawerItem = ({
2469
2517
  index,
2470
2518
  isDragDisabled
2471
2519
  }) => {
2472
- const ctx = (0, import_react14.useContext)(drawerContext);
2520
+ const ctx = (0, import_react16.useContext)(drawerContext);
2473
2521
  const resolvedId = `${ctx.droppableId}::${id || name}`;
2474
- const CustomInner = (0, import_react14.useMemo)(
2522
+ const CustomInner = (0, import_react16.useMemo)(
2475
2523
  () => children || (({ children: children2, name: name2 }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
2476
2524
  [children]
2477
2525
  );
@@ -2512,11 +2560,11 @@ Drawer.Item = DrawerItem;
2512
2560
 
2513
2561
  // components/DropZone/index.tsx
2514
2562
  init_react_import();
2515
- var import_react18 = require("react");
2563
+ var import_react20 = require("react");
2516
2564
 
2517
2565
  // components/DraggableComponent/index.tsx
2518
2566
  init_react_import();
2519
- var import_react16 = require("react");
2567
+ var import_react18 = require("react");
2520
2568
  var import_dnd4 = require("@measured/dnd");
2521
2569
 
2522
2570
  // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
@@ -2525,10 +2573,10 @@ var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1bhad
2525
2573
 
2526
2574
  // lib/use-modifier-held.ts
2527
2575
  init_react_import();
2528
- var import_react15 = require("react");
2576
+ var import_react17 = require("react");
2529
2577
  var useModifierHeld = (modifier) => {
2530
- const [modifierHeld, setModifierHeld] = (0, import_react15.useState)(false);
2531
- (0, import_react15.useEffect)(() => {
2578
+ const [modifierHeld, setModifierHeld] = (0, import_react17.useState)(false);
2579
+ (0, import_react17.useEffect)(() => {
2532
2580
  function downHandler({ key }) {
2533
2581
  if (key === modifier) {
2534
2582
  setModifierHeld(true);
@@ -2597,14 +2645,14 @@ var DraggableComponent = ({
2597
2645
  const { zoomConfig, status, overrides, selectedItem, getPermissions } = useAppContext();
2598
2646
  const isModifierHeld = useModifierHeld("Alt");
2599
2647
  const El = status !== "LOADING" ? import_dnd4.Draggable : DefaultDraggable;
2600
- (0, import_react16.useEffect)(onMount, []);
2601
- const [disableSecondaryAnimation, setDisableSecondaryAnimation] = (0, import_react16.useState)(false);
2602
- (0, import_react16.useEffect)(() => {
2648
+ (0, import_react18.useEffect)(onMount, []);
2649
+ const [disableSecondaryAnimation, setDisableSecondaryAnimation] = (0, import_react18.useState)(false);
2650
+ (0, import_react18.useEffect)(() => {
2603
2651
  if (isIos()) {
2604
2652
  setDisableSecondaryAnimation(true);
2605
2653
  }
2606
2654
  }, []);
2607
- const CustomActionBar = (0, import_react16.useMemo)(
2655
+ const CustomActionBar = (0, import_react18.useMemo)(
2608
2656
  () => overrides.actionBar || DefaultActionBar,
2609
2657
  [overrides.actionBar]
2610
2658
  );
@@ -2682,7 +2730,7 @@ var styles_module_default12 = { "DropZone": "_DropZone_djoti_1", "DropZone-conte
2682
2730
 
2683
2731
  // components/DropZone/context.tsx
2684
2732
  init_react_import();
2685
- var import_react17 = require("react");
2733
+ var import_react19 = require("react");
2686
2734
  var import_use_debounce2 = require("use-debounce");
2687
2735
 
2688
2736
  // lib/get-zone-id.ts
@@ -2699,29 +2747,29 @@ var getZoneId = (zoneCompound) => {
2699
2747
 
2700
2748
  // components/DropZone/context.tsx
2701
2749
  var import_jsx_runtime23 = require("react/jsx-runtime");
2702
- var dropZoneContext = (0, import_react17.createContext)(null);
2750
+ var dropZoneContext = (0, import_react19.createContext)(null);
2703
2751
  var DropZoneProvider = ({
2704
2752
  children,
2705
2753
  value
2706
2754
  }) => {
2707
- const [hoveringArea, setHoveringArea] = (0, import_react17.useState)(null);
2708
- const [hoveringZone, setHoveringZone] = (0, import_react17.useState)(
2755
+ const [hoveringArea, setHoveringArea] = (0, import_react19.useState)(null);
2756
+ const [hoveringZone, setHoveringZone] = (0, import_react19.useState)(
2709
2757
  rootDroppableId
2710
2758
  );
2711
- const [hoveringComponent, setHoveringComponent] = (0, import_react17.useState)();
2759
+ const [hoveringComponent, setHoveringComponent] = (0, import_react19.useState)();
2712
2760
  const [hoveringAreaDb] = (0, import_use_debounce2.useDebounce)(hoveringArea, 75, { leading: false });
2713
- const [areasWithZones, setAreasWithZones] = (0, import_react17.useState)(
2761
+ const [areasWithZones, setAreasWithZones] = (0, import_react19.useState)(
2714
2762
  {}
2715
2763
  );
2716
- const [activeZones, setActiveZones] = (0, import_react17.useState)({});
2764
+ const [activeZones, setActiveZones] = (0, import_react19.useState)({});
2717
2765
  const { dispatch = null } = value ? value : {};
2718
- const registerZoneArea = (0, import_react17.useCallback)(
2766
+ const registerZoneArea = (0, import_react19.useCallback)(
2719
2767
  (area) => {
2720
2768
  setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
2721
2769
  },
2722
2770
  [setAreasWithZones]
2723
2771
  );
2724
- const registerZone = (0, import_react17.useCallback)(
2772
+ const registerZone = (0, import_react19.useCallback)(
2725
2773
  (zoneCompound) => {
2726
2774
  if (!dispatch) {
2727
2775
  return;
@@ -2734,7 +2782,7 @@ var DropZoneProvider = ({
2734
2782
  },
2735
2783
  [setActiveZones, dispatch]
2736
2784
  );
2737
- const unregisterZone = (0, import_react17.useCallback)(
2785
+ const unregisterZone = (0, import_react19.useCallback)(
2738
2786
  (zoneCompound) => {
2739
2787
  if (!dispatch) {
2740
2788
  return;
@@ -2749,8 +2797,8 @@ var DropZoneProvider = ({
2749
2797
  },
2750
2798
  [setActiveZones, dispatch]
2751
2799
  );
2752
- const [pathData, setPathData] = (0, import_react17.useState)();
2753
- const registerPath = (0, import_react17.useCallback)(
2800
+ const [pathData, setPathData] = (0, import_react19.useState)();
2801
+ const registerPath = (0, import_react19.useCallback)(
2754
2802
  (selector) => {
2755
2803
  if (!(value == null ? void 0 : value.data)) {
2756
2804
  return;
@@ -2775,7 +2823,7 @@ var DropZoneProvider = ({
2775
2823
  },
2776
2824
  [value, setPathData]
2777
2825
  );
2778
- const [zoneWillDrag, setZoneWillDrag] = (0, import_react17.useState)("");
2826
+ const [zoneWillDrag, setZoneWillDrag] = (0, import_react19.useState)("");
2779
2827
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_jsx_runtime23.Fragment, { children: value && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2780
2828
  dropZoneContext.Provider,
2781
2829
  {
@@ -2807,7 +2855,7 @@ var getClassName18 = get_class_name_factory_default("DropZone", styles_module_de
2807
2855
  function DropZoneEdit({ zone, allow, disallow, style }) {
2808
2856
  var _a;
2809
2857
  const appContext2 = useAppContext();
2810
- const ctx = (0, import_react18.useContext)(dropZoneContext);
2858
+ const ctx = (0, import_react20.useContext)(dropZoneContext);
2811
2859
  const {
2812
2860
  // These all need setting via context
2813
2861
  data,
@@ -2826,12 +2874,12 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
2826
2874
  } = ctx || {};
2827
2875
  let content = data.content || [];
2828
2876
  let zoneCompound = rootDroppableId;
2829
- (0, import_react18.useEffect)(() => {
2877
+ (0, import_react20.useEffect)(() => {
2830
2878
  if (areaId && registerZoneArea) {
2831
2879
  registerZoneArea(areaId);
2832
2880
  }
2833
2881
  }, [areaId]);
2834
- (0, import_react18.useEffect)(() => {
2882
+ (0, import_react20.useEffect)(() => {
2835
2883
  if (ctx == null ? void 0 : ctx.registerZone) {
2836
2884
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
2837
2885
  }
@@ -3087,7 +3135,7 @@ function DropZoneEdit({ zone, allow, disallow, style }) {
3087
3135
  );
3088
3136
  }
3089
3137
  function DropZoneRender({ zone }) {
3090
- const ctx = (0, import_react18.useContext)(dropZoneContext);
3138
+ const ctx = (0, import_react20.useContext)(dropZoneContext);
3091
3139
  const { data, areaId = "root", config } = ctx || {};
3092
3140
  let zoneCompound = rootDroppableId;
3093
3141
  let content = (data == null ? void 0 : data.content) || [];
@@ -3119,7 +3167,7 @@ function DropZoneRender({ zone }) {
3119
3167
  }) });
3120
3168
  }
3121
3169
  function DropZone(props) {
3122
- const ctx = (0, import_react18.useContext)(dropZoneContext);
3170
+ const ctx = (0, import_react20.useContext)(dropZoneContext);
3123
3171
  if ((ctx == null ? void 0 : ctx.mode) === "edit") {
3124
3172
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneEdit, __spreadValues({}, props));
3125
3173
  }
@@ -3128,11 +3176,11 @@ function DropZone(props) {
3128
3176
 
3129
3177
  // components/Puck/index.tsx
3130
3178
  init_react_import();
3131
- var import_react33 = require("react");
3179
+ var import_react35 = require("react");
3132
3180
 
3133
3181
  // lib/use-placeholder-style.ts
3134
3182
  init_react_import();
3135
- var import_react19 = require("react");
3183
+ var import_react21 = require("react");
3136
3184
 
3137
3185
  // lib/get-frame.ts
3138
3186
  init_react_import();
@@ -3147,7 +3195,7 @@ var getFrame = () => {
3147
3195
  // lib/use-placeholder-style.ts
3148
3196
  var usePlaceholderStyle = () => {
3149
3197
  const queryAttr = "data-rfd-drag-handle-draggable-id";
3150
- const [placeholderStyle, setPlaceholderStyle] = (0, import_react19.useState)();
3198
+ const [placeholderStyle, setPlaceholderStyle] = (0, import_react21.useState)();
3151
3199
  const onDragStartOrUpdate = (draggedItem) => {
3152
3200
  var _a;
3153
3201
  const draggableId = draggedItem.draggableId;
@@ -3200,7 +3248,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_125qe_1", "Si
3200
3248
 
3201
3249
  // lib/use-breadcrumbs.ts
3202
3250
  init_react_import();
3203
- var import_react20 = require("react");
3251
+ var import_react22 = require("react");
3204
3252
  var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
3205
3253
  const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
3206
3254
  const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
@@ -3250,8 +3298,8 @@ var useBreadcrumbs = (renderCount) => {
3250
3298
  state: { data },
3251
3299
  selectedItem
3252
3300
  } = useAppContext();
3253
- const dzContext = (0, import_react20.useContext)(dropZoneContext);
3254
- return (0, import_react20.useMemo)(() => {
3301
+ const dzContext = (0, import_react22.useContext)(dropZoneContext);
3302
+ return (0, import_react22.useMemo)(() => {
3255
3303
  const breadcrumbs = convertPathDataToBreadcrumbs(
3256
3304
  selectedItem,
3257
3305
  dzContext == null ? void 0 : dzContext.pathData,
@@ -3735,15 +3783,15 @@ init_react_import();
3735
3783
  var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields--isLoading": "_PuckFields--isLoading_jp3lw_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_jp3lw_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_jp3lw_25" };
3736
3784
 
3737
3785
  // components/Puck/components/Fields/index.tsx
3738
- var import_react22 = require("react");
3786
+ var import_react24 = require("react");
3739
3787
 
3740
3788
  // lib/use-parent.ts
3741
3789
  init_react_import();
3742
- var import_react21 = require("react");
3790
+ var import_react23 = require("react");
3743
3791
  var useParent = (itemSelector) => {
3744
3792
  var _a;
3745
3793
  const { selectedItem, state } = useAppContext();
3746
- const { pathData } = (0, import_react21.useContext)(dropZoneContext) || {};
3794
+ const { pathData } = (0, import_react23.useContext)(dropZoneContext) || {};
3747
3795
  const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
3748
3796
  const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
3749
3797
  const lastItem = breadcrumbs[breadcrumbs.length - 1];
@@ -3769,20 +3817,20 @@ var useResolvedFields = () => {
3769
3817
  const { data } = state;
3770
3818
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
3771
3819
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
3772
- const defaultFields = (0, import_react22.useMemo)(
3820
+ const defaultFields = (0, import_react24.useMemo)(
3773
3821
  () => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
3774
3822
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
3775
3823
  );
3776
3824
  const rootProps = data.root.props || data.root;
3777
- const [lastSelectedData, setLastSelectedData] = (0, import_react22.useState)({});
3778
- const [resolvedFields, setResolvedFields] = (0, import_react22.useState)(defaultFields);
3779
- const [fieldsLoading, setFieldsLoading] = (0, import_react22.useState)(false);
3825
+ const [lastSelectedData, setLastSelectedData] = (0, import_react24.useState)({});
3826
+ const [resolvedFields, setResolvedFields] = (0, import_react24.useState)(defaultFields);
3827
+ const [fieldsLoading, setFieldsLoading] = (0, import_react24.useState)(false);
3780
3828
  const defaultResolveFields = (_componentData, _params) => defaultFields;
3781
3829
  const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
3782
3830
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
3783
3831
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
3784
3832
  const hasResolver = hasComponentResolver || hasRootResolver;
3785
- const resolveFields = (0, import_react22.useCallback)(
3833
+ const resolveFields = (0, import_react24.useCallback)(
3786
3834
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
3787
3835
  var _a2;
3788
3836
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -3820,7 +3868,7 @@ var useResolvedFields = () => {
3820
3868
  }),
3821
3869
  [data, config, componentData, selectedItem, resolvedFields, state]
3822
3870
  );
3823
- (0, import_react22.useEffect)(() => {
3871
+ (0, import_react24.useEffect)(() => {
3824
3872
  if (hasResolver) {
3825
3873
  setFieldsLoading(true);
3826
3874
  resolveFields(defaultFields).then((fields) => {
@@ -3851,7 +3899,7 @@ var Fields = () => {
3851
3899
  const componentResolving = selectedItem ? ((_a = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.loadingCount) > 0 : ((_b = componentState["puck-root"]) == null ? void 0 : _b.loadingCount) > 0;
3852
3900
  const isLoading = fieldsResolving || componentResolving;
3853
3901
  const rootProps = data.root.props || data.root;
3854
- const Wrapper = (0, import_react22.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
3902
+ const Wrapper = (0, import_react24.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
3855
3903
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
3856
3904
  "form",
3857
3905
  {
@@ -3930,34 +3978,36 @@ var Fields = () => {
3930
3978
  const { edit } = getPermissions({
3931
3979
  item: selectedItem
3932
3980
  });
3981
+ const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
3933
3982
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3934
3983
  AutoFieldPrivate,
3935
3984
  {
3936
3985
  field,
3937
3986
  name: fieldName,
3938
- id: `${selectedItem.props.id}_${fieldName}`,
3987
+ id,
3939
3988
  readOnly: !edit || readOnly[fieldName],
3940
3989
  value: selectedItem.props[fieldName],
3941
3990
  onChange
3942
3991
  },
3943
- `${selectedItem.props.id}_${fieldName}`
3992
+ id
3944
3993
  );
3945
3994
  } else {
3946
3995
  const readOnly = data.root.readOnly || {};
3947
3996
  const { edit } = getPermissions({
3948
3997
  root: true
3949
3998
  });
3999
+ const id = `root_${field.type}_${fieldName}`;
3950
4000
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3951
4001
  AutoFieldPrivate,
3952
4002
  {
3953
4003
  field,
3954
4004
  name: fieldName,
3955
- id: `root_${fieldName}`,
4005
+ id,
3956
4006
  readOnly: !edit || readOnly[fieldName],
3957
4007
  value: rootProps[fieldName],
3958
4008
  onChange
3959
4009
  },
3960
- `page_${fieldName}`
4010
+ id
3961
4011
  );
3962
4012
  }
3963
4013
  }) }),
@@ -3972,7 +4022,7 @@ init_react_import();
3972
4022
 
3973
4023
  // lib/use-component-list.tsx
3974
4024
  init_react_import();
3975
- var import_react23 = require("react");
4025
+ var import_react25 = require("react");
3976
4026
 
3977
4027
  // components/ComponentList/index.tsx
3978
4028
  init_react_import();
@@ -4050,8 +4100,8 @@ ComponentList.Item = ComponentListItem;
4050
4100
  // lib/use-component-list.tsx
4051
4101
  var import_jsx_runtime29 = require("react/jsx-runtime");
4052
4102
  var useComponentList = (config, ui) => {
4053
- const [componentList, setComponentList] = (0, import_react23.useState)();
4054
- (0, import_react23.useEffect)(() => {
4103
+ const [componentList, setComponentList] = (0, import_react25.useState)();
4104
+ (0, import_react25.useEffect)(() => {
4055
4105
  var _a, _b, _c;
4056
4106
  if (Object.keys(ui.componentList).length > 0) {
4057
4107
  const matchedComponents = [];
@@ -4120,22 +4170,22 @@ var useComponentList = (config, ui) => {
4120
4170
  };
4121
4171
 
4122
4172
  // components/Puck/components/Components/index.tsx
4123
- var import_react24 = require("react");
4173
+ var import_react26 = require("react");
4124
4174
  var import_jsx_runtime30 = require("react/jsx-runtime");
4125
4175
  var Components = () => {
4126
4176
  const { config, state, overrides } = useAppContext();
4127
4177
  const componentList = useComponentList(config, state.ui);
4128
- const Wrapper = (0, import_react24.useMemo)(() => overrides.components || "div", [overrides]);
4178
+ const Wrapper = (0, import_react26.useMemo)(() => overrides.components || "div", [overrides]);
4129
4179
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
4130
4180
  };
4131
4181
 
4132
4182
  // components/Puck/components/Preview/index.tsx
4133
4183
  init_react_import();
4134
- var import_react26 = require("react");
4184
+ var import_react28 = require("react");
4135
4185
 
4136
4186
  // components/AutoFrame/index.tsx
4137
4187
  init_react_import();
4138
- var import_react25 = require("react");
4188
+ var import_react27 = require("react");
4139
4189
  var import_object_hash = __toESM(require("object-hash"));
4140
4190
  var import_react_dom2 = require("react-dom");
4141
4191
  var import_jsx_runtime31 = require("react/jsx-runtime");
@@ -4181,7 +4231,7 @@ var CopyHostStyles = ({
4181
4231
  onStylesLoaded = () => null
4182
4232
  }) => {
4183
4233
  const { document: doc, window: win } = useFrame();
4184
- (0, import_react25.useEffect)(() => {
4234
+ (0, import_react27.useEffect)(() => {
4185
4235
  if (!win || !doc) {
4186
4236
  return () => {
4187
4237
  };
@@ -4340,8 +4390,8 @@ var CopyHostStyles = ({
4340
4390
  }, []);
4341
4391
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
4342
4392
  };
4343
- var autoFrameContext = (0, import_react25.createContext)({});
4344
- var useFrame = () => (0, import_react25.useContext)(autoFrameContext);
4393
+ var autoFrameContext = (0, import_react27.createContext)({});
4394
+ var useFrame = () => (0, import_react27.useContext)(autoFrameContext);
4345
4395
  function AutoFrame(_a) {
4346
4396
  var _b = _a, {
4347
4397
  children,
@@ -4356,11 +4406,11 @@ function AutoFrame(_a) {
4356
4406
  "id",
4357
4407
  "onStylesLoaded"
4358
4408
  ]);
4359
- const [loaded, setLoaded] = (0, import_react25.useState)(false);
4360
- const [ctx, setCtx] = (0, import_react25.useState)({});
4361
- const ref = (0, import_react25.useRef)(null);
4362
- const [mountTarget, setMountTarget] = (0, import_react25.useState)();
4363
- (0, import_react25.useEffect)(() => {
4409
+ const [loaded, setLoaded] = (0, import_react27.useState)(false);
4410
+ const [ctx, setCtx] = (0, import_react27.useState)({});
4411
+ const ref = (0, import_react27.useRef)(null);
4412
+ const [mountTarget, setMountTarget] = (0, import_react27.useState)();
4413
+ (0, import_react27.useEffect)(() => {
4364
4414
  var _a2;
4365
4415
  if (ref.current) {
4366
4416
  setCtx({
@@ -4396,7 +4446,7 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
4396
4446
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
4397
4447
  var Preview = ({ id = "puck-preview" }) => {
4398
4448
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
4399
- const Page = (0, import_react26.useCallback)(
4449
+ const Page = (0, import_react28.useCallback)(
4400
4450
  (pageProps) => {
4401
4451
  var _a, _b;
4402
4452
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
@@ -4405,7 +4455,7 @@ var Preview = ({ id = "puck-preview" }) => {
4405
4455
  },
4406
4456
  [config.root]
4407
4457
  );
4408
- const Frame = (0, import_react26.useMemo)(() => overrides.iframe, [overrides]);
4458
+ const Frame = (0, import_react28.useMemo)(() => overrides.iframe, [overrides]);
4409
4459
  const rootProps = state.data.root.props || state.data.root;
4410
4460
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
4411
4461
  "div",
@@ -4494,7 +4544,7 @@ var scrollIntoView = (el) => {
4494
4544
  };
4495
4545
 
4496
4546
  // components/LayerTree/index.tsx
4497
- var import_react27 = require("react");
4547
+ var import_react29 = require("react");
4498
4548
 
4499
4549
  // lib/is-child-of-zone.ts
4500
4550
  init_react_import();
@@ -4521,7 +4571,7 @@ var LayerTree = ({
4521
4571
  label
4522
4572
  }) => {
4523
4573
  const zones = data.zones || {};
4524
- const ctx = (0, import_react27.useContext)(dropZoneContext);
4574
+ const ctx = (0, import_react29.useContext)(dropZoneContext);
4525
4575
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
4526
4576
  label && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
4527
4577
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Layers, { size: "16" }) }),
@@ -4627,13 +4677,13 @@ var LayerTree = ({
4627
4677
  };
4628
4678
 
4629
4679
  // components/Puck/components/Outline/index.tsx
4630
- var import_react28 = require("react");
4680
+ var import_react30 = require("react");
4631
4681
  var import_jsx_runtime34 = require("react/jsx-runtime");
4632
4682
  var Outline = () => {
4633
4683
  const { dispatch, state, overrides, config } = useAppContext();
4634
4684
  const { data, ui } = state;
4635
4685
  const { itemSelector } = ui;
4636
- const setItemSelector = (0, import_react28.useCallback)(
4686
+ const setItemSelector = (0, import_react30.useCallback)(
4637
4687
  (newItemSelector) => {
4638
4688
  dispatch({
4639
4689
  type: "setUi",
@@ -4642,7 +4692,7 @@ var Outline = () => {
4642
4692
  },
4643
4693
  []
4644
4694
  );
4645
- const Wrapper = (0, import_react28.useMemo)(() => overrides.outline || "div", [overrides]);
4695
+ const Wrapper = (0, import_react30.useMemo)(() => overrides.outline || "div", [overrides]);
4646
4696
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
4647
4697
  (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4648
4698
  LayerTree,
@@ -4731,19 +4781,19 @@ function usePuckHistory({
4731
4781
 
4732
4782
  // lib/use-history-store.ts
4733
4783
  init_react_import();
4734
- var import_react29 = require("react");
4784
+ var import_react31 = require("react");
4735
4785
  var import_use_debounce3 = require("use-debounce");
4736
4786
  var EMPTY_HISTORY_INDEX = 0;
4737
4787
  function useHistoryStore(initialHistory) {
4738
4788
  var _a, _b;
4739
- const [histories, setHistories] = (0, import_react29.useState)(
4789
+ const [histories, setHistories] = (0, import_react31.useState)(
4740
4790
  (_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
4741
4791
  );
4742
4792
  const updateHistories = (histories2) => {
4743
4793
  setHistories(histories2);
4744
4794
  setIndex(histories2.length - 1);
4745
4795
  };
4746
- const [index, setIndex] = (0, import_react29.useState)(
4796
+ const [index, setIndex] = (0, import_react31.useState)(
4747
4797
  (_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
4748
4798
  );
4749
4799
  const hasPast = index > EMPTY_HISTORY_INDEX;
@@ -4903,11 +4953,11 @@ var getBox = function getBox2(el) {
4903
4953
  };
4904
4954
 
4905
4955
  // components/Puck/components/Canvas/index.tsx
4906
- var import_react31 = require("react");
4956
+ var import_react33 = require("react");
4907
4957
 
4908
4958
  // components/ViewportControls/index.tsx
4909
4959
  init_react_import();
4910
- var import_react30 = require("react");
4960
+ var import_react32 = require("react");
4911
4961
 
4912
4962
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
4913
4963
  init_react_import();
@@ -4930,8 +4980,8 @@ var ViewportButton = ({
4930
4980
  onClick
4931
4981
  }) => {
4932
4982
  const { state } = useAppContext();
4933
- const [isActive, setIsActive] = (0, import_react30.useState)(false);
4934
- (0, import_react30.useEffect)(() => {
4983
+ const [isActive, setIsActive] = (0, import_react32.useState)(false);
4984
+ (0, import_react32.useEffect)(() => {
4935
4985
  setIsActive(width === state.ui.viewports.current.width);
4936
4986
  }, [width, state.ui.viewports.current.width]);
4937
4987
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
@@ -4967,7 +5017,7 @@ var ViewportControls = ({
4967
5017
  const defaultsContainAutoZoom = defaultZoomOptions.find(
4968
5018
  (option) => option.value === autoZoom
4969
5019
  );
4970
- const zoomOptions = (0, import_react30.useMemo)(
5020
+ const zoomOptions = (0, import_react32.useMemo)(
4971
5021
  () => [
4972
5022
  ...defaultZoomOptions,
4973
5023
  ...defaultsContainAutoZoom ? [] : [
@@ -5090,17 +5140,17 @@ var Canvas = () => {
5090
5140
  const { status, iframe } = useAppContext();
5091
5141
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
5092
5142
  const { ui } = state;
5093
- const frameRef = (0, import_react31.useRef)(null);
5094
- const [showTransition, setShowTransition] = (0, import_react31.useState)(false);
5095
- const defaultRender = (0, import_react31.useMemo)(() => {
5143
+ const frameRef = (0, import_react33.useRef)(null);
5144
+ const [showTransition, setShowTransition] = (0, import_react33.useState)(false);
5145
+ const defaultRender = (0, import_react33.useMemo)(() => {
5096
5146
  const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children });
5097
5147
  return PuckDefault;
5098
5148
  }, []);
5099
- const CustomPreview = (0, import_react31.useMemo)(
5149
+ const CustomPreview = (0, import_react33.useMemo)(
5100
5150
  () => overrides.preview || defaultRender,
5101
5151
  [overrides]
5102
5152
  );
5103
- const getFrameDimensions = (0, import_react31.useCallback)(() => {
5153
+ const getFrameDimensions = (0, import_react33.useCallback)(() => {
5104
5154
  if (frameRef.current) {
5105
5155
  const frame = frameRef.current;
5106
5156
  const box = getBox(frame);
@@ -5108,7 +5158,7 @@ var Canvas = () => {
5108
5158
  }
5109
5159
  return { width: 0, height: 0 };
5110
5160
  }, [frameRef]);
5111
- const resetAutoZoom = (0, import_react31.useCallback)(
5161
+ const resetAutoZoom = (0, import_react33.useCallback)(
5112
5162
  (ui2 = state.ui) => {
5113
5163
  if (frameRef.current) {
5114
5164
  setZoomConfig(
@@ -5118,11 +5168,11 @@ var Canvas = () => {
5118
5168
  },
5119
5169
  [frameRef, zoomConfig, state.ui]
5120
5170
  );
5121
- (0, import_react31.useEffect)(() => {
5171
+ (0, import_react33.useEffect)(() => {
5122
5172
  setShowTransition(false);
5123
5173
  resetAutoZoom();
5124
5174
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
5125
- (0, import_react31.useEffect)(() => {
5175
+ (0, import_react33.useEffect)(() => {
5126
5176
  const { height: frameHeight } = getFrameDimensions();
5127
5177
  if (ui.viewports.current.height === "auto") {
5128
5178
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -5130,13 +5180,13 @@ var Canvas = () => {
5130
5180
  }));
5131
5181
  }
5132
5182
  }, [zoomConfig.zoom]);
5133
- (0, import_react31.useEffect)(() => {
5183
+ (0, import_react33.useEffect)(() => {
5134
5184
  if (ZOOM_ON_CHANGE) {
5135
5185
  setShowTransition(true);
5136
5186
  resetAutoZoom(ui);
5137
5187
  }
5138
5188
  }, [ui.viewports.current.width]);
5139
- (0, import_react31.useEffect)(() => {
5189
+ (0, import_react33.useEffect)(() => {
5140
5190
  const observer = new ResizeObserver(() => {
5141
5191
  setShowTransition(false);
5142
5192
  resetAutoZoom();
@@ -5148,8 +5198,8 @@ var Canvas = () => {
5148
5198
  observer.disconnect();
5149
5199
  };
5150
5200
  }, []);
5151
- const [showLoader, setShowLoader] = (0, import_react31.useState)(false);
5152
- (0, import_react31.useEffect)(() => {
5201
+ const [showLoader, setShowLoader] = (0, import_react33.useState)(false);
5202
+ (0, import_react33.useEffect)(() => {
5153
5203
  setTimeout(() => {
5154
5204
  setShowLoader(true);
5155
5205
  }, 500);
@@ -5252,7 +5302,7 @@ var insertComponent = (componentType, zone, index, {
5252
5302
 
5253
5303
  // lib/use-loaded-overrides.ts
5254
5304
  init_react_import();
5255
- var import_react32 = require("react");
5305
+ var import_react34 = require("react");
5256
5306
 
5257
5307
  // lib/load-overrides.ts
5258
5308
  init_react_import();
@@ -5291,7 +5341,7 @@ var useLoadedOverrides = ({
5291
5341
  overrides,
5292
5342
  plugins
5293
5343
  }) => {
5294
- return (0, import_react32.useMemo)(() => {
5344
+ return (0, import_react34.useMemo)(() => {
5295
5345
  return loadOverrides({ overrides, plugins });
5296
5346
  }, [plugins, overrides]);
5297
5347
  };
@@ -5330,7 +5380,7 @@ function Puck({
5330
5380
  enabled: true,
5331
5381
  waitForStyles: true
5332
5382
  }, _iframe);
5333
- const [generatedAppState] = (0, import_react33.useState)(() => {
5383
+ const [generatedAppState] = (0, import_react35.useState)(() => {
5334
5384
  var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
5335
5385
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
5336
5386
  let clientUiState = {};
@@ -5402,22 +5452,22 @@ function Puck({
5402
5452
  histories,
5403
5453
  index: initialHistoryIndex
5404
5454
  });
5405
- const [reducer] = (0, import_react33.useState)(
5455
+ const [reducer] = (0, import_react35.useState)(
5406
5456
  () => createReducer({
5407
5457
  config,
5408
5458
  record: historyStore.record,
5409
5459
  onAction
5410
5460
  })
5411
5461
  );
5412
- const [appState, dispatch] = (0, import_react33.useReducer)(
5462
+ const [appState, dispatch] = (0, import_react35.useReducer)(
5413
5463
  reducer,
5414
5464
  flushZones(initialAppState)
5415
5465
  );
5416
5466
  const { data, ui } = appState;
5417
5467
  const history = usePuckHistory({ dispatch, initialAppState, historyStore });
5418
- const [menuOpen, setMenuOpen] = (0, import_react33.useState)(false);
5468
+ const [menuOpen, setMenuOpen] = (0, import_react35.useState)(false);
5419
5469
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
5420
- const setItemSelector = (0, import_react33.useCallback)(
5470
+ const setItemSelector = (0, import_react35.useCallback)(
5421
5471
  (newItemSelector) => {
5422
5472
  if (newItemSelector === itemSelector) return;
5423
5473
  dispatch({
@@ -5429,13 +5479,13 @@ function Puck({
5429
5479
  [itemSelector]
5430
5480
  );
5431
5481
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
5432
- (0, import_react33.useEffect)(() => {
5482
+ (0, import_react35.useEffect)(() => {
5433
5483
  if (onChange) onChange(data);
5434
5484
  }, [data]);
5435
5485
  const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
5436
- const [draggedItem, setDraggedItem] = (0, import_react33.useState)();
5486
+ const [draggedItem, setDraggedItem] = (0, import_react35.useState)();
5437
5487
  const rootProps = data.root.props || data.root;
5438
- const toggleSidebars = (0, import_react33.useCallback)(
5488
+ const toggleSidebars = (0, import_react35.useCallback)(
5439
5489
  (sidebar) => {
5440
5490
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
5441
5491
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -5449,7 +5499,7 @@ function Puck({
5449
5499
  },
5450
5500
  [dispatch, leftSideBarVisible, rightSideBarVisible]
5451
5501
  );
5452
- (0, import_react33.useEffect)(() => {
5502
+ (0, import_react35.useEffect)(() => {
5453
5503
  if (!window.matchMedia("(min-width: 638px)").matches) {
5454
5504
  dispatch({
5455
5505
  type: "setUi",
@@ -5472,7 +5522,7 @@ function Puck({
5472
5522
  window.removeEventListener("resize", handleResize);
5473
5523
  };
5474
5524
  }, []);
5475
- const defaultHeaderRender = (0, import_react33.useMemo)(() => {
5525
+ const defaultHeaderRender = (0, import_react35.useMemo)(() => {
5476
5526
  if (renderHeader) {
5477
5527
  console.warn(
5478
5528
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -5486,7 +5536,7 @@ function Puck({
5486
5536
  }
5487
5537
  return DefaultOverride;
5488
5538
  }, [renderHeader]);
5489
- const defaultHeaderActionsRender = (0, import_react33.useMemo)(() => {
5539
+ const defaultHeaderActionsRender = (0, import_react35.useMemo)(() => {
5490
5540
  if (renderHeaderActions) {
5491
5541
  console.warn(
5492
5542
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
@@ -5503,20 +5553,20 @@ function Puck({
5503
5553
  overrides,
5504
5554
  plugins
5505
5555
  });
5506
- const CustomPuck = (0, import_react33.useMemo)(
5556
+ const CustomPuck = (0, import_react35.useMemo)(
5507
5557
  () => loadedOverrides.puck || DefaultOverride,
5508
5558
  [loadedOverrides]
5509
5559
  );
5510
- const CustomHeader = (0, import_react33.useMemo)(
5560
+ const CustomHeader = (0, import_react35.useMemo)(
5511
5561
  () => loadedOverrides.header || defaultHeaderRender,
5512
5562
  [loadedOverrides]
5513
5563
  );
5514
- const CustomHeaderActions = (0, import_react33.useMemo)(
5564
+ const CustomHeaderActions = (0, import_react35.useMemo)(
5515
5565
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
5516
5566
  [loadedOverrides]
5517
5567
  );
5518
- const [mounted, setMounted] = (0, import_react33.useState)(false);
5519
- (0, import_react33.useEffect)(() => {
5568
+ const [mounted, setMounted] = (0, import_react35.useState)(false);
5569
+ (0, import_react35.useEffect)(() => {
5520
5570
  setMounted(true);
5521
5571
  }, []);
5522
5572
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
@@ -5919,6 +5969,11 @@ var usePuck = () => {
5919
5969
  getPermissions,
5920
5970
  refreshPermissions
5921
5971
  } = useAppContext();
5972
+ if (dispatch === defaultContext.dispatch) {
5973
+ throw new Error(
5974
+ "usePuck was used outside of the <Puck> component. The usePuck hook must be rendered within the <Puck> context as children, overrides or plugins as described in https://puckeditor.com/docs/api-reference/functions/use-puck."
5975
+ );
5976
+ }
5922
5977
  return {
5923
5978
  appState,
5924
5979
  config,