@rxap/xml-parser
Version:
Provides a set of decorators and services for parsing and serializing XML documents into TypeScript classes. It simplifies the process of mapping XML elements and attributes to class properties, handling data validation, and serializing objects back into
81 lines • 3.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OptionsElement = exports.OptionToDisplayElement = exports.OptionElement = void 0;
const tslib_1 = require("tslib");
const data_source_element_1 = require("./data-source.element");
const element_def_1 = require("../decorators/element-def");
const element_attribute_1 = require("../decorators/element-attribute");
const element_text_content_1 = require("../decorators/element-text-content");
const required_element_mixin_1 = require("../decorators/mixins/required-element.mixin");
const element_children_1 = require("../decorators/element-children");
const element_child_1 = require("../decorators/element-child");
let OptionElement = class OptionElement {
getControlOption() {
var _a;
return {
value: (_a = this.value) !== null && _a !== void 0 ? _a : this.display,
display: this.display,
i18n: this.i18n,
};
}
validate() {
return true;
}
};
exports.OptionElement = OptionElement;
tslib_1.__decorate([
(0, element_attribute_1.ElementAttribute)(),
tslib_1.__metadata("design:type", Object)
], OptionElement.prototype, "value", void 0);
tslib_1.__decorate([
(0, element_text_content_1.ElementTextContent)(),
(0, required_element_mixin_1.ElementRequired)(),
tslib_1.__metadata("design:type", String)
], OptionElement.prototype, "display", void 0);
tslib_1.__decorate([
(0, element_attribute_1.ElementAttribute)(),
tslib_1.__metadata("design:type", String)
], OptionElement.prototype, "i18n", void 0);
exports.OptionElement = OptionElement = tslib_1.__decorate([
(0, element_def_1.ElementDef)('option')
], OptionElement);
let OptionToDisplayElement = class OptionToDisplayElement {
validate() {
return true;
}
};
exports.OptionToDisplayElement = OptionToDisplayElement;
tslib_1.__decorate([
(0, element_text_content_1.ElementTextContent)({
required: true,
}),
tslib_1.__metadata("design:type", String)
], OptionToDisplayElement.prototype, "template", void 0);
exports.OptionToDisplayElement = OptionToDisplayElement = tslib_1.__decorate([
(0, element_def_1.ElementDef)('to-display')
], OptionToDisplayElement);
let OptionsElement = class OptionsElement {
getControlOptions() {
return this.options.map(option => option.getControlOption());
}
validate() {
return this.options.length !== 0 || !!this.dataSource;
}
};
exports.OptionsElement = OptionsElement;
tslib_1.__decorate([
(0, element_children_1.ElementChildren)(OptionElement),
tslib_1.__metadata("design:type", Array)
], OptionsElement.prototype, "options", void 0);
tslib_1.__decorate([
(0, element_child_1.ElementChild)(OptionToDisplayElement),
tslib_1.__metadata("design:type", OptionToDisplayElement)
], OptionsElement.prototype, "toDisplay", void 0);
tslib_1.__decorate([
(0, element_child_1.ElementChild)(data_source_element_1.DataSourceElement),
tslib_1.__metadata("design:type", data_source_element_1.DataSourceElement)
], OptionsElement.prototype, "dataSource", void 0);
exports.OptionsElement = OptionsElement = tslib_1.__decorate([
(0, element_def_1.ElementDef)('options')
], OptionsElement);
//# sourceMappingURL=option.element.js.map