Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@prismicio/api-renderer

Package Overview
Dependencies
Maintainers
29
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prismicio/api-renderer - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0-alpha.0

lib/models/defineRenderer.d.ts

677

lib/models/customtypes/fields/GroupDef.d.ts
import * as t from "io-ts";
import { WithKey } from "../utils";
export declare const NestedGroupDef: t.Type<WithKey<{
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;
}>, WithKey<{
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;
}>, unknown>;
export declare const GroupDef: t.Type<WithKey<{

@@ -169,2 +508,171 @@ type: "Group";

} | undefined;
}) | ({
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;
});

@@ -339,2 +847,171 @@ } | undefined;

} | undefined;
}) | ({
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;
});

@@ -341,0 +1018,0 @@ } | undefined;

34

lib/models/customtypes/fields/GroupDef.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GroupDef = void 0;
exports.GroupDef = exports.NestedGroupDef = void 0;
const tslib_1 = require("tslib");

@@ -11,17 +11,21 @@ const customtypes_1 = require("@prismicio/types-internal/lib/customtypes");

const NestableDef_1 = require("./nestable/NestableDef");
exports.NestedGroupDef = createGroupDef(customtypes_1.NestedGroup, NestableDef_1.NestableDef);
exports.GroupDef = createGroupDef(customtypes_1.Group, t.union([NestableDef_1.NestableDef, exports.NestedGroupDef]));
const GroupDefType = "Group";
const codec = t.strict({
name: t.string,
fields: t.array(NestableDef_1.NestableDef),
});
exports.GroupDef = new t.Type("GroupDef", (u) => (0, utils_1.isFieldDef)(u) && customtypes_1.Group.is(u.def), (u) => {
return (0, function_1.pipe)(codec.decode(u), fp_ts_1.either.map(({ name, fields }) => ({
key: name,
def: {
type: GroupDefType,
config: {
fields: fields.reduce((acc, field) => ({ ...acc, [field.key]: field.def }), {}),
function createGroupDef(groupCodec, fieldsDef) {
return new t.Type("GroupDef", (u) => (0, utils_1.isFieldDef)(u) && groupCodec.is(u.def), (u) => {
const codec = t.strict({
name: t.string,
fields: t.array(fieldsDef),
});
return (0, function_1.pipe)(codec.decode(u), fp_ts_1.either.map(({ name, fields }) => ({
key: name,
def: {
type: GroupDefType,
config: {
fields: fields.reduce((acc, field) => ({ ...acc, [field.key]: field.def }), {}),
},
},
},
})));
}, (n) => n);
})));
}, (n) => n);
}

@@ -15,3 +15,3 @@ "use strict";

primary: t.array(NestableDef_1.NestableDef),
items: GroupDef_1.GroupDef,
items: GroupDef_1.NestedGroupDef,
});

@@ -18,0 +18,0 @@ exports.CompositeSliceDef = new t.Type("CompositeSliceDef", (u) => (0, utils_1.isFieldDef)(u) && customtypes_1.CompositeSlice.is(u.def), (u) => {

@@ -14,3 +14,3 @@ "use strict";

name: t.string,
widget: t.union([GroupDef_1.GroupDef, nestable_1.NestableDef]),
widget: t.union([GroupDef_1.NestedGroupDef, nestable_1.NestableDef]),
});

