@acorex/platform 21.0.0-next.71 → 21.0.0-next.72

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 (51) hide show
  1. package/fesm2022/acorex-platform-auth.mjs +10 -2
  2. package/fesm2022/acorex-platform-auth.mjs.map +1 -1
  3. package/fesm2022/{acorex-platform-common-common-settings.provider-Bi1RYif5.mjs → acorex-platform-common-common-settings.provider-Ytey9uhY.mjs} +15 -1
  4. package/fesm2022/acorex-platform-common-common-settings.provider-Ytey9uhY.mjs.map +1 -0
  5. package/fesm2022/acorex-platform-common.mjs +3792 -1679
  6. package/fesm2022/acorex-platform-common.mjs.map +1 -1
  7. package/fesm2022/acorex-platform-core.mjs +1112 -103
  8. package/fesm2022/acorex-platform-core.mjs.map +1 -1
  9. package/fesm2022/acorex-platform-layout-builder.mjs +53 -170
  10. package/fesm2022/acorex-platform-layout-builder.mjs.map +1 -1
  11. package/fesm2022/acorex-platform-layout-components.mjs +70 -46
  12. package/fesm2022/acorex-platform-layout-components.mjs.map +1 -1
  13. package/fesm2022/acorex-platform-layout-designer.mjs +199 -126
  14. package/fesm2022/acorex-platform-layout-designer.mjs.map +1 -1
  15. package/fesm2022/{acorex-platform-layout-entity-attachments-page.component-D8iQnT-R.mjs → acorex-platform-layout-entity-attachments-page.component-B0EkdqvH.mjs} +6 -1
  16. package/fesm2022/acorex-platform-layout-entity-attachments-page.component-B0EkdqvH.mjs.map +1 -0
  17. package/fesm2022/acorex-platform-layout-entity.mjs +341 -418
  18. package/fesm2022/acorex-platform-layout-entity.mjs.map +1 -1
  19. package/fesm2022/acorex-platform-layout-views.mjs +675 -301
  20. package/fesm2022/acorex-platform-layout-views.mjs.map +1 -1
  21. package/fesm2022/acorex-platform-layout-widget-core.mjs +115 -74
  22. package/fesm2022/acorex-platform-layout-widget-core.mjs.map +1 -1
  23. package/fesm2022/{acorex-platform-layout-widgets-tabular-data-edit-popup.component-BcpRkpJp.mjs → acorex-platform-layout-widgets-tabular-data-edit-popup.component-DjpZU6gz.mjs} +2 -2
  24. package/fesm2022/{acorex-platform-layout-widgets-tabular-data-edit-popup.component-BcpRkpJp.mjs.map → acorex-platform-layout-widgets-tabular-data-edit-popup.component-DjpZU6gz.mjs.map} +1 -1
  25. package/fesm2022/{acorex-platform-layout-widgets-tabular-data-view-popup.component-DQtK4lxl.mjs → acorex-platform-layout-widgets-tabular-data-view-popup.component-gX-3Kx9I.mjs} +2 -2
  26. package/fesm2022/{acorex-platform-layout-widgets-tabular-data-view-popup.component-DQtK4lxl.mjs.map → acorex-platform-layout-widgets-tabular-data-view-popup.component-gX-3Kx9I.mjs.map} +1 -1
  27. package/fesm2022/acorex-platform-layout-widgets.mjs +184 -655
  28. package/fesm2022/acorex-platform-layout-widgets.mjs.map +1 -1
  29. package/fesm2022/acorex-platform-themes-default-error-401.component-B1nsdpTY.mjs +48 -0
  30. package/fesm2022/acorex-platform-themes-default-error-401.component-B1nsdpTY.mjs.map +1 -0
  31. package/fesm2022/acorex-platform-themes-default-error-404.component-D4UvRe8u.mjs +42 -0
  32. package/fesm2022/acorex-platform-themes-default-error-404.component-D4UvRe8u.mjs.map +1 -0
  33. package/fesm2022/acorex-platform-themes-default.mjs +76 -32
  34. package/fesm2022/acorex-platform-themes-default.mjs.map +1 -1
  35. package/package.json +1 -1
  36. package/types/acorex-platform-auth.d.ts +2 -0
  37. package/types/acorex-platform-common.d.ts +891 -259
  38. package/types/acorex-platform-core.d.ts +284 -40
  39. package/types/acorex-platform-layout-builder.d.ts +10 -22
  40. package/types/acorex-platform-layout-components.d.ts +9 -7
  41. package/types/acorex-platform-layout-entity.d.ts +37 -41
  42. package/types/acorex-platform-layout-views.d.ts +125 -67
  43. package/types/acorex-platform-layout-widget-core.d.ts +53 -61
  44. package/types/acorex-platform-layout-widgets.d.ts +33 -20
  45. package/types/acorex-platform-themes-default.d.ts +14 -4
  46. package/fesm2022/acorex-platform-common-common-settings.provider-Bi1RYif5.mjs.map +0 -1
  47. package/fesm2022/acorex-platform-layout-entity-attachments-page.component-D8iQnT-R.mjs.map +0 -1
  48. package/fesm2022/acorex-platform-themes-default-error-401.component-C7EYJzSr.mjs +0 -31
  49. package/fesm2022/acorex-platform-themes-default-error-401.component-C7EYJzSr.mjs.map +0 -1
  50. package/fesm2022/acorex-platform-themes-default-error-404.component-7MVLMwIa.mjs +0 -25
  51. package/fesm2022/acorex-platform-themes-default-error-404.component-7MVLMwIa.mjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { signal, computed, Injectable, InjectionToken, inject, ElementRef, effect, untracked, EventEmitter, Injector, ChangeDetectorRef, ViewChild, Input, Output, ChangeDetectionStrategy, Component, input, output, ViewContainerRef, Directive, NgModule } from '@angular/core';
