@measured/puck 0.18.0-canary.63b8b9a → 0.18.0-canary.97d25d4

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -205,7 +205,7 @@ init_react_import();
205
205
 
206
206
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
207
207
  init_react_import();
208
- var styles_module_default2 = { "InputWrapper": "_InputWrapper_1l5m8_1", "Input": "_Input_1l5m8_1", "Input-label": "_Input-label_1l5m8_26", "Input-labelIcon": "_Input-labelIcon_1l5m8_35", "Input-disabledIcon": "_Input-disabledIcon_1l5m8_42", "Input-input": "_Input-input_1l5m8_47", "Input--readOnly": "_Input--readOnly_1l5m8_91", "Input-radioGroupItems": "_Input-radioGroupItems_1l5m8_102", "Input-radio": "_Input-radio_1l5m8_102", "Input-radioInner": "_Input-radioInner_1l5m8_119", "Input-radioInput": "_Input-radioInput_1l5m8_164" };
208
+ var styles_module_default2 = { "InputWrapper": "_InputWrapper_1h1p1_1", "Input-label": "_Input-label_1h1p1_5", "Input-labelIcon": "_Input-labelIcon_1h1p1_14", "Input-disabledIcon": "_Input-disabledIcon_1h1p1_21", "Input-input": "_Input-input_1h1p1_26", "Input": "_Input_1h1p1_1", "Input--readOnly": "_Input--readOnly_1h1p1_70", "Input-radioGroupItems": "_Input-radioGroupItems_1h1p1_81", "Input-radio": "_Input-radio_1h1p1_81", "Input-radioInner": "_Input-radioInner_1h1p1_98", "Input-radioInput": "_Input-radioInput_1h1p1_143" };
209
209
 
210
210
  // components/AutoField/index.tsx
