@ng-formworks/core 17.6.7 → 17.6.9

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.
Files changed (27) hide show
  1. package/esm2022/lib/json-schema-form.component.mjs +27 -6
  2. package/esm2022/lib/json-schema-form.service.mjs +62 -4
  3. package/esm2022/lib/shared/json-schema.functions.mjs +2 -9
  4. package/esm2022/lib/shared/layout.functions.mjs +15 -5
  5. package/esm2022/lib/shared/utility.functions.mjs +44 -1
  6. package/esm2022/lib/widget-library/add-reference.component.mjs +3 -3
  7. package/esm2022/lib/widget-library/index.mjs +4 -2
  8. package/esm2022/lib/widget-library/input.component.mjs +7 -2
  9. package/esm2022/lib/widget-library/item-title.component.mjs +43 -0
  10. package/esm2022/lib/widget-library/number.component.mjs +5 -2
  11. package/esm2022/lib/widget-library/root.component.mjs +12 -4
  12. package/esm2022/lib/widget-library/tabs.component.mjs +15 -2
  13. package/esm2022/lib/widget-library/textarea.component.mjs +5 -2
  14. package/esm2022/lib/widget-library/widget-library.module.mjs +3 -2
  15. package/fesm2022/ng-formworks-core.mjs +225 -29
  16. package/fesm2022/ng-formworks-core.mjs.map +1 -1
  17. package/lib/json-schema-form.component.d.ts +1 -1
  18. package/lib/json-schema-form.service.d.ts +1 -0
  19. package/lib/shared/layout.functions.d.ts +1 -0
  20. package/lib/shared/utility.functions.d.ts +15 -0
  21. package/lib/shared/validator.functions.d.ts +1 -1
  22. package/lib/widget-library/index.d.ts +3 -1
  23. package/lib/widget-library/item-title.component.d.ts +19 -0
  24. package/lib/widget-library/root.component.d.ts +1 -0
  25. package/lib/widget-library/tabs.component.d.ts +6 -2
  26. package/lib/widget-library/widget-library.module.d.ts +8 -7
  27. package/package.json +1 -1
@@ -9,6 +9,7 @@ import Ajv2019 from 'ajv/dist/2019';
9
9
  import jsonDraft6 from 'ajv/lib/refs/json-schema-draft-06.json';
10
10
  import jsonDraft7 from 'ajv/lib/refs/json-schema-draft-07.json';
11
11
  import cloneDeep from 'lodash/cloneDeep';
12
+ import _isArray from 'lodash/isArray';
12
13
  import { from, Observable, forkJoin, Subject, BehaviorSubject, lastValueFrom } from 'rxjs';
13
14
  import { some, isNil, isEmpty as isEmpty$1, pick, isObject as isObject$1, isEqual as isEqual$2, memoize } from 'lodash';
14
15
  import isEqual$1 from 'lodash/isEqual';
@@ -16,7 +17,6 @@ import { map, takeUntil } from 'rxjs/operators';
16
17
  import omit from 'lodash/omit';
17
18
  import filter from 'lodash/filter';
18
19
  import map$1 from 'lodash/map';
19
- import _isArray from 'lodash/isArray';
20
20
  import _isPlainObject from 'lodash/isPlainObject';
21
21
  import uniqueId from 'lodash/uniqueId';
22
22
  import * as i2$1 from '@angular/cdk/drag-drop';
@@ -1457,6 +1457,49 @@ function hasNonNullValue(obj) {
1457
1457
  return !isNil(value);
1458
1458
  });
1459
1459
  }