3
3
  import { convertArrayToDataSource, AXDataSource, AX_STYLE_COLOR_TYPES, AX_STYLE_LOOK_TYPES } from '@acorex/cdk/common';
4
- import { AXPContextStore, AXPDataSourceDefinitionProviderService, extractValue, AXPExpressionEvaluatorService, getSmart } from '@acorex/platform/core';
4
+ import { AXPContextStore, isSelectionValueEqual, isFormValueEqual, AXPDataSourceDefinitionProviderService, extractValue, AXPExpressionEvaluatorService, getSmart } from '@acorex/platform/core';
5
5
  export { normalizeDefinitionCategories } from '@acorex/platform/core';
6
6
  import { set, merge, cloneDeep, isNil, get, isEqual, isUndefined, isObjectLike, sum, isEmpty, isString } from 'lodash-es';
7
7
  import { Subject, BehaviorSubject, filter } from 'rxjs';
@@ -65,7 +65,6 @@ class AXPWidgetCoreService {
65
65
  return [AXPPageStatus.Processing, AXPPageStatus.Submitting, AXPPageStatus.Rendering].includes(this.status());
66
66
  }, ...(ngDevMode ? [{ debugName: "isBusy" }] : /* istanbul ignore next */ []));
67
67
  this.registeredWidgetsCount = signal(0, ...(ngDevMode ? [{ debugName: "registeredWidgetsCount" }] : /* istanbul ignore next */ []));
68
- /** Bumped when a widget reports dirty-state changes via `api().isDirty()`. */
69
68
  this.dirtyWidgetsRevision = signal(0, ...(ngDevMode ? [{ debugName: "dirtyWidgetsRevision" }] : /* istanbul ignore next */ []));
70
69
  this.dirtyWidgetsRevisionSignal = this.dirtyWidgetsRevision.asReadonly();
71
70
  }
@@ -81,22 +80,19 @@ class AXPWidgetCoreService {
81
80
  }
82
81
  detectStatus() {
83
82
  const statuses = Array.from(this.widgets.values()).map((c) => c.status());
84
- // Rendering statuses
85
83
  if (statuses.some((status) => status === AXPWidgetStatus.Rendering)) {
86
84
  return AXPPageStatus.Rendering;
87
85
  }
88
86
  if (statuses.every((status) => status === AXPWidgetStatus.Rendered)) {
89
87
  return AXPPageStatus.Rendered;
90
88
  }
91
- // Processing statuses
92
89
  if (statuses.some((status) => status === AXPWidgetStatus.Processing)) {
93
90
  return AXPPageStatus.Processing;
94
91
  }
95
- // Error handling
96
92
  if (statuses.some((status) => status === AXPWidgetStatus.Error)) {
97
93
  return AXPPageStatus.Error;
98
94
  }
99
- return AXPPageStatus.Rendered; // Default to Loaded when all widgets are in a completed state
95
+ return AXPPageStatus.Rendered;
100
96
  }
