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

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
  }
@@ -5027,7 +5014,7 @@ var DropZoneRender = forwardRef3(
5027
5014
  const ctx = useContext7(dropZoneContext);
5028
5015
  const { areaId = "root" } = ctx || {};
5029
5016
  const { config, data, metadata } = useContext7(renderContext);
5030
- let zoneCompound = rootDroppableId;
5017
+ let zoneCompound = `${areaId}:${zone}`;
5031
5018
  let content = (data == null ? void 0 : data.content) || [];
5032
5019
  useEffect16(() => {
5033
5020
  if (!content) {
@@ -5044,8 +5031,7 @@ var DropZoneRender = forwardRef3(
5044
5031
  if (!data || !config) {
5045
5032
  return null;
5046
5033
  }
5047
- if (areaId !== rootAreaId && zone !== rootZone) {
5048
- zoneCompound = `${areaId}:${zone}`;
5034
+ if (zoneCompound !== rootDroppableId) {
5049
5035
  content = setupZone(data, zoneCompound).zones[zoneCompound];
5050
5036
  }
5051
5037
  return /* @__PURE__ */ jsx23("div", { className, style, ref, children: content.map((item) => {
@@ -5946,28 +5932,125 @@ import {
5946
5932
  createContext as createContext7,
5947
5933
  useCallback as useCallback18,
5948
5934
  useContext as useContext12,
5949
- useEffect as useEffect26,
5950
- useMemo as useMemo22,
5935
+ useEffect as useEffect25,
5936
+ useMemo as useMemo21,
5951
5937
  useRef as useRef8,
5952
- useState as useState24
5938
+ useState as useState23
5953
5939
  } from "react";
5954
5940
 
5941
+ // components/SidebarSection/index.tsx
5942
+ init_react_import();
5943
+
5944
+ // css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
5945
+ init_react_import();
5946
+ 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" };
5947
+
5948
+ // lib/use-breadcrumbs.ts
5949
+ init_react_import();
5950
+ import { useMemo as useMemo12 } from "react";
5951
+ var useBreadcrumbs = (renderCount) => {
5952
+ const selectedId = useAppStore((s) => {
5953
+ var _a;
5954
+ return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
5955
+ });
5956
+ const config = useAppStore((s) => s.config);
5957
+ const path = useAppStore((s) => {
5958
+ var _a;
5959
+ return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
5960
+ });
5961
+ const appStore = useAppStoreApi();
5962
+ return useMemo12(() => {
5963
+ const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
5964
+ var _a, _b, _c;
5965
+ const [componentId] = zoneCompound.split(":");
5966
+ if (componentId === "root") {
5967
+ return {
5968
+ label: "Page",
5969
+ selector: null
5970
+ };
5971
+ }
5972
+ const node = appStore.getState().state.indexes.nodes[componentId];
5973
+ const parentId = node.path[node.path.length - 1];
5974
+ const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
5975
+ const index = contentIds.indexOf(componentId);
5976
+ const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
5977
+ return {
5978
+ label,
5979
+ selector: node ? {
5980
+ index,
5981
+ zone: node.path[node.path.length - 1]
5982
+ } : null
5983
+ };
5984
+ })) || [];
5985
+ if (renderCount) {
5986
+ return breadcrumbs.slice(breadcrumbs.length - renderCount);
5987
+ }
5988
+ return breadcrumbs;
5989
+ }, [path, renderCount]);
5990
+ };
5991
+
5992
+ // components/SidebarSection/index.tsx
5993
+ import { jsx as jsx26, jsxs as jsxs12 } from "react/jsx-runtime";
5994
+ var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
5995
+ var SidebarSection = ({
5996
+ children,
5997
+ title,
5998
+ background,
5999
+ showBreadcrumbs,
6000
+ noBorderTop,
6001
+ noPadding,
6002
+ isLoading
6003
+ }) => {
6004
+ const setUi = useAppStore((s) => s.setUi);
6005
+ const breadcrumbs = useBreadcrumbs(1);
6006
+ return /* @__PURE__ */ jsxs12(
6007
+ "div",
6008
+ {
6009
+ className: getClassName19({ noBorderTop, noPadding }),
6010
+ style: { background },
6011
+ children: [
6012
+ /* @__PURE__ */ jsx26("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
6013
+ showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumb"), children: [
6014
+ /* @__PURE__ */ jsx26(
6015
+ "button",
6016
+ {
6017
+ type: "button",
6018
+ className: getClassName19("breadcrumbLabel"),
6019
+ onClick: () => setUi({ itemSelector: breadcrumb.selector }),
6020
+ children: breadcrumb.label
6021
+ }
6022
+ ),
6023
+ /* @__PURE__ */ jsx26(ChevronRight, { size: 16 })
6024
+ ] }, i)) : null,
6025
+ /* @__PURE__ */ jsx26("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx26(Heading, { rank: "2", size: "xs", children: title }) })
6026
+ ] }) }),
6027
+ /* @__PURE__ */ jsx26("div", { className: getClassName19("content"), children }),
6028
+ isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx26(Loader, { size: 32 }) })
6029
+ ]
6030
+ }
6031
+ );
6032
+ };
6033
+
6034
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
6035
+ init_react_import();
6036
+ 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" };
6037
+
5955
6038
  // components/Puck/components/Fields/index.tsx
5956
6039
  init_react_import();
5957
6040
 
5958
6041
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
5959
6042
  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" };
6043
+ 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
6044
 
5962
6045
  // components/Puck/components/Fields/index.tsx
5963
- import { memo as memo2, useCallback as useCallback12, useMemo as useMemo12 } from "react";
6046
+ import { memo as memo2, useCallback as useCallback12, useMemo as useMemo13 } from "react";
5964
6047
  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);
6048
+ import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
6049
+ var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
5967
6050
  var DefaultFields = ({
5968
6051
  children
5969
6052
  }) => {
5970
- return /* @__PURE__ */ jsx26(Fragment7, { children });
6053
+ return /* @__PURE__ */ jsx27(Fragment7, { children });
5971
6054
  };
5972
6055
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
5973
6056
  let currentProps;
@@ -6039,7 +6122,7 @@ var FieldsChild = ({ fieldName }) => {
6039
6122
  const { visible = true } = field != null ? field : {};
6040
6123
  if (!field || !id || !visible) return null;
6041
6124
  if (field.type === "slot") return null;
6042
- return /* @__PURE__ */ jsx26("div", { className: getClassName19("field"), children: /* @__PURE__ */ jsx26(
6125
+ return /* @__PURE__ */ jsx27("div", { className: getClassName20("field"), children: /* @__PURE__ */ jsx27(
6043
6126
  AutoFieldPrivate,
6044
6127
  {
6045
6128
  field,
@@ -6076,17 +6159,17 @@ var FieldsInternal = ({ wrapFields = true }) => {
6076
6159
  })
6077
6160
  );
6078
6161
  const isLoading = fieldsLoading || componentResolving;
6079
- const Wrapper = useMemo12(() => overrides.fields || DefaultFields, [overrides]);
6080
- return /* @__PURE__ */ jsxs12(
6162
+ const Wrapper = useMemo13(() => overrides.fields || DefaultFields, [overrides]);
6163
+ return /* @__PURE__ */ jsxs13(
6081
6164
  "form",
6082
6165
  {
6083
- className: getClassName19({ wrapFields }),
6166
+ className: getClassName20({ wrapFields }),
6084
6167
  onSubmit: (e) => {
6085
6168
  e.preventDefault();
6086
6169
  },
6087
6170
  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 }) }) })
6171
+ /* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx27(FieldsChildMemo, { fieldName }, fieldName)) }),
6172
+ isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName20("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
6090
6173
  ]
6091
6174
  }
6092
6175
  );
@@ -6105,11 +6188,11 @@ init_react_import();
6105
6188
 
6106
6189
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
6107
6190
  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" };
6191
+ 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
6192
 
6110
6193
  // 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);
6194
+ import { jsx as jsx28, jsxs as jsxs14 } from "react/jsx-runtime";
6195
+ var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default16);
6113
6196
  var ComponentListItem = ({
6114
6197
  name,
6115
6198
  label
@@ -6120,7 +6203,7 @@ var ComponentListItem = ({
6120
6203
  type: name
6121
6204
  }).insert
6122
6205
  );
6123
- return /* @__PURE__ */ jsx27(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6206
+ return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
6124
6207
  };
6125
6208
  var ComponentList = ({
6126
6209
  children,
@@ -6131,12 +6214,12 @@ var ComponentList = ({
6131
6214
  const setUi = useAppStore((s) => s.setUi);
6132
6215
  const componentList = useAppStore((s) => s.state.ui.componentList);
6133
6216
  const { expanded = true } = componentList[id] || {};
6134
- return /* @__PURE__ */ jsxs13("div", { className: getClassName20({ isExpanded: expanded }), children: [
6135
- title && /* @__PURE__ */ jsxs13(
6217
+ return /* @__PURE__ */ jsxs14("div", { className: getClassName21({ isExpanded: expanded }), children: [
6218
+ title && /* @__PURE__ */ jsxs14(
6136
6219
  "button",
6137
6220
  {
6138
6221
  type: "button",
6139
- className: getClassName20("title"),
6222
+ className: getClassName21("title"),
6140
6223
  onClick: () => setUi({
6141
6224
  componentList: __spreadProps(__spreadValues({}, componentList), {
6142
6225
  [id]: __spreadProps(__spreadValues({}, componentList[id]), {
@@ -6146,14 +6229,14 @@ var ComponentList = ({
6146
6229
  }),
6147
6230
  title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
6148
6231
  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 }) })
6232
+ /* @__PURE__ */ jsx28("div", { children: title }),
6233
+ /* @__PURE__ */ jsx28("div", { className: getClassName21("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
6151
6234
  ]
6152
6235
  }
6153
6236
  ),
6154
- /* @__PURE__ */ jsx27("div", { className: getClassName20("content"), children: /* @__PURE__ */ jsx27(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6237
+ /* @__PURE__ */ jsx28("div", { className: getClassName21("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
6155
6238
  var _a;
6156
- return /* @__PURE__ */ jsx27(
6239
+ return /* @__PURE__ */ jsx28(
6157
6240
  ComponentListItem,
6158
6241
  {
6159
6242
  label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
@@ -6167,7 +6250,7 @@ var ComponentList = ({
6167
6250
  ComponentList.Item = ComponentListItem;
6168
6251
 
6169
6252
  // lib/use-component-list.tsx
6170
- import { jsx as jsx28 } from "react/jsx-runtime";
6253
+ import { jsx as jsx29 } from "react/jsx-runtime";
6171
6254
  var useComponentList = () => {
6172
6255
  const [componentList, setComponentList] = useState16();
6173
6256
  const config = useAppStore((s) => s.config);
@@ -6182,7 +6265,7 @@ var useComponentList = () => {
6182
6265
  if (category.visible === false || !category.components) {
6183
6266
  return null;
6184
6267
  }
6185
- return /* @__PURE__ */ jsx28(
6268
+ return /* @__PURE__ */ jsx29(
6186
6269
  ComponentList,
6187
6270
  {
6188
6271
  id: categoryKey,
@@ -6191,7 +6274,7 @@ var useComponentList = () => {
6191
6274
  var _a2;
6192
6275
  matchedComponents.push(componentName);
6193
6276
  const componentConf = config.components[componentName] || {};
6194
- return /* @__PURE__ */ jsx28(
6277
+ return /* @__PURE__ */ jsx29(
6195
6278
  ComponentList.Item,
6196
6279
  {
6197
6280
  label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
@@ -6211,7 +6294,7 @@ var useComponentList = () => {
6211
6294
  );
6212
6295
  if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
6213
6296
  _componentList.push(
6214
- /* @__PURE__ */ jsx28(
6297
+ /* @__PURE__ */ jsx29(
6215
6298
  ComponentList,
6216
6299
  {
6217
6300
  id: "other",
@@ -6219,7 +6302,7 @@ var useComponentList = () => {
6219
6302
  children: remainingComponents.map((componentName, i) => {
6220
6303
  var _a2;
6221
6304
  const componentConf = config.components[componentName] || {};
6222
- return /* @__PURE__ */ jsx28(
6305
+ return /* @__PURE__ */ jsx29(
6223
6306
  ComponentList.Item,
6224
6307
  {
6225
6308
  name: componentName,
@@ -6241,18 +6324,18 @@ var useComponentList = () => {
6241
6324
  };
6242
6325
 
6243
6326
  // components/Puck/components/Components/index.tsx
6244
- import { useMemo as useMemo13 } from "react";
6245
- import { jsx as jsx29 } from "react/jsx-runtime";
6327
+ import { useMemo as useMemo14 } from "react";
6328
+ import { jsx as jsx30 } from "react/jsx-runtime";
6246
6329
  var Components = () => {
6247
6330
  const overrides = useAppStore((s) => s.overrides);
6248
6331
  const componentList = useComponentList();
6249
- const Wrapper = useMemo13(() => overrides.components || "div", [overrides]);
6250
- return /* @__PURE__ */ jsx29(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx29(ComponentList, { id: "all" }) });
6332
+ const Wrapper = useMemo14(() => overrides.components || "div", [overrides]);
6333
+ return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
6251
6334
  };
6252
6335
 
6253
6336
  // components/Puck/components/Preview/index.tsx
6254
6337
  init_react_import();
6255
- import { useCallback as useCallback13, useEffect as useEffect20, useRef as useRef6, useMemo as useMemo14 } from "react";
6338
+ import { useCallback as useCallback13, useEffect as useEffect20, useRef as useRef6, useMemo as useMemo15 } from "react";
6256
6339
 
6257
6340
  // components/AutoFrame/index.tsx
6258
6341
  init_react_import();
@@ -6264,12 +6347,19 @@ import {
6264
6347
  } from "react";
6265
6348
  import hash from "object-hash";
6266
6349
  import { createPortal as createPortal3 } from "react-dom";
6267
- import { Fragment as Fragment8, jsx as jsx30 } from "react/jsx-runtime";
6350
+ import { Fragment as Fragment8, jsx as jsx31 } from "react/jsx-runtime";
6268
6351
  var styleSelector = 'style, link[rel="stylesheet"]';
6269
6352
  var collectStyles = (doc) => {
6270
6353
  const collected = [];
6271
6354
  doc.querySelectorAll(styleSelector).forEach((style) => {
6272
- collected.push(style);
6355
+ if (style.tagName === "STYLE") {
6356
+ const hasContent = !!style.innerHTML.trim();
6357
+ if (hasContent) {
6358
+ collected.push(style);
6359
+ }
6360
+ } else {
6361
+ collected.push(style);
6362
+ }
6273
6363
  });
6274
6364
  return collected;
6275
6365
  };
@@ -6282,7 +6372,7 @@ var getStyleSheet = (el) => {
6282
6372
  var getStyles = (styleSheet) => {
6283
6373
  if (styleSheet) {
6284
6374
  try {
6285
- return [...styleSheet.cssRules].map((rule) => rule.cssText).join("");
6375
+ return [...Array.from(styleSheet.cssRules)].map((rule) => rule.cssText).join("");
6286
6376
  } catch (e) {
6287
6377
  console.warn(
6288
6378
  "Access to stylesheet %s is denied. Ignoring\u2026",
@@ -6464,7 +6554,7 @@ var CopyHostStyles = ({
6464
6554
  observer.disconnect();
6465
6555
  };
6466
6556
  }, []);
6467
- return /* @__PURE__ */ jsx30(Fragment8, { children });
6557
+ return /* @__PURE__ */ jsx31(Fragment8, { children });
6468
6558
  };
6469
6559
  var autoFrameContext = createContext5({});
6470
6560
  var useFrame = () => useContext9(autoFrameContext);
@@ -6511,7 +6601,7 @@ function AutoFrame(_a) {
6511
6601
  }
6512
6602
  }
6513
6603
  }, [frameRef, loaded, stylesLoaded]);
6514
- return /* @__PURE__ */ jsx30(
6604
+ return /* @__PURE__ */ jsx31(
6515
6605
  "iframe",
6516
6606
  __spreadProps(__spreadValues({}, props), {
6517
6607
  className,
@@ -6521,7 +6611,7 @@ function AutoFrame(_a) {
6521
6611
  onLoad: () => {
6522
6612
  setLoaded(true);
6523
6613
  },
6524
- children: /* @__PURE__ */ jsx30(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx30(
6614
+ children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(
6525
6615
  CopyHostStyles,
6526
6616
  {
6527
6617
  debug,
@@ -6537,11 +6627,11 @@ var AutoFrame_default = AutoFrame;
6537
6627
 
6538
6628
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
6539
6629
  init_react_import();
6540
- var styles_module_default15 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
6630
+ var styles_module_default17 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
6541
6631
 
6542
6632
  // 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);
6633
+ import { Fragment as Fragment9, jsx as jsx32 } from "react/jsx-runtime";
6634
+ var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
6545
6635
  var useBubbleIframeEvents = (ref) => {
6546
6636
  const status = useAppStore((s) => s.status);
6547
6637
  useEffect20(() => {
@@ -6603,15 +6693,15 @@ var Preview2 = ({ id = "puck-preview" }) => {
6603
6693
  );
6604
6694
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
6605
6695
  id: "puck-root"
6606
- }, propsWithSlots)) : /* @__PURE__ */ jsx31(Fragment9, { children: propsWithSlots.children });
6696
+ }, propsWithSlots)) : /* @__PURE__ */ jsx32(Fragment9, { children: propsWithSlots.children });
6607
6697
  },
6608
6698
  [config]
6609
6699
  );
6610
- const Frame = useMemo14(() => overrides.iframe, [overrides]);
6700
+ const Frame = useMemo15(() => overrides.iframe, [overrides]);
6611
6701
  const rootProps = root.props || root;
6612
6702
  const ref = useRef6(null);
6613
6703
  useBubbleIframeEvents(ref);
6614
- const inner = !renderData ? /* @__PURE__ */ jsx31(
6704
+ const inner = !renderData ? /* @__PURE__ */ jsx32(
6615
6705
  Page,
6616
6706
  __spreadProps(__spreadValues({}, rootProps), {
6617
6707
  puck: {
@@ -6621,28 +6711,28 @@ var Preview2 = ({ id = "puck-preview" }) => {
6621
6711
  metadata
6622
6712
  },
6623
6713
  editMode: true,
6624
- children: /* @__PURE__ */ jsx31(DropZonePure, { zone: rootDroppableId })
6714
+ children: /* @__PURE__ */ jsx32(DropZonePure, { zone: rootDroppableId })
6625
6715
  })
6626
- ) : /* @__PURE__ */ jsx31(Render, { data: renderData, config });
6716
+ ) : /* @__PURE__ */ jsx32(Render, { data: renderData, config });
6627
6717
  useEffect20(() => {
6628
6718
  if (!iframe.enabled) {
6629
6719
  setStatus("READY");
6630
6720
  }
6631
6721
  }, [iframe.enabled]);
6632
- return /* @__PURE__ */ jsx31(
6722
+ return /* @__PURE__ */ jsx32(
6633
6723
  "div",
6634
6724
  {
6635
- className: getClassName21(),
6725
+ className: getClassName22(),
6636
6726
  id,
6637
6727
  "data-puck-preview": true,
6638
6728
  onClick: () => {
6639
6729
  dispatch({ type: "setUi", ui: { itemSelector: null } });
6640
6730
  },
6641
- children: iframe.enabled ? /* @__PURE__ */ jsx31(
6731
+ children: iframe.enabled ? /* @__PURE__ */ jsx32(
6642
6732
  AutoFrame_default,
6643
6733
  {
6644
6734
  id: "preview-frame",
6645
- className: getClassName21("frame"),
6735
+ className: getClassName22("frame"),
6646
6736
  "data-rfd-iframe": true,
6647
6737
  onReady: () => {
6648
6738
  setStatus("READY");
@@ -6651,18 +6741,18 @@ var Preview2 = ({ id = "puck-preview" }) => {
6651
6741
  setStatus("MOUNTED");
6652
6742
  },
6653
6743
  frameRef: ref,
6654
- children: /* @__PURE__ */ jsx31(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6744
+ children: /* @__PURE__ */ jsx32(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
6655
6745
  if (Frame) {
6656
- return /* @__PURE__ */ jsx31(Frame, { document: document2, children: inner });
6746
+ return /* @__PURE__ */ jsx32(Frame, { document: document2, children: inner });
6657
6747
  }
6658
6748
  return inner;
6659
6749
  } })
6660
6750
  }
6661
- ) : /* @__PURE__ */ jsx31(
6751
+ ) : /* @__PURE__ */ jsx32(
6662
6752
  "div",
6663
6753
  {
6664
6754
  id: "preview-frame",
6665
- className: getClassName21("frame"),
6755
+ className: getClassName22("frame"),
6666
6756
  ref,
6667
6757
  "data-puck-entry": true,
6668
6758
  children: inner
@@ -6680,7 +6770,7 @@ init_react_import();
6680
6770
 
6681
6771
  // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
6682
6772
  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" };
6773
+ 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
6774
 
6685
6775
  // lib/scroll-into-view.ts
6686
6776
  init_react_import();
@@ -6717,16 +6807,15 @@ var onScrollEnd = (frame, cb) => {
6717
6807
 
6718
6808
  // components/LayerTree/index.tsx
6719
6809
  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);
6810
+ import { Fragment as Fragment10, jsx as jsx33, jsxs as jsxs15 } from "react/jsx-runtime";
6811
+ var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
6812
+ var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
6723
6813
  var Layer = ({
6724
6814
  index,
6725
6815
  itemId,
6726
6816
  zoneCompound
6727
6817
  }) => {
6728
6818
  var _a;
6729
- const ctx = useContext10(dropZoneContext);
6730
6819
  const config = useAppStore((s) => s.config);
6731
6820
  const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
6732
6821
  const dispatch = useAppStore((s) => s.dispatch);
@@ -6765,7 +6854,7 @@ var Layer = ({
6765
6854
  });
6766
6855
  const componentConfig = config.components[nodeData.data.type];
6767
6856
  const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
6768
- return /* @__PURE__ */ jsxs14(
6857
+ return /* @__PURE__ */ jsxs15(
6769
6858
  "li",
6770
6859
  {
6771
6860
  className: getClassNameLayer({
@@ -6775,7 +6864,7 @@ var Layer = ({
6775
6864
  childIsSelected
6776
6865
  }),
6777
6866
  children: [
6778
- /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs14(
6867
+ /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs15(
6779
6868
  "button",
6780
6869
  {
6781
6870
  type: "button",
@@ -6813,22 +6902,22 @@ var Layer = ({
6813
6902
  zoneStore.setState({ hoveringComponent: null });
6814
6903
  },
6815
6904
  children: [
6816
- containsZone && /* @__PURE__ */ jsx32(
6905
+ containsZone && /* @__PURE__ */ jsx33(
6817
6906
  "div",
6818
6907
  {
6819
6908
  className: getClassNameLayer("chevron"),
6820
6909
  title: isSelected ? "Collapse" : "Expand",
6821
- children: /* @__PURE__ */ jsx32(ChevronDown, { size: "12" })
6910
+ children: /* @__PURE__ */ jsx33(ChevronDown, { size: "12" })
6822
6911
  }
6823
6912
  ),
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 })
6913
+ /* @__PURE__ */ jsxs15("div", { className: getClassNameLayer("title"), children: [
6914
+ /* @__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" }) }),
6915
+ /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("name"), children: label })
6827
6916
  ] })
6828
6917
  ]
6829
6918
  }
6830
6919
  ) }),
6831
- containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx32("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx32(LayerTree, { zoneCompound: subzone }) }, subzone))
6920
+ containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx33(LayerTree, { zoneCompound: subzone }) }, subzone))
6832
6921
  ]
6833
6922
  }
6834
6923
  );
@@ -6837,7 +6926,15 @@ var LayerTree = ({
6837
6926
  label: _label,
6838
6927
  zoneCompound
6839
6928
  }) => {
6840
- const label = _label != null ? _label : zoneCompound.split(":")[1];
6929
+ const label = useAppStore((s) => {
6930
+ var _a, _b, _c, _d;
6931
+ if (_label) return _label;
6932
+ if (zoneCompound === rootDroppableId) return;
6933
+ const [componentId, slotId] = zoneCompound.split(":");
6934
+ const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
6935
+ const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
6936
+ return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
6937
+ });
6841
6938
  const contentIds = useAppStore(
6842
6939
  useShallow6(
6843
6940
  (s) => {
@@ -6846,15 +6943,15 @@ var LayerTree = ({
6846
6943
  }
6847
6944
  )
6848
6945
  );
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" }) }),
6946
+ return /* @__PURE__ */ jsxs15(Fragment10, { children: [
6947
+ label && /* @__PURE__ */ jsxs15("div", { className: getClassName23("zoneTitle"), children: [
6948
+ /* @__PURE__ */ jsx33("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ jsx33(Layers, { size: "16" }) }),
6852
6949
  label
6853
6950
  ] }),
6854
- /* @__PURE__ */ jsxs14("ul", { className: getClassName22(), children: [
6855
- contentIds.length === 0 && /* @__PURE__ */ jsx32("div", { className: getClassName22("helper"), children: "No items" }),
6951
+ /* @__PURE__ */ jsxs15("ul", { className: getClassName23(), children: [
6952
+ contentIds.length === 0 && /* @__PURE__ */ jsx33("div", { className: getClassName23("helper"), children: "No items" }),
6856
6953
  contentIds.map((itemId, i) => {
6857
- return /* @__PURE__ */ jsx32(
6954
+ return /* @__PURE__ */ jsx33(
6858
6955
  Layer,
6859
6956
  {
6860
6957
  index: i,
@@ -6869,7 +6966,7 @@ var LayerTree = ({
6869
6966
  };
6870
6967
 
6871
6968
  // components/Puck/components/Outline/index.tsx
6872
- import { useMemo as useMemo15 } from "react";
6969
+ import { useMemo as useMemo16 } from "react";
6873
6970
 
6874
6971
  // lib/data/find-zones-for-area.ts
6875
6972
  init_react_import();
@@ -6881,14 +6978,14 @@ var findZonesForArea = (state, area) => {
6881
6978
 
6882
6979
  // components/Puck/components/Outline/index.tsx
6883
6980
  import { useShallow as useShallow7 } from "zustand/react/shallow";
6884
- import { jsx as jsx33 } from "react/jsx-runtime";
6981
+ import { jsx as jsx34 } from "react/jsx-runtime";
6885
6982
  var Outline = () => {
6886
6983
  const outlineOverride = useAppStore((s) => s.overrides.outline);
6887
6984
  const rootZones = useAppStore(
6888
6985
  useShallow7((s) => findZonesForArea(s.state, "root"))
6889
6986
  );
6890
- const Wrapper = useMemo15(() => outlineOverride || "div", [outlineOverride]);
6891
- return /* @__PURE__ */ jsx33(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx33(
6987
+ const Wrapper = useMemo16(() => outlineOverride || "div", [outlineOverride]);
6988
+ return /* @__PURE__ */ jsx34(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx34(
6892
6989
  LayerTree,
6893
6990
  {
6894
6991
  label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
@@ -6898,572 +6995,64 @@ var Outline = () => {
6898
6995
  )) });
6899
6996
  };
6900
6997
 
6901
- // lib/use-loaded-overrides.ts
6998
+ // components/Puck/components/Canvas/index.tsx
6902
6999
  init_react_import();
6903
- import { useMemo as useMemo16 } from "react";
6904
7000
 
6905
- // lib/load-overrides.ts
7001
+ // ../../node_modules/css-box-model/dist/css-box-model.esm.js
6906
7002
  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
7003
 
6948
- // lib/use-puck.ts
7004
+ // ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
6949
7005
  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 };
7006
+ var isProduction = process.env.NODE_ENV === "production";
7007
+ var prefix = "Invariant failed";
7008
+ function invariant(condition, message) {
7009
+ if (condition) {
7010
+ return;
7011
+ }
7012
+ if (isProduction) {
7013
+ throw new Error(prefix);
7014
+ }
7015
+ var provided = typeof message === "function" ? message() : message;
7016
+ var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
7017
+ throw new Error(value);
7018
+ }
7019
+
7020
+ // ../../node_modules/css-box-model/dist/css-box-model.esm.js
7021
+ var getRect = function getRect2(_ref) {
7022
+ var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
7023
+ var width = right - left;
7024
+ var height = bottom - top;
7025
+ var rect = {
7026
+ top,
7027
+ right,
7028
+ bottom,
7029
+ left,
7030
+ width,
7031
+ height,
7032
+ x: left,
7033
+ y: top,
7034
+ center: {
7035
+ x: (right + left) / 2,
7036
+ y: (bottom + top) / 2
6979
7037
  }
6980
7038
  };
6981
- const get = () => storeData;
6982
- return __spreadProps(__spreadValues({}, storeData), { get });
7039
+ return rect;
6983
7040
  };
6984
- var UsePuckStoreContext = createContext6(
6985
- null
6986
- );
6987
- var convertToPickedStore = (store) => {
7041
+ var expand = function expand2(target, expandBy) {
6988
7042
  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
7043
+ top: target.top - expandBy.top,
7044
+ left: target.left - expandBy.left,
7045
+ bottom: target.bottom + expandBy.bottom,
7046
+ right: target.right + expandBy.right
6995
7047
  };
6996
7048
  };
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
7458
- };
7459
- };
7460
- var shrink = function shrink2(target, shrinkBy) {
7461
- return {
7462
- top: target.top + shrinkBy.top,
7463
- left: target.left + shrinkBy.left,
7464
- bottom: target.bottom - shrinkBy.bottom,
7465
- right: target.right - shrinkBy.right
7466
- };
7049
+ var shrink = function shrink2(target, shrinkBy) {
7050
+ return {
7051
+ top: target.top + shrinkBy.top,
7052
+ left: target.left + shrinkBy.left,
7053
+ bottom: target.bottom - shrinkBy.bottom,
7054
+ right: target.right - shrinkBy.right
7055
+ };
7467
7056
  };
7468
7057
  var noSpacing = {
7469
7058
  top: 0,
@@ -7530,30 +7119,30 @@ var getBox = function getBox2(el) {
7530
7119
 
7531
7120
  // components/Puck/components/Canvas/index.tsx
7532
7121
  import {
7533
- useCallback as useCallback17,
7534
- useEffect as useEffect24,
7535
- useMemo as useMemo20,
7122
+ useCallback as useCallback15,
7123
+ useEffect as useEffect22,
7124
+ useMemo as useMemo18,
7536
7125
  useRef as useRef7,
7537
- useState as useState22
7126
+ useState as useState19
7538
7127
  } from "react";
7539
7128
 
7540
7129
  // components/ViewportControls/index.tsx
7541
7130
  init_react_import();
7542
- import { useEffect as useEffect23, useMemo as useMemo19, useState as useState21 } from "react";
7131
+ import { useEffect as useEffect21, useMemo as useMemo17, useState as useState18 } from "react";
7543
7132
 
7544
7133
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
7545
7134
  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" };
7135
+ 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
7136
 
7548
7137
  // components/ViewportControls/index.tsx
7549
- import { jsx as jsx38, jsxs as jsxs18 } from "react/jsx-runtime";
7138
+ import { jsx as jsx35, jsxs as jsxs16 } from "react/jsx-runtime";
7550
7139
  var icons = {
7551
- Smartphone: /* @__PURE__ */ jsx38(Smartphone, { size: 16 }),
7552
- Tablet: /* @__PURE__ */ jsx38(Tablet, { size: 16 }),
7553
- Monitor: /* @__PURE__ */ jsx38(Monitor, { size: 16 })
7140
+ Smartphone: /* @__PURE__ */ jsx35(Smartphone, { size: 16 }),
7141
+ Tablet: /* @__PURE__ */ jsx35(Tablet, { size: 16 }),
7142
+ Monitor: /* @__PURE__ */ jsx35(Monitor, { size: 16 })
7554
7143
  };
7555
- var getClassName26 = get_class_name_factory_default("ViewportControls", styles_module_default21);
7556
- var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default21);
7144
+ var getClassName24 = get_class_name_factory_default("ViewportControls", styles_module_default19);
7145
+ var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default19);
7557
7146
  var ViewportButton = ({
7558
7147
  children,
7559
7148
  height = "auto",
@@ -7562,20 +7151,21 @@ var ViewportButton = ({
7562
7151
  onClick
7563
7152
  }) => {
7564
7153
  const viewports = useAppStore((s) => s.state.ui.viewports);
7565
- const [isActive, setIsActive] = useState21(false);
7566
- useEffect23(() => {
7154
+ const [isActive, setIsActive] = useState18(false);
7155
+ useEffect21(() => {
7567
7156
  setIsActive(width === viewports.current.width);
7568
7157
  }, [width, viewports.current.width]);
7569
- return /* @__PURE__ */ jsx38("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx38(
7158
+ return /* @__PURE__ */ jsx35("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx35(
7570
7159
  IconButton,
7571
7160
  {
7161
+ type: "button",
7572
7162
  title,
7573
7163
  disabled: isActive,
7574
7164
  onClick: (e) => {
7575
7165
  e.stopPropagation();
7576
7166
  onClick({ width, height });
7577
7167
  },
7578
- children: /* @__PURE__ */ jsx38("span", { className: getClassNameButton("inner"), children })
7168
+ children: /* @__PURE__ */ jsx35("span", { className: getClassNameButton("inner"), children })
7579
7169
  }
7580
7170
  ) });
7581
7171
  };
@@ -7599,7 +7189,7 @@ var ViewportControls = ({
7599
7189
  const defaultsContainAutoZoom = defaultZoomOptions.find(
7600
7190
  (option) => option.value === autoZoom
7601
7191
  );
7602
- const zoomOptions = useMemo19(
7192
+ const zoomOptions = useMemo17(
7603
7193
  () => [
7604
7194
  ...defaultZoomOptions,
7605
7195
  ...defaultsContainAutoZoom ? [] : [
@@ -7611,8 +7201,8 @@ var ViewportControls = ({
7611
7201
  ].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
7612
7202
  [autoZoom]
7613
7203
  );
7614
- return /* @__PURE__ */ jsxs18("div", { className: getClassName26(), children: [
7615
- viewports.map((viewport, i) => /* @__PURE__ */ jsx38(
7204
+ return /* @__PURE__ */ jsxs16("div", { className: getClassName24(), children: [
7205
+ viewports.map((viewport, i) => /* @__PURE__ */ jsx35(
7616
7206
  ViewportButton,
7617
7207
  {
7618
7208
  height: viewport.height,
@@ -7623,10 +7213,11 @@ var ViewportControls = ({
7623
7213
  },
7624
7214
  i
7625
7215
  )),
7626
- /* @__PURE__ */ jsx38("div", { className: getClassName26("divider") }),
7627
- /* @__PURE__ */ jsx38(
7216
+ /* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
7217
+ /* @__PURE__ */ jsx35(
7628
7218
  IconButton,
7629
7219
  {
7220
+ type: "button",
7630
7221
  title: "Zoom viewport out",
7631
7222
  disabled: zoom <= ((_a = zoomOptions[0]) == null ? void 0 : _a.value),
7632
7223
  onClick: (e) => {
@@ -7638,12 +7229,13 @@ var ViewportControls = ({
7638
7229
  )].value
7639
7230
  );
7640
7231
  },
7641
- children: /* @__PURE__ */ jsx38(ZoomOut, { size: 16 })
7232
+ children: /* @__PURE__ */ jsx35(ZoomOut, { size: 16 })
7642
7233
  }
7643
7234
  ),
7644
- /* @__PURE__ */ jsx38(
7235
+ /* @__PURE__ */ jsx35(
7645
7236
  IconButton,
7646
7237
  {
7238
+ type: "button",
7647
7239
  title: "Zoom viewport in",
7648
7240
  disabled: zoom >= ((_b = zoomOptions[zoomOptions.length - 1]) == null ? void 0 : _b.value),
7649
7241
  onClick: (e) => {
@@ -7655,19 +7247,19 @@ var ViewportControls = ({
7655
7247
  )].value
7656
7248
  );
7657
7249
  },
7658
- children: /* @__PURE__ */ jsx38(ZoomIn, { size: 16 })
7250
+ children: /* @__PURE__ */ jsx35(ZoomIn, { size: 16 })
7659
7251
  }
7660
7252
  ),
7661
- /* @__PURE__ */ jsx38("div", { className: getClassName26("divider") }),
7662
- /* @__PURE__ */ jsx38(
7253
+ /* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
7254
+ /* @__PURE__ */ jsx35(
7663
7255
  "select",
7664
7256
  {
7665
- className: getClassName26("zoomSelect"),
7257
+ className: getClassName24("zoomSelect"),
7666
7258
  value: zoom.toString(),
7667
7259
  onChange: (e) => {
7668
7260
  onZoom(parseFloat(e.currentTarget.value));
7669
7261
  },
7670
- children: zoomOptions.map((option) => /* @__PURE__ */ jsx38(
7262
+ children: zoomOptions.map((option) => /* @__PURE__ */ jsx35(
7671
7263
  "option",
7672
7264
  {
7673
7265
  value: option.value,
@@ -7682,7 +7274,7 @@ var ViewportControls = ({
7682
7274
 
7683
7275
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
7684
7276
  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" };
7277
+ 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
7278
 
7687
7279
  // lib/get-zoom-config.ts
7688
7280
  init_react_import();
@@ -7716,8 +7308,8 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
7716
7308
 
7717
7309
  // components/Puck/components/Canvas/index.tsx
7718
7310
  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);
7311
+ import { Fragment as Fragment11, jsx as jsx36, jsxs as jsxs17 } from "react/jsx-runtime";
7312
+ var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
7721
7313
  var ZOOM_ON_CHANGE = true;
7722
7314
  var Canvas = () => {
7723
7315
  const {
@@ -7747,344 +7339,585 @@ var Canvas = () => {
7747
7339
  }))
7748
7340
  );
7749
7341
  const frameRef = useRef7(null);
7750
- const [showTransition, setShowTransition] = useState22(false);
7751
- const defaultRender = useMemo20(() => {
7752
- const PuckDefault = ({ children }) => /* @__PURE__ */ jsx39(Fragment14, { children });
7342
+ const [showTransition, setShowTransition] = useState19(false);
7343
+ const defaultRender = useMemo18(() => {
7344
+ const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment11, { children });
7753
7345
  return PuckDefault;
7754
7346
  }, []);
7755
- const CustomPreview = useMemo20(
7347
+ const CustomPreview = useMemo18(
7756
7348
  () => overrides.preview || defaultRender,
7757
7349
  [overrides]
7758
7350
  );
7759
- const getFrameDimensions = useCallback17(() => {
7351
+ const getFrameDimensions = useCallback15(() => {
7760
7352
  if (frameRef.current) {
7761
7353
  const frame = frameRef.current;
7762
7354
  const box = getBox(frame);
7763
7355
  return { width: box.contentBox.width, height: box.contentBox.height };
7764
7356
  }
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]
7357
+ return { width: 0, height: 0 };
7358
+ }, [frameRef]);
7359
+ const resetAutoZoom = useCallback15(
7360
+ (newViewports = viewports) => {
7361
+ if (frameRef.current) {
7362
+ setZoomConfig(
7363
+ getZoomConfig(
7364
+ newViewports == null ? void 0 : newViewports.current,
7365
+ frameRef.current,
7366
+ zoomConfig.zoom
7367
+ )
7368
+ );
7369
+ }
7370
+ },
7371
+ [frameRef, zoomConfig, viewports]
7372
+ );
7373
+ useEffect22(() => {
7374
+ setShowTransition(false);
7375
+ resetAutoZoom(viewports);
7376
+ }, [frameRef, leftSideBarVisible, rightSideBarVisible]);
7377
+ useEffect22(() => {
7378
+ const { height: frameHeight } = getFrameDimensions();
7379
+ if (viewports.current.height === "auto") {
7380
+ setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
7381
+ rootHeight: frameHeight / zoomConfig.zoom
7382
+ }));
7383
+ }
7384
+ }, [zoomConfig.zoom]);
7385
+ useEffect22(() => {
7386
+ if (ZOOM_ON_CHANGE) {
7387
+ setShowTransition(true);
7388
+ resetAutoZoom(viewports);
7389
+ }
7390
+ }, [viewports.current.width]);
7391
+ useEffect22(() => {
7392
+ const cb = () => {
7393
+ setShowTransition(false);
7394
+ resetAutoZoom();
7395
+ };
7396
+ window.addEventListener("resize", cb);
7397
+ return () => {
7398
+ window.removeEventListener("resize", cb);
7399
+ };
7400
+ }, []);
7401
+ const [showLoader, setShowLoader] = useState19(false);
7402
+ useEffect22(() => {
7403
+ setTimeout(() => {
7404
+ setShowLoader(true);
7405
+ }, 500);
7406
+ }, []);
7407
+ return /* @__PURE__ */ jsxs17(
7408
+ "div",
7409
+ {
7410
+ className: getClassName25({
7411
+ ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
7412
+ showLoader
7413
+ }),
7414
+ onClick: () => dispatch({
7415
+ type: "setUi",
7416
+ ui: { itemSelector: null },
7417
+ recordHistory: true
7418
+ }),
7419
+ children: [
7420
+ viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx36("div", { className: getClassName25("controls"), children: /* @__PURE__ */ jsx36(
7421
+ ViewportControls,
7422
+ {
7423
+ autoZoom: zoomConfig.autoZoom,
7424
+ zoom: zoomConfig.zoom,
7425
+ onViewportChange: (viewport) => {
7426
+ setShowTransition(true);
7427
+ const uiViewport = __spreadProps(__spreadValues({}, viewport), {
7428
+ height: viewport.height || "auto",
7429
+ zoom: zoomConfig.zoom
7430
+ });
7431
+ const newUi = {
7432
+ viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport }),
7433
+ itemSelector: null
7434
+ };
7435
+ setUi(newUi);
7436
+ if (ZOOM_ON_CHANGE) {
7437
+ resetAutoZoom(__spreadProps(__spreadValues({}, viewports), { current: uiViewport }));
7438
+ }
7439
+ },
7440
+ onZoom: (zoom) => {
7441
+ setShowTransition(true);
7442
+ setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
7443
+ }
7444
+ }
7445
+ ) }),
7446
+ /* @__PURE__ */ jsxs17("div", { className: getClassName25("inner"), ref: frameRef, children: [
7447
+ /* @__PURE__ */ jsx36(
7448
+ "div",
7449
+ {
7450
+ className: getClassName25("root"),
7451
+ style: {
7452
+ width: iframe.enabled ? viewports.current.width : "100%",
7453
+ height: zoomConfig.rootHeight,
7454
+ transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
7455
+ transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : "",
7456
+ overflow: iframe.enabled ? void 0 : "auto"
7457
+ },
7458
+ suppressHydrationWarning: true,
7459
+ id: "puck-canvas-root",
7460
+ onTransitionEnd: () => {
7461
+ window.dispatchEvent(
7462
+ new CustomEvent("viewportchange", {
7463
+ bubbles: true,
7464
+ cancelable: false
7465
+ })
7466
+ );
7467
+ },
7468
+ children: /* @__PURE__ */ jsx36(CustomPreview, { children: /* @__PURE__ */ jsx36(Preview2, {}) })
7469
+ }
7470
+ ),
7471
+ /* @__PURE__ */ jsx36("div", { className: getClassName25("loader"), children: /* @__PURE__ */ jsx36(Loader, { size: 24 }) })
7472
+ ] })
7473
+ ]
7474
+ }
7475
+ );
7476
+ };
7477
+
7478
+ // lib/use-loaded-overrides.ts
7479
+ init_react_import();
7480
+ import { useMemo as useMemo19 } from "react";
7481
+
7482
+ // lib/load-overrides.ts
7483
+ init_react_import();
7484
+ var loadOverrides = ({
7485
+ overrides,
7486
+ plugins
7487
+ }) => {
7488
+ const collected = __spreadValues({}, overrides);
7489
+ plugins == null ? void 0 : plugins.forEach((plugin) => {
7490
+ Object.keys(plugin.overrides).forEach((_overridesType) => {
7491
+ const overridesType = _overridesType;
7492
+ if (overridesType === "fieldTypes") {
7493
+ const fieldTypes = plugin.overrides.fieldTypes;
7494
+ Object.keys(fieldTypes).forEach((fieldType) => {
7495
+ collected.fieldTypes = collected.fieldTypes || {};
7496
+ const childNode2 = collected.fieldTypes[fieldType];
7497
+ const Comp2 = (props) => fieldTypes[fieldType](__spreadProps(__spreadValues({}, props), {
7498
+ children: childNode2 ? childNode2(props) : props.children
7499
+ }));
7500
+ collected.fieldTypes[fieldType] = Comp2;
7501
+ });
7502
+ return;
7503
+ }
7504
+ const childNode = collected[overridesType];
7505
+ const Comp = (props) => plugin.overrides[overridesType](__spreadProps(__spreadValues({}, props), {
7506
+ children: childNode ? childNode(props) : props.children
7507
+ }));
7508
+ collected[overridesType] = Comp;
7509
+ });
7510
+ });
7511
+ return collected;
7512
+ };
7513
+
7514
+ // lib/use-loaded-overrides.ts
7515
+ var useLoadedOverrides = ({
7516
+ overrides,
7517
+ plugins
7518
+ }) => {
7519
+ return useMemo19(() => {
7520
+ return loadOverrides({ overrides, plugins });
7521
+ }, [plugins, overrides]);
7522
+ };
7523
+
7524
+ // components/DefaultOverride/index.tsx
7525
+ init_react_import();
7526
+ import { Fragment as Fragment12, jsx as jsx37 } from "react/jsx-runtime";
7527
+ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment12, { children });
7528
+
7529
+ // lib/use-inject-css.ts
7530
+ init_react_import();
7531
+ import { useEffect as useEffect23, useState as useState20 } from "react";
7532
+ var styles = ``;
7533
+ var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7534
+ const [el, setEl] = useState20();
7535
+ useEffect23(() => {
7536
+ setEl(document.createElement("style"));
7537
+ }, []);
7538
+ useEffect23(() => {
7539
+ var _a;
7540
+ if (!el || typeof window === "undefined") {
7541
+ return;
7542
+ }
7543
+ el.innerHTML = initialStyles;
7544
+ if (iframeEnabled) {
7545
+ const frame = getFrame();
7546
+ (_a = frame == null ? void 0 : frame.head) == null ? void 0 : _a.appendChild(el);
7547
+ }
7548
+ document.head.appendChild(el);
7549
+ }, [iframeEnabled, el]);
7550
+ return el;
7551
+ };
7552
+ var useInjectGlobalCss = (iframeEnabled) => {
7553
+ return useInjectStyleSheet(styles, iframeEnabled);
7554
+ };
7555
+
7556
+ // lib/use-preview-mode-hotkeys.ts
7557
+ init_react_import();
7558
+ import { useCallback as useCallback16 } from "react";
7559
+ var usePreviewModeHotkeys = () => {
7560
+ const appStore = useAppStoreApi();
7561
+ const toggleInteractive = useCallback16(() => {
7562
+ const dispatch = appStore.getState().dispatch;
7563
+ dispatch({
7564
+ type: "setUi",
7565
+ ui: (ui) => ({
7566
+ previewMode: ui.previewMode === "edit" ? "interactive" : "edit"
7567
+ })
7568
+ });
7569
+ }, [appStore]);
7570
+ useHotkey({ meta: true, i: true }, toggleInteractive);
7571
+ useHotkey({ ctrl: true, i: true }, toggleInteractive);
7572
+ };
7573
+
7574
+ // lib/use-puck.ts
7575
+ init_react_import();
7576
+ import { createContext as createContext6, useContext as useContext11, useEffect as useEffect24, useState as useState21 } from "react";
7577
+ import { createStore as createStore4, useStore as useStore3 } from "zustand";
7578
+ var generateUsePuck = (store) => {
7579
+ const history = {
7580
+ back: store.history.back,
7581
+ forward: store.history.forward,
7582
+ setHistories: store.history.setHistories,
7583
+ setHistoryIndex: store.history.setHistoryIndex,
7584
+ hasPast: store.history.hasPast(),
7585
+ hasFuture: store.history.hasFuture(),
7586
+ histories: store.history.histories,
7587
+ index: store.history.index
7588
+ };
7589
+ const storeData = {
7590
+ appState: makeStatePublic(store.state),
7591
+ config: store.config,
7592
+ dispatch: store.dispatch,
7593
+ getPermissions: store.permissions.getPermissions,
7594
+ refreshPermissions: store.permissions.refreshPermissions,
7595
+ history,
7596
+ selectedItem: store.selectedItem || null,
7597
+ getItemBySelector: (selector) => getItem(selector, store.state),
7598
+ getItemById: (id) => store.state.indexes.nodes[id].data,
7599
+ getSelectorForId: (id) => {
7600
+ const node = store.state.indexes.nodes[id];
7601
+ if (!node) return;
7602
+ const zoneCompound = `${node.parentId}:${node.zone}`;
7603
+ const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
7604
+ return { zone: zoneCompound, index };
7605
+ }
7606
+ };
7607
+ const get = () => storeData;
7608
+ return __spreadProps(__spreadValues({}, storeData), { get });
7609
+ };
7610
+ var UsePuckStoreContext = createContext6(
7611
+ null
7612
+ );
7613
+ var convertToPickedStore = (store) => {
7614
+ return {
7615
+ state: store.state,
7616
+ config: store.config,
7617
+ dispatch: store.dispatch,
7618
+ permissions: store.permissions,
7619
+ history: store.history,
7620
+ selectedItem: store.selectedItem
7621
+ };
7622
+ };
7623
+ var useRegisterUsePuckStore = (appStore) => {
7624
+ const [usePuckStore] = useState21(
7625
+ () => createStore4(
7626
+ () => generateUsePuck(convertToPickedStore(appStore.getState()))
7627
+ )
7780
7628
  );
7781
7629
  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
- };
7630
+ return appStore.subscribe(
7631
+ (store) => convertToPickedStore(store),
7632
+ (pickedStore) => {
7633
+ usePuckStore.setState(generateUsePuck(pickedStore));
7634
+ }
7635
+ );
7808
7636
  }, []);
7809
- const [showLoader, setShowLoader] = useState22(false);
7637
+ return usePuckStore;
7638
+ };
7639
+ function createUsePuck() {
7640
+ return function usePuck2(selector) {
7641
+ const usePuckApi = useContext11(UsePuckStoreContext);
7642
+ if (!usePuckApi) {
7643
+ throw new Error("usePuck must be used inside <Puck>.");
7644
+ }
7645
+ const result = useStore3(
7646
+ usePuckApi,
7647
+ selector != null ? selector : (s) => s
7648
+ );
7649
+ return result;
7650
+ };
7651
+ }
7652
+ function usePuck() {
7810
7653
  useEffect24(() => {
7811
- setTimeout(() => {
7812
- setShowLoader(true);
7813
- }, 500);
7654
+ console.warn(
7655
+ "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."
7656
+ );
7814
7657
  }, []);
7815
- return /* @__PURE__ */ jsxs19(
7658
+ return createUsePuck()((s) => s);
7659
+ }
7660
+ function useGetPuck() {
7661
+ const usePuckApi = useContext11(UsePuckStoreContext);
7662
+ if (!usePuckApi) {
7663
+ throw new Error("usePuckGet must be used inside <Puck>.");
7664
+ }
7665
+ return usePuckApi.getState;
7666
+ }
7667
+
7668
+ // components/Puck/index.tsx
7669
+ import fdeq from "fast-deep-equal";
7670
+
7671
+ // components/Puck/components/Header/index.tsx
7672
+ init_react_import();
7673
+ import { memo as memo3, useCallback as useCallback17, useMemo as useMemo20, useState as useState22 } from "react";
7674
+
7675
+ // components/MenuBar/index.tsx
7676
+ init_react_import();
7677
+
7678
+ // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
7679
+ init_react_import();
7680
+ 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" };
7681
+
7682
+ // components/MenuBar/index.tsx
7683
+ import { Fragment as Fragment13, jsx as jsx38, jsxs as jsxs18 } from "react/jsx-runtime";
7684
+ var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
7685
+ function MenuBar({
7686
+ menuOpen = false,
7687
+ renderHeaderActions,
7688
+ setMenuOpen
7689
+ }) {
7690
+ const back = useAppStore((s) => s.history.back);
7691
+ const forward = useAppStore((s) => s.history.forward);
7692
+ const hasFuture = useAppStore((s) => s.history.hasFuture());
7693
+ const hasPast = useAppStore((s) => s.history.hasPast());
7694
+ return /* @__PURE__ */ jsx38(
7816
7695
  "div",
7817
7696
  {
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",
7697
+ className: getClassName26({ menuOpen }),
7698
+ onClick: (event) => {
7699
+ var _a;
7700
+ const element = event.target;
7701
+ if (window.matchMedia("(min-width: 638px)").matches) {
7702
+ return;
7703
+ }
7704
+ if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
7705
+ setMenuOpen(false);
7706
+ }
7707
+ },
7708
+ children: /* @__PURE__ */ jsxs18("div", { className: getClassName26("inner"), children: [
7709
+ /* @__PURE__ */ jsxs18("div", { className: getClassName26("history"), children: [
7710
+ /* @__PURE__ */ jsx38(
7711
+ IconButton,
7857
7712
  {
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, {}) })
7713
+ type: "button",
7714
+ title: "undo",
7715
+ disabled: !hasPast,
7716
+ onClick: back,
7717
+ children: /* @__PURE__ */ jsx38(Undo2, { size: 21 })
7877
7718
  }
7878
7719
  ),
7879
- /* @__PURE__ */ jsx39("div", { className: getClassName27("loader"), children: /* @__PURE__ */ jsx39(Loader, { size: 24 }) })
7880
- ] })
7881
- ]
7720
+ /* @__PURE__ */ jsx38(
7721
+ IconButton,
7722
+ {
7723
+ type: "button",
7724
+ title: "redo",
7725
+ disabled: !hasFuture,
7726
+ onClick: forward,
7727
+ children: /* @__PURE__ */ jsx38(Redo2, { size: 21 })
7728
+ }
7729
+ )
7730
+ ] }),
7731
+ /* @__PURE__ */ jsx38(Fragment13, { children: renderHeaderActions && renderHeaderActions() })
7732
+ ] })
7882
7733
  }
7883
7734
  );
7884
- };
7885
-
7886
- // components/Puck/components/Nav/index.tsx
7887
- init_react_import();
7735
+ }
7888
7736
 
7889
- // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Nav/styles.module.css#css-module
7737
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
7890
7738
  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
- };
7739
+ 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
7740
 
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";
7741
+ // components/Puck/components/Header/index.tsx
7742
+ import { Fragment as Fragment14, jsx as jsx39, jsxs as jsxs19 } from "react/jsx-runtime";
7743
+ var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
7744
+ var HeaderInner = () => {
7745
+ const {
7746
+ onPublish,
7747
+ renderHeader,
7748
+ renderHeaderActions,
7749
+ headerTitle,
7750
+ headerPath,
7751
+ iframe: _iframe
7752
+ } = usePropsContext();
7753
+ const dispatch = useAppStore((s) => s.dispatch);
7754
+ const appStore = useAppStoreApi();
7755
+ const defaultHeaderRender = useMemo20(() => {
7756
+ if (renderHeader) {
7757
+ console.warn(
7758
+ "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
7759
+ );
7760
+ const RenderHeader = (_a) => {
7761
+ var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
7762
+ const Comp = renderHeader;
7763
+ const appState = useAppStore((s) => s.state);
7764
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
7765
+ };
7766
+ return RenderHeader;
7767
+ }
7768
+ return DefaultOverride;
7769
+ }, [renderHeader]);
7770
+ const defaultHeaderActionsRender = useMemo20(() => {
7771
+ if (renderHeaderActions) {
7772
+ console.warn(
7773
+ "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
7774
+ );
7775
+ const RenderHeader = (props) => {
7776
+ const Comp = renderHeaderActions;
7777
+ const appState = useAppStore((s) => s.state);
7778
+ return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
7779
+ };
7780
+ return RenderHeader;
7938
7781
  }
7782
+ return DefaultOverride;
7783
+ }, [renderHeader]);
7784
+ const CustomHeader = useAppStore(
7785
+ (s) => s.overrides.header || defaultHeaderRender
7939
7786
  );
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]
7787
+ const CustomHeaderActions = useAppStore(
7788
+ (s) => s.overrides.headerActions || defaultHeaderActionsRender
7955
7789
  );
7956
- useInjectGlobalCss(iframe.enabled);
7790
+ const [menuOpen, setMenuOpen] = useState22(false);
7791
+ const rootTitle = useAppStore((s) => {
7792
+ var _a, _b;
7793
+ const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
7794
+ return (_b = rootData.props.title) != null ? _b : "";
7795
+ });
7957
7796
  const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
7958
7797
  const rightSideBarVisible = useAppStore(
7959
7798
  (s) => s.state.ui.rightSideBarVisible
7960
7799
  );
7961
- const dispatch = useAppStore((s) => s.dispatch);
7962
- useEffect25(() => {
7963
- if (!window.matchMedia("(min-width: 638px)").matches) {
7800
+ const toggleSidebars = useCallback17(
7801
+ (sidebar) => {
7802
+ const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7803
+ const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
7804
+ const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
7964
7805
  dispatch({
7965
7806
  type: "setUi",
7966
- ui: {
7967
- leftSideBarVisible: false,
7968
- rightSideBarVisible: false
7969
- }
7807
+ ui: __spreadValues({
7808
+ [`${sidebar}SideBarVisible`]: !sideBarVisible
7809
+ }, !widerViewport ? { [oppositeSideBar]: false } : {})
7970
7810
  });
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]
7811
+ },
7812
+ [dispatch, leftSideBarVisible, rightSideBarVisible]
7989
7813
  );
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, {}),
7814
+ return /* @__PURE__ */ jsx39(
7815
+ CustomHeader,
7816
+ {
7817
+ actions: /* @__PURE__ */ jsx39(Fragment14, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7818
+ Button,
7819
+ {
8014
7820
  onClick: () => {
8015
- setView(plugin.name);
7821
+ const data = appStore.getState().state.data;
7822
+ onPublish && onPublish(data);
8016
7823
  },
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, {}),
7824
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7825
+ children: "Publish"
7826
+ }
7827
+ ) }) }),
7828
+ children: /* @__PURE__ */ jsx39(
7829
+ "header",
7830
+ {
7831
+ className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
7832
+ children: /* @__PURE__ */ jsxs19("div", { className: getClassName27("inner"), children: [
7833
+ /* @__PURE__ */ jsxs19("div", { className: getClassName27("toggle"), children: [
7834
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ jsx39(
7835
+ IconButton,
7836
+ {
7837
+ type: "button",
7838
+ onClick: () => {
7839
+ toggleSidebars("left");
7840
+ },
7841
+ title: "Toggle left sidebar",
7842
+ children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
7843
+ }
7844
+ ) }),
7845
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ jsx39(
7846
+ IconButton,
7847
+ {
7848
+ type: "button",
7849
+ onClick: () => {
7850
+ toggleSidebars("right");
7851
+ },
7852
+ title: "Toggle right sidebar",
7853
+ children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
7854
+ }
7855
+ ) })
7856
+ ] }),
7857
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("title"), children: /* @__PURE__ */ jsxs19(Heading, { rank: "2", size: "xs", children: [
7858
+ headerTitle || rootTitle || "Page",
7859
+ headerPath && /* @__PURE__ */ jsxs19(Fragment14, { children: [
7860
+ " ",
7861
+ /* @__PURE__ */ jsx39("code", { className: getClassName27("path"), children: headerPath })
7862
+ ] })
7863
+ ] }) }),
7864
+ /* @__PURE__ */ jsxs19("div", { className: getClassName27("tools"), children: [
7865
+ /* @__PURE__ */ jsx39("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ jsx39(
7866
+ IconButton,
7867
+ {
7868
+ type: "button",
7869
+ onClick: () => {
7870
+ return setMenuOpen(!menuOpen);
7871
+ },
7872
+ title: "Toggle menu bar",
7873
+ children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
7874
+ }
7875
+ ) }),
7876
+ /* @__PURE__ */ jsx39(
7877
+ MenuBar,
7878
+ {
7879
+ dispatch,
7880
+ onPublish,
7881
+ menuOpen,
7882
+ renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
7883
+ Button,
7884
+ {
8063
7885
  onClick: () => {
8064
- setView("outline");
7886
+ const data = appStore.getState().state.data;
7887
+ onPublish && onPublish(data);
8065
7888
  },
8066
- isActive: view === "outline"
7889
+ icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
7890
+ children: "Publish"
8067
7891
  }
8068
- }, pluginItems)
7892
+ ) }),
7893
+ setMenuOpen
8069
7894
  }
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
- ] });
7895
+ )
7896
+ ] })
7897
+ ] })
7898
+ }
7899
+ )
7900
+ }
7901
+ );
8081
7902
  };
7903
+ var Header = memo3(HeaderInner);
8082
7904
 
8083
7905
  // components/Puck/index.tsx
8084
- import { jsx as jsx42 } from "react/jsx-runtime";
7906
+ import { jsx as jsx40, jsxs as jsxs20 } from "react/jsx-runtime";
7907
+ var getClassName28 = get_class_name_factory_default("Puck", styles_module_default14);
7908
+ var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
7909
+ var FieldSideBar = () => {
7910
+ const title = useAppStore(
7911
+ (s) => {
7912
+ var _a, _b;
7913
+ return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
7914
+ }
7915
+ );
7916
+ return /* @__PURE__ */ jsx40(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx40(Fields, {}) });
7917
+ };
8085
7918
  var propsContext = createContext7({});
8086
7919
  function PropsProvider(props) {
8087
- return /* @__PURE__ */ jsx42(propsContext.Provider, { value: props, children: props.children });
7920
+ return /* @__PURE__ */ jsx40(propsContext.Provider, { value: props, children: props.children });
8088
7921
  }
8089
7922
  var usePropsContext = () => useContext12(propsContext);
8090
7923
  function PuckProvider({ children }) {
@@ -8102,14 +7935,14 @@ function PuckProvider({ children }) {
8102
7935
  metadata,
8103
7936
  onAction
8104
7937
  } = usePropsContext();
8105
- const iframe = useMemo22(
7938
+ const iframe = useMemo21(
8106
7939
  () => __spreadValues({
8107
7940
  enabled: true,
8108
7941
  waitForStyles: true
8109
7942
  }, _iframe),
8110
7943
  [_iframe]
8111
7944
  );
8112
- const [generatedAppState] = useState24(() => {
7945
+ const [generatedAppState] = useState23(() => {
8113
7946
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
8114
7947
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
8115
7948
  let clientUiState = {};
@@ -8169,7 +8002,7 @@ function PuckProvider({ children }) {
8169
8002
  return walkAppState(newAppState, config);
8170
8003
  });
8171
8004
  const { appendData = true } = _initialHistory || {};
8172
- const [blendedHistories] = useState24(
8005
+ const [blendedHistories] = useState23(
8173
8006
  [
8174
8007
  ...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
8175
8008
  ...appendData ? [{ state: generatedAppState }] : []
@@ -8213,15 +8046,15 @@ function PuckProvider({ children }) {
8213
8046
  metadata
8214
8047
  ]
8215
8048
  );
8216
- const [appStore] = useState24(
8049
+ const [appStore] = useState23(
8217
8050
  () => createAppStore(generateAppStore(initialAppState))
8218
8051
  );
8219
- useEffect26(() => {
8052
+ useEffect25(() => {
8220
8053
  if (process.env.NODE_ENV !== "production") {
8221
8054
  window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
8222
8055
  }
8223
8056
  }, [appStore]);
8224
- useEffect26(() => {
8057
+ useEffect25(() => {
8225
8058
  const state = appStore.getState().state;
8226
8059
  appStore.setState(__spreadValues({}, generateAppStore(state)));
8227
8060
  }, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
@@ -8231,7 +8064,7 @@ function PuckProvider({ children }) {
8231
8064
  initialAppState
8232
8065
  });
8233
8066
  const previousData = useRef8(null);
8234
- useEffect26(() => {
8067
+ useEffect25(() => {
8235
8068
  appStore.subscribe(
8236
8069
  (s) => s.state.data,
8237
8070
  (data) => {
@@ -8245,14 +8078,99 @@ function PuckProvider({ children }) {
8245
8078
  }, []);
8246
8079
  useRegisterPermissionsSlice(appStore, permissions);
8247
8080
  const uPuckStore = useRegisterUsePuckStore(appStore);
8248
- useEffect26(() => {
8081
+ useEffect25(() => {
8249
8082
  const { resolveAndCommitData } = appStore.getState();
8250
8083
  resolveAndCommitData();
8251
8084
  }, []);
8252
- return /* @__PURE__ */ jsx42(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx42(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8085
+ return /* @__PURE__ */ jsx40(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx40(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
8086
+ }
8087
+ function PuckLayout({ children }) {
8088
+ const {
8089
+ iframe: _iframe,
8090
+ dnd,
8091
+ initialHistory: _initialHistory
8092
+ } = usePropsContext();
8093
+ const iframe = useMemo21(
8094
+ () => __spreadValues({
8095
+ enabled: true,
8096
+ waitForStyles: true
8097
+ }, _iframe),
8098
+ [_iframe]
8099
+ );
8100
+ useInjectGlobalCss(iframe.enabled);
8101
+ const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
8102
+ const rightSideBarVisible = useAppStore(
8103
+ (s) => s.state.ui.rightSideBarVisible
8104
+ );
8105
+ const dispatch = useAppStore((s) => s.dispatch);
8106
+ useEffect25(() => {
8107
+ if (!window.matchMedia("(min-width: 638px)").matches) {
8108
+ dispatch({
8109
+ type: "setUi",
8110
+ ui: {
8111
+ leftSideBarVisible: false,
8112
+ rightSideBarVisible: false
8113
+ }
8114
+ });
8115
+ }
8116
+ const handleResize = () => {
8117
+ if (!window.matchMedia("(min-width: 638px)").matches) {
8118
+ dispatch({
8119
+ type: "setUi",
8120
+ ui: (ui) => __spreadValues(__spreadValues({}, ui), ui.rightSideBarVisible ? { leftSideBarVisible: false } : {})
8121
+ });
8122
+ }
8123
+ };
8124
+ window.addEventListener("resize", handleResize);
8125
+ return () => {
8126
+ window.removeEventListener("resize", handleResize);
8127
+ };
8128
+ }, []);
8129
+ const overrides = useAppStore((s) => s.overrides);
8130
+ const CustomPuck = useMemo21(
8131
+ () => overrides.puck || DefaultOverride,
8132
+ [overrides]
8133
+ );
8134
+ const [mounted, setMounted] = useState23(false);
8135
+ useEffect25(() => {
8136
+ setMounted(true);
8137
+ }, []);
8138
+ const ready = useAppStore((s) => s.status === "READY");
8139
+ useMonitorHotkeys();
8140
+ useEffect25(() => {
8141
+ if (ready && iframe.enabled) {
8142
+ const frameDoc = getFrame();
8143
+ if (frameDoc) {
8144
+ return monitorHotkeys(frameDoc);
8145
+ }
8146
+ }
8147
+ }, [ready, iframe.enabled]);
8148
+ usePreviewModeHotkeys();
8149
+ return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName28()}`, children: [
8150
+ /* @__PURE__ */ jsx40(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx40(CustomPuck, { children: children || /* @__PURE__ */ jsx40(
8151
+ "div",
8152
+ {
8153
+ className: getLayoutClassName({
8154
+ leftSideBarVisible,
8155
+ mounted,
8156
+ rightSideBarVisible
8157
+ }),
8158
+ children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
8159
+ /* @__PURE__ */ jsx40(Header, {}),
8160
+ /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("leftSideBar"), children: [
8161
+ /* @__PURE__ */ jsx40(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx40(Components, {}) }),
8162
+ /* @__PURE__ */ jsx40(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx40(Outline, {}) })
8163
+ ] }),
8164
+ /* @__PURE__ */ jsx40(Canvas, {}),
8165
+ /* @__PURE__ */ jsx40("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx40(FieldSideBar, {}) })
8166
+ ] })
8167
+ }
8168
+ ) }) }),
8169
+ /* @__PURE__ */ jsx40("div", { id: "puck-portal-root", className: getClassName28("portal") })
8170
+ ] });
8253
8171
  }
8254
8172
  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 }) })) }));
8173
+ return /* @__PURE__ */ jsx40(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx40(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx40(PuckLayout, __spreadValues({}, props)) })) }));
8256
8174
  }
8257
8175
  Puck.Components = Components;
8258
8176
  Puck.Fields = Fields;
@@ -8386,14 +8304,6 @@ lucide-react/dist/esm/icons/globe.js:
8386
8304
  * See the LICENSE file in the root directory of this source tree.
8387
8305
  *)
8388
8306
 
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
8307
  lucide-react/dist/esm/icons/hash.js:
8398
8308
  (**
8399
8309
  * @license lucide-react v0.468.0 - ISC
@@ -8522,14 +8432,6 @@ lucide-react/dist/esm/icons/tablet.js:
8522
8432
  * See the LICENSE file in the root directory of this source tree.
8523
8433
  *)
8524
8434
 
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
8435
  lucide-react/dist/esm/icons/trash.js:
8534
8436
  (**
8535
8437
  * @license lucide-react v0.468.0 - ISC