@measured/puck 0.20.0-canary.93d525c5 → 0.20.0-canary.aee5fc96
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/README.md +9 -9
- package/dist/{chunk-H6KSTNLT.mjs → chunk-BNXRZWNI.mjs} +355 -295
- package/dist/chunk-UTM42U4O.mjs +9568 -0
- package/dist/index.css +719 -314
- package/dist/index.d.mts +29 -11
- package/dist/index.d.ts +29 -11
- package/dist/index.js +5344 -4204
- package/dist/index.mjs +35 -8456
- package/dist/no-external.css +2298 -0
- package/dist/no-external.d.mts +4 -0
- package/dist/no-external.d.ts +4 -0
- package/dist/no-external.js +10496 -0
- package/dist/no-external.mjs +62 -0
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +141 -72
- package/dist/rsc.mjs +5 -1
- package/dist/{walk-tree-BOSl1o0G.d.mts → walk-tree-CU8Fq-KC.d.mts} +56 -6
- package/dist/{walk-tree-BOSl1o0G.d.ts → walk-tree-CU8Fq-KC.d.ts} +56 -6
- package/package.json +3 -2
|
@@ -84,36 +84,10 @@ var init_react_import = __esm({
|
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
//
|
|
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
|
-
};
|
|
111
|
-
|
|
112
|
-
// lib/use-slots.tsx
|
|
87
|
+
// lib/data/walk-tree.ts
|
|
113
88
|
init_react_import();
|
|
114
|
-
import { useMemo } from "react";
|
|
115
89
|
|
|
116
|
-
// lib/data/map-
|
|
90
|
+
// lib/data/map-fields.ts
|
|
117
91
|
init_react_import();
|
|
118
92
|
|
|
119
93
|
// lib/data/default-slots.ts
|
|
@@ -123,14 +97,14 @@ var defaultSlots = (value, fields) => Object.keys(fields).reduce(
|
|
|
123
97
|
value
|
|
124
98
|
);
|
|
125
99
|
|
|
126
|
-
// lib/data/map-
|
|
100
|
+
// lib/data/map-fields.ts
|
|
127
101
|
var isPromise = (v) => !!v && typeof v.then === "function";
|
|
128
102
|
var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
|
|
129
103
|
var containsPromise = (arr) => arr.some(isPromise);
|
|
130
104
|
var walkField = ({
|
|
131
105
|
value,
|
|
132
106
|
fields,
|
|
133
|
-
|
|
107
|
+
mappers,
|
|
134
108
|
propKey = "",
|
|
135
109
|
propPath = "",
|
|
136
110
|
id = "",
|
|
@@ -138,7 +112,9 @@ var walkField = ({
|
|
|
138
112
|
recurseSlots = false
|
|
139
113
|
}) => {
|
|
140
114
|
var _a, _b, _c;
|
|
141
|
-
|
|
115
|
+
const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
|
|
116
|
+
const map = mappers[fieldType];
|
|
117
|
+
if (map && fieldType === "slot") {
|
|
142
118
|
const content = value || [];
|
|
143
119
|
const mappedContent = recurseSlots ? content.map((el) => {
|
|
144
120
|
var _a2;
|
|
@@ -150,7 +126,7 @@ var walkField = ({
|
|
|
150
126
|
return walkField({
|
|
151
127
|
value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
|
|
152
128
|
fields: fields2,
|
|
153
|
-
|
|
129
|
+
mappers,
|
|
154
130
|
id: el.props.id,
|
|
155
131
|
config,
|
|
156
132
|
recurseSlots
|
|
@@ -159,7 +135,21 @@ var walkField = ({
|
|
|
159
135
|
if (containsPromise(mappedContent)) {
|
|
160
136
|
return Promise.all(mappedContent);
|
|
161
137
|
}
|
|
162
|
-
return map(
|
|
138
|
+
return map({
|
|
139
|
+
value: mappedContent,
|
|
140
|
+
parentId: id,
|
|
141
|
+
propName: propKey,
|
|
142
|
+
field: fields[propKey],
|
|
143
|
+
propPath
|
|
144
|
+
});
|
|
145
|
+
} else if (map && fields[propKey]) {
|
|
146
|
+
return map({
|
|
147
|
+
value,
|
|
148
|
+
parentId: id,
|
|
149
|
+
propName: propKey,
|
|
150
|
+
field: fields[propKey],
|
|
151
|
+
propPath
|
|
152
|
+
});
|
|
163
153
|
}
|
|
164
154
|
if (value && typeof value === "object") {
|
|
165
155
|
if (Array.isArray(value)) {
|
|
@@ -169,7 +159,7 @@ var walkField = ({
|
|
|
169
159
|
(el, idx) => walkField({
|
|
170
160
|
value: el,
|
|
171
161
|
fields: arrayFields,
|
|
172
|
-
|
|
162
|
+
mappers,
|
|
173
163
|
propKey,
|
|
174
164
|
propPath: `${propPath}[${idx}]`,
|
|
175
165
|
id,
|
|
@@ -188,7 +178,7 @@ var walkField = ({
|
|
|
188
178
|
return walkObject({
|
|
189
179
|
value,
|
|
190
180
|
fields: objectFields,
|
|
191
|
-
|
|
181
|
+
mappers,
|
|
192
182
|
id,
|
|
193
183
|
getPropPath: (k) => `${propPath}.${k}`,
|
|
194
184
|
config,
|
|
@@ -201,7 +191,7 @@ var walkField = ({
|
|
|
201
191
|
var walkObject = ({
|
|
202
192
|
value,
|
|
203
193
|
fields,
|
|
204
|
-
|
|
194
|
+
mappers,
|
|
205
195
|
id,
|
|
206
196
|
getPropPath,
|
|
207
197
|
config,
|
|
@@ -211,7 +201,7 @@ var walkObject = ({
|
|
|
211
201
|
const opts = {
|
|
212
202
|
value: v,
|
|
213
203
|
fields,
|
|
214
|
-
|
|
204
|
+
mappers,
|
|
215
205
|
propKey: k,
|
|
216
206
|
propPath: getPropPath(k),
|
|
217
207
|
id,
|
|
@@ -233,14 +223,14 @@ var walkObject = ({
|
|
|
233
223
|
}
|
|
234
224
|
return flatten(newProps);
|
|
235
225
|
};
|
|
236
|
-
function
|
|
226
|
+
function mapFields(item, mappers, config, recurseSlots = false) {
|
|
237
227
|
var _a, _b, _c, _d, _e;
|
|
238
228
|
const itemType = "type" in item ? item.type : "root";
|
|
239
229
|
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
|
240
230
|
const newProps = walkObject({
|
|
241
231
|
value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
|
|
242
232
|
fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
|
|
243
|
-
|
|
233
|
+
mappers,
|
|
244
234
|
id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
|
|
245
235
|
getPropPath: (k) => k,
|
|
246
236
|
config,
|
|
@@ -256,35 +246,132 @@ function mapSlots(item, map, config, recurseSlots = false) {
|
|
|
256
246
|
});
|
|
257
247
|
}
|
|
258
248
|
|
|
259
|
-
// lib/
|
|
260
|
-
function
|
|
261
|
-
|
|
262
|
-
|
|
249
|
+
// lib/data/walk-tree.ts
|
|
250
|
+
function walkTree(data, config, callbackFn) {
|
|
251
|
+
var _a, _b;
|
|
252
|
+
const walkItem = (item) => {
|
|
253
|
+
return mapFields(
|
|
263
254
|
item,
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
|
271
|
-
}, dzProps), {
|
|
272
|
-
zone: propName,
|
|
273
|
-
content
|
|
274
|
-
}));
|
|
275
|
-
return Slot;
|
|
255
|
+
{
|
|
256
|
+
slot: ({ value, parentId, propName }) => {
|
|
257
|
+
var _a2;
|
|
258
|
+
const content = value;
|
|
259
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
|
260
|
+
}
|
|
276
261
|
},
|
|
277
|
-
config
|
|
278
|
-
|
|
262
|
+
config,
|
|
263
|
+
true
|
|
264
|
+
);
|
|
265
|
+
};
|
|
266
|
+
if ("props" in data) {
|
|
267
|
+
return walkItem(data);
|
|
268
|
+
}
|
|
269
|
+
const _data = data;
|
|
270
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
|
271
|
+
const mappedContent = _data.content.map(walkItem);
|
|
272
|
+
return {
|
|
273
|
+
root: walkItem(_data.root),
|
|
274
|
+
content: (_b = callbackFn(mappedContent, {
|
|
275
|
+
parentId: "root",
|
|
276
|
+
propName: "default-zone"
|
|
277
|
+
})) != null ? _b : mappedContent,
|
|
278
|
+
zones: Object.keys(zones).reduce(
|
|
279
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
|
280
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
|
281
|
+
}),
|
|
282
|
+
{}
|
|
283
|
+
)
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// components/ServerRender/index.tsx
|
|
288
|
+
init_react_import();
|
|
289
|
+
|
|
290
|
+
// lib/root-droppable-id.ts
|
|
291
|
+
init_react_import();
|
|
292
|
+
var rootAreaId = "root";
|
|
293
|
+
var rootZone = "default-zone";
|
|
294
|
+
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
|
295
|
+
|
|
296
|
+
// lib/data/setup-zone.ts
|
|
297
|
+
init_react_import();
|
|
298
|
+
var setupZone = (data, zoneKey) => {
|
|
299
|
+
if (zoneKey === rootDroppableId) {
|
|
300
|
+
return data;
|
|
301
|
+
}
|
|
302
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
|
303
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
|
304
|
+
});
|
|
305
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
|
306
|
+
return newData;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
// lib/use-slots.tsx
|
|
310
|
+
init_react_import();
|
|
311
|
+
|
|
312
|
+
// lib/field-transforms/use-field-transforms.tsx
|
|
313
|
+
init_react_import();
|
|
314
|
+
import { useMemo } from "react";
|
|
315
|
+
function useFieldTransforms(config, item, transforms, readOnly, forceReadOnly) {
|
|
316
|
+
const mappers = useMemo(() => {
|
|
317
|
+
return Object.keys(transforms).reduce((acc, _fieldType) => {
|
|
318
|
+
const fieldType = _fieldType;
|
|
319
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
320
|
+
[fieldType]: (_a) => {
|
|
321
|
+
var _b = _a, {
|
|
322
|
+
parentId
|
|
323
|
+
} = _b, params = __objRest(_b, [
|
|
324
|
+
"parentId"
|
|
325
|
+
]);
|
|
326
|
+
const wildcardPath = params.propPath.replace(/\[\d+\]/g, "[*]");
|
|
327
|
+
const isReadOnly = (readOnly == null ? void 0 : readOnly[params.propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly || false;
|
|
328
|
+
const fn = transforms[fieldType];
|
|
329
|
+
return fn == null ? void 0 : fn(__spreadProps(__spreadValues({}, params), {
|
|
330
|
+
isReadOnly,
|
|
331
|
+
componentId: parentId
|
|
332
|
+
}));
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
}, {});
|
|
336
|
+
}, [transforms, readOnly, forceReadOnly]);
|
|
337
|
+
const transformedProps = useMemo(() => {
|
|
338
|
+
const mapped = mapFields(item, mappers, config).props;
|
|
279
339
|
return mapped;
|
|
280
|
-
}, [config, item,
|
|
340
|
+
}, [config, item, mappers]);
|
|
281
341
|
const mergedProps = useMemo(
|
|
282
|
-
() => __spreadValues(__spreadValues({}, item.props),
|
|
283
|
-
[item.props,
|
|
342
|
+
() => __spreadValues(__spreadValues({}, item.props), transformedProps),
|
|
343
|
+
[item.props, transformedProps]
|
|
284
344
|
);
|
|
285
345
|
return mergedProps;
|
|
286
346
|
}
|
|
287
347
|
|
|
348
|
+
// lib/field-transforms/default-transforms/slot-transform.tsx
|
|
349
|
+
init_react_import();
|
|
350
|
+
var getSlotTransform = (renderSlotEdit, renderSlotRender = renderSlotEdit) => ({
|
|
351
|
+
slot: ({ value: content, propName, field, isReadOnly }) => {
|
|
352
|
+
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
|
353
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
|
354
|
+
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
|
355
|
+
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
|
356
|
+
}, dzProps), {
|
|
357
|
+
zone: propName,
|
|
358
|
+
content
|
|
359
|
+
}));
|
|
360
|
+
return Slot;
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// lib/use-slots.tsx
|
|
365
|
+
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
|
366
|
+
return useFieldTransforms(
|
|
367
|
+
config,
|
|
368
|
+
item,
|
|
369
|
+
getSlotTransform(renderSlotEdit, renderSlotRender),
|
|
370
|
+
readOnly,
|
|
371
|
+
forceReadOnly
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
|
|
288
375
|
// components/SlotRender/server.tsx
|
|
289
376
|
init_react_import();
|
|
290
377
|
import { forwardRef } from "react";
|
|
@@ -421,221 +508,6 @@ function Render({
|
|
|
421
508
|
);
|
|
422
509
|
}
|
|
423
510
|
|
|
424
|
-
// lib/resolve-all-data.ts
|
|
425
|
-
init_react_import();
|
|
426
|
-
|
|
427
|
-
// lib/resolve-component-data.ts
|
|
428
|
-
init_react_import();
|
|
429
|
-
|
|
430
|
-
// lib/get-changed.ts
|
|
431
|
-
init_react_import();
|
|
432
|
-
import fdeq from "fast-deep-equal";
|
|
433
|
-
var getChanged = (newItem, oldItem) => {
|
|
434
|
-
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
|
435
|
-
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
|
436
|
-
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
|
437
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
438
|
-
[item]: !fdeq(oldItemProps[item], newItemProps[item])
|
|
439
|
-
});
|
|
440
|
-
}, {}) : {};
|
|
441
|
-
};
|
|
442
|
-
|
|
443
|
-
// lib/resolve-component-data.ts
|
|
444
|
-
import fdeq2 from "fast-deep-equal";
|
|
445
|
-
var cache = { lastChange: {} };
|
|
446
|
-
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
|
447
|
-
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
448
|
-
const resolvedItem = __spreadValues({}, item);
|
|
449
|
-
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
|
450
|
-
const id = "id" in item.props ? item.props.id : "root";
|
|
451
|
-
if (shouldRunResolver) {
|
|
452
|
-
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
|
453
|
-
if (item && fdeq2(item, oldItem)) {
|
|
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
|
-
}
|
|
470
|
-
}
|
|
471
|
-
let itemWithResolvedChildren = yield mapSlots(
|
|
472
|
-
resolvedItem,
|
|
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);
|
|
493
|
-
}
|
|
494
|
-
cache.lastChange[id] = {
|
|
495
|
-
item,
|
|
496
|
-
resolved: itemWithResolvedChildren
|
|
497
|
-
};
|
|
498
|
-
return {
|
|
499
|
-
node: itemWithResolvedChildren,
|
|
500
|
-
didChange: !fdeq2(item, itemWithResolvedChildren)
|
|
501
|
-
};
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
// lib/data/default-data.ts
|
|
505
|
-
init_react_import();
|
|
506
|
-
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
507
|
-
root: data.root || {},
|
|
508
|
-
content: data.content || []
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
// lib/data/to-component.ts
|
|
512
|
-
init_react_import();
|
|
513
|
-
var toComponent = (item) => {
|
|
514
|
-
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
|
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
511
|
// lib/migrate.ts
|
|
640
512
|
init_react_import();
|
|
641
513
|
|
|
@@ -669,7 +541,8 @@ var defaultAppState = {
|
|
|
669
541
|
options: [],
|
|
670
542
|
controlsVisible: true
|
|
671
543
|
},
|
|
672
|
-
field: { focus: null }
|
|
544
|
+
field: { focus: null },
|
|
545
|
+
plugin: { current: null }
|
|
673
546
|
},
|
|
674
547
|
indexes: {
|
|
675
548
|
nodes: {},
|
|
@@ -712,7 +585,7 @@ import flat from "flat";
|
|
|
712
585
|
// lib/data/strip-slots.ts
|
|
713
586
|
init_react_import();
|
|
714
587
|
var stripSlots = (data, config) => {
|
|
715
|
-
return
|
|
588
|
+
return mapFields(data, { slot: () => null }, config);
|
|
716
589
|
};
|
|
717
590
|
|
|
718
591
|
// lib/data/flatten-node.ts
|
|
@@ -771,18 +644,21 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
|
|
|
771
644
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
|
772
645
|
if (!mappedItem) return item;
|
|
773
646
|
const id = mappedItem.props.id;
|
|
774
|
-
const newProps = __spreadProps(__spreadValues({},
|
|
647
|
+
const newProps = __spreadProps(__spreadValues({}, mapFields(
|
|
775
648
|
mappedItem,
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
649
|
+
{
|
|
650
|
+
slot: ({ value, parentId: parentId2, propPath }) => {
|
|
651
|
+
const content = value;
|
|
652
|
+
const zoneCompound = `${parentId2}:${propPath}`;
|
|
653
|
+
const [_2, newContent2] = processContent(
|
|
654
|
+
path,
|
|
655
|
+
zoneCompound,
|
|
656
|
+
content,
|
|
657
|
+
"slot",
|
|
658
|
+
parentId2
|
|
659
|
+
);
|
|
660
|
+
return newContent2;
|
|
661
|
+
}
|
|
786
662
|
},
|
|
787
663
|
config
|
|
788
664
|
).props), {
|
|
@@ -974,6 +850,188 @@ function migrate(data, config, migrationOptions) {
|
|
|
974
850
|
);
|
|
975
851
|
}
|
|
976
852
|
|
|
853
|
+
// lib/transform-props.ts
|
|
854
|
+
init_react_import();
|
|
855
|
+
|
|
856
|
+
// lib/data/default-data.ts
|
|
857
|
+
init_react_import();
|
|
858
|
+
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
859
|
+
root: data.root || {},
|
|
860
|
+
content: data.content || []
|
|
861
|
+
});
|
|
862
|
+
|
|
863
|
+
// lib/transform-props.ts
|
|
864
|
+
function transformProps(data, propTransforms, config = { components: {} }) {
|
|
865
|
+
const mapItem = (item) => {
|
|
866
|
+
if (propTransforms[item.type]) {
|
|
867
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
868
|
+
props: __spreadValues({
|
|
869
|
+
id: item.props.id
|
|
870
|
+
}, propTransforms[item.type](item.props))
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
return item;
|
|
874
|
+
};
|
|
875
|
+
const defaultedData = defaultData(data);
|
|
876
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
|
877
|
+
let newRoot = __spreadValues({}, defaultedData.root);
|
|
878
|
+
if (propTransforms["root"]) {
|
|
879
|
+
newRoot.props = propTransforms["root"](rootProps);
|
|
880
|
+
}
|
|
881
|
+
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
|
882
|
+
const updatedData = walkTree(
|
|
883
|
+
dataWithUpdatedRoot,
|
|
884
|
+
config,
|
|
885
|
+
(content) => content.map(mapItem)
|
|
886
|
+
);
|
|
887
|
+
if (!defaultedData.root.props) {
|
|
888
|
+
updatedData.root = updatedData.root.props;
|
|
889
|
+
}
|
|
890
|
+
return updatedData;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
// lib/resolve-all-data.ts
|
|
894
|
+
init_react_import();
|
|
895
|
+
|
|
896
|
+
// lib/resolve-component-data.ts
|
|
897
|
+
init_react_import();
|
|
898
|
+
|
|
899
|
+
// lib/get-changed.ts
|
|
900
|
+
init_react_import();
|
|
901
|
+
import fdeq from "fast-deep-equal";
|
|
902
|
+
var getChanged = (newItem, oldItem) => {
|
|
903
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
|
904
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
|
905
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
|
906
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
907
|
+
[item]: !fdeq(oldItemProps[item], newItemProps[item])
|
|
908
|
+
});
|
|
909
|
+
}, {}) : {};
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
// lib/resolve-component-data.ts
|
|
913
|
+
import fdeq2 from "fast-deep-equal";
|
|
914
|
+
var cache = { lastChange: {} };
|
|
915
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
|
916
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
917
|
+
const resolvedItem = __spreadValues({}, item);
|
|
918
|
+
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
|
919
|
+
const id = "id" in item.props ? item.props.id : "root";
|
|
920
|
+
if (shouldRunResolver) {
|
|
921
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
|
922
|
+
if (item && fdeq2(item, oldItem)) {
|
|
923
|
+
return { node: resolved, didChange: false };
|
|
924
|
+
}
|
|
925
|
+
const changed = getChanged(item, oldItem);
|
|
926
|
+
if (onResolveStart) {
|
|
927
|
+
onResolveStart(item);
|
|
928
|
+
}
|
|
929
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
|
930
|
+
changed,
|
|
931
|
+
lastData: oldItem,
|
|
932
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
|
933
|
+
trigger
|
|
934
|
+
});
|
|
935
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
|
936
|
+
if (Object.keys(readOnly).length) {
|
|
937
|
+
resolvedItem.readOnly = readOnly;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
let itemWithResolvedChildren = yield mapFields(
|
|
941
|
+
resolvedItem,
|
|
942
|
+
{
|
|
943
|
+
slot: (_02) => __async(void 0, [_02], function* ({ value }) {
|
|
944
|
+
const content = value;
|
|
945
|
+
return yield Promise.all(
|
|
946
|
+
content.map(
|
|
947
|
+
(childItem) => __async(void 0, null, function* () {
|
|
948
|
+
return (yield resolveComponentData(
|
|
949
|
+
childItem,
|
|
950
|
+
config,
|
|
951
|
+
metadata,
|
|
952
|
+
onResolveStart,
|
|
953
|
+
onResolveEnd,
|
|
954
|
+
trigger
|
|
955
|
+
)).node;
|
|
956
|
+
})
|
|
957
|
+
)
|
|
958
|
+
);
|
|
959
|
+
})
|
|
960
|
+
},
|
|
961
|
+
config
|
|
962
|
+
);
|
|
963
|
+
if (shouldRunResolver && onResolveEnd) {
|
|
964
|
+
onResolveEnd(resolvedItem);
|
|
965
|
+
}
|
|
966
|
+
cache.lastChange[id] = {
|
|
967
|
+
item,
|
|
968
|
+
resolved: itemWithResolvedChildren
|
|
969
|
+
};
|
|
970
|
+
return {
|
|
971
|
+
node: itemWithResolvedChildren,
|
|
972
|
+
didChange: !fdeq2(item, itemWithResolvedChildren)
|
|
973
|
+
};
|
|
974
|
+
});
|
|
975
|
+
|
|
976
|
+
// lib/data/to-component.ts
|
|
977
|
+
init_react_import();
|
|
978
|
+
var toComponent = (item) => {
|
|
979
|
+
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
|
980
|
+
props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
|
|
981
|
+
type: "root"
|
|
982
|
+
});
|
|
983
|
+
};
|
|
984
|
+
|
|
985
|
+
// lib/resolve-all-data.ts
|
|
986
|
+
function resolveAllData(_0, _1) {
|
|
987
|
+
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
|
988
|
+
var _a;
|
|
989
|
+
const defaultedData = defaultData(data);
|
|
990
|
+
const resolveNode = (_node) => __async(this, null, function* () {
|
|
991
|
+
const node = toComponent(_node);
|
|
992
|
+
onResolveStart == null ? void 0 : onResolveStart(node);
|
|
993
|
+
const resolved = (yield resolveComponentData(
|
|
994
|
+
node,
|
|
995
|
+
config,
|
|
996
|
+
metadata,
|
|
997
|
+
() => {
|
|
998
|
+
},
|
|
999
|
+
() => {
|
|
1000
|
+
},
|
|
1001
|
+
"force"
|
|
1002
|
+
)).node;
|
|
1003
|
+
const resolvedDeep = yield mapFields(
|
|
1004
|
+
resolved,
|
|
1005
|
+
{ slot: ({ value }) => processContent(value) },
|
|
1006
|
+
config
|
|
1007
|
+
);
|
|
1008
|
+
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
1009
|
+
return resolvedDeep;
|
|
1010
|
+
});
|
|
1011
|
+
const processContent = (content) => __async(this, null, function* () {
|
|
1012
|
+
return Promise.all(content.map(resolveNode));
|
|
1013
|
+
});
|
|
1014
|
+
const processZones = () => __async(this, null, function* () {
|
|
1015
|
+
var _a2;
|
|
1016
|
+
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
|
1017
|
+
Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
|
|
1018
|
+
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
|
1019
|
+
}));
|
|
1020
|
+
return zones;
|
|
1021
|
+
});
|
|
1022
|
+
const dynamic = {
|
|
1023
|
+
root: yield resolveNode(defaultedData.root),
|
|
1024
|
+
content: yield processContent(defaultedData.content),
|
|
1025
|
+
zones: yield processZones()
|
|
1026
|
+
};
|
|
1027
|
+
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
|
|
1028
|
+
const content = defaultedData.zones[zoneKey];
|
|
1029
|
+
dynamic.zones[zoneKey] = yield processContent(content);
|
|
1030
|
+
}), {});
|
|
1031
|
+
return dynamic;
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
|
|
977
1035
|
export {
|
|
978
1036
|
__spreadValues,
|
|
979
1037
|
__spreadProps,
|
|
@@ -991,15 +1049,17 @@ export {
|
|
|
991
1049
|
walkAppState,
|
|
992
1050
|
walkTree,
|
|
993
1051
|
setupZone,
|
|
1052
|
+
defaultViewports,
|
|
1053
|
+
getChanged,
|
|
1054
|
+
resolveComponentData,
|
|
1055
|
+
defaultAppState,
|
|
1056
|
+
useFieldTransforms,
|
|
1057
|
+
getSlotTransform,
|
|
994
1058
|
useSlots,
|
|
1059
|
+
Render,
|
|
995
1060
|
SlotRenderPure,
|
|
996
1061
|
SlotRender,
|
|
997
|
-
|
|
998
|
-
getChanged,
|
|
999
|
-
resolveComponentData,
|
|
1000
|
-
resolveAllData,
|
|
1062
|
+
migrate,
|
|
1001
1063
|
transformProps,
|
|
1002
|
-
|
|
1003
|
-
defaultAppState,
|
|
1004
|
-
migrate
|
|
1064
|
+
resolveAllData
|
|
1005
1065
|
};
|