@measured/puck 0.17.0-canary.8ea38c3 → 0.17.0-canary.9991c07

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.js CHANGED
@@ -276,7 +276,7 @@ init_react_import();
276
276
 
277
277
  // css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
278
278
  init_react_import();
279
- var styles_module_default2 = { "Input": "_Input_3pq3z_1", "Input-label": "_Input-label_3pq3z_26", "Input-labelIcon": "_Input-labelIcon_3pq3z_35", "Input-disabledIcon": "_Input-disabledIcon_3pq3z_42", "Input-input": "_Input-input_3pq3z_47", "Input--readOnly": "_Input--readOnly_3pq3z_91", "Input-radioGroupItems": "_Input-radioGroupItems_3pq3z_102", "Input-radio": "_Input-radio_3pq3z_102", "Input-radioInner": "_Input-radioInner_3pq3z_119", "Input-radioInput": "_Input-radioInput_3pq3z_164" };
279
+ 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" };
280
280
 
281
281
  // components/AutoField/index.tsx
282
282
  var import_react13 = require("react");
@@ -1071,7 +1071,8 @@ var defaultAppState = {
1071
1071
  },
1072
1072
  options: [],
1073
1073
  controlsVisible: true
1074
- }
1074
+ },
1075
+ field: { focus: null }
1075
1076
  }
1076
1077
  };
1077
1078
  var defaultContext = {
@@ -1415,11 +1416,13 @@ var ArrayField = ({
1415
1416
  event.source.index,
1416
1417
  (_b = event.destination) == null ? void 0 : _b.index
1417
1418
  );
1418
- onChange(newValue, {
1419
+ const newUi = {
1419
1420
  arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
1420
1421
  [id]: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
1421
1422
  })
1422
- });
1423
+ };
1424
+ setUi(newUi, false);
1425
+ onChange(newValue, newUi);
1423
1426
  setLocalState({
1424
1427
  value: newValue,
1425
1428
  arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
@@ -1485,32 +1488,60 @@ var ArrayField = ({
1485
1488
  children: [
1486
1489
  field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
1487
1490
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: getClassNameItem("rhs"), children: [
1488
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("actions"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1489
- IconButton,
1490
- {
1491
- type: "button",
1492
- disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
1493
- onClick: (e) => {
1494
- e.stopPropagation();
1495
- const existingValue = [
1496
- ...value || []
1497
- ];
1498
- const existingItems = [
1499
- ...arrayState.items || []
1500
- ];
1501
- existingValue.splice(i, 1);
1502
- existingItems.splice(i, 1);
1503
- onChange(
1504
- existingValue,
1505
- mapArrayStateToUi({
1506
- items: existingItems
1507
- })
1508
- );
1509
- },
1510
- title: "Delete",
1511
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Trash, { size: 16 })
1512
- }
1513
- ) }) }),
1491
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: getClassNameItem("actions"), children: [
1492
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1493
+ IconButton,
1494
+ {
1495
+ type: "button",
1496
+ disabled: !!addDisabled,
1497
+ onClick: (e) => {
1498
+ e.stopPropagation();
1499
+ const existingValue = [
1500
+ ...value || []
1501
+ ];
1502
+ existingValue.splice(
1503
+ i,
1504
+ 0,
1505
+ existingValue[i]
1506
+ );
1507
+ onChange(
1508
+ existingValue,
1509
+ mapArrayStateToUi(
1510
+ regenerateArrayState(existingValue)
1511
+ )
1512
+ );
1513
+ },
1514
+ title: "Duplicate",
1515
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Copy, { size: 16 })
1516
+ }
1517
+ ) }),
1518
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1519
+ IconButton,
1520
+ {
1521
+ type: "button",
1522
+ disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
1523
+ onClick: (e) => {
1524
+ e.stopPropagation();
1525
+ const existingValue = [
1526
+ ...value || []
1527
+ ];
1528
+ const existingItems = [
1529
+ ...arrayState.items || []
1530
+ ];
1531
+ existingValue.splice(i, 1);
1532
+ existingItems.splice(i, 1);
1533
+ onChange(
1534
+ existingValue,
1535
+ mapArrayStateToUi({
1536
+ items: existingItems
1537
+ })
1538
+ );
1539
+ },
1540
+ title: "Delete",
1541
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Trash, { size: 16 })
1542
+ }
1543
+ ) })
1544
+ ] }),
1514
1545
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DragIcon, {}) })
1515
1546
  ] })
1516
1547
  ]