1460
+ /**
1461
+ * Recursively compares array sizes of nested arrays
1462
+ *
1463
+ * @param obj1 - The object to check.
1464
+ * @param obj2 - The object to check.
1465
+ * @returns `false` if at least one nested array size mismatches`.
1466
+ *
1467
+ * @example
1468
+ * const obj1 = { a: ['a','aa'], b:{c:[1,11,11]} };
1469
+ * const obj2 = { a: ['ee','dd'], b:{c:[2]} };
1470
+ *
1471
+ * console.log(compareObjectArraySizes(obj1,obj1)); // Output: false
1472
+ * mismatch will be on path b/c
1473
+ */
1474
+ function compareObjectArraySizes(obj1, obj2, comparePath = "") {
1475
+ if (isArray(obj1) && isArray(obj2)) {
1476
+ if (obj1.length != obj2.length) {
1477
+ console.log(`size mismatch at ${comparePath}`);
1478
+ return false; // immediately return false on mismatch
1479
+ }
1480
+ else {
1481
+ for (let ind = 0; ind < obj1.length; ind++) {
1482
+ const item1 = obj1[ind];
1483
+ const item2 = obj2[ind];
1484
+ const result = compareObjectArraySizes(item1, item2, `${comparePath}/${ind}`);
1485
+ if (result === false) {
1486
+ return false; // propagate false if mismatch is found
1487
+ }
1488
+ }
1489
+ }
1490
+ }
1491
+ if (isObject(obj1) && !isArray(obj1)) {
1492
+ for (let key in obj1) {
1493
+ if (obj2.hasOwnProperty(key)) {
1494
+ const result = compareObjectArraySizes(obj1[key], obj2[key], `${comparePath}/${key}`);
1495
+ if (result === false) {
1496
+ return false; // propagate false if mismatch is found
1497
+ }
1498
+ }
1499
+ }
1500
+ }
1501
+ return true; // all checks passed
1502
+ }
1460
1503
 
