@prismicio/types-internal 3.11.0 → 3.11.1
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/lib/customtypes/CustomType.js +9 -8
- package/lib/customtypes/Section.js +7 -6
- package/lib/customtypes/widgets/Group.js +43 -45
- package/lib/customtypes/widgets/slices/CompositeSlice.js +13 -18
- package/lib/customtypes/widgets/slices/SharedSlice.js +36 -43
- package/lib/customtypes/widgets/slices/Slices.js +46 -47
- package/package.json +1 -1
- package/src/customtypes/CustomType.ts +11 -10
- package/src/customtypes/Section.ts +8 -6
- package/src/customtypes/widgets/Group.ts +47 -52
- package/src/customtypes/widgets/slices/CompositeSlice.ts +15 -26
- package/src/customtypes/widgets/slices/SharedSlice.ts +41 -46
- package/src/customtypes/widgets/slices/Slices.ts +49 -50
- package/lib/content/fields/nestable/RichTextContent/Block.d.ts +0 -1036
- package/lib/content/fields/nestable/RichTextContent/Block.js +0 -31
- package/lib/content/fields/nestable/RichTextContent/EmbedBlock.d.ts +0 -60
- package/lib/content/fields/nestable/RichTextContent/EmbedBlock.js +0 -53
- package/lib/content/fields/nestable/RichTextContent/ImageBlock.d.ts +0 -203
- package/lib/content/fields/nestable/RichTextContent/ImageBlock.js +0 -36
- package/lib/content/fields/nestable/RichTextContent/TableBlock.d.ts +0 -500
- package/lib/content/fields/nestable/RichTextContent/TableBlock.js +0 -21
- package/lib/content/fields/nestable/RichTextContent/TextBlock.d.ts +0 -590
- package/lib/content/fields/nestable/RichTextContent/TextBlock.js +0 -80
|
@@ -165,16 +165,17 @@ function collectSharedSlices(customType) {
|
|
|
165
165
|
exports.collectSharedSlices = collectSharedSlices;
|
|
166
166
|
function traverseCustomType(args) {
|
|
167
167
|
const { customType, onField } = args;
|
|
168
|
+
const json = {};
|
|
169
|
+
for (const [key, section] of Object.entries(customType.json)) {
|
|
170
|
+
json[key] = (0, Section_1.traverseSection)({
|
|
171
|
+
path: [key],
|
|
172
|
+
section,
|
|
173
|
+
onField,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
168
176
|
return {
|
|
169
177
|
...customType,
|
|
170
|
-
json
|
|
171
|
-
acc[key] = (0, Section_1.traverseSection)({
|
|
172
|
-
path: [key],
|
|
173
|
-
section,
|
|
174
|
-
onField,
|
|
175
|
-
});
|
|
176
|
-
return acc;
|
|
177
|
-
}, {}),
|
|
178
|
+
json,
|
|
178
179
|
};
|
|
179
180
|
}
|
|
180
181
|
exports.traverseCustomType = traverseCustomType;
|
|
@@ -21,9 +21,10 @@ exports.Sections = {
|
|
|
21
21
|
},
|
|
22
22
|
};
|
|
23
23
|
function traverseSection(args) {
|
|
24
|
-
const { path: prevPath, section, onField } = args;
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const { path: prevPath, section: prevSection, onField } = args;
|
|
25
|
+
const section = { ...prevSection };
|
|
26
|
+
for (const [key, prevModel] of Object.entries(prevSection)) {
|
|
27
|
+
const path = [...prevPath, key];
|
|
27
28
|
let model;
|
|
28
29
|
switch (prevModel.type) {
|
|
29
30
|
case "Choice":
|
|
@@ -53,8 +54,8 @@ function traverseSection(args) {
|
|
|
53
54
|
});
|
|
54
55
|
break;
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
section[key] = model;
|
|
58
|
+
}
|
|
59
|
+
return section;
|
|
59
60
|
}
|
|
60
61
|
exports.traverseSection = traverseSection;
|
|
@@ -34,61 +34,59 @@ exports.Group = createGroup(t.union([NestableWidget_1.NestableWidget, exports.Ne
|
|
|
34
34
|
function traverseNestedGroup(args) {
|
|
35
35
|
var _a;
|
|
36
36
|
const { path: prevPath, group, onField } = args;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
37
|
+
if (!((_a = group.config) === null || _a === void 0 ? void 0 : _a.fields))
|
|
38
|
+
return group;
|
|
39
|
+
const fields = {};
|
|
40
|
+
for (const [key, prevField] of Object.entries(group.config.fields)) {
|
|
41
|
+
const path = [...prevPath, key];
|
|
42
|
+
fields[key] = onField({
|
|
43
|
+
path,
|
|
44
|
+
key,
|
|
45
|
+
field: prevField,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
47
48
|
return {
|
|
48
49
|
...group,
|
|
49
|
-
|
|
50
|
-
config
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
}),
|
|
50
|
+
config: {
|
|
51
|
+
...group.config,
|
|
52
|
+
fields,
|
|
53
|
+
},
|
|
55
54
|
};
|
|
56
55
|
}
|
|
57
56
|
exports.traverseNestedGroup = traverseNestedGroup;
|
|
58
57
|
function traverseGroup(args) {
|
|
59
58
|
var _a;
|
|
60
59
|
const { path: prevPath, group, onField } = args;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
60
|
+
if (!((_a = group.config) === null || _a === void 0 ? void 0 : _a.fields))
|
|
61
|
+
return group;
|
|
62
|
+
const fields = {};
|
|
63
|
+
for (const [key, prevField] of Object.entries(group.config.fields)) {
|
|
64
|
+
const path = [...prevPath, key];
|
|
65
|
+
let field;
|
|
66
|
+
switch (prevField.type) {
|
|
67
|
+
case "Group":
|
|
68
|
+
field = traverseNestedGroup({
|
|
69
|
+
path,
|
|
70
|
+
group: prevField,
|
|
71
|
+
onField: onField,
|
|
72
|
+
});
|
|
73
|
+
break;
|
|
74
|
+
default:
|
|
75
|
+
field = prevField;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
fields[key] = onField({
|
|
79
|
+
path,
|
|
80
|
+
key,
|
|
81
|
+
field,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
84
|
return {
|
|
85
85
|
...group,
|
|
86
|
-
|
|
87
|
-
config
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
}),
|
|
86
|
+
config: {
|
|
87
|
+
...group.config,
|
|
88
|
+
fields,
|
|
89
|
+
},
|
|
92
90
|
};
|
|
93
91
|
}
|
|
94
92
|
exports.traverseGroup = traverseGroup;
|
|
@@ -29,27 +29,22 @@ function isCompositeSlice(slice) {
|
|
|
29
29
|
}
|
|
30
30
|
exports.isCompositeSlice = isCompositeSlice;
|
|
31
31
|
function traverseCompositeSlice(args) {
|
|
32
|
+
var _a, _b;
|
|
32
33
|
const { path: prevPath, slice, onField } = args;
|
|
33
|
-
const nonRepeat =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return acc;
|
|
44
|
-
}, {});
|
|
34
|
+
const nonRepeat = {};
|
|
35
|
+
for (const [key, field] of Object.entries((_a = slice["non-repeat"]) !== null && _a !== void 0 ? _a : {})) {
|
|
36
|
+
const path = [...prevPath, "non-repeat", key];
|
|
37
|
+
nonRepeat[key] = onField({ path, key, field });
|
|
38
|
+
}
|
|
39
|
+
const repeat = {};
|
|
40
|
+
for (const [key, field] of Object.entries((_b = slice.repeat) !== null && _b !== void 0 ? _b : {})) {
|
|
41
|
+
const path = [...prevPath, "repeat", key];
|
|
42
|
+
repeat[key] = onField({ path, key, field });
|
|
43
|
+
}
|
|
45
44
|
return {
|
|
46
45
|
...slice,
|
|
47
|
-
...(
|
|
48
|
-
|
|
49
|
-
}),
|
|
50
|
-
...(repeat && {
|
|
51
|
-
repeat,
|
|
52
|
-
}),
|
|
46
|
+
...(slice["non-repeat"] && { "non-repeat": nonRepeat }),
|
|
47
|
+
...(slice.repeat && { repeat }),
|
|
53
48
|
};
|
|
54
49
|
}
|
|
55
50
|
exports.traverseCompositeSlice = traverseCompositeSlice;
|
|
@@ -48,59 +48,52 @@ function isDynamicSharedSlice(slice) {
|
|
|
48
48
|
}
|
|
49
49
|
exports.isDynamicSharedSlice = isDynamicSharedSlice;
|
|
50
50
|
function traverseVariation(args) {
|
|
51
|
+
var _a, _b;
|
|
51
52
|
const { path: prevPath, variation, onField } = args;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
...
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
case "Group":
|
|
60
|
-
field = (0, Group_1.traverseGroup)({
|
|
61
|
-
path,
|
|
62
|
-
group: prevField,
|
|
63
|
-
onField: onField,
|
|
64
|
-
});
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
field = prevField;
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
acc[key] = onField({
|
|
71
|
-
path,
|
|
72
|
-
key,
|
|
73
|
-
field,
|
|
74
|
-
});
|
|
75
|
-
return acc;
|
|
76
|
-
}, {}),
|
|
77
|
-
}),
|
|
78
|
-
...(variation.items && {
|
|
79
|
-
items: Object.entries(variation.items).reduce((acc, [key, field]) => {
|
|
80
|
-
const path = prevPath.concat("items", key);
|
|
81
|
-
acc[key] = onField({
|
|
53
|
+
const primary = {};
|
|
54
|
+
for (const [key, prevField] of Object.entries((_a = variation.primary) !== null && _a !== void 0 ? _a : {})) {
|
|
55
|
+
const path = [...prevPath, "primary", key];
|
|
56
|
+
let field;
|
|
57
|
+
switch (prevField.type) {
|
|
58
|
+
case "Group":
|
|
59
|
+
field = (0, Group_1.traverseGroup)({
|
|
82
60
|
path,
|
|
83
|
-
|
|
84
|
-
|
|
61
|
+
group: prevField,
|
|
62
|
+
onField: onField,
|
|
85
63
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
64
|
+
break;
|
|
65
|
+
default:
|
|
66
|
+
field = prevField;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
primary[key] = onField({ path, key, field });
|
|
70
|
+
}
|
|
71
|
+
const items = {};
|
|
72
|
+
for (const [key, field] of Object.entries((_b = variation.items) !== null && _b !== void 0 ? _b : {})) {
|
|
73
|
+
const path = [...prevPath, "items", key];
|
|
74
|
+
items[key] = onField({ path, key, field });
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
...variation,
|
|
78
|
+
...(variation.primary && { primary }),
|
|
79
|
+
...(variation.items && { items }),
|
|
89
80
|
};
|
|
90
81
|
}
|
|
91
82
|
exports.traverseVariation = traverseVariation;
|
|
92
83
|
function traverseSharedSlice(args) {
|
|
93
84
|
const { path: prevPath, slice, onField } = args;
|
|
85
|
+
const variations = [];
|
|
86
|
+
for (const variation of slice.variations) {
|
|
87
|
+
const path = [...prevPath, variation.id];
|
|
88
|
+
variations.push(traverseVariation({
|
|
89
|
+
path,
|
|
90
|
+
variation,
|
|
91
|
+
onField,
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
94
|
return {
|
|
95
95
|
...slice,
|
|
96
|
-
variations
|
|
97
|
-
const path = prevPath.concat(variation.id);
|
|
98
|
-
return traverseVariation({
|
|
99
|
-
path,
|
|
100
|
-
variation,
|
|
101
|
-
onField,
|
|
102
|
-
});
|
|
103
|
-
}),
|
|
96
|
+
variations,
|
|
104
97
|
};
|
|
105
98
|
}
|
|
106
99
|
exports.traverseSharedSlice = traverseSharedSlice;
|
|
@@ -82,59 +82,58 @@ exports.Slices = {
|
|
|
82
82
|
function traverseSlices(args) {
|
|
83
83
|
var _a;
|
|
84
84
|
const { path: prevPath, slices, onField } = args;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
if (!((_a = slices.config) === null || _a === void 0 ? void 0 : _a.choices))
|
|
86
|
+
return slices;
|
|
87
|
+
const choices = {};
|
|
88
|
+
for (const [key, prevModel] of Object.entries(slices.config.choices)) {
|
|
89
|
+
const path = [...prevPath, key];
|
|
90
|
+
let model;
|
|
91
|
+
switch (prevModel.type) {
|
|
92
|
+
case "Slice":
|
|
93
|
+
model = (0, CompositeSlice_1.traverseCompositeSlice)({
|
|
94
|
+
path,
|
|
95
|
+
slice: prevModel,
|
|
96
|
+
onField: onField,
|
|
97
|
+
});
|
|
98
|
+
break;
|
|
99
|
+
case "SharedSlice":
|
|
100
|
+
if ("variations" in prevModel)
|
|
101
|
+
model = (0, SharedSlice_1.traverseSharedSlice)({
|
|
92
102
|
path,
|
|
93
103
|
slice: prevModel,
|
|
94
|
-
onField
|
|
95
|
-
});
|
|
96
|
-
break;
|
|
97
|
-
case "SharedSlice":
|
|
98
|
-
if ("variations" in prevModel)
|
|
99
|
-
model = (0, SharedSlice_1.traverseSharedSlice)({
|
|
100
|
-
path,
|
|
101
|
-
slice: prevModel,
|
|
102
|
-
onField,
|
|
103
|
-
});
|
|
104
|
-
else
|
|
105
|
-
model = prevModel;
|
|
106
|
-
break;
|
|
107
|
-
// Group and other fields are technically possible because of legacy slices.
|
|
108
|
-
case "Group":
|
|
109
|
-
model = onField({
|
|
110
|
-
path,
|
|
111
|
-
key,
|
|
112
|
-
field: (0, Group_1.traverseNestedGroup)({
|
|
113
|
-
path,
|
|
114
|
-
group: prevModel,
|
|
115
|
-
onField: onField,
|
|
116
|
-
}),
|
|
104
|
+
onField,
|
|
117
105
|
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
106
|
+
else
|
|
107
|
+
model = prevModel;
|
|
108
|
+
break;
|
|
109
|
+
// Group and other fields are technically possible because of legacy slices.
|
|
110
|
+
case "Group":
|
|
111
|
+
model = onField({
|
|
112
|
+
path,
|
|
113
|
+
key,
|
|
114
|
+
field: (0, Group_1.traverseNestedGroup)({
|
|
121
115
|
path,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
116
|
+
group: prevModel,
|
|
117
|
+
onField: onField,
|
|
118
|
+
}),
|
|
119
|
+
});
|
|
120
|
+
break;
|
|
121
|
+
default:
|
|
122
|
+
model = onField({
|
|
123
|
+
path,
|
|
124
|
+
key,
|
|
125
|
+
field: prevModel,
|
|
126
|
+
});
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
choices[key] = model;
|
|
130
|
+
}
|
|
130
131
|
return {
|
|
131
132
|
...slices,
|
|
132
|
-
|
|
133
|
-
config
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
},
|
|
137
|
-
}),
|
|
133
|
+
config: {
|
|
134
|
+
...slices.config,
|
|
135
|
+
choices,
|
|
136
|
+
},
|
|
138
137
|
};
|
|
139
138
|
}
|
|
140
139
|
exports.traverseSlices = traverseSlices;
|
package/package.json
CHANGED
|
@@ -260,17 +260,18 @@ export function traverseCustomType<
|
|
|
260
260
|
onField: OnFieldFn<UID | NestableWidget | Group | NestedGroup>
|
|
261
261
|
}): T {
|
|
262
262
|
const { customType, onField } = args
|
|
263
|
+
|
|
264
|
+
const json: Record<string, typeof customType.json[string]> = {}
|
|
265
|
+
for (const [key, section] of Object.entries(customType.json)) {
|
|
266
|
+
json[key] = traverseSection({
|
|
267
|
+
path: [key],
|
|
268
|
+
section,
|
|
269
|
+
onField,
|
|
270
|
+
})
|
|
271
|
+
}
|
|
272
|
+
|
|
263
273
|
return {
|
|
264
274
|
...customType,
|
|
265
|
-
json
|
|
266
|
-
Record<string, typeof customType.json[string]>
|
|
267
|
-
>((acc, [key, section]) => {
|
|
268
|
-
acc[key] = traverseSection({
|
|
269
|
-
path: [key],
|
|
270
|
-
section,
|
|
271
|
-
onField,
|
|
272
|
-
})
|
|
273
|
-
return acc
|
|
274
|
-
}, {}),
|
|
275
|
+
json,
|
|
275
276
|
}
|
|
276
277
|
}
|
|
@@ -50,9 +50,11 @@ export function traverseSection<
|
|
|
50
50
|
section: T
|
|
51
51
|
onField: OnFieldFn<UID | NestableWidget | Group | NestedGroup>
|
|
52
52
|
}): T {
|
|
53
|
-
const { path: prevPath, section, onField } = args
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
const { path: prevPath, section: prevSection, onField } = args
|
|
54
|
+
|
|
55
|
+
const section = { ...prevSection }
|
|
56
|
+
for (const [key, prevModel] of Object.entries(prevSection)) {
|
|
57
|
+
const path = [...prevPath, key]
|
|
56
58
|
let model
|
|
57
59
|
switch (prevModel.type) {
|
|
58
60
|
case "Choice":
|
|
@@ -82,7 +84,7 @@ export function traverseSection<
|
|
|
82
84
|
})
|
|
83
85
|
break
|
|
84
86
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
section[key] = model
|
|
88
|
+
}
|
|
89
|
+
return section
|
|
88
90
|
}
|
|
@@ -55,28 +55,25 @@ export function traverseNestedGroup(args: {
|
|
|
55
55
|
onField: OnFieldFn<NestableWidget>
|
|
56
56
|
}): NestedGroup {
|
|
57
57
|
const { path: prevPath, group, onField } = args
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
)
|
|
58
|
+
|
|
59
|
+
if (!group.config?.fields) return group
|
|
60
|
+
|
|
61
|
+
const fields: Record<string, NestableWidget> = {}
|
|
62
|
+
for (const [key, prevField] of Object.entries(group.config.fields)) {
|
|
63
|
+
const path = [...prevPath, key]
|
|
64
|
+
fields[key] = onField({
|
|
65
|
+
path,
|
|
66
|
+
key,
|
|
67
|
+
field: prevField,
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
72
71
|
return {
|
|
73
72
|
...group,
|
|
74
|
-
|
|
75
|
-
config
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
}),
|
|
73
|
+
config: {
|
|
74
|
+
...group.config,
|
|
75
|
+
fields,
|
|
76
|
+
},
|
|
80
77
|
}
|
|
81
78
|
}
|
|
82
79
|
|
|
@@ -86,39 +83,37 @@ export function traverseGroup(args: {
|
|
|
86
83
|
onField: OnFieldFn<NestableWidget | NestedGroup>
|
|
87
84
|
}): Group {
|
|
88
85
|
const { path: prevPath, group, onField } = args
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
86
|
+
|
|
87
|
+
if (!group.config?.fields) return group
|
|
88
|
+
|
|
89
|
+
const fields: Record<string, NestableWidget | NestedGroup> = {}
|
|
90
|
+
for (const [key, prevField] of Object.entries(group.config.fields)) {
|
|
91
|
+
const path = [...prevPath, key]
|
|
92
|
+
let field
|
|
93
|
+
switch (prevField.type) {
|
|
94
|
+
case "Group":
|
|
95
|
+
field = traverseNestedGroup({
|
|
96
|
+
path,
|
|
97
|
+
group: prevField,
|
|
98
|
+
onField: onField as OnFieldFn<NestableWidget>,
|
|
99
|
+
})
|
|
100
|
+
break
|
|
101
|
+
default:
|
|
102
|
+
field = prevField
|
|
103
|
+
break
|
|
104
|
+
}
|
|
105
|
+
fields[key] = onField({
|
|
106
|
+
path,
|
|
107
|
+
key,
|
|
108
|
+
field,
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
|
|
115
112
|
return {
|
|
116
113
|
...group,
|
|
117
|
-
|
|
118
|
-
config
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
},
|
|
122
|
-
}),
|
|
114
|
+
config: {
|
|
115
|
+
...group.config,
|
|
116
|
+
fields,
|
|
117
|
+
},
|
|
123
118
|
}
|
|
124
119
|
}
|
|
@@ -45,33 +45,22 @@ export function traverseCompositeSlice(args: {
|
|
|
45
45
|
onField: OnFieldFn<NestableWidget>
|
|
46
46
|
}): CompositeSlice {
|
|
47
47
|
const { path: prevPath, slice, onField } = args
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
(acc, [key, field]) => {
|
|
62
|
-
const path = prevPath.concat("repeat", key)
|
|
63
|
-
acc[key] = onField({ path, key, field })
|
|
64
|
-
return acc
|
|
65
|
-
},
|
|
66
|
-
{},
|
|
67
|
-
)
|
|
48
|
+
|
|
49
|
+
const nonRepeat: Record<string, NestableWidget> = {}
|
|
50
|
+
for (const [key, field] of Object.entries(slice["non-repeat"] ?? {})) {
|
|
51
|
+
const path = [...prevPath, "non-repeat", key]
|
|
52
|
+
nonRepeat[key] = onField({ path, key, field })
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const repeat: Record<string, NestableWidget> = {}
|
|
56
|
+
for (const [key, field] of Object.entries(slice.repeat ?? {})) {
|
|
57
|
+
const path = [...prevPath, "repeat", key]
|
|
58
|
+
repeat[key] = onField({ path, key, field })
|
|
59
|
+
}
|
|
60
|
+
|
|
68
61
|
return {
|
|
69
62
|
...slice,
|
|
70
|
-
...(
|
|
71
|
-
|
|
72
|
-
}),
|
|
73
|
-
...(repeat && {
|
|
74
|
-
repeat,
|
|
75
|
-
}),
|
|
63
|
+
...(slice["non-repeat"] && { "non-repeat": nonRepeat }),
|
|
64
|
+
...(slice.repeat && { repeat }),
|
|
76
65
|
}
|
|
77
66
|
}
|