@prismicio/types-internal 3.11.2-alpha.1 → 3.11.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/fields/RepeatableContent.d.ts +45 -47
- package/lib/content/fields/nestable/RichTextContent/TextBlock.d.ts +727 -0
- package/lib/content/fields/nestable/RichTextContent/TextBlock.js +80 -0
- package/lib/customtypes/CustomType.js +1 -0
- package/lib/customtypes/Section.js +1 -0
- package/lib/customtypes/widgets/Group.js +2 -0
- package/lib/customtypes/widgets/slices/CompositeSlice.js +1 -0
- package/lib/customtypes/widgets/slices/SharedSlice.js +2 -0
- package/lib/customtypes/widgets/slices/SliceWidget.d.ts +327 -0
- package/lib/customtypes/widgets/slices/SliceWidget.js +8 -0
- package/lib/customtypes/widgets/slices/Slices.js +1 -0
- package/package.json +1 -1
- package/src/customtypes/CustomType.ts +3 -0
- package/src/customtypes/Section.ts +2 -0
- package/src/customtypes/widgets/Group.ts +3 -0
- package/src/customtypes/widgets/slices/CompositeSlice.ts +1 -0
- package/src/customtypes/widgets/slices/SharedSlice.ts +2 -0
- package/src/customtypes/widgets/slices/Slices.ts +1 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextBlockLegacy = exports.ParagraphBlock = exports.TextBlock = exports.ValidatedSpans = exports.SpanLegacy = exports.Span = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Either_1 = require("fp-ts/lib/Either");
|
|
6
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
7
|
+
const io_ts_types_1 = require("io-ts-types");
|
|
8
|
+
const nestable_1 = require("../../../../customtypes/widgets/nestable");
|
|
9
|
+
const function_1 = require("../../../../validators/function");
|
|
10
|
+
const LinkContent_1 = require("../LinkContent");
|
|
11
|
+
const linkSpan = (linkCodec) => t.strict({
|
|
12
|
+
data: linkCodec,
|
|
13
|
+
start: t.number,
|
|
14
|
+
end: t.number,
|
|
15
|
+
type: t.literal(nestable_1.RichTextNodeType.hyperlink),
|
|
16
|
+
});
|
|
17
|
+
const labelSpan = t.strict({
|
|
18
|
+
data: (0, io_ts_types_1.withFallback)(t.string, ""),
|
|
19
|
+
start: t.number,
|
|
20
|
+
end: t.number,
|
|
21
|
+
type: t.literal("label"),
|
|
22
|
+
});
|
|
23
|
+
const basicSpan = t.strict({
|
|
24
|
+
start: t.number,
|
|
25
|
+
end: t.number,
|
|
26
|
+
type: t.keyof({
|
|
27
|
+
[nestable_1.RichTextNodeType.strong]: null,
|
|
28
|
+
[nestable_1.RichTextNodeType.em]: null,
|
|
29
|
+
"list-item": null, // legacy case that should not happen, we shouldn't support this in new page builder or migration API
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
exports.Span = t.union([linkSpan(LinkContent_1.Link), labelSpan, basicSpan]);
|
|
33
|
+
exports.SpanLegacy = t.union([linkSpan(LinkContent_1.LinkLegacy), labelSpan, basicSpan]);
|
|
34
|
+
const ValidatedSpans = (spanCodec) => {
|
|
35
|
+
return new t.Type("ValidatedSpans", (spans) => Array.isArray(spans) && spans.every(spanCodec.is), (spans, c) => {
|
|
36
|
+
if (Array.isArray(spans)) {
|
|
37
|
+
const res = spans
|
|
38
|
+
.reduce((acc, maybeSpan) => {
|
|
39
|
+
const decodedSpan = spanCodec.decode(maybeSpan);
|
|
40
|
+
if ((0, Either_1.isLeft)(decodedSpan))
|
|
41
|
+
return acc;
|
|
42
|
+
return [...acc, decodedSpan.right];
|
|
43
|
+
}, [])
|
|
44
|
+
.sort((m1, m2) => m1.start - m2.start);
|
|
45
|
+
return t.success(res);
|
|
46
|
+
}
|
|
47
|
+
else
|
|
48
|
+
return t.failure(spans, c);
|
|
49
|
+
}, (m) => {
|
|
50
|
+
return m.reduce((acc, meta) => {
|
|
51
|
+
const encoded = spanCodec.encode(meta);
|
|
52
|
+
return [...acc, encoded];
|
|
53
|
+
}, []);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
exports.ValidatedSpans = ValidatedSpans;
|
|
57
|
+
const TextBlockCodec = (spanCodec, nodeFilter) => t.exact(t.intersection([
|
|
58
|
+
t.type({
|
|
59
|
+
type: nodeFilter
|
|
60
|
+
? (0, function_1.refineType)(nestable_1.RichTextNodeTypeCodec, `string which isn't ${nestable_1.RichTextNodeType.image} ${nestable_1.RichTextNodeType.embed}`, nodeFilter)
|
|
61
|
+
: nestable_1.RichTextNodeTypeCodec,
|
|
62
|
+
content: t.intersection([
|
|
63
|
+
t.type({
|
|
64
|
+
text: t.string,
|
|
65
|
+
}),
|
|
66
|
+
t.partial({
|
|
67
|
+
spans: (0, exports.ValidatedSpans)(spanCodec),
|
|
68
|
+
}),
|
|
69
|
+
]),
|
|
70
|
+
}),
|
|
71
|
+
t.partial({
|
|
72
|
+
label: t.string,
|
|
73
|
+
direction: t.string,
|
|
74
|
+
}),
|
|
75
|
+
]));
|
|
76
|
+
/* These Text block will decode codec A and encode from codec B to A */
|
|
77
|
+
exports.TextBlock = TextBlockCodec(exports.Span, (nodeType) => nodeType !== nestable_1.RichTextNodeType.image && nodeType !== nestable_1.RichTextNodeType.embed);
|
|
78
|
+
/** A paragraph Text block. Paragraphs may contain spans. */
|
|
79
|
+
exports.ParagraphBlock = TextBlockCodec(exports.Span, (nodeType) => nodeType === nestable_1.RichTextNodeType.paragraph);
|
|
80
|
+
exports.TextBlockLegacy = TextBlockCodec(exports.SpanLegacy);
|
|
@@ -178,6 +178,7 @@ function traverseCustomType(args) {
|
|
|
178
178
|
json[key] = newSection;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
+
// returns the traversed model instead of a new one if it didn't change
|
|
181
182
|
return json ? { ...customType, json } : customType;
|
|
182
183
|
}
|
|
183
184
|
exports.traverseCustomType = traverseCustomType;
|
|
@@ -60,6 +60,7 @@ function traverseSection(args) {
|
|
|
60
60
|
section[key] = model;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
// returns the traversed model instead of a new one if it didn't change
|
|
63
64
|
return section !== null && section !== void 0 ? section : prevSection;
|
|
64
65
|
}
|
|
65
66
|
exports.traverseSection = traverseSection;
|
|
@@ -50,6 +50,7 @@ function traverseNestedGroup(args) {
|
|
|
50
50
|
fields[key] = newField;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
// returns the traversed model instead of a new one if it didn't change
|
|
53
54
|
return fields ? { ...group, config: { ...group.config, fields } } : group;
|
|
54
55
|
}
|
|
55
56
|
exports.traverseNestedGroup = traverseNestedGroup;
|
|
@@ -85,6 +86,7 @@ function traverseGroup(args) {
|
|
|
85
86
|
fields[key] = newField;
|
|
86
87
|
}
|
|
87
88
|
}
|
|
89
|
+
// returns the traversed model instead of a new one if it didn't change
|
|
88
90
|
return fields ? { ...group, config: { ...group.config, fields } } : group;
|
|
89
91
|
}
|
|
90
92
|
exports.traverseGroup = traverseGroup;
|
|
@@ -87,6 +87,7 @@ function traverseVariation(args) {
|
|
|
87
87
|
items[key] = newField;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
+
// returns the traversed model instead of a new one if it didn't change
|
|
90
91
|
return primary || items
|
|
91
92
|
? { ...variation, ...(primary && { primary }), ...(items && { items }) }
|
|
92
93
|
: variation;
|
|
@@ -111,6 +112,7 @@ function traverseSharedSlice(args) {
|
|
|
111
112
|
variations[i] = newVariation;
|
|
112
113
|
}
|
|
113
114
|
}
|
|
115
|
+
// returns the traversed model instead of a new one if it didn't change
|
|
114
116
|
return variations ? { ...slice, variations } : slice;
|
|
115
117
|
}
|
|
116
118
|
exports.traverseSharedSlice = traverseSharedSlice;
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
export declare const SliceWidget: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
3
|
+
type: t.LiteralC<"Group">;
|
|
4
|
+
}>, t.PartialC<{
|
|
5
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
6
|
+
icon: t.StringC;
|
|
7
|
+
description: t.StringC;
|
|
8
|
+
config: t.ExactC<t.PartialC<{
|
|
9
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
10
|
+
repeat: t.BooleanC;
|
|
11
|
+
fields: t.RecordC<t.Type<string, string, unknown>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
12
|
+
type: t.LiteralC<"Color">;
|
|
13
|
+
}>, t.PartialC<{
|
|
14
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
15
|
+
config: t.ExactC<t.PartialC<{
|
|
16
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
17
|
+
placeholder: t.StringC;
|
|
18
|
+
}>>;
|
|
19
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
20
|
+
type: t.LiteralC<"Boolean">;
|
|
21
|
+
}>, t.PartialC<{
|
|
22
|
+
config: t.ExactC<t.PartialC<{
|
|
23
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
24
|
+
default_value: t.BooleanC;
|
|
25
|
+
placeholder_true: t.StringC;
|
|
26
|
+
placeholder_false: t.StringC;
|
|
27
|
+
}>>;
|
|
28
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
29
|
+
type: t.LiteralC<"Embed">;
|
|
30
|
+
}>, t.PartialC<{
|
|
31
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
32
|
+
config: t.ExactC<t.PartialC<{
|
|
33
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
34
|
+
placeholder: t.StringC;
|
|
35
|
+
useAsTitle: t.BooleanC;
|
|
36
|
+
}>>;
|
|
37
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
38
|
+
type: t.LiteralC<"GeoPoint">;
|
|
39
|
+
}>, t.PartialC<{
|
|
40
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
41
|
+
config: t.ExactC<t.PartialC<{
|
|
42
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
43
|
+
}>>;
|
|
44
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
45
|
+
type: t.LiteralC<"Date">;
|
|
46
|
+
}>, t.PartialC<{
|
|
47
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
48
|
+
config: t.ExactC<t.PartialC<{
|
|
49
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
50
|
+
placeholder: t.StringC;
|
|
51
|
+
default: t.StringC;
|
|
52
|
+
}>>;
|
|
53
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
54
|
+
type: t.LiteralC<"Number">;
|
|
55
|
+
}>, t.PartialC<{
|
|
56
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
57
|
+
config: t.ExactC<t.PartialC<{
|
|
58
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
59
|
+
placeholder: t.StringC;
|
|
60
|
+
min: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
|
|
61
|
+
max: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
|
|
62
|
+
step: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
|
|
63
|
+
}>>;
|
|
64
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
65
|
+
type: t.LiteralC<"Range">;
|
|
66
|
+
}>, t.PartialC<{
|
|
67
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
68
|
+
config: t.ExactC<t.PartialC<{
|
|
69
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
70
|
+
placeholder: t.StringC;
|
|
71
|
+
min: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
|
|
72
|
+
max: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
|
|
73
|
+
step: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
|
|
74
|
+
}>>;
|
|
75
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
76
|
+
type: t.LiteralC<"StructuredText">;
|
|
77
|
+
}>, t.PartialC<{
|
|
78
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
79
|
+
config: t.ExactC<t.PartialC<{
|
|
80
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
81
|
+
placeholder: t.StringC;
|
|
82
|
+
useAsTitle: t.BooleanC;
|
|
83
|
+
single: t.Type<string, string, unknown>;
|
|
84
|
+
multi: t.Type<string, string, unknown>;
|
|
85
|
+
imageConstraint: t.PartialC<{
|
|
86
|
+
width: t.Type<number | null, unknown, unknown>;
|
|
87
|
+
height: t.Type<number | null, unknown, unknown>;
|
|
88
|
+
}>;
|
|
89
|
+
labels: t.Type<readonly string[], object, unknown>;
|
|
90
|
+
allowTargetBlank: t.BooleanC;
|
|
91
|
+
}>>;
|
|
92
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
93
|
+
type: t.LiteralC<"Select">;
|
|
94
|
+
}>, t.PartialC<{
|
|
95
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
96
|
+
config: t.ExactC<t.PartialC<{
|
|
97
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
98
|
+
placeholder: t.StringC;
|
|
99
|
+
default_value: t.StringC;
|
|
100
|
+
options: t.ReadonlyArrayC<t.UnionC<[t.StringC, t.Type<string, string, unknown>, t.Type<string, string, unknown>]>>;
|
|
101
|
+
}>>;
|
|
102
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
103
|
+
type: t.LiteralC<"Separator">;
|
|
104
|
+
}>, t.PartialC<{
|
|
105
|
+
config: t.ExactC<t.PartialC<{
|
|
106
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
107
|
+
}>>;
|
|
108
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
109
|
+
type: t.LiteralC<"Text">;
|
|
110
|
+
}>, t.PartialC<{
|
|
111
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
112
|
+
config: t.ExactC<t.PartialC<{
|
|
113
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
114
|
+
useAsTitle: t.BooleanC;
|
|
115
|
+
placeholder: t.StringC;
|
|
116
|
+
}>>;
|
|
117
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
118
|
+
type: t.LiteralC<"Timestamp">;
|
|
119
|
+
}>, t.PartialC<{
|
|
120
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
121
|
+
config: t.ExactC<t.PartialC<{
|
|
122
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
123
|
+
placeholder: t.StringC;
|
|
124
|
+
default: t.StringC;
|
|
125
|
+
}>>;
|
|
126
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
127
|
+
type: t.LiteralC<"Link">;
|
|
128
|
+
}>, t.PartialC<{
|
|
129
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
130
|
+
config: t.ExactC<t.PartialC<{
|
|
131
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
132
|
+
useAsTitle: t.BooleanC;
|
|
133
|
+
placeholder: t.StringC;
|
|
134
|
+
select: t.UnionC<[t.LiteralC<"media">, t.LiteralC<"document">, t.LiteralC<"web">, t.NullC]>;
|
|
135
|
+
customtypes: t.ReadonlyArrayC<t.StringC>;
|
|
136
|
+
masks: t.Type<readonly string[], object, unknown>;
|
|
137
|
+
tags: t.Type<readonly string[], object, unknown>;
|
|
138
|
+
allowTargetBlank: t.BooleanC;
|
|
139
|
+
}>>;
|
|
140
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
141
|
+
type: t.LiteralC<"Image">;
|
|
142
|
+
}>, t.PartialC<{
|
|
143
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
144
|
+
config: t.ExactC<t.PartialC<{
|
|
145
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
146
|
+
placeholder: t.StringC;
|
|
147
|
+
constraint: t.PartialC<{
|
|
148
|
+
width: t.Type<number | null, unknown, unknown>;
|
|
149
|
+
height: t.Type<number | null, unknown, unknown>;
|
|
150
|
+
}>;
|
|
151
|
+
thumbnails: t.ReadonlyArrayC<t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
152
|
+
name: t.StringC;
|
|
153
|
+
}>, t.PartialC<{
|
|
154
|
+
width: t.Type<number | null, unknown, unknown>;
|
|
155
|
+
height: t.Type<number | null, unknown, unknown>;
|
|
156
|
+
}>]>>>;
|
|
157
|
+
}>>;
|
|
158
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
159
|
+
type: t.LiteralC<"IntegrationFields">;
|
|
160
|
+
}>, t.PartialC<{
|
|
161
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
162
|
+
config: t.ExactC<t.PartialC<{
|
|
163
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
164
|
+
placeholder: t.StringC;
|
|
165
|
+
catalog: t.StringC;
|
|
166
|
+
}>>;
|
|
167
|
+
}>]>>]>>;
|
|
168
|
+
}>>;
|
|
169
|
+
}>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
170
|
+
type: t.LiteralC<"Color">;
|
|
171
|
+
}>, t.PartialC<{
|
|
172
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
173
|
+
config: t.ExactC<t.PartialC<{
|
|
174
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
175
|
+
placeholder: t.StringC;
|
|
176
|
+
}>>;
|
|
177
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
178
|
+
type: t.LiteralC<"Boolean">;
|
|
179
|
+
}>, t.PartialC<{
|
|
180
|
+
config: t.ExactC<t.PartialC<{
|
|
181
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
182
|
+
default_value: t.BooleanC;
|
|
183
|
+
placeholder_true: t.StringC;
|
|
184
|
+
placeholder_false: t.StringC;
|
|
185
|
+
}>>;
|
|
186
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
187
|
+
type: t.LiteralC<"Embed">;
|
|
188
|
+
}>, t.PartialC<{
|
|
189
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
190
|
+
config: t.ExactC<t.PartialC<{
|
|
191
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
192
|
+
placeholder: t.StringC;
|
|
193
|
+
useAsTitle: t.BooleanC;
|
|
194
|
+
}>>;
|
|
195
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
196
|
+
type: t.LiteralC<"GeoPoint">;
|
|
197
|
+
}>, t.PartialC<{
|
|
198
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
199
|
+
config: t.ExactC<t.PartialC<{
|
|
200
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
201
|
+
}>>;
|
|
202
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
203
|
+
type: t.LiteralC<"Date">;
|
|
204
|
+
}>, t.PartialC<{
|
|
205
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
206
|
+
config: t.ExactC<t.PartialC<{
|
|
207
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
208
|
+
placeholder: t.StringC;
|
|
209
|
+
default: t.StringC;
|
|
210
|
+
}>>;
|
|
211
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
212
|
+
type: t.LiteralC<"Number">;
|
|
213
|
+
}>, t.PartialC<{
|
|
214
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
215
|
+
config: t.ExactC<t.PartialC<{
|
|
216
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
217
|
+
placeholder: t.StringC;
|
|
218
|
+
min: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
|
|
219
|
+
max: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
|
|
220
|
+
step: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
|
|
221
|
+
}>>;
|
|
222
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
223
|
+
type: t.LiteralC<"Range">;
|
|
224
|
+
}>, t.PartialC<{
|
|
225
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
226
|
+
config: t.ExactC<t.PartialC<{
|
|
227
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
228
|
+
placeholder: t.StringC;
|
|
229
|
+
min: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
|
|
230
|
+
max: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
|
|
231
|
+
step: t.UnionC<[t.NumberC, import("io-ts-types").NumberFromStringC]>;
|
|
232
|
+
}>>;
|
|
233
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
234
|
+
type: t.LiteralC<"StructuredText">;
|
|
235
|
+
}>, t.PartialC<{
|
|
236
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
237
|
+
config: t.ExactC<t.PartialC<{
|
|
238
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
239
|
+
placeholder: t.StringC;
|
|
240
|
+
useAsTitle: t.BooleanC;
|
|
241
|
+
single: t.Type<string, string, unknown>;
|
|
242
|
+
multi: t.Type<string, string, unknown>;
|
|
243
|
+
imageConstraint: t.PartialC<{
|
|
244
|
+
width: t.Type<number | null, unknown, unknown>;
|
|
245
|
+
height: t.Type<number | null, unknown, unknown>;
|
|
246
|
+
}>;
|
|
247
|
+
labels: t.Type<readonly string[], object, unknown>;
|
|
248
|
+
allowTargetBlank: t.BooleanC;
|
|
249
|
+
}>>;
|
|
250
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
251
|
+
type: t.LiteralC<"Select">;
|
|
252
|
+
}>, t.PartialC<{
|
|
253
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
254
|
+
config: t.ExactC<t.PartialC<{
|
|
255
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
256
|
+
placeholder: t.StringC;
|
|
257
|
+
default_value: t.StringC;
|
|
258
|
+
options: t.ReadonlyArrayC<t.UnionC<[t.StringC, t.Type<string, string, unknown>, t.Type<string, string, unknown>]>>;
|
|
259
|
+
}>>;
|
|
260
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
261
|
+
type: t.LiteralC<"Separator">;
|
|
262
|
+
}>, t.PartialC<{
|
|
263
|
+
config: t.ExactC<t.PartialC<{
|
|
264
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
265
|
+
}>>;
|
|
266
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
267
|
+
type: t.LiteralC<"Text">;
|
|
268
|
+
}>, t.PartialC<{
|
|
269
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
270
|
+
config: t.ExactC<t.PartialC<{
|
|
271
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
272
|
+
useAsTitle: t.BooleanC;
|
|
273
|
+
placeholder: t.StringC;
|
|
274
|
+
}>>;
|
|
275
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
276
|
+
type: t.LiteralC<"Timestamp">;
|
|
277
|
+
}>, t.PartialC<{
|
|
278
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
279
|
+
config: t.ExactC<t.PartialC<{
|
|
280
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
281
|
+
placeholder: t.StringC;
|
|
282
|
+
default: t.StringC;
|
|
283
|
+
}>>;
|
|
284
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
285
|
+
type: t.LiteralC<"Link">;
|
|
286
|
+
}>, t.PartialC<{
|
|
287
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
288
|
+
config: t.ExactC<t.PartialC<{
|
|
289
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
290
|
+
useAsTitle: t.BooleanC;
|
|
291
|
+
placeholder: t.StringC;
|
|
292
|
+
select: t.UnionC<[t.LiteralC<"media">, t.LiteralC<"document">, t.LiteralC<"web">, t.NullC]>;
|
|
293
|
+
customtypes: t.ReadonlyArrayC<t.StringC>;
|
|
294
|
+
masks: t.Type<readonly string[], object, unknown>;
|
|
295
|
+
tags: t.Type<readonly string[], object, unknown>;
|
|
296
|
+
allowTargetBlank: t.BooleanC;
|
|
297
|
+
}>>;
|
|
298
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
299
|
+
type: t.LiteralC<"Image">;
|
|
300
|
+
}>, t.PartialC<{
|
|
301
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
302
|
+
config: t.ExactC<t.PartialC<{
|
|
303
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
304
|
+
placeholder: t.StringC;
|
|
305
|
+
constraint: t.PartialC<{
|
|
306
|
+
width: t.Type<number | null, unknown, unknown>;
|
|
307
|
+
height: t.Type<number | null, unknown, unknown>;
|
|
308
|
+
}>;
|
|
309
|
+
thumbnails: t.ReadonlyArrayC<t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
310
|
+
name: t.StringC;
|
|
311
|
+
}>, t.PartialC<{
|
|
312
|
+
width: t.Type<number | null, unknown, unknown>;
|
|
313
|
+
height: t.Type<number | null, unknown, unknown>;
|
|
314
|
+
}>]>>>;
|
|
315
|
+
}>>;
|
|
316
|
+
}>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
317
|
+
type: t.LiteralC<"IntegrationFields">;
|
|
318
|
+
}>, t.PartialC<{
|
|
319
|
+
fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
320
|
+
config: t.ExactC<t.PartialC<{
|
|
321
|
+
label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
|
|
322
|
+
placeholder: t.StringC;
|
|
323
|
+
catalog: t.StringC;
|
|
324
|
+
}>>;
|
|
325
|
+
}>]>>]>]>;
|
|
326
|
+
export declare type SliceWidget = t.TypeOf<typeof SliceWidget>;
|
|
327
|
+
export declare type SliceFieldTypes = SliceWidget["type"];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SliceWidget = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
6
|
+
const Group_1 = require("../Group");
|
|
7
|
+
const nestable_1 = require("../nestable");
|
|
8
|
+
exports.SliceWidget = t.union([Group_1.Group, nestable_1.NestableWidget]);
|
package/package.json
CHANGED
|
@@ -268,10 +268,13 @@ export function traverseCustomType<
|
|
|
268
268
|
section,
|
|
269
269
|
onField,
|
|
270
270
|
})
|
|
271
|
+
|
|
271
272
|
if (newSection !== section) {
|
|
272
273
|
if (!json) json = { ...customType.json }
|
|
273
274
|
json[key] = newSection
|
|
274
275
|
}
|
|
275
276
|
}
|
|
277
|
+
|
|
278
|
+
// returns the traversed model instead of a new one if it didn't change
|
|
276
279
|
return json ? { ...customType, json } : customType
|
|
277
280
|
}
|
|
@@ -84,11 +84,13 @@ export function traverseSection<
|
|
|
84
84
|
})
|
|
85
85
|
break
|
|
86
86
|
}
|
|
87
|
+
|
|
87
88
|
if (model !== prevModel) {
|
|
88
89
|
if (!section) section = { ...prevSection }
|
|
89
90
|
section[key] = model
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
// returns the traversed model instead of a new one if it didn't change
|
|
93
95
|
return section ?? prevSection
|
|
94
96
|
}
|
|
@@ -73,6 +73,7 @@ export function traverseNestedGroup(args: {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
// returns the traversed model instead of a new one if it didn't change
|
|
76
77
|
return fields ? { ...group, config: { ...group.config, fields } } : group
|
|
77
78
|
}
|
|
78
79
|
|
|
@@ -107,11 +108,13 @@ export function traverseGroup(args: {
|
|
|
107
108
|
key,
|
|
108
109
|
field,
|
|
109
110
|
})
|
|
111
|
+
|
|
110
112
|
if (field !== newField) {
|
|
111
113
|
if (!fields) fields = { ...group.config.fields }
|
|
112
114
|
fields[key] = newField
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
|
|
118
|
+
// returns the traversed model instead of a new one if it didn't change
|
|
116
119
|
return fields ? { ...group, config: { ...group.config, fields } } : group
|
|
117
120
|
}
|
|
@@ -117,6 +117,7 @@ export function traverseVariation(args: {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
// returns the traversed model instead of a new one if it didn't change
|
|
120
121
|
return primary || items
|
|
121
122
|
? { ...variation, ...(primary && { primary }), ...(items && { items }) }
|
|
122
123
|
: variation
|
|
@@ -146,5 +147,6 @@ export function traverseSharedSlice(args: {
|
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
149
|
|
|
150
|
+
// returns the traversed model instead of a new one if it didn't change
|
|
149
151
|
return variations ? { ...slice, variations } : slice
|
|
150
152
|
}
|