@prismicio/types-internal 0.2.2 → 0.2.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.
Files changed (87) hide show
  1. package/lib/customtypes/CustomType.d.ts +2 -20
  2. package/lib/customtypes/CustomType.js +33 -25
  3. package/lib/customtypes/Format.js +5 -2
  4. package/lib/customtypes/Section.d.ts +3 -30
  5. package/lib/customtypes/Section.js +14 -9
  6. package/lib/customtypes/index.js +9 -4
  7. package/lib/customtypes/widgets/Group.js +12 -9
  8. package/lib/customtypes/widgets/UID.js +10 -7
  9. package/lib/customtypes/widgets/Widget.d.ts +3 -30
  10. package/lib/customtypes/widgets/Widget.js +19 -14
  11. package/lib/customtypes/widgets/WidgetTypes.js +3 -1
  12. package/lib/customtypes/widgets/index.js +14 -7
  13. package/lib/customtypes/widgets/nestable/BooleanField.js +9 -6
  14. package/lib/customtypes/widgets/nestable/Color.js +10 -7
  15. package/lib/customtypes/widgets/nestable/Date.js +10 -7
  16. package/lib/customtypes/widgets/nestable/Embed.js +10 -7
  17. package/lib/customtypes/widgets/nestable/GeoPoint.js +10 -7
  18. package/lib/customtypes/widgets/nestable/Image.js +13 -10
  19. package/lib/customtypes/widgets/nestable/IntegrationField.js +10 -7
  20. package/lib/customtypes/widgets/nestable/Link.js +14 -11
  21. package/lib/customtypes/widgets/nestable/NestableWidget.js +35 -32
  22. package/lib/customtypes/widgets/nestable/Number.js +14 -11
  23. package/lib/customtypes/widgets/nestable/Range.js +14 -11
  24. package/lib/customtypes/widgets/nestable/RichText.js +15 -12
  25. package/lib/customtypes/widgets/nestable/Select.js +11 -8
  26. package/lib/customtypes/widgets/nestable/Separator.js +9 -6
  27. package/lib/customtypes/widgets/nestable/Text.js +10 -7
  28. package/lib/customtypes/widgets/nestable/Timestamp.js +10 -7
  29. package/lib/customtypes/widgets/nestable/index.js +36 -15
  30. package/lib/customtypes/widgets/shared/ImageConstraint.js +12 -9
  31. package/lib/customtypes/widgets/shared/index.js +8 -1
  32. package/lib/customtypes/widgets/slices/CompositeSlice.js +13 -10
  33. package/lib/customtypes/widgets/slices/LegacySlice.d.ts +1 -10
  34. package/lib/customtypes/widgets/slices/LegacySlice.js +8 -6
  35. package/lib/customtypes/widgets/slices/SharedSlice.js +12 -9
  36. package/lib/customtypes/widgets/slices/SharedSliceRef.js +7 -4
  37. package/lib/customtypes/widgets/slices/Slice.js +2 -1
  38. package/lib/customtypes/widgets/slices/Slices.d.ts +6 -60
  39. package/lib/customtypes/widgets/slices/Slices.js +33 -27
  40. package/lib/customtypes/widgets/slices/SlicesTypes.js +3 -1
  41. package/lib/customtypes/widgets/slices/index.js +16 -7
  42. package/lib/documents/DocumentData.js +7 -4
  43. package/lib/documents/index.js +7 -2
  44. package/lib/documents/widgets/EmptyContent.js +6 -3
  45. package/lib/documents/widgets/GroupContent.js +14 -10
  46. package/lib/documents/widgets/SimpleWidgetContent.js +32 -27
  47. package/lib/documents/widgets/StaticWidgetContent.js +11 -8
  48. package/lib/documents/widgets/UIDContent.js +8 -4
  49. package/lib/documents/widgets/index.js +27 -22
  50. package/lib/documents/widgets/nestable/BooleanContent.js +10 -6
  51. package/lib/documents/widgets/nestable/EmbedContent.js +24 -20
  52. package/lib/documents/widgets/nestable/FieldContent.js +10 -6
  53. package/lib/documents/widgets/nestable/GeoPointContent.js +9 -5
  54. package/lib/documents/widgets/nestable/ImageContent.js +16 -12
  55. package/lib/documents/widgets/nestable/IntegrationFieldsContent.js +10 -6
  56. package/lib/documents/widgets/nestable/Link/DocumentLink.js +12 -7
  57. package/lib/documents/widgets/nestable/Link/ExternalLink.js +15 -10
  58. package/lib/documents/widgets/nestable/Link/FileLink.js +15 -10
  59. package/lib/documents/widgets/nestable/Link/ImageLink.js +14 -9
  60. package/lib/documents/widgets/nestable/Link/LinkContent.js +13 -9
  61. package/lib/documents/widgets/nestable/Link/index.js +33 -24
  62. package/lib/documents/widgets/nestable/SeparatorContent.js +5 -2
  63. package/lib/documents/widgets/nestable/StructuredTextContent/Block.js +39 -33
  64. package/lib/documents/widgets/nestable/StructuredTextContent/index.js +11 -7
  65. package/lib/documents/widgets/nestable/index.js +39 -28
  66. package/lib/documents/widgets/slices/CompositeSliceContent.js +13 -9
  67. package/lib/documents/widgets/slices/SharedSliceContent.js +16 -12
  68. package/lib/documents/widgets/slices/SimpleSliceContent.js +6 -2
  69. package/lib/documents/widgets/slices/SliceWidgetContent.js +12 -8
  70. package/lib/documents/widgets/slices/SlicesContent.js +17 -13
  71. package/lib/documents/widgets/slices/index.js +8 -5
  72. package/lib/index.js +7 -3
  73. package/lib/validators/DateFromString.js +7 -4
  74. package/lib/validators/DateFromStringOrNumber.js +7 -4
  75. package/lib/validators/DateFromTsMs.js +7 -4
  76. package/lib/validators/IntFromNumber.js +7 -4
  77. package/lib/validators/IntFromPixels.js +7 -4
  78. package/lib/validators/NonEmptyString.js +6 -3
  79. package/lib/validators/NonEmptyStringOrNull.js +10 -7
  80. package/lib/validators/NumberOrNull.js +6 -3
  81. package/lib/validators/StringFromBoolean.js +7 -4
  82. package/lib/validators/StringFromNumber.js +7 -4
  83. package/lib/validators/StringOrNull.js +6 -3
  84. package/lib/validators/function.js +28 -15
  85. package/lib/validators/index.js +27 -12
  86. package/package.json +1 -1
  87. package/src/customtypes/widgets/slices/LegacySlice.ts +1 -2
