@prismicio/types-internal 3.11.0-alpha.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
|
@@ -78,47 +78,36 @@ export function traverseVariation(args: {
|
|
|
78
78
|
onField: OnFieldFn<NestableWidget | Group | NestedGroup>
|
|
79
79
|
}): Variation {
|
|
80
80
|
const { path: prevPath, variation, onField } = args
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
switch (prevField.type) {
|
|
90
|
-
case "Group":
|
|
91
|
-
field = traverseGroup({
|
|
92
|
-
path,
|
|
93
|
-
group: prevField,
|
|
94
|
-
onField: onField as OnFieldFn<NestableWidget | NestedGroup>,
|
|
95
|
-
})
|
|
96
|
-
break
|
|
97
|
-
default:
|
|
98
|
-
field = prevField
|
|
99
|
-
break
|
|
100
|
-
}
|
|
101
|
-
acc[key] = onField({
|
|
102
|
-
path,
|
|
103
|
-
key,
|
|
104
|
-
field,
|
|
105
|
-
})
|
|
106
|
-
return acc
|
|
107
|
-
}, {}),
|
|
108
|
-
}),
|
|
109
|
-
...(variation.items && {
|
|
110
|
-
items: Object.entries(variation.items).reduce<
|
|
111
|
-
Record<string, NestableWidget>
|
|
112
|
-
>((acc, [key, field]) => {
|
|
113
|
-
const path = prevPath.concat("items", key)
|
|
114
|
-
acc[key] = (onField as OnFieldFn<NestableWidget>)({
|
|
81
|
+
|
|
82
|
+
const primary: Record<string, NestableWidget | Group> = {}
|
|
83
|
+
for (const [key, prevField] of Object.entries(variation.primary ?? {})) {
|
|
84
|
+
const path = [...prevPath, "primary", key]
|
|
85
|
+
let field
|
|
86
|
+
switch (prevField.type) {
|
|
87
|
+
case "Group":
|
|
88
|
+
field = traverseGroup({
|
|
115
89
|
path,
|
|
116
|
-
|
|
117
|
-
|
|
90
|
+
group: prevField,
|
|
91
|
+
onField: onField as OnFieldFn<NestableWidget | NestedGroup>,
|
|
118
92
|
})
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
93
|
+
break
|
|
94
|
+
default:
|
|
95
|
+
field = prevField
|
|
96
|
+
break
|
|
97
|
+
}
|
|
98
|
+
primary[key] = onField({ path, key, field })
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const items: Record<string, NestableWidget> = {}
|
|
102
|
+
for (const [key, field] of Object.entries(variation.items ?? {})) {
|
|
103
|
+
const path = [...prevPath, "items", key]
|
|
104
|
+
items[key] = (onField as OnFieldFn<NestableWidget>)({ path, key, field })
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
...variation,
|
|
109
|
+
...(variation.primary && { primary }),
|
|
110
|
+
...(variation.items && { items }),
|
|
122
111
|
}
|
|
123
112
|
}
|
|
124
113
|
|
|
@@ -128,15 +117,21 @@ export function traverseSharedSlice(args: {
|
|
|
128
117
|
onField: OnFieldFn<NestableWidget | Group | NestedGroup>
|
|
129
118
|
}): SharedSlice {
|
|
130
119
|
const { path: prevPath, slice, onField } = args
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
120
|
+
|
|
121
|
+
const variations: Variation[] = []
|
|
122
|
+
for (const variation of slice.variations) {
|
|
123
|
+
const path = [...prevPath, variation.id]
|
|
124
|
+
variations.push(
|
|
125
|
+
traverseVariation({
|
|
136
126
|
path,
|
|
137
127
|
variation,
|
|
138
128
|
onField,
|
|
139
|
-
})
|
|
140
|
-
|
|
129
|
+
}),
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
...slice,
|
|
135
|
+
variations,
|
|
141
136
|
}
|
|
142
137
|
}
|
|
@@ -120,60 +120,59 @@ export function traverseSlices<T extends DynamicSlices | StaticSlices>(args: {
|
|
|
120
120
|
onField: OnFieldFn<NestableWidget | Group | NestedGroup>
|
|
121
121
|
}): T {
|
|
122
122
|
const { path: prevPath, slices, onField } = args
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
path,
|
|
142
|
-
slice: prevModel as SharedSlice,
|
|
143
|
-
onField,
|
|
144
|
-
})
|
|
145
|
-
else model = prevModel
|
|
146
|
-
break
|
|
147
|
-
// Group and other fields are technically possible because of legacy slices.
|
|
148
|
-
case "Group":
|
|
149
|
-
model = onField({
|
|
123
|
+
|
|
124
|
+
if (!slices.config?.choices) return slices
|
|
125
|
+
|
|
126
|
+
const choices: Record<string, typeof slices.config.choices[string]> = {}
|
|
127
|
+
for (const [key, prevModel] of Object.entries(slices.config.choices)) {
|
|
128
|
+
const path = [...prevPath, key]
|
|
129
|
+
let model
|
|
130
|
+
switch (prevModel.type) {
|
|
131
|
+
case "Slice":
|
|
132
|
+
model = traverseCompositeSlice({
|
|
133
|
+
path,
|
|
134
|
+
slice: prevModel,
|
|
135
|
+
onField: onField as OnFieldFn<NestableWidget>,
|
|
136
|
+
})
|
|
137
|
+
break
|
|
138
|
+
case "SharedSlice":
|
|
139
|
+
if ("variations" in prevModel)
|
|
140
|
+
model = traverseSharedSlice({
|
|
150
141
|
path,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
path,
|
|
154
|
-
group: prevModel,
|
|
155
|
-
onField: onField as OnFieldFn<NestableWidget>,
|
|
156
|
-
}),
|
|
142
|
+
slice: prevModel as SharedSlice,
|
|
143
|
+
onField,
|
|
157
144
|
})
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
145
|
+
else model = prevModel
|
|
146
|
+
break
|
|
147
|
+
// Group and other fields are technically possible because of legacy slices.
|
|
148
|
+
case "Group":
|
|
149
|
+
model = onField({
|
|
150
|
+
path,
|
|
151
|
+
key,
|
|
152
|
+
field: traverseNestedGroup({
|
|
161
153
|
path,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
154
|
+
group: prevModel,
|
|
155
|
+
onField: onField as OnFieldFn<NestableWidget>,
|
|
156
|
+
}),
|
|
157
|
+
})
|
|
158
|
+
break
|
|
159
|
+
default:
|
|
160
|
+
model = onField({
|
|
161
|
+
path,
|
|
162
|
+
key,
|
|
163
|
+
field: prevModel,
|
|
164
|
+
})
|
|
165
|
+
break
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
choices[key] = model as typeof slices.config.choices[string]
|
|
169
|
+
}
|
|
170
|
+
|
|
170
171
|
return {
|
|
171
172
|
...slices,
|
|
172
|
-
|
|
173
|
-
config
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
},
|
|
177
|
-
}),
|
|
173
|
+
config: {
|
|
174
|
+
...slices.config,
|
|
175
|
+
choices,
|
|
176
|
+
},
|
|
178
177
|
}
|
|
179
178
|
}
|