@measured/puck 0.19.4-canary.f09540db → 0.20.0-canary.33cf4f0e
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-IM42S4YL.mjs → chunk-IAEXMHQX.mjs} +365 -412
- package/dist/chunk-M6W7YEVX.mjs +95 -0
- package/dist/index.css +3 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +780 -738
- package/dist/index.mjs +14 -9
- package/dist/no-external.css +145 -0
- package/dist/no-external.d.mts +2 -0
- package/dist/no-external.d.ts +2 -0
- package/dist/no-external.js +26 -0
- package/dist/no-external.mjs +6 -0
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +50 -8
- package/dist/rsc.mjs +7 -1
- package/dist/{walk-tree-DrJNb8b-.d.mts → walk-tree-6p9XnDIV.d.mts} +19 -27
- package/dist/{walk-tree-DrJNb8b-.d.ts → walk-tree-6p9XnDIV.d.ts} +19 -27
- package/package.json +3 -2
|
@@ -1,117 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
});
|
|
86
|
-
|
|
87
|
-
// rsc.tsx
|
|
88
|
-
init_react_import();
|
|
89
|
-
|
|
90
|
-
// components/ServerRender/index.tsx
|
|
91
|
-
init_react_import();
|
|
92
|
-
|
|
93
|
-
// lib/root-droppable-id.ts
|
|
94
|
-
init_react_import();
|
|
95
|
-
var rootAreaId = "root";
|
|
96
|
-
var rootZone = "default-zone";
|
|
97
|
-
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
|
98
|
-
|
|
99
|
-
// lib/data/setup-zone.ts
|
|
100
|
-
init_react_import();
|
|
101
|
-
var setupZone = (data, zoneKey) => {
|
|
102
|
-
if (zoneKey === rootDroppableId) {
|
|
103
|
-
return data;
|
|
104
|
-
}
|
|
105
|
-
const newData = __spreadProps(__spreadValues({}, data), {
|
|
106
|
-
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
|
107
|
-
});
|
|
108
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
|
109
|
-
return newData;
|
|
110
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
__async,
|
|
3
|
+
__spreadProps,
|
|
4
|
+
__spreadValues,
|
|
5
|
+
init_react_import
|
|
6
|
+
} from "./chunk-M6W7YEVX.mjs";
|
|
111
7
|
|
|
112
|
-
// lib/
|
|
8
|
+
// lib/data/walk-tree.ts
|
|
113
9
|
init_react_import();
|
|
114
|
-
import { useMemo } from "react";
|
|
115
10
|
|
|
116
11
|
// lib/data/map-slots.ts
|
|
117
12
|
init_react_import();
|
|
@@ -256,7 +151,66 @@ function mapSlots(item, map, config, recurseSlots = false) {
|
|
|
256
151
|
});
|
|
257
152
|
}
|
|
258
153
|
|
|
154
|
+
// lib/data/walk-tree.ts
|
|
155
|
+
function walkTree(data, config, callbackFn) {
|
|
156
|
+
var _a, _b;
|
|
157
|
+
const walkItem = (item) => {
|
|
158
|
+
return mapSlots(
|
|
159
|
+
item,
|
|
160
|
+
(content, parentId, propName) => {
|
|
161
|
+
var _a2;
|
|
162
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
|
163
|
+
},
|
|
164
|
+
config,
|
|
165
|
+
true
|
|
166
|
+
);
|
|
167
|
+
};
|
|
168
|
+
if ("props" in data) {
|
|
169
|
+
return walkItem(data);
|
|
170
|
+
}
|
|
171
|
+
const _data = data;
|
|
172
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
|
173
|
+
const mappedContent = _data.content.map(walkItem);
|
|
174
|
+
return {
|
|
175
|
+
root: walkItem(_data.root),
|
|
176
|
+
content: (_b = callbackFn(mappedContent, {
|
|
177
|
+
parentId: "root",
|
|
178
|
+
propName: "default-zone"
|
|
179
|
+
})) != null ? _b : mappedContent,
|
|
180
|
+
zones: Object.keys(zones).reduce(
|
|
181
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
|
182
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
|
183
|
+
}),
|
|
184
|
+
{}
|
|
185
|
+
)
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// components/ServerRender/index.tsx
|
|
190
|
+
init_react_import();
|
|
191
|
+
|
|
192
|
+
// lib/root-droppable-id.ts
|
|
193
|
+
init_react_import();
|
|
194
|
+
var rootAreaId = "root";
|
|
195
|
+
var rootZone = "default-zone";
|
|
196
|
+
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
|
197
|
+
|
|
198
|
+
// lib/data/setup-zone.ts
|
|
199
|
+
init_react_import();
|
|
200
|
+
var setupZone = (data, zoneKey) => {
|
|
201
|
+
if (zoneKey === rootDroppableId) {
|
|
202
|
+
return data;
|
|
203
|
+
}
|
|
204
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
|
205
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
|
206
|
+
});
|
|
207
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
|
208
|
+
return newData;
|
|
209
|
+
};
|
|
210
|
+
|
|
259
211
|
// lib/use-slots.tsx
|
|
212
|
+
init_react_import();
|
|
213
|
+
import { useMemo } from "react";
|
|
260
214
|
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
|
261
215
|
const slotProps = useMemo(() => {
|
|
262
216
|
const mapped = mapSlots(
|
|
@@ -421,298 +375,83 @@ function Render({
|
|
|
421
375
|
);
|
|
422
376
|
}
|
|
423
377
|
|
|
424
|
-
// lib/
|
|
378
|
+
// lib/migrate.ts
|
|
425
379
|
init_react_import();
|
|
426
380
|
|
|
427
|
-
//
|
|
381
|
+
// store/default-app-state.ts
|
|
428
382
|
init_react_import();
|
|
429
383
|
|
|
430
|
-
//
|
|
384
|
+
// components/ViewportControls/default-viewports.ts
|
|
431
385
|
init_react_import();
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
386
|
+
var defaultViewports = [
|
|
387
|
+
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
|
388
|
+
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
|
389
|
+
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
|
390
|
+
];
|
|
391
|
+
|
|
392
|
+
// store/default-app-state.ts
|
|
393
|
+
var defaultAppState = {
|
|
394
|
+
data: { content: [], root: {}, zones: {} },
|
|
395
|
+
ui: {
|
|
396
|
+
leftSideBarVisible: true,
|
|
397
|
+
rightSideBarVisible: true,
|
|
398
|
+
arrayState: {},
|
|
399
|
+
itemSelector: null,
|
|
400
|
+
componentList: {},
|
|
401
|
+
isDragging: false,
|
|
402
|
+
previewMode: "edit",
|
|
403
|
+
viewports: {
|
|
404
|
+
current: {
|
|
405
|
+
width: defaultViewports[0].width,
|
|
406
|
+
height: defaultViewports[0].height || "auto"
|
|
407
|
+
},
|
|
408
|
+
options: [],
|
|
409
|
+
controlsVisible: true
|
|
410
|
+
},
|
|
411
|
+
field: { focus: null }
|
|
412
|
+
},
|
|
413
|
+
indexes: {
|
|
414
|
+
nodes: {},
|
|
415
|
+
zones: {}
|
|
416
|
+
}
|
|
441
417
|
};
|
|
442
418
|
|
|
443
|
-
// lib/
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
return { node: resolved, didChange: false };
|
|
455
|
-
}
|
|
456
|
-
const changed = getChanged(item, oldItem);
|
|
457
|
-
if (onResolveStart) {
|
|
458
|
-
onResolveStart(item);
|
|
459
|
-
}
|
|
460
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
|
461
|
-
changed,
|
|
462
|
-
lastData: oldItem,
|
|
463
|
-
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
|
464
|
-
trigger
|
|
465
|
-
});
|
|
466
|
-
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
|
467
|
-
if (Object.keys(readOnly).length) {
|
|
468
|
-
resolvedItem.readOnly = readOnly;
|
|
469
|
-
}
|
|
419
|
+
// lib/data/walk-app-state.ts
|
|
420
|
+
init_react_import();
|
|
421
|
+
|
|
422
|
+
// lib/data/for-related-zones.ts
|
|
423
|
+
init_react_import();
|
|
424
|
+
|
|
425
|
+
// lib/get-zone-id.ts
|
|
426
|
+
init_react_import();
|
|
427
|
+
var getZoneId = (zoneCompound) => {
|
|
428
|
+
if (!zoneCompound) {
|
|
429
|
+
return [];
|
|
470
430
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
(content) => __async(void 0, null, function* () {
|
|
474
|
-
return yield Promise.all(
|
|
475
|
-
content.map(
|
|
476
|
-
(childItem) => __async(void 0, null, function* () {
|
|
477
|
-
return (yield resolveComponentData(
|
|
478
|
-
childItem,
|
|
479
|
-
config,
|
|
480
|
-
metadata,
|
|
481
|
-
onResolveStart,
|
|
482
|
-
onResolveEnd,
|
|
483
|
-
trigger
|
|
484
|
-
)).node;
|
|
485
|
-
})
|
|
486
|
-
)
|
|
487
|
-
);
|
|
488
|
-
}),
|
|
489
|
-
config
|
|
490
|
-
);
|
|
491
|
-
if (shouldRunResolver && onResolveEnd) {
|
|
492
|
-
onResolveEnd(resolvedItem);
|
|
431
|
+
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
|
432
|
+
return zoneCompound.split(":");
|
|
493
433
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
resolved: itemWithResolvedChildren
|
|
497
|
-
};
|
|
498
|
-
return {
|
|
499
|
-
node: itemWithResolvedChildren,
|
|
500
|
-
didChange: !fdeq2(item, itemWithResolvedChildren)
|
|
501
|
-
};
|
|
502
|
-
});
|
|
434
|
+
return [rootDroppableId, zoneCompound];
|
|
435
|
+
};
|
|
503
436
|
|
|
504
|
-
// lib/data/
|
|
437
|
+
// lib/data/for-related-zones.ts
|
|
438
|
+
function forRelatedZones(item, data, cb, path = []) {
|
|
439
|
+
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
|
440
|
+
const [parentId] = getZoneId(zoneCompound);
|
|
441
|
+
if (parentId === item.props.id) {
|
|
442
|
+
cb(path, zoneCompound, content);
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// lib/data/flatten-node.ts
|
|
505
448
|
init_react_import();
|
|
506
|
-
|
|
507
|
-
root: data.root || {},
|
|
508
|
-
content: data.content || []
|
|
509
|
-
});
|
|
449
|
+
import flat from "flat";
|
|
510
450
|
|
|
511
|
-
// lib/data/
|
|
451
|
+
// lib/data/strip-slots.ts
|
|
512
452
|
init_react_import();
|
|
513
|
-
var
|
|
514
|
-
return
|
|
515
|
-
props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
|
|
516
|
-
type: "root"
|
|
517
|
-
});
|
|
518
|
-
};
|
|
519
|
-
|
|
520
|
-
// lib/resolve-all-data.ts
|
|
521
|
-
function resolveAllData(_0, _1) {
|
|
522
|
-
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
|
523
|
-
var _a;
|
|
524
|
-
const defaultedData = defaultData(data);
|
|
525
|
-
const resolveNode = (_node) => __async(this, null, function* () {
|
|
526
|
-
const node = toComponent(_node);
|
|
527
|
-
onResolveStart == null ? void 0 : onResolveStart(node);
|
|
528
|
-
const resolved = (yield resolveComponentData(
|
|
529
|
-
node,
|
|
530
|
-
config,
|
|
531
|
-
metadata,
|
|
532
|
-
() => {
|
|
533
|
-
},
|
|
534
|
-
() => {
|
|
535
|
-
},
|
|
536
|
-
"force"
|
|
537
|
-
)).node;
|
|
538
|
-
const resolvedDeep = yield mapSlots(
|
|
539
|
-
resolved,
|
|
540
|
-
processContent,
|
|
541
|
-
config
|
|
542
|
-
);
|
|
543
|
-
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
544
|
-
return resolvedDeep;
|
|
545
|
-
});
|
|
546
|
-
const processContent = (content) => __async(this, null, function* () {
|
|
547
|
-
return Promise.all(content.map(resolveNode));
|
|
548
|
-
});
|
|
549
|
-
const processZones = () => __async(this, null, function* () {
|
|
550
|
-
var _a2;
|
|
551
|
-
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
|
552
|
-
Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
|
|
553
|
-
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
|
554
|
-
}));
|
|
555
|
-
return zones;
|
|
556
|
-
});
|
|
557
|
-
const dynamic = {
|
|
558
|
-
root: yield resolveNode(defaultedData.root),
|
|
559
|
-
content: yield processContent(defaultedData.content),
|
|
560
|
-
zones: yield processZones()
|
|
561
|
-
};
|
|
562
|
-
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
|
|
563
|
-
const content = defaultedData.zones[zoneKey];
|
|
564
|
-
dynamic.zones[zoneKey] = yield processContent(content);
|
|
565
|
-
}), {});
|
|
566
|
-
return dynamic;
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
// lib/transform-props.ts
|
|
571
|
-
init_react_import();
|
|
572
|
-
|
|
573
|
-
// lib/data/walk-tree.ts
|
|
574
|
-
init_react_import();
|
|
575
|
-
function walkTree(data, config, callbackFn) {
|
|
576
|
-
var _a, _b;
|
|
577
|
-
const walkItem = (item) => {
|
|
578
|
-
return mapSlots(
|
|
579
|
-
item,
|
|
580
|
-
(content, parentId, propName) => {
|
|
581
|
-
var _a2;
|
|
582
|
-
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
|
583
|
-
},
|
|
584
|
-
config,
|
|
585
|
-
true
|
|
586
|
-
);
|
|
587
|
-
};
|
|
588
|
-
if ("props" in data) {
|
|
589
|
-
return walkItem(data);
|
|
590
|
-
}
|
|
591
|
-
const _data = data;
|
|
592
|
-
const zones = (_a = _data.zones) != null ? _a : {};
|
|
593
|
-
const mappedContent = _data.content.map(walkItem);
|
|
594
|
-
return {
|
|
595
|
-
root: walkItem(_data.root),
|
|
596
|
-
content: (_b = callbackFn(mappedContent, {
|
|
597
|
-
parentId: "root",
|
|
598
|
-
propName: "default-zone"
|
|
599
|
-
})) != null ? _b : mappedContent,
|
|
600
|
-
zones: Object.keys(zones).reduce(
|
|
601
|
-
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
|
602
|
-
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
|
603
|
-
}),
|
|
604
|
-
{}
|
|
605
|
-
)
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
// lib/transform-props.ts
|
|
610
|
-
function transformProps(data, propTransforms, config = { components: {} }) {
|
|
611
|
-
const mapItem = (item) => {
|
|
612
|
-
if (propTransforms[item.type]) {
|
|
613
|
-
return __spreadProps(__spreadValues({}, item), {
|
|
614
|
-
props: __spreadValues({
|
|
615
|
-
id: item.props.id
|
|
616
|
-
}, propTransforms[item.type](item.props))
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
return item;
|
|
620
|
-
};
|
|
621
|
-
const defaultedData = defaultData(data);
|
|
622
|
-
const rootProps = defaultedData.root.props || defaultedData.root;
|
|
623
|
-
let newRoot = __spreadValues({}, defaultedData.root);
|
|
624
|
-
if (propTransforms["root"]) {
|
|
625
|
-
newRoot.props = propTransforms["root"](rootProps);
|
|
626
|
-
}
|
|
627
|
-
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
|
628
|
-
const updatedData = walkTree(
|
|
629
|
-
dataWithUpdatedRoot,
|
|
630
|
-
config,
|
|
631
|
-
(content) => content.map(mapItem)
|
|
632
|
-
);
|
|
633
|
-
if (!defaultedData.root.props) {
|
|
634
|
-
updatedData.root = updatedData.root.props;
|
|
635
|
-
}
|
|
636
|
-
return updatedData;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
// lib/migrate.ts
|
|
640
|
-
init_react_import();
|
|
641
|
-
|
|
642
|
-
// store/default-app-state.ts
|
|
643
|
-
init_react_import();
|
|
644
|
-
|
|
645
|
-
// components/ViewportControls/default-viewports.ts
|
|
646
|
-
init_react_import();
|
|
647
|
-
var defaultViewports = [
|
|
648
|
-
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
|
649
|
-
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
|
650
|
-
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
|
651
|
-
];
|
|
652
|
-
|
|
653
|
-
// store/default-app-state.ts
|
|
654
|
-
var defaultAppState = {
|
|
655
|
-
data: { content: [], root: {}, zones: {} },
|
|
656
|
-
ui: {
|
|
657
|
-
leftSideBarVisible: true,
|
|
658
|
-
rightSideBarVisible: true,
|
|
659
|
-
arrayState: {},
|
|
660
|
-
itemSelector: null,
|
|
661
|
-
componentList: {},
|
|
662
|
-
isDragging: false,
|
|
663
|
-
previewMode: "edit",
|
|
664
|
-
viewports: {
|
|
665
|
-
current: {
|
|
666
|
-
width: defaultViewports[0].width,
|
|
667
|
-
height: defaultViewports[0].height || "auto"
|
|
668
|
-
},
|
|
669
|
-
options: [],
|
|
670
|
-
controlsVisible: true
|
|
671
|
-
},
|
|
672
|
-
field: { focus: null }
|
|
673
|
-
},
|
|
674
|
-
indexes: {
|
|
675
|
-
nodes: {},
|
|
676
|
-
zones: {}
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
|
-
|
|
680
|
-
// lib/data/walk-app-state.ts
|
|
681
|
-
init_react_import();
|
|
682
|
-
|
|
683
|
-
// lib/data/for-related-zones.ts
|
|
684
|
-
init_react_import();
|
|
685
|
-
|
|
686
|
-
// lib/get-zone-id.ts
|
|
687
|
-
init_react_import();
|
|
688
|
-
var getZoneId = (zoneCompound) => {
|
|
689
|
-
if (!zoneCompound) {
|
|
690
|
-
return [];
|
|
691
|
-
}
|
|
692
|
-
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
|
693
|
-
return zoneCompound.split(":");
|
|
694
|
-
}
|
|
695
|
-
return [rootDroppableId, zoneCompound];
|
|
696
|
-
};
|
|
697
|
-
|
|
698
|
-
// lib/data/for-related-zones.ts
|
|
699
|
-
function forRelatedZones(item, data, cb, path = []) {
|
|
700
|
-
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
|
701
|
-
const [parentId] = getZoneId(zoneCompound);
|
|
702
|
-
if (parentId === item.props.id) {
|
|
703
|
-
cb(path, zoneCompound, content);
|
|
704
|
-
}
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
// lib/data/flatten-node.ts
|
|
709
|
-
init_react_import();
|
|
710
|
-
import flat from "flat";
|
|
711
|
-
|
|
712
|
-
// lib/data/strip-slots.ts
|
|
713
|
-
init_react_import();
|
|
714
|
-
var stripSlots = (data, config) => {
|
|
715
|
-
return mapSlots(data, () => null, config);
|
|
453
|
+
var stripSlots = (data, config) => {
|
|
454
|
+
return mapSlots(data, () => null, config);
|
|
716
455
|
};
|
|
717
456
|
|
|
718
457
|
// lib/data/flatten-node.ts
|
|
@@ -871,8 +610,8 @@ var migrations = [
|
|
|
871
610
|
return data;
|
|
872
611
|
},
|
|
873
612
|
// Migrate zones to slots
|
|
874
|
-
(data, config) => {
|
|
875
|
-
var _a;
|
|
613
|
+
(data, config, migrationOptions) => {
|
|
614
|
+
var _a, _b;
|
|
876
615
|
if (!config) return data;
|
|
877
616
|
console.log("Migrating DropZones to slots...");
|
|
878
617
|
const updatedItems = {};
|
|
@@ -880,13 +619,13 @@ var migrations = [
|
|
|
880
619
|
const { indexes } = walkAppState(appState, config);
|
|
881
620
|
const deletedCompounds = [];
|
|
882
621
|
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
|
883
|
-
var _a2,
|
|
622
|
+
var _a2, _b2, _c;
|
|
884
623
|
if (zoneType === "dropzone") {
|
|
885
624
|
const [id, slotName] = zoneCompound.split(":");
|
|
886
625
|
const nodeData = indexes.nodes[id].data;
|
|
887
626
|
const componentType = nodeData.type;
|
|
888
627
|
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
|
889
|
-
if (((
|
|
628
|
+
if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
|
|
890
629
|
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
|
891
630
|
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
|
892
631
|
[slotName]: content
|
|
@@ -915,7 +654,49 @@ var migrations = [
|
|
|
915
654
|
);
|
|
916
655
|
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
|
917
656
|
});
|
|
918
|
-
|
|
657
|
+
if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
|
|
658
|
+
const unmigratedZonesGrouped = {};
|
|
659
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
660
|
+
var _a2;
|
|
661
|
+
const [componentId, propName] = zoneCompound.split(":");
|
|
662
|
+
const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
|
|
663
|
+
if (!content) {
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
if (!unmigratedZonesGrouped[componentId]) {
|
|
667
|
+
unmigratedZonesGrouped[componentId] = {};
|
|
668
|
+
}
|
|
669
|
+
if (!unmigratedZonesGrouped[componentId][propName]) {
|
|
670
|
+
unmigratedZonesGrouped[componentId][propName] = content;
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
|
|
674
|
+
updated.data = walkTree(updated.data, config, (content) => {
|
|
675
|
+
return content.map((child) => {
|
|
676
|
+
var _a2;
|
|
677
|
+
if (child.props.id !== componentId) {
|
|
678
|
+
return child;
|
|
679
|
+
}
|
|
680
|
+
const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
|
|
681
|
+
if (!migrateFn) {
|
|
682
|
+
return child;
|
|
683
|
+
}
|
|
684
|
+
const zones = unmigratedZonesGrouped[componentId];
|
|
685
|
+
const migratedProps = migrateFn(child.props, zones);
|
|
686
|
+
Object.keys(zones).forEach((propName) => {
|
|
687
|
+
var _a3;
|
|
688
|
+
const zoneCompound = `${componentId}:${propName}`;
|
|
689
|
+
console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
|
|
690
|
+
(_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
|
|
691
|
+
});
|
|
692
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
693
|
+
props: migratedProps
|
|
694
|
+
});
|
|
695
|
+
});
|
|
696
|
+
});
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
|
|
919
700
|
const [_, propName] = zoneCompound.split(":");
|
|
920
701
|
throw new Error(
|
|
921
702
|
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
@@ -925,21 +706,193 @@ var migrations = [
|
|
|
925
706
|
return updated.data;
|
|
926
707
|
}
|
|
927
708
|
];
|
|
928
|
-
function migrate(data, config) {
|
|
709
|
+
function migrate(data, config, migrationOptions) {
|
|
929
710
|
return migrations == null ? void 0 : migrations.reduce(
|
|
930
|
-
(acc, migration) => migration(acc, config),
|
|
711
|
+
(acc, migration) => migration(acc, config, migrationOptions),
|
|
931
712
|
data
|
|
932
713
|
);
|
|
933
714
|
}
|
|
934
715
|
|
|
716
|
+
// lib/transform-props.ts
|
|
717
|
+
init_react_import();
|
|
718
|
+
|
|
719
|
+
// lib/data/default-data.ts
|
|
720
|
+
init_react_import();
|
|
721
|
+
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
722
|
+
root: data.root || {},
|
|
723
|
+
content: data.content || []
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
// lib/transform-props.ts
|
|
727
|
+
function transformProps(data, propTransforms, config = { components: {} }) {
|
|
728
|
+
const mapItem = (item) => {
|
|
729
|
+
if (propTransforms[item.type]) {
|
|
730
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
731
|
+
props: __spreadValues({
|
|
732
|
+
id: item.props.id
|
|
733
|
+
}, propTransforms[item.type](item.props))
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
return item;
|
|
737
|
+
};
|
|
738
|
+
const defaultedData = defaultData(data);
|
|
739
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
|
740
|
+
let newRoot = __spreadValues({}, defaultedData.root);
|
|
741
|
+
if (propTransforms["root"]) {
|
|
742
|
+
newRoot.props = propTransforms["root"](rootProps);
|
|
743
|
+
}
|
|
744
|
+
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
|
745
|
+
const updatedData = walkTree(
|
|
746
|
+
dataWithUpdatedRoot,
|
|
747
|
+
config,
|
|
748
|
+
(content) => content.map(mapItem)
|
|
749
|
+
);
|
|
750
|
+
if (!defaultedData.root.props) {
|
|
751
|
+
updatedData.root = updatedData.root.props;
|
|
752
|
+
}
|
|
753
|
+
return updatedData;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// lib/resolve-all-data.ts
|
|
757
|
+
init_react_import();
|
|
758
|
+
|
|
759
|
+
// lib/resolve-component-data.ts
|
|
760
|
+
init_react_import();
|
|
761
|
+
|
|
762
|
+
// lib/get-changed.ts
|
|
763
|
+
init_react_import();
|
|
764
|
+
import fdeq from "fast-deep-equal";
|
|
765
|
+
var getChanged = (newItem, oldItem) => {
|
|
766
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
|
767
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
|
768
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
|
769
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
770
|
+
[item]: !fdeq(oldItemProps[item], newItemProps[item])
|
|
771
|
+
});
|
|
772
|
+
}, {}) : {};
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
// lib/resolve-component-data.ts
|
|
776
|
+
import fdeq2 from "fast-deep-equal";
|
|
777
|
+
var cache = { lastChange: {} };
|
|
778
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
|
779
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
780
|
+
const resolvedItem = __spreadValues({}, item);
|
|
781
|
+
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
|
782
|
+
const id = "id" in item.props ? item.props.id : "root";
|
|
783
|
+
if (shouldRunResolver) {
|
|
784
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
|
785
|
+
if (item && fdeq2(item, oldItem)) {
|
|
786
|
+
return { node: resolved, didChange: false };
|
|
787
|
+
}
|
|
788
|
+
const changed = getChanged(item, oldItem);
|
|
789
|
+
if (onResolveStart) {
|
|
790
|
+
onResolveStart(item);
|
|
791
|
+
}
|
|
792
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
|
793
|
+
changed,
|
|
794
|
+
lastData: oldItem,
|
|
795
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
|
796
|
+
trigger
|
|
797
|
+
});
|
|
798
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
|
799
|
+
if (Object.keys(readOnly).length) {
|
|
800
|
+
resolvedItem.readOnly = readOnly;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
let itemWithResolvedChildren = yield mapSlots(
|
|
804
|
+
resolvedItem,
|
|
805
|
+
(content) => __async(void 0, null, function* () {
|
|
806
|
+
return yield Promise.all(
|
|
807
|
+
content.map(
|
|
808
|
+
(childItem) => __async(void 0, null, function* () {
|
|
809
|
+
return (yield resolveComponentData(
|
|
810
|
+
childItem,
|
|
811
|
+
config,
|
|
812
|
+
metadata,
|
|
813
|
+
onResolveStart,
|
|
814
|
+
onResolveEnd,
|
|
815
|
+
trigger
|
|
816
|
+
)).node;
|
|
817
|
+
})
|
|
818
|
+
)
|
|
819
|
+
);
|
|
820
|
+
}),
|
|
821
|
+
config
|
|
822
|
+
);
|
|
823
|
+
if (shouldRunResolver && onResolveEnd) {
|
|
824
|
+
onResolveEnd(resolvedItem);
|
|
825
|
+
}
|
|
826
|
+
cache.lastChange[id] = {
|
|
827
|
+
item,
|
|
828
|
+
resolved: itemWithResolvedChildren
|
|
829
|
+
};
|
|
830
|
+
return {
|
|
831
|
+
node: itemWithResolvedChildren,
|
|
832
|
+
didChange: !fdeq2(item, itemWithResolvedChildren)
|
|
833
|
+
};
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
// lib/data/to-component.ts
|
|
837
|
+
init_react_import();
|
|
838
|
+
var toComponent = (item) => {
|
|
839
|
+
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
|
840
|
+
props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
|
|
841
|
+
type: "root"
|
|
842
|
+
});
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
// lib/resolve-all-data.ts
|
|
846
|
+
function resolveAllData(_0, _1) {
|
|
847
|
+
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
|
848
|
+
var _a;
|
|
849
|
+
const defaultedData = defaultData(data);
|
|
850
|
+
const resolveNode = (_node) => __async(this, null, function* () {
|
|
851
|
+
const node = toComponent(_node);
|
|
852
|
+
onResolveStart == null ? void 0 : onResolveStart(node);
|
|
853
|
+
const resolved = (yield resolveComponentData(
|
|
854
|
+
node,
|
|
855
|
+
config,
|
|
856
|
+
metadata,
|
|
857
|
+
() => {
|
|
858
|
+
},
|
|
859
|
+
() => {
|
|
860
|
+
},
|
|
861
|
+
"force"
|
|
862
|
+
)).node;
|
|
863
|
+
const resolvedDeep = yield mapSlots(
|
|
864
|
+
resolved,
|
|
865
|
+
processContent,
|
|
866
|
+
config
|
|
867
|
+
);
|
|
868
|
+
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
869
|
+
return resolvedDeep;
|
|
870
|
+
});
|
|
871
|
+
const processContent = (content) => __async(this, null, function* () {
|
|
872
|
+
return Promise.all(content.map(resolveNode));
|
|
873
|
+
});
|
|
874
|
+
const processZones = () => __async(this, null, function* () {
|
|
875
|
+
var _a2;
|
|
876
|
+
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
|
877
|
+
Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
|
|
878
|
+
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
|
879
|
+
}));
|
|
880
|
+
return zones;
|
|
881
|
+
});
|
|
882
|
+
const dynamic = {
|
|
883
|
+
root: yield resolveNode(defaultedData.root),
|
|
884
|
+
content: yield processContent(defaultedData.content),
|
|
885
|
+
zones: yield processZones()
|
|
886
|
+
};
|
|
887
|
+
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
|
|
888
|
+
const content = defaultedData.zones[zoneKey];
|
|
889
|
+
dynamic.zones[zoneKey] = yield processContent(content);
|
|
890
|
+
}), {});
|
|
891
|
+
return dynamic;
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
|
|
935
895
|
export {
|
|
936
|
-
__spreadValues,
|
|
937
|
-
__spreadProps,
|
|
938
|
-
__objRest,
|
|
939
|
-
__commonJS,
|
|
940
|
-
__toESM,
|
|
941
|
-
__async,
|
|
942
|
-
init_react_import,
|
|
943
896
|
rootAreaId,
|
|
944
897
|
rootZone,
|
|
945
898
|
rootDroppableId,
|
|
@@ -949,15 +902,15 @@ export {
|
|
|
949
902
|
walkAppState,
|
|
950
903
|
walkTree,
|
|
951
904
|
setupZone,
|
|
905
|
+
defaultViewports,
|
|
906
|
+
getChanged,
|
|
907
|
+
resolveComponentData,
|
|
908
|
+
defaultAppState,
|
|
952
909
|
useSlots,
|
|
910
|
+
Render,
|
|
953
911
|
SlotRenderPure,
|
|
954
912
|
SlotRender,
|
|
955
|
-
|
|
956
|
-
getChanged,
|
|
957
|
-
resolveComponentData,
|
|
958
|
-
resolveAllData,
|
|
913
|
+
migrate,
|
|
959
914
|
transformProps,
|
|
960
|
-
|
|
961
|
-
defaultAppState,
|
|
962
|
-
migrate
|
|
915
|
+
resolveAllData
|
|
963
916
|
};
|