@@ -357,16 +357,7 @@ export declare const StaticCustomType: t.ExactC<t.IntersectionC<[t.TypeC<{
357
357
  }>, t.PartialC<{
358
358
  display: t.StringC;
359
359
  }>]>>>>, t.NullC]>;
360
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
361
- type: t.LiteralC<WidgetTypes.UID>;
362
- }>, t.PartialC<{
363
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
364
- config: t.ExactC<t.PartialC<{
365
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
366
- useAsTitle: t.BooleanC;
367
- placeholder: t.StringC;
368
- }>>;
369
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
360
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
370
361
  type: t.LiteralC<WidgetTypes.Color>;
371
362
  }>, t.PartialC<{
372
363
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1700,16 +1691,7 @@ export declare const CustomType: t.ExactC<t.IntersectionC<[t.TypeC<{
1700
1691
  }>, t.PartialC<{
1701
1692
  display: t.StringC;
1702
1693
  }>]>>>>, t.NullC]>;
1703
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1704
- type: t.LiteralC<WidgetTypes.UID>;
1705
- }>, t.PartialC<{
1706
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1707
- config: t.ExactC<t.PartialC<{
1708
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1709
- useAsTitle: t.BooleanC;
1710
- placeholder: t.StringC;
1711
- }>>;
1712
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1694
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1713
1695
  type: t.LiteralC<WidgetTypes.Color>;
1714
1696
  }>, t.PartialC<{
1715
1697
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1,11 +1,15 @@
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";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterMissingSharedSlices = exports.collectWidgets = exports.validateSlices = exports.toStatic = exports.CustomType = exports.StaticCustomType = 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 withFallback_1 = require("io-ts-types/lib/withFallback");
8
+ const validators_1 = require("../validators");
9
+ const Format_1 = require("./Format");
10
+ const Section_1 = require("./Section");
11
+ const SlicesTypes_1 = (0, tslib_1.__importDefault)(require("./widgets/slices/SlicesTypes"));
12
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("./widgets/WidgetTypes"));
9
13
  class CustomTypeSlicesError extends Error {
10
14
  constructor(slices) {
11
15
  super();
@@ -35,29 +39,29 @@ function customTypeReader(format) {
35
39
  return t.exact(t.intersection([
36
40
  t.type({
37
41
  id: t.string,
38
- label: StringOrNull,
39
- repeatable: withFallback(t.boolean, true),
40
- json: t.record(t.string, sectionReader(format)),
41
- status: withFallback(t.boolean, true),
42
+ label: validators_1.StringOrNull,
43
+ repeatable: (0, withFallback_1.withFallback)(t.boolean, true),
44
+ json: t.record(t.string, (0, Section_1.sectionReader)(format)),
45
+ status: (0, withFallback_1.withFallback)(t.boolean, true),
42
46
  }),
43
47
  t.partial({
44
48
  hash: t.string,
45
49
  }),
46
50
  ]));
47
51
  }
48
- export const StaticCustomType = customTypeReader(Format.Static);
49
- export const CustomType = customTypeReader(Format.Dynamic);
52
+ exports.StaticCustomType = customTypeReader(Format_1.Format.Static);
53
+ exports.CustomType = customTypeReader(Format_1.Format.Dynamic);
50
54
  function _retrieveSharedSlicesRef(customType) {
51
55
  const flattenWidgets = Object.entries(customType.json).reduce((acc, [, section]) => {
52
56
  const sectionWidgets = Object.entries(section);
53
57
  return acc.concat(sectionWidgets);
54
58
  }, []);
55
- const slicezones = flattenWidgets.filter(([, widget]) => widget.type === WidgetTypes.Slices);
59
+ const slicezones = flattenWidgets.filter(([, widget]) => widget.type === WidgetTypes_1.default.Slices);
56
60
  const allSharedRefs = slicezones.reduce((acc, [, slicezone]) => {
57
61
  const sharedRefs = Object.entries(slicezone.config && slicezone.config.choices
58
62
  ? slicezone.config.choices
59
63
  : {})
60
- .filter(([, slice]) => slice.type === SlicesTypes.SharedSlice)
64
+ .filter(([, slice]) => slice.type === SlicesTypes_1.default.SharedSlice)
61
65
  .map(([key]) => key);
62
66
  return acc.concat(sharedRefs);
63
67
  }, []);
@@ -69,16 +73,17 @@ function _mapSharedSlicesRefs(customType) {
69
73
  return refs.map(mapFn);
70
74
  };
71
75
  }
72
- export function toStatic(customType, sharedSlices) {
76
+ function toStatic(customType, sharedSlices) {
73
77
  const json = Object.entries(customType.json).reduce((acc, [sectionKey, dynSection]) => {
74
78
  return {
75
79
  ...acc,
76
- [sectionKey]: Sections.toStatic(dynSection, sharedSlices),
80
+ [sectionKey]: Section_1.Sections.toStatic(dynSection, sharedSlices),
77
81
  };
78
82
  }, {});
79
83
  return { ...customType, json };
80
84
  }
81
- export function validateSlices(customType, sharedSlices) {
85
+ exports.toStatic = toStatic;
86
+ function validateSlices(customType, sharedSlices) {
82
87
  const missingSlices = _mapSharedSlicesRefs(customType)((ref) => {
83
88
  const slice = sharedSlices.get(ref);
84
89
  const isMissing = !slice;
@@ -87,11 +92,12 @@ export function validateSlices(customType, sharedSlices) {
87
92
  return;
88
93
  }).filter(Boolean);
89
94
  if (missingSlices.length > 0)
90
- return left(new CustomTypeSlicesError(missingSlices));
95
+ return (0, Either_1.left)(new CustomTypeSlicesError(missingSlices));
91
96
  else
92
- return right(customType);
97
+ return (0, Either_1.right)(customType);
93
98
  }
94
- export function collectWidgets(customType, f) {
99
+ exports.validateSlices = validateSlices;
100
+ function collectWidgets(customType, f) {
95
101
  const json = Object.entries(customType.json).reduce((acc, [sectionId, section]) => {
96
102
  const updatedSection = Object.entries(section).reduce((acc, [ref, widget]) => {
97
103
  const updatedWidget = f(ref, widget);
@@ -104,13 +110,14 @@ export function collectWidgets(customType, f) {
104
110
  }, {});
105
111
  return { ...customType, json };
106
112
  }
107
- export function filterMissingSharedSlices(customType, sharedSlices) {
113
+ exports.collectWidgets = collectWidgets;
114
+ function filterMissingSharedSlices(customType, sharedSlices) {
108
115
  return collectWidgets(customType, (_widgetId, widget) => {
109
- if (widget.type === WidgetTypes.Slices) {
116
+ if (widget.type === WidgetTypes_1.default.Slices) {
110
117
  if (!widget.config || !widget.config.choices)
111
118
  return widget;
112
119
  const choices = Object.entries(widget.config.choices).reduce((acc, [sliceId, sliceValue]) => {
113
- if (sliceValue.type === SlicesTypes.SharedSlice &&
120
+ if (sliceValue.type === SlicesTypes_1.default.SharedSlice &&
114
121
  !sharedSlices.get(sliceId))
115
122
  return acc;
116
123
  return { ...acc, [sliceId]: sliceValue };
@@ -121,3 +128,4 @@ export function filterMissingSharedSlices(customType, sharedSlices) {
121
128
  return widget;
122
129
  });
123
130
  }
131
+ exports.filterMissingSharedSlices = filterMissingSharedSlices;
@@ -1,5 +1,8 @@
1
- export var Format;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Format = void 0;
4
+ var Format;
2
5
  (function (Format) {
3
6
  Format["Static"] = "static";
4
7
  Format["Dynamic"] = "dynamic";
5
- })(Format || (Format = {}));
8
+ })(Format = exports.Format || (exports.Format = {}));
@@ -344,16 +344,7 @@ export declare function sectionReader<F extends Format>(format: F): t.RecordC<t.
344
344
  }>, t.PartialC<{
345
345
  display: t.StringC;
346
346
  }>]>>>>, t.NullC]>;
347
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
348
- type: t.LiteralC<import("./widgets/WidgetTypes").default.UID>;
349
- }>, t.PartialC<{
350
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
351
- config: t.ExactC<t.PartialC<{
352
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
353
- useAsTitle: t.BooleanC;
354
- placeholder: t.StringC;
355
- }>>;
356
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
347
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
357
348
  type: t.LiteralC<import("./widgets/WidgetTypes").default.Color>;
358
349
  }>, t.PartialC<{
359
350
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1678,16 +1669,7 @@ export declare const StaticSection: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.In
1678
1669
  }>, t.PartialC<{
1679
1670
  display: t.StringC;
1680
1671
  }>]>>>>, t.NullC]>;
1681
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1682
- type: t.LiteralC<import("./widgets/WidgetTypes").default.UID>;
1683
- }>, t.PartialC<{
1684
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1685
- config: t.ExactC<t.PartialC<{
1686
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1687
- useAsTitle: t.BooleanC;
1688
- placeholder: t.StringC;
1689
- }>>;
1690
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1672
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1691
1673
  type: t.LiteralC<import("./widgets/WidgetTypes").default.Color>;
1692
1674
  }>, t.PartialC<{
1693
1675
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -3013,16 +2995,7 @@ export declare const DynamicSection: t.RecordC<t.StringC, t.UnionC<[t.ExactC<t.I
3013
2995
  }>, t.PartialC<{
3014
2996
  display: t.StringC;
3015
2997
  }>]>>>>, t.NullC]>;
3016
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
3017
- type: t.LiteralC<import("./widgets/WidgetTypes").default.UID>;
3018
- }>, t.PartialC<{
3019
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
3020
- config: t.ExactC<t.PartialC<{
3021
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
3022
- useAsTitle: t.BooleanC;
3023
- placeholder: t.StringC;
3024
- }>>;
3025
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
2998
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
3026
2999
  type: t.LiteralC<import("./widgets/WidgetTypes").default.Color>;
3027
3000
  }>, t.PartialC<{
3028
3001
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1,15 +1,20 @@
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));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Sections = exports.DynamicSection = exports.StaticSection = exports.sectionReader = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const Format_1 = require("./Format");
7
+ const Widget_1 = require("./widgets/Widget");
8
+ function sectionReader(format) {
9
+ return t.record(t.string, (0, Widget_1.widgetReader)(format));
6
10
  }
7
- export const StaticSection = sectionReader(Format.Static);
8
- export const DynamicSection = sectionReader(Format.Dynamic);
9
- export const Sections = {
11
+ exports.sectionReader = sectionReader;
12
+ exports.StaticSection = sectionReader(Format_1.Format.Static);
13
+ exports.DynamicSection = sectionReader(Format_1.Format.Dynamic);
14
+ exports.Sections = {
10
15
  toStatic(dynamic, sharedSlices) {
11
16
  const section = Object.entries(dynamic).reduce((acc, [widgetKey, widget]) => {
12
- return { ...acc, [widgetKey]: Widgets.toStatic(widget, sharedSlices) };
17
+ return { ...acc, [widgetKey]: Widget_1.Widgets.toStatic(widget, sharedSlices) };
13
18
  }, {});
14
19
  return section;
15
20
  },
@@ -1,4 +1,9 @@
1
- export * from "./CustomType";
2
- export { Format } from "./Format";
3
- export * as Section from "./Section";
4
- export * as Widgets from "./widgets";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Widgets = exports.Section = exports.Format = void 0;
4
+ const tslib_1 = require("tslib");
5
+ (0, tslib_1.__exportStar)(require("./CustomType"), exports);
6
+ var Format_1 = require("./Format");
7
+ Object.defineProperty(exports, "Format", { enumerable: true, get: function () { return Format_1.Format; } });
8
+ exports.Section = (0, tslib_1.__importStar)(require("./Section"));
9
+ exports.Widgets = (0, tslib_1.__importStar)(require("./widgets"));
@@ -1,21 +1,24 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../validators";
3
- import NestableWidget from "./nestable/NestableWidget";
4
- import WidgetTypes from "./WidgetTypes";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
5
+ const validators_1 = require("../../validators");
6
+ const NestableWidget_1 = (0, tslib_1.__importDefault)(require("./nestable/NestableWidget"));
7
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("./WidgetTypes"));
5
8
  const GroupConfig = t.exact(t.partial({
6
- label: StringOrNull,
9
+ label: validators_1.StringOrNull,
7
10
  repeat: t.boolean,
8
- fields: t.record(t.string, NestableWidget),
11
+ fields: t.record(t.string, NestableWidget_1.default),
9
12
  }));
10
13
  const Group = t.exact(t.intersection([
11
14
  t.type({
12
- type: t.literal(WidgetTypes.Group),
15
+ type: t.literal(WidgetTypes_1.default.Group),
13
16
  }),
14
17
  t.partial({
15
- fieldset: StringOrNull,
18
+ fieldset: validators_1.StringOrNull,
16
19
  icon: t.string,
17
20
  description: t.string,
18
21
  config: GroupConfig,
19
22
  }),
20
23
  ]));
21
- export default Group;
24
+ exports.default = Group;
@@ -1,18 +1,21 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../validators";
3
- import WidgetTypes from "./WidgetTypes";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
5
+ const validators_1 = require("../../validators");
6
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("./WidgetTypes"));
4
7
  const UIDConfig = t.exact(t.partial({
5
- label: StringOrNull,
8
+ label: validators_1.StringOrNull,
6
9
  useAsTitle: t.boolean,
7
10
  placeholder: t.string,
8
11
  }));
9
12
  const UID = t.exact(t.intersection([
10
13
  t.type({
11
- type: t.literal(WidgetTypes.UID),
14
+ type: t.literal(WidgetTypes_1.default.UID),
12
15
  }),
13
16
  t.partial({
14
- fieldset: StringOrNull,
17
+ fieldset: validators_1.StringOrNull,
15
18
  config: UIDConfig,
16
19
  }),
17
20
  ]));
18
- export default UID;
21
+ exports.default = UID;
@@ -345,16 +345,7 @@ export declare function widgetReader<F extends Format>(format: F): t.UnionC<[t.E
345
345
  }>, t.PartialC<{
346
346
  display: t.StringC;
347
347
  }>]>>>>, t.NullC]>;
348
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
349
- type: t.LiteralC<WidgetTypes.UID>;
350
- }>, t.PartialC<{
351
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
352
- config: t.ExactC<t.PartialC<{
353
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
354
- useAsTitle: t.BooleanC;
355
- placeholder: t.StringC;
356
- }>>;
357
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
348
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
358
349
  type: t.LiteralC<WidgetTypes.Color>;
359
350
  }>, t.PartialC<{
360
351
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1679,16 +1670,7 @@ export declare const StaticWidget: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1679
1670
  }>, t.PartialC<{
1680
1671
  display: t.StringC;
1681
1672
  }>]>>>>, t.NullC]>;