@@ -17,0 +17,0 @@ exports.LegacySliceDef = new t.Type("LegacySliceDef", (u) => (0, utils_1.isFieldDef)(u) && customtypes_1.LegacySlice.is(u.def), (u) => {

@@ -13,3 +13,3 @@ import * as t from "io-ts";

fields: {
[key: string]: Field;
[key: string]: GroupOrField;
};

@@ -49,7 +49,7 @@ }

nonRepeat: t.ExactC<t.TypeC<{
fields: t.RecordC<t.StringC, t.Type<Field, Field, unknown>>;
fields: t.RecordC<t.StringC, t.Type<GroupOrField, GroupOrField, unknown>>;
TYPE: t.LiteralC<"NonRepeat">;
}>>;
repeat: t.ExactC<t.TypeC<{
fields: t.RecordC<t.StringC, t.Type<Field, Field, unknown>>;
fields: t.RecordC<t.StringC, t.Type<GroupOrField, GroupOrField, unknown>>;
TYPE: t.LiteralC<"Repeat">;

@@ -71,7 +71,7 @@ }>>;

nonRepeat: t.ExactC<t.TypeC<{
fields: t.RecordC<t.StringC, t.Type<Field, Field, unknown>>;
fields: t.RecordC<t.StringC, t.Type<GroupOrField, GroupOrField, unknown>>;
TYPE: t.LiteralC<"NonRepeat">;
}>>;
repeat: t.ExactC<t.TypeC<{
fields: t.RecordC<t.StringC, t.Type<Field, Field, unknown>>;
fields: t.RecordC<t.StringC, t.Type<GroupOrField, GroupOrField, unknown>>;
TYPE: t.LiteralC<"Repeat">;

@@ -78,0 +78,0 @@ }>>;

@@ -15,3 +15,3 @@ "use strict";

name: t.string,
fields: t.record(t.string, exports.FieldC),
fields: t.record(t.string, exports.GroupOrFieldC),
}));

@@ -39,7 +39,7 @@ exports.GroupOrFieldC = t.recursion("GroupOrField", () => t.union([exports.Simple, exports.Group]));

