@measured/puck 0.16.0-canary.2bef00b → 0.16.0-canary.2cce878

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
@@ -8,7 +8,7 @@ import {
8
8
  init_react_import,
9
9
  rootDroppableId,
10
10
  setupZone
11
- } from "./chunk-TM7CT64S.mjs";
11
+ } from "./chunk-LM7YWFFF.mjs";
12
12
 
13
13
  // ../../node_modules/classnames/index.js
14
14
  var require_classnames = __commonJS({
@@ -65,46 +65,73 @@ var require_classnames = __commonJS({
65
65
  // index.ts
66
66
  init_react_import();
67
67
 
68
+ // types/API/index.ts
69
+ init_react_import();
70
+
71
+ // types/API/Viewports.ts
72
+ init_react_import();
73
+
74
+ // types/index.ts
75
+ init_react_import();
76
+
77
+ // types/API/Overrides.ts
78
+ init_react_import();
79
+ var overrideKeys = [
80
+ "header",
81
+ "headerActions",
82
+ "fields",
83
+ "fieldLabel",
84
+ "components",
85
+ "componentItem",
86
+ "outline",
87
+ "puck",
88
+ "preview"
89
+ ];
90
+
91
+ // types/AppState.tsx
92
+ init_react_import();
93
+
68
94
  // types/Config.tsx
69
95
  init_react_import();
70
96
 
71
- // types/Plugin.ts
97
+ // types/Data.tsx
72
98
  init_react_import();
73
99
 
74
100
  // types/Fields.ts
75
101
  init_react_import();
76
102
 
103
+ // types/Props.tsx
104
+ init_react_import();
105
+
106
+ // types/Utils.tsx
107
+ init_react_import();
108
+
77
109
  // components/ActionBar/index.tsx
78
110
  init_react_import();
79
111
 
80
112
  // lib/get-class-name-factory.ts
81
113
  init_react_import();
82
114
  var import_classnames = __toESM(require_classnames());
83
- var getClassNameFactory = (rootClass, styles, { baseClass = "" } = {}) => (options = {}) => {
84
- let descendant = false;
85
- let modifiers = false;
115
+ var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (options = {}) => {
86
116
  if (typeof options === "string") {
87
- descendant = options;
88
- } else if (typeof options === "object") {
89
- modifiers = options;
90
- }
91
- if (descendant) {
117
+ const descendant = options;
92
118
  const style = styles[`${rootClass}-${descendant}`];
93
119
  if (style) {
94
- return baseClass + styles[`${rootClass}-${descendant}`] || "";
120
+ return config.baseClass + styles[`${rootClass}-${descendant}`] || "";
95
121
  }
96
122
  return "";
97
- } else if (modifiers) {
123
+ } else if (typeof options === "object") {
124
+ const modifiers = options;
98
125
  const prefixedModifiers = {};
99
126
  for (let modifier in modifiers) {
100
127
  prefixedModifiers[styles[`${rootClass}--${modifier}`]] = modifiers[modifier];
101
128
  }
102
129
  const c = styles[rootClass];
103
- return baseClass + (0, import_classnames.default)(__spreadValues({
130
+ return config.baseClass + (0, import_classnames.default)(__spreadValues({
104
131
  [c]: !!c
105
132
  }, prefixedModifiers));
106
133
  } else {
107
- return baseClass + styles[rootClass] || "";
134
+ return config.baseClass + styles[rootClass] || "";
108
135
  }
109
136
  };
110
137
  var get_class_name_factory_default = getClassNameFactory;
@@ -127,7 +154,16 @@ var Action = ({
127
154
  children,
128
155
  label,
129
156
  onClick
130
- }) => /* @__PURE__ */ jsx("button", { className: getClassName("action"), onClick, title: label, children });
157
+ }) => /* @__PURE__ */ jsx(
158
+ "button",
159
+ {
160
+ type: "button",
161
+ className: getClassName("action"),
162
+ onClick,
163
+ title: label,
164
+ children
165
+ }
166
+ );
131
167
  ActionBar.Action = Action;
132
168
 
133
169
  // components/AutoField/index.tsx
@@ -562,14 +598,14 @@ import {
562
598
 
563
599
  // lib/get-item.ts
564
600
  init_react_import();
565
- var getItem = (selector, data, dynamicProps = {}) => {
601
+ function getItem(selector, data, dynamicProps = {}) {
566
602
  if (!selector.zone || selector.zone === rootDroppableId) {
567
603
  const item2 = data.content[selector.index];
568
604
  return (item2 == null ? void 0 : item2.props) ? __spreadProps(__spreadValues({}, item2), { props: dynamicProps[item2.props.id] || item2.props }) : void 0;
569
605
  }
570
606
  const item = setupZone(data, selector.zone).zones[selector.zone][selector.index];
571
607
  return (item == null ? void 0 : item.props) ? __spreadProps(__spreadValues({}, item), { props: dynamicProps[item.props.id] || item.props }) : void 0;
572
- };
608
+ }
573
609
 
574
610
  // components/ViewportControls/default-viewports.ts
575
611
  init_react_import();
@@ -583,7 +619,7 @@ var defaultViewports = [
583
619
  import { UAParser } from "ua-parser-js";
584
620
  import { jsx as jsx4 } from "react/jsx-runtime";
585
621
  var defaultAppState = {
586
- data: { content: [], root: { props: {} } },
622
+ data: { content: [], root: {} },
587
623
  ui: {
588
624
  leftSideBarVisible: true,
589
625
  rightSideBarVisible: true,
@@ -1322,6 +1358,7 @@ var ExternalInput = ({
1322
1358
  value && /* @__PURE__ */ jsx14(
1323
1359
  "button",
1324
1360
  {
1361
+ type: "button",
1325
1362
  className: getClassName10("detachButton"),
1326
1363
  onClick: () => {
1327
1364
  onChange(null);
@@ -1378,7 +1415,7 @@ var ExternalInput = ({
1378
1415
  }
1379
1416
  ) })
1380
1417
  ] })
1381
- ] }) : /* @__PURE__ */ jsx14(Heading, { rank: 2, size: "xs", children: field.placeholder || "Select data" }) }),
1418
+ ] }) : /* @__PURE__ */ jsx14(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
1382
1419
  /* @__PURE__ */ jsxs7("div", { className: getClassNameModal("grid"), children: [
1383
1420
  hasFilterFields && /* @__PURE__ */ jsx14("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
1384
1421
  const filterField = filterFields[fieldName];
@@ -2811,6 +2848,7 @@ var SidebarSection = ({
2811
2848
  /* @__PURE__ */ jsx26(
2812
2849
  "button",
2813
2850
  {
2851
+ type: "button",
2814
2852
  className: getClassName19("breadcrumbLabel"),
2815
2853
  onClick: () => setUi({ itemSelector: breadcrumb.selector }),
2816
2854
  children: breadcrumb.label
@@ -2818,7 +2856,7 @@ var SidebarSection = ({
2818
2856
  ),
2819
2857
  /* @__PURE__ */ jsx26(ChevronRight, { size: 16 })
2820
2858
  ] }, i)) : null,
2821
- /* @__PURE__ */ jsx26("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx26(Heading, { rank: 2, size: "xs", children: title }) })
2859
+ /* @__PURE__ */ jsx26("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx26(Heading, { rank: "2", size: "xs", children: title }) })
2822
2860
  ] }) }),
2823
2861
  /* @__PURE__ */ jsx26("div", { className: getClassName19("content"), children }),
2824
2862
  isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx26(Loader, { size: 32 }) })
@@ -2851,7 +2889,7 @@ var remove = (list, index) => {
2851
2889
 
2852
2890
  // lib/reduce-related-zones.ts
2853
2891
  init_react_import();
2854
- var reduceRelatedZones = (item, data, fn) => {
2892
+ function reduceRelatedZones(item, data, fn) {
2855
2893
  return __spreadProps(__spreadValues({}, data), {
2856
2894
  zones: Object.keys(data.zones || {}).reduce(
2857
2895
  (acc, key) => {
@@ -2865,28 +2903,34 @@ var reduceRelatedZones = (item, data, fn) => {
2865
2903
  {}
2866
2904
  )
2867
2905
  });
2868
- };
2906
+ }
2869
2907
  var findRelatedByZoneId = (zoneId, data) => {
2870
2908
  const [zoneParentId] = getZoneId(zoneId);
2871
- return (data.zones[zoneId] || []).reduce((acc, zoneItem) => {
2872
- const related = findRelatedByItem(zoneItem, data);
2873
- if (zoneItem.props.id === zoneParentId) {
2874
- return __spreadProps(__spreadValues(__spreadValues({}, acc), related), { [zoneId]: zoneItem });
2875
- }
2876
- return __spreadValues(__spreadValues({}, acc), related);
2877
- }, {});
2909
+ return (data.zones[zoneId] || []).reduce(
2910
+ (acc, zoneItem) => {
2911
+ const related = findRelatedByItem(zoneItem, data);
2912
+ if (zoneItem.props.id === zoneParentId) {
2913
+ return __spreadProps(__spreadValues(__spreadValues({}, acc), related), { [zoneId]: zoneItem });
2914
+ }
2915
+ return __spreadValues(__spreadValues({}, acc), related);
2916
+ },
2917
+ {}
2918
+ );
2878
2919
  };
2879
2920
  var findRelatedByItem = (item, data) => {
2880
- return Object.keys(data.zones || {}).reduce((acc, zoneId) => {
2881
- const [zoneParentId] = getZoneId(zoneId);
2882
- if (item.props.id === zoneParentId) {
2883
- const related = findRelatedByZoneId(zoneId, data);
2884
- return __spreadProps(__spreadValues(__spreadValues({}, acc), related), {
2885
- [zoneId]: data.zones[zoneId]
2886
- });
2887
- }
2888
- return acc;
2889
- }, {});
2921
+ return Object.keys(data.zones || {}).reduce(
2922
+ (acc, zoneId) => {
2923
+ const [zoneParentId] = getZoneId(zoneId);
2924
+ if (item.props.id === zoneParentId) {
2925
+ const related = findRelatedByZoneId(zoneId, data);
2926
+ return __spreadProps(__spreadValues(__spreadValues({}, acc), related), {
2927
+ [zoneId]: data.zones[zoneId]
2928
+ });
2929
+ }
2930
+ return acc;
2931
+ },
2932
+ {}
2933
+ );
2890
2934
  };
2891
2935
  var removeRelatedZones = (item, data) => {
2892
2936
  const newData = __spreadValues({}, data);
@@ -2896,7 +2940,7 @@ var removeRelatedZones = (item, data) => {
2896
2940
  });
2897
2941
  return newData;
2898
2942
  };
2899
- var duplicateRelatedZones = (item, data, newId) => {
2943
+ function duplicateRelatedZones(item, data, newId) {
2900
2944
  return reduceRelatedZones(item, data, (acc, key, zone) => {
2901
2945
  const dupedZone = zone.map((zoneItem) => __spreadProps(__spreadValues({}, zoneItem), {
2902
2946
  props: __spreadProps(__spreadValues({}, zoneItem.props), { id: generateId(zoneItem.type) })
@@ -2911,7 +2955,7 @@ var duplicateRelatedZones = (item, data, newId) => {
2911
2955
  [`${newId}:${zoneId}`]: dupedZone
2912
2956
  });
2913
2957
  });
2914
- };
2958
+ }
2915
2959
 
2916
2960
  // reducer/data.ts
2917
2961
  var zoneCache = {};
@@ -2935,7 +2979,7 @@ var replaceAction = (data, action) => {
2935
2979
  })
2936
2980
  });
2937
2981
  };
2938
- var insertAction = (data, action, config) => {
2982
+ function insertAction(data, action, config) {
2939
2983
  const emptyComponentData = {
2940
2984
  type: action.componentType,
2941
2985
  props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
@@ -2961,8 +3005,8 @@ var insertAction = (data, action, config) => {
2961
3005
  )
2962
3006
  })
2963
3007
  });
2964
- };
2965
- var reduceData = (data, action, config) => {
3008
+ }
3009
+ function reduceData(data, action, config) {
2966
3010
  if (action.type === "insert") {
2967
3011
  return insertAction(data, action, config);
2968
3012
  }
@@ -3111,7 +3155,7 @@ var reduceData = (data, action, config) => {
3111
3155
  return __spreadValues(__spreadValues({}, data), action.data(data));
3112
3156
  }
3113
3157
  return data;
3114
- };
3158
+ }
3115
3159
 
3116
3160
  // reducer/state.ts
3117
3161
  init_react_import();
@@ -3129,7 +3173,7 @@ var reduceUi = (ui, action) => {
3129
3173
  init_react_import();
3130
3174
 
3131
3175
  // reducer/index.ts
3132
- var storeInterceptor = (reducer, record, onAction) => {
3176
+ function storeInterceptor(reducer, record, onAction) {
3133
3177
  return (state, action) => {
3134
3178
  const newAppState = reducer(state, action);
3135
3179
  const isValidType = ![
@@ -3145,7 +3189,7 @@ var storeInterceptor = (reducer, record, onAction) => {
3145
3189
  onAction == null ? void 0 : onAction(action, newAppState, state);
3146
3190
  return newAppState;
3147
3191
  };
3148
- };
3192
+ }
3149
3193
  var setAction = (state, action) => {
3150
3194
  if (typeof action.state === "object") {
3151
3195
  return __spreadValues(__spreadValues({}, state), action.state);
@@ -3260,28 +3304,30 @@ var applyDynamicProps = (data, dynamicProps, rootData) => {
3260
3304
  // lib/resolve-root-data.ts
3261
3305
  init_react_import();
3262
3306
  var cache3 = {};
3263
- var resolveRootData = (data, config) => __async(void 0, null, function* () {
3264
- var _a, _b, _c, _d, _e;
3265
- if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
3266
- if (((_b = cache3.lastChange) == null ? void 0 : _b.original) === data.root) {
3267
- return cache3.lastChange.resolved;
3307
+ function resolveRootData(data, config) {
3308
+ return __async(this, null, function* () {
3309
+ var _a, _b, _c, _d, _e;
3310
+ if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
3311
+ if (((_b = cache3.lastChange) == null ? void 0 : _b.original) === data.root) {
3312
+ return cache3.lastChange.resolved;
3313
+ }
3314
+ const changed = getChanged(data.root, (_c = cache3.lastChange) == null ? void 0 : _c.original);
3315
+ const rootWithProps = data.root;
3316
+ const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
3317
+ changed,
3318
+ lastData: ((_d = cache3.lastChange) == null ? void 0 : _d.original) || {}
3319
+ });
3320
+ cache3.lastChange = {
3321
+ original: data.root,
3322
+ resolved: resolvedRoot
3323
+ };
3324
+ return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
3325
+ props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
3326
+ });
3268
3327
  }
3269
- const changed = getChanged(data.root, (_c = cache3.lastChange) == null ? void 0 : _c.original);
3270
- const rootWithProps = data.root;
3271
- const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
3272
- changed,
3273
- lastData: ((_d = cache3.lastChange) == null ? void 0 : _d.original) || {}
3274
- });
3275
- cache3.lastChange = {
3276
- original: data.root,
3277
- resolved: resolvedRoot
3278
- };
3279
- return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
3280
- props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
3281
- });
3282
- }
3283
- return data.root;
3284
- });
3328
+ return data.root;
3329
+ });
3330
+ }
3285
3331
 
3286
3332
  // lib/use-resolved-data.ts
3287
3333
  var useResolvedData = (appState, config, dispatch) => {
@@ -3386,15 +3432,14 @@ var styles_module_default14 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpe
3386
3432
  // components/MenuBar/index.tsx
3387
3433
  import { Fragment as Fragment12, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
3388
3434
  var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
3389
- var MenuBar = ({
3435
+ function MenuBar({
3390
3436
  appState,
3391
- data = { content: [], root: {} },
3392
3437
  dispatch,
3393
3438
  menuOpen = false,
3394
3439
  onPublish,
3395
3440
  renderHeaderActions,
3396
3441
  setMenuOpen
3397
- }) => {
3442
+ }) {
3398
3443
  const {
3399
3444
  history: { back, forward, historyStore }
3400
3445
  } = useAppContext();
@@ -3425,7 +3470,7 @@ var MenuBar = ({
3425
3470
  ] })
3426
3471
  }
3427
3472
  );
3428
- };
3473
+ }
3429
3474
 
3430
3475
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
3431
3476
  init_react_import();
@@ -3458,9 +3503,7 @@ var useResolvedFields = () => {
3458
3503
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
3459
3504
  const defaultFields = selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields;
3460
3505
  const rootProps = data.root.props || data.root;
3461
- const [lastSelectedData, setLastSelectedData] = useState14(
3462
- {}
3463
- );
3506
+ const [lastSelectedData, setLastSelectedData] = useState14({});
3464
3507
  const [resolvedFields, setResolvedFields] = useState14(defaultFields || {});
3465
3508
  const [fieldsLoading, setFieldsLoading] = useState14(false);
3466
3509
  const defaultResolveFields = (_componentData, _params) => defaultFields;
@@ -3623,7 +3666,7 @@ var Fields = () => {
3623
3666
  `${selectedItem.props.id}_${fieldName}`
3624
3667
  );
3625
3668
  } else {
3626
- const { readOnly = {} } = data.root;
3669
+ const readOnly = data.root.readOnly || {};
3627
3670
  return /* @__PURE__ */ jsx28(
3628
3671
  AutoFieldPrivate,
3629
3672
  {
@@ -3695,6 +3738,7 @@ var ComponentList = ({
3695
3738
  title && /* @__PURE__ */ jsxs16(
3696
3739
  "button",
3697
3740
  {
3741
+ type: "button",
3698
3742
  className: getClassName22("title"),
3699
3743
  onClick: () => setUi({
3700
3744
  componentList: __spreadProps(__spreadValues({}, state.ui.componentList), {
@@ -3863,13 +3907,17 @@ var defer = (fn) => setTimeout(fn, 0);
3863
3907
  var CopyHostStyles = ({
3864
3908
  children,
3865
3909
  debug = false,
3866
- onStylesLoaded = () => null
3910
+ onStylesLoaded = () => null,
3911
+ enabled = true
3867
3912
  }) => {
3868
3913
  const { document: doc, window: win } = useFrame();
3869
3914
  useEffect14(() => {
3870
3915
  if (!win || !doc) {
3871
- return () => {
3872
- };
3916
+ return;
3917
+ }
3918
+ if (!enabled) {
3919
+ onStylesLoaded();
3920
+ return;
3873
3921
  }
3874
3922
  let elements = [];
3875
3923
  const hashes = {};
@@ -4033,13 +4081,15 @@ function AutoFrame(_a) {
4033
4081
  className,
4034
4082
  debug,
4035
4083
  id,
4036
- onStylesLoaded
4084
+ onStylesLoaded,
4085
+ syncHostStyles = true
4037
4086
  } = _b, props = __objRest(_b, [
4038
4087
  "children",
4039
4088
  "className",
4040
4089
  "debug",
4041
4090
  "id",
4042
- "onStylesLoaded"
4091
+ "onStylesLoaded",
4092
+ "syncHostStyles"
4043
4093
  ]);
4044
4094
  const [loaded, setLoaded] = useState16(false);
4045
4095
  const [ctx, setCtx] = useState16({});
@@ -4065,7 +4115,15 @@ function AutoFrame(_a) {
4065
4115
  onLoad: () => {
4066
4116
  setLoaded(true);
4067
4117
  },
4068
- children: /* @__PURE__ */ jsx32(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx32(CopyHostStyles, { debug, onStylesLoaded, children: createPortal2(children, mountTarget) }) })
4118
+ children: /* @__PURE__ */ jsx32(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx32(
4119
+ CopyHostStyles,
4120
+ {
4121
+ debug,
4122
+ onStylesLoaded,
4123
+ enabled: syncHostStyles,
4124
+ children: createPortal2(children, mountTarget)
4125
+ }
4126
+ ) })
4069
4127
  })
4070
4128
  );
4071
4129
  }
@@ -4084,13 +4142,9 @@ var Preview = ({ id = "puck-preview" }) => {
4084
4142
  const Page = useCallback7(
4085
4143
  (pageProps) => {
4086
4144
  var _a, _b;
4087
- return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadProps(__spreadValues({
4145
+ return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
4088
4146
  id: "puck-root"
4089
- }, pageProps), {
4090
- editMode: true,
4091
- // DEPRECATED
4092
- puck: { renderDropZone: DropZone, isEditing: true }
4093
- })) : /* @__PURE__ */ jsx33(Fragment15, { children: pageProps.children });
4147
+ }, pageProps)) : /* @__PURE__ */ jsx33(Fragment15, { children: pageProps.children });
4094
4148
  },
4095
4149
  [config.root]
4096
4150
  );
@@ -4113,15 +4167,30 @@ var Preview = ({ id = "puck-preview" }) => {
4113
4167
  onStylesLoaded: () => {
4114
4168
  setStatus("READY");
4115
4169
  },
4170
+ syncHostStyles: iframe.syncHostStyles,
4116
4171
  children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
4117
- const inner = /* @__PURE__ */ jsx33(Page, __spreadProps(__spreadValues({ dispatch, state }, rootProps), { children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId }) }));
4172
+ const inner = /* @__PURE__ */ jsx33(
4173
+ Page,
4174
+ __spreadProps(__spreadValues({}, rootProps), {
4175
+ puck: { renderDropZone: DropZone, isEditing: true },
4176
+ editMode: true,
4177
+ children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
4178
+ })
4179
+ );
4118
4180
  if (Frame) {
4119
4181
  return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
4120
4182
  }
4121
4183
  return inner;
4122
4184
  } })
4123
4185
  }
4124
- ) : /* @__PURE__ */ jsx33("div", { id: "preview-frame", className: getClassName23("frame"), children: /* @__PURE__ */ jsx33(Page, __spreadProps(__spreadValues({ dispatch, state }, rootProps), { children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId }) })) })
4186
+ ) : /* @__PURE__ */ jsx33("div", { id: "preview-frame", className: getClassName23("frame"), children: /* @__PURE__ */ jsx33(
4187
+ Page,
4188
+ __spreadProps(__spreadValues({}, rootProps), {
4189
+ puck: { renderDropZone: DropZone, isEditing: true },
4190
+ editMode: true,
4191
+ children: /* @__PURE__ */ jsx33(DropZone, { zone: rootDroppableId })
4192
+ })
4193
+ ) })
4125
4194
  }