1682
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1683
- type: t.LiteralC<WidgetTypes.UID>;
1684
- }>, t.PartialC<{
1685
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1686
- config: t.ExactC<t.PartialC<{
1687
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1688
- useAsTitle: t.BooleanC;
1689
- placeholder: t.StringC;
1690
- }>>;
1691
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1673
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
1692
1674
  type: t.LiteralC<WidgetTypes.Color>;
1693
1675
  }>, t.PartialC<{
1694
1676
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -3014,16 +2996,7 @@ export declare const DynamicWidget: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<
3014
2996
  }>, t.PartialC<{
3015
2997
  display: t.StringC;
3016
2998
  }>]>>>>, t.NullC]>;
3017
- choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
3018
- type: t.LiteralC<WidgetTypes.UID>;
3019
- }>, t.PartialC<{
3020
- fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
3021
- config: t.ExactC<t.PartialC<{
3022
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
3023
- useAsTitle: t.BooleanC;
3024
- placeholder: t.StringC;
3025
- }>>;
3026
- }>]>>, t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
2999
+ choices: t.RecordC<t.StringC, t.UnionC<[t.UnionC<[t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
3027
3000
  type: t.LiteralC<WidgetTypes.Color>;
3028
3001
  }>, t.PartialC<{
3029
3002
  fieldset: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -1,20 +1,25 @@
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)]);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Widgets = exports.DynamicWidget = exports.StaticWidget = exports.widgetReader = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
6
+ const Format_1 = require("../Format");
7
+ const Group_1 = (0, tslib_1.__importDefault)(require("./Group"));
8
+ const NestableWidget_1 = (0, tslib_1.__importDefault)(require("./nestable/NestableWidget"));
9
+ const Slices_1 = require("./slices/Slices");
10
+ const UID_1 = (0, tslib_1.__importDefault)(require("./UID"));
11
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("./WidgetTypes"));
12
+ function widgetReader(format) {
13
+ return t.union([UID_1.default, NestableWidget_1.default, Group_1.default, (0, Slices_1.slicesReader)(format)]);
10
14
  }
