@measured/puck 0.21.0-canary.eb8ea5ce → 0.21.0-canary.ed10e2a4
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/{chunk-YZQENDBP.mjs → chunk-JA7SEUEH.mjs} +499 -70
- package/dist/{chunk-MSIUWPEI.mjs → chunk-UABEUL66.mjs} +2681 -913
- package/dist/index.css +22 -278
- package/dist/index.d.mts +7 -104
- package/dist/index.d.ts +7 -104
- package/dist/index.js +2494 -5508
- package/dist/index.mjs +9 -19
- package/dist/no-external.css +22 -278
- package/dist/no-external.d.mts +2 -17
- package/dist/no-external.d.ts +2 -17
- package/dist/no-external.js +2494 -5508
- package/dist/no-external.mjs +9 -19
- package/dist/rsc.d.mts +2 -17
- package/dist/rsc.d.ts +2 -17
- package/dist/rsc.js +21 -407
- package/dist/rsc.mjs +9 -15
- package/dist/{walk-tree-Ja9bNCM9.d.mts → walk-tree-CgWnYC1X.d.mts} +3 -202
- package/dist/{walk-tree-Ja9bNCM9.d.ts → walk-tree-CgWnYC1X.d.ts} +3 -202
- package/package.json +1 -23
- package/dist/Editor-DR57V55X.mjs +0 -194
- package/dist/Editor-F2LSS6SE.css +0 -403
- package/dist/Render-6Q5WP25Y.mjs +0 -51
- package/dist/Render-QEMDIDQC.css +0 -101
- package/dist/chunk-A7EMVTSK.mjs +0 -413
- package/dist/chunk-CF5XA6LF.mjs +0 -103
- package/dist/chunk-GQ457KMA.mjs +0 -199
- package/dist/chunk-OPXWLTPM.mjs +0 -3140
- package/dist/rsc.css +0 -101
|
@@ -1,9 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
var __esm = (fn, res) => function __init() {
|
|
37
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
38
|
+
};
|
|
39
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
40
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
41
|
+
};
|
|
42
|
+
var __copyProps = (to, from, except, desc) => {
|
|
43
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
44
|
+
for (let key of __getOwnPropNames(from))
|
|
45
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
46
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
47
|
+
}
|
|
48
|
+
return to;
|
|
49
|
+
};
|
|
50
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
51
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
52
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
53
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
54
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
55
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
56
|
+
mod
|
|
57
|
+
));
|
|
58
|
+
var __async = (__this, __arguments, generator) => {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
var fulfilled = (value) => {
|
|
61
|
+
try {
|
|
62
|
+
step(generator.next(value));
|
|
63
|
+
} catch (e) {
|
|
64
|
+
reject(e);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var rejected = (value) => {
|
|
68
|
+
try {
|
|
69
|
+
step(generator.throw(value));
|
|
70
|
+
} catch (e) {
|
|
71
|
+
reject(e);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
75
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// ../tsup-config/react-import.js
|
|
80
|
+
import React from "react";
|
|
81
|
+
var init_react_import = __esm({
|
|
82
|
+
"../tsup-config/react-import.js"() {
|
|
83
|
+
"use strict";
|
|
84
|
+
}
|
|
85
|
+
});
|
|
7
86
|
|
|
8
87
|
// lib/data/walk-tree.ts
|
|
9
88
|
init_react_import();
|
|
@@ -205,34 +284,45 @@ function walkTree(data, config, callbackFn) {
|
|
|
205
284
|
};
|
|
206
285
|
}
|
|
207
286
|
|
|
208
|
-
// lib/
|
|
287
|
+
// lib/migrate.ts
|
|
209
288
|
init_react_import();
|
|
210
|
-
var rootAreaId = "root";
|
|
211
|
-
var rootZone = "default-zone";
|
|
212
|
-
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
|
213
289
|
|
|
214
|
-
//
|
|
290
|
+
// store/default-app-state.ts
|
|
215
291
|
init_react_import();
|
|
216
|
-
import flat from "flat";
|
|
217
292
|
|
|
218
|
-
//
|
|
293
|
+
// components/ViewportControls/default-viewports.ts
|
|
219
294
|
init_react_import();
|
|
220
|
-
var
|
|
221
|
-
|
|
222
|
-
}
|
|
295
|
+
var defaultViewports = [
|
|
296
|
+
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
|
297
|
+
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
|
298
|
+
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
|
299
|
+
];
|
|
223
300
|
|
|
224
|
-
//
|
|
225
|
-
var
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
301
|
+
// store/default-app-state.ts
|
|
302
|
+
var defaultAppState = {
|
|
303
|
+
data: { content: [], root: {}, zones: {} },
|
|
304
|
+
ui: {
|
|
305
|
+
leftSideBarVisible: true,
|
|
306
|
+
rightSideBarVisible: true,
|
|
307
|
+
arrayState: {},
|
|
308
|
+
itemSelector: null,
|
|
309
|
+
componentList: {},
|
|
310
|
+
isDragging: false,
|
|
311
|
+
previewMode: "edit",
|
|
312
|
+
viewports: {
|
|
313
|
+
current: {
|
|
314
|
+
width: defaultViewports[0].width,
|
|
315
|
+
height: defaultViewports[0].height || "auto"
|
|
316
|
+
},
|
|
317
|
+
options: [],
|
|
318
|
+
controlsVisible: true
|
|
319
|
+
},
|
|
320
|
+
field: { focus: null }
|
|
321
|
+
},
|
|
322
|
+
indexes: {
|
|
323
|
+
nodes: {},
|
|
324
|
+
zones: {}
|
|
325
|
+
}
|
|
236
326
|
};
|
|
237
327
|
|
|
238
328
|
// lib/data/walk-app-state.ts
|
|
@@ -243,6 +333,14 @@ init_react_import();
|
|
|
243
333
|
|
|
244
334
|
// lib/get-zone-id.ts
|
|
245
335
|
init_react_import();
|
|
336
|
+
|
|
337
|
+
// lib/root-droppable-id.ts
|
|
338
|
+
init_react_import();
|
|
339
|
+
var rootAreaId = "root";
|
|
340
|
+
var rootZone = "default-zone";
|
|
341
|
+
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
|
342
|
+
|
|
343
|
+
// lib/get-zone-id.ts
|
|
246
344
|
var getZoneId = (zoneCompound) => {
|
|
247
345
|
if (!zoneCompound) {
|
|
248
346
|
return [];
|
|
@@ -263,6 +361,30 @@ function forRelatedZones(item, data, cb, path = []) {
|
|
|
263
361
|
});
|
|
264
362
|
}
|
|
265
363
|
|
|
364
|
+
// lib/data/flatten-node.ts
|
|
365
|
+
init_react_import();
|
|
366
|
+
import flat from "flat";
|
|
367
|
+
|
|
368
|
+
// lib/data/strip-slots.ts
|
|
369
|
+
init_react_import();
|
|
370
|
+
var stripSlots = (data, config) => {
|
|
371
|
+
return mapFields(data, { slot: () => null }, config);
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
// lib/data/flatten-node.ts
|
|
375
|
+
var { flatten: flatten2, unflatten } = flat;
|
|
376
|
+
var flattenNode = (node, config) => {
|
|
377
|
+
return __spreadProps(__spreadValues({}, node), {
|
|
378
|
+
props: flatten2(stripSlots(node, config).props)
|
|
379
|
+
});
|
|
380
|
+
};
|
|
381
|
+
var expandNode = (node) => {
|
|
382
|
+
const props = unflatten(node.props);
|
|
383
|
+
return __spreadProps(__spreadValues({}, node), {
|
|
384
|
+
props
|
|
385
|
+
});
|
|
386
|
+
};
|
|
387
|
+
|
|
266
388
|
// lib/data/walk-app-state.ts
|
|
267
389
|
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
|
268
390
|
var _a;
|
|
@@ -390,26 +512,169 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
|
|
|
390
512
|
});
|
|
391
513
|
}
|
|
392
514
|
|
|
393
|
-
// lib/
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
515
|
+
// lib/migrate.ts
|
|
516
|
+
var migrations = [
|
|
517
|
+
// Migrate root to root.props
|
|
518
|
+
(data) => {
|
|
519
|
+
const rootProps = data.root.props || data.root;
|
|
520
|
+
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
|
521
|
+
console.warn(
|
|
522
|
+
"Migration applied: Root props moved from `root` to `root.props`."
|
|
523
|
+
);
|
|
524
|
+
return __spreadProps(__spreadValues({}, data), {
|
|
525
|
+
root: {
|
|
526
|
+
props: __spreadValues({}, rootProps)
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
}
|
|
397
530
|
return data;
|
|
531
|
+
},
|
|
532
|
+
// Migrate zones to slots
|
|
533
|
+
(data, config, migrationOptions) => {
|
|
534
|
+
var _a, _b;
|
|
535
|
+
if (!config) return data;
|
|
536
|
+
console.log("Migrating DropZones to slots...");
|
|
537
|
+
const updatedItems = {};
|
|
538
|
+
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
|
539
|
+
const { indexes } = walkAppState(appState, config);
|
|
540
|
+
const deletedCompounds = [];
|
|
541
|
+
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
|
542
|
+
var _a2, _b2, _c;
|
|
543
|
+
if (zoneType === "dropzone") {
|
|
544
|
+
const [id, slotName] = zoneCompound.split(":");
|
|
545
|
+
const nodeData = indexes.nodes[id].data;
|
|
546
|
+
const componentType = nodeData.type;
|
|
547
|
+
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
|
548
|
+
if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
|
|
549
|
+
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
|
550
|
+
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
|
551
|
+
[slotName]: content
|
|
552
|
+
})
|
|
553
|
+
});
|
|
554
|
+
deletedCompounds.push(zoneCompound);
|
|
555
|
+
}
|
|
556
|
+
return content;
|
|
557
|
+
}
|
|
558
|
+
return content;
|
|
559
|
+
});
|
|
560
|
+
const updated = walkAppState(
|
|
561
|
+
appState,
|
|
562
|
+
config,
|
|
563
|
+
(content) => content,
|
|
564
|
+
(item) => {
|
|
565
|
+
var _a2;
|
|
566
|
+
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
|
567
|
+
}
|
|
568
|
+
);
|
|
569
|
+
deletedCompounds.forEach((zoneCompound) => {
|
|
570
|
+
var _a2;
|
|
571
|
+
const [_, propName] = zoneCompound.split(":");
|
|
572
|
+
console.log(
|
|
573
|
+
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
|
574
|
+
);
|
|
575
|
+
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
|
576
|
+
});
|
|
577
|
+
if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
|
|
578
|
+
const unmigratedZonesGrouped = {};
|
|
579
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
580
|
+
var _a2;
|
|
581
|
+
const [componentId, propName] = zoneCompound.split(":");
|
|
582
|
+
const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
|
|
583
|
+
if (!content) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
if (!unmigratedZonesGrouped[componentId]) {
|
|
587
|
+
unmigratedZonesGrouped[componentId] = {};
|
|
588
|
+
}
|
|
589
|
+
if (!unmigratedZonesGrouped[componentId][propName]) {
|
|
590
|
+
unmigratedZonesGrouped[componentId][propName] = content;
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
|
|
594
|
+
updated.data = walkTree(updated.data, config, (content) => {
|
|
595
|
+
return content.map((child) => {
|
|
596
|
+
var _a2;
|
|
597
|
+
if (child.props.id !== componentId) {
|
|
598
|
+
return child;
|
|
599
|
+
}
|
|
600
|
+
const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
|
|
601
|
+
if (!migrateFn) {
|
|
602
|
+
return child;
|
|
603
|
+
}
|
|
604
|
+
const zones = unmigratedZonesGrouped[componentId];
|
|
605
|
+
const migratedProps = migrateFn(child.props, zones);
|
|
606
|
+
Object.keys(zones).forEach((propName) => {
|
|
607
|
+
var _a3;
|
|
608
|
+
const zoneCompound = `${componentId}:${propName}`;
|
|
609
|
+
console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
|
|
610
|
+
(_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
|
|
611
|
+
});
|
|
612
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
613
|
+
props: migratedProps
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
|
|
620
|
+
const [_, propName] = zoneCompound.split(":");
|
|
621
|
+
throw new Error(
|
|
622
|
+
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
623
|
+
);
|
|
624
|
+
});
|
|
625
|
+
delete updated.data.zones;
|
|
626
|
+
return updated.data;
|
|
398
627
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
628
|
+
];
|
|
629
|
+
function migrate(data, config, migrationOptions) {
|
|
630
|
+
return migrations == null ? void 0 : migrations.reduce(
|
|
631
|
+
(acc, migration) => migration(acc, config, migrationOptions),
|
|
632
|
+
data
|
|
633
|
+
);
|
|
634
|
+
}
|
|
405
635
|
|
|
406
|
-
//
|
|
636
|
+
// lib/transform-props.ts
|
|
637
|
+
init_react_import();
|
|
638
|
+
|
|
639
|
+
// lib/data/default-data.ts
|
|
640
|
+
init_react_import();
|
|
641
|
+
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
642
|
+
root: data.root || {},
|
|
643
|
+
content: data.content || []
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
// lib/transform-props.ts
|
|
647
|
+
function transformProps(data, propTransforms, config = { components: {} }) {
|
|
648
|
+
const mapItem = (item) => {
|
|
649
|
+
if (propTransforms[item.type]) {
|
|
650
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
651
|
+
props: __spreadValues({
|
|
652
|
+
id: item.props.id
|
|
653
|
+
}, propTransforms[item.type](item.props))
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
return item;
|
|
657
|
+
};
|
|
658
|
+
const defaultedData = defaultData(data);
|
|
659
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
|
660
|
+
let newRoot = __spreadValues({}, defaultedData.root);
|
|
661
|
+
if (propTransforms["root"]) {
|
|
662
|
+
newRoot.props = propTransforms["root"](rootProps);
|
|
663
|
+
}
|
|
664
|
+
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
|
665
|
+
const updatedData = walkTree(
|
|
666
|
+
dataWithUpdatedRoot,
|
|
667
|
+
config,
|
|
668
|
+
(content) => content.map(mapItem)
|
|
669
|
+
);
|
|
670
|
+
if (!defaultedData.root.props) {
|
|
671
|
+
updatedData.root = updatedData.root.props;
|
|
672
|
+
}
|
|
673
|
+
return updatedData;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// lib/resolve-all-data.ts
|
|
407
677
|
init_react_import();
|
|
408
|
-
var defaultViewports = [
|
|
409
|
-
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
|
410
|
-
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
|
411
|
-
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
|
412
|
-
];
|
|
413
678
|
|
|
414
679
|
// lib/resolve-component-data.ts
|
|
415
680
|
init_react_import();
|
|
@@ -491,41 +756,196 @@ var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], fun
|
|
|
491
756
|
};
|
|
492
757
|
});
|
|
493
758
|
|
|
494
|
-
//
|
|
759
|
+
// lib/data/to-component.ts
|
|
495
760
|
init_react_import();
|
|
496
|
-
var
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
761
|
+
var toComponent = (item) => {
|
|
762
|
+
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
|
763
|
+
props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
|
|
764
|
+
type: "root"
|
|
765
|
+
});
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
// lib/resolve-all-data.ts
|
|
769
|
+
function resolveAllData(_0, _1) {
|
|
770
|
+
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
|
771
|
+
var _a;
|
|
772
|
+
const defaultedData = defaultData(data);
|
|
773
|
+
const resolveNode = (_node) => __async(null, null, function* () {
|
|
774
|
+
const node = toComponent(_node);
|
|
775
|
+
onResolveStart == null ? void 0 : onResolveStart(node);
|
|
776
|
+
const resolved = (yield resolveComponentData(
|
|
777
|
+
node,
|
|
778
|
+
config,
|
|
779
|
+
metadata,
|
|
780
|
+
() => {
|
|
781
|
+
},
|
|
782
|
+
() => {
|
|
783
|
+
},
|
|
784
|
+
"force"
|
|
785
|
+
)).node;
|
|
786
|
+
const resolvedDeep = yield mapFields(
|
|
787
|
+
resolved,
|
|
788
|
+
{ slot: ({ value }) => processContent(value) },
|
|
789
|
+
config
|
|
790
|
+
);
|
|
791
|
+
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
792
|
+
return resolvedDeep;
|
|
793
|
+
});
|
|
794
|
+
const processContent = (content) => __async(null, null, function* () {
|
|
795
|
+
return Promise.all(content.map(resolveNode));
|
|
796
|
+
});
|
|
797
|
+
const processZones = () => __async(null, null, function* () {
|
|
798
|
+
var _a2;
|
|
799
|
+
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
|
800
|
+
Object.entries(zones).forEach((_02) => __async(null, [_02], function* ([zoneKey, content]) {
|
|
801
|
+
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
|
802
|
+
}));
|
|
803
|
+
return zones;
|
|
804
|
+
});
|
|
805
|
+
const dynamic = {
|
|
806
|
+
root: yield resolveNode(defaultedData.root),
|
|
807
|
+
content: yield processContent(defaultedData.content),
|
|
808
|
+
zones: yield processZones()
|
|
809
|
+
};
|
|
810
|
+
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(null, null, function* () {
|
|
811
|
+
const content = defaultedData.zones[zoneKey];
|
|
812
|
+
dynamic.zones[zoneKey] = yield processContent(content);
|
|
813
|
+
}), {});
|
|
814
|
+
return dynamic;
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
// lib/data/setup-zone.ts
|
|
819
|
+
init_react_import();
|
|
820
|
+
var setupZone = (data, zoneKey) => {
|
|
821
|
+
if (zoneKey === rootDroppableId) {
|
|
822
|
+
return data;
|
|
823
|
+
}
|
|
824
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
|
825
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
|
826
|
+
});
|
|
827
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
|
828
|
+
return newData;
|
|
829
|
+
};
|
|
830
|
+
|
|
831
|
+
// lib/field-transforms/use-field-transforms.tsx
|
|
832
|
+
init_react_import();
|
|
833
|
+
import { useMemo } from "react";
|
|
834
|
+
function useFieldTransforms(config, item, transforms, readOnly, forceReadOnly) {
|
|
835
|
+
const mappers = useMemo(() => {
|
|
836
|
+
return Object.keys(transforms).reduce((acc, _fieldType) => {
|
|
837
|
+
const fieldType = _fieldType;
|
|
838
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
839
|
+
[fieldType]: (_a) => {
|
|
840
|
+
var _b = _a, {
|
|
841
|
+
parentId
|
|
842
|
+
} = _b, params = __objRest(_b, [
|
|
843
|
+
"parentId"
|
|
844
|
+
]);
|
|
845
|
+
const wildcardPath = params.propPath.replace(/\[\d+\]/g, "[*]");
|
|
846
|
+
const isReadOnly = (readOnly == null ? void 0 : readOnly[params.propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly || false;
|
|
847
|
+
const fn = transforms[fieldType];
|
|
848
|
+
return fn == null ? void 0 : fn(__spreadProps(__spreadValues({}, params), {
|
|
849
|
+
isReadOnly,
|
|
850
|
+
componentId: parentId
|
|
851
|
+
}));
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
}, {});
|
|
855
|
+
}, [transforms, readOnly, forceReadOnly]);
|
|
856
|
+
const transformedProps = useMemo(() => {
|
|
857
|
+
const mapped = mapFields(item, mappers, config).props;
|
|
858
|
+
return mapped;
|
|
859
|
+
}, [config, item, mappers]);
|
|
860
|
+
const mergedProps = useMemo(
|
|
861
|
+
() => __spreadValues(__spreadValues({}, item.props), transformedProps),
|
|
862
|
+
[item.props, transformedProps]
|
|
863
|
+
);
|
|
864
|
+
return mergedProps;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// lib/field-transforms/default-transforms/slot-transform.tsx
|
|
868
|
+
init_react_import();
|
|
869
|
+
var getSlotTransform = (renderSlotEdit, renderSlotRender = renderSlotEdit) => ({
|
|
870
|
+
slot: ({ value: content, propName, field, isReadOnly }) => {
|
|
871
|
+
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
|
872
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
|
873
|
+
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
|
874
|
+
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
|
875
|
+
}, dzProps), {
|
|
876
|
+
zone: propName,
|
|
877
|
+
content
|
|
878
|
+
}));
|
|
879
|
+
return Slot;
|
|
519
880
|
}
|
|
881
|
+
});
|
|
882
|
+
|
|
883
|
+
// lib/use-slots.tsx
|
|
884
|
+
init_react_import();
|
|
885
|
+
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
|
886
|
+
return useFieldTransforms(
|
|
887
|
+
config,
|
|
888
|
+
item,
|
|
889
|
+
getSlotTransform(renderSlotEdit, renderSlotRender),
|
|
890
|
+
readOnly,
|
|
891
|
+
forceReadOnly
|
|
892
|
+
);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
// components/SlotRender/server.tsx
|
|
896
|
+
init_react_import();
|
|
897
|
+
import { forwardRef } from "react";
|
|
898
|
+
import { jsx } from "react/jsx-runtime";
|
|
899
|
+
var SlotRenderPure = (props) => /* @__PURE__ */ jsx(SlotRender, __spreadValues({}, props));
|
|
900
|
+
var Item = ({
|
|
901
|
+
config,
|
|
902
|
+
item,
|
|
903
|
+
metadata
|
|
904
|
+
}) => {
|
|
905
|
+
const Component = config.components[item.type];
|
|
906
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ jsx(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
907
|
+
return /* @__PURE__ */ jsx(
|
|
908
|
+
Component.render,
|
|
909
|
+
__spreadProps(__spreadValues({}, props), {
|
|
910
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
911
|
+
metadata: metadata || {}
|
|
912
|
+
})
|
|
913
|
+
})
|
|
914
|
+
);
|
|
520
915
|
};
|
|
916
|
+
var SlotRender = forwardRef(
|
|
917
|
+
function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
|
|
918
|
+
const El = as != null ? as : "div";
|
|
919
|
+
return /* @__PURE__ */ jsx(El, { className, style, ref, children: content.map((item) => {
|
|
920
|
+
if (!config.components[item.type]) {
|
|
921
|
+
return null;
|
|
922
|
+
}
|
|
923
|
+
return /* @__PURE__ */ jsx(
|
|
924
|
+
Item,
|
|
925
|
+
{
|
|
926
|
+
config,
|
|
927
|
+
item,
|
|
928
|
+
metadata
|
|
929
|
+
},
|
|
930
|
+
item.props.id
|
|
931
|
+
);
|
|
932
|
+
}) });
|
|
933
|
+
}
|
|
934
|
+
);
|
|
521
935
|
|
|
522
936
|
export {
|
|
937
|
+
__spreadValues,
|
|
938
|
+
__spreadProps,
|
|
939
|
+
__objRest,
|
|
940
|
+
__commonJS,
|
|
941
|
+
__toESM,
|
|
942
|
+
__async,
|
|
943
|
+
init_react_import,
|
|
523
944
|
rootAreaId,
|
|
524
945
|
rootZone,
|
|
525
946
|
rootDroppableId,
|
|
526
947
|
defaultSlots,
|
|
527
948
|
walkField,
|
|
528
|
-
mapFields,
|
|
529
949
|
expandNode,
|
|
530
950
|
walkAppState,
|
|
531
951
|
walkTree,
|
|
@@ -533,5 +953,14 @@ export {
|
|
|
533
953
|
defaultViewports,
|
|
534
954
|
getChanged,
|
|
535
955
|
resolveComponentData,
|
|
536
|
-
defaultAppState
|
|
956
|
+
defaultAppState,
|
|
957
|
+
useFieldTransforms,
|
|
958
|
+
getSlotTransform,
|
|
959
|
+
useSlots,
|
|
960
|
+
SlotRenderPure,
|
|
961
|
+
SlotRender,
|
|
962
|
+
toComponent,
|
|
963
|
+
migrate,
|
|
964
|
+
transformProps,
|
|
965
|
+
resolveAllData
|
|
537
966
|
};
|