@prismicio/types-internal 2.5.0-alpha.0 → 2.5.0-alpha.2
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/content/Document.d.ts +3972 -7926
- package/lib/content/fields/GroupContent.d.ts +17 -1754
- package/lib/content/fields/GroupContent.js +62 -22
- package/lib/content/fields/WidgetContent.d.ts +3371 -7324
- package/lib/content/fields/nestable/NestableContent.d.ts +3 -145
- package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +4 -212
- package/lib/content/fields/nestable/RichTextContent/Blocks.js +2 -0
- package/lib/content/fields/nestable/RichTextContent/index.d.ts +4 -184
- package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +6 -290
- package/lib/content/fields/slices/Slice/CompositeSliceContent.js +3 -0
- package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +2 -383
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +15 -1333
- package/lib/content/fields/slices/Slice/SharedSliceContent.js +2 -0
- package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +7 -1182
- package/lib/content/fields/slices/Slice/SimpleSliceContent.js +1 -0
- package/lib/content/fields/slices/Slice/SlicePrimaryContent.d.ts +7 -1182
- package/lib/content/fields/slices/Slice/index.d.ts +983 -2935
- package/lib/content/fields/slices/SliceItem.d.ts +148 -2100
- package/lib/content/fields/slices/SlicesContent.d.ts +866 -3644
- package/lib/content/fields/withDefaultValues.d.ts +4 -3
- package/lib/content/fields/withDefaultValues.js +17 -1
- package/lib/customtypes/CustomType.d.ts +70 -915
- package/lib/customtypes/Section.d.ts +70 -915
- package/lib/customtypes/diff/SharedSlice.d.ts +2 -340
- package/lib/customtypes/diff/Variation.d.ts +4 -351
- package/lib/customtypes/diff/Variation.js +4 -3
- package/lib/customtypes/diff/Widgets.d.ts +11 -0
- package/lib/customtypes/diff/Widgets.js +2 -0
- package/lib/customtypes/diff/index.d.ts +1 -0
- package/lib/customtypes/diff/index.js +1 -0
- package/lib/customtypes/widgets/Group.d.ts +15 -331
- package/lib/customtypes/widgets/Group.js +25 -5
- package/lib/customtypes/widgets/Widget.d.ts +7 -1014
- package/lib/customtypes/widgets/slices/LegacySlice.d.ts +2 -168
- package/lib/customtypes/widgets/slices/SharedSlice.d.ts +2 -336
- package/lib/customtypes/widgets/slices/SlicePrimaryWidget.d.ts +3 -338
- package/lib/customtypes/widgets/slices/Slices.d.ts +7 -1184
- package/lib/validators/function.js +8 -1
- package/package.json +5 -5
- package/src/content/fields/GroupContent.ts +107 -32
- package/src/content/fields/nestable/RichTextContent/Blocks.ts +3 -1
- package/src/content/fields/slices/Slice/CompositeSliceContent.ts +7 -4
- package/src/content/fields/slices/Slice/SharedSliceContent.ts +5 -3
- package/src/content/fields/slices/Slice/SimpleSliceContent.ts +3 -1
- package/src/content/fields/withDefaultValues.ts +27 -3
- package/src/customtypes/diff/Variation.ts +9 -20
- package/src/customtypes/diff/Widgets.ts +17 -0
- package/src/customtypes/diff/index.ts +1 -0
- package/src/customtypes/widgets/Group.ts +66 -20
- package/src/validators/function.ts +11 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { type NestableWidget, type SlicePrimaryWidget } from "../../customtypes";
|
|
1
|
+
import { type NestableWidget, type SlicePrimaryWidget, Group } from "../../customtypes";
|
|
2
|
+
import { GroupContent } from "./GroupContent";
|
|
2
3
|
import type { NestableContent } from "./nestable";
|
|
3
4
|
import type { SlicePrimaryContent } from "./slices/Slice/SlicePrimaryContent";
|
|
4
5
|
export declare function withDefaultSlicePrimaryContentValues(customType: Record<string, SlicePrimaryWidget>, content: Partial<Record<string, SlicePrimaryContent>>): Record<string, SlicePrimaryContent>;
|
|
5
6
|
export declare function withDefaultNestableContentValues(customType: Record<string, NestableWidget>, content: Record<string, NestableContent>): Record<string, NestableContent>;
|
|
6
7
|
export declare function repeatableContentWithDefaultNestableContentValues<T extends {
|
|
7
|
-
value: [string, NestableContent][];
|
|
8
|
-
}>(fields: Record<string, NestableWidget>, content: T[]): T[];
|
|
8
|
+
value: [string, GroupContent | NestableContent][];
|
|
9
|
+
}>(fields: Record<string, Group | NestableWidget>, content: T[]): T[];
|
|
@@ -46,7 +46,23 @@ function repeatableContentWithDefaultNestableContentValues(fields, content) {
|
|
|
46
46
|
const groupKeys = Object.entries(fields);
|
|
47
47
|
return content.map((contentItem) => {
|
|
48
48
|
return groupKeys.reduce((updatedContentItem, [key, fieldDef]) => {
|
|
49
|
-
|
|
49
|
+
var _a;
|
|
50
|
+
const maybeContentItemValue = contentItem.value.find(([_key]) => _key === key);
|
|
51
|
+
if (fieldDef.type === "Group") {
|
|
52
|
+
const defaultValue = (0, GroupContent_1.groupContentWithDefaultValues)(fieldDef, (_a = maybeContentItemValue === null || maybeContentItemValue === void 0 ? void 0 : maybeContentItemValue[1]) !== null && _a !== void 0 ? _a : {
|
|
53
|
+
__TYPE__: GroupContent_1.GroupContentType,
|
|
54
|
+
value: [],
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
...updatedContentItem,
|
|
58
|
+
value: [
|
|
59
|
+
// Since there was default content for the group, we need to remove the old one
|
|
60
|
+
...updatedContentItem.value.filter(([_key]) => _key !== key),
|
|
61
|
+
...(defaultValue ? [[key, defaultValue]] : []),
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
else if (!maybeContentItemValue) {
|
|
50
66
|
const defaultValue = (0, nestable_1.NestableContentDefaultValue)(fieldDef);
|
|
51
67
|
return {
|
|
52
68
|
...updatedContentItem,
|