@prismicio/types-internal 0.2.4 → 0.2.6

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 (43) hide show
  1. package/lib/customtypes/CustomType.d.ts +2 -1
  2. package/lib/customtypes/CustomType.js +7 -4
  3. package/lib/customtypes/Section.d.ts +1 -1
  4. package/lib/customtypes/widgets/Widget.d.ts +1 -1
  5. package/lib/customtypes/widgets/nestable/NestableWidget.js +2 -2
  6. package/lib/customtypes/widgets/nestable/RichText.d.ts +22 -3
  7. package/lib/customtypes/widgets/nestable/RichText.js +64 -24
  8. package/lib/customtypes/widgets/nestable/index.d.ts +2 -1
  9. package/lib/customtypes/widgets/nestable/index.js +19 -20
  10. package/lib/customtypes/widgets/slices/SharedSlice.d.ts +327 -3
  11. package/lib/customtypes/widgets/slices/SharedSlice.js +4 -4
  12. package/lib/customtypes/widgets/slices/Slice.d.ts +1 -1
  13. package/lib/customtypes/widgets/slices/Slices.d.ts +1 -1
  14. package/lib/customtypes/widgets/slices/Slices.js +2 -2
  15. package/lib/customtypes/widgets/slices/index.d.ts +1 -1
  16. package/lib/customtypes/widgets/slices/index.js +2 -3
  17. package/lib/documents/widgets/SimpleWidgetContent.d.ts +2 -2
  18. package/lib/documents/widgets/SimpleWidgetContent.js +2 -2
  19. package/lib/documents/widgets/index.d.ts +13 -13
  20. package/lib/documents/widgets/nestable/EmbedContent.d.ts +6 -3
  21. package/lib/documents/widgets/nestable/EmbedContent.js +2 -3
  22. package/lib/documents/widgets/nestable/FieldContent.d.ts +3 -2
  23. package/lib/documents/widgets/nestable/StructuredTextContent/Block.d.ts +2 -3
  24. package/lib/documents/widgets/nestable/StructuredTextContent/Block.js +2 -2
  25. package/lib/documents/widgets/nestable/index.d.ts +1 -1
  26. package/lib/documents/widgets/nestable/index.js +2 -3
  27. package/package.json +1 -1
  28. package/src/customtypes/CustomType.ts +8 -7
  29. package/src/customtypes/Section.ts +1 -1
  30. package/src/customtypes/widgets/Widget.ts +1 -1
  31. package/src/customtypes/widgets/nestable/NestableWidget.ts +1 -1
  32. package/src/customtypes/widgets/nestable/RichText.ts +64 -24
  33. package/src/customtypes/widgets/nestable/index.ts +2 -1
  34. package/src/customtypes/widgets/slices/SharedSlice.ts +4 -6
  35. package/src/customtypes/widgets/slices/Slice.ts +1 -1
  36. package/src/customtypes/widgets/slices/Slices.ts +1 -1
  37. package/src/customtypes/widgets/slices/index.ts +1 -1
  38. package/src/documents/widgets/SimpleWidgetContent.ts +4 -4
  39. package/src/documents/widgets/index.ts +1 -1
  40. package/src/documents/widgets/nestable/EmbedContent.ts +8 -6
  41. package/src/documents/widgets/nestable/FieldContent.ts +10 -2
  42. package/src/documents/widgets/nestable/StructuredTextContent/Block.ts +1 -1
  43. package/src/documents/widgets/nestable/index.ts +1 -1
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SharedSlice = exports.Variation = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  const t = (0, tslib_1.__importStar)(require("io-ts"));
5
6
  const withFallback_1 = require("io-ts-types/lib/withFallback");
6
7
  const NestableWidget_1 = (0, tslib_1.__importDefault)(require("../nestable/NestableWidget"));
7
8
  const SlicesTypes_1 = (0, tslib_1.__importDefault)(require("./SlicesTypes"));
8
9
  const IMAGE_PLACEHOLDER_URL = "https://images.prismic.io/slice-machine/621a5ec4-0387-4bc5-9860-2dd46cbc07cd_default_ss.png?auto=compress,format";
