@measured/puck 0.18.0-canary.c6df5b2 → 0.18.0-canary.d211707

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -205,7 +205,7 @@ init_react_import();
205
205
 
206
206
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
207
207
  init_react_import();
208
- 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" };
208
+ var styles_module_default2 = { "InputWrapper": "_InputWrapper_1h1p1_1", "Input-label": "_Input-label_1h1p1_5", "Input-labelIcon": "_Input-labelIcon_1h1p1_14", "Input-disabledIcon": "_Input-disabledIcon_1h1p1_21", "Input-input": "_Input-input_1h1p1_26", "Input": "_Input_1h1p1_1", "Input--readOnly": "_Input--readOnly_1h1p1_70", "Input-radioGroupItems": "_Input-radioGroupItems_1h1p1_81", "Input-radio": "_Input-radio_1h1p1_81", "Input-radioInner": "_Input-radioInner_1h1p1_98", "Input-radioInput": "_Input-radioInput_1h1p1_143" };
209
209
 
210
210
  // components/AutoField/index.tsx
211
211
  import {
@@ -1504,12 +1504,13 @@ var DefaultField = ({
1504
1504
  field,
1505
1505
  onChange,
1506
1506
  readOnly,
1507
- value,
1507
+ value: _value,
1508
1508
  name,
1509
1509
  label,
1510
1510
  Label: Label2,
1511
1511
  id
1512
1512
  }) => {
1513
+ const value = _value;
1513
1514
  return /* @__PURE__ */ jsx9(
1514
1515
  Label2,
1515
1516
  {
@@ -1527,10 +1528,17 @@ var DefaultField = ({
1527
1528
  type: field.type,
1528
1529
  title: label || name,
1529
1530
  name,
1530
- value: typeof value === "undefined" ? "" : value.toString(),
1531
+ value: (value == null ? void 0 : value.toString) ? value.toString() : "",
1531
1532
  onChange: (e) => {
1532
1533
  if (field.type === "number") {
1533
- onChange(Number(e.currentTarget.value));
1534
+ const numberValue = Number(e.currentTarget.value);
1535
+ if (typeof field.min !== "undefined" && numberValue < field.min) {
1536
+ return;
1537
+ }
1538
+ if (typeof field.max !== "undefined" && numberValue > field.max) {
1539
+ return;
1540
+ }
1541
+ onChange(numberValue);
1534
1542
  } else {
1535
1543
  onChange(e.currentTarget.value);
1536
1544
  }
@@ -2284,6 +2292,7 @@ var FieldLabelInternal = ({
2284
2292
  function AutoFieldInternal(props) {
2285
2293
  var _a, _b, _c, _d, _e, _f, _g, _h;
2286
2294
  const { dispatch, overrides, selectedItem } = useAppContext();
2295
+ const nestedFieldContext = useContext3(NestedFieldContext);
2287
2296
  const { id, Label: Label2 = FieldLabelInternal } = props;
2288
2297
  const field = props.field;
2289
2298
  const label = field.label;
@@ -2348,7 +2357,6 @@ function AutoFieldInternal(props) {
2348
2357
  }
2349
2358
  const children = defaultFields[field.type](mergedProps);
2350
2359
  const Render2 = render[field.type];
2351
- const nestedFieldContext = useContext3(NestedFieldContext);
2352
2360
  return /* @__PURE__ */ jsx19(
2353
2361
  NestedFieldContext.Provider,
2354
2362
  {
@@ -2418,7 +2426,7 @@ init_react_import();
2418
2426
  var styles_module_default10 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
2419
2427
 
2420
2428
  // components/Drawer/index.tsx
2421
- import { useMemo as useMemo9, useState as useState18 } from "react";
2429
+ import { useId as useId2, useMemo as useMemo9, useState as useState18 } from "react";
2422
2430
 
2423
2431
  // components/DragDropContext/index.tsx
2424
2432
  init_react_import();
@@ -2429,7 +2437,7 @@ import {
2429
2437
  useContext as useContext7,
2430
2438
  useEffect as useEffect15,
2431
2439
  useId,
2432
- useRef as useRef4,
2440
+ useRef as useRef3,
2433
2441
  useState as useState17
2434
2442
  } from "react";
2435
2443
  import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
@@ -2442,7 +2450,7 @@ import {
2442
2450
  useContext as useContext6,
2443
2451
  useEffect as useEffect14,
2444
2452
  useMemo as useMemo8,
2445
- useRef as useRef3
2453
+ useRef as useRef2
2446
2454
  } from "react";
2447
2455
 
2448
2456
  // components/DraggableComponent/index.tsx
@@ -2452,7 +2460,7 @@ import {
2452
2460
  useContext as useContext5,
2453
2461
  useEffect as useEffect10,
2454
2462
  useMemo as useMemo7,
2455
- useRef as useRef2,
2463
+ useRef,
2456
2464
  useState as useState13
2457
2465
  } from "react";
2458
2466
 
@@ -3040,7 +3048,7 @@ var DraggableComponent = ({
3040
3048
  }
3041
3049
  });
3042
3050
  const thisIsDragging = status === "dragging";
3043
- const ref = useRef2(null);
3051
+ const ref = useRef(null);
3044
3052
  const refSetter = useCallback7(
3045
3053
  (el) => {
3046
3054
  sortableRef(el);
@@ -3091,13 +3099,19 @@ var DraggableComponent = ({
3091
3099
  }
3092
3100
  }, [ref.current]);
3093
3101
  useEffect10(() => {
3094
- if (isSelected) {
3095
- ctx == null ? void 0 : ctx.registerPath({
3102
+ ctx == null ? void 0 : ctx.registerPath(
3103
+ id,
3104
+ {
3096
3105
  index,
3097
3106
  zone: zoneCompound
3098
- });
3099
- }
3100
- }, [isSelected]);
3107
+ },
3108
+ componentType
3109
+ );
3110
+ return () => {
3111
+ var _a;
3112
+ (_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
3113
+ };
3114
+ }, [id, zoneCompound, index, componentType]);
3101
3115
  const CustomActionBar = useMemo7(
3102
3116
  () => overrides.actionBar || DefaultActionBar,
3103
3117
  [overrides.actionBar]
@@ -3417,9 +3431,20 @@ var useContentWithPreview = (content, zoneCompound) => {
3417
3431
  };
3418
3432
  }
3419
3433
  );
3434
+ const {
3435
+ state: {
3436
+ ui: { isDragging }
3437
+ }
3438
+ } = useAppContext();
3420
3439
  const [contentWithPreview, setContentWithPreview] = useState15(content);
3440
+ const [localPreview, setLocalPreview] = useState15(
3441
+ preview
3442
+ );
3421
3443
  const updateContent = useRenderedCallback(
3422
- (content2, preview2) => {
3444
+ (content2, preview2, isDragging2) => {
3445
+ if (isDragging2 && !previewExists) {
3446
+ return;
3447
+ }
3423
3448
  if (preview2) {
3424
3449
  if (preview2.type === "insert") {
3425
3450
  setContentWithPreview(
@@ -3449,13 +3474,14 @@ var useContentWithPreview = (content, zoneCompound) => {
3449
3474
  previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
3450
3475
  );
3451
3476
  }
3477
+ setLocalPreview(preview2);
3452
3478
  },
3453
3479
  [draggedItemId, previewExists]
3454
3480
  );
3455
3481
  useEffect12(() => {
3456
- updateContent(content, preview);
3457
- }, [content, preview]);
3458
- return contentWithPreview;
3482
+ updateContent(content, preview, isDragging);
3483
+ }, [content, preview, isDragging]);
3484
+ return [contentWithPreview, localPreview];
3459
3485
  };
3460
3486
 
3461
3487
  // components/DropZone/lib/use-drag-axis.ts
@@ -3499,8 +3525,9 @@ import { Fragment as Fragment6, jsx as jsx22, jsxs as jsxs10 } from "react/jsx-r
3499
3525
  var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3500
3526
  var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
3501
3527
  var RENDER_DEBUG = false;
3528
+ var DropZoneEditPure = (props) => /* @__PURE__ */ jsx22(DropZoneEdit, __spreadValues({}, props));
3502
3529
  var DropZoneEdit = forwardRef3(
3503
- function DropZoneEdit2({
3530
+ function DropZoneEditInternal({
3504
3531
  zone,
3505
3532
  allow,
3506
3533
  disallow,
@@ -3534,8 +3561,7 @@ var DropZoneEdit = forwardRef3(
3534
3561
  isDeepestZone,
3535
3562
  inNextDeepestArea,
3536
3563
  draggedComponentType,
3537
- userIsDragging,
3538
- preview
3564
+ userIsDragging
3539
3565
  } = useContextStore(ZoneStoreContext, (s) => {
3540
3566
  var _a, _b, _c;
3541
3567
  return {
@@ -3543,8 +3569,7 @@ var DropZoneEdit = forwardRef3(
3543
3569
  inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
3544
3570
  draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
3545
3571
  draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
3546
- userIsDragging: !!s.draggedItem,
3547
- preview: s.previewIndex[zoneCompound]
3572
+ userIsDragging: !!s.draggedItem
3548
3573
  };
3549
3574
  });
3550
3575
  const { itemSelector } = appContext2.state.ui;
@@ -3569,7 +3594,7 @@ var DropZoneEdit = forwardRef3(
3569
3594
  }
3570
3595
  return data.content || [];
3571
3596
  }, [data, zoneCompound]);
3572
- const ref = useRef3(null);
3597
+ const ref = useRef2(null);
3573
3598
  const acceptsTarget = useCallback10(
3574
3599
  (componentType) => {
3575
3600
  if (!componentType) {
@@ -3610,7 +3635,10 @@ var DropZoneEdit = forwardRef3(
3610
3635
  if (isEnabled) {
3611
3636
  isEnabled = acceptsTarget(draggedComponentType);
3612
3637
  }
3613
- const contentWithPreview = useContentWithPreview(content, zoneCompound);
3638
+ const [contentWithPreview, preview] = useContentWithPreview(
3639
+ content,
3640
+ zoneCompound
3641
+ );
3614
3642
  const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3615
3643
  const droppableConfig = {
3616
3644
  id: zoneCompound,
@@ -3652,16 +3680,15 @@ var DropZoneEdit = forwardRef3(
3652
3680
  },
3653
3681
  "data-testid": `dropzone:${zoneCompound}`,
3654
3682
  "data-puck-dropzone": zoneCompound,
3655
- "data-puck-dnd": zoneCompound,
3656
3683
  style: __spreadProps(__spreadValues({}, style), {
3657
3684
  "--min-empty-height": `${minEmptyHeight}px`,
3658
- backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
3685
+ backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
3659
3686
  }),
3660
3687
  children: contentWithPreview.map((item, i) => {
3661
- var _a, _b, _c, _d, _e;
3688
+ var _a, _b, _c, _d, _e, _f, _g;
3662
3689
  const componentId = item.props.id;
3663
3690
  const puckProps = {
3664
- renderDropZone: DropZone,
3691
+ renderDropZone: DropZoneEditPure,
3665
3692
  isEditing: true,
3666
3693
  dragRef: null
3667
3694
  };
@@ -3678,13 +3705,13 @@ var DropZoneEdit = forwardRef3(
3678
3705
  const componentConfig = config.components[item.type];
3679
3706
  let componentType = item.type;
3680
3707
  let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3681
- if (item.type === "preview" && preview) {
3708
+ if (item.type === "preview") {
3682
3709
  let Preview4 = function() {
3683
3710
  return /* @__PURE__ */ jsx22(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3684
3711
  };
3685
3712
  var Preview3 = Preview4;
3686
- componentType = preview.componentType;
3687
- label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
3713
+ componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
3714
+ label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
3688
3715
  Render2 = Preview4;
3689
3716
  }
3690
3717
  return /* @__PURE__ */ jsx22(
@@ -3699,7 +3726,7 @@ var DropZoneEdit = forwardRef3(
3699
3726
  zoneCompound,
3700
3727
  depth: depth + 1,
3701
3728
  index: i,
3702
- isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
3729
+ isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
3703
3730
  isSelected,
3704
3731
  label,
3705
3732
  isEnabled,
@@ -3724,8 +3751,9 @@ var DropZoneEdit = forwardRef3(
3724
3751
  );
3725
3752
  }
3726
3753
  );
3754
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx22(DropZoneRender, __spreadValues({}, props));
3727
3755
  var DropZoneRender = forwardRef3(
3728
- function DropZoneRender2({ className, style, zone }, ref) {
3756
+ function DropZoneRenderInternal({ className, style, zone }, ref) {
3729
3757
  const ctx = useContext6(dropZoneContext);
3730
3758
  const { data, areaId = "root", config } = ctx || {};
3731
3759
  let zoneCompound = rootDroppableId;
@@ -3763,7 +3791,9 @@ var DropZoneRender = forwardRef3(
3763
3791
  children: /* @__PURE__ */ jsx22(
3764
3792
  Component.render,
3765
3793
  __spreadProps(__spreadValues({}, item.props), {
3766
- puck: { renderDropZone: DropZoneRender2 }
3794
+ puck: {
3795
+ renderDropZone: DropZoneRenderPure
3796
+ }
3767
3797
  })
3768
3798
  )
3769
3799
  },
@@ -3838,6 +3868,48 @@ var getFrame = () => {
3838
3868
  return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
3839
3869
  };
3840
3870
 
3871
+ // lib/global-position.ts
3872
+ init_react_import();
3873
+ var GlobalPosition = class {
3874
+ constructor(target, original) {
3875
+ this.scaleFactor = 1;
3876
+ this.frameEl = null;
3877
+ this.frameRect = null;
3878
+ var _a;
3879
+ this.target = target;
3880
+ this.original = original;
3881
+ this.frameEl = document.querySelector("iframe");
3882
+ if (this.frameEl) {
3883
+ this.frameRect = this.frameEl.getBoundingClientRect();
3884
+ this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
3885
+ }
3886
+ }
3887
+ get x() {
3888
+ return this.original.x;
3889
+ }
3890
+ get y() {
3891
+ return this.original.y;
3892
+ }
3893
+ get global() {
3894
+ if (document !== this.target.ownerDocument && this.frameRect) {
3895
+ return {
3896
+ x: this.x * this.scaleFactor + this.frameRect.left,
3897
+ y: this.y * this.scaleFactor + this.frameRect.top
3898
+ };
3899
+ }
3900
+ return this.original;
3901
+ }
3902
+ get frame() {
3903
+ if (document === this.target.ownerDocument && this.frameRect) {
3904
+ return {
3905
+ x: (this.x - this.frameRect.left) / this.scaleFactor,
3906
+ y: (this.y - this.frameRect.top) / this.scaleFactor
3907
+ };
3908
+ }
3909
+ return this.original;
3910
+ }
3911
+ };
3912
+
3841
3913
  // lib/dnd/NestedDroppablePlugin.ts
3842
3914
  var depthSort = (candidates) => {
3843
3915
  return candidates.sort((a, b) => {
@@ -3867,10 +3939,12 @@ var getZoneId2 = (candidate) => {
3867
3939
  }
3868
3940
  return id;
3869
3941
  };
3870
- var getPointerCollisions = (position, manager, ownerDocument) => {
3871
- var _a;
3942
+ var getPointerCollisions = (position, manager) => {
3872
3943
  const candidates = [];
3873
- let elements = ownerDocument.elementsFromPoint(position.x, position.y);
3944
+ let elements = position.target.ownerDocument.elementsFromPoint(
3945
+ position.x,
3946
+ position.y
3947
+ );
3874
3948
  const previewFrame = elements.find(
3875
3949
  (el) => el.getAttribute("data-puck-preview")
3876
3950
  );
@@ -3879,22 +3953,21 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3879
3953
  elements = [drawer];
3880
3954
  }
3881
3955
  if (previewFrame) {
3882
- const iframe = previewFrame.querySelector("iframe");
3883
- if (iframe) {
3884
- const rect = iframe.getBoundingClientRect();
3885
- const frame = getFrame();
3886
- if (frame) {
3887
- const scaleFactor = rect.width / (((_a = iframe.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
3888
- elements = frame.elementsFromPoint(
3889
- (position.x - rect.left) / scaleFactor,
3890
- (position.y - rect.top) / scaleFactor
3891
- );
3892
- }
3956
+ const frame = getFrame();
3957
+ if (frame) {
3958
+ elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
3893
3959
  }
3894
3960
  }
3895
3961
  if (elements) {
3896
3962
  for (let i = 0; i < elements.length; i++) {
3897
3963
  const element = elements[i];
3964
+ const dropzoneId = element.getAttribute("data-puck-dropzone");
3965
+ if (dropzoneId) {
3966
+ const droppable = manager.registry.droppables.get(dropzoneId);
3967
+ if (droppable) {
3968
+ candidates.push(droppable);
3969
+ }
3970
+ }
3898
3971
  const id = element.getAttribute("data-puck-dnd");
3899
3972
  if (id) {
3900
3973
  const droppable = manager.registry.droppables.get(id);
@@ -3906,9 +3979,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
3906
3979
  }
3907
3980
  return candidates;
3908
3981
  };
3909
- var findDeepestCandidate = (position, manager, ownerDocument) => {
3982
+ var findDeepestCandidate = (position, manager) => {
3910
3983
  var _a;
3911
- const candidates = getPointerCollisions(position, manager, ownerDocument);
3984
+ const candidates = getPointerCollisions(position, manager);
3912
3985
  if (candidates.length > 0) {
3913
3986
  const sortedCandidates = depthSort(candidates);
3914
3987
  const draggable = manager.dragOperation.source;
@@ -3961,22 +4034,18 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
3961
4034
  }
3962
4035
  const cleanupEffect = effects(() => {
3963
4036
  const handleMove = (event) => {
3964
- const position = {
4037
+ const target = event.originalTarget || event.target;
4038
+ const position = new GlobalPosition(target, {
3965
4039
  x: event.clientX,
3966
4040
  y: event.clientY
3967
- };
3968
- const target = event.originalTarget || event.target;
3969
- const ownerDocument = target == null ? void 0 : target.ownerDocument;
4041
+ });
3970
4042
  const elements = document.elementsFromPoint(
3971
- event.clientX,
3972
- event.clientY
4043
+ position.global.x,
4044
+ position.global.y
3973
4045
  );
3974
4046
  const overEl = elements.some((el) => el.id === id);
3975
4047
  if (overEl) {
3976
- onChange(
3977
- findDeepestCandidate(position, manager, ownerDocument),
3978
- manager
3979
- );
4048
+ onChange(findDeepestCandidate(position, manager), manager);
3980
4049
  }
3981
4050
  };
3982
4051
  const handleMoveThrottled = throttle(handleMove, 50);
@@ -4307,6 +4376,11 @@ var reduceUi = (ui, action) => {
4307
4376
  itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4308
4377
  });
4309
4378
  }
4379
+ if (action.type === "remove") {
4380
+ return __spreadProps(__spreadValues({}, ui), {
4381
+ itemSelector: null
4382
+ });
4383
+ }
4310
4384
  return ui;
4311
4385
  };
4312
4386
 
@@ -4566,6 +4640,9 @@ var _PointerSensor = class _PointerSensor extends Sensor {
4566
4640
  }
4567
4641
  }
4568
4642
  handlePointerUp(event) {
4643
+ if (!this.source) {
4644
+ return;
4645
+ }
4569
4646
  event.preventDefault();
4570
4647
  event.stopPropagation();
4571
4648
  const { status } = this.manager.dragOperation;
@@ -4683,7 +4760,7 @@ function useDragListener(type, fn, deps = []) {
4683
4760
  }
4684
4761
  var AREA_CHANGE_DEBOUNCE_MS = 100;
4685
4762
  var useTempDisableFallback = (timeout3) => {
4686
- const lastFallbackDisable = useRef4(null);
4763
+ const lastFallbackDisable = useRef3(null);
4687
4764
  return useCallback11((manager) => {
4688
4765
  collisionStore.setState({ fallbackEnabled: false });
4689
4766
  const fallbackId = generateId();
@@ -4703,7 +4780,7 @@ var DragDropContextClient = ({
4703
4780
  const { state, config, dispatch, resolveData } = useAppContext();
4704
4781
  const id = useId();
4705
4782
  const { data } = state;
4706
- const debouncedParamsRef = useRef4(null);
4783
+ const debouncedParamsRef = useRef3(null);
4707
4784
  const tempDisableFallback = useTempDisableFallback(100);
4708
4785
  const [zoneStore] = useState17(
4709
4786
  () => createStore3(() => ({
@@ -4842,30 +4919,36 @@ var DragDropContextClient = ({
4842
4919
  ]);
4843
4920
  const [dragListeners, setDragListeners] = useState17({});
4844
4921
  const [pathData, setPathData] = useState17();
4845
- const dragMode = useRef4(null);
4922
+ const dragMode = useRef3(null);
4846
4923
  const registerPath = useCallback11(
4847
- (selector) => {
4848
- const item = getItem(selector, data);
4849
- if (!item) {
4850
- return;
4851
- }
4924
+ (id2, selector, label) => {
4852
4925
  const [area] = getZoneId(selector.zone);
4853
4926
  setPathData((latestPathData = {}) => {
4854
4927
  const parentPathData = latestPathData[area] || { path: [] };
4855
4928
  return __spreadProps(__spreadValues({}, latestPathData), {
4856
- [item.props.id]: {
4929
+ [id2]: {
4857
4930
  path: [
4858
4931
  ...parentPathData.path,
4859
4932
  ...selector.zone ? [selector.zone] : []
4860
4933
  ],
4861
- label: item.type
4934
+ label
4862
4935
  }
4863
4936
  });
4864
4937
  });
4865
4938
  },
4866
4939
  [data, setPathData]
4867
4940
  );
4868
- const initialSelector = useRef4(void 0);
4941
+ const unregisterPath = useCallback11(
4942
+ (id2) => {
4943
+ setPathData((latestPathData = {}) => {
4944
+ const newPathData = __spreadValues({}, latestPathData);
4945
+ delete newPathData[id2];
4946
+ return newPathData;
4947
+ });
4948
+ },
4949
+ [data, setPathData]
4950
+ );
4951
+ const initialSelector = useRef3(void 0);
4869
4952
  return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
4870
4953
  dragListenerContext.Provider,
4871
4954
  {
@@ -5061,6 +5144,7 @@ var DragDropContextClient = ({
5061
5144
  areaId: "root",
5062
5145
  depth: 0,
5063
5146
  registerPath,
5147
+ unregisterPath,
5064
5148
  pathData,
5065
5149
  path: []
5066
5150
  },
@@ -5187,7 +5271,7 @@ var Drawer = ({
5187
5271
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
5188
5272
  );
5189
5273
  }
5190
- const [id] = useState18(generateId());
5274
+ const id = useId2();
5191
5275
  const { ref } = useDroppableSafe({
5192
5276
  id,
5193
5277
  type: "void",
@@ -5210,9 +5294,9 @@ Drawer.Item = DrawerItem;
5210
5294
  // components/Puck/index.tsx
5211
5295
  init_react_import();
5212
5296
  import {
5213
- useCallback as useCallback17,
5214
- useEffect as useEffect23,
5215
- useMemo as useMemo18,
5297
+ useCallback as useCallback18,
5298
+ useEffect as useEffect24,
5299
+ useMemo as useMemo19,
5216
5300
  useReducer,
5217
5301
  useState as useState26
5218
5302
  } from "react";
@@ -5408,36 +5492,61 @@ init_react_import();
5408
5492
 
5409
5493
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
5410
5494
  init_react_import();
5411
- 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" };
5495
+ var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
5412
5496
 
5413
5497
  // components/Puck/components/Fields/index.tsx
5414
- import { useCallback as useCallback12, useEffect as useEffect16, useMemo as useMemo11, useState as useState19 } from "react";
5498
+ import { useMemo as useMemo12 } from "react";
5499
+
5500
+ // lib/use-resolved-fields.ts
5501
+ init_react_import();
5502
+ import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as useRef5, useState as useState19 } from "react";
5415
5503
 
5416
5504
  // lib/use-parent.ts
5417
5505
  init_react_import();
5418
- import { useContext as useContext9 } from "react";
5419
- var useParent = (itemSelector) => {
5506
+ import { useCallback as useCallback12, useContext as useContext9 } from "react";
5507
+ var getParent = (itemSelector, pathData, data) => {
5420
5508
  var _a;
5421
- const { selectedItem, state } = useAppContext();
5422
- const { pathData } = useContext9(dropZoneContext) || {};
5423
- const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
5424
- const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
5509
+ if (!itemSelector) return null;
5510
+ const item = getItem(itemSelector, data);
5511
+ const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
5425
5512
  const lastItem = breadcrumbs[breadcrumbs.length - 1];
5426
- const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, state.data)) != null ? _a : null : null;
5513
+ const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
5427
5514
  return parent || null;
5428
5515
  };
5516
+ var useGetParent = () => {
5517
+ const { state } = useAppContext();
5518
+ const { pathData } = useContext9(dropZoneContext) || {};
5519
+ return useCallback12(
5520
+ () => getParent(state.ui.itemSelector, pathData, state.data),
5521
+ [state.ui.itemSelector, pathData, state.data]
5522
+ );
5523
+ };
5524
+ var useParent = () => {
5525
+ return useGetParent()();
5526
+ };
5429
5527
 
5430
- // components/Puck/components/Fields/index.tsx
5431
- import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
5432
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5528
+ // lib/use-on-value-change.ts
5529
+ init_react_import();
5530
+ import { useRef as useRef4, useEffect as useEffect16 } from "react";
5531
+ function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
5532
+ const tracked = useRef4(value);
5533
+ useEffect16(() => {
5534
+ const oldValue = tracked.current;
5535
+ if (!compare(value, oldValue)) {
5536
+ tracked.current = value;
5537
+ onChange(value, oldValue);
5538
+ }
5539
+ }, [onChange, compare, value, ...deps]);
5540
+ }
5541
+
5542
+ // lib/selector-is.ts
5543
+ init_react_import();
5544
+ var selectorIs = (a, b) => (a == null ? void 0 : a.zone) === (b == null ? void 0 : b.zone) && (a == null ? void 0 : a.index) === (b == null ? void 0 : b.index);
5545
+
5546
+ // lib/use-resolved-fields.ts
5433
5547
  var defaultPageFields = {
5434
5548
  title: { type: "text" }
5435
5549
  };
5436
- var DefaultFields = ({
5437
- children
5438
- }) => {
5439
- return /* @__PURE__ */ jsx27(Fragment8, { children });
5440
- };
5441
5550
  var useResolvedFields = () => {
5442
5551
  var _a, _b;
5443
5552
  const { selectedItem, state, config } = useAppContext();
@@ -5453,12 +5562,13 @@ var useResolvedFields = () => {
5453
5562
  const [lastSelectedData, setLastSelectedData] = useState19({});
5454
5563
  const [resolvedFields, setResolvedFields] = useState19(defaultFields);
5455
5564
  const [fieldsLoading, setFieldsLoading] = useState19(false);
5565
+ const lastFields = useRef5(defaultFields);
5456
5566
  const defaultResolveFields = (_componentData, _params) => defaultFields;
5457
5567
  const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
5458
5568
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
5459
5569
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
5460
5570
  const hasResolver = hasComponentResolver || hasRootResolver;
5461
- const resolveFields = useCallback12(
5571
+ const resolveFields = useCallback13(
5462
5572
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
5463
5573
  var _a2;
5464
5574
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -5470,7 +5580,7 @@ var useResolvedFields = () => {
5470
5580
  {
5471
5581
  changed,
5472
5582
  fields,
5473
- lastFields: resolvedFields,
5583
+ lastFields: lastFields.current,
5474
5584
  lastData,
5475
5585
  appState: state,
5476
5586
  parent
@@ -5481,7 +5591,7 @@ var useResolvedFields = () => {
5481
5591
  return yield config.root.resolveFields(componentData, {
5482
5592
  changed,
5483
5593
  fields,
5484
- lastFields: resolvedFields,
5594
+ lastFields: lastFields.current,
5485
5595
  lastData,
5486
5596
  appState: state,
5487
5597
  parent
@@ -5490,26 +5600,56 @@ var useResolvedFields = () => {
5490
5600
  return defaultResolveFields(componentData, {
5491
5601
  changed,
5492
5602
  fields,
5493
- lastFields: resolvedFields,
5603
+ lastFields: lastFields.current,
5494
5604
  lastData
5495
5605
  });
5496
5606
  }),
5497
- [data, config, componentData, selectedItem, resolvedFields, state]
5607
+ [data, config, componentData, selectedItem, state, parent]
5498
5608
  );
5499
- useEffect16(() => {
5500
- if (hasResolver) {
5501
- setFieldsLoading(true);
5502
- resolveFields(defaultFields).then((fields) => {
5503
- setResolvedFields(fields || {});
5504
- setFieldsLoading(false);
5505
- });
5506
- } else {
5507
- setResolvedFields(defaultFields);
5609
+ const triggerResolver = useCallback13(() => {
5610
+ var _a2, _b2;
5611
+ if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
5612
+ if (hasResolver) {
5613
+ setFieldsLoading(true);
5614
+ resolveFields(defaultFields).then((fields) => {
5615
+ setResolvedFields(fields || {});
5616
+ lastFields.current = fields;
5617
+ setFieldsLoading(false);
5618
+ });
5619
+ return;
5620
+ }
5508
5621
  }
5509
- }, [data, defaultFields, selectedItem, hasResolver]);
5622
+ setResolvedFields(defaultFields);
5623
+ }, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
5624
+ useOnValueChange(
5625
+ state.ui.itemSelector,
5626
+ () => {
5627
+ lastFields.current = defaultFields;
5628
+ },
5629
+ selectorIs
5630
+ );
5631
+ useOnValueChange(
5632
+ { data, parent, itemSelector: state.ui.itemSelector },
5633
+ () => {
5634
+ triggerResolver();
5635
+ },
5636
+ (a, b) => JSON.stringify(a) === JSON.stringify(b)
5637
+ );
5638
+ useEffect17(() => {
5639
+ triggerResolver();
5640
+ }, []);
5510
5641
  return [resolvedFields, fieldsLoading];
5511
5642
  };
5512
- var Fields = () => {
5643
+
5644
+ // components/Puck/components/Fields/index.tsx
5645
+ import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
5646
+ var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5647
+ var DefaultFields = ({
5648
+ children
5649
+ }) => {
5650
+ return /* @__PURE__ */ jsx27(Fragment8, { children });
5651
+ };
5652
+ var Fields = ({ wrapFields = true }) => {
5513
5653
  var _a, _b;
5514
5654
  const {
5515
5655
  selectedItem,
@@ -5527,11 +5667,11 @@ var Fields = () => {
5527
5667
  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;
5528
5668
  const isLoading = fieldsResolving || componentResolving;
5529
5669
  const rootProps = data.root.props || data.root;
5530
- const Wrapper = useMemo11(() => overrides.fields || DefaultFields, [overrides]);
5670
+ const Wrapper = useMemo12(() => overrides.fields || DefaultFields, [overrides]);
5531
5671
  return /* @__PURE__ */ jsxs14(
5532
5672
  "form",
5533
5673
  {
5534
- className: getClassName21(),
5674
+ className: getClassName21({ wrapFields }),
5535
5675
  onSubmit: (e) => {
5536
5676
  e.preventDefault();
5537
5677
  },
@@ -5607,7 +5747,7 @@ var Fields = () => {
5607
5747
  item: selectedItem
5608
5748
  });
5609
5749
  const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
5610
- return /* @__PURE__ */ jsx27(
5750
+ return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
5611
5751
  AutoFieldPrivate,
5612
5752
  {
5613
5753
  field,
@@ -5616,16 +5756,15 @@ var Fields = () => {
5616
5756
  readOnly: !edit || readOnly[fieldName],
5617
5757
  value: selectedItem.props[fieldName],
5618
5758
  onChange
5619
- },
5620
- id
5621
- );
5759
+ }
5760
+ ) }, id);
5622
5761
  } else {
5623
5762
  const readOnly = data.root.readOnly || {};
5624
5763
  const { edit } = getPermissions({
5625
5764
  root: true
5626
5765
  });
5627
5766
  const id = `root_${field.type}_${fieldName}`;
5628
- return /* @__PURE__ */ jsx27(
5767
+ return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
5629
5768
  AutoFieldPrivate,
5630
5769
  {
5631
5770
  field,
@@ -5634,9 +5773,8 @@ var Fields = () => {
5634
5773
  readOnly: !edit || readOnly[fieldName],
5635
5774
  value: rootProps[fieldName],
5636
5775
  onChange
5637
- },
5638
- id
5639
- );
5776
+ }
5777
+ ) }, id);
5640
5778
  }
5641
5779
  }) }),
5642
5780
  isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
@@ -5650,7 +5788,7 @@ init_react_import();
5650
5788
 
5651
5789
  // lib/use-component-list.tsx
5652
5790
  init_react_import();
5653
- import { useEffect as useEffect17, useState as useState20 } from "react";
5791
+ import { useEffect as useEffect18, useState as useState20 } from "react";
5654
5792
 
5655
5793
  // components/ComponentList/index.tsx
5656
5794
  init_react_import();
@@ -5718,7 +5856,7 @@ ComponentList.Item = ComponentListItem;
5718
5856
  import { jsx as jsx29 } from "react/jsx-runtime";
5719
5857
  var useComponentList = (config, ui) => {
5720
5858
  const [componentList, setComponentList] = useState20();
5721
- useEffect17(() => {
5859
+ useEffect18(() => {
5722
5860
  var _a, _b, _c;
5723
5861
  if (Object.keys(ui.componentList).length > 0) {
5724
5862
  const matchedComponents = [];
@@ -5787,25 +5925,25 @@ var useComponentList = (config, ui) => {
5787
5925
  };
5788
5926
 
5789
5927
  // components/Puck/components/Components/index.tsx
5790
- import { useMemo as useMemo12 } from "react";
5928
+ import { useMemo as useMemo13 } from "react";
5791
5929
  import { jsx as jsx30 } from "react/jsx-runtime";
5792
5930
  var Components = () => {
5793
5931
  const { config, state, overrides } = useAppContext();
5794
5932
  const componentList = useComponentList(config, state.ui);
5795
- const Wrapper = useMemo12(() => overrides.components || "div", [overrides]);
5933
+ const Wrapper = useMemo13(() => overrides.components || "div", [overrides]);
5796
5934
  return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
5797
5935
  };
5798
5936
 
5799
5937
  // components/Puck/components/Preview/index.tsx
5800
5938
  init_react_import();
5801
- import { useCallback as useCallback13, useEffect as useEffect19, useRef as useRef6, useMemo as useMemo13 } from "react";
5939
+ import { useCallback as useCallback14, useEffect as useEffect20, useRef as useRef7, useMemo as useMemo14 } from "react";
5802
5940
 
5803
5941
  // components/AutoFrame/index.tsx
5804
5942
  init_react_import();
5805
5943
  import {
5806
5944
  createContext as createContext5,
5807
5945
  useContext as useContext10,
5808
- useEffect as useEffect18,
5946
+ useEffect as useEffect19,
5809
5947
  useState as useState21
5810
5948
  } from "react";
5811
5949
  import hash from "object-hash";
@@ -5853,7 +5991,7 @@ var CopyHostStyles = ({
5853
5991
  onStylesLoaded = () => null
5854
5992
  }) => {
5855
5993
  const { document: doc, window: win } = useFrame();
5856
- useEffect18(() => {
5994
+ useEffect19(() => {
5857
5995
  if (!win || !doc) {
5858
5996
  return () => {
5859
5997
  };
@@ -6033,7 +6171,7 @@ function AutoFrame(_a) {
6033
6171
  const [loaded, setLoaded] = useState21(false);
6034
6172
  const [ctx, setCtx] = useState21({});
6035
6173
  const [mountTarget, setMountTarget] = useState21();
6036
- useEffect18(() => {
6174
+ useEffect19(() => {
6037
6175
  var _a2;
6038
6176
  if (frameRef.current) {
6039
6177
  setCtx({
@@ -6127,7 +6265,7 @@ import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
6127
6265
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
6128
6266
  var useBubbleIframeEvents = (ref) => {
6129
6267
  const { status } = useAppContext();
6130
- useEffect19(() => {
6268
+ useEffect20(() => {
6131
6269
  var _a;
6132
6270
  if (ref.current && status === "READY") {
6133
6271
  const iframe = ref.current;
@@ -6166,7 +6304,7 @@ var useBubbleIframeEvents = (ref) => {
6166
6304
  };
6167
6305
  var Preview2 = ({ id = "puck-preview" }) => {
6168
6306
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
6169
- const Page = useCallback13(
6307
+ const Page = useCallback14(
6170
6308
  (pageProps) => {
6171
6309
  var _a, _b;
6172
6310
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
@@ -6175,9 +6313,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
6175
6313
  },
6176
6314
  [config.root]
6177
6315
  );
6178
- const Frame = useMemo13(() => overrides.iframe, [overrides]);
6316
+ const Frame = useMemo14(() => overrides.iframe, [overrides]);
6179
6317
  const rootProps = state.data.root.props || state.data.root;
6180
- const ref = useRef6(null);
6318
+ const ref = useRef7(null);
6181
6319
  useBubbleIframeEvents(ref);
6182
6320
  const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
6183
6321
  Page,
@@ -6427,13 +6565,13 @@ var LayerTree = ({
6427
6565
  };
6428
6566
 
6429
6567
  // components/Puck/components/Outline/index.tsx
6430
- import { useCallback as useCallback14, useMemo as useMemo14 } from "react";
6568
+ import { useCallback as useCallback15, useMemo as useMemo15 } from "react";
6431
6569
  import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
6432
6570
  var Outline = () => {
6433
6571
  const { dispatch, state, overrides, config } = useAppContext();
6434
6572
  const { data, ui } = state;
6435
6573
  const { itemSelector } = ui;
6436
- const setItemSelector = useCallback14(
6574
+ const setItemSelector = useCallback15(
6437
6575
  (newItemSelector) => {
6438
6576
  dispatch({
6439
6577
  type: "setUi",
@@ -6442,7 +6580,7 @@ var Outline = () => {
6442
6580
  },
6443
6581
  []
6444
6582
  );
6445
- const Wrapper = useMemo14(() => overrides.outline || "div", [overrides]);
6583
+ const Wrapper = useMemo15(() => overrides.outline || "div", [overrides]);
6446
6584
  return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
6447
6585
  (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
6448
6586
  LayerTree,
@@ -6729,16 +6867,16 @@ var getBox = function getBox2(el) {
6729
6867
 
6730
6868
  // components/Puck/components/Canvas/index.tsx
6731
6869
  import {
6732
- useCallback as useCallback15,
6733
- useEffect as useEffect21,
6734
- useMemo as useMemo16,
6735
- useRef as useRef7,
6870
+ useCallback as useCallback16,
6871
+ useEffect as useEffect22,
6872
+ useMemo as useMemo17,
6873
+ useRef as useRef8,
6736
6874
  useState as useState24
6737
6875
  } from "react";
6738
6876
 
6739
6877
  // components/ViewportControls/index.tsx
6740
6878
  init_react_import();
6741
- import { useEffect as useEffect20, useMemo as useMemo15, useState as useState23 } from "react";
6879
+ import { useEffect as useEffect21, useMemo as useMemo16, useState as useState23 } from "react";
6742
6880
 
6743
6881
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
6744
6882
  init_react_import();
@@ -6762,7 +6900,7 @@ var ViewportButton = ({
6762
6900
  }) => {
6763
6901
  const { state } = useAppContext();
6764
6902
  const [isActive, setIsActive] = useState23(false);
6765
- useEffect20(() => {
6903
+ useEffect21(() => {
6766
6904
  setIsActive(width === state.ui.viewports.current.width);
6767
6905
  }, [width, state.ui.viewports.current.width]);
6768
6906
  return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
@@ -6798,7 +6936,7 @@ var ViewportControls = ({
6798
6936
  const defaultsContainAutoZoom = defaultZoomOptions.find(
6799
6937
  (option) => option.value === autoZoom
6800
6938
  );
6801
- const zoomOptions = useMemo15(
6939
+ const zoomOptions = useMemo16(
6802
6940
  () => [
6803
6941
  ...defaultZoomOptions,
6804
6942
  ...defaultsContainAutoZoom ? [] : [
@@ -6921,17 +7059,17 @@ var Canvas = () => {
6921
7059
  const { status, iframe } = useAppContext();
6922
7060
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
6923
7061
  const { ui } = state;
6924
- const frameRef = useRef7(null);
7062
+ const frameRef = useRef8(null);
6925
7063
  const [showTransition, setShowTransition] = useState24(false);
6926
- const defaultRender = useMemo16(() => {
7064
+ const defaultRender = useMemo17(() => {
6927
7065
  const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
6928
7066
  return PuckDefault;
6929
7067
  }, []);
6930
- const CustomPreview = useMemo16(
7068
+ const CustomPreview = useMemo17(
6931
7069
  () => overrides.preview || defaultRender,
6932
7070
  [overrides]
6933
7071
  );
6934
- const getFrameDimensions = useCallback15(() => {
7072
+ const getFrameDimensions = useCallback16(() => {
6935
7073
  if (frameRef.current) {
6936
7074
  const frame = frameRef.current;
6937
7075
  const box = getBox(frame);
@@ -6939,7 +7077,7 @@ var Canvas = () => {
6939
7077
  }
6940
7078
  return { width: 0, height: 0 };
6941
7079
  }, [frameRef]);
6942
- const resetAutoZoom = useCallback15(
7080
+ const resetAutoZoom = useCallback16(
6943
7081
  (ui2 = state.ui) => {
6944
7082
  if (frameRef.current) {
6945
7083
  setZoomConfig(
@@ -6949,11 +7087,11 @@ var Canvas = () => {
6949
7087
  },
6950
7088
  [frameRef, zoomConfig, state.ui]
6951
7089
  );
6952
- useEffect21(() => {
7090
+ useEffect22(() => {
6953
7091
  setShowTransition(false);
6954
7092
  resetAutoZoom();
6955
7093
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
6956
- useEffect21(() => {
7094
+ useEffect22(() => {
6957
7095
  const { height: frameHeight } = getFrameDimensions();
6958
7096
  if (ui.viewports.current.height === "auto") {
6959
7097
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -6961,13 +7099,13 @@ var Canvas = () => {
6961
7099
  }));
6962
7100
  }
6963
7101
  }, [zoomConfig.zoom]);
6964
- useEffect21(() => {
7102
+ useEffect22(() => {
6965
7103
  if (ZOOM_ON_CHANGE) {
6966
7104
  setShowTransition(true);
6967
7105
  resetAutoZoom(ui);
6968
7106
  }
6969
7107
  }, [ui.viewports.current.width]);
6970
- useEffect21(() => {
7108
+ useEffect22(() => {
6971
7109
  const cb = () => {
6972
7110
  setShowTransition(false);
6973
7111
  resetAutoZoom();
@@ -6978,7 +7116,7 @@ var Canvas = () => {
6978
7116
  };
6979
7117
  }, []);
6980
7118
  const [showLoader, setShowLoader] = useState24(false);
6981
- useEffect21(() => {
7119
+ useEffect22(() => {
6982
7120
  setTimeout(() => {
6983
7121
  setShowLoader(true);
6984
7122
  }, 500);
@@ -7056,7 +7194,7 @@ var Canvas = () => {
7056
7194
 
7057
7195
  // lib/use-loaded-overrides.ts
7058
7196
  init_react_import();
7059
- import { useMemo as useMemo17 } from "react";
7197
+ import { useMemo as useMemo18 } from "react";
7060
7198
 
7061
7199
  // lib/load-overrides.ts
7062
7200
  init_react_import();
@@ -7095,7 +7233,7 @@ var useLoadedOverrides = ({
7095
7233
  overrides,
7096
7234
  plugins
7097
7235
  }) => {
7098
- return useMemo17(() => {
7236
+ return useMemo18(() => {
7099
7237
  return loadOverrides({ overrides, plugins });
7100
7238
  }, [plugins, overrides]);
7101
7239
  };
@@ -7107,14 +7245,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { chil
7107
7245
 
7108
7246
  // lib/use-inject-css.ts
7109
7247
  init_react_import();
7110
- import { useEffect as useEffect22, useState as useState25 } from "react";
7248
+ import { useEffect as useEffect23, useState as useState25 } from "react";
7111
7249
  var styles = ``;
7112
7250
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7113
7251
  const [el, setEl] = useState25();
7114
- useEffect22(() => {
7252
+ useEffect23(() => {
7115
7253
  setEl(document.createElement("style"));
7116
7254
  }, []);
7117
- useEffect22(() => {
7255
+ useEffect23(() => {
7118
7256
  var _a;
7119
7257
  if (!el || typeof window === "undefined") {
7120
7258
  return;
@@ -7134,10 +7272,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
7134
7272
 
7135
7273
  // lib/use-preview-mode-hotkeys.ts
7136
7274
  init_react_import();
7137
- import { useCallback as useCallback16 } from "react";
7275
+ import { useCallback as useCallback17 } from "react";
7138
7276
  import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
7139
7277
  var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
7140
- const toggleInteractive = useCallback16(() => {
7278
+ const toggleInteractive = useCallback17(() => {
7141
7279
  dispatch({
7142
7280
  type: "setUi",
7143
7281
  ui: (ui) => ({
@@ -7282,11 +7420,11 @@ function Puck({
7282
7420
  const [menuOpen, setMenuOpen] = useState26(false);
7283
7421
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
7284
7422
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
7285
- useEffect23(() => {
7423
+ useEffect24(() => {
7286
7424
  if (onChange) onChange(data);
7287
7425
  }, [data]);
7288
7426
  const rootProps = data.root.props || data.root;
7289
- const toggleSidebars = useCallback17(
7427
+ const toggleSidebars = useCallback18(
7290
7428
  (sidebar) => {
7291
7429
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7292
7430
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -7300,7 +7438,7 @@ function Puck({
7300
7438
  },
7301
7439
  [dispatch, leftSideBarVisible, rightSideBarVisible]
7302
7440
  );
7303
- useEffect23(() => {
7441
+ useEffect24(() => {
7304
7442
  if (!window.matchMedia("(min-width: 638px)").matches) {
7305
7443
  dispatch({
7306
7444
  type: "setUi",
@@ -7323,7 +7461,7 @@ function Puck({
7323
7461
  window.removeEventListener("resize", handleResize);
7324
7462
  };
7325
7463
  }, []);
7326
- const defaultHeaderRender = useMemo18(() => {
7464
+ const defaultHeaderRender = useMemo19(() => {
7327
7465
  if (renderHeader) {
7328
7466
  console.warn(
7329
7467
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -7337,7 +7475,7 @@ function Puck({
7337
7475
  }
7338
7476
  return DefaultOverride;
7339
7477
  }, [renderHeader]);
7340
- const defaultHeaderActionsRender = useMemo18(() => {
7478
+ const defaultHeaderActionsRender = useMemo19(() => {
7341
7479
  if (renderHeaderActions) {
7342
7480
  console.warn(
7343
7481
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
@@ -7354,20 +7492,20 @@ function Puck({
7354
7492
  overrides,
7355
7493
  plugins
7356
7494
  });
7357
- const CustomPuck = useMemo18(
7495
+ const CustomPuck = useMemo19(
7358
7496
  () => loadedOverrides.puck || DefaultOverride,
7359
7497
  [loadedOverrides]
7360
7498
  );
7361
- const CustomHeader = useMemo18(
7499
+ const CustomHeader = useMemo19(
7362
7500
  () => loadedOverrides.header || defaultHeaderRender,
7363
7501
  [loadedOverrides]
7364
7502
  );
7365
- const CustomHeaderActions = useMemo18(
7503
+ const CustomHeaderActions = useMemo19(
7366
7504
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
7367
7505
  [loadedOverrides]
7368
7506
  );
7369
7507
  const [mounted, setMounted] = useState26(false);
7370
- useEffect23(() => {
7508
+ useEffect24(() => {
7371
7509
  setMounted(true);
7372
7510
  }, []);
7373
7511
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];