@cfstratos/ajsf-material
Version:
Angular JSON Schema Form builder using Angular Material UI
705 lines (671 loc) • 104 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@cfstratos/ajsf-core'), require('@angular/material/core'), require('@angular/material/form-field'), require('lodash/cloneDeep'), require('@angular/common'), require('@angular/forms'), require('@angular/flex-layout'), require('@angular/material/autocomplete'), require('@angular/material/button'), require('@angular/material/button-toggle'), require('@angular/material/card'), require('@angular/material/checkbox'), require('@angular/material/chips'), require('@angular/material/datepicker'), require('@angular/material/expansion'), require('@angular/material/icon'), require('@angular/material/input'), require('@angular/material/radio'), require('@angular/material/select'), require('@angular/material/slide-toggle'), require('@angular/material/slider'), require('@angular/material/stepper'), require('@angular/material/tabs'), require('@angular/material/tooltip'), require('@angular/material/menu'), require('@angular/material/toolbar'), require('@angular/flex-layout/core')) :
typeof define === 'function' && define.amd ? define('@ajsf/material', ['exports', '@angular/core', '@cfstratos/ajsf-core', '@angular/material/core', '@angular/material/form-field', 'lodash/cloneDeep', '@angular/common', '@angular/forms', '@angular/flex-layout', '@angular/material/autocomplete', '@angular/material/button', '@angular/material/button-toggle', '@angular/material/card', '@angular/material/checkbox', '@angular/material/chips', '@angular/material/datepicker', '@angular/material/expansion', '@angular/material/icon', '@angular/material/input', '@angular/material/radio', '@angular/material/select', '@angular/material/slide-toggle', '@angular/material/slider', '@angular/material/stepper', '@angular/material/tabs', '@angular/material/tooltip', '@angular/material/menu', '@angular/material/toolbar', '@angular/flex-layout/core'], factory) :
(global = global || self, factory((global.ajsf = global.ajsf || {}, global.ajsf.material = {}), global.ng.core, global['@cfstratos/ajsf-core'], global.ng.material.core, global.ng.material['form-field'], global['lodash-es'], global.ng.common, global.ng.forms, global.ng['flex-layout'], global.ng.material.autocomplete, global.ng.material.button, global.ng.material['button-toggle'], global.ng.material.card, global.ng.material.checkbox, global.ng.material.chips, global.ng.material.datepicker, global.ng.material.expansion, global.ng.material.icon, global.ng.material.input, global.ng.material.radio, global.ng.material.select, global.ng.material['slide-toggle'], global.ng.material.slider, global.ng.material.stepper, global.ng.material.tabs, global.ng.material.tooltip, global.ng.material.menu, global.ng.material.toolbar, global.ng['flex-layout'].core));
}(this, (function (exports, core, ajsfCore, core$1, formField, cloneDeep, common, forms, flexLayout, autocomplete, button, buttonToggle, card, checkbox, chips, datepicker, expansion, icon, input, radio, select, slideToggle, slider, stepper, tabs, tooltip, menu, toolbar, core$2) { 'use strict';
cloneDeep = cloneDeep && cloneDeep.hasOwnProperty('default') ? cloneDeep['default'] : cloneDeep;
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
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 extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __exportStar(m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result.default = mod;
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
var FlexLayoutRootComponent = /** @class */ (function () {
function FlexLayoutRootComponent(jsf) {
this.jsf = jsf;
this.isFlexItem = false;
}
FlexLayoutRootComponent.prototype.removeItem = function (item) {
this.jsf.removeItem(item);
};
// Set attributes for flexbox child
// (container attributes are set in flex-layout-section.component)
FlexLayoutRootComponent.prototype.getFlexAttribute = function (node, attribute) {
var index = ['flex-grow', 'flex-shrink', 'flex-basis'].indexOf(attribute);
return ((node.options || {}).flex || '').split(/\s+/)[index] ||
(node.options || {})[attribute] || ['1', '1', 'auto'][index];
};
FlexLayoutRootComponent.prototype.showWidget = function (layoutNode) {
return this.jsf.evaluateCondition(layoutNode, this.dataIndex);
};
FlexLayoutRootComponent.ctorParameters = function () { return [
{ type: ajsfCore.JsonSchemaFormService }
]; };
__decorate([
core.Input()
], FlexLayoutRootComponent.prototype, "dataIndex", void 0);
__decorate([
core.Input()
], FlexLayoutRootComponent.prototype, "layoutIndex", void 0);
__decorate([
core.Input()
], FlexLayoutRootComponent.prototype, "layout", void 0);
__decorate([
core.Input()
], FlexLayoutRootComponent.prototype, "isFlexItem", void 0);
FlexLayoutRootComponent = __decorate([
core.Component({
// tslint:disable-next-line:component-selector
selector: 'flex-layout-root-widget',
template: "\n <div *ngFor=\"let layoutNode of layout; let i = index\"\n [class.form-flex-item]=\"isFlexItem\"\n [style.flex-grow]=\"getFlexAttribute(layoutNode, 'flex-grow')\"\n [style.flex-shrink]=\"getFlexAttribute(layoutNode, 'flex-shrink')\"\n [style.flex-basis]=\"getFlexAttribute(layoutNode, 'flex-basis')\"\n [style.align-self]=\"(layoutNode?.options || {})['align-self']\"\n [style.order]=\"layoutNode?.options?.order\"\n [fxFlex]=\"layoutNode?.options?.fxFlex\"\n [fxFlexOrder]=\"layoutNode?.options?.fxFlexOrder\"\n [fxFlexOffset]=\"layoutNode?.options?.fxFlexOffset\"\n [fxFlexAlign]=\"layoutNode?.options?.fxFlexAlign\">\n <select-framework-widget *ngIf=\"showWidget(layoutNode)\"\n [dataIndex]=\"layoutNode?.arrayItem ? (dataIndex || []).concat(i) : (dataIndex || [])\"\n [layoutIndex]=\"(layoutIndex || []).concat(i)\"\n [layoutNode]=\"layoutNode\"></select-framework-widget>\n <div>",
changeDetection: core.ChangeDetectionStrategy.Default
})
], FlexLayoutRootComponent);
return FlexLayoutRootComponent;
}());
var FlexLayoutSectionComponent = /** @class */ (function () {
function FlexLayoutSectionComponent(jsf) {
this.jsf = jsf;
this.controlDisabled = false;
this.boundControl = false;
this.expanded = true;
this.containerType = 'div';
}
Object.defineProperty(FlexLayoutSectionComponent.prototype, "sectionTitle", {
get: function () {
return this.options.notitle ? null : this.jsf.setItemTitle(this);
},
enumerable: true,
configurable: true
});
FlexLayoutSectionComponent.prototype.ngOnInit = function () {
this.jsf.initializeControl(this);
this.options = this.layoutNode.options || {};
this.expanded = typeof this.options.expanded === 'boolean' ?
this.options.expanded : !this.options.expandable;
switch (this.layoutNode.type) {
case 'section':
case 'array':
case 'fieldset':
case 'advancedfieldset':
case 'authfieldset':
case 'optionfieldset':
case 'selectfieldset':
this.containerType = 'fieldset';
break;
case 'card':
this.containerType = 'card';
break;
case 'expansion-panel':
this.containerType = 'expansion-panel';
break;
default: // 'div', 'flex', 'tab', 'conditional', 'actions'
this.containerType = 'div';
}
};
FlexLayoutSectionComponent.prototype.toggleExpanded = function () {
if (this.options.expandable) {
this.expanded = !this.expanded;
}
};
// Set attributes for flexbox container
// (child attributes are set in flex-layout-root.component)
FlexLayoutSectionComponent.prototype.getFlexAttribute = function (attribute) {
var flexActive = this.layoutNode.type === 'flex' ||
!!this.options.displayFlex ||
this.options.display === 'flex';
// if (attribute !== 'flex' && !flexActive) { return null; }
switch (attribute) {
case 'is-flex':
return flexActive;
case 'display':
return flexActive ? 'flex' : 'initial';
case 'flex-direction':
case 'flex-wrap':
var index = ['flex-direction', 'flex-wrap'].indexOf(attribute);
return (this.options['flex-flow'] || '').split(/\s+/)[index] ||
this.options[attribute] || ['column', 'nowrap'][index];
case 'justify-content':
case 'align-items':
case 'align-content':
return this.options[attribute];
case 'layout':
return (this.options.fxLayout || 'row') +
this.options.fxLayoutWrap ? ' ' + this.options.fxLayoutWrap : '';
}
};
FlexLayoutSectionComponent.ctorParameters = function () { return [
{ type: ajsfCore.JsonSchemaFormService }
]; };
__decorate([
core.Input()
], FlexLayoutSectionComponent.prototype, "layoutNode", void 0);
__decorate([
core.Input()
], FlexLayoutSectionComponent.prototype, "layoutIndex", void 0);
__decorate([
core.Input()
], FlexLayoutSectionComponent.prototype, "dataIndex", void 0);
FlexLayoutSectionComponent = __decorate([
core.Component({
// tslint:disable-next-line:component-selector
selector: 'flex-layout-section-widget',
template: "\n <div *ngIf=\"containerType === 'div'\"\n [class]=\"options?.htmlClass || ''\"\n [class.expandable]=\"options?.expandable && !expanded\"\n [class.expanded]=\"options?.expandable && expanded\">\n <label *ngIf=\"sectionTitle\"\n [class]=\"'legend ' + (options?.labelHtmlClass || '')\"\n [innerHTML]=\"sectionTitle\"\n (click)=\"toggleExpanded()\"></label>\n <flex-layout-root-widget *ngIf=\"expanded\"\n [layout]=\"layoutNode.items\"\n [dataIndex]=\"dataIndex\"\n [layoutIndex]=\"layoutIndex\"\n [isFlexItem]=\"getFlexAttribute('is-flex')\"\n [class.form-flex-column]=\"getFlexAttribute('flex-direction') === 'column'\"\n [class.form-flex-row]=\"getFlexAttribute('flex-direction') === 'row'\"\n [style.display]=\"getFlexAttribute('display')\"\n [style.flex-direction]=\"getFlexAttribute('flex-direction')\"\n [style.flex-wrap]=\"getFlexAttribute('flex-wrap')\"\n [style.justify-content]=\"getFlexAttribute('justify-content')\"\n [style.align-items]=\"getFlexAttribute('align-items')\"\n [style.align-content]=\"getFlexAttribute('align-content')\"\n [fxLayout]=\"getFlexAttribute('layout')\"\n [fxLayoutGap]=\"options?.fxLayoutGap\"\n [fxLayoutAlign]=\"options?.fxLayoutAlign\"\n [attr.fxFlexFill]=\"options?.fxLayoutAlign\"></flex-layout-root-widget>\n <mat-error *ngIf=\"options?.showErrors && options?.errorMessage\"\n [innerHTML]=\"options?.errorMessage\"></mat-error>\n </div>\n\n <fieldset *ngIf=\"containerType === 'fieldset'\"\n [class]=\"options?.htmlClass || ''\"\n [class.expandable]=\"options?.expandable && !expanded\"\n [class.expanded]=\"options?.expandable && expanded\"\n [disabled]=\"options?.readonly\">\n <legend *ngIf=\"sectionTitle\"\n [class]=\"'legend ' + (options?.labelHtmlClass || '')\"\n [innerHTML]=\"sectionTitle\"\n (click)=\"toggleExpanded()\"></legend>\n <flex-layout-root-widget *ngIf=\"expanded\"\n [layout]=\"layoutNode.items\"\n [dataIndex]=\"dataIndex\"\n [layoutIndex]=\"layoutIndex\"\n [isFlexItem]=\"getFlexAttribute('is-flex')\"\n [class.form-flex-column]=\"getFlexAttribute('flex-direction') === 'column'\"\n [class.form-flex-row]=\"getFlexAttribute('flex-direction') === 'row'\"\n [style.display]=\"getFlexAttribute('display')\"\n [style.flex-direction]=\"getFlexAttribute('flex-direction')\"\n [style.flex-wrap]=\"getFlexAttribute('flex-wrap')\"\n [style.justify-content]=\"getFlexAttribute('justify-content')\"\n [style.align-items]=\"getFlexAttribute('align-items')\"\n [style.align-content]=\"getFlexAttribute('align-content')\"\n [fxLayout]=\"getFlexAttribute('layout')\"\n [fxLayoutGap]=\"options?.fxLayoutGap\"\n [fxLayoutAlign]=\"options?.fxLayoutAlign\"\n [attr.fxFlexFill]=\"options?.fxLayoutAlign\"></flex-layout-root-widget>\n <mat-error *ngIf=\"options?.showErrors && options?.errorMessage\"\n [innerHTML]=\"options?.errorMessage\"></mat-error>\n </fieldset>\n\n <mat-card *ngIf=\"containerType === 'card'\"\n [ngClass]=\"options?.htmlClass || ''\"\n [class.expandable]=\"options?.expandable && !expanded\"\n [class.expanded]=\"options?.expandable && expanded\">\n <mat-card-header *ngIf=\"sectionTitle\">\n <legend\n [class]=\"'legend ' + (options?.labelHtmlClass || '')\"\n [innerHTML]=\"sectionTitle\"\n (click)=\"toggleExpanded()\"></legend>\n </mat-card-header>\n <mat-card-content *ngIf=\"expanded\">\n <fieldset [disabled]=\"options?.readonly\">\n <flex-layout-root-widget *ngIf=\"expanded\"\n [layout]=\"layoutNode.items\"\n [dataIndex]=\"dataIndex\"\n [layoutIndex]=\"layoutIndex\"\n [isFlexItem]=\"getFlexAttribute('is-flex')\"\n [class.form-flex-column]=\"getFlexAttribute('flex-direction') === 'column'\"\n [class.form-flex-row]=\"getFlexAttribute('flex-direction') === 'row'\"\n [style.display]=\"getFlexAttribute('display')\"\n [style.flex-direction]=\"getFlexAttribute('flex-direction')\"\n [style.flex-wrap]=\"getFlexAttribute('flex-wrap')\"\n [style.justify-content]=\"getFlexAttribute('justify-content')\"\n [style.align-items]=\"getFlexAttribute('align-items')\"\n [style.align-content]=\"getFlexAttribute('align-content')\"\n [fxLayout]=\"getFlexAttribute('layout')\"\n [fxLayoutGap]=\"options?.fxLayoutGap\"\n [fxLayoutAlign]=\"options?.fxLayoutAlign\"\n [attr.fxFlexFill]=\"options?.fxLayoutAlign\"></flex-layout-root-widget>\n </fieldset>\n </mat-card-content>\n <mat-card-footer>\n <mat-error *ngIf=\"options?.showErrors && options?.errorMessage\"\n [innerHTML]=\"options?.errorMessage\"></mat-error>\n </mat-card-footer>\n </mat-card>\n\n <mat-expansion-panel *ngIf=\"containerType === 'expansion-panel'\"\n [expanded]=\"expanded\"\n [hideToggle]=\"!options?.expandable\">\n <mat-expansion-panel-header>\n <mat-panel-title>\n <legend *ngIf=\"sectionTitle\"\n [class]=\"options?.labelHtmlClass\"\n [innerHTML]=\"sectionTitle\"\n (click)=\"toggleExpanded()\"></legend>\n </mat-panel-title>\n </mat-expansion-panel-header>\n <fieldset [disabled]=\"options?.readonly\">\n <flex-layout-root-widget *ngIf=\"expanded\"\n [layout]=\"layoutNode.items\"\n [dataIndex]=\"dataIndex\"\n [layoutIndex]=\"layoutIndex\"\n [isFlexItem]=\"getFlexAttribute('is-flex')\"\n [class.form-flex-column]=\"getFlexAttribute('flex-direction') === 'column'\"\n [class.form-flex-row]=\"getFlexAttribute('flex-direction') === 'row'\"\n [style.display]=\"getFlexAttribute('display')\"\n [style.flex-direction]=\"getFlexAttribute('flex-direction')\"\n [style.flex-wrap]=\"getFlexAttribute('flex-wrap')\"\n [style.justify-content]=\"getFlexAttribute('justify-content')\"\n [style.align-items]=\"getFlexAttribute('align-items')\"\n [style.align-content]=\"getFlexAttribute('align-content')\"\n [fxLayout]=\"getFlexAttribute('layout')\"\n [fxLayoutGap]=\"options?.fxLayoutGap\"\n [fxLayoutAlign]=\"options?.fxLayoutAlign\"\n [attr.fxFlexFill]=\"options?.fxLayoutAlign\"></flex-layout-root-widget>\n </fieldset>\n <mat-error *ngIf=\"options?.showErrors && options?.errorMessage\"\n [innerHTML]=\"options?.errorMessage\"></mat-error>\n </mat-expansion-panel>",
styles: ["\n fieldset { border: 0; margin: 0; padding: 0; }\n .legend { font-weight: bold; }\n .expandable > .legend:before { content: '\u25B6'; padding-right: .3em; }\n .expanded > .legend:before { content: '\u25BC'; padding-right: .2em; }\n "]
})
], FlexLayoutSectionComponent);
return FlexLayoutSectionComponent;
}());
var MaterialAddReferenceComponent = /** @class */ (function () {
function MaterialAddReferenceComponent(jsf) {
this.jsf = jsf;
}
MaterialAddReferenceComponent.prototype.ngOnInit = function () {
this.options = this.layoutNode.options || {};
};
Object.defineProperty(MaterialAddReferenceComponent.prototype, "showAddButton", {
get: function () {
return !this.layoutNode.arrayItem ||
this.layoutIndex[this.layoutIndex.length - 1] < this.options.maxItems;
},
enumerable: true,
configurable: true
});
MaterialAddReferenceComponent.prototype.addItem = function (event) {
event.preventDefault();
this.jsf.addItem(this);
};
Object.defineProperty(MaterialAddReferenceComponent.prototype, "buttonText", {
get: function () {
var parent = {
dataIndex: this.dataIndex.slice(0, -1),
layoutIndex: this.layoutIndex.slice(0, -1),
layoutNode: this.jsf.getParentNode(this),
};
return parent.layoutNode.add ||
this.jsf.setArrayItemTitle(parent, this.layoutNode, this.itemCount);
},
enumerable: true,
configurable: true
});
MaterialAddReferenceComponent.ctorParameters = function () { return [
{ type: ajsfCore.JsonSchemaFormService }
]; };
__decorate([
core.Input()
], MaterialAddReferenceComponent.prototype, "layoutNode", void 0);
__decorate([
core.Input()
], MaterialAddReferenceComponent.prototype, "layoutIndex", void 0);
__decorate([
core.Input()
], MaterialAddReferenceComponent.prototype, "dataIndex", void 0);
MaterialAddReferenceComponent = __decorate([
core.Component({
// tslint:disable-next-line:component-selector
selector: 'material-add-reference-widget',
template: "\n <section [class]=\"options?.htmlClass || ''\" align=\"end\">\n <button mat-raised-button *ngIf=\"showAddButton\"\n [color]=\"options?.color || 'accent'\"\n [disabled]=\"options?.readonly\"\n (click)=\"addItem($event)\">\n <span *ngIf=\"options?.icon\" [class]=\"options?.icon\"></span>\n <span *ngIf=\"options?.title\" [innerHTML]=\"buttonText\"></span>\n </button>\n </section>",
changeDetection: core.ChangeDetectionStrategy.Default
})
], MaterialAddReferenceComponent);
return MaterialAddReferenceComponent;
}());
var MaterialButtonComponent = /** @class */ (function () {
function MaterialButtonComponent(jsf) {
this.jsf = jsf;
this.controlDisabled = false;
this.boundControl = false;
}
MaterialButtonComponent.prototype.ngOnInit = function () {
var _this = this;
this.options = this.layoutNode.options || {};
this.jsf.initializeControl(this);
if (ajsfCore.hasOwn(this.options, 'disabled')) {
this.controlDisabled = this.options.disabled;
}
else if (this.jsf.formOptions.disableInvalidSubmit) {
this.controlDisabled = !this.jsf.isValid;
this.jsf.isValidChanges.subscribe(function (isValid) { return _this.controlDisabled = !isValid; });
}
};
MaterialButtonComponent.prototype.updateValue = function (event) {
if (typeof this.options.onClick === 'function') {
this.options.onClick(event);
}
else {
this.jsf.updateValue(this, event.target.value);
}
};
MaterialButtonComponent.ctorParameters = function () { return [
{ type: ajsfCore.JsonSchemaFormService }
]; };
__decorate([
core.Input()
], MaterialButtonComponent.prototype, "layoutNode", void 0);
__decorate([
core.Input()
], MaterialButtonComponent.prototype, "layoutIndex", void 0);
__decorate([
core.Input()
], MaterialButtonComponent.prototype, "dataIndex", void 0);
MaterialButtonComponent = __decorate([
core.Component({
// tslint:disable-next-line:component-selector
selector: 'material-button-widget',
template: "\n <div class=\"button-row\" [class]=\"options?.htmlClass || ''\">\n <button mat-raised-button\n [attr.readonly]=\"options?.readonly ? 'readonly' : null\"\n [attr.aria-describedby]=\"'control' + layoutNode?._id + 'Status'\"\n [color]=\"options?.color || 'primary'\"\n [disabled]=\"controlDisabled || options?.readonly\"\n [id]=\"'control' + layoutNode?._id\"\n [name]=\"controlName\"\n [type]=\"layoutNode?.type\"\n [value]=\"controlValue\"\n (click)=\"updateValue($event)\">\n <mat-icon *ngIf=\"options?.icon\" class=\"mat-24\">{{options?.icon}}</mat-icon>\n <span *ngIf=\"options?.title\" [innerHTML]=\"options?.title\"></span>\n </button>\n </div>",
styles: [" button { margin-top: 10px; } "]
})
], MaterialButtonComponent);
return MaterialButtonComponent;
}());
var MaterialButtonGroupComponent = /** @class */ (function () {
function MaterialButtonGroupComponent(jsf) {
this.jsf = jsf;
this.controlDisabled = false;
this.boundControl = false;
this.radiosList = [];
this.vertical = false;
}
MaterialButtonGroupComponent.prototype.ngOnInit = function () {
this.options = this.layoutNode.options || {};
this.radiosList = ajsfCore.buildTitleMap(this.options.titleMap || this.options.enumNames, this.options.enum, true);
this.jsf.initializeControl(this);
};
MaterialButtonGroupComponent.prototype.updateValue = function (value) {
this.options.showErrors = true;
this.jsf.updateValue(this, value);
};
MaterialButtonGroupComponent.ctorParameters = function () { return [
{ type: ajsfCore.JsonSchemaFormService }
]; };
__decorate([
core.Input()
], MaterialButtonGroupComponent.prototype, "layoutNode", void 0);
__decorate([
core.Input()
], MaterialButtonGroupComponent.prototype, "layoutIndex", void 0);
__decorate([
core.Input()
], MaterialButtonGroupComponent.prototype, "dataIndex", void 0);
MaterialButtonGroupComponent = __decorate([
core.Component({
// tslint:disable-next-line:component-selector
selector: 'material-button-group-widget',
template: "\n <div>\n <div *ngIf=\"options?.title\">\n <label\n [attr.for]=\"'control' + layoutNode?._id\"\n [class]=\"options?.labelHtmlClass || ''\"\n [style.display]=\"options?.notitle ? 'none' : ''\"\n [innerHTML]=\"options?.title\"></label>\n </div>\n <mat-button-toggle-group\n [attr.aria-describedby]=\"'control' + layoutNode?._id + 'Status'\"\n [attr.readonly]=\"options?.readonly ? 'readonly' : null\"\n [attr.required]=\"options?.required\"\n [disabled]=\"controlDisabled || options?.readonly\"\n [name]=\"controlName\"\n [value]=\"controlValue\"\n [vertical]=\"!!options.vertical\">\n <mat-button-toggle *ngFor=\"let radioItem of radiosList\"\n [id]=\"'control' + layoutNode?._id + '/' + radioItem?.name\"\n [value]=\"radioItem?.value\"\n (click)=\"updateValue(radioItem?.value)\">\n <span [innerHTML]=\"radioItem?.name\"></span>\n </mat-button-toggle>\n </mat-button-toggle-group>\n <mat-error *ngIf=\"options?.showErrors && options?.errorMessage\"\n [innerHTML]=\"options?.errorMessage\"></mat-error>\n </div>",
styles: [" mat-error { font-size: 75%; } "]
})
], MaterialButtonGroupComponent);
return MaterialButtonGroupComponent;
}());
var MaterialCheckboxComponent = /** @class */ (function () {
function MaterialCheckboxComponent(jsf) {
this.jsf = jsf;
this.controlDisabled = false;
this.boundControl = false;
this.trueValue = true;
this.falseValue = false;
this.showSlideToggle = false;
}
MaterialCheckboxComponent.prototype.ngOnInit = function () {
this.options = this.layoutNode.options || {};
this.jsf.initializeControl(this, !this.options.readonly);
if (this.controlValue === null || this.controlValue === undefined) {
this.controlValue = false;
this.jsf.updateValue(this, this.falseValue);
}
if (this.layoutNode.type === 'slide-toggle' ||
this.layoutNode.format === 'slide-toggle') {
this.showSlideToggle = true;
}
};
MaterialCheckboxComponent.prototype.updateValue = function (event) {
this.options.showErrors = true;
this.jsf.updateValue(this, event.checked ? this.trueValue : this.falseValue);
};
Object.defineProperty(MaterialCheckboxComponent.prototype, "isChecked", {
get: function () {
return this.jsf.getFormControlValue(this) === this.trueValue;
},
enumerable: true,
configurable: true
});
MaterialCheckboxComponent.ctorParameters = function () { return [
{ type: ajsfCore.JsonSchemaFormService }
]; };
__decorate([
core.Input()
], MaterialCheckboxComponent.prototype, "layoutNode", void 0);
__decorate([
core.Input()
], MaterialCheckboxComponent.prototype, "layoutIndex", void 0);
__decorate([
core.Input()
], MaterialCheckboxComponent.prototype, "dataIndex", void 0);
MaterialCheckboxComponent = __decorate([
core.Component({
// tslint:disable-next-line:component-selector
selector: 'material-checkbox-widget',
template: "\n <mat-checkbox *ngIf=\"boundControl && !showSlideToggle\"\n [formControl]=\"formControl\"\n align=\"left\"\n [color]=\"options?.color || 'primary'\"\n [id]=\"'control' + layoutNode?._id\"\n labelPosition=\"after\"\n [name]=\"controlName\"\n (blur)=\"options.showErrors = true\">\n <span *ngIf=\"options?.title\"\n class=\"checkbox-name\"\n [style.display]=\"options?.notitle ? 'none' : ''\"\n [innerHTML]=\"options?.title\"></span>\n </mat-checkbox>\n <mat-checkbox *ngIf=\"!boundControl && !showSlideToggle\"\n align=\"left\"\n [color]=\"options?.color || 'primary'\"\n [disabled]=\"controlDisabled || options?.readonly\"\n [id]=\"'control' + layoutNode?._id\"\n labelPosition=\"after\"\n [name]=\"controlName\"\n [checked]=\"isChecked\"\n (blur)=\"options.showErrors = true\"\n (change)=\"updateValue($event)\">\n <span *ngIf=\"options?.title\"\n class=\"checkbox-name\"\n [style.display]=\"options?.notitle ? 'none' : ''\"\n [innerHTML]=\"options?.title\"></span>\n </mat-checkbox>\n <mat-slide-toggle *ngIf=\"boundControl && showSlideToggle\"\n [formControl]=\"formControl\"\n align=\"left\"\n [color]=\"options?.color || 'primary'\"\n [id]=\"'control' + layoutNode?._id\"\n labelPosition=\"after\"\n [name]=\"controlName\"\n (blur)=\"options.showErrors = true\">\n <span *ngIf=\"options?.title\"\n class=\"checkbox-name\"\n [style.display]=\"options?.notitle ? 'none' : ''\"\n [innerHTML]=\"options?.title\"></span>\n </mat-slide-toggle>\n <mat-slide-toggle *ngIf=\"!boundControl && showSlideToggle\"\n align=\"left\"\n [color]=\"options?.color || 'primary'\"\n [disabled]=\"controlDisabled || options?.readonly\"\n [id]=\"'control' + layoutNode?._id\"\n labelPosition=\"after\"\n [name]=\"controlName\"\n [checked]=\"isChecked\"\n (blur)=\"options.showErrors = true\"\n (change)=\"updateValue($event)\">\n <span *ngIf=\"options?.title\"\n class=\"checkbox-name\"\n [style.display]=\"options?.notitle ? 'none' : ''\"\n [innerHTML]=\"options?.title\"></span>\n </mat-slide-toggle>\n <mat-error *ngIf=\"options?.showErrors && options?.errorMessage\"\n [innerHTML]=\"options?.errorMessage\"></mat-error>",
styles: ["\n .checkbox-name { white-space: nowrap; }\n mat-error { font-size: 75%; }\n "]
})
], MaterialCheckboxComponent);
return MaterialCheckboxComponent;
}());
// TODO: Change this to use a Selection List instead?
// https://material.angular.io/components/list/overview
var MaterialCheckboxesComponent = /** @class */ (function () {
function MaterialCheckboxesComponent(jsf) {
this.jsf = jsf;
this.controlDisabled = false;
this.boundControl = false;
this.horizontalList = false;
this.checkboxList = [];
}
MaterialCheckboxesComponent.prototype.ngOnInit = function () {
var e_1, _a;
this.options = this.layoutNode.options || {};
this.horizontalList = this.layoutNode.type === 'checkboxes-inline' ||
this.layoutNode.type === 'checkboxbuttons';
this.jsf.initializeControl(this);
this.checkboxList = ajsfCore.buildTitleMap(this.options.titleMap || this.options.enumNames, this.options.enum, true);
if (this.boundControl) {
var formArray = this.jsf.getFormControl(this);
try {
for (var _b = __values(this.checkboxList), _c = _b.next(); !_c.done; _c = _b.next()) {
var checkboxItem = _c.value;
checkboxItem.checked = formArray.value.includes(checkboxItem.value);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
}
};
Object.defineProperty(MaterialCheckboxesComponent.prototype, "allChecked", {
get: function () {
return this.checkboxList.filter(function (t) { return t.checked; }).length === this.checkboxList.length;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MaterialCheckboxesComponent.prototype, "someChecked", {
get: function () {
var checkedItems = this.checkboxList.filter(function (t) { return t.checked; }).length;
return checkedItems > 0 && checkedItems < this.checkboxList.length;
},
enumerable: true,
configurable: true
});
MaterialCheckboxesComponent.prototype.updateValue = function () {
this.options.showErrors = true;
if (this.boundControl) {
this.jsf.updateArrayCheckboxList(this, this.checkboxList);
}
};
MaterialCheckboxesComponent.prototype.updateAllValues = function (event) {
this.options.showErrors = true;
this.checkboxList.forEach(function (t) { return t.checked = event.checked; });
this.updateValue();
};
MaterialCheckboxesComponent.ctorParameters = function () { return [
{ type: ajsfCore.JsonSchemaFormService }
]; };
__decorate([
core.Input()
], MaterialCheckboxesComponent.prototype, "layoutNode", void 0);
__decorate([
core.Input()
], MaterialCheckboxesComponent.prototype, "layoutIndex", void 0);
__decorate([
core.Input()
], MaterialCheckboxesComponent.prototype, "dataIndex", void 0);
MaterialCheckboxesComponent = __decorate([
core.Component({
// tslint:disable-next-line:component-selector
selector: 'material-checkboxes-widget',
template: "\n <div>\n <mat-checkbox type=\"checkbox\"\n [checked]=\"allChecked\"\n [color]=\"options?.color || 'primary'\"\n [disabled]=\"controlDisabled || options?.readonly\"\n [indeterminate]=\"someChecked\"\n [name]=\"options?.name\"\n (blur)=\"options.showErrors = true\"\n (change)=\"updateAllValues($event)\">\n <span class=\"checkbox-name\" [innerHTML]=\"options?.name\"></span>\n </mat-checkbox>\n <label *ngIf=\"options?.title\"\n class=\"title\"\n [class]=\"options?.labelHtmlClass || ''\"\n [style.display]=\"options?.notitle ? 'none' : ''\"\n [innerHTML]=\"options?.title\"></label>\n <ul class=\"checkbox-list\" [class.horizontal-list]=\"horizontalList\">\n <li *ngFor=\"let checkboxItem of checkboxList\"\n [class]=\"options?.htmlClass || ''\">\n <mat-checkbox type=\"checkbox\"\n [(ngModel)]=\"checkboxItem.checked\"\n [color]=\"options?.color || 'primary'\"\n [disabled]=\"controlDisabled || options?.readonly\"\n [name]=\"checkboxItem?.name\"\n (blur)=\"options.showErrors = true\"\n (change)=\"updateValue()\">\n <span class=\"checkbox-name\" [innerHTML]=\"checkboxItem?.name\"></span>\n </mat-checkbox>\n </li>\n </ul>\n <mat-error *ngIf=\"options?.showErrors && options?.errorMessage\"\n [innerHTML]=\"options?.errorMessage\"></mat-error>\n </div>",
styles: ["\n .title { font-weight: bold; }\n .checkbox-list { list-style-type: none; }\n .horizontal-list > li { display: inline-block; margin-right: 10px; zoom: 1; }\n .checkbox-name { white-space: nowrap; }\n mat-error { font-size: 75%; }\n "]
})
], MaterialCheckboxesComponent);
return MaterialCheckboxesComponent;
}());
// TODO: Add this control
var MaterialChipListComponent = /** @class */ (function () {
function MaterialChipListComponent(jsf) {
this.jsf = jsf;
this.controlDisabled = false;
this.boundControl = false;
}
MaterialChipListComponent.prototype.ngOnInit = function () {
this.options = this.layoutNode.options || {};
this.jsf.initializeControl(this);
};
MaterialChipListComponent.prototype.updateValue = function (event) {
this.jsf.updateValue(this, event.target.value);
};
MaterialChipListComponent.ctorParameters = function () { return [
{ type: ajsfCore.JsonSchemaFormService }
]; };
__decorate([
core.Input()
], MaterialChipListComponent.prototype, "layoutNode", void 0);
__decorate([
core.Input()
], MaterialChipListComponent.prototype, "layoutIndex", void 0);
__decorate([
core.Input()
], MaterialChipListComponent.prototype, "dataIndex", void 0);
MaterialChipListComponent = __decorate([
core.Component({
// tslint:disable-next-line:component-selector
selector: 'material-chip-list-widget',
template: ""
})
], MaterialChipListComponent);
return MaterialChipListComponent;
}());
var MaterialDatepickerComponent = /** @class */ (function () {
function MaterialDatepickerComponent(matFormFieldDefaultOptions, matLabelGlobalOptions, jsf) {
this.matFormFieldDefaultOptions = matFormFieldDefaultOptions;
this.matLabelGlobalOptions = matLabelGlobalOptions;
this.jsf = jsf;
this.controlDisabled = false;
this.boundControl = false;
this.autoCompleteList = [];
}
MaterialDatepickerComponent.prototype.ngOnInit = function () {
this.options = this.layoutNode.options || {};
this.jsf.initializeControl(this, !this.options.readonly);
if (this.controlValue) {
this.formControl.setValue(ajsfCore.dateToString(this.controlValue, this.options));
}
if (!this.options.notitle && !this.options.description && this.options.placeholder) {
this.options.description = this.options.placeholder;
}
};
MaterialDatepickerComponent.prototype.updateValue = function (event) {
this.options.showErrors = true;
if (event.value) {
this.formControl.setValue(ajsfCore.dateToString(event.value, this.options));
}
};
MaterialDatepickerComponent.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: core.Inject, args: [formField.MAT_FORM_FIELD_DEFAULT_OPTIONS,] }, { type: core.Optional }] },
{ type: undefined, decorators: [{ type: core.Inject, args: [core$1.MAT_LABEL_GLOBAL_OPTIONS,] }, { type: core.Optional }] },
{ type: ajsfCore.JsonSchemaFormService }
]; };
__decorate([
core.Input()
], MaterialDatepickerComponent.prototype, "layoutNode", void 0);
__decorate([
core.Input()
], MaterialDatepickerComponent.prototype, "layoutIndex", void 0);
__decorate([
core.Input()
], MaterialDatepickerComponent.prototype, "dataIndex", void 0);
MaterialDatepickerComponent = __decorate([
core.Component({
// tslint:disable-next-line:component-selector
selector: 'material-datepicker-widget',
template: "\n <mat-form-field [appearance]=\"options?.appearance || matFormFieldDefaultOptions?.appearance || 'standard'\"\n [class]=\"options?.htmlClass || ''\"\n [floatLabel]=\"options?.floatLabel || matLabelGlobalOptions?.float || (options?.notitle ? 'never' : 'auto')\"\n [hideRequiredMarker]=\"options?.hideRequired ? 'true' : 'false'\