@prismicio/api-renderer
Advanced tools
Comparing version 3.1.0-alpha.1 to 3.1.0-alpha.2
@@ -159,3 +159,2 @@ import * as t from "io-ts"; | ||
})[] | undefined; | ||
allowCaption?: boolean | undefined; | ||
} | undefined; | ||
@@ -330,3 +329,2 @@ }) | ({ | ||
})[] | undefined; | ||
allowCaption?: boolean | undefined; | ||
} | undefined; | ||
@@ -333,0 +331,0 @@ }) | ({ |
@@ -20,3 +20,2 @@ import * as t from "io-ts"; | ||
})[] | undefined; | ||
allowCaption?: boolean | undefined; | ||
} | undefined; | ||
@@ -40,4 +39,3 @@ }>, WithKey<{ | ||
})[] | undefined; | ||
allowCaption?: boolean | undefined; | ||
} | undefined; | ||
}>, unknown>; |
@@ -103,3 +103,2 @@ import * as t from "io-ts"; | ||
})[] | undefined; | ||
allowCaption?: boolean | undefined; | ||
} | undefined; | ||
@@ -123,3 +122,2 @@ }>, import("../..").WithKey<{ | ||
})[] | undefined; | ||
allowCaption?: boolean | undefined; | ||
} | undefined; | ||
@@ -126,0 +124,0 @@ }>, unknown>, t.Type<import("../..").WithKey<{ |
@@ -157,3 +157,2 @@ import * as t from "io-ts"; | ||
})[] | undefined; | ||
allowCaption?: boolean | undefined; | ||
} | undefined; | ||
@@ -318,3 +317,2 @@ }) | ({ | ||
})[] | undefined; | ||
allowCaption?: boolean | undefined; | ||
} | undefined; | ||
@@ -489,3 +487,2 @@ }) | ({ | ||
})[] | undefined; | ||
allowCaption?: boolean | undefined; | ||
} | undefined; | ||
@@ -650,3 +647,2 @@ }) | ({ | ||
})[] | undefined; | ||
allowCaption?: boolean | undefined; | ||
} | undefined; | ||
@@ -653,0 +649,0 @@ }) | ({ |
@@ -149,3 +149,2 @@ import * as t from "io-ts"; | ||
})[] | undefined; | ||
allowCaption?: boolean | undefined; | ||
} | undefined; | ||
@@ -317,3 +316,2 @@ }) | ({ | ||
})[] | undefined; | ||
allowCaption?: boolean | undefined; | ||
} | undefined; | ||
@@ -478,3 +476,2 @@ }) | ({ | ||
})[] | undefined; | ||
allowCaption?: boolean | undefined; | ||
} | undefined; | ||
@@ -646,3 +643,2 @@ }) | ({ | ||
})[] | undefined; | ||
allowCaption?: boolean | undefined; | ||
} | undefined; | ||
@@ -649,0 +645,0 @@ }) | ({ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SharedSliceDef = exports.VariationDef = void 0; | ||
exports.SharedSliceDef = exports.VariationDef = exports.VariationPrimaryDef = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -10,6 +10,8 @@ const customtypes_1 = require("@prismicio/types-internal/lib/customtypes"); | ||
const utils_1 = require("../../utils"); | ||
const GroupDef_1 = require("../GroupDef"); | ||
const NestableDef_1 = require("../nestable/NestableDef"); | ||
exports.VariationPrimaryDef = t.union([GroupDef_1.GroupDef, NestableDef_1.NestableDef]); | ||
const variationCodec = t.strict({ | ||
id: t.string, | ||
primary: t.array(NestableDef_1.NestableDef), | ||
primary: t.array(exports.VariationPrimaryDef), | ||
items: t.array(NestableDef_1.NestableDef), | ||
@@ -16,0 +18,0 @@ version: t.string, |
@@ -34,3 +34,3 @@ import * as t from "io-ts"; | ||
fields: { | ||
[key: string]: Field; | ||
[key: string]: GroupOrField; | ||
}; | ||
@@ -37,0 +37,0 @@ }; |
@@ -28,3 +28,3 @@ "use strict"; | ||
nonRepeat: t.strict({ | ||
fields: t.record(t.string, exports.FieldC), | ||
fields: t.record(t.string, exports.GroupOrFieldC), | ||
}), | ||
@@ -31,0 +31,0 @@ repeat: t.strict({ |
@@ -10,3 +10,3 @@ "use strict"; | ||
value: content.value.map((items) => { | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderObjectOfSimpleWidgetV1(items.value, fetch === null || fetch === void 0 ? void 0 : fetch.fields); | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderV1Object(items.value, fetch === null || fetch === void 0 ? void 0 : fetch.fields); | ||
}), | ||
@@ -18,3 +18,3 @@ }; | ||
var _a; | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderObjectOfSimpleWidgetV2(items.value, fetch === null || fetch === void 0 ? void 0 : fetch.fields, ((_a = groupDef.config) === null || _a === void 0 ? void 0 : _a.fields) || {}, { | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderV2Object(items.value, fetch === null || fetch === void 0 ? void 0 : fetch.fields, ((_a = groupDef.config) === null || _a === void 0 ? void 0 : _a.fields) || {}, { | ||
withFetch: "filter", | ||
@@ -36,3 +36,3 @@ }, { | ||
return {}; | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderObjectOfSimpleWidgetMocks(items.value, (_b = def.config) === null || _b === void 0 ? void 0 : _b.fields); | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderMocksObject(items.value, (_b = def.config) === null || _b === void 0 ? void 0 : _b.fields); | ||
}); | ||
@@ -39,0 +39,0 @@ }, |
@@ -9,3 +9,2 @@ "use strict"; | ||
id: imageContentView.origin.id, | ||
caption: (0, utils_1.writeEmptyStringOrNull)(imageContentView.caption, ctx.emptyStringInsteadOfNull), | ||
edit: { | ||
@@ -12,0 +11,0 @@ x: imageContentView.edit.crop.x, |
@@ -20,2 +20,3 @@ "use strict"; | ||
link_type: "Media", | ||
id: link.id, | ||
name: link.name, | ||
@@ -22,0 +23,0 @@ kind: link.kind, |
@@ -1,17 +0,940 @@ | ||
import { NestableContent } from "@prismicio/types-internal/lib/content"; | ||
import type { NestableWidget } from "@prismicio/types-internal/lib/customtypes"; | ||
import type { RenderContext } from "../models"; | ||
import type { Renderer } from "../models"; | ||
import { Field } from "../models/fetch"; | ||
declare const SimpleWidgetRenderer: (ctx: RenderContext) => Renderer<NestableWidget, NestableContent, Field> & { | ||
renderObjectOfSimpleWidgetV1(content: Array<[string, NestableContent]> | Record<string, NestableContent>, fetch: Record<string, Field> | undefined): object; | ||
renderObjectOfSimpleWidgetV2(content: Array<[string, NestableContent]> | Record<string, NestableContent>, fetch: Record<string, Field> | undefined, fieldsDef: Record<string, NestableWidget>, renderIfUndefined: { | ||
withFetch: "default" | "filter"; | ||
}, renderIfNull: { | ||
default: "default" | "render" | "filter"; | ||
withFetch: "default" | "filter"; | ||
withFetchField: "default" | "render" | "filter"; | ||
}): Record<string, unknown>; | ||
renderObjectOfSimpleWidgetMocks(content: Array<[string, NestableContent]> | Record<string, NestableContent>, fieldsDef: Record<string, NestableWidget>): Record<string, unknown>; | ||
}; | ||
declare const SimpleWidgetRenderer: (ctx: RenderContext) => import("../object").WithObjectRenderers<import("../models").Renderer<({ | ||
type: "Color"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Boolean"; | ||
} & { | ||
config?: { | ||
label?: string | null | undefined; | ||
default_value?: boolean | undefined; | ||
placeholder_true?: string | undefined; | ||
placeholder_false?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Embed"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
useAsTitle?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "GeoPoint"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Date"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Number"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
min?: number | undefined; | ||
max?: number | undefined; | ||
step?: number | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Range"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
min?: number | undefined; | ||
max?: number | undefined; | ||
step?: number | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "StructuredText"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
useAsTitle?: boolean | undefined; | ||
single?: string | undefined; | ||
multi?: string | undefined; | ||
imageConstraint?: { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
} | undefined; | ||
labels?: readonly string[] | undefined; | ||
allowTargetBlank?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Select"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default_value?: string | undefined; | ||
options?: readonly string[] | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Separator"; | ||
} & { | ||
config?: { | ||
label?: string | null | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Text"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
useAsTitle?: boolean | undefined; | ||
placeholder?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Timestamp"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Link"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
useAsTitle?: boolean | undefined; | ||
placeholder?: string | undefined; | ||
select?: "document" | "media" | "web" | null | undefined; | ||
customtypes?: readonly string[] | undefined; | ||
masks?: readonly string[] | undefined; | ||
tags?: readonly string[] | undefined; | ||
allowTargetBlank?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Image"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
constraint?: { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
} | undefined; | ||
thumbnails?: readonly ({ | ||
name: string; | ||
} & { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
})[] | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "IntegrationFields"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
catalog?: string | undefined; | ||
} | undefined; | ||
}), { | ||
type: string; | ||
__TYPE__: "EmptyContent"; | ||
} | { | ||
__TYPE__: "BooleanContent"; | ||
value: boolean; | ||
} | ({ | ||
embed_url: string; | ||
type: string; | ||
} & { | ||
version?: string | number | null | undefined; | ||
title?: string | null | undefined; | ||
author_name?: string | null | undefined; | ||
author_url?: string | null | undefined; | ||
provider_name?: string | null | undefined; | ||
provider_url?: string | null | undefined; | ||
cache_age?: string | number | null | undefined; | ||
thumbnail_url?: string | null | undefined; | ||
thumbnail_width?: number | null | undefined; | ||
thumbnail_height?: number | null | undefined; | ||
html?: string | null | undefined; | ||
} & { | ||
__TYPE__: "EmbedContent"; | ||
all: unknown; | ||
}) | { | ||
type: "Text"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Timestamp"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Select"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Range"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Number"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Date"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Color"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | ({ | ||
position: { | ||
lat: number; | ||
lng: number; | ||
}; | ||
} & { | ||
__TYPE__: "GeoPointContent"; | ||
}) | ({ | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
} & { | ||
thumbnails?: { | ||
[x: string]: { | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
}; | ||
} | undefined; | ||
} & { | ||
__TYPE__: "ImageContent"; | ||
}) | { | ||
__TYPE__: "IntegrationFieldsContent"; | ||
value: string; | ||
} | { | ||
__TYPE__: "LinkContent"; | ||
value: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}); | ||
} | { | ||
__TYPE__: "StructuredTextContent"; | ||
value: (({ | ||
type: "image"; | ||
data: { | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
} & { | ||
linkTo?: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}) | null | undefined; | ||
}; | ||
} & { | ||
label?: string | null | undefined; | ||
direction?: string | null | undefined; | ||
}) | ({ | ||
type: "embed"; | ||
data: { | ||
embed_url: string; | ||
type: string; | ||
} & { | ||
version?: string | number | null | undefined; | ||
title?: string | null | undefined; | ||
author_name?: string | null | undefined; | ||
author_url?: string | null | undefined; | ||
provider_name?: string | null | undefined; | ||
provider_url?: string | null | undefined; | ||
cache_age?: string | number | null | undefined; | ||
thumbnail_url?: string | null | undefined; | ||
thumbnail_width?: number | null | undefined; | ||
thumbnail_height?: number | null | undefined; | ||
html?: string | null | undefined; | ||
} & { | ||
__TYPE__: "EmbedContent"; | ||
all: unknown; | ||
}; | ||
} & { | ||
label?: string | null | undefined; | ||
direction?: string | null | undefined; | ||
}) | ({ | ||
type: "embed" | "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "list-item" | "o-list-item" | "rtl"; | ||
content: { | ||
text: string; | ||
} & { | ||
spans?: ({ | ||
data: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}); | ||
start: number; | ||
end: number; | ||
type: "hyperlink"; | ||
} | { | ||
data: string; | ||
start: number; | ||
end: number; | ||
type: "label"; | ||
} | { | ||
start: number; | ||
end: number; | ||
type: "strong" | "em" | "list-item"; | ||
})[] | undefined; | ||
}; | ||
} & { | ||
label?: string | undefined; | ||
direction?: string | undefined; | ||
}))[]; | ||
} | { | ||
__TYPE__: "SeparatorContent"; | ||
}, Field>, ({ | ||
type: "Color"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Boolean"; | ||
} & { | ||
config?: { | ||
label?: string | null | undefined; | ||
default_value?: boolean | undefined; | ||
placeholder_true?: string | undefined; | ||
placeholder_false?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Embed"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
useAsTitle?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "GeoPoint"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Date"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Number"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
min?: number | undefined; | ||
max?: number | undefined; | ||
step?: number | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Range"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
min?: number | undefined; | ||
max?: number | undefined; | ||
step?: number | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "StructuredText"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
useAsTitle?: boolean | undefined; | ||
single?: string | undefined; | ||
multi?: string | undefined; | ||
imageConstraint?: { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
} | undefined; | ||
labels?: readonly string[] | undefined; | ||
allowTargetBlank?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Select"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default_value?: string | undefined; | ||
options?: readonly string[] | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Separator"; | ||
} & { | ||
config?: { | ||
label?: string | null | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Text"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
useAsTitle?: boolean | undefined; | ||
placeholder?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Timestamp"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Link"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
useAsTitle?: boolean | undefined; | ||
placeholder?: string | undefined; | ||
select?: "document" | "media" | "web" | null | undefined; | ||
customtypes?: readonly string[] | undefined; | ||
masks?: readonly string[] | undefined; | ||
tags?: readonly string[] | undefined; | ||
allowTargetBlank?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Image"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
constraint?: { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
} | undefined; | ||
thumbnails?: readonly ({ | ||
name: string; | ||
} & { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
})[] | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "IntegrationFields"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
catalog?: string | undefined; | ||
} | undefined; | ||
}), { | ||
type: string; | ||
__TYPE__: "EmptyContent"; | ||
} | { | ||
__TYPE__: "BooleanContent"; | ||
value: boolean; | ||
} | ({ | ||
embed_url: string; | ||
type: string; | ||
} & { | ||
version?: string | number | null | undefined; | ||
title?: string | null | undefined; | ||
author_name?: string | null | undefined; | ||
author_url?: string | null | undefined; | ||
provider_name?: string | null | undefined; | ||
provider_url?: string | null | undefined; | ||
cache_age?: string | number | null | undefined; | ||
thumbnail_url?: string | null | undefined; | ||
thumbnail_width?: number | null | undefined; | ||
thumbnail_height?: number | null | undefined; | ||
html?: string | null | undefined; | ||
} & { | ||
__TYPE__: "EmbedContent"; | ||
all: unknown; | ||
}) | { | ||
type: "Text"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Timestamp"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Select"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Range"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Number"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Date"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Color"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | ({ | ||
position: { | ||
lat: number; | ||
lng: number; | ||
}; | ||
} & { | ||
__TYPE__: "GeoPointContent"; | ||
}) | ({ | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
} & { | ||
thumbnails?: { | ||
[x: string]: { | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
}; | ||
} | undefined; | ||
} & { | ||
__TYPE__: "ImageContent"; | ||
}) | { | ||
__TYPE__: "IntegrationFieldsContent"; | ||
value: string; | ||
} | { | ||
__TYPE__: "LinkContent"; | ||
value: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}); | ||
} | { | ||
__TYPE__: "StructuredTextContent"; | ||
value: (({ | ||
type: "image"; | ||
data: { | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
} & { | ||
linkTo?: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}) | null | undefined; | ||
}; | ||
} & { | ||
label?: string | null | undefined; | ||
direction?: string | null | undefined; | ||
}) | ({ | ||
type: "embed"; | ||
data: { | ||
embed_url: string; | ||
type: string; | ||
} & { | ||
version?: string | number | null | undefined; | ||
title?: string | null | undefined; | ||
author_name?: string | null | undefined; | ||
author_url?: string | null | undefined; | ||
provider_name?: string | null | undefined; | ||
provider_url?: string | null | undefined; | ||
cache_age?: string | number | null | undefined; | ||
thumbnail_url?: string | null | undefined; | ||
thumbnail_width?: number | null | undefined; | ||
thumbnail_height?: number | null | undefined; | ||
html?: string | null | undefined; | ||
} & { | ||
__TYPE__: "EmbedContent"; | ||
all: unknown; | ||
}; | ||
} & { | ||
label?: string | null | undefined; | ||
direction?: string | null | undefined; | ||
}) | ({ | ||
type: "embed" | "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "list-item" | "o-list-item" | "rtl"; | ||
content: { | ||
text: string; | ||
} & { | ||
spans?: ({ | ||
data: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}); | ||
start: number; | ||
end: number; | ||
type: "hyperlink"; | ||
} | { | ||
data: string; | ||
start: number; | ||
end: number; | ||
type: "label"; | ||
} | { | ||
start: number; | ||
end: number; | ||
type: "strong" | "em" | "list-item"; | ||
})[] | undefined; | ||
}; | ||
} & { | ||
label?: string | undefined; | ||
direction?: string | undefined; | ||
}))[]; | ||
} | { | ||
__TYPE__: "SeparatorContent"; | ||
}, Field>; | ||
export default SimpleWidgetRenderer; |
@@ -5,6 +5,4 @@ "use strict"; | ||
const content_1 = require("@prismicio/types-internal/lib/content"); | ||
const Array_1 = require("fp-ts/lib/Array"); | ||
const O = tslib_1.__importStar(require("fp-ts/lib/Option")); | ||
const fetch_1 = require("../models/fetch"); | ||
const utils_1 = require("../utils"); | ||
const object_1 = require("../object"); | ||
const nestable_1 = require("./nestable"); | ||
@@ -28,3 +26,3 @@ const UIDRenderer_1 = tslib_1.__importDefault(require("./UIDRenderer")); | ||
} | ||
const SimpleWidgetRenderer = (ctx) => ({ | ||
const SimpleWidgetRenderer = (ctx) => (0, object_1.withObjectRenderers)({ | ||
renderV1(content, fetch) { | ||
@@ -180,80 +178,3 @@ if ((0, content_1.isRichTextContent)(content)) { | ||
}, | ||
renderObjectOfSimpleWidgetV1(content, fetch) { | ||
const c = content instanceof Array ? content : Object.entries(content); | ||
return Object.fromEntries((0, Array_1.compact)(c.map(([key, widget]) => { | ||
if (content_1.EmptyContent.is(widget)) { | ||
return O.none; | ||
} | ||
return (0, utils_1.renderIfNoFetchOrFetchDefined)(fetch, key, (f) => O.some([key, this.renderV1(widget, f)])); | ||
}))); | ||
}, | ||
renderObjectOfSimpleWidgetV2(content, fetch, fieldsDef, renderIfUndefined, renderIfNull) { | ||
const itemByKey = content instanceof Array ? Object.fromEntries(content) : content; | ||
const result = {}; | ||
Object.entries(fieldsDef).forEach(([key, def]) => { | ||
const item = itemByKey[key]; | ||
if (item === undefined) { | ||
if ((fetch && key in fetch) || !fetch) { | ||
result[key] = this.renderDefault(def); | ||
} | ||
else if (fetch) { | ||
if (renderIfUndefined.withFetch === "default") { | ||
result[key] = this.renderDefault(def); | ||
} | ||
} | ||
} | ||
else if (content_1.EmptyContent.is(item)) { | ||
if (fetch && key in fetch) { | ||
if (renderIfNull.withFetchField === "default") { | ||
result[key] = this.renderDefault(def); | ||
} | ||
else if (renderIfNull.withFetchField === "render") { | ||
result[key] = this.renderV2(def, item, fetch[key]); | ||
} | ||
} | ||
else if (fetch) { | ||
if (renderIfNull.withFetch === "default") { | ||
result[key] = this.renderDefault(def); | ||
} | ||
} | ||
else { | ||
if (renderIfNull.default === "default") { | ||
result[key] = this.renderDefault(def); | ||
} | ||
else if (renderIfNull.default === "render") { | ||
result[key] = this.renderV2(def, item); | ||
} | ||
} | ||
} | ||
else { | ||
const renderedO = (0, utils_1.renderIfNoFetchOrFetchDefined)(fetch, key, (f) => O.some(this.renderV2(def, item, f))); | ||
if (O.isSome(renderedO)) { | ||
result[key] = renderedO.value; | ||
} | ||
} | ||
}); | ||
return result; | ||
}, | ||
renderObjectOfSimpleWidgetMocks(content, fieldsDef) { | ||
const itemByKey = content instanceof Array ? Object.fromEntries(content) : content; | ||
const result = {}; | ||
Object.entries(fieldsDef).forEach(([name, def]) => { | ||
const key = name; | ||
const item = itemByKey[key]; | ||
if (item === undefined) { | ||
result[key] = this.renderDefault(def); | ||
} | ||
else if (content_1.EmptyContent.is(item)) { | ||
result[key] = this.renderDefault(def); | ||
} | ||
else { | ||
const renderedO = (0, utils_1.renderIfNoFetchOrFetchDefined)(undefined, key, () => O.some(this.renderMocks(def, item))); | ||
if (O.isSome(renderedO)) { | ||
result[key] = renderedO.value; | ||
} | ||
} | ||
}); | ||
return result; | ||
}, | ||
}); | ||
exports.default = SimpleWidgetRenderer; |
@@ -13,3 +13,3 @@ "use strict"; | ||
const itemsValue = content.repeat.flatMap((groupItem) => { | ||
const rendered = (0, SimpleWidgetRenderer_1.default)(ctx).renderObjectOfSimpleWidgetV1(groupItem.value, repeatFetch); | ||
const rendered = (0, SimpleWidgetRenderer_1.default)(ctx).renderV1Object(groupItem.value, repeatFetch); | ||
if ((0, utils_1.isEmpty)(rendered)) { | ||
@@ -20,3 +20,3 @@ return []; | ||
}); | ||
const primaryValue = (0, SimpleWidgetRenderer_1.default)(ctx).renderObjectOfSimpleWidgetV1(content.nonRepeat, nonRepeatFetch); | ||
const primaryValue = (0, SimpleWidgetRenderer_1.default)(ctx).renderV1Object(content.nonRepeat, nonRepeatFetch); | ||
return { | ||
@@ -39,3 +39,3 @@ "non-repeat": primaryValue, | ||
return content.repeat.map((items) => { | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderObjectOfSimpleWidgetV2(items.value, repeatFetch === null || repeatFetch === void 0 ? void 0 : repeatFetch.fields, def.repeat || {}, { | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderV2Object(items.value, repeatFetch === null || repeatFetch === void 0 ? void 0 : repeatFetch.fields, def.repeat || {}, { | ||
withFetch: "default", | ||
@@ -50,3 +50,3 @@ }, { | ||
const primaryValue = (() => { | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderObjectOfSimpleWidgetV2(content.nonRepeat, nonRepeatFetch, def["non-repeat"] || {}, { | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderV2Object(content.nonRepeat, nonRepeatFetch, def["non-repeat"] || {}, { | ||
withFetch: "default", | ||
@@ -69,5 +69,5 @@ }, { | ||
const itemsValue = content.repeat.map((items) => { | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderObjectOfSimpleWidgetMocks(items.value, def.repeat || {}); | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderMocksObject(items.value, def.repeat || {}); | ||
}); | ||
const primaryValue = (0, SimpleWidgetRenderer_1.default)(ctx).renderObjectOfSimpleWidgetMocks(content.nonRepeat, def["non-repeat"] || {}); | ||
const primaryValue = (0, SimpleWidgetRenderer_1.default)(ctx).renderMocksObject(content.nonRepeat, def["non-repeat"] || {}); | ||
return { | ||
@@ -74,0 +74,0 @@ primary: primaryValue, |
@@ -5,2 +5,3 @@ "use strict"; | ||
const SimpleWidgetRenderer_1 = tslib_1.__importDefault(require("../SimpleWidgetRenderer")); | ||
const StaticWidgetRenderer_1 = tslib_1.__importDefault(require("../StaticWidgetRenderer")); | ||
function getFetchField(variation, part, fetch) { | ||
@@ -13,5 +14,5 @@ var _a, _b, _c; | ||
const itemsValue = content.items.map((groupItem) => { | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderObjectOfSimpleWidgetV1(groupItem.value, getFetchField(content.variation, "repeat", fetch)); | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderV1Object(groupItem.value, getFetchField(content.variation, "repeat", fetch)); | ||
}); | ||
const primaryValue = (0, SimpleWidgetRenderer_1.default)(ctx).renderObjectOfSimpleWidgetV1(content.primary, getFetchField(content.variation, "nonRepeat", fetch)); | ||
const primaryValue = (0, StaticWidgetRenderer_1.default)(ctx).renderV1Object(content.primary, getFetchField(content.variation, "nonRepeat", fetch)); | ||
return { | ||
@@ -29,3 +30,3 @@ variation: content.variation, | ||
const itemsValue = content.items.map((groupItem) => { | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderObjectOfSimpleWidgetV2(groupItem.value, getFetchField(content.variation, "repeat", fetch), variation.items || {}, { | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderV2Object(groupItem.value, getFetchField(content.variation, "repeat", fetch), variation.items || {}, { | ||
withFetch: "filter", | ||
@@ -38,3 +39,3 @@ }, { | ||
}); | ||
const primaryValue = (0, SimpleWidgetRenderer_1.default)(ctx).renderObjectOfSimpleWidgetV2(content.primary, getFetchField(content.variation, "nonRepeat", fetch), variation.primary || {}, { | ||
const primaryValue = (0, StaticWidgetRenderer_1.default)(ctx).renderV2Object(content.primary, getFetchField(content.variation, "nonRepeat", fetch), variation.primary || {}, { | ||
withFetch: "filter", | ||
@@ -62,5 +63,5 @@ }, { | ||
const itemsValue = content.items.map((groupItem) => { | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderObjectOfSimpleWidgetMocks(groupItem.value, variation.items || {}); | ||
return (0, SimpleWidgetRenderer_1.default)(ctx).renderMocksObject(groupItem.value, variation.items || {}); | ||
}); | ||
const primaryValue = (0, SimpleWidgetRenderer_1.default)(ctx).renderObjectOfSimpleWidgetMocks(content.primary, variation.primary || {}); | ||
const primaryValue = (0, StaticWidgetRenderer_1.default)(ctx).renderMocksObject(content.primary, variation.primary || {}); | ||
return { | ||
@@ -67,0 +68,0 @@ variation: content.variation, |
@@ -1,6 +0,1914 @@ | ||
import { GroupContent, NestableContent } from "@prismicio/types-internal/lib/content"; | ||
import type { Group as GroupField, NestableWidget } from "@prismicio/types-internal/lib/customtypes"; | ||
import type { RenderContext, Renderer } from "../models"; | ||
import type { RenderContext } from "../models"; | ||
import { GroupOrField } from "../models/fetch"; | ||
declare const StaticWidgetRenderer: (ctx: RenderContext) => Renderer<NestableWidget | GroupField, NestableContent | GroupContent, GroupOrField>; | ||
declare const StaticWidgetRenderer: (ctx: RenderContext) => import("../object").WithObjectRenderers<import("../models").Renderer<({ | ||
type: "Group"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
icon?: string | undefined; | ||
description?: string | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
repeat?: boolean | undefined; | ||
fields?: { | ||
[x: string]: ({ | ||
type: "Color"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Boolean"; | ||
} & { | ||
config?: { | ||
label?: string | null | undefined; | ||
default_value?: boolean | undefined; | ||
placeholder_true?: string | undefined; | ||
placeholder_false?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Embed"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
useAsTitle?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "GeoPoint"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Date"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Number"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
min?: number | undefined; | ||
max?: number | undefined; | ||
step?: number | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Range"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
min?: number | undefined; | ||
max?: number | undefined; | ||
step?: number | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "StructuredText"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
useAsTitle?: boolean | undefined; | ||
single?: string | undefined; | ||
multi?: string | undefined; | ||
imageConstraint?: { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
} | undefined; | ||
labels?: readonly string[] | undefined; | ||
allowTargetBlank?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Select"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default_value?: string | undefined; | ||
options?: readonly string[] | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Separator"; | ||
} & { | ||
config?: { | ||
label?: string | null | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Text"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
useAsTitle?: boolean | undefined; | ||
placeholder?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Timestamp"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Link"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
useAsTitle?: boolean | undefined; | ||
placeholder?: string | undefined; | ||
select?: "document" | "media" | "web" | null | undefined; | ||
customtypes?: readonly string[] | undefined; | ||
masks?: readonly string[] | undefined; | ||
tags?: readonly string[] | undefined; | ||
allowTargetBlank?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Image"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
constraint?: { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
} | undefined; | ||
thumbnails?: readonly ({ | ||
name: string; | ||
} & { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
})[] | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "IntegrationFields"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
catalog?: string | undefined; | ||
} | undefined; | ||
}); | ||
} | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Color"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Boolean"; | ||
} & { | ||
config?: { | ||
label?: string | null | undefined; | ||
default_value?: boolean | undefined; | ||
placeholder_true?: string | undefined; | ||
placeholder_false?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Embed"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
useAsTitle?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "GeoPoint"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Date"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Number"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
min?: number | undefined; | ||
max?: number | undefined; | ||
step?: number | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Range"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
min?: number | undefined; | ||
max?: number | undefined; | ||
step?: number | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "StructuredText"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
useAsTitle?: boolean | undefined; | ||
single?: string | undefined; | ||
multi?: string | undefined; | ||
imageConstraint?: { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
} | undefined; | ||
labels?: readonly string[] | undefined; | ||
allowTargetBlank?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Select"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default_value?: string | undefined; | ||
options?: readonly string[] | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Separator"; | ||
} & { | ||
config?: { | ||
label?: string | null | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Text"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
useAsTitle?: boolean | undefined; | ||
placeholder?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Timestamp"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Link"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
useAsTitle?: boolean | undefined; | ||
placeholder?: string | undefined; | ||
select?: "document" | "media" | "web" | null | undefined; | ||
customtypes?: readonly string[] | undefined; | ||
masks?: readonly string[] | undefined; | ||
tags?: readonly string[] | undefined; | ||
allowTargetBlank?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Image"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
constraint?: { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
} | undefined; | ||
thumbnails?: readonly ({ | ||
name: string; | ||
} & { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
})[] | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "IntegrationFields"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
catalog?: string | undefined; | ||
} | undefined; | ||
}), { | ||
type: string; | ||
__TYPE__: "EmptyContent"; | ||
} | { | ||
__TYPE__: "BooleanContent"; | ||
value: boolean; | ||
} | ({ | ||
embed_url: string; | ||
type: string; | ||
} & { | ||
version?: string | number | null | undefined; | ||
title?: string | null | undefined; | ||
author_name?: string | null | undefined; | ||
author_url?: string | null | undefined; | ||
provider_name?: string | null | undefined; | ||
provider_url?: string | null | undefined; | ||
cache_age?: string | number | null | undefined; | ||
thumbnail_url?: string | null | undefined; | ||
thumbnail_width?: number | null | undefined; | ||
thumbnail_height?: number | null | undefined; | ||
html?: string | null | undefined; | ||
} & { | ||
__TYPE__: "EmbedContent"; | ||
all: unknown; | ||
}) | { | ||
type: "Text"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Timestamp"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Select"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Range"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Number"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Date"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Color"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | ({ | ||
position: { | ||
lat: number; | ||
lng: number; | ||
}; | ||
} & { | ||
__TYPE__: "GeoPointContent"; | ||
}) | ({ | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
} & { | ||
thumbnails?: { | ||
[x: string]: { | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
}; | ||
} | undefined; | ||
} & { | ||
__TYPE__: "ImageContent"; | ||
}) | { | ||
__TYPE__: "IntegrationFieldsContent"; | ||
value: string; | ||
} | { | ||
__TYPE__: "LinkContent"; | ||
value: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}); | ||
} | { | ||
__TYPE__: "StructuredTextContent"; | ||
value: (({ | ||
type: "image"; | ||
data: { | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
} & { | ||
linkTo?: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}) | null | undefined; | ||
}; | ||
} & { | ||
label?: string | null | undefined; | ||
direction?: string | null | undefined; | ||
}) | ({ | ||
type: "embed"; | ||
data: { | ||
embed_url: string; | ||
type: string; | ||
} & { | ||
version?: string | number | null | undefined; | ||
title?: string | null | undefined; | ||
author_name?: string | null | undefined; | ||
author_url?: string | null | undefined; | ||
provider_name?: string | null | undefined; | ||
provider_url?: string | null | undefined; | ||
cache_age?: string | number | null | undefined; | ||
thumbnail_url?: string | null | undefined; | ||
thumbnail_width?: number | null | undefined; | ||
thumbnail_height?: number | null | undefined; | ||
html?: string | null | undefined; | ||
} & { | ||
__TYPE__: "EmbedContent"; | ||
all: unknown; | ||
}; | ||
} & { | ||
label?: string | null | undefined; | ||
direction?: string | null | undefined; | ||
}) | ({ | ||
type: "embed" | "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "list-item" | "o-list-item" | "rtl"; | ||
content: { | ||
text: string; | ||
} & { | ||
spans?: ({ | ||
data: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}); | ||
start: number; | ||
end: number; | ||
type: "hyperlink"; | ||
} | { | ||
data: string; | ||
start: number; | ||
end: number; | ||
type: "label"; | ||
} | { | ||
start: number; | ||
end: number; | ||
type: "strong" | "em" | "list-item"; | ||
})[] | undefined; | ||
}; | ||
} & { | ||
label?: string | undefined; | ||
direction?: string | undefined; | ||
}))[]; | ||
} | { | ||
__TYPE__: "SeparatorContent"; | ||
} | { | ||
__TYPE__: "GroupContentType"; | ||
value: { | ||
__TYPE__: "GroupItemContent"; | ||
value: [string, { | ||
type: string; | ||
__TYPE__: "EmptyContent"; | ||
} | { | ||
__TYPE__: "BooleanContent"; | ||
value: boolean; | ||
} | ({ | ||
embed_url: string; | ||
type: string; | ||
} & { | ||
version?: string | number | null | undefined; | ||
title?: string | null | undefined; | ||
author_name?: string | null | undefined; | ||
author_url?: string | null | undefined; | ||
provider_name?: string | null | undefined; | ||
provider_url?: string | null | undefined; | ||
cache_age?: string | number | null | undefined; | ||
thumbnail_url?: string | null | undefined; | ||
thumbnail_width?: number | null | undefined; | ||
thumbnail_height?: number | null | undefined; | ||
html?: string | null | undefined; | ||
} & { | ||
__TYPE__: "EmbedContent"; | ||
all: unknown; | ||
}) | { | ||
type: "Text"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Timestamp"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Select"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Range"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Number"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Date"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Color"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | ({ | ||
position: { | ||
lat: number; | ||
lng: number; | ||
}; | ||
} & { | ||
__TYPE__: "GeoPointContent"; | ||
}) | ({ | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
} & { | ||
thumbnails?: { | ||
[x: string]: { | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
}; | ||
} | undefined; | ||
} & { | ||
__TYPE__: "ImageContent"; | ||
}) | { | ||
__TYPE__: "IntegrationFieldsContent"; | ||
value: string; | ||
} | { | ||
__TYPE__: "LinkContent"; | ||
value: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}); | ||
} | { | ||
__TYPE__: "StructuredTextContent"; | ||
value: (({ | ||
type: "image"; | ||
data: { | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
} & { | ||
linkTo?: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}) | null | undefined; | ||
}; | ||
} & { | ||
label?: string | null | undefined; | ||
direction?: string | null | undefined; | ||
}) | ({ | ||
type: "embed"; | ||
data: { | ||
embed_url: string; | ||
type: string; | ||
} & { | ||
version?: string | number | null | undefined; | ||
title?: string | null | undefined; | ||
author_name?: string | null | undefined; | ||
author_url?: string | null | undefined; | ||
provider_name?: string | null | undefined; | ||
provider_url?: string | null | undefined; | ||
cache_age?: string | number | null | undefined; | ||
thumbnail_url?: string | null | undefined; | ||
thumbnail_width?: number | null | undefined; | ||
thumbnail_height?: number | null | undefined; | ||
html?: string | null | undefined; | ||
} & { | ||
__TYPE__: "EmbedContent"; | ||
all: unknown; | ||
}; | ||
} & { | ||
label?: string | null | undefined; | ||
direction?: string | null | undefined; | ||
}) | ({ | ||
type: "embed" | "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "list-item" | "o-list-item" | "rtl"; | ||
content: { | ||
text: string; | ||
} & { | ||
spans?: ({ | ||
data: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}); | ||
start: number; | ||
end: number; | ||
type: "hyperlink"; | ||
} | { | ||
data: string; | ||
start: number; | ||
end: number; | ||
type: "label"; | ||
} | { | ||
start: number; | ||
end: number; | ||
type: "strong" | "em" | "list-item"; | ||
})[] | undefined; | ||
}; | ||
} & { | ||
label?: string | undefined; | ||
direction?: string | undefined; | ||
}))[]; | ||
} | { | ||
__TYPE__: "SeparatorContent"; | ||
}][]; | ||
}[]; | ||
}, GroupOrField>, ({ | ||
type: "Group"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
icon?: string | undefined; | ||
description?: string | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
repeat?: boolean | undefined; | ||
fields?: { | ||
[x: string]: ({ | ||
type: "Color"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Boolean"; | ||
} & { | ||
config?: { | ||
label?: string | null | undefined; | ||
default_value?: boolean | undefined; | ||
placeholder_true?: string | undefined; | ||
placeholder_false?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Embed"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
useAsTitle?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "GeoPoint"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Date"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Number"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
min?: number | undefined; | ||
max?: number | undefined; | ||
step?: number | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Range"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
min?: number | undefined; | ||
max?: number | undefined; | ||
step?: number | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "StructuredText"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
useAsTitle?: boolean | undefined; | ||
single?: string | undefined; | ||
multi?: string | undefined; | ||
imageConstraint?: { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
} | undefined; | ||
labels?: readonly string[] | undefined; | ||
allowTargetBlank?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Select"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default_value?: string | undefined; | ||
options?: readonly string[] | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Separator"; | ||
} & { | ||
config?: { | ||
label?: string | null | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Text"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
useAsTitle?: boolean | undefined; | ||
placeholder?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Timestamp"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Link"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
useAsTitle?: boolean | undefined; | ||
placeholder?: string | undefined; | ||
select?: "document" | "media" | "web" | null | undefined; | ||
customtypes?: readonly string[] | undefined; | ||
masks?: readonly string[] | undefined; | ||
tags?: readonly string[] | undefined; | ||
allowTargetBlank?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Image"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
constraint?: { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
} | undefined; | ||
thumbnails?: readonly ({ | ||
name: string; | ||
} & { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
})[] | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "IntegrationFields"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
catalog?: string | undefined; | ||
} | undefined; | ||
}); | ||
} | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Color"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Boolean"; | ||
} & { | ||
config?: { | ||
label?: string | null | undefined; | ||
default_value?: boolean | undefined; | ||
placeholder_true?: string | undefined; | ||
placeholder_false?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Embed"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
useAsTitle?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "GeoPoint"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Date"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Number"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
min?: number | undefined; | ||
max?: number | undefined; | ||
step?: number | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Range"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
min?: number | undefined; | ||
max?: number | undefined; | ||
step?: number | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "StructuredText"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
useAsTitle?: boolean | undefined; | ||
single?: string | undefined; | ||
multi?: string | undefined; | ||
imageConstraint?: { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
} | undefined; | ||
labels?: readonly string[] | undefined; | ||
allowTargetBlank?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Select"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default_value?: string | undefined; | ||
options?: readonly string[] | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Separator"; | ||
} & { | ||
config?: { | ||
label?: string | null | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Text"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
useAsTitle?: boolean | undefined; | ||
placeholder?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Timestamp"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
default?: string | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Link"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
useAsTitle?: boolean | undefined; | ||
placeholder?: string | undefined; | ||
select?: "document" | "media" | "web" | null | undefined; | ||
customtypes?: readonly string[] | undefined; | ||
masks?: readonly string[] | undefined; | ||
tags?: readonly string[] | undefined; | ||
allowTargetBlank?: boolean | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "Image"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
constraint?: { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
} | undefined; | ||
thumbnails?: readonly ({ | ||
name: string; | ||
} & { | ||
width?: number | null | undefined; | ||
height?: number | null | undefined; | ||
})[] | undefined; | ||
} | undefined; | ||
}) | ({ | ||
type: "IntegrationFields"; | ||
} & { | ||
fieldset?: string | null | undefined; | ||
config?: { | ||
label?: string | null | undefined; | ||
placeholder?: string | undefined; | ||
catalog?: string | undefined; | ||
} | undefined; | ||
}), { | ||
type: string; | ||
__TYPE__: "EmptyContent"; | ||
} | { | ||
__TYPE__: "BooleanContent"; | ||
value: boolean; | ||
} | ({ | ||
embed_url: string; | ||
type: string; | ||
} & { | ||
version?: string | number | null | undefined; | ||
title?: string | null | undefined; | ||
author_name?: string | null | undefined; | ||
author_url?: string | null | undefined; | ||
provider_name?: string | null | undefined; | ||
provider_url?: string | null | undefined; | ||
cache_age?: string | number | null | undefined; | ||
thumbnail_url?: string | null | undefined; | ||
thumbnail_width?: number | null | undefined; | ||
thumbnail_height?: number | null | undefined; | ||
html?: string | null | undefined; | ||
} & { | ||
__TYPE__: "EmbedContent"; | ||
all: unknown; | ||
}) | { | ||
type: "Text"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Timestamp"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Select"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Range"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Number"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Date"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Color"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | ({ | ||
position: { | ||
lat: number; | ||
lng: number; | ||
}; | ||
} & { | ||
__TYPE__: "GeoPointContent"; | ||
}) | ({ | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
} & { | ||
thumbnails?: { | ||
[x: string]: { | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
}; | ||
} | undefined; | ||
} & { | ||
__TYPE__: "ImageContent"; | ||
}) | { | ||
__TYPE__: "IntegrationFieldsContent"; | ||
value: string; | ||
} | { | ||
__TYPE__: "LinkContent"; | ||
value: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}); | ||
} | { | ||
__TYPE__: "StructuredTextContent"; | ||
value: (({ | ||
type: "image"; | ||
data: { | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
} & { | ||
linkTo?: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}) | null | undefined; | ||
}; | ||
} & { | ||
label?: string | null | undefined; | ||
direction?: string | null | undefined; | ||
}) | ({ | ||
type: "embed"; | ||
data: { | ||
embed_url: string; | ||
type: string; | ||
} & { | ||
version?: string | number | null | undefined; | ||
title?: string | null | undefined; | ||
author_name?: string | null | undefined; | ||
author_url?: string | null | undefined; | ||
provider_name?: string | null | undefined; | ||
provider_url?: string | null | undefined; | ||
cache_age?: string | number | null | undefined; | ||
thumbnail_url?: string | null | undefined; | ||
thumbnail_width?: number | null | undefined; | ||
thumbnail_height?: number | null | undefined; | ||
html?: string | null | undefined; | ||
} & { | ||
__TYPE__: "EmbedContent"; | ||
all: unknown; | ||
}; | ||
} & { | ||
label?: string | null | undefined; | ||
direction?: string | null | undefined; | ||
}) | ({ | ||
type: "embed" | "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "list-item" | "o-list-item" | "rtl"; | ||
content: { | ||
text: string; | ||
} & { | ||
spans?: ({ | ||
data: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}); | ||
start: number; | ||
end: number; | ||
type: "hyperlink"; | ||
} | { | ||
data: string; | ||
start: number; | ||
end: number; | ||
type: "label"; | ||
} | { | ||
start: number; | ||
end: number; | ||
type: "strong" | "em" | "list-item"; | ||
})[] | undefined; | ||
}; | ||
} & { | ||
label?: string | undefined; | ||
direction?: string | undefined; | ||
}))[]; | ||
} | { | ||
__TYPE__: "SeparatorContent"; | ||
} | { | ||
__TYPE__: "GroupContentType"; | ||
value: { | ||
__TYPE__: "GroupItemContent"; | ||
value: [string, { | ||
type: string; | ||
__TYPE__: "EmptyContent"; | ||
} | { | ||
__TYPE__: "BooleanContent"; | ||
value: boolean; | ||
} | ({ | ||
embed_url: string; | ||
type: string; | ||
} & { | ||
version?: string | number | null | undefined; | ||
title?: string | null | undefined; | ||
author_name?: string | null | undefined; | ||
author_url?: string | null | undefined; | ||
provider_name?: string | null | undefined; | ||
provider_url?: string | null | undefined; | ||
cache_age?: string | number | null | undefined; | ||
thumbnail_url?: string | null | undefined; | ||
thumbnail_width?: number | null | undefined; | ||
thumbnail_height?: number | null | undefined; | ||
html?: string | null | undefined; | ||
} & { | ||
__TYPE__: "EmbedContent"; | ||
all: unknown; | ||
}) | { | ||
type: "Text"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Timestamp"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Select"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Range"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Number"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Date"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | { | ||
type: "Color"; | ||
value: string; | ||
__TYPE__: "FieldContent"; | ||
} | ({ | ||
position: { | ||
lat: number; | ||
lng: number; | ||
}; | ||
} & { | ||
__TYPE__: "GeoPointContent"; | ||
}) | ({ | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
} & { | ||
thumbnails?: { | ||
[x: string]: { | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
}; | ||
} | undefined; | ||
} & { | ||
__TYPE__: "ImageContent"; | ||
}) | { | ||
__TYPE__: "IntegrationFieldsContent"; | ||
value: string; | ||
} | { | ||
__TYPE__: "LinkContent"; | ||
value: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}); | ||
} | { | ||
__TYPE__: "StructuredTextContent"; | ||
value: (({ | ||
type: "image"; | ||
data: { | ||
origin: { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
}; | ||
width: number; | ||
height: number; | ||
edit: { | ||
zoom: number; | ||
crop: { | ||
x: number; | ||
y: number; | ||
}; | ||
background: string; | ||
}; | ||
} & { | ||
url?: string | undefined; | ||
credits?: string | null | undefined; | ||
alt?: string | null | undefined; | ||
provider?: string | null | undefined; | ||
} & { | ||
linkTo?: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}) | null | undefined; | ||
}; | ||
} & { | ||
label?: string | null | undefined; | ||
direction?: string | null | undefined; | ||
}) | ({ | ||
type: "embed"; | ||
data: { | ||
embed_url: string; | ||
type: string; | ||
} & { | ||
version?: string | number | null | undefined; | ||
title?: string | null | undefined; | ||
author_name?: string | null | undefined; | ||
author_url?: string | null | undefined; | ||
provider_name?: string | null | undefined; | ||
provider_url?: string | null | undefined; | ||
cache_age?: string | number | null | undefined; | ||
thumbnail_url?: string | null | undefined; | ||
thumbnail_width?: number | null | undefined; | ||
thumbnail_height?: number | null | undefined; | ||
html?: string | null | undefined; | ||
} & { | ||
__TYPE__: "EmbedContent"; | ||
all: unknown; | ||
}; | ||
} & { | ||
label?: string | null | undefined; | ||
direction?: string | null | undefined; | ||
}) | ({ | ||
type: "embed" | "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "list-item" | "o-list-item" | "rtl"; | ||
content: { | ||
text: string; | ||
} & { | ||
spans?: ({ | ||
data: ({ | ||
__TYPE__: "ImageLink"; | ||
} & { | ||
id: string; | ||
url: string; | ||
height: string; | ||
width: string; | ||
size: string; | ||
name: string; | ||
kind: string; | ||
} & { | ||
date?: string | null | undefined; | ||
}) | ({ | ||
id: string; | ||
url: string; | ||
name: string; | ||
kind: string; | ||
size: string; | ||
} & { | ||
date?: string | null | undefined; | ||
} & { | ||
__TYPE__: "FileLink"; | ||
} & { | ||
size?: string | undefined; | ||
}) | ({ | ||
__TYPE__: "DocumentLink"; | ||
} & { | ||
id: string; | ||
}) | ({ | ||
__TYPE__: "ExternalLink"; | ||
} & { | ||
url: string; | ||
} & { | ||
kind?: "web" | undefined; | ||
target?: string | null | undefined; | ||
preview?: { | ||
title?: string | undefined; | ||
} | null | undefined; | ||
}); | ||
start: number; | ||
end: number; | ||
type: "hyperlink"; | ||
} | { | ||
data: string; | ||
start: number; | ||
end: number; | ||
type: "label"; | ||
} | { | ||
start: number; | ||
end: number; | ||
type: "strong" | "em" | "list-item"; | ||
})[] | undefined; | ||
}; | ||
} & { | ||
label?: string | undefined; | ||
direction?: string | undefined; | ||
}))[]; | ||
} | { | ||
__TYPE__: "SeparatorContent"; | ||
}][]; | ||
}[]; | ||
}, GroupOrField>; | ||
export default StaticWidgetRenderer; |
@@ -6,2 +6,3 @@ "use strict"; | ||
const fetch_1 = require("../models/fetch"); | ||
const object_1 = require("../object"); | ||
const GroupRenderer_1 = tslib_1.__importDefault(require("./GroupRenderer")); | ||
@@ -25,3 +26,3 @@ const SimpleWidgetRenderer_1 = tslib_1.__importDefault(require("./SimpleWidgetRenderer")); | ||
} | ||
const StaticWidgetRenderer = (ctx) => ({ | ||
const StaticWidgetRenderer = (ctx) => (0, object_1.withObjectRenderers)({ | ||
renderV1(content, fetch) { | ||
@@ -28,0 +29,0 @@ if ((0, content_1.isGroupContent)(content)) { |
{ | ||
"name": "@prismicio/api-renderer", | ||
"version": "3.1.0-alpha.1", | ||
"version": "3.1.0-alpha.2", | ||
"description": "Prismic renderers for the content API", | ||
@@ -28,4 +28,4 @@ "keywords": [ | ||
"release:dry": "standard-version --dry-run", | ||
"release:alpha": "npm run test && standard-version --prerelease alpha && git push --follow-tags && npm run build && npm publish --tag alpha", | ||
"release:alpha:dry": "standard-version --prerelease alpha --dry-run", | ||
"release:alpha": "npm run test && standard-version --release-as minor --prerelease alpha && git push --follow-tags && npm run build && npm publish --tag alpha", | ||
"release:alpha:dry": "standard-version --release-as minor --prerelease alpha --dry-run", | ||
"test": "jest --no-cache --silent=false --verbose=false --coverage", | ||
@@ -39,3 +39,3 @@ "eslint": "eslint . --cache --cache-location .caches/eslint --cache-strategy content --ext js,ts,tsx --max-warnings 0", | ||
"dependencies": { | ||
"@prismicio/types-internal": "2.4.0-alpha.1", | ||
"@prismicio/types-internal": "2.4.0-alpha.4", | ||
"tslib": "^2.5.0", | ||
@@ -42,0 +42,0 @@ "uuid": "^9.0.0" |
@@ -48,2 +48,6 @@ # @prismicio/api-renderer | ||
**Testing your changes Locally**: Reference this project in your local Wroom-Lambda-API to test your changes using [npm link](https://docs.npmjs.com/cli/v10/commands/npm-link) | ||
**Testing your changes Remotely**: Deploy an alpha version of this package, reference it in your Wroom-Lambda-API PR and deploy Wroom-Lambda-API in your environment. | ||
## License | ||
@@ -50,0 +54,0 @@ |
@@ -7,7 +7,10 @@ import { SharedSlice, Variation } from "@prismicio/types-internal/lib/customtypes" | ||
import { hasType, isFieldDef, WithKey } from "../../utils" | ||
import { GroupDef } from "../GroupDef" | ||
import { NestableDef } from "../nestable/NestableDef" | ||
export const VariationPrimaryDef = t.union([GroupDef, NestableDef]) | ||
const variationCodec = t.strict({ | ||
id: t.string, | ||
primary: t.array(NestableDef), | ||
primary: t.array(VariationPrimaryDef), | ||
items: t.array(NestableDef), | ||
@@ -14,0 +17,0 @@ version: t.string, |
@@ -54,3 +54,3 @@ import * as t from "io-ts" | ||
fields: { | ||
[key: string]: Field | ||
[key: string]: GroupOrField | ||
} | ||
@@ -69,3 +69,3 @@ } | ||
nonRepeat: t.strict({ | ||
fields: t.record(t.string, FieldC), | ||
fields: t.record(t.string, GroupOrFieldC), | ||
}), | ||
@@ -72,0 +72,0 @@ repeat: t.strict({ |
@@ -14,3 +14,3 @@ import type { GroupContent } from "@prismicio/types-internal/lib/content" | ||
value: content.value.map((items) => { | ||
return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV1(items.value, fetch?.fields) | ||
return SimpleWidgetRenderer(ctx).renderV1Object(items.value, fetch?.fields) | ||
}), | ||
@@ -22,3 +22,3 @@ } | ||
return content.value.map((items) => { | ||
return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV2( | ||
return SimpleWidgetRenderer(ctx).renderV2Object( | ||
items.value, | ||
@@ -46,3 +46,3 @@ fetch?.fields, | ||
if (!def.config?.fields) return {} | ||
return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetMocks(items.value, def.config?.fields) | ||
return SimpleWidgetRenderer(ctx).renderMocksObject(items.value, def.config?.fields) | ||
}) | ||
@@ -49,0 +49,0 @@ }, |
@@ -13,3 +13,2 @@ import type { ImageContent, ImageContentView } from "@prismicio/types-internal/lib/content" | ||
id: imageContentView.origin.id, | ||
caption: writeEmptyStringOrNull(imageContentView.caption, ctx.emptyStringInsteadOfNull), | ||
edit: { | ||
@@ -16,0 +15,0 @@ x: imageContentView.edit.crop.x, |
@@ -24,2 +24,3 @@ import type { FileLinkContent } from "@prismicio/types-internal/lib/content" | ||
link_type: "Media", | ||
id: link.id, | ||
name: link.name, | ||
@@ -26,0 +27,0 @@ kind: link.kind, |
import { | ||
EmptyContent, | ||
isBooleanContent, | ||
@@ -31,9 +30,6 @@ isColorContent, | ||
} from "@prismicio/types-internal/lib/customtypes" | ||
import { compact } from "fp-ts/lib/Array" | ||
import * as O from "fp-ts/lib/Option" | ||
import type { RenderContext } from "../models" | ||
import type { Renderer } from "../models" | ||
import { DocRelation, DocRelationType, Field, SimpleField, SimpleFieldType } from "../models/fetch" | ||
import { renderIfNoFetchOrFetchDefined } from "../utils" | ||
import { withObjectRenderers } from "../object" | ||
import { | ||
@@ -68,249 +64,128 @@ BooleanRenderer, | ||
const SimpleWidgetRenderer: (ctx: RenderContext) => Renderer<NestableWidget, NestableContent, Field> & { | ||
renderObjectOfSimpleWidgetV1( | ||
content: Array<[string, NestableContent]> | Record<string, NestableContent>, | ||
fetch: Record<string, Field> | undefined, | ||
): object | ||
renderObjectOfSimpleWidgetV2( | ||
content: Array<[string, NestableContent]> | Record<string, NestableContent>, | ||
fetch: Record<string, Field> | undefined, | ||
fieldsDef: Record<string, NestableWidget>, | ||
renderIfUndefined: { | ||
withFetch: "default" | "filter" | ||
const SimpleWidgetRenderer = (ctx: RenderContext) => | ||
withObjectRenderers<NestableWidget, NestableContent, Field>({ | ||
renderV1(content, fetch) { | ||
if (isRichTextContent(content)) { | ||
return StructuredTextRenderer(ctx).renderV1(content, extractSimpleFieldIfAny(fetch)) | ||
} else if (isImageContent(content)) { | ||
return ImageRenderer(ctx).renderV1(content) | ||
} else if ( | ||
// We should split the renderers of each | ||
isRangeContent(content) || | ||
isNumberContent(content) || | ||
isTimestampContent(content) || | ||
isDateContent(content) || | ||
isTextContent(content) || | ||
isColorContent(content) || | ||
isSelectContent(content) | ||
) { | ||
return FieldRenderer.renderV1(content) | ||
} else if (isLinkContent(content)) { | ||
return LinkRenderer(ctx).renderV1(content, extractFetchDocRelationIfAny(fetch)) | ||
} else if (isEmbedContent(content)) { | ||
return EmbedRenderer.renderV1(content) | ||
} else if (isGeoPointContent(content)) { | ||
return GeoPointRenderer.renderV1(content) | ||
} else if (isUIDContent(content)) { | ||
return UIDRenderer.renderV1(content) | ||
} else if (isIntegrationFieldContent(content)) { | ||
return IntegrationFieldsRenderer(ctx).renderV1(content) | ||
} else if (isSeparatorContent(content)) { | ||
return SeparatorRenderer.renderV1(content) | ||
} else if (isBooleanContent(content)) { | ||
return BooleanRenderer.renderV1(content) | ||
} else { | ||
return null | ||
} | ||
}, | ||
renderIfNull: { | ||
default: "default" | "render" | "filter" | ||
withFetch: "default" | "filter" | ||
withFetchField: "default" | "render" | "filter" | ||
}, | ||
): Record<string, unknown> | ||
renderObjectOfSimpleWidgetMocks( | ||
content: Array<[string, NestableContent]> | Record<string, NestableContent>, | ||
fieldsDef: Record<string, NestableWidget>, | ||
): Record<string, unknown> | ||
} = (ctx) => ({ | ||
renderV1(content: NestableContent, fetch: Field | undefined): unknown { | ||
if (isRichTextContent(content)) { | ||
return StructuredTextRenderer(ctx).renderV1(content, extractSimpleFieldIfAny(fetch)) | ||
} else if (isImageContent(content)) { | ||
return ImageRenderer(ctx).renderV1(content) | ||
} else if ( | ||
// We should split the renderers of each | ||
isRangeContent(content) || | ||
isNumberContent(content) || | ||
isTimestampContent(content) || | ||
isDateContent(content) || | ||
isTextContent(content) || | ||
isColorContent(content) || | ||
isSelectContent(content) | ||
) { | ||
return FieldRenderer.renderV1(content) | ||
} else if (isLinkContent(content)) { | ||
return LinkRenderer(ctx).renderV1(content, extractFetchDocRelationIfAny(fetch)) | ||
} else if (isEmbedContent(content)) { | ||
return EmbedRenderer.renderV1(content) | ||
} else if (isGeoPointContent(content)) { | ||
return GeoPointRenderer.renderV1(content) | ||
} else if (isUIDContent(content)) { | ||
return UIDRenderer.renderV1(content) | ||
} else if (isIntegrationFieldContent(content)) { | ||
return IntegrationFieldsRenderer(ctx).renderV1(content) | ||
} else if (isSeparatorContent(content)) { | ||
return SeparatorRenderer.renderV1(content) | ||
} else if (isBooleanContent(content)) { | ||
return BooleanRenderer.renderV1(content) | ||
} else { | ||
return null | ||
} | ||
}, | ||
renderV2(def: NestableWidget, content: NestableContent, fetch: Field | undefined): unknown { | ||
if (def.type === "StructuredText" && isRichTextContent(content)) { | ||
return StructuredTextRenderer(ctx).renderV2(def, content, extractSimpleFieldIfAny(fetch)) | ||
} else if (def.type === "Image" && isImageContent(content)) { | ||
return ImageRenderer(ctx).renderV2(def, content) | ||
} else if (def.type === "Link" && isLinkContent(content)) { | ||
return LinkRenderer(ctx).renderV2(def, content, extractFetchDocRelationIfAny(fetch)) | ||
} else if (def.type === "Embed" && isEmbedContent(content)) { | ||
return EmbedRenderer.renderV2(def, content) | ||
} else if (def.type === "GeoPoint" && isGeoPointContent(content)) { | ||
return GeoPointRenderer.renderV2(def, content) | ||
} else if (def.type === "IntegrationFields" && isIntegrationFieldContent(content)) { | ||
return IntegrationFieldsRenderer(ctx).renderV2(def, content) | ||
} else if (def.type === "Separator" && isSeparatorContent(content)) { | ||
return SeparatorRenderer.renderV2(def, content) | ||
} else if (def.type === "Boolean" && isBooleanContent(content)) { | ||
return BooleanRenderer.renderV2(def, content) | ||
} else if ( | ||
isRangeContent(content) || | ||
isNumberContent(content) || | ||
isTimestampContent(content) || | ||
isDateContent(content) || | ||
isTextContent(content) || | ||
isColorContent(content) || | ||
isSelectContent(content) | ||
) { | ||
// TODO: because of an old bug, we have to cast the type here to maintain backward compatibility | ||
// We should check that `def.type` is matching FieldDef or fallback to the null case. | ||
return FieldRenderer.renderV2(def as Color | NumberDef | DateDef | Timestamp | Select | Text | Range, content) | ||
} else { | ||
return null | ||
} | ||
}, | ||
renderDefault(def: NestableWidget): unknown { | ||
if (def.type === "Link") { | ||
return LinkRenderer(ctx).renderDefault(def) | ||
} else if (def.type === "Embed") { | ||
return EmbedRenderer.renderDefault(def) | ||
} else if (def.type === "GeoPoint") { | ||
return GeoPointRenderer.renderDefault(def) | ||
} else if (def.type === "StructuredText") { | ||
return StructuredTextRenderer(ctx).renderDefault(def) | ||
} else if (def.type === "Image") { | ||
return ImageRenderer(ctx).renderDefault(def) | ||
} else if (def.type === "Separator") { | ||
return SeparatorRenderer.renderDefault(def) | ||
} else if (def.type === "Boolean") { | ||
return BooleanRenderer.renderDefault(def) | ||
} else if (def.type === "IntegrationFields") { | ||
return IntegrationFieldsRenderer(ctx).renderDefault(def) | ||
} else { | ||
return FieldRenderer.renderDefault(def) | ||
} | ||
}, | ||
renderMocks(def: NestableWidget, content: NestableContent): unknown { | ||
if (def.type === "StructuredText" && isRichTextContent(content)) { | ||
return StructuredTextRenderer(ctx).renderMocks(def, content) | ||
} else if (def.type === "Image" && isImageContent(content)) { | ||
return ImageRenderer(ctx).renderMocks(def, content) | ||
} else if (def.type === "Link" && isLinkContent(content)) { | ||
return LinkRenderer(ctx).renderMocks(def, content) | ||
} else if (def.type === "Embed" && isEmbedContent(content)) { | ||
return EmbedRenderer.renderMocks(def, content) | ||
} else if (def.type === "GeoPoint" && isGeoPointContent(content)) { | ||
return GeoPointRenderer.renderMocks(def, content) | ||
} else if (def.type === "IntegrationFields" && isIntegrationFieldContent(content)) { | ||
return IntegrationFieldsRenderer(ctx).renderMocks(def, content) | ||
} else if (def.type === "Separator" && isSeparatorContent(content)) { | ||
return SeparatorRenderer.renderMocks(def, content) | ||
} else if (def.type === "Boolean" && isBooleanContent(content)) { | ||
return BooleanRenderer.renderMocks(def, content) | ||
} else if ( | ||
(isRangeContent(content) && def.type === "Range") || | ||
(isNumberContent(content) && def.type === "Number") || | ||
(isTimestampContent(content) && def.type === "Timestamp") || | ||
(isDateContent(content) && def.type === "Date") || | ||
(isTextContent(content) && def.type === "Text") || | ||
(isColorContent(content) && def.type === "Color") || | ||
(isSelectContent(content) && def.type === "Select") | ||
) { | ||
return FieldRenderer.renderMocks(def, content) | ||
} else { | ||
return null | ||
} | ||
}, | ||
renderObjectOfSimpleWidgetV1( | ||
content: Array<[string, NestableContent]> | Record<string, NestableContent>, | ||
fetch: Record<string, Field> | undefined, | ||
): object { | ||
const c: Array<[string, NestableContent]> = content instanceof Array ? content : Object.entries(content) | ||
return Object.fromEntries( | ||
compact( | ||
c.map(([key, widget]) => { | ||
if (EmptyContent.is(widget)) { | ||
return O.none | ||
} | ||
return renderIfNoFetchOrFetchDefined(fetch, key, (f: Field | undefined) => | ||
O.some([key, this.renderV1(widget, f)]), | ||
) | ||
}), | ||
), | ||
) | ||
}, | ||
renderObjectOfSimpleWidgetV2( | ||
content: Array<[string, NestableContent]> | Record<string, NestableContent>, | ||
fetch: Record<string, Field> | undefined, | ||
fieldsDef: Record<string, NestableWidget>, | ||
renderIfUndefined: { | ||
withFetch: "default" | "filter" | ||
renderV2(def, content, fetch) { | ||
if (def.type === "StructuredText" && isRichTextContent(content)) { | ||
return StructuredTextRenderer(ctx).renderV2(def, content, extractSimpleFieldIfAny(fetch)) | ||
} else if (def.type === "Image" && isImageContent(content)) { | ||
return ImageRenderer(ctx).renderV2(def, content) | ||
} else if (def.type === "Link" && isLinkContent(content)) { | ||
return LinkRenderer(ctx).renderV2(def, content, extractFetchDocRelationIfAny(fetch)) | ||
} else if (def.type === "Embed" && isEmbedContent(content)) { | ||
return EmbedRenderer.renderV2(def, content) | ||
} else if (def.type === "GeoPoint" && isGeoPointContent(content)) { | ||
return GeoPointRenderer.renderV2(def, content) | ||
} else if (def.type === "IntegrationFields" && isIntegrationFieldContent(content)) { | ||
return IntegrationFieldsRenderer(ctx).renderV2(def, content) | ||
} else if (def.type === "Separator" && isSeparatorContent(content)) { | ||
return SeparatorRenderer.renderV2(def, content) | ||
} else if (def.type === "Boolean" && isBooleanContent(content)) { | ||
return BooleanRenderer.renderV2(def, content) | ||
} else if ( | ||
isRangeContent(content) || | ||
isNumberContent(content) || | ||
isTimestampContent(content) || | ||
isDateContent(content) || | ||
isTextContent(content) || | ||
isColorContent(content) || | ||
isSelectContent(content) | ||
) { | ||
// TODO: because of an old bug, we have to cast the type here to maintain backward compatibility | ||
// We should check that `def.type` is matching FieldDef or fallback to the null case. | ||
return FieldRenderer.renderV2(def as Color | NumberDef | DateDef | Timestamp | Select | Text | Range, content) | ||
} else { | ||
return null | ||
} | ||
}, | ||
renderIfNull: { | ||
default: "default" | "render" | "filter" | ||
withFetch: "default" | "filter" | ||
withFetchField: "default" | "render" | "filter" | ||
}, | ||
): Record<string, unknown> { | ||
const itemByKey: Record<string, NestableContent> = content instanceof Array ? Object.fromEntries(content) : content | ||
const result: Record<string, unknown> = {} | ||
Object.entries(fieldsDef).forEach(([key, def]) => { | ||
const item = itemByKey[key] | ||
if (item === undefined) { | ||
if ((fetch && key in fetch) || !fetch) { | ||
result[key] = this.renderDefault(def) | ||
} else if (fetch) { | ||
if (renderIfUndefined.withFetch === "default") { | ||
result[key] = this.renderDefault(def) | ||
} | ||
} | ||
} else if (EmptyContent.is(item)) { | ||
if (fetch && key in fetch) { | ||
if (renderIfNull.withFetchField === "default") { | ||
result[key] = this.renderDefault(def) | ||
} else if (renderIfNull.withFetchField === "render") { | ||
result[key] = this.renderV2(def, item, fetch[key]) | ||
} | ||
} else if (fetch) { | ||
if (renderIfNull.withFetch === "default") { | ||
result[key] = this.renderDefault(def) | ||
} | ||
} else { | ||
if (renderIfNull.default === "default") { | ||
result[key] = this.renderDefault(def) | ||
} else if (renderIfNull.default === "render") { | ||
result[key] = this.renderV2(def, item) | ||
} | ||
} | ||
renderDefault(def) { | ||
if (def.type === "Link") { | ||
return LinkRenderer(ctx).renderDefault(def) | ||
} else if (def.type === "Embed") { | ||
return EmbedRenderer.renderDefault(def) | ||
} else if (def.type === "GeoPoint") { | ||
return GeoPointRenderer.renderDefault(def) | ||
} else if (def.type === "StructuredText") { | ||
return StructuredTextRenderer(ctx).renderDefault(def) | ||
} else if (def.type === "Image") { | ||
return ImageRenderer(ctx).renderDefault(def) | ||
} else if (def.type === "Separator") { | ||
return SeparatorRenderer.renderDefault(def) | ||
} else if (def.type === "Boolean") { | ||
return BooleanRenderer.renderDefault(def) | ||
} else if (def.type === "IntegrationFields") { | ||
return IntegrationFieldsRenderer(ctx).renderDefault(def) | ||
} else { | ||
const renderedO = renderIfNoFetchOrFetchDefined(fetch, key, (f) => O.some(this.renderV2(def, item, f))) | ||
if (O.isSome(renderedO)) { | ||
result[key] = renderedO.value | ||
} | ||
return FieldRenderer.renderDefault(def) | ||
} | ||
}) | ||
}, | ||
return result | ||
}, | ||
renderObjectOfSimpleWidgetMocks( | ||
content: Array<[string, NestableContent]> | Record<string, NestableContent>, | ||
fieldsDef: Record<string, NestableWidget>, | ||
): Record<string, unknown> { | ||
const itemByKey: Record<string, NestableContent> = content instanceof Array ? Object.fromEntries(content) : content | ||
const result: Record<string, unknown> = {} | ||
Object.entries(fieldsDef).forEach(([name, def]) => { | ||
const key = name | ||
const item = itemByKey[key] | ||
if (item === undefined) { | ||
result[key] = this.renderDefault(def) | ||
} else if (EmptyContent.is(item)) { | ||
result[key] = this.renderDefault(def) | ||
renderMocks(def, content) { | ||
if (def.type === "StructuredText" && isRichTextContent(content)) { | ||
return StructuredTextRenderer(ctx).renderMocks(def, content) | ||
} else if (def.type === "Image" && isImageContent(content)) { | ||
return ImageRenderer(ctx).renderMocks(def, content) | ||
} else if (def.type === "Link" && isLinkContent(content)) { | ||
return LinkRenderer(ctx).renderMocks(def, content) | ||
} else if (def.type === "Embed" && isEmbedContent(content)) { | ||
return EmbedRenderer.renderMocks(def, content) | ||
} else if (def.type === "GeoPoint" && isGeoPointContent(content)) { | ||
return GeoPointRenderer.renderMocks(def, content) | ||
} else if (def.type === "IntegrationFields" && isIntegrationFieldContent(content)) { | ||
return IntegrationFieldsRenderer(ctx).renderMocks(def, content) | ||
} else if (def.type === "Separator" && isSeparatorContent(content)) { | ||
return SeparatorRenderer.renderMocks(def, content) | ||
} else if (def.type === "Boolean" && isBooleanContent(content)) { | ||
return BooleanRenderer.renderMocks(def, content) | ||
} else if ( | ||
(isRangeContent(content) && def.type === "Range") || | ||
(isNumberContent(content) && def.type === "Number") || | ||
(isTimestampContent(content) && def.type === "Timestamp") || | ||
(isDateContent(content) && def.type === "Date") || | ||
(isTextContent(content) && def.type === "Text") || | ||
(isColorContent(content) && def.type === "Color") || | ||
(isSelectContent(content) && def.type === "Select") | ||
) { | ||
return FieldRenderer.renderMocks(def, content) | ||
} else { | ||
const renderedO = renderIfNoFetchOrFetchDefined(undefined, key, () => O.some(this.renderMocks(def, item))) | ||
if (O.isSome(renderedO)) { | ||
result[key] = renderedO.value | ||
} | ||
return null | ||
} | ||
}) | ||
}, | ||
}) | ||
return result | ||
}, | ||
}) | ||
export default SimpleWidgetRenderer |
@@ -18,3 +18,3 @@ import type { CompositeSliceContent } from "@prismicio/types-internal/lib/content" | ||
const itemsValue = content.repeat.flatMap((groupItem) => { | ||
const rendered = SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV1(groupItem.value, repeatFetch) | ||
const rendered = SimpleWidgetRenderer(ctx).renderV1Object(groupItem.value, repeatFetch) | ||
if (isEmpty(rendered)) { | ||
@@ -25,3 +25,3 @@ return [] | ||
}) | ||
const primaryValue = SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV1(content.nonRepeat, nonRepeatFetch) | ||
const primaryValue = SimpleWidgetRenderer(ctx).renderV1Object(content.nonRepeat, nonRepeatFetch) | ||
return { | ||
@@ -47,3 +47,3 @@ "non-repeat": primaryValue, | ||
return content.repeat.map((items) => { | ||
return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV2( | ||
return SimpleWidgetRenderer(ctx).renderV2Object( | ||
items.value, | ||
@@ -65,3 +65,3 @@ repeatFetch?.fields, | ||
const primaryValue = (() => { | ||
return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV2( | ||
return SimpleWidgetRenderer(ctx).renderV2Object( | ||
content.nonRepeat, | ||
@@ -93,8 +93,5 @@ nonRepeatFetch, | ||
const itemsValue = content.repeat.map((items) => { | ||
return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetMocks(items.value, def.repeat || {}) | ||
return SimpleWidgetRenderer(ctx).renderMocksObject(items.value, def.repeat || {}) | ||
}) | ||
const primaryValue = SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetMocks( | ||
content.nonRepeat, | ||
def["non-repeat"] || {}, | ||
) | ||
const primaryValue = SimpleWidgetRenderer(ctx).renderMocksObject(content.nonRepeat, def["non-repeat"] || {}) | ||
@@ -101,0 +98,0 @@ return { |
@@ -5,12 +5,15 @@ import type { SharedSliceContent } from "@prismicio/types-internal/lib/content" | ||
import type { RenderContext } from "../../models" | ||
import type { Field, SharedSlice } from "../../models/fetch" | ||
import type { Field, GroupOrField, SharedSlice } from "../../models/fetch" | ||
import type { SliceRenderer } from "../../models/Renderer" | ||
import SimpleWidgetRenderer from "../SimpleWidgetRenderer" | ||
import StaticWidgetRenderer from "../StaticWidgetRenderer" | ||
function getFetchField( | ||
type FetchField<Part extends "repeat" | "nonRepeat"> = Record<string, Part extends "nonRepeat" ? GroupOrField : Field> | ||
function getFetchField<Part extends "repeat" | "nonRepeat">( | ||
variation: string, | ||
part: "repeat" | "nonRepeat", | ||
part: Part, | ||
fetch: SharedSlice | undefined, | ||
): Record<string, Field> | undefined { | ||
return fetch?.variations?.[variation]?.[part]?.fields | ||
): FetchField<Part> | undefined { | ||
return fetch?.variations?.[variation]?.[part]?.fields as FetchField<Part> | undefined | ||
} | ||
@@ -23,3 +26,3 @@ | ||
const itemsValue = content.items.map((groupItem) => { | ||
return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV1( | ||
return SimpleWidgetRenderer(ctx).renderV1Object( | ||
groupItem.value, | ||
@@ -29,3 +32,3 @@ getFetchField(content.variation, "repeat", fetch), | ||
}) | ||
const primaryValue = SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV1( | ||
const primaryValue = StaticWidgetRenderer(ctx).renderV1Object( | ||
content.primary, | ||
@@ -48,3 +51,3 @@ getFetchField(content.variation, "nonRepeat", fetch), | ||
const itemsValue = content.items.map((groupItem) => { | ||
return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV2( | ||
return SimpleWidgetRenderer(ctx).renderV2Object( | ||
groupItem.value, | ||
@@ -63,3 +66,3 @@ getFetchField(content.variation, "repeat", fetch), | ||
}) | ||
const primaryValue = SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetV2( | ||
const primaryValue = StaticWidgetRenderer(ctx).renderV2Object( | ||
content.primary, | ||
@@ -97,8 +100,5 @@ getFetchField(content.variation, "nonRepeat", fetch), | ||
const itemsValue = content.items.map((groupItem) => { | ||
return SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetMocks(groupItem.value, variation.items || {}) | ||
return SimpleWidgetRenderer(ctx).renderMocksObject(groupItem.value, variation.items || {}) | ||
}) | ||
const primaryValue = SimpleWidgetRenderer(ctx).renderObjectOfSimpleWidgetMocks( | ||
content.primary, | ||
variation.primary || {}, | ||
) | ||
const primaryValue = StaticWidgetRenderer(ctx).renderMocksObject(content.primary, variation.primary || {}) | ||
@@ -105,0 +105,0 @@ return { |
import { GroupContent, isGroupContent, isNestableContent, NestableContent } from "@prismicio/types-internal/lib/content" | ||
import type { Group as GroupField, NestableWidget } from "@prismicio/types-internal/lib/customtypes" | ||
import type { RenderContext, Renderer } from "../models" | ||
import type { RenderContext } from "../models" | ||
import { Field, Group, GroupOrField, GroupType } from "../models/fetch" | ||
import { withObjectRenderers } from "../object" | ||
import GroupRenderer from "./GroupRenderer" | ||
@@ -25,47 +26,42 @@ import SimpleWidgetRenderer from "./SimpleWidgetRenderer" | ||
const StaticWidgetRenderer: ( | ||
ctx: RenderContext, | ||
) => Renderer<NestableWidget | GroupField, NestableContent | GroupContent, GroupOrField> = (ctx) => ({ | ||
renderV1(content: NestableContent | GroupContent, fetch: GroupOrField | undefined): unknown { | ||
if (isGroupContent(content)) { | ||
return GroupRenderer(ctx).renderV1(content, extractFetchGroupIfAny(fetch)) | ||
} else { | ||
return SimpleWidgetRenderer(ctx).renderV1(content, extractFetchFieldIfAny(fetch)) | ||
} | ||
}, | ||
const StaticWidgetRenderer = (ctx: RenderContext) => | ||
withObjectRenderers<NestableWidget | GroupField, NestableContent | GroupContent, GroupOrField>({ | ||
renderV1(content, fetch) { | ||
if (isGroupContent(content)) { | ||
return GroupRenderer(ctx).renderV1(content, extractFetchGroupIfAny(fetch)) | ||
} else { | ||
return SimpleWidgetRenderer(ctx).renderV1(content, extractFetchFieldIfAny(fetch)) | ||
} | ||
}, | ||
renderV2( | ||
def: NestableWidget | GroupField, | ||
content: NestableContent | GroupContent, | ||
fetch: GroupOrField | undefined, | ||
): unknown { | ||
if (def.type !== "Group" && isNestableContent(content)) { | ||
// todo maybe find an other condition | ||
return SimpleWidgetRenderer(ctx).renderV2(def, content, extractFetchFieldIfAny(fetch)) | ||
} else if (def.type === "Group" && isGroupContent(content)) { | ||
return GroupRenderer(ctx).renderV2(def, content, extractFetchGroupIfAny(fetch)) | ||
} else { | ||
return this.renderDefault(def) | ||
} | ||
}, | ||
renderV2(def, content, fetch) { | ||
if (def.type !== "Group" && isNestableContent(content)) { | ||
// todo maybe find an other condition | ||
return SimpleWidgetRenderer(ctx).renderV2(def, content, extractFetchFieldIfAny(fetch)) | ||
} else if (def.type === "Group" && isGroupContent(content)) { | ||
return GroupRenderer(ctx).renderV2(def, content, extractFetchGroupIfAny(fetch)) | ||
} else { | ||
return this.renderDefault(def) | ||
} | ||
}, | ||
renderDefault(def: NestableWidget | GroupField): unknown { | ||
if (def.type === "Group") { | ||
return GroupRenderer(ctx).renderDefault(def) | ||
} else { | ||
return SimpleWidgetRenderer(ctx).renderDefault(def) | ||
} | ||
}, | ||
renderDefault(def) { | ||
if (def.type === "Group") { | ||
return GroupRenderer(ctx).renderDefault(def) | ||
} else { | ||
return SimpleWidgetRenderer(ctx).renderDefault(def) | ||
} | ||
}, | ||
renderMocks(def: NestableWidget | GroupField, content: NestableContent | GroupContent): unknown { | ||
if (isNestableContent(content) && def.type !== "Group") { | ||
return SimpleWidgetRenderer(ctx).renderMocks(def, content) | ||
} else if (isGroupContent(content) && def.type === "Group") { | ||
return GroupRenderer(ctx).renderMocks(def, content) | ||
} else { | ||
return this.renderDefault(def) | ||
} | ||
}, | ||
}) | ||
renderMocks(def, content) { | ||
if (isNestableContent(content) && def.type !== "Group") { | ||
return SimpleWidgetRenderer(ctx).renderMocks(def, content) | ||
} else if (isGroupContent(content) && def.type === "Group") { | ||
return GroupRenderer(ctx).renderMocks(def, content) | ||
} else { | ||
return this.renderDefault(def) | ||
} | ||
}, | ||
}) | ||
export default StaticWidgetRenderer |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
902279
234
22752
101
86
+ Added@prismicio/types-internal@2.4.0-alpha.4(transitive)
- Removed@prismicio/types-internal@2.4.0-alpha.1(transitive)