@measured/puck 0.16.0-canary.a1d52cb → 0.16.0-canary.a3518ca
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/actions-BaAekM3E.d.mts +434 -0
- package/dist/actions-BaAekM3E.d.ts +434 -0
- package/dist/{chunk-TM7CT64S.mjs → chunk-LM7YWFFF.mjs} +3 -2
- package/dist/index.css +25 -9
- package/dist/index.d.mts +34 -180
- package/dist/index.d.ts +34 -180
- package/dist/index.js +227 -134
- package/dist/index.mjs +224 -133
- package/dist/rsc.d.mts +1 -1
- package/dist/rsc.d.ts +1 -1
- package/dist/rsc.js +3 -2
- package/dist/rsc.mjs +1 -1
- package/package.json +13 -4
- package/dist/Config-CkVFT1_w.d.mts +0 -276
- package/dist/Config-CkVFT1_w.d.ts +0 -276
package/dist/index.js
CHANGED
@@ -161,6 +161,7 @@ __export(core_exports, {
|
|
161
161
|
Render: () => Render,
|
162
162
|
dropZoneContext: () => dropZoneContext,
|
163
163
|
migrate: () => migrate,
|
164
|
+
overrideKeys: () => overrideKeys,
|
164
165
|
resolveAllData: () => resolveAllData,
|
165
166
|
transformProps: () => transformProps,
|
166
167
|
usePuck: () => usePuck
|
@@ -168,46 +169,73 @@ __export(core_exports, {
|
|
168
169
|
module.exports = __toCommonJS(core_exports);
|
169
170
|
init_react_import();
|
170
171
|
|
172
|
+
// types/API/index.ts
|
173
|
+
init_react_import();
|
174
|
+
|
175
|
+
// types/API/Viewports.ts
|
176
|
+
init_react_import();
|
177
|
+
|
178
|
+
// types/index.ts
|
179
|
+
init_react_import();
|
180
|
+
|
181
|
+
// types/API/Overrides.ts
|
182
|
+
init_react_import();
|
183
|
+
var overrideKeys = [
|
184
|
+
"header",
|
185
|
+
"headerActions",
|
186
|
+
"fields",
|
187
|
+
"fieldLabel",
|
188
|
+
"components",
|
189
|
+
"componentItem",
|
190
|
+
"outline",
|
191
|
+
"puck",
|
192
|
+
"preview"
|
193
|
+
];
|
194
|
+
|
195
|
+
// types/AppState.tsx
|
196
|
+
init_react_import();
|
197
|
+
|
171
198
|
// types/Config.tsx
|
172
199
|
init_react_import();
|
173
200
|
|
174
|
-
// types/
|
201
|
+
// types/Data.tsx
|
175
202
|
init_react_import();
|
176
203
|
|
177
204
|
// types/Fields.ts
|
178
205
|
init_react_import();
|
179
206
|
|
207
|
+
// types/Props.tsx
|
208
|
+
init_react_import();
|
209
|
+
|
210
|
+
// types/Utils.tsx
|
211
|
+
init_react_import();
|
212
|
+
|
180
213
|
// components/ActionBar/index.tsx
|
181
214
|
init_react_import();
|
182
215
|
|
183
216
|
// lib/get-class-name-factory.ts
|
184
217
|
init_react_import();
|
185
218
|
var import_classnames = __toESM(require_classnames());
|
186
|
-
var getClassNameFactory = (rootClass, styles, { baseClass
|
187
|
-
let descendant = false;
|
188
|
-
let modifiers = false;
|
219
|
+
var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (options = {}) => {
|
189
220
|
if (typeof options === "string") {
|
190
|
-
descendant = options;
|
191
|
-
} else if (typeof options === "object") {
|
192
|
-
modifiers = options;
|
193
|
-
}
|
194
|
-
if (descendant) {
|
221
|
+
const descendant = options;
|
195
222
|
const style = styles[`${rootClass}-${descendant}`];
|
196
223
|
if (style) {
|
197
|
-
return baseClass + styles[`${rootClass}-${descendant}`] || "";
|
224
|
+
return config.baseClass + styles[`${rootClass}-${descendant}`] || "";
|
198
225
|
}
|
199
226
|
return "";
|
200
|
-
} else if (
|
227
|
+
} else if (typeof options === "object") {
|
228
|
+
const modifiers = options;
|
201
229
|
const prefixedModifiers = {};
|
202
230
|
for (let modifier in modifiers) {
|
203
231
|
prefixedModifiers[styles[`${rootClass}--${modifier}`]] = modifiers[modifier];
|
204
232
|
}
|
205
233
|
const c = styles[rootClass];
|
206
|
-
return baseClass + (0, import_classnames.default)(__spreadValues({
|
234
|
+
return config.baseClass + (0, import_classnames.default)(__spreadValues({
|
207
235
|
[c]: !!c
|
208
236
|
}, prefixedModifiers));
|
209
237
|
} else {
|
210
|
-
return baseClass + styles[rootClass] || "";
|
238
|
+
return config.baseClass + styles[rootClass] || "";
|
211
239
|
}
|
212
240
|
};
|
213
241
|
var get_class_name_factory_default = getClassNameFactory;
|
@@ -230,7 +258,16 @@ var Action = ({
|
|
230
258
|
children,
|
231
259
|
label,
|
232
260
|
onClick
|
233
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
261
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
262
|
+
"button",
|
263
|
+
{
|
264
|
+
type: "button",
|
265
|
+
className: getClassName("action"),
|
266
|
+
onClick,
|
267
|
+
title: label,
|
268
|
+
children
|
269
|
+
}
|
270
|
+
);
|
234
271
|
ActionBar.Action = Action;
|
235
272
|
|
236
273
|
// components/AutoField/index.tsx
|
@@ -664,21 +701,22 @@ var setupZone = (data, zoneKey) => {
|
|
664
701
|
if (zoneKey === rootDroppableId) {
|
665
702
|
return data;
|
666
703
|
}
|
667
|
-
const newData = __spreadValues({}, data)
|
668
|
-
|
704
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
705
|
+
zones: data.zones || {}
|
706
|
+
});
|
669
707
|
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
670
708
|
return newData;
|
671
709
|
};
|
672
710
|
|
673
711
|
// lib/get-item.ts
|
674
|
-
|
712
|
+
function getItem(selector, data, dynamicProps = {}) {
|
675
713
|
if (!selector.zone || selector.zone === rootDroppableId) {
|
676
714
|
const item2 = data.content[selector.index];
|
677
715
|
return (item2 == null ? void 0 : item2.props) ? __spreadProps(__spreadValues({}, item2), { props: dynamicProps[item2.props.id] || item2.props }) : void 0;
|
678
716
|
}
|
679
717
|
const item = setupZone(data, selector.zone).zones[selector.zone][selector.index];
|
680
718
|
return (item == null ? void 0 : item.props) ? __spreadProps(__spreadValues({}, item), { props: dynamicProps[item.props.id] || item.props }) : void 0;
|
681
|
-
}
|
719
|
+
}
|
682
720
|
|
683
721
|
// components/ViewportControls/default-viewports.ts
|
684
722
|
init_react_import();
|
@@ -692,7 +730,7 @@ var defaultViewports = [
|
|
692
730
|
var import_ua_parser_js = require("ua-parser-js");
|
693
731
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
694
732
|
var defaultAppState = {
|
695
|
-
data: { content: [], root: {
|
733
|
+
data: { content: [], root: {} },
|
696
734
|
ui: {
|
697
735
|
leftSideBarVisible: true,
|
698
736
|
rightSideBarVisible: true,
|
@@ -1427,6 +1465,7 @@ var ExternalInput = ({
|
|
1427
1465
|
value && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
1428
1466
|
"button",
|
1429
1467
|
{
|
1468
|
+
type: "button",
|
1430
1469
|
className: getClassName10("detachButton"),
|
1431
1470
|
onClick: () => {
|
1432
1471
|
onChange(null);
|
@@ -1483,7 +1522,7 @@ var ExternalInput = ({
|
|
1483
1522
|
}
|
1484
1523
|
) })
|
1485
1524
|
] })
|
1486
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Heading, { rank: 2, size: "xs", children: field.placeholder || "Select data" }) }),
|
1525
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
1487
1526
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassNameModal("grid"), children: [
|
1488
1527
|
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
1489
1528
|
const filterField = filterFields[fieldName];
|
@@ -2898,6 +2937,7 @@ var SidebarSection = ({
|
|
2898
2937
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
2899
2938
|
"button",
|
2900
2939
|
{
|
2940
|
+
type: "button",
|
2901
2941
|
className: getClassName19("breadcrumbLabel"),
|
2902
2942
|
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
2903
2943
|
children: breadcrumb.label
|
@@ -2905,7 +2945,7 @@ var SidebarSection = ({
|
|
2905
2945
|
),
|
2906
2946
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ChevronRight, { size: 16 })
|
2907
2947
|
] }, i)) : null,
|
2908
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Heading, { rank: 2, size: "xs", children: title }) })
|
2948
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
2909
2949
|
] }) }),
|
2910
2950
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("content"), children }),
|
2911
2951
|
isLoading && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Loader, { size: 32 }) })
|
@@ -2938,7 +2978,7 @@ var remove = (list, index) => {
|
|
2938
2978
|
|
2939
2979
|
// lib/reduce-related-zones.ts
|
2940
2980
|
init_react_import();
|
2941
|
-
|
2981
|
+
function reduceRelatedZones(item, data, fn) {
|
2942
2982
|
return __spreadProps(__spreadValues({}, data), {
|
2943
2983
|
zones: Object.keys(data.zones || {}).reduce(
|
2944
2984
|
(acc, key) => {
|
@@ -2952,28 +2992,34 @@ var reduceRelatedZones = (item, data, fn) => {
|
|
2952
2992
|
{}
|
2953
2993
|
)
|
2954
2994
|
});
|
2955
|
-
}
|
2995
|
+
}
|
2956
2996
|
var findRelatedByZoneId = (zoneId, data) => {
|
2957
2997
|
const [zoneParentId] = getZoneId(zoneId);
|
2958
|
-
return (data.zones[zoneId] || []).reduce(
|
2959
|
-
|
2960
|
-
|
2961
|
-
|
2962
|
-
|
2963
|
-
|
2964
|
-
|
2998
|
+
return (data.zones[zoneId] || []).reduce(
|
2999
|
+
(acc, zoneItem) => {
|
3000
|
+
const related = findRelatedByItem(zoneItem, data);
|
3001
|
+
if (zoneItem.props.id === zoneParentId) {
|
3002
|
+
return __spreadProps(__spreadValues(__spreadValues({}, acc), related), { [zoneId]: zoneItem });
|
3003
|
+
}
|
3004
|
+
return __spreadValues(__spreadValues({}, acc), related);
|
3005
|
+
},
|
3006
|
+
{}
|
3007
|
+
);
|
2965
3008
|
};
|
2966
3009
|
var findRelatedByItem = (item, data) => {
|
2967
|
-
return Object.keys(data.zones || {}).reduce(
|
2968
|
-
|
2969
|
-
|
2970
|
-
|
2971
|
-
|
2972
|
-
|
2973
|
-
|
2974
|
-
|
2975
|
-
|
2976
|
-
|
3010
|
+
return Object.keys(data.zones || {}).reduce(
|
3011
|
+
(acc, zoneId) => {
|
3012
|
+
const [zoneParentId] = getZoneId(zoneId);
|
3013
|
+
if (item.props.id === zoneParentId) {
|
3014
|
+
const related = findRelatedByZoneId(zoneId, data);
|
3015
|
+
return __spreadProps(__spreadValues(__spreadValues({}, acc), related), {
|
3016
|
+
[zoneId]: data.zones[zoneId]
|
3017
|
+
});
|
3018
|
+
}
|
3019
|
+
return acc;
|
3020
|
+
},
|
3021
|
+
{}
|
3022
|
+
);
|
2977
3023
|
};
|
2978
3024
|
var removeRelatedZones = (item, data) => {
|
2979
3025
|
const newData = __spreadValues({}, data);
|
@@ -2983,7 +3029,7 @@ var removeRelatedZones = (item, data) => {
|
|
2983
3029
|
});
|
2984
3030
|
return newData;
|
2985
3031
|
};
|
2986
|
-
|
3032
|
+
function duplicateRelatedZones(item, data, newId) {
|
2987
3033
|
return reduceRelatedZones(item, data, (acc, key, zone) => {
|
2988
3034
|
const dupedZone = zone.map((zoneItem) => __spreadProps(__spreadValues({}, zoneItem), {
|
2989
3035
|
props: __spreadProps(__spreadValues({}, zoneItem.props), { id: generateId(zoneItem.type) })
|
@@ -2998,7 +3044,7 @@ var duplicateRelatedZones = (item, data, newId) => {
|
|
2998
3044
|
[`${newId}:${zoneId}`]: dupedZone
|
2999
3045
|
});
|
3000
3046
|
});
|
3001
|
-
}
|
3047
|
+
}
|
3002
3048
|
|
3003
3049
|
// reducer/data.ts
|
3004
3050
|
var zoneCache = {};
|
@@ -3022,7 +3068,7 @@ var replaceAction = (data, action) => {
|
|
3022
3068
|
})
|
3023
3069
|
});
|
3024
3070
|
};
|
3025
|
-
|
3071
|
+
function insertAction(data, action, config) {
|
3026
3072
|
const emptyComponentData = {
|
3027
3073
|
type: action.componentType,
|
3028
3074
|
props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
|
@@ -3048,8 +3094,8 @@ var insertAction = (data, action, config) => {
|
|
3048
3094
|
)
|
3049
3095
|
})
|
3050
3096
|
});
|
3051
|
-
}
|
3052
|
-
|
3097
|
+
}
|
3098
|
+
function reduceData(data, action, config) {
|
3053
3099
|
if (action.type === "insert") {
|
3054
3100
|
return insertAction(data, action, config);
|
3055
3101
|
}
|
@@ -3198,7 +3244,7 @@ var reduceData = (data, action, config) => {
|
|
3198
3244
|
return __spreadValues(__spreadValues({}, data), action.data(data));
|
3199
3245
|
}
|
3200
3246
|
return data;
|
3201
|
-
}
|
3247
|
+
}
|
3202
3248
|
|
3203
3249
|
// reducer/state.ts
|
3204
3250
|
init_react_import();
|
@@ -3216,7 +3262,7 @@ var reduceUi = (ui, action) => {
|
|
3216
3262
|
init_react_import();
|
3217
3263
|
|
3218
3264
|
// reducer/index.ts
|
3219
|
-
|
3265
|
+
function storeInterceptor(reducer, record, onAction) {
|
3220
3266
|
return (state, action) => {
|
3221
3267
|
const newAppState = reducer(state, action);
|
3222
3268
|
const isValidType = ![
|
@@ -3232,7 +3278,7 @@ var storeInterceptor = (reducer, record, onAction) => {
|
|
3232
3278
|
onAction == null ? void 0 : onAction(action, newAppState, state);
|
3233
3279
|
return newAppState;
|
3234
3280
|
};
|
3235
|
-
}
|
3281
|
+
}
|
3236
3282
|
var setAction = (state, action) => {
|
3237
3283
|
if (typeof action.state === "object") {
|
3238
3284
|
return __spreadValues(__spreadValues({}, state), action.state);
|
@@ -3347,28 +3393,30 @@ var applyDynamicProps = (data, dynamicProps, rootData) => {
|
|
3347
3393
|
// lib/resolve-root-data.ts
|
3348
3394
|
init_react_import();
|
3349
3395
|
var cache3 = {};
|
3350
|
-
|
3351
|
-
|
3352
|
-
|
3353
|
-
if (((
|
3354
|
-
|
3396
|
+
function resolveRootData(data, config) {
|
3397
|
+
return __async(this, null, function* () {
|
3398
|
+
var _a, _b, _c, _d, _e;
|
3399
|
+
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
3400
|
+
if (((_b = cache3.lastChange) == null ? void 0 : _b.original) === data.root) {
|
3401
|
+
return cache3.lastChange.resolved;
|
3402
|
+
}
|
3403
|
+
const changed = getChanged(data.root, (_c = cache3.lastChange) == null ? void 0 : _c.original);
|
3404
|
+
const rootWithProps = data.root;
|
3405
|
+
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
3406
|
+
changed,
|
3407
|
+
lastData: ((_d = cache3.lastChange) == null ? void 0 : _d.original) || {}
|
3408
|
+
});
|
3409
|
+
cache3.lastChange = {
|
3410
|
+
original: data.root,
|
3411
|
+
resolved: resolvedRoot
|
3412
|
+
};
|
3413
|
+
return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
|
3414
|
+
props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
|
3415
|
+
});
|
3355
3416
|
}
|
3356
|
-
|
3357
|
-
|
3358
|
-
|
3359
|
-
changed,
|
3360
|
-
lastData: ((_d = cache3.lastChange) == null ? void 0 : _d.original) || {}
|
3361
|
-
});
|
3362
|
-
cache3.lastChange = {
|
3363
|
-
original: data.root,
|
3364
|
-
resolved: resolvedRoot
|
3365
|
-
};
|
3366
|
-
return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
|
3367
|
-
props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
|
3368
|
-
});
|
3369
|
-
}
|
3370
|
-
return data.root;
|
3371
|
-
});
|
3417
|
+
return data.root;
|
3418
|
+
});
|
3419
|
+
}
|
3372
3420
|
|
3373
3421
|
// lib/use-resolved-data.ts
|
3374
3422
|
var useResolvedData = (appState, config, dispatch) => {
|
@@ -3473,15 +3521,14 @@ var styles_module_default14 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpe
|
|
3473
3521
|
// components/MenuBar/index.tsx
|
3474
3522
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
3475
3523
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
3476
|
-
|
3524
|
+
function MenuBar({
|
3477
3525
|
appState,
|
3478
|
-
data = { content: [], root: {} },
|
3479
3526
|
dispatch,
|
3480
3527
|
menuOpen = false,
|
3481
3528
|
onPublish,
|
3482
3529
|
renderHeaderActions,
|
3483
3530
|
setMenuOpen
|
3484
|
-
})
|
3531
|
+
}) {
|
3485
3532
|
const {
|
3486
3533
|
history: { back, forward, historyStore }
|
3487
3534
|
} = useAppContext();
|
@@ -3512,7 +3559,7 @@ var MenuBar = ({
|
|
3512
3559
|
] })
|
3513
3560
|
}
|
3514
3561
|
);
|
3515
|
-
}
|
3562
|
+
}
|
3516
3563
|
|
3517
3564
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
3518
3565
|
init_react_import();
|
@@ -3545,9 +3592,7 @@ var useResolvedFields = () => {
|
|
3545
3592
|
const componentConfig = selectedItem ? config.components[selectedItem.type] : null;
|
3546
3593
|
const defaultFields = selectedItem ? componentConfig == null ? void 0 : componentConfig.fields : rootFields;
|
3547
3594
|
const rootProps = data.root.props || data.root;
|
3548
|
-
const [lastSelectedData, setLastSelectedData] = (0, import_react20.useState)(
|
3549
|
-
{}
|
3550
|
-
);
|
3595
|
+
const [lastSelectedData, setLastSelectedData] = (0, import_react20.useState)({});
|
3551
3596
|
const [resolvedFields, setResolvedFields] = (0, import_react20.useState)(defaultFields || {});
|
3552
3597
|
const [fieldsLoading, setFieldsLoading] = (0, import_react20.useState)(false);
|
3553
3598
|
const defaultResolveFields = (_componentData, _params) => defaultFields;
|
@@ -3594,7 +3639,7 @@ var useResolvedFields = () => {
|
|
3594
3639
|
setResolvedFields(fields || {});
|
3595
3640
|
setFieldsLoading(false);
|
3596
3641
|
});
|
3597
|
-
}, [data, defaultFields]);
|
3642
|
+
}, [data, defaultFields, state.ui.itemSelector]);
|
3598
3643
|
return [resolvedFields, fieldsLoading];
|
3599
3644
|
};
|
3600
3645
|
var Fields = () => {
|
@@ -3710,7 +3755,7 @@ var Fields = () => {
|
|
3710
3755
|
`${selectedItem.props.id}_${fieldName}`
|
3711
3756
|
);
|
3712
3757
|
} else {
|
3713
|
-
const
|
3758
|
+
const readOnly = data.root.readOnly || {};
|
3714
3759
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
3715
3760
|
AutoFieldPrivate,
|
3716
3761
|
{
|
@@ -3782,6 +3827,7 @@ var ComponentList = ({
|
|
3782
3827
|
title && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
3783
3828
|
"button",
|
3784
3829
|
{
|
3830
|
+
type: "button",
|
3785
3831
|
className: getClassName22("title"),
|
3786
3832
|
onClick: () => setUi({
|
3787
3833
|
componentList: __spreadProps(__spreadValues({}, state.ui.componentList), {
|
@@ -4165,13 +4211,9 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4165
4211
|
const Page = (0, import_react24.useCallback)(
|
4166
4212
|
(pageProps) => {
|
4167
4213
|
var _a, _b;
|
4168
|
-
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(
|
4214
|
+
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
4169
4215
|
id: "puck-root"
|
4170
|
-
}, pageProps), {
|
4171
|
-
editMode: true,
|
4172
|
-
// DEPRECATED
|
4173
|
-
puck: { renderDropZone: DropZone, isEditing: true }
|
4174
|
-
})) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: pageProps.children });
|
4216
|
+
}, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: pageProps.children });
|
4175
4217
|
},
|
4176
4218
|
[config.root]
|
4177
4219
|
);
|
@@ -4195,14 +4237,28 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
4195
4237
|
setStatus("READY");
|
4196
4238
|
},
|
4197
4239
|
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
4198
|
-
const inner = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4240
|
+
const inner = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4241
|
+
Page,
|
4242
|
+
__spreadProps(__spreadValues({}, rootProps), {
|
4243
|
+
puck: { renderDropZone: DropZone, isEditing: true },
|
4244
|
+
editMode: true,
|
4245
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
4246
|
+
})
|
4247
|
+
);
|
4199
4248
|
if (Frame) {
|
4200
4249
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
|
4201
4250
|
}
|
4202
4251
|
return inner;
|
4203
4252
|
} })
|
4204
4253
|
}
|
4205
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { id: "preview-frame", className: getClassName23("frame"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4254
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { id: "preview-frame", className: getClassName23("frame"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
4255
|
+
Page,
|
4256
|
+
__spreadProps(__spreadValues({}, rootProps), {
|
4257
|
+
puck: { renderDropZone: DropZone, isEditing: true },
|
4258
|
+
editMode: true,
|
4259
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
4260
|
+
})
|
4261
|
+
) })
|
4206
4262
|
}
|
4207
4263
|
);
|
4208
4264
|
};
|
@@ -4316,6 +4372,7 @@ var LayerTree = ({
|
|
4316
4372
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
4317
4373
|
"button",
|
4318
4374
|
{
|
4375
|
+
type: "button",
|
4319
4376
|
className: getClassNameLayer("clickable"),
|
4320
4377
|
onClick: () => {
|
4321
4378
|
if (isSelected) {
|
@@ -4443,14 +4500,14 @@ function usePuckHistory({
|
|
4443
4500
|
if (historyStore.hasPast) {
|
4444
4501
|
dispatch({
|
4445
4502
|
type: "set",
|
4446
|
-
state: ((_a = historyStore.prevHistory) == null ? void 0 : _a.
|
4503
|
+
state: ((_a = historyStore.prevHistory) == null ? void 0 : _a.state) || initialAppState
|
4447
4504
|
});
|
4448
4505
|
historyStore.back();
|
4449
4506
|
}
|
4450
4507
|
};
|
4451
4508
|
const forward = () => {
|
4452
4509
|
if (historyStore.nextHistory) {
|
4453
|
-
dispatch({ type: "set", state: historyStore.nextHistory.
|
4510
|
+
dispatch({ type: "set", state: historyStore.nextHistory.state });
|
4454
4511
|
historyStore.forward();
|
4455
4512
|
}
|
4456
4513
|
};
|
@@ -4458,7 +4515,7 @@ function usePuckHistory({
|
|
4458
4515
|
var _a;
|
4459
4516
|
dispatch({
|
4460
4517
|
type: "set",
|
4461
|
-
state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.
|
4518
|
+
state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.state) || initialAppState
|
4462
4519
|
});
|
4463
4520
|
historyStore.setHistories(histories);
|
4464
4521
|
};
|
@@ -4467,7 +4524,7 @@ function usePuckHistory({
|
|
4467
4524
|
if (historyStore.histories.length > index) {
|
4468
4525
|
dispatch({
|
4469
4526
|
type: "set",
|
4470
|
-
state: ((_a = historyStore.histories[index]) == null ? void 0 : _a.
|
4527
|
+
state: ((_a = historyStore.histories[index]) == null ? void 0 : _a.state) || initialAppState
|
4471
4528
|
});
|
4472
4529
|
historyStore.setHistoryIndex(index);
|
4473
4530
|
}
|
@@ -4488,7 +4545,7 @@ function usePuckHistory({
|
|
4488
4545
|
init_react_import();
|
4489
4546
|
var import_react27 = require("react");
|
4490
4547
|
var import_use_debounce3 = require("use-debounce");
|
4491
|
-
var EMPTY_HISTORY_INDEX =
|
4548
|
+
var EMPTY_HISTORY_INDEX = 0;
|
4492
4549
|
function useHistoryStore(initialHistory) {
|
4493
4550
|
var _a, _b;
|
4494
4551
|
const [histories, setHistories] = (0, import_react27.useState)(
|
@@ -4506,9 +4563,9 @@ function useHistoryStore(initialHistory) {
|
|
4506
4563
|
const currentHistory = histories[index];
|
4507
4564
|
const nextHistory = hasFuture ? histories[index + 1] : null;
|
4508
4565
|
const prevHistory = hasPast ? histories[index - 1] : null;
|
4509
|
-
const record = (0, import_use_debounce3.useDebouncedCallback)((
|
4566
|
+
const record = (0, import_use_debounce3.useDebouncedCallback)((state) => {
|
4510
4567
|
const history = {
|
4511
|
-
|
4568
|
+
state,
|
4512
4569
|
id: generateId("history")
|
4513
4570
|
};
|
4514
4571
|
updateHistories([...histories.slice(0, index + 1), history]);
|
@@ -4805,7 +4862,7 @@ var ViewportControls = ({
|
|
4805
4862
|
|
4806
4863
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
4807
4864
|
init_react_import();
|
4808
|
-
var styles_module_default21 = { "PuckCanvas": "
|
4865
|
+
var styles_module_default21 = { "PuckCanvas": "_PuckCanvas_esbg1_1", "PuckCanvas-controls": "_PuckCanvas-controls_esbg1_16", "PuckCanvas-inner": "_PuckCanvas-inner_esbg1_21", "PuckCanvas-root": "_PuckCanvas-root_esbg1_32", "PuckCanvas--ready": "_PuckCanvas--ready_esbg1_56", "PuckCanvas-loader": "_PuckCanvas-loader_esbg1_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_esbg1_70" };
|
4809
4866
|
|
4810
4867
|
// lib/get-zoom-config.ts
|
4811
4868
|
init_react_import();
|
@@ -4885,6 +4942,12 @@ var Canvas = () => {
|
|
4885
4942
|
}));
|
4886
4943
|
}
|
4887
4944
|
}, [zoomConfig.zoom]);
|
4945
|
+
(0, import_react29.useEffect)(() => {
|
4946
|
+
if (ZOOM_ON_CHANGE) {
|
4947
|
+
setShowTransition(true);
|
4948
|
+
resetAutoZoom(ui);
|
4949
|
+
}
|
4950
|
+
}, [ui.viewports.current.width]);
|
4888
4951
|
(0, import_react29.useEffect)(() => {
|
4889
4952
|
const observer = new ResizeObserver(() => {
|
4890
4953
|
setShowTransition(false);
|
@@ -4897,11 +4960,18 @@ var Canvas = () => {
|
|
4897
4960
|
observer.disconnect();
|
4898
4961
|
};
|
4899
4962
|
}, []);
|
4963
|
+
const [showLoader, setShowLoader] = (0, import_react29.useState)(false);
|
4964
|
+
(0, import_react29.useEffect)(() => {
|
4965
|
+
setTimeout(() => {
|
4966
|
+
setShowLoader(true);
|
4967
|
+
}, 500);
|
4968
|
+
}, []);
|
4900
4969
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
4901
4970
|
"div",
|
4902
4971
|
{
|
4903
4972
|
className: getClassName26({
|
4904
|
-
ready: status === "READY" || !iframe.enabled
|
4973
|
+
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
4974
|
+
showLoader
|
4905
4975
|
}),
|
4906
4976
|
onClick: () => dispatch({
|
4907
4977
|
type: "setUi",
|
@@ -4934,21 +5004,24 @@ var Canvas = () => {
|
|
4934
5004
|
}
|
4935
5005
|
}
|
4936
5006
|
) }),
|
4937
|
-
/* @__PURE__ */ (0, import_jsx_runtime37.
|
4938
|
-
|
4939
|
-
|
4940
|
-
|
4941
|
-
|
4942
|
-
|
4943
|
-
|
4944
|
-
|
4945
|
-
|
4946
|
-
|
4947
|
-
|
4948
|
-
|
4949
|
-
|
4950
|
-
|
4951
|
-
|
5007
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
5008
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
5009
|
+
"div",
|
5010
|
+
{
|
5011
|
+
className: getClassName26("root"),
|
5012
|
+
style: {
|
5013
|
+
width: iframe.enabled ? ui.viewports.current.width : "100%",
|
5014
|
+
height: zoomConfig.rootHeight,
|
5015
|
+
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
5016
|
+
transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : "",
|
5017
|
+
overflow: iframe.enabled ? void 0 : "auto"
|
5018
|
+
},
|
5019
|
+
suppressHydrationWarning: true,
|
5020
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview, {}) })
|
5021
|
+
}
|
5022
|
+
),
|
5023
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
|
5024
|
+
] })
|
4952
5025
|
]
|
4953
5026
|
}
|
4954
5027
|
);
|
@@ -4973,7 +5046,10 @@ var insertComponent = (componentType, zone, index, {
|
|
4973
5046
|
const insertedData = insertAction(state.data, insertActionData, config);
|
4974
5047
|
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
4975
5048
|
// Dispatch insert rather set, as user's may rely on this via onAction
|
4976
|
-
|
5049
|
+
// We must always record history here so the insert is added to user history
|
5050
|
+
// If the user has defined a resolveData method, they will end up with 2 history
|
5051
|
+
// entries on insert - one for the initial insert, and one when the data resolves
|
5052
|
+
recordHistory: true
|
4977
5053
|
}));
|
4978
5054
|
const itemSelector = {
|
4979
5055
|
index,
|
@@ -4998,7 +5074,8 @@ var loadOverrides = ({
|
|
4998
5074
|
}) => {
|
4999
5075
|
const collected = __spreadValues({}, overrides);
|
5000
5076
|
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
5001
|
-
Object.keys(plugin.overrides).forEach((
|
5077
|
+
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
5078
|
+
const overridesType = _overridesType;
|
5002
5079
|
if (overridesType === "fieldTypes") {
|
5003
5080
|
const fieldTypes = plugin.overrides.fieldTypes;
|
5004
5081
|
Object.keys(fieldTypes).forEach((fieldType) => {
|
@@ -5038,7 +5115,7 @@ var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_mod
|
|
5038
5115
|
function Puck({
|
5039
5116
|
children,
|
5040
5117
|
config,
|
5041
|
-
data: initialData
|
5118
|
+
data: initialData,
|
5042
5119
|
ui: initialUi,
|
5043
5120
|
onChange,
|
5044
5121
|
onPublish,
|
@@ -5051,19 +5128,17 @@ function Puck({
|
|
5051
5128
|
headerTitle,
|
5052
5129
|
headerPath,
|
5053
5130
|
viewports = defaultViewports,
|
5054
|
-
iframe
|
5055
|
-
enabled: true
|
5056
|
-
},
|
5131
|
+
iframe: _iframe,
|
5057
5132
|
dnd,
|
5058
|
-
initialHistory
|
5133
|
+
initialHistory: _initialHistory
|
5059
5134
|
}) {
|
5060
5135
|
var _a;
|
5061
|
-
const
|
5062
|
-
|
5063
|
-
|
5064
|
-
);
|
5065
|
-
const [
|
5066
|
-
var _a2, _b, _c, _d, _e, _f, _g;
|
5136
|
+
const iframe = __spreadValues({
|
5137
|
+
enabled: true,
|
5138
|
+
waitForStyles: true
|
5139
|
+
}, _iframe);
|
5140
|
+
const [generatedAppState] = (0, import_react31.useState)(() => {
|
5141
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
5067
5142
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
5068
5143
|
let clientUiState = {};
|
5069
5144
|
if (typeof window !== "undefined") {
|
@@ -5083,20 +5158,20 @@ function Puck({
|
|
5083
5158
|
clientUiState = {
|
5084
5159
|
viewports: __spreadProps(__spreadValues({}, initial.viewports), {
|
5085
5160
|
current: __spreadProps(__spreadValues({}, initial.viewports.current), {
|
5086
|
-
height: ((_b = (_a2 = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a2.current) == null ? void 0 : _b.height) || viewports[closestViewport].height || "auto",
|
5087
|
-
width: ((
|
5161
|
+
height: ((_b = (_a2 = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _a2.current) == null ? void 0 : _b.height) || ((_c = viewports[closestViewport]) == null ? void 0 : _c.height) || "auto",
|
5162
|
+
width: ((_e = (_d = initialUi == null ? void 0 : initialUi.viewports) == null ? void 0 : _d.current) == null ? void 0 : _e.width) || ((_f = viewports[closestViewport]) == null ? void 0 : _f.width)
|
5088
5163
|
})
|
5089
5164
|
})
|
5090
5165
|
};
|
5091
5166
|
}
|
5092
5167
|
}
|
5093
|
-
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((
|
5168
|
+
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_g = initialData == null ? void 0 : initialData.root) == null ? void 0 : _g.props)) {
|
5094
5169
|
console.error(
|
5095
5170
|
"Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
|
5096
5171
|
);
|
5097
5172
|
}
|
5098
|
-
const rootProps2 = ((
|
5099
|
-
const defaultedRootProps = __spreadValues(__spreadValues({}, (
|
5173
|
+
const rootProps2 = ((_h = initialData == null ? void 0 : initialData.root) == null ? void 0 : _h.props) || (initialData == null ? void 0 : initialData.root) || {};
|
5174
|
+
const defaultedRootProps = __spreadValues(__spreadValues({}, (_i = config.root) == null ? void 0 : _i.defaultProps), rootProps2);
|
5100
5175
|
return __spreadProps(__spreadValues({}, defaultAppState), {
|
5101
5176
|
data: __spreadProps(__spreadValues({}, initialData), {
|
5102
5177
|
root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps }),
|
@@ -5120,6 +5195,27 @@ function Puck({
|
|
5120
5195
|
})
|
5121
5196
|
});
|
5122
5197
|
});
|
5198
|
+
const { appendData = true } = _initialHistory || {};
|
5199
|
+
const histories = [
|
5200
|
+
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
5201
|
+
...appendData ? [{ state: generatedAppState }] : []
|
5202
|
+
].map((history2) => __spreadProps(__spreadValues({}, history2), {
|
5203
|
+
// Inject default data to enable partial history injections
|
5204
|
+
state: __spreadValues(__spreadValues({}, generatedAppState), history2.state)
|
5205
|
+
}));
|
5206
|
+
const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || histories.length - 1;
|
5207
|
+
const initialAppState = histories[initialHistoryIndex].state;
|
5208
|
+
const historyStore = useHistoryStore({
|
5209
|
+
histories,
|
5210
|
+
index: initialHistoryIndex
|
5211
|
+
});
|
5212
|
+
const [reducer] = (0, import_react31.useState)(
|
5213
|
+
() => createReducer({
|
5214
|
+
config,
|
5215
|
+
record: historyStore.record,
|
5216
|
+
onAction
|
5217
|
+
})
|
5218
|
+
);
|
5123
5219
|
const [appState, dispatch] = (0, import_react31.useReducer)(
|
5124
5220
|
reducer,
|
5125
5221
|
flushZones(initialAppState)
|
@@ -5388,7 +5484,7 @@ function Puck({
|
|
5388
5484
|
}
|
5389
5485
|
)
|
5390
5486
|
] }),
|
5391
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Heading, { rank: 2, size: "xs", children: [
|
5487
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
5392
5488
|
headerTitle || rootProps.title || "Page",
|
5393
5489
|
headerPath && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
|
5394
5490
|
" ",
|
@@ -5416,7 +5512,6 @@ function Puck({
|
|
5416
5512
|
MenuBar,
|
5417
5513
|
{
|
5418
5514
|
appState,
|
5419
|
-
data,
|
5420
5515
|
dispatch,
|
5421
5516
|
onPublish,
|
5422
5517
|
menuOpen,
|
@@ -5472,10 +5567,7 @@ Puck.Preview = Preview;
|
|
5472
5567
|
// components/Render/index.tsx
|
5473
5568
|
init_react_import();
|
5474
5569
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
5475
|
-
function Render({
|
5476
|
-
config,
|
5477
|
-
data
|
5478
|
-
}) {
|
5570
|
+
function Render({ config, data }) {
|
5479
5571
|
var _a;
|
5480
5572
|
const defaultedData = __spreadProps(__spreadValues({}, data), {
|
5481
5573
|
root: data.root || {},
|
@@ -5656,6 +5748,7 @@ var usePuck = () => {
|
|
5656
5748
|
Render,
|
5657
5749
|
dropZoneContext,
|
5658
5750
|
migrate,
|
5751
|
+
overrideKeys,
|
5659
5752
|
resolveAllData,
|
5660
5753
|
transformProps,
|
5661
5754
|
usePuck
|