101
97
  refresh() {
102
98
  setTimeout(() => {
@@ -131,11 +127,6 @@ class AXPWidgetCoreService {
131
127
  getWidget(id) {
132
128
  return this.widgets.get(id);
133
129
  }
134
- /**
135
- * Waits until a widget with the given id is registered, then resolves with it.
136
- * If the widget is already registered, resolves immediately.
137
- * Optionally accepts a timeout (in ms) after which it resolves with undefined.
138
- */
139
130
  async waitForWidget(id, timeoutMs) {
140
131
  const existing = this.widgets.get(id);
141
132
  if (existing) {
@@ -165,28 +156,12 @@ class AXPWidgetCoreService {
165
156
  }
166
157
  });
167
158
  }
168
- /**
169
- * Returns a list of registered widget ids (names).
170
- */
171
159
  listRegisteredWidgetNames() {
172
160
  return Array.from(this.widgets.keys());
173
161
  }
174
- /** Notifies listeners that a widget's composite dirty state may have changed. */
175
162
  notifyWidgetDirtyChanged() {
176
163
  this.dirtyWidgetsRevision.update((value) => value + 1);
177
164
  }
178
- /**
179
- * Returns whether any registered widget reports dirty state via `api().isDirty()`.
180
- */
181
- hasDirtyWidgets() {
182
- for (const widget of this.widgets.values()) {
183
- const isDirty = widget.api()?.['isDirty'];
184
- if (typeof isDirty === 'function' && isDirty()) {
185
- return true;
186
- }
187
- }
188
- return false;
189
- }
190
165
  ngOnDestroy() { }
191
166
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPWidgetCoreService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
192
167
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPWidgetCoreService }); }
@@ -503,7 +478,7 @@ class AXPValueWidgetComponent extends AXPLayoutBaseWidgetComponent {
503
478
  this.detectFullPath();
504
479
  // Set defaultValue if it exists and the path doesn't exist in context
505
480
  if (!isNil(this.defaultValue) && this.fullPath() && !this.contextService.hasValue(this.fullPath())) {
506
- this.setValue(this.defaultValue, { origin: 'system' });
481
+ this.setValue(this.defaultValue);
507
482
  }
508
483
  }
509
484
  //
@@ -516,31 +491,38 @@ class AXPValueWidgetComponent extends AXPLayoutBaseWidgetComponent {
516
491
  }
517
492
  return rawValue;
518
493
  }
519
- setValue(value, options) {
494
+ setValue(value) {
520
495
  if (this.node.valueTransforms?.setter) {
521
496
  value = this.node.valueTransforms?.setter(value);
522
497
  }
498
+ const path = this.fullPath();
499
+ if (!path) {
500
+ return;
501
+ }
523
502
  const oldValue = this.getValue();
524
503
  value = isUndefined(value) ? null : value;
525
504
  if (isNil(value) && isNil(oldValue)) {
526
505
  return;
527
506
  }
507
+ const savedAtPath = this.contextService.getSavedValue(path);
508
+ if (this.contextService.isSavedCommitted() &&
509
+ isSelectionValueEqual(value, savedAtPath) &&
510
+ !isEqual(oldValue, savedAtPath)) {
511
+ this.contextService.update(path, cloneDeep(savedAtPath));
512
+ this.onValueChanged.next({ sender: this });
513
+ return;
514
+ }
528
515
  // Reordered arrays must persist even when items are deep-equal (e.g. empty row objects).
529
516
  const isArrayReorder = Array.isArray(oldValue) &&
530
517
  Array.isArray(value) &&
531
518
  oldValue.length === value.length &&
532
519
  oldValue.some((v, i) => v !== value[i]);
533
- if (!isArrayReorder && isEqual(oldValue, value)) {
520
+ const isArrayLengthChange = Array.isArray(value) && (!Array.isArray(oldValue) || value.length !== oldValue.length);
521
+ if (!isArrayReorder && !isArrayLengthChange && isFormValueEqual(oldValue, value)) {
534
522
  return;
535
523
  }
536
- if (this.fullPath()) {
537
- this.contextService.update(this.fullPath(), value, { origin: options?.origin ?? 'user' });
538
- this.onValueChanged.next({ sender: this });
539
- }
540
- }
541
- /** Persists a user-initiated value change into the shared context store. */
542
- setUserValue(value) {
543
- this.setValue(value, { origin: 'user' });
524
+ this.contextService.update(path, value);
525
+ this.onValueChanged.next({ sender: this });
544
526
  }
545
527
  detectFullPath() {
546
528
  const sections = [];
@@ -578,7 +560,7 @@ class AXPValueWidgetComponent extends AXPLayoutBaseWidgetComponent {
578
560
  }
579
561
  handleValueChanged(e) {
580
562
  if (e.isUserInteraction) {
581
- this.setUserValue(e.value);
563
+ this.setValue(e.value);
582
564
  }
583
565
  }
584
566
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPValueWidgetComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
@@ -1672,13 +1654,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
1672
1654
  args: ['header']
1673
1655
  }] } });
1674
1656
 
