UNPKG

@cfstratos/ajsf-material

Version:

Angular JSON Schema Form builder using Angular Material UI

719 lines (707 loc) 85.7 kB
import { __decorate, __values, __param, __assign, __extends, __spread } from 'tslib'; import { Input, Component, ChangeDetectionStrategy, Inject, Optional, ChangeDetectorRef, Injectable, NgModule } from '@angular/core'; import { JsonSchemaFormService, hasOwn, buildTitleMap, dateToString, isDefined, isArray, Framework, WidgetLibraryModule, JsonSchemaFormModule, FrameworkLibraryService, WidgetLibraryService } from '@cfstratos/ajsf-core'; import { MAT_LABEL_GLOBAL_OPTIONS, MatNativeDateModule } from '@angular/material/core'; import { MAT_FORM_FIELD_DEFAULT_OPTIONS, MatFormFieldModule } from '@angular/material/form-field'; import cloneDeep from 'lodash/cloneDeep'; import { CommonModule } from '@angular/common'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FlexLayoutModule } from '@angular/flex-layout'; import { MatAutocompleteModule } from '@angular/material/autocomplete'; import { MatButtonModule } from '@angular/material/button'; import { MatButtonToggleModule } from '@angular/material/button-toggle'; import { MatCardModule } from '@angular/material/card'; import { MatCheckboxModule } from '@angular/material/checkbox'; import { MatChipsModule } from '@angular/material/chips'; import { MatDatepickerModule } from '@angular/material/datepicker'; import { MatExpansionModule } from '@angular/material/expansion'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { MatRadioModule } from '@angular/material/radio'; import { MatSelectModule } from '@angular/material/select'; import { MatSlideToggleModule } from '@angular/material/slide-toggle'; import { MatSliderModule } from '@angular/material/slider'; import { MatStepperModule } from '@angular/material/stepper'; import { MatTabsModule } from '@angular/material/tabs'; import { MatTooltipModule } from '@angular/material/tooltip'; import { MatMenuModule } from '@angular/material/menu'; import { MatToolbarModule } from '@angular/material/toolbar'; import { MediaMarshaller } from '@angular/flex-layout/core'; 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: JsonSchemaFormService } ]; }; __decorate([ Input() ], FlexLayoutRootComponent.prototype, "dataIndex", void 0); __decorate([ Input() ], FlexLayoutRootComponent.prototype, "layoutIndex", void 0); __decorate([ Input() ], FlexLayoutRootComponent.prototype, "layout", void 0); __decorate([ Input() ], FlexLayoutRootComponent.prototype, "isFlexItem", void 0); FlexLayoutRootComponent = __decorate([ 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: 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: JsonSchemaFormService } ]; }; __decorate([ Input() ], FlexLayoutSectionComponent.prototype, "layoutNode", void 0); __decorate([ Input() ], FlexLayoutSectionComponent.prototype, "layoutIndex", void 0); __decorate([ Input() ], FlexLayoutSectionComponent.prototype, "dataIndex", void 0); FlexLayoutSectionComponent = __decorate([ 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: JsonSchemaFormService } ]; }; __decorate([ Input() ], MaterialAddReferenceComponent.prototype, "layoutNode", void 0); __decorate([ Input() ], MaterialAddReferenceComponent.prototype, "layoutIndex", void 0); __decorate([ Input() ], MaterialAddReferenceComponent.prototype, "dataIndex", void 0); MaterialAddReferenceComponent = __decorate([ 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: 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 (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: JsonSchemaFormService } ]; }; __decorate([ Input() ], MaterialButtonComponent.prototype, "layoutNode", void 0); __decorate([ Input() ], MaterialButtonComponent.prototype, "layoutIndex", void 0); __decorate([ Input() ], MaterialButtonComponent.prototype, "dataIndex", void 0); MaterialButtonComponent = __decorate([ 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 = 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: JsonSchemaFormService } ]; }; __decorate([ Input() ], MaterialButtonGroupComponent.prototype, "layoutNode", void 0); __decorate([ Input() ], MaterialButtonGroupComponent.prototype, "layoutIndex", void 0); __decorate([ Input() ], MaterialButtonGroupComponent.prototype, "dataIndex", void 0); MaterialButtonGroupComponent = __decorate([ 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: JsonSchemaFormService } ]; }; __decorate([ Input() ], MaterialCheckboxComponent.prototype, "layoutNode", void 0); __decorate([ Input() ], MaterialCheckboxComponent.prototype, "layoutIndex", void 0); __decorate([ Input() ], MaterialCheckboxComponent.prototype, "dataIndex", void 0); MaterialCheckboxComponent = __decorate([ 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 = 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: JsonSchemaFormService } ]; }; __decorate([ Input() ], MaterialCheckboxesComponent.prototype, "layoutNode", void 0); __decorate([ Input() ], MaterialCheckboxesComponent.prototype, "layoutIndex", void 0); __decorate([ Input() ], MaterialCheckboxesComponent.prototype, "dataIndex", void 0); MaterialCheckboxesComponent = __decorate([ 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: JsonSchemaFormService } ]; }; __decorate([ Input() ], MaterialChipListComponent.prototype, "layoutNode", void 0); __decorate([ Input() ], MaterialChipListComponent.prototype, "layoutIndex", void 0); __decorate([ Input() ], MaterialChipListComponent.prototype, "dataIndex", void 0); MaterialChipListComponent = __decorate([ 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(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(dateToString(event.value, this.options)); } }; MaterialDatepickerComponent.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: Inject, args: [MAT_FORM_FIELD_DEFAULT_OPTIONS,] }, { type: Optional }] }, { type: undefined, decorators: [{ type: Inject, args: [MAT_LABEL_GLOBAL_OPTIONS,] }, { type: Optional }] }, { type: JsonSchemaFormService } ]; }; __decorate([ Input() ], MaterialDatepickerComponent.prototype, "layoutNode", void 0); __decorate([ Input() ], MaterialDatepickerComponent.prototype, "layoutIndex", void 0); __decorate([ Input() ], MaterialDatepickerComponent.prototype, "dataIndex", void 0); MaterialDatepickerComponent = __decorate([ 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'\"\n [style.width]=\"'100%'\">\n <mat-label *ngIf=\"!options?.notitle\">{{options?.title}}</mat-label>\n <span matPrefix *ngIf=\"options?.prefix || options?.fieldAddonLeft\"\n [innerHTML]=\"options?.prefix || options?.fieldAddonLeft\"></span>\n <input matInput *ngIf=\"boundControl\"\n [formControl]=\"formControl\"\n [attr.aria-describedby]=\"'control' + layoutNode?._id + 'Status'\"\n [attr.list]=\"'control' + layoutNode?._id + 'Autocomplete'\"\n [attr.readonly]=\"options?.readonly ? 'readonly' : null\"\n [id]=\"'control' + layoutNode?._id\"\n [max]=\"options?.maximum\"\n [matDatepicker]=\"picker\"\n [min]=\"options?.minimum\"\n [name]=\"controlName\"\n [placeholder]=\"options?.title\"\n [readonly]=\"options?.readonly\"\n [required]=\"options?.required\"\n [style.width]=\"'100%'\"\n (blur)=\"options.showErrors = true\"\n (dateChange)=\"updateValue($event)\"\n (dateInput)=\"updateValue($event)\">\n <input matInput *ngIf=\"!boundControl\"\n [attr.aria-describedby]=\"'control' + layoutNode?._id + 'Status'\"\n [attr.list]=\"'control' + layoutNode?._id + 'Autocomplete'\"\n [attr.readonly]=\"options?.readonly ? 'readonly' : null\"\n [disabled]=\"controlDisabled || options?.readonly\"\n [id]=\"'control' + layoutNode?._id\"\n [max]=\"options?.maximum\"\n [matDatepicker]=\"picker\"\n [min]=\"options?.minimum\"\n [name]=\"controlName\"\n [placeholder]=\"options?.title\"\n [required]=\"options?.required\"\n [style.width]=\"'100%'\"\n [readonly]=\"options?.readonly\"\n (blur)=\"options.showErrors = true\"\n (dateChange)=\"updateValue($event)\"\n (dateInput)=\"updateValue($event)\">\n <span matSuffix *ngIf=\"options?.suffix || options?.fieldAddonRight\"\n [innerHTML]=\"options?.suffix || options?.fieldAddonRight\"></span>\n <mat-hint *ngIf=\"options?.description && (!options?.showErrors || !options?.errorMessage)\"\n align=\"end\" [innerHTML]=\"options?.description\"></mat-hint>\n <mat-datepicker-toggle matSuffix [for]=\"picker\"></mat-datepicker-toggle>\n </mat-form-field>\n <mat-datepicker #picker ></mat-datepicker>\n <mat-error *ngIf=\"options?.showErrors && options?.errorMessage\"\n [innerHTML]=\"options?.errorMessage\"></mat-error>", styles: ["\n mat-error { font-size: 75%; margin-top: -1rem; margin-bottom: 0.5rem; }\n ::ng-deep json-schema-form mat-form-field .mat-form-field-wrapper .mat-form-field-flex\n .mat-form-field-infix { width: initial; }\n "] }), __param(0, Inject(MAT_FORM_FIELD_DEFAULT_OPTIONS)), __param(0, Optional()), __param(1, Inject(MAT_LABEL_GLOBAL_OPTIONS)), __param(1, Optional()) ], MaterialDatepickerComponent); return MaterialDatepickerComponent; }()); var MaterialDesignFrameworkComponent = /** @class */ (function () { function MaterialDesignFrameworkComponent(changeDetector, jsf) { this.changeDetector = changeDetector; this.jsf = jsf; this.frameworkInitialized = false; this.formControl = null; this.parentArray = null; this.isOrderable = false; this.dynamicTitle = null; } Object.defineProperty(MaterialDesignFrameworkComponent.prototype, "showRemoveButton", { get: function () { if (!this.layoutNode || !this.widgetOptions.removable || this.widgetOptions.readonly || this.layoutNode.type === '$ref') { return false; } if (this.layoutNode.recursiveReference) { return true; } if (!this.layoutNode.arrayItem || !this.parentArray) { return false; } // If array length <= minItems, don't allow removing any items return this.parentArray.items.length - 1 <= this.parentArray.options.minItems ? false : // For removable list items, allow removing any item this.layoutNode.arrayItemType === 'list' ? true : // For removable tuple items, only allow removing last item in list this.layoutIndex[this.layoutIndex.length - 1] === this.parentArray.items.length - 2; }, enumerable: true, configurable: true }); MaterialDesignFrameworkComponent.prototype.ngOnInit = function () { this.initializeFramework(); }; MaterialDesignFrameworkComponent.prototype.ngOnChanges = function () { if (!this.frameworkInitialized) { this.initializeFramework(); } if (this.dynamicTitle) { this.updateTitle(); } }; MaterialDesignFrameworkComponent.prototype.initializeFramework = function () { if (this.layoutNode) { this.options = cloneDeep(this.layoutNode.options || {}); this.widgetLayoutNode = __assign(__assign({}, this.layoutNode), { options: cloneDeep(this.layoutNode.options || {}) }); this.widgetOptions = this.widgetLayoutNode.options; this.formControl = this.jsf.getFormControl(this); if (isDefined(this.widgetOptions.minimum) && isDefined(this.widgetOptions.maximum) && this.widgetOptions.multipleOf >= 1) { this.layoutNode.type = 'range'; } if (!['$ref', 'advancedfieldset', 'authfieldset', 'button', 'card', 'checkbox', 'expansion-panel', 'help', 'message', 'msg', 'section', 'submit', 'tabarray', 'tabs'].includes(this.layoutNode.type) && /{{.+?}}/.test(this.widgetOptions.title || '')) { this.dynamicTitle = this.widgetOptions.title; this.updateTitle(); } if (this.layoutNode.arrayItem && this.layoutNode.type !== '$ref') { this.parentArray = this.jsf.getParentNode(this); if (this.parentArray) { this.isOrderable = this.parentArray.type.slice(0, 3) !== 'tab' && this.layoutNode.arrayItemType === 'list' && !this.widgetOptions.readonly && this.parentArray.options.orderable; } } this.frameworkInitialized = true; } else { this.options = {}; } }; MaterialDesignFrameworkComponent.prototype.updateTitle = function () { this.widgetLayoutNode.options.title = this.jsf.parseText(this.dynamicTitle, this.jsf.getFormControlValue(this), this.jsf.getFormControlGroup(this).value, this.dataIndex[this.dataIndex.length - 1]); }; MaterialDesignFrameworkComponent.prototype.removeItem = function () { this.jsf.removeItem(this); }; MaterialDesignFrameworkComponent.ctorParameters = function () { return [ { type: ChangeDetectorRef }, { type: JsonSchemaFormService } ]; }; __decorate([ Input() ], MaterialDesignFrameworkComponent.prototype, "layoutNode", void 0); __decorate([ Input() ], MaterialDesignFrameworkComponent.prototype, "layoutIndex", void 0); __decorate([ Input() ], MaterialDesignFrameworkComponent.prototype, "dataIndex", void 0); MaterialDesignFrameworkComponent = __decorate([ Component({ // tslint:disable-next-line:component-selector selector: 'material-design-framework', template: "<div\n [class.array-item]=\"widgetLayoutNode?.arrayItem && widgetLayoutNode?.type !== '$ref'\"\n [orderable]=\"isOrderable\"\n [dataIndex]=\"dataIndex\"\n [layoutIndex]=\"layoutIndex\"\n [layoutNode]=\"widgetLayoutNode\">\n <svg *ngIf=\"showRemoveButton\"\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"18\" width=\"18\" viewBox=\"0 0 24 24\"\n class=\"close-button\"\n (click)=\"removeItem()\">\n <path\n d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z\"/>\n </svg>\n <select-widget-widget\n [dataIndex]=\"dataIndex\"\n [layoutIndex]=\"layoutIndex\"\n [layoutNode]=\"widgetLayoutNode\"></select-widget-widget>\n</div>\n<div class=\"spacer\" *ngIf=\"widgetLayoutNode?.arrayItem && widgetLayoutNode?.type !== '$ref'\"></div>\n", styles: [".array-item{border-radius:2px;box-shadow:0 3px 1px -2px rgba(0,0,0,.2),0 2px 2px 0 rgba(0,0,0,.14),0 1px 5px 0 rgba(0,0,0,.12);padding:6px;position:relative;transition:280ms cubic-bezier(.4,0,.2,1)}.close-button{cursor:pointer;position:absolute;top:6px;right:6px;fill:rgba(0,0,0,.4);visibility:hidden;z-index:500}.close-button:hover{fill:rgba(0,0,0,.8)}.array-item:hover>.close-button{visibility:visible}.spacer{margin:6px 0}[draggable=true]:hover{box-shadow:0 5px 5px -3px rgba(0,0,0,.2),0 8px 10px 1px rgba(0,0,0,.14),0 3px 14px 2px rgba(0,0,0,.12);cursor:move;z-index:10}[draggable=true].drag-target-top{box-shadow:0 -2px 0 #000;position:relative;z-index:20}[draggable=true].drag-target-bottom{box-shadow:0 2px 0 #000;position:relative;z-index:20}"] }) ], MaterialDesignFrameworkComponent); return MaterialDesignFrameworkComponent; }()); // TODO: Add this control var MaterialFileComponent = /** @class */ (function () { function MaterialFileComponent(jsf) { this.jsf = jsf; this.controlDisabled = false; this.boundControl = false; } MaterialFileComponent.prototype.ngOnInit = function () { this.options = this.layoutNode.options || {}; this.jsf.initializeControl(this); }; MaterialFileComponent.prototype.updateValue = function (event) { this.jsf.updateValue(this, event.target.value); }; MaterialFileComponent.ctorParameters = function () { return [ { type: JsonSchemaFormService } ]; }; __decorate([ Input() ], MaterialFileComponent.prototype, "layoutNode", void 0); __decorate([ Input() ], MaterialFileComponent.prototype, "layoutIndex", void 0); __decorate([ Input() ], MaterialFileComponent.prototype, "dataIndex", void 0); MaterialFileComponent = __decorate([ Component({ // tslint:disable-next-line:component-selector selector: 'material-file-widget', template: "" }) ], MaterialFileComponent); return MaterialFileComponent; }()); var MaterialInputComponent = /** @class */ (function () { function MaterialInputComponent(matFormFieldDefaultOptions, matLabelGlobalOptions, jsf) { this.matFormFieldDefaultOptions = matFormFieldDefaultOptions; this.matLabelGlobalOptions = matLabelGlobalOptions; this.jsf = jsf; this.controlDisabled = false; this.boundControl = false; this.autoCompleteList = []; } MaterialInputComponent.prototype.ngOnInit = function () { this.options = this.layoutNode.options || {}; this.jsf.initializeControl(this); if (!this.options.notitle && !this.options.description && this.options.placeholder) { this.options.description = this.options.placeholder; } }; MaterialInputComponent.prototype.updateValue = function (event) { this.jsf.updateValue(this, event.target.value); }; MaterialInputComponent.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: Inject, args: [MAT_FORM_FIELD_DEFAULT_OPTIONS,] }, { type: Optional }] }, { type: undefined, decorators: [{ type: Inject, args: [MAT_LABEL_GLOBAL_OPTIONS,] }, { type: Optional }] }, { type: JsonSchemaFormService } ]; }; __decorate([ Input() ], MaterialInputComponent.prototype, "layoutNode", void 0); __decorate([ Input() ], MaterialInputComponent.prototype, "layoutIndex", void 0); __decorate([ Input() ], MaterialInputComponent.prototype, "dataIndex", void 0); MaterialInputComponent = __decorate([ Component({ // tslint:disable-next-line:component-selector selector: 'material-input-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'\"\n [style.width]=\"'100%'\">\n <mat-label *ngIf=\"!options?.notitle\">{{options?.title}}</mat-label>\n <span matPrefix *ngIf=\"options?.prefix || options?.fieldAddonLeft\"\n [innerHTML]=\"options?.prefix || options?.fieldAddonLeft\"></span>\n <input matInput *ngIf=\"boundControl\"\n [formControl]=\"formControl\"\n [attr.aria-describedby]=\"'control' + layoutNode?._id + 'Status'\"\n [attr.list]=\"'control' + layoutNode?._id + 'Autocomplete'\"\n [attr.maxlength]=\"options?.maxLength\"\n [attr.minlength]=\"options?.minLength\"\n [attr.pattern]=\"options?.pattern\"\n [readonly]=\"options?.readonly ? 'readonly' : null\"\n [id]=\"'control' + layoutNode?._id\"\n [name]=\"controlName\"\n [placeholder]=\"options?.notitle ?