@measured/puck 0.14.3-canary.9df6633 → 0.15.0-canary.46aa8ff
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -4
- package/dist/{Config-09628f3c.d.ts → Config-25917005.d.ts} +15 -11
- package/dist/index.css +5 -2
- package/dist/index.d.ts +7 -7
- package/dist/index.js +492 -223
- package/dist/rsc.d.ts +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
@@ -8033,9 +8033,9 @@ var require_react_dom_development = __commonJS({
|
|
8033
8033
|
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
8034
8034
|
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
8035
8035
|
}
|
8036
|
-
var
|
8036
|
+
var React3 = require("react");
|
8037
8037
|
var Scheduler = require_scheduler();
|
8038
|
-
var ReactSharedInternals =
|
8038
|
+
var ReactSharedInternals = React3.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
8039
8039
|
var suppressWarning = false;
|
8040
8040
|
function setSuppressWarning(newSuppressWarning) {
|
8041
8041
|
{
|
@@ -8084,7 +8084,7 @@ var require_react_dom_development = __commonJS({
|
|
8084
8084
|
var HostPortal = 4;
|
8085
8085
|
var HostComponent = 5;
|
8086
8086
|
var HostText = 6;
|
8087
|
-
var
|
8087
|
+
var Fragment18 = 7;
|
8088
8088
|
var Mode = 8;
|
8089
8089
|
var ContextConsumer = 9;
|
8090
8090
|
var ContextProvider = 10;
|
@@ -9240,7 +9240,7 @@ var require_react_dom_development = __commonJS({
|
|
9240
9240
|
return "DehydratedFragment";
|
9241
9241
|
case ForwardRef:
|
9242
9242
|
return getWrappedName$1(type, type.render, "ForwardRef");
|
9243
|
-
case
|
9243
|
+
case Fragment18:
|
9244
9244
|
return "Fragment";
|
9245
9245
|
case HostComponent:
|
9246
9246
|
return type;
|
@@ -9640,7 +9640,7 @@ var require_react_dom_development = __commonJS({
|
|
9640
9640
|
{
|
9641
9641
|
if (props.value == null) {
|
9642
9642
|
if (typeof props.children === "object" && props.children !== null) {
|
9643
|
-
|
9643
|
+
React3.Children.forEach(props.children, function(child) {
|
9644
9644
|
if (child == null) {
|
9645
9645
|
return;
|
9646
9646
|
}
|
@@ -18087,7 +18087,7 @@ var require_react_dom_development = __commonJS({
|
|
18087
18087
|
}
|
18088
18088
|
}
|
18089
18089
|
var fakeInternalInstance = {};
|
18090
|
-
var emptyRefsObject = new
|
18090
|
+
var emptyRefsObject = new React3.Component().refs;
|
18091
18091
|
var didWarnAboutStateAssignmentForComponent;
|
18092
18092
|
var didWarnAboutUninitializedState;
|
18093
18093
|
var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
|
@@ -18911,7 +18911,7 @@ var require_react_dom_development = __commonJS({
|
|
18911
18911
|
}
|
18912
18912
|
}
|
18913
18913
|
function updateFragment2(returnFiber, current2, fragment, lanes, key) {
|
18914
|
-
if (current2 === null || current2.tag !==
|
18914
|
+
if (current2 === null || current2.tag !== Fragment18) {
|
18915
18915
|
var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);
|
18916
18916
|
created.return = returnFiber;
|
18917
18917
|
return created;
|
@@ -19314,7 +19314,7 @@ var require_react_dom_development = __commonJS({
|
|
19314
19314
|
if (child.key === key) {
|
19315
19315
|
var elementType = element.type;
|
19316
19316
|
if (elementType === REACT_FRAGMENT_TYPE) {
|
19317
|
-
if (child.tag ===
|
19317
|
+
if (child.tag === Fragment18) {
|
19318
19318
|
deleteRemainingChildren(returnFiber, child.sibling);
|
19319
19319
|
var existing = useFiber(child, element.props.children);
|
19320
19320
|
existing.return = returnFiber;
|
@@ -23489,7 +23489,7 @@ var require_react_dom_development = __commonJS({
|
|
23489
23489
|
var _resolvedProps2 = workInProgress2.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
|
23490
23490
|
return updateForwardRef(current2, workInProgress2, type, _resolvedProps2, renderLanes2);
|
23491
23491
|
}
|
23492
|
-
case
|
23492
|
+
case Fragment18:
|
23493
23493
|
return updateFragment(current2, workInProgress2, renderLanes2);
|
23494
23494
|
case Mode:
|
23495
23495
|
return updateMode(current2, workInProgress2, renderLanes2);
|
@@ -23762,7 +23762,7 @@ var require_react_dom_development = __commonJS({
|
|
23762
23762
|
case SimpleMemoComponent:
|
23763
23763
|
case FunctionComponent:
|
23764
23764
|
case ForwardRef:
|
23765
|
-
case
|
23765
|
+
case Fragment18:
|
23766
23766
|
case Mode:
|
23767
23767
|
case Profiler:
|
23768
23768
|
case ContextConsumer:
|
@@ -28021,7 +28021,7 @@ var require_react_dom_development = __commonJS({
|
|
28021
28021
|
return fiber;
|
28022
28022
|
}
|
28023
28023
|
function createFiberFromFragment(elements, mode, lanes, key) {
|
28024
|
-
var fiber = createFiber(
|
28024
|
+
var fiber = createFiber(Fragment18, elements, key, mode);
|
28025
28025
|
fiber.lanes = lanes;
|
28026
28026
|
return fiber;
|
28027
28027
|
}
|
@@ -29314,7 +29314,7 @@ var defaultViewports = [
|
|
29314
29314
|
var import_ua_parser_js = require("ua-parser-js");
|
29315
29315
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
29316
29316
|
var defaultAppState = {
|
29317
|
-
data: { content: [], root: { props: {
|
29317
|
+
data: { content: [], root: { props: {} } },
|
29318
29318
|
ui: {
|
29319
29319
|
leftSideBarVisible: true,
|
29320
29320
|
rightSideBarVisible: true,
|
@@ -30528,7 +30528,7 @@ var IconButton = ({
|
|
30528
30528
|
|
30529
30529
|
// components/Puck/index.tsx
|
30530
30530
|
init_react_import();
|
30531
|
-
var
|
30531
|
+
var import_react29 = require("react");
|
30532
30532
|
|
30533
30533
|
// lib/use-placeholder-style.ts
|
30534
30534
|
init_react_import();
|
@@ -31095,6 +31095,20 @@ var import_react13 = require("react");
|
|
31095
31095
|
|
31096
31096
|
// lib/resolve-component-data.ts
|
31097
31097
|
init_react_import();
|
31098
|
+
|
31099
|
+
// lib/get-changed.ts
|
31100
|
+
init_react_import();
|
31101
|
+
var getChanged = (newItem, oldItem) => {
|
31102
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
31103
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
31104
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
31105
|
+
return __spreadProps(__spreadValues({}, acc), {
|
31106
|
+
[item]: oldItemProps[item] !== newItemProps[item]
|
31107
|
+
});
|
31108
|
+
}, {}) : {};
|
31109
|
+
};
|
31110
|
+
|
31111
|
+
// lib/resolve-component-data.ts
|
31098
31112
|
var cache = { lastChange: {} };
|
31099
31113
|
var resolveAllComponentData = (content, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
31100
31114
|
return yield Promise.all(
|
@@ -31111,25 +31125,15 @@ var resolveAllComponentData = (content, config, onResolveStart, onResolveEnd) =>
|
|
31111
31125
|
var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
|
31112
31126
|
const configForItem = config.components[item.type];
|
31113
31127
|
if (configForItem.resolveData) {
|
31114
|
-
|
31115
|
-
|
31116
|
-
|
31117
|
-
);
|
31118
|
-
if (cache.lastChange[item.props.id]) {
|
31119
|
-
const { item: oldItem, resolved } = cache.lastChange[item.props.id];
|
31120
|
-
if (oldItem === item) {
|
31121
|
-
return resolved;
|
31122
|
-
}
|
31123
|
-
Object.keys(item.props).forEach((propName) => {
|
31124
|
-
if (oldItem.props[propName] === item.props[propName]) {
|
31125
|
-
changed[propName] = false;
|
31126
|
-
}
|
31127
|
-
});
|
31128
|
+
const { item: oldItem = {}, resolved = {} } = cache.lastChange[item.props.id] || {};
|
31129
|
+
if (item && item === oldItem) {
|
31130
|
+
return resolved;
|
31128
31131
|
}
|
31132
|
+
const changed = getChanged(item, oldItem);
|
31129
31133
|
if (onResolveStart) {
|
31130
31134
|
onResolveStart(item);
|
31131
31135
|
}
|
31132
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed });
|
31136
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, { changed, lastData: oldItem });
|
31133
31137
|
const { readOnly: existingReadOnly = {} } = item || {};
|
31134
31138
|
const newReadOnly = __spreadValues(__spreadValues({}, existingReadOnly), readOnly);
|
31135
31139
|
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
@@ -31172,26 +31176,16 @@ var applyDynamicProps = (data, dynamicProps, rootData) => {
|
|
31172
31176
|
init_react_import();
|
31173
31177
|
var cache2 = {};
|
31174
31178
|
var resolveRootData = (data, config) => __async(void 0, null, function* () {
|
31175
|
-
var _a, _b;
|
31179
|
+
var _a, _b, _c, _d, _e;
|
31176
31180
|
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
31177
|
-
|
31178
|
-
|
31179
|
-
{}
|
31180
|
-
);
|
31181
|
-
if (cache2.lastChange) {
|
31182
|
-
const { original, resolved } = cache2.lastChange;
|
31183
|
-
if (original === data.root) {
|
31184
|
-
return resolved;
|
31185
|
-
}
|
31186
|
-
Object.keys(data.root.props).forEach((propName) => {
|
31187
|
-
if (original.props[propName] === data.root.props[propName]) {
|
31188
|
-
changed[propName] = false;
|
31189
|
-
}
|
31190
|
-
});
|
31181
|
+
if (((_b = cache2.lastChange) == null ? void 0 : _b.original) === data.root) {
|
31182
|
+
return cache2.lastChange.resolved;
|
31191
31183
|
}
|
31184
|
+
const changed = getChanged(data.root, (_c = cache2.lastChange) == null ? void 0 : _c.original);
|
31192
31185
|
const rootWithProps = data.root;
|
31193
|
-
const resolvedRoot = yield (
|
31194
|
-
changed
|
31186
|
+
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
31187
|
+
changed,
|
31188
|
+
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {}
|
31195
31189
|
});
|
31196
31190
|
cache2.lastChange = {
|
31197
31191
|
original: data.root,
|
@@ -31213,7 +31207,7 @@ var useResolvedData = (appState, config, dispatch) => {
|
|
31213
31207
|
const [componentState, setComponentState] = (0, import_react13.useState)({});
|
31214
31208
|
const deferredSetStates = {};
|
31215
31209
|
const setComponentLoading = (0, import_react13.useCallback)(
|
31216
|
-
(id, loading,
|
31210
|
+
(id, loading, defer2 = 0) => {
|
31217
31211
|
if (deferredSetStates[id]) {
|
31218
31212
|
clearTimeout(deferredSetStates[id]);
|
31219
31213
|
delete deferredSetStates[id];
|
@@ -31223,7 +31217,7 @@ var useResolvedData = (appState, config, dispatch) => {
|
|
31223
31217
|
[id]: __spreadProps(__spreadValues({}, prev[id]), { loading })
|
31224
31218
|
}));
|
31225
31219
|
delete deferredSetStates[id];
|
31226
|
-
},
|
31220
|
+
}, defer2);
|
31227
31221
|
},
|
31228
31222
|
[]
|
31229
31223
|
);
|
@@ -31309,7 +31303,7 @@ var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
31309
31303
|
var getClassName9 = get_class_name_factory_default("MenuBar", styles_module_default7);
|
31310
31304
|
var MenuBar = ({
|
31311
31305
|
appState,
|
31312
|
-
data = { content: [], root: {
|
31306
|
+
data = { content: [], root: {} },
|
31313
31307
|
dispatch,
|
31314
31308
|
menuOpen = false,
|
31315
31309
|
onPublish,
|
@@ -31354,17 +31348,7 @@ var MenuBar = ({
|
|
31354
31348
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: renderHeaderActions && renderHeaderActions({
|
31355
31349
|
state: appState,
|
31356
31350
|
dispatch
|
31357
|
-
}) })
|
31358
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
31359
|
-
Button,
|
31360
|
-
{
|
31361
|
-
onClick: () => {
|
31362
|
-
onPublish && onPublish(data);
|
31363
|
-
},
|
31364
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Globe, { size: "14px" }),
|
31365
|
-
children: "Publish"
|
31366
|
-
}
|
31367
|
-
) })
|
31351
|
+
}) })
|
31368
31352
|
] })
|
31369
31353
|
}
|
31370
31354
|
);
|
@@ -32331,7 +32315,7 @@ var InputOrGroup = (_a) => {
|
|
32331
32315
|
|
32332
32316
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
32333
32317
|
init_react_import();
|
32334
|
-
var styles_module_default14 = { "PuckFields": "
|
32318
|
+
var styles_module_default14 = { "PuckFields": "_PuckFields_1o0if_1", "PuckFields--isLoading": "_PuckFields--isLoading_1o0if_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_1o0if_10" };
|
32335
32319
|
|
32336
32320
|
// components/Puck/components/Fields/index.tsx
|
32337
32321
|
var import_react19 = require("react");
|
@@ -32344,13 +32328,73 @@ var DefaultFields = ({
|
|
32344
32328
|
children,
|
32345
32329
|
isLoading
|
32346
32330
|
}) => {
|
32347
|
-
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19(), children: [
|
32331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19({ isLoading }), children: [
|
32348
32332
|
children,
|
32349
32333
|
isLoading && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_spinners6.ClipLoader, { "aria-label": "loading" }) })
|
32350
32334
|
] });
|
32351
32335
|
};
|
32336
|
+
var useResolvedFields = () => {
|
32337
|
+
var _a;
|
32338
|
+
const { selectedItem, state, config } = useAppContext();
|
32339
|
+
const { data } = state;
|
32340
|
+
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
32341
|
+
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
32342
|
+
const defaultFields = selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields;
|
32343
|
+
const rootProps = data.root.props || data.root;
|
32344
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react19.useState)(
|
32345
|
+
{}
|
32346
|
+
);
|
32347
|
+
const [resolvedFields, setResolvedFields] = (0, import_react19.useState)(defaultFields || {});
|
32348
|
+
const [fieldsLoading, setFieldsLoading] = (0, import_react19.useState)(false);
|
32349
|
+
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
32350
|
+
const componentData = selectedItem ? selectedItem : { props: rootProps, readOnly: data.root.readOnly };
|
32351
|
+
const resolveFields = (0, import_react19.useCallback)(
|
32352
|
+
(..._0) => __async(void 0, [..._0], function* (fields = {}) {
|
32353
|
+
var _a2, _b, _c;
|
32354
|
+
const lastData = ((_a2 = lastSelectedData.props) == null ? void 0 : _a2.id) === componentData.props.id ? lastSelectedData : {};
|
32355
|
+
const changed = getChanged(componentData, lastData);
|
32356
|
+
setLastSelectedData(componentData);
|
32357
|
+
if (selectedItem && (componentConfig == null ? void 0 : componentConfig.resolveFields)) {
|
32358
|
+
return yield componentConfig == null ? void 0 : componentConfig.resolveFields(
|
32359
|
+
componentData,
|
32360
|
+
{
|
32361
|
+
changed,
|
32362
|
+
fields,
|
32363
|
+
lastFields: resolvedFields,
|
32364
|
+
lastData,
|
32365
|
+
appState: state
|
32366
|
+
}
|
32367
|
+
);
|
32368
|
+
}
|
32369
|
+
if (!selectedItem && ((_b = config.root) == null ? void 0 : _b.resolveFields)) {
|
32370
|
+
return yield (_c = config.root) == null ? void 0 : _c.resolveFields(componentData, {
|
32371
|
+
changed,
|
32372
|
+
fields,
|
32373
|
+
lastFields: resolvedFields,
|
32374
|
+
lastData,
|
32375
|
+
appState: state
|
32376
|
+
});
|
32377
|
+
}
|
32378
|
+
return defaultResolveFields(componentData, {
|
32379
|
+
changed,
|
32380
|
+
fields,
|
32381
|
+
lastFields: resolvedFields,
|
32382
|
+
lastData
|
32383
|
+
});
|
32384
|
+
}),
|
32385
|
+
[data, config, componentData, selectedItem, resolvedFields, state]
|
32386
|
+
);
|
32387
|
+
(0, import_react19.useEffect)(() => {
|
32388
|
+
setFieldsLoading(true);
|
32389
|
+
resolveFields(defaultFields).then((fields) => {
|
32390
|
+
setResolvedFields(fields || {});
|
32391
|
+
setFieldsLoading(false);
|
32392
|
+
});
|
32393
|
+
}, [data, defaultFields]);
|
32394
|
+
return [resolvedFields, fieldsLoading];
|
32395
|
+
};
|
32352
32396
|
var Fields = () => {
|
32353
|
-
var _a, _b
|
32397
|
+
var _a, _b;
|
32354
32398
|
const {
|
32355
32399
|
selectedItem,
|
32356
32400
|
state,
|
@@ -32362,9 +32406,9 @@ var Fields = () => {
|
|
32362
32406
|
} = useAppContext();
|
32363
32407
|
const { data, ui } = state;
|
32364
32408
|
const { itemSelector } = ui;
|
32365
|
-
const
|
32366
|
-
const
|
32367
|
-
const isLoading =
|
32409
|
+
const [fields, fieldsResolving] = useResolvedFields();
|
32410
|
+
const componentResolving = selectedItem ? (_a = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.loading : (_b = componentState["puck-root"]) == null ? void 0 : _b.loading;
|
32411
|
+
const isLoading = fieldsResolving || componentResolving;
|
32368
32412
|
const rootProps = data.root.props || data.root;
|
32369
32413
|
const Wrapper = (0, import_react19.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
32370
32414
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
@@ -32376,6 +32420,8 @@ var Fields = () => {
|
|
32376
32420
|
},
|
32377
32421
|
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Wrapper, { isLoading, itemSelector, children: Object.keys(fields).map((fieldName) => {
|
32378
32422
|
const field = fields[fieldName];
|
32423
|
+
if (!(field == null ? void 0 : field.type))
|
32424
|
+
return null;
|
32379
32425
|
const onChange = (value, updatedUi) => {
|
32380
32426
|
var _a2, _b2;
|
32381
32427
|
let currentProps;
|
@@ -32627,19 +32673,218 @@ var Components = () => {
|
|
32627
32673
|
|
32628
32674
|
// components/Puck/components/Preview/index.tsx
|
32629
32675
|
init_react_import();
|
32630
|
-
var
|
32631
|
-
|
32676
|
+
var import_react23 = require("react");
|
32677
|
+
|
32678
|
+
// components/AutoFrame/index.tsx
|
32679
|
+
init_react_import();
|
32680
|
+
var import_react22 = __toESM(require("react"));
|
32681
|
+
var import_react_frame_component = __toESM(require("react-frame-component"));
|
32682
|
+
var import_object_hash = __toESM(require("object-hash"));
|
32683
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
32684
|
+
var styleSelector = 'style, link[rel="stylesheet"]';
|
32685
|
+
var collectStyles = (doc) => {
|
32686
|
+
const collected = [];
|
32687
|
+
doc.head.querySelectorAll(styleSelector).forEach((style) => {
|
32688
|
+
collected.push(style);
|
32689
|
+
});
|
32690
|
+
return collected;
|
32691
|
+
};
|
32692
|
+
var getStyleSheet = (el) => {
|
32693
|
+
return Array.from(document.styleSheets).find((ss) => {
|
32694
|
+
const ownerNode = ss.ownerNode;
|
32695
|
+
return ownerNode.href === el.href;
|
32696
|
+
});
|
32697
|
+
};
|
32698
|
+
var getStyles = (styleSheet) => {
|
32699
|
+
if (styleSheet) {
|
32700
|
+
try {
|
32701
|
+
return [...styleSheet.cssRules].map((rule) => rule.cssText).join("");
|
32702
|
+
} catch (e) {
|
32703
|
+
console.warn(
|
32704
|
+
"Access to stylesheet %s is denied. Ignoring\u2026",
|
32705
|
+
styleSheet.href
|
32706
|
+
);
|
32707
|
+
}
|
32708
|
+
}
|
32709
|
+
return "";
|
32710
|
+
};
|
32711
|
+
var defer = (fn) => setTimeout(fn, 0);
|
32712
|
+
var CopyHostStyles = ({
|
32713
|
+
children,
|
32714
|
+
debug = false,
|
32715
|
+
onStylesLoaded = () => null
|
32716
|
+
}) => {
|
32717
|
+
const { document: doc, window: win } = (0, import_react_frame_component.useFrame)();
|
32718
|
+
(0, import_react22.useEffect)(() => {
|
32719
|
+
if (!win || !doc) {
|
32720
|
+
return () => {
|
32721
|
+
};
|
32722
|
+
}
|
32723
|
+
let elements = [];
|
32724
|
+
const hashes = {};
|
32725
|
+
const lookupEl = (el) => elements.findIndex((elementMap) => elementMap.original === el);
|
32726
|
+
const mirrorEl = (el, inlineStyles = false) => __async(void 0, null, function* () {
|
32727
|
+
let mirror;
|
32728
|
+
if (el.nodeName === "LINK" && inlineStyles) {
|
32729
|
+
mirror = document.createElement("style");
|
32730
|
+
mirror.type = "text/css";
|
32731
|
+
let styleSheet = getStyleSheet(el);
|
32732
|
+
if (!styleSheet) {
|
32733
|
+
yield new Promise((resolve) => {
|
32734
|
+
const fn = () => {
|
32735
|
+
resolve();
|
32736
|
+
el.removeEventListener("load", fn);
|
32737
|
+
};
|
32738
|
+
el.addEventListener("load", fn);
|
32739
|
+
});
|
32740
|
+
styleSheet = getStyleSheet(el);
|
32741
|
+
}
|
32742
|
+
const styles = getStyles(styleSheet);
|
32743
|
+
if (!styles) {
|
32744
|
+
if (debug) {
|
32745
|
+
console.warn(
|
32746
|
+
`Tried to load styles for link element, but couldn't find them. Skipping...`
|
32747
|
+
);
|
32748
|
+
}
|
32749
|
+
return;
|
32750
|
+
}
|
32751
|
+
mirror.innerHTML = styles;
|
32752
|
+
mirror.setAttribute("data-href", el.getAttribute("href"));
|
32753
|
+
} else {
|
32754
|
+
mirror = el.cloneNode(true);
|
32755
|
+
}
|
32756
|
+
return mirror;
|
32757
|
+
});
|
32758
|
+
const addEl = (el) => __async(void 0, null, function* () {
|
32759
|
+
const index = lookupEl(el);
|
32760
|
+
if (index > -1) {
|
32761
|
+
if (debug)
|
32762
|
+
console.log(
|
32763
|
+
`Tried to add an element that was already mirrored. Updating instead...`
|
32764
|
+
);
|
32765
|
+
elements[index].mirror.innerText = el.innerText;
|
32766
|
+
return;
|
32767
|
+
}
|
32768
|
+
const mirror = yield mirrorEl(el);
|
32769
|
+
if (!mirror) {
|
32770
|
+
return;
|
32771
|
+
}
|
32772
|
+
const elHash = (0, import_object_hash.default)(mirror.outerHTML);
|
32773
|
+
if (hashes[elHash]) {
|
32774
|
+
if (debug)
|
32775
|
+
console.log(
|
32776
|
+
`iframe already contains element that is being mirrored. Skipping...`
|
32777
|
+
);
|
32778
|
+
return;
|
32779
|
+
}
|
32780
|
+
hashes[elHash] = true;
|
32781
|
+
doc.head.append(mirror);
|
32782
|
+
elements.push({ original: el, mirror });
|
32783
|
+
if (debug)
|
32784
|
+
console.log(`Added style node ${el.outerHTML}`);
|
32785
|
+
});
|
32786
|
+
const removeEl = (el) => {
|
32787
|
+
var _a, _b;
|
32788
|
+
const index = lookupEl(el);
|
32789
|
+
if (index === -1) {
|
32790
|
+
if (debug)
|
32791
|
+
console.log(
|
32792
|
+
`Tried to remove an element that did not exist. Skipping...`
|
32793
|
+
);
|
32794
|
+
return;
|
32795
|
+
}
|
32796
|
+
const elHash = (0, import_object_hash.default)(el.outerHTML);
|
32797
|
+
(_b = (_a = elements[index]) == null ? void 0 : _a.mirror) == null ? void 0 : _b.remove();
|
32798
|
+
delete hashes[elHash];
|
32799
|
+
if (debug)
|
32800
|
+
console.log(`Removed style node ${el.outerHTML}`);
|
32801
|
+
};
|
32802
|
+
const observer = new MutationObserver((mutations) => {
|
32803
|
+
mutations.forEach((mutation) => {
|
32804
|
+
if (mutation.type === "childList") {
|
32805
|
+
mutation.addedNodes.forEach((node) => {
|
32806
|
+
if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
|
32807
|
+
const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
32808
|
+
if (el && el.matches(styleSelector)) {
|
32809
|
+
defer(() => addEl(el));
|
32810
|
+
}
|
32811
|
+
}
|
32812
|
+
});
|
32813
|
+
mutation.removedNodes.forEach((node) => {
|
32814
|
+
if (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE) {
|
32815
|
+
const el = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
32816
|
+
if (el && el.matches(styleSelector)) {
|
32817
|
+
defer(() => removeEl(el));
|
32818
|
+
}
|
32819
|
+
}
|
32820
|
+
});
|
32821
|
+
}
|
32822
|
+
});
|
32823
|
+
});
|
32824
|
+
const parentDocument = win.parent.document;
|
32825
|
+
const collectedStyles = collectStyles(parentDocument);
|
32826
|
+
const hrefs = [];
|
32827
|
+
let stylesLoaded = 0;
|
32828
|
+
Promise.all(
|
32829
|
+
collectedStyles.map((styleNode, i) => __async(void 0, null, function* () {
|
32830
|
+
if (styleNode.nodeName === "LINK") {
|
32831
|
+
const linkHref = styleNode.href;
|
32832
|
+
if (hrefs.indexOf(linkHref) > -1) {
|
32833
|
+
return;
|
32834
|
+
}
|
32835
|
+
hrefs.push(linkHref);
|
32836
|
+
}
|
32837
|
+
const mirror = yield mirrorEl(styleNode);
|
32838
|
+
if (!mirror)
|
32839
|
+
return;
|
32840
|
+
elements.push({ original: styleNode, mirror });
|
32841
|
+
return mirror;
|
32842
|
+
}))
|
32843
|
+
).then((mirrorStyles) => {
|
32844
|
+
const filtered = mirrorStyles.filter(
|
32845
|
+
(el) => typeof el !== "undefined"
|
32846
|
+
);
|
32847
|
+
filtered.forEach((mirror) => {
|
32848
|
+
mirror.onload = () => {
|
32849
|
+
stylesLoaded = stylesLoaded + 1;
|
32850
|
+
if (stylesLoaded >= elements.length) {
|
32851
|
+
onStylesLoaded();
|
32852
|
+
}
|
32853
|
+
};
|
32854
|
+
});
|
32855
|
+
doc.head.innerHTML = "";
|
32856
|
+
doc.head.append(...filtered);
|
32857
|
+
observer.observe(parentDocument.head, { childList: true, subtree: true });
|
32858
|
+
filtered.forEach((el) => {
|
32859
|
+
const elHash = (0, import_object_hash.default)(el.outerHTML);
|
32860
|
+
hashes[elHash] = true;
|
32861
|
+
});
|
32862
|
+
});
|
32863
|
+
return () => {
|
32864
|
+
observer.disconnect();
|
32865
|
+
};
|
32866
|
+
}, []);
|
32867
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children });
|
32868
|
+
};
|
32869
|
+
var AutoFrameComponent = import_react22.default.forwardRef(
|
32870
|
+
function(_a, ref) {
|
32871
|
+
var _b = _a, { children, debug, onStylesLoaded } = _b, props = __objRest(_b, ["children", "debug", "onStylesLoaded"]);
|
32872
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react_frame_component.default, __spreadProps(__spreadValues({}, props), { ref, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(CopyHostStyles, { debug, onStylesLoaded, children }) }));
|
32873
|
+
}
|
32874
|
+
);
|
32875
|
+
AutoFrameComponent.displayName = "AutoFrameComponent";
|
32876
|
+
var AutoFrame_default = AutoFrameComponent;
|
32632
32877
|
|
32633
32878
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
32634
32879
|
init_react_import();
|
32635
32880
|
var styles_module_default16 = { "PuckPreview": "_PuckPreview_rxwlr_1", "PuckPreview-frame": "_PuckPreview-frame_rxwlr_5" };
|
32636
32881
|
|
32637
32882
|
// components/Puck/components/Preview/index.tsx
|
32638
|
-
var
|
32883
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
32639
32884
|
var getClassName21 = get_class_name_factory_default("PuckPreview", styles_module_default16);
|
32640
32885
|
var Preview = ({ id = "puck-preview" }) => {
|
32641
32886
|
const { config, dispatch, state, setStatus, iframe } = useAppContext();
|
32642
|
-
const Page = (0,
|
32887
|
+
const Page = (0, import_react23.useCallback)(
|
32643
32888
|
(pageProps) => {
|
32644
32889
|
var _a, _b;
|
32645
32890
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadProps(__spreadValues({
|
@@ -32647,13 +32892,13 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
32647
32892
|
}, pageProps), {
|
32648
32893
|
editMode: true,
|
32649
32894
|
puck: { renderDropZone: DropZone }
|
32650
|
-
})) : /* @__PURE__ */ (0,
|
32895
|
+
})) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children: pageProps.children });
|
32651
32896
|
},
|
32652
32897
|
[config.root]
|
32653
32898
|
);
|
32654
32899
|
const rootProps = state.data.root.props || state.data.root;
|
32655
|
-
const ref = (0,
|
32656
|
-
return /* @__PURE__ */ (0,
|
32900
|
+
const ref = (0, import_react23.useRef)(null);
|
32901
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
32657
32902
|
"div",
|
32658
32903
|
{
|
32659
32904
|
className: getClassName21(),
|
@@ -32661,8 +32906,8 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
32661
32906
|
onClick: () => {
|
32662
32907
|
dispatch({ type: "setUi", ui: __spreadProps(__spreadValues({}, state.ui), { itemSelector: null }) });
|
32663
32908
|
},
|
32664
|
-
children: iframe.enabled ? /* @__PURE__ */ (0,
|
32665
|
-
|
32909
|
+
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
32910
|
+
AutoFrame_default,
|
32666
32911
|
{
|
32667
32912
|
id: "preview-frame",
|
32668
32913
|
className: getClassName21("frame"),
|
@@ -32671,9 +32916,9 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
32671
32916
|
onStylesLoaded: () => {
|
32672
32917
|
setStatus("READY");
|
32673
32918
|
},
|
32674
|
-
children: /* @__PURE__ */ (0,
|
32919
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Page, __spreadProps(__spreadValues({ dispatch, state }, rootProps), { children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(DropZone, { zone: rootDroppableId }) }))
|
32675
32920
|
}
|
32676
|
-
) : /* @__PURE__ */ (0,
|
32921
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { id: "preview-frame", className: getClassName21("frame"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Page, __spreadProps(__spreadValues({ dispatch, state }, rootProps), { children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(DropZone, { zone: rootDroppableId }) })) })
|
32677
32922
|
}
|
32678
32923
|
);
|
32679
32924
|
};
|
@@ -32721,7 +32966,7 @@ var scrollIntoView = (el) => {
|
|
32721
32966
|
};
|
32722
32967
|
|
32723
32968
|
// components/LayerTree/index.tsx
|
32724
|
-
var
|
32969
|
+
var import_react24 = require("react");
|
32725
32970
|
|
32726
32971
|
// lib/is-child-of-zone.ts
|
32727
32972
|
init_react_import();
|
@@ -32735,7 +32980,7 @@ var isChildOfZone = (item, maybeChild, ctx) => {
|
|
32735
32980
|
};
|
32736
32981
|
|
32737
32982
|
// components/LayerTree/index.tsx
|
32738
|
-
var
|
32983
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
32739
32984
|
var getClassName22 = get_class_name_factory_default("LayerTree", styles_module_default17);
|
32740
32985
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default17);
|
32741
32986
|
var LayerTree = ({
|
@@ -32748,15 +32993,15 @@ var LayerTree = ({
|
|
32748
32993
|
label
|
32749
32994
|
}) => {
|
32750
32995
|
const zones = data.zones || {};
|
32751
|
-
const ctx = (0,
|
32752
|
-
return /* @__PURE__ */ (0,
|
32753
|
-
label && /* @__PURE__ */ (0,
|
32754
|
-
/* @__PURE__ */ (0,
|
32996
|
+
const ctx = (0, import_react24.useContext)(dropZoneContext);
|
32997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
|
32998
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassName22("zoneTitle"), children: [
|
32999
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Layers, { size: "16" }) }),
|
32755
33000
|
" ",
|
32756
33001
|
label
|
32757
33002
|
] }),
|
32758
|
-
/* @__PURE__ */ (0,
|
32759
|
-
zoneContent.length === 0 && /* @__PURE__ */ (0,
|
33003
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("ul", { className: getClassName22(), children: [
|
33004
|
+
zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassName22("helper"), children: "No items" }),
|
32760
33005
|
zoneContent.map((item, i) => {
|
32761
33006
|
var _a;
|
32762
33007
|
const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
|
@@ -32772,7 +33017,7 @@ var LayerTree = ({
|
|
32772
33017
|
const selectedItem = itemSelector && data ? getItem(itemSelector, data) : null;
|
32773
33018
|
const isHovering = hoveringComponent === item.props.id;
|
32774
33019
|
const childIsSelected = isChildOfZone(item, selectedItem, ctx);
|
32775
|
-
return /* @__PURE__ */ (0,
|
33020
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
32776
33021
|
"li",
|
32777
33022
|
{
|
32778
33023
|
className: getClassNameLayer({
|
@@ -32782,7 +33027,7 @@ var LayerTree = ({
|
|
32782
33027
|
childIsSelected
|
32783
33028
|
}),
|
32784
33029
|
children: [
|
32785
|
-
/* @__PURE__ */ (0,
|
33030
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
32786
33031
|
"button",
|
32787
33032
|
{
|
32788
33033
|
className: getClassNameLayer("clickable"),
|
@@ -32814,22 +33059,22 @@ var LayerTree = ({
|
|
32814
33059
|
setHoveringComponent(null);
|
32815
33060
|
},
|
32816
33061
|
children: [
|
32817
|
-
containsZone && /* @__PURE__ */ (0,
|
33062
|
+
containsZone && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
32818
33063
|
"div",
|
32819
33064
|
{
|
32820
33065
|
className: getClassNameLayer("chevron"),
|
32821
33066
|
title: isSelected ? "Collapse" : "Expand",
|
32822
|
-
children: /* @__PURE__ */ (0,
|
33067
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ChevronDown, { size: "12" })
|
32823
33068
|
}
|
32824
33069
|
),
|
32825
|
-
/* @__PURE__ */ (0,
|
32826
|
-
/* @__PURE__ */ (0,
|
32827
|
-
/* @__PURE__ */ (0,
|
33070
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: getClassNameLayer("title"), children: [
|
33071
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(LayoutGrid, { size: "16" }) }),
|
33072
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassNameLayer("name"), children: (_a = config.components[item.type]["label"]) != null ? _a : item.type })
|
32828
33073
|
] })
|
32829
33074
|
]
|
32830
33075
|
}
|
32831
33076
|
) }),
|
32832
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0,
|
33077
|
+
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
32833
33078
|
LayerTree,
|
32834
33079
|
{
|
32835
33080
|
config,
|
@@ -32851,13 +33096,13 @@ var LayerTree = ({
|
|
32851
33096
|
};
|
32852
33097
|
|
32853
33098
|
// components/Puck/components/Outline/index.tsx
|
32854
|
-
var
|
32855
|
-
var
|
33099
|
+
var import_react25 = require("react");
|
33100
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
32856
33101
|
var Outline = () => {
|
32857
33102
|
const { dispatch, state, overrides, config } = useAppContext();
|
32858
33103
|
const { data, ui } = state;
|
32859
33104
|
const { itemSelector } = ui;
|
32860
|
-
const setItemSelector = (0,
|
33105
|
+
const setItemSelector = (0, import_react25.useCallback)(
|
32861
33106
|
(newItemSelector) => {
|
32862
33107
|
dispatch({
|
32863
33108
|
type: "setUi",
|
@@ -32866,9 +33111,9 @@ var Outline = () => {
|
|
32866
33111
|
},
|
32867
33112
|
[]
|
32868
33113
|
);
|
32869
|
-
const Wrapper = (0,
|
32870
|
-
return /* @__PURE__ */ (0,
|
32871
|
-
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0,
|
33114
|
+
const Wrapper = (0, import_react25.useMemo)(() => overrides.outline || "div", [overrides]);
|
33115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
|
33116
|
+
(ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
32872
33117
|
LayerTree,
|
32873
33118
|
{
|
32874
33119
|
config,
|
@@ -32881,7 +33126,7 @@ var Outline = () => {
|
|
32881
33126
|
),
|
32882
33127
|
Object.entries(findZonesForArea(data, "root")).map(
|
32883
33128
|
([zoneKey, zone]) => {
|
32884
|
-
return /* @__PURE__ */ (0,
|
33129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
32885
33130
|
LayerTree,
|
32886
33131
|
{
|
32887
33132
|
config,
|
@@ -32966,12 +33211,12 @@ function usePuckHistory({
|
|
32966
33211
|
|
32967
33212
|
// lib/use-history-store.ts
|
32968
33213
|
init_react_import();
|
32969
|
-
var
|
33214
|
+
var import_react26 = require("react");
|
32970
33215
|
var import_use_debounce3 = require("use-debounce");
|
32971
33216
|
var EMPTY_HISTORY_INDEX = -1;
|
32972
33217
|
function useHistoryStore() {
|
32973
|
-
const [histories, setHistories] = (0,
|
32974
|
-
const [index, setIndex] = (0,
|
33218
|
+
const [histories, setHistories] = (0, import_react26.useState)([]);
|
33219
|
+
const [index, setIndex] = (0, import_react26.useState)(EMPTY_HISTORY_INDEX);
|
32975
33220
|
const hasPast = index > EMPTY_HISTORY_INDEX;
|
32976
33221
|
const hasFuture = index < histories.length - 1;
|
32977
33222
|
const currentHistory = histories[index];
|
@@ -33131,22 +33376,22 @@ var getBox = function getBox2(el) {
|
|
33131
33376
|
};
|
33132
33377
|
|
33133
33378
|
// components/Puck/components/Canvas/index.tsx
|
33134
|
-
var
|
33379
|
+
var import_react28 = require("react");
|
33135
33380
|
|
33136
33381
|
// components/ViewportControls/index.tsx
|
33137
33382
|
init_react_import();
|
33138
|
-
var
|
33383
|
+
var import_react27 = require("react");
|
33139
33384
|
|
33140
33385
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
33141
33386
|
init_react_import();
|
33142
33387
|
var styles_module_default18 = { "ViewportControls": "_ViewportControls_3zdvn_1", "ViewportControls-divider": "_ViewportControls-divider_3zdvn_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_3zdvn_21", "ViewportButton--isActive": "_ViewportButton--isActive_3zdvn_33", "ViewportButton-inner": "_ViewportButton-inner_3zdvn_33" };
|
33143
33388
|
|
33144
33389
|
// components/ViewportControls/index.tsx
|
33145
|
-
var
|
33390
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
33146
33391
|
var icons = {
|
33147
|
-
Smartphone: /* @__PURE__ */ (0,
|
33148
|
-
Tablet: /* @__PURE__ */ (0,
|
33149
|
-
Monitor: /* @__PURE__ */ (0,
|
33392
|
+
Smartphone: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Smartphone, { size: 16 }),
|
33393
|
+
Tablet: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Tablet, { size: 16 }),
|
33394
|
+
Monitor: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Monitor, { size: 16 })
|
33150
33395
|
};
|
33151
33396
|
var getClassName23 = get_class_name_factory_default("ViewportControls", styles_module_default18);
|
33152
33397
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default18);
|
@@ -33158,11 +33403,11 @@ var ViewportButton = ({
|
|
33158
33403
|
onClick
|
33159
33404
|
}) => {
|
33160
33405
|
const { state } = useAppContext();
|
33161
|
-
const [isActive, setIsActive] = (0,
|
33162
|
-
(0,
|
33406
|
+
const [isActive, setIsActive] = (0, import_react27.useState)(false);
|
33407
|
+
(0, import_react27.useEffect)(() => {
|
33163
33408
|
setIsActive(width === state.ui.viewports.current.width);
|
33164
33409
|
}, [width, state.ui.viewports.current.width]);
|
33165
|
-
return /* @__PURE__ */ (0,
|
33410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33166
33411
|
IconButton,
|
33167
33412
|
{
|
33168
33413
|
title,
|
@@ -33171,7 +33416,7 @@ var ViewportButton = ({
|
|
33171
33416
|
e.stopPropagation();
|
33172
33417
|
onClick({ width, height });
|
33173
33418
|
},
|
33174
|
-
children: /* @__PURE__ */ (0,
|
33419
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: getClassNameButton("inner"), children })
|
33175
33420
|
}
|
33176
33421
|
) });
|
33177
33422
|
};
|
@@ -33195,7 +33440,7 @@ var ViewportControls = ({
|
|
33195
33440
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
33196
33441
|
(option) => option.value === autoZoom
|
33197
33442
|
);
|
33198
|
-
const zoomOptions = (0,
|
33443
|
+
const zoomOptions = (0, import_react27.useMemo)(
|
33199
33444
|
() => [
|
33200
33445
|
...defaultZoomOptions,
|
33201
33446
|
...defaultsContainAutoZoom ? [] : [
|
@@ -33207,8 +33452,8 @@ var ViewportControls = ({
|
|
33207
33452
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
33208
33453
|
[autoZoom]
|
33209
33454
|
);
|
33210
|
-
return /* @__PURE__ */ (0,
|
33211
|
-
viewports.map((viewport, i) => /* @__PURE__ */ (0,
|
33455
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getClassName23(), children: [
|
33456
|
+
viewports.map((viewport, i) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33212
33457
|
ViewportButton,
|
33213
33458
|
{
|
33214
33459
|
height: viewport.height,
|
@@ -33219,8 +33464,8 @@ var ViewportControls = ({
|
|
33219
33464
|
},
|
33220
33465
|
i
|
33221
33466
|
)),
|
33222
|
-
/* @__PURE__ */ (0,
|
33223
|
-
/* @__PURE__ */ (0,
|
33467
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName23("divider") }),
|
33468
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33224
33469
|
IconButton,
|
33225
33470
|
{
|
33226
33471
|
title: "Zoom viewport out",
|
@@ -33234,10 +33479,10 @@ var ViewportControls = ({
|
|
33234
33479
|
)].value
|
33235
33480
|
);
|
33236
33481
|
},
|
33237
|
-
children: /* @__PURE__ */ (0,
|
33482
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ZoomOut, { size: 16 })
|
33238
33483
|
}
|
33239
33484
|
),
|
33240
|
-
/* @__PURE__ */ (0,
|
33485
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33241
33486
|
IconButton,
|
33242
33487
|
{
|
33243
33488
|
title: "Zoom viewport in",
|
@@ -33251,11 +33496,11 @@ var ViewportControls = ({
|
|
33251
33496
|
)].value
|
33252
33497
|
);
|
33253
33498
|
},
|
33254
|
-
children: /* @__PURE__ */ (0,
|
33499
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ZoomIn, { size: 16 })
|
33255
33500
|
}
|
33256
33501
|
),
|
33257
|
-
/* @__PURE__ */ (0,
|
33258
|
-
/* @__PURE__ */ (0,
|
33502
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: getClassName23("divider") }),
|
33503
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33259
33504
|
"select",
|
33260
33505
|
{
|
33261
33506
|
className: getClassName23("zoomSelect"),
|
@@ -33263,7 +33508,7 @@ var ViewportControls = ({
|
|
33263
33508
|
onChange: (e) => {
|
33264
33509
|
onZoom(parseFloat(e.currentTarget.value));
|
33265
33510
|
},
|
33266
|
-
children: zoomOptions.map((option) => /* @__PURE__ */ (0,
|
33511
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
33267
33512
|
"option",
|
33268
33513
|
{
|
33269
33514
|
value: option.value,
|
@@ -33311,24 +33556,24 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
33311
33556
|
};
|
33312
33557
|
|
33313
33558
|
// components/Puck/components/Canvas/index.tsx
|
33314
|
-
var
|
33559
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
33315
33560
|
var getClassName24 = get_class_name_factory_default("PuckCanvas", styles_module_default19);
|
33316
33561
|
var ZOOM_ON_CHANGE = true;
|
33317
33562
|
var Canvas = () => {
|
33318
33563
|
const { status, iframe } = useAppContext();
|
33319
33564
|
const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
|
33320
33565
|
const { ui } = state;
|
33321
|
-
const frameRef = (0,
|
33322
|
-
const [showTransition, setShowTransition] = (0,
|
33323
|
-
const defaultRender = (0,
|
33324
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
33566
|
+
const frameRef = (0, import_react28.useRef)(null);
|
33567
|
+
const [showTransition, setShowTransition] = (0, import_react28.useState)(false);
|
33568
|
+
const defaultRender = (0, import_react28.useMemo)(() => {
|
33569
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children });
|
33325
33570
|
return PuckDefault;
|
33326
33571
|
}, []);
|
33327
|
-
const CustomPreview = (0,
|
33572
|
+
const CustomPreview = (0, import_react28.useMemo)(
|
33328
33573
|
() => overrides.preview || defaultRender,
|
33329
33574
|
[overrides]
|
33330
33575
|
);
|
33331
|
-
const getFrameDimensions = (0,
|
33576
|
+
const getFrameDimensions = (0, import_react28.useCallback)(() => {
|
33332
33577
|
if (frameRef.current) {
|
33333
33578
|
const frame = frameRef.current;
|
33334
33579
|
const box = getBox(frame);
|
@@ -33336,7 +33581,7 @@ var Canvas = () => {
|
|
33336
33581
|
}
|
33337
33582
|
return { width: 0, height: 0 };
|
33338
33583
|
}, [frameRef]);
|
33339
|
-
const resetAutoZoom = (0,
|
33584
|
+
const resetAutoZoom = (0, import_react28.useCallback)(
|
33340
33585
|
(ui2 = state.ui) => {
|
33341
33586
|
if (frameRef.current) {
|
33342
33587
|
setZoomConfig(
|
@@ -33346,11 +33591,11 @@ var Canvas = () => {
|
|
33346
33591
|
},
|
33347
33592
|
[frameRef, zoomConfig, state.ui]
|
33348
33593
|
);
|
33349
|
-
(0,
|
33594
|
+
(0, import_react28.useEffect)(() => {
|
33350
33595
|
setShowTransition(false);
|
33351
33596
|
resetAutoZoom();
|
33352
33597
|
}, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
|
33353
|
-
(0,
|
33598
|
+
(0, import_react28.useEffect)(() => {
|
33354
33599
|
const { height: frameHeight } = getFrameDimensions();
|
33355
33600
|
if (ui.viewports.current.height === "auto") {
|
33356
33601
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -33358,7 +33603,7 @@ var Canvas = () => {
|
|
33358
33603
|
}));
|
33359
33604
|
}
|
33360
33605
|
}, [zoomConfig.zoom]);
|
33361
|
-
(0,
|
33606
|
+
(0, import_react28.useEffect)(() => {
|
33362
33607
|
const observer = new ResizeObserver(() => {
|
33363
33608
|
setShowTransition(false);
|
33364
33609
|
resetAutoZoom();
|
@@ -33370,7 +33615,7 @@ var Canvas = () => {
|
|
33370
33615
|
observer.disconnect();
|
33371
33616
|
};
|
33372
33617
|
}, []);
|
33373
|
-
return /* @__PURE__ */ (0,
|
33618
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
33374
33619
|
"div",
|
33375
33620
|
{
|
33376
33621
|
className: getClassName24({
|
@@ -33382,7 +33627,7 @@ var Canvas = () => {
|
|
33382
33627
|
recordHistory: true
|
33383
33628
|
}),
|
33384
33629
|
children: [
|
33385
|
-
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
33630
|
+
ui.viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
33386
33631
|
ViewportControls,
|
33387
33632
|
{
|
33388
33633
|
autoZoom: zoomConfig.autoZoom,
|
@@ -33407,7 +33652,7 @@ var Canvas = () => {
|
|
33407
33652
|
}
|
33408
33653
|
}
|
33409
33654
|
) }),
|
33410
|
-
/* @__PURE__ */ (0,
|
33655
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName24("inner"), ref: frameRef, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
33411
33656
|
"div",
|
33412
33657
|
{
|
33413
33658
|
className: getClassName24("root"),
|
@@ -33419,7 +33664,7 @@ var Canvas = () => {
|
|
33419
33664
|
overflow: iframe.enabled ? void 0 : "auto"
|
33420
33665
|
},
|
33421
33666
|
suppressHydrationWarning: true,
|
33422
|
-
children: /* @__PURE__ */ (0,
|
33667
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Preview, {}) })
|
33423
33668
|
}
|
33424
33669
|
) })
|
33425
33670
|
]
|
@@ -33428,12 +33673,12 @@ var Canvas = () => {
|
|
33428
33673
|
};
|
33429
33674
|
|
33430
33675
|
// components/Puck/index.tsx
|
33431
|
-
var
|
33676
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
33432
33677
|
var getClassName25 = get_class_name_factory_default("Puck", styles_module_default8);
|
33433
33678
|
function Puck({
|
33434
33679
|
children,
|
33435
33680
|
config,
|
33436
|
-
data: initialData = { content: [], root: {
|
33681
|
+
data: initialData = { content: [], root: {} },
|
33437
33682
|
ui: initialUi,
|
33438
33683
|
onChange,
|
33439
33684
|
onPublish,
|
@@ -33451,11 +33696,11 @@ function Puck({
|
|
33451
33696
|
}) {
|
33452
33697
|
var _a;
|
33453
33698
|
const historyStore = useHistoryStore();
|
33454
|
-
const [reducer] = (0,
|
33699
|
+
const [reducer] = (0, import_react29.useState)(
|
33455
33700
|
() => createReducer({ config, record: historyStore.record })
|
33456
33701
|
);
|
33457
|
-
const [initialAppState] = (0,
|
33458
|
-
var _a2, _b, _c, _d;
|
33702
|
+
const [initialAppState] = (0, import_react29.useState)(() => {
|
33703
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
33459
33704
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
33460
33705
|
let clientUiState = {};
|
33461
33706
|
if (typeof window !== "undefined") {
|
@@ -33482,8 +33727,18 @@ function Puck({
|
|
33482
33727
|
};
|
33483
33728
|
}
|
33484
33729
|
}
|
33730
|
+
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_e = initialData == null ? void 0 : initialData.root) == null ? void 0 : _e.props)) {
|
33731
|
+
console.error(
|
33732
|
+
"Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
|
33733
|
+
);
|
33734
|
+
}
|
33735
|
+
const rootProps2 = ((_f = initialData == null ? void 0 : initialData.root) == null ? void 0 : _f.props) || (initialData == null ? void 0 : initialData.root) || {};
|
33736
|
+
const defaultedRootProps = __spreadValues(__spreadValues({}, (_g = config.root) == null ? void 0 : _g.defaultProps), rootProps2);
|
33485
33737
|
return __spreadProps(__spreadValues({}, defaultAppState), {
|
33486
|
-
data: initialData,
|
33738
|
+
data: __spreadProps(__spreadValues({}, initialData), {
|
33739
|
+
root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps }),
|
33740
|
+
content: initialData.content || []
|
33741
|
+
}),
|
33487
33742
|
ui: __spreadProps(__spreadValues(__spreadValues({}, initial), clientUiState), {
|
33488
33743
|
// Store categories under componentList on state to allow render functions and plugins to modify
|
33489
33744
|
componentList: config.categories ? Object.entries(config.categories).reduce(
|
@@ -33502,7 +33757,7 @@ function Puck({
|
|
33502
33757
|
})
|
33503
33758
|
});
|
33504
33759
|
});
|
33505
|
-
const [appState, dispatch] = (0,
|
33760
|
+
const [appState, dispatch] = (0, import_react29.useReducer)(
|
33506
33761
|
reducer,
|
33507
33762
|
flushZones(initialAppState)
|
33508
33763
|
);
|
@@ -33513,9 +33768,9 @@ function Puck({
|
|
33513
33768
|
config,
|
33514
33769
|
dispatch
|
33515
33770
|
);
|
33516
|
-
const [menuOpen, setMenuOpen] = (0,
|
33771
|
+
const [menuOpen, setMenuOpen] = (0, import_react29.useState)(false);
|
33517
33772
|
const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
|
33518
|
-
const setItemSelector = (0,
|
33773
|
+
const setItemSelector = (0, import_react29.useCallback)(
|
33519
33774
|
(newItemSelector) => {
|
33520
33775
|
if (newItemSelector === itemSelector)
|
33521
33776
|
return;
|
@@ -33528,21 +33783,14 @@ function Puck({
|
|
33528
33783
|
[itemSelector]
|
33529
33784
|
);
|
33530
33785
|
const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
|
33531
|
-
(0,
|
33786
|
+
(0, import_react29.useEffect)(() => {
|
33532
33787
|
if (onChange)
|
33533
33788
|
onChange(data);
|
33534
33789
|
}, [data]);
|
33535
33790
|
const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
|
33536
|
-
const [draggedItem, setDraggedItem] = (0,
|
33791
|
+
const [draggedItem, setDraggedItem] = (0, import_react29.useState)();
|
33537
33792
|
const rootProps = data.root.props || data.root;
|
33538
|
-
(0,
|
33539
|
-
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
33540
|
-
console.error(
|
33541
|
-
"Warning: Defining props on `root` is deprecated. Please use `root.props`. This will be a breaking change in a future release."
|
33542
|
-
);
|
33543
|
-
}
|
33544
|
-
}, []);
|
33545
|
-
const toggleSidebars = (0, import_react28.useCallback)(
|
33793
|
+
const toggleSidebars = (0, import_react29.useCallback)(
|
33546
33794
|
(sidebar) => {
|
33547
33795
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
33548
33796
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
@@ -33556,7 +33804,7 @@ function Puck({
|
|
33556
33804
|
},
|
33557
33805
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
33558
33806
|
);
|
33559
|
-
(0,
|
33807
|
+
(0, import_react29.useEffect)(() => {
|
33560
33808
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
33561
33809
|
dispatch({
|
33562
33810
|
type: "setUi",
|
@@ -33579,11 +33827,11 @@ function Puck({
|
|
33579
33827
|
window.removeEventListener("resize", handleResize);
|
33580
33828
|
};
|
33581
33829
|
}, []);
|
33582
|
-
const defaultRender = (0,
|
33583
|
-
const PuckDefault = ({ children: children2 }) => /* @__PURE__ */ (0,
|
33830
|
+
const defaultRender = (0, import_react29.useMemo)(() => {
|
33831
|
+
const PuckDefault = ({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: children2 });
|
33584
33832
|
return PuckDefault;
|
33585
33833
|
}, []);
|
33586
|
-
const defaultHeaderRender = (0,
|
33834
|
+
const defaultHeaderRender = (0, import_react29.useMemo)(() => {
|
33587
33835
|
if (renderHeader) {
|
33588
33836
|
console.warn(
|
33589
33837
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -33591,45 +33839,45 @@ function Puck({
|
|
33591
33839
|
const RenderHeader = (_a2) => {
|
33592
33840
|
var _b = _a2, { actions } = _b, props = __objRest(_b, ["actions"]);
|
33593
33841
|
const Comp = renderHeader;
|
33594
|
-
return /* @__PURE__ */ (0,
|
33842
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
33595
33843
|
};
|
33596
33844
|
return RenderHeader;
|
33597
33845
|
}
|
33598
33846
|
return defaultRender;
|
33599
33847
|
}, [renderHeader]);
|
33600
|
-
const defaultHeaderActionsRender = (0,
|
33848
|
+
const defaultHeaderActionsRender = (0, import_react29.useMemo)(() => {
|
33601
33849
|
if (renderHeaderActions) {
|
33602
33850
|
console.warn(
|
33603
33851
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
33604
33852
|
);
|
33605
33853
|
const RenderHeader = (props) => {
|
33606
33854
|
const Comp = renderHeaderActions;
|
33607
|
-
return /* @__PURE__ */ (0,
|
33855
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
33608
33856
|
};
|
33609
33857
|
return RenderHeader;
|
33610
33858
|
}
|
33611
33859
|
return defaultRender;
|
33612
33860
|
}, [renderHeader]);
|
33613
|
-
const loadedOverrides = (0,
|
33861
|
+
const loadedOverrides = (0, import_react29.useMemo)(() => {
|
33614
33862
|
return loadOverrides({ overrides, plugins });
|
33615
33863
|
}, [plugins]);
|
33616
|
-
const CustomPuck = (0,
|
33864
|
+
const CustomPuck = (0, import_react29.useMemo)(
|
33617
33865
|
() => loadedOverrides.puck || defaultRender,
|
33618
33866
|
[loadedOverrides]
|
33619
33867
|
);
|
33620
|
-
const CustomHeader = (0,
|
33868
|
+
const CustomHeader = (0, import_react29.useMemo)(
|
33621
33869
|
() => loadedOverrides.header || defaultHeaderRender,
|
33622
33870
|
[loadedOverrides]
|
33623
33871
|
);
|
33624
|
-
const CustomHeaderActions = (0,
|
33872
|
+
const CustomHeaderActions = (0, import_react29.useMemo)(
|
33625
33873
|
() => loadedOverrides.headerActions || defaultHeaderActionsRender,
|
33626
33874
|
[loadedOverrides]
|
33627
33875
|
);
|
33628
|
-
const [mounted, setMounted] = (0,
|
33629
|
-
(0,
|
33876
|
+
const [mounted, setMounted] = (0, import_react29.useState)(false);
|
33877
|
+
(0, import_react29.useEffect)(() => {
|
33630
33878
|
setMounted(true);
|
33631
33879
|
}, []);
|
33632
|
-
return /* @__PURE__ */ (0,
|
33880
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "Puck", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33633
33881
|
AppProvider,
|
33634
33882
|
{
|
33635
33883
|
value: {
|
@@ -33644,7 +33892,7 @@ function Puck({
|
|
33644
33892
|
viewports,
|
33645
33893
|
iframe
|
33646
33894
|
},
|
33647
|
-
children: /* @__PURE__ */ (0,
|
33895
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33648
33896
|
DragDropContext,
|
33649
33897
|
{
|
33650
33898
|
autoScrollerOptions: { disabled: dnd == null ? void 0 : dnd.disableAutoScroll },
|
@@ -33700,7 +33948,7 @@ function Puck({
|
|
33700
33948
|
});
|
33701
33949
|
}
|
33702
33950
|
},
|
33703
|
-
children: /* @__PURE__ */ (0,
|
33951
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33704
33952
|
DropZoneProvider,
|
33705
33953
|
{
|
33706
33954
|
value: {
|
@@ -33714,7 +33962,7 @@ function Puck({
|
|
33714
33962
|
mode: "edit",
|
33715
33963
|
areaId: "root"
|
33716
33964
|
},
|
33717
|
-
children: /* @__PURE__ */ (0,
|
33965
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
33718
33966
|
"div",
|
33719
33967
|
{
|
33720
33968
|
className: getClassName25({
|
@@ -33724,65 +33972,62 @@ function Puck({
|
|
33724
33972
|
rightSideBarVisible
|
33725
33973
|
}),
|
33726
33974
|
children: [
|
33727
|
-
/* @__PURE__ */ (0,
|
33728
|
-
/* @__PURE__ */ (0,
|
33975
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25("layout"), children: [
|
33976
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33729
33977
|
CustomHeader,
|
33730
33978
|
{
|
33731
|
-
actions: /* @__PURE__ */ (0,
|
33732
|
-
|
33733
|
-
|
33734
|
-
|
33735
|
-
|
33736
|
-
|
33737
|
-
|
33738
|
-
|
33739
|
-
|
33740
|
-
|
33741
|
-
|
33742
|
-
)
|
33743
|
-
|
33744
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("header", { className: getClassName25("header"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName25("headerInner"), children: [
|
33745
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName25("headerToggle"), children: [
|
33746
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName25("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
33979
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33980
|
+
Button,
|
33981
|
+
{
|
33982
|
+
onClick: () => {
|
33983
|
+
onPublish && onPublish(data);
|
33984
|
+
},
|
33985
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Globe, { size: "14px" }),
|
33986
|
+
children: "Publish"
|
33987
|
+
}
|
33988
|
+
) }) }),
|
33989
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("header", { className: getClassName25("header"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25("headerInner"), children: [
|
33990
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25("headerToggle"), children: [
|
33991
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33747
33992
|
IconButton,
|
33748
33993
|
{
|
33749
33994
|
onClick: () => {
|
33750
33995
|
toggleSidebars("left");
|
33751
33996
|
},
|
33752
33997
|
title: "Toggle left sidebar",
|
33753
|
-
children: /* @__PURE__ */ (0,
|
33998
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PanelLeft, { focusable: "false" })
|
33754
33999
|
}
|
33755
34000
|
) }),
|
33756
|
-
/* @__PURE__ */ (0,
|
34001
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33757
34002
|
IconButton,
|
33758
34003
|
{
|
33759
34004
|
onClick: () => {
|
33760
34005
|
toggleSidebars("right");
|
33761
34006
|
},
|
33762
34007
|
title: "Toggle right sidebar",
|
33763
|
-
children: /* @__PURE__ */ (0,
|
34008
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PanelRight, { focusable: "false" })
|
33764
34009
|
}
|
33765
34010
|
) })
|
33766
34011
|
] }),
|
33767
|
-
/* @__PURE__ */ (0,
|
34012
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Heading, { rank: 2, size: "xs", children: [
|
33768
34013
|
headerTitle || rootProps.title || "Page",
|
33769
|
-
headerPath && /* @__PURE__ */ (0,
|
34014
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
33770
34015
|
" ",
|
33771
|
-
/* @__PURE__ */ (0,
|
34016
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("code", { className: getClassName25("headerPath"), children: headerPath })
|
33772
34017
|
] })
|
33773
34018
|
] }) }),
|
33774
|
-
/* @__PURE__ */ (0,
|
33775
|
-
/* @__PURE__ */ (0,
|
34019
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25("headerTools"), children: [
|
34020
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33776
34021
|
IconButton,
|
33777
34022
|
{
|
33778
34023
|
onClick: () => {
|
33779
34024
|
return setMenuOpen(!menuOpen);
|
33780
34025
|
},
|
33781
34026
|
title: "Toggle menu bar",
|
33782
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
34027
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ChevronDown, { focusable: "false" })
|
33783
34028
|
}
|
33784
34029
|
) }),
|
33785
|
-
/* @__PURE__ */ (0,
|
34030
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33786
34031
|
MenuBar,
|
33787
34032
|
{
|
33788
34033
|
appState,
|
@@ -33790,7 +34035,16 @@ function Puck({
|
|
33790
34035
|
dispatch,
|
33791
34036
|
onPublish,
|
33792
34037
|
menuOpen,
|
33793
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
34038
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
34039
|
+
Button,
|
34040
|
+
{
|
34041
|
+
onClick: () => {
|
34042
|
+
onPublish && onPublish(data);
|
34043
|
+
},
|
34044
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Globe, { size: "14px" }),
|
34045
|
+
children: "Publish"
|
34046
|
+
}
|
34047
|
+
) }),
|
33794
34048
|
setMenuOpen
|
33795
34049
|
}
|
33796
34050
|
)
|
@@ -33798,23 +34052,23 @@ function Puck({
|
|
33798
34052
|
] }) })
|
33799
34053
|
}
|
33800
34054
|
),
|
33801
|
-
/* @__PURE__ */ (0,
|
33802
|
-
/* @__PURE__ */ (0,
|
33803
|
-
/* @__PURE__ */ (0,
|
34055
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName25("leftSideBar"), children: [
|
34056
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Components, {}) }),
|
34057
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Outline, {}) })
|
33804
34058
|
] }),
|
33805
|
-
/* @__PURE__ */ (0,
|
33806
|
-
/* @__PURE__ */ (0,
|
34059
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Canvas, {}),
|
34060
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName25("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33807
34061
|
SidebarSection,
|
33808
34062
|
{
|
33809
34063
|
noPadding: true,
|
33810
34064
|
noBorderTop: true,
|
33811
34065
|
showBreadcrumbs: true,
|
33812
34066
|
title: selectedItem ? (_a = config.components[selectedItem.type]["label"]) != null ? _a : selectedItem.type : "Page",
|
33813
|
-
children: /* @__PURE__ */ (0,
|
34067
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Fields, {})
|
33814
34068
|
}
|
33815
34069
|
) })
|
33816
34070
|
] }),
|
33817
|
-
/* @__PURE__ */ (0,
|
34071
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
33818
34072
|
"div",
|
33819
34073
|
{
|
33820
34074
|
id: "puck-portal-root",
|
@@ -33838,16 +34092,20 @@ Puck.Preview = Preview;
|
|
33838
34092
|
|
33839
34093
|
// components/Render/index.tsx
|
33840
34094
|
init_react_import();
|
33841
|
-
var
|
34095
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
33842
34096
|
function Render({
|
33843
34097
|
config,
|
33844
34098
|
data
|
33845
34099
|
}) {
|
33846
34100
|
var _a;
|
33847
|
-
const
|
34101
|
+
const defaultedData = __spreadProps(__spreadValues({}, data), {
|
34102
|
+
root: data.root || {},
|
34103
|
+
content: data.content || []
|
34104
|
+
});
|
34105
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
33848
34106
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
33849
34107
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
33850
|
-
return /* @__PURE__ */ (0,
|
34108
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZoneProvider, { value: { data: defaultedData, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
33851
34109
|
config.root.render,
|
33852
34110
|
__spreadProps(__spreadValues({}, rootProps), {
|
33853
34111
|
puck: {
|
@@ -33856,11 +34114,11 @@ function Render({
|
|
33856
34114
|
title,
|
33857
34115
|
editMode: false,
|
33858
34116
|
id: "puck-root",
|
33859
|
-
children: /* @__PURE__ */ (0,
|
34117
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZone, { zone: rootDroppableId })
|
33860
34118
|
})
|
33861
34119
|
) });
|
33862
34120
|
}
|
33863
|
-
return /* @__PURE__ */ (0,
|
34121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZoneProvider, { value: { data: defaultedData, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropZone, { zone: rootDroppableId }) });
|
33864
34122
|
}
|
33865
34123
|
|
33866
34124
|
// lib/migrate.ts
|
@@ -33888,6 +34146,15 @@ function migrate(data) {
|
|
33888
34146
|
|
33889
34147
|
// lib/transform-props.ts
|
33890
34148
|
init_react_import();
|
34149
|
+
|
34150
|
+
// lib/default-data.ts
|
34151
|
+
init_react_import();
|
34152
|
+
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
34153
|
+
root: data.root || {},
|
34154
|
+
content: data.content || []
|
34155
|
+
});
|
34156
|
+
|
34157
|
+
// lib/transform-props.ts
|
33891
34158
|
function transformProps(data, propTransforms) {
|
33892
34159
|
const mapItem = (item) => {
|
33893
34160
|
if (propTransforms[item.type]) {
|
@@ -33897,18 +34164,19 @@ function transformProps(data, propTransforms) {
|
|
33897
34164
|
}
|
33898
34165
|
return item;
|
33899
34166
|
};
|
33900
|
-
const
|
33901
|
-
|
34167
|
+
const defaultedData = defaultData(data);
|
34168
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
34169
|
+
let newRoot = __spreadValues({}, defaultedData.root);
|
33902
34170
|
if (propTransforms["root"]) {
|
33903
|
-
if (
|
34171
|
+
if (defaultedData.root.props) {
|
33904
34172
|
newRoot.props = propTransforms["root"](rootProps);
|
33905
34173
|
} else {
|
33906
34174
|
newRoot = propTransforms["root"](rootProps);
|
33907
34175
|
}
|
33908
34176
|
}
|
33909
|
-
const afterPropTransforms = __spreadProps(__spreadValues({},
|
34177
|
+
const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
|
33910
34178
|
root: newRoot,
|
33911
|
-
content:
|
34179
|
+
content: defaultedData.content.map(mapItem),
|
33912
34180
|
zones: Object.keys(data.zones || {}).reduce(
|
33913
34181
|
(acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
|
33914
34182
|
[zoneKey]: data.zones[zoneKey].map(mapItem)
|
@@ -33923,7 +34191,8 @@ function transformProps(data, propTransforms) {
|
|
33923
34191
|
init_react_import();
|
33924
34192
|
function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
33925
34193
|
return __async(this, null, function* () {
|
33926
|
-
const
|
34194
|
+
const defaultedData = defaultData(data);
|
34195
|
+
const dynamicRoot = yield resolveRootData(defaultedData, config);
|
33927
34196
|
const { zones = {} } = data;
|
33928
34197
|
const zoneKeys = Object.keys(zones);
|
33929
34198
|
const resolvedZones = {};
|
@@ -33936,10 +34205,10 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
|
33936
34205
|
onResolveEnd
|
33937
34206
|
);
|
33938
34207
|
}
|
33939
|
-
return __spreadProps(__spreadValues({},
|
34208
|
+
return __spreadProps(__spreadValues({}, defaultedData), {
|
33940
34209
|
root: dynamicRoot,
|
33941
34210
|
content: yield resolveAllComponentData(
|
33942
|
-
|
34211
|
+
defaultedData.content,
|
33943
34212
|
config,
|
33944
34213
|
onResolveStart,
|
33945
34214
|
onResolveEnd
|