@@ -1606,6 +1637,7 @@ var DefaultField = ({
1606
1637
  className: getClassName6("input"),
1607
1638
  autoComplete: "off",
1608
1639
  type: field.type,
1640
+ title: label || name,
1609
1641
  name,
1610
1642
  value: typeof value === "undefined" ? "" : value.toString(),
1611
1643
  onChange: (e) => {
@@ -1636,7 +1668,7 @@ var import_react10 = require("react");
1636
1668
 
1637
1669
  // css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
1638
1670
  init_react_import();
1639
- var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_wprq3_1", "ExternalInput-button": "_ExternalInput-button_wprq3_5", "ExternalInput--dataSelected": "_ExternalInput--dataSelected_wprq3_24", "ExternalInput--readOnly": "_ExternalInput--readOnly_wprq3_31", "ExternalInput-detachButton": "_ExternalInput-detachButton_wprq3_35", "ExternalInput": "_ExternalInput_wprq3_1", "ExternalInputModal": "_ExternalInputModal_wprq3_79", "ExternalInputModal-grid": "_ExternalInputModal-grid_wprq3_89", "ExternalInputModal--filtersToggled": "_ExternalInputModal--filtersToggled_wprq3_100", "ExternalInputModal-filters": "_ExternalInputModal-filters_wprq3_105", "ExternalInputModal-masthead": "_ExternalInputModal-masthead_wprq3_124", "ExternalInputModal-tableWrapper": "_ExternalInputModal-tableWrapper_wprq3_133", "ExternalInputModal-table": "_ExternalInputModal-table_wprq3_133", "ExternalInputModal-thead": "_ExternalInputModal-thead_wprq3_149", "ExternalInputModal-th": "_ExternalInputModal-th_wprq3_149", "ExternalInputModal-td": "_ExternalInputModal-td_wprq3_164", "ExternalInputModal-tr": "_ExternalInputModal-tr_wprq3_169", "ExternalInputModal-tbody": "_ExternalInputModal-tbody_wprq3_176", "ExternalInputModal--hasData": "_ExternalInputModal--hasData_wprq3_202", "ExternalInputModal-loadingBanner": "_ExternalInputModal-loadingBanner_wprq3_206", "ExternalInputModal--isLoading": "_ExternalInputModal--isLoading_wprq3_223", "ExternalInputModal-searchForm": "_ExternalInputModal-searchForm_wprq3_227", "ExternalInputModal-search": "_ExternalInputModal-search_wprq3_227", "ExternalInputModal-searchIcon": "_ExternalInputModal-searchIcon_wprq3_264", "ExternalInputModal-searchIconText": "_ExternalInputModal-searchIconText_wprq3_289", "ExternalInputModal-searchInput": "_ExternalInputModal-searchInput_wprq3_299", "ExternalInputModal-searchActions": "_ExternalInputModal-searchActions_wprq3_313", "ExternalInputModal-searchActionIcon": "_ExternalInputModal-searchActionIcon_wprq3_326", "ExternalInputModal-footer": "_ExternalInputModal-footer_wprq3_330" };
1671
+ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_8wgzm_1", "ExternalInput-button": "_ExternalInput-button_8wgzm_5", "ExternalInput--dataSelected": "_ExternalInput--dataSelected_8wgzm_24", "ExternalInput--readOnly": "_ExternalInput--readOnly_8wgzm_31", "ExternalInput-detachButton": "_ExternalInput-detachButton_8wgzm_35", "ExternalInput": "_ExternalInput_8wgzm_1", "ExternalInputModal": "_ExternalInputModal_8wgzm_79", "ExternalInputModal-grid": "_ExternalInputModal-grid_8wgzm_89", "ExternalInputModal--filtersToggled": "_ExternalInputModal--filtersToggled_8wgzm_100", "ExternalInputModal-filters": "_ExternalInputModal-filters_8wgzm_105", "ExternalInputModal-masthead": "_ExternalInputModal-masthead_8wgzm_124", "ExternalInputModal-tableWrapper": "_ExternalInputModal-tableWrapper_8wgzm_133", "ExternalInputModal-table": "_ExternalInputModal-table_8wgzm_133", "ExternalInputModal-thead": "_ExternalInputModal-thead_8wgzm_149", "ExternalInputModal-th": "_ExternalInputModal-th_8wgzm_149", "ExternalInputModal-td": "_ExternalInputModal-td_8wgzm_164", "ExternalInputModal-tr": "_ExternalInputModal-tr_8wgzm_169", "ExternalInputModal-tbody": "_ExternalInputModal-tbody_8wgzm_176", "ExternalInputModal--hasData": "_ExternalInputModal--hasData_8wgzm_202", "ExternalInputModal-loadingBanner": "_ExternalInputModal-loadingBanner_8wgzm_206", "ExternalInputModal--isLoading": "_ExternalInputModal--isLoading_8wgzm_223", "ExternalInputModal-searchForm": "_ExternalInputModal-searchForm_8wgzm_227", "ExternalInputModal-search": "_ExternalInputModal-search_8wgzm_227", "ExternalInputModal-searchIcon": "_ExternalInputModal-searchIcon_8wgzm_264", "ExternalInputModal-searchIconText": "_ExternalInputModal-searchIconText_8wgzm_289", "ExternalInputModal-searchInput": "_ExternalInputModal-searchInput_8wgzm_299", "ExternalInputModal-searchActions": "_ExternalInputModal-searchActions_8wgzm_313", "ExternalInputModal-searchActionIcon": "_ExternalInputModal-searchActionIcon_8wgzm_326", "ExternalInputModal-footerContainer": "_ExternalInputModal-footerContainer_8wgzm_330", "ExternalInputModal-footer": "_ExternalInputModal-footer_8wgzm_330" };
1640
1672
 
1641
1673
  // components/Modal/index.tsx
1642
1674
  init_react_import();
@@ -1814,6 +1846,14 @@ var ExternalInput = ({
1814
1846
  }),
1815
1847
  [id, field]
1816
1848
  );
1849
+ const Footer = (0, import_react10.useCallback)(
1850
+ (props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: getClassNameModal("footer"), children: [
1851
+ props.items.length,
1852
+ " result",
1853
+ props.items.length === 1 ? "" : "s"
1854
+ ] }),
1855
+ [field.renderFooter]
1856
+ );
1817
1857
  (0, import_react10.useEffect)(() => {
1818
1858
  search(searchQuery, filters);
1819
1859
  }, []);
@@ -1953,11 +1993,7 @@ var ExternalInput = ({
1953
1993
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Loader, { size: 24 }) })
1954
1994
  ] })
