@measured/puck 0.20.0-canary.68dd73b8 → 0.20.0-canary.6a211610
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-FYXJ5FPS.mjs +9040 -0
- package/dist/{chunk-H6KSTNLT.mjs → chunk-HUKJ36SA.mjs} +353 -294
- package/dist/index.css +158 -75
- package/dist/index.d.mts +16 -4
- package/dist/index.d.ts +16 -4
- package/dist/index.js +3203 -2565
- package/dist/index.mjs +29 -8436
- package/dist/no-external.css +1976 -0
- package/dist/no-external.d.mts +4 -0
- package/dist/no-external.d.ts +4 -0
- package/dist/no-external.js +9974 -0
- package/dist/no-external.mjs +56 -0
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +139 -71
- package/dist/rsc.mjs +5 -1
- package/dist/{walk-tree-BOSl1o0G.d.mts → walk-tree-B57SgEEc.d.mts} +44 -5
- package/dist/{walk-tree-BOSl1o0G.d.ts → walk-tree-B57SgEEc.d.ts} +44 -5
- package/package.json +3 -2
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Action,
|
|
3
|
+
ActionBar,
|
|
4
|
+
AutoField,
|
|
5
|
+
Button,
|
|
6
|
+
Drawer,
|
|
7
|
+
DropZone,
|
|
8
|
+
FieldLabel,
|
|
9
|
+
Group,
|
|
10
|
+
IconButton,
|
|
11
|
+
Label,
|
|
12
|
+
Puck,
|
|
13
|
+
Render,
|
|
14
|
+
createUsePuck,
|
|
15
|
+
overrideKeys,
|
|
16
|
+
registerOverlayPortal,
|
|
17
|
+
renderContext,
|
|
18
|
+
setDeep,
|
|
19
|
+
useGetPuck,
|
|
20
|
+
usePuck
|
|
21
|
+
} from "./chunk-FYXJ5FPS.mjs";
|
|
22
|
+
import {
|
|
23
|
+
init_react_import,
|
|
24
|
+
migrate,
|
|
25
|
+
resolveAllData,
|
|
26
|
+
transformProps,
|
|
27
|
+
walkTree
|
|
28
|
+
} from "./chunk-HUKJ36SA.mjs";
|
|
29
|
+
|
|
30
|
+
// bundle/no-external.ts
|
|
31
|
+
init_react_import();
|
|
32
|
+
export {
|
|
33
|
+
Action,
|
|
34
|
+
ActionBar,
|
|
35
|
+
AutoField,
|
|
36
|
+
Button,
|
|
37
|
+
Drawer,
|
|
38
|
+
DropZone,
|
|
39
|
+
FieldLabel,
|
|
40
|
+
Group,
|
|
41
|
+
IconButton,
|
|
42
|
+
Label,
|
|
43
|
+
Puck,
|
|
44
|
+
Render,
|
|
45
|
+
createUsePuck,
|
|
46
|
+
migrate,
|
|
47
|
+
overrideKeys,
|
|
48
|
+
registerOverlayPortal,
|
|
49
|
+
renderContext,
|
|
50
|
+
resolveAllData,
|
|
51
|
+
setDeep,
|
|
52
|
+
transformProps,
|
|
53
|
+
useGetPuck,
|
|
54
|
+
usePuck,
|
|
55
|
+
walkTree
|
|
56
|
+
};
|
package/dist/rsc.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
2
|
+
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-B57SgEEc.mjs';
|
|
3
|
+
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-B57SgEEc.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
package/dist/rsc.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
2
|
+
import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-B57SgEEc.js';
|
|
3
|
+
export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-B57SgEEc.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
package/dist/rsc.js
CHANGED
|
@@ -22,6 +22,18 @@ var __spreadValues = (a, b) => {
|
|
|
22
22
|
return a;
|
|
23
23
|
};
|
|
24
24
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
25
37
|
var __export = (target, all) => {
|
|
26
38
|
for (var name in all)
|
|
27
39
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -64,7 +76,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
64
76
|
});
|
|
65
77
|
};
|
|
66
78
|
|
|
67
|
-
// rsc.tsx
|
|
79
|
+
// bundle/rsc.tsx
|
|
68
80
|
var rsc_exports = {};
|
|
69
81
|
__export(rsc_exports, {
|
|
70
82
|
Render: () => Render,
|
|
@@ -95,7 +107,7 @@ var setupZone = (data, zoneKey) => {
|
|
|
95
107
|
return newData;
|
|
96
108
|
};
|
|
97
109
|
|
|
98
|
-
// lib/use-
|
|
110
|
+
// lib/field-transforms/use-field-transforms.tsx
|
|
99
111
|
var import_react2 = require("react");
|
|
100
112
|
|
|
101
113
|
// lib/data/default-slots.ts
|
|
@@ -104,14 +116,14 @@ var defaultSlots = (value, fields) => Object.keys(fields).reduce(
|
|
|
104
116
|
value
|
|
105
117
|
);
|
|
106
118
|
|
|
107
|
-
// lib/data/map-
|
|
119
|
+
// lib/data/map-fields.ts
|
|
108
120
|
var isPromise = (v) => !!v && typeof v.then === "function";
|
|
109
121
|
var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
|
|
110
122
|
var containsPromise = (arr) => arr.some(isPromise);
|
|
111
123
|
var walkField = ({
|
|
112
124
|
value,
|
|
113
125
|
fields,
|
|
114
|
-
|
|
126
|
+
mappers,
|
|
115
127
|
propKey = "",
|
|
116
128
|
propPath = "",
|
|
117
129
|
id = "",
|
|
@@ -119,7 +131,9 @@ var walkField = ({
|
|
|
119
131
|
recurseSlots = false
|
|
120
132
|
}) => {
|
|
121
133
|
var _a, _b, _c;
|
|
122
|
-
|
|
134
|
+
const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
|
|
135
|
+
const map = mappers[fieldType];
|
|
136
|
+
if (map && fieldType === "slot") {
|
|
123
137
|
const content = value || [];
|
|
124
138
|
const mappedContent = recurseSlots ? content.map((el) => {
|
|
125
139
|
var _a2;
|
|
@@ -131,7 +145,7 @@ var walkField = ({
|
|
|
131
145
|
return walkField({
|
|
132
146
|
value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
|
|
133
147
|
fields: fields2,
|
|
134
|
-
|
|
148
|
+
mappers,
|
|
135
149
|
id: el.props.id,
|
|
136
150
|
config,
|
|
137
151
|
recurseSlots
|
|
@@ -140,7 +154,21 @@ var walkField = ({
|
|
|
140
154
|
if (containsPromise(mappedContent)) {
|
|
141
155
|
return Promise.all(mappedContent);
|
|
142
156
|
}
|
|
143
|
-
return map(
|
|
157
|
+
return map({
|
|
158
|
+
value: mappedContent,
|
|
159
|
+
parentId: id,
|
|
160
|
+
propName: propKey,
|
|
161
|
+
field: fields[propKey],
|
|
162
|
+
propPath
|
|
163
|
+
});
|
|
164
|
+
} else if (map && fields[propKey]) {
|
|
165
|
+
return map({
|
|
166
|
+
value,
|
|
167
|
+
parentId: id,
|
|
168
|
+
propName: propKey,
|
|
169
|
+
field: fields[propKey],
|
|
170
|
+
propPath
|
|
171
|
+
});
|
|
144
172
|
}
|
|
145
173
|
if (value && typeof value === "object") {
|
|
146
174
|
if (Array.isArray(value)) {
|
|
@@ -150,7 +178,7 @@ var walkField = ({
|
|
|
150
178
|
(el, idx) => walkField({
|
|
151
179
|
value: el,
|
|
152
180
|
fields: arrayFields,
|
|
153
|
-
|
|
181
|
+
mappers,
|
|
154
182
|
propKey,
|
|
155
183
|
propPath: `${propPath}[${idx}]`,
|
|
156
184
|
id,
|
|
@@ -169,7 +197,7 @@ var walkField = ({
|
|
|
169
197
|
return walkObject({
|
|
170
198
|
value,
|
|
171
199
|
fields: objectFields,
|
|
172
|
-
|
|
200
|
+
mappers,
|
|
173
201
|
id,
|
|
174
202
|
getPropPath: (k) => `${propPath}.${k}`,
|
|
175
203
|
config,
|
|
@@ -182,7 +210,7 @@ var walkField = ({
|
|
|
182
210
|
var walkObject = ({
|
|
183
211
|
value,
|
|
184
212
|
fields,
|
|
185
|
-
|
|
213
|
+
mappers,
|
|
186
214
|
id,
|
|
187
215
|
getPropPath,
|
|
188
216
|
config,
|
|
@@ -192,7 +220,7 @@ var walkObject = ({
|
|
|
192
220
|
const opts = {
|
|
193
221
|
value: v,
|
|
194
222
|
fields,
|
|
195
|
-
|
|
223
|
+
mappers,
|
|
196
224
|
propKey: k,
|
|
197
225
|
propPath: getPropPath(k),
|
|
198
226
|
id,
|
|
@@ -214,14 +242,14 @@ var walkObject = ({
|
|
|
214
242
|
}
|
|
215
243
|
return flatten(newProps);
|
|
216
244
|
};
|
|
217
|
-
function
|
|
245
|
+
function mapFields(item, mappers, config, recurseSlots = false) {
|
|
218
246
|
var _a, _b, _c, _d, _e;
|
|
219
247
|
const itemType = "type" in item ? item.type : "root";
|
|
220
248
|
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
|
221
249
|
const newProps = walkObject({
|
|
222
250
|
value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
|
|
223
251
|
fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
|
|
224
|
-
|
|
252
|
+
mappers,
|
|
225
253
|
id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
|
|
226
254
|
getPropPath: (k) => k,
|
|
227
255
|
config,
|
|
@@ -237,35 +265,66 @@ function mapSlots(item, map, config, recurseSlots = false) {
|
|
|
237
265
|
});
|
|
238
266
|
}
|
|
239
267
|
|
|
240
|
-
// lib/use-
|
|
241
|
-
function
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
268
|
+
// lib/field-transforms/use-field-transforms.tsx
|
|
269
|
+
function useFieldTransforms(config, item, transforms, readOnly, forceReadOnly) {
|
|
270
|
+
const mappers = (0, import_react2.useMemo)(() => {
|
|
271
|
+
return Object.keys(transforms).reduce((acc, _fieldType) => {
|
|
272
|
+
const fieldType = _fieldType;
|
|
273
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
274
|
+
[fieldType]: (_a) => {
|
|
275
|
+
var _b = _a, {
|
|
276
|
+
parentId
|
|
277
|
+
} = _b, params = __objRest(_b, [
|
|
278
|
+
"parentId"
|
|
279
|
+
]);
|
|
280
|
+
const wildcardPath = params.propPath.replace(/\[\d+\]/g, "[*]");
|
|
281
|
+
const isReadOnly = (readOnly == null ? void 0 : readOnly[params.propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly || false;
|
|
282
|
+
const fn = transforms[fieldType];
|
|
283
|
+
return fn == null ? void 0 : fn(__spreadProps(__spreadValues({}, params), {
|
|
284
|
+
isReadOnly,
|
|
285
|
+
componentId: parentId
|
|
286
|
+
}));
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}, {});
|
|
290
|
+
}, [transforms, readOnly, forceReadOnly]);
|
|
291
|
+
const transformedProps = (0, import_react2.useMemo)(() => {
|
|
292
|
+
const mapped = mapFields(item, mappers, config).props;
|
|
260
293
|
return mapped;
|
|
261
|
-
}, [config, item,
|
|
294
|
+
}, [config, item, mappers]);
|
|
262
295
|
const mergedProps = (0, import_react2.useMemo)(
|
|
263
|
-
() => __spreadValues(__spreadValues({}, item.props),
|
|
264
|
-
[item.props,
|
|
296
|
+
() => __spreadValues(__spreadValues({}, item.props), transformedProps),
|
|
297
|
+
[item.props, transformedProps]
|
|
265
298
|
);
|
|
266
299
|
return mergedProps;
|
|
267
300
|
}
|
|
268
301
|
|
|
302
|
+
// lib/field-transforms/default-transforms/slot-transform.tsx
|
|
303
|
+
var getSlotTransform = (renderSlotEdit, renderSlotRender = renderSlotEdit) => ({
|
|
304
|
+
slot: ({ value: content, propName, field, isReadOnly }) => {
|
|
305
|
+
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
|
306
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
|
307
|
+
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
|
308
|
+
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
|
309
|
+
}, dzProps), {
|
|
310
|
+
zone: propName,
|
|
311
|
+
content
|
|
312
|
+
}));
|
|
313
|
+
return Slot;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
// lib/use-slots.tsx
|
|
318
|
+
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
|
319
|
+
return useFieldTransforms(
|
|
320
|
+
config,
|
|
321
|
+
item,
|
|
322
|
+
getSlotTransform(renderSlotEdit, renderSlotRender),
|
|
323
|
+
readOnly,
|
|
324
|
+
forceReadOnly
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
|
|
269
328
|
// components/SlotRender/server.tsx
|
|
270
329
|
var import_react3 = require("react");
|
|
271
330
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -441,24 +500,27 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
|
441
500
|
resolvedItem.readOnly = readOnly;
|
|
442
501
|
}
|
|
443
502
|
}
|
|
444
|
-
let itemWithResolvedChildren = yield
|
|
503
|
+
let itemWithResolvedChildren = yield mapFields(
|
|
445
504
|
resolvedItem,
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
content
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
505
|
+
{
|
|
506
|
+
slot: (_02) => __async(void 0, [_02], function* ({ value }) {
|
|
507
|
+
const content = value;
|
|
508
|
+
return yield Promise.all(
|
|
509
|
+
content.map(
|
|
510
|
+
(childItem) => __async(void 0, null, function* () {
|
|
511
|
+
return (yield resolveComponentData(
|
|
512
|
+
childItem,
|
|
513
|
+
config,
|
|
514
|
+
metadata,
|
|
515
|
+
onResolveStart,
|
|
516
|
+
onResolveEnd,
|
|
517
|
+
trigger
|
|
518
|
+
)).node;
|
|
519
|
+
})
|
|
520
|
+
)
|
|
521
|
+
);
|
|
522
|
+
})
|
|
523
|
+
},
|
|
462
524
|
config
|
|
463
525
|
);
|
|
464
526
|
if (shouldRunResolver && onResolveEnd) {
|
|
@@ -506,9 +568,9 @@ function resolveAllData(_0, _1) {
|
|
|
506
568
|
},
|
|
507
569
|
"force"
|
|
508
570
|
)).node;
|
|
509
|
-
const resolvedDeep = yield
|
|
571
|
+
const resolvedDeep = yield mapFields(
|
|
510
572
|
resolved,
|
|
511
|
-
processContent,
|
|
573
|
+
{ slot: ({ value }) => processContent(value) },
|
|
512
574
|
config
|
|
513
575
|
);
|
|
514
576
|
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
@@ -542,11 +604,14 @@ function resolveAllData(_0, _1) {
|
|
|
542
604
|
function walkTree(data, config, callbackFn) {
|
|
543
605
|
var _a, _b;
|
|
544
606
|
const walkItem = (item) => {
|
|
545
|
-
return
|
|
607
|
+
return mapFields(
|
|
546
608
|
item,
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
609
|
+
{
|
|
610
|
+
slot: ({ value, parentId, propName }) => {
|
|
611
|
+
var _a2;
|
|
612
|
+
const content = value;
|
|
613
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
|
614
|
+
}
|
|
550
615
|
},
|
|
551
616
|
config,
|
|
552
617
|
true
|
|
@@ -663,7 +728,7 @@ var import_flat = __toESM(require("flat"));
|
|
|
663
728
|
|
|
664
729
|
// lib/data/strip-slots.ts
|
|
665
730
|
var stripSlots = (data, config) => {
|
|
666
|
-
return
|
|
731
|
+
return mapFields(data, { slot: () => null }, config);
|
|
667
732
|
};
|
|
668
733
|
|
|
669
734
|
// lib/data/flatten-node.ts
|
|
@@ -716,18 +781,21 @@ function walkAppState(state, config, mapContent = (content) => content, mapNodeO
|
|
|
716
781
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
|
717
782
|
if (!mappedItem) return item;
|
|
718
783
|
const id = mappedItem.props.id;
|
|
719
|
-
const newProps = __spreadProps(__spreadValues({},
|
|
784
|
+
const newProps = __spreadProps(__spreadValues({}, mapFields(
|
|
720
785
|
mappedItem,
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
786
|
+
{
|
|
787
|
+
slot: ({ value, parentId: parentId2, propPath }) => {
|
|
788
|
+
const content = value;
|
|
789
|
+
const zoneCompound = `${parentId2}:${propPath}`;
|
|
790
|
+
const [_2, newContent2] = processContent(
|
|
791
|
+
path,
|
|
792
|
+
zoneCompound,
|
|
793
|
+
content,
|
|
794
|
+
"slot",
|
|
795
|
+
parentId2
|
|
796
|
+
);
|
|
797
|
+
return newContent2;
|
|
798
|
+
}
|
|
731
799
|
},
|
|
732
800
|
config
|
|
733
801
|
).props), {
|
package/dist/rsc.mjs
CHANGED
|
@@ -17,7 +17,7 @@ type DropZoneProps = {
|
|
|
17
17
|
|
|
18
18
|
type FieldOption = {
|
|
19
19
|
label: string;
|
|
20
|
-
value: string | number | boolean;
|
|
20
|
+
value: string | number | boolean | undefined | null | object;
|
|
21
21
|
};
|
|
22
22
|
type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
|
23
23
|
type BaseField = {
|
|
@@ -29,6 +29,7 @@ type BaseField = {
|
|
|
29
29
|
type TextField = BaseField & {
|
|
30
30
|
type: "text";
|
|
31
31
|
placeholder?: string;
|
|
32
|
+
contentEditable?: boolean;
|
|
32
33
|
};
|
|
33
34
|
type NumberField = BaseField & {
|
|
34
35
|
type: "number";
|
|
@@ -40,6 +41,7 @@ type NumberField = BaseField & {
|
|
|
40
41
|
type TextareaField = BaseField & {
|
|
41
42
|
type: "textarea";
|
|
42
43
|
placeholder?: string;
|
|
44
|
+
contentEditable?: boolean;
|
|
43
45
|
};
|
|
44
46
|
type SelectField = BaseField & {
|
|
45
47
|
type: "select";
|
|
@@ -117,6 +119,7 @@ type CustomFieldRender<Value extends any> = (props: {
|
|
|
117
119
|
type CustomField<Value extends any> = BaseField & {
|
|
118
120
|
type: "custom";
|
|
119
121
|
render: CustomFieldRender<Value>;
|
|
122
|
+
contentEditable?: boolean;
|
|
120
123
|
};
|
|
121
124
|
type SlotField = BaseField & {
|
|
122
125
|
type: "slot";
|
|
@@ -209,14 +212,18 @@ type WithChildren<Props> = Props & {
|
|
|
209
212
|
};
|
|
210
213
|
type ExtractPropsFromConfig<UserConfig> = UserConfig extends Config<infer P, any, any> ? P : never;
|
|
211
214
|
type ExtractRootPropsFromConfig<UserConfig> = UserConfig extends Config<any, infer P, any> ? P : never;
|
|
212
|
-
type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractPropsFromConfig<UserConfig> = ExtractPropsFromConfig<UserConfig>, UserRootProps extends ExtractRootPropsFromConfig<UserConfig> = ExtractRootPropsFromConfig<UserConfig>, UserData extends Data<UserProps, UserRootProps> | Data = Data<UserProps, UserRootProps>, UserAppState extends PrivateAppState<UserData> = PrivateAppState<UserData>, UserComponentData extends ComponentData = UserData["content"][0]> = {
|
|
215
|
+
type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractPropsFromConfig<UserConfig> = ExtractPropsFromConfig<UserConfig>, UserRootProps extends ExtractRootPropsFromConfig<UserConfig> = ExtractRootPropsFromConfig<UserConfig>, UserData extends Data<UserProps, UserRootProps> | Data = Data<UserProps, UserRootProps>, UserAppState extends PrivateAppState<UserData> = PrivateAppState<UserData>, UserPublicAppState extends AppState<UserData> = AppState<UserData>, UserComponentData extends ComponentData = UserData["content"][0]> = {
|
|
213
216
|
UserConfig: UserConfig;
|
|
214
217
|
UserProps: UserProps;
|
|
215
218
|
UserRootProps: UserRootProps;
|
|
216
219
|
UserData: UserData;
|
|
217
220
|
UserAppState: UserAppState;
|
|
221
|
+
UserPublicAppState: UserPublicAppState;
|
|
218
222
|
UserComponentData: UserComponentData;
|
|
219
223
|
};
|
|
224
|
+
type ExtractField<T extends Field["type"]> = Extract<Field, {
|
|
225
|
+
type: T;
|
|
226
|
+
}>;
|
|
220
227
|
|
|
221
228
|
type PuckContext = {
|
|
222
229
|
renderDropZone: React.FC<DropZoneProps>;
|
|
@@ -285,6 +292,8 @@ type ArrayState = {
|
|
|
285
292
|
type UiState = {
|
|
286
293
|
leftSideBarVisible: boolean;
|
|
287
294
|
rightSideBarVisible: boolean;
|
|
295
|
+
leftSideBarWidth?: number | null;
|
|
296
|
+
rightSideBarWidth?: number | null;
|
|
288
297
|
itemSelector: ItemSelector | null;
|
|
289
298
|
arrayState: Record<string, ArrayState | undefined>;
|
|
290
299
|
previewMode: "interactive" | "edit";
|
|
@@ -341,12 +350,29 @@ type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (inf
|
|
|
341
350
|
[K in keyof T]: WithDeepSlots<T[K], SlotType>;
|
|
342
351
|
} : T;
|
|
343
352
|
|
|
353
|
+
type MapFnParams<ThisField = Field> = {
|
|
354
|
+
value: any;
|
|
355
|
+
parentId: string;
|
|
356
|
+
propName: string;
|
|
357
|
+
field: ThisField;
|
|
358
|
+
propPath: string;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
type FieldTransformFnParams<T> = Omit<MapFnParams<T>, "parentId"> & {
|
|
362
|
+
isReadOnly: boolean;
|
|
363
|
+
componentId: string;
|
|
364
|
+
};
|
|
365
|
+
type FieldTransformFn<T = any> = (params: FieldTransformFnParams<T>) => any;
|
|
366
|
+
type FieldTransforms = Partial<{
|
|
367
|
+
[FieldType in Field["type"]]: FieldTransformFn<ExtractField<FieldType>>;
|
|
368
|
+
}>;
|
|
369
|
+
|
|
344
370
|
type RenderFunc<Props extends {
|
|
345
371
|
[key: string]: any;
|
|
346
372
|
} = {
|
|
347
373
|
children: ReactNode;
|
|
348
374
|
}> = (props: Props) => ReactElement;
|
|
349
|
-
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "
|
|
375
|
+
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
|
|
350
376
|
type OverrideKey = (typeof overrideKeys)[number];
|
|
351
377
|
type OverridesGeneric<Shape extends {
|
|
352
378
|
[key in OverrideKey]: any;
|
|
@@ -384,11 +410,23 @@ type Overrides = OverridesGeneric<{
|
|
|
384
410
|
children: ReactNode;
|
|
385
411
|
name: string;
|
|
386
412
|
}>;
|
|
413
|
+
drawer: RenderFunc;
|
|
414
|
+
drawerItem: RenderFunc<{
|
|
415
|
+
children: ReactNode;
|
|
416
|
+
name: string;
|
|
417
|
+
}>;
|
|
387
418
|
iframe: RenderFunc<{
|
|
388
419
|
children: ReactNode;
|
|
389
420
|
document?: Document;
|
|
390
421
|
}>;
|
|
391
422
|
outline: RenderFunc;
|
|
423
|
+
componentOverlay: RenderFunc<{
|
|
424
|
+
children: ReactNode;
|
|
425
|
+
hover: boolean;
|
|
426
|
+
isSelected: boolean;
|
|
427
|
+
componentId: string;
|
|
428
|
+
componentType: string;
|
|
429
|
+
}>;
|
|
392
430
|
puck: RenderFunc;
|
|
393
431
|
}>;
|
|
394
432
|
type FieldRenderFunctions = Omit<{
|
|
@@ -430,7 +468,8 @@ type IframeConfig = {
|
|
|
430
468
|
};
|
|
431
469
|
type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
|
|
432
470
|
type Plugin = {
|
|
433
|
-
overrides
|
|
471
|
+
overrides?: Partial<Overrides>;
|
|
472
|
+
fieldTransforms?: FieldTransforms;
|
|
434
473
|
};
|
|
435
474
|
type History<D = any> = {
|
|
436
475
|
state: D;
|
|
@@ -548,4 +587,4 @@ type WalkTreeOptions = {
|
|
|
548
587
|
};
|
|
549
588
|
declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
|
|
550
589
|
|
|
551
|
-
export { type
|
|
590
|
+
export { type NumberField as $, type AppState as A, type ArrayState as B, type Config as C, type DropZoneProps as D, type SlotComponent as E, type Fields as F, type PuckComponent as G, type History as H, type IframeConfig as I, type RootConfig as J, type BaseData as K, type RootDataWithoutProps as L, type Metadata as M, type RootData as N, type Overrides as O, type Permissions as P, type ComponentDataOptionalId as Q, type RootDataWithProps as R, type Slot as S, type MappedItem as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type ComponentDataMap as X, type Content as Y, type BaseField as Z, type TextField as _, type ComponentData as a, type TextareaField as a0, type SelectField as a1, type RadioField as a2, type ArrayField as a3, type ObjectField as a4, type Adaptor as a5, type ExternalFieldWithAdaptor as a6, type ExternalField as a7, type CustomFieldRender as a8, type CustomField as a9, type SlotField as aa, type PuckContext as ab, type DefaultRootFieldProps as ac, type DefaultRootRenderProps as ad, type DefaultRootProps as ae, type DefaultComponentProps as af, type WithId as ag, type WithPuckProps as ah, type AsFieldProps as ai, type WithChildren as aj, type ExtractPropsFromConfig as ak, type ExtractRootPropsFromConfig as al, type ExtractField as am, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type FieldTransforms as g, type Field as h, type FieldProps as i, type Data as j, type OnAction as k, type InitialHistory as l, migrate as m, type ItemSelector as n, type Direction as o, type DragAxis as p, type Viewport as q, resolveAllData as r, type FieldTransformFnParams as s, transformProps as t, type FieldTransformFn as u, overrideKeys as v, walkTree as w, type OverrideKey as x, type FieldRenderFunctions as y, type ItemWithId as z };
|