@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.07 kB
JavaScript
export class ItemsMetadata {
constructor() {
this.data = {};
this._typeDictionary = {};
}
getPropertyMetadata(item, property) {
const type = item["type"];
if (type == null)
return null;
if (this._typeDictionary[type] == null) {
this._typeDictionary[type] = [];
let prototype = item;
while (prototype.constructor.type != null) {
this._typeDictionary[type].push(prototype.constructor.type);
prototype = Object.getPrototypeOf(prototype);
}
}
for (let i = 0; i < this._typeDictionary[type].length; i++) {
const dictType = this._typeDictionary[type][i];
if (this.data[dictType] != null) {
const result = this.data[dictType][property];
if (result != null)
return result;
}
}
return null;
}
}
export const itemsMetadata = new ItemsMetadata();
//# sourceMappingURL=ItemsMetadata.js.map