@measured/puck 0.16.0-canary.2bef00b → 0.16.0-canary.2cce878
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions-B02fIT66.d.mts +419 -0
- package/dist/actions-B02fIT66.d.ts +419 -0
- package/dist/{chunk-TM7CT64S.mjs → chunk-LM7YWFFF.mjs} +3 -2
- package/dist/index.css +25 -9
- package/dist/index.d.mts +18 -157
- package/dist/index.d.ts +18 -157
- package/dist/index.js +212 -126
- package/dist/index.mjs +209 -125
- 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 +3 -1
- 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;
|
|
@@ -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), {
|
|
@@ -3944,13 +3990,17 @@ var defer = (fn) => setTimeout(fn, 0);
|
|
|
3944
3990
|
var CopyHostStyles = ({
|
|
3945
3991
|
children,
|
|
3946
3992
|
debug = false,
|
|
3947
|
-
onStylesLoaded = () => null
|
|
3993
|
+
onStylesLoaded = () => null,
|
|
3994
|
+
enabled = true
|
|
3948
3995
|
}) => {
|
|
3949
3996
|
const { document: doc, window: win } = useFrame();
|
|
3950
3997
|
(0, import_react23.useEffect)(() => {
|
|
3951
3998
|
if (!win || !doc) {
|
|
3952
|
-
return
|
|
3953
|
-
|
|
3999
|
+
return;
|
|
4000
|
+
}
|
|
4001
|
+
if (!enabled) {
|
|
4002
|
+
onStylesLoaded();
|
|
4003
|
+
return;
|
|
3954
4004
|
}
|
|
3955
4005
|
let elements = [];
|
|
3956
4006
|
const hashes = {};
|
|
@@ -4114,13 +4164,15 @@ function AutoFrame(_a) {
|
|
|
4114
4164
|
className,
|
|
4115
4165
|
debug,
|
|
4116
4166
|
id,
|
|
4117
|
-
onStylesLoaded
|
|
4167
|
+
onStylesLoaded,
|
|
4168
|
+
syncHostStyles = true
|
|
4118
4169
|
} = _b, props = __objRest(_b, [
|
|
4119
4170
|
"children",
|
|
4120
4171
|
"className",
|
|
4121
4172
|
"debug",
|
|
4122
4173
|
"id",
|
|
4123
|
-
"onStylesLoaded"
|
|
4174
|
+
"onStylesLoaded",
|
|
4175
|
+
"syncHostStyles"
|
|
4124
4176
|
]);
|
|
4125
4177
|
const [loaded, setLoaded] = (0, import_react23.useState)(false);
|
|
4126
4178
|
const [ctx, setCtx] = (0, import_react23.useState)({});
|
|
@@ -4146,7 +4198,15 @@ function AutoFrame(_a) {
|
|
|
4146
4198
|
onLoad: () => {
|
|
4147
4199
|
setLoaded(true);
|
|
4148
4200
|
},
|
|
4149
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4201
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4202
|
+
CopyHostStyles,
|
|
4203
|
+
{
|
|
4204
|
+
debug,
|
|
4205
|
+
onStylesLoaded,
|
|
4206
|
+
enabled: syncHostStyles,
|
|
4207
|
+
children: (0, import_react_dom2.createPortal)(children, mountTarget)
|
|
4208
|
+
}
|
|
4209
|
+
) })
|
|
4150
4210
|
})
|
|
4151
4211
|
);
|
|
4152
4212
|
}
|
|
@@ -4165,13 +4225,9 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
|
4165
4225
|
const Page = (0, import_react24.useCallback)(
|
|
4166
4226
|
(pageProps) => {
|
|
4167
4227
|
var _a, _b;
|
|
4168
|
-
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(
|
|
4228
|
+
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
|
4169
4229
|
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 });
|
|
4230
|
+
}, pageProps)) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: pageProps.children });
|
|
4175
4231
|
},
|
|
4176
4232
|
[config.root]
|
|
4177
4233
|
);
|
|
@@ -4194,15 +4250,30 @@ var Preview = ({ id = "puck-preview" }) => {
|
|
|
4194
4250
|
onStylesLoaded: () => {
|
|
4195
4251
|
setStatus("READY");
|
|
4196
4252
|
},
|
|
4253
|
+
syncHostStyles: iframe.syncHostStyles,
|
|
4197
4254
|
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
|
4198
|
-
const inner = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4255
|
+
const inner = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4256
|
+
Page,
|
|
4257
|
+
__spreadProps(__spreadValues({}, rootProps), {
|
|
4258
|
+
puck: { renderDropZone: DropZone, isEditing: true },
|
|
4259
|
+
editMode: true,
|
|
4260
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
|
4261
|
+
})
|
|
4262
|
+
);
|
|
4199
4263
|
if (Frame) {
|
|
4200
4264
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Frame, { document: document2, children: inner });
|
|
4201
4265
|
}
|
|
4202
4266
|
return inner;
|
|
4203
4267
|
} })
|
|
4204
4268
|
}
|
|
4205
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { id: "preview-frame", className: getClassName23("frame"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4269
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { id: "preview-frame", className: getClassName23("frame"), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4270
|
+
Page,
|
|
4271
|
+
__spreadProps(__spreadValues({}, rootProps), {
|
|
4272
|
+
puck: { renderDropZone: DropZone, isEditing: true },
|
|
4273
|
+
editMode: true,
|
|
4274
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZone, { zone: rootDroppableId })
|
|
4275
|
+
})
|
|
4276
|
+
) })
|
|
4206
4277
|
}
|
|
4207
4278
|
);
|
|
4208
4279
|
};
|
|
@@ -4316,6 +4387,7 @@ var LayerTree = ({
|
|
|
4316
4387
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
4317
4388
|
"button",
|
|
4318
4389
|
{
|
|
4390
|
+
type: "button",
|
|
4319
4391
|
className: getClassNameLayer("clickable"),
|
|
4320
4392
|
onClick: () => {
|
|
4321
4393
|
if (isSelected) {
|
|
@@ -4805,7 +4877,7 @@ var ViewportControls = ({
|
|
|
4805
4877
|
|
|
4806
4878
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
|
4807
4879
|
init_react_import();
|
|
4808
|
-
var styles_module_default21 = { "PuckCanvas": "
|
|
4880
|
+
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
4881
|
|
|
4810
4882
|
// lib/get-zoom-config.ts
|
|
4811
4883
|
init_react_import();
|
|
@@ -4897,11 +4969,18 @@ var Canvas = () => {
|
|
|
4897
4969
|
observer.disconnect();
|
|
4898
4970
|
};
|
|
4899
4971
|
}, []);
|
|
4972
|
+
const [showLoader, setShowLoader] = (0, import_react29.useState)(false);
|
|
4973
|
+
(0, import_react29.useEffect)(() => {
|
|
4974
|
+
setTimeout(() => {
|
|
4975
|
+
setShowLoader(true);
|
|
4976
|
+
}, 500);
|
|
4977
|
+
}, []);
|
|
4900
4978
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
4901
4979
|
"div",
|
|
4902
4980
|
{
|
|
4903
4981
|
className: getClassName26({
|
|
4904
|
-
ready: status === "READY" || !iframe.enabled
|
|
4982
|
+
ready: status === "READY" || !iframe.enabled,
|
|
4983
|
+
showLoader
|
|
4905
4984
|
}),
|
|
4906
4985
|
onClick: () => dispatch({
|
|
4907
4986
|
type: "setUi",
|
|
@@ -4934,21 +5013,24 @@ var Canvas = () => {
|
|
|
4934
5013
|
}
|
|
4935
5014
|
}
|
|
4936
5015
|
) }),
|
|
4937
|
-
/* @__PURE__ */ (0, import_jsx_runtime37.
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
5016
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
|
5017
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
5018
|
+
"div",
|
|
5019
|
+
{
|
|
5020
|
+
className: getClassName26("root"),
|
|
5021
|
+
style: {
|
|
5022
|
+
width: iframe.enabled ? ui.viewports.current.width : "100%",
|
|
5023
|
+
height: zoomConfig.rootHeight,
|
|
5024
|
+
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
|
5025
|
+
transition: showTransition ? "width 150ms ease-out, height 150ms ease-out, transform 150ms ease-out" : "",
|
|
5026
|
+
overflow: iframe.enabled ? void 0 : "auto"
|
|
5027
|
+
},
|
|
5028
|
+
suppressHydrationWarning: true,
|
|
5029
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Preview, {}) })
|
|
5030
|
+
}
|
|
5031
|
+
),
|
|
5032
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: getClassName26("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Loader, { size: 24 }) })
|
|
5033
|
+
] })
|
|
4952
5034
|
]
|
|
4953
5035
|
}
|
|
4954
5036
|
);
|
|
@@ -4998,7 +5080,8 @@ var loadOverrides = ({
|
|
|
4998
5080
|
}) => {
|
|
4999
5081
|
const collected = __spreadValues({}, overrides);
|
|
5000
5082
|
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
|
5001
|
-
Object.keys(plugin.overrides).forEach((
|
|
5083
|
+
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
|
5084
|
+
const overridesType = _overridesType;
|
|
5002
5085
|
if (overridesType === "fieldTypes") {
|
|
5003
5086
|
const fieldTypes = plugin.overrides.fieldTypes;
|
|
5004
5087
|
Object.keys(fieldTypes).forEach((fieldType) => {
|
|
@@ -5038,7 +5121,7 @@ var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_mod
|
|
|
5038
5121
|
function Puck({
|
|
5039
5122
|
children,
|
|
5040
5123
|
config,
|
|
5041
|
-
data: initialData
|
|
5124
|
+
data: initialData,
|
|
5042
5125
|
ui: initialUi,
|
|
5043
5126
|
onChange,
|
|
5044
5127
|
onPublish,
|
|
@@ -5051,19 +5134,25 @@ function Puck({
|
|
|
5051
5134
|
headerTitle,
|
|
5052
5135
|
headerPath,
|
|
5053
5136
|
viewports = defaultViewports,
|
|
5054
|
-
iframe
|
|
5055
|
-
enabled: true
|
|
5056
|
-
},
|
|
5137
|
+
iframe: _iframe,
|
|
5057
5138
|
dnd,
|
|
5058
5139
|
initialHistory
|
|
5059
5140
|
}) {
|
|
5060
5141
|
var _a;
|
|
5061
5142
|
const historyStore = useHistoryStore(initialHistory);
|
|
5062
5143
|
const [reducer] = (0, import_react31.useState)(
|
|
5063
|
-
() => createReducer({
|
|
5144
|
+
() => createReducer({
|
|
5145
|
+
config,
|
|
5146
|
+
record: historyStore.record,
|
|
5147
|
+
onAction
|
|
5148
|
+
})
|
|
5064
5149
|
);
|
|
5150
|
+
const iframe = __spreadValues({
|
|
5151
|
+
enabled: true,
|
|
5152
|
+
syncHostStyles: true
|
|
5153
|
+
}, _iframe);
|
|
5065
5154
|
const [initialAppState] = (0, import_react31.useState)(() => {
|
|
5066
|
-
var _a2, _b, _c, _d, _e, _f, _g;
|
|
5155
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
5067
5156
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
5068
5157
|
let clientUiState = {};
|
|
5069
5158
|
if (typeof window !== "undefined") {
|
|
@@ -5083,20 +5172,20 @@ function Puck({
|
|
|
5083
5172
|
clientUiState = {
|
|
5084
5173
|
viewports: __spreadProps(__spreadValues({}, initial.viewports), {
|
|
5085
5174
|
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: ((
|
|
5175
|
+
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",
|
|
5176
|
+
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
5177
|
})
|
|
5089
5178
|
})
|
|
5090
5179
|
};
|
|
5091
5180
|
}
|
|
5092
5181
|
}
|
|
5093
|
-
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((
|
|
5182
|
+
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_g = initialData == null ? void 0 : initialData.root) == null ? void 0 : _g.props)) {
|
|
5094
5183
|
console.error(
|
|
5095
5184
|
"Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
|
|
5096
5185
|
);
|
|
5097
5186
|
}
|
|
5098
|
-
const rootProps2 = ((
|
|
5099
|
-
const defaultedRootProps = __spreadValues(__spreadValues({}, (
|
|
5187
|
+
const rootProps2 = ((_h = initialData == null ? void 0 : initialData.root) == null ? void 0 : _h.props) || (initialData == null ? void 0 : initialData.root) || {};
|
|
5188
|
+
const defaultedRootProps = __spreadValues(__spreadValues({}, (_i = config.root) == null ? void 0 : _i.defaultProps), rootProps2);
|
|
5100
5189
|
return __spreadProps(__spreadValues({}, defaultAppState), {
|
|
5101
5190
|
data: __spreadProps(__spreadValues({}, initialData), {
|
|
5102
5191
|
root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps }),
|
|
@@ -5388,7 +5477,7 @@ function Puck({
|
|
|
5388
5477
|
}
|
|
5389
5478
|
)
|
|
5390
5479
|
] }),
|
|
5391
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Heading, { rank: 2, size: "xs", children: [
|
|
5480
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
|
5392
5481
|
headerTitle || rootProps.title || "Page",
|
|
5393
5482
|
headerPath && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
|
|
5394
5483
|
" ",
|
|
@@ -5416,7 +5505,6 @@ function Puck({
|
|
|
5416
5505
|
MenuBar,
|
|
5417
5506
|
{
|
|
5418
5507
|
appState,
|
|
5419
|
-
data,
|
|
5420
5508
|
dispatch,
|
|
5421
5509
|
onPublish,
|
|
5422
5510
|
menuOpen,
|
|
@@ -5472,10 +5560,7 @@ Puck.Preview = Preview;
|
|
|
5472
5560
|
// components/Render/index.tsx
|
|
5473
5561
|
init_react_import();
|
|
5474
5562
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
5475
|
-
function Render({
|
|
5476
|
-
config,
|
|
5477
|
-
data
|
|
5478
|
-
}) {
|
|
5563
|
+
function Render({ config, data }) {
|
|
5479
5564
|
var _a;
|
|
5480
5565
|
const defaultedData = __spreadProps(__spreadValues({}, data), {
|
|
5481
5566
|
root: data.root || {},
|
|
@@ -5656,6 +5741,7 @@ var usePuck = () => {
|
|
|
5656
5741
|
Render,
|
|
5657
5742
|
dropZoneContext,
|
|
5658
5743
|
migrate,
|
|
5744
|
+
overrideKeys,
|
|
5659
5745
|
resolveAllData,
|
|
5660
5746
|
transformProps,
|
|
5661
5747
|
usePuck
|