nonRepeat: t.strict({
fields: t.record(t.string, exports.FieldC),
fields: t.record(t.string, exports.GroupOrFieldC),
TYPE: t.literal("NonRepeat"),
}),
repeat: t.strict({
fields: t.record(t.string, exports.FieldC),
fields: t.record(t.string, exports.GroupOrFieldC),
TYPE: t.literal("Repeat"),

@@ -46,0 +46,0 @@ }),

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const SimpleWidgetRenderer_1 = tslib_1.__importDefault(require("./SimpleWidgetRenderer"));
const StaticWidgetRenderer_1 = tslib_1.__importDefault(require("./StaticWidgetRenderer"));
const GroupRenderer = (ctx) => ({

@@ -10,3 +10,3 @@ renderV1(content, fetch) {

value: content.value.map((items) => {
return (0, SimpleWidgetRenderer_1.default)(ctx).renderV1Object(items.value, fetch === null || fetch === void 0 ? void 0 : fetch.fields);
return (0, StaticWidgetRenderer_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).renderV2Object(items.value, fetch === null || fetch === void 0 ? void 0 : fetch.fields, ((_a = groupDef.config) === null || _a === void 0 ? void 0 : _a.fields) || {}, {
return (0, StaticWidgetRenderer_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",

@@ -28,3 +28,3 @@ }, {

},
renderDefault(_) {
renderDefault() {
return [];

@@ -37,3 +37,3 @@ },

return {};
return (0, SimpleWidgetRenderer_1.default)(ctx).renderMocksObject(items.value, (_b = def.config) === null || _b === void 0 ? void 0 : _b.fields);
return (0, StaticWidgetRenderer_1.default)(ctx).renderMocksObject(items.value, (_b = def.config) === null || _b === void 0 ? void 0 : _b.fields);
});

@@ -40,0 +40,0 @@ },

@@ -6,3 +6,3 @@ "use strict";

const utils_1 = require("../../utils");
const SimpleWidgetRenderer_1 = tslib_1.__importDefault(require("../SimpleWidgetRenderer"));
const StaticWidgetRenderer_1 = tslib_1.__importDefault(require("../StaticWidgetRenderer"));
const CompositeSliceRenderer = (ctx) => ({

@@ -14,3 +14,3 @@ renderV1(content, fetch) {

const itemsValue = content.repeat.flatMap((groupItem) => {
const rendered = (0, SimpleWidgetRenderer_1.default)(ctx).renderV1Object(groupItem.value, repeatFetch);
const rendered = (0, StaticWidgetRenderer_1.default)(ctx).renderV1Object(groupItem.value, repeatFetch);
if ((0, utils_1.isEmpty)(rendered)) {

@@ -21,3 +21,3 @@ return [];

});
const primaryValue = (0, SimpleWidgetRenderer_1.default)(ctx).renderV1Object(content.nonRepeat, nonRepeatFetch);
const primaryValue = (0, StaticWidgetRenderer_1.default)(ctx).renderV1Object(content.nonRepeat, nonRepeatFetch);
return {

@@ -40,3 +40,3 @@ "non-repeat": primaryValue,

return content.repeat.map((items) => {
return (0, SimpleWidgetRenderer_1.default)(ctx).renderV2Object(items.value, repeatFetch === null || repeatFetch === void 0 ? void 0 : repeatFetch.fields, def.repeat || {}, {
return (0, StaticWidgetRenderer_1.default)(ctx).renderV2Object(items.value, repeatFetch === null || repeatFetch === void 0 ? void 0 : repeatFetch.fields, def.repeat || {}, {
withFetch: "default",

@@ -51,3 +51,3 @@ }, {

const primaryValue = (() => {
return (0, SimpleWidgetRenderer_1.default)(ctx).renderV2Object(content.nonRepeat, nonRepeatFetch, def["non-repeat"] || {}, {
return (0, StaticWidgetRenderer_1.default)(ctx).renderV2Object(content.nonRepeat, nonRepeatFetch, def["non-repeat"] || {}, {
withFetch: "default",

@@ -70,5 +70,5 @@ }, {

const itemsValue = content.repeat.map((items) => {
return (0, SimpleWidgetRenderer_1.default)(ctx).renderMocksObject(items.value, def.repeat || {});
return (0, StaticWidgetRenderer_1.default)(ctx).renderMocksObject(items.value, def.repeat || {});
});
const primaryValue = (0, SimpleWidgetRenderer_1.default)(ctx).renderMocksObject(content.nonRepeat, def["non-repeat"] || {});
const primaryValue = (0, StaticWidgetRenderer_1.default)(ctx).renderMocksObject(content.nonRepeat, def["non-repeat"] || {});
return {

@@ -75,0 +75,0 @@ primary: primaryValue,

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const SimpleWidgetRenderer_1 = tslib_1.__importDefault(require("../SimpleWidgetRenderer"));
const StaticWidgetRenderer_1 = tslib_1.__importDefault(require("../StaticWidgetRenderer"));

@@ -13,3 +12,3 @@ function getFetchField(variation, part, fetch) {

const itemsValue = content.items.map((groupItem) => {
return (0, SimpleWidgetRenderer_1.default)(ctx).renderV1Object(groupItem.value, getFetchField(content.variation, "repeat", fetch));
return (0, StaticWidgetRenderer_1.default)(ctx).renderV1Object(groupItem.value, getFetchField(content.variation, "repeat", fetch));
});

@@ -29,3 +28,3 @@ const primaryValue = (0, StaticWidgetRenderer_1.default)(ctx).renderV1Object(content.primary, getFetchField(content.variation, "nonRepeat", fetch));

const itemsValue = content.items.map((groupItem) => {
return (0, SimpleWidgetRenderer_1.default)(ctx).renderV2Object(groupItem.value, getFetchField(content.variation, "repeat", fetch), variation.items || {}, {
return (0, StaticWidgetRenderer_1.default)(ctx).renderV2Object(groupItem.value, getFetchField(content.variation, "repeat", fetch), variation.items || {}, {
withFetch: "filter",

@@ -61,3 +60,3 @@ }, {

const itemsValue = content.items.map((groupItem) => {
return (0, SimpleWidgetRenderer_1.default)(ctx).renderMocksObject(groupItem.value, variation.items || {});
return (0, StaticWidgetRenderer_1.default)(ctx).renderMocksObject(groupItem.value, variation.items || {});
});

@@ -64,0 +63,0 @@ const primaryValue = (0, StaticWidgetRenderer_1.default)(ctx).renderMocksObject(content.primary, variation.primary || {});

@@ -0,1 +1,2 @@

import { GroupContent } from "@prismicio/types-internal/lib/content";
import type { RenderContext } from "../models";

@@ -169,2 +170,171 @@ import { GroupOrField } from "../models/fetch";

} | undefined;
}) | ({
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;
});

@@ -329,3 +499,3 @@ } | undefined;

} | undefined;
}), {
}), GroupContent | {
type: string;

@@ -642,320 +812,2 @@ __TYPE__: "EmptyContent";

__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>, ({

@@ -1127,2 +979,171 @@ type: "Group";

} | undefined;
}) | ({
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;
});

@@ -1287,3 +1308,3 @@ } | undefined;

} | undefined;
}), {
}), GroupContent | {
type: string;

@@ -1600,321 +1621,3 @@ __TYPE__: "EmptyContent";

__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;
{
"name": "@prismicio/api-renderer",
"version": "3.1.0",
"version": "3.2.0-alpha.0",
"description": "Prismic renderers for the content API",

@@ -38,3 +38,3 @@ "keywords": [

"dependencies": {
"@prismicio/types-internal": "2.4.1",
"@prismicio/types-internal": "2.5.0-alpha.4",
"tslib": "^2.5.0",

@@ -72,3 +72,3 @@ "uuid": "^9.0.0"

"engines": {
"node": ">=12.7.0"
"node": "20"
},

@@ -75,0 +75,0 @@ "publishConfig": {

@@ -1,2 +0,2 @@

import { Group } from "@prismicio/types-internal/lib/customtypes"
import { FieldType, Group, NestedGroup } from "@prismicio/types-internal/lib/customtypes"
import { either } from "fp-ts"

@@ -6,32 +6,40 @@ import { pipe } from "fp-ts/lib/function"

import { isFieldDef, WithKey } from "../utils"
import { Definition, isFieldDef, WithKey } from "../utils"
import { NestableDef } from "./nestable/NestableDef"
export const NestedGroupDef = createGroupDef(NestedGroup, NestableDef)
export const GroupDef = createGroupDef(Group, t.union([NestableDef, NestedGroupDef]))
const GroupDefType = "Group"
const codec = t.strict({
name: t.string,
fields: t.array(NestableDef),
})
function createGroupDef<T1 extends typeof Group | typeof NestedGroup, A2 extends WithKey<Definition<FieldType>>, O2>(
groupCodec: T1,
fieldsDef: t.Type<A2, O2>,
) {
return new t.Type<WithKey<t.TypeOf<T1>>>(
"GroupDef",
(u: unknown): u is WithKey<t.TypeOf<T1>> => isFieldDef(u) && groupCodec.is(u.def),
(u: unknown) => {
const codec = t.strict({
name: t.string,
fields: t.array(fieldsDef),
})
export const GroupDef = new t.Type<WithKey<Group>>(
"GroupDef",
(u: unknown): u is WithKey<Group> => isFieldDef(u) && Group.is(u.def),
(u: unknown) => {
return pipe(
codec.decode(u),
either.map(
({ name, fields }): WithKey<Group> => ({
key: name,
def: {
type: GroupDefType,
config: {
fields: fields.reduce((acc, field) => ({ ...acc, [field.key]: field.def }), {}),
return pipe(
codec.decode(u),
either.map(
({ name, fields }): WithKey<t.TypeOf<T1>> => ({
key: name,
def: {
type: GroupDefType,
config: {
fields: fields.reduce((acc, field) => ({ ...acc, [field.key]: field.def }), {}),
},
},
},
}),
),
)
},
(n) => n,
)
}),
),
)
},
(n) => n,
)
}

@@ -7,3 +7,3 @@ import { CompositeSlice } from "@prismicio/types-internal/lib/customtypes"

import { isFieldDef, WithKey } from "../../utils"
import { GroupDef } from "../GroupDef"
import { NestedGroupDef } from "../GroupDef"
import { NestableDef } from "../nestable/NestableDef"

@@ -14,3 +14,3 @@

primary: t.array(NestableDef),
items: GroupDef,
items: NestedGroupDef,
})

@@ -17,0 +17,0 @@

@@ -7,3 +7,3 @@ import { LegacySlice } from "@prismicio/types-internal/lib/customtypes"

import { isFieldDef, WithKey } from "../../utils"
import { GroupDef } from "../GroupDef"
import { NestedGroupDef } from "../GroupDef"
import { NestableDef } from "../nestable"

@@ -13,3 +13,3 @@

name: t.string,
widget: t.union([GroupDef, NestableDef]),
widget: t.union([NestedGroupDef, NestableDef]),
})

@@ -16,0 +16,0 @@

@@ -15,3 +15,3 @@ import * as t from "io-ts"

fields: {
[key: string]: Field
[key: string]: GroupOrField
}

@@ -24,3 +24,3 @@ }

name: t.string,
fields: t.record(t.string, FieldC),
fields: t.record(t.string, GroupOrFieldC),
}),

@@ -82,7 +82,7 @@ )

nonRepeat: t.strict({
fields: t.record(t.string, FieldC),
fields: t.record(t.string, GroupOrFieldC),
TYPE: t.literal("NonRepeat"),
}),
repeat: t.strict({
fields: t.record(t.string, FieldC),
fields: t.record(t.string, GroupOrFieldC),
TYPE: t.literal("Repeat"),

@@ -89,0 +89,0 @@ }),

@@ -7,10 +7,10 @@ import type { GroupContent } from "@prismicio/types-internal/lib/content"

import type RenderContext from "../models/RenderContext"
import SimpleWidgetRenderer from "./SimpleWidgetRenderer"
import StaticWidgetRenderer from "./StaticWidgetRenderer"
const GroupRenderer: (ctx: RenderContext) => Renderer<GroupField, GroupContent, GroupFetch> = (ctx) => ({
renderV1(content: GroupContent, fetch?: GroupFetch | undefined): unknown {
renderV1(content, fetch) {
return {
type: "Group",
value: content.value.map((items) => {
return SimpleWidgetRenderer(ctx).renderV1Object(items.value, fetch?.fields)
return StaticWidgetRenderer(ctx).renderV1Object(items.value, fetch?.fields)
}),

@@ -20,5 +20,5 @@ }

renderV2(groupDef: GroupField, content: GroupContent, fetch?: GroupFetch | undefined): unknown {
renderV2(groupDef, content, fetch) {
return content.value.map((items) => {
return SimpleWidgetRenderer(ctx).renderV2Object(
return StaticWidgetRenderer(ctx).renderV2Object(
items.value,

@@ -39,10 +39,10 @@ fetch?.fields,

renderDefault(_: GroupField): unknown {
renderDefault() {
return []
},
renderMocks(def: GroupField, content: GroupContent) {
renderMocks(def, content) {
return content.value.map((items) => {
if (!def.config?.fields) return {}
return SimpleWidgetRenderer(ctx).renderMocksObject(items.value, def.config?.fields)
return StaticWidgetRenderer(ctx).renderMocksObject(items.value, def.config?.fields)
})

@@ -49,0 +49,0 @@ },

@@ -8,3 +8,3 @@ import type { CompositeSliceContent } from "@prismicio/types-internal/lib/content"

import { isEmpty } from "../../utils"
import SimpleWidgetRenderer from "../SimpleWidgetRenderer"
import StaticWidgetRenderer from "../StaticWidgetRenderer"

@@ -19,3 +19,3 @@ const CompositeSliceRenderer: (

const itemsValue = content.repeat.flatMap((groupItem) => {
const rendered = SimpleWidgetRenderer(ctx).renderV1Object(groupItem.value, repeatFetch)
const rendered = StaticWidgetRenderer(ctx).renderV1Object(groupItem.value, repeatFetch)
if (isEmpty(rendered)) {

@@ -26,3 +26,3 @@ return []

})
const primaryValue = SimpleWidgetRenderer(ctx).renderV1Object(content.nonRepeat, nonRepeatFetch)
const primaryValue = StaticWidgetRenderer(ctx).renderV1Object(content.nonRepeat, nonRepeatFetch)
return {

@@ -48,3 +48,3 @@ "non-repeat": primaryValue,

return content.repeat.map((items) => {
return SimpleWidgetRenderer(ctx).renderV2Object(
return StaticWidgetRenderer(ctx).renderV2Object(
items.value,

@@ -66,3 +66,3 @@ repeatFetch?.fields,

const primaryValue = (() => {
return SimpleWidgetRenderer(ctx).renderV2Object(
return StaticWidgetRenderer(ctx).renderV2Object(
content.nonRepeat,

@@ -94,5 +94,5 @@ nonRepeatFetch,

const itemsValue = content.repeat.map((items) => {
return SimpleWidgetRenderer(ctx).renderMocksObject(items.value, def.repeat || {})
return StaticWidgetRenderer(ctx).renderMocksObject(items.value, def.repeat || {})
})
const primaryValue = SimpleWidgetRenderer(ctx).renderMocksObject(content.nonRepeat, def["non-repeat"] || {})
const primaryValue = StaticWidgetRenderer(ctx).renderMocksObject(content.nonRepeat, def["non-repeat"] || {})

@@ -99,0 +99,0 @@ return {

@@ -5,9 +5,6 @@ import type { SharedSliceContent } from "@prismicio/types-internal/lib/content"

import type { RenderContext } from "../../models"
import type { Field, GroupOrField, SharedSlice } from "../../models/fetch"
import type { GroupOrField, SharedSlice } from "../../models/fetch"
import type { SliceRenderer } from "../../models/Renderer"
import SimpleWidgetRenderer from "../SimpleWidgetRenderer"
import StaticWidgetRenderer from "../StaticWidgetRenderer"
type FetchField<Part extends "repeat" | "nonRepeat"> = Record<string, Part extends "nonRepeat" ? GroupOrField : Field>
function getFetchField<Part extends "repeat" | "nonRepeat">(

@@ -17,4 +14,4 @@ variation: string,

fetch: SharedSlice | undefined,
): FetchField<Part> | undefined {
return fetch?.variations?.[variation]?.[part]?.fields as FetchField<Part> | undefined
): Record<string, GroupOrField> | undefined {
return fetch?.variations?.[variation]?.[part]?.fields as Record<string, GroupOrField> | undefined
}

@@ -27,3 +24,3 @@

const itemsValue = content.items.map((groupItem) => {
return SimpleWidgetRenderer(ctx).renderV1Object(
return StaticWidgetRenderer(ctx).renderV1Object(
groupItem.value,

@@ -51,3 +48,3 @@ getFetchField(content.variation, "repeat", fetch),

const itemsValue = content.items.map((groupItem) => {
return SimpleWidgetRenderer(ctx).renderV2Object(
return StaticWidgetRenderer(ctx).renderV2Object(
groupItem.value,

@@ -99,3 +96,3 @@ getFetchField(content.variation, "repeat", fetch),

const itemsValue = content.items.map((groupItem) => {
return SimpleWidgetRenderer(ctx).renderMocksObject(groupItem.value, variation.items || {})
return StaticWidgetRenderer(ctx).renderMocksObject(groupItem.value, variation.items || {})
})

@@ -102,0 +99,0 @@ const primaryValue = StaticWidgetRenderer(ctx).renderMocksObject(content.primary, variation.primary || {})

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc