@measured/puck 0.16.3-canary.83b8190 → 0.17.0-canary.00ccd1d
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.css +85 -83
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +210 -135
- package/dist/index.mjs +153 -73
- package/dist/{resolve-all-data-BoWgijLi.d.mts → resolve-all-data-C7aAQCY3.d.mts} +8 -1
- package/dist/{resolve-all-data-BoWgijLi.d.ts → resolve-all-data-C7aAQCY3.d.ts} +8 -1
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/package.json +1 -1
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": "
|
|
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
|
-
|
|
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.
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
e
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
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,8 +1637,9 @@ var DefaultField = ({
|
|
|
1606
1637
|
className: getClassName6("input"),
|
|
1607
1638
|
autoComplete: "off",
|
|
1608
1639
|
type: field.type,
|
|
1640
|
+
title: label || name,
|
|
1609
1641
|
name,
|
|
1610
|
-
value: typeof value === "undefined" ? "" : value,
|
|
1642
|
+
value: typeof value === "undefined" ? "" : value.toString(),
|
|
1611
1643
|
onChange: (e) => {
|
|
1612
1644
|
if (field.type === "number") {
|
|
1613
1645
|
onChange(Number(e.currentTarget.value));
|
|
@@ -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-
|
|
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();
|
|
@@ -1793,7 +1825,7 @@ var ExternalInput = ({
|
|
|
1793
1825
|
const validKeys = /* @__PURE__ */ new Set();
|
|
1794
1826
|
for (const item of mappedData) {
|
|
1795
1827
|
for (const key of Object.keys(item)) {
|
|
1796
|
-
if (typeof item[key] === "string" || typeof item[key] === "number") {
|
|
1828
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react10.isValidElement)(item[key])) {
|
|
1797
1829
|
validKeys.add(key);
|
|
1798
1830
|
}
|
|
1799
1831
|
}
|
|
@@ -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.
|
|
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: (
|
|
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: (
|
|
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,45 @@ 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)("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Render2, __spreadProps(__spreadValues({}, mergedProps), { children })) });
|
|
2329
2392
|
}
|
|
2330
|
-
var RECENT_CHANGE_TIMEOUT = 200;
|
|
2331
2393
|
function AutoFieldPrivate(props) {
|
|
2394
|
+
const { state } = useAppContext();
|
|
2332
2395
|
const { value, onChange } = props;
|
|
2333
2396
|
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
2397
|
const onChangeDb = (0, import_use_debounce.useDebouncedCallback)(
|
|
2337
2398
|
(val, ui) => {
|
|
2338
2399
|
onChange(val, ui);
|
|
@@ -2342,15 +2403,10 @@ function AutoFieldPrivate(props) {
|
|
|
2342
2403
|
);
|
|
2343
2404
|
const onChangeLocal = (0, import_react13.useCallback)((val, ui) => {
|
|
2344
2405
|
setLocalValue(val);
|
|
2345
|
-
setRecentlyChanged(true);
|
|
2346
|
-
clearTimeout(timeoutRef.current);
|
|
2347
|
-
timeoutRef.current = setTimeout(() => {
|
|
2348
|
-
setRecentlyChanged(false);
|
|
2349
|
-
}, RECENT_CHANGE_TIMEOUT);
|
|
2350
2406
|
onChangeDb(val, ui);
|
|
2351
2407
|
}, []);
|
|
2352
2408
|
(0, import_react13.useEffect)(() => {
|
|
2353
|
-
if (
|
|
2409
|
+
if (state.ui.field.focus !== props.name) {
|
|
2354
2410
|
setLocalValue(value);
|
|
2355
2411
|
}
|
|
2356
2412
|
}, [value]);
|
|
@@ -3075,7 +3131,7 @@ function DropZone(props) {
|
|
|
3075
3131
|
|
|
3076
3132
|
// components/Puck/index.tsx
|
|
3077
3133
|
init_react_import();
|
|
3078
|
-
var
|
|
3134
|
+
var import_react33 = require("react");
|
|
3079
3135
|
|
|
3080
3136
|
// lib/use-placeholder-style.ts
|
|
3081
3137
|
init_react_import();
|
|
@@ -3682,7 +3738,23 @@ init_react_import();
|
|
|
3682
3738
|
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
3739
|
|
|
3684
3740
|
// components/Puck/components/Fields/index.tsx
|
|
3741
|
+
var import_react22 = require("react");
|
|
3742
|
+
|
|
3743
|
+
// lib/use-parent.ts
|
|
3744
|
+
init_react_import();
|
|
3685
3745
|
var import_react21 = require("react");
|
|
3746
|
+
var useParent = (itemSelector) => {
|
|
3747
|
+
var _a;
|
|
3748
|
+
const { selectedItem, state } = useAppContext();
|
|
3749
|
+
const { pathData } = (0, import_react21.useContext)(dropZoneContext) || {};
|
|
3750
|
+
const item = itemSelector ? getItem(itemSelector, state.data) : selectedItem;
|
|
3751
|
+
const breadcrumbs = convertPathDataToBreadcrumbs(item, pathData, state.data);
|
|
3752
|
+
const lastItem = breadcrumbs[breadcrumbs.length - 1];
|
|
3753
|
+
const parent = (lastItem == null ? void 0 : lastItem.selector) ? (_a = getItem(lastItem.selector, state.data)) != null ? _a : null : null;
|
|
3754
|
+
return parent || null;
|
|
3755
|
+
};
|
|
3756
|
+
|
|
3757
|
+
// components/Puck/components/Fields/index.tsx
|
|
3686
3758
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3687
3759
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
|
3688
3760
|
var defaultPageFields = {
|
|
@@ -3696,23 +3768,24 @@ var DefaultFields = ({
|
|
|
3696
3768
|
var useResolvedFields = () => {
|
|
3697
3769
|
var _a, _b;
|
|
3698
3770
|
const { selectedItem, state, config } = useAppContext();
|
|
3771
|
+
const parent = useParent();
|
|
3699
3772
|
const { data } = state;
|
|
3700
3773
|
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
|
3701
3774
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
|
3702
|
-
const defaultFields = (0,
|
|
3775
|
+
const defaultFields = (0, import_react22.useMemo)(
|
|
3703
3776
|
() => (selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields) || {},
|
|
3704
3777
|
[selectedItem, rootFields, componentConfig == null ? void 0 : componentConfig.fields]
|
|
3705
3778
|
);
|
|
3706
3779
|
const rootProps = data.root.props || data.root;
|
|
3707
|
-
const [lastSelectedData, setLastSelectedData] = (0,
|
|
3708
|
-
const [resolvedFields, setResolvedFields] = (0,
|
|
3709
|
-
const [fieldsLoading, setFieldsLoading] = (0,
|
|
3780
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react22.useState)({});
|
|
3781
|
+
const [resolvedFields, setResolvedFields] = (0, import_react22.useState)(defaultFields);
|
|
3782
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react22.useState)(false);
|
|
3710
3783
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
|
3711
3784
|
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
|
3712
3785
|
const hasComponentResolver = selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields);
|
|
3713
3786
|
const hasRootResolver = !selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields);
|
|
3714
3787
|
const hasResolver = hasComponentResolver || hasRootResolver;
|
|
3715
|
-
const resolveFields = (0,
|
|
3788
|
+
const resolveFields = (0, import_react22.useCallback)(
|
|
3716
3789
|
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
|
3717
3790
|
var _a2;
|
|
3718
3791
|
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : null;
|
|
@@ -3726,7 +3799,8 @@ var useResolvedFields = () => {
|
|
|
3726
3799
|
fields,
|
|
3727
3800
|
lastFields: resolvedFields,
|
|
3728
3801
|
lastData,
|
|
3729
|
-
appState: state
|
|
3802
|
+
appState: state,
|
|
3803
|
+
parent
|
|
3730
3804
|
}
|
|
3731
3805
|
);
|
|
3732
3806
|
}
|
|
@@ -3736,7 +3810,8 @@ var useResolvedFields = () => {
|
|
|
3736
3810
|
fields,
|
|
3737
3811
|
lastFields: resolvedFields,
|
|
3738
3812
|
lastData,
|
|
3739
|
-
appState: state
|
|
3813
|
+
appState: state,
|
|
3814
|
+
parent
|
|
3740
3815
|
});
|
|
3741
3816
|
}
|
|
3742
3817
|
return defaultResolveFields(componentData, {
|
|
@@ -3748,7 +3823,7 @@ var useResolvedFields = () => {
|
|
|
3748
3823
|
}),
|
|
3749
3824
|
[data, config, componentData, selectedItem, resolvedFields, state]
|
|
3750
3825
|
);
|
|
3751
|
-
(0,
|
|
3826
|
+
(0, import_react22.useEffect)(() => {
|
|
3752
3827
|
if (hasResolver) {
|
|
3753
3828
|
setFieldsLoading(true);
|
|
3754
3829
|
resolveFields(defaultFields).then((fields) => {
|
|
@@ -3758,7 +3833,7 @@ var useResolvedFields = () => {
|
|
|
3758
3833
|
} else {
|
|
3759
3834
|
setResolvedFields(defaultFields);
|
|
3760
3835
|
}
|
|
3761
|
-
}, [data, defaultFields,
|
|
3836
|
+
}, [data, defaultFields, selectedItem, hasResolver]);
|
|
3762
3837
|
return [resolvedFields, fieldsLoading];
|
|
3763
3838
|
};
|
|
3764
3839
|
var Fields = () => {
|
|
@@ -3779,7 +3854,7 @@ var Fields = () => {
|
|
|
3779
3854
|
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
3855
|
const isLoading = fieldsResolving || componentResolving;
|
|
3781
3856
|
const rootProps = data.root.props || data.root;
|
|
3782
|
-
const Wrapper = (0,
|
|
3857
|
+
const Wrapper = (0, import_react22.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
|
3783
3858
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3784
3859
|
"form",
|
|
3785
3860
|
{
|
|
@@ -3900,7 +3975,7 @@ init_react_import();
|
|
|
3900
3975
|
|
|
3901
3976
|
// lib/use-component-list.tsx
|
|
3902
3977
|
init_react_import();
|
|
3903
|
-
var
|
|
3978
|
+
var import_react23 = require("react");
|
|
3904
3979
|
|
|
3905
3980
|
// components/ComponentList/index.tsx
|
|
3906
3981
|
init_react_import();
|
|
@@ -3978,8 +4053,8 @@ ComponentList.Item = ComponentListItem;
|
|
|
3978
4053
|
// lib/use-component-list.tsx
|
|
3979
4054
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3980
4055
|
var useComponentList = (config, ui) => {
|
|
3981
|
-
const [componentList, setComponentList] = (0,
|
|
3982
|
-
(0,
|
|
4056
|
+
const [componentList, setComponentList] = (0, import_react23.useState)();
|
|
4057
|
+
(0, import_react23.useEffect)(() => {
|
|
3983
4058
|
var _a, _b, _c;
|
|
3984
4059
|
if (Object.keys(ui.componentList).length > 0) {
|
|
3985
4060
|
const matchedComponents = [];
|
|
@@ -4048,22 +4123,22 @@ var useComponentList = (config, ui) => {
|
|
|
4048
4123
|
};
|
|
4049
4124
|
|
|
4050
4125
|
// components/Puck/components/Components/index.tsx
|
|
4051
|
-
var
|
|
4126
|
+
var import_react24 = require("react");
|
|
4052
4127
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
4053
4128
|
var Components = () => {
|
|
4054
4129
|
const { config, state, overrides } = useAppContext();
|
|
4055
4130
|
const componentList = useComponentList(config, state.ui);
|
|
4056
|
-
const Wrapper = (0,
|
|
4131
|
+
const Wrapper = (0, import_react24.useMemo)(() => overrides.components || "div", [overrides]);
|
|
4057
4132
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ComponentList, { id: "all" }) });
|
|
4058
4133
|
};
|
|
4059
4134
|
|
|
4060
4135
|
// components/Puck/components/Preview/index.tsx
|
|
4061
4136
|
init_react_import();
|
|
4062
|
-
var
|
|
4137
|
+
var import_react26 = require("react");
|
|
4063
4138
|
|
|
4064
4139
|
// components/AutoFrame/index.tsx
|
|
4065
4140
|
init_react_import();
|
|
4066
|
-
var
|
|
4141
|
+
var import_react25 = require("react");
|
|
4067
4142
|
var import_object_hash = __toESM(require("object-hash"));
|
|
4068
4143
|
var import_react_dom2 = require("react-dom");
|
|
4069
4144
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
@@ -4109,7 +4184,7 @@ var CopyHostStyles = ({
|
|
|
4109
4184
|
onStylesLoaded = () => null
|
|
4110
4185
|
}) => {
|
|
4111
4186
|
const { document: doc, window: win } = useFrame();
|
|
4112
|
-
(0,
|
|
4187
|
+
(0, import_react25.useEffect)(() => {
|
|
4113
4188
|
if (!win || !doc) {
|
|
4114
4189
|
return () => {
|
|
4115
4190
|
};
|
|
@@ -4268,8 +4343,8 @@ var CopyHostStyles = ({
|
|
|
4268
4343
|
}, []);
|
|
4269
4344
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
|
|
4270
4345
|
};
|
|
4271
|
-
var autoFrameContext = (0,
|
|
4272
|
-
var useFrame = () => (0,
|
|
4346
|
+
var autoFrameContext = (0, import_react25.createContext)({});
|
|
4347
|
+
var useFrame = () => (0, import_react25.useContext)(autoFrameContext);
|
|
4273
4348
|
function AutoFrame(_a) {
|
|
4274
4349
|
var _b = _a, {
|
|
4275
4350
|
children,
|
|
@@ -4284,11 +4359,11 @@ function AutoFrame(_a) {
|
|
|
4284
4359
|
"id",
|
|
4285
4360
|
"onStylesLoaded"
|
|
4286
4361
|
]);
|
|
4287
|
-
const [loaded, setLoaded] = (0,
|
|
4288
|
-
const [ctx, setCtx] = (0,
|
|
4289
|
-
const ref = (0,
|
|
4290
|
-
const [mountTarget, setMountTarget] = (0,
|
|
4291
|
-
(0,
|
|
4362
|
+
const [loaded, setLoaded] = (0, import_react25.useState)(false);
|
|
4363
|
+
const [ctx, setCtx] = (0, import_react25.useState)({});
|
|
4364
|
+
const ref = (0, import_react25.useRef)(null);
|
|
4365
|
+
const [mountTarget, setMountTarget] = (0, import_react25.useState)();
|
|
4366
|
+
(0, import_react25.useEffect)(() => {
|
|
4292
4367
|
var _a2;
|
|
4293
4368
|
if (ref.current) {
|
|
4294
4369
|
setCtx({
|
|
@@ -4324,7 +4399,7 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
|
4324
4399
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
|
4325
4400
|
var Preview = ({ id = "puck-preview" }) => {
|
|
4326
4401
|
const { config, dispatch, state, setStatus, iframe, overrides } = useAppContext();
|
|
4327
|
-
const Page = (0,
|
|
4402
|
+
const Page = (0, import_react26.useCallback)(
|
|
4328
4403
|
(pageProps) => {
|
|
4329
4404
|
var _a, _b;
|
|
4330
4405
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
|
@@ -4333,7 +4408,7 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
|
4333
4408
|
},
|
|
4334
4409
|
[config.root]
|
|
4335
4410
|
);
|
|
4336
|
-
const Frame = (0,
|
|
4411
|
+
const Frame = (0, import_react26.useMemo)(() => overrides.iframe, [overrides]);
|
|
4337
4412
|
const rootProps = state.data.root.props || state.data.root;
|
|
4338
4413
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4339
4414
|
"div",
|
|
@@ -4422,7 +4497,7 @@ var scrollIntoView = (el) => {
|
|
|
4422
4497
|
};
|
|
4423
4498
|
|
|
4424
4499
|
// components/LayerTree/index.tsx
|
|
4425
|
-
var
|
|
4500
|
+
var import_react27 = require("react");
|
|
4426
4501
|
|
|
4427
4502
|
// lib/is-child-of-zone.ts
|
|
4428
4503
|
init_react_import();
|
|
@@ -4449,7 +4524,7 @@ var LayerTree = ({
|
|
|
4449
4524
|
label
|
|
4450
4525
|
}) => {
|
|
4451
4526
|
const zones = data.zones || {};
|
|
4452
|
-
const ctx = (0,
|
|
4527
|
+
const ctx = (0, import_react27.useContext)(dropZoneContext);
|
|
4453
4528
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
|
4454
4529
|
label && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName24("zoneTitle"), children: [
|
|
4455
4530
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Layers, { size: "16" }) }),
|
|
@@ -4555,13 +4630,13 @@ var LayerTree = ({
|
|
|
4555
4630
|
};
|
|
4556
4631
|
|
|
4557
4632
|
// components/Puck/components/Outline/index.tsx
|
|
4558
|
-
var
|
|
4633
|
+
var import_react28 = require("react");
|
|
4559
4634
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
4560
4635
|
var Outline = () => {
|
|
4561
4636
|
const { dispatch, state, overrides, config } = useAppContext();
|
|
4562
4637
|
const { data, ui } = state;
|
|
4563
4638
|
const { itemSelector } = ui;
|
|
4564
|
-
const setItemSelector = (0,
|
|
4639
|
+
const setItemSelector = (0, import_react28.useCallback)(
|
|
4565
4640
|
(newItemSelector) => {
|
|
4566
4641
|
dispatch({
|
|
4567
4642
|
type: "setUi",
|
|
@@ -4570,7 +4645,7 @@ var Outline = () => {
|
|
|
4570
4645
|
},
|
|
4571
4646
|
[]
|
|
4572
4647
|
);
|
|
4573
|
-
const Wrapper = (0,
|
|
4648
|
+
const Wrapper = (0, import_react28.useMemo)(() => overrides.outline || "div", [overrides]);
|
|
4574
4649
|
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
4650
|
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4576
4651
|
LayerTree,
|
|
@@ -4659,19 +4734,19 @@ function usePuckHistory({
|
|
|
4659
4734
|
|
|
4660
4735
|
// lib/use-history-store.ts
|
|
4661
4736
|
init_react_import();
|
|
4662
|
-
var
|
|
4737
|
+
var import_react29 = require("react");
|
|
4663
4738
|
var import_use_debounce3 = require("use-debounce");
|
|
4664
4739
|
var EMPTY_HISTORY_INDEX = 0;
|
|
4665
4740
|
function useHistoryStore(initialHistory) {
|
|
4666
4741
|
var _a, _b;
|
|
4667
|
-
const [histories, setHistories] = (0,
|
|
4742
|
+
const [histories, setHistories] = (0, import_react29.useState)(
|
|
4668
4743
|
(_a = initialHistory == null ? void 0 : initialHistory.histories) != null ? _a : []
|
|
4669
4744
|
);
|
|
4670
4745
|
const updateHistories = (histories2) => {
|
|
4671
4746
|
setHistories(histories2);
|
|
4672
4747
|
setIndex(histories2.length - 1);
|
|
4673
4748
|
};
|
|
4674
|
-
const [index, setIndex] = (0,
|
|
4749
|
+
const [index, setIndex] = (0, import_react29.useState)(
|
|
4675
4750
|
(_b = initialHistory == null ? void 0 : initialHistory.index) != null ? _b : EMPTY_HISTORY_INDEX
|
|
4676
4751
|
);
|
|
4677
4752
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
|
@@ -4831,11 +4906,11 @@ var getBox = function getBox2(el) {
|
|
|
4831
4906
|
};
|
|
4832
4907
|
|
|
4833
4908
|
// components/Puck/components/Canvas/index.tsx
|
|
4834
|
-
var
|
|
4909
|
+
var import_react31 = require("react");
|
|
4835
4910
|
|
|
4836
4911
|
// components/ViewportControls/index.tsx
|
|
4837
4912
|
init_react_import();
|
|
4838
|
-
var
|
|
4913
|
+
var import_react30 = require("react");
|
|
4839
4914
|
|
|
4840
4915
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
4841
4916
|
init_react_import();
|
|
@@ -4858,8 +4933,8 @@ var ViewportButton = ({
|
|
|
4858
4933
|
onClick
|
|
4859
4934
|
}) => {
|
|
4860
4935
|
const { state } = useAppContext();
|
|
4861
|
-
const [isActive, setIsActive] = (0,
|
|
4862
|
-
(0,
|
|
4936
|
+
const [isActive, setIsActive] = (0, import_react30.useState)(false);
|
|
4937
|
+
(0, import_react30.useEffect)(() => {
|
|
4863
4938
|
setIsActive(width === state.ui.viewports.current.width);
|
|
4864
4939
|
}, [width, state.ui.viewports.current.width]);
|
|
4865
4940
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
@@ -4895,7 +4970,7 @@ var ViewportControls = ({
|
|
|
4895
4970
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
|
4896
4971
|
(option) => option.value === autoZoom
|
|
4897
4972
|
);
|
|
4898
|
-
const zoomOptions = (0,
|
|
4973
|
+
const zoomOptions = (0, import_react30.useMemo)(
|
|
4899
4974
|
() => [
|
|
4900
4975
|
...defaultZoomOptions,
|
|
4901
4976
|
...defaultsContainAutoZoom ? [] : [
|
|
@@ -5018,17 +5093,17 @@ var Canvas = () => {
|
|
|
5018
5093
|
const { status, iframe } = useAppContext();
|
|
5019
5094
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
|
5020
5095
|
const { ui } = state;
|
|
5021
|
-
const frameRef = (0,
|
|
5022
|
-
const [showTransition, setShowTransition] = (0,
|
|
5023
|
-
const defaultRender = (0,
|
|
5096
|
+
const frameRef = (0, import_react31.useRef)(null);
|
|
5097
|
+
const [showTransition, setShowTransition] = (0, import_react31.useState)(false);
|
|
5098
|
+
const defaultRender = (0, import_react31.useMemo)(() => {
|
|
5024
5099
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_jsx_runtime36.Fragment, { children });
|
|
5025
5100
|
return PuckDefault;
|
|
5026
5101
|
}, []);
|
|
5027
|
-
const CustomPreview = (0,
|
|
5102
|
+
const CustomPreview = (0, import_react31.useMemo)(
|
|
5028
5103
|
() => overrides.preview || defaultRender,
|
|
5029
5104
|
[overrides]
|
|
5030
5105
|
);
|
|
5031
|
-
const getFrameDimensions = (0,
|
|
5106
|
+
const getFrameDimensions = (0, import_react31.useCallback)(() => {
|
|
5032
5107
|
if (frameRef.current) {
|
|
5033
5108
|
const frame = frameRef.current;
|
|
5034
5109
|
const box = getBox(frame);
|
|
@@ -5036,7 +5111,7 @@ var Canvas = () => {
|
|
|
5036
5111
|
}
|
|
5037
5112
|
return { width: 0, height: 0 };
|
|
5038
5113
|
}, [frameRef]);
|
|
5039
|
-
const resetAutoZoom = (0,
|
|
5114
|
+
const resetAutoZoom = (0, import_react31.useCallback)(
|
|
5040
5115
|
(ui2 = state.ui) => {
|
|
5041
5116
|
if (frameRef.current) {
|
|
5042
5117
|
setZoomConfig(
|
|
@@ -5046,11 +5121,11 @@ var Canvas = () => {
|
|
|
5046
5121
|
},
|
|
5047
5122
|
[frameRef, zoomConfig, state.ui]
|
|
5048
5123
|
);
|
|
5049
|
-
(0,
|
|
5124
|
+
(0, import_react31.useEffect)(() => {
|
|
5050
5125
|
setShowTransition(false);
|
|
5051
5126
|
resetAutoZoom();
|
|
5052
5127
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
|
5053
|
-
(0,
|
|
5128
|
+
(0, import_react31.useEffect)(() => {
|
|
5054
5129
|
const { height: frameHeight } = getFrameDimensions();
|
|
5055
5130
|
if (ui.viewports.current.height === "auto") {
|
|
5056
5131
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
@@ -5058,13 +5133,13 @@ var Canvas = () => {
|
|
|
5058
5133
|
}));
|
|
5059
5134
|
}
|
|
5060
5135
|
}, [zoomConfig.zoom]);
|
|
5061
|
-
(0,
|
|
5136
|
+
(0, import_react31.useEffect)(() => {
|
|
5062
5137
|
if (ZOOM_ON_CHANGE) {
|
|
5063
5138
|
setShowTransition(true);
|
|
5064
5139
|
resetAutoZoom(ui);
|
|
5065
5140
|
}
|
|
5066
5141
|
}, [ui.viewports.current.width]);
|
|
5067
|
-
(0,
|
|
5142
|
+
(0, import_react31.useEffect)(() => {
|
|
5068
5143
|
const observer = new ResizeObserver(() => {
|
|
5069
5144
|
setShowTransition(false);
|
|
5070
5145
|
resetAutoZoom();
|
|
@@ -5076,8 +5151,8 @@ var Canvas = () => {
|
|
|
5076
5151
|
observer.disconnect();
|
|
5077
5152
|
};
|
|
5078
5153
|
}, []);
|
|
5079
|
-
const [showLoader, setShowLoader] = (0,
|
|
5080
|
-
(0,
|
|
5154
|
+
const [showLoader, setShowLoader] = (0, import_react31.useState)(false);
|
|
5155
|
+
(0, import_react31.useEffect)(() => {
|
|
5081
5156
|
setTimeout(() => {
|
|
5082
5157
|
setShowLoader(true);
|
|
5083
5158
|
}, 500);
|
|
@@ -5180,7 +5255,7 @@ var insertComponent = (componentType, zone, index, {
|
|
|
5180
5255
|
|
|
5181
5256
|
// lib/use-loaded-overrides.ts
|
|
5182
5257
|
init_react_import();
|
|
5183
|
-
var
|
|
5258
|
+
var import_react32 = require("react");
|
|
5184
5259
|
|
|
5185
5260
|
// lib/load-overrides.ts
|
|
5186
5261
|
init_react_import();
|
|
@@ -5219,7 +5294,7 @@ var useLoadedOverrides = ({
|
|
|
5219
5294
|
overrides,
|
|
5220
5295
|
plugins
|
|
5221
5296
|
}) => {
|
|
5222
|
-
return (0,
|
|
5297
|
+
return (0, import_react32.useMemo)(() => {
|
|
5223
5298
|
return loadOverrides({ overrides, plugins });
|
|
5224
5299
|
}, [plugins, overrides]);
|
|
5225
5300
|
};
|
|
@@ -5258,7 +5333,7 @@ function Puck({
|
|
|
5258
5333
|
enabled: true,
|
|
5259
5334
|
waitForStyles: true
|
|
5260
5335
|
}, _iframe);
|
|
5261
|
-
const [generatedAppState] = (0,
|
|
5336
|
+
const [generatedAppState] = (0, import_react33.useState)(() => {
|
|
5262
5337
|
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
5263
5338
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
5264
5339
|
let clientUiState = {};
|
|
@@ -5330,22 +5405,22 @@ function Puck({
|
|
|
5330
5405
|
histories,
|
|
5331
5406
|
index: initialHistoryIndex
|
|
5332
5407
|
});
|
|
5333
|
-
const [reducer] = (0,
|
|
5408
|
+
const [reducer] = (0, import_react33.useState)(
|
|
5334
5409
|
() => createReducer({
|
|
5335
5410
|
config,
|
|
5336
5411
|
record: historyStore.record,
|
|
5337
5412
|
onAction
|
|
5338
5413
|
})
|
|
5339
5414
|
);
|
|
5340
|
-
const [appState, dispatch] = (0,
|
|
5415
|
+
const [appState, dispatch] = (0, import_react33.useReducer)(
|
|
5341
5416
|
reducer,
|
|
5342
5417
|
flushZones(initialAppState)
|
|
5343
5418
|
);
|
|
5344
5419
|
const { data, ui } = appState;
|
|
5345
5420
|
const history = usePuckHistory({ dispatch, initialAppState, historyStore });
|
|
5346
|
-
const [menuOpen, setMenuOpen] = (0,
|
|
5421
|
+
const [menuOpen, setMenuOpen] = (0, import_react33.useState)(false);
|
|
5347
5422
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
|
5348
|
-
const setItemSelector = (0,
|
|
5423
|
+
const setItemSelector = (0, import_react33.useCallback)(
|
|
5349
5424
|
(newItemSelector) => {
|
|
5350
5425
|
if (newItemSelector === itemSelector) return;
|
|
5351
5426
|
dispatch({
|
|
@@ -5357,13 +5432,13 @@ function Puck({
|
|
|
5357
5432
|
[itemSelector]
|
|
5358
5433
|
);
|
|
5359
5434
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
|
5360
|
-
(0,
|
|
5435
|
+
(0, import_react33.useEffect)(() => {
|
|
5361
5436
|
if (onChange) onChange(data);
|
|
5362
5437
|
}, [data]);
|
|
5363
5438
|
const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
|
|
5364
|
-
const [draggedItem, setDraggedItem] = (0,
|
|
5439
|
+
const [draggedItem, setDraggedItem] = (0, import_react33.useState)();
|
|
5365
5440
|
const rootProps = data.root.props || data.root;
|
|
5366
|
-
const toggleSidebars = (0,
|
|
5441
|
+
const toggleSidebars = (0, import_react33.useCallback)(
|
|
5367
5442
|
(sidebar) => {
|
|
5368
5443
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
5369
5444
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -5377,7 +5452,7 @@ function Puck({
|
|
|
5377
5452
|
},
|
|
5378
5453
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
5379
5454
|
);
|
|
5380
|
-
(0,
|
|
5455
|
+
(0, import_react33.useEffect)(() => {
|
|
5381
5456
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
5382
5457
|
dispatch({
|
|
5383
5458
|
type: "setUi",
|
|
@@ -5400,7 +5475,7 @@ function Puck({
|
|
|
5400
5475
|
window.removeEventListener("resize", handleResize);
|
|
5401
5476
|
};
|
|
5402
5477
|
}, []);
|
|
5403
|
-
const defaultHeaderRender = (0,
|
|
5478
|
+
const defaultHeaderRender = (0, import_react33.useMemo)(() => {
|
|
5404
5479
|
if (renderHeader) {
|
|
5405
5480
|
console.warn(
|
|
5406
5481
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
@@ -5414,7 +5489,7 @@ function Puck({
|
|
|
5414
5489
|
}
|
|
5415
5490
|
return DefaultOverride;
|
|
5416
5491
|
}, [renderHeader]);
|
|
5417
|
-
const defaultHeaderActionsRender = (0,
|
|
5492
|
+
const defaultHeaderActionsRender = (0, import_react33.useMemo)(() => {
|
|
5418
5493
|
if (renderHeaderActions) {
|
|
5419
5494
|
console.warn(
|
|
5420
5495
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
@@ -5431,20 +5506,20 @@ function Puck({
|
|
|
5431
5506
|
overrides,
|
|
5432
5507
|
plugins
|
|
5433
5508
|
});
|
|
5434
|
-
const CustomPuck = (0,
|
|
5509
|
+
const CustomPuck = (0, import_react33.useMemo)(
|
|
5435
5510
|
() => loadedOverrides.puck || DefaultOverride,
|
|
5436
5511
|
[loadedOverrides]
|
|
5437
5512
|
);
|
|
5438
|
-
const CustomHeader = (0,
|
|
5513
|
+
const CustomHeader = (0, import_react33.useMemo)(
|
|
5439
5514
|
() => loadedOverrides.header || defaultHeaderRender,
|
|
5440
5515
|
[loadedOverrides]
|
|
5441
5516
|
);
|
|
5442
|
-
const CustomHeaderActions = (0,
|
|
5517
|
+
const CustomHeaderActions = (0, import_react33.useMemo)(
|
|
5443
5518
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
|
5444
5519
|
[loadedOverrides]
|
|
5445
5520
|
);
|
|
5446
|
-
const [mounted, setMounted] = (0,
|
|
5447
|
-
(0,
|
|
5521
|
+
const [mounted, setMounted] = (0, import_react33.useState)(false);
|
|
5522
|
+
(0, import_react33.useEffect)(() => {
|
|
5448
5523
|
setMounted(true);
|
|
5449
5524
|
}, []);
|
|
5450
5525
|
const selectedComponentConfig = selectedItem && config.components[selectedItem.type];
|