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

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -308,7 +308,7 @@ init_react_import();
308
308
 
309
309
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
310
310
  init_react_import();
311
- 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" };
311
+ 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" };
312
312
 
313
313
  // components/AutoField/index.tsx
314
314
  var import_react20 = require("react");
@@ -1697,12 +1697,13 @@ var DefaultField = ({
1697
1697
  field,
1698
1698
  onChange,
1699
1699
  readOnly,
1700
- value,
1700
+ value: _value,
1701
1701
  name,
1702
1702
  label,
1703
1703
  Label: Label2,
1704
1704
  id
1705
1705
  }) => {
1706
+ const value = _value;
1706
1707
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1707
1708
  Label2,
1708
1709
  {
@@ -1720,10 +1721,17 @@ var DefaultField = ({
1720
1721
  type: field.type,
1721
1722
  title: label || name,
1722
1723
  name,
1723
- value: typeof value === "undefined" ? "" : value.toString(),
1724
+ value: (value == null ? void 0 : value.toString) ? value.toString() : "",
1724
1725
  onChange: (e) => {
1725
1726
  if (field.type === "number") {
1726
- onChange(Number(e.currentTarget.value));
1727
+ const numberValue = Number(e.currentTarget.value);
1728
+ if (typeof field.min !== "undefined" && numberValue < field.min) {
1729
+ return;
1730
+ }
1731
+ if (typeof field.max !== "undefined" && numberValue > field.max) {
1732
+ return;
1733
+ }
1734
+ onChange(numberValue);
1727
1735
  } else {
1728
1736
  onChange(e.currentTarget.value);
1729
1737
  }
@@ -2471,6 +2479,7 @@ var FieldLabelInternal = ({
2471
2479
  function AutoFieldInternal(props) {
2472
2480
  var _a, _b, _c, _d, _e, _f, _g, _h;
2473
2481
  const { dispatch, overrides, selectedItem } = useAppContext();
2482
+ const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
2474
2483
  const { id, Label: Label2 = FieldLabelInternal } = props;
2475
2484
  const field = props.field;
2476
2485
  const label = field.label;
@@ -2535,7 +2544,6 @@ function AutoFieldInternal(props) {
2535
2544
  }
2536
2545
  const children = defaultFields[field.type](mergedProps);
2537
2546
  const Render2 = render[field.type];
2538
- const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
2539
2547
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2540
2548
  NestedFieldContext.Provider,
2541
2549
  {
@@ -3248,13 +3256,19 @@ var DraggableComponent = ({
3248
3256
  }
3249
3257
  }, [ref.current]);
3250
3258
  (0, import_react23.useEffect)(() => {
3251
- if (isSelected) {
3252
- ctx == null ? void 0 : ctx.registerPath({
3259
+ ctx == null ? void 0 : ctx.registerPath(
3260
+ id,
3261
+ {
3253
3262
  index,
3254
3263
  zone: zoneCompound
3255
- });
3256
- }
3257
- }, [isSelected]);
3264
+ },
3265
+ componentType
3266
+ );
3267
+ return () => {
3268
+ var _a;
3269
+ (_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
3270
+ };
3271
+ }, [id, zoneCompound, index, componentType]);
3258
3272
  const CustomActionBar = (0, import_react23.useMemo)(
3259
3273
  () => overrides.actionBar || DefaultActionBar,
3260
3274
  [overrides.actionBar]
@@ -3574,9 +3588,20 @@ var useContentWithPreview = (content, zoneCompound) => {
3574
3588
  };
3575
3589
  }
3576
3590
  );
3591
+ const {
3592
+ state: {
3593
+ ui: { isDragging }
3594
+ }
3595
+ } = useAppContext();
3577
3596
  const [contentWithPreview, setContentWithPreview] = (0, import_react27.useState)(content);
3597
+ const [localPreview, setLocalPreview] = (0, import_react27.useState)(
3598
+ preview
3599
+ );
3578
3600
  const updateContent = useRenderedCallback(
3579
- (content2, preview2) => {
3601
+ (content2, preview2, isDragging2) => {
3602
+ if (isDragging2 && !previewExists) {
3603
+ return;
3604
+ }
3580
3605
  if (preview2) {
3581
3606
  if (preview2.type === "insert") {
3582
3607
  setContentWithPreview(
@@ -3606,13 +3631,14 @@ var useContentWithPreview = (content, zoneCompound) => {
3606
3631
  previewExists ? content2.filter((item) => item.props.id !== draggedItemId) : content2
3607
3632
  );
3608
3633
  }
3634
+ setLocalPreview(preview2);
3609
3635
  },
3610
3636
  [draggedItemId, previewExists]
3611
3637
  );
3612
3638
  (0, import_react27.useEffect)(() => {
3613
- updateContent(content, preview);
3614
- }, [content, preview]);
3615
- return contentWithPreview;
3639
+ updateContent(content, preview, isDragging);
3640
+ }, [content, preview, isDragging]);
3641
+ return [contentWithPreview, localPreview];
3616
3642
  };
3617
3643
 
3618
3644
  // components/DropZone/lib/use-drag-axis.ts
@@ -3656,8 +3682,9 @@ var import_jsx_runtime22 = require("react/jsx-runtime");
3656
3682
  var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
3657
3683
  var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
3658
3684
  var RENDER_DEBUG = false;
3685
+ var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneEdit, __spreadValues({}, props));
3659
3686
  var DropZoneEdit = (0, import_react29.forwardRef)(
3660
- function DropZoneEdit2({
3687
+ function DropZoneEditInternal({
3661
3688
  zone,
3662
3689
  allow,
3663
3690
  disallow,
@@ -3691,8 +3718,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
3691
3718
  isDeepestZone,
3692
3719
  inNextDeepestArea,
3693
3720
  draggedComponentType,
3694
- userIsDragging,
3695
- preview
3721
+ userIsDragging
3696
3722
  } = useContextStore(ZoneStoreContext, (s) => {
3697
3723
  var _a, _b, _c;
3698
3724
  return {
@@ -3700,8 +3726,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
3700
3726
  inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
3701
3727
  draggedItemId: (_b = s.draggedItem) == null ? void 0 : _b.id,
3702
3728
  draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
3703
- userIsDragging: !!s.draggedItem,
3704
- preview: s.previewIndex[zoneCompound]
3729
+ userIsDragging: !!s.draggedItem
3705
3730
  };
3706
3731
  });
3707
3732
  const { itemSelector } = appContext2.state.ui;
@@ -3767,7 +3792,10 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
3767
3792
  if (isEnabled) {
3768
3793
  isEnabled = acceptsTarget(draggedComponentType);
3769
3794
  }
3770
- const contentWithPreview = useContentWithPreview(content, zoneCompound);
3795
+ const [contentWithPreview, preview] = useContentWithPreview(
3796
+ content,
3797
+ zoneCompound
3798
+ );
3771
3799
  const isDropEnabled = isEnabled && (preview ? contentWithPreview.length === 1 : contentWithPreview.length === 0);
3772
3800
  const droppableConfig = {
3773
3801
  id: zoneCompound,
@@ -3809,16 +3837,15 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
3809
3837
  },
3810
3838
  "data-testid": `dropzone:${zoneCompound}`,
3811
3839
  "data-puck-dropzone": zoneCompound,
3812
- "data-puck-dnd": zoneCompound,
3813
3840
  style: __spreadProps(__spreadValues({}, style), {
3814
3841
  "--min-empty-height": `${minEmptyHeight}px`,
3815
- backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
3842
+ backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
3816
3843
  }),
3817
3844
  children: contentWithPreview.map((item, i) => {
3818
- var _a, _b, _c, _d, _e;
3845
+ var _a, _b, _c, _d, _e, _f, _g;
3819
3846
  const componentId = item.props.id;
3820
3847
  const puckProps = {
3821
- renderDropZone: DropZone,
3848
+ renderDropZone: DropZoneEditPure,
3822
3849
  isEditing: true,
3823
3850
  dragRef: null
3824
3851
  };
@@ -3835,13 +3862,13 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
3835
3862
  const componentConfig = config.components[item.type];
3836
3863
  let componentType = item.type;
3837
3864
  let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3838
- if (item.type === "preview" && preview) {
3865
+ if (item.type === "preview") {
3839
3866
  let Preview4 = function() {
3840
3867
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3841
3868
  };
3842
3869
  var Preview3 = Preview4;
3843
- componentType = preview.componentType;
3844
- label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
3870
+ componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
3871
+ label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
3845
3872
  Render2 = Preview4;
3846
3873
  }
3847
3874
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
@@ -3856,7 +3883,7 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
3856
3883
  zoneCompound,
3857
3884
  depth: depth + 1,
3858
3885
  index: i,
3859
- isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
3886
+ isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
3860
3887
  isSelected,
3861
3888
  label,
3862
3889
  isEnabled,
@@ -3881,8 +3908,9 @@ var DropZoneEdit = (0, import_react29.forwardRef)(
3881
3908
  );
3882
3909
  }
3883
3910
  );
3911
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZoneRender, __spreadValues({}, props));
3884
3912
  var DropZoneRender = (0, import_react29.forwardRef)(
3885
- function DropZoneRender2({ className, style, zone }, ref) {
3913
+ function DropZoneRenderInternal({ className, style, zone }, ref) {
3886
3914
  const ctx = (0, import_react29.useContext)(dropZoneContext);
3887
3915
  const { data, areaId = "root", config } = ctx || {};
3888
3916
  let zoneCompound = rootDroppableId;
@@ -3920,7 +3948,9 @@ var DropZoneRender = (0, import_react29.forwardRef)(
3920
3948
  children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3921
3949
  Component.render,
3922
3950
  __spreadProps(__spreadValues({}, item.props), {
3923
- puck: { renderDropZone: DropZoneRender2 }
3951
+ puck: {
3952
+ renderDropZone: DropZoneRenderPure
3953
+ }
3924
3954
  })
3925
3955
  )
3926
3956
  },
@@ -3995,6 +4025,48 @@ var getFrame = () => {
3995
4025
  return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
3996
4026
  };
3997
4027
 
4028
+ // lib/global-position.ts
4029
+ init_react_import();
4030
+ var GlobalPosition = class {
4031
+ constructor(target, original) {
4032
+ this.scaleFactor = 1;
4033
+ this.frameEl = null;
4034
+ this.frameRect = null;
4035
+ var _a;
4036
+ this.target = target;
4037
+ this.original = original;
4038
+ this.frameEl = document.querySelector("iframe");
4039
+ if (this.frameEl) {
4040
+ this.frameRect = this.frameEl.getBoundingClientRect();
4041
+ this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
4042
+ }
4043
+ }
4044
+ get x() {
4045
+ return this.original.x;
4046
+ }
4047
+ get y() {
4048
+ return this.original.y;
4049
+ }
4050
+ get global() {
4051
+ if (document !== this.target.ownerDocument && this.frameRect) {
4052
+ return {
4053
+ x: this.x * this.scaleFactor + this.frameRect.left,
4054
+ y: this.y * this.scaleFactor + this.frameRect.top
4055
+ };
4056
+ }
4057
+ return this.original;
4058
+ }
4059
+ get frame() {
4060
+ if (document === this.target.ownerDocument && this.frameRect) {
4061
+ return {
4062
+ x: (this.x - this.frameRect.left) / this.scaleFactor,
4063
+ y: (this.y - this.frameRect.top) / this.scaleFactor
4064
+ };
4065
+ }
4066
+ return this.original;
4067
+ }
4068
+ };
4069
+
3998
4070
  // lib/dnd/NestedDroppablePlugin.ts
3999
4071
  var depthSort = (candidates) => {
4000
4072
  return candidates.sort((a, b) => {
@@ -4024,10 +4096,12 @@ var getZoneId2 = (candidate) => {
4024
4096
  }
4025
4097
  return id;
4026
4098
  };
4027
- var getPointerCollisions = (position, manager, ownerDocument) => {
4028
- var _a;
4099
+ var getPointerCollisions = (position, manager) => {
4029
4100
  const candidates = [];
4030
- let elements = ownerDocument.elementsFromPoint(position.x, position.y);
4101
+ let elements = position.target.ownerDocument.elementsFromPoint(
4102
+ position.x,
4103
+ position.y
4104
+ );
4031
4105
  const previewFrame = elements.find(
4032
4106
  (el) => el.getAttribute("data-puck-preview")
4033
4107
  );
@@ -4036,22 +4110,21 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
4036
4110
  elements = [drawer];
4037
4111
  }
4038
4112
  if (previewFrame) {
4039
- const iframe = previewFrame.querySelector("iframe");
4040
- if (iframe) {
4041
- const rect = iframe.getBoundingClientRect();
4042
- const frame = getFrame();
4043
- if (frame) {
4044
- const scaleFactor = rect.width / (((_a = iframe.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
4045
- elements = frame.elementsFromPoint(
4046
- (position.x - rect.left) / scaleFactor,
4047
- (position.y - rect.top) / scaleFactor
4048
- );
4049
- }
4113
+ const frame = getFrame();
4114
+ if (frame) {
4115
+ elements = frame.elementsFromPoint(position.frame.x, position.frame.y);
4050
4116
  }
4051
4117
  }
4052
4118
  if (elements) {
4053
4119
  for (let i = 0; i < elements.length; i++) {
4054
4120
  const element = elements[i];
4121
+ const dropzoneId = element.getAttribute("data-puck-dropzone");
4122
+ if (dropzoneId) {
4123
+ const droppable = manager.registry.droppables.get(dropzoneId);
4124
+ if (droppable) {
4125
+ candidates.push(droppable);
4126
+ }
4127
+ }
4055
4128
  const id = element.getAttribute("data-puck-dnd");
4056
4129
  if (id) {
4057
4130
  const droppable = manager.registry.droppables.get(id);
@@ -4063,9 +4136,9 @@ var getPointerCollisions = (position, manager, ownerDocument) => {
4063
4136
  }
4064
4137
  return candidates;
4065
4138
  };
4066
- var findDeepestCandidate = (position, manager, ownerDocument) => {
4139
+ var findDeepestCandidate = (position, manager) => {
4067
4140
  var _a;
4068
- const candidates = getPointerCollisions(position, manager, ownerDocument);
4141
+ const candidates = getPointerCollisions(position, manager);
4069
4142
  if (candidates.length > 0) {
4070
4143
  const sortedCandidates = depthSort(candidates);
4071
4144
  const draggable = manager.dragOperation.source;
@@ -4118,22 +4191,18 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
4118
4191
  }
4119
4192
  const cleanupEffect = (0, import_state.effects)(() => {
4120
4193
  const handleMove = (event) => {
4121
- const position = {
4194
+ const target = event.originalTarget || event.target;
4195
+ const position = new GlobalPosition(target, {
4122
4196
  x: event.clientX,
4123
4197
  y: event.clientY
4124
- };
4125
- const target = event.originalTarget || event.target;
4126
- const ownerDocument = target == null ? void 0 : target.ownerDocument;
4198
+ });
4127
4199
  const elements = document.elementsFromPoint(
4128
- event.clientX,
4129
- event.clientY
4200
+ position.global.x,
4201
+ position.global.y
4130
4202
  );
4131
4203
  const overEl = elements.some((el) => el.id === id);
4132
4204
  if (overEl) {
4133
- onChange(
4134
- findDeepestCandidate(position, manager, ownerDocument),
4135
- manager
4136
- );
4205
+ onChange(findDeepestCandidate(position, manager), manager);
4137
4206
  }
4138
4207
  };
4139
4208
  const handleMoveThrottled = throttle(handleMove, 50);
@@ -4464,6 +4533,11 @@ var reduceUi = (ui, action) => {
4464
4533
  itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4465
4534
  });
4466
4535
  }
4536
+ if (action.type === "remove") {
4537
+ return __spreadProps(__spreadValues({}, ui), {
4538
+ itemSelector: null
4539
+ });
4540
+ }
4467
4541
  return ui;
4468
4542
  };
4469
4543
 
@@ -4714,6 +4788,9 @@ var _PointerSensor = class _PointerSensor extends import_abstract10.Sensor {
4714
4788
  }
4715
4789
  }
4716
4790
  handlePointerUp(event) {
4791
+ if (!this.source) {
4792
+ return;
4793
+ }
4717
4794
  event.preventDefault();
4718
4795
  event.stopPropagation();
4719
4796
  const { status } = this.manager.dragOperation;
@@ -4992,27 +5069,33 @@ var DragDropContextClient = ({
4992
5069
  const [pathData, setPathData] = (0, import_react31.useState)();
4993
5070
  const dragMode = (0, import_react31.useRef)(null);
4994
5071
  const registerPath = (0, import_react31.useCallback)(
4995
- (selector) => {
4996
- const item = getItem(selector, data);
4997
- if (!item) {
4998
- return;
4999
- }
5072
+ (id2, selector, label) => {
5000
5073
  const [area] = getZoneId(selector.zone);
5001
5074
  setPathData((latestPathData = {}) => {
5002
5075
  const parentPathData = latestPathData[area] || { path: [] };
5003
5076
  return __spreadProps(__spreadValues({}, latestPathData), {
5004
- [item.props.id]: {
5077
+ [id2]: {
5005
5078
  path: [
5006
5079
  ...parentPathData.path,
5007
5080
  ...selector.zone ? [selector.zone] : []
5008
5081
  ],
5009
- label: item.type
5082
+ label
5010
5083
  }
5011
5084
  });
5012
5085
  });
5013
5086
  },
5014
5087
  [data, setPathData]
5015
5088
  );
5089
+ const unregisterPath = (0, import_react31.useCallback)(
5090
+ (id2) => {
5091
+ setPathData((latestPathData = {}) => {
5092
+ const newPathData = __spreadValues({}, latestPathData);
5093
+ delete newPathData[id2];
5094
+ return newPathData;
5095
+ });
5096
+ },
5097
+ [data, setPathData]
5098
+ );
5016
5099
  const initialSelector = (0, import_react31.useRef)(void 0);
5017
5100
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5018
5101
  dragListenerContext.Provider,
@@ -5209,6 +5292,7 @@ var DragDropContextClient = ({
5209
5292
  areaId: "root",
5210
5293
  depth: 0,
5211
5294
  registerPath,
5295
+ unregisterPath,
5212
5296
  pathData,
5213
5297
  path: []
5214
5298
  },
@@ -5335,7 +5419,7 @@ var Drawer = ({
5335
5419
  "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
5336
5420
  );
5337
5421
  }
5338
- const [id] = (0, import_react32.useState)(generateId());
5422
+ const id = (0, import_react32.useId)();
5339
5423
  const { ref } = useDroppableSafe({
5340
5424
  id,
5341
5425
  type: "void",
@@ -5357,7 +5441,7 @@ Drawer.Item = DrawerItem;
5357
5441
 
5358
5442
  // components/Puck/index.tsx
5359
5443
  init_react_import();
5360
- var import_react48 = require("react");
5444
+ var import_react50 = require("react");
5361
5445
 
5362
5446
  // components/SidebarSection/index.tsx
5363
5447
  init_react_import();
@@ -5550,36 +5634,61 @@ init_react_import();
5550
5634
 
5551
5635
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
5552
5636
  init_react_import();
5553
- 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" };
5637
+ 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" };
5554
5638
 
5555
5639
  // components/Puck/components/Fields/index.tsx
5556
- var import_react35 = require("react");
5640
+ var import_react37 = require("react");
5641
+
5642
+ // lib/use-resolved-fields.ts
5643
+ init_react_import();
5644
+ var import_react36 = require("react");
5557
5645
 
5558
5646
  // lib/use-parent.ts
5559
5647
  init_react_import();
5560
5648
  var import_react34 = require("react");
5561
- var useParent = (itemSelector) => {
5649
+ var getParent = (itemSelector, pathData, data) => {
5562
5650
  var _a;
5563
- const { selectedItem, state } = useAppContext();
5564
- const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
5565
- const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
5566
- const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
5651
+ if (!itemSelector) return null;
5652
+ const item = getItem(itemSelector, data);
5653
+ const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
5567
5654
  const lastItem = breadcrumbs[breadcrumbs.length - 1];
5568
- const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, state.data)) != null ? _a : null : null;
5655
+ const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
5569
5656
  return parent || null;
5570
5657
  };
5658
+ var useGetParent = () => {
5659
+ const { state } = useAppContext();
5660
+ const { pathData } = (0, import_react34.useContext)(dropZoneContext) || {};
5661
+ return (0, import_react34.useCallback)(
5662
+ () => getParent(state.ui.itemSelector, pathData, state.data),
5663
+ [state.ui.itemSelector, pathData, state.data]
5664
+ );
5665
+ };
5666
+ var useParent = () => {
5667
+ return useGetParent()();
5668
+ };
5571
5669
 
5572
- // components/Puck/components/Fields/index.tsx
5573
- var import_jsx_runtime27 = require("react/jsx-runtime");
5574
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5670
+ // lib/use-on-value-change.ts
5671
+ init_react_import();
5672
+ var import_react35 = require("react");
5673
+ function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
5674
+ const tracked = (0, import_react35.useRef)(value);
5675
+ (0, import_react35.useEffect)(() => {
5676
+ const oldValue = tracked.current;
5677
+ if (!compare(value, oldValue)) {
5678
+ tracked.current = value;
5679
+ onChange(value, oldValue);
5680
+ }
5681
+ }, [onChange, compare, value, ...deps]);
5682
+ }
5683
+
5684
+ // lib/selector-is.ts
5685
+ init_react_import();
5686
+ 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);
5687
+
5688
+ // lib/use-resolved-fields.ts
5575
5689
  var defaultPageFields = {
5576
5690
  title: { type: "text" }
5577
5691
  };
5578
- var DefaultFields = ({
5579
- children
5580
- }) => {
5581
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
5582
- };
5583
5692
  var useResolvedFields = () => {
5584
5693
  var _a, _b;
5585
5694
  const { selectedItem, state, config } = useAppContext();
@@ -5587,20 +5696,21 @@ var useResolvedFields = () => {
5587
5696
  const { data } = state;
5588
5697
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
5589
5698
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
5590
- const defaultFields = (0, import_react35.useMemo)(
5699
+ const defaultFields = (0, import_react36.useMemo)(
5591
5700
  () => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
5592
5701
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
5593
5702
  );
5594
5703
  const rootProps = data.root.props || data.root;
5595
- const [lastSelectedData, setLastSelectedData] = (0, import_react35.useState)({});
5596
- const [resolvedFields, setResolvedFields] = (0, import_react35.useState)(defaultFields);
5597
- const [fieldsLoading, setFieldsLoading] = (0, import_react35.useState)(false);
5704
+ const [lastSelectedData, setLastSelectedData] = (0, import_react36.useState)({});
5705
+ const [resolvedFields, setResolvedFields] = (0, import_react36.useState)(defaultFields);
5706
+ const [fieldsLoading, setFieldsLoading] = (0, import_react36.useState)(false);
5707
+ const lastFields = (0, import_react36.useRef)(defaultFields);
5598
5708
  const defaultResolveFields = (_componentData, _params) => defaultFields;
5599
5709
  const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
5600
5710
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
5601
5711
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
5602
5712
  const hasResolver = hasComponentResolver || hasRootResolver;
5603
- const resolveFields = (0, import_react35.useCallback)(
5713
+ const resolveFields = (0, import_react36.useCallback)(
5604
5714
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
5605
5715
  var _a2;
5606
5716
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -5612,7 +5722,7 @@ var useResolvedFields = () => {
5612
5722
  {
5613
5723
  changed,
5614
5724
  fields,
5615
- lastFields: resolvedFields,
5725
+ lastFields: lastFields.current,
5616
5726
  lastData,
5617
5727
  appState: state,
5618
5728
  parent
@@ -5623,7 +5733,7 @@ var useResolvedFields = () => {
5623
5733
  return yield config.root.resolveFields(componentData, {
5624
5734
  changed,
5625
5735
  fields,
5626
- lastFields: resolvedFields,
5736
+ lastFields: lastFields.current,
5627
5737
  lastData,
5628
5738
  appState: state,
5629
5739
  parent
@@ -5632,26 +5742,56 @@ var useResolvedFields = () => {
5632
5742
  return defaultResolveFields(componentData, {
5633
5743
  changed,
5634
5744
  fields,
5635
- lastFields: resolvedFields,
5745
+ lastFields: lastFields.current,
5636
5746
  lastData
5637
5747
  });
5638
5748
  }),
5639
- [data, config, componentData, selectedItem, resolvedFields, state]
5749
+ [data, config, componentData, selectedItem, state, parent]
5640
5750
  );
5641
- (0, import_react35.useEffect)(() => {
5642
- if (hasResolver) {
5643
- setFieldsLoading(true);
5644
- resolveFields(defaultFields).then((fields) => {
5645
- setResolvedFields(fields || {});
5646
- setFieldsLoading(false);
5647
- });
5648
- } else {
5649
- setResolvedFields(defaultFields);
5751
+ const triggerResolver = (0, import_react36.useCallback)(() => {
5752
+ var _a2, _b2;
5753
+ if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
5754
+ if (hasResolver) {
5755
+ setFieldsLoading(true);
5756
+ resolveFields(defaultFields).then((fields) => {
5757
+ setResolvedFields(fields || {});
5758
+ lastFields.current = fields;
5759
+ setFieldsLoading(false);
5760
+ });
5761
+ return;
5762
+ }
5650
5763
  }
5651
- }, [data, defaultFields, selectedItem, hasResolver]);
5764
+ setResolvedFields(defaultFields);
5765
+ }, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
5766
+ useOnValueChange(
5767
+ state.ui.itemSelector,
5768
+ () => {
5769
+ lastFields.current = defaultFields;
5770
+ },
5771
+ selectorIs
5772
+ );
5773
+ useOnValueChange(
5774
+ { data, parent, itemSelector: state.ui.itemSelector },
5775
+ () => {
5776
+ triggerResolver();
5777
+ },
5778
+ (a, b) => JSON.stringify(a) === JSON.stringify(b)
5779
+ );
5780
+ (0, import_react36.useEffect)(() => {
5781
+ triggerResolver();
5782
+ }, []);
5652
5783
  return [resolvedFields, fieldsLoading];
5653
5784
  };
5654
- var Fields = () => {
5785
+
5786
+ // components/Puck/components/Fields/index.tsx
5787
+ var import_jsx_runtime27 = require("react/jsx-runtime");
5788
+ var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5789
+ var DefaultFields = ({
5790
+ children
5791
+ }) => {
5792
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children });
5793
+ };
5794
+ var Fields = ({ wrapFields = true }) => {
5655
5795
  var _a, _b;
5656
5796
  const {
5657
5797
  selectedItem,
@@ -5669,11 +5809,11 @@ var Fields = () => {
5669
5809
  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;
5670
5810
  const isLoading = fieldsResolving || componentResolving;
5671
5811
  const rootProps = data.root.props || data.root;
5672
- const Wrapper = (0, import_react35.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
5812
+ const Wrapper = (0, import_react37.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
5673
5813
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
5674
5814
  "form",
5675
5815
  {
5676
- className: getClassName21(),
5816
+ className: getClassName21({ wrapFields }),
5677
5817
  onSubmit: (e) => {
5678
5818
  e.preventDefault();
5679
5819
  },
@@ -5749,7 +5889,7 @@ var Fields = () => {
5749
5889
  item: selectedItem
5750
5890
  });
5751
5891
  const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
5752
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5892
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5753
5893
  AutoFieldPrivate,
5754
5894
  {
5755
5895
  field,
@@ -5758,16 +5898,15 @@ var Fields = () => {
5758
5898
  readOnly: !edit || readOnly[fieldName],
5759
5899
  value: selectedItem.props[fieldName],
5760
5900
  onChange
5761
- },
5762
- id
5763
- );
5901
+ }
5902
+ ) }, id);
5764
5903
  } else {
5765
5904
  const readOnly = data.root.readOnly || {};
5766
5905
  const { edit } = getPermissions({
5767
5906
  root: true
5768
5907
  });
5769
5908
  const id = `root_${field.type}_${fieldName}`;
5770
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5909
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("field"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
5771
5910
  AutoFieldPrivate,
5772
5911
  {
5773
5912
  field,
@@ -5776,9 +5915,8 @@ var Fields = () => {
5776
5915
  readOnly: !edit || readOnly[fieldName],
5777
5916
  value: rootProps[fieldName],
5778
5917
  onChange
5779
- },
5780
- id
5781
- );
5918
+ }
5919
+ ) }, id);
5782
5920
  }
5783
5921
  }) }),
5784
5922
  isLoading && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Loader, { size: 16 }) }) })
@@ -5792,7 +5930,7 @@ init_react_import();
5792
5930
 
5793
5931
  // lib/use-component-list.tsx
5794
5932
  init_react_import();
5795
- var import_react36 = require("react");
5933
+ var import_react38 = require("react");
5796
5934
 
5797
5935
  // components/ComponentList/index.tsx
5798
5936
  init_react_import();
@@ -5859,8 +5997,8 @@ ComponentList.Item = ComponentListItem;
5859
5997
  // lib/use-component-list.tsx
5860
5998
  var import_jsx_runtime29 = require("react/jsx-runtime");
5861
5999
  var useComponentList = (config, ui) => {
5862
- const [componentList, setComponentList] = (0, import_react36.useState)();
5863
- (0, import_react36.useEffect)(() => {
6000
+ const [componentList, setComponentList] = (0, import_react38.useState)();
6001
+ (0, import_react38.useEffect)(() => {
5864
6002
  var _a, _b, _c;
5865
6003
  if (Object.keys(ui.componentList).length > 0) {
5866
6004
  const matchedComponents = [];
@@ -5929,22 +6067,22 @@ var useComponentList = (config, ui) => {
5929
6067
  };
5930
6068
 
5931
6069
  // components/Puck/components/Components/index.tsx
5932
- var import_react37 = require("react");
6070
+ var import_react39 = require("react");
5933
6071
  var import_jsx_runtime30 = require("react/jsx-runtime");
5934
6072
  var Components = () => {
5935
6073
  const { config, state, overrides } = useAppContext();
5936
6074
  const componentList = useComponentList(config, state.ui);
5937
- const Wrapper = (0, import_react37.useMemo)(() => overrides.components || "div", [overrides]);
6075
+ const Wrapper = (0, import_react39.useMemo)(() => overrides.components || "div", [overrides]);
5938
6076
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
5939
6077
  };
5940
6078
 
5941
6079
  // components/Puck/components/Preview/index.tsx
5942
6080
  init_react_import();
5943
- var import_react39 = require("react");
6081
+ var import_react41 = require("react");
5944
6082
 
5945
6083
  // components/AutoFrame/index.tsx
5946
6084
  init_react_import();
5947
- var import_react38 = require("react");
6085
+ var import_react40 = require("react");
5948
6086
  var import_object_hash = __toESM(require("object-hash"));
5949
6087
  var import_react_dom3 = require("react-dom");
5950
6088
  var import_jsx_runtime31 = require("react/jsx-runtime");
@@ -5990,7 +6128,7 @@ var CopyHostStyles = ({
5990
6128
  onStylesLoaded = () => null
5991
6129
  }) => {
5992
6130
  const { document: doc, window: win } = useFrame();
5993
- (0, import_react38.useEffect)(() => {
6131
+ (0, import_react40.useEffect)(() => {
5994
6132
  if (!win || !doc) {
5995
6133
  return () => {
5996
6134
  };
@@ -6149,8 +6287,8 @@ var CopyHostStyles = ({
6149
6287
  }, []);
6150
6288
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
6151
6289
  };
6152
- var autoFrameContext = (0, import_react38.createContext)({});
6153
- var useFrame = () => (0, import_react38.useContext)(autoFrameContext);
6290
+ var autoFrameContext = (0, import_react40.createContext)({});
6291
+ var useFrame = () => (0, import_react40.useContext)(autoFrameContext);
6154
6292
  function AutoFrame(_a) {
6155
6293
  var _b = _a, {
6156
6294
  children,
@@ -6167,10 +6305,10 @@ function AutoFrame(_a) {
6167
6305
  "onStylesLoaded",
6168
6306
  "frameRef"
6169
6307
  ]);
6170
- const [loaded, setLoaded] = (0, import_react38.useState)(false);
6171
- const [ctx, setCtx] = (0, import_react38.useState)({});
6172
- const [mountTarget, setMountTarget] = (0, import_react38.useState)();
6173
- (0, import_react38.useEffect)(() => {
6308
+ const [loaded, setLoaded] = (0, import_react40.useState)(false);
6309
+ const [ctx, setCtx] = (0, import_react40.useState)({});
6310
+ const [mountTarget, setMountTarget] = (0, import_react40.useState)();
6311
+ (0, import_react40.useEffect)(() => {
6174
6312
  var _a2;
6175
6313
  if (frameRef.current) {
6176
6314
  setCtx({
@@ -6264,7 +6402,7 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
6264
6402
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
6265
6403
  var useBubbleIframeEvents = (ref) => {
6266
6404
  const { status } = useAppContext();
6267
- (0, import_react39.useEffect)(() => {
6405
+ (0, import_react41.useEffect)(() => {
6268
6406
  var _a;
6269
6407
  if (ref.current && status === "READY") {
6270
6408
  const iframe = ref.current;
@@ -6303,7 +6441,7 @@ var useBubbleIframeEvents = (ref) => {
6303
6441
  };
6304
6442
  var Preview2 = ({ id = "puck-preview" }) => {
6305
6443
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
6306
- const Page = (0, import_react39.useCallback)(
6444
+ const Page = (0, import_react41.useCallback)(
6307
6445
  (pageProps) => {
6308
6446
  var _a, _b;
6309
6447
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
@@ -6312,9 +6450,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
6312
6450
  },
6313
6451
  [config.root]
6314
6452
  );
6315
- const Frame = (0, import_react39.useMemo)(() => overrides.iframe, [overrides]);
6453
+ const Frame = (0, import_react41.useMemo)(() => overrides.iframe, [overrides]);
6316
6454
  const rootProps = state.data.root.props || state.data.root;
6317
- const ref = (0, import_react39.useRef)(null);
6455
+ const ref = (0, import_react41.useRef)(null);
6318
6456
  useBubbleIframeEvents(ref);
6319
6457
  const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
6320
6458
  Page,
@@ -6411,7 +6549,7 @@ var scrollIntoView = (el) => {
6411
6549
  };
6412
6550
 
6413
6551
  // components/LayerTree/index.tsx
6414
- var import_react40 = require("react");
6552
+ var import_react42 = require("react");
6415
6553
 
6416
6554
  // lib/is-child-of-zone.ts
6417
6555
  init_react_import();
@@ -6457,7 +6595,7 @@ var LayerTree = ({
6457
6595
  label
6458
6596
  }) => {
6459
6597
  const zones = data.zones || {};
6460
- const ctx = (0, import_react40.useContext)(dropZoneContext);
6598
+ const ctx = (0, import_react42.useContext)(dropZoneContext);
6461
6599
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
6462
6600
  label && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
6463
6601
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Layers, { size: "16" }) }),
@@ -6564,13 +6702,13 @@ var LayerTree = ({
6564
6702
  };
6565
6703
 
6566
6704
  // components/Puck/components/Outline/index.tsx
6567
- var import_react41 = require("react");
6705
+ var import_react43 = require("react");
6568
6706
  var import_jsx_runtime35 = require("react/jsx-runtime");
6569
6707
  var Outline = () => {
6570
6708
  const { dispatch, state, overrides, config } = useAppContext();
6571
6709
  const { data, ui } = state;
6572
6710
  const { itemSelector } = ui;
6573
- const setItemSelector = (0, import_react41.useCallback)(
6711
+ const setItemSelector = (0, import_react43.useCallback)(
6574
6712
  (newItemSelector) => {
6575
6713
  dispatch({
6576
6714
  type: "setUi",
@@ -6579,7 +6717,7 @@ var Outline = () => {
6579
6717
  },
6580
6718
  []
6581
6719
  );
6582
- const Wrapper = (0, import_react41.useMemo)(() => overrides.outline || "div", [overrides]);
6720
+ const Wrapper = (0, import_react43.useMemo)(() => overrides.outline || "div", [overrides]);
6583
6721
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
6584
6722
  (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
6585
6723
  LayerTree,
@@ -6693,19 +6831,19 @@ function usePuckHistory({
6693
6831
 
6694
6832
  // lib/use-history-store.ts
6695
6833
  init_react_import();
6696
- var import_react42 = require("react");
6834
+ var import_react44 = require("react");
6697
6835
  var import_use_debounce3 = require("use-debounce");
6698
6836
  var EMPTY_HISTORY_INDEX = 0;
6699
6837
  function useHistoryStore(initialHistory) {
6700
6838
  var _a, _b;
6701
- const [histories, setHistories] = (0, import_react42.useState)(
6839
+ const [histories, setHistories] = (0, import_react44.useState)(
6702
6840
  (_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
6703
6841
  );
6704
6842
  const updateHistories = (histories2) => {
6705
6843
  setHistories(histories2);
6706
6844
  setIndex(histories2.length - 1);
6707
6845
  };
6708
- const [index, setIndex] = (0, import_react42.useState)(
6846
+ const [index, setIndex] = (0, import_react44.useState)(
6709
6847
  (_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
6710
6848
  );
6711
6849
  const hasPast = index > EMPTY_HISTORY_INDEX;
@@ -6865,11 +7003,11 @@ var getBox = function getBox2(el) {
6865
7003
  };
6866
7004
 
6867
7005
  // components/Puck/components/Canvas/index.tsx
6868
- var import_react44 = require("react");
7006
+ var import_react46 = require("react");
6869
7007
 
6870
7008
  // components/ViewportControls/index.tsx
6871
7009
  init_react_import();
6872
- var import_react43 = require("react");
7010
+ var import_react45 = require("react");
6873
7011
 
6874
7012
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
6875
7013
  init_react_import();
@@ -6892,8 +7030,8 @@ var ViewportButton = ({
6892
7030
  onClick
6893
7031
  }) => {
6894
7032
  const { state } = useAppContext();
6895
- const [isActive, setIsActive] = (0, import_react43.useState)(false);
6896
- (0, import_react43.useEffect)(() => {
7033
+ const [isActive, setIsActive] = (0, import_react45.useState)(false);
7034
+ (0, import_react45.useEffect)(() => {
6897
7035
  setIsActive(width === state.ui.viewports.current.width);
6898
7036
  }, [width, state.ui.viewports.current.width]);
6899
7037
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
@@ -6929,7 +7067,7 @@ var ViewportControls = ({
6929
7067
  const defaultsContainAutoZoom = defaultZoomOptions.find(
6930
7068
  (option) => option.value === autoZoom
6931
7069
  );
6932
- const zoomOptions = (0, import_react43.useMemo)(
7070
+ const zoomOptions = (0, import_react45.useMemo)(
6933
7071
  () => [
6934
7072
  ...defaultZoomOptions,
6935
7073
  ...defaultsContainAutoZoom ? [] : [
@@ -7052,17 +7190,17 @@ var Canvas = () => {
7052
7190
  const { status, iframe } = useAppContext();
7053
7191
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
7054
7192
  const { ui } = state;
7055
- const frameRef = (0, import_react44.useRef)(null);
7056
- const [showTransition, setShowTransition] = (0, import_react44.useState)(false);
7057
- const defaultRender = (0, import_react44.useMemo)(() => {
7193
+ const frameRef = (0, import_react46.useRef)(null);
7194
+ const [showTransition, setShowTransition] = (0, import_react46.useState)(false);
7195
+ const defaultRender = (0, import_react46.useMemo)(() => {
7058
7196
  const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
7059
7197
  return PuckDefault;
7060
7198
  }, []);
7061
- const CustomPreview = (0, import_react44.useMemo)(
7199
+ const CustomPreview = (0, import_react46.useMemo)(
7062
7200
  () => overrides.preview || defaultRender,
7063
7201
  [overrides]
7064
7202
  );
7065
- const getFrameDimensions = (0, import_react44.useCallback)(() => {
7203
+ const getFrameDimensions = (0, import_react46.useCallback)(() => {
7066
7204
  if (frameRef.current) {
7067
7205
  const frame = frameRef.current;
7068
7206
  const box = getBox(frame);
@@ -7070,7 +7208,7 @@ var Canvas = () => {
7070
7208
  }
7071
7209
  return { width: 0, height: 0 };
7072
7210
  }, [frameRef]);
7073
- const resetAutoZoom = (0, import_react44.useCallback)(
7211
+ const resetAutoZoom = (0, import_react46.useCallback)(
7074
7212
  (ui2 = state.ui) => {
7075
7213
  if (frameRef.current) {
7076
7214
  setZoomConfig(
@@ -7080,11 +7218,11 @@ var Canvas = () => {
7080
7218
  },
7081
7219
  [frameRef, zoomConfig, state.ui]
7082
7220
  );
7083
- (0, import_react44.useEffect)(() => {
7221
+ (0, import_react46.useEffect)(() => {
7084
7222
  setShowTransition(false);
7085
7223
  resetAutoZoom();
7086
7224
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
7087
- (0, import_react44.useEffect)(() => {
7225
+ (0, import_react46.useEffect)(() => {
7088
7226
  const { height: frameHeight } = getFrameDimensions();
7089
7227
  if (ui.viewports.current.height === "auto") {
7090
7228
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -7092,13 +7230,13 @@ var Canvas = () => {
7092
7230
  }));
7093
7231
  }
7094
7232
  }, [zoomConfig.zoom]);
7095
- (0, import_react44.useEffect)(() => {
7233
+ (0, import_react46.useEffect)(() => {
7096
7234
  if (ZOOM_ON_CHANGE) {
7097
7235
  setShowTransition(true);
7098
7236
  resetAutoZoom(ui);
7099
7237
  }
7100
7238
  }, [ui.viewports.current.width]);
7101
- (0, import_react44.useEffect)(() => {
7239
+ (0, import_react46.useEffect)(() => {
7102
7240
  const cb = () => {
7103
7241
  setShowTransition(false);
7104
7242
  resetAutoZoom();
@@ -7108,8 +7246,8 @@ var Canvas = () => {
7108
7246
  window.removeEventListener("resize", cb);
7109
7247
  };
7110
7248
  }, []);
7111
- const [showLoader, setShowLoader] = (0, import_react44.useState)(false);
7112
- (0, import_react44.useEffect)(() => {
7249
+ const [showLoader, setShowLoader] = (0, import_react46.useState)(false);
7250
+ (0, import_react46.useEffect)(() => {
7113
7251
  setTimeout(() => {
7114
7252
  setShowLoader(true);
7115
7253
  }, 500);
@@ -7187,7 +7325,7 @@ var Canvas = () => {
7187
7325
 
7188
7326
  // lib/use-loaded-overrides.ts
7189
7327
  init_react_import();
7190
- var import_react45 = require("react");
7328
+ var import_react47 = require("react");
7191
7329
 
7192
7330
  // lib/load-overrides.ts
7193
7331
  init_react_import();
@@ -7226,7 +7364,7 @@ var useLoadedOverrides = ({
7226
7364
  overrides,
7227
7365
  plugins
7228
7366
  }) => {
7229
- return (0, import_react45.useMemo)(() => {
7367
+ return (0, import_react47.useMemo)(() => {
7230
7368
  return loadOverrides({ overrides, plugins });
7231
7369
  }, [plugins, overrides]);
7232
7370
  };
@@ -7238,14 +7376,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38
7238
7376
 
7239
7377
  // lib/use-inject-css.ts
7240
7378
  init_react_import();
7241
- var import_react46 = require("react");
7379
+ var import_react48 = require("react");
7242
7380
  var styles = ``;
7243
7381
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7244
- const [el, setEl] = (0, import_react46.useState)();
7245
- (0, import_react46.useEffect)(() => {
7382
+ const [el, setEl] = (0, import_react48.useState)();
7383
+ (0, import_react48.useEffect)(() => {
7246
7384
  setEl(document.createElement("style"));
7247
7385
  }, []);
7248
- (0, import_react46.useEffect)(() => {
7386
+ (0, import_react48.useEffect)(() => {
7249
7387
  var _a;
7250
7388
  if (!el || typeof window === "undefined") {
7251
7389
  return;
@@ -7265,10 +7403,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
7265
7403
 
7266
7404
  // lib/use-preview-mode-hotkeys.ts
7267
7405
  init_react_import();
7268
- var import_react47 = require("react");
7406
+ var import_react49 = require("react");
7269
7407
  var import_react_hotkeys_hook2 = require("react-hotkeys-hook");
7270
7408
  var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
7271
- const toggleInteractive = (0, import_react47.useCallback)(() => {
7409
+ const toggleInteractive = (0, import_react49.useCallback)(() => {
7272
7410
  dispatch({
7273
7411
  type: "setUi",
7274
7412
  ui: (ui) => ({
@@ -7320,7 +7458,7 @@ function Puck({
7320
7458
  waitForStyles: true
7321
7459
  }, _iframe);
7322
7460
  useInjectGlobalCss(iframe.enabled);
7323
- const [generatedAppState] = (0, import_react48.useState)(() => {
7461
+ const [generatedAppState] = (0, import_react50.useState)(() => {
7324
7462
  var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
7325
7463
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
7326
7464
  let clientUiState = {};
@@ -7392,14 +7530,14 @@ function Puck({
7392
7530
  histories,
7393
7531
  index: initialHistoryIndex
7394
7532
  });
7395
- const [reducer] = (0, import_react48.useState)(
7533
+ const [reducer] = (0, import_react50.useState)(
7396
7534
  () => createReducer({
7397
7535
  config,
7398
7536
  record: historyStore.record,
7399
7537
  onAction
7400
7538
  })
7401
7539
  );
7402
- const [appState, dispatch] = (0, import_react48.useReducer)(
7540
+ const [appState, dispatch] = (0, import_react50.useReducer)(
7403
7541
  reducer,
7404
7542
  flushZones(initialAppState)
7405
7543
  );
@@ -7410,14 +7548,14 @@ function Puck({
7410
7548
  historyStore,
7411
7549
  iframeEnabled: (_a = _iframe == null ? void 0 : _iframe.enabled) != null ? _a : true
7412
7550
  });
7413
- const [menuOpen, setMenuOpen] = (0, import_react48.useState)(false);
7551
+ const [menuOpen, setMenuOpen] = (0, import_react50.useState)(false);
7414
7552
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
7415
7553
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
7416
- (0, import_react48.useEffect)(() => {
7554
+ (0, import_react50.useEffect)(() => {
7417
7555
  if (onChange) onChange(data);
7418
7556
  }, [data]);
7419
7557
  const rootProps = data.root.props || data.root;
7420
- const toggleSidebars = (0, import_react48.useCallback)(
7558
+ const toggleSidebars = (0, import_react50.useCallback)(
7421
7559
  (sidebar) => {
7422
7560
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7423
7561
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -7431,7 +7569,7 @@ function Puck({
7431
7569
  },
7432
7570
  [dispatch, leftSideBarVisible, rightSideBarVisible]
7433
7571
  );
7434
- (0, import_react48.useEffect)(() => {
7572
+ (0, import_react50.useEffect)(() => {
7435
7573
  if (!window.matchMedia("(min-width: 638px)").matches) {
7436
7574
  dispatch({
7437
7575
  type: "setUi",
@@ -7454,7 +7592,7 @@ function Puck({
7454
7592
  window.removeEventListener("resize", handleResize);
7455
7593
  };
7456
7594
  }, []);
7457
- const defaultHeaderRender = (0, import_react48.useMemo)(() => {
7595
+ const defaultHeaderRender = (0, import_react50.useMemo)(() => {
7458
7596
  if (renderHeader) {
7459
7597
  console.warn(
7460
7598
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -7468,7 +7606,7 @@ function Puck({
7468
7606
  }
7469
7607
  return DefaultOverride;
7470
7608
  }, [renderHeader]);
7471
- const defaultHeaderActionsRender = (0, import_react48.useMemo)(() => {
7609
+ const defaultHeaderActionsRender = (0, import_react50.useMemo)(() => {
7472
7610
  if (renderHeaderActions) {
7473
7611
  console.warn(
7474
7612
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
@@ -7485,20 +7623,20 @@ function Puck({
7485
7623
  overrides,
7486
7624
  plugins
7487
7625
  });
7488
- const CustomPuck = (0, import_react48.useMemo)(
7626
+ const CustomPuck = (0, import_react50.useMemo)(
7489
7627
  () => loadedOverrides.puck || DefaultOverride,
7490
7628
  [loadedOverrides]
7491
7629
  );
7492
- const CustomHeader = (0, import_react48.useMemo)(
7630
+ const CustomHeader = (0, import_react50.useMemo)(
7493
7631
  () => loadedOverrides.header || defaultHeaderRender,
7494
7632
  [loadedOverrides]
7495
7633
  );
7496
- const CustomHeaderActions = (0, import_react48.useMemo)(
7634
+ const CustomHeaderActions = (0, import_react50.useMemo)(
7497
7635
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
7498
7636
  [loadedOverrides]
7499
7637
  );
7500
- const [mounted, setMounted] = (0, import_react48.useState)(false);
7501
- (0, import_react48.useEffect)(() => {
7638
+ const [mounted, setMounted] = (0, import_react50.useState)(false);
7639
+ (0, import_react50.useEffect)(() => {
7502
7640
  setMounted(true);
7503
7641
  }, []);
7504
7642
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];