@measured/puck 0.20.0-canary.2b50fb19 → 0.20.0-canary.2ce4c22c
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-ANWTLGCS.mjs +9040 -0
- package/dist/{chunk-IAEXMHQX.mjs → chunk-HUKJ36SA.mjs} +223 -75
- package/dist/index.css +155 -74
- package/dist/index.d.mts +17 -8
- package/dist/index.d.ts +17 -8
- package/dist/index.js +1715 -1096
- package/dist/index.mjs +29 -8460
- package/dist/no-external.css +1831 -0
- package/dist/no-external.d.mts +4 -2
- package/dist/no-external.d.ts +4 -2
- package/dist/no-external.js +9949 -1
- package/dist/no-external.mjs +52 -2
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +138 -70
- package/dist/rsc.mjs +2 -4
- package/dist/{walk-tree-6p9XnDIV.d.mts → walk-tree-B57SgEEc.d.mts} +44 -5
- package/dist/{walk-tree-6p9XnDIV.d.ts → walk-tree-B57SgEEc.d.ts} +44 -5
- package/package.json +1 -1
- package/dist/chunk-M6W7YEVX.mjs +0 -95
|
@@ -1,14 +1,93 @@
|
|
|
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();
|
|
10
89
|
|
|
11
|
-
// lib/data/map-
|
|
90
|
+
// lib/data/map-fields.ts
|
|
12
91
|
init_react_import();
|
|
13
92
|
|
|
14
93
|
// lib/data/default-slots.ts
|
|
@@ -18,14 +97,14 @@ var defaultSlots = (value, fields) => Object.keys(fields).reduce(
|
|
|
18
97
|
value
|
|
19
98
|
);
|
|
20
99
|
|
|
21
|
-
// lib/data/map-
|
|
100
|
+
// lib/data/map-fields.ts
|
|
22
101
|
var isPromise = (v) => !!v && typeof v.then === "function";
|
|
23
102
|
var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
|
|
24
103
|
var containsPromise = (arr) => arr.some(isPromise);
|
|
25
104
|
var walkField = ({
|
|
26
105
|
value,
|
|
27
106
|
fields,
|
|
28
|
-
|
|
107
|
+
mappers,
|
|
29
108
|
propKey = "",
|
|
30
109
|
propPath = "",
|
|
31
110
|
id = "",
|
|
@@ -33,7 +112,9 @@ var walkField = ({
|
|
|
33
112
|
recurseSlots = false
|
|
34
113
|
}) => {
|
|
35
114
|
var _a, _b, _c;
|
|
36
|
-
|
|
115
|
+
const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
|
|
116
|
+
const map = mappers[fieldType];
|
|
117
|
+
if (map && fieldType === "slot") {
|
|
37
118
|
const content = value || [];
|
|
38
119
|
const mappedContent = recurseSlots ? content.map((el) => {
|
|
39
120
|
var _a2;
|
|
@@ -45,7 +126,7 @@ var walkField = ({
|
|
|
45
126
|
return walkField({
|
|
46
127
|
value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
|
|
47
128
|
fields: fields2,
|
|
48
|
-
|
|
129
|
+
mappers,
|
|
49
130
|
id: el.props.id,
|
|
50
131
|
config,
|
|
51
132
|
recurseSlots
|
|
@@ -54,7 +135,21 @@ var walkField = ({
|
|
|
54
135
|
if (containsPromise(mappedContent)) {
|
|
55
136
|
return Promise.all(mappedContent);
|
|
56
137
|
}
|
|
57
|
-
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
|
+
});
|
|
58
153
|
}
|
|
59
154
|
if (value && typeof value === "object") {
|
|
60
155
|
if (Array.isArray(value)) {
|
|
@@ -64,7 +159,7 @@ var walkField = ({
|
|
|
64
159
|
(el, idx) => walkField({
|
|
65
160
|
value: el,
|
|
66
161
|
fields: arrayFields,
|
|
67
|
-
|
|
162
|
+
mappers,
|
|
68
163
|
propKey,
|
|
69
164
|
propPath: `${propPath}[${idx}]`,
|
|
70
165
|
id,
|
|
@@ -83,7 +178,7 @@ var walkField = ({
|
|
|
83
178
|
return walkObject({
|
|
84
179
|
value,
|
|
85
180
|
fields: objectFields,
|
|
86
|
-
|
|
181
|
+
mappers,
|
|
87
182
|
id,
|
|
88
183
|
getPropPath: (k) => `${propPath}.${k}`,
|
|
89
184
|
config,
|
|
@@ -96,7 +191,7 @@ var walkField = ({
|
|
|
96
191
|
var walkObject = ({
|
|
97
192
|
value,
|
|
98
193
|
fields,
|
|
99
|
-
|
|
194
|
+
mappers,
|
|
100
195
|
id,
|
|
101
196
|
getPropPath,
|
|
102
197
|
config,
|
|
@@ -106,7 +201,7 @@ var walkObject = ({
|
|
|
106
201
|
const opts = {
|
|
107
202
|
value: v,
|
|
108
203
|
fields,
|
|
109
|
-
|
|
204
|
+
mappers,
|
|
110
205
|
propKey: k,
|
|
111
206
|
propPath: getPropPath(k),
|
|
112
207
|
id,
|
|
@@ -128,14 +223,14 @@ var walkObject = ({
|
|
|
128
223
|
}
|
|
129
224
|
return flatten(newProps);
|
|
130
225
|
};
|
|
131
|
-
function
|
|
226
|
+
function mapFields(item, mappers, config, recurseSlots = false) {
|
|
132
227
|
var _a, _b, _c, _d, _e;
|
|
133
228
|
const itemType = "type" in item ? item.type : "root";
|
|
134
229
|
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
|
135
230
|
const newProps = walkObject({
|
|
136
231
|
value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
|
|
137
232
|
fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
|
|
138
|
-
|
|
233
|
+
mappers,
|
|
139
234
|
id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
|
|
140
235
|
getPropPath: (k) => k,
|
|
141
236
|
config,
|
|
@@ -155,11 +250,14 @@ function mapSlots(item, map, config, recurseSlots = false) {
|
|
|
155
250
|
function walkTree(data, config, callbackFn) {
|
|
156
251
|
var _a, _b;
|
|
157
252
|
const walkItem = (item) => {
|
|
158
|
-
return
|
|
253
|
+
return mapFields(
|
|
159
254
|
item,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
255
|
+
{
|
|
256
|
+
slot: ({ value, parentId, propName }) => {
|
|
257
|
+
var _a2;
|
|
258
|
+
const content = value;
|
|
259
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
|
260
|
+
}
|
|
163
261
|
},
|
|
164
262
|
config,
|
|
165
263
|
true
|
|
@@ -210,35 +308,70 @@ var setupZone = (data, zoneKey) => {
|
|
|
210
308
|
|
|
211
309
|
// lib/use-slots.tsx
|
|
212
310
|
init_react_import();
|
|
311
|
+
|
|
312
|
+
// lib/field-transforms/use-field-transforms.tsx
|
|
313
|
+
init_react_import();
|
|
213
314
|
import { useMemo } from "react";
|
|
214
|
-
function
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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;
|
|
233
339
|
return mapped;
|
|
234
|
-
}, [config, item,
|
|
340
|
+
}, [config, item, mappers]);
|
|
235
341
|
const mergedProps = useMemo(
|
|
236
|
-
() => __spreadValues(__spreadValues({}, item.props),
|
|
237
|
-
[item.props,
|
|
342
|
+
() => __spreadValues(__spreadValues({}, item.props), transformedProps),
|
|
343
|
+
[item.props, transformedProps]
|
|
238
344
|
);
|
|
239
345
|
return mergedProps;
|
|
240
346
|
}
|
|
241
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
|
+
|
|
242
375
|
// components/SlotRender/server.tsx
|
|
243
376
|
init_react_import();
|
|
244
377
|
import { forwardRef } from "react";
|
|
@@ -451,7 +584,7 @@ import flat from "flat";
|
|
|
451
584
|
// lib/data/strip-slots.ts
|
|
452
585
|
init_react_import();
|
|
453
586
|
var stripSlots = (data, config) => {
|
|
454
|
-
return
|
|
587
|
+
return mapFields(data, { slot: () => null }, config);
|
|
455
588
|
};
|
|
456
589
|
|
|
457
590
|
// lib/data/flatten-node.ts
|
|
@@ -510,18 +643,21 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
|
|
|
510
643
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
|
511
644
|
if (!mappedItem) return item;
|
|
512
645
|
const id = mappedItem.props.id;
|
|
513
|
-
const newProps = __spreadProps(__spreadValues({},
|
|
646
|
+
const newProps = __spreadProps(__spreadValues({}, mapFields(
|
|
514
647
|
mappedItem,
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
648
|
+
{
|
|
649
|
+
slot: ({ value, parentId: parentId2, propPath }) => {
|
|
650
|
+
const content = value;
|
|
651
|
+
const zoneCompound = `${parentId2}:${propPath}`;
|
|
652
|
+
const [_2, newContent2] = processContent(
|
|
653
|
+
path,
|
|
654
|
+
zoneCompound,
|
|
655
|
+
content,
|
|
656
|
+
"slot",
|
|
657
|
+
parentId2
|
|
658
|
+
);
|
|
659
|
+
return newContent2;
|
|
660
|
+
}
|
|
525
661
|
},
|
|
526
662
|
config
|
|
527
663
|
).props), {
|
|
@@ -800,24 +936,27 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
|
800
936
|
resolvedItem.readOnly = readOnly;
|
|
801
937
|
}
|
|
802
938
|
}
|
|
803
|
-
let itemWithResolvedChildren = yield
|
|
939
|
+
let itemWithResolvedChildren = yield mapFields(
|
|
804
940
|
resolvedItem,
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
content
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
941
|
+
{
|
|
942
|
+
slot: (_02) => __async(void 0, [_02], function* ({ value }) {
|
|
943
|
+
const content = value;
|
|
944
|
+
return yield Promise.all(
|
|
945
|
+
content.map(
|
|
946
|
+
(childItem) => __async(void 0, null, function* () {
|
|
947
|
+
return (yield resolveComponentData(
|
|
948
|
+
childItem,
|
|
949
|
+
config,
|
|
950
|
+
metadata,
|
|
951
|
+
onResolveStart,
|
|
952
|
+
onResolveEnd,
|
|
953
|
+
trigger
|
|
954
|
+
)).node;
|
|
955
|
+
})
|
|
956
|
+
)
|
|
957
|
+
);
|
|
958
|
+
})
|
|
959
|
+
},
|
|
821
960
|
config
|
|
822
961
|
);
|
|
823
962
|
if (shouldRunResolver && onResolveEnd) {
|
|
@@ -860,9 +999,9 @@ function resolveAllData(_0, _1) {
|
|
|
860
999
|
},
|
|
861
1000
|
"force"
|
|
862
1001
|
)).node;
|
|
863
|
-
const resolvedDeep = yield
|
|
1002
|
+
const resolvedDeep = yield mapFields(
|
|
864
1003
|
resolved,
|
|
865
|
-
processContent,
|
|
1004
|
+
{ slot: ({ value }) => processContent(value) },
|
|
866
1005
|
config
|
|
867
1006
|
);
|
|
868
1007
|
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
@@ -893,6 +1032,13 @@ function resolveAllData(_0, _1) {
|
|
|
893
1032
|
}
|
|
894
1033
|
|
|
895
1034
|
export {
|
|
1035
|
+
__spreadValues,
|
|
1036
|
+
__spreadProps,
|
|
1037
|
+
__objRest,
|
|
1038
|
+
__commonJS,
|
|
1039
|
+
__toESM,
|
|
1040
|
+
__async,
|
|
1041
|
+
init_react_import,
|
|
896
1042
|
rootAreaId,
|
|
897
1043
|
rootZone,
|
|
898
1044
|
rootDroppableId,
|
|
@@ -906,6 +1052,8 @@ export {
|
|
|
906
1052
|
getChanged,
|
|
907
1053
|
resolveComponentData,
|
|
908
1054
|
defaultAppState,
|
|
1055
|
+
useFieldTransforms,
|
|
1056
|
+
getSlotTransform,
|
|
909
1057
|
useSlots,
|
|
910
1058
|
Render,
|
|
911
1059
|
SlotRenderPure,
|