@aurigma/design-atoms-model
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
30 lines • 1.21 kB
JavaScript
import { itemsMetadata } from "./ItemsMetadata";
export function Property(value) {
return function (target, propertyKey) {
const type = target.constructor.type;
if (itemsMetadata.data[type] == null)
itemsMetadata.data[type] = {};
let typeMetadata = itemsMetadata.data[type];
if (typeMetadata[propertyKey] != null)
return;
typeMetadata[propertyKey] = {
type: checkType(value, target, propertyKey),
displayName: (value != null && value.displayName != null) ? value.displayName : propertyKey,
propertyFactory: value.factory,
values: value.enumObject != null ?
Object.keys(value.enumObject).map(k => value.enumObject[k]).filter(v => typeof v === "string") :
null,
ignore: value.ignore != null ? value.ignore : true
};
};
}
export const checkType = (meta, target, key) => {
if (meta.type != null)
return meta.type;
if (meta.enumObject != null)
return "enum";
if (meta.factory != null)
return meta.factory.type;
return typeof target[key];
};
//# sourceMappingURL=Property.js.map