@nitrogenbuilder/client-react
Version:
Nitrogen Builder React Client
35 lines (34 loc) • 1.11 kB
JavaScript
export function getDefault(prop, propV) {
const def = propV.default ?? '';
if (def === undefined || def === null || def === '') {
return prop;
}
if (prop === undefined || prop === null) {
return def;
}
if (typeof prop === 'object') {
if (typeof def === 'object') {
if (propV.responsive) {
if ('mobile' in prop) {
return { ...prop };
}
let returnObject = {};
if ('mobile' in def) {
returnObject.mobile = def.mobile;
}
if ('tablet' in prop) {
return { ...returnObject, ...prop };
}
if ('tablet' in def) {
returnObject.tablet = def.tablet;
}
if ('laptop' in prop) {
return { ...returnObject, ...prop };
}
}
return { ...def, ...prop };
}
throw new Error("Default value should be responsive, but it ain't bruh");
}
return prop;
}