11
- export const StaticWidget = widgetReader(Format.Static);
12
- export const DynamicWidget = widgetReader(Format.Dynamic);
13
- export const Widgets = {
15
+ exports.widgetReader = widgetReader;
16
+ exports.StaticWidget = widgetReader(Format_1.Format.Static);
17
+ exports.DynamicWidget = widgetReader(Format_1.Format.Dynamic);
18
+ exports.Widgets = {
14
19
  toStatic(widget, sharedSlices) {
15
20
  switch (widget.type) {
16
- case WidgetTypes.Slices:
17
- return Slices.toStatic(widget, sharedSlices);
21
+ case WidgetTypes_1.default.Slices:
22
+ return Slices_1.Slices.toStatic(widget, sharedSlices);
18
23
  default:
19
24
  return widget;
20
25
  }
@@ -1,3 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  var WidgetTypes;
2
4
  (function (WidgetTypes) {
3
5
  WidgetTypes["Text"] = "Text";
@@ -21,4 +23,4 @@ var WidgetTypes;
21
23
  // Legacy type for slices
22
24
  WidgetTypes["LegacySlices"] = "Choice";
23
25
  })(WidgetTypes || (WidgetTypes = {}));
24
- export default WidgetTypes;
26
+ exports.default = WidgetTypes;
@@ -1,7 +1,14 @@
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
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WidgetTypes = exports.Widget = exports.UID = exports.Slices = exports.Shared = exports.Nestable = exports.Group = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var Group_1 = require("./Group");
6
+ Object.defineProperty(exports, "Group", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(Group_1).default; } });
7
+ exports.Nestable = (0, tslib_1.__importStar)(require("./nestable"));
8
+ exports.Shared = (0, tslib_1.__importStar)(require("./shared"));
9
+ exports.Slices = (0, tslib_1.__importStar)(require("./slices"));
10
+ var UID_1 = require("./UID");
11
+ Object.defineProperty(exports, "UID", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(UID_1).default; } });
12
+ exports.Widget = (0, tslib_1.__importStar)(require("./Widget"));
13
+ var WidgetTypes_1 = require("./WidgetTypes");
14
+ Object.defineProperty(exports, "WidgetTypes", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(WidgetTypes_1).default; } });
@@ -1,18 +1,21 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../../validators";
3
- import WidgetTypes from "../WidgetTypes";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
5
+ const validators_1 = require("../../../validators");
6
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("../WidgetTypes"));
4
7
  const BooleanConfig = t.exact(t.partial({
5
- label: StringOrNull,
8
+ label: validators_1.StringOrNull,
6
9
  default_value: t.boolean,
7
10
  placeholder_true: t.string,
8
11
  placeholder_false: t.string,
9
12
  }));
