UNPKG

@pilotlab/lux-attributes

Version:

A luxurious user experience framework, developed by your friends at Pilot.

69 lines 3.14 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var lux_is_1 = require("@pilotlab/lux-is"); var attributeEnums_1 = require("./attributeEnums"); var attribute_1 = require("./attribute"); var attributeTools_1 = require("./attributeTools"); var attributeFactoryBase_1 = require("./attributeFactoryBase"); var attributesFactory_1 = require("./attributesFactory"); var AttributeFactory = (function (_super) { __extends(AttributeFactory, _super); function AttributeFactory() { var _this = _super.call(this) || this; _this.p_collection = new attributesFactory_1.default(_this); return _this; } Object.defineProperty(AttributeFactory.prototype, "collection", { get: function () { return this.p_collection; }, enumerable: true, configurable: true }); AttributeFactory.prototype.instance = function (createOptions, key) { function createAttribute() { var attribute = new attribute_1.default(key, createOptions.value, createOptions.dataType, createOptions.label); attribute.validate = createOptions.validate; attribute.omit = createOptions.omit; return attribute; } if (lux_is_1.default.notEmpty(createOptions)) { switch (attributeTools_1.default.getBaseDataType(createOptions.dataType)) { case attributeEnums_1.DataType.ARRAY: return createAttribute(); case attributeEnums_1.DataType.BOOLEAN: return createAttribute(); case attributeEnums_1.DataType.COLLECTION: return createAttribute(); case attributeEnums_1.DataType.DATE_TIME: return createAttribute(); case attributeEnums_1.DataType.FUNCTION: return createAttribute(); case attributeEnums_1.DataType.NUMBER: return createAttribute(); case attributeEnums_1.DataType.STRING: return createAttribute(); case attributeEnums_1.DataType.UNDEFINED: case attributeEnums_1.DataType.NULL: case attributeEnums_1.DataType.ANY: case attributeEnums_1.DataType.OBJECT: default: return createAttribute(); } } else return new attribute_1.default(''); }; return AttributeFactory; }(attributeFactoryBase_1.default)); exports.AttributeFactory = AttributeFactory; exports.default = AttributeFactory; //# sourceMappingURL=attributeFactory.js.map