@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.
Files changed (50) hide show
  1. package/lib/content/Document.d.ts +3972 -7926
  2. package/lib/content/fields/GroupContent.d.ts +17 -1754
  3. package/lib/content/fields/GroupContent.js +62 -22
  4. package/lib/content/fields/WidgetContent.d.ts +3371 -7324
  5. package/lib/content/fields/nestable/NestableContent.d.ts +3 -145
  6. package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +4 -212
  7. package/lib/content/fields/nestable/RichTextContent/Blocks.js +2 -0
  8. package/lib/content/fields/nestable/RichTextContent/index.d.ts +4 -184
  9. package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +6 -290
  10. package/lib/content/fields/slices/Slice/CompositeSliceContent.js +3 -0
  11. package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +2 -383
  12. package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +15 -1333
  13. package/lib/content/fields/slices/Slice/SharedSliceContent.js +2 -0
  14. package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +7 -1182
  15. package/lib/content/fields/slices/Slice/SimpleSliceContent.js +1 -0
  16. package/lib/content/fields/slices/Slice/SlicePrimaryContent.d.ts +7 -1182
  17. package/lib/content/fields/slices/Slice/index.d.ts +983 -2935
  18. package/lib/content/fields/slices/SliceItem.d.ts +148 -2100
  19. package/lib/content/fields/slices/SlicesContent.d.ts +866 -3644
  20. package/lib/content/fields/withDefaultValues.d.ts +4 -3
  21. package/lib/content/fields/withDefaultValues.js +17 -1
  22. package/lib/customtypes/CustomType.d.ts +70 -915
  23. package/lib/customtypes/Section.d.ts +70 -915
  24. package/lib/customtypes/diff/SharedSlice.d.ts +2 -340
  25. package/lib/customtypes/diff/Variation.d.ts +4 -351
  26. package/lib/customtypes/diff/Variation.js +4 -3
  27. package/lib/customtypes/diff/Widgets.d.ts +11 -0
  28. package/lib/customtypes/diff/Widgets.js +2 -0
  29. package/lib/customtypes/diff/index.d.ts +1 -0
  30. package/lib/customtypes/diff/index.js +1 -0
  31. package/lib/customtypes/widgets/Group.d.ts +15 -331
  32. package/lib/customtypes/widgets/Group.js +25 -5
  33. package/lib/customtypes/widgets/Widget.d.ts +7 -1014
  34. package/lib/customtypes/widgets/slices/LegacySlice.d.ts +2 -168
  35. package/lib/customtypes/widgets/slices/SharedSlice.d.ts +2 -336
  36. package/lib/customtypes/widgets/slices/SlicePrimaryWidget.d.ts +3 -338
  37. package/lib/customtypes/widgets/slices/Slices.d.ts +7 -1184
  38. package/lib/validators/function.js +8 -1
  39. package/package.json +5 -5
  40. package/src/content/fields/GroupContent.ts +107 -32
  41. package/src/content/fields/nestable/RichTextContent/Blocks.ts +3 -1
  42. package/src/content/fields/slices/Slice/CompositeSliceContent.ts +7 -4
  43. package/src/content/fields/slices/Slice/SharedSliceContent.ts +5 -3
  44. package/src/content/fields/slices/Slice/SimpleSliceContent.ts +3 -1
  45. package/src/content/fields/withDefaultValues.ts +27 -3
  46. package/src/customtypes/diff/Variation.ts +9 -20
  47. package/src/customtypes/diff/Widgets.ts +17 -0
  48. package/src/customtypes/diff/index.ts +1 -0
  49. package/src/customtypes/widgets/Group.ts +66 -20
  50. 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
- if (!contentItem.value.find(([_key]) => _key === key)) {
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,