9
- const Variation = t.exact(t.intersection([
10
+ exports.Variation = t.exact(t.intersection([
10
11
  t.type({
11
12
  id: t.string,
12
13
  name: t.string,
@@ -21,15 +22,14 @@ const Variation = t.exact(t.intersection([
21
22
  items: t.record(t.string, NestableWidget_1.default),
22
23
  }),
23
24
  ]));
24
- const SharedSlice = t.exact(t.intersection([
25
+ exports.SharedSlice = t.exact(t.intersection([
25
26
  t.type({
26
27
  id: t.string,
27
28
  type: t.literal(SlicesTypes_1.default.SharedSlice),
28
29
  name: t.string,
29
- variations: t.array(Variation),
30
+ variations: t.array(exports.Variation),
30
31
  }),
31
32
  t.partial({
32
33
  description: t.string,
33
34
  }),
34
35
  ]));
35
- exports.default = SharedSlice;
@@ -1,6 +1,6 @@
1
1
  import type CompositeSlice from "./CompositeSlice";
2
2
  import type LegacySlice from "./LegacySlice";
3
- import type SharedSlice from "./SharedSlice";
3
+ import type { SharedSlice } from "./SharedSlice";
4
4
  import type SharedSliceRef from "./SharedSliceRef";
5
5
  export declare type DynamicSlice = CompositeSlice | LegacySlice | SharedSliceRef;
6
6
  export declare type StaticSlice = CompositeSlice | LegacySlice | SharedSlice;
@@ -1,7 +1,7 @@
1
1
  import * as t from "io-ts";
2
2
  import { Format } from "../../Format";
3
3
  import WidgetTypes from "../WidgetTypes";
4
- import SharedSlice from "./SharedSlice";
4
+ import { SharedSlice } from "./SharedSlice";
5
5
  import SlicesTypes from "./SlicesTypes";
6
6
  export declare function slicesConfigReader<F extends Format>(format: F): t.ExactC<t.PartialC<{
7
7
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -8,7 +8,7 @@ const Format_1 = require("../../Format");
8
8
  const WidgetTypes_1 = (0, tslib_1.__importDefault)(require("../WidgetTypes"));
9
9
  const CompositeSlice_1 = (0, tslib_1.__importDefault)(require("./CompositeSlice"));
10
10
  const LegacySlice_1 = (0, tslib_1.__importDefault)(require("./LegacySlice"));
11
- const SharedSlice_1 = (0, tslib_1.__importDefault)(require("./SharedSlice"));
11
+ const SharedSlice_1 = require("./SharedSlice");
12
12
  const SharedSliceRef_1 = (0, tslib_1.__importDefault)(require("./SharedSliceRef"));
13
13
  const SlicesTypes_1 = (0, tslib_1.__importDefault)(require("./SlicesTypes"));
14
14
  const SlicesLabels = t.union([
@@ -32,7 +32,7 @@ function slicesConfigReader(format) {
32
32
  (() => {
33
33
  switch (format) {
34
34
  case Format_1.Format.Static:
35
- return SharedSlice_1.default;
35
+ return SharedSlice_1.SharedSlice;
36
36
  case Format_1.Format.Dynamic:
37
37
  return SharedSliceRef_1.default;
38
38
  default:
@@ -1,6 +1,6 @@
1
1
  export { default as CompositeSlice } from "./CompositeSlice";
2
2
  export { default as LegacySlice } from "./LegacySlice";
3
- export { default as SharedSlice } from "./SharedSlice";
3
+ export * from "./SharedSlice";
4
4
  export { default as SharedSliceRef } from "./SharedSliceRef";
5
5
  export * as Slice from "./Slice";
6
6
  export * as SliceZone from "./Slices";
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SlicesTypes = exports.SliceZone = exports.Slice = exports.SharedSliceRef = exports.SharedSlice = exports.LegacySlice = exports.CompositeSlice = void 0;
3
+ exports.SlicesTypes = exports.SliceZone = exports.Slice = exports.SharedSliceRef = exports.LegacySlice = exports.CompositeSlice = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  var CompositeSlice_1 = require("./CompositeSlice");
6
6
  Object.defineProperty(exports, "CompositeSlice", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(CompositeSlice_1).default; } });
7
7
  var LegacySlice_1 = require("./LegacySlice");
8
8
  Object.defineProperty(exports, "LegacySlice", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(LegacySlice_1).default; } });
9
- var SharedSlice_1 = require("./SharedSlice");
10
- Object.defineProperty(exports, "SharedSlice", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(SharedSlice_1).default; } });
9
+ (0, tslib_1.__exportStar)(require("./SharedSlice"), exports);
11
10
  var SharedSliceRef_1 = require("./SharedSliceRef");
12
11
  Object.defineProperty(exports, "SharedSliceRef", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(SharedSliceRef_1).default; } });
13
12
  exports.Slice = (0, tslib_1.__importStar)(require("./Slice"));
@@ -1,7 +1,7 @@
1
1
  import * as O from "fp-ts/Option";
2
2
  import type { EmptyContent } from "./EmptyContent";
3
3
  import BooleanContent from "./nestable/BooleanContent";
4
- import EmbedContent from "./nestable/EmbedContent";
4
+ import { EmbedContentO } from "./nestable/EmbedContent";
5
5
  import FieldContent from "./nestable/FieldContent";
6
6
  import { GeoPointContentO } from "./nestable/GeoPointContent";
7
7
  import { ImageContentO } from "./nestable/ImageContent";
@@ -11,7 +11,7 @@ import type { SeparatorContent } from "./nestable/SeparatorContent";
11
11
  import { StructuredTextContent } from "./nestable/StructuredTextContent";
12
12
  import { UIDContent } from "./UIDContent";
13
13
  export declare const SimpleWidgetContentType: string[];
14
- export declare type NonEmptySimpleWidgetContent = IntegrationFieldsContent | StructuredTextContent | ImageContentO | GeoPointContentO | EmbedContent | LinkContent | UIDContent | SeparatorContent | FieldContent | BooleanContent;
14
+ export declare type NonEmptySimpleWidgetContent = IntegrationFieldsContent | StructuredTextContent | ImageContentO | GeoPointContentO | EmbedContentO | LinkContent | UIDContent | SeparatorContent | FieldContent | BooleanContent;
15
15
  export declare type SimpleWidgetContent = NonEmptySimpleWidgetContent | EmptyContent;
16
16
  export declare function is(value: unknown): value is SimpleWidgetContent;
17
17
  export declare const SimpleWidgetContent: {
@@ -6,7 +6,7 @@ const function_1 = require("fp-ts/function");
6
6
  const O = (0, tslib_1.__importStar)(require("fp-ts/Option"));
7
7
  const t = (0, tslib_1.__importStar)(require("io-ts"));
8
8
  const BooleanContent_1 = (0, tslib_1.__importDefault)(require("./nestable/BooleanContent"));
9
- const EmbedContent_1 = (0, tslib_1.__importDefault)(require("./nestable/EmbedContent"));
9
+ const EmbedContent_1 = require("./nestable/EmbedContent");
10
10
  const FieldContent_1 = (0, tslib_1.__importDefault)(require("./nestable/FieldContent"));
11
11
  const GeoPointContent_1 = require("./nestable/GeoPointContent");
12
12
  const ImageContent_1 = require("./nestable/ImageContent");
@@ -52,7 +52,7 @@ exports.SimpleWidgetContent = {
52
52
  case "GeoPoint":
53
53
  return (0, function_1.pipe)(O.fromEither(GeoPointContent_1.GeoPointContent.decode(content)), O.map((geopointContent) => GeoPointContent_1.GeoPointContent.encode(geopointContent)));
54
54
  case "Embed":
55
- return O.fromEither(EmbedContent_1.default.decode(content));
55
+ return O.fromEither(EmbedContent_1.EmbedContent.decode(content));
56
56
  case "Link":
57
57
  return O.fromEither(Link_1.LinkContent.decode(content));
58
58
  case "UID":
@@ -8,25 +8,25 @@ export * as Slices from "./slices";
8
8
  export { type NonEmptyStaticWidgetContent, default as StaticWidgetContent, } from "./StaticWidgetContent";
9
9
  export * from "./UIDContent";
10
10
  export declare const WidgetTypes: {
11
- Empty: string;
12
- UID: string;
13
- Group: string;
14
- slices: string;
15
- Links: {
11
+ readonly Empty: "EmptyContent";
12
+ readonly UID: "UIDContent";
13
+ readonly Group: "GroupContentType";
14
+ readonly slices: "SliceContentType";
15
+ readonly Links: {
16
16
  readonly DocumentLink: "DocumentLink";
17
17
  readonly FileLink: "FileLink";
18
18
  readonly ExternalLink: "ExternalLink";
19
19
  readonly ImageLink: "ImageLink";
20
20
  readonly LinkContent: "LinkContent";
21
21
  };
22
- StructuredText: "StructuredTextContent";
23
- Boolean: "BooleanContent";
24
- Embed: "EmbedContent";
25
- Field: "FieldContent";
26
- GeoPoint: "GeoPointContent";
27
- Image: "ImageContent";
28
- IntegrationFields: "IntegrationFieldsContent";
29
- Separator: "SeparatorContent";
22
+ readonly StructuredText: "StructuredTextContent";
23
+ readonly Boolean: "BooleanContent";
24
+ readonly Embed: "EmbedContent";
25
+ readonly Field: "FieldContent";
26
+ readonly GeoPoint: "GeoPointContent";
27
+ readonly Image: "ImageContent";
28
+ readonly IntegrationFields: "IntegrationFieldsContent";
29
+ readonly Separator: "SeparatorContent";
30
30
  };
31
31
  export declare type WidgetKey = string;
32
32
  export declare type WidgetContent = SlicesContent | StaticWidgetContent;
@@ -1,9 +1,12 @@
1
1
  import * as t from "io-ts";
2
2
  export declare const EmbedContentType = "EmbedContent";
3
- declare type EmbedContent = t.OutputOf<typeof EmbedContentC> & {
3
+ export declare type EmbedContent = t.TypeOf<typeof EmbedContentC> & {
4
4
  all: unknown;
5
5
  };
6
- declare const EmbedContent: t.Type<EmbedContent, unknown, unknown>;
6
+ export declare type EmbedContentO = t.OutputOf<typeof EmbedContentC> & {
7
+ all: unknown;
8
+ };
9
+ export declare const EmbedContent: t.Type<EmbedContentO, unknown, unknown>;
7
10
  declare const EmbedContentC: t.Type<{
8
11
  embed_url: string;
9
12
  type: string;
@@ -37,4 +40,4 @@ declare const EmbedContentC: t.Type<{
37
40
  } & {
38
41
  __TYPE__: "EmbedContent";
39
42
  }, unknown>;
40
- export default EmbedContent;
43
+ export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmbedContentType = void 0;
3
+ exports.EmbedContent = exports.EmbedContentType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const fp_ts_1 = require("fp-ts");
6
6
  const function_1 = require("fp-ts/function");
@@ -8,7 +8,7 @@ const t = (0, tslib_1.__importStar)(require("io-ts"));
8
8
  const validators_1 = require("../../../validators");
9
9
  const function_2 = require("../../../validators/function");
10
10
  exports.EmbedContentType = "EmbedContent";
11
- const EmbedContent = new t.Type("EmbedContent", (u) => u.__TYPE__ === exports.EmbedContentType, (u) => {
11
+ exports.EmbedContent = new t.Type("EmbedContent", (u) => u.__TYPE__ === exports.EmbedContentType, (u) => {
12
12
  return (0, function_1.pipe)(EmbedContentC.decode(u), fp_ts_1.either.map((s) => ({
13
13
  ...EmbedContentC.encode(s),
14
14
  all: u,
@@ -33,4 +33,3 @@ const EmbedContentC = (0, function_2.addType)(t.exact(t.intersection([
33
33
  html: validators_1.StringOrNull,
34
34
  }),
35
35
  ])), exports.EmbedContentType);
36
- exports.default = EmbedContent;
@@ -1,12 +1,13 @@
1
1
  import * as O from "fp-ts/Option";
2
+ export declare type FieldType = "Text" | "Date" | "Timestamp" | "Color" | "Number" | "Range" | "Select";
2
3
  export declare const FieldContentType = "FieldContent";
3
4
  declare type FieldContent = {
4
5
  value: string;
5
- type: string;
6
+ type: FieldType;
6
7
  __TYPE__: typeof FieldContentType;
7
8
  };
8
9
  declare const FieldContent: {
9
10
  types: string[];
10
- forType: (type: string, value: unknown) => O.Option<FieldContent>;
11
+ forType: (type: FieldType, value: unknown) => O.Option<FieldContent>;
11
12
  };
12
13
  export default FieldContent;
@@ -1,5 +1,4 @@
1
1
  import * as t from "io-ts";
2
- import EmbedContent from "../EmbedContent";
3
2
  export declare const Meta: t.ExactC<t.IntersectionC<[t.PartialC<{
4
3
  data: t.UnknownC;
5
4
  }>, t.TypeC<{
@@ -119,7 +118,7 @@ export declare function checkImageBlock(block: Block): block is ImageBlock;
119
118
  export declare const EmbedBlockType = "embed";
120
119
  export declare const EmbedBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
121
120
  type: t.LiteralC<"embed">;
122
- data: t.Type<EmbedContent, unknown, unknown>;
121
+ data: t.Type<import("../EmbedContent").EmbedContentO, unknown, unknown>;
123
122
  }>, t.PartialC<{
124
123
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
125
124
  direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -244,7 +243,7 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
244
243
  direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
245
244
  }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
246
245
  type: t.LiteralC<"embed">;
247
- data: t.Type<EmbedContent, unknown, unknown>;
246
+ data: t.Type<import("../EmbedContent").EmbedContentO, unknown, unknown>;
248
247
  }>, t.PartialC<{
249
248
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
250
249
  direction: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
@@ -6,7 +6,7 @@ const E = (0, tslib_1.__importStar)(require("fp-ts/lib/Either"));
6
6
  const t = (0, tslib_1.__importStar)(require("io-ts"));
7
7
  const validators_1 = require("../../../../validators");
8
8
  const function_1 = require("../../../../validators/function");
9
- const EmbedContent_1 = (0, tslib_1.__importDefault)(require("../EmbedContent"));
9
+ const EmbedContent_1 = require("../EmbedContent");
10
10
  const ImageContent_1 = require("../ImageContent");
11
11
  const Link_1 = require("../Link");
12
12
  exports.Meta = t.exact(t.intersection([
@@ -66,7 +66,7 @@ exports.EmbedBlockType = "embed";
66
66
  exports.EmbedBlock = t.exact(t.intersection([
67
67
  t.type({
68
68
  type: t.literal(exports.EmbedBlockType),
69
- data: EmbedContent_1.default,
69
+ data: EmbedContent_1.EmbedContent,
70
70
  }),
71
71
  t.partial({
72
72
  label: validators_1.StringOrNull,
@@ -1,5 +1,5 @@
1
1
  export { default as BooleanContent } from "./BooleanContent";
2
- export { default as EmbedContent } from "./EmbedContent";
2
+ export * from "./EmbedContent";
3
3
  export { default as FieldContent } from "./FieldContent";
4
4
  export { type GeoPointContentO, GeoPointContent } from "./GeoPointContent";
5
5
  export { type ImageContentO, ImageContent, ImageContentView, } from "./ImageContent";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NestableTypes = exports.Links = exports.IntegrationFieldsContent = exports.ImageContentView = exports.ImageContent = exports.GeoPointContent = exports.FieldContent = exports.EmbedContent = exports.BooleanContent = void 0;
3
+ exports.NestableTypes = exports.Links = exports.IntegrationFieldsContent = exports.ImageContentView = exports.ImageContent = exports.GeoPointContent = exports.FieldContent = exports.BooleanContent = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const BooleanContent_1 = require("./BooleanContent");
6
6
  const EmbedContent_1 = require("./EmbedContent");
@@ -13,8 +13,7 @@ const SeparatorContent_1 = require("./SeparatorContent");
13
13
  const StructuredTextContent_1 = require("./StructuredTextContent");
14
14
  var BooleanContent_2 = require("./BooleanContent");
15
15
  Object.defineProperty(exports, "BooleanContent", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(BooleanContent_2).default; } });
16
- var EmbedContent_2 = require("./EmbedContent");
17
- Object.defineProperty(exports, "EmbedContent", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(EmbedContent_2).default; } });
16
+ (0, tslib_1.__exportStar)(require("./EmbedContent"), exports);
18
17
  var FieldContent_2 = require("./FieldContent");
19
18
  Object.defineProperty(exports, "FieldContent", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(FieldContent_2).default; } });
20
19
  var GeoPointContent_2 = require("./GeoPointContent");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/types-internal",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Prismic types for Custom Types and Prismic Data",
5
5
  "keywords": [
6
6
  "typescript",
@@ -10,7 +10,7 @@ import {
10
10
  Sections,
11
11
  StaticSection,
12
12
  } from "./Section"
13
- import type SharedSlice from "./widgets/slices/SharedSlice"
13
+ import type { SharedSlice } from "./widgets/slices/SharedSlice"
14
14
  import type { DynamicSlice } from "./widgets/slices/Slice"
15
15
  import type { DynamicSlices } from "./widgets/slices/Slices"
16
16
  import SlicesTypes from "./widgets/slices/SlicesTypes"
@@ -58,10 +58,10 @@ export type StaticCustomType = t.TypeOf<typeof StaticCustomType>
58
58
  export const CustomType = customTypeReader(Format.Dynamic)
59
59
  export type CustomType = t.TypeOf<typeof CustomType>
60
60
 
61
- function _retrieveSharedSlicesRef(customType: CustomType): Array<string> {
62
- const flattenWidgets: Array<[string, DynamicWidget]> = Object.entries(
63
- customType.json,
64
- ).reduce(
61
+ export function flattenWidgets(
62
+ customType: CustomType,
63
+ ): Array<[string, DynamicWidget]> {
64
+ return Object.entries(customType.json).reduce(
65
65
  (
66
66
  acc: Array<[string, DynamicWidget]>,
67
67
  [, section]: [string, DynamicSection],
@@ -72,8 +72,9 @@ function _retrieveSharedSlicesRef(customType: CustomType): Array<string> {
72
72
  },
73
73
  [],
74
74
  )
75
-
76
- const slicezones = flattenWidgets.filter(
75
+ }
76
+ function _retrieveSharedSlicesRef(customType: CustomType): Array<string> {
77
+ const slicezones = flattenWidgets(customType).filter(
77
78
  ([, widget]: [string, DynamicWidget]) => widget.type === WidgetTypes.Slices,
78
79
  ) as Array<[string, DynamicSlices]>
79
80
 
@@ -1,7 +1,7 @@
1
1
  import * as t from "io-ts"
2
2
 
3
3
  import { Format } from "./Format"
4
- import type SharedSlice from "./widgets/slices/SharedSlice"
4
+ import type { SharedSlice } from "./widgets/slices/SharedSlice"
5
5
  import {
6
6
  DynamicWidget,
7
7
  StaticWidget,
@@ -3,7 +3,7 @@ import * as t from "io-ts"
3
3
  import { Format } from "../Format"
4
4
  import Group from "./Group"
5
5
  import NestableWidget from "./nestable/NestableWidget"
6
- import type SharedSlice from "./slices/SharedSlice"
6
+ import type { SharedSlice } from "./slices/SharedSlice"
7
7
  import { Slices, slicesReader } from "./slices/Slices"
8
8
  import UID from "./UID"
9
9
  import WidgetTypes from "./WidgetTypes"
@@ -10,7 +10,7 @@ import IntegrationField from "./IntegrationField"
10
10
  import Link from "./Link"
11
11
  import Number from "./Number"
12
12
  import Range from "./Range"
13
- import RichText from "./RichText"
13
+ import { RichText } from "./RichText"
14
14
  import Select from "./Select"
15
15
  import Separator from "./Separator"
16
16
  import Text from "./Text"
@@ -5,25 +5,67 @@ import { StringOrNull } from "../../../validators"
5
5
  import ImageConstraint from "../shared/ImageConstraint"
6
6
  import WidgetTypes from "../WidgetTypes"
7
7
 
8
- const DEFAULT_OPTION = "paragraph"
9
- const options = [
10
- "heading1",
11
- "heading2",
12
- "heading3",
13
- "heading4",
14
- "heading5",
15
- "heading6",
16
- "paragraph",
17
- "strong",
18
- "em",
19
- "preformatted",
20
- "hyperlink",
21
- "image",
22
- "embed",
23
- "list-item",
24
- "o-list-item",
25
- "rtl",
26
- ]
8
+ export const DEFAULT_OPTION = "paragraph"
9
+
10
+ export enum RichTextNodeType {
11
+ heading1 = "heading1",
12
+ heading2 = "heading2",
13
+ heading3 = "heading3",
14
+ heading4 = "heading4",
15
+ heading5 = "heading5",
16
+ heading6 = "heading6",
17
+ paragraph = "paragraph",
18
+ strong = "strong",
19
+ em = "em",
20
+ preformatted = "preformatted",
21
+ hyperlink = "hyperlink",
22
+ image = "image",
23
+ embed = "embed",
24
+ list = "list-item",
25
+ orderedList = "o-list-item",
26
+ rtl = "rtl",
27
+ }
28
+
29
+ export function parseRichTextNodeType(
30
+ str: string,
31
+ ): RichTextNodeType | undefined {
32
+ switch (str) {
33
+ case RichTextNodeType.heading1:
34
+ return RichTextNodeType.heading1
35
+ case RichTextNodeType.heading2:
36
+ return RichTextNodeType.heading2
37
+ case RichTextNodeType.heading3:
38
+ return RichTextNodeType.heading3
39
+ case RichTextNodeType.heading4:
40
+ return RichTextNodeType.heading4
41
+ case RichTextNodeType.heading5:
42
+ return RichTextNodeType.heading5
43
+ case RichTextNodeType.heading6:
44
+ return RichTextNodeType.heading6
45
+ case RichTextNodeType.paragraph:
46
+ return RichTextNodeType.paragraph
47
+ case RichTextNodeType.strong:
48
+ return RichTextNodeType.strong
49
+ case RichTextNodeType.em:
50
+ return RichTextNodeType.em
51
+ case RichTextNodeType.preformatted:
52
+ return RichTextNodeType.preformatted
53
+ case RichTextNodeType.hyperlink:
54
+ return RichTextNodeType.hyperlink
55
+ case RichTextNodeType.image:
56
+ return RichTextNodeType.image
57
+ case RichTextNodeType.embed:
58
+ return RichTextNodeType.embed
59
+ case RichTextNodeType.list:
60
+ return RichTextNodeType.list
61
+ case RichTextNodeType.orderedList:
62
+ return RichTextNodeType.orderedList
63
+ case RichTextNodeType.rtl:
64
+ return RichTextNodeType.rtl
65
+ default:
66
+ return
67
+ }
68
+ }
27
69
 
28
70
  const RichTextOptions = new t.Type<string, string, unknown>(
29
71
  "RichTextOptions",
@@ -34,7 +76,7 @@ const RichTextOptions = new t.Type<string, string, unknown>(
34
76
  (s: string | null) => {
35
77
  if (!s) return t.success(DEFAULT_OPTION)
36
78
  const entries = s.split(",").map((e: string) => e.trim())
37
- const filtered = entries.filter((entry) => options.includes(entry))
79
+ const filtered = entries.filter((entry) => parseRichTextNodeType(entry))
38
80
  if (!filtered.length) return t.success(DEFAULT_OPTION)
39
81
 
40
82
  return t.success(filtered.join(","))
@@ -174,7 +216,7 @@ const RichTextConfig = t.exact(
174
216
  )
175
217
  type RichTextConfig = t.TypeOf<typeof RichTextConfig>
176
218
 
177
- const RichText = t.exact(
219
+ export const RichText = t.exact(
178
220
  t.intersection([
179
221
  t.type({
180
222
  type: t.literal(WidgetTypes.RichText),
@@ -185,6 +227,4 @@ const RichText = t.exact(
185
227
  }),
186
228
  ]),
187
229
  )
188
- type RichText = t.TypeOf<typeof RichText>
189
-
190
- export default RichText
230
+ export type RichText = t.TypeOf<typeof RichText>
@@ -1,6 +1,7 @@
1
1
  export { default as BooleanField } from "./BooleanField"
2
2
  export { default as Color } from "./Color"
3
3
  export { default as Date } from "./Date"
4
+ export { default as Embed } from "./Embed"
4
5
  export { default as GeoPoint } from "./GeoPoint"
5
6
  export { default as Image } from "./Image"
6
7
  export { default as IntegrationField } from "./IntegrationField"
@@ -8,7 +9,7 @@ export { default as Link } from "./Link"
8
9
  export { default as NestableWidget } from "./NestableWidget"
9
10
  export { default as Number } from "./Number"
10
11
  export { default as Range } from "./Range"
11
- export { default as RichText } from "./RichText"
12
+ export * from "./RichText"
12
13
  export { default as Select } from "./Select"
13
14
  export { default as Separator } from "./Separator"
14
15
  export { default as Text } from "./Text"
@@ -7,7 +7,7 @@ import SlicesTypes from "./SlicesTypes"
7
7
  const IMAGE_PLACEHOLDER_URL =
8
8
  "https://images.prismic.io/slice-machine/621a5ec4-0387-4bc5-9860-2dd46cbc07cd_default_ss.png?auto=compress,format"
9
9
 
10
- const Variation = t.exact(
10
+ export const Variation = t.exact(
11
11
  t.intersection([
12
12
  t.type({
13
13
  id: t.string,
@@ -25,9 +25,9 @@ const Variation = t.exact(
25
25
  ]),
26
26
  )
27
27
 
28
- type Variation = t.TypeOf<typeof Variation>
28
+ export type Variation = t.TypeOf<typeof Variation>
29
29
 
30
- const SharedSlice = t.exact(
30
+ export const SharedSlice = t.exact(
31
31
  t.intersection([
32
32
  t.type({
33
33
  id: t.string,
@@ -41,6 +41,4 @@ const SharedSlice = t.exact(
41
41
  ]),
42
42
  )
43
43
 
44
- type SharedSlice = t.TypeOf<typeof SharedSlice>
45
-
46
- export default SharedSlice
44
+ export type SharedSlice = t.TypeOf<typeof SharedSlice>
@@ -1,6 +1,6 @@
1
1
  import type CompositeSlice from "./CompositeSlice"
2
2
  import type LegacySlice from "./LegacySlice"
3
- import type SharedSlice from "./SharedSlice"
3
+ import type { SharedSlice } from "./SharedSlice"
4
4
  import type SharedSliceRef from "./SharedSliceRef"
5
5
 
6
6
  export type DynamicSlice = CompositeSlice | LegacySlice | SharedSliceRef
@@ -5,7 +5,7 @@ import { Format } from "../../Format"
5
5
  import WidgetTypes from "../WidgetTypes"
6
6
  import CompositeSlice from "./CompositeSlice"
7
7
  import LegacySlice from "./LegacySlice"
8
- import SharedSlice from "./SharedSlice"
8
+ import { SharedSlice } from "./SharedSlice"
9
9
  import SharedSliceRef from "./SharedSliceRef"
10
10
  import SlicesTypes from "./SlicesTypes"
11
11
 
@@ -1,6 +1,6 @@
1
1
  export { default as CompositeSlice } from "./CompositeSlice"
2
2
  export { default as LegacySlice } from "./LegacySlice"
3
- export { default as SharedSlice } from "./SharedSlice"
3
+ export * from "./SharedSlice"
4
4
  export { default as SharedSliceRef } from "./SharedSliceRef"
5
5
  export * as Slice from "./Slice"
6
6
  export * as SliceZone from "./Slices"
@@ -4,8 +4,8 @@ import * as t from "io-ts"
4
4
 
5
5
  import type { EmptyContent } from "./EmptyContent"
6
6
  import BooleanContent from "./nestable/BooleanContent"
7
- import EmbedContent from "./nestable/EmbedContent"
8
- import FieldContent from "./nestable/FieldContent"
7
+ import { EmbedContent, EmbedContentO } from "./nestable/EmbedContent"
8
+ import FieldContent, { FieldType } from "./nestable/FieldContent"
9
9
  import { GeoPointContent, GeoPointContentO } from "./nestable/GeoPointContent"
10
10
  import { ImageContent, ImageContentO } from "./nestable/ImageContent"
11
11
  import IntegrationFieldsContent from "./nestable/IntegrationFieldsContent"
@@ -34,7 +34,7 @@ export type NonEmptySimpleWidgetContent =
34
34
  | StructuredTextContent
35
35
  | ImageContentO
36
36
  | GeoPointContentO
37
- | EmbedContent
37
+ | EmbedContentO
38
38
  | LinkContent
39
39
  | UIDContent
40
40
  | SeparatorContent
@@ -84,7 +84,7 @@ export const SimpleWidgetContent = {
84
84
  return O.fromEither(BooleanContent.decode(content))
85
85
  default:
86
86
  if (FieldContent.types.includes(type)) {
87
- return FieldContent.forType(type, content)
87
+ return FieldContent.forType(type as FieldType, content)
88
88
  } else {
89
89
  return O.none
90
90
  }
@@ -22,7 +22,7 @@ export const WidgetTypes = {
22
22
  UID: UIDContentType,
23
23
  Group: GroupContentType,
24
24
  slices: SlicesContentType,
25
- }
25
+ } as const
26
26
 
27
27
  export type WidgetKey = string
28
28
  export type WidgetContent = SlicesContent | StaticWidgetContent