@prismicio/types-internal 0.2.0 → 0.2.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/customtypes/CustomType.d.ts +2 -2
- package/lib/customtypes/CustomType.js +38 -56
- package/lib/customtypes/Format.js +2 -5
- package/lib/customtypes/Section.d.ts +1 -1
- package/lib/customtypes/Section.js +9 -32
- package/lib/customtypes/index.js +4 -30
- package/lib/customtypes/widgets/Group.js +9 -33
- package/lib/customtypes/widgets/UID.js +7 -31
- package/lib/customtypes/widgets/Widget.d.ts +1 -1
- package/lib/customtypes/widgets/Widget.js +14 -40
- package/lib/customtypes/widgets/WidgetTypes.js +1 -3
- package/lib/customtypes/widgets/index.js +7 -35
- package/lib/customtypes/widgets/nestable/BooleanField.js +6 -30
- package/lib/customtypes/widgets/nestable/Color.js +7 -31
- package/lib/customtypes/widgets/nestable/Date.js +7 -31
- package/lib/customtypes/widgets/nestable/Embed.js +7 -31
- package/lib/customtypes/widgets/nestable/GeoPoint.js +7 -31
- package/lib/customtypes/widgets/nestable/Image.js +10 -34
- package/lib/customtypes/widgets/nestable/IntegrationField.js +7 -31
- package/lib/customtypes/widgets/nestable/Link.js +13 -35
- package/lib/customtypes/widgets/nestable/NestableWidget.js +32 -56
- package/lib/customtypes/widgets/nestable/Number.js +11 -35
- package/lib/customtypes/widgets/nestable/Range.js +11 -35
- package/lib/customtypes/widgets/nestable/RichText.js +16 -36
- package/lib/customtypes/widgets/nestable/Select.js +8 -32
- package/lib/customtypes/widgets/nestable/Separator.js +6 -30
- package/lib/customtypes/widgets/nestable/Text.js +7 -31
- package/lib/customtypes/widgets/nestable/Timestamp.js +7 -31
- package/lib/customtypes/widgets/nestable/index.js +15 -36
- package/lib/customtypes/widgets/shared/ImageConstraint.js +9 -30
- package/lib/customtypes/widgets/shared/index.js +1 -8
- package/lib/customtypes/widgets/slices/CompositeSlice.js +10 -34
- package/lib/customtypes/widgets/slices/LegacySlice.js +6 -30
- package/lib/customtypes/widgets/slices/SharedSlice.js +9 -33
- package/lib/customtypes/widgets/slices/SharedSliceRef.js +4 -28
- package/lib/customtypes/widgets/slices/Slice.d.ts +4 -4
- package/lib/customtypes/widgets/slices/Slice.js +1 -2
- package/lib/customtypes/widgets/slices/Slices.js +27 -54
- package/lib/customtypes/widgets/slices/SlicesTypes.js +1 -3
- package/lib/customtypes/widgets/slices/index.js +7 -37
- package/lib/documents/DocumentData.js +4 -25
- package/lib/documents/index.js +2 -28
- package/lib/documents/widgets/EmptyContent.js +3 -6
- package/lib/documents/widgets/GroupContent.js +10 -32
- package/lib/documents/widgets/SimpleWidgetContent.d.ts +2 -2
- package/lib/documents/widgets/SimpleWidgetContent.js +27 -53
- package/lib/documents/widgets/StaticWidgetContent.js +8 -29
- package/lib/documents/widgets/UIDContent.js +4 -26
- package/lib/documents/widgets/index.js +22 -51
- package/lib/documents/widgets/nestable/BooleanContent.js +6 -28
- package/lib/documents/widgets/nestable/EmbedContent.d.ts +4 -4
- package/lib/documents/widgets/nestable/EmbedContent.js +20 -42
- package/lib/documents/widgets/nestable/FieldContent.js +8 -28
- package/lib/documents/widgets/nestable/GeoPointContent.js +5 -27
- package/lib/documents/widgets/nestable/ImageContent.d.ts +14 -14
- package/lib/documents/widgets/nestable/ImageContent.js +12 -34
- package/lib/documents/widgets/nestable/IntegrationFieldsContent.js +6 -28
- package/lib/documents/widgets/nestable/Link/DocumentLink.js +7 -30
- package/lib/documents/widgets/nestable/Link/ExternalLink.d.ts +4 -4
- package/lib/documents/widgets/nestable/Link/ExternalLink.js +10 -33
- package/lib/documents/widgets/nestable/Link/FileLink.js +10 -33
- package/lib/documents/widgets/nestable/Link/ImageLink.js +9 -32
- package/lib/documents/widgets/nestable/Link/LinkContent.d.ts +2 -2
- package/lib/documents/widgets/nestable/Link/LinkContent.js +9 -31
- package/lib/documents/widgets/nestable/Link/index.d.ts +8 -8
- package/lib/documents/widgets/nestable/Link/index.js +24 -51
- package/lib/documents/widgets/nestable/SeparatorContent.js +2 -5
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.d.ts +8 -8
- package/lib/documents/widgets/nestable/StructuredTextContent/Block.js +33 -60
- package/lib/documents/widgets/nestable/StructuredTextContent/index.js +7 -29
- package/lib/documents/widgets/nestable/index.d.ts +2 -2
- package/lib/documents/widgets/nestable/index.js +28 -63
- package/lib/documents/widgets/slices/CompositeSliceContent.d.ts +1 -1
- package/lib/documents/widgets/slices/CompositeSliceContent.js +9 -31
- package/lib/documents/widgets/slices/SharedSliceContent.d.ts +1 -1
- package/lib/documents/widgets/slices/SharedSliceContent.js +12 -34
- package/lib/documents/widgets/slices/SimpleSliceContent.js +2 -8
- package/lib/documents/widgets/slices/SliceWidgetContent.d.ts +1 -1
- package/lib/documents/widgets/slices/SliceWidgetContent.js +8 -33
- package/lib/documents/widgets/slices/SlicesContent.js +13 -35
- package/lib/documents/widgets/slices/index.js +5 -17
- package/lib/index.js +3 -25
- package/lib/validators/DateFromString.js +4 -25
- package/lib/validators/DateFromStringOrNumber.js +4 -25
- package/lib/validators/DateFromTsMs.js +4 -25
- package/lib/validators/IntFromNumber.js +4 -25
- package/lib/validators/IntFromPixels.js +7 -29
- package/lib/validators/NonEmptyString.js +3 -24
- package/lib/validators/NonEmptyStringOrNull.js +7 -12
- package/lib/validators/NumberOrNull.js +3 -24
- package/lib/validators/StringFromBoolean.js +4 -25
- package/lib/validators/StringFromNumber.js +4 -25
- package/lib/validators/StringOrNull.js +3 -24
- package/lib/validators/function.js +17 -47
- package/lib/validators/index.js +12 -48
- package/package.json +1 -1
- package/lib/documents/widgets/Widget.d.ts +0 -0
- package/lib/documents/widgets/Widget.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Either } from "fp-ts/lib/Either";
|
|
2
2
|
import * as t from "io-ts";
|
|
3
|
-
import SharedSlice from "./widgets/slices/SharedSlice";
|
|
3
|
+
import type SharedSlice from "./widgets/slices/SharedSlice";
|
|
4
4
|
import SlicesTypes from "./widgets/slices/SlicesTypes";
|
|
5
|
-
import { DynamicWidget } from "./widgets/Widget";
|
|
5
|
+
import type { DynamicWidget } from "./widgets/Widget";
|
|
6
6
|
import WidgetTypes from "./widgets/WidgetTypes";
|
|
7
7
|
declare class CustomTypeSlicesError extends Error {
|
|
8
8
|
slices: Array<string>;
|
|
@@ -1,41 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.filterMissingSharedSlices = exports.collectWidgets = exports.validateSlices = exports.toStatic = exports.CustomType = exports.StaticCustomType = void 0;
|
|
26
|
-
const Either_1 = require("fp-ts/lib/Either");
|
|
27
|
-
const t = __importStar(require("io-ts"));
|
|
28
|
-
const withFallback_1 = require("io-ts-types/lib/withFallback");
|
|
29
|
-
const validators_1 = require("../validators");
|
|
30
|
-
const Format_1 = require("./Format");
|
|
31
|
-
const Section_1 = require("./Section");
|
|
32
|
-
const SlicesTypes_1 = __importDefault(require("./widgets/slices/SlicesTypes"));
|
|
33
|
-
const WidgetTypes_1 = __importDefault(require("./widgets/WidgetTypes"));
|
|
1
|
+
import { left, right } from "fp-ts/lib/Either";
|
|
2
|
+
import * as t from "io-ts";
|
|
3
|
+
import { withFallback } from "io-ts-types/lib/withFallback";
|
|
4
|
+
import { StringOrNull } from "../validators";
|
|
5
|
+
import { Format } from "./Format";
|
|
6
|
+
import { sectionReader, Sections, } from "./Section";
|
|
7
|
+
import SlicesTypes from "./widgets/slices/SlicesTypes";
|
|
8
|
+
import WidgetTypes from "./widgets/WidgetTypes";
|
|
34
9
|
class CustomTypeSlicesError extends Error {
|
|
35
|
-
slices;
|
|
36
|
-
message;
|
|
37
10
|
constructor(slices) {
|
|
38
11
|
super();
|
|
12
|
+
Object.defineProperty(this, "slices", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: void 0
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(this, "message", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: void 0
|
|
23
|
+
});
|
|
39
24
|
this.slices = slices;
|
|
40
25
|
this.message = this._formatError(slices);
|
|
41
26
|
}
|
|
@@ -50,29 +35,29 @@ function customTypeReader(format) {
|
|
|
50
35
|
return t.exact(t.intersection([
|
|
51
36
|
t.type({
|
|
52
37
|
id: t.string,
|
|
53
|
-
label:
|
|
54
|
-
repeatable:
|
|
55
|
-
json: t.record(t.string,
|
|
56
|
-
status:
|
|
38
|
+
label: StringOrNull,
|
|
39
|
+
repeatable: withFallback(t.boolean, true),
|
|
40
|
+
json: t.record(t.string, sectionReader(format)),
|
|
41
|
+
status: withFallback(t.boolean, true),
|
|
57
42
|
}),
|
|
58
43
|
t.partial({
|
|
59
44
|
hash: t.string,
|
|
60
45
|
}),
|
|
61
46
|
]));
|
|
62
47
|
}
|
|
63
|
-
|
|
64
|
-
|
|
48
|
+
export const StaticCustomType = customTypeReader(Format.Static);
|
|
49
|
+
export const CustomType = customTypeReader(Format.Dynamic);
|
|
65
50
|
function _retrieveSharedSlicesRef(customType) {
|
|
66
51
|
const flattenWidgets = Object.entries(customType.json).reduce((acc, [, section]) => {
|
|
67
52
|
const sectionWidgets = Object.entries(section);
|
|
68
53
|
return acc.concat(sectionWidgets);
|
|
69
54
|
}, []);
|
|
70
|
-
const slicezones = flattenWidgets.filter(([, widget]) => widget.type ===
|
|
55
|
+
const slicezones = flattenWidgets.filter(([, widget]) => widget.type === WidgetTypes.Slices);
|
|
71
56
|
const allSharedRefs = slicezones.reduce((acc, [, slicezone]) => {
|
|
72
57
|
const sharedRefs = Object.entries(slicezone.config && slicezone.config.choices
|
|
73
58
|
? slicezone.config.choices
|
|
74
59
|
: {})
|
|
75
|
-
.filter(([, slice]) => slice.type ===
|
|
60
|
+
.filter(([, slice]) => slice.type === SlicesTypes.SharedSlice)
|
|
76
61
|
.map(([key]) => key);
|
|
77
62
|
return acc.concat(sharedRefs);
|
|
78
63
|
}, []);
|
|
@@ -84,30 +69,29 @@ function _mapSharedSlicesRefs(customType) {
|
|
|
84
69
|
return refs.map(mapFn);
|
|
85
70
|
};
|
|
86
71
|
}
|
|
87
|
-
function toStatic(customType, sharedSlices) {
|
|
72
|
+
export function toStatic(customType, sharedSlices) {
|
|
88
73
|
const json = Object.entries(customType.json).reduce((acc, [sectionKey, dynSection]) => {
|
|
89
74
|
return {
|
|
90
75
|
...acc,
|
|
91
|
-
[sectionKey]:
|
|
76
|
+
[sectionKey]: Sections.toStatic(dynSection, sharedSlices),
|
|
92
77
|
};
|
|
93
78
|
}, {});
|
|
94
79
|
return { ...customType, json };
|
|
95
80
|
}
|
|
96
|
-
|
|
97
|
-
function validateSlices(customType, sharedSlices) {
|
|
81
|
+
export function validateSlices(customType, sharedSlices) {
|
|
98
82
|
const missingSlices = _mapSharedSlicesRefs(customType)((ref) => {
|
|
99
83
|
const slice = sharedSlices.get(ref);
|
|
100
84
|
const isMissing = !slice;
|
|
101
85
|
if (isMissing)
|
|
102
86
|
return ref;
|
|
87
|
+
return;
|
|
103
88
|
}).filter(Boolean);
|
|
104
89
|
if (missingSlices.length > 0)
|
|
105
|
-
return
|
|
90
|
+
return left(new CustomTypeSlicesError(missingSlices));
|
|
106
91
|
else
|
|
107
|
-
return
|
|
92
|
+
return right(customType);
|
|
108
93
|
}
|
|
109
|
-
|
|
110
|
-
function collectWidgets(customType, f) {
|
|
94
|
+
export function collectWidgets(customType, f) {
|
|
111
95
|
const json = Object.entries(customType.json).reduce((acc, [sectionId, section]) => {
|
|
112
96
|
const updatedSection = Object.entries(section).reduce((acc, [ref, widget]) => {
|
|
113
97
|
const updatedWidget = f(ref, widget);
|
|
@@ -120,14 +104,13 @@ function collectWidgets(customType, f) {
|
|
|
120
104
|
}, {});
|
|
121
105
|
return { ...customType, json };
|
|
122
106
|
}
|
|
123
|
-
|
|
124
|
-
function filterMissingSharedSlices(customType, sharedSlices) {
|
|
107
|
+
export function filterMissingSharedSlices(customType, sharedSlices) {
|
|
125
108
|
return collectWidgets(customType, (_widgetId, widget) => {
|
|
126
|
-
if (widget.type ===
|
|
109
|
+
if (widget.type === WidgetTypes.Slices) {
|
|
127
110
|
if (!widget.config || !widget.config.choices)
|
|
128
111
|
return widget;
|
|
129
112
|
const choices = Object.entries(widget.config.choices).reduce((acc, [sliceId, sliceValue]) => {
|
|
130
|
-
if (sliceValue.type ===
|
|
113
|
+
if (sliceValue.type === SlicesTypes.SharedSlice &&
|
|
131
114
|
!sharedSlices.get(sliceId))
|
|
132
115
|
return acc;
|
|
133
116
|
return { ...acc, [sliceId]: sliceValue };
|
|
@@ -138,4 +121,3 @@ function filterMissingSharedSlices(customType, sharedSlices) {
|
|
|
138
121
|
return widget;
|
|
139
122
|
});
|
|
140
123
|
}
|
|
141
|
-
exports.filterMissingSharedSlices = filterMissingSharedSlices;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Format = void 0;
|
|
4
|
-
var Format;
|
|
1
|
+
export var Format;
|
|
5
2
|
(function (Format) {
|
|
6
3
|
Format["Static"] = "static";
|
|
7
4
|
Format["Dynamic"] = "dynamic";
|
|
8
|
-
})(Format
|
|
5
|
+
})(Format || (Format = {}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
2
|
import { Format } from "./Format";
|
|
3
|
-
import SharedSlice from "./widgets/slices/SharedSlice";
|
|
3
|
+
import type SharedSlice from "./widgets/slices/SharedSlice";
|
|
4
4
|
export declare function sectionReader<F extends Format>(format: F): t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
5
5
|
type: t.LiteralC<import("./widgets/WidgetTypes").default.UID>;
|
|
6
6
|
}>, t.PartialC<{
|
|
@@ -1,38 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.Sections = exports.DynamicSection = exports.StaticSection = exports.sectionReader = void 0;
|
|
23
|
-
const t = __importStar(require("io-ts"));
|
|
24
|
-
const Format_1 = require("./Format");
|
|
25
|
-
const Widget_1 = require("./widgets/Widget");
|
|
26
|
-
function sectionReader(format) {
|
|
27
|
-
return t.record(t.string, (0, Widget_1.widgetReader)(format));
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { Format } from "./Format";
|
|
3
|
+
import { widgetReader, Widgets, } from "./widgets/Widget";
|
|
4
|
+
export function sectionReader(format) {
|
|
5
|
+
return t.record(t.string, widgetReader(format));
|
|
28
6
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
exports.Sections = {
|
|
7
|
+
export const StaticSection = sectionReader(Format.Static);
|
|
8
|
+
export const DynamicSection = sectionReader(Format.Dynamic);
|
|
9
|
+
export const Sections = {
|
|
33
10
|
toStatic(dynamic, sharedSlices) {
|
|
34
11
|
const section = Object.entries(dynamic).reduce((acc, [widgetKey, widget]) => {
|
|
35
|
-
return { ...acc, [widgetKey]:
|
|
12
|
+
return { ...acc, [widgetKey]: Widgets.toStatic(widget, sharedSlices) };
|
|
36
13
|
}, {});
|
|
37
14
|
return section;
|
|
38
15
|
},
|
package/lib/customtypes/index.js
CHANGED
|
@@ -1,30 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
-
};
|
|
17
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
-
if (mod && mod.__esModule) return mod;
|
|
19
|
-
var result = {};
|
|
20
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
-
__setModuleDefault(result, mod);
|
|
22
|
-
return result;
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.Widgets = exports.Section = exports.Format = void 0;
|
|
26
|
-
__exportStar(require("./CustomType"), exports);
|
|
27
|
-
var Format_1 = require("./Format");
|
|
28
|
-
Object.defineProperty(exports, "Format", { enumerable: true, get: function () { return Format_1.Format; } });
|
|
29
|
-
exports.Section = __importStar(require("./Section"));
|
|
30
|
-
exports.Widgets = __importStar(require("./widgets"));
|
|
1
|
+
export * from "./CustomType";
|
|
2
|
+
export { Format } from "./Format";
|
|
3
|
+
export * as Section from "./Section";
|
|
4
|
+
export * as Widgets from "./widgets";
|
|
@@ -1,45 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const t = __importStar(require("io-ts"));
|
|
26
|
-
const validators_1 = require("../../validators");
|
|
27
|
-
const NestableWidget_1 = __importDefault(require("./nestable/NestableWidget"));
|
|
28
|
-
const WidgetTypes_1 = __importDefault(require("./WidgetTypes"));
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { StringOrNull } from "../../validators";
|
|
3
|
+
import NestableWidget from "./nestable/NestableWidget";
|
|
4
|
+
import WidgetTypes from "./WidgetTypes";
|
|
29
5
|
const GroupConfig = t.exact(t.partial({
|
|
30
|
-
label:
|
|
6
|
+
label: StringOrNull,
|
|
31
7
|
repeat: t.boolean,
|
|
32
|
-
fields: t.record(t.string,
|
|
8
|
+
fields: t.record(t.string, NestableWidget),
|
|
33
9
|
}));
|
|
34
10
|
const Group = t.exact(t.intersection([
|
|
35
11
|
t.type({
|
|
36
|
-
type: t.literal(
|
|
12
|
+
type: t.literal(WidgetTypes.Group),
|
|
37
13
|
}),
|
|
38
14
|
t.partial({
|
|
39
|
-
fieldset:
|
|
15
|
+
fieldset: StringOrNull,
|
|
40
16
|
icon: t.string,
|
|
41
17
|
description: t.string,
|
|
42
18
|
config: GroupConfig,
|
|
43
19
|
}),
|
|
44
20
|
]));
|
|
45
|
-
|
|
21
|
+
export default Group;
|
|
@@ -1,42 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const t = __importStar(require("io-ts"));
|
|
26
|
-
const validators_1 = require("../../validators");
|
|
27
|
-
const WidgetTypes_1 = __importDefault(require("./WidgetTypes"));
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { StringOrNull } from "../../validators";
|
|
3
|
+
import WidgetTypes from "./WidgetTypes";
|
|
28
4
|
const UIDConfig = t.exact(t.partial({
|
|
29
|
-
label:
|
|
5
|
+
label: StringOrNull,
|
|
30
6
|
useAsTitle: t.boolean,
|
|
31
7
|
placeholder: t.string,
|
|
32
8
|
}));
|
|
33
9
|
const UID = t.exact(t.intersection([
|
|
34
10
|
t.type({
|
|
35
|
-
type: t.literal(
|
|
11
|
+
type: t.literal(WidgetTypes.UID),
|
|
36
12
|
}),
|
|
37
13
|
t.partial({
|
|
38
|
-
fieldset:
|
|
14
|
+
fieldset: StringOrNull,
|
|
39
15
|
config: UIDConfig,
|
|
40
16
|
}),
|
|
41
17
|
]));
|
|
42
|
-
|
|
18
|
+
export default UID;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
2
|
import { Format } from "../Format";
|
|
3
|
-
import SharedSlice from "./slices/SharedSlice";
|
|
3
|
+
import type SharedSlice from "./slices/SharedSlice";
|
|
4
4
|
import WidgetTypes from "./WidgetTypes";
|
|
5
5
|
export declare function widgetReader<F extends Format>(format: F): t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
6
6
|
type: t.LiteralC<WidgetTypes.UID>;
|
|
@@ -1,46 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.Widgets = exports.DynamicWidget = exports.StaticWidget = exports.widgetReader = void 0;
|
|
26
|
-
const t = __importStar(require("io-ts"));
|
|
27
|
-
const Format_1 = require("../Format");
|
|
28
|
-
const Group_1 = __importDefault(require("./Group"));
|
|
29
|
-
const NestableWidget_1 = __importDefault(require("./nestable/NestableWidget"));
|
|
30
|
-
const Slices_1 = require("./slices/Slices");
|
|
31
|
-
const UID_1 = __importDefault(require("./UID"));
|
|
32
|
-
const WidgetTypes_1 = __importDefault(require("./WidgetTypes"));
|
|
33
|
-
function widgetReader(format) {
|
|
34
|
-
return t.union([UID_1.default, NestableWidget_1.default, Group_1.default, (0, Slices_1.slicesReader)(format)]);
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { Format } from "../Format";
|
|
3
|
+
import Group from "./Group";
|
|
4
|
+
import NestableWidget from "./nestable/NestableWidget";
|
|
5
|
+
import { Slices, slicesReader } from "./slices/Slices";
|
|
6
|
+
import UID from "./UID";
|
|
7
|
+
import WidgetTypes from "./WidgetTypes";
|
|
8
|
+
export function widgetReader(format) {
|
|
9
|
+
return t.union([UID, NestableWidget, Group, slicesReader(format)]);
|
|
35
10
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
exports.Widgets = {
|
|
11
|
+
export const StaticWidget = widgetReader(Format.Static);
|
|
12
|
+
export const DynamicWidget = widgetReader(Format.Dynamic);
|
|
13
|
+
export const Widgets = {
|
|
40
14
|
toStatic(widget, sharedSlices) {
|
|
41
15
|
switch (widget.type) {
|
|
42
|
-
case
|
|
43
|
-
return
|
|
16
|
+
case WidgetTypes.Slices:
|
|
17
|
+
return Slices.toStatic(widget, sharedSlices);
|
|
44
18
|
default:
|
|
45
19
|
return widget;
|
|
46
20
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
var WidgetTypes;
|
|
4
2
|
(function (WidgetTypes) {
|
|
5
3
|
WidgetTypes["Text"] = "Text";
|
|
@@ -23,4 +21,4 @@ var WidgetTypes;
|
|
|
23
21
|
// Legacy type for slices
|
|
24
22
|
WidgetTypes["LegacySlices"] = "Choice";
|
|
25
23
|
})(WidgetTypes || (WidgetTypes = {}));
|
|
26
|
-
|
|
24
|
+
export default WidgetTypes;
|
|
@@ -1,35 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.WidgetTypes = exports.Widget = exports.UID = exports.Slices = exports.Shared = exports.Nestable = exports.Group = void 0;
|
|
26
|
-
var Group_1 = require("./Group");
|
|
27
|
-
Object.defineProperty(exports, "Group", { enumerable: true, get: function () { return __importDefault(Group_1).default; } });
|
|
28
|
-
exports.Nestable = __importStar(require("./nestable"));
|
|
29
|
-
exports.Shared = __importStar(require("./shared"));
|
|
30
|
-
exports.Slices = __importStar(require("./slices"));
|
|
31
|
-
var UID_1 = require("./UID");
|
|
32
|
-
Object.defineProperty(exports, "UID", { enumerable: true, get: function () { return __importDefault(UID_1).default; } });
|
|
33
|
-
exports.Widget = __importStar(require("./Widget"));
|
|
34
|
-
var WidgetTypes_1 = require("./WidgetTypes");
|
|
35
|
-
Object.defineProperty(exports, "WidgetTypes", { enumerable: true, get: function () { return __importDefault(WidgetTypes_1).default; } });
|
|
1
|
+
export { default as Group } from "./Group";
|
|
2
|
+
export * as Nestable from "./nestable";
|
|
3
|
+
export * as Shared from "./shared";
|
|
4
|
+
export * as Slices from "./slices";
|
|
5
|
+
export { default as UID } from "./UID";
|
|
6
|
+
export * as Widget from "./Widget";
|
|
7
|
+
export { default as WidgetTypes } from "./WidgetTypes";
|
|
@@ -1,42 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const t = __importStar(require("io-ts"));
|
|
26
|
-
const validators_1 = require("../../../validators");
|
|
27
|
-
const WidgetTypes_1 = __importDefault(require("../WidgetTypes"));
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { StringOrNull } from "../../../validators";
|
|
3
|
+
import WidgetTypes from "../WidgetTypes";
|
|
28
4
|
const BooleanConfig = t.exact(t.partial({
|
|
29
|
-
label:
|
|
5
|
+
label: StringOrNull,
|
|
30
6
|
default_value: t.boolean,
|
|
31
7
|
placeholder_true: t.string,
|
|
32
8
|
placeholder_false: t.string,
|
|
33
9
|
}));
|
|
34
10
|
const BooleanField = t.exact(t.intersection([
|
|
35
11
|
t.type({
|
|
36
|
-
type: t.literal(
|
|
12
|
+
type: t.literal(WidgetTypes.BooleanField),
|
|
37
13
|
}),
|
|
38
14
|
t.partial({
|
|
39
15
|
config: BooleanConfig,
|
|
40
16
|
}),
|
|
41
17
|
]));
|
|
42
|
-
|
|
18
|
+
export default BooleanField;
|
|
@@ -1,41 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const t = __importStar(require("io-ts"));
|
|
26
|
-
const validators_1 = require("../../../validators");
|
|
27
|
-
const WidgetTypes_1 = __importDefault(require("../WidgetTypes"));
|
|
1
|
+
import * as t from "io-ts";
|
|
2
|
+
import { StringOrNull } from "../../../validators";
|
|
3
|
+
import WidgetTypes from "../WidgetTypes";
|
|
28
4
|
const ColorConfig = t.exact(t.partial({
|
|
29
|
-
label:
|
|
5
|
+
label: StringOrNull,
|
|
30
6
|
placeholder: t.string,
|
|
31
7
|
}));
|
|
32
8
|
const Color = t.exact(t.intersection([
|
|
33
9
|
t.type({
|
|
34
|
-
type: t.literal(
|
|
10
|
+
type: t.literal(WidgetTypes.Color),
|
|
35
11
|
}),
|
|
36
12
|
t.partial({
|
|
37
|
-
fieldset:
|
|
13
|
+
fieldset: StringOrNull,
|
|
38
14
|
config: ColorConfig,
|
|
39
15
|
}),
|
|
40
16
|
]));
|
|
41
|
-
|
|
17
|
+
export default Color;
|