1955
1995
  ] }),
1956
- /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassNameModal("footer"), children: [
1957
- mappedData.length,
1958
- " result",
1959
- mappedData.length === 1 ? "" : "s"
1960
- ] })
1996
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Footer, { items: mappedData }) })
1961
1997
  ]
1962
1998
  }
1963
1999
  ) })
@@ -2016,6 +2052,19 @@ var ExternalField = ({
2016
2052
 
2017
2053
  // components/AutoField/fields/RadioField/index.tsx
2018
2054
  init_react_import();
2055
+
2056
+ // lib/safe-json-parse.ts
2057
+ init_react_import();
2058
+ var safeJsonParse = (str) => {
2059
+ try {
2060
+ const jsonValue = JSON.parse(str);
2061
+ return jsonValue;
2062
+ } catch (e) {
2063
+ return str;
2064
+ }
2065
+ };
2066
+
2067
+ // components/AutoField/fields/RadioField/index.tsx
2019
2068
  var import_jsx_runtime16 = require("react/jsx-runtime");
2020
2069
  var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
2021
2070
  var RadioField = ({
@@ -2050,13 +2099,7 @@ var RadioField = ({
2050
2099
  className: getClassName11("radioInput"),
2051
2100
  value: option.value,
2052
2101
  name,
2053
- onChange: (e) => {
2054
- if (e.currentTarget.value === "true" || e.currentTarget.value === "false") {
2055
- onChange(JSON.parse(e.currentTarget.value));
2056
- return;
2057
- }
2058
- onChange(e.currentTarget.value);
2059
- },
2102
+ onChange: ({ target: { value: value2 } }) => onChange(safeJsonParse(value2) || value2),
2060
2103
  disabled: readOnly,
2061
2104
  checked: value === option.value
2062
2105
  }
@@ -2097,15 +2140,10 @@ var SelectField = ({
2097
2140
  "select",
2098
2141
  {
2099
2142
  id,
2143
+ title: label || name,
2100
2144
  className: getClassName12("input"),
2101
2145
  disabled: readOnly,
2102
- onChange: (e) => {
2103
- if (e.currentTarget.value === "true" || e.currentTarget.value === "false") {
2104
- onChange(JSON.parse(e.currentTarget.value));
2105
- return;
2106
- }
2107
- onChange(e.currentTarget.value);
2108
- },
2146
+ onChange: ({ target: { value: value2 } }) => onChange(safeJsonParse(value2) || value2),
2109
2147
  value,
2110
2148
  children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2111
2149
  "option",
@@ -2237,6 +2275,7 @@ var useSafeId = () => {
2237
2275
  // components/AutoField/index.tsx
2238
2276
  var import_jsx_runtime20 = require("react/jsx-runtime");
2239
2277
  var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
2278
+ var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
2240
2279
  var FieldLabel = ({
2241
2280
  children,
2242
2281
  icon,
@@ -2284,7 +2323,7 @@ var FieldLabelInternal2 = ({
2284
2323
  };
2285
2324
  function AutoFieldInternal(props) {
2286
2325
  var _a, _b, _c, _d, _e, _f, _g, _h;
2287
- const { overrides } = useAppContext();
2326
+ const { dispatch, overrides } = useAppContext();
2288
2327
  const { id, Label = FieldLabelInternal2 } = props;
2289
2328
  const field = props.field;
2290
2329
  const label = field.label;
@@ -2316,23 +2355,56 @@ function AutoFieldInternal(props) {
2316
2355
  Label,
2317
2356
  id: resolvedId
2318
2357
  });
2358
+ const onFocus = (0, import_react13.useCallback)(
2359
+ (e) => {
2360
+ if (mergedProps.name && e.target.nodeName === "INPUT") {
2361
+ e.stopPropagation();
2362
+ dispatch({
2363
+ type: "setUi",
2364
+ ui: {
2365
+ field: { focus: mergedProps.name }
2366
+ }
2367
+ });
2368
+ }
2369
+ },
2370
+ [mergedProps.name]
2371
+ );
2372
+ const onBlur = (0, import_react13.useCallback)((e) => {
2373
+ if ("name" in e.target) {
2374
+ dispatch({
2375
+ type: "setUi",
2376
+ ui: {
2377
+ field: { focus: null }
2378
+ }
2379
+ });
2380
+ }
2381
+ }, []);
2319
2382
  if (field.type === "custom") {
2320
2383
  if (!field.render) {
2321
2384
  return null;
2322
2385
  }
2323
2386
  const CustomField = field.render;
2324
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName15(), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CustomField, __spreadValues({}, mergedProps)) });
2387
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName15(), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CustomField, __spreadValues({}, mergedProps)) }) });
2325
2388
  }
2326
2389
  const children = defaultFields[field.type](mergedProps);
2327
2390
  const Render2 = render[field.type];
2328
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }));
2391
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2392
+ "div",
2393
+ {
2394
+ className: getClassNameWrapper(),
2395
+ onFocus,
2396
+ onBlur,
2397
+ onClick: (e) => {
2398
+ e.stopPropagation();
2399
+ },
2400
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children }))
2401
+ }
2402
+ );
2329
2403
  }