1657
+ /** Idle period after widgets register / hydrate before committing the saved baseline. */
1658
+ const FORM_SAVED_BASELINE_IDLE_MS = 500;
1675
1659
  class AXPWidgetContainerComponent {
1676
1660
  set context(value) {
1677
- // Parent re-binds the same context after widget-driven updates; avoid reset() clearing dirty paths.
1678
- if (isEqual(this.contextService.data(), value)) {
1679
- return;
1680
- }
1681
- this.contextService.set(value);
1661
+ this.syncExternalContext(value);
1682
1662
  }
1683
1663
  set functions(v) {
1684
1664
  this.builderService.setFunctions(v);
@@ -1687,25 +1667,38 @@ class AXPWidgetContainerComponent {
1687
1667
  this.contextService = inject(AXPContextStore);
1688
1668
  this.builderService = inject(AXPWidgetCoreService);
1689
1669
  this.onContextChanged = new EventEmitter();
1690
- /** True when user-edited context paths or composite widgets report dirty state. */
1670
+ this.isSavedCommitted = computed(() => this.contextService.isSavedCommitted(), ...(ngDevMode ? [{ debugName: "isSavedCommitted" }] : /* istanbul ignore next */ []));
1691
1671
  this.isFormDirty = computed(() => {
1692
- this.builderService.dirtyWidgetsRevisionSignal();
1693
- return this.contextService.isUserDirty() || this.builderService.hasDirtyWidgets();
1672
+ if (!this.contextService.isSavedCommitted()) {
1673
+ return false;
1674
+ }
1675
+ this.contextService.data();
1676
+ return this.contextService.isDirty();
1694
1677
  }, ...(ngDevMode ? [{ debugName: "isFormDirty" }] : /* istanbul ignore next */ []));
1695
- this.status = computed(() => {
1696
- return this.builderService.status();
1697
- }, ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
1698
- this.isBusy = computed(() => {
1699
- return this.builderService.isBusy();
1700
- }, ...(ngDevMode ? [{ debugName: "isBusy" }] : /* istanbul ignore next */ []));
1678
+ this.status = computed(() => this.builderService.status(), ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
1679
+ this.isBusy = computed(() => this.builderService.isBusy(), ...(ngDevMode ? [{ debugName: "isBusy" }] : /* istanbul ignore next */ []));
1701
1680
  effect(() => {
1702
- if (this.contextService.isChanged()) {
1703
- const changeEvent = this.contextService.changeEvent();
1704
- this.onContextChanged.emit({
1705
- ...changeEvent,
1706
- isFormDirty: this.isFormDirty(),
1707
- });
1681
+ const isDirty = this.isFormDirty();
1682
+ const data = this.contextService.data();
1683
+ const changeEvent = this.contextService.changeEvent();
1684
+ if (!this.contextService.isChanged() && this.lastEmittedFormDirty === isDirty) {
1685
+ return;
1686
+ }
1687
+ this.lastEmittedFormDirty = isDirty;
1688
+ this.onContextChanged.emit({
1689
+ ...changeEvent,
1690
+ data: cloneDeep(data),
1691
+ isFormDirty: isDirty,
1692
+ });
1693
+ });
1694
+ effect(() => {
1695
+ if (this.contextService.isSavedCommitted()) {
1696
+ return;
1697
+ }
1698
+ if (this.builderService.registeredWidgetsCount() === 0) {
1699
+ return;
1708
1700
  }
1701
+ untracked(() => void this.settleSavedBaseline());
1709
1702
  });
1710
1703
  }
1711
1704
  refresh() {
@@ -1714,17 +1707,61 @@ class AXPWidgetContainerComponent {
1714
1707
  find(name) {
1715
1708
  return this.builderService.waitForWidget(name);
1716
1709
  }
1717
- /** Replaces context and clears dirty tracking (discard, save reload, external reset). */
1718
- replaceContext(value) {
1719
- const next = cloneDeep(value);
1720
- this.contextService.clearUserDirtyPaths();
1721
- // After save the parent often re-binds deeply-equal data; still reset the clean baseline.
1722
- if (isEqual(this.contextService.data(), next)) {
1723
- this.contextService.commitBaseline();
1724
- this.builderService.notifyWidgetDirtyChanged();
1710
+ syncExternalContext(value) {
1711
+ const next = cloneDeep(value ?? {});
1712
+ const current = this.contextService.data();
1713
+ if (isEqual(current, next)) {
1714
+ return;
1715
+ }
1716
+ if (this.contextService.isSavedCommitted() && this.isFormDirty()) {
1717
+ return;
1718
+ }
1719
+ if (this.contextService.isSavedCommitted()) {
1720
+ this.contextService.set(next);
1721
+ void this.settleSavedBaseline();
1722
+ return;
1723
+ }
1724
+ if (this.contextService.isChanged()) {
1725
1725
  return;
1726
1726
  }
1727
1727
  this.contextService.set(next);
1728
+ void this.settleSavedBaseline();
1729
+ }
1730
+ /** Commits the current data as saved after widget hydration settles. */
1731
+ settleSavedBaseline() {
1732
+ this.clearSavedBaselineTimer();
1733
+ return new Promise((resolve) => {
1734
+ const commit = () => {
1735
+ if (this.builderService.registeredWidgetsCount() === 0) {
1736
+ this.savedBaselineTimer = setTimeout(commit, FORM_SAVED_BASELINE_IDLE_MS);
1737
+ return;
1738
+ }
1739
+ this.contextService.commitSaved();
1740
+ this.lastEmittedFormDirty = undefined;
1741
+ this.savedBaselineTimer = undefined;
1742
+ resolve();
1743
+ };
1744
+ this.savedBaselineTimer = setTimeout(commit, FORM_SAVED_BASELINE_IDLE_MS);
1745
+ });
1746
+ }
1747
+ async replaceContext(value) {
1748
+ this.clearSavedBaselineTimer();
1749
+ this.contextService.set(cloneDeep(value));
1750
+ // Commit immediately so save/replace is clean even when `set()` no-ops (data already matches).
1751
+ this.contextService.commitSaved();
1752
+ this.lastEmittedFormDirty = undefined;
1753
+ await this.settleSavedBaseline();
1754
+ }
1755
+ revertAndSettle() {
1756
+ this.clearSavedBaselineTimer();
1757
+ this.contextService.revertToSaved();
1758
+ this.lastEmittedFormDirty = undefined;
1759
+ }
1760
+ clearSavedBaselineTimer() {
1761
+ if (this.savedBaselineTimer) {
1762
+ clearTimeout(this.savedBaselineTimer);
1763
+ this.savedBaselineTimer = undefined;
1764
+ }
1728
1765
  }
1729
1766
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: AXPWidgetContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1730
1767
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.9", type: AXPWidgetContainerComponent, isStandalone: false, selector: "axp-widgets-container", inputs: { context: "context", functions: "functions" }, outputs: { onContextChanged: "onContextChanged" }, host: { styleAttribute: "display: contents;" }, providers: [AXPWidgetCoreService, AXPContextStore], ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
@@ -1801,6 +1838,7 @@ class AXPWidgetRendererDirective {
1801
1838
  this.isVisible = signal(true, ...(ngDevMode ? [{ debugName: "isVisible" }] : /* istanbul ignore next */ []));
1802
1839
  this.expressionEvaluators = new Map();
1803
1840
  this.renderTimeoutId = null;
1841
+ this.renderGeneration = 0;
1804
1842
  this.hasInitialRender = false;
1805
1843
  this.onContextChanged = new Subject();
1806
1844
  this.onLoadEvent = new Subject();
@@ -2159,18 +2197,18 @@ class AXPWidgetRendererDirective {
2159
2197
  }
2160
2198
  }
2161
2199
  rerenderComponent() {
2162
- // Clear any pending render operation to prevent double rendering
2163
2200
  if (this.renderTimeoutId) {
2164
2201
  clearTimeout(this.renderTimeoutId);
2165
2202
  this.renderTimeoutId = null;
2166
2203
  }
2167
- // Reset loading state to allow re-rendering
2168
- this.isLoading.set(false);
2169
- // Schedule the component loading
2204
+ const generation = ++this.renderGeneration;
2170
2205
  this.renderTimeoutId = setTimeout(async () => {
2171
- await this.loadComponent();
2172
2206
  this.renderTimeoutId = null;
2173
- });
2207
+ if (generation !== this.renderGeneration) {
2208
+ return;
2209
+ }
2210
+ await this.loadComponent();
2211
+ }, 0);
2174
2212
  }
2175
2213
  ngOnDestroy() {
2176
2214
  if (this.renderTimeoutId) {
@@ -2559,7 +2597,10 @@ class AXPWidgetRendererDirective {
2559
2597
  return this.contextService.data();
2560
2598
  },
2561
2599
  isDirty: () => {
2562
- return this.contextService.isUserDirty() || this.builderService.hasDirtyWidgets();
2600
+ if (!this.contextService.isSavedCommitted()) {
2601
+ return false;
2602
+ }
2603
+ return this.contextService.isDirty();
2563
2604
  },
2564
2605
  /**
2565
2606
  * Host/widget-under-edit `options` from the shared context store (same values as