@ng-formworks/core 19.5.3 → 19.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common';
3
3
  import * as i2 from '@angular/forms';
4
4
  import { UntypedFormControl, UntypedFormArray, UntypedFormGroup, NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
5
5
  import * as i0 from '@angular/core';
6
- import { Injectable, inject, input, Component, ChangeDetectionStrategy, ComponentFactoryResolver, viewChild, ViewContainerRef, ElementRef, NgZone, Directive, signal, Inject, forwardRef, ChangeDetectorRef, output, Input, NgModule } from '@angular/core';
6
+ import { Injectable, inject, input, Component, ChangeDetectionStrategy, Directive, Input, viewChild, ViewContainerRef, ElementRef, NgZone, signal, Inject, forwardRef, ChangeDetectorRef, output, NgModule } from '@angular/core';
7
7
  import cloneDeep from 'lodash/cloneDeep';
8
8
  import isEqual$1 from 'lodash/isEqual';
9
9
  import { from, Observable, forkJoin, Subject, lastValueFrom } from 'rxjs';
@@ -7434,6 +7434,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
7434
7434
  }]
7435
7435
  }] });
7436
7436
 
7437
+ class ElementAttributeDirective {
7438
+ constructor(renderer, elementRef) {
7439
+ this.renderer = renderer;
7440
+ this.elementRef = elementRef;
7441
+ }
7442
+ ngOnChanges(changes) {
7443
+ if (changes.attributes) {
7444
+ for (let attributeName in this.attributes) {
7445
+ const attributeValue = this.attributes[attributeName];
7446
+ if (attributeValue) {
7447
+ this.renderer.setAttribute(this.elementRef.nativeElement, attributeName, attributeValue);
7448
+ }
7449
+ else {
7450
+ this.renderer.removeAttribute(this.elementRef.nativeElement, attributeName);
7451
+ }
7452
+ }
7453
+ }
7454
+ }
7455
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: ElementAttributeDirective, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
7456
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.4", type: ElementAttributeDirective, isStandalone: false, selector: "[attributes]", inputs: { attributes: "attributes" }, usesOnChanges: true, ngImport: i0 }); }
7457
+ }
7458
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: ElementAttributeDirective, decorators: [{
7459
+ type: Directive,
7460
+ args: [{
7461
+ selector: '[attributes]',
7462
+ standalone: false
7463
+ }]
7464
+ }], ctorParameters: () => [{ type: i0.Renderer2 }, { type: i0.ElementRef }], propDecorators: { attributes: [{
7465
+ type: Input
7466
+ }] } });
7467
+
7437
7468
  class InputComponent {
7438
7469
  constructor() {
7439
7470
  this.jsf = inject(JsonSchemaFormService);
@@ -7444,6 +7475,10 @@ class InputComponent {
7444
7475
  this.layoutIndex = input(undefined);
7445
7476
  this.dataIndex = input(undefined);
7446
7477
  }
7478
+ //needed as templates don't accept something like [attributes]="options?.['x-inputAttributes']"
7479
+ get inputAttributes() {
7480
+ return this.options?.['x-inputAttributes'];
7481
+ }
7447
7482
  ngOnInit() {
7448
7483
  this.options = this.layoutNode().options || {};
7449
7484
  this.jsf.initializeControl(this);
@@ -7472,7 +7507,9 @@ class InputComponent {
7472
7507
  [id]="'control' + layoutNode()?._id"
7473
7508
  [name]="controlName"
7474
7509
  [readonly]="options?.readonly ? 'readonly' : null"
7475
- [type]="layoutNode()?.type">
7510
+ [type]="layoutNode()?.type"
7511
+ [attributes]="inputAttributes"
7512
+ >
7476
7513
  <input *ngIf="!boundControl"
7477
7514
  [attr.aria-describedby]="'control' + layoutNode()?._id + 'Status'"
7478
7515
  [attr.list]="'control' + layoutNode()?._id + 'Autocomplete'"
@@ -7488,12 +7525,14 @@ class InputComponent {
7488
7525
  [readonly]="options?.readonly ? 'readonly' : null"
7489
7526
  [type]="layoutNode()?.type"
7490
7527
  [value]="controlValue"
7491
- (input)="updateValue($event)">
7528
+ (input)="updateValue($event)"
7529
+ [attributes]="inputAttributes"
7530
+ >
7492
7531
  <datalist *ngIf="options?.typeahead?.source"
7493
7532
  [id]="'control' + layoutNode()?._id + 'Autocomplete'">
7494
7533
  <option *ngFor="let word of options?.typeahead?.source" [value]="word">
7495
7534
  </datalist>
7496
- </div>`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }] }); }
7535
+ </div>`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: ElementAttributeDirective, selector: "[attributes]", inputs: ["attributes"] }] }); }
7497
7536
  }
7498
7537
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: InputComponent, decorators: [{
7499
7538
  type: Component,
@@ -7520,7 +7559,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
7520
7559
  [id]="'control' + layoutNode()?._id"
7521
7560
  [name]="controlName"
7522
7561
  [readonly]="options?.readonly ? 'readonly' : null"
7523
- [type]="layoutNode()?.type">
7562
+ [type]="layoutNode()?.type"
7563
+ [attributes]="inputAttributes"
7564
+ >
7524
7565
  <input *ngIf="!boundControl"
7525
7566
  [attr.aria-describedby]="'control' + layoutNode()?._id + 'Status'"
7526
7567
  [attr.list]="'control' + layoutNode()?._id + 'Autocomplete'"
@@ -7536,7 +7577,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
7536
7577
  [readonly]="options?.readonly ? 'readonly' : null"
7537
7578
  [type]="layoutNode()?.type"
7538
7579
  [value]="controlValue"
7539
- (input)="updateValue($event)">
7580
+ (input)="updateValue($event)"
7581
+ [attributes]="inputAttributes"
7582
+ >
7540
7583
  <datalist *ngIf="options?.typeahead?.source"
7541
7584
  [id]="'control' + layoutNode()?._id + 'Autocomplete'">
7542
7585
  <option *ngFor="let word of options?.typeahead?.source" [value]="word">
@@ -7892,7 +7935,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
7892
7935
 
7893
7936
  class SelectFrameworkComponent {
7894
7937
  constructor() {
7895
- this.componentFactory = inject(ComponentFactoryResolver);
7896
7938
  this.jsf = inject(JsonSchemaFormService);
7897
7939
  this.newComponent = null;
7898
7940
  this.layoutNode = input(undefined);
@@ -7909,7 +7951,7 @@ class SelectFrameworkComponent {
7909
7951
  updateComponent() {
7910
7952
  const widgetContainer = this.widgetContainer();
7911
7953
  if (widgetContainer && !this.newComponent && this.jsf.framework) {
7912
- this.newComponent = widgetContainer.createComponent(this.componentFactory.resolveComponentFactory(this.jsf.framework));
7954
+ this.newComponent = widgetContainer.createComponent((this.jsf.framework));
7913
7955
  //TODO fix all deprecated calls and test
7914
7956
  //this.widgetContainer.createComponent<any>(this.jsf.framework)
7915
7957
  }
@@ -8452,7 +8494,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
8452
8494
 
8453
8495
  class SelectWidgetComponent {
8454
8496
  constructor() {
8455
- this.componentFactory = inject(ComponentFactoryResolver);
8456
8497
  this.jsf = inject(JsonSchemaFormService);
8457
8498
  this.newComponent = null;
8458
8499
  this.layoutNode = input(undefined);
@@ -8469,7 +8510,7 @@ class SelectWidgetComponent {
8469
8510
  updateComponent() {
8470
8511
  const widgetContainer = this.widgetContainer();
8471
8512
  if (widgetContainer && !this.newComponent && (this.layoutNode() || {}).widget) {
8472
- this.newComponent = widgetContainer.createComponent(this.componentFactory.resolveComponentFactory(this.layoutNode().widget));
8513
+ this.newComponent = widgetContainer.createComponent((this.layoutNode().widget));
8473
8514
  }
8474
8515
  if (this.newComponent) {
8475
8516
  for (const input of ['layoutNode', 'layoutIndex', 'dataIndex']) {
@@ -8669,7 +8710,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
8669
8710
 
8670
8711
  class TemplateComponent {
8671
8712
  constructor() {
8672
- this.componentFactory = inject(ComponentFactoryResolver);
8673
8713
  this.jsf = inject(JsonSchemaFormService);
8674
8714
  this.newComponent = null;
8675
8715
  this.layoutNode = input(undefined);
@@ -8687,7 +8727,7 @@ class TemplateComponent {
8687
8727
  const layoutNode = this.layoutNode();
8688
8728
  const widgetContainer = this.widgetContainer();
8689
8729
  if (widgetContainer && !this.newComponent && layoutNode.options.template) {
8690
- this.newComponent = widgetContainer.createComponent(this.componentFactory.resolveComponentFactory(layoutNode.options.template));
8730
+ this.newComponent = widgetContainer.createComponent((layoutNode.options.template));
8691
8731
  }
8692
8732
  if (this.newComponent) {
8693
8733
  for (const input of ['layoutNode', 'layoutIndex', 'dataIndex']) {
@@ -9385,7 +9425,7 @@ class JsonSchemaFormComponent {
9385
9425
  }
9386
9426
  // Get names of changed inputs
9387
9427
  let changedInput = Object.keys(this.previousInputs)
9388
- .filter(input => this.previousInputs[input] !== this[input]);
9428
+ .filter(input => this.previousInputs[input] !== this.getInputValue(input));
9389
9429
  let resetFirst = true;
9390
9430
  if (changedInput.length === 1 && changedInput[0] === 'form' &&
9391
9431
  this.formValuesInput.startsWith('form.')) {
@@ -9398,12 +9438,13 @@ class JsonSchemaFormComponent {
9398
9438
  // If only input values have changed, update the form values
9399
9439
  if (changedInput.length === 1 && changedInput[0] === this.formValuesInput) {
9400
9440
  if (this.formValuesInput.indexOf('.') === -1) {
9401
- changedData = this[this.formValuesInput];
9441
+ changedData = this.getInputValue(this.formValuesInput);
9442
+ //this[this.formValuesInput];
9402
9443
  this.setFormValues(changedData, resetFirst);
9403
9444
  }
9404
9445
  else {
9405
9446
  const [input, key] = this.formValuesInput.split('.');
9406
- changedData = this[input][key];
9447
+ changedData = this.getInputValue(input)[key];
9407
9448
  this.setFormValues(changedData, resetFirst);
9408
9449
  }
9409
9450
  // If anything else has changed, re-render the entire form
@@ -9424,7 +9465,7 @@ class JsonSchemaFormComponent {
9424
9465
  }
9425
9466
  // Update previous inputs
9426
9467
  Object.keys(this.previousInputs)
9427
- .filter(input => this.previousInputs[input] !== this[input])
9468
+ .filter(input => this.previousInputs[input] !== this.getInputValue(input))
9428
9469
  .forEach(input => this.previousInputs[input] = this.getInputValue(input));
9429
9470
  }
9430
9471
  }
@@ -10049,15 +10090,15 @@ const BASIC_WIDGETS = [
10049
10090
 
10050
10091
  class WidgetLibraryModule {
10051
10092
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: WidgetLibraryModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
10052
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.4", ngImport: i0, type: WidgetLibraryModule, declarations: [AddReferenceComponent, OneOfComponent, ButtonComponent, CheckboxComponent, CheckboxesComponent, FileComponent, HiddenComponent, InputComponent, MessageComponent, NoneComponent, NumberComponent, RadiosComponent, RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent, TemplateComponent, TextareaComponent, OrderableDirective], imports: [CommonModule, FormsModule, ReactiveFormsModule], exports: [AddReferenceComponent, OneOfComponent, ButtonComponent, CheckboxComponent, CheckboxesComponent, FileComponent, HiddenComponent, InputComponent, MessageComponent, NoneComponent, NumberComponent, RadiosComponent, RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent, TemplateComponent, TextareaComponent, OrderableDirective] }); }
10093
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.4", ngImport: i0, type: WidgetLibraryModule, declarations: [AddReferenceComponent, OneOfComponent, ButtonComponent, CheckboxComponent, CheckboxesComponent, FileComponent, HiddenComponent, InputComponent, MessageComponent, NoneComponent, NumberComponent, RadiosComponent, RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent, TemplateComponent, TextareaComponent, OrderableDirective, ElementAttributeDirective], imports: [CommonModule, FormsModule, ReactiveFormsModule], exports: [AddReferenceComponent, OneOfComponent, ButtonComponent, CheckboxComponent, CheckboxesComponent, FileComponent, HiddenComponent, InputComponent, MessageComponent, NoneComponent, NumberComponent, RadiosComponent, RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent, TemplateComponent, TextareaComponent, OrderableDirective, ElementAttributeDirective] }); }
10053
10094
  static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: WidgetLibraryModule, imports: [CommonModule, FormsModule, ReactiveFormsModule] }); }
10054
10095
  }
10055
10096
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImport: i0, type: WidgetLibraryModule, decorators: [{
10056
10097
  type: NgModule,
10057
10098
  args: [{
10058
10099
  imports: [CommonModule, FormsModule, ReactiveFormsModule],
10059
- declarations: [...BASIC_WIDGETS, OrderableDirective],
10060
- exports: [...BASIC_WIDGETS, OrderableDirective]
10100
+ declarations: [...BASIC_WIDGETS, OrderableDirective, ElementAttributeDirective],
10101
+ exports: [...BASIC_WIDGETS, OrderableDirective, ElementAttributeDirective]
10061
10102
  }]
10062
10103
  }] });
10063
10104
 
@@ -10108,5 +10149,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.4", ngImpor
10108
10149
  * Generated bundle index. Do not edit.
10109
10150
  */
10110
10151
 
10111
- export { AddReferenceComponent, BASIC_WIDGETS, ButtonComponent, CheckboxComponent, CheckboxesComponent, FileComponent, Framework, FrameworkLibraryService, HiddenComponent, InputComponent, JsonPointer, JsonSchemaFormComponent, JsonSchemaFormModule, JsonSchemaFormService, JsonValidators, MessageComponent, NoneComponent, NumberComponent, OneOfComponent, OrderableDirective, RadiosComponent, RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent, TemplateComponent, TextareaComponent, WidgetLibraryModule, WidgetLibraryService, _executeAsyncValidators, _executeValidators, _mergeErrors, _mergeObjects, _toPromise, addClasses, buildFormGroup, buildFormGroupTemplate, buildLayout, buildLayoutFromSchema, buildSchemaFromData, buildSchemaFromLayout, buildTitleMap, checkInlineType, combineAllOf, commonItems, convertSchemaToDraft6, copy, deValidationMessages, enValidationMessages, esValidationMessages, fixRequiredArrayProperties, fixTitle, forEach, forEachCopy, formatFormData, frValidationMessages, getControl, getControlValidators, getFromSchema, getInputType, getLayoutNode, getSubSchema, getTitleMapFromOneOf, getType, hasOwn, hasValue, inArray, isArray, isBoolean, isDate, isDefined, isEmpty, isFunction, isInputRequired, isInteger, isMap, isNumber, isObject, isObservable, isPrimitive, isPromise, isSet, isString, isType, itValidationMessages, mapLayout, mergeFilteredObject, mergeSchemas, ptValidationMessages, removeRecursiveReferences, resolveSchemaReferences, setRequiredFields, toJavaScriptType, toObservable, toSchemaType, toTitleCase, uniqueItems, updateInputOptions, xor, zhValidationMessages };
10152
+ export { AddReferenceComponent, BASIC_WIDGETS, ButtonComponent, CheckboxComponent, CheckboxesComponent, ElementAttributeDirective, FileComponent, Framework, FrameworkLibraryService, HiddenComponent, InputComponent, JsonPointer, JsonSchemaFormComponent, JsonSchemaFormModule, JsonSchemaFormService, JsonValidators, MessageComponent, NoneComponent, NumberComponent, OneOfComponent, OrderableDirective, RadiosComponent, RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent, TemplateComponent, TextareaComponent, WidgetLibraryModule, WidgetLibraryService, _executeAsyncValidators, _executeValidators, _mergeErrors, _mergeObjects, _toPromise, addClasses, buildFormGroup, buildFormGroupTemplate, buildLayout, buildLayoutFromSchema, buildSchemaFromData, buildSchemaFromLayout, buildTitleMap, checkInlineType, combineAllOf, commonItems, convertSchemaToDraft6, copy, deValidationMessages, enValidationMessages, esValidationMessages, fixRequiredArrayProperties, fixTitle, forEach, forEachCopy, formatFormData, frValidationMessages, getControl, getControlValidators, getFromSchema, getInputType, getLayoutNode, getSubSchema, getTitleMapFromOneOf, getType, hasOwn, hasValue, inArray, isArray, isBoolean, isDate, isDefined, isEmpty, isFunction, isInputRequired, isInteger, isMap, isNumber, isObject, isObservable, isPrimitive, isPromise, isSet, isString, isType, itValidationMessages, mapLayout, mergeFilteredObject, mergeSchemas, ptValidationMessages, removeRecursiveReferences, resolveSchemaReferences, setRequiredFields, toJavaScriptType, toObservable, toSchemaType, toTitleCase, uniqueItems, updateInputOptions, xor, zhValidationMessages };
10112
10153
  //# sourceMappingURL=ng-formworks-core.mjs.map