@measured/puck 0.20.0-canary.755737e8 → 0.20.0-canary.ba585f93

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
@@ -25,7 +25,7 @@ import {
25
25
  walkAppState,
26
26
  walkField,
27
27
  walkTree
28
- } from "./chunk-IM42S4YL.mjs";
28
+ } from "./chunk-H6KSTNLT.mjs";
29
29
 
30
30
  // ../../node_modules/classnames/index.js
31
31
  var require_classnames = __commonJS({
@@ -375,20 +375,6 @@ var Globe = createLucideIcon("Globe", [
375
375
  ["path", { d: "M2 12h20", key: "9i4pu4" }]
376
376
  ]);
377
377
 
378
- // ../../node_modules/lucide-react/dist/esm/icons/hammer.js
379
- init_react_import();
380
- var Hammer = createLucideIcon("Hammer", [
381
- ["path", { d: "m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9", key: "eefl8a" }],
382
- ["path", { d: "m18 15 4-4", key: "16gjal" }],
383
- [
384
- "path",
385
- {
386
- d: "m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",
387
- key: "b7pghm"
388
- }
389
- ]
390
- ]);
391
-
392
378
  // ../../node_modules/lucide-react/dist/esm/icons/hash.js
393
379
  init_react_import();
394
380
  var Hash = createLucideIcon("Hash", [
@@ -536,14 +522,6 @@ var Tablet = createLucideIcon("Tablet", [
536
522
  ["line", { x1: "12", x2: "12.01", y1: "18", y2: "18", key: "1dp563" }]
537
523
  ]);
538
524
 
539
- // ../../node_modules/lucide-react/dist/esm/icons/toy-brick.js
540
- init_react_import();
541
- var ToyBrick = createLucideIcon("ToyBrick", [
542
- ["rect", { width: "18", height: "12", x: "3", y: "8", rx: "1", key: "158fvp" }],
543
- ["path", { d: "M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3", key: "s0042v" }],
544
- ["path", { d: "M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3", key: "9wmeh2" }]
545
- ]);
546
-
547
525
  // ../../node_modules/lucide-react/dist/esm/icons/trash.js
548
526
  init_react_import();
549
527
  var Trash = createLucideIcon("Trash", [
@@ -1316,11 +1294,18 @@ var monitorHotkeys = (doc) => {
1316
1294
  }
1317
1295
  }
1318
1296
  };
1297
+ const onVisibilityChanged = (e) => {
1298
+ if (document.visibilityState === "hidden") {
1299
+ useHotkeyStore.getState().reset();
1300
+ }
1301
+ };
1319
1302
  doc.addEventListener("keydown", onKeyDown);
1320
1303
  doc.addEventListener("keyup", onKeyUp);
1304
+ doc.addEventListener("visibilitychange", onVisibilityChanged);
1321
1305
  return () => {
1322
1306
  doc.removeEventListener("keydown", onKeyDown);
1323
1307
  doc.removeEventListener("keyup", onKeyUp);
1308
+ doc.removeEventListener("visibilitychange", onVisibilityChanged);
1324
1309
  };
1325
1310
  };
1326
1311
  var useMonitorHotkeys = () => {
@@ -1415,7 +1400,7 @@ var createHistorySlice = (set, get) => {
1415
1400
  const { dispatch, history } = get();
1416
1401
  dispatch({
1417
1402
  type: "set",
1418
- state: ((_a = history.histories[history.histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
1403
+ state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
1419
1404
  });
1420
1405
  set({ history: __spreadProps(__spreadValues({}, history), { histories, index: histories.length - 1 }) });
1421
1406
  },
@@ -3109,6 +3094,7 @@ var ExternalInput = ({
3109
3094
  hasFilterFields && /* @__PURE__ */ jsx12("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ jsx12(
3110
3095
  IconButton,
3111
3096
  {
3097
+ type: "button",
3112
3098
  title: "Toggle filters",
3113
3099
  onClick: (e) => {
3114
3100
  e.preventDefault();
@@ -3456,9 +3442,8 @@ var ObjectField = ({
3456
3442
  readOnly,
3457
3443
  children: /* @__PURE__ */ jsx17("div", { className: getClassName14(), children: /* @__PURE__ */ jsx17("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
3458
3444
  const subField = field.objectFields[subName];
3459
- const subPath = `${name}.${subName}`;
3460
- const localSubPath = `${localName || name}.${subName}`;
3461
- const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
3445
+ const subPath = `${localName}.${subName}`;
3446
+ const subReadOnly = readOnly ? readOnly : readOnlyFields[subPath];
3462
3447
  const label2 = subField.label || subName;
3463
3448
  return /* @__PURE__ */ jsx17(
3464
3449
  NestedFieldProvider,
@@ -3557,7 +3542,7 @@ var FieldLabelInternal = ({
3557
3542
  );
3558
3543
  };
3559
3544
  function AutoFieldInternal(props) {
3560
- var _a, _b, _c, _d, _e, _f, _g, _h;
3545
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
3561
3546
  const dispatch = useAppStore((s) => s.dispatch);
3562
3547
  const overrides = useAppStore((s) => s.overrides);
3563
3548
  const readOnly = useAppStore((s) => {
@@ -3629,21 +3614,23 @@ function AutoFieldInternal(props) {
3629
3614
  if (field.type === "slot") {
3630
3615
  return null;
3631
3616
  }
3617
+ let children = null;
3618
+ let FieldComponent;
3632
3619
  if (field.type === "custom") {
3633
3620
  if (!field.render) {
3634
3621
  return null;
3635
3622
  }
3636
- const CustomField = field.render;
3637
- return /* @__PURE__ */ jsx18("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ jsx18("div", { className: getClassName15(), children: /* @__PURE__ */ jsx18(CustomField, __spreadValues({}, mergedProps)) }) });
3623
+ FieldComponent = field.render;
3624
+ } else {
3625
+ children = defaultFields[field.type](mergedProps);
3626
+ FieldComponent = render[field.type];
3638
3627
  }
3639
- const children = defaultFields[field.type](mergedProps);
3640
- const Render2 = render[field.type];
3641
3628
  return /* @__PURE__ */ jsx18(
3642
3629
  NestedFieldContext.Provider,
3643
3630
  {
3644
3631
  value: {
3645
3632
  readOnlyFields: nestedFieldContext.readOnlyFields || readOnly || {},
3646
- localName: nestedFieldContext.localName
3633
+ localName: (_i = nestedFieldContext.localName) != null ? _i : mergedProps.name
3647
3634
  },
3648
3635
  children: /* @__PURE__ */ jsx18(
3649
3636
  "div",
@@ -3654,7 +3641,7 @@ function AutoFieldInternal(props) {
3654
3641
  onClick: (e) => {
3655
3642
  e.stopPropagation();
3656
3643
  },
3657
- children: /* @__PURE__ */ jsx18(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
3644
+ children: /* @__PURE__ */ jsx18(FieldComponent, __spreadProps(__spreadValues({}, mergedProps), { children }))
3658
3645
  }
3659
3646
  )
3660
3647
  }
@@ -3821,19 +3808,9 @@ var DropZoneProvider = ({
3821
3808
  },
3822
3809
  [dispatch]
3823
3810
  );
3824
- const unregisterZone = useCallback5(
3825
- (zoneCompound) => {
3826
- dispatch({
3827
- type: "unregisterZone",
3828
- zone: zoneCompound
3829
- });
3830
- },
3831
- [dispatch]
3832
- );
3833
3811
  const memoValue = useMemo6(
3834
3812
  () => __spreadValues({
3835
- registerZone,
3836
- unregisterZone
3813
+ registerZone
3837
3814
  }, value),
3838
3815
  [value]
3839
3816
  );
@@ -4205,7 +4182,8 @@ var DraggableComponent = ({
4205
4182
  el.removeEventListener("mouseout", _onMouseOut);
4206
4183
  };
4207
4184
  }, [
4208
- ref,
4185
+ ref.current,
4186
+ // Remount attributes if the element changes
4209
4187
  onClick,
4210
4188
  containsActiveZone,
4211
4189
  zoneCompound,
@@ -4707,7 +4685,8 @@ var DropZoneChild = ({
4707
4685
  return {
4708
4686
  type: preview.componentType,
4709
4687
  props: preview.props,
4710
- previewType: preview.type
4688
+ previewType: preview.type,
4689
+ element: preview.element
4711
4690
  };
4712
4691
  }
4713
4692
  return null;
@@ -4740,6 +4719,12 @@ var DropZoneChild = ({
4740
4719
  let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
4741
4720
  const renderPreview = useMemo9(
4742
4721
  () => function Preview3() {
4722
+ if (item && "element" in item && item.element) {
4723
+ return (
4724
+ // Safe to use this since the HTML is set by the user
4725
+ /* @__PURE__ */ jsx23("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
4726
+ );
4727
+ }
4743
4728
  return /* @__PURE__ */ jsx23(DrawerItemInner, { name: label, children: overrides.componentItem });
4744
4729
  },
4745
4730
  [componentId, label, overrides]
@@ -4815,6 +4800,7 @@ var DropZoneEdit = forwardRef3(
4815
4800
  collisionAxis
4816
4801
  }, userRef) {
4817
4802
  const ctx = useContext7(dropZoneContext);
4803
+ const appStoreApi = useAppStoreApi();
4818
4804
  const {
4819
4805
  // These all need setting via context
4820
4806
  areaId,
@@ -4856,13 +4842,8 @@ var DropZoneEdit = forwardRef3(
4856
4842
  if (ctx == null ? void 0 : ctx.registerZone) {
4857
4843
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
4858
4844
  }
4859
- return () => {
4860
- if (ctx == null ? void 0 : ctx.unregisterZone) {
4861
- ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
4862
- }
4863
- };
4864
4845
  }
4865
- }, [zoneType]);
4846
+ }, [zoneType, appStoreApi]);
4866
4847
  useEffect16(() => {
4867
4848
  if (zoneType === "dropzone") {
4868
4849
  if (zoneCompound !== rootDroppableId) {
@@ -5027,25 +5008,19 @@ var DropZoneRender = forwardRef3(
5027
5008
  const ctx = useContext7(dropZoneContext);
5028
5009
  const { areaId = "root" } = ctx || {};
5029
5010
  const { config, data, metadata } = useContext7(renderContext);
5030
- let zoneCompound = rootDroppableId;
5011
+ let zoneCompound = `${areaId}:${zone}`;
5031
5012
  let content = (data == null ? void 0 : data.content) || [];
5032
5013
  useEffect16(() => {
5033
5014
  if (!content) {
5034
5015
  if (ctx == null ? void 0 : ctx.registerZone) {
5035
5016
  ctx == null ? void 0 : ctx.registerZone(zoneCompound);
5036
5017
  }
5037
- return () => {
5038
- if (ctx == null ? void 0 : ctx.unregisterZone) {
5039
- ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
5040
- }
5041
- };
5042
5018
  }
5043
5019
  }, [content]);
5044
5020
  if (!data || !config) {
5045
5021
  return null;
5046
5022
  }
5047
- if (areaId !== rootAreaId && zone !== rootZone) {
5048
- zoneCompound = `${areaId}:${zone}`;
5023
+ if (zoneCompound !== rootDroppableId) {
5049
5024
  content = setupZone(data, zoneCompound).zones[zoneCompound];
5050
5025
  }
5051
5026
  return /* @__PURE__ */ jsx23("div", { className, style, ref, children: content.map((item) => {
@@ -5300,6 +5275,7 @@ var findDeepestCandidate = (position, manager) => {
5300
5275
  });
5301
5276
  filteredCandidates.reverse();
5302
5277
  const primaryCandidate = filteredCandidates[0];
5278
+ if (!primaryCandidate) return { zone: null, area: null };
5303
5279
  const primaryCandidateData = primaryCandidate.data;
5304
5280
  const primaryCandidateIsComponent = "containsActiveZone" in primaryCandidateData;
5305
5281
  const zone = getZoneId(primaryCandidate);
@@ -5704,6 +5680,7 @@ var DragDropContextClient = ({
5704
5680
  type: "insert",
5705
5681
  index: targetIndex,
5706
5682
  zone: targetZone,
5683
+ element: source.element,
5707
5684
  props: {
5708
5685
  id: source.id.toString()
5709
5686
  }
@@ -5729,7 +5706,8 @@ var DragDropContextClient = ({
5729
5706
  type: "move",
5730
5707
  index: targetIndex,
5731
5708
  zone: targetZone,
5732
- props: item.props
5709
+ props: item.props,
5710
+ element: source.element
5733
5711
  }
5734
5712
  }
5735
5713
  });
@@ -5759,7 +5737,8 @@ var DragDropContextClient = ({
5759
5737
  type: "move",
5760
5738
  index: sourceData.index,
5761
5739
  zone: sourceData.zone,
5762
- props: item.props
5740
+ props: item.props,
5741
+ element: source.element
5763
5742
  }
5764
5743
  }
5765
5744
  });
@@ -5946,28 +5925,125 @@ import {
5946
5925
  createContext as createContext7,
5947
5926
  useCallback as useCallback18,
5948
5927
  useContext as useContext12,
5949
- useEffect as useEffect26,
5950
- useMemo as useMemo22,
5928
+ useEffect as useEffect25,
5929
+ useMemo as useMemo21,
5951
5930
  useRef as useRef8,
5952
- useState as useState24
5931
+ useState as useState23
5953
5932
  } from "react";
5954
5933
 
5934
+ // components/SidebarSection/index.tsx
5935
+ init_react_import();
5936
+
5937
+ // css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
5938
+ init_react_import();
5939
+ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
5940
+
5941
+ // lib/use-breadcrumbs.ts
5942
+ init_react_import();
5943
+ import { useMemo as useMemo12 } from "react";
5944
+ var useBreadcrumbs = (renderCount) => {
5945
+ const selectedId = useAppStore((s) => {
5946
+ var _a;
5947
+ return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
5948
+ });
5949
+ const config = useAppStore((s) => s.config);
5950
+ const path = useAppStore((s) => {
5951
+ var _a;
5952
+ return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
5953
+ });
5954
+ const appStore = useAppStoreApi();
5955
+ return useMemo12(() => {
5956
+ const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
5957
+ var _a, _b, _c;
5958
+ const [componentId] = zoneCompound.split(":");
5959
+ if (componentId === "root") {
5960
+ return {
5961
+ label: "Page",
5962
+ selector: null
5963
+ };
5964
+ }
5965
+ const node = appStore.getState().state.indexes.nodes[componentId];
5966
+ const parentId = node.path[node.path.length - 1];
5967
+ const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
5968
+ const index = contentIds.indexOf(componentId);
5969
+ const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
5970
+ return {
5971
+ label,
5972
+ selector: node ? {
5973
+ index,
5974
+ zone: node.path[node.path.length - 1]
5975
+ } : null
5976
+ };
5977
+ })) || [];
5978
+ if (renderCount) {
5979
+ return breadcrumbs.slice(breadcrumbs.length - renderCount);
5980
+ }
5981
+ return breadcrumbs;
5982
+ }, [path, renderCount]);
5983
+ };
5984
+
5985
+ // components/SidebarSection/index.tsx
5986
+ import { jsx as jsx26, jsxs as jsxs12 } from "react/jsx-runtime";
5987
+ var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
5988
+ var SidebarSection = ({
5989
+ children,
5990
+ title,
5991
+ background,
5992
+ showBreadcrumbs,
5993
+ noBorderTop,
5994
+ noPadding,
5995
+ isLoading
5996
+ }) => {
5997
+ const setUi = useAppStore((s) => s.setUi);
5998
+ const breadcrumbs = useBreadcrumbs(1);
5999
+ return /* @__PURE__ */ jsxs12(
6000
+ "div",
6001
+ {
6002
+ className: getClassName19({ noBorderTop, noPadding }),
6003
+ style: { background },
6004
+ children: [
6005
+ /* @__PURE__ */ jsx26("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
6006
+ showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumb"), children: [
6007
+ /* @__PURE__ */ jsx26(
6008
+ "button",
6009
+ {
6010
+ type: "button",
6011
+ className: getClassName19("breadcrumbLabel"),
6012
+ onClick: () => setUi({ itemSelector: breadcrumb.selector }),
6013
+ children: breadcrumb.label
6014
+ }
6015
+ ),
6016
+ /* @__PURE__ */ jsx26(ChevronRight, { size: 16 })
6017
+ ] }, i)) : null,
6018
+ /* @__PURE__ */ jsx26("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx26(Heading, { rank: "2", size: "xs", children: title }) })
6019
+ ] }) }),
6020
+ /* @__PURE__ */ jsx26("div", { className: getClassName19("content"), children }),
6021
+ isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx26(Loader, { size: 32 }) })
6022
+ ]
6023
+ }
6024
+ );
6025
+ };
6026
+
6027
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
6028
+ init_react_import();
6029
+ var styles_module_default14 = { "Puck": "_Puck_dnlfp_19", "Puck-portal": "_Puck-portal_dnlfp_31", "PuckLayout-inner": "_PuckLayout-inner_dnlfp_38", "PuckLayout--mounted": "_PuckLayout--mounted_dnlfp_50", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_dnlfp_54", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_dnlfp_60", "PuckLayout-mounted": "_PuckLayout-mounted_dnlfp_74", "PuckLayout": "_PuckLayout_dnlfp_38", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_dnlfp_115", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_dnlfp_124" };
6030
+
5955
6031
  // components/Puck/components/Fields/index.tsx
5956
6032
  init_react_import();
5957
6033
 
5958
6034
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
5959
6035
  init_react_import();
5960
- var styles_module_default13 = { "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" };
6036
+ 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" };
5961
6037
 
5962
6038
  // components/Puck/components/Fields/index.tsx
5963
- import { memo as memo2, useCallback as useCallback12, useMemo as useMemo12 } from "react";
6039
+ import { memo as memo2, useCallback as useCallback12, useMemo as useMemo13 } from "react";
5964
6040
  import { useShallow as useShallow5 } from "zustand/react/shallow";
5965
- import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs12 } from "react/jsx-runtime";
5966
- var getClassName19 = get_class_name_factory_default("PuckFields", styles_module_default13);
6041
+ import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
6042
+ var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
5967
6043
  var DefaultFields = ({
5968
6044
  children
5969
6045
  }) => {
5970
- return /* @__PURE__ */ jsx26(Fragment7, { children });
6046
+ return /* @__PURE__ */ jsx27(Fragment7, { children });
5971
6047
  };
5972
6048
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
5973
6049
  let currentProps;
@@ -6039,7 +6115,7 @@ var FieldsChild = ({ fieldName }) => {
6039
6115
  const { visible = true } = field != null ? field : {};
6040
6116
  if (!field || !id || !visible) return null;
6041
6117
  if (field.type === "slot") return null;
6042
- return /* @__PURE__ */ jsx26("div", { className: getClassName19("field"), children: /* @__PURE__ */ jsx26(
6118
+ return /* @__PURE__ */ jsx27("div", { className: getClassName20("field"), children: /* @__PURE__ */ jsx27(
6043
6119
  AutoFieldPrivate,
6044
6120
  {
6045
6121
  field,
@@ -6076,17 +6152,17 @@ var FieldsInternal = ({ wrapFields = true }) => {
6076
6152
  })
6077
6153
  );
6078
6154
  const isLoading = fieldsLoading || componentResolving;
6079
- const Wrapper = useMemo12(() => overrides.fields || DefaultFields, [overrides]);
6080
- return /* @__PURE__ */ jsxs12(
6155
+ const Wrapper = useMemo13(() => overrides.fields || DefaultFields, [overrides]);
6156
+ return /* @__PURE__ */ jsxs13(
6081
6157
  "form",
6082
6158
  {
6083
- className: getClassName19({ wrapFields }),
6159
+ className: getClassName20({ wrapFields }),
6084
6160
  onSubmit: (e) => {
6085
6161
  e.preventDefault();
6086
6162
  },
6087
6163
  children: [
6088
- /* @__PURE__ */ jsx26(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx26(FieldsChildMemo, { fieldName }, fieldName)) }),
6089
- isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx26("div", { className: getClassName19("loadingOverlayInner"), children: /* @__PURE__ */ jsx26(Loader, { size: 16 }) }) })
6164
+ /* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx27(FieldsChildMemo, { fieldName }, fieldName)) }),
6165
+ isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName20("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
6090
6166
  ]
6091
6167
  }
6092
6168
  );
@@ -6105,11 +6181,11 @@ init_react_import();
6105
6181
 
6106
6182
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
6107
6183
  init_react_import();
6108
- var styles_module_default14 = { "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" };
6184
+ 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" };
6109
6185
 
6110
6186
  // components/ComponentList/index.tsx
6111
- import { jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
6112
- var getClassName20 = get_class_name_factory_default("ComponentList", styles_module_default14);
6187
+ import { jsx as jsx28, jsxs as jsxs14 } from "react/jsx-runtime";
6188
+ var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default16);
6113
6189
  var ComponentListItem = ({
6114
6190
  name,
6115
6191
  label
@@ -6120,7 +6196,7 @@ var ComponentListItem = ({
6120
6196
  type: name
6121
6197
  }).insert
6122
6198
  );
6123
- return /* @__PURE__ */ jsx27(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6199
+ return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6124
6200
  };
6125
6201
  var ComponentList = ({
6126
6202
  children,
@@ -6131,12 +6207,12 @@ var ComponentList = ({
6131
6207
  const setUi = useAppStore((s) => s.setUi);
6132
6208
  const componentList = useAppStore((s) => s.state.ui.componentList);
6133
6209
  const { expanded = true } = componentList[id] || {};
6134
- return /* @__PURE__ */ jsxs13("div", { className: getClassName20({ isExpanded: expanded }), children: [
6135
- title && /* @__PURE__ */ jsxs13(
6210
+ return /* @__PURE__ */ jsxs14("div", { className: getClassName21({ isExpanded: expanded }), children: [
6211
+ title && /* @__PURE__ */ jsxs14(
6136
6212
  "button",
6137
6213
  {
6138
6214
  type: "button",
6139
- className: getClassName20("title"),
6215
+ className: getClassName21("title"),
6140
6216
  onClick: () => setUi({
6141
6217
  componentList: __spreadProps(__spreadValues({}, componentList), {
6142
6218
  [id]: __spreadProps(__spreadValues({}, componentList[id]), {
@@ -6146,14 +6222,14 @@ var ComponentList = ({
6146
6222
  }),
6147
6223
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
6148
6224
  children: [
6149
- /* @__PURE__ */ jsx27("div", { children: title }),
6150
- /* @__PURE__ */ jsx27("div", { className: getClassName20("titleIcon"), children: expanded ? /* @__PURE__ */ jsx27(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx27(ChevronDown, { size: 12 }) })
6225
+ /* @__PURE__ */ jsx28("div", { children: title }),
6226
+ /* @__PURE__ */ jsx28("div", { className: getClassName21("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
6151
6227
  ]
6152
6228
  }
6153
6229
  ),
6154
- /* @__PURE__ */ jsx27("div", { className: getClassName20("content"), children: /* @__PURE__ */ jsx27(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6230
+ /* @__PURE__ */ jsx28("div", { className: getClassName21("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6155
6231
  var _a;
6156
- return /* @__PURE__ */ jsx27(
6232
+ return /* @__PURE__ */ jsx28(
6157
6233
  ComponentListItem,
6158
6234
  {
6159
6235
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -6167,7 +6243,7 @@ var ComponentList = ({
6167
6243
  ComponentList.Item = ComponentListItem;
6168
6244
 
6169
6245
  // lib/use-component-list.tsx
6170
- import { jsx as jsx28 } from "react/jsx-runtime";
6246
+ import { jsx as jsx29 } from "react/jsx-runtime";
6171
6247
  var useComponentList = () => {
6172
6248
  const [componentList, setComponentList] = useState16();
6173
6249
  const config = useAppStore((s) => s.config);
@@ -6182,7 +6258,7 @@ var useComponentList = () => {
6182
6258
  if (category.visible === false || !category.components) {
6183
6259
  return null;
6184
6260
  }
6185
- return /* @__PURE__ */ jsx28(
6261
+ return /* @__PURE__ */ jsx29(
6186
6262
  ComponentList,
6187
6263
  {
6188
6264
  id: categoryKey,
@@ -6191,7 +6267,7 @@ var useComponentList = () => {
6191
6267
  var _a2;
6192
6268
  matchedComponents.push(componentName);
6193
6269
  const componentConf = config.components[componentName] || {};
6194
- return /* @__PURE__ */ jsx28(
6270
+ return /* @__PURE__ */ jsx29(
6195
6271
  ComponentList.Item,
6196
6272
  {
6197
6273
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -6211,7 +6287,7 @@ var useComponentList = () => {
6211
6287
  );
6212
6288
  if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
6213
6289
  _componentList.push(
6214
- /* @__PURE__ */ jsx28(
6290
+ /* @__PURE__ */ jsx29(
6215
6291
  ComponentList,
6216
6292
  {
6217
6293
  id: "other",
@@ -6219,7 +6295,7 @@ var useComponentList = () => {
6219
6295
  children: remainingComponents.map((componentName, i) => {
6220
6296
  var _a2;
6221
6297
  const componentConf = config.components[componentName] || {};
6222
- return /* @__PURE__ */ jsx28(
6298
+ return /* @__PURE__ */ jsx29(
6223
6299
  ComponentList.Item,
6224
6300
  {
6225
6301
  name: componentName,
@@ -6241,18 +6317,18 @@ var useComponentList = () => {
6241
6317
  };
6242
6318
 
6243
6319
  // components/Puck/components/Components/index.tsx
6244
- import { useMemo as useMemo13 } from "react";
6245
- import { jsx as jsx29 } from "react/jsx-runtime";
6320
+ import { useMemo as useMemo14 } from "react";
6321
+ import { jsx as jsx30 } from "react/jsx-runtime";
6246
6322
  var Components = () => {
6247
6323
  const overrides = useAppStore((s) => s.overrides);
6248
6324
  const componentList = useComponentList();
6249
- const Wrapper = useMemo13(() => overrides.components || "div", [overrides]);
6250
- return /* @__PURE__ */ jsx29(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx29(ComponentList, { id: "all" }) });
6325
+ const Wrapper = useMemo14(() => overrides.components || "div", [overrides]);
6326
+ return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
6251
6327
  };
6252
6328
 
6253
6329
  // components/Puck/components/Preview/index.tsx
6254
6330
  init_react_import();
6255
- import { useCallback as useCallback13, useEffect as useEffect20, useRef as useRef6, useMemo as useMemo14 } from "react";
6331
+ import { useCallback as useCallback13, useEffect as useEffect20, useRef as useRef6, useMemo as useMemo15 } from "react";
6256
6332
 
6257
6333
  // components/AutoFrame/index.tsx
6258
6334
  init_react_import();
@@ -6264,12 +6340,19 @@ import {
6264
6340
  } from "react";
6265
6341
  import hash from "object-hash";
6266
6342
  import { createPortal as createPortal3 } from "react-dom";
6267
- import { Fragment as Fragment8, jsx as jsx30 } from "react/jsx-runtime";
6343
+ import { Fragment as Fragment8, jsx as jsx31 } from "react/jsx-runtime";
6268
6344
  var styleSelector = 'style, link[rel="stylesheet"]';
6269
6345
  var collectStyles = (doc) => {
6270
6346
  const collected = [];
6271
6347
  doc.querySelectorAll(styleSelector).forEach((style) => {
6272
- collected.push(style);
6348
+ if (style.tagName === "STYLE") {
6349
+ const hasContent = !!style.innerHTML.trim();
6350
+ if (hasContent) {
6351
+ collected.push(style);
6352
+ }
6353
+ } else {
6354
+ collected.push(style);
6355
+ }
6273
6356
  });
6274
6357
  return collected;
6275
6358
  };
@@ -6282,7 +6365,7 @@ var getStyleSheet = (el) => {
6282
6365
  var getStyles = (styleSheet) => {
6283
6366
  if (styleSheet) {
6284
6367
  try {
6285
- return [...styleSheet.cssRules].map((rule) => rule.cssText).join("");
6368
+ return [...Array.from(styleSheet.cssRules)].map((rule) => rule.cssText).join("");
6286
6369
  } catch (e) {
6287
6370
  console.warn(
6288
6371
  "Access to stylesheet %s is denied. Ignoring\u2026",
@@ -6464,7 +6547,7 @@ var CopyHostStyles = ({
6464
6547
  observer.disconnect();
6465
6548
  };
6466
6549
  }, []);
6467
- return /* @__PURE__ */ jsx30(Fragment8, { children });
6550
+ return /* @__PURE__ */ jsx31(Fragment8, { children });
6468
6551
  };
6469
6552
  var autoFrameContext = createContext5({});
6470
6553
  var useFrame = () => useContext9(autoFrameContext);
@@ -6511,7 +6594,7 @@ function AutoFrame(_a) {
6511
6594
  }
6512
6595
  }
6513
6596
  }, [frameRef, loaded, stylesLoaded]);
6514
- return /* @__PURE__ */ jsx30(
6597
+ return /* @__PURE__ */ jsx31(
6515
6598
  "iframe",
6516
6599
  __spreadProps(__spreadValues({}, props), {
6517
6600
  className,
@@ -6521,7 +6604,7 @@ function AutoFrame(_a) {
6521
6604
  onLoad: () => {
6522
6605
  setLoaded(true);
6523
6606
  },
6524
- children: /* @__PURE__ */ jsx30(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx30(
6607
+ children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(
6525
6608
  CopyHostStyles,
6526
6609
  {
6527
6610
  debug,
@@ -6537,11 +6620,11 @@ var AutoFrame_default = AutoFrame;
6537
6620
 
6538
6621
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
6539
6622
  init_react_import();
6540
- var styles_module_default15 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
6623
+ var styles_module_default17 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
6541
6624
 
6542
6625
  // components/Puck/components/Preview/index.tsx
6543
- import { Fragment as Fragment9, jsx as jsx31 } from "react/jsx-runtime";
6544
- var getClassName21 = get_class_name_factory_default("PuckPreview", styles_module_default15);
6626
+ import { Fragment as Fragment9, jsx as jsx32 } from "react/jsx-runtime";
6627
+ var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
6545
6628
  var useBubbleIframeEvents = (ref) => {
6546
6629
  const status = useAppStore((s) => s.status);
6547
6630
  useEffect20(() => {
@@ -6603,15 +6686,15 @@ var Preview2 = ({ id = "puck-preview" }) => {
6603
6686
  );
6604
6687
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
6605
6688
  id: "puck-root"
6606
- }, propsWithSlots)) : /* @__PURE__ */ jsx31(Fragment9, { children: propsWithSlots.children });
6689
+ }, propsWithSlots)) : /* @__PURE__ */ jsx32(Fragment9, { children: propsWithSlots.children });
6607
6690
  },
6608
6691
  [config]
6609
6692
  );
6610
- const Frame = useMemo14(() => overrides.iframe, [overrides]);
6693
+ const Frame = useMemo15(() => overrides.iframe, [overrides]);
6611
6694
  const rootProps = root.props || root;
6612
6695
  const ref = useRef6(null);
6613
6696
  useBubbleIframeEvents(ref);
6614
- const inner = !renderData ? /* @__PURE__ */ jsx31(
6697
+ const inner = !renderData ? /* @__PURE__ */ jsx32(
6615
6698
  Page,
6616
6699
  __spreadProps(__spreadValues({}, rootProps), {
6617
6700
  puck: {
@@ -6621,28 +6704,28 @@ var Preview2 = ({ id = "puck-preview" }) => {
6621
6704
  metadata
6622
6705
  },
6623
6706
  editMode: true,
6624
- children: /* @__PURE__ */ jsx31(DropZonePure, { zone: rootDroppableId })
6707
+ children: /* @__PURE__ */ jsx32(DropZonePure, { zone: rootDroppableId })
6625
6708
  })
6626
- ) : /* @__PURE__ */ jsx31(Render, { data: renderData, config });
6709
+ ) : /* @__PURE__ */ jsx32(Render, { data: renderData, config, metadata });
6627
6710
  useEffect20(() => {
6628
6711
  if (!iframe.enabled) {
6629
6712
  setStatus("READY");
6630
6713
  }
6631
6714
  }, [iframe.enabled]);
6632
- return /* @__PURE__ */ jsx31(
6715
+ return /* @__PURE__ */ jsx32(
6633
6716
  "div",
6634
6717
  {
6635
- className: getClassName21(),
6718
+ className: getClassName22(),
6636
6719
  id,
6637
6720
  "data-puck-preview": true,
6638
6721
  onClick: () => {
6639
6722
  dispatch({ type: "setUi", ui: { itemSelector: null } });
6640
6723
  },
6641
- children: iframe.enabled ? /* @__PURE__ */ jsx31(
6724
+ children: iframe.enabled ? /* @__PURE__ */ jsx32(
6642
6725
  AutoFrame_default,
6643
6726
  {
6644
6727
  id: "preview-frame",
6645
- className: getClassName21("frame"),
6728
+ className: getClassName22("frame"),
6646
6729
  "data-rfd-iframe": true,
6647
6730
  onReady: () => {
6648
6731
  setStatus("READY");
@@ -6651,18 +6734,18 @@ var Preview2 = ({ id = "puck-preview" }) => {
6651
6734
  setStatus("MOUNTED");
6652
6735
  },
6653
6736
  frameRef: ref,
6654
- children: /* @__PURE__ */ jsx31(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6737
+ children: /* @__PURE__ */ jsx32(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6655
6738
  if (Frame) {
6656
- return /* @__PURE__ */ jsx31(Frame, { document: document2, children: inner });
6739
+ return /* @__PURE__ */ jsx32(Frame, { document: document2, children: inner });
6657
6740
  }
6658
6741
  return inner;
6659
6742
  } })
6660
6743
  }
6661
- ) : /* @__PURE__ */ jsx31(
6744
+ ) : /* @__PURE__ */ jsx32(
6662
6745
  "div",
6663
6746
  {
6664
6747
  id: "preview-frame",
6665
- className: getClassName21("frame"),
6748
+ className: getClassName22("frame"),
6666
6749
  ref,
6667
6750
  "data-puck-entry": true,
6668
6751
  children: inner
@@ -6680,7 +6763,7 @@ init_react_import();
6680
6763
 
6681
6764
  // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
6682
6765
  init_react_import();
6683
- var styles_module_default16 = { "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" };
6766
+ 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" };
6684
6767
 
6685
6768
  // lib/scroll-into-view.ts
6686
6769
  init_react_import();
@@ -6717,16 +6800,15 @@ var onScrollEnd = (frame, cb) => {
6717
6800
 
6718
6801
  // components/LayerTree/index.tsx
6719
6802
  import { useShallow as useShallow6 } from "zustand/react/shallow";
6720
- import { Fragment as Fragment10, jsx as jsx32, jsxs as jsxs14 } from "react/jsx-runtime";
6721
- var getClassName22 = get_class_name_factory_default("LayerTree", styles_module_default16);
6722
- var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default16);
6803
+ import { Fragment as Fragment10, jsx as jsx33, jsxs as jsxs15 } from "react/jsx-runtime";
6804
+ var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
6805
+ var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
6723
6806
  var Layer = ({
6724
6807
  index,
6725
6808
  itemId,
6726
6809
  zoneCompound
6727
6810
  }) => {
6728
6811
  var _a;
6729
- const ctx = useContext10(dropZoneContext);
6730
6812
  const config = useAppStore((s) => s.config);
6731
6813
  const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
6732
6814
  const dispatch = useAppStore((s) => s.dispatch);
@@ -6765,7 +6847,7 @@ var Layer = ({
6765
6847
  });
6766
6848
  const componentConfig = config.components[nodeData.data.type];
6767
6849
  const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
6768
- return /* @__PURE__ */ jsxs14(
6850
+ return /* @__PURE__ */ jsxs15(
6769
6851
  "li",
6770
6852
  {
6771
6853
  className: getClassNameLayer({
@@ -6775,7 +6857,7 @@ var Layer = ({
6775
6857
  childIsSelected
6776
6858
  }),
6777
6859
  children: [
6778
- /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs14(
6860
+ /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs15(
6779
6861
  "button",
6780
6862
  {
6781
6863
  type: "button",
@@ -6813,22 +6895,22 @@ var Layer = ({
6813
6895
  zoneStore.setState({ hoveringComponent: null });
6814
6896
  },
6815
6897
  children: [
6816
- containsZone && /* @__PURE__ */ jsx32(
6898
+ containsZone && /* @__PURE__ */ jsx33(
6817
6899
  "div",
6818
6900
  {
6819
6901
  className: getClassNameLayer("chevron"),
6820
6902
  title: isSelected ? "Collapse" : "Expand",
6821
- children: /* @__PURE__ */ jsx32(ChevronDown, { size: "12" })
6903
+ children: /* @__PURE__ */ jsx33(ChevronDown, { size: "12" })
6822
6904
  }
6823
6905
  ),
6824
- /* @__PURE__ */ jsxs14("div", { className: getClassNameLayer("title"), children: [
6825
- /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ jsx32(Type, { size: "16" }) : /* @__PURE__ */ jsx32(LayoutGrid, { size: "16" }) }),
6826
- /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("name"), children: label })
6906
+ /* @__PURE__ */ jsxs15("div", { className: getClassNameLayer("title"), children: [
6907
+ /* @__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" }) }),
6908
+ /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("name"), children: label })
6827
6909
  ] })
6828
6910
  ]
6829
6911
  }
6830
6912
  ) }),
6831
- containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx32(LayerTree, { zoneCompound: subzone }) }, subzone))
6913
+ containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx33(LayerTree, { zoneCompound: subzone }) }, subzone))
6832
6914
  ]
6833
6915
  }
6834
6916
  );
@@ -6837,7 +6919,15 @@ var LayerTree = ({
6837
6919
  label: _label,
6838
6920
  zoneCompound
6839
6921
  }) => {
6840
- const label = _label != null ? _label : zoneCompound.split(":")[1];
6922
+ const label = useAppStore((s) => {
6923
+ var _a, _b, _c, _d;
6924
+ if (_label) return _label;
6925
+ if (zoneCompound === rootDroppableId) return;
6926
+ const [componentId, slotId] = zoneCompound.split(":");
6927
+ const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
6928
+ const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
6929
+ return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
6930
+ });
6841
6931
  const contentIds = useAppStore(
6842
6932
  useShallow6(
6843
6933
  (s) => {
@@ -6846,15 +6936,15 @@ var LayerTree = ({
6846
6936
  }
6847
6937
  )
6848
6938
  );
6849
- return /* @__PURE__ */ jsxs14(Fragment10, { children: [
6850
- label && /* @__PURE__ */ jsxs14("div", { className: getClassName22("zoneTitle"), children: [
6851
- /* @__PURE__ */ jsx32("div", { className: getClassName22("zoneIcon"), children: /* @__PURE__ */ jsx32(Layers, { size: "16" }) }),
6939
+ return /* @__PURE__ */ jsxs15(Fragment10, { children: [
6940
+ label && /* @__PURE__ */ jsxs15("div", { className: getClassName23("zoneTitle"), children: [
6941
+ /* @__PURE__ */ jsx33("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ jsx33(Layers, { size: "16" }) }),
6852
6942
  label
6853
6943
  ] }),
6854
- /* @__PURE__ */ jsxs14("ul", { className: getClassName22(), children: [
6855
- contentIds.length === 0 && /* @__PURE__ */ jsx32("div", { className: getClassName22("helper"), children: "No items" }),
6944
+ /* @__PURE__ */ jsxs15("ul", { className: getClassName23(), children: [
6945
+ contentIds.length === 0 && /* @__PURE__ */ jsx33("div", { className: getClassName23("helper"), children: "No items" }),
6856
6946
  contentIds.map((itemId, i) => {
6857
- return /* @__PURE__ */ jsx32(
6947
+ return /* @__PURE__ */ jsx33(
6858
6948
  Layer,
6859
6949
  {
6860
6950
  index: i,
@@ -6869,7 +6959,7 @@ var LayerTree = ({
6869
6959
  };
6870
6960
 
6871
6961
  // components/Puck/components/Outline/index.tsx
6872
- import { useMemo as useMemo15 } from "react";
6962
+ import { useMemo as useMemo16 } from "react";
6873
6963
 
6874
6964
  // lib/data/find-zones-for-area.ts
6875
6965
  init_react_import();
@@ -6881,14 +6971,14 @@ var findZonesForArea = (state, area) => {
6881
6971
 
6882
6972
  // components/Puck/components/Outline/index.tsx
6883
6973
  import { useShallow as useShallow7 } from "zustand/react/shallow";
6884
- import { jsx as jsx33 } from "react/jsx-runtime";
6974
+ import { jsx as jsx34 } from "react/jsx-runtime";
6885
6975
  var Outline = () => {
6886
6976
  const outlineOverride = useAppStore((s) => s.overrides.outline);
6887
6977
  const rootZones = useAppStore(
6888
6978
  useShallow7((s) => findZonesForArea(s.state, "root"))
6889
6979
  );
6890
- const Wrapper = useMemo15(() => outlineOverride || "div", [outlineOverride]);
6891
- return /* @__PURE__ */ jsx33(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx33(
6980
+ const Wrapper = useMemo16(() => outlineOverride || "div", [outlineOverride]);
6981
+ return /* @__PURE__ */ jsx34(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx34(
6892
6982
  LayerTree,
6893
6983
  {
6894
6984
  label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
@@ -6898,563 +6988,55 @@ var Outline = () => {
6898
6988
  )) });
6899
6989
  };
6900
6990
 
6901
- // lib/use-loaded-overrides.ts
6991
+ // components/Puck/components/Canvas/index.tsx
6902
6992
  init_react_import();
6903
- import { useMemo as useMemo16 } from "react";
6904
6993
 
6905
- // lib/load-overrides.ts
6994
+ // ../../node_modules/css-box-model/dist/css-box-model.esm.js
6906
6995
  init_react_import();
6907
- var loadOverrides = ({
6908
- overrides,
6909
- plugins
6910
- }) => {
6911
- const collected = __spreadValues({}, overrides);
6912
- plugins == null ? void 0 : plugins.forEach((plugin) => {
6913
- if (!plugin.overrides) return;
6914
- Object.keys(plugin.overrides).forEach((_overridesType) => {
6915
- const overridesType = _overridesType;
6916
- if (overridesType === "fieldTypes") {
6917
- const fieldTypes = plugin.overrides.fieldTypes;
6918
- Object.keys(fieldTypes).forEach((fieldType) => {
6919
- collected.fieldTypes = collected.fieldTypes || {};
6920
- const childNode2 = collected.fieldTypes[fieldType];
6921
- const Comp2 = (props) => fieldTypes[fieldType](__spreadProps(__spreadValues({}, props), {
6922
- children: childNode2 ? childNode2(props) : props.children
6923
- }));
6924
- collected.fieldTypes[fieldType] = Comp2;
6925
- });
6926
- return;
6927
- }
6928
- const childNode = collected[overridesType];
6929
- const Comp = (props) => plugin.overrides[overridesType](__spreadProps(__spreadValues({}, props), {
6930
- children: childNode ? childNode(props) : props.children
6931
- }));
6932
- collected[overridesType] = Comp;
6933
- });
6934
- });
6935
- return collected;
6936
- };
6937
-
6938
- // lib/use-loaded-overrides.ts
6939
- var useLoadedOverrides = ({
6940
- overrides,
6941
- plugins
6942
- }) => {
6943
- return useMemo16(() => {
6944
- return loadOverrides({ overrides, plugins });
6945
- }, [plugins, overrides]);
6946
- };
6947
6996
 
6948
- // lib/use-puck.ts
6997
+ // ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
6949
6998
  init_react_import();
6950
- import { createContext as createContext6, useContext as useContext11, useEffect as useEffect21, useState as useState18 } from "react";
6951
- import { createStore as createStore4, useStore as useStore3 } from "zustand";
6952
- var generateUsePuck = (store) => {
6953
- const history = {
6954
- back: store.history.back,
6955
- forward: store.history.forward,
6956
- setHistories: store.history.setHistories,
6957
- setHistoryIndex: store.history.setHistoryIndex,
6958
- hasPast: store.history.hasPast(),
6959
- hasFuture: store.history.hasFuture(),
6960
- histories: store.history.histories,
6961
- index: store.history.index
6962
- };
6963
- const storeData = {
6964
- appState: makeStatePublic(store.state),
6965
- config: store.config,
6966
- dispatch: store.dispatch,
6967
- getPermissions: store.permissions.getPermissions,
6968
- refreshPermissions: store.permissions.refreshPermissions,
6969
- history,
6970
- selectedItem: store.selectedItem || null,
6971
- getItemBySelector: (selector) => getItem(selector, store.state),
6972
- getItemById: (id) => store.state.indexes.nodes[id].data,
6973
- getSelectorForId: (id) => {
6974
- const node = store.state.indexes.nodes[id];
6975
- if (!node) return;
6976
- const zoneCompound = `${node.parentId}:${node.zone}`;
6977
- const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
6978
- return { zone: zoneCompound, index };
6999
+ var isProduction = process.env.NODE_ENV === "production";
7000
+ var prefix = "Invariant failed";
7001
+ function invariant(condition, message) {
7002
+ if (condition) {
7003
+ return;
7004
+ }
7005
+ if (isProduction) {
7006
+ throw new Error(prefix);
7007
+ }
7008
+ var provided = typeof message === "function" ? message() : message;
7009
+ var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
7010
+ throw new Error(value);
7011
+ }
7012
+
7013
+ // ../../node_modules/css-box-model/dist/css-box-model.esm.js
7014
+ var getRect = function getRect2(_ref) {
7015
+ var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
7016
+ var width = right - left;
7017
+ var height = bottom - top;
7018
+ var rect = {
7019
+ top,
7020
+ right,
7021
+ bottom,
7022
+ left,
7023
+ width,
7024
+ height,
7025
+ x: left,
7026
+ y: top,
7027
+ center: {
7028
+ x: (right + left) / 2,
7029
+ y: (bottom + top) / 2
6979
7030
  }
6980
7031
  };
6981
- const get = () => storeData;
6982
- return __spreadProps(__spreadValues({}, storeData), { get });
7032
+ return rect;
6983
7033
  };
6984
- var UsePuckStoreContext = createContext6(
6985
- null
6986
- );
6987
- var convertToPickedStore = (store) => {
7034
+ var expand = function expand2(target, expandBy) {
6988
7035
  return {
6989
- state: store.state,
6990
- config: store.config,
6991
- dispatch: store.dispatch,
6992
- permissions: store.permissions,
6993
- history: store.history,
6994
- selectedItem: store.selectedItem
6995
- };
6996
- };
6997
- var useRegisterUsePuckStore = (appStore) => {
6998
- const [usePuckStore] = useState18(
6999
- () => createStore4(
7000
- () => generateUsePuck(convertToPickedStore(appStore.getState()))
7001
- )
7002
- );
7003
- useEffect21(() => {
7004
- return appStore.subscribe(
7005
- (store) => convertToPickedStore(store),
7006
- (pickedStore) => {
7007
- usePuckStore.setState(generateUsePuck(pickedStore));
7008
- }
7009
- );
7010
- }, []);
7011
- return usePuckStore;
7012
- };
7013
- function createUsePuck() {
7014
- return function usePuck2(selector) {
7015
- const usePuckApi = useContext11(UsePuckStoreContext);
7016
- if (!usePuckApi) {
7017
- throw new Error("usePuck must be used inside <Puck>.");
7018
- }
7019
- const result = useStore3(
7020
- usePuckApi,
7021
- selector != null ? selector : (s) => s
7022
- );
7023
- return result;
7024
- };
7025
- }
7026
- function usePuck() {
7027
- useEffect21(() => {
7028
- console.warn(
7029
- "You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
7030
- );
7031
- }, []);
7032
- return createUsePuck()((s) => s);
7033
- }
7034
- function useGetPuck() {
7035
- const usePuckApi = useContext11(UsePuckStoreContext);
7036
- if (!usePuckApi) {
7037
- throw new Error("usePuckGet must be used inside <Puck>.");
7038
- }
7039
- return usePuckApi.getState;
7040
- }
7041
-
7042
- // components/Puck/index.tsx
7043
- import fdeq from "fast-deep-equal";
7044
-
7045
- // components/Puck/components/Layout/index.tsx
7046
- init_react_import();
7047
- import { useEffect as useEffect25, useMemo as useMemo21, useState as useState23 } from "react";
7048
-
7049
- // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Layout/styles.module.css#css-module
7050
- init_react_import();
7051
- var styles_module_default17 = { "Puck": "_Puck_n6ob8_19", "Puck-portal": "_Puck-portal_n6ob8_31", "PuckLayout-inner": "_PuckLayout-inner_n6ob8_36", "PuckLayout--mounted": "_PuckLayout--mounted_n6ob8_48", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_n6ob8_53", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_n6ob8_61", "PuckLayout-mounted": "_PuckLayout-mounted_n6ob8_77", "PuckLayout": "_PuckLayout_n6ob8_36", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_n6ob8_118", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_n6ob8_128", "PuckLayout-nav": "_PuckLayout-nav_n6ob8_137" };
7052
-
7053
- // lib/use-inject-css.ts
7054
- init_react_import();
7055
- import { useEffect as useEffect22, useState as useState19 } from "react";
7056
- var styles = ``;
7057
- var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7058
- const [el, setEl] = useState19();
7059
- useEffect22(() => {
7060
- setEl(document.createElement("style"));
7061
- }, []);
7062
- useEffect22(() => {
7063
- var _a;
7064
- if (!el || typeof window === "undefined") {
7065
- return;
7066
- }
7067
- el.innerHTML = initialStyles;
7068
- if (iframeEnabled) {
7069
- const frame = getFrame();
7070
- (_a = frame == null ? void 0 : frame.head) == null ? void 0 : _a.appendChild(el);
7071
- }
7072
- document.head.appendChild(el);
7073
- }, [iframeEnabled, el]);
7074
- return el;
7075
- };
7076
- var useInjectGlobalCss = (iframeEnabled) => {
7077
- return useInjectStyleSheet(styles, iframeEnabled);
7078
- };
7079
-
7080
- // components/DefaultOverride/index.tsx
7081
- init_react_import();
7082
- import { Fragment as Fragment11, jsx as jsx34 } from "react/jsx-runtime";
7083
- var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx34(Fragment11, { children });
7084
-
7085
- // lib/use-preview-mode-hotkeys.ts
7086
- init_react_import();
7087
- import { useCallback as useCallback15 } from "react";
7088
- var usePreviewModeHotkeys = () => {
7089
- const appStore = useAppStoreApi();
7090
- const toggleInteractive = useCallback15(() => {
7091
- const dispatch = appStore.getState().dispatch;
7092
- dispatch({
7093
- type: "setUi",
7094
- ui: (ui) => ({
7095
- previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
7096
- })
7097
- });
7098
- }, [appStore]);
7099
- useHotkey({ meta: true, i: true }, toggleInteractive);
7100
- useHotkey({ ctrl: true, i: true }, toggleInteractive);
7101
- };
7102
-
7103
- // components/Puck/components/Header/index.tsx
7104
- init_react_import();
7105
- import { memo as memo3, useCallback as useCallback16, useMemo as useMemo17, useState as useState20 } from "react";
7106
-
7107
- // components/MenuBar/index.tsx
7108
- init_react_import();
7109
-
7110
- // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
7111
- init_react_import();
7112
- var styles_module_default18 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
7113
-
7114
- // components/MenuBar/index.tsx
7115
- import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs15 } from "react/jsx-runtime";
7116
- var getClassName23 = get_class_name_factory_default("MenuBar", styles_module_default18);
7117
- function MenuBar({
7118
- menuOpen = false,
7119
- renderHeaderActions,
7120
- setMenuOpen
7121
- }) {
7122
- const back = useAppStore((s) => s.history.back);
7123
- const forward = useAppStore((s) => s.history.forward);
7124
- const hasFuture = useAppStore((s) => s.history.hasFuture());
7125
- const hasPast = useAppStore((s) => s.history.hasPast());
7126
- return /* @__PURE__ */ jsx35(
7127
- "div",
7128
- {
7129
- className: getClassName23({ menuOpen }),
7130
- onClick: (event) => {
7131
- var _a;
7132
- const element = event.target;
7133
- if (window.matchMedia("(min-width: 638px)").matches) {
7134
- return;
7135
- }
7136
- if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
7137
- setMenuOpen(false);
7138
- }
7139
- },
7140
- children: /* @__PURE__ */ jsxs15("div", { className: getClassName23("inner"), children: [
7141
- /* @__PURE__ */ jsxs15("div", { className: getClassName23("history"), children: [
7142
- /* @__PURE__ */ jsx35(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx35(Undo2, { size: 21 }) }),
7143
- /* @__PURE__ */ jsx35(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx35(Redo2, { size: 21 }) })
7144
- ] }),
7145
- /* @__PURE__ */ jsx35(Fragment12, { children: renderHeaderActions && renderHeaderActions() })
7146
- ] })
7147
- }
7148
- );
7149
- }
7150
-
7151
- // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
7152
- init_react_import();
7153
- var styles_module_default19 = { "PuckHeader": "_PuckHeader_dlc6d_1", "PuckHeader-inner": "_PuckHeader-inner_dlc6d_16", "PuckHeader-toggle": "_PuckHeader-toggle_dlc6d_33", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_dlc6d_40", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_dlc6d_40", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_dlc6d_41", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_dlc6d_41", "PuckHeader-title": "_PuckHeader-title_dlc6d_45", "PuckHeader-path": "_PuckHeader-path_dlc6d_49", "PuckHeader-tools": "_PuckHeader-tools_dlc6d_56", "PuckHeader-menuButton": "_PuckHeader-menuButton_dlc6d_62", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_dlc6d_67" };
7154
-
7155
- // components/Puck/components/Header/index.tsx
7156
- import { Fragment as Fragment13, jsx as jsx36, jsxs as jsxs16 } from "react/jsx-runtime";
7157
- var getClassName24 = get_class_name_factory_default("PuckHeader", styles_module_default19);
7158
- var HeaderInner = () => {
7159
- const {
7160
- onPublish,
7161
- renderHeader,
7162
- renderHeaderActions,
7163
- headerTitle,
7164
- headerPath,
7165
- iframe: _iframe
7166
- } = usePropsContext();
7167
- const dispatch = useAppStore((s) => s.dispatch);
7168
- const appStore = useAppStoreApi();
7169
- const defaultHeaderRender = useMemo17(() => {
7170
- if (renderHeader) {
7171
- console.warn(
7172
- "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
7173
- );
7174
- const RenderHeader = (_a) => {
7175
- var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
7176
- const Comp = renderHeader;
7177
- const appState = useAppStore((s) => s.state);
7178
- return /* @__PURE__ */ jsx36(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7179
- };
7180
- return RenderHeader;
7181
- }
7182
- return DefaultOverride;
7183
- }, [renderHeader]);
7184
- const defaultHeaderActionsRender = useMemo17(() => {
7185
- if (renderHeaderActions) {
7186
- console.warn(
7187
- "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
7188
- );
7189
- const RenderHeader = (props) => {
7190
- const Comp = renderHeaderActions;
7191
- const appState = useAppStore((s) => s.state);
7192
- return /* @__PURE__ */ jsx36(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7193
- };
7194
- return RenderHeader;
7195
- }
7196
- return DefaultOverride;
7197
- }, [renderHeader]);
7198
- const CustomHeader = useAppStore(
7199
- (s) => s.overrides.header || defaultHeaderRender
7200
- );
7201
- const CustomHeaderActions = useAppStore(
7202
- (s) => s.overrides.headerActions || defaultHeaderActionsRender
7203
- );
7204
- const [menuOpen, setMenuOpen] = useState20(false);
7205
- const rootTitle = useAppStore((s) => {
7206
- var _a, _b;
7207
- const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
7208
- return (_b = rootData.props.title) != null ? _b : "";
7209
- });
7210
- const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
7211
- const rightSideBarVisible = useAppStore(
7212
- (s) => s.state.ui.rightSideBarVisible
7213
- );
7214
- const toggleSidebars = useCallback16(
7215
- (sidebar) => {
7216
- const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7217
- const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
7218
- const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
7219
- dispatch({
7220
- type: "setUi",
7221
- ui: __spreadValues({
7222
- [`${sidebar}SideBarVisible`]: !sideBarVisible
7223
- }, !widerViewport ? { [oppositeSideBar]: false } : {})
7224
- });
7225
- },
7226
- [dispatch, leftSideBarVisible, rightSideBarVisible]
7227
- );
7228
- return /* @__PURE__ */ jsx36(
7229
- CustomHeader,
7230
- {
7231
- actions: /* @__PURE__ */ jsx36(Fragment13, { children: /* @__PURE__ */ jsx36(CustomHeaderActions, { children: /* @__PURE__ */ jsx36(
7232
- Button,
7233
- {
7234
- onClick: () => {
7235
- const data = appStore.getState().state.data;
7236
- onPublish && onPublish(data);
7237
- },
7238
- icon: /* @__PURE__ */ jsx36(Globe, { size: "14px" }),
7239
- children: "Publish"
7240
- }
7241
- ) }) }),
7242
- children: /* @__PURE__ */ jsx36(
7243
- "header",
7244
- {
7245
- className: getClassName24({ leftSideBarVisible, rightSideBarVisible }),
7246
- children: /* @__PURE__ */ jsxs16("div", { className: getClassName24("inner"), children: [
7247
- /* @__PURE__ */ jsxs16("div", { className: getClassName24("toggle"), children: [
7248
- /* @__PURE__ */ jsx36("div", { className: getClassName24("leftSideBarToggle"), children: /* @__PURE__ */ jsx36(
7249
- IconButton,
7250
- {
7251
- onClick: () => {
7252
- toggleSidebars("left");
7253
- },
7254
- title: "Toggle left sidebar",
7255
- children: /* @__PURE__ */ jsx36(PanelLeft, { focusable: "false" })
7256
- }
7257
- ) }),
7258
- /* @__PURE__ */ jsx36("div", { className: getClassName24("rightSideBarToggle"), children: /* @__PURE__ */ jsx36(
7259
- IconButton,
7260
- {
7261
- onClick: () => {
7262
- toggleSidebars("right");
7263
- },
7264
- title: "Toggle right sidebar",
7265
- children: /* @__PURE__ */ jsx36(PanelRight, { focusable: "false" })
7266
- }
7267
- ) })
7268
- ] }),
7269
- /* @__PURE__ */ jsx36("div", { className: getClassName24("title"), children: /* @__PURE__ */ jsxs16(Heading, { rank: "2", size: "xs", children: [
7270
- headerTitle || rootTitle || "Page",
7271
- headerPath && /* @__PURE__ */ jsxs16(Fragment13, { children: [
7272
- " ",
7273
- /* @__PURE__ */ jsx36("code", { className: getClassName24("path"), children: headerPath })
7274
- ] })
7275
- ] }) }),
7276
- /* @__PURE__ */ jsxs16("div", { className: getClassName24("tools"), children: [
7277
- /* @__PURE__ */ jsx36("div", { className: getClassName24("menuButton"), children: /* @__PURE__ */ jsx36(
7278
- IconButton,
7279
- {
7280
- onClick: () => {
7281
- return setMenuOpen(!menuOpen);
7282
- },
7283
- title: "Toggle menu bar",
7284
- children: menuOpen ? /* @__PURE__ */ jsx36(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx36(ChevronDown, { focusable: "false" })
7285
- }
7286
- ) }),
7287
- /* @__PURE__ */ jsx36(
7288
- MenuBar,
7289
- {
7290
- dispatch,
7291
- onPublish,
7292
- menuOpen,
7293
- renderHeaderActions: () => /* @__PURE__ */ jsx36(CustomHeaderActions, { children: /* @__PURE__ */ jsx36(
7294
- Button,
7295
- {
7296
- onClick: () => {
7297
- const data = appStore.getState().state.data;
7298
- onPublish && onPublish(data);
7299
- },
7300
- icon: /* @__PURE__ */ jsx36(Globe, { size: "14px" }),
7301
- children: "Publish"
7302
- }
7303
- ) }),
7304
- setMenuOpen
7305
- }
7306
- )
7307
- ] })
7308
- ] })
7309
- }
7310
- )
7311
- }
7312
- );
7313
- };
7314
- var Header = memo3(HeaderInner);
7315
-
7316
- // components/SidebarSection/index.tsx
7317
- init_react_import();
7318
-
7319
- // css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
7320
- init_react_import();
7321
- var styles_module_default20 = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
7322
-
7323
- // lib/use-breadcrumbs.ts
7324
- init_react_import();
7325
- import { useMemo as useMemo18 } from "react";
7326
- var useBreadcrumbs = (renderCount) => {
7327
- const selectedId = useAppStore((s) => {
7328
- var _a;
7329
- return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
7330
- });
7331
- const config = useAppStore((s) => s.config);
7332
- const path = useAppStore((s) => {
7333
- var _a;
7334
- return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
7335
- });
7336
- const appStore = useAppStoreApi();
7337
- return useMemo18(() => {
7338
- const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
7339
- var _a, _b, _c;
7340
- const [componentId] = zoneCompound.split(":");
7341
- if (componentId === "root") {
7342
- return {
7343
- label: "Page",
7344
- selector: null
7345
- };
7346
- }
7347
- const node = appStore.getState().state.indexes.nodes[componentId];
7348
- const parentId = node.path[node.path.length - 1];
7349
- const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
7350
- const index = contentIds.indexOf(componentId);
7351
- const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
7352
- return {
7353
- label,
7354
- selector: node ? {
7355
- index,
7356
- zone: node.path[node.path.length - 1]
7357
- } : null
7358
- };
7359
- })) || [];
7360
- if (renderCount) {
7361
- return breadcrumbs.slice(breadcrumbs.length - renderCount);
7362
- }
7363
- return breadcrumbs;
7364
- }, [path, renderCount]);
7365
- };
7366
-
7367
- // components/SidebarSection/index.tsx
7368
- import { jsx as jsx37, jsxs as jsxs17 } from "react/jsx-runtime";
7369
- var getClassName25 = get_class_name_factory_default("SidebarSection", styles_module_default20);
7370
- var SidebarSection = ({
7371
- children,
7372
- title,
7373
- background,
7374
- showBreadcrumbs,
7375
- noBorderTop,
7376
- noPadding,
7377
- isLoading
7378
- }) => {
7379
- const setUi = useAppStore((s) => s.setUi);
7380
- const breadcrumbs = useBreadcrumbs(1);
7381
- return /* @__PURE__ */ jsxs17(
7382
- "div",
7383
- {
7384
- className: getClassName25({ noBorderTop, noPadding }),
7385
- style: { background },
7386
- children: [
7387
- /* @__PURE__ */ jsx37("div", { className: getClassName25("title"), children: /* @__PURE__ */ jsxs17("div", { className: getClassName25("breadcrumbs"), children: [
7388
- showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs17("div", { className: getClassName25("breadcrumb"), children: [
7389
- /* @__PURE__ */ jsx37(
7390
- "button",
7391
- {
7392
- type: "button",
7393
- className: getClassName25("breadcrumbLabel"),
7394
- onClick: () => setUi({ itemSelector: breadcrumb.selector }),
7395
- children: breadcrumb.label
7396
- }
7397
- ),
7398
- /* @__PURE__ */ jsx37(ChevronRight, { size: 16 })
7399
- ] }, i)) : null,
7400
- /* @__PURE__ */ jsx37("div", { className: getClassName25("heading"), children: /* @__PURE__ */ jsx37(Heading, { rank: "2", size: "xs", children: title }) })
7401
- ] }) }),
7402
- /* @__PURE__ */ jsx37("div", { className: getClassName25("content"), children }),
7403
- isLoading && /* @__PURE__ */ jsx37("div", { className: getClassName25("loadingOverlay"), children: /* @__PURE__ */ jsx37(Loader, { size: 32 }) })
7404
- ]
7405
- }
7406
- );
7407
- };
7408
-
7409
- // components/Puck/components/Canvas/index.tsx
7410
- init_react_import();
7411
-
7412
- // ../../node_modules/css-box-model/dist/css-box-model.esm.js
7413
- init_react_import();
7414
-
7415
- // ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
7416
- init_react_import();
7417
- var isProduction = process.env.NODE_ENV === "production";
7418
- var prefix = "Invariant failed";
7419
- function invariant(condition, message) {
7420
- if (condition) {
7421
- return;
7422
- }
7423
- if (isProduction) {
7424
- throw new Error(prefix);
7425
- }
7426
- var provided = typeof message === "function" ? message() : message;
7427
- var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
7428
- throw new Error(value);
7429
- }
7430
-
7431
- // ../../node_modules/css-box-model/dist/css-box-model.esm.js
7432
- var getRect = function getRect2(_ref) {
7433
- var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
7434
- var width = right - left;
7435
- var height = bottom - top;
7436
- var rect = {
7437
- top,
7438
- right,
7439
- bottom,
7440
- left,
7441
- width,
7442
- height,
7443
- x: left,
7444
- y: top,
7445
- center: {
7446
- x: (right + left) / 2,
7447
- y: (bottom + top) / 2
7448
- }
7449
- };
7450
- return rect;
7451
- };
7452
- var expand = function expand2(target, expandBy) {
7453
- return {
7454
- top: target.top - expandBy.top,
7455
- left: target.left - expandBy.left,
7456
- bottom: target.bottom + expandBy.bottom,
7457
- right: target.right + expandBy.right
7036
+ top: target.top - expandBy.top,
7037
+ left: target.left - expandBy.left,
7038
+ bottom: target.bottom + expandBy.bottom,
7039
+ right: target.right + expandBy.right
7458
7040
  };
7459
7041
  };
7460
7042
  var shrink = function shrink2(target, shrinkBy) {
@@ -7530,30 +7112,30 @@ var getBox = function getBox2(el) {
7530
7112
 
7531
7113
  // components/Puck/components/Canvas/index.tsx
7532
7114
  import {
7533
- useCallback as useCallback17,
7534
- useEffect as useEffect24,
7535
- useMemo as useMemo20,
7115
+ useCallback as useCallback15,
7116
+ useEffect as useEffect22,
7117
+ useMemo as useMemo18,
7536
7118
  useRef as useRef7,
7537
- useState as useState22
7119
+ useState as useState19
7538
7120
  } from "react";
7539
7121
 
7540
7122
  // components/ViewportControls/index.tsx
7541
7123
  init_react_import();
7542
- import { useEffect as useEffect23, useMemo as useMemo19, useState as useState21 } from "react";
7124
+ import { useEffect as useEffect21, useMemo as useMemo17, useState as useState18 } from "react";
7543
7125
 
7544
7126
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7545
7127
  init_react_import();
7546
- var styles_module_default21 = { "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" };
7128
+ 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" };
7547
7129
 
7548
7130
  // components/ViewportControls/index.tsx
7549
- import { jsx as jsx38, jsxs as jsxs18 } from "react/jsx-runtime";
7131
+ import { jsx as jsx35, jsxs as jsxs16 } from "react/jsx-runtime";
7550
7132
  var icons = {
7551
- Smartphone: /* @__PURE__ */ jsx38(Smartphone, { size: 16 }),
7552
- Tablet: /* @__PURE__ */ jsx38(Tablet, { size: 16 }),
7553
- Monitor: /* @__PURE__ */ jsx38(Monitor, { size: 16 })
7133
+ Smartphone: /* @__PURE__ */ jsx35(Smartphone, { size: 16 }),
7134
+ Tablet: /* @__PURE__ */ jsx35(Tablet, { size: 16 }),
7135
+ Monitor: /* @__PURE__ */ jsx35(Monitor, { size: 16 })
7554
7136
  };
7555
- var getClassName26 = get_class_name_factory_default("ViewportControls", styles_module_default21);
7556
- var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default21);
7137
+ var getClassName24 = get_class_name_factory_default("ViewportControls", styles_module_default19);
7138
+ var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default19);
7557
7139
  var ViewportButton = ({
7558
7140
  children,
7559
7141
  height = "auto",
@@ -7562,20 +7144,21 @@ var ViewportButton = ({
7562
7144
  onClick
7563
7145
  }) => {
7564
7146
  const viewports = useAppStore((s) => s.state.ui.viewports);
7565
- const [isActive, setIsActive] = useState21(false);
7566
- useEffect23(() => {
7147
+ const [isActive, setIsActive] = useState18(false);
7148
+ useEffect21(() => {
7567
7149
  setIsActive(width === viewports.current.width);
7568
7150
  }, [width, viewports.current.width]);
7569
- return /* @__PURE__ */ jsx38("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx38(
7151
+ return /* @__PURE__ */ jsx35("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx35(
7570
7152
  IconButton,
7571
7153
  {
7154
+ type: "button",
7572
7155
  title,
7573
7156
  disabled: isActive,
7574
7157
  onClick: (e) => {
7575
7158
  e.stopPropagation();
7576
7159
  onClick({ width, height });
7577
7160
  },
7578
- children: /* @__PURE__ */ jsx38("span", { className: getClassNameButton("inner"), children })
7161
+ children: /* @__PURE__ */ jsx35("span", { className: getClassNameButton("inner"), children })
7579
7162
  }
7580
7163
  ) });
7581
7164
  };
@@ -7599,7 +7182,7 @@ var ViewportControls = ({
7599
7182
  const defaultsContainAutoZoom = defaultZoomOptions.find(
7600
7183
  (option) => option.value === autoZoom
7601
7184
  );
7602
- const zoomOptions = useMemo19(
7185
+ const zoomOptions = useMemo17(
7603
7186
  () => [
7604
7187
  ...defaultZoomOptions,
7605
7188
  ...defaultsContainAutoZoom ? [] : [
@@ -7611,8 +7194,8 @@ var ViewportControls = ({
7611
7194
  ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
7612
7195
  [autoZoom]
7613
7196
  );
7614
- return /* @__PURE__ */ jsxs18("div", { className: getClassName26(), children: [
7615
- viewports.map((viewport, i) => /* @__PURE__ */ jsx38(
7197
+ return /* @__PURE__ */ jsxs16("div", { className: getClassName24(), children: [
7198
+ viewports.map((viewport, i) => /* @__PURE__ */ jsx35(
7616
7199
  ViewportButton,
7617
7200
  {
7618
7201
  height: viewport.height,
@@ -7623,10 +7206,11 @@ var ViewportControls = ({
7623
7206
  },
7624
7207
  i
7625
7208
  )),
7626
- /* @__PURE__ */ jsx38("div", { className: getClassName26("divider") }),
7627
- /* @__PURE__ */ jsx38(
7209
+ /* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
7210
+ /* @__PURE__ */ jsx35(
7628
7211
  IconButton,
7629
7212
  {
7213
+ type: "button",
7630
7214
  title: "Zoom viewport out",
7631
7215
  disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
7632
7216
  onClick: (e) => {
@@ -7638,12 +7222,13 @@ var ViewportControls = ({
7638
7222
  )].value
7639
7223
  );
7640
7224
  },
7641
- children: /* @__PURE__ */ jsx38(ZoomOut, { size: 16 })
7225
+ children: /* @__PURE__ */ jsx35(ZoomOut, { size: 16 })
7642
7226
  }
7643
7227
  ),
7644
- /* @__PURE__ */ jsx38(
7228
+ /* @__PURE__ */ jsx35(
7645
7229
  IconButton,
7646
7230
  {
7231
+ type: "button",
7647
7232
  title: "Zoom viewport in",
7648
7233
  disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
7649
7234
  onClick: (e) => {
@@ -7655,19 +7240,19 @@ var ViewportControls = ({
7655
7240
  )].value
7656
7241
  );
7657
7242
  },
7658
- children: /* @__PURE__ */ jsx38(ZoomIn, { size: 16 })
7243
+ children: /* @__PURE__ */ jsx35(ZoomIn, { size: 16 })
7659
7244
  }
7660
7245
  ),
7661
- /* @__PURE__ */ jsx38("div", { className: getClassName26("divider") }),
7662
- /* @__PURE__ */ jsx38(
7246
+ /* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
7247
+ /* @__PURE__ */ jsx35(
7663
7248
  "select",
7664
7249
  {
7665
- className: getClassName26("zoomSelect"),
7250
+ className: getClassName24("zoomSelect"),
7666
7251
  value: zoom.toString(),
7667
7252
  onChange: (e) => {
7668
7253
  onZoom(parseFloat(e.currentTarget.value));
7669
7254
  },
7670
- children: zoomOptions.map((option) => /* @__PURE__ */ jsx38(
7255
+ children: zoomOptions.map((option) => /* @__PURE__ */ jsx35(
7671
7256
  "option",
7672
7257
  {
7673
7258
  value: option.value,
@@ -7682,7 +7267,7 @@ var ViewportControls = ({
7682
7267
 
7683
7268
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
7684
7269
  init_react_import();
7685
- var styles_module_default22 = { "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" };
7270
+ 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" };
7686
7271
 
7687
7272
  // lib/get-zoom-config.ts
7688
7273
  init_react_import();
@@ -7716,8 +7301,8 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
7716
7301
 
7717
7302
  // components/Puck/components/Canvas/index.tsx
7718
7303
  import { useShallow as useShallow8 } from "zustand/react/shallow";
7719
- import { Fragment as Fragment14, jsx as jsx39, jsxs as jsxs19 } from "react/jsx-runtime";
7720
- var getClassName27 = get_class_name_factory_default("PuckCanvas", styles_module_default22);
7304
+ import { Fragment as Fragment11, jsx as jsx36, jsxs as jsxs17 } from "react/jsx-runtime";
7305
+ var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
7721
7306
  var ZOOM_ON_CHANGE = true;
7722
7307
  var Canvas = () => {
7723
7308
  const {
@@ -7747,344 +7332,584 @@ var Canvas = () => {
7747
7332
  }))
7748
7333
  );
7749
7334
  const frameRef = useRef7(null);
7750
- const [showTransition, setShowTransition] = useState22(false);
7751
- const defaultRender = useMemo20(() => {
7752
- const PuckDefault = ({ children }) => /* @__PURE__ */ jsx39(Fragment14, { children });
7335
+ const [showTransition, setShowTransition] = useState19(false);
7336
+ const defaultRender = useMemo18(() => {
7337
+ const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment11, { children });
7753
7338
  return PuckDefault;
7754
7339
  }, []);
7755
- const CustomPreview = useMemo20(
7340
+ const CustomPreview = useMemo18(
7756
7341
  () => overrides.preview || defaultRender,
7757
7342
  [overrides]
7758
7343
  );
7759
- const getFrameDimensions = useCallback17(() => {
7344
+ const getFrameDimensions = useCallback15(() => {
7760
7345
  if (frameRef.current) {
7761
7346
  const frame = frameRef.current;
7762
7347
  const box = getBox(frame);
7763
7348
  return { width: box.contentBox.width, height: box.contentBox.height };
7764
7349
  }
7765
- return { width: 0, height: 0 };
7766
- }, [frameRef]);
7767
- const resetAutoZoom = useCallback17(
7768
- (newViewports = viewports) => {
7769
- if (frameRef.current) {
7770
- setZoomConfig(
7771
- getZoomConfig(
7772
- newViewports == null ? void 0 : newViewports.current,
7773
- frameRef.current,
7774
- zoomConfig.zoom
7775
- )
7776
- );
7777
- }
7778
- },
7779
- [frameRef, zoomConfig, viewports]
7350
+ return { width: 0, height: 0 };
7351
+ }, [frameRef]);
7352
+ const resetAutoZoom = useCallback15(
7353
+ (newViewports = viewports) => {
7354
+ if (frameRef.current) {
7355
+ setZoomConfig(
7356
+ getZoomConfig(
7357
+ newViewports == null ? void 0 : newViewports.current,
7358
+ frameRef.current,
7359
+ zoomConfig.zoom
7360
+ )
7361
+ );
7362
+ }
7363
+ },
7364
+ [frameRef, zoomConfig, viewports]
7365
+ );
7366
+ useEffect22(() => {
7367
+ setShowTransition(false);
7368
+ resetAutoZoom(viewports);
7369
+ }, [frameRef, leftSideBarVisible, rightSideBarVisible]);
7370
+ useEffect22(() => {
7371
+ const { height: frameHeight } = getFrameDimensions();
7372
+ if (viewports.current.height === "auto") {
7373
+ setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
7374
+ rootHeight: frameHeight / zoomConfig.zoom
7375
+ }));
7376
+ }
7377
+ }, [zoomConfig.zoom]);
7378
+ useEffect22(() => {
7379
+ if (ZOOM_ON_CHANGE) {
7380
+ setShowTransition(true);
7381
+ resetAutoZoom(viewports);
7382
+ }
7383
+ }, [viewports.current.width]);
7384
+ useEffect22(() => {
7385
+ const cb = () => {
7386
+ setShowTransition(false);
7387
+ resetAutoZoom();
7388
+ };
7389
+ window.addEventListener("resize", cb);
7390
+ return () => {
7391
+ window.removeEventListener("resize", cb);
7392
+ };
7393
+ }, []);
7394
+ const [showLoader, setShowLoader] = useState19(false);
7395
+ useEffect22(() => {
7396
+ setTimeout(() => {
7397
+ setShowLoader(true);
7398
+ }, 500);
7399
+ }, []);
7400
+ return /* @__PURE__ */ jsxs17(
7401
+ "div",
7402
+ {
7403
+ className: getClassName25({
7404
+ ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
7405
+ showLoader
7406
+ }),
7407
+ onClick: () => dispatch({
7408
+ type: "setUi",
7409
+ ui: { itemSelector: null },
7410
+ recordHistory: true
7411
+ }),
7412
+ children: [
7413
+ viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx36("div", { className: getClassName25("controls"), children: /* @__PURE__ */ jsx36(
7414
+ ViewportControls,
7415
+ {
7416
+ autoZoom: zoomConfig.autoZoom,
7417
+ zoom: zoomConfig.zoom,
7418
+ onViewportChange: (viewport) => {
7419
+ setShowTransition(true);
7420
+ const uiViewport = __spreadProps(__spreadValues({}, viewport), {
7421
+ height: viewport.height || "auto",
7422
+ zoom: zoomConfig.zoom
7423
+ });
7424
+ const newUi = {
7425
+ viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport }),
7426
+ itemSelector: null
7427
+ };
7428
+ setUi(newUi);
7429
+ if (ZOOM_ON_CHANGE) {
7430
+ resetAutoZoom(__spreadProps(__spreadValues({}, viewports), { current: uiViewport }));
7431
+ }
7432
+ },
7433
+ onZoom: (zoom) => {
7434
+ setShowTransition(true);
7435
+ setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
7436
+ }
7437
+ }
7438
+ ) }),
7439
+ /* @__PURE__ */ jsxs17("div", { className: getClassName25("inner"), ref: frameRef, children: [
7440
+ /* @__PURE__ */ jsx36(
7441
+ "div",
7442
+ {
7443
+ className: getClassName25("root"),
7444
+ style: {
7445
+ width: iframe.enabled ? viewports.current.width : "100%",
7446
+ height: zoomConfig.rootHeight,
7447
+ transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
7448
+ transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : "",
7449
+ overflow: iframe.enabled ? void 0 : "auto"
7450
+ },
7451
+ suppressHydrationWarning: true,
7452
+ id: "puck-canvas-root",
7453
+ onTransitionEnd: () => {
7454
+ window.dispatchEvent(
7455
+ new CustomEvent("viewportchange", {
7456
+ bubbles: true,
7457
+ cancelable: false
7458
+ })
7459
+ );
7460
+ },
7461
+ children: /* @__PURE__ */ jsx36(CustomPreview, { children: /* @__PURE__ */ jsx36(Preview2, {}) })
7462
+ }
7463
+ ),
7464
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("loader"), children: /* @__PURE__ */ jsx36(Loader, { size: 24 }) })
7465
+ ] })
7466
+ ]
7467
+ }
7468
+ );
7469
+ };
7470
+
7471
+ // lib/use-loaded-overrides.ts
7472
+ init_react_import();
7473
+ import { useMemo as useMemo19 } from "react";
7474
+
7475
+ // lib/load-overrides.ts
7476
+ init_react_import();
7477
+ var loadOverrides = ({
7478
+ overrides,
7479
+ plugins
7480
+ }) => {
7481
+ const collected = __spreadValues({}, overrides);
7482
+ plugins == null ? void 0 : plugins.forEach((plugin) => {
7483
+ Object.keys(plugin.overrides).forEach((_overridesType) => {
7484
+ const overridesType = _overridesType;
7485
+ if (overridesType === "fieldTypes") {
7486
+ const fieldTypes = plugin.overrides.fieldTypes;
7487
+ Object.keys(fieldTypes).forEach((fieldType) => {
7488
+ collected.fieldTypes = collected.fieldTypes || {};
7489
+ const childNode2 = collected.fieldTypes[fieldType];
7490
+ const Comp2 = (props) => fieldTypes[fieldType](__spreadProps(__spreadValues({}, props), {
7491
+ children: childNode2 ? childNode2(props) : props.children
7492
+ }));
7493
+ collected.fieldTypes[fieldType] = Comp2;
7494
+ });
7495
+ return;
7496
+ }
7497
+ const childNode = collected[overridesType];
7498
+ const Comp = (props) => plugin.overrides[overridesType](__spreadProps(__spreadValues({}, props), {
7499
+ children: childNode ? childNode(props) : props.children
7500
+ }));
7501
+ collected[overridesType] = Comp;
7502
+ });
7503
+ });
7504
+ return collected;
7505
+ };
7506
+
7507
+ // lib/use-loaded-overrides.ts
7508
+ var useLoadedOverrides = ({
7509
+ overrides,
7510
+ plugins
7511
+ }) => {
7512
+ return useMemo19(() => {
7513
+ return loadOverrides({ overrides, plugins });
7514
+ }, [plugins, overrides]);
7515
+ };
7516
+
7517
+ // components/DefaultOverride/index.tsx
7518
+ init_react_import();
7519
+ import { Fragment as Fragment12, jsx as jsx37 } from "react/jsx-runtime";
7520
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment12, { children });
7521
+
7522
+ // lib/use-inject-css.ts
7523
+ init_react_import();
7524
+ import { useEffect as useEffect23, useState as useState20 } from "react";
7525
+ var styles = ``;
7526
+ var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7527
+ const [el, setEl] = useState20();
7528
+ useEffect23(() => {
7529
+ setEl(document.createElement("style"));
7530
+ }, []);
7531
+ useEffect23(() => {
7532
+ var _a;
7533
+ if (!el || typeof window === "undefined") {
7534
+ return;
7535
+ }
7536
+ el.innerHTML = initialStyles;
7537
+ if (iframeEnabled) {
7538
+ const frame = getFrame();
7539
+ (_a = frame == null ? void 0 : frame.head) == null ? void 0 : _a.appendChild(el);
7540
+ }
7541
+ document.head.appendChild(el);
7542
+ }, [iframeEnabled, el]);
7543
+ return el;
7544
+ };
7545
+ var useInjectGlobalCss = (iframeEnabled) => {
7546
+ return useInjectStyleSheet(styles, iframeEnabled);
7547
+ };
7548
+
7549
+ // lib/use-preview-mode-hotkeys.ts
7550
+ init_react_import();
7551
+ import { useCallback as useCallback16 } from "react";
7552
+ var usePreviewModeHotkeys = () => {
7553
+ const appStore = useAppStoreApi();
7554
+ const toggleInteractive = useCallback16(() => {
7555
+ const dispatch = appStore.getState().dispatch;
7556
+ dispatch({
7557
+ type: "setUi",
7558
+ ui: (ui) => ({
7559
+ previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
7560
+ })
7561
+ });
7562
+ }, [appStore]);
7563
+ useHotkey({ meta: true, i: true }, toggleInteractive);
7564
+ useHotkey({ ctrl: true, i: true }, toggleInteractive);
7565
+ };
7566
+
7567
+ // lib/use-puck.ts
7568
+ init_react_import();
7569
+ import { createContext as createContext6, useContext as useContext11, useEffect as useEffect24, useState as useState21 } from "react";
7570
+ import { createStore as createStore4, useStore as useStore3 } from "zustand";
7571
+ var generateUsePuck = (store) => {
7572
+ const history = {
7573
+ back: store.history.back,
7574
+ forward: store.history.forward,
7575
+ setHistories: store.history.setHistories,
7576
+ setHistoryIndex: store.history.setHistoryIndex,
7577
+ hasPast: store.history.hasPast(),
7578
+ hasFuture: store.history.hasFuture(),
7579
+ histories: store.history.histories,
7580
+ index: store.history.index
7581
+ };
7582
+ const storeData = {
7583
+ appState: makeStatePublic(store.state),
7584
+ config: store.config,
7585
+ dispatch: store.dispatch,
7586
+ getPermissions: store.permissions.getPermissions,
7587
+ refreshPermissions: store.permissions.refreshPermissions,
7588
+ history,
7589
+ selectedItem: store.selectedItem || null,
7590
+ getItemBySelector: (selector) => getItem(selector, store.state),
7591
+ getItemById: (id) => store.state.indexes.nodes[id].data,
7592
+ getSelectorForId: (id) => {
7593
+ const node = store.state.indexes.nodes[id];
7594
+ if (!node) return;
7595
+ const zoneCompound = `${node.parentId}:${node.zone}`;
7596
+ const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
7597
+ return { zone: zoneCompound, index };
7598
+ }
7599
+ };
7600
+ return storeData;
7601
+ };
7602
+ var UsePuckStoreContext = createContext6(
7603
+ null
7604
+ );
7605
+ var convertToPickedStore = (store) => {
7606
+ return {
7607
+ state: store.state,
7608
+ config: store.config,
7609
+ dispatch: store.dispatch,
7610
+ permissions: store.permissions,
7611
+ history: store.history,
7612
+ selectedItem: store.selectedItem
7613
+ };
7614
+ };
7615
+ var useRegisterUsePuckStore = (appStore) => {
7616
+ const [usePuckStore] = useState21(
7617
+ () => createStore4(
7618
+ () => generateUsePuck(convertToPickedStore(appStore.getState()))
7619
+ )
7780
7620
  );
7781
7621
  useEffect24(() => {
7782
- setShowTransition(false);
7783
- resetAutoZoom(viewports);
7784
- }, [frameRef, leftSideBarVisible, rightSideBarVisible]);
7785
- useEffect24(() => {
7786
- const { height: frameHeight } = getFrameDimensions();
7787
- if (viewports.current.height === "auto") {
7788
- setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
7789
- rootHeight: frameHeight / zoomConfig.zoom
7790
- }));
7791
- }
7792
- }, [zoomConfig.zoom]);
7793
- useEffect24(() => {
7794
- if (ZOOM_ON_CHANGE) {
7795
- setShowTransition(true);
7796
- resetAutoZoom(viewports);
7797
- }
7798
- }, [viewports.current.width]);
7799
- useEffect24(() => {
7800
- const cb = () => {
7801
- setShowTransition(false);
7802
- resetAutoZoom();
7803
- };
7804
- window.addEventListener("resize", cb);
7805
- return () => {
7806
- window.removeEventListener("resize", cb);
7807
- };
7622
+ return appStore.subscribe(
7623
+ (store) => convertToPickedStore(store),
7624
+ (pickedStore) => {
7625
+ usePuckStore.setState(generateUsePuck(pickedStore));
7626
+ }
7627
+ );
7808
7628
  }, []);
7809
- const [showLoader, setShowLoader] = useState22(false);
7629
+ return usePuckStore;
7630
+ };
7631
+ function createUsePuck() {
7632
+ return function usePuck2(selector) {
7633
+ const usePuckApi = useContext11(UsePuckStoreContext);
7634
+ if (!usePuckApi) {
7635
+ throw new Error("usePuck must be used inside <Puck>.");
7636
+ }
7637
+ const result = useStore3(
7638
+ usePuckApi,
7639
+ selector != null ? selector : (s) => s
7640
+ );
7641
+ return result;
7642
+ };
7643
+ }
7644
+ function usePuck() {
7810
7645
  useEffect24(() => {
7811
- setTimeout(() => {
7812
- setShowLoader(true);
7813
- }, 500);
7646
+ console.warn(
7647
+ "You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
7648
+ );
7814
7649
  }, []);
7815
- return /* @__PURE__ */ jsxs19(
7650
+ return createUsePuck()((s) => s);
7651
+ }
7652
+ function useGetPuck() {
7653
+ const usePuckApi = useContext11(UsePuckStoreContext);
7654
+ if (!usePuckApi) {
7655
+ throw new Error("usePuckGet must be used inside <Puck>.");
7656
+ }
7657
+ return usePuckApi.getState;
7658
+ }
7659
+
7660
+ // components/Puck/index.tsx
7661
+ import fdeq from "fast-deep-equal";
7662
+
7663
+ // components/Puck/components/Header/index.tsx
7664
+ init_react_import();
7665
+ import { memo as memo3, useCallback as useCallback17, useMemo as useMemo20, useState as useState22 } from "react";
7666
+
7667
+ // components/MenuBar/index.tsx
7668
+ init_react_import();
7669
+
7670
+ // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
7671
+ init_react_import();
7672
+ 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" };
7673
+
7674
+ // components/MenuBar/index.tsx
7675
+ import { Fragment as Fragment13, jsx as jsx38, jsxs as jsxs18 } from "react/jsx-runtime";
7676
+ var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
7677
+ function MenuBar({
7678
+ menuOpen = false,
7679
+ renderHeaderActions,
7680
+ setMenuOpen
7681
+ }) {
7682
+ const back = useAppStore((s) => s.history.back);
7683
+ const forward = useAppStore((s) => s.history.forward);
7684
+ const hasFuture = useAppStore((s) => s.history.hasFuture());
7685
+ const hasPast = useAppStore((s) => s.history.hasPast());
7686
+ return /* @__PURE__ */ jsx38(
7816
7687
  "div",
7817
7688
  {
7818
- className: getClassName27({
7819
- ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
7820
- showLoader
7821
- }),
7822
- onClick: () => dispatch({
7823
- type: "setUi",
7824
- ui: { itemSelector: null },
7825
- recordHistory: true
7826
- }),
7827
- children: [
7828
- viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx39("div", { className: getClassName27("controls"), children: /* @__PURE__ */ jsx39(
7829
- ViewportControls,
7830
- {
7831
- autoZoom: zoomConfig.autoZoom,
7832
- zoom: zoomConfig.zoom,
7833
- onViewportChange: (viewport) => {
7834
- setShowTransition(true);
7835
- const uiViewport = __spreadProps(__spreadValues({}, viewport), {
7836
- height: viewport.height || "auto",
7837
- zoom: zoomConfig.zoom
7838
- });
7839
- const newUi = {
7840
- viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport }),
7841
- itemSelector: null
7842
- };
7843
- setUi(newUi);
7844
- if (ZOOM_ON_CHANGE) {
7845
- resetAutoZoom(__spreadProps(__spreadValues({}, viewports), { current: uiViewport }));
7846
- }
7847
- },
7848
- onZoom: (zoom) => {
7849
- setShowTransition(true);
7850
- setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
7851
- }
7852
- }
7853
- ) }),
7854
- /* @__PURE__ */ jsxs19("div", { className: getClassName27("inner"), ref: frameRef, children: [
7855
- /* @__PURE__ */ jsx39(
7856
- "div",
7689
+ className: getClassName26({ menuOpen }),
7690
+ onClick: (event) => {
7691
+ var _a;
7692
+ const element = event.target;
7693
+ if (window.matchMedia("(min-width: 638px)").matches) {
7694
+ return;
7695
+ }
7696
+ if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
7697
+ setMenuOpen(false);
7698
+ }
7699
+ },
7700
+ children: /* @__PURE__ */ jsxs18("div", { className: getClassName26("inner"), children: [
7701
+ /* @__PURE__ */ jsxs18("div", { className: getClassName26("history"), children: [
7702
+ /* @__PURE__ */ jsx38(
7703
+ IconButton,
7857
7704
  {
7858
- className: getClassName27("root"),
7859
- style: {
7860
- width: iframe.enabled ? viewports.current.width : "100%",
7861
- height: zoomConfig.rootHeight,
7862
- transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
7863
- transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : "",
7864
- overflow: iframe.enabled ? void 0 : "auto"
7865
- },
7866
- suppressHydrationWarning: true,
7867
- id: "puck-canvas-root",
7868
- onTransitionEnd: () => {
7869
- window.dispatchEvent(
7870
- new CustomEvent("viewportchange", {
7871
- bubbles: true,
7872
- cancelable: false
7873
- })
7874
- );
7875
- },
7876
- children: /* @__PURE__ */ jsx39(CustomPreview, { children: /* @__PURE__ */ jsx39(Preview2, {}) })
7705
+ type: "button",
7706
+ title: "undo",
7707
+ disabled: !hasPast,
7708
+ onClick: back,
7709
+ children: /* @__PURE__ */ jsx38(Undo2, { size: 21 })
7877
7710
  }
7878
7711
  ),
7879
- /* @__PURE__ */ jsx39("div", { className: getClassName27("loader"), children: /* @__PURE__ */ jsx39(Loader, { size: 24 }) })
7880
- ] })
7881
- ]
7712
+ /* @__PURE__ */ jsx38(
7713
+ IconButton,
7714
+ {
7715
+ type: "button",
7716
+ title: "redo",
7717
+ disabled: !hasFuture,
7718
+ onClick: forward,
7719
+ children: /* @__PURE__ */ jsx38(Redo2, { size: 21 })
7720
+ }
7721
+ )
7722
+ ] }),
7723
+ /* @__PURE__ */ jsx38(Fragment13, { children: renderHeaderActions && renderHeaderActions() })
7724
+ ] })
7882
7725
  }
7883
7726
  );
7884
- };
7885
-
7886
- // components/Puck/components/Nav/index.tsx
7887
- init_react_import();
7727
+ }
7888
7728
 
7889
- // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Nav/styles.module.css#css-module
7729
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
7890
7730
  init_react_import();
7891
- var styles_module_default23 = { "Nav-list": "_Nav-list_b6txo_1", "NavSection": "_NavSection_b6txo_7", "Nav--slim": "_Nav--slim_b6txo_15", "NavSection-list": "_NavSection-list_b6txo_24", "NavSection-title": "_NavSection-title_b6txo_36", "NavItem-link": "_NavItem-link_b6txo_47", "NavItem-linkIcon": "_NavItem-linkIcon_b6txo_67", "NavItem--active": "_NavItem--active_b6txo_72", "NavItem": "_NavItem_b6txo_47", "NavItem-list": "_NavItem-list_b6txo_91" };
7892
-
7893
- // components/Puck/components/Nav/index.tsx
7894
- import { jsx as jsx40, jsxs as jsxs20 } from "react/jsx-runtime";
7895
- var getClassName28 = get_class_name_factory_default("Nav", styles_module_default23);
7896
- var getClassNameSection = get_class_name_factory_default("NavSection", styles_module_default23);
7897
- var getClassNameItem3 = get_class_name_factory_default("NavItem", styles_module_default23);
7898
- var MenuItem = ({
7899
- label,
7900
- icon,
7901
- items,
7902
- onClick,
7903
- isActive
7904
- }) => {
7905
- const showChildren = isActive;
7906
- return /* @__PURE__ */ jsxs20("li", { className: getClassNameItem3({ active: isActive }), children: [
7907
- onClick && /* @__PURE__ */ jsxs20("div", { className: getClassNameItem3("link"), onClick, children: [
7908
- icon && /* @__PURE__ */ jsx40("span", { className: getClassNameItem3("linkIcon"), children: icon }),
7909
- /* @__PURE__ */ jsx40("span", { className: getClassNameItem3("linkLabel"), children: label })
7910
- ] }),
7911
- items && showChildren && /* @__PURE__ */ jsx40("ul", { className: getClassNameItem3("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ jsx40(MenuItem, __spreadValues({}, item), key)) })
7912
- ] });
7913
- };
7914
- var NavSection = ({ title, items }) => {
7915
- return /* @__PURE__ */ jsxs20("li", { className: getClassNameSection(), children: [
7916
- title && /* @__PURE__ */ jsx40("div", { className: getClassNameSection("title"), children: title }),
7917
- /* @__PURE__ */ jsx40("ul", { className: getClassNameSection("list"), children: Object.entries(items).map(([key, item]) => /* @__PURE__ */ jsx40(MenuItem, __spreadValues({}, item), key)) })
7918
- ] });
7919
- };
7920
- var Nav = ({
7921
- navigation,
7922
- slim
7923
- }) => {
7924
- return /* @__PURE__ */ jsx40("nav", { className: getClassName28({ slim }), children: /* @__PURE__ */ jsx40("ul", { className: getClassName28("list"), children: Object.entries(navigation).map(([key, section]) => {
7925
- return /* @__PURE__ */ jsx40(NavSection, { title: section.title, items: section.items }, key);
7926
- }) }) });
7927
- };
7731
+ 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" };
7928
7732
 
7929
- // components/Puck/components/Layout/index.tsx
7930
- import { jsx as jsx41, jsxs as jsxs21 } from "react/jsx-runtime";
7931
- var getClassName29 = get_class_name_factory_default("Puck", styles_module_default17);
7932
- var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default17);
7933
- var FieldSideBar = () => {
7934
- const title = useAppStore(
7935
- (s) => {
7936
- var _a, _b;
7937
- return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
7733
+ // components/Puck/components/Header/index.tsx
7734
+ import { Fragment as Fragment14, jsx as jsx39, jsxs as jsxs19 } from "react/jsx-runtime";
7735
+ var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
7736
+ var HeaderInner = () => {
7737
+ const {
7738
+ onPublish,
7739
+ renderHeader,
7740
+ renderHeaderActions,
7741
+ headerTitle,
7742
+ headerPath,
7743
+ iframe: _iframe
7744
+ } = usePropsContext();
7745
+ const dispatch = useAppStore((s) => s.dispatch);
7746
+ const appStore = useAppStoreApi();
7747
+ const defaultHeaderRender = useMemo20(() => {
7748
+ if (renderHeader) {
7749
+ console.warn(
7750
+ "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
7751
+ );
7752
+ const RenderHeader = (_a) => {
7753
+ var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
7754
+ const Comp = renderHeader;
7755
+ const appState = useAppStore((s) => s.state);
7756
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7757
+ };
7758
+ return RenderHeader;
7759
+ }
7760
+ return DefaultOverride;
7761
+ }, [renderHeader]);
7762
+ const defaultHeaderActionsRender = useMemo20(() => {
7763
+ if (renderHeaderActions) {
7764
+ console.warn(
7765
+ "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
7766
+ );
7767
+ const RenderHeader = (props) => {
7768
+ const Comp = renderHeaderActions;
7769
+ const appState = useAppStore((s) => s.state);
7770
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7771
+ };
7772
+ return RenderHeader;
7938
7773
  }
7774
+ return DefaultOverride;
7775
+ }, [renderHeader]);
7776
+ const CustomHeader = useAppStore(
7777
+ (s) => s.overrides.header || defaultHeaderRender
7939
7778
  );
7940
- return /* @__PURE__ */ jsx41(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx41(Fields, {}) });
7941
- };
7942
- var Layout = ({ children }) => {
7943
- const {
7944
- iframe: _iframe,
7945
- dnd,
7946
- initialHistory: _initialHistory,
7947
- plugins
7948
- } = usePropsContext();
7949
- const iframe = useMemo21(
7950
- () => __spreadValues({
7951
- enabled: true,
7952
- waitForStyles: true
7953
- }, _iframe),
7954
- [_iframe]
7779
+ const CustomHeaderActions = useAppStore(
7780
+ (s) => s.overrides.headerActions || defaultHeaderActionsRender
7955
7781
  );
7956
- useInjectGlobalCss(iframe.enabled);
7782
+ const [menuOpen, setMenuOpen] = useState22(false);
7783
+ const rootTitle = useAppStore((s) => {
7784
+ var _a, _b;
7785
+ const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
7786
+ return (_b = rootData.props.title) != null ? _b : "";
7787
+ });
7957
7788
  const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
7958
7789
  const rightSideBarVisible = useAppStore(
7959
7790
  (s) => s.state.ui.rightSideBarVisible
7960
7791
  );
7961
- const dispatch = useAppStore((s) => s.dispatch);
7962
- useEffect25(() => {
7963
- if (!window.matchMedia("(min-width: 638px)").matches) {
7792
+ const toggleSidebars = useCallback17(
7793
+ (sidebar) => {
7794
+ const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7795
+ const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
7796
+ const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
7964
7797
  dispatch({
7965
7798
  type: "setUi",
7966
- ui: {
7967
- leftSideBarVisible: false,
7968
- rightSideBarVisible: false
7969
- }
7799
+ ui: __spreadValues({
7800
+ [`${sidebar}SideBarVisible`]: !sideBarVisible
7801
+ }, !widerViewport ? { [oppositeSideBar]: false } : {})
7970
7802
  });
7971
- }
7972
- const handleResize = () => {
7973
- if (!window.matchMedia("(min-width: 638px)").matches) {
7974
- dispatch({
7975
- type: "setUi",
7976
- ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
7977
- });
7978
- }
7979
- };
7980
- window.addEventListener("resize", handleResize);
7981
- return () => {
7982
- window.removeEventListener("resize", handleResize);
7983
- };
7984
- }, []);
7985
- const overrides = useAppStore((s) => s.overrides);
7986
- const CustomPuck = useMemo21(
7987
- () => overrides.puck || DefaultOverride,
7988
- [overrides]
7803
+ },
7804
+ [dispatch, leftSideBarVisible, rightSideBarVisible]
7989
7805
  );
7990
- const [mounted, setMounted] = useState23(false);
7991
- useEffect25(() => {
7992
- setMounted(true);
7993
- }, []);
7994
- const ready = useAppStore((s) => s.status === "READY");
7995
- useMonitorHotkeys();
7996
- useEffect25(() => {
7997
- if (ready && iframe.enabled) {
7998
- const frameDoc = getFrame();
7999
- if (frameDoc) {
8000
- return monitorHotkeys(frameDoc);
8001
- }
8002
- }
8003
- }, [ready, iframe.enabled]);
8004
- usePreviewModeHotkeys();
8005
- const [view, setView] = useState23("blocks");
8006
- const pluginItems = useMemo21(() => {
8007
- const details = {};
8008
- plugins == null ? void 0 : plugins.forEach((plugin) => {
8009
- var _a, _b;
8010
- if (plugin.name && plugin.render) {
8011
- details[plugin.name] = {
8012
- label: (_a = plugin.label) != null ? _a : plugin.name,
8013
- icon: (_b = plugin.icon) != null ? _b : /* @__PURE__ */ jsx41(ToyBrick, {}),
7806
+ return /* @__PURE__ */ jsx39(
7807
+ CustomHeader,
7808
+ {
7809
+ actions: /* @__PURE__ */ jsx39(Fragment14, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7810
+ Button,
7811
+ {
8014
7812
  onClick: () => {
8015
- setView(plugin.name);
7813
+ const data = appStore.getState().state.data;
7814
+ onPublish && onPublish(data);
8016
7815
  },
8017
- isActive: view === plugin.name,
8018
- render: plugin.render
8019
- };
8020
- }
8021
- });
8022
- return details;
8023
- }, [plugins, view]);
8024
- const PluginRender = useMemo21(() => {
8025
- var _a;
8026
- if (view === "blocks") {
8027
- return Components;
8028
- } else if (view === "outline") {
8029
- return Outline;
8030
- } else {
8031
- return (_a = pluginItems[view]) == null ? void 0 : _a.render;
8032
- }
8033
- }, [view]);
8034
- return /* @__PURE__ */ jsxs21("div", { className: `Puck ${getClassName29()}`, children: [
8035
- /* @__PURE__ */ jsx41(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx41(CustomPuck, { children: children || /* @__PURE__ */ jsx41(
8036
- "div",
8037
- {
8038
- className: getLayoutClassName({
8039
- leftSideBarVisible,
8040
- mounted,
8041
- rightSideBarVisible
8042
- }),
8043
- children: /* @__PURE__ */ jsxs21("div", { className: getLayoutClassName("inner"), children: [
8044
- /* @__PURE__ */ jsx41(Header, {}),
8045
- /* @__PURE__ */ jsx41("div", { className: getLayoutClassName("nav"), children: /* @__PURE__ */ jsx41(
8046
- Nav,
8047
- {
8048
- slim: true,
8049
- navigation: {
8050
- main: {
8051
- items: __spreadValues({
8052
- build: {
8053
- label: "Blocks",
8054
- icon: /* @__PURE__ */ jsx41(Hammer, {}),
8055
- onClick: () => {
8056
- setView("blocks");
8057
- },
8058
- isActive: view === "blocks"
8059
- },
8060
- outline: {
8061
- label: "Outline",
8062
- icon: /* @__PURE__ */ jsx41(Layers, {}),
7816
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7817
+ children: "Publish"
7818
+ }
7819
+ ) }) }),
7820
+ children: /* @__PURE__ */ jsx39(
7821
+ "header",
7822
+ {
7823
+ className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
7824
+ children: /* @__PURE__ */ jsxs19("div", { className: getClassName27("inner"), children: [
7825
+ /* @__PURE__ */ jsxs19("div", { className: getClassName27("toggle"), children: [
7826
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ jsx39(
7827
+ IconButton,
7828
+ {
7829
+ type: "button",
7830
+ onClick: () => {
7831
+ toggleSidebars("left");
7832
+ },
7833
+ title: "Toggle left sidebar",
7834
+ children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
7835
+ }
7836
+ ) }),
7837
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ jsx39(
7838
+ IconButton,
7839
+ {
7840
+ type: "button",
7841
+ onClick: () => {
7842
+ toggleSidebars("right");
7843
+ },
7844
+ title: "Toggle right sidebar",
7845
+ children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
7846
+ }
7847
+ ) })
7848
+ ] }),
7849
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("title"), children: /* @__PURE__ */ jsxs19(Heading, { rank: "2", size: "xs", children: [
7850
+ headerTitle || rootTitle || "Page",
7851
+ headerPath && /* @__PURE__ */ jsxs19(Fragment14, { children: [
7852
+ " ",
7853
+ /* @__PURE__ */ jsx39("code", { className: getClassName27("path"), children: headerPath })
7854
+ ] })
7855
+ ] }) }),
7856
+ /* @__PURE__ */ jsxs19("div", { className: getClassName27("tools"), children: [
7857
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ jsx39(
7858
+ IconButton,
7859
+ {
7860
+ type: "button",
7861
+ onClick: () => {
7862
+ return setMenuOpen(!menuOpen);
7863
+ },
7864
+ title: "Toggle menu bar",
7865
+ children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
7866
+ }
7867
+ ) }),
7868
+ /* @__PURE__ */ jsx39(
7869
+ MenuBar,
7870
+ {
7871
+ dispatch,
7872
+ onPublish,
7873
+ menuOpen,
7874
+ renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7875
+ Button,
7876
+ {
8063
7877
  onClick: () => {
8064
- setView("outline");
7878
+ const data = appStore.getState().state.data;
7879
+ onPublish && onPublish(data);
8065
7880
  },
8066
- isActive: view === "outline"
7881
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7882
+ children: "Publish"
8067
7883
  }
8068
- }, pluginItems)
7884
+ ) }),
7885
+ setMenuOpen
8069
7886
  }
8070
- }
8071
- }
8072
- ) }),
8073
- /* @__PURE__ */ jsx41("div", { className: getLayoutClassName("leftSideBar"), children: leftSideBarVisible && /* @__PURE__ */ jsx41(PluginRender, {}) }),
8074
- /* @__PURE__ */ jsx41(Canvas, {}),
8075
- /* @__PURE__ */ jsx41("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx41(FieldSideBar, {}) })
8076
- ] })
8077
- }
8078
- ) }) }),
8079
- /* @__PURE__ */ jsx41("div", { id: "puck-portal-root", className: getClassName29("portal") })
8080
- ] });
7887
+ )
7888
+ ] })
7889
+ ] })
7890
+ }
7891
+ )
7892
+ }
7893
+ );
8081
7894
  };
7895
+ var Header = memo3(HeaderInner);
8082
7896
 
8083
7897
  // components/Puck/index.tsx
8084
- import { jsx as jsx42 } from "react/jsx-runtime";
7898
+ import { jsx as jsx40, jsxs as jsxs20 } from "react/jsx-runtime";
7899
+ var getClassName28 = get_class_name_factory_default("Puck", styles_module_default14);
7900
+ var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
7901
+ var FieldSideBar = () => {
7902
+ const title = useAppStore(
7903
+ (s) => {
7904
+ var _a, _b;
7905
+ return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
7906
+ }
7907
+ );
7908
+ return /* @__PURE__ */ jsx40(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx40(Fields, {}) });
7909
+ };
8085
7910
  var propsContext = createContext7({});
8086
7911
  function PropsProvider(props) {
8087
- return /* @__PURE__ */ jsx42(propsContext.Provider, { value: props, children: props.children });
7912
+ return /* @__PURE__ */ jsx40(propsContext.Provider, { value: props, children: props.children });
8088
7913
  }
8089
7914
  var usePropsContext = () => useContext12(propsContext);
8090
7915
  function PuckProvider({ children }) {
@@ -8102,14 +7927,14 @@ function PuckProvider({ children }) {
8102
7927
  metadata,
8103
7928
  onAction
8104
7929
  } = usePropsContext();
8105
- const iframe = useMemo22(
7930
+ const iframe = useMemo21(
8106
7931
  () => __spreadValues({
8107
7932
  enabled: true,
8108
7933
  waitForStyles: true
8109
7934
  }, _iframe),
8110
7935
  [_iframe]
8111
7936
  );
8112
- const [generatedAppState] = useState24(() => {
7937
+ const [generatedAppState] = useState23(() => {
8113
7938
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
8114
7939
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
8115
7940
  let clientUiState = {};
@@ -8169,7 +7994,7 @@ function PuckProvider({ children }) {
8169
7994
  return walkAppState(newAppState, config);
8170
7995
  });
8171
7996
  const { appendData = true } = _initialHistory || {};
8172
- const [blendedHistories] = useState24(
7997
+ const [blendedHistories] = useState23(
8173
7998
  [
8174
7999
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
8175
8000
  ...appendData ? [{ state: generatedAppState }] : []
@@ -8213,15 +8038,15 @@ function PuckProvider({ children }) {
8213
8038
  metadata
8214
8039
  ]
8215
8040
  );
8216
- const [appStore] = useState24(
8041
+ const [appStore] = useState23(
8217
8042
  () => createAppStore(generateAppStore(initialAppState))
8218
8043
  );
8219
- useEffect26(() => {
8044
+ useEffect25(() => {
8220
8045
  if (process.env.NODE_ENV !== "production") {
8221
8046
  window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
8222
8047
  }
8223
8048
  }, [appStore]);
8224
- useEffect26(() => {
8049
+ useEffect25(() => {
8225
8050
  const state = appStore.getState().state;
8226
8051
  appStore.setState(__spreadValues({}, generateAppStore(state)));
8227
8052
  }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
@@ -8231,7 +8056,7 @@ function PuckProvider({ children }) {
8231
8056
  initialAppState
8232
8057
  });
8233
8058
  const previousData = useRef8(null);
8234
- useEffect26(() => {
8059
+ useEffect25(() => {
8235
8060
  appStore.subscribe(
8236
8061
  (s) => s.state.data,
8237
8062
  (data) => {
@@ -8245,14 +8070,99 @@ function PuckProvider({ children }) {
8245
8070
  }, []);
8246
8071
  useRegisterPermissionsSlice(appStore, permissions);
8247
8072
  const uPuckStore = useRegisterUsePuckStore(appStore);
8248
- useEffect26(() => {
8073
+ useEffect25(() => {
8249
8074
  const { resolveAndCommitData } = appStore.getState();
8250
8075
  resolveAndCommitData();
8251
8076
  }, []);
8252
- return /* @__PURE__ */ jsx42(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx42(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8077
+ return /* @__PURE__ */ jsx40(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx40(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8078
+ }
8079
+ function PuckLayout({ children }) {
8080
+ const {
8081
+ iframe: _iframe,
8082
+ dnd,
8083
+ initialHistory: _initialHistory
8084
+ } = usePropsContext();
8085
+ const iframe = useMemo21(
8086
+ () => __spreadValues({
8087
+ enabled: true,
8088
+ waitForStyles: true
8089
+ }, _iframe),
8090
+ [_iframe]
8091
+ );
8092
+ useInjectGlobalCss(iframe.enabled);
8093
+ const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8094
+ const rightSideBarVisible = useAppStore(
8095
+ (s) => s.state.ui.rightSideBarVisible
8096
+ );
8097
+ const dispatch = useAppStore((s) => s.dispatch);
8098
+ useEffect25(() => {
8099
+ if (!window.matchMedia("(min-width: 638px)").matches) {
8100
+ dispatch({
8101
+ type: "setUi",
8102
+ ui: {
8103
+ leftSideBarVisible: false,
8104
+ rightSideBarVisible: false
8105
+ }
8106
+ });
8107
+ }
8108
+ const handleResize = () => {
8109
+ if (!window.matchMedia("(min-width: 638px)").matches) {
8110
+ dispatch({
8111
+ type: "setUi",
8112
+ ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
8113
+ });
8114
+ }
8115
+ };
8116
+ window.addEventListener("resize", handleResize);
8117
+ return () => {
8118
+ window.removeEventListener("resize", handleResize);
8119
+ };
8120
+ }, []);
8121
+ const overrides = useAppStore((s) => s.overrides);
8122
+ const CustomPuck = useMemo21(
8123
+ () => overrides.puck || DefaultOverride,
8124
+ [overrides]
8125
+ );
8126
+ const [mounted, setMounted] = useState23(false);
8127
+ useEffect25(() => {
8128
+ setMounted(true);
8129
+ }, []);
8130
+ const ready = useAppStore((s) => s.status === "READY");
8131
+ useMonitorHotkeys();
8132
+ useEffect25(() => {
8133
+ if (ready && iframe.enabled) {
8134
+ const frameDoc = getFrame();
8135
+ if (frameDoc) {
8136
+ return monitorHotkeys(frameDoc);
8137
+ }
8138
+ }
8139
+ }, [ready, iframe.enabled]);
8140
+ usePreviewModeHotkeys();
8141
+ return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName28()}`, children: [
8142
+ /* @__PURE__ */ jsx40(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx40(CustomPuck, { children: children || /* @__PURE__ */ jsx40(
8143
+ "div",
8144
+ {
8145
+ className: getLayoutClassName({
8146
+ leftSideBarVisible,
8147
+ mounted,
8148
+ rightSideBarVisible
8149
+ }),
8150
+ children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
8151
+ /* @__PURE__ */ jsx40(Header, {}),
8152
+ /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("leftSideBar"), children: [
8153
+ /* @__PURE__ */ jsx40(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx40(Components, {}) }),
8154
+ /* @__PURE__ */ jsx40(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx40(Outline, {}) })
8155
+ ] }),
8156
+ /* @__PURE__ */ jsx40(Canvas, {}),
8157
+ /* @__PURE__ */ jsx40("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx40(FieldSideBar, {}) })
8158
+ ] })
8159
+ }
8160
+ ) }) }),
8161
+ /* @__PURE__ */ jsx40("div", { id: "puck-portal-root", className: getClassName28("portal") })
8162
+ ] });
8253
8163
  }
8254
8164
  function Puck(props) {
8255
- return /* @__PURE__ */ jsx42(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx42(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx42(Layout, { children: props.children }) })) }));
8165
+ return /* @__PURE__ */ jsx40(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx40(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx40(PuckLayout, __spreadValues({}, props)) })) }));
8256
8166
  }
8257
8167
  Puck.Components = Components;
8258
8168
  Puck.Fields = Fields;
@@ -8386,14 +8296,6 @@ lucide-react/dist/esm/icons/globe.js:
8386
8296
  * See the LICENSE file in the root directory of this source tree.
8387
8297
  *)
8388
8298
 
8389
- lucide-react/dist/esm/icons/hammer.js:
8390
- (**
8391
- * @license lucide-react v0.468.0 - ISC
8392
- *
8393
- * This source code is licensed under the ISC license.
8394
- * See the LICENSE file in the root directory of this source tree.
8395
- *)
8396
-
8397
8299
  lucide-react/dist/esm/icons/hash.js:
8398
8300
  (**
8399
8301
  * @license lucide-react v0.468.0 - ISC
@@ -8522,14 +8424,6 @@ lucide-react/dist/esm/icons/tablet.js:
8522
8424
  * See the LICENSE file in the root directory of this source tree.
8523
8425
  *)
8524
8426
 
8525
- lucide-react/dist/esm/icons/toy-brick.js:
8526
- (**
8527
- * @license lucide-react v0.468.0 - ISC
8528
- *
8529
- * This source code is licensed under the ISC license.
8530
- * See the LICENSE file in the root directory of this source tree.
8531
- *)
8532
-
8533
8427
  lucide-react/dist/esm/icons/trash.js:
8534
8428
  (**
8535
8429
  * @license lucide-react v0.468.0 - ISC