2330
- var RECENT_CHANGE_TIMEOUT = 200;
2331
2404
  function AutoFieldPrivate(props) {
2405
+ const { state } = useAppContext();
2332
2406
  const { value, onChange } = props;
2333
2407
  const [localValue, setLocalValue] = (0, import_react13.useState)(value);
2334
- const [recentlyChanged, setRecentlyChanged] = (0, import_react13.useState)(false);
2335
- const timeoutRef = (0, import_react13.useRef)();
2336
2408
  const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
2337
2409
  (val, ui) => {
2338
2410
  onChange(val, ui);
@@ -2342,15 +2414,10 @@ function AutoFieldPrivate(props) {
2342
2414
  );
2343
2415
  const onChangeLocal = (0, import_react13.useCallback)((val, ui) => {
2344
2416
  setLocalValue(val);
2345
- setRecentlyChanged(true);
2346
- clearTimeout(timeoutRef.current);
2347
- timeoutRef.current = setTimeout(() => {
2348
- setRecentlyChanged(false);
2349
- }, RECENT_CHANGE_TIMEOUT);
2350
2417
  onChangeDb(val, ui);
2351
2418
  }, []);
2352
2419
  (0, import_react13.useEffect)(() => {
2353
- if (!recentlyChanged) {
2420
+ if (state.ui.field.focus !== props.name) {
2354
2421
  setLocalValue(value);
2355
2422
  }
2356
2423
  }, [value]);
@@ -3075,7 +3142,7 @@ function DropZone(props) {
3075
3142
 
3076
3143
  // components/Puck/index.tsx
3077
3144
  init_react_import();
3078
- var import_react32 = require("react");
3145
+ var import_react33 = require("react");
3079
3146
 
3080
3147
  // lib/use-placeholder-style.ts
3081
3148
  init_react_import();
@@ -3682,7 +3749,23 @@ init_react_import();
3682
3749
  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" };
3683
3750
 
3684
3751
  // components/Puck/components/Fields/index.tsx
3752
+ var import_react22 = require("react");
3753
+
3754
+ // lib/use-parent.ts
3755
+ init_react_import();
3685
3756
  var import_react21 = require("react");
3757
+ var useParent = (itemSelector) => {
3758
+ var _a;
3759
+ const { selectedItem, state } = useAppContext();
3760
+ const { pathData } = (0, import_react21.useContext)(dropZoneContext) || {};
3761
+ const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
3762
+ const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
3763
+ const lastItem = breadcrumbs[breadcrumbs.length - 1];
3764
+ const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, state.data)) != null ? _a : null : null;
3765
+ return parent || null;
3766
+ };
3767
+
3768
+ // components/Puck/components/Fields/index.tsx
3686
3769
  var import_jsx_runtime27 = require("react/jsx-runtime");
3687
3770
  var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
3688
3771
  var defaultPageFields = {
@@ -3696,23 +3779,24 @@ var DefaultFields = ({
3696
3779
  var useResolvedFields = () => {
3697
3780
  var _a, _b;
3698
3781
  const { selectedItem, state, config } = useAppContext();
3782
+ const parent = useParent();
3699
3783
  const { data } = state;
3700
3784
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
3701
3785
  const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
3702
- const defaultFields = (0, import_react21.useMemo)(
3786
+ const defaultFields = (0, import_react22.useMemo)(
3703
3787
  () => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
3704
3788
  [selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
3705
3789
  );
3706
3790
  const rootProps = data.root.props || data.root;
3707
- const [lastSelectedData, setLastSelectedData] = (0, import_react21.useState)({});
3708
- const [resolvedFields, setResolvedFields] = (0, import_react21.useState)(defaultFields);
3709
- const [fieldsLoading, setFieldsLoading] = (0, import_react21.useState)(false);
3791
+ const [lastSelectedData, setLastSelectedData] = (0, import_react22.useState)({});
3792
+ const [resolvedFields, setResolvedFields] = (0, import_react22.useState)(defaultFields);
3793
+ const [fieldsLoading, setFieldsLoading] = (0, import_react22.useState)(false);
3710
3794
  const defaultResolveFields = (_componentData, _params) => defaultFields;
3711
3795
  const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
3712
3796
  const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
3713
3797
  const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
3714
3798
  const hasResolver = hasComponentResolver || hasRootResolver;
3715
- const resolveFields = (0, import_react21.useCallback)(
3799
+ const resolveFields = (0, import_react22.useCallback)(
3716
3800
  (..._0) => __async(void 0, [..._0], function* (fields = {}) {
3717
3801
  var _a2;
3718
3802
  const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
@@ -3726,7 +3810,8 @@ var useResolvedFields = () => {
3726
3810
  fields,
3727
3811
  lastFields: resolvedFields,
3728
3812
  lastData,
3729
- appState: state
3813
+ appState: state,
3814
+ parent
3730
3815
  }
3731
3816
  );
3732
3817
  }
@@ -3736,7 +3821,8 @@ var useResolvedFields = () => {
3736
3821
  fields,
3737
3822
  lastFields: resolvedFields,
3738
3823
  lastData,
3739
- appState: state
3824
+ appState: state,
3825
+ parent
3740
3826
  });
3741
3827
  }
3742
3828
  return defaultResolveFields(componentData, {
@@ -3748,7 +3834,7 @@ var useResolvedFields = () => {
3748
3834
  }),
3749
3835
  [data, config, componentData, selectedItem, resolvedFields, state]
3750
3836
  );
3751
- (0, import_react21.useEffect)(() => {
3837
+ (0, import_react22.useEffect)(() => {
3752
3838
  if (hasResolver) {
3753
3839
  setFieldsLoading(true);
3754
3840
  resolveFields(defaultFields).then((fields) => {
@@ -3758,7 +3844,7 @@ var useResolvedFields = () => {
3758
3844
  } else {
3759
3845
  setResolvedFields(defaultFields);
3760
3846
  }
3761
- }, [data, defaultFields, state.ui.itemSelector, hasResolver]);
3847
+ }, [data, defaultFields, selectedItem, hasResolver]);
3762
3848
  return [resolvedFields, fieldsLoading];
3763
3849
  };
3764
3850
  var Fields = () => {
@@ -3779,7 +3865,7 @@ var Fields = () => {
3779
3865
  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;
3780
3866
  const isLoading = fieldsResolving || componentResolving;
3781
3867
  const rootProps = data.root.props || data.root;
3782
- const Wrapper = (0, import_react21.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
3868
+ const Wrapper = (0, import_react22.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
3783
3869
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
3784
3870
  "form",
3785
3871
  {
@@ -3900,7 +3986,7 @@ init_react_import();
3900
3986
 
3901
3987
  // lib/use-component-list.tsx
3902
3988
  init_react_import();
3903
- var import_react22 = require("react");
3989
+ var import_react23 = require("react");
3904
3990
 
3905
3991
  // components/ComponentList/index.tsx
3906
3992
  init_react_import();
@@ -3978,8 +4064,8 @@ ComponentList.Item = ComponentListItem;
3978
4064
  // lib/use-component-list.tsx
3979
4065
  var import_jsx_runtime29 = require("react/jsx-runtime");
3980
4066
  var useComponentList = (config, ui) => {
3981
- const [componentList, setComponentList] = (0, import_react22.useState)();
3982
- (0, import_react22.useEffect)(() => {
4067
+ const [componentList, setComponentList] = (0, import_react23.useState)();
4068
+ (0, import_react23.useEffect)(() => {
3983
4069
  var _a, _b, _c;
3984
4070
  if (Object.keys(ui.componentList).length > 0) {
3985
4071
  const matchedComponents = [];
@@ -4048,22 +4134,22 @@ var useComponentList = (config, ui) => {
4048
4134
  };
4049
4135
 
4050
4136
  // components/Puck/components/Components/index.tsx
4051
- var import_react23 = require("react");
4137
+ var import_react24 = require("react");
4052
4138
  var import_jsx_runtime30 = require("react/jsx-runtime");
4053
4139
  var Components = () => {
4054
4140
  const { config, state, overrides } = useAppContext();
4055
4141
  const componentList = useComponentList(config, state.ui);
4056
- const Wrapper = (0, import_react23.useMemo)(() => overrides.components || "div", [overrides]);
4142
+ const Wrapper = (0, import_react24.useMemo)(() => overrides.components || "div", [overrides]);
4057
4143
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
4058
4144
  };
4059
4145
 
4060
4146
  // components/Puck/components/Preview/index.tsx
4061
4147
  init_react_import();
4062
- var import_react25 = require("react");
4148
+ var import_react26 = require("react");
4063
4149
 
4064
4150
  // components/AutoFrame/index.tsx
4065
4151
  init_react_import();
4066
- var import_react24 = require("react");
4152
+ var import_react25 = require("react");
4067
4153
  var import_object_hash = __toESM(require("object-hash"));
4068
4154
  var import_react_dom2 = require("react-dom");
4069
4155
  var import_jsx_runtime31 = require("react/jsx-runtime");
@@ -4109,7 +4195,7 @@ var CopyHostStyles = ({
4109
4195
  onStylesLoaded = () => null
4110
4196
  }) => {
4111
4197
  const { document: doc, window: win } = useFrame();
4112
- (0, import_react24.useEffect)(() => {
4198
+ (0, import_react25.useEffect)(() => {
4113
4199
  if (!win || !doc) {
4114
4200
  return () => {
4115
4201
  };
@@ -4268,8 +4354,8 @@ var CopyHostStyles = ({
4268
4354
  }, []);
4269
4355
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
4270
4356
  };
4271
- var autoFrameContext = (0, import_react24.createContext)({});
4272
- var useFrame = () => (0, import_react24.useContext)(autoFrameContext);
4357
+ var autoFrameContext = (0, import_react25.createContext)({});
4358
+ var useFrame = () => (0, import_react25.useContext)(autoFrameContext);
4273
4359
  function AutoFrame(_a) {
4274
4360
  var _b = _a, {
4275
4361
  children,
@@ -4284,11 +4370,11 @@ function AutoFrame(_a) {
4284
4370
  "id",
4285
4371
  "onStylesLoaded"
4286
4372
  ]);
4287
- const [loaded, setLoaded] = (0, import_react24.useState)(false);
4288
- const [ctx, setCtx] = (0, import_react24.useState)({});
4289
- const ref = (0, import_react24.useRef)(null);
4290
- const [mountTarget, setMountTarget] = (0, import_react24.useState)();
4291
- (0, import_react24.useEffect)(() => {
4373
+ const [loaded, setLoaded] = (0, import_react25.useState)(false);
4374
+ const [ctx, setCtx] = (0, import_react25.useState)({});
4375
+ const ref = (0, import_react25.useRef)(null);
4376
+ const [mountTarget, setMountTarget] = (0, import_react25.useState)();
4377
+ (0, import_react25.useEffect)(() => {
4292
4378
  var _a2;
4293
4379
  if (ref.current) {
4294
4380
  setCtx({
@@ -4324,7 +4410,7 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
4324
4410
  var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
4325
4411
  var Preview = ({ id = "puck-preview" }) => {
4326
4412
  const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
4327
- const Page = (0, import_react25.useCallback)(
4413
+ const Page = (0, import_react26.useCallback)(
4328
4414
  (pageProps) => {
4329
4415
  var _a, _b;
4330
4416
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
@@ -4333,7 +4419,7 @@ var Preview = ({ id = "puck-preview" }) => {
4333
4419
  },
4334
4420
  [config.root]
4335
4421
  );
4336
- const Frame = (0, import_react25.useMemo)(() => overrides.iframe, [overrides]);
4422
+ const Frame = (0, import_react26.useMemo)(() => overrides.iframe, [overrides]);
4337
4423
  const rootProps = state.data.root.props || state.data.root;
4338
4424
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
4339
4425
  "div",
@@ -4422,7 +4508,7 @@ var scrollIntoView = (el) => {
4422
4508
  };
4423
4509
 
4424
4510
  // components/LayerTree/index.tsx
4425
- var import_react26 = require("react");
4511
+ var import_react27 = require("react");
4426
4512
 
4427
4513
  // lib/is-child-of-zone.ts
4428
4514
  init_react_import();
@@ -4449,7 +4535,7 @@ var LayerTree = ({
4449
4535
  label
4450
4536
  }) => {
4451
4537
  const zones = data.zones || {};
4452
- const ctx = (0, import_react26.useContext)(dropZoneContext);
4538
+ const ctx = (0, import_react27.useContext)(dropZoneContext);
4453
4539
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
4454
4540
  label && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
4455
4541
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Layers, { size: "16" }) }),
@@ -4555,13 +4641,13 @@ var LayerTree = ({
4555
4641
  };
4556
4642
 
4557
4643
  // components/Puck/components/Outline/index.tsx
4558
- var import_react27 = require("react");
4644
+ var import_react28 = require("react");
4559
4645
  var import_jsx_runtime34 = require("react/jsx-runtime");
4560
4646
  var Outline = () => {
4561
4647
  const { dispatch, state, overrides, config } = useAppContext();
4562
4648
  const { data, ui } = state;
4563
4649
  const { itemSelector } = ui;
4564
- const setItemSelector = (0, import_react27.useCallback)(
4650
+ const setItemSelector = (0, import_react28.useCallback)(
4565
4651
  (newItemSelector) => {
4566
4652
  dispatch({
4567
4653
  type: "setUi",
@@ -4570,7 +4656,7 @@ var Outline = () => {
4570
4656
  },
4571
4657
  []
4572
4658
  );
4573
- const Wrapper = (0, import_react27.useMemo)(() => overrides.outline || "div", [overrides]);
4659
+ const Wrapper = (0, import_react28.useMemo)(() => overrides.outline || "div", [overrides]);
4574
4660
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
4575
4661
  (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4576
4662
  LayerTree,
@@ -4659,19 +4745,19 @@ function usePuckHistory({
4659
4745
 
4660
4746
  // lib/use-history-store.ts
4661
4747
  init_react_import();
4662
- var import_react28 = require("react");
4748
+ var import_react29 = require("react");
4663
4749
  var import_use_debounce3 = require("use-debounce");
4664
4750
  var EMPTY_HISTORY_INDEX = 0;
4665
4751
  function useHistoryStore(initialHistory) {
4666
4752
  var _a, _b;
4667
- const [histories, setHistories] = (0, import_react28.useState)(
4753
+ const [histories, setHistories] = (0, import_react29.useState)(
4668
4754
  (_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
4669
4755
  );
4670
4756
  const updateHistories = (histories2) => {
4671
4757
  setHistories(histories2);
4672
4758
  setIndex(histories2.length - 1);
4673
4759
  };
4674
- const [index, setIndex] = (0, import_react28.useState)(
4760
+ const [index, setIndex] = (0, import_react29.useState)(
4675
4761
  (_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
4676
4762
  );
4677
4763
  const hasPast = index > EMPTY_HISTORY_INDEX;
@@ -4831,11 +4917,11 @@ var getBox = function getBox2(el) {
4831
4917
  };
4832
4918
 
4833
4919
  // components/Puck/components/Canvas/index.tsx
4834
- var import_react30 = require("react");
4920
+ var import_react31 = require("react");
4835
4921
 
4836
4922
  // components/ViewportControls/index.tsx
4837
4923
  init_react_import();
4838
- var import_react29 = require("react");
4924
+ var import_react30 = require("react");
4839
4925
 
4840
4926
  // css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
4841
4927
  init_react_import();
@@ -4858,8 +4944,8 @@ var ViewportButton = ({
4858
4944
  onClick
4859
4945
  }) => {
4860
4946
  const { state } = useAppContext();
4861
- const [isActive, setIsActive] = (0, import_react29.useState)(false);
4862
- (0, import_react29.useEffect)(() => {
4947
+ const [isActive, setIsActive] = (0, import_react30.useState)(false);
4948
+ (0, import_react30.useEffect)(() => {
4863
4949
  setIsActive(width === state.ui.viewports.current.width);
4864
4950
  }, [width, state.ui.viewports.current.width]);
4865
4951
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
@@ -4895,7 +4981,7 @@ var ViewportControls = ({
4895
4981
  const defaultsContainAutoZoom = defaultZoomOptions.find(
4896
4982
  (option) => option.value === autoZoom
4897
4983
  );
4898
- const zoomOptions = (0, import_react29.useMemo)(
4984
+ const zoomOptions = (0, import_react30.useMemo)(
4899
4985
  () => [
4900
4986
  ...defaultZoomOptions,
4901
4987
  ...defaultsContainAutoZoom ? [] : [
@@ -5018,17 +5104,17 @@ var Canvas = () => {
5018
5104
  const { status, iframe } = useAppContext();
5019
5105
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
5020
5106
  const { ui } = state;
5021
- const frameRef = (0, import_react30.useRef)(null);
5022
- const [showTransition, setShowTransition] = (0, import_react30.useState)(false);
5023
- const defaultRender = (0, import_react30.useMemo)(() => {
5107
+ const frameRef = (0, import_react31.useRef)(null);
5108
+ const [showTransition, setShowTransition] = (0, import_react31.useState)(false);
5109
+ const defaultRender = (0, import_react31.useMemo)(() => {
5024
5110
  const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children });
5025
5111
  return PuckDefault;
5026
5112
  }, []);
5027
- const CustomPreview = (0, import_react30.useMemo)(
5113
+ const CustomPreview = (0, import_react31.useMemo)(
5028
5114
  () => overrides.preview || defaultRender,
5029
5115
  [overrides]
5030
5116
  );
5031
- const getFrameDimensions = (0, import_react30.useCallback)(() => {
5117
+ const getFrameDimensions = (0, import_react31.useCallback)(() => {
5032
5118
  if (frameRef.current) {
5033
5119
  const frame = frameRef.current;
5034
5120
  const box = getBox(frame);
@@ -5036,7 +5122,7 @@ var Canvas = () => {
5036
5122
  }
5037
5123
  return { width: 0, height: 0 };
5038
5124
  }, [frameRef]);
5039
- const resetAutoZoom = (0, import_react30.useCallback)(
5125
+ const resetAutoZoom = (0, import_react31.useCallback)(
5040
5126
  (ui2 = state.ui) => {
5041
5127
  if (frameRef.current) {
5042
5128
  setZoomConfig(
@@ -5046,11 +5132,11 @@ var Canvas = () => {
5046
5132
  },
5047
5133
  [frameRef, zoomConfig, state.ui]
5048
5134
  );
5049
- (0, import_react30.useEffect)(() => {
5135
+ (0, import_react31.useEffect)(() => {
5050
5136
  setShowTransition(false);
5051
5137
  resetAutoZoom();
5052
5138
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
5053
- (0, import_react30.useEffect)(() => {
5139
+ (0, import_react31.useEffect)(() => {
5054
5140
  const { height: frameHeight } = getFrameDimensions();
5055
5141
  if (ui.viewports.current.height === "auto") {
5056
5142
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -5058,13 +5144,13 @@ var Canvas = () => {
5058
5144
  }));
5059
5145
  }
5060
5146
  }, [zoomConfig.zoom]);
5061
- (0, import_react30.useEffect)(() => {
5147
+ (0, import_react31.useEffect)(() => {
5062
5148
  if (ZOOM_ON_CHANGE) {
5063
5149
  setShowTransition(true);
5064
5150
  resetAutoZoom(ui);
5065
5151
  }
5066
5152
  }, [ui.viewports.current.width]);
5067
- (0, import_react30.useEffect)(() => {
5153
+ (0, import_react31.useEffect)(() => {
5068
5154
  const observer = new ResizeObserver(() => {
5069
5155
  setShowTransition(false);
5070
5156
  resetAutoZoom();
@@ -5076,8 +5162,8 @@ var Canvas = () => {
5076
5162
  observer.disconnect();
5077
5163
  };
5078
5164
  }, []);
5079
- const [showLoader, setShowLoader] = (0, import_react30.useState)(false);
5080
- (0, import_react30.useEffect)(() => {
5165
+ const [showLoader, setShowLoader] = (0, import_react31.useState)(false);
5166
+ (0, import_react31.useEffect)(() => {
5081
5167
  setTimeout(() => {
5082
5168
  setShowLoader(true);
5083
5169
  }, 500);
@@ -5180,7 +5266,7 @@ var insertComponent = (componentType, zone, index, {
5180
5266
 
5181
5267
  // lib/use-loaded-overrides.ts
5182
5268
  init_react_import();
5183
- var import_react31 = require("react");
5269
+ var import_react32 = require("react");
5184
5270
 
5185
5271
  // lib/load-overrides.ts
5186
5272
  init_react_import();
@@ -5219,7 +5305,7 @@ var useLoadedOverrides = ({
5219
5305
  overrides,
5220
5306
  plugins
5221
5307
  }) => {
5222
- return (0, import_react31.useMemo)(() => {
5308
+ return (0, import_react32.useMemo)(() => {
5223
5309
  return loadOverrides({ overrides, plugins });
5224
5310
  }, [plugins, overrides]);
5225
5311
  };
@@ -5258,7 +5344,7 @@ function Puck({
5258
5344
  enabled: true,
5259
5345
  waitForStyles: true
5260
5346
  }, _iframe);
5261
- const [generatedAppState] = (0, import_react32.useState)(() => {
5347
+ const [generatedAppState] = (0, import_react33.useState)(() => {
5262
5348
  var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
5263
5349
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
5264
5350
  let clientUiState = {};
@@ -5330,22 +5416,22 @@ function Puck({
5330
5416
  histories,
5331
5417
  index: initialHistoryIndex
5332
5418
  });
5333
- const [reducer] = (0, import_react32.useState)(
5419
+ const [reducer] = (0, import_react33.useState)(
5334
5420
  () => createReducer({
5335
5421
  config,
5336
5422
  record: historyStore.record,
5337
5423
  onAction
5338
5424
  })
5339
5425
  );
5340
- const [appState, dispatch] = (0, import_react32.useReducer)(
5426
+ const [appState, dispatch] = (0, import_react33.useReducer)(
5341
5427
  reducer,
5342
5428
  flushZones(initialAppState)
5343
5429
  );
5344
5430
  const { data, ui } = appState;
5345
5431
  const history = usePuckHistory({ dispatch, initialAppState, historyStore });
5346
- const [menuOpen, setMenuOpen] = (0, import_react32.useState)(false);
5432
+ const [menuOpen, setMenuOpen] = (0, import_react33.useState)(false);
5347
5433
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
5348
- const setItemSelector = (0, import_react32.useCallback)(
5434
+ const setItemSelector = (0, import_react33.useCallback)(
5349
5435
  (newItemSelector) => {
5350
5436
  if (newItemSelector === itemSelector) return;
5351
5437
  dispatch({
@@ -5357,13 +5443,13 @@ function Puck({
5357
5443
  [itemSelector]
5358
5444
  );
5359
5445
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
5360
- (0, import_react32.useEffect)(() => {
5446
+ (0, import_react33.useEffect)(() => {
5361
5447
  if (onChange) onChange(data);
5362
5448
  }, [data]);
5363
5449
  const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
5364
- const [draggedItem, setDraggedItem] = (0, import_react32.useState)();
5450
+ const [draggedItem, setDraggedItem] = (0, import_react33.useState)();
5365
5451
  const rootProps = data.root.props || data.root;
5366
- const toggleSidebars = (0, import_react32.useCallback)(
5452
+ const toggleSidebars = (0, import_react33.useCallback)(
5367
5453
  (sidebar) => {
5368
5454
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
5369
5455
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -5377,7 +5463,7 @@ function Puck({
5377
5463
  },
5378
5464
  [dispatch, leftSideBarVisible, rightSideBarVisible]
5379
5465
  );
5380
- (0, import_react32.useEffect)(() => {
5466
+ (0, import_react33.useEffect)(() => {
5381
5467
  if (!window.matchMedia("(min-width: 638px)").matches) {
5382
5468
  dispatch({
5383
5469
  type: "setUi",
@@ -5400,7 +5486,7 @@ function Puck({
5400
5486
  window.removeEventListener("resize", handleResize);
5401
5487
  };
5402
5488
  }, []);
5403
- const defaultHeaderRender = (0, import_react32.useMemo)(() => {
5489
+ const defaultHeaderRender = (0, import_react33.useMemo)(() => {
5404
5490
  if (renderHeader) {
5405
5491
  console.warn(
5406
5492
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -5414,7 +5500,7 @@ function Puck({
5414
5500
  }
5415
5501
  return DefaultOverride;
5416
5502
  }, [renderHeader]);
5417
- const defaultHeaderActionsRender = (0, import_react32.useMemo)(() => {
5503
+ const defaultHeaderActionsRender = (0, import_react33.useMemo)(() => {
5418
5504
  if (renderHeaderActions) {
5419
5505
  console.warn(
5420
5506
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
@@ -5431,20 +5517,20 @@ function Puck({
5431
5517
  overrides,
5432
5518
  plugins
5433
5519
  });
5434
- const CustomPuck = (0, import_react32.useMemo)(
5520
+ const CustomPuck = (0, import_react33.useMemo)(
5435
5521
  () => loadedOverrides.puck || DefaultOverride,
5436
5522
  [loadedOverrides]
5437
5523
  );
5438
- const CustomHeader = (0, import_react32.useMemo)(
5524
+ const CustomHeader = (0, import_react33.useMemo)(
5439
5525
  () => loadedOverrides.header || defaultHeaderRender,
5440
5526
  [loadedOverrides]
5441
5527
  );
5442
- const CustomHeaderActions = (0, import_react32.useMemo)(
5528
+ const CustomHeaderActions = (0, import_react33.useMemo)(
5443
5529
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
5444
5530
  [loadedOverrides]
5445
5531
  );
5446
- const [mounted, setMounted] = (0, import_react32.useState)(false);
5447
- (0, import_react32.useEffect)(() => {
5532
+ const [mounted, setMounted] = (0, import_react33.useState)(false);
5533
+ (0, import_react33.useEffect)(() => {
5448
5534
  setMounted(true);
5449
5535
  }, []);
5450
5536
  const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
@@ -5847,6 +5933,11 @@ var usePuck = () => {
5847
5933
  getPermissions,
5848
5934
  refreshPermissions
5849
5935
  } = useAppContext();
5936
+ if (dispatch === defaultContext.dispatch) {
5937
+ throw new Error(
5938
+ "usePuck was used outside of the <Puck> component. The usePuck hook must be rendered within the <Puck> context as children, overrides or plugins as described in https://puckeditor.com/docs/api-reference/functions/use-puck."
5939
+ );
5940
+ }
5850
5941
  return {
5851
5942
  appState,
5852
5943
  config,