@meta-cms/next
Advanced tools
Comparing version 1.0.47 to 1.0.48
@@ -41,3 +41,3 @@ import * as _meta_cms_core from '@meta-cms/core'; | ||
useContent: (idAccessors?: IdAccessors) => <P_1 extends Paths<S>, O_1 extends TOptions>(p: P_1, options?: O_1 | undefined) => GetNextType<GetField<S, P_1>, GetType2<GetField<S, P_1>>>; | ||
ContentProvider: ({ children, content, }: { | ||
ContentProvider: ({ children, content }: { | ||
content: CMSPayload<S>; | ||
@@ -44,0 +44,0 @@ children: React$1.ReactNode; |
121
index.js
@@ -110,2 +110,3 @@ "use strict"; | ||
var mediaImageFragment = (nested) => ` | ||
id | ||
image { | ||
@@ -116,3 +117,2 @@ ${imageFragment(nested)} | ||
var imageFragment = (nested) => ` | ||
id | ||
alt: altText | ||
@@ -517,2 +517,3 @@ height | ||
}) => { | ||
var _a, _b; | ||
let acc = initalizer || {}; | ||
@@ -522,3 +523,6 @@ for (let i = 0; i < content.length; i++) { | ||
if (item) { | ||
const field = client.config[item.namespace.replace(`@${client.locale}`, "")].schema[item.key]; | ||
const field = (_b = (_a = client.config[item.namespace.replace(`@${client.locale}`, "")]) == null ? void 0 : _a.schema) == null ? void 0 : _b[item.key]; | ||
if (!field) { | ||
return acc; | ||
} | ||
const transformedValue = transformMetafield({ | ||
@@ -577,10 +581,8 @@ client, | ||
return metafields.reduce((acc, item) => { | ||
var _a, _b; | ||
if (item) { | ||
console.log( | ||
item.namespace, | ||
client.locale, | ||
item.key, | ||
client.config[item.namespace.replace(`_${client.locale}`, "")] | ||
); | ||
const field = client.config[item.namespace.replace(`_${client.locale}`, "")].schema[item.key]; | ||
const field = (_b = (_a = client.config[item.namespace.replace(`@${client.locale}`, "")]) == null ? void 0 : _a.schema) == null ? void 0 : _b[item.key]; | ||
if (!field) { | ||
return acc; | ||
} | ||
const transformedItem = transformMetafield({ | ||
@@ -720,3 +722,3 @@ field, | ||
}; | ||
var mockValue = (field, attributes) => { | ||
var mockValue = (field, attributes, fill = true) => { | ||
switch (field.type) { | ||
@@ -743,6 +745,6 @@ case "object": { | ||
return { | ||
value: field.isList ? loremArray(getLoremImageData) : { | ||
value: field.isList ? fill ? loremArray(getLoremImageData) : [] : fill ? { | ||
id: randomId(), | ||
...getLoremImageData() | ||
}, | ||
} : void 0, | ||
attributes | ||
@@ -961,3 +963,6 @@ }; | ||
const mock = mockValue(field, attributes); | ||
return transform ? transform(mock, field) : mock; | ||
if (transform) { | ||
return transform(mock, field); | ||
} else { | ||
} | ||
}); | ||
@@ -1006,32 +1011,23 @@ }; | ||
if (field.isList) { | ||
const newValue = value.map((value2) => { | ||
return Object.entries(field.schema).reduce((acc, [key, field2]) => { | ||
const data2 = value2[key]; | ||
acc[key] = transformField( | ||
field2.type === "object" ? { value: data2 } : data2, | ||
field2, | ||
false | ||
); | ||
return acc; | ||
}, {}); | ||
}); | ||
Object.assign( | ||
transformedValue, | ||
isTop ? { | ||
value: newValue | ||
} : newValue | ||
); | ||
if (Array.isArray(value)) { | ||
const newValue = value.map((value2) => { | ||
return Object.entries(field.schema).reduce((acc, [key, field2]) => { | ||
const data2 = value2[key]; | ||
acc[key] = transformField(field2.type === "object" ? { value: data2 } : data2, field2, false); | ||
return acc; | ||
}, {}); | ||
}); | ||
Object.assign( | ||
transformedValue, | ||
isTop ? { | ||
value: newValue | ||
} : newValue | ||
); | ||
} | ||
} else { | ||
const newValue = Object.entries(field.schema).reduce( | ||
(acc, [key, field2]) => { | ||
const data2 = value[key]; | ||
acc[key] = transformField( | ||
field2.type === "object" ? { value: data2 } : data2, | ||
field2, | ||
false | ||
); | ||
return acc; | ||
}, | ||
{} | ||
); | ||
const newValue = Object.entries(field.schema).reduce((acc, [key, field2]) => { | ||
const data2 = value[key]; | ||
acc[key] = transformField(field2.type === "object" ? { value: data2 } : data2, field2, false); | ||
return acc; | ||
}, {}); | ||
Object.assign( | ||
@@ -1070,5 +1066,3 @@ transformedValue, | ||
attributes, | ||
value: value.map((text) => ({ | ||
dangerouslySetInnerHTML: { __html: text } | ||
})) | ||
value: value.map((text) => ({ dangerouslySetInnerHTML: { __html: text } })) | ||
}; | ||
@@ -1088,17 +1082,11 @@ } else { | ||
var nextJsAdapter = (content, schema) => { | ||
return Object.entries(content).reduce( | ||
(acc, [namespace, value]) => { | ||
acc[namespace] = Object.entries(value).reduce( | ||
(acc2, [suffixedKey, value2]) => { | ||
const [key] = suffixedKey.split("@"); | ||
const field = schema[namespace].schema[key]; | ||
acc2[suffixedKey] = transformField(value2, field); | ||
return acc2; | ||
}, | ||
{} | ||
); | ||
return acc; | ||
}, | ||
{} | ||
); | ||
return Object.entries(content).reduce((acc, [namespace, value]) => { | ||
acc[namespace] = Object.entries(value).reduce((acc2, [suffixedKey, value2]) => { | ||
const [key] = suffixedKey.split("@"); | ||
const field = schema[namespace].schema[key]; | ||
acc2[suffixedKey] = transformField(value2, field); | ||
return acc2; | ||
}, {}); | ||
return acc; | ||
}, {}); | ||
}; | ||
@@ -1216,6 +1204,3 @@ | ||
const contentContext = React.createContext(); | ||
const ContentProvider = ({ | ||
children, | ||
content | ||
}) => { | ||
const ContentProvider = ({ children, content }) => { | ||
const state = useBuilder(content, schema); | ||
@@ -1243,4 +1228,8 @@ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(import_head.default, null, /* @__PURE__ */ React.createElement("style", { | ||
return (p, options2) => { | ||
const value = client.t(p, content, idAccessors, transformField); | ||
const { attributes } = value; | ||
const value = client.t( | ||
p, | ||
content, | ||
idAccessors, | ||
transformField | ||
); | ||
return value; | ||
@@ -1247,0 +1236,0 @@ }; |
{ | ||
"name": "@meta-cms/next", | ||
"version": "1.0.47", | ||
"version": "1.0.48", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
37677
1264