4126
4195
  );
4127
4196
  };
@@ -4235,6 +4304,7 @@ var LayerTree = ({
4235
4304
  /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs17(
4236
4305
  "button",
4237
4306
  {
4307
+ type: "button",
4238
4308
  className: getClassNameLayer("clickable"),
4239
4309
  onClick: () => {
4240
4310
  if (isSelected) {
@@ -4730,7 +4800,7 @@ var ViewportControls = ({
4730
4800
 
4731
4801
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
4732
4802
  init_react_import();
4733
- var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_6zd4y_1", "PuckCanvas-controls": "_PuckCanvas-controls_6zd4y_16", "PuckCanvas-inner": "_PuckCanvas-inner_6zd4y_21", "PuckCanvas-root": "_PuckCanvas-root_6zd4y_32", "PuckCanvas--ready": "_PuckCanvas--ready_6zd4y_56" };
4803
+ var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_esbg1_1", "PuckCanvas-controls": "_PuckCanvas-controls_esbg1_16", "PuckCanvas-inner": "_PuckCanvas-inner_esbg1_21", "PuckCanvas-root": "_PuckCanvas-root_esbg1_32", "PuckCanvas--ready": "_PuckCanvas--ready_esbg1_56", "PuckCanvas-loader": "_PuckCanvas-loader_esbg1_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_esbg1_70" };
4734
4804
 
4735
4805
  // lib/get-zoom-config.ts
4736
4806
  init_react_import();
@@ -4822,11 +4892,18 @@ var Canvas = () => {
4822
4892
  observer.disconnect();
4823
4893
  };
4824
4894
  }, []);
4895
+ const [showLoader, setShowLoader] = useState19(false);
4896
+ useEffect16(() => {
4897
+ setTimeout(() => {
4898
+ setShowLoader(true);
4899
+ }, 500);
4900
+ }, []);
4825
4901
  return /* @__PURE__ */ jsxs20(
4826
4902
  "div",
4827
4903
  {
4828
4904
  className: getClassName26({
4829
- ready: status === "READY" || !iframe.enabled
4905
+ ready: status === "READY" || !iframe.enabled,
4906
+ showLoader
4830
4907
  }),
4831
4908
  onClick: () => dispatch({
4832
4909
  type: "setUi",
@@ -4859,21 +4936,24 @@ var Canvas = () => {
4859
4936
  }
4860
4937
  }
4861
4938
  ) }),
4862
- /* @__PURE__ */ jsx37("div", { className: getClassName26("inner"), ref: frameRef, children: /* @__PURE__ */ jsx37(
4863
- "div",
4864
- {
4865
- className: getClassName26("root"),
4866
- style: {
4867
- width: iframe.enabled ? ui.viewports.current.width : "100%",
4868
- height: zoomConfig.rootHeight,
4869
- transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
4870
- transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : "",
4871
- overflow: iframe.enabled ? void 0 : "auto"
4872
- },
4873
- suppressHydrationWarning: true,
4874
- children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview, {}) })
4875
- }
4876
- ) })
4939
+ /* @__PURE__ */ jsxs20("div", { className: getClassName26("inner"), ref: frameRef, children: [
4940
+ /* @__PURE__ */ jsx37(
4941
+ "div",
4942
+ {
4943
+ className: getClassName26("root"),
4944
+ style: {
4945
+ width: iframe.enabled ? ui.viewports.current.width : "100%",
4946
+ height: zoomConfig.rootHeight,
4947
+ transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
4948
+ transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : "",
4949
+ overflow: iframe.enabled ? void 0 : "auto"
4950
+ },
4951
+ suppressHydrationWarning: true,
4952
+ children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview, {}) })
4953
+ }
4954
+ ),
4955
+ /* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
4956
+ ] })
4877
4957
  ]
4878
4958
  }
4879
4959
  );
@@ -4923,7 +5003,8 @@ var loadOverrides = ({
4923
5003
  }) => {
4924
5004
  const collected = __spreadValues({}, overrides);
4925
5005
  plugins == null ? void 0 : plugins.forEach((plugin) => {
4926
- Object.keys(plugin.overrides).forEach((overridesType) => {
5006
+ Object.keys(plugin.overrides).forEach((_overridesType) => {
5007
+ const overridesType = _overridesType;
4927
5008
  if (overridesType === "fieldTypes") {
4928
5009
  const fieldTypes = plugin.overrides.fieldTypes;
4929
5010
  Object.keys(fieldTypes).forEach((fieldType) => {
@@ -4963,7 +5044,7 @@ var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_mod
4963
5044
  function Puck({
4964
5045
  children,
4965
5046
  config,
4966
- data: initialData = { content: [], root: {} },
5047
+ data: initialData,
4967
5048
  ui: initialUi,
4968
5049
  onChange,
4969
5050
  onPublish,
@@ -4976,19 +5057,25 @@ function Puck({
4976
5057
  headerTitle,
4977
5058
  headerPath,
4978
5059
  viewports = defaultViewports,
4979
- iframe = {
4980
- enabled: true
4981
- },
5060
+ iframe: _iframe,
4982
5061
  dnd,
4983
5062
  initialHistory
4984
5063
  }) {
4985
5064
  var _a;
4986
5065
  const historyStore = useHistoryStore(initialHistory);
4987
5066
  const [reducer] = useState20(
4988
- () => createReducer({ config, record: historyStore.record, onAction })
5067
+ () => createReducer({
5068
+ config,
5069
+ record: historyStore.record,
5070
+ onAction
5071
+ })
4989
5072
  );
5073
+ const iframe = __spreadValues({
5074
+ enabled: true,
5075
+ syncHostStyles: true
5076
+ }, _iframe);
4990
5077
  const [initialAppState] = useState20(() => {
4991
- var _a2, _b, _c, _d, _e, _f, _g;
5078
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
4992
5079
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
4993
5080
  let clientUiState = {};
4994
5081
  if (typeof window !== "undefined") {
@@ -5008,20 +5095,20 @@ function Puck({
5008
5095
  clientUiState = {
5009
5096
  viewports: __spreadProps(__spreadValues({}, initial.viewports), {
5010
5097
  current: __spreadProps(__spreadValues({}, initial.viewports.current), {
5011
- height: ((_b = (_a2 = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a2.current) == null ? void 0 : _b.height) || viewports[closestViewport].height || "auto",
5012
- width: ((_d = (_c = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _c.current) == null ? void 0 : _d.width) || viewports[closestViewport].width
5098
+ height: ((_b = (_a2 = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a2.current) == null ? void 0 : _b.height) || ((_c = viewports[closestViewport]) == null ? void 0 : _c.height) || "auto",
5099
+ width: ((_e = (_d = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _d.current) == null ? void 0 : _e.width) || ((_f = viewports[closestViewport]) == null ? void 0 : _f.width)
5013
5100
  })
5014
5101
  })
5015
5102
  };
5016
5103
  }
5017
5104
  }
5018
- if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_e = initialData == null ? void 0 : initialData.root) == null ? void 0 : _e.props)) {
5105
+ if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_g = initialData == null ? void 0 : initialData.root) == null ? void 0 : _g.props)) {
5019
5106
  console.error(
5020
5107
  "Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
5021
5108
  );
5022
5109
  }
5023
- const rootProps2 = ((_f = initialData == null ? void 0 : initialData.root) == null ? void 0 : _f.props) || (initialData == null ? void 0 : initialData.root) || {};
5024
- const defaultedRootProps = __spreadValues(__spreadValues({}, (_g = config.root) == null ? void 0 : _g.defaultProps), rootProps2);
5110
+ const rootProps2 = ((_h = initialData == null ? void 0 : initialData.root) == null ? void 0 : _h.props) || (initialData == null ? void 0 : initialData.root) || {};
5111
+ const defaultedRootProps = __spreadValues(__spreadValues({}, (_i = config.root) == null ? void 0 : _i.defaultProps), rootProps2);
5025
5112
  return __spreadProps(__spreadValues({}, defaultAppState), {
5026
5113
  data: __spreadProps(__spreadValues({}, initialData), {
5027
5114
  root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps }),
@@ -5313,7 +5400,7 @@ function Puck({
5313
5400
  }
5314
5401
  )
5315
5402
  ] }),
5316
- /* @__PURE__ */ jsx38("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs21(Heading, { rank: 2, size: "xs", children: [
5403
+ /* @__PURE__ */ jsx38("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs21(Heading, { rank: "2", size: "xs", children: [
5317
5404
  headerTitle || rootProps.title || "Page",
5318
5405
  headerPath && /* @__PURE__ */ jsxs21(Fragment19, { children: [
5319
5406
  " ",
@@ -5341,7 +5428,6 @@ function Puck({
5341
5428
  MenuBar,
5342
5429
  {
5343
5430
  appState,
5344
- data,
5345
5431
  dispatch,
5346
5432
  onPublish,
5347
5433
  menuOpen,
@@ -5397,10 +5483,7 @@ Puck.Preview = Preview;
5397
5483
  // components/Render/index.tsx
5398
5484
  init_react_import();
5399
5485
  import { jsx as jsx39 } from "react/jsx-runtime";
5400
- function Render({
5401
- config,
5402
- data
5403
- }) {
5486
+ function Render({ config, data }) {
5404
5487
  var _a;
5405
5488
  const defaultedData = __spreadProps(__spreadValues({}, data), {
5406
5489
  root: data.root || {},
@@ -5580,6 +5663,7 @@ export {
5580
5663
  Render,
5581
5664
  dropZoneContext,
5582
5665
  migrate,
5666
+ overrideKeys,
5583
5667
  resolveAllData,
5584
5668
  transformProps,
5585
5669
  usePuck