211
211
  import {
@@ -1504,12 +1504,13 @@ var DefaultField = ({
1504
1504
  field,
1505
1505
  onChange,
1506
1506
  readOnly,
1507
- value,
1507
+ value: _value,
1508
1508
  name,
1509
1509
  label,
1510
1510
  Label: Label2,
1511
1511
  id
1512
1512
  }) => {
1513
+ const value = _value;
1513
1514
  return /* @__PURE__ */ jsx9(
1514
1515
  Label2,
1515
1516
  {
@@ -1527,7 +1528,7 @@ var DefaultField = ({
1527
1528
  type: field.type,
1528
1529
  title: label || name,
1529
1530
  name,
1530
- value: typeof value === "undefined" ? "" : value.toString(),
1531
+ value: (value == null ? void 0 : value.toString) ? value.toString() : "",
1531
1532
  onChange: (e) => {
1532
1533
  if (field.type === "number") {
1533
1534
  const numberValue = Number(e.currentTarget.value);
@@ -2436,7 +2437,7 @@ import {
2436
2437
  useContext as useContext7,
2437
2438
  useEffect as useEffect15,
2438
2439
  useId,
2439
- useRef as useRef4,
2440
+ useRef as useRef3,
2440
2441
  useState as useState17
2441
2442
  } from "react";
2442
2443
  import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
@@ -2449,7 +2450,7 @@ import {
2449
2450
  useContext as useContext6,
2450
2451
  useEffect as useEffect14,
2451
2452
  useMemo as useMemo8,
2452
- useRef as useRef3
2453
+ useRef as useRef2
2453
2454
  } from "react";
2454
2455
 
2455
2456
  // components/DraggableComponent/index.tsx
@@ -2459,7 +2460,7 @@ import {
2459
2460
  useContext as useContext5,
2460
2461
  useEffect as useEffect10,
2461
2462
  useMemo as useMemo7,
2462
- useRef as useRef2,
2463
+ useRef,
2463
2464
  useState as useState13
2464
2465
  } from "react";
2465
2466
 
@@ -3047,7 +3048,7 @@ var DraggableComponent = ({
3047
3048
  }
3048
3049
  });
3049
3050
  const thisIsDragging = status === "dragging";
3050
- const ref = useRef2(null);
3051
+ const ref = useRef(null);
3051
3052
  const refSetter = useCallback7(
3052
3053
  (el) => {
3053
3054
  sortableRef(el);
@@ -3577,7 +3578,7 @@ var DropZoneEdit = forwardRef3(
3577
3578
  }
3578
3579
  return data.content || [];
3579
3580
  }, [data, zoneCompound]);
3580
- const ref = useRef3(null);
3581
+ const ref = useRef2(null);
3581
3582
  const acceptsTarget = useCallback10(
3582
3583
  (componentType) => {
3583
3584
  if (!componentType) {
@@ -3666,7 +3667,7 @@ var DropZoneEdit = forwardRef3(
3666
3667
  backgroundColor: RENDER_DEBUG ? getRandomColor() : void 0
3667
3668
  }),
3668
3669
  children: contentWithPreview.map((item, i) => {
3669
- var _a, _b, _c, _d, _e;
3670
+ var _a, _b, _c, _d, _e, _f, _g;
3670
3671
  const componentId = item.props.id;
3671
3672
  const puckProps = {
3672
3673
  renderDropZone: DropZoneEditPure,
@@ -3686,13 +3687,13 @@ var DropZoneEdit = forwardRef3(
3686
3687
  const componentConfig = config.components[item.type];
3687
3688
  let componentType = item.type;
3688
3689
  let label = (_b = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _b : item.type.toString();
3689
- if (item.type === "preview" && preview) {
3690
+ if (item.type === "preview") {
3690
3691
  let Preview4 = function() {
3691
3692
  return /* @__PURE__ */ jsx22(DrawerItemInner, { name: label, children: appContext2.overrides.componentItem });
3692
3693
  };
3693
3694
  var Preview3 = Preview4;
3694
- componentType = preview.componentType;
3695
- label = (_d = (_c = config.components[componentType]) == null ? void 0 : _c.label) != null ? _d : preview.componentType;
3695
+ componentType = (_c = preview == null ? void 0 : preview.componentType) != null ? _c : "__preview";
3696
+ label = (_f = (_e = (_d = config.components[componentType]) == null ? void 0 : _d.label) != null ? _e : componentType) != null ? _f : "Preview";
3696
3697
  Render2 = Preview4;
3697
3698
  }
3698
3699
  return /* @__PURE__ */ jsx22(
@@ -3707,7 +3708,7 @@ var DropZoneEdit = forwardRef3(
3707
3708
  zoneCompound,
3708
3709
  depth: depth + 1,
3709
3710
  index: i,
3710
- isLoading: ((_e = appContext2.componentState[componentId]) == null ? void 0 : _e.loadingCount) > 0,
3711
+ isLoading: ((_g = appContext2.componentState[componentId]) == null ? void 0 : _g.loadingCount) > 0,
3711
3712
  isSelected,
3712
3713
  label,
3713
3714
  isEnabled,
@@ -4350,6 +4351,11 @@ var reduceUi = (ui, action) => {
4350
4351
  itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
4351
4352
  });
4352
4353
  }
4354
+ if (action.type === "remove") {
4355
+ return __spreadProps(__spreadValues({}, ui), {
4356
+ itemSelector: null
4357
+ });
4358
+ }
4353
4359
  return ui;
4354
4360
  };
4355
4361
 
@@ -4729,7 +4735,7 @@ function useDragListener(type, fn, deps = []) {
4729
4735
  }
4730
4736
  var AREA_CHANGE_DEBOUNCE_MS = 100;
4731
4737
  var useTempDisableFallback = (timeout3) => {
4732
- const lastFallbackDisable = useRef4(null);
4738
+ const lastFallbackDisable = useRef3(null);
4733
4739
  return useCallback11((manager) => {
4734
4740
  collisionStore.setState({ fallbackEnabled: false });
4735
4741
  const fallbackId = generateId();
@@ -4749,7 +4755,7 @@ var DragDropContextClient = ({
4749
4755
  const { state, config, dispatch, resolveData } = useAppContext();
4750
4756
  const id = useId();
4751
4757
  const { data } = state;
4752
- const debouncedParamsRef = useRef4(null);
4758
+ const debouncedParamsRef = useRef3(null);
4753
4759
  const tempDisableFallback = useTempDisableFallback(100);
4754
4760
  const [zoneStore] = useState17(
4755
4761
  () => createStore3(() => ({
@@ -4888,7 +4894,7 @@ var DragDropContextClient = ({
4888
4894
  ]);
4889
4895
  const [dragListeners, setDragListeners] = useState17({});
4890
4896
  const [pathData, setPathData] = useState17();
4891
- const dragMode = useRef4(null);
4897
+ const dragMode = useRef3(null);
4892
4898
  const registerPath = useCallback11(
4893
4899
  (selector) => {
4894
4900
  const item = getItem(selector, data);
@@ -4911,7 +4917,7 @@ var DragDropContextClient = ({
4911
4917
  },
4912
4918
  [data, setPathData]
4913
4919
  );
4914
- const initialSelector = useRef4(void 0);
4920
+ const initialSelector = useRef3(void 0);
4915
4921
  return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
4916
4922
  dragListenerContext.Provider,
4917
4923
  {
@@ -5256,9 +5262,9 @@ Drawer.Item = DrawerItem;
5256
5262
  // components/Puck/index.tsx
5257
5263
  init_react_import();
5258
5264
  import {
5259
- useCallback as useCallback17,
5260
- useEffect as useEffect23,
5261
- useMemo as useMemo18,
5265
+ useCallback as useCallback18,
5266
+ useEffect as useEffect24,
5267
+ useMemo as useMemo19,
5262
5268
  useReducer,
5263
5269
  useState as useState26
5264
5270
  } from "react";
@@ -5454,36 +5460,61 @@ init_react_import();
5454
5460
 
5455
5461
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
5456
5462
  init_react_import();
5457
- var styles_module_default16 = { "PuckFields": "_PuckFields_jp3lw_1", "PuckFields--isLoading": "_PuckFields--isLoading_jp3lw_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_jp3lw_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_jp3lw_25" };
5463
+ var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
5458
5464
 
5459
5465
  // components/Puck/components/Fields/index.tsx
5460
- import { useCallback as useCallback12, useEffect as useEffect16, useMemo as useMemo11, useState as useState19 } from "react";
5466
+ import { useMemo as useMemo12 } from "react";
5467
+
5468
+ // lib/use-resolved-fields.ts
5469
+ init_react_import();
5470
+ import { useCallback as useCallback13, useEffect as useEffect17, useMemo as useMemo11, useRef as useRef5, useState as useState19 } from "react";
5461
5471
 
5462
5472
  // lib/use-parent.ts
5463
5473
  init_react_import();
5464
- import { useContext as useContext9 } from "react";
5465
- var useParent = (itemSelector) => {
5474
+ import { useCallback as useCallback12, useContext as useContext9 } from "react";
5475
+ var getParent = (itemSelector, pathData, data) => {
5466
5476
  var _a;
5467
- const { selectedItem, state } = useAppContext();
5468
- const { pathData } = useContext9(dropZoneContext) || {};
5469
- const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
5470
- const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
5477
+ if (!itemSelector) return null;
5478
+ const item = getItem(itemSelector, data);
5479
+ const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, data);
5471
5480
  const lastItem = breadcrumbs[breadcrumbs.length - 1];
5472
- const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, state.data)) != null ? _a : null : null;
5481
+ const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, data)) != null ? _a : null : null;
5473
5482
  return parent || null;
5474
5483
  };
5484
+ var useGetParent = () => {
5485
+ const { state } = useAppContext();
5486
+ const { pathData } = useContext9(dropZoneContext) || {};
5487
+ return useCallback12(
5488
+ () => getParent(state.ui.itemSelector, pathData, state.data),
5489
+ [state.ui.itemSelector, pathData, state.data]
5490
+ );
5491
+ };
5492
+ var useParent = () => {
5493
+ return useGetParent()();
5494
+ };
5475
5495
 
5476
- // components/Puck/components/Fields/index.tsx
5477
- import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
5478
- var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5496
+ // lib/use-on-value-change.ts
5497
+ init_react_import();
5498
+ import { useRef as useRef4, useEffect as useEffect16 } from "react";
5499
+ function useOnValueChange(value, onChange, compare = Object.is, deps = []) {
5500
+ const tracked = useRef4(value);
5501
+ useEffect16(() => {
5502
+ const oldValue = tracked.current;
5503
+ if (!compare(value, oldValue)) {
5504
+ tracked.current = value;
5505
+ onChange(value, oldValue);
5506
+ }
5507
+ }, [onChange, compare, value, ...deps]);
5508
+ }
5509
+
5510
+ // lib/selector-is.ts
5511
+ init_react_import();
5512
+ var selectorIs = (a, b) => (a == null ? void 0 : a.zone) === (b == null ? void 0 : b.zone) && (a == null ? void 0 : a.index) === (b == null ? void 0 : b.index);
5513
+
5514
+ // lib/use-resolved-fields.ts
5479
5515
  var defaultPageFields = {
5480
5516
  title: { type: "text" }
5481
5517
  };
5482
- var DefaultFields = ({
5483
- children
5484
- }) => {
5485
- return /* @__PURE__ */ jsx27(Fragment8, { children });
5486
- };
5487
5518
  var useResolvedFields = () => {
5488
5519
  var _a, _b;
5489
5520
  const { selectedItem, state, config } = useAppContext();
@@ -5499,12 +5530,13 @@ var useResolvedFields = () => {
5499
5530
  const [lastSelectedData, setLastSelectedData] = useState19({});
5500
5531
  const [resolvedFields, setResolvedFields] = useState19(defaultFields);
5501
5532
  const [fieldsLoading, setFieldsLoading] = useState19(false);
5533
+ const lastFields = useRef5(defaultFields);
5502
5534
  const defaultResolveFields = (_componentData, _params) => defaultFields;
5503
5535
  const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
5504
5536
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
5505
5537
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
5506
5538
  const hasResolver = hasComponentResolver || hasRootResolver;
5507
- const resolveFields = useCallback12(
5539
+ const resolveFields = useCallback13(
5508
5540
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
5509
5541
  var _a2;
5510
5542
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -5516,7 +5548,7 @@ var useResolvedFields = () => {
5516
5548
  {
5517
5549
  changed,
5518
5550
  fields,
5519
- lastFields: resolvedFields,
5551
+ lastFields: lastFields.current,
5520
5552
  lastData,
5521
5553
  appState: state,
5522
5554
  parent
@@ -5527,7 +5559,7 @@ var useResolvedFields = () => {
5527
5559
  return yield config.root.resolveFields(componentData, {
5528
5560
  changed,
5529
5561
  fields,
5530
- lastFields: resolvedFields,
5562
+ lastFields: lastFields.current,
5531
5563
  lastData,
5532
5564
  appState: state,
5533
5565
  parent
@@ -5536,40 +5568,56 @@ var useResolvedFields = () => {
5536
5568
  return defaultResolveFields(componentData, {
5537
5569
  changed,
5538
5570
  fields,
5539
- lastFields: resolvedFields,
5571
+ lastFields: lastFields.current,
5540
5572
  lastData
5541
5573
  });
5542
5574
  }),
5543
- [data, config, componentData, selectedItem, resolvedFields, state, parent]
5575
+ [data, config, componentData, selectedItem, state, parent]
5544
5576
  );
5545
- const [hasParent, setHasParent] = useState19(false);
5546
- useEffect16(() => {
5547
- setHasParent(!!parent);
5548
- }, [parent]);
5549
- useEffect16(() => {
5577
+ const triggerResolver = useCallback13(() => {
5550
5578
  var _a2, _b2;
5551
- if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || hasParent) {
5579
+ if (!((_a2 = state.ui.itemSelector) == null ? void 0 : _a2.zone) || ((_b2 = state.ui.itemSelector) == null ? void 0 : _b2.zone) === "default-zone" || parent) {
5552
5580
  if (hasResolver) {
5553
5581
  setFieldsLoading(true);
5554
5582
  resolveFields(defaultFields).then((fields) => {
5555
5583
  setResolvedFields(fields || {});
5584
+ lastFields.current = fields;
5556
5585
  setFieldsLoading(false);
5557
5586
  });
5558
- } else {
5559
- setResolvedFields(defaultFields);
5587
+ return;
5560
5588
  }
5561
5589
  }
5562
- }, [
5563
- data,
5564
- defaultFields,
5590
+ setResolvedFields(defaultFields);
5591
+ }, [defaultFields, state.ui.itemSelector, hasResolver, parent]);
5592
+ useOnValueChange(
5565
5593
  state.ui.itemSelector,
5566
- selectedItem,
5567
- hasResolver,
5568
- hasParent
5569
- ]);
5594
+ () => {
5595
+ lastFields.current = defaultFields;
5596
+ },
5597
+ selectorIs
5598
+ );
5599
+ useOnValueChange(
5600
+ { data, parent, itemSelector: state.ui.itemSelector },
5601
+ () => {
5602
+ triggerResolver();
5603
+ },
5604
+ (a, b) => JSON.stringify(a) === JSON.stringify(b)
5605
+ );
5606
+ useEffect17(() => {
5607
+ triggerResolver();
5608
+ }, []);
5570
5609
  return [resolvedFields, fieldsLoading];
5571
5610
  };
5572
- var Fields = () => {
5611
+
5612
+ // components/Puck/components/Fields/index.tsx
5613
+ import { Fragment as Fragment8, jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
5614
+ var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
5615
+ var DefaultFields = ({
5616
+ children
5617
+ }) => {
5618
+ return /* @__PURE__ */ jsx27(Fragment8, { children });
5619
+ };
5620
+ var Fields = ({ wrapFields = true }) => {
5573
5621
  var _a, _b;
5574
5622
  const {
5575
5623
  selectedItem,
@@ -5587,11 +5635,11 @@ var Fields = () => {
5587
5635
  const componentResolving = selectedItem ? ((_a = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.loadingCount) > 0 : ((_b = componentState["puck-root"]) == null ? void 0 : _b.loadingCount) > 0;
5588
5636
  const isLoading = fieldsResolving || componentResolving;
5589
5637
  const rootProps = data.root.props || data.root;
5590
- const Wrapper = useMemo11(() => overrides.fields || DefaultFields, [overrides]);
5638
+ const Wrapper = useMemo12(() => overrides.fields || DefaultFields, [overrides]);
5591
5639
  return /* @__PURE__ */ jsxs14(
5592
5640
  "form",
5593
5641
  {
5594
- className: getClassName21(),
5642
+ className: getClassName21({ wrapFields }),
5595
5643
  onSubmit: (e) => {
5596
5644
  e.preventDefault();
5597
5645
  },
@@ -5667,7 +5715,7 @@ var Fields = () => {
5667
5715
  item: selectedItem
5668
5716
  });
5669
5717
  const id = `${selectedItem.props.id}_${field.type}_${fieldName}`;
5670
- return /* @__PURE__ */ jsx27(
5718
+ return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
5671
5719
  AutoFieldPrivate,
5672
5720
  {
5673
5721
  field,
@@ -5676,16 +5724,15 @@ var Fields = () => {
5676
5724
  readOnly: !edit || readOnly[fieldName],
5677
5725
  value: selectedItem.props[fieldName],
5678
5726
  onChange
5679
- },
5680
- id
5681
- );
5727
+ }
5728
+ ) }, id);
5682
5729
  } else {
5683
5730
  const readOnly = data.root.readOnly || {};
5684
5731
  const { edit } = getPermissions({
5685
5732
  root: true
5686
5733
  });
5687
5734
  const id = `root_${field.type}_${fieldName}`;
5688
- return /* @__PURE__ */ jsx27(
5735
+ return /* @__PURE__ */ jsx27("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx27(
5689
5736
  AutoFieldPrivate,
5690
5737
  {
5691
5738
  field,
@@ -5694,9 +5741,8 @@ var Fields = () => {
5694
5741
  readOnly: !edit || readOnly[fieldName],
5695
5742
  value: rootProps[fieldName],
5696
5743
  onChange
5697
- },
5698
- id
5699
- );
5744
+ }
5745
+ ) }, id);
5700
5746
  }
5701
5747
  }) }),
5702
5748
  isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
@@ -5710,7 +5756,7 @@ init_react_import();
5710
5756
 
5711
5757
  // lib/use-component-list.tsx
5712
5758
  init_react_import();
5713
- import { useEffect as useEffect17, useState as useState20 } from "react";
5759
+ import { useEffect as useEffect18, useState as useState20 } from "react";
5714
5760
 
5715
5761
  // components/ComponentList/index.tsx
5716
5762
  init_react_import();
@@ -5778,7 +5824,7 @@ ComponentList.Item = ComponentListItem;
5778
5824
  import { jsx as jsx29 } from "react/jsx-runtime";
5779
5825
  var useComponentList = (config, ui) => {
5780
5826
  const [componentList, setComponentList] = useState20();
5781
- useEffect17(() => {
5827
+ useEffect18(() => {
5782
5828
  var _a, _b, _c;
5783
5829
  if (Object.keys(ui.componentList).length > 0) {
5784
5830
  const matchedComponents = [];
@@ -5847,25 +5893,25 @@ var useComponentList = (config, ui) => {
5847
5893
  };
5848
5894
 
5849
5895
  // components/Puck/components/Components/index.tsx
5850
- import { useMemo as useMemo12 } from "react";
5896
+ import { useMemo as useMemo13 } from "react";
5851
5897
  import { jsx as jsx30 } from "react/jsx-runtime";
5852
5898
  var Components = () => {
5853
5899
  const { config, state, overrides } = useAppContext();
5854
5900
  const componentList = useComponentList(config, state.ui);
5855
- const Wrapper = useMemo12(() => overrides.components || "div", [overrides]);
5901
+ const Wrapper = useMemo13(() => overrides.components || "div", [overrides]);
5856
5902
  return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
5857
5903
  };
5858
5904
 
5859
5905
  // components/Puck/components/Preview/index.tsx
5860
5906
  init_react_import();
5861
- import { useCallback as useCallback13, useEffect as useEffect19, useRef as useRef6, useMemo as useMemo13 } from "react";
5907
+ import { useCallback as useCallback14, useEffect as useEffect20, useRef as useRef7, useMemo as useMemo14 } from "react";
5862
5908
 
5863
5909
  // components/AutoFrame/index.tsx
5864
5910
  init_react_import();
5865
5911
  import {
5866
5912
  createContext as createContext5,
5867
5913
  useContext as useContext10,
5868
- useEffect as useEffect18,
5914
+ useEffect as useEffect19,
5869
5915
  useState as useState21
5870
5916
  } from "react";
5871
5917
  import hash from "object-hash";
@@ -5913,7 +5959,7 @@ var CopyHostStyles = ({
5913
5959
  onStylesLoaded = () => null
5914
5960
  }) => {
5915
5961
  const { document: doc, window: win } = useFrame();
5916
- useEffect18(() => {
5962
+ useEffect19(() => {
5917
5963
  if (!win || !doc) {
5918
5964
  return () => {
5919
5965
  };
@@ -6093,7 +6139,7 @@ function AutoFrame(_a) {
6093
6139
  const [loaded, setLoaded] = useState21(false);
6094
6140
  const [ctx, setCtx] = useState21({});
6095
6141
  const [mountTarget, setMountTarget] = useState21();
6096
- useEffect18(() => {
6142
+ useEffect19(() => {
6097
6143
  var _a2;
6098
6144
  if (frameRef.current) {
6099
6145
  setCtx({
@@ -6187,7 +6233,7 @@ import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
6187
6233
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
6188
6234
  var useBubbleIframeEvents = (ref) => {
6189
6235
  const { status } = useAppContext();
6190
- useEffect19(() => {
6236
+ useEffect20(() => {
6191
6237
  var _a;
6192
6238
  if (ref.current && status === "READY") {
6193
6239
  const iframe = ref.current;
@@ -6226,7 +6272,7 @@ var useBubbleIframeEvents = (ref) => {
6226
6272
  };
6227
6273
  var Preview2 = ({ id = "puck-preview" }) => {
6228
6274
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
6229
- const Page = useCallback13(
6275
+ const Page = useCallback14(
6230
6276
  (pageProps) => {
6231
6277
  var _a, _b;
6232
6278
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
@@ -6235,9 +6281,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
6235
6281
  },
6236
6282
  [config.root]
6237
6283
  );
6238
- const Frame = useMemo13(() => overrides.iframe, [overrides]);
6284
+ const Frame = useMemo14(() => overrides.iframe, [overrides]);
6239
6285
  const rootProps = state.data.root.props || state.data.root;
6240
- const ref = useRef6(null);
6286
+ const ref = useRef7(null);
6241
6287
  useBubbleIframeEvents(ref);
6242
6288
  const inner = state.ui.previewMode === "edit" ? /* @__PURE__ */ jsx33(
6243
6289
  Page,
@@ -6487,13 +6533,13 @@ var LayerTree = ({
6487
6533
  };
6488
6534
 
6489
6535
  // components/Puck/components/Outline/index.tsx
6490
- import { useCallback as useCallback14, useMemo as useMemo14 } from "react";
6536
+ import { useCallback as useCallback15, useMemo as useMemo15 } from "react";
6491
6537
  import { Fragment as Fragment12, jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
6492
6538
  var Outline = () => {
6493
6539
  const { dispatch, state, overrides, config } = useAppContext();
6494
6540
  const { data, ui } = state;
6495
6541
  const { itemSelector } = ui;
6496
- const setItemSelector = useCallback14(
6542
+ const setItemSelector = useCallback15(
6497
6543
  (newItemSelector) => {
6498
6544
  dispatch({
6499
6545
  type: "setUi",
@@ -6502,7 +6548,7 @@ var Outline = () => {
6502
6548
  },
6503
6549
  []
6504
6550
  );
6505
- const Wrapper = useMemo14(() => overrides.outline || "div", [overrides]);
6551
+ const Wrapper = useMemo15(() => overrides.outline || "div", [overrides]);
6506
6552
  return /* @__PURE__ */ jsx35(Wrapper, { children: /* @__PURE__ */ jsx35(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ jsxs17(Fragment12, { children: [
6507
6553
  (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ jsx35(
6508
6554
  LayerTree,
@@ -6789,16 +6835,16 @@ var getBox = function getBox2(el) {
6789
6835
 
6790
6836
  // components/Puck/components/Canvas/index.tsx
6791
6837
  import {
6792
- useCallback as useCallback15,
6793
- useEffect as useEffect21,
6794
- useMemo as useMemo16,
6795
- useRef as useRef7,
6838
+ useCallback as useCallback16,
6839
+ useEffect as useEffect22,
6840
+ useMemo as useMemo17,
6841
+ useRef as useRef8,
6796
6842
  useState as useState24
6797
6843
  } from "react";
6798
6844
 
6799
6845
  // components/ViewportControls/index.tsx
6800
6846
  init_react_import();
6801
- import { useEffect as useEffect20, useMemo as useMemo15, useState as useState23 } from "react";
6847
+ import { useEffect as useEffect21, useMemo as useMemo16, useState as useState23 } from "react";
6802
6848
 
6803
6849
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
6804
6850
  init_react_import();
@@ -6822,7 +6868,7 @@ var ViewportButton = ({
6822
6868
  }) => {
6823
6869
  const { state } = useAppContext();
6824
6870
  const [isActive, setIsActive] = useState23(false);
6825
- useEffect20(() => {
6871
+ useEffect21(() => {
6826
6872
  setIsActive(width === state.ui.viewports.current.width);
6827
6873
  }, [width, state.ui.viewports.current.width]);
6828
6874
  return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
@@ -6858,7 +6904,7 @@ var ViewportControls = ({
6858
6904
  const defaultsContainAutoZoom = defaultZoomOptions.find(
6859
6905
  (option) => option.value === autoZoom
6860
6906
  );
6861
- const zoomOptions = useMemo15(
6907
+ const zoomOptions = useMemo16(
6862
6908
  () => [
6863
6909
  ...defaultZoomOptions,
6864
6910
  ...defaultsContainAutoZoom ? [] : [
@@ -6981,17 +7027,17 @@ var Canvas = () => {
6981
7027
  const { status, iframe } = useAppContext();
6982
7028
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
6983
7029
  const { ui } = state;
6984
- const frameRef = useRef7(null);
7030
+ const frameRef = useRef8(null);
6985
7031
  const [showTransition, setShowTransition] = useState24(false);
6986
- const defaultRender = useMemo16(() => {
7032
+ const defaultRender = useMemo17(() => {
6987
7033
  const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment13, { children });
6988
7034
  return PuckDefault;
6989
7035
  }, []);
6990
- const CustomPreview = useMemo16(
7036
+ const CustomPreview = useMemo17(
6991
7037
  () => overrides.preview || defaultRender,
6992
7038
  [overrides]
6993
7039
  );
6994
- const getFrameDimensions = useCallback15(() => {
7040
+ const getFrameDimensions = useCallback16(() => {
6995
7041
  if (frameRef.current) {
6996
7042
  const frame = frameRef.current;
6997
7043
  const box = getBox(frame);
@@ -6999,7 +7045,7 @@ var Canvas = () => {
6999
7045
  }
7000
7046
  return { width: 0, height: 0 };
7001
7047
  }, [frameRef]);
7002
- const resetAutoZoom = useCallback15(
7048
+ const resetAutoZoom = useCallback16(
7003
7049
  (ui2 = state.ui) => {
7004
7050
  if (frameRef.current) {
7005
7051
  setZoomConfig(
@@ -7009,11 +7055,11 @@ var Canvas = () => {
7009
7055
  },
7010
7056
  [frameRef, zoomConfig, state.ui]
7011
7057
  );
7012
- useEffect21(() => {
7058
+ useEffect22(() => {
7013
7059
  setShowTransition(false);
7014
7060
  resetAutoZoom();
7015
7061
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
7016
- useEffect21(() => {
7062
+ useEffect22(() => {
7017
7063
  const { height: frameHeight } = getFrameDimensions();
7018
7064
  if (ui.viewports.current.height === "auto") {
7019
7065
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -7021,13 +7067,13 @@ var Canvas = () => {
7021
7067
  }));
7022
7068
  }
7023
7069
  }, [zoomConfig.zoom]);
7024
- useEffect21(() => {
7070
+ useEffect22(() => {
7025
7071
  if (ZOOM_ON_CHANGE) {
7026
7072
  setShowTransition(true);
7027
7073
  resetAutoZoom(ui);
7028
7074
  }
7029
7075
  }, [ui.viewports.current.width]);
7030
- useEffect21(() => {
7076
+ useEffect22(() => {
7031
7077
  const cb = () => {
7032
7078
  setShowTransition(false);
7033
7079
  resetAutoZoom();
@@ -7038,7 +7084,7 @@ var Canvas = () => {
7038
7084
  };
7039
7085
  }, []);
7040
7086
  const [showLoader, setShowLoader] = useState24(false);
7041
- useEffect21(() => {
7087
+ useEffect22(() => {
7042
7088
  setTimeout(() => {
7043
7089
  setShowLoader(true);
7044
7090
  }, 500);
@@ -7116,7 +7162,7 @@ var Canvas = () => {
7116
7162
 
7117
7163
  // lib/use-loaded-overrides.ts
7118
7164
  init_react_import();
7119
- import { useMemo as useMemo17 } from "react";
7165
+ import { useMemo as useMemo18 } from "react";
7120
7166
 
7121
7167
  // lib/load-overrides.ts
7122
7168
  init_react_import();
@@ -7155,7 +7201,7 @@ var useLoadedOverrides = ({
7155
7201
  overrides,
7156
7202
  plugins
7157
7203
  }) => {
7158
- return useMemo17(() => {
7204
+ return useMemo18(() => {
7159
7205
  return loadOverrides({ overrides, plugins });
7160
7206
  }, [plugins, overrides]);
7161
7207
  };
@@ -7167,14 +7213,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment14, { chil
7167
7213
 
7168
7214
  // lib/use-inject-css.ts
7169
7215
  init_react_import();
7170
- import { useEffect as useEffect22, useState as useState25 } from "react";
7216
+ import { useEffect as useEffect23, useState as useState25 } from "react";
7171
7217
  var styles = ``;
7172
7218
  var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
7173
7219
  const [el, setEl] = useState25();
7174
- useEffect22(() => {
7220
+ useEffect23(() => {
7175
7221
  setEl(document.createElement("style"));
7176
7222
  }, []);
7177
- useEffect22(() => {
7223
+ useEffect23(() => {
7178
7224
  var _a;
7179
7225
  if (!el || typeof window === "undefined") {
7180
7226
  return;
@@ -7194,10 +7240,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
7194
7240
 
7195
7241
  // lib/use-preview-mode-hotkeys.ts
7196
7242
  init_react_import();
7197
- import { useCallback as useCallback16 } from "react";
7243
+ import { useCallback as useCallback17 } from "react";
7198
7244
  import { useHotkeys as useHotkeys2 } from "react-hotkeys-hook";
7199
7245
  var usePreviewModeHotkeys = (dispatch, iframeEnabled) => {
7200
- const toggleInteractive = useCallback16(() => {
7246
+ const toggleInteractive = useCallback17(() => {
7201
7247
  dispatch({
7202
7248
  type: "setUi",
7203
7249
  ui: (ui) => ({
@@ -7342,11 +7388,11 @@ function Puck({
7342
7388
  const [menuOpen, setMenuOpen] = useState26(false);
7343
7389
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
7344
7390
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
7345
- useEffect23(() => {
7391
+ useEffect24(() => {
7346
7392
  if (onChange) onChange(data);
7347
7393
  }, [data]);
7348
7394
  const rootProps = data.root.props || data.root;
7349
- const toggleSidebars = useCallback17(
7395
+ const toggleSidebars = useCallback18(
7350
7396
  (sidebar) => {
7351
7397
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
7352
7398
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -7360,7 +7406,7 @@ function Puck({
7360
7406
  },
7361
7407
  [dispatch, leftSideBarVisible, rightSideBarVisible]
7362
7408
  );
7363
- useEffect23(() => {
7409
+ useEffect24(() => {
7364
7410
  if (!window.matchMedia("(min-width: 638px)").matches) {
7365
7411
  dispatch({
7366
7412
  type: "setUi",
@@ -7383,7 +7429,7 @@ function Puck({
7383
7429
  window.removeEventListener("resize", handleResize);
7384
7430
  };
7385
7431
  }, []);
7386
- const defaultHeaderRender = useMemo18(() => {
7432
+ const defaultHeaderRender = useMemo19(() => {
7387
7433
  if (renderHeader) {
7388
7434
  console.warn(
7389
7435
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -7397,7 +7443,7 @@ function Puck({
7397
7443
  }
7398
7444
  return DefaultOverride;
7399
7445
  }, [renderHeader]);
7400
- const defaultHeaderActionsRender = useMemo18(() => {
7446
+ const defaultHeaderActionsRender = useMemo19(() => {
7401
7447
  if (renderHeaderActions) {
7402
7448
  console.warn(
7403
7449
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
@@ -7414,20 +7460,20 @@ function Puck({
7414
7460
  overrides,
7415
7461
  plugins
7416
7462
  });
7417
- const CustomPuck = useMemo18(
7463
+ const CustomPuck = useMemo19(
7418
7464
  () => loadedOverrides.puck || DefaultOverride,
7419
7465
  [loadedOverrides]
7420
7466
  );
7421
- const CustomHeader = useMemo18(
7467
+ const CustomHeader = useMemo19(
7422
7468
  () => loadedOverrides.header || defaultHeaderRender,
7423
7469
  [loadedOverrides]
7424
7470
  );
7425
- const CustomHeaderActions = useMemo18(
7471
+ const CustomHeaderActions = useMemo19(
7426
7472
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
7427
7473
  [loadedOverrides]
7428
7474
  );
7429
7475
  const [mounted, setMounted] = useState26(false);
7430
- useEffect23(() => {
7476
+ useEffect24(() => {
7431
7477
  setMounted(true);
7432
7478
  }, []);
7433
7479
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];