@measured/puck 0.19.0-canary.a967ca42 → 0.19.0-canary.af1dc891

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
@@ -9,6 +9,7 @@ import {
9
9
  __toESM,
10
10
  defaultAppState,
11
11
  defaultViewports,
12
+ expandNode,
12
13
  getChanged,
13
14
  init_react_import,
14
15
  migrate,
@@ -21,8 +22,9 @@ import {
21
22
  transformProps,
22
23
  useSlots,
23
24
  walkAppState,
25
+ walkField,
24
26
  walkTree
25
- } from "./chunk-GL73J54P.mjs";
27
+ } from "./chunk-HGAPIQP5.mjs";
26
28
 
27
29
  // ../../node_modules/classnames/index.js
28
30
  var require_classnames = __commonJS({
@@ -746,7 +748,7 @@ var populateIds = (data, config, override = false) => {
746
748
  const id = generateId(data.type);
747
749
  return walkTree(
748
750
  __spreadProps(__spreadValues({}, data), {
749
- props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
751
+ props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
750
752
  }),
751
753
  config,
752
754
  (contents) => contents.map((item) => {
@@ -1425,7 +1427,11 @@ var createNodesSlice = (set, get) => ({
1425
1427
  const s = get().nodes;
1426
1428
  const emptyNode = {
1427
1429
  id,
1428
- methods: { sync: () => null },
1430
+ methods: {
1431
+ sync: () => null,
1432
+ hideOverlay: () => null,
1433
+ showOverlay: () => null
1434
+ },
1429
1435
  element: null
1430
1436
  };
1431
1437
  const existingNode = s.nodes[id];
@@ -2445,6 +2451,19 @@ var ArrayField = ({
2445
2451
  );
2446
2452
  const forceReadOnly = !canEdit;
2447
2453
  const valueRef = useRef(value);
2454
+ const uniqifyItem = useCallback2(
2455
+ (val) => {
2456
+ if (field.type !== "array" || !field.arrayFields) return;
2457
+ const config = appStore.getState().config;
2458
+ return walkField({
2459
+ value: val,
2460
+ fields: field.arrayFields,
2461
+ map: (content) => content.map((item) => populateIds(item, config, true)),
2462
+ config
2463
+ });
2464
+ },
2465
+ [appStore, field]
2466
+ );
2448
2467
  if (field.type !== "array" || !field.arrayFields) {
2449
2468
  return null;
2450
2469
  }
@@ -2549,11 +2568,10 @@ var ArrayField = ({
2549
2568
  onClick: (e) => {
2550
2569
  e.stopPropagation();
2551
2570
  const existingValue = [...value || []];
2552
- existingValue.splice(
2553
- i,
2554
- 0,
2571
+ const newItem = uniqifyItem(
2555
2572
  existingValue[i]
2556
2573
  );
2574
+ existingValue.splice(i, 0, newItem);
2557
2575
  const newUi = mapArrayStateToUi(
2558
2576
  regenerateArrayState(existingValue)
2559
2577
  );
@@ -2651,12 +2669,11 @@ var ArrayField = ({
2651
2669
  type: "button",
2652
2670
  className: getClassName5("addButton"),
2653
2671
  onClick: () => {
2672
+ var _a;
2654
2673
  if (isDraggingAny) return;
2655
2674
  const existingValue = value || [];
2656
- const newValue = [
2657
- ...existingValue,
2658
- field.defaultItemProps || {}
2659
- ];
2675
+ const newItem = uniqifyItem((_a = field.defaultItemProps) != null ? _a : {});
2676
+ const newValue = [...existingValue, newItem];
2660
2677
  const newArrayState = regenerateArrayState(newValue);
2661
2678
  setUi(mapArrayStateToUi(newArrayState), false);
2662
2679
  onChange(newValue);
@@ -3556,6 +3573,10 @@ function AutoFieldInternal(props) {
3556
3573
  });
3557
3574
  }
3558
3575
  }, []);
3576
+ const { visible = true } = props.field;
3577
+ if (!visible) {
3578
+ return null;
3579
+ }
3559
3580
  if (field.type === "slot") {
3560
3581
  return null;
3561
3582
  }
@@ -3654,7 +3675,7 @@ import {
3654
3675
  useContext as useContext8,
3655
3676
  useEffect as useEffect17,
3656
3677
  useMemo as useMemo10,
3657
- useRef as useRef4,
3678
+ useRef as useRef5,
3658
3679
  useState as useState14
3659
3680
  } from "react";
3660
3681
  import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
@@ -3668,7 +3689,7 @@ import {
3668
3689
  useContext as useContext7,
3669
3690
  useEffect as useEffect16,
3670
3691
  useMemo as useMemo9,
3671
- useRef as useRef3
3692
+ useRef as useRef4
3672
3693
  } from "react";
3673
3694
 
3674
3695
  // components/DraggableComponent/index.tsx
@@ -3774,6 +3795,21 @@ var DropZoneProvider = ({
3774
3795
  import { useShallow as useShallow2 } from "zustand/react/shallow";
3775
3796
  import { useSortable as useSortable2 } from "@dnd-kit/react/sortable";
3776
3797
 
3798
+ // lib/accumulate-transform.ts
3799
+ init_react_import();
3800
+ function accumulateTransform(el) {
3801
+ let matrix = new DOMMatrixReadOnly();
3802
+ let n = el.parentElement;
3803
+ while (n && n !== document.documentElement) {
3804
+ const t = getComputedStyle(n).transform;
3805
+ if (t && t !== "none") {
3806
+ matrix = new DOMMatrixReadOnly(t).multiply(matrix);
3807
+ }
3808
+ n = n.parentElement;
3809
+ }
3810
+ return { scaleX: matrix.a, scaleY: matrix.d };
3811
+ }
3812
+
3777
3813
  // lib/use-context-store.ts
3778
3814
  init_react_import();
3779
3815
  import { useContext as useContext4 } from "react";
@@ -3799,7 +3835,9 @@ var useOnDragFinished = (cb, deps = []) => {
3799
3835
  if (isDragging2) {
3800
3836
  cb(false);
3801
3837
  } else {
3802
- cb(true);
3838
+ setTimeout(() => {
3839
+ cb(true);
3840
+ }, 0);
3803
3841
  if (dispose) dispose();
3804
3842
  }
3805
3843
  };
@@ -3975,11 +4013,16 @@ var DraggableComponent = ({
3975
4013
  x: deepScrollPosition.x - portalScroll.x - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _b : 0),
3976
4014
  y: deepScrollPosition.y - portalScroll.y - ((_c = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _c : 0)
3977
4015
  };
4016
+ const untransformed = {
4017
+ height: ref.current.offsetHeight,
4018
+ width: ref.current.offsetWidth
4019
+ };
4020
+ const transform = accumulateTransform(ref.current);
3978
4021
  const style2 = {
3979
- left: `${rect.left + scroll.x}px`,
3980
- top: `${rect.top + scroll.y}px`,
3981
- height: `${rect.height}px`,
3982
- width: `${rect.width}px`
4022
+ left: `${(rect.left + scroll.x) / transform.scaleX}px`,
4023
+ top: `${(rect.top + scroll.y) / transform.scaleY}px`,
4024
+ height: `${untransformed.height}px`,
4025
+ width: `${untransformed.width}px`
3983
4026
  };
3984
4027
  return style2;
3985
4028
  }, [ref.current]);
@@ -3988,8 +4031,7 @@ var DraggableComponent = ({
3988
4031
  setStyle(getStyle());
3989
4032
  }, [ref.current, iframe]);
3990
4033
  useEffect12(() => {
3991
- const userIsDragging = !!zoneStore.getState().draggedItem;
3992
- if (ref.current && !userIsDragging) {
4034
+ if (ref.current) {
3993
4035
  const observer = new ResizeObserver(sync);
3994
4036
  observer.observe(ref.current);
3995
4037
  return () => {
@@ -3998,11 +4040,27 @@ var DraggableComponent = ({
3998
4040
  }
3999
4041
  }, [ref.current]);
4000
4042
  const registerNode = useAppStore((s) => s.nodes.registerNode);
4043
+ const hideOverlay = useCallback7(() => {
4044
+ setIsVisible(false);
4045
+ }, []);
4046
+ const showOverlay = useCallback7(() => {
4047
+ setIsVisible(true);
4048
+ }, []);
4001
4049
  useEffect12(() => {
4002
4050
  var _a;
4003
- registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
4051
+ registerNode(id, {
4052
+ methods: { sync, showOverlay, hideOverlay },
4053
+ element: (_a = ref.current) != null ? _a : null
4054
+ });
4004
4055
  return () => {
4005
- registerNode(id, { methods: { sync: () => null }, element: null });
4056
+ registerNode(id, {
4057
+ methods: {
4058
+ sync: () => null,
4059
+ hideOverlay: () => null,
4060
+ showOverlay: () => null
4061
+ },
4062
+ element: null
4063
+ });
4006
4064
  };
4007
4065
  }, [id, zoneCompound, index, componentType, sync]);
4008
4066
  const CustomActionBar = useMemo7(
@@ -4269,7 +4327,8 @@ import { useDroppable } from "@dnd-kit/react";
4269
4327
 
4270
4328
  // components/DropZone/lib/use-min-empty-height.ts
4271
4329
  init_react_import();
4272
- import { useEffect as useEffect13, useState as useState11 } from "react";
4330
+ import { useEffect as useEffect13, useRef as useRef3, useState as useState11 } from "react";
4331
+ var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
4273
4332
  var useMinEmptyHeight = ({
4274
4333
  zoneCompound,
4275
4334
  userMinEmptyHeight,
@@ -4285,35 +4344,52 @@ var useMinEmptyHeight = ({
4285
4344
  isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
4286
4345
  };
4287
4346
  });
4347
+ const numItems = useRef3(0);
4348
+ const onDragFinished = useOnDragFinished(
4349
+ (finished) => {
4350
+ var _a;
4351
+ if (finished) {
4352
+ const newNumItems = getNumItems(appStore, zoneCompound);
4353
+ setPrevHeight(0);
4354
+ if (newNumItems || numItems.current === 0) {
4355
+ setIsAnimating(false);
4356
+ return;
4357
+ }
4358
+ const selectedItem = appStore.getState().selectedItem;
4359
+ const zones = appStore.getState().state.indexes.zones;
4360
+ const nodes = appStore.getState().nodes;
4361
+ (_a = nodes.nodes[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.methods.hideOverlay();
4362
+ setTimeout(() => {
4363
+ var _a2;
4364
+ const contentIds = ((_a2 = zones[zoneCompound]) == null ? void 0 : _a2.contentIds) || [];
4365
+ contentIds.forEach((contentId) => {
4366
+ const node = nodes.nodes[contentId];
4367
+ node == null ? void 0 : node.methods.sync();
4368
+ });
4369
+ if (selectedItem) {
4370
+ setTimeout(() => {
4371
+ var _a3, _b;
4372
+ (_a3 = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _a3.methods.sync();
4373
+ (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.showOverlay();
4374
+ }, 200);
4375
+ }
4376
+ setIsAnimating(false);
4377
+ }, 100);
4378
+ }
4379
+ },
4380
+ [appStore, prevHeight, zoneCompound]
4381
+ );
4288
4382
  useEffect13(() => {
4289
4383
  if (draggedItem && ref.current) {
4290
4384
  if (isZone) {
4291
4385
  const rect = ref.current.getBoundingClientRect();
4386
+ numItems.current = getNumItems(appStore, zoneCompound);
4292
4387
  setPrevHeight(rect.height);
4293
4388
  setIsAnimating(true);
4294
- return;
4389
+ return onDragFinished();
4295
4390
  }
4296
4391
  }
4297
- const _prevHeight = prevHeight;
4298
- setPrevHeight(0);
4299
- setTimeout(() => {
4300
- var _a, _b, _c;
4301
- const newHeight = (_a = ref.current) == null ? void 0 : _a.getBoundingClientRect().height;
4302
- if (newHeight === _prevHeight) return;
4303
- const zones = appStore.getState().state.indexes.zones;
4304
- const nodes = appStore.getState().nodes;
4305
- const selectedItem = appStore.getState().selectedItem;
4306
- const contentIds = ((_b = zones[zoneCompound]) == null ? void 0 : _b.contentIds) || [];
4307
- contentIds.forEach((contentId) => {
4308
- const node = nodes.nodes[contentId];
4309
- node == null ? void 0 : node.methods.sync();
4310
- });
4311
- if (selectedItem) {
4312
- (_c = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _c.methods.sync();
4313
- }
4314
- setIsAnimating(false);
4315
- }, 400);
4316
- }, [ref.current, draggedItem, zoneCompound]);
4392
+ }, [ref.current, draggedItem, onDragFinished]);
4317
4393
  return [prevHeight || userMinEmptyHeight, isAnimating];
4318
4394
  };
4319
4395
 
@@ -4438,7 +4514,7 @@ var useDragAxis = (ref, collisionAxis) => {
4438
4514
  };
4439
4515
 
4440
4516
  // components/DropZone/index.tsx
4441
- import { useShallow as useShallow3 } from "zustand/react/shallow";
4517
+ import { useShallow as useShallow4 } from "zustand/react/shallow";
4442
4518
 
4443
4519
  // components/Render/index.tsx
4444
4520
  init_react_import();
@@ -4446,6 +4522,7 @@ import React3, { useMemo as useMemo8 } from "react";
4446
4522
 
4447
4523
  // components/SlotRender/index.tsx
4448
4524
  init_react_import();
4525
+ import { useShallow as useShallow3 } from "zustand/react/shallow";
4449
4526
  import { jsx as jsx21 } from "react/jsx-runtime";
4450
4527
  var ContextSlotRender = ({
4451
4528
  componentId,
@@ -4454,10 +4531,12 @@ var ContextSlotRender = ({
4454
4531
  const config = useAppStore((s) => s.config);
4455
4532
  const metadata = useAppStore((s) => s.metadata);
4456
4533
  const slotContent = useAppStore(
4457
- (s) => {
4534
+ useShallow3((s) => {
4458
4535
  var _a, _b;
4459
- return (_b = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.props[zone]) != null ? _b : null;
4460
- }
4536
+ const indexes = s.state.indexes;
4537
+ const contentIds = (_b = (_a = indexes.zones[`${componentId}:${zone}`]) == null ? void 0 : _a.contentIds) != null ? _b : [];
4538
+ return contentIds.map((contentId) => indexes.nodes[contentId].flatData);
4539
+ })
4461
4540
  );
4462
4541
  return /* @__PURE__ */ jsx21(
4463
4542
  SlotRenderPure,
@@ -4487,7 +4566,7 @@ function Render({
4487
4566
  root: data.root || {},
4488
4567
  content: data.content || []
4489
4568
  });
4490
- const rootProps = defaultedData.root.props || defaultedData.root;
4569
+ const rootProps = "props" in defaultedData.root ? defaultedData.root.props : defaultedData.root;
4491
4570
  const title = (rootProps == null ? void 0 : rootProps.title) || "";
4492
4571
  const pageProps = __spreadProps(__spreadValues({}, rootProps), {
4493
4572
  puck: {
@@ -4500,7 +4579,11 @@ function Render({
4500
4579
  editMode: false,
4501
4580
  id: "puck-root"
4502
4581
  });
4503
- const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ jsx22(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
4582
+ const propsWithSlots = useSlots(
4583
+ config,
4584
+ { type: "root", props: pageProps },
4585
+ (props) => /* @__PURE__ */ jsx22(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
4586
+ );
4504
4587
  const nextContextValue = useMemo8(
4505
4588
  () => ({
4506
4589
  mode: "render",
@@ -4534,7 +4617,7 @@ var DropZoneChild = ({
4534
4617
  const { depth = 1 } = ctx != null ? ctx : {};
4535
4618
  const zoneStore = useContext7(ZoneStoreContext);
4536
4619
  const nodeProps = useAppStore(
4537
- useShallow3((s) => {
4620
+ useShallow4((s) => {
4538
4621
  var _a2;
4539
4622
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
4540
4623
  })
@@ -4546,14 +4629,19 @@ var DropZoneChild = ({
4546
4629
  }
4547
4630
  );
4548
4631
  const nodeReadOnly = useAppStore(
4549
- useShallow3((s) => {
4632
+ useShallow4((s) => {
4550
4633
  var _a2;
4551
4634
  return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
4552
4635
  })
4553
4636
  );
4637
+ const appStore = useAppStoreApi();
4554
4638
  const item = useMemo9(() => {
4555
4639
  if (nodeProps) {
4556
- return { type: nodeType, props: nodeProps };
4640
+ const expanded = expandNode({
4641
+ type: nodeType,
4642
+ props: nodeProps
4643
+ });
4644
+ return expanded;
4557
4645
  }
4558
4646
  const preview = zoneStore.getState().previewIndex[zoneCompound];
4559
4647
  if (componentId === (preview == null ? void 0 : preview.props.id)) {
@@ -4564,7 +4652,7 @@ var DropZoneChild = ({
4564
4652
  };
4565
4653
  }
4566
4654
  return null;
4567
- }, [componentId, zoneCompound, nodeType, nodeProps]);
4655
+ }, [appStore, componentId, zoneCompound, nodeType, nodeProps]);
4568
4656
  const componentConfig = useAppStore(
4569
4657
  (s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
4570
4658
  );
@@ -4605,9 +4693,17 @@ var DropZoneChild = ({
4605
4693
  }),
4606
4694
  [componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
4607
4695
  );
4696
+ const defaultedNode = useMemo9(
4697
+ () => {
4698
+ var _a2;
4699
+ return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
4700
+ },
4701
+ [item == null ? void 0 : item.type, nodeType, defaultsProps]
4702
+ );
4703
+ const config = useAppStore((s) => s.config);
4608
4704
  const defaultedPropsWithSlots = useSlots(
4609
- componentConfig,
4610
- defaultsProps,
4705
+ config,
4706
+ defaultedNode,
4611
4707
  DropZoneEditPure,
4612
4708
  (slotProps) => /* @__PURE__ */ jsx23(ContextSlotRender, { componentId, zone: slotProps.zone }),
4613
4709
  nodeReadOnly,
@@ -4619,7 +4715,7 @@ var DropZoneChild = ({
4619
4715
  item.type
4620
4716
  ] });
4621
4717
  let componentType = item.type;
4622
- const isInserting = item.previewType === "insert";
4718
+ const isInserting = "previewType" in item ? item.previewType === "insert" : false;
4623
4719
  if (isInserting) {
4624
4720
  Render2 = renderPreview;
4625
4721
  }
@@ -4668,7 +4764,7 @@ var DropZoneEdit = forwardRef3(
4668
4764
  unregisterLocalZone
4669
4765
  } = ctx != null ? ctx : {};
4670
4766
  const path = useAppStore(
4671
- useShallow3((s) => {
4767
+ useShallow4((s) => {
4672
4768
  var _a;
4673
4769
  return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
4674
4770
  })
@@ -4685,13 +4781,13 @@ var DropZoneEdit = forwardRef3(
4685
4781
  (s) => s.nextAreaDepthIndex[areaId || ""]
4686
4782
  );
4687
4783
  const zoneContentIds = useAppStore(
4688
- useShallow3((s) => {
4784
+ useShallow4((s) => {
4689
4785
  var _a;
4690
4786
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
4691
4787
  })
4692
4788
  );
4693
4789
  const zoneType = useAppStore(
4694
- useShallow3((s) => {
4790
+ useShallow4((s) => {
4695
4791
  var _a;
4696
4792
  return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
4697
4793
  })
@@ -4720,7 +4816,7 @@ var DropZoneEdit = forwardRef3(
4720
4816
  const contentIds = useMemo9(() => {
4721
4817
  return zoneContentIds || [];
4722
4818
  }, [zoneContentIds]);
4723
- const ref = useRef3(null);
4819
+ const ref = useRef4(null);
4724
4820
  const acceptsTarget = useCallback10(
4725
4821
  (componentType) => {
4726
4822
  if (!componentType) {
@@ -4848,7 +4944,7 @@ var DropZoneRenderItem = ({
4848
4944
  metadata
4849
4945
  }) => {
4850
4946
  const Component = config.components[item.type];
4851
- const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ jsx23(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
4947
+ const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ jsx23(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
4852
4948
  const nextContextValue = useMemo9(
4853
4949
  () => ({
4854
4950
  areaId: props.id,
@@ -5266,7 +5362,7 @@ function useDragListener(type, fn, deps = []) {
5266
5362
  }
5267
5363
  var AREA_CHANGE_DEBOUNCE_MS = 100;
5268
5364
  var useTempDisableFallback = (timeout3) => {
5269
- const lastFallbackDisable = useRef4(null);
5365
+ const lastFallbackDisable = useRef5(null);
5270
5366
  return useCallback11((manager) => {
5271
5367
  collisionStore.setState({ fallbackEnabled: false });
5272
5368
  const fallbackId = generateId();
@@ -5286,7 +5382,7 @@ var DragDropContextClient = ({
5286
5382
  const dispatch = useAppStore((s) => s.dispatch);
5287
5383
  const appStore = useAppStoreApi();
5288
5384
  const id = useSafeId();
5289
- const debouncedParamsRef = useRef4(null);
5385
+ const debouncedParamsRef = useRef5(null);
5290
5386
  const tempDisableFallback = useTempDisableFallback(100);
5291
5387
  const [zoneStore] = useState14(
5292
5388
  () => createStore3(() => ({
@@ -5408,8 +5504,8 @@ var DragDropContextClient = ({
5408
5504
  ]);
5409
5505
  const sensors = useSensors();
5410
5506
  const [dragListeners, setDragListeners] = useState14({});
5411
- const dragMode = useRef4(null);
5412
- const initialSelector = useRef4(void 0);
5507
+ const dragMode = useRef5(null);
5508
+ const initialSelector = useRef5(void 0);
5413
5509
  const nextContextValue = useMemo10(
5414
5510
  () => ({
5415
5511
  mode: "edit",
@@ -5786,12 +5882,12 @@ Drawer.Item = DrawerItem;
5786
5882
  init_react_import();
5787
5883
  import {
5788
5884
  createContext as createContext7,
5789
- useCallback as useCallback17,
5885
+ useCallback as useCallback18,
5790
5886
  useContext as useContext12,
5791
5887
  useEffect as useEffect25,
5792
- useMemo as useMemo20,
5793
- useRef as useRef7,
5794
- useState as useState22
5888
+ useMemo as useMemo21,
5889
+ useRef as useRef8,
5890
+ useState as useState23
5795
5891
  } from "react";
5796
5892
 
5797
5893
  // components/SidebarSection/index.tsx
@@ -5887,70 +5983,26 @@ var SidebarSection = ({
5887
5983
  );
5888
5984
  };
5889
5985
 
5890
- // components/MenuBar/index.tsx
5891
- init_react_import();
5892
-
5893
- // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
5894
- init_react_import();
5895
- var styles_module_default14 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
5896
-
5897
- // components/MenuBar/index.tsx
5898
- import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
5899
- var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
5900
- function MenuBar({
5901
- menuOpen = false,
5902
- renderHeaderActions,
5903
- setMenuOpen
5904
- }) {
5905
- const back = useAppStore((s) => s.history.back);
5906
- const forward = useAppStore((s) => s.history.forward);
5907
- const hasFuture = useAppStore((s) => s.history.hasFuture());
5908
- const hasPast = useAppStore((s) => s.history.hasPast());
5909
- return /* @__PURE__ */ jsx27(
5910
- "div",
5911
- {
5912
- className: getClassName20({ menuOpen }),
5913
- onClick: (event) => {
5914
- var _a;
5915
- const element = event.target;
5916
- if (window.matchMedia("(min-width: 638px)").matches) {
5917
- return;
5918
- }
5919
- if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
5920
- setMenuOpen(false);
5921
- }
5922
- },
5923
- children: /* @__PURE__ */ jsxs13("div", { className: getClassName20("inner"), children: [
5924
- /* @__PURE__ */ jsxs13("div", { className: getClassName20("history"), children: [
5925
- /* @__PURE__ */ jsx27(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx27(Undo2, { size: 21 }) }),
5926
- /* @__PURE__ */ jsx27(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx27(Redo2, { size: 21 }) })
5927
- ] }),
5928
- /* @__PURE__ */ jsx27(Fragment7, { children: renderHeaderActions && renderHeaderActions() })
5929
- ] })
5930
- }
5931
- );
5932
- }
5933
-
5934
5986
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
5935
5987
  init_react_import();
5936
- var styles_module_default15 = { "Puck": "_Puck_11o75_19", "Puck-portal": "_Puck-portal_11o75_24", "PuckLayout-inner": "_PuckLayout-inner_11o75_31", "PuckLayout--mounted": "_PuckLayout--mounted_11o75_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_11o75_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_11o75_53", "PuckLayout-mounted": "_PuckLayout-mounted_11o75_67", "PuckLayout": "_PuckLayout_11o75_31", "PuckLayout-header": "_PuckLayout-header_11o75_108", "PuckLayout-headerInner": "_PuckLayout-headerInner_11o75_117", "PuckLayout-headerToggle": "_PuckLayout-headerToggle_11o75_127", "PuckLayout-rightSideBarToggle": "_PuckLayout-rightSideBarToggle_11o75_134", "PuckLayout-leftSideBarToggle": "_PuckLayout-leftSideBarToggle_11o75_135", "PuckLayout-headerTitle": "_PuckLayout-headerTitle_11o75_139", "PuckLayout-headerPath": "_PuckLayout-headerPath_11o75_143", "PuckLayout-headerTools": "_PuckLayout-headerTools_11o75_150", "PuckLayout-menuButton": "_PuckLayout-menuButton_11o75_156", "PuckLayout--menuOpen": "_PuckLayout--menuOpen_11o75_161", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_11o75_135", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_11o75_134" };
5988
+ var styles_module_default14 = { "Puck": "_Puck_mc1k2_19", "Puck-portal": "_Puck-portal_mc1k2_24", "PuckLayout-inner": "_PuckLayout-inner_mc1k2_31", "PuckLayout--mounted": "_PuckLayout--mounted_mc1k2_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_mc1k2_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_mc1k2_53", "PuckLayout-mounted": "_PuckLayout-mounted_mc1k2_67", "PuckLayout": "_PuckLayout_mc1k2_31", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_mc1k2_108", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_mc1k2_117" };
5937
5989
 
5938
5990
  // components/Puck/components/Fields/index.tsx
5939
5991
  init_react_import();
5940
5992
 
5941
5993
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
5942
5994
  init_react_import();
5943
- 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" };
5995
+ var styles_module_default15 = { "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" };
5944
5996
 
5945
5997
  // components/Puck/components/Fields/index.tsx
5946
- import { useCallback as useCallback12, useMemo as useMemo13 } from "react";
5947
- import { useShallow as useShallow4 } from "zustand/react/shallow";
5948
- import { Fragment as Fragment8, jsx as jsx28, jsxs as jsxs14 } from "react/jsx-runtime";
5949
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5998
+ import { memo as memo2, useCallback as useCallback12, useMemo as useMemo13 } from "react";
5999
+ import { useShallow as useShallow5 } from "zustand/react/shallow";
6000
+ import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
6001
+ var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
5950
6002
  var DefaultFields = ({
5951
6003
  children
5952
6004
  }) => {
5953
- return /* @__PURE__ */ jsx28(Fragment8, { children });
6005
+ return /* @__PURE__ */ jsx27(Fragment7, { children });
5954
6006
  };
5955
6007
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
5956
6008
  let currentProps;
@@ -6010,7 +6062,7 @@ var FieldsChild = ({ fieldName }) => {
6010
6062
  return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
6011
6063
  });
6012
6064
  const permissions = useAppStore(
6013
- useShallow4((s) => {
6065
+ useShallow5((s) => {
6014
6066
  const { selectedItem, permissions: permissions2 } = s;
6015
6067
  return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
6016
6068
  })
@@ -6019,9 +6071,10 @@ var FieldsChild = ({ fieldName }) => {
6019
6071
  const onChange = useCallback12(createOnChange(fieldName, appStore), [
6020
6072
  fieldName
6021
6073
  ]);
6022
- if (!field || !id) return null;
6074
+ const { visible = true } = field != null ? field : {};
6075
+ if (!field || !id || !visible) return null;
6023
6076
  if (field.type === "slot") return null;
6024
- return /* @__PURE__ */ jsx28("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx28(
6077
+ return /* @__PURE__ */ jsx27("div", { className: getClassName20("field"), children: /* @__PURE__ */ jsx27(
6025
6078
  AutoFieldPrivate,
6026
6079
  {
6027
6080
  field,
@@ -6033,14 +6086,15 @@ var FieldsChild = ({ fieldName }) => {
6033
6086
  }
6034
6087
  ) }, id);
6035
6088
  };
6036
- var Fields = ({ wrapFields = true }) => {
6089
+ var FieldsChildMemo = memo2(FieldsChild);
6090
+ var FieldsInternal = ({ wrapFields = true }) => {
6037
6091
  const overrides = useAppStore((s) => s.overrides);
6038
6092
  const componentResolving = useAppStore((s) => {
6039
6093
  var _a, _b;
6040
6094
  const loadingCount = s.selectedItem ? (_a = s.componentState[s.selectedItem.props.id]) == null ? void 0 : _a.loadingCount : (_b = s.componentState["root"]) == null ? void 0 : _b.loadingCount;
6041
6095
  return (loadingCount != null ? loadingCount : 0) > 0;
6042
6096
  });
6043
- const itemSelector = useAppStore(useShallow4((s) => s.state.ui.itemSelector));
6097
+ const itemSelector = useAppStore(useShallow5((s) => s.state.ui.itemSelector));
6044
6098
  const id = useAppStore((s) => {
6045
6099
  var _a;
6046
6100
  return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
@@ -6049,7 +6103,7 @@ var Fields = ({ wrapFields = true }) => {
6049
6103
  useRegisterFieldsSlice(appStore, id);
6050
6104
  const fieldsLoading = useAppStore((s) => s.fields.loading);
6051
6105
  const fieldNames = useAppStore(
6052
- useShallow4((s) => {
6106
+ useShallow5((s) => {
6053
6107
  if (s.fields.id === id) {
6054
6108
  return Object.keys(s.fields.fields);
6055
6109
  }
@@ -6058,20 +6112,21 @@ var Fields = ({ wrapFields = true }) => {
6058
6112
  );
6059
6113
  const isLoading = fieldsLoading || componentResolving;
6060
6114
  const Wrapper = useMemo13(() => overrides.fields || DefaultFields, [overrides]);
6061
- return /* @__PURE__ */ jsxs14(
6115
+ return /* @__PURE__ */ jsxs13(
6062
6116
  "form",
6063
6117
  {
6064
- className: getClassName21({ wrapFields }),
6118
+ className: getClassName20({ wrapFields }),
6065
6119
  onSubmit: (e) => {
6066
6120
  e.preventDefault();
6067
6121
  },
6068
6122
  children: [
6069
- /* @__PURE__ */ jsx28(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx28(FieldsChild, { fieldName }, fieldName)) }),
6070
- isLoading && /* @__PURE__ */ jsx28("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx28("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx28(Loader, { size: 16 }) }) })
6123
+ /* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx27(FieldsChildMemo, { fieldName }, fieldName)) }),
6124
+ isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName20("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
6071
6125
  ]
6072
6126
  }
6073
6127
  );
6074
6128
  };
6129
+ var Fields = memo2(FieldsInternal);
6075
6130
 
6076
6131
  // components/Puck/components/Components/index.tsx
6077
6132
  init_react_import();
@@ -6085,11 +6140,11 @@ init_react_import();
6085
6140
 
6086
6141
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
6087
6142
  init_react_import();
6088
- var styles_module_default17 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
6143
+ var styles_module_default16 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
6089
6144
 
6090
6145
  // components/ComponentList/index.tsx
6091
- import { jsx as jsx29, jsxs as jsxs15 } from "react/jsx-runtime";
6092
- var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
6146
+ import { jsx as jsx28, jsxs as jsxs14 } from "react/jsx-runtime";
6147
+ var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default16);
6093
6148
  var ComponentListItem = ({
6094
6149
  name,
6095
6150
  label
@@ -6100,7 +6155,7 @@ var ComponentListItem = ({
6100
6155
  type: name
6101
6156
  }).insert
6102
6157
  );
6103
- return /* @__PURE__ */ jsx29(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6158
+ return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6104
6159
  };
6105
6160
  var ComponentList = ({
6106
6161
  children,
@@ -6111,12 +6166,12 @@ var ComponentList = ({
6111
6166
  const setUi = useAppStore((s) => s.setUi);
6112
6167
  const componentList = useAppStore((s) => s.state.ui.componentList);
6113
6168
  const { expanded = true } = componentList[id] || {};
6114
- return /* @__PURE__ */ jsxs15("div", { className: getClassName22({ isExpanded: expanded }), children: [
6115
- title && /* @__PURE__ */ jsxs15(
6169
+ return /* @__PURE__ */ jsxs14("div", { className: getClassName21({ isExpanded: expanded }), children: [
6170
+ title && /* @__PURE__ */ jsxs14(
6116
6171
  "button",
6117
6172
  {
6118
6173
  type: "button",
6119
- className: getClassName22("title"),
6174
+ className: getClassName21("title"),
6120
6175
  onClick: () => setUi({
6121
6176
  componentList: __spreadProps(__spreadValues({}, componentList), {
6122
6177
  [id]: __spreadProps(__spreadValues({}, componentList[id]), {
@@ -6126,14 +6181,14 @@ var ComponentList = ({
6126
6181
  }),
6127
6182
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
6128
6183
  children: [
6129
- /* @__PURE__ */ jsx29("div", { children: title }),
6130
- /* @__PURE__ */ jsx29("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx29(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx29(ChevronDown, { size: 12 }) })
6184
+ /* @__PURE__ */ jsx28("div", { children: title }),
6185
+ /* @__PURE__ */ jsx28("div", { className: getClassName21("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
6131
6186
  ]
6132
6187
  }
6133
6188
  ),
6134
- /* @__PURE__ */ jsx29("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx29(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6189
+ /* @__PURE__ */ jsx28("div", { className: getClassName21("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6135
6190
  var _a;
6136
- return /* @__PURE__ */ jsx29(
6191
+ return /* @__PURE__ */ jsx28(
6137
6192
  ComponentListItem,
6138
6193
  {
6139
6194
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -6147,7 +6202,7 @@ var ComponentList = ({
6147
6202
  ComponentList.Item = ComponentListItem;
6148
6203
 
6149
6204
  // lib/use-component-list.tsx
6150
- import { jsx as jsx30 } from "react/jsx-runtime";
6205
+ import { jsx as jsx29 } from "react/jsx-runtime";
6151
6206
  var useComponentList = () => {
6152
6207
  const [componentList, setComponentList] = useState16();
6153
6208
  const config = useAppStore((s) => s.config);
@@ -6162,7 +6217,7 @@ var useComponentList = () => {
6162
6217
  if (category.visible === false || !category.components) {
6163
6218
  return null;
6164
6219
  }
6165
- return /* @__PURE__ */ jsx30(
6220
+ return /* @__PURE__ */ jsx29(
6166
6221
  ComponentList,
6167
6222
  {
6168
6223
  id: categoryKey,
@@ -6171,7 +6226,7 @@ var useComponentList = () => {
6171
6226
  var _a2;
6172
6227
  matchedComponents.push(componentName);
6173
6228
  const componentConf = config.components[componentName] || {};
6174
- return /* @__PURE__ */ jsx30(
6229
+ return /* @__PURE__ */ jsx29(
6175
6230
  ComponentList.Item,
6176
6231
  {
6177
6232
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -6191,7 +6246,7 @@ var useComponentList = () => {
6191
6246
  );
6192
6247
  if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
6193
6248
  _componentList.push(
6194
- /* @__PURE__ */ jsx30(
6249
+ /* @__PURE__ */ jsx29(
6195
6250
  ComponentList,
6196
6251
  {
6197
6252
  id: "other",
@@ -6199,7 +6254,7 @@ var useComponentList = () => {
6199
6254
  children: remainingComponents.map((componentName, i) => {
6200
6255
  var _a2;
6201
6256
  const componentConf = config.components[componentName] || {};
6202
- return /* @__PURE__ */ jsx30(
6257
+ return /* @__PURE__ */ jsx29(
6203
6258
  ComponentList.Item,
6204
6259
  {
6205
6260
  name: componentName,
@@ -6222,17 +6277,17 @@ var useComponentList = () => {
6222
6277
 
6223
6278
  // components/Puck/components/Components/index.tsx
6224
6279
  import { useMemo as useMemo14 } from "react";
6225
- import { jsx as jsx31 } from "react/jsx-runtime";
6280
+ import { jsx as jsx30 } from "react/jsx-runtime";
6226
6281
  var Components = () => {
6227
6282
  const overrides = useAppStore((s) => s.overrides);
6228
6283
  const componentList = useComponentList();
6229
6284
  const Wrapper = useMemo14(() => overrides.components || "div", [overrides]);
6230
- return /* @__PURE__ */ jsx31(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx31(ComponentList, { id: "all" }) });
6285
+ return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
6231
6286
  };
6232
6287
 
6233
6288
  // components/Puck/components/Preview/index.tsx
6234
6289
  init_react_import();
6235
- import { useCallback as useCallback13, useEffect as useEffect20, useRef as useRef5, useMemo as useMemo15 } from "react";
6290
+ import { useCallback as useCallback13, useEffect as useEffect20, useRef as useRef6, useMemo as useMemo15 } from "react";
6236
6291
 
6237
6292
  // components/AutoFrame/index.tsx
6238
6293
  init_react_import();
@@ -6244,7 +6299,7 @@ import {
6244
6299
  } from "react";
6245
6300
  import hash from "object-hash";
6246
6301
  import { createPortal as createPortal3 } from "react-dom";
6247
- import { Fragment as Fragment9, jsx as jsx32 } from "react/jsx-runtime";
6302
+ import { Fragment as Fragment8, jsx as jsx31 } from "react/jsx-runtime";
6248
6303
  var styleSelector = 'style, link[rel="stylesheet"]';
6249
6304
  var collectStyles = (doc) => {
6250
6305
  const collected = [];
@@ -6444,7 +6499,7 @@ var CopyHostStyles = ({
6444
6499
  observer.disconnect();
6445
6500
  };
6446
6501
  }, []);
6447
- return /* @__PURE__ */ jsx32(Fragment9, { children });
6502
+ return /* @__PURE__ */ jsx31(Fragment8, { children });
6448
6503
  };
6449
6504
  var autoFrameContext = createContext5({});
6450
6505
  var useFrame = () => useContext9(autoFrameContext);
@@ -6491,7 +6546,7 @@ function AutoFrame(_a) {
6491
6546
  }
6492
6547
  }
6493
6548
  }, [frameRef, loaded, stylesLoaded]);
6494
- return /* @__PURE__ */ jsx32(
6549
+ return /* @__PURE__ */ jsx31(
6495
6550
  "iframe",
6496
6551
  __spreadProps(__spreadValues({}, props), {
6497
6552
  className,
@@ -6501,7 +6556,7 @@ function AutoFrame(_a) {
6501
6556
  onLoad: () => {
6502
6557
  setLoaded(true);
6503
6558
  },
6504
- children: /* @__PURE__ */ jsx32(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx32(
6559
+ children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(
6505
6560
  CopyHostStyles,
6506
6561
  {
6507
6562
  debug,
@@ -6517,11 +6572,11 @@ var AutoFrame_default = AutoFrame;
6517
6572
 
6518
6573
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
6519
6574
  init_react_import();
6520
- var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
6575
+ var styles_module_default17 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
6521
6576
 
6522
6577
  // components/Puck/components/Preview/index.tsx
6523
- import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
6524
- var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
6578
+ import { Fragment as Fragment9, jsx as jsx32 } from "react/jsx-runtime";
6579
+ var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
6525
6580
  var useBubbleIframeEvents = (ref) => {
6526
6581
  const status = useAppStore((s) => s.status);
6527
6582
  useEffect20(() => {
@@ -6576,19 +6631,22 @@ var Preview2 = ({ id = "puck-preview" }) => {
6576
6631
  const Page = useCallback13(
6577
6632
  (pageProps) => {
6578
6633
  var _a, _b;
6579
- const rootConfig = config.root;
6580
- const propsWithSlots = useSlots(rootConfig, pageProps, DropZoneEditPure);
6634
+ const propsWithSlots = useSlots(
6635
+ config,
6636
+ { type: "root", props: pageProps },
6637
+ DropZoneEditPure
6638
+ );
6581
6639
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
6582
6640
  id: "puck-root"
6583
- }, propsWithSlots)) : /* @__PURE__ */ jsx33(Fragment10, { children: propsWithSlots.children });
6641
+ }, propsWithSlots)) : /* @__PURE__ */ jsx32(Fragment9, { children: propsWithSlots.children });
6584
6642
  },
6585
- [config.root]
6643
+ [config]
6586
6644
  );
6587
6645
  const Frame = useMemo15(() => overrides.iframe, [overrides]);
6588
6646
  const rootProps = root.props || root;
6589
- const ref = useRef5(null);
6647
+ const ref = useRef6(null);
6590
6648
  useBubbleIframeEvents(ref);
6591
- const inner = !renderData ? /* @__PURE__ */ jsx33(
6649
+ const inner = !renderData ? /* @__PURE__ */ jsx32(
6592
6650
  Page,
6593
6651
  __spreadProps(__spreadValues({}, rootProps), {
6594
6652
  puck: {
@@ -6598,28 +6656,28 @@ var Preview2 = ({ id = "puck-preview" }) => {
6598
6656
  metadata
6599
6657
  },
6600
6658
  editMode: true,
6601
- children: /* @__PURE__ */ jsx33(DropZonePure, { zone: rootDroppableId })
6659
+ children: /* @__PURE__ */ jsx32(DropZonePure, { zone: rootDroppableId })
6602
6660
  })
6603
- ) : /* @__PURE__ */ jsx33(Render, { data: renderData, config });
6661
+ ) : /* @__PURE__ */ jsx32(Render, { data: renderData, config });
6604
6662
  useEffect20(() => {
6605
6663
  if (!iframe.enabled) {
6606
6664
  setStatus("READY");
6607
6665
  }
6608
6666
  }, [iframe.enabled]);
6609
- return /* @__PURE__ */ jsx33(
6667
+ return /* @__PURE__ */ jsx32(
6610
6668
  "div",
6611
6669
  {
6612
- className: getClassName23(),
6670
+ className: getClassName22(),
6613
6671
  id,
6614
6672
  "data-puck-preview": true,
6615
6673
  onClick: () => {
6616
6674
  dispatch({ type: "setUi", ui: { itemSelector: null } });
6617
6675
  },
6618
- children: iframe.enabled ? /* @__PURE__ */ jsx33(
6676
+ children: iframe.enabled ? /* @__PURE__ */ jsx32(
6619
6677
  AutoFrame_default,
6620
6678
  {
6621
6679
  id: "preview-frame",
6622
- className: getClassName23("frame"),
6680
+ className: getClassName22("frame"),
6623
6681
  "data-rfd-iframe": true,
6624
6682
  onReady: () => {
6625
6683
  setStatus("READY");
@@ -6628,18 +6686,18 @@ var Preview2 = ({ id = "puck-preview" }) => {
6628
6686
  setStatus("MOUNTED");
6629
6687
  },
6630
6688
  frameRef: ref,
6631
- children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6689
+ children: /* @__PURE__ */ jsx32(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6632
6690
  if (Frame) {
6633
- return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
6691
+ return /* @__PURE__ */ jsx32(Frame, { document: document2, children: inner });
6634
6692
  }
6635
6693
  return inner;
6636
6694
  } })
6637
6695
  }
6638
- ) : /* @__PURE__ */ jsx33(
6696
+ ) : /* @__PURE__ */ jsx32(
6639
6697
  "div",
6640
6698
  {
6641
6699
  id: "preview-frame",
6642
- className: getClassName23("frame"),
6700
+ className: getClassName22("frame"),
6643
6701
  ref,
6644
6702
  "data-puck-entry": true,
6645
6703
  children: inner
@@ -6657,7 +6715,7 @@ init_react_import();
6657
6715
 
6658
6716
  // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
6659
6717
  init_react_import();
6660
- var styles_module_default19 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
6718
+ var styles_module_default18 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
6661
6719
 
6662
6720
  // lib/scroll-into-view.ts
6663
6721
  init_react_import();
@@ -6693,10 +6751,10 @@ var onScrollEnd = (frame, cb) => {
6693
6751
  };
6694
6752
 
6695
6753
  // components/LayerTree/index.tsx
6696
- import { useShallow as useShallow5 } from "zustand/react/shallow";
6697
- import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
6698
- var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
6699
- var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
6754
+ import { useShallow as useShallow6 } from "zustand/react/shallow";
6755
+ import { Fragment as Fragment10, jsx as jsx33, jsxs as jsxs15 } from "react/jsx-runtime";
6756
+ var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
6757
+ var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
6700
6758
  var Layer = ({
6701
6759
  index,
6702
6760
  itemId,
@@ -6720,7 +6778,7 @@ var Layer = ({
6720
6778
  const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
6721
6779
  const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
6722
6780
  const zonesForItem = useAppStore(
6723
- useShallow5(
6781
+ useShallow6(
6724
6782
  (s) => Object.keys(s.state.indexes.zones).filter(
6725
6783
  (z) => z.split(":")[0] === itemId
6726
6784
  )
@@ -6742,7 +6800,7 @@ var Layer = ({
6742
6800
  });
6743
6801
  const componentConfig = config.components[nodeData.data.type];
6744
6802
  const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
6745
- return /* @__PURE__ */ jsxs16(
6803
+ return /* @__PURE__ */ jsxs15(
6746
6804
  "li",
6747
6805
  {
6748
6806
  className: getClassNameLayer({
@@ -6752,7 +6810,7 @@ var Layer = ({
6752
6810
  childIsSelected
6753
6811
  }),
6754
6812
  children: [
6755
- /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
6813
+ /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs15(
6756
6814
  "button",
6757
6815
  {
6758
6816
  type: "button",
@@ -6767,7 +6825,10 @@ var Layer = ({
6767
6825
  `[data-puck-component="${itemId}"]`
6768
6826
  );
6769
6827
  if (!el) {
6770
- console.error("Scroll failed. No element was found for", itemId);
6828
+ setItemSelector({
6829
+ index,
6830
+ zone: zoneCompound
6831
+ });
6771
6832
  return;
6772
6833
  }
6773
6834
  scrollIntoView(el);
@@ -6787,22 +6848,22 @@ var Layer = ({
6787
6848
  zoneStore.setState({ hoveringComponent: null });
6788
6849
  },
6789
6850
  children: [
6790
- containsZone && /* @__PURE__ */ jsx34(
6851
+ containsZone && /* @__PURE__ */ jsx33(
6791
6852
  "div",
6792
6853
  {
6793
6854
  className: getClassNameLayer("chevron"),
6794
6855
  title: isSelected ? "Collapse" : "Expand",
6795
- children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
6856
+ children: /* @__PURE__ */ jsx33(ChevronDown, { size: "12" })
6796
6857
  }
6797
6858
  ),
6798
- /* @__PURE__ */ jsxs16("div", { className: getClassNameLayer("title"), children: [
6799
- /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ jsx34(Type, { size: "16" }) : /* @__PURE__ */ jsx34(LayoutGrid, { size: "16" }) }),
6800
- /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("name"), children: label })
6859
+ /* @__PURE__ */ jsxs15("div", { className: getClassNameLayer("title"), children: [
6860
+ /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ jsx33(Type, { size: "16" }) : /* @__PURE__ */ jsx33(LayoutGrid, { size: "16" }) }),
6861
+ /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("name"), children: label })
6801
6862
  ] })
6802
6863
  ]
6803
6864
  }
6804
6865
  ) }),
6805
- containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx34(LayerTree, { zoneCompound: subzone }) }, subzone))
6866
+ containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx33(LayerTree, { zoneCompound: subzone }) }, subzone))
6806
6867
  ]
6807
6868
  }
6808
6869
  );
@@ -6813,22 +6874,22 @@ var LayerTree = ({
6813
6874
  }) => {
6814
6875
  const label = _label != null ? _label : zoneCompound.split(":")[1];
6815
6876
  const contentIds = useAppStore(
6816
- useShallow5(
6877
+ useShallow6(
6817
6878
  (s) => {
6818
6879
  var _a, _b;
6819
6880
  return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
6820
6881
  }
6821
6882
  )
6822
6883
  );
6823
- return /* @__PURE__ */ jsxs16(Fragment11, { children: [
6824
- label && /* @__PURE__ */ jsxs16("div", { className: getClassName24("zoneTitle"), children: [
6825
- /* @__PURE__ */ jsx34("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx34(Layers, { size: "16" }) }),
6884
+ return /* @__PURE__ */ jsxs15(Fragment10, { children: [
6885
+ label && /* @__PURE__ */ jsxs15("div", { className: getClassName23("zoneTitle"), children: [
6886
+ /* @__PURE__ */ jsx33("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ jsx33(Layers, { size: "16" }) }),
6826
6887
  label
6827
6888
  ] }),
6828
- /* @__PURE__ */ jsxs16("ul", { className: getClassName24(), children: [
6829
- contentIds.length === 0 && /* @__PURE__ */ jsx34("div", { className: getClassName24("helper"), children: "No items" }),
6889
+ /* @__PURE__ */ jsxs15("ul", { className: getClassName23(), children: [
6890
+ contentIds.length === 0 && /* @__PURE__ */ jsx33("div", { className: getClassName23("helper"), children: "No items" }),
6830
6891
  contentIds.map((itemId, i) => {
6831
- return /* @__PURE__ */ jsx34(
6892
+ return /* @__PURE__ */ jsx33(
6832
6893
  Layer,
6833
6894
  {
6834
6895
  index: i,
@@ -6854,15 +6915,15 @@ var findZonesForArea = (state, area) => {
6854
6915
  };
6855
6916
 
6856
6917
  // components/Puck/components/Outline/index.tsx
6857
- import { useShallow as useShallow6 } from "zustand/react/shallow";
6858
- import { jsx as jsx35 } from "react/jsx-runtime";
6918
+ import { useShallow as useShallow7 } from "zustand/react/shallow";
6919
+ import { jsx as jsx34 } from "react/jsx-runtime";
6859
6920
  var Outline = () => {
6860
6921
  const outlineOverride = useAppStore((s) => s.overrides.outline);
6861
6922
  const rootZones = useAppStore(
6862
- useShallow6((s) => findZonesForArea(s.state, "root"))
6923
+ useShallow7((s) => findZonesForArea(s.state, "root"))
6863
6924
  );
6864
6925
  const Wrapper = useMemo16(() => outlineOverride || "div", [outlineOverride]);
6865
- return /* @__PURE__ */ jsx35(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx35(
6926
+ return /* @__PURE__ */ jsx34(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx34(
6866
6927
  LayerTree,
6867
6928
  {
6868
6929
  label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
@@ -6999,7 +7060,7 @@ import {
6999
7060
  useCallback as useCallback15,
7000
7061
  useEffect as useEffect22,
7001
7062
  useMemo as useMemo18,
7002
- useRef as useRef6,
7063
+ useRef as useRef7,
7003
7064
  useState as useState19
7004
7065
  } from "react";
7005
7066
 
@@ -7009,17 +7070,17 @@ import { useEffect as useEffect21, useMemo as useMemo17, useState as useState18
7009
7070
 
7010
7071
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7011
7072
  init_react_import();
7012
- var styles_module_default20 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
7073
+ var styles_module_default19 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
7013
7074
 
7014
7075
  // components/ViewportControls/index.tsx
7015
- import { jsx as jsx36, jsxs as jsxs17 } from "react/jsx-runtime";
7076
+ import { jsx as jsx35, jsxs as jsxs16 } from "react/jsx-runtime";
7016
7077
  var icons = {
7017
- Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
7018
- Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
7019
- Monitor: /* @__PURE__ */ jsx36(Monitor, { size: 16 })
7078
+ Smartphone: /* @__PURE__ */ jsx35(Smartphone, { size: 16 }),
7079
+ Tablet: /* @__PURE__ */ jsx35(Tablet, { size: 16 }),
7080
+ Monitor: /* @__PURE__ */ jsx35(Monitor, { size: 16 })
7020
7081
  };
7021
- var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
7022
- var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
7082
+ var getClassName24 = get_class_name_factory_default("ViewportControls", styles_module_default19);
7083
+ var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default19);
7023
7084
  var ViewportButton = ({
7024
7085
  children,
7025
7086
  height = "auto",
@@ -7032,7 +7093,7 @@ var ViewportButton = ({
7032
7093
  useEffect21(() => {
7033
7094
  setIsActive(width === viewports.current.width);
7034
7095
  }, [width, viewports.current.width]);
7035
- return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
7096
+ return /* @__PURE__ */ jsx35("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx35(
7036
7097
  IconButton,
7037
7098
  {
7038
7099
  title,
@@ -7041,7 +7102,7 @@ var ViewportButton = ({
7041
7102
  e.stopPropagation();
7042
7103
  onClick({ width, height });
7043
7104
  },
7044
- children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
7105
+ children: /* @__PURE__ */ jsx35("span", { className: getClassNameButton("inner"), children })
7045
7106
  }
7046
7107
  ) });
7047
7108
  };
@@ -7077,8 +7138,8 @@ var ViewportControls = ({
7077
7138
  ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
7078
7139
  [autoZoom]
7079
7140
  );
7080
- return /* @__PURE__ */ jsxs17("div", { className: getClassName25(), children: [
7081
- viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
7141
+ return /* @__PURE__ */ jsxs16("div", { className: getClassName24(), children: [
7142
+ viewports.map((viewport, i) => /* @__PURE__ */ jsx35(
7082
7143
  ViewportButton,
7083
7144
  {
7084
7145
  height: viewport.height,
@@ -7089,8 +7150,8 @@ var ViewportControls = ({
7089
7150
  },
7090
7151
  i
7091
7152
  )),
7092
- /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
7093
- /* @__PURE__ */ jsx36(
7153
+ /* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
7154
+ /* @__PURE__ */ jsx35(
7094
7155
  IconButton,
7095
7156
  {
7096
7157
  title: "Zoom viewport out",
@@ -7104,10 +7165,10 @@ var ViewportControls = ({
7104
7165
  )].value
7105
7166
  );
7106
7167
  },
7107
- children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
7168
+ children: /* @__PURE__ */ jsx35(ZoomOut, { size: 16 })
7108
7169
  }
7109
7170
  ),
7110
- /* @__PURE__ */ jsx36(
7171
+ /* @__PURE__ */ jsx35(
7111
7172
  IconButton,
7112
7173
  {
7113
7174
  title: "Zoom viewport in",
@@ -7121,19 +7182,19 @@ var ViewportControls = ({
7121
7182
  )].value
7122
7183
  );
7123
7184
  },
7124
- children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
7185
+ children: /* @__PURE__ */ jsx35(ZoomIn, { size: 16 })
7125
7186
  }
7126
7187
  ),
7127
- /* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
7128
- /* @__PURE__ */ jsx36(
7188
+ /* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
7189
+ /* @__PURE__ */ jsx35(
7129
7190
  "select",
7130
7191
  {
7131
- className: getClassName25("zoomSelect"),
7192
+ className: getClassName24("zoomSelect"),
7132
7193
  value: zoom.toString(),
7133
7194
  onChange: (e) => {
7134
7195
  onZoom(parseFloat(e.currentTarget.value));
7135
7196
  },
7136
- children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
7197
+ children: zoomOptions.map((option) => /* @__PURE__ */ jsx35(
7137
7198
  "option",
7138
7199
  {
7139
7200
  value: option.value,
@@ -7148,7 +7209,7 @@ var ViewportControls = ({
7148
7209
 
7149
7210
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
7150
7211
  init_react_import();
7151
- var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
7212
+ var styles_module_default20 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
7152
7213
 
7153
7214
  // lib/get-zoom-config.ts
7154
7215
  init_react_import();
@@ -7181,9 +7242,9 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
7181
7242
  };
7182
7243
 
7183
7244
  // components/Puck/components/Canvas/index.tsx
7184
- import { useShallow as useShallow7 } from "zustand/react/shallow";
7185
- import { Fragment as Fragment12, jsx as jsx37, jsxs as jsxs18 } from "react/jsx-runtime";
7186
- var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
7245
+ import { useShallow as useShallow8 } from "zustand/react/shallow";
7246
+ import { Fragment as Fragment11, jsx as jsx36, jsxs as jsxs17 } from "react/jsx-runtime";
7247
+ var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
7187
7248
  var ZOOM_ON_CHANGE = true;
7188
7249
  var Canvas = () => {
7189
7250
  const {
@@ -7195,7 +7256,7 @@ var Canvas = () => {
7195
7256
  status,
7196
7257
  iframe
7197
7258
  } = useAppStore(
7198
- useShallow7((s) => ({
7259
+ useShallow8((s) => ({
7199
7260
  dispatch: s.dispatch,
7200
7261
  overrides: s.overrides,
7201
7262
  setUi: s.setUi,
@@ -7206,16 +7267,16 @@ var Canvas = () => {
7206
7267
  }))
7207
7268
  );
7208
7269
  const { leftSideBarVisible, rightSideBarVisible, viewports } = useAppStore(
7209
- useShallow7((s) => ({
7270
+ useShallow8((s) => ({
7210
7271
  leftSideBarVisible: s.state.ui.leftSideBarVisible,
7211
7272
  rightSideBarVisible: s.state.ui.rightSideBarVisible,
7212
7273
  viewports: s.state.ui.viewports
7213
7274
  }))
7214
7275
  );
7215
- const frameRef = useRef6(null);
7276
+ const frameRef = useRef7(null);
7216
7277
  const [showTransition, setShowTransition] = useState19(false);
7217
7278
  const defaultRender = useMemo18(() => {
7218
- const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment12, { children });
7279
+ const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment11, { children });
7219
7280
  return PuckDefault;
7220
7281
  }, []);
7221
7282
  const CustomPreview = useMemo18(
@@ -7278,10 +7339,10 @@ var Canvas = () => {
7278
7339
  setShowLoader(true);
7279
7340
  }, 500);
7280
7341
  }, []);
7281
- return /* @__PURE__ */ jsxs18(
7342
+ return /* @__PURE__ */ jsxs17(
7282
7343
  "div",
7283
7344
  {
7284
- className: getClassName26({
7345
+ className: getClassName25({
7285
7346
  ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
7286
7347
  showLoader
7287
7348
  }),
@@ -7291,7 +7352,7 @@ var Canvas = () => {
7291
7352
  recordHistory: true
7292
7353
  }),
7293
7354
  children: [
7294
- viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx37("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx37(
7355
+ viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx36("div", { className: getClassName25("controls"), children: /* @__PURE__ */ jsx36(
7295
7356
  ViewportControls,
7296
7357
  {
7297
7358
  autoZoom: zoomConfig.autoZoom,
@@ -7317,11 +7378,11 @@ var Canvas = () => {
7317
7378
  }
7318
7379
  }
7319
7380
  ) }),
7320
- /* @__PURE__ */ jsxs18("div", { className: getClassName26("inner"), ref: frameRef, children: [
7321
- /* @__PURE__ */ jsx37(
7381
+ /* @__PURE__ */ jsxs17("div", { className: getClassName25("inner"), ref: frameRef, children: [
7382
+ /* @__PURE__ */ jsx36(
7322
7383
  "div",
7323
7384
  {
7324
- className: getClassName26("root"),
7385
+ className: getClassName25("root"),
7325
7386
  style: {
7326
7387
  width: iframe.enabled ? viewports.current.width : "100%",
7327
7388
  height: zoomConfig.rootHeight,
@@ -7339,10 +7400,10 @@ var Canvas = () => {
7339
7400
  })
7340
7401
  );
7341
7402
  },
7342
- children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview2, {}) })
7403
+ children: /* @__PURE__ */ jsx36(CustomPreview, { children: /* @__PURE__ */ jsx36(Preview2, {}) })
7343
7404
  }
7344
7405
  ),
7345
- /* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
7406
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("loader"), children: /* @__PURE__ */ jsx36(Loader, { size: 24 }) })
7346
7407
  ] })
7347
7408
  ]
7348
7409
  }
@@ -7397,8 +7458,8 @@ var useLoadedOverrides = ({
7397
7458
 
7398
7459
  // components/DefaultOverride/index.tsx
7399
7460
  init_react_import();
7400
- import { Fragment as Fragment13, jsx as jsx38 } from "react/jsx-runtime";
7401
- var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment13, { children });
7461
+ import { Fragment as Fragment12, jsx as jsx37 } from "react/jsx-runtime";
7462
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment12, { children });
7402
7463
 
7403
7464
  // lib/use-inject-css.ts
7404
7465
  init_react_import();
@@ -7541,9 +7602,224 @@ function useGetPuck() {
7541
7602
 
7542
7603
  // components/Puck/index.tsx
7543
7604
  import fdeq from "fast-deep-equal";
7605
+
7606
+ // components/Puck/components/Header/index.tsx
7607
+ init_react_import();
7608
+ import { memo as memo3, useCallback as useCallback17, useMemo as useMemo20, useState as useState22 } from "react";
7609
+
7610
+ // components/MenuBar/index.tsx
7611
+ init_react_import();
7612
+
7613
+ // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
7614
+ init_react_import();
7615
+ var styles_module_default21 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
7616
+
7617
+ // components/MenuBar/index.tsx
7618
+ import { Fragment as Fragment13, jsx as jsx38, jsxs as jsxs18 } from "react/jsx-runtime";
7619
+ var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
7620
+ function MenuBar({
7621
+ menuOpen = false,
7622
+ renderHeaderActions,
7623
+ setMenuOpen
7624
+ }) {
7625
+ const back = useAppStore((s) => s.history.back);
7626
+ const forward = useAppStore((s) => s.history.forward);
7627
+ const hasFuture = useAppStore((s) => s.history.hasFuture());
7628
+ const hasPast = useAppStore((s) => s.history.hasPast());
7629
+ return /* @__PURE__ */ jsx38(
7630
+ "div",
7631
+ {
7632
+ className: getClassName26({ menuOpen }),
7633
+ onClick: (event) => {
7634
+ var _a;
7635
+ const element = event.target;
7636
+ if (window.matchMedia("(min-width: 638px)").matches) {
7637
+ return;
7638
+ }
7639
+ if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
7640
+ setMenuOpen(false);
7641
+ }
7642
+ },
7643
+ children: /* @__PURE__ */ jsxs18("div", { className: getClassName26("inner"), children: [
7644
+ /* @__PURE__ */ jsxs18("div", { className: getClassName26("history"), children: [
7645
+ /* @__PURE__ */ jsx38(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx38(Undo2, { size: 21 }) }),
7646
+ /* @__PURE__ */ jsx38(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx38(Redo2, { size: 21 }) })
7647
+ ] }),
7648
+ /* @__PURE__ */ jsx38(Fragment13, { children: renderHeaderActions && renderHeaderActions() })
7649
+ ] })
7650
+ }
7651
+ );
7652
+ }
7653
+
7654
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
7655
+ init_react_import();
7656
+ var styles_module_default22 = { "PuckHeader": "_PuckHeader_15xnq_1", "PuckHeader-inner": "_PuckHeader-inner_15xnq_10", "PuckHeader-toggle": "_PuckHeader-toggle_15xnq_20", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_15xnq_27", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_15xnq_27", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_15xnq_28", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_15xnq_28", "PuckHeader-title": "_PuckHeader-title_15xnq_32", "PuckHeader-path": "_PuckHeader-path_15xnq_36", "PuckHeader-tools": "_PuckHeader-tools_15xnq_43", "PuckHeader-menuButton": "_PuckHeader-menuButton_15xnq_49", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_15xnq_54" };
7657
+
7658
+ // components/Puck/components/Header/index.tsx
7544
7659
  import { Fragment as Fragment14, jsx as jsx39, jsxs as jsxs19 } from "react/jsx-runtime";
7545
- var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
7546
- var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
7660
+ var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
7661
+ var HeaderInner = () => {
7662
+ const {
7663
+ onPublish,
7664
+ renderHeader,
7665
+ renderHeaderActions,
7666
+ headerTitle,
7667
+ headerPath,
7668
+ iframe: _iframe
7669
+ } = usePropsContext();
7670
+ const dispatch = useAppStore((s) => s.dispatch);
7671
+ const appStore = useAppStoreApi();
7672
+ const defaultHeaderRender = useMemo20(() => {
7673
+ if (renderHeader) {
7674
+ console.warn(
7675
+ "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
7676
+ );
7677
+ const RenderHeader = (_a) => {
7678
+ var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
7679
+ const Comp = renderHeader;
7680
+ const appState = useAppStore((s) => s.state);
7681
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7682
+ };
7683
+ return RenderHeader;
7684
+ }
7685
+ return DefaultOverride;
7686
+ }, [renderHeader]);
7687
+ const defaultHeaderActionsRender = useMemo20(() => {
7688
+ if (renderHeaderActions) {
7689
+ console.warn(
7690
+ "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
7691
+ );
7692
+ const RenderHeader = (props) => {
7693
+ const Comp = renderHeaderActions;
7694
+ const appState = useAppStore((s) => s.state);
7695
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7696
+ };
7697
+ return RenderHeader;
7698
+ }
7699
+ return DefaultOverride;
7700
+ }, [renderHeader]);
7701
+ const CustomHeader = useAppStore(
7702
+ (s) => s.overrides.header || defaultHeaderRender
7703
+ );
7704
+ const CustomHeaderActions = useAppStore(
7705
+ (s) => s.overrides.headerActions || defaultHeaderActionsRender
7706
+ );
7707
+ const [menuOpen, setMenuOpen] = useState22(false);
7708
+ const rootTitle = useAppStore((s) => {
7709
+ var _a, _b;
7710
+ const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
7711
+ return (_b = rootData.props.title) != null ? _b : "";
7712
+ });
7713
+ const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
7714
+ const rightSideBarVisible = useAppStore(
7715
+ (s) => s.state.ui.rightSideBarVisible
7716
+ );
7717
+ const toggleSidebars = useCallback17(
7718
+ (sidebar) => {
7719
+ const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7720
+ const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
7721
+ const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
7722
+ dispatch({
7723
+ type: "setUi",
7724
+ ui: __spreadValues({
7725
+ [`${sidebar}SideBarVisible`]: !sideBarVisible
7726
+ }, !widerViewport ? { [oppositeSideBar]: false } : {})
7727
+ });
7728
+ },
7729
+ [dispatch, leftSideBarVisible, rightSideBarVisible]
7730
+ );
7731
+ return /* @__PURE__ */ jsx39(
7732
+ CustomHeader,
7733
+ {
7734
+ actions: /* @__PURE__ */ jsx39(Fragment14, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7735
+ Button,
7736
+ {
7737
+ onClick: () => {
7738
+ const data = appStore.getState().state.data;
7739
+ onPublish && onPublish(data);
7740
+ },
7741
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7742
+ children: "Publish"
7743
+ }
7744
+ ) }) }),
7745
+ children: /* @__PURE__ */ jsx39(
7746
+ "header",
7747
+ {
7748
+ className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
7749
+ children: /* @__PURE__ */ jsxs19("div", { className: getClassName27("inner"), children: [
7750
+ /* @__PURE__ */ jsxs19("div", { className: getClassName27("toggle"), children: [
7751
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ jsx39(
7752
+ IconButton,
7753
+ {
7754
+ onClick: () => {
7755
+ toggleSidebars("left");
7756
+ },
7757
+ title: "Toggle left sidebar",
7758
+ children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
7759
+ }
7760
+ ) }),
7761
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ jsx39(
7762
+ IconButton,
7763
+ {
7764
+ onClick: () => {
7765
+ toggleSidebars("right");
7766
+ },
7767
+ title: "Toggle right sidebar",
7768
+ children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
7769
+ }
7770
+ ) })
7771
+ ] }),
7772
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("title"), children: /* @__PURE__ */ jsxs19(Heading, { rank: "2", size: "xs", children: [
7773
+ headerTitle || rootTitle || "Page",
7774
+ headerPath && /* @__PURE__ */ jsxs19(Fragment14, { children: [
7775
+ " ",
7776
+ /* @__PURE__ */ jsx39("code", { className: getClassName27("path"), children: headerPath })
7777
+ ] })
7778
+ ] }) }),
7779
+ /* @__PURE__ */ jsxs19("div", { className: getClassName27("tools"), children: [
7780
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ jsx39(
7781
+ IconButton,
7782
+ {
7783
+ onClick: () => {
7784
+ return setMenuOpen(!menuOpen);
7785
+ },
7786
+ title: "Toggle menu bar",
7787
+ children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
7788
+ }
7789
+ ) }),
7790
+ /* @__PURE__ */ jsx39(
7791
+ MenuBar,
7792
+ {
7793
+ dispatch,
7794
+ onPublish,
7795
+ menuOpen,
7796
+ renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7797
+ Button,
7798
+ {
7799
+ onClick: () => {
7800
+ const data = appStore.getState().state.data;
7801
+ onPublish && onPublish(data);
7802
+ },
7803
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7804
+ children: "Publish"
7805
+ }
7806
+ ) }),
7807
+ setMenuOpen
7808
+ }
7809
+ )
7810
+ ] })
7811
+ ] })
7812
+ }
7813
+ )
7814
+ }
7815
+ );
7816
+ };
7817
+ var Header = memo3(HeaderInner);
7818
+
7819
+ // components/Puck/index.tsx
7820
+ import { jsx as jsx40, jsxs as jsxs20 } from "react/jsx-runtime";
7821
+ var getClassName28 = get_class_name_factory_default("Puck", styles_module_default14);
7822
+ var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
7547
7823
  var FieldSideBar = () => {
7548
7824
  const title = useAppStore(
7549
7825
  (s) => {
@@ -7551,11 +7827,11 @@ var FieldSideBar = () => {
7551
7827
  return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
7552
7828
  }
7553
7829
  );
7554
- return /* @__PURE__ */ jsx39(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx39(Fields, {}) });
7830
+ return /* @__PURE__ */ jsx40(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx40(Fields, {}) });
7555
7831
  };
7556
7832
  var propsContext = createContext7({});
7557
7833
  function PropsProvider(props) {
7558
- return /* @__PURE__ */ jsx39(propsContext.Provider, { value: props, children: props.children });
7834
+ return /* @__PURE__ */ jsx40(propsContext.Provider, { value: props, children: props.children });
7559
7835
  }
7560
7836
  var usePropsContext = () => useContext12(propsContext);
7561
7837
  function PuckProvider({ children }) {
@@ -7573,11 +7849,14 @@ function PuckProvider({ children }) {
7573
7849
  metadata,
7574
7850
  onAction
7575
7851
  } = usePropsContext();
7576
- const iframe = __spreadValues({
7577
- enabled: true,
7578
- waitForStyles: true
7579
- }, _iframe);
7580
- const [generatedAppState] = useState22(() => {
7852
+ const iframe = useMemo21(
7853
+ () => __spreadValues({
7854
+ enabled: true,
7855
+ waitForStyles: true
7856
+ }, _iframe),
7857
+ [_iframe]
7858
+ );
7859
+ const [generatedAppState] = useState23(() => {
7581
7860
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
7582
7861
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
7583
7862
  let clientUiState = {};
@@ -7637,7 +7916,7 @@ function PuckProvider({ children }) {
7637
7916
  return walkAppState(newAppState, config);
7638
7917
  });
7639
7918
  const { appendData = true } = _initialHistory || {};
7640
- const [blendedHistories] = useState22(
7919
+ const [blendedHistories] = useState23(
7641
7920
  [
7642
7921
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
7643
7922
  ...appendData ? [{ state: generatedAppState }] : []
@@ -7657,7 +7936,7 @@ function PuckProvider({ children }) {
7657
7936
  overrides,
7658
7937
  plugins
7659
7938
  });
7660
- const generateAppStore = useCallback17(
7939
+ const generateAppStore = useCallback18(
7661
7940
  (state) => {
7662
7941
  return {
7663
7942
  state,
@@ -7681,9 +7960,14 @@ function PuckProvider({ children }) {
7681
7960
  metadata
7682
7961
  ]
7683
7962
  );
7684
- const [appStore] = useState22(
7963
+ const [appStore] = useState23(
7685
7964
  () => createAppStore(generateAppStore(initialAppState))
7686
7965
  );
7966
+ useEffect25(() => {
7967
+ if (process.env.NODE_ENV !== "production") {
7968
+ window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
7969
+ }
7970
+ }, [appStore]);
7687
7971
  useEffect25(() => {
7688
7972
  const state = appStore.getState().state;
7689
7973
  appStore.setState(__spreadValues({}, generateAppStore(state)));
@@ -7693,7 +7977,7 @@ function PuckProvider({ children }) {
7693
7977
  index: initialHistoryIndex,
7694
7978
  initialAppState
7695
7979
  });
7696
- const previousData = useRef7(null);
7980
+ const previousData = useRef8(null);
7697
7981
  useEffect25(() => {
7698
7982
  appStore.subscribe(
7699
7983
  (s) => s.state.data,
@@ -7712,48 +7996,27 @@ function PuckProvider({ children }) {
7712
7996
  const { resolveAndCommitData } = appStore.getState();
7713
7997
  resolveAndCommitData();
7714
7998
  }, []);
7715
- return /* @__PURE__ */ jsx39(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx39(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
7999
+ return /* @__PURE__ */ jsx40(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx40(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
7716
8000
  }
7717
8001
  function PuckLayout({ children }) {
7718
8002
  const {
7719
- onPublish,
7720
- renderHeader,
7721
- renderHeaderActions,
7722
- headerTitle,
7723
- headerPath,
7724
8003
  iframe: _iframe,
7725
8004
  dnd,
7726
8005
  initialHistory: _initialHistory
7727
8006
  } = usePropsContext();
7728
- const iframe = __spreadValues({
7729
- enabled: true,
7730
- waitForStyles: true
7731
- }, _iframe);
8007
+ const iframe = useMemo21(
8008
+ () => __spreadValues({
8009
+ enabled: true,
8010
+ waitForStyles: true
8011
+ }, _iframe),
8012
+ [_iframe]
8013
+ );
7732
8014
  useInjectGlobalCss(iframe.enabled);
7733
8015
  const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
7734
8016
  const rightSideBarVisible = useAppStore(
7735
8017
  (s) => s.state.ui.rightSideBarVisible
7736
8018
  );
7737
- const [menuOpen, setMenuOpen] = useState22(false);
7738
- const appStore = useAppStoreApi();
7739
- const rootProps = useAppStore(
7740
- (s) => s.state.data.root.props || s.state.data.root.props
7741
- );
7742
8019
  const dispatch = useAppStore((s) => s.dispatch);
7743
- const toggleSidebars = useCallback17(
7744
- (sidebar) => {
7745
- const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7746
- const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
7747
- const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
7748
- dispatch({
7749
- type: "setUi",
7750
- ui: __spreadValues({
7751
- [`${sidebar}SideBarVisible`]: !sideBarVisible
7752
- }, !widerViewport ? { [oppositeSideBar]: false } : {})
7753
- });
7754
- },
7755
- [dispatch, leftSideBarVisible, rightSideBarVisible]
7756
- );
7757
8020
  useEffect25(() => {
7758
8021
  if (!window.matchMedia("(min-width: 638px)").matches) {
7759
8022
  dispatch({
@@ -7777,49 +8040,12 @@ function PuckLayout({ children }) {
7777
8040
  window.removeEventListener("resize", handleResize);
7778
8041
  };
7779
8042
  }, []);
7780
- const defaultHeaderRender = useMemo20(() => {
7781
- if (renderHeader) {
7782
- console.warn(
7783
- "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
7784
- );
7785
- const RenderHeader = (_a) => {
7786
- var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
7787
- const Comp = renderHeader;
7788
- const appState = useAppStore((s) => s.state);
7789
- return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7790
- };
7791
- return RenderHeader;
7792
- }
7793
- return DefaultOverride;
7794
- }, [renderHeader]);
7795
- const defaultHeaderActionsRender = useMemo20(() => {
7796
- if (renderHeaderActions) {
7797
- console.warn(
7798
- "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
7799
- );
7800
- const RenderHeader = (props) => {
7801
- const Comp = renderHeaderActions;
7802
- const appState = useAppStore((s) => s.state);
7803
- return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7804
- };
7805
- return RenderHeader;
7806
- }
7807
- return DefaultOverride;
7808
- }, [renderHeader]);
7809
8043
  const overrides = useAppStore((s) => s.overrides);
7810
- const CustomPuck = useMemo20(
8044
+ const CustomPuck = useMemo21(
7811
8045
  () => overrides.puck || DefaultOverride,
7812
8046
  [overrides]
7813
8047
  );
7814
- const CustomHeader = useMemo20(
7815
- () => overrides.header || defaultHeaderRender,
7816
- [overrides]
7817
- );
7818
- const CustomHeaderActions = useMemo20(
7819
- () => overrides.headerActions || defaultHeaderActionsRender,
7820
- [overrides]
7821
- );
7822
- const [mounted, setMounted] = useState22(false);
8048
+ const [mounted, setMounted] = useState23(false);
7823
8049
  useEffect25(() => {
7824
8050
  setMounted(true);
7825
8051
  }, []);
@@ -7834,128 +8060,31 @@ function PuckLayout({ children }) {
7834
8060
  }
7835
8061
  }, [ready, iframe.enabled]);
7836
8062
  usePreviewModeHotkeys();
7837
- return /* @__PURE__ */ jsxs19("div", { className: `Puck ${getClassName27()}`, children: [
7838
- /* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
8063
+ return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName28()}`, children: [
8064
+ /* @__PURE__ */ jsx40(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx40(CustomPuck, { children: children || /* @__PURE__ */ jsx40(
7839
8065
  "div",
7840
8066
  {
7841
8067
  className: getLayoutClassName({
7842
8068
  leftSideBarVisible,
7843
- menuOpen,
7844
8069
  mounted,
7845
8070
  rightSideBarVisible
7846
8071
  }),
7847
- children: /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("inner"), children: [
7848
- /* @__PURE__ */ jsx39(
7849
- CustomHeader,
7850
- {
7851
- actions: /* @__PURE__ */ jsx39(Fragment14, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7852
- Button,
7853
- {
7854
- onClick: () => {
7855
- const data = appStore.getState().state.data;
7856
- onPublish && onPublish(data);
7857
- },
7858
- icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7859
- children: "Publish"
7860
- }
7861
- ) }) }),
7862
- children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("headerInner"), children: [
7863
- /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("headerToggle"), children: [
7864
- /* @__PURE__ */ jsx39(
7865
- "div",
7866
- {
7867
- className: getLayoutClassName("leftSideBarToggle"),
7868
- children: /* @__PURE__ */ jsx39(
7869
- IconButton,
7870
- {
7871
- onClick: () => {
7872
- toggleSidebars("left");
7873
- },
7874
- title: "Toggle left sidebar",
7875
- children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
7876
- }
7877
- )
7878
- }
7879
- ),
7880
- /* @__PURE__ */ jsx39(
7881
- "div",
7882
- {
7883
- className: getLayoutClassName("rightSideBarToggle"),
7884
- children: /* @__PURE__ */ jsx39(
7885
- IconButton,
7886
- {
7887
- onClick: () => {
7888
- toggleSidebars("right");
7889
- },
7890
- title: "Toggle right sidebar",
7891
- children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
7892
- }
7893
- )
7894
- }
7895
- )
7896
- ] }),
7897
- /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs19(Heading, { rank: "2", size: "xs", children: [
7898
- headerTitle || (rootProps == null ? void 0 : rootProps.title) || "Page",
7899
- headerPath && /* @__PURE__ */ jsxs19(Fragment14, { children: [
7900
- " ",
7901
- /* @__PURE__ */ jsx39(
7902
- "code",
7903
- {
7904
- className: getLayoutClassName("headerPath"),
7905
- children: headerPath
7906
- }
7907
- )
7908
- ] })
7909
- ] }) }),
7910
- /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("headerTools"), children: [
7911
- /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
7912
- IconButton,
7913
- {
7914
- onClick: () => {
7915
- return setMenuOpen(!menuOpen);
7916
- },
7917
- title: "Toggle menu bar",
7918
- children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
7919
- }
7920
- ) }),
7921
- /* @__PURE__ */ jsx39(
7922
- MenuBar,
7923
- {
7924
- dispatch,
7925
- onPublish,
7926
- menuOpen,
7927
- renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7928
- Button,
7929
- {
7930
- onClick: () => {
7931
- const data = appStore.getState().state.data;
7932
- onPublish && onPublish(data);
7933
- },
7934
- icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7935
- children: "Publish"
7936
- }
7937
- ) }),
7938
- setMenuOpen
7939
- }
7940
- )
7941
- ] })
7942
- ] }) })
7943
- }
7944
- ),
7945
- /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("leftSideBar"), children: [
7946
- /* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
7947
- /* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
8072
+ children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
8073
+ /* @__PURE__ */ jsx40(Header, {}),
8074
+ /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("leftSideBar"), children: [
8075
+ /* @__PURE__ */ jsx40(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx40(Components, {}) }),
8076
+ /* @__PURE__ */ jsx40(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx40(Outline, {}) })
7948
8077
  ] }),
7949
- /* @__PURE__ */ jsx39(Canvas, {}),
7950
- /* @__PURE__ */ jsx39("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx39(FieldSideBar, {}) })
8078
+ /* @__PURE__ */ jsx40(Canvas, {}),
8079
+ /* @__PURE__ */ jsx40("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx40(FieldSideBar, {}) })
7951
8080
  ] })
7952
8081
  }
7953
8082
  ) }) }),
7954
- /* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
8083
+ /* @__PURE__ */ jsx40("div", { id: "puck-portal-root", className: getClassName28("portal") })
7955
8084
  ] });
7956
8085
  }
7957
8086
  function Puck(props) {
7958
- return /* @__PURE__ */ jsx39(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx39(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx39(PuckLayout, __spreadValues({}, props)) })) }));
8087
+ return /* @__PURE__ */ jsx40(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx40(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx40(PuckLayout, __spreadValues({}, props)) })) }));
7959
8088
  }
7960
8089
  Puck.Components = Components;
7961
8090
  Puck.Fields = Fields;