@prismicio/types-internal 2.5.0-alpha.2 → 2.5.0-alpha.3
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 +8 -8
- package/lib/content/fields/GroupContent.d.ts +8 -8
- package/lib/content/fields/GroupContent.js +14 -32
- package/lib/content/fields/WidgetContent.d.ts +8 -8
- package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +4 -4
- package/lib/content/fields/slices/Slice/CompositeSliceContent.js +0 -3
- package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +3 -2
- package/lib/content/fields/slices/Slice/RepeatableContent.js +4 -1
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +4 -4
- package/lib/content/fields/slices/Slice/SharedSliceContent.js +0 -2
- package/lib/content/fields/slices/Slice/SimpleSliceContent.js +0 -1
- package/lib/content/fields/slices/Slice/index.d.ts +6 -6
- package/lib/content/fields/slices/SliceItem.d.ts +6 -6
- package/lib/content/fields/slices/SlicesContent.d.ts +8 -8
- package/lib/customtypes/CustomType.d.ts +2042 -690
- package/lib/customtypes/Section.d.ts +2028 -676
- package/lib/customtypes/diff/SharedSlice.d.ts +678 -2
- package/lib/customtypes/diff/Variation.d.ts +678 -3
- package/lib/customtypes/widgets/Group.d.ts +996 -15
- package/lib/customtypes/widgets/Group.js +15 -27
- package/lib/customtypes/widgets/Widget.d.ts +1684 -7
- package/lib/customtypes/widgets/slices/LegacySlice.d.ts +168 -2
- package/lib/customtypes/widgets/slices/LegacySlice.js +1 -1
- package/lib/customtypes/widgets/slices/SharedSlice.d.ts +670 -2
- package/lib/customtypes/widgets/slices/SlicePrimaryWidget.d.ts +674 -3
- package/lib/customtypes/widgets/slices/Slices.d.ts +1522 -7
- package/package.json +1 -1
- package/src/content/fields/GroupContent.ts +24 -48
- package/src/content/fields/slices/Slice/CompositeSliceContent.ts +4 -7
- package/src/content/fields/slices/Slice/RepeatableContent.ts +9 -2
- package/src/content/fields/slices/Slice/SharedSliceContent.ts +3 -5
- package/src/content/fields/slices/Slice/SimpleSliceContent.ts +1 -3
- package/src/customtypes/widgets/Group.ts +34 -61
- package/src/customtypes/widgets/slices/LegacySlice.ts +2 -2
|
@@ -1,33 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Group = exports.GroupConfig = exports.GroupFieldType = void 0;
|
|
3
|
+
exports.Group = exports.GroupConfig = exports.NestedGroup = exports.NestedGroupConfig = exports.GroupFieldType = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
6
|
const common_1 = require("../../common");
|
|
7
7
|
const validators_1 = require("../../validators");
|
|
8
|
-
const function_1 = require("../../validators/function");
|
|
9
8
|
const NestableWidget_1 = require("./nestable/NestableWidget");
|
|
10
9
|
exports.GroupFieldType = "Group";
|
|
11
|
-
|
|
10
|
+
// We're obliged to use `t.Mixed` here, otherwise the factory would be
|
|
11
|
+
// referencing itself and TypeScript would infer its type as `any`
|
|
12
|
+
const createGroupConfig = (widgets) => t.exact(t.partial({
|
|
12
13
|
label: validators_1.StringOrNull,
|
|
13
14
|
repeat: t.boolean,
|
|
14
|
-
fields: t.record(common_1.WidgetKey,
|
|
15
|
-
}))
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// Stop searching when we're over limit
|
|
20
|
-
if (depth > MAX_GROUP_DEPTH)
|
|
21
|
-
return depth;
|
|
22
|
-
for (const key in (_a = group.config) === null || _a === void 0 ? void 0 : _a.fields) {
|
|
23
|
-
const field = (_b = group.config) === null || _b === void 0 ? void 0 : _b.fields[key];
|
|
24
|
-
if ((field === null || field === void 0 ? void 0 : field.type) === exports.GroupFieldType) {
|
|
25
|
-
depth = Math.max(depth, getGroupDepth(field, depth + 1));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return depth;
|
|
29
|
-
};
|
|
30
|
-
exports.Group = (0, function_1.refineType)(t.recursion("Group", () => t.exact(t.intersection([
|
|
15
|
+
fields: t.record(common_1.WidgetKey, widgets),
|
|
16
|
+
}));
|
|
17
|
+
// We're obliged to use `t.Mixed` here, otherwise the factory would be
|
|
18
|
+
// referencing itself and TypeScript would infer its type as `any`
|
|
19
|
+
const createGroup = (widgets) => t.exact(t.intersection([
|
|
31
20
|
t.type({
|
|
32
21
|
type: t.literal(exports.GroupFieldType),
|
|
33
22
|
}),
|
|
@@ -35,11 +24,10 @@ exports.Group = (0, function_1.refineType)(t.recursion("Group", () => t.exact(t.
|
|
|
35
24
|
fieldset: validators_1.StringOrNull,
|
|
36
25
|
icon: t.string,
|
|
37
26
|
description: t.string,
|
|
38
|
-
config:
|
|
27
|
+
config: createGroupConfig(widgets),
|
|
39
28
|
}),
|
|
40
|
-
]))
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
29
|
+
]));
|
|
30
|
+
exports.NestedGroupConfig = createGroupConfig(NestableWidget_1.NestableWidget);
|
|
31
|
+
exports.NestedGroup = createGroup(NestableWidget_1.NestableWidget);
|
|
32
|
+
exports.GroupConfig = createGroupConfig(t.union([NestableWidget_1.NestableWidget, exports.NestedGroup]));
|
|
33
|
+
exports.Group = createGroup(t.union([NestableWidget_1.NestableWidget, exports.NestedGroup]));
|