10
13
  const BooleanField = t.exact(t.intersection([
11
14
  t.type({
12
- type: t.literal(WidgetTypes.BooleanField),
15
+ type: t.literal(WidgetTypes_1.default.BooleanField),
13
16
  }),
14
17
  t.partial({
15
18
  config: BooleanConfig,
16
19
  }),
17
20
  ]));
18
- export default BooleanField;
21
+ exports.default = BooleanField;
@@ -1,17 +1,20 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../../validators";
3
- import WidgetTypes from "../WidgetTypes";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
5
+ const validators_1 = require("../../../validators");
6
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("../WidgetTypes"));
4
7
  const ColorConfig = t.exact(t.partial({
5
- label: StringOrNull,
8
+ label: validators_1.StringOrNull,
6
9
  placeholder: t.string,
7
10
  }));
8
11
  const Color = t.exact(t.intersection([
9
12
  t.type({
10
- type: t.literal(WidgetTypes.Color),
13
+ type: t.literal(WidgetTypes_1.default.Color),
11
14
  }),
12
15
  t.partial({
13
- fieldset: StringOrNull,
16
+ fieldset: validators_1.StringOrNull,
14
17
  config: ColorConfig,
15
18
  }),
16
19
  ]));
17
- export default Color;
20
+ exports.default = Color;
@@ -1,18 +1,21 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../../validators";
3
- import WidgetTypes from "../WidgetTypes";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
5
+ const validators_1 = require("../../../validators");
6
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("../WidgetTypes"));
4
7
  const DateConfig = t.exact(t.partial({
5
- label: StringOrNull,
8
+ label: validators_1.StringOrNull,
6
9
  placeholder: t.string,
7
10
  default: t.string,
8
11
  }));