1461
1504
  class JsonPointer {
1462
1505
  /**
@@ -4643,14 +4686,7 @@ function convertJSONSchemaIfToCondition(schema, layoutNode, negate = false) {
4643
4686
  .join("")
4644
4687
  : "";
4645
4688
  let modelPath = parentPath ? `model.${parentPath}` : "model";
4646
- let checkPath = modelPath.split('.')
4647
- .map((_, index, array) => {
4648
- return array.slice(0, index + 1).join('.'); // Build each part of the path dynamically
4649
- }).join(' && '); // Join the parts with '&&'
4650
- // .reduce((accumulator, currentPart, index) => {
4651
- // const currentExpression = index === 0 ? currentPart : `${accumulator}.${currentPart}`;
4652
- // return index === 0 ? currentExpression : `${accumulator} && ${currentExpression}`;
4653
- // }, '');
4689
+ let checkPath = modelPath.replace(/\[/g, ".[").split('.').join("?.");
4654
4690
  if (schema.if) {
4655
4691
  Object.keys(schema.if.properties).forEach((ifProp, ind) => {
4656
4692
  let amper = ind > 0 ? "&" : "";
@@ -6201,7 +6237,7 @@ function buildLayout_original(jsf, widgetLibrary) {
6201
6237
  return formLayout;
6202
6238
  }
6203
6239
  //TODO-review:this implements a quick 'post' fix rather than an
6204
- //integrared ideal fix
6240
+ //integrated ideal fix
6205
6241
  function buildLayout(jsf, widgetLibrary) {
6206
6242
  let layout = buildLayout_original(jsf, widgetLibrary);
6207
6243
  if (jsf.formValues) {
@@ -6313,11 +6349,21 @@ function fixNestedArrayLayout(options) {
6313
6349
  : cloneDeep(builtLayout.items[0]); //copy first
6314
6350
  newItem._id = uniqueId("new_");
6315
6351
  builtLayout.items.unshift(newItem);
6352
+ // builtLayout.items=[newItem, ...builtLayout.items];
6316
6353
  }
6317
- if (builtLayout.options.listItems) {
6318
- builtLayout.options.listItems = numDataItems;
6354
+ }
6355
+ else if (numActualItems > numDataItems) {
6356
+ let numItemsToRemove = numActualItems - numDataItems;
6357
+ for (let i = 0; i < numItemsToRemove; i++) {
6358
+ builtLayout.items.pop();
6359
+ //builtLayout.items=builtLayout.items.slice(0, -1);
6360
+ //builtLayout.items.slice(0, -1);
6319
6361
  }
6320
6362
  }
6363
+ if (builtLayout.options.listItems) {
6364
+ builtLayout.options.listItems = numDataItems;
6365
+ }
6366
+ //builtLayout.items=[...builtLayout.items];
6321
6367
  indices[builtLayout.dataPointer] = indices[builtLayout.dataPointer] || -1;
6322
6368
  indexPos++;
6323
6369
  builtLayout.items.forEach((item, index) => {
@@ -7689,7 +7735,7 @@ class JsonSchemaFormService {
7689
7735
  // Set values of any related controls in copyValueTo array
7690
7736
  if (isArray(ctx.options.copyValueTo)) {
7691
7737
  for (const item of ctx.options.copyValueTo) {
7692
- const targetControl = getControl(this.formGroup, item);
7738
+ const targetControl = this.formGroup && getControl(this.formGroup, item);
7693
7739
  if (isObject(targetControl) &&
7694
7740
  typeof targetControl.setValue === 'function') {
7695
7741
  targetControl.setValue(value);
@@ -7764,7 +7810,8 @@ class JsonSchemaFormService {
7764
7810
  getFormControlValue(ctx) {
7765
7811
  if (!ctx || !ctx.layoutNode ||
7766
7812
  !isDefined(ctx.layoutNode().dataPointer) ||
7767
- ctx.layoutNode().type === '$ref') {
7813
+ ctx.layoutNode().type === '$ref'
7814
+ || this.formGroup == null) {
7768
7815
  return null;
7769
7816
  }
7770
7817
  const schemaPointer = ctx.layoutNode()?.isITEItem ? ctx.layoutNode()?.schemaPointer : null;
@@ -7774,7 +7821,7 @@ class JsonSchemaFormService {
7774
7821
  return control ? control.value : null;
7775
7822
  }
7776
7823
  getFormControlGroup(ctx) {
7777
- if (!ctx || !ctx.layoutNode || !isDefined(ctx.layoutNode().dataPointer)) {
7824
+ if (!ctx || !ctx.layoutNode || !isDefined(ctx.layoutNode().dataPointer) || this.formGroup == null) {
7778
7825
  return null;
7779
7826
  }
7780
7827
  const schemaPointer = ctx.layoutNode()?.isITEItem ? ctx.layoutNode()?.schemaPointer : null;
@@ -7902,6 +7949,62 @@ class JsonSchemaFormService {
7902
7949
  JsonPointer.remove(this.layout, this.getLayoutPointer(ctx));
7903
7950
  return true;
7904
7951
  }
7952
+ //TODO fix-doesnt seem to work for nested array
7953
+ adjustLayout(layout, newData, currLayoutIndex = [0], currDataIndex = []) {
7954
+ const createWidgetCtx = (layoutNode, layoutIndex, dataIndex) => {
7955
+ return {
7956
+ layoutNode: () => { return layoutNode; },
7957
+ layoutIndex: () => { return layoutIndex; },
7958
+ dataIndex: () => { return dataIndex; },
7959
+ };
7960
+ };
7961
+ // console.log(`adjustLayout currLayoutIndex:${currLayoutIndex}`);
7962
+ if (layout.items && _isArray(newData)) {
7963
+ let ctx = createWidgetCtx({
7964
+ ...layout,
7965
+ $ref: layout.$ref || layout.items[0]?.dataPointer,
7966
+ dataPointer: layout.items[0]?.dataPointer,
7967
+ arrayItem: true,
7968
+ arrayItemType: "list"
7969
+ }, [...currLayoutIndex.slice(0, currLayoutIndex.length - 1), layout.items.length - 1], [...currDataIndex.slice(0, currDataIndex.length - 1), layout.items.length - 1]);
7970
+ const lengthDifference = newData.length - layout.items.filter(litem => {
7971
+ return litem?.type != "$ref";
7972
+ }).length;
7973
+ if (lengthDifference > 0) {
7974
+ // Add missing controls if newData has more items
7975
+ for (let i = 0; i < lengthDifference; i++) {
7976
+ this.addItem(ctx);
7977
+ }
7978
+ }
7979
+ else if (lengthDifference < 0) {
7980
+ let numToRemove = layout.items.filter(litem => {
7981
+ return litem?.type != "$ref";
7982
+ })
7983
+ .length - newData.length;
7984
+ // Remove extra controls if newData has fewer items
7985
+ for (let i = 0; i < numToRemove; i++) {
7986
+ let oldDataIndex = ctx.dataIndex();
7987
+ let lastDataIndex = oldDataIndex[oldDataIndex.length - 1];
7988
+ let updatedLayoutIndex = [...currLayoutIndex.slice(0, currLayoutIndex.length - 1), 0];
7989
+ let updatedDataIndex = [...oldDataIndex.slice(0, oldDataIndex.length - 1), 0];
7990
+ ctx = createWidgetCtx(ctx.layoutNode(), updatedLayoutIndex, updatedDataIndex);
7991
+ let removed = this.removeItem(ctx);
7992
+ // if(removed){
7993
+ //}
7994
+ }
7995
+ }
7996
+ return;
7997
+ }
7998
+ if (_isArray(layout)) {
7999
+ layout.forEach((layoutNode, ind) => {
8000
+ //if(layoutNode.items){
8001
+ let layoutMappedData = layoutNode.dataPointer ? JsonPointer.get(newData, layoutNode.dataPointer)
8002
+ : undefined;
8003
+ this.adjustLayout(layoutNode, layoutMappedData, [...currLayoutIndex, ind], [...currDataIndex, ind]);
8004
+ ///}
8005
+ });
8006
+ }
8007
+ }
7905
8008
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: JsonSchemaFormService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
7906
8009
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: JsonSchemaFormService }); }
7907
8010
  }
@@ -8072,8 +8175,8 @@ class AddReferenceComponent {
8072
8175
  layoutIndex: this.layoutIndex().slice(0, -1),
8073
8176
  layoutNode: this.jsf.getParentNode(this)
8074
8177
  };
8075
- return parent.layoutNode.add ||
8076
- this.jsf.setArrayItemTitle(parent, this.layoutNode(), this.itemCount);
8178
+ return parent.layoutNode && (parent.layoutNode.add ||
8179
+ this.jsf.setArrayItemTitle(parent, this.layoutNode(), this.itemCount));
8077
8180
  }
8078
8181
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AddReferenceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
8079
8182
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "17.3.12", type: AddReferenceComponent, selector: "add-reference-widget", inputs: { layoutNode: { classPropertyName: "layoutNode", publicName: "layoutNode", isSignal: true, isRequired: false, transformFunction: null }, layoutIndex: { classPropertyName: "layoutIndex", publicName: "layoutIndex", isSignal: true, isRequired: false, transformFunction: null }, dataIndex: { classPropertyName: "dataIndex", publicName: "dataIndex", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
@@ -8540,7 +8643,12 @@ class InputComponent {
8540
8643
  this.jsf.updateValue(this, event.target.value);
8541
8644
  }
8542
8645
  ngOnDestroy() {
8543
- this.jsf.updateValue(this, null);
8646
+ //needed to be done in timeout for when dynamic/condition based
8647
+ //titles depend on the formControls value but the formControl
8648
+ //is also destroyed
8649
+ setTimeout(() => {
8650
+ this.jsf.updateValue(this, null);
8651
+ });
8544
8652
  }
8545
8653
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: InputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
8546
8654
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "17.3.12", type: InputComponent, selector: "input-widget", inputs: { layoutNode: { classPropertyName: "layoutNode", publicName: "layoutNode", isSignal: true, isRequired: false, transformFunction: null }, layoutIndex: { classPropertyName: "layoutIndex", publicName: "layoutIndex", isSignal: true, isRequired: false, transformFunction: null }, dataIndex: { classPropertyName: "dataIndex", publicName: "dataIndex", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
@@ -8648,6 +8756,46 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
8648
8756
  }]
8649
8757
  }] });
8650
8758
 
8759
+ // item-title.component.ts
8760
+ class ItemTitleComponent {
8761
+ constructor(jsf) {
8762
+ this.jsf = jsf;
8763
+ }
8764
+ ngOnChanges(changes) {
8765
+ this.updateTitle();
8766
+ }
8767
+ ngOnInit() {
8768
+ // Calculate the title once on init, or subscribe to changes here
8769
+ this.updateTitle();
8770
+ this.dataChangesSubs = this.jsf.dataChanges.subscribe((val) => {
8771
+ this.updateTitle();
8772
+ });
8773
+ }
8774
+ updateTitle() {
8775
+ this.title = this.jsf.setArrayItemTitle(this.ctx, this.item, this.index);
8776
+ }
8777
+ ngOnDestroy() {
8778
+ this.dataChangesSubs?.unsubscribe();
8779
+ }
8780
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ItemTitleComponent, deps: [{ token: JsonSchemaFormService }], target: i0.ɵɵFactoryTarget.Component }); }
8781
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: ItemTitleComponent, selector: "item-title", inputs: { item: "item", index: "index", ctx: "ctx" }, usesOnChanges: true, ngImport: i0, template: `<div>{{ title }}</div>`, isInline: true }); }
8782
+ }
8783
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ItemTitleComponent, decorators: [{
8784
+ type: Component,
8785
+ args: [{
8786
+ selector: 'item-title',
8787
+ template: `<div>{{ title }}</div>`,
8788
+ standalone: false
8789
+ // Consider using ChangeDetectionStrategy.OnPush here for maximum efficiency
8790
+ }]
8791
+ }], ctorParameters: () => [{ type: JsonSchemaFormService }], propDecorators: { item: [{
8792
+ type: Input
8793
+ }], index: [{
8794
+ type: Input
8795
+ }], ctx: [{
8796
+ type: Input
8797
+ }] } });
8798
+
8651
8799
  class MessageComponent {
8652
8800
  constructor() {
8653
8801
  this.jsf = inject(JsonSchemaFormService);
@@ -8726,7 +8874,10 @@ class NumberComponent {
8726
8874
  this.jsf.updateValue(this, event.target.value);
8727
8875
  }
8728
8876
  ngOnDestroy() {
8729
- this.jsf.updateValue(this, null);
8877
+ //see cpmments in input component
8878
+ setTimeout(() => {
8879
+ this.jsf.updateValue(this, null);
8880
+ });
8730
8881
  }
8731
8882
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NumberComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
8732
8883
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "17.3.12", type: NumberComponent, selector: "number-widget", inputs: { layoutNode: { classPropertyName: "layoutNode", publicName: "layoutNode", isSignal: true, isRequired: false, transformFunction: null }, layoutIndex: { classPropertyName: "layoutIndex", publicName: "layoutIndex", isSignal: true, isRequired: false, transformFunction: null }, dataIndex: { classPropertyName: "dataIndex", publicName: "dataIndex", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "inputControl", first: true, predicate: ["inputControl"], descendants: true }, { propertyName: "div", first: true, predicate: ["divElt"], descendants: true }], ngImport: i0, template: `
@@ -8885,6 +9036,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
8885
9036
  class TabsComponent {
8886
9037
  constructor() {
8887
9038
  this.jsf = inject(JsonSchemaFormService);
9039
+ this.cdr = inject(ChangeDetectorRef);
8888
9040
  this.selectedItem = 0;
8889
9041
  this.showAddTab = true;
8890
9042
  this.layoutNode = input(undefined);
@@ -8898,6 +9050,13 @@ class TabsComponent {
8898
9050
  }
8899
9051
  this.itemCount = this.layoutNode().items.length - 1;
8900
9052
  this.updateControl();
9053
+ //TODO review/test-introduced to fix dynamic titles not updating
9054
+ //when their conditional linked field is destroyed
9055
+ //-forces change detection!
9056
+ //-commented out, causing other issues
9057
+ this.dataChangesSubs = this.jsf.dataChanges.subscribe((val) => {
9058
+ //this.cdr.detectChanges();
9059
+ });
8901
9060
  }
8902
9061
  select(index) {
8903
9062
  const layoutNode = this.layoutNode();
@@ -8922,6 +9081,9 @@ class TabsComponent {
8922
9081
  setTabTitle(item, index) {
8923
9082
  return this.jsf.setArrayItemTitle(this, item, index);
8924
9083
  }
9084
+ ngOnDestroy() {
9085
+ this.dataChangesSubs?.unsubscribe();
9086
+ }
8925
9087
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TabsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
8926
9088
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "17.3.12", type: TabsComponent, selector: "tabs-widget", inputs: { layoutNode: { classPropertyName: "layoutNode", publicName: "layoutNode", isSignal: true, isRequired: false, transformFunction: null }, layoutIndex: { classPropertyName: "layoutIndex", publicName: "layoutIndex", isSignal: true, isRequired: false, transformFunction: null }, dataIndex: { classPropertyName: "dataIndex", publicName: "dataIndex", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
8927
9089
  <ul
@@ -8945,6 +9107,7 @@ class TabsComponent {
8945
9107
  />
8946
9108
  {{setTabTitle(item, i)}}
8947
9109
  </a>
9110
+
8948
9111
  </li>
8949
9112
  </ul>
8950
9113
 
@@ -8999,6 +9162,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
8999
9162
  />
9000
9163
  {{setTabTitle(item, i)}}
9001
9164
  </a>
9165
+
9002
9166
  </li>
9003
9167
  </ul>
9004
9168
 
@@ -9292,6 +9456,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9292
9456
  class RootComponent {
9293
9457
  constructor() {
9294
9458
  this.jsf = inject(JsonSchemaFormService);
9459
+ this.cdr = inject(ChangeDetectorRef);
9295
9460
  this.dataIndex = input(undefined);
9296
9461
  this.layoutIndex = input(undefined);
9297
9462
  this.layout = input(undefined);
@@ -9399,6 +9564,8 @@ class RootComponent {
9399
9564
  return this._getSelectFrameworkInputsRaw(layoutItem, i);
9400
9565
  }
9401
9566
  }
9567
+ //TODO investigate-causing layout issue with layout,for now
9568
+ //removed from template
9402
9569
  trackByFn(index, item) {
9403
9570
  return item._id ?? index;
9404
9571
  }
@@ -9414,6 +9581,7 @@ class RootComponent {
9414
9581
  if (changes['layout'] || changes['dataIndex'] || changes['layoutIndex']) {
9415
9582
  // Clear the entire cache of the memoized function
9416
9583
  this._getSelectFrameworkInputsMemoized.cache.clear();
9584
+ this.cdr.markForCheck();
9417
9585
  }
9418
9586
  }
9419
9587
  showWidget(layoutNode) {
@@ -9424,6 +9592,10 @@ class RootComponent {
9424
9592
  this.jsf.dataChanges.subscribe((val) => {
9425
9593
  //this.selectframeworkInputCache?.clear();
9426
9594
  this._getSelectFrameworkInputsMemoized.cache.clear();
9595
+ //TODO-fix for now changed to detectChanges-
9596
+ //used to updated the dynamic titles in tab compnents
9597
+ this.cdr.markForCheck();
9598
+ // this.cdr.detectChanges();-breaks oneOf/ matdatepicker
9427
9599
  });
9428
9600
  }
9429
9601
  }
@@ -9445,7 +9617,7 @@ class RootComponent {
9445
9617
  You must explicitly disable dragging on the main element
9446
9618
  and re-enable it only when using the handle.
9447
9619
  -->
9448
- <div *ngFor="let layoutItem of layout(); let i = index;trackBy: trackByFn"
9620
+ <div *ngFor="let layoutItem of layout(); let i = index;"
9449
9621
  cdkDrag [cdkDragStartDelay]="{touch:1000,mouse:0}"
9450
9622
  [cdkDragDisabled]="!isDraggable(layoutItem)"
9451
9623
  [class.form-flex-item]="isFlexItem()"
@@ -9500,7 +9672,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9500
9672
  You must explicitly disable dragging on the main element
9501
9673
  and re-enable it only when using the handle.
9502
9674
  -->
9503
- <div *ngFor="let layoutItem of layout(); let i = index;trackBy: trackByFn"
9675
+ <div *ngFor="let layoutItem of layout(); let i = index;"
9504
9676
  cdkDrag [cdkDragStartDelay]="{touch:1000,mouse:0}"
9505
9677
  [cdkDragDisabled]="!isDraggable(layoutItem)"
9506
9678
  [class.form-flex-item]="isFlexItem()"
@@ -10096,7 +10268,10 @@ class TextareaComponent {
10096
10268
  this.jsf.updateValue(this, event.target.value);
10097
10269
  }
10098
10270
  ngOnDestroy() {
10099
- this.jsf.updateValue(this, null);
10271
+ //see cpmments in input component
10272
+ setTimeout(() => {
10273
+ this.jsf.updateValue(this, null);
10274
+ });
10100
10275
  }
10101
10276
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: TextareaComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
10102
10277
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "17.3.12", type: TextareaComponent, selector: "textarea-widget", inputs: { layoutNode: { classPropertyName: "layoutNode", publicName: "layoutNode", isSignal: true, isRequired: false, transformFunction: null }, layoutIndex: { classPropertyName: "layoutIndex", publicName: "layoutIndex", isSignal: true, isRequired: false, transformFunction: null }, dataIndex: { classPropertyName: "dataIndex", publicName: "dataIndex", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
@@ -10892,12 +11067,12 @@ const BASIC_WIDGETS = [
10892
11067
  MessageComponent, NoneComponent, NumberComponent, RadiosComponent,
10893
11068
  RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent,
10894
11069
  SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent,
10895
- TemplateComponent, TextareaComponent, SelectCheckboxComponent
11070
+ TemplateComponent, TextareaComponent, SelectCheckboxComponent, ItemTitleComponent
10896
11071
  ];
10897
11072
 
10898
11073
  class WidgetLibraryModule {
10899
11074
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: WidgetLibraryModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
10900
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", 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, SelectCheckboxComponent, OrderableDirective, ElementAttributeDirective, StopPropagationDirective], imports: [CommonModule, FormsModule, ReactiveFormsModule, DragDropModule], exports: [AddReferenceComponent, OneOfComponent, ButtonComponent, CheckboxComponent, CheckboxesComponent, FileComponent, HiddenComponent, InputComponent, MessageComponent, NoneComponent, NumberComponent, RadiosComponent, RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent, TemplateComponent, TextareaComponent, SelectCheckboxComponent, OrderableDirective, ElementAttributeDirective, StopPropagationDirective] }); }
11075
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", 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, SelectCheckboxComponent, ItemTitleComponent, OrderableDirective, ElementAttributeDirective, StopPropagationDirective], imports: [CommonModule, FormsModule, ReactiveFormsModule, DragDropModule], exports: [AddReferenceComponent, OneOfComponent, ButtonComponent, CheckboxComponent, CheckboxesComponent, FileComponent, HiddenComponent, InputComponent, MessageComponent, NoneComponent, NumberComponent, RadiosComponent, RootComponent, SectionComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, SubmitComponent, TabComponent, TabsComponent, TemplateComponent, TextareaComponent, SelectCheckboxComponent, ItemTitleComponent, OrderableDirective, ElementAttributeDirective, StopPropagationDirective] }); }
10901
11076
  static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: WidgetLibraryModule, imports: [CommonModule, FormsModule, ReactiveFormsModule, DragDropModule] }); }
10902
11077
  }
10903
11078
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: WidgetLibraryModule, decorators: [{
@@ -11145,11 +11320,26 @@ class JsonSchemaFormComponent {
11145
11320
  if (this.formValuesInput.indexOf('.') === -1) {
11146
11321
  changedData = this.getInputValue(this.formValuesInput);
11147
11322
  //this[this.formValuesInput];
11148
- this.setFormValues(changedData, resetFirst);
11149
11323
  }
11150
11324
  else {
11151
11325
  const [input, key] = this.formValuesInput.split('.');
11152
11326
  changedData = this.getInputValue(input)[key];
11327
+ }
11328
+ //TODO -review if any of the the array sizes changed then the
11329
+ //layout array sizes need to be resynced to match
11330
+ //-for now jsf.adjustLayout doesnt seem to work with nested arrays
11331
+ //so entire form is reinited
11332
+ let arraySizesChanged = !compareObjectArraySizes(changedData, this.jsf.data);
11333
+ if (arraySizesChanged) {
11334
+ this.initializeForm(changedData);
11335
+ if (this.onChange) {
11336
+ this.onChange(changedData);
11337
+ }
11338
+ if (this.onTouched) {
11339
+ this.onTouched(changedData);
11340
+ }
11341
+ }
11342
+ else {
11153
11343
  this.setFormValues(changedData, resetFirst);
11154
11344
  }
11155
11345
  // If anything else has changed, re-render the entire form
@@ -11174,7 +11364,7 @@ class JsonSchemaFormComponent {
11174
11364
  .forEach(input => this.previousInputs[input] = this.getInputValue(input));
11175
11365
  }
11176
11366
  }
11177
- setFormValues(formValues, resetFirst = true) {
11367
+ setFormValues(formValues, resetFirst = true, emitFormEvent = true, usePatch = true) {
11178
11368
  if (formValues) {
11179
11369
  const newFormValues = this.objectWrap ? formValues['1'] : formValues;
11180
11370
  if (!this.jsf.formGroup) {
@@ -11182,10 +11372,15 @@ class JsonSchemaFormComponent {
11182
11372
  this.activateForm();
11183
11373
  }
11184
11374
  else if (resetFirst) { //changed to avoid reset events
11185
- this.jsf.formGroup.reset({}, { emitEvent: false });
11375
+ this.jsf.formGroup.reset({}, { emitEvent: emitFormEvent });
11186
11376
  }
11187
11377
  if (this.jsf.formGroup) { //changed to avoid reset events
11188
- this.jsf.formGroup.patchValue(newFormValues, { emitEvent: false });
11378
+ if (usePatch) {
11379
+ this.jsf.formGroup.patchValue(newFormValues, { emitEvent: emitFormEvent });
11380
+ }
11381
+ else {
11382
+ this.jsf.formGroup.setValue(newFormValues, { emitEvent: emitFormEvent });
11383
+ }
11189
11384
  }
11190
11385
  if (this.onChange) {
11191
11386
  this.onChange(newFormValues);
@@ -11197,6 +11392,7 @@ class JsonSchemaFormComponent {
11197
11392
  else {
11198
11393
  this.jsf.formGroup.reset();
11199
11394
  }
11395
+ this.changeDetector.markForCheck();
11200
11396
  }
11201
11397
  submitForm() {
11202
11398
  const validData = this.jsf.validData;
@@ -11717,5 +11913,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
11717
11913
  * Generated bundle index. Do not edit.
11718
11914
  */
11719
11915
 
11720
- 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, SelectCheckboxComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, StopPropagationDirective, 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, hasNonNullValue, hasOwn, hasValue, inArray, isArray, isBoolean, isDate, isDefined, isEmpty, isFunction, isInputRequired, isInteger, isMap, isNumber, isObject, isObservable, isPrimitive, isPromise, isSet, isString, isType, itValidationMessages, mapLayout, mergeFilteredObject, mergeSchemas, path2ControlKey, ptValidationMessages, removeRecursiveReferences, resolveSchemaReferences, setControl, setRequiredFields, toJavaScriptType, toObservable, toSchemaType, toTitleCase, uniqueItems, updateInputOptions, xor, zhValidationMessages };
11916
+ export { AddReferenceComponent, BASIC_WIDGETS, ButtonComponent, CheckboxComponent, CheckboxesComponent, ElementAttributeDirective, FileComponent, Framework, FrameworkLibraryService, HiddenComponent, InputComponent, ItemTitleComponent, JsonPointer, JsonSchemaFormComponent, JsonSchemaFormModule, JsonSchemaFormService, JsonValidators, MessageComponent, NoneComponent, NumberComponent, OneOfComponent, OrderableDirective, RadiosComponent, RootComponent, SectionComponent, SelectCheckboxComponent, SelectComponent, SelectFrameworkComponent, SelectWidgetComponent, StopPropagationDirective, 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, hasNonNullValue, hasOwn, hasValue, inArray, isArray, isBoolean, isDate, isDefined, isEmpty, isFunction, isInputRequired, isInteger, isMap, isNumber, isObject, isObservable, isPrimitive, isPromise, isSet, isString, isType, itValidationMessages, mapLayout, mergeFilteredObject, mergeSchemas, path2ControlKey, ptValidationMessages, removeRecursiveReferences, resolveSchemaReferences, setControl, setRequiredFields, toJavaScriptType, toObservable, toSchemaType, toTitleCase, uniqueItems, updateInputOptions, xor, zhValidationMessages };
11721
11917
  //# sourceMappingURL=ng-formworks-core.mjs.map