9
12
  const Date = t.exact(t.intersection([
10
13
  t.type({
11
- type: t.literal(WidgetTypes.Date),
14
+ type: t.literal(WidgetTypes_1.default.Date),
12
15
  }),
13
16
  t.partial({
14
- fieldset: StringOrNull,
17
+ fieldset: validators_1.StringOrNull,
15
18
  config: DateConfig,
16
19
  }),
17
20
  ]));
18
- export default Date;
21
+ exports.default = Date;
@@ -1,18 +1,21 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../../validators";
3
- import WidgetTypes from "../WidgetTypes";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
5
+ const validators_1 = require("../../../validators");
6
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("../WidgetTypes"));
4
7
  const EmbedConfig = t.exact(t.partial({
5
- label: StringOrNull,
8
+ label: validators_1.StringOrNull,
6
9
  placeholder: t.string,
7
10
  useAsTitle: t.boolean,
8
11
  }));
9
12
  const Embed = t.exact(t.intersection([
10
13
  t.type({
11
- type: t.literal(WidgetTypes.Embed),
14
+ type: t.literal(WidgetTypes_1.default.Embed),
12
15
  }),
13
16
  t.partial({
14
- fieldset: StringOrNull,
17
+ fieldset: validators_1.StringOrNull,
15
18
  config: EmbedConfig,
16
19
  }),
17
20
  ]));
18
- export default Embed;
21
+ exports.default = Embed;
@@ -1,16 +1,19 @@
1
- import * as t from "io-ts";
2
- import { StringOrNull } from "../../../validators";
3
- import WidgetTypes from "../WidgetTypes";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
5
+ const validators_1 = require("../../../validators");
6
+ const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("../WidgetTypes"));
4
7
  const GeoPointConfig = t.exact(t.partial({
5
- label: StringOrNull,
8
+ label: validators_1.StringOrNull,
6
9
  }));
7
10
  const GeoPoint = t.exact(t.intersection([
8
11
  t.type({
9
- type: t.literal(WidgetTypes.GeoPoint),
12
+ type: t.literal(WidgetTypes_1.default.GeoPoint),
10
13
  }),
11
14
  t.partial({
12
- fieldset: StringOrNull,
15
+ fieldset: validators_1.StringOrNull,
13
16
  config: GeoPointConfig,
14
17
  }),
15
18
  ]));
16
- export default GeoPoint;
19
+ exports.default = GeoPoint;