@acorex/platform 20.3.0-next.9 → 20.4.1
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.
- package/common/index.d.ts +643 -365
- package/core/index.d.ts +19 -4
- package/fesm2022/acorex-platform-auth.mjs +19 -19
- package/fesm2022/acorex-platform-auth.mjs.map +1 -1
- package/fesm2022/acorex-platform-common-common-settings.provider-9OHien_H.mjs +47 -0
- package/fesm2022/acorex-platform-common-common-settings.provider-9OHien_H.mjs.map +1 -0
- package/fesm2022/acorex-platform-common.mjs +674 -243
- package/fesm2022/acorex-platform-common.mjs.map +1 -1
- package/fesm2022/acorex-platform-core.mjs +58 -46
- package/fesm2022/acorex-platform-core.mjs.map +1 -1
- package/fesm2022/acorex-platform-domain.mjs +16 -16
- package/fesm2022/acorex-platform-domain.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-builder.mjs +1933 -2330
- package/fesm2022/acorex-platform-layout-builder.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-components.mjs +1511 -1626
- package/fesm2022/acorex-platform-layout-components.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-designer.mjs +82 -82
- package/fesm2022/acorex-platform-layout-designer.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-entity-create-entity.command-DyXF9zAh.mjs +52 -0
- package/fesm2022/acorex-platform-layout-entity-create-entity.command-DyXF9zAh.mjs.map +1 -0
- package/fesm2022/acorex-platform-layout-entity.mjs +1371 -917
- package/fesm2022/acorex-platform-layout-entity.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-views.mjs +63 -54
- package/fesm2022/acorex-platform-layout-views.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-widget-core.mjs +2758 -0
- package/fesm2022/acorex-platform-layout-widget-core.mjs.map +1 -0
- package/fesm2022/{acorex-platform-widgets-button-widget-designer.component-C2Qn1YAW.mjs → acorex-platform-layout-widgets-button-widget-designer.component-C_3IWNkj.mjs} +6 -6
- package/fesm2022/acorex-platform-layout-widgets-button-widget-designer.component-C_3IWNkj.mjs.map +1 -0
- package/fesm2022/{acorex-platform-widgets-extra-properties-schema-widget-edit.component-D9mf08rU.mjs → acorex-platform-layout-widgets-extra-properties-schema-widget-edit.component-CJltEgut.mjs} +5 -5
- package/fesm2022/acorex-platform-layout-widgets-extra-properties-schema-widget-edit.component-CJltEgut.mjs.map +1 -0
- package/fesm2022/{acorex-platform-widgets-extra-properties-schema-widget-view.component-D6GQ-eyr.mjs → acorex-platform-layout-widgets-extra-properties-schema-widget-view.component-pM-TIuk0.mjs} +5 -5
- package/fesm2022/acorex-platform-layout-widgets-extra-properties-schema-widget-view.component-pM-TIuk0.mjs.map +1 -0
- package/fesm2022/{acorex-platform-widgets-extra-properties-values-widget-edit.component-DVbIdVZ6.mjs → acorex-platform-layout-widgets-extra-properties-values-widget-edit.component-BqI96-fU.mjs} +5 -5
- package/fesm2022/acorex-platform-layout-widgets-extra-properties-values-widget-edit.component-BqI96-fU.mjs.map +1 -0
- package/fesm2022/{acorex-platform-widgets-extra-properties-values-widget-view.component-D-aM64Hu.mjs → acorex-platform-layout-widgets-extra-properties-values-widget-view.component-C-AhenaM.mjs} +5 -5
- package/fesm2022/acorex-platform-layout-widgets-extra-properties-values-widget-view.component-C-AhenaM.mjs.map +1 -0
- package/fesm2022/{acorex-platform-widgets-extra-properties-widget-edit.component-em2-aU8E.mjs → acorex-platform-layout-widgets-extra-properties-widget-edit.component-DCAya5ne.mjs} +5 -5
- package/fesm2022/acorex-platform-layout-widgets-extra-properties-widget-edit.component-DCAya5ne.mjs.map +1 -0
- package/fesm2022/{acorex-platform-widgets-extra-properties-widget-view.component-BeuIofdr.mjs → acorex-platform-layout-widgets-extra-properties-widget-view.component-D-PnBqLb.mjs} +5 -5
- package/fesm2022/acorex-platform-layout-widgets-extra-properties-widget-view.component-D-PnBqLb.mjs.map +1 -0
- package/fesm2022/{acorex-platform-widgets-file-list-popup.component-Cmtq2bBV.mjs → acorex-platform-layout-widgets-file-list-popup.component-DuuFHWvB.mjs} +9 -9
- package/fesm2022/acorex-platform-layout-widgets-file-list-popup.component-DuuFHWvB.mjs.map +1 -0
- package/fesm2022/{acorex-platform-widgets-page-widget-designer.component-D8ivmxzT.mjs → acorex-platform-layout-widgets-page-widget-designer.component-Bss0xUcu.mjs} +8 -8
- package/fesm2022/acorex-platform-layout-widgets-page-widget-designer.component-Bss0xUcu.mjs.map +1 -0
- package/fesm2022/{acorex-platform-widgets-tabular-data-edit-popup.component-CMqq_iOj.mjs → acorex-platform-layout-widgets-tabular-data-edit-popup.component-Cy9mHnNP.mjs} +8 -8
- package/fesm2022/acorex-platform-layout-widgets-tabular-data-edit-popup.component-Cy9mHnNP.mjs.map +1 -0
- package/fesm2022/{acorex-platform-widgets-tabular-data-view-popup.component-Dmg5DdX8.mjs → acorex-platform-layout-widgets-tabular-data-view-popup.component-DznLtuer.mjs} +6 -5
- package/fesm2022/acorex-platform-layout-widgets-tabular-data-view-popup.component-DznLtuer.mjs.map +1 -0
- package/fesm2022/{acorex-platform-widgets-text-block-widget-designer.component-yADN3Xji.mjs → acorex-platform-layout-widgets-text-block-widget-designer.component-ndOUSFi9.mjs} +6 -7
- package/fesm2022/acorex-platform-layout-widgets-text-block-widget-designer.component-ndOUSFi9.mjs.map +1 -0
- package/fesm2022/{acorex-platform-widgets.mjs → acorex-platform-layout-widgets.mjs} +4154 -3147
- package/fesm2022/acorex-platform-layout-widgets.mjs.map +1 -0
- package/fesm2022/acorex-platform-native.mjs +7 -7
- package/fesm2022/acorex-platform-native.mjs.map +1 -1
- package/fesm2022/acorex-platform-runtime.mjs +40 -40
- package/fesm2022/acorex-platform-runtime.mjs.map +1 -1
- package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-B1PT6FtZ.mjs +115 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-B1PT6FtZ.mjs.map +1 -0
- package/fesm2022/{acorex-platform-themes-default-entity-master-list-view.component-7BB4LdjK.mjs → acorex-platform-themes-default-entity-master-list-view.component-rdKxuMC_.mjs} +69 -33
- package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-rdKxuMC_.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-4g19A3eI.mjs +101 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-4g19A3eI.mjs.map +1 -0
- package/fesm2022/{acorex-platform-themes-default-entity-master-single-view.component-BExtm1JE.mjs → acorex-platform-themes-default-entity-master-single-view.component-B8gx5cG7.mjs} +17 -17
- package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-B8gx5cG7.mjs.map +1 -0
- package/fesm2022/{acorex-platform-themes-default-error-401.component-DrO1PEOH.mjs → acorex-platform-themes-default-error-401.component-CcvGfdhu.mjs} +4 -4
- package/fesm2022/{acorex-platform-themes-default-error-401.component-DrO1PEOH.mjs.map → acorex-platform-themes-default-error-401.component-CcvGfdhu.mjs.map} +1 -1
- package/fesm2022/{acorex-platform-themes-default-error-404.component-DqVq0oHX.mjs → acorex-platform-themes-default-error-404.component-4-CaEsnV.mjs} +4 -4
- package/fesm2022/{acorex-platform-themes-default-error-404.component-DqVq0oHX.mjs.map → acorex-platform-themes-default-error-404.component-4-CaEsnV.mjs.map} +1 -1
- package/fesm2022/{acorex-platform-themes-default-error-offline.component-Bt2PTL7_.mjs → acorex-platform-themes-default-error-offline.component-BNecbFEj.mjs} +4 -4
- package/fesm2022/{acorex-platform-themes-default-error-offline.component-Bt2PTL7_.mjs.map → acorex-platform-themes-default-error-offline.component-BNecbFEj.mjs.map} +1 -1
- package/fesm2022/acorex-platform-themes-default.mjs +118 -54
- package/fesm2022/acorex-platform-themes-default.mjs.map +1 -1
- package/fesm2022/{acorex-platform-themes-shared-icon-chooser-view.component-BgEh06Tn.mjs → acorex-platform-themes-shared-icon-chooser-view.component-Dc_Txe32.mjs} +5 -5
- package/fesm2022/acorex-platform-themes-shared-icon-chooser-view.component-Dc_Txe32.mjs.map +1 -0
- package/fesm2022/{acorex-platform-themes-shared-settings.provider-CLUKU4y0.mjs → acorex-platform-themes-shared-settings.provider-DY2xFnrv.mjs} +8 -8
- package/fesm2022/acorex-platform-themes-shared-settings.provider-DY2xFnrv.mjs.map +1 -0
- package/fesm2022/{acorex-platform-themes-shared-theme-color-chooser-column.component-AeOQxjbS.mjs → acorex-platform-themes-shared-theme-color-chooser-column.component-hgWLhhle.mjs} +5 -5
- package/fesm2022/acorex-platform-themes-shared-theme-color-chooser-column.component-hgWLhhle.mjs.map +1 -0
- package/fesm2022/{acorex-platform-themes-shared-theme-color-chooser-view.component-DEVzRd6-.mjs → acorex-platform-themes-shared-theme-color-chooser-view.component-CY3JZK_W.mjs} +5 -5
- package/fesm2022/acorex-platform-themes-shared-theme-color-chooser-view.component-CY3JZK_W.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-shared.mjs +66 -55
- package/fesm2022/acorex-platform-themes-shared.mjs.map +1 -1
- package/fesm2022/acorex-platform-workflow.mjs +27 -39
- package/fesm2022/acorex-platform-workflow.mjs.map +1 -1
- package/layout/builder/README.md +1577 -3
- package/layout/builder/index.d.ts +735 -868
- package/layout/components/index.d.ts +218 -714
- package/layout/designer/index.d.ts +4 -4
- package/layout/entity/index.d.ts +954 -375
- package/layout/views/index.d.ts +13 -14
- package/layout/widget-core/README.md +4 -0
- package/layout/widget-core/index.d.ts +959 -0
- package/layout/widgets/README.md +4 -0
- package/{widgets → layout/widgets}/index.d.ts +426 -365
- package/package.json +18 -14
- package/themes/shared/index.d.ts +2 -2
- package/workflow/index.d.ts +3 -173
- package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-Ct-ri59W.mjs +0 -115
- package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-Ct-ri59W.mjs.map +0 -1
- package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-7BB4LdjK.mjs.map +0 -1
- package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-BDJR088o.mjs +0 -101
- package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-BDJR088o.mjs.map +0 -1
- package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-BExtm1JE.mjs.map +0 -1
- package/fesm2022/acorex-platform-themes-shared-icon-chooser-view.component-BgEh06Tn.mjs.map +0 -1
- package/fesm2022/acorex-platform-themes-shared-settings.provider-CLUKU4y0.mjs.map +0 -1
- package/fesm2022/acorex-platform-themes-shared-theme-color-chooser-column.component-AeOQxjbS.mjs.map +0 -1
- package/fesm2022/acorex-platform-themes-shared-theme-color-chooser-view.component-DEVzRd6-.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-button-widget-designer.component-C2Qn1YAW.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-checkbox-widget-column.component-CzEFmKWG.mjs +0 -84
- package/fesm2022/acorex-platform-widgets-checkbox-widget-column.component-CzEFmKWG.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-checkbox-widget-designer.component-BXPrXy-h.mjs +0 -55
- package/fesm2022/acorex-platform-widgets-checkbox-widget-designer.component-BXPrXy-h.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-checkbox-widget-view.component-KYCQ2qTJ.mjs +0 -92
- package/fesm2022/acorex-platform-widgets-checkbox-widget-view.component-KYCQ2qTJ.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-color-box-widget-designer.component-BVZ7lWm9.mjs +0 -55
- package/fesm2022/acorex-platform-widgets-color-box-widget-designer.component-BVZ7lWm9.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-extra-properties-schema-widget-edit.component-D9mf08rU.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-extra-properties-schema-widget-view.component-D6GQ-eyr.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-extra-properties-values-widget-edit.component-DVbIdVZ6.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-extra-properties-values-widget-view.component-D-aM64Hu.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-extra-properties-widget-edit.component-em2-aU8E.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-extra-properties-widget-view.component-BeuIofdr.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-file-list-popup.component-Cmtq2bBV.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-page-widget-designer.component-D8ivmxzT.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-rich-text-popup.component-Cydlpsat.mjs +0 -40
- package/fesm2022/acorex-platform-widgets-rich-text-popup.component-Cydlpsat.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-tabular-data-edit-popup.component-CMqq_iOj.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-tabular-data-view-popup.component-Dmg5DdX8.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-text-block-widget-designer.component-yADN3Xji.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets.mjs.map +0 -1
- package/widgets/README.md +0 -4
|
@@ -0,0 +1,2758 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { signal, computed, Injectable, InjectionToken, inject, ElementRef, effect, Injector, ChangeDetectorRef, ViewChild, Input, ChangeDetectionStrategy, Component, EventEmitter, Output, input, output, ViewContainerRef, Directive, Optional, Inject, NgModule, createComponent } from '@angular/core';
|
|
3
|
+
import { convertArrayToDataSource, AXDataSource } from '@acorex/cdk/common';
|
|
4
|
+
import { setSmart, AXPDataSourceDefinitionProviderService, extractValue, getSmart, AXPExpressionEvaluatorService } from '@acorex/platform/core';
|
|
5
|
+
import { set, cloneDeep, isEqual, get, merge, isNil, isUndefined, isObjectLike, sum, isEmpty, isString } from 'lodash-es';
|
|
6
|
+
import { Subject, BehaviorSubject, filter } from 'rxjs';
|
|
7
|
+
import { signalStore, withState, withComputed, withMethods, patchState } from '@ngrx/signals';
|
|
8
|
+
import * as i1$1 from '@acorex/components/skeleton';
|
|
9
|
+
import { AXSkeletonModule } from '@acorex/components/skeleton';
|
|
10
|
+
import * as i2 from '@acorex/core/translation';
|
|
11
|
+
import { AXTranslationService, AXTranslationModule } from '@acorex/core/translation';
|
|
12
|
+
import { PortalModule } from '@angular/cdk/portal';
|
|
13
|
+
import * as i1 from '@angular/common';
|
|
14
|
+
import { CommonModule } from '@angular/common';
|
|
15
|
+
import { AXDataTableColumnComponent, AXBaseDataTable } from '@acorex/components/data-table';
|
|
16
|
+
import { AXUnsubscriber } from '@acorex/core/utils';
|
|
17
|
+
|
|
18
|
+
var AXPPageStatus;
|
|
19
|
+
(function (AXPPageStatus) {
|
|
20
|
+
// Idle statuses
|
|
21
|
+
AXPPageStatus["Idle"] = "idle";
|
|
22
|
+
// Rendering statuses
|
|
23
|
+
AXPPageStatus["Rendering"] = "rendering";
|
|
24
|
+
AXPPageStatus["Rendered"] = "rendered";
|
|
25
|
+
// Processing statuses
|
|
26
|
+
AXPPageStatus["Processing"] = "processing";
|
|
27
|
+
// Submission statuses
|
|
28
|
+
AXPPageStatus["Submitting"] = "submitting";
|
|
29
|
+
AXPPageStatus["Submitted"] = "submitted";
|
|
30
|
+
// Validation statuses
|
|
31
|
+
AXPPageStatus["Validating"] = "validating";
|
|
32
|
+
AXPPageStatus["Validated"] = "validated";
|
|
33
|
+
// Error handling
|
|
34
|
+
AXPPageStatus["Error"] = "error";
|
|
35
|
+
})(AXPPageStatus || (AXPPageStatus = {}));
|
|
36
|
+
var AXPWidgetStatus;
|
|
37
|
+
(function (AXPWidgetStatus) {
|
|
38
|
+
// Rendering statuses
|
|
39
|
+
AXPWidgetStatus["Rendering"] = "rendering";
|
|
40
|
+
AXPWidgetStatus["Rendered"] = "rendered";
|
|
41
|
+
// Processing statuses
|
|
42
|
+
AXPWidgetStatus["Processing"] = "processing";
|
|
43
|
+
// Error handling
|
|
44
|
+
AXPWidgetStatus["Error"] = "error";
|
|
45
|
+
})(AXPWidgetStatus || (AXPWidgetStatus = {}));
|
|
46
|
+
|
|
47
|
+
class AXPWidgetCoreElement {
|
|
48
|
+
api() {
|
|
49
|
+
return {};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
class AXPWidgetCoreService {
|
|
53
|
+
constructor() {
|
|
54
|
+
this.variables$ = signal({}, ...(ngDevMode ? [{ debugName: "variables$" }] : []));
|
|
55
|
+
this.functions$ = signal({}, ...(ngDevMode ? [{ debugName: "functions$" }] : []));
|
|
56
|
+
this.onRefresh = new Subject();
|
|
57
|
+
this.widgets = new Map();
|
|
58
|
+
this.onWidgetRegistered = new Subject();
|
|
59
|
+
this.status$ = signal(AXPPageStatus.Rendering, ...(ngDevMode ? [{ debugName: "status$" }] : []));
|
|
60
|
+
this.status = this.status$.asReadonly();
|
|
61
|
+
this.isBusy = computed(() => {
|
|
62
|
+
return [AXPPageStatus.Processing, AXPPageStatus.Submitting, AXPPageStatus.Rendering].includes(this.status());
|
|
63
|
+
}, ...(ngDevMode ? [{ debugName: "isBusy" }] : []));
|
|
64
|
+
}
|
|
65
|
+
get variables() {
|
|
66
|
+
return this.variables$();
|
|
67
|
+
}
|
|
68
|
+
get functions() {
|
|
69
|
+
return this.functions$();
|
|
70
|
+
}
|
|
71
|
+
updateStatus() {
|
|
72
|
+
this.status$.update(() => this.detectStatus());
|
|
73
|
+
}
|
|
74
|
+
detectStatus() {
|
|
75
|
+
const statuses = Array.from(this.widgets.values()).map((c) => c.status());
|
|
76
|
+
// Rendering statuses
|
|
77
|
+
if (statuses.some((status) => status === AXPWidgetStatus.Rendering)) {
|
|
78
|
+
return AXPPageStatus.Rendering;
|
|
79
|
+
}
|
|
80
|
+
if (statuses.every((status) => status === AXPWidgetStatus.Rendered)) {
|
|
81
|
+
return AXPPageStatus.Rendered;
|
|
82
|
+
}
|
|
83
|
+
// Processing statuses
|
|
84
|
+
if (statuses.some((status) => status === AXPWidgetStatus.Processing)) {
|
|
85
|
+
return AXPPageStatus.Processing;
|
|
86
|
+
}
|
|
87
|
+
// Error handling
|
|
88
|
+
if (statuses.some((status) => status === AXPWidgetStatus.Error)) {
|
|
89
|
+
return AXPPageStatus.Error;
|
|
90
|
+
}
|
|
91
|
+
return AXPPageStatus.Rendered; // Default to Loaded when all widgets are in a completed state
|
|
92
|
+
}
|
|
93
|
+
refresh() {
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
this.onRefresh.next();
|
|
96
|
+
}, 0);
|
|
97
|
+
}
|
|
98
|
+
setStatus(status) {
|
|
99
|
+
this.status$.set(status);
|
|
100
|
+
}
|
|
101
|
+
setVariables(...args) {
|
|
102
|
+
if (args.length == 0)
|
|
103
|
+
return;
|
|
104
|
+
else if (args.length == 1)
|
|
105
|
+
this.variables$.set(args[0]);
|
|
106
|
+
else if (args.length == 2) {
|
|
107
|
+
this.variables$.update((v) => set(v, args[0], args[1]));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
setFunctions(...args) {
|
|
111
|
+
if (args.length == 0)
|
|
112
|
+
return;
|
|
113
|
+
else if (args.length == 1)
|
|
114
|
+
this.functions$.set(args[0]);
|
|
115
|
+
else if (args.length == 2) {
|
|
116
|
+
this.functions$.update((v) => set(v, args[0], args[1]));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
registerWidget(id, widget) {
|
|
120
|
+
this.widgets.set(id, widget);
|
|
121
|
+
this.onWidgetRegistered.next({ id, widget });
|
|
122
|
+
}
|
|
123
|
+
getWidget(id) {
|
|
124
|
+
return this.widgets.get(id);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Waits until a widget with the given id is registered, then resolves with it.
|
|
128
|
+
* If the widget is already registered, resolves immediately.
|
|
129
|
+
* Optionally accepts a timeout (in ms) after which it resolves with undefined.
|
|
130
|
+
*/
|
|
131
|
+
async waitForWidget(id, timeoutMs) {
|
|
132
|
+
const existing = this.widgets.get(id);
|
|
133
|
+
if (existing) {
|
|
134
|
+
return existing;
|
|
135
|
+
}
|
|
136
|
+
return new Promise((resolve) => {
|
|
137
|
+
let resolved = false;
|
|
138
|
+
let timer = null;
|
|
139
|
+
const sub = this.onWidgetRegistered.subscribe(({ id: registeredId, widget }) => {
|
|
140
|
+
if (registeredId === id && !resolved) {
|
|
141
|
+
resolved = true;
|
|
142
|
+
sub.unsubscribe();
|
|
143
|
+
if (timer) {
|
|
144
|
+
clearTimeout(timer);
|
|
145
|
+
}
|
|
146
|
+
resolve(widget);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
if (timeoutMs != null && timeoutMs > 0) {
|
|
150
|
+
timer = setTimeout(() => {
|
|
151
|
+
if (!resolved) {
|
|
152
|
+
resolved = true;
|
|
153
|
+
sub.unsubscribe();
|
|
154
|
+
resolve(undefined);
|
|
155
|
+
}
|
|
156
|
+
}, timeoutMs);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
ngOnDestroy() { }
|
|
161
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetCoreService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
162
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetCoreService }); }
|
|
163
|
+
}
|
|
164
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetCoreService, decorators: [{
|
|
165
|
+
type: Injectable
|
|
166
|
+
}] });
|
|
167
|
+
|
|
168
|
+
class AXPWidgetCoreContextChangeEvent {
|
|
169
|
+
}
|
|
170
|
+
const AXPWidgetCoreContextStore = signalStore(
|
|
171
|
+
// Initial State
|
|
172
|
+
withState(() => ({
|
|
173
|
+
data: {}, // Shared context data
|
|
174
|
+
state: 'initiated', // Current state
|
|
175
|
+
initialSnapshot: {}, // Snapshot of the first initialized state
|
|
176
|
+
previousSnapshot: {}, // Snapshot of the previous state
|
|
177
|
+
lastChange: {
|
|
178
|
+
state: 'initiated',
|
|
179
|
+
}, // Last change event
|
|
180
|
+
})),
|
|
181
|
+
// Computed Signals
|
|
182
|
+
withComputed(({ data, state, lastChange, initialSnapshot, previousSnapshot }) => ({
|
|
183
|
+
isChanged: computed(() => state() === 'changed'),
|
|
184
|
+
isReset: computed(() => state() === 'restored'),
|
|
185
|
+
isInitiated: computed(() => state() === 'initiated'),
|
|
186
|
+
isEmpty: computed(() => Object.keys(data()).length === 0),
|
|
187
|
+
isDirty: computed(() => !isEqual(data(), previousSnapshot())),
|
|
188
|
+
snapshot: computed(() => cloneDeep(data())), // Current data snapshot
|
|
189
|
+
initial: computed(() => cloneDeep(initialSnapshot())), // Initial snapshot
|
|
190
|
+
previous: computed(() => cloneDeep(previousSnapshot())), // Previous snapshot
|
|
191
|
+
changeEvent: computed(() => lastChange()), // Reactive last change event
|
|
192
|
+
})),
|
|
193
|
+
// Methods for State Management
|
|
194
|
+
withMethods((store) => ({
|
|
195
|
+
// Update a specific value
|
|
196
|
+
update(path, value) {
|
|
197
|
+
const currentData = cloneDeep(store.data());
|
|
198
|
+
const oldValue = get(currentData, path);
|
|
199
|
+
// Skip if the value hasn't changed
|
|
200
|
+
if (isEqual(oldValue, value)) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
// Update the value and prepare the change event
|
|
204
|
+
const updatedData = setSmart(currentData, path, value);
|
|
205
|
+
const changeEvent = {
|
|
206
|
+
oldValue,
|
|
207
|
+
newValue: value,
|
|
208
|
+
path,
|
|
209
|
+
state: 'changed',
|
|
210
|
+
data: updatedData,
|
|
211
|
+
};
|
|
212
|
+
// Patch the state
|
|
213
|
+
patchState(store, {
|
|
214
|
+
previousSnapshot: store.snapshot(), // Save the previous state
|
|
215
|
+
data: updatedData,
|
|
216
|
+
state: 'changed',
|
|
217
|
+
lastChange: changeEvent,
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
patch(context) {
|
|
221
|
+
const currentData = cloneDeep(store.data());
|
|
222
|
+
// Update the value and prepare the change event
|
|
223
|
+
const updatedData = { ...currentData, ...context };
|
|
224
|
+
const changeEvent = {
|
|
225
|
+
state: 'patch',
|
|
226
|
+
data: updatedData,
|
|
227
|
+
};
|
|
228
|
+
// Patch the state
|
|
229
|
+
patchState(store, {
|
|
230
|
+
previousSnapshot: store.snapshot(), // Save the previous state
|
|
231
|
+
data: updatedData,
|
|
232
|
+
state: 'changed',
|
|
233
|
+
lastChange: changeEvent,
|
|
234
|
+
});
|
|
235
|
+
},
|
|
236
|
+
// Reset to the initial state
|
|
237
|
+
reset() {
|
|
238
|
+
const initialData = store.initial();
|
|
239
|
+
const changeEvent = {
|
|
240
|
+
oldValue: cloneDeep(store.data()), // Current data becomes old value
|
|
241
|
+
newValue: cloneDeep(initialData), // Reset to the initial state
|
|
242
|
+
path: '',
|
|
243
|
+
state: 'restored',
|
|
244
|
+
data: initialData,
|
|
245
|
+
};
|
|
246
|
+
patchState(store, {
|
|
247
|
+
previousSnapshot: store.snapshot(), // Save the previous state
|
|
248
|
+
data: initialData,
|
|
249
|
+
state: 'restored',
|
|
250
|
+
lastChange: changeEvent,
|
|
251
|
+
});
|
|
252
|
+
},
|
|
253
|
+
// Initialize the state
|
|
254
|
+
set(initialData) {
|
|
255
|
+
const currentData = store.data();
|
|
256
|
+
if (isEqual(currentData, initialData)) {
|
|
257
|
+
return; // Skip if the current state matches the initial state
|
|
258
|
+
}
|
|
259
|
+
const changeEvent = {
|
|
260
|
+
oldValue: null,
|
|
261
|
+
newValue: cloneDeep(initialData),
|
|
262
|
+
path: '',
|
|
263
|
+
state: 'initiated',
|
|
264
|
+
data: initialData,
|
|
265
|
+
};
|
|
266
|
+
patchState(store, {
|
|
267
|
+
initialSnapshot: cloneDeep(initialData), // Save the initial state
|
|
268
|
+
previousSnapshot: store.snapshot(), // Save the current state as the previous
|
|
269
|
+
data: initialData,
|
|
270
|
+
state: 'initiated',
|
|
271
|
+
lastChange: changeEvent,
|
|
272
|
+
});
|
|
273
|
+
},
|
|
274
|
+
// Get a specific value
|
|
275
|
+
getValue(path) {
|
|
276
|
+
return get(store.data(), path);
|
|
277
|
+
},
|
|
278
|
+
})));
|
|
279
|
+
|
|
280
|
+
const AXPWidgetsCatalog = {
|
|
281
|
+
timeDuration: 'time-duration',
|
|
282
|
+
timeDurationFilter: 'time-duration-filter',
|
|
283
|
+
tagable: 'tagable-editor',
|
|
284
|
+
checkbox: 'checkbox-editor',
|
|
285
|
+
color: 'color-editor',
|
|
286
|
+
contact: 'contact-editor',
|
|
287
|
+
dateTime: 'date-time-editor',
|
|
288
|
+
largeText: 'large-text-editor',
|
|
289
|
+
number: 'number-editor',
|
|
290
|
+
numberUnit: 'number-unit-editor',
|
|
291
|
+
password: 'password-editor',
|
|
292
|
+
richText: 'rich-text-editor',
|
|
293
|
+
select: 'select-editor',
|
|
294
|
+
selectionList: 'selection-list-editor',
|
|
295
|
+
text: 'text-editor',
|
|
296
|
+
table: 'table-editor',
|
|
297
|
+
toggle: 'toggle-editor',
|
|
298
|
+
blockLayout: 'block-layout',
|
|
299
|
+
pageLayout: 'page-layout',
|
|
300
|
+
repeaterLayout: 'repeater-layout',
|
|
301
|
+
textBlockLayout: 'text-block-layout',
|
|
302
|
+
fileUploader: 'file-uploader',
|
|
303
|
+
fileTypeExtension: 'file-type-extension',
|
|
304
|
+
map: 'map',
|
|
305
|
+
imageMarker: 'image-marker',
|
|
306
|
+
image: 'image',
|
|
307
|
+
gallery: 'gallery',
|
|
308
|
+
signature: 'signature',
|
|
309
|
+
buttonAction: 'button-action',
|
|
310
|
+
document: 'document-layout',
|
|
311
|
+
lookup: 'lookup-editor',
|
|
312
|
+
formField: 'form-field',
|
|
313
|
+
qrcode: 'qrcode',
|
|
314
|
+
advancedGrid: 'advanced-grid-layout',
|
|
315
|
+
advancedGridItem: 'advanced-grid-item-layout',
|
|
316
|
+
grid: 'grid-layout',
|
|
317
|
+
gridItem: 'grid-item-layout',
|
|
318
|
+
// gridRow: 'grid-row-layout',
|
|
319
|
+
widgetSelector: 'widget-selector',
|
|
320
|
+
template: 'template',
|
|
321
|
+
templateDesigner: 'template-designer',
|
|
322
|
+
cronJob: 'cron-job',
|
|
323
|
+
spacing: 'spacing',
|
|
324
|
+
direction: 'direction',
|
|
325
|
+
border: 'border',
|
|
326
|
+
flexLayout: 'flex-layout',
|
|
327
|
+
flexItem: 'flex-item-layout',
|
|
328
|
+
tableLayout: 'table-layout',
|
|
329
|
+
tableItem: 'table-item-layout',
|
|
330
|
+
avatar: 'avatar',
|
|
331
|
+
themePaletteChooser: 'theme-palette-chooser',
|
|
332
|
+
themeModeChooser: 'theme-mode-chooser',
|
|
333
|
+
menuOrientationChooser: 'menu-orientation-chooser',
|
|
334
|
+
fontStyleChooser: 'font-style-chooser',
|
|
335
|
+
fontSizeChooser: 'font-size-chooser',
|
|
336
|
+
iconChooser: 'icon-chooser',
|
|
337
|
+
icon: 'icon',
|
|
338
|
+
themeColorChooser: 'theme-color-chooser',
|
|
339
|
+
gridOptions: 'grid-options',
|
|
340
|
+
gridItemOptions: 'grid-item-options',
|
|
341
|
+
advancedGridOptions: 'advanced-grid-options',
|
|
342
|
+
stringFilter: 'string-filter',
|
|
343
|
+
numberFilter: 'number-filter',
|
|
344
|
+
dateTimeFilter: 'datetime-filter',
|
|
345
|
+
booleanFilter: 'boolean-filter',
|
|
346
|
+
lookupFilter: 'lookup-filter',
|
|
347
|
+
flexOptions: 'flex-options',
|
|
348
|
+
flexItemOptions: 'flex-item-options',
|
|
349
|
+
selectFilter: 'select-filter',
|
|
350
|
+
requiredValidation: 'required-validation',
|
|
351
|
+
regularExpressionValidation: 'regular-expression-validation',
|
|
352
|
+
minLengthValidation: 'min-length-validation',
|
|
353
|
+
maxLengthValidation: 'max-length-validation',
|
|
354
|
+
lessThanValidation: 'less-than-validation',
|
|
355
|
+
greaterThanValidation: 'greater-than-validation',
|
|
356
|
+
betweenValidation: 'between-validation',
|
|
357
|
+
equalValidation: 'equal-validation',
|
|
358
|
+
callbackValidation: 'callback-validation',
|
|
359
|
+
donutChart: 'donut-chart',
|
|
360
|
+
lineChart: 'line-chart',
|
|
361
|
+
barChart: 'bar-chart',
|
|
362
|
+
gaugeChart: 'gauge-chart',
|
|
363
|
+
stickyNote: 'sticky-note',
|
|
364
|
+
clockCalendar: 'clock-calendar',
|
|
365
|
+
analogClock: 'analog-clock',
|
|
366
|
+
weather: 'weather',
|
|
367
|
+
minimalWeather: 'minimal-weather',
|
|
368
|
+
advancedWeather: 'advanced-weather',
|
|
369
|
+
metaData: 'meta-data-editor',
|
|
370
|
+
templateEditor: 'template-box-editor',
|
|
371
|
+
panel: 'panel',
|
|
372
|
+
notification: 'notification',
|
|
373
|
+
taskBoard: 'task-board',
|
|
374
|
+
comment: 'comment',
|
|
375
|
+
list: 'list',
|
|
376
|
+
listToolbar: 'list-toolbar',
|
|
377
|
+
entityList: 'entity-list',
|
|
378
|
+
documentUploader: 'document-uploader',
|
|
379
|
+
signatureList: 'signature-list',
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
function cloneProperty(property, values) {
|
|
383
|
+
return merge(cloneDeep(property), values);
|
|
384
|
+
}
|
|
385
|
+
function createStringProperty(ctor) {
|
|
386
|
+
return {
|
|
387
|
+
name: ctor.name,
|
|
388
|
+
title: ctor.title,
|
|
389
|
+
group: ctor.group,
|
|
390
|
+
schema: {
|
|
391
|
+
dataType: 'string',
|
|
392
|
+
defaultValue: ctor.defaultValue,
|
|
393
|
+
interface: {
|
|
394
|
+
name: ctor.name,
|
|
395
|
+
path: ctor.path ?? ctor.name,
|
|
396
|
+
type: AXPWidgetsCatalog.text,
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
visible: !isNil(ctor.visible) ? ctor.visible : true,
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
function createNumberProperty(ctor) {
|
|
403
|
+
return {
|
|
404
|
+
name: ctor.name,
|
|
405
|
+
title: ctor.title,
|
|
406
|
+
group: ctor.group,
|
|
407
|
+
schema: {
|
|
408
|
+
dataType: 'number',
|
|
409
|
+
defaultValue: ctor.defaultValue,
|
|
410
|
+
interface: {
|
|
411
|
+
name: ctor.name,
|
|
412
|
+
path: ctor.path ?? ctor.name,
|
|
413
|
+
type: AXPWidgetsCatalog.number,
|
|
414
|
+
options: ctor.options,
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
visible: !isNil(ctor.visible) ? ctor.visible : true,
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
function createBooleanProperty(ctor) {
|
|
421
|
+
return {
|
|
422
|
+
name: ctor.name,
|
|
423
|
+
title: ctor.title,
|
|
424
|
+
group: ctor.group,
|
|
425
|
+
schema: {
|
|
426
|
+
dataType: 'boolean',
|
|
427
|
+
defaultValue: ctor.defaultValue ?? false,
|
|
428
|
+
interface: {
|
|
429
|
+
name: ctor.name,
|
|
430
|
+
path: ctor.path ?? ctor.name,
|
|
431
|
+
type: AXPWidgetsCatalog.toggle,
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
visible: ctor.visible ?? true,
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
function createSelectProperty(ctor) {
|
|
438
|
+
return {
|
|
439
|
+
name: ctor.name,
|
|
440
|
+
title: ctor.title,
|
|
441
|
+
group: ctor.group,
|
|
442
|
+
schema: {
|
|
443
|
+
dataType: 'string',
|
|
444
|
+
defaultValue: Array.isArray(ctor.defaultValue)
|
|
445
|
+
? ctor.defaultValue.map((item) => (typeof item === 'string' ? { id: item } : item))
|
|
446
|
+
: typeof ctor.defaultValue === 'string'
|
|
447
|
+
? { id: ctor.defaultValue, title: ctor.defaultValue }
|
|
448
|
+
: ctor.defaultValue,
|
|
449
|
+
interface: {
|
|
450
|
+
name: ctor.name,
|
|
451
|
+
path: ctor.path ?? ctor.name,
|
|
452
|
+
type: AXPWidgetsCatalog.select,
|
|
453
|
+
options: {
|
|
454
|
+
dataSource: ctor.dataSource.map((item) => (typeof item === 'string' ? { id: item, title: item } : item)),
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
visible: ctor.visible ?? true,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
const AXP_WIDGET_TOKEN = new InjectionToken('AXP_WIDGET_TOKEN');
|
|
462
|
+
const AXP_WIDGET_COLUMN_TOKEN = new InjectionToken('AXP_WIDGET_COLUMN_TOKEN');
|
|
463
|
+
|
|
464
|
+
class AXPBaseWidgetComponent extends AXPWidgetCoreElement {
|
|
465
|
+
constructor() {
|
|
466
|
+
super(...arguments);
|
|
467
|
+
this.token = inject(AXP_WIDGET_TOKEN);
|
|
468
|
+
this.host = inject(ElementRef).nativeElement;
|
|
469
|
+
this.layoutService = inject(AXPWidgetCoreService);
|
|
470
|
+
this.contextService = inject(AXPWidgetCoreContextStore);
|
|
471
|
+
this.config = this.token.config;
|
|
472
|
+
this.node = this.token.node;
|
|
473
|
+
this.name = this.token.node.name;
|
|
474
|
+
this.component = this;
|
|
475
|
+
this._options = signal(this.token.options ?? {}, ...(ngDevMode ? [{ debugName: "_options" }] : []));
|
|
476
|
+
this.options = this._options.asReadonly();
|
|
477
|
+
this.onOptionsChanged = new Subject();
|
|
478
|
+
this._status = signal(AXPWidgetStatus.Rendering, ...(ngDevMode ? [{ debugName: "_status" }] : []));
|
|
479
|
+
this.status = this._status.asReadonly();
|
|
480
|
+
this.onStatusChanged = new BehaviorSubject(this._status());
|
|
481
|
+
this.#statusEffect = effect(() => {
|
|
482
|
+
this.onStatusChanged.next(this.status());
|
|
483
|
+
}, ...(ngDevMode ? [{ debugName: "#statusEffect" }] : []));
|
|
484
|
+
this.isBusy = computed(() => [AXPWidgetStatus.Rendering, AXPWidgetStatus.Processing].includes(this.status()), ...(ngDevMode ? [{ debugName: "isBusy" }] : []));
|
|
485
|
+
this._children = signal(this.token.node.children ?? [], ...(ngDevMode ? [{ debugName: "_children" }] : []));
|
|
486
|
+
this.children = this._children.asReadonly();
|
|
487
|
+
}
|
|
488
|
+
get id() {
|
|
489
|
+
return this._id;
|
|
490
|
+
}
|
|
491
|
+
#statusEffect;
|
|
492
|
+
outputs() {
|
|
493
|
+
return [];
|
|
494
|
+
}
|
|
495
|
+
ngOnInit() {
|
|
496
|
+
if (get(this.node, '__meta__.added')) {
|
|
497
|
+
this.onAdded();
|
|
498
|
+
}
|
|
499
|
+
this.setStatus(AXPWidgetStatus.Rendered);
|
|
500
|
+
}
|
|
501
|
+
setStatus(status) {
|
|
502
|
+
this._status.set(status);
|
|
503
|
+
this.layoutService.updateStatus();
|
|
504
|
+
}
|
|
505
|
+
setOptions(values) {
|
|
506
|
+
const oldValue = this.options();
|
|
507
|
+
const value = cloneDeep(values);
|
|
508
|
+
this._options.set({ ...oldValue, ...value });
|
|
509
|
+
this.onOptionsChanged.next({ sender: this });
|
|
510
|
+
}
|
|
511
|
+
output(name) {
|
|
512
|
+
const outputs = this.outputs().map((c) => (typeof c == 'string' ? { name: c, value: c } : c));
|
|
513
|
+
if (outputs.some((c) => c.name == name)) {
|
|
514
|
+
const opt = get(this, name);
|
|
515
|
+
if (typeof opt == 'function') {
|
|
516
|
+
return opt();
|
|
517
|
+
}
|
|
518
|
+
return opt;
|
|
519
|
+
}
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
call(name, ...args) {
|
|
523
|
+
const fn = get(this, name);
|
|
524
|
+
if (fn && typeof fn == 'function') {
|
|
525
|
+
fn.bind(this)(...args);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
setChildren(children) {
|
|
529
|
+
this._children.set([...children]);
|
|
530
|
+
}
|
|
531
|
+
onAdded() { }
|
|
532
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPBaseWidgetComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
533
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPBaseWidgetComponent }); }
|
|
534
|
+
}
|
|
535
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPBaseWidgetComponent, decorators: [{
|
|
536
|
+
type: Injectable
|
|
537
|
+
}] });
|
|
538
|
+
class AXPLayoutBaseWidgetComponent extends AXPBaseWidgetComponent {
|
|
539
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPLayoutBaseWidgetComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
540
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPLayoutBaseWidgetComponent }); }
|
|
541
|
+
}
|
|
542
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPLayoutBaseWidgetComponent, decorators: [{
|
|
543
|
+
type: Injectable
|
|
544
|
+
}] });
|
|
545
|
+
class AXPValueWidgetComponent extends AXPLayoutBaseWidgetComponent {
|
|
546
|
+
constructor() {
|
|
547
|
+
super(...arguments);
|
|
548
|
+
this.path = this.token.node.path;
|
|
549
|
+
this.defaultValue = this.token.defaultValue ?? this.token.node.defaultValue;
|
|
550
|
+
this._isValueWidget = false;
|
|
551
|
+
this.isValueWidget = () => this._isValueWidget;
|
|
552
|
+
this.onValueChanged = new Subject();
|
|
553
|
+
this.fullPath = signal(null, ...(ngDevMode ? [{ debugName: "fullPath" }] : []));
|
|
554
|
+
this.parentPath = signal(null, ...(ngDevMode ? [{ debugName: "parentPath" }] : []));
|
|
555
|
+
this.getValue = computed(() => {
|
|
556
|
+
return this.fullPath() ? this.extractValue(this.fullPath()) : null;
|
|
557
|
+
}, ...(ngDevMode ? [{ debugName: "getValue", equal: isEqual }] : [{ equal: isEqual }]));
|
|
558
|
+
this.validationRules = computed(() => {
|
|
559
|
+
const validationsRaw = this.options()['validations'];
|
|
560
|
+
if (validationsRaw == null) {
|
|
561
|
+
return [];
|
|
562
|
+
}
|
|
563
|
+
return Object.values(this.options()['validations'])
|
|
564
|
+
.filter((c) => c != null)
|
|
565
|
+
.map((c) => ({
|
|
566
|
+
rule: c.rule,
|
|
567
|
+
message: c.message,
|
|
568
|
+
options: c.options,
|
|
569
|
+
}));
|
|
570
|
+
}, ...(ngDevMode ? [{ debugName: "validationRules" }] : []));
|
|
571
|
+
}
|
|
572
|
+
ngOnInit() {
|
|
573
|
+
this._isValueWidget = this.config.properties?.some((c) => c.name == 'path') ?? false;
|
|
574
|
+
if (this.isValueWidget()) {
|
|
575
|
+
this.detectFullPath();
|
|
576
|
+
if (!isNil(this.defaultValue) && isNil(this.getValue())) {
|
|
577
|
+
this.setValue(this.defaultValue);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
//
|
|
581
|
+
super.ngOnInit();
|
|
582
|
+
}
|
|
583
|
+
extractValue(path) {
|
|
584
|
+
const rawValue = this.contextService.getValue(path);
|
|
585
|
+
if (this.node.valueTransforms?.getter) {
|
|
586
|
+
return this.node.valueTransforms?.getter(rawValue);
|
|
587
|
+
}
|
|
588
|
+
return rawValue;
|
|
589
|
+
}
|
|
590
|
+
setValue(value) {
|
|
591
|
+
if (this.node.valueTransforms?.setter) {
|
|
592
|
+
value = this.node.valueTransforms?.setter(value);
|
|
593
|
+
}
|
|
594
|
+
const oldValue = this.getValue();
|
|
595
|
+
value = isUndefined(value) ? null : value;
|
|
596
|
+
if (isNil(value) && isNil(oldValue)) {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
if (isEqual(oldValue, value)) {
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
if (this.fullPath()) {
|
|
603
|
+
this.contextService.update(this.fullPath(), value);
|
|
604
|
+
this.onValueChanged.next({ sender: this });
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
detectFullPath() {
|
|
608
|
+
const sections = [];
|
|
609
|
+
const ids = [];
|
|
610
|
+
//
|
|
611
|
+
let parent = this;
|
|
612
|
+
//
|
|
613
|
+
while (parent) {
|
|
614
|
+
const isValueWidget = parent instanceof AXPValueWidgetComponent && parent.isValueWidget();
|
|
615
|
+
const valueParent = parent;
|
|
616
|
+
const path = valueParent.path ?? (isValueWidget ? valueParent.name : null);
|
|
617
|
+
const id = valueParent.name;
|
|
618
|
+
//
|
|
619
|
+
if (path) {
|
|
620
|
+
sections.push(path);
|
|
621
|
+
}
|
|
622
|
+
if (parent.index != null && isValueWidget) {
|
|
623
|
+
sections.push(`[${parent.index}]`);
|
|
624
|
+
}
|
|
625
|
+
if (id) {
|
|
626
|
+
ids.push(id);
|
|
627
|
+
if (parent.index != null) {
|
|
628
|
+
ids.push(`${parent.index}`);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
parent = parent.parent;
|
|
632
|
+
}
|
|
633
|
+
//
|
|
634
|
+
this.fullPath.set(sections.reverse().join('.'));
|
|
635
|
+
this.parentPath.set(sections.slice(0, sections.length - 1).join('.'));
|
|
636
|
+
this._id = this.name || this.parent ? ids.reverse().join('_') : null;
|
|
637
|
+
if (this._id) {
|
|
638
|
+
this.layoutService.registerWidget(this._id, this);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
handleValueChanged(e) {
|
|
642
|
+
if (e.isUserInteraction) {
|
|
643
|
+
this.setValue(e.value);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPValueWidgetComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
647
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPValueWidgetComponent }); }
|
|
648
|
+
}
|
|
649
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPValueWidgetComponent, decorators: [{
|
|
650
|
+
type: Injectable
|
|
651
|
+
}] });
|
|
652
|
+
class AXPDataListWidgetComponent extends AXPValueWidgetComponent {
|
|
653
|
+
constructor() {
|
|
654
|
+
super(...arguments);
|
|
655
|
+
this.dataService = inject(AXPDataSourceDefinitionProviderService);
|
|
656
|
+
this.textField = computed(() => this.options()['textField'] ?? 'title', ...(ngDevMode ? [{ debugName: "textField" }] : []));
|
|
657
|
+
this.valueField = computed(() => this.options()['valueField'] ?? 'id', ...(ngDevMode ? [{ debugName: "valueField" }] : []));
|
|
658
|
+
this.dataSource = signal(convertArrayToDataSource([]), ...(ngDevMode ? [{ debugName: "dataSource" }] : []));
|
|
659
|
+
this.isReady = computed(() => {
|
|
660
|
+
const key = this.dataSource().config?.key;
|
|
661
|
+
const valueField = this.valueField();
|
|
662
|
+
const result = key == valueField;
|
|
663
|
+
return result;
|
|
664
|
+
}, ...(ngDevMode ? [{ debugName: "isReady" }] : []));
|
|
665
|
+
this.selectedItems = signal([], ...(ngDevMode ? [{ debugName: "selectedItems" }] : []));
|
|
666
|
+
this.rf = effect(async () => {
|
|
667
|
+
const rawValue = this.options()['dataSource'];
|
|
668
|
+
// static datasource class
|
|
669
|
+
if (rawValue instanceof AXDataSource) {
|
|
670
|
+
this.dataSource.set(rawValue);
|
|
671
|
+
}
|
|
672
|
+
// static array datasource
|
|
673
|
+
else if (Array.isArray(rawValue)) {
|
|
674
|
+
const ds = new AXDataSource({
|
|
675
|
+
key: this.valueField(),
|
|
676
|
+
pageSize: 10,
|
|
677
|
+
load: async (e) => {
|
|
678
|
+
const raw = this.options()['dataSource'];
|
|
679
|
+
return {
|
|
680
|
+
items: raw,
|
|
681
|
+
total: raw.length,
|
|
682
|
+
};
|
|
683
|
+
},
|
|
684
|
+
byKey: (key) => {
|
|
685
|
+
const raw = this.options()['dataSource'];
|
|
686
|
+
const item = raw.filter((c) => c[this.valueField()] == key);
|
|
687
|
+
return Promise.resolve(item[0]);
|
|
688
|
+
},
|
|
689
|
+
});
|
|
690
|
+
this.dataSource.set(ds);
|
|
691
|
+
}
|
|
692
|
+
// resolve data source by name
|
|
693
|
+
else if (rawValue && (typeof rawValue == 'string' || typeof rawValue == 'object')) {
|
|
694
|
+
const id = typeof rawValue == 'object' ? rawValue['id'] : rawValue;
|
|
695
|
+
const c = await this.dataService.get(id);
|
|
696
|
+
if (this.mode == 'designer' && c?.samples?.length) {
|
|
697
|
+
this.dataSource.set(convertArrayToDataSource(c.samples, {
|
|
698
|
+
key: this.valueField(),
|
|
699
|
+
pageSize: 500,
|
|
700
|
+
}));
|
|
701
|
+
}
|
|
702
|
+
else {
|
|
703
|
+
const ds = c?.source();
|
|
704
|
+
if (ds && ds instanceof Promise) {
|
|
705
|
+
const d = await ds;
|
|
706
|
+
this.dataSource.set(d);
|
|
707
|
+
}
|
|
708
|
+
else if (ds) {
|
|
709
|
+
this.dataSource.set(ds);
|
|
710
|
+
}
|
|
711
|
+
// empty datasource
|
|
712
|
+
else {
|
|
713
|
+
this.dataSource.set(convertArrayToDataSource([]));
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
// empty datasource
|
|
718
|
+
else {
|
|
719
|
+
this.dataSource.set(convertArrayToDataSource([]));
|
|
720
|
+
}
|
|
721
|
+
}, ...(ngDevMode ? [{ debugName: "rf" }] : []));
|
|
722
|
+
this.effect2 = effect(async () => {
|
|
723
|
+
const value = this.getValue();
|
|
724
|
+
const items = [];
|
|
725
|
+
if (Array.isArray(value)) {
|
|
726
|
+
items.push(...(await Promise.all(value.map((item) => this.extractItem(item)))));
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
items.push(await this.extractItem(value));
|
|
730
|
+
}
|
|
731
|
+
this.selectedItems.set(items.filter((c) => c != null));
|
|
732
|
+
}, ...(ngDevMode ? [{ debugName: "effect2" }] : []));
|
|
733
|
+
}
|
|
734
|
+
async extractItem(item) {
|
|
735
|
+
if (isNil(item)) {
|
|
736
|
+
return null;
|
|
737
|
+
}
|
|
738
|
+
if (isObjectLike(item) && get(item, this.textField()) != null) {
|
|
739
|
+
return item;
|
|
740
|
+
}
|
|
741
|
+
const key = extractValue(item, this.valueField());
|
|
742
|
+
const ds = this.dataSource();
|
|
743
|
+
if (ds.config?.byKey) {
|
|
744
|
+
const found = await ds.config?.byKey(key);
|
|
745
|
+
if (found) {
|
|
746
|
+
return found;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
return isObjectLike(item)
|
|
750
|
+
? item
|
|
751
|
+
: {
|
|
752
|
+
[this.valueField()]: item,
|
|
753
|
+
[this.textField()]: item,
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPDataListWidgetComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
757
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPDataListWidgetComponent }); }
|
|
758
|
+
}
|
|
759
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPDataListWidgetComponent, decorators: [{
|
|
760
|
+
type: Injectable
|
|
761
|
+
}] });
|
|
762
|
+
class AXPColumnWidgetComponent {
|
|
763
|
+
constructor() {
|
|
764
|
+
this.token = inject(AXP_WIDGET_COLUMN_TOKEN);
|
|
765
|
+
this.path = this.token.path;
|
|
766
|
+
this.options = this.token.options ?? {};
|
|
767
|
+
this.rawValue = null;
|
|
768
|
+
this.nullText = this.options['nullText'];
|
|
769
|
+
this.nullValue = this.options['nullValue'];
|
|
770
|
+
this.value = computed(() => {
|
|
771
|
+
if (isNil(this.rawValue) && !isNil(this.nullValue)) {
|
|
772
|
+
return this.nullValue;
|
|
773
|
+
}
|
|
774
|
+
return this.rawValue;
|
|
775
|
+
}, ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
776
|
+
}
|
|
777
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPColumnWidgetComponent, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
778
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPColumnWidgetComponent }); }
|
|
779
|
+
}
|
|
780
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPColumnWidgetComponent, decorators: [{
|
|
781
|
+
type: Injectable
|
|
782
|
+
}] });
|
|
783
|
+
|
|
784
|
+
class AXPBoxModelLayoutWidgetComponent extends AXPLayoutBaseWidgetComponent {
|
|
785
|
+
constructor() {
|
|
786
|
+
super(...arguments);
|
|
787
|
+
this.hostBoxStyle = computed(() => {
|
|
788
|
+
const options = this.options();
|
|
789
|
+
const style = {};
|
|
790
|
+
const spacing = options?.['spacing'];
|
|
791
|
+
const border = options?.['border'];
|
|
792
|
+
const backgroundColor = options?.['backgroundColor'];
|
|
793
|
+
const direction = options?.['direction'];
|
|
794
|
+
const overflow = options?.['overflow'];
|
|
795
|
+
const overflowX = options?.['overflowX'];
|
|
796
|
+
const overflowY = options?.['overflowY'];
|
|
797
|
+
style['background-color'] = backgroundColor ?? '';
|
|
798
|
+
style['padding'] = spacing?.padding ?? '';
|
|
799
|
+
style['margin'] = spacing?.margin ?? '';
|
|
800
|
+
style['border-radius'] = border?.radius ?? '';
|
|
801
|
+
style['border-width'] = border?.width ?? '';
|
|
802
|
+
style['border-color'] = border?.color ?? '';
|
|
803
|
+
style['border-style'] = border?.style ?? '';
|
|
804
|
+
style['overflow'] = overflow ?? '';
|
|
805
|
+
style['overflow-x'] = overflowX ?? '';
|
|
806
|
+
style['overflow-y'] = overflowY ?? '';
|
|
807
|
+
style['direction'] = direction ?? '';
|
|
808
|
+
return style;
|
|
809
|
+
}, ...(ngDevMode ? [{ debugName: "hostBoxStyle" }] : []));
|
|
810
|
+
this.blockStyle = computed(() => {
|
|
811
|
+
const options = this.options();
|
|
812
|
+
const style = { ...this.hostBoxStyle() };
|
|
813
|
+
const width = options?.['width'];
|
|
814
|
+
const minWidth = options?.['minWidth'];
|
|
815
|
+
const maxWidth = options?.['maxWidth'];
|
|
816
|
+
const height = options?.['height'];
|
|
817
|
+
const minHeight = options?.['minHeight'];
|
|
818
|
+
const maxHeight = options?.['maxHeight'];
|
|
819
|
+
style['min-width'] = minWidth ?? '';
|
|
820
|
+
style['width'] = width ?? '';
|
|
821
|
+
style['max-width'] = maxWidth ?? '';
|
|
822
|
+
style['min-height'] = minHeight ?? '';
|
|
823
|
+
style['height'] = height ?? '';
|
|
824
|
+
style['max-height'] = maxHeight ?? '';
|
|
825
|
+
return style;
|
|
826
|
+
}, ...(ngDevMode ? [{ debugName: "blockStyle" }] : []));
|
|
827
|
+
this.inlineStyle = computed(() => {
|
|
828
|
+
return { ...this.hostBoxStyle() };
|
|
829
|
+
}, ...(ngDevMode ? [{ debugName: "inlineStyle" }] : []));
|
|
830
|
+
this.blockClass = computed(() => {
|
|
831
|
+
return {
|
|
832
|
+
'ax-block': true,
|
|
833
|
+
'ax-w-full': true,
|
|
834
|
+
// 'ax-widget-outline': true,
|
|
835
|
+
};
|
|
836
|
+
}, ...(ngDevMode ? [{ debugName: "blockClass" }] : []));
|
|
837
|
+
this.inlineClass = computed(() => {
|
|
838
|
+
return {
|
|
839
|
+
'ax-inline-block': true,
|
|
840
|
+
};
|
|
841
|
+
}, ...(ngDevMode ? [{ debugName: "inlineClass" }] : []));
|
|
842
|
+
}
|
|
843
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPBoxModelLayoutWidgetComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
844
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPBoxModelLayoutWidgetComponent }); }
|
|
845
|
+
}
|
|
846
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPBoxModelLayoutWidgetComponent, decorators: [{
|
|
847
|
+
type: Injectable
|
|
848
|
+
}] });
|
|
849
|
+
|
|
850
|
+
class AXPBlockBaseLayoutWidgetComponent extends AXPBoxModelLayoutWidgetComponent {
|
|
851
|
+
constructor() {
|
|
852
|
+
super(...arguments);
|
|
853
|
+
this.hostClass = computed(() => this.blockClass(), ...(ngDevMode ? [{ debugName: "hostClass" }] : []));
|
|
854
|
+
this.hostStyle = computed(() => this.blockStyle(), ...(ngDevMode ? [{ debugName: "hostStyle" }] : []));
|
|
855
|
+
}
|
|
856
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPBlockBaseLayoutWidgetComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
857
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPBlockBaseLayoutWidgetComponent }); }
|
|
858
|
+
}
|
|
859
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPBlockBaseLayoutWidgetComponent, decorators: [{
|
|
860
|
+
type: Injectable
|
|
861
|
+
}] });
|
|
862
|
+
|
|
863
|
+
class AXPFlexBaseLayoutWidgetComponent extends AXPBlockBaseLayoutWidgetComponent {
|
|
864
|
+
constructor() {
|
|
865
|
+
super(...arguments);
|
|
866
|
+
this.flex = computed(() => this.options(), ...(ngDevMode ? [{ debugName: "flex" }] : []));
|
|
867
|
+
this.hostFlexStyle = computed(() => {
|
|
868
|
+
const blockStyle = this.blockStyle();
|
|
869
|
+
const style = { ...blockStyle };
|
|
870
|
+
const flex = this.flex();
|
|
871
|
+
if (isNil(flex?.flexDirection)) {
|
|
872
|
+
style['flex-direction'] = '';
|
|
873
|
+
}
|
|
874
|
+
else {
|
|
875
|
+
style['flex-direction'] = flex.flexDirection;
|
|
876
|
+
}
|
|
877
|
+
if (isNil(flex?.flexWrap)) {
|
|
878
|
+
style['flex-wrap'] = '';
|
|
879
|
+
}
|
|
880
|
+
else {
|
|
881
|
+
style['flex-wrap'] = flex.flexWrap;
|
|
882
|
+
}
|
|
883
|
+
//TODO NEED TO FIX LATER
|
|
884
|
+
style['overflow'] = flex?.flexWrap === 'nowrap' ? 'auto' : '';
|
|
885
|
+
//END
|
|
886
|
+
if (isNil(flex?.justifyContent)) {
|
|
887
|
+
style['justify-content'] = '';
|
|
888
|
+
}
|
|
889
|
+
else {
|
|
890
|
+
style['justify-content'] = flex.justifyContent;
|
|
891
|
+
}
|
|
892
|
+
if (isNil(flex?.alignItems)) {
|
|
893
|
+
style['align-items'] = '';
|
|
894
|
+
}
|
|
895
|
+
else {
|
|
896
|
+
style['align-items'] = flex.alignItems;
|
|
897
|
+
}
|
|
898
|
+
if (isNil(flex?.gap)) {
|
|
899
|
+
style['gap'] = '';
|
|
900
|
+
}
|
|
901
|
+
else {
|
|
902
|
+
style['gap'] = flex.gap;
|
|
903
|
+
}
|
|
904
|
+
return style;
|
|
905
|
+
}, ...(ngDevMode ? [{ debugName: "hostFlexStyle" }] : []));
|
|
906
|
+
this.hostFlexClass = computed(() => {
|
|
907
|
+
return {
|
|
908
|
+
...this.blockClass(),
|
|
909
|
+
'ax-flex': true,
|
|
910
|
+
'ax-h-full': true,
|
|
911
|
+
};
|
|
912
|
+
}, ...(ngDevMode ? [{ debugName: "hostFlexClass" }] : []));
|
|
913
|
+
this.hostClass = computed(() => {
|
|
914
|
+
return this.hostFlexClass();
|
|
915
|
+
}, ...(ngDevMode ? [{ debugName: "hostClass" }] : []));
|
|
916
|
+
this.hostStyle = computed(() => {
|
|
917
|
+
return this.hostFlexStyle();
|
|
918
|
+
}, ...(ngDevMode ? [{ debugName: "hostStyle" }] : []));
|
|
919
|
+
}
|
|
920
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPFlexBaseLayoutWidgetComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
921
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPFlexBaseLayoutWidgetComponent }); }
|
|
922
|
+
}
|
|
923
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPFlexBaseLayoutWidgetComponent, decorators: [{
|
|
924
|
+
type: Injectable
|
|
925
|
+
}] });
|
|
926
|
+
|
|
927
|
+
class AXPInlineBaseLayoutWidgetComponent extends AXPBoxModelLayoutWidgetComponent {
|
|
928
|
+
constructor() {
|
|
929
|
+
super(...arguments);
|
|
930
|
+
this.hostClass = computed(() => this.inlineClass(), ...(ngDevMode ? [{ debugName: "hostClass" }] : []));
|
|
931
|
+
this.hostStyle = computed(() => this.inlineStyle(), ...(ngDevMode ? [{ debugName: "hostStyle" }] : []));
|
|
932
|
+
}
|
|
933
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPInlineBaseLayoutWidgetComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
934
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPInlineBaseLayoutWidgetComponent }); }
|
|
935
|
+
}
|
|
936
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPInlineBaseLayoutWidgetComponent, decorators: [{
|
|
937
|
+
type: Injectable
|
|
938
|
+
}] });
|
|
939
|
+
|
|
940
|
+
class AXPFlexItemBaseLayoutWidgetComponent extends AXPInlineBaseLayoutWidgetComponent {
|
|
941
|
+
constructor() {
|
|
942
|
+
super(...arguments);
|
|
943
|
+
this.flexItem = computed(() => this.options(), ...(ngDevMode ? [{ debugName: "flexItem" }] : []));
|
|
944
|
+
this.hostFlexItemStyle = computed(() => {
|
|
945
|
+
const inlineStyle = this.blockStyle();
|
|
946
|
+
const style = { ...inlineStyle };
|
|
947
|
+
const fi = this.flexItem();
|
|
948
|
+
if (isNil(fi?.order)) {
|
|
949
|
+
style['order'] = '';
|
|
950
|
+
}
|
|
951
|
+
else {
|
|
952
|
+
style['order'] = fi.order;
|
|
953
|
+
}
|
|
954
|
+
if (isNil(fi?.grow)) {
|
|
955
|
+
style['flex-grow'] = '';
|
|
956
|
+
}
|
|
957
|
+
else {
|
|
958
|
+
style['flex-grow'] = fi.grow;
|
|
959
|
+
}
|
|
960
|
+
if (isNil(fi?.shrink)) {
|
|
961
|
+
style['flex-shrink'] = '';
|
|
962
|
+
}
|
|
963
|
+
else {
|
|
964
|
+
style['flex-shrink'] = fi.shrink;
|
|
965
|
+
}
|
|
966
|
+
if (isNil(fi?.basis)) {
|
|
967
|
+
style['flex-basis'] = '';
|
|
968
|
+
}
|
|
969
|
+
else {
|
|
970
|
+
style['flex-basis'] = fi.basis;
|
|
971
|
+
}
|
|
972
|
+
if (isNil(fi?.alignSelf)) {
|
|
973
|
+
style['align-self'] = '';
|
|
974
|
+
}
|
|
975
|
+
else {
|
|
976
|
+
style['align-self'] = fi.alignSelf;
|
|
977
|
+
}
|
|
978
|
+
return style;
|
|
979
|
+
}, ...(ngDevMode ? [{ debugName: "hostFlexItemStyle" }] : []));
|
|
980
|
+
this.hostFlexItemClass = computed(() => {
|
|
981
|
+
return {
|
|
982
|
+
...this.blockClass(),
|
|
983
|
+
};
|
|
984
|
+
}, ...(ngDevMode ? [{ debugName: "hostFlexItemClass" }] : []));
|
|
985
|
+
this.hostClass = computed(() => {
|
|
986
|
+
return this.hostFlexItemClass();
|
|
987
|
+
}, ...(ngDevMode ? [{ debugName: "hostClass" }] : []));
|
|
988
|
+
this.hostStyle = computed(() => {
|
|
989
|
+
return this.hostFlexItemStyle();
|
|
990
|
+
}, ...(ngDevMode ? [{ debugName: "hostStyle" }] : []));
|
|
991
|
+
}
|
|
992
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPFlexItemBaseLayoutWidgetComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
993
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPFlexItemBaseLayoutWidgetComponent }); }
|
|
994
|
+
}
|
|
995
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPFlexItemBaseLayoutWidgetComponent, decorators: [{
|
|
996
|
+
type: Injectable
|
|
997
|
+
}] });
|
|
998
|
+
|
|
999
|
+
class AXPGridBaseLayoutWidgetComponent extends AXPBlockBaseLayoutWidgetComponent {
|
|
1000
|
+
constructor() {
|
|
1001
|
+
super(...arguments);
|
|
1002
|
+
this.grid = computed(() => this.options()?.['grid'], ...(ngDevMode ? [{ debugName: "grid" }] : []));
|
|
1003
|
+
this.hostGridStyle = computed(() => {
|
|
1004
|
+
const style = { ...this.inlineStyle() };
|
|
1005
|
+
const g = this.grid()?.default;
|
|
1006
|
+
if (g?.gap)
|
|
1007
|
+
style['gap'] = g.gap;
|
|
1008
|
+
return style;
|
|
1009
|
+
}, ...(ngDevMode ? [{ debugName: "hostGridStyle" }] : []));
|
|
1010
|
+
this.hostGridClass = computed(() => {
|
|
1011
|
+
const cls = {
|
|
1012
|
+
...this.inlineClass(),
|
|
1013
|
+
'ax-grid': true,
|
|
1014
|
+
};
|
|
1015
|
+
const g = this.grid()?.default;
|
|
1016
|
+
if (g?.columns)
|
|
1017
|
+
cls[`lg:ax-grid-cols-${g.columns}`] = true;
|
|
1018
|
+
if (g?.rows)
|
|
1019
|
+
cls[`lg:ax-grid-rows-${g.rows}`] = true;
|
|
1020
|
+
if (g?.justifyItems)
|
|
1021
|
+
cls[`lg:ax-justify-items-${g.justifyItems}`] = true;
|
|
1022
|
+
if (g?.alignItems)
|
|
1023
|
+
cls[`lg:ax-align-items-${g.alignItems}`] = true;
|
|
1024
|
+
if (g?.autoFlow)
|
|
1025
|
+
cls[`lg:ax-grid-flow-${g.autoFlow}`] = true;
|
|
1026
|
+
return cls;
|
|
1027
|
+
}, ...(ngDevMode ? [{ debugName: "hostGridClass" }] : []));
|
|
1028
|
+
this.hostClass = computed(() => this.hostGridClass(), ...(ngDevMode ? [{ debugName: "hostClass" }] : []));
|
|
1029
|
+
this.hostStyle = computed(() => this.hostGridStyle(), ...(ngDevMode ? [{ debugName: "hostStyle" }] : []));
|
|
1030
|
+
}
|
|
1031
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPGridBaseLayoutWidgetComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1032
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPGridBaseLayoutWidgetComponent }); }
|
|
1033
|
+
}
|
|
1034
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPGridBaseLayoutWidgetComponent, decorators: [{
|
|
1035
|
+
type: Injectable
|
|
1036
|
+
}] });
|
|
1037
|
+
|
|
1038
|
+
class AXPGridItemBaseLayoutWidgetComponent extends AXPFlexBaseLayoutWidgetComponent {
|
|
1039
|
+
constructor() {
|
|
1040
|
+
super(...arguments);
|
|
1041
|
+
this.gridItem = computed(() => this.options(), ...(ngDevMode ? [{ debugName: "gridItem" }] : []));
|
|
1042
|
+
this.hostGridItemStyle = computed(() => {
|
|
1043
|
+
const style = { ...this.hostFlexStyle() };
|
|
1044
|
+
const g = this.gridItem();
|
|
1045
|
+
if (g?.alignSelf)
|
|
1046
|
+
style['align-self'] = g.alignSelf;
|
|
1047
|
+
if (g?.justifySelf)
|
|
1048
|
+
style['justify-self'] = g.justifySelf;
|
|
1049
|
+
return style;
|
|
1050
|
+
}, ...(ngDevMode ? [{ debugName: "hostGridItemStyle" }] : []));
|
|
1051
|
+
this.hostGridItemClass = computed(() => {
|
|
1052
|
+
const cls = { ...this.hostFlexClass() };
|
|
1053
|
+
const g = this.gridItem();
|
|
1054
|
+
if (g?.colSpan)
|
|
1055
|
+
cls[`lg:ax-col-span-${g.colSpan}`] = true;
|
|
1056
|
+
if (g?.colStart)
|
|
1057
|
+
cls[`lg:ax-col-start-${g.colStart}`] = true;
|
|
1058
|
+
if (g?.colEnd)
|
|
1059
|
+
cls[`lg:ax-col-end-${g.colEnd}`] = true;
|
|
1060
|
+
if (g?.rowSpan)
|
|
1061
|
+
cls[`lg:ax-row-span-${g.rowSpan}`] = true;
|
|
1062
|
+
if (g?.rowStart)
|
|
1063
|
+
cls[`lg:ax-row-start-${g.rowStart}`] = true;
|
|
1064
|
+
if (g?.rowEnd)
|
|
1065
|
+
cls[`lg:ax-row-end-${g.rowEnd}`] = true;
|
|
1066
|
+
return cls;
|
|
1067
|
+
}, ...(ngDevMode ? [{ debugName: "hostGridItemClass" }] : []));
|
|
1068
|
+
this.hostClass = computed(() => this.hostGridItemClass(), ...(ngDevMode ? [{ debugName: "hostClass" }] : []));
|
|
1069
|
+
this.hostStyle = computed(() => this.hostGridItemStyle(), ...(ngDevMode ? [{ debugName: "hostStyle" }] : []));
|
|
1070
|
+
}
|
|
1071
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPGridItemBaseLayoutWidgetComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1072
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPGridItemBaseLayoutWidgetComponent }); }
|
|
1073
|
+
}
|
|
1074
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPGridItemBaseLayoutWidgetComponent, decorators: [{
|
|
1075
|
+
type: Injectable
|
|
1076
|
+
}] });
|
|
1077
|
+
|
|
1078
|
+
class AXPTableBaseLayoutWidgetComponent extends AXPBlockBaseLayoutWidgetComponent {
|
|
1079
|
+
constructor() {
|
|
1080
|
+
super(...arguments);
|
|
1081
|
+
this.hostTableClass = computed(() => ({
|
|
1082
|
+
...this.blockClass(),
|
|
1083
|
+
}), ...(ngDevMode ? [{ debugName: "hostTableClass" }] : []));
|
|
1084
|
+
this.hostTableStyle = computed(() => {
|
|
1085
|
+
const style = { ...this.blockStyle() };
|
|
1086
|
+
style['overflow-x'] = 'auto';
|
|
1087
|
+
return style;
|
|
1088
|
+
}, ...(ngDevMode ? [{ debugName: "hostTableStyle" }] : []));
|
|
1089
|
+
this.hostClass = computed(() => this.hostTableClass(), ...(ngDevMode ? [{ debugName: "hostClass" }] : []));
|
|
1090
|
+
this.hostStyle = computed(() => this.hostTableStyle(), ...(ngDevMode ? [{ debugName: "hostStyle" }] : []));
|
|
1091
|
+
}
|
|
1092
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPTableBaseLayoutWidgetComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1093
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPTableBaseLayoutWidgetComponent }); }
|
|
1094
|
+
}
|
|
1095
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPTableBaseLayoutWidgetComponent, decorators: [{
|
|
1096
|
+
type: Injectable
|
|
1097
|
+
}] });
|
|
1098
|
+
|
|
1099
|
+
class AXPTableItemOpsBaseLayoutWidgetComponent extends AXPBlockBaseLayoutWidgetComponent {
|
|
1100
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPTableItemOpsBaseLayoutWidgetComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1101
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPTableItemOpsBaseLayoutWidgetComponent }); }
|
|
1102
|
+
}
|
|
1103
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPTableItemOpsBaseLayoutWidgetComponent, decorators: [{
|
|
1104
|
+
type: Injectable
|
|
1105
|
+
}] });
|
|
1106
|
+
|
|
1107
|
+
class AXPTableItemBaseLayoutWidgetComponent extends AXPTableItemOpsBaseLayoutWidgetComponent {
|
|
1108
|
+
constructor() {
|
|
1109
|
+
super(...arguments);
|
|
1110
|
+
this.colSpan = computed(() => {
|
|
1111
|
+
const v = this.options()?.colSpan;
|
|
1112
|
+
return v ? Math.max(1, v) : 1;
|
|
1113
|
+
}, ...(ngDevMode ? [{ debugName: "colSpan" }] : []));
|
|
1114
|
+
this.rowSpan = computed(() => {
|
|
1115
|
+
const v = this.options()?.rowSpan;
|
|
1116
|
+
return v ? Math.max(1, v) : 1;
|
|
1117
|
+
}, ...(ngDevMode ? [{ debugName: "rowSpan" }] : []));
|
|
1118
|
+
this.hostClass = computed(() => this.blockClass(), ...(ngDevMode ? [{ debugName: "hostClass" }] : []));
|
|
1119
|
+
this.hostStyle = computed(() => this.blockStyle(), ...(ngDevMode ? [{ debugName: "hostStyle" }] : []));
|
|
1120
|
+
}
|
|
1121
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPTableItemBaseLayoutWidgetComponent, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1122
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPTableItemBaseLayoutWidgetComponent }); }
|
|
1123
|
+
}
|
|
1124
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPTableItemBaseLayoutWidgetComponent, decorators: [{
|
|
1125
|
+
type: Injectable
|
|
1126
|
+
}] });
|
|
1127
|
+
|
|
1128
|
+
class AXPWidgetRegistryService {
|
|
1129
|
+
/**
|
|
1130
|
+
*
|
|
1131
|
+
*/
|
|
1132
|
+
constructor() {
|
|
1133
|
+
this.types = new Map();
|
|
1134
|
+
AXPWidgetRegistryService.instance = this;
|
|
1135
|
+
}
|
|
1136
|
+
register(widget) {
|
|
1137
|
+
this.types.set(widget.name, widget);
|
|
1138
|
+
}
|
|
1139
|
+
extend(parentName, widget) {
|
|
1140
|
+
const parentWidget = this.resolve(parentName);
|
|
1141
|
+
const newWidget = merge({}, parentWidget, widget);
|
|
1142
|
+
newWidget.name = widget.name;
|
|
1143
|
+
this.register(newWidget);
|
|
1144
|
+
}
|
|
1145
|
+
resolve(name) {
|
|
1146
|
+
const widget = this.types.get(name);
|
|
1147
|
+
if (!widget) {
|
|
1148
|
+
throw new Error(`Widget with name "${name}" does not exist.`);
|
|
1149
|
+
}
|
|
1150
|
+
return widget;
|
|
1151
|
+
}
|
|
1152
|
+
all() {
|
|
1153
|
+
return Array.from(this.types.values());
|
|
1154
|
+
}
|
|
1155
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetRegistryService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1156
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetRegistryService, providedIn: 'root' }); }
|
|
1157
|
+
}
|
|
1158
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetRegistryService, decorators: [{
|
|
1159
|
+
type: Injectable,
|
|
1160
|
+
args: [{
|
|
1161
|
+
providedIn: 'root',
|
|
1162
|
+
}]
|
|
1163
|
+
}], ctorParameters: () => [] });
|
|
1164
|
+
|
|
1165
|
+
class AXPWidgetColumnRendererComponent extends AXDataTableColumnComponent {
|
|
1166
|
+
constructor() {
|
|
1167
|
+
super(...arguments);
|
|
1168
|
+
this.widgetRegistery = inject(AXPWidgetRegistryService);
|
|
1169
|
+
this.grid = inject(AXBaseDataTable);
|
|
1170
|
+
this.mergedOptions = signal({}, ...(ngDevMode ? [{ debugName: "mergedOptions" }] : []));
|
|
1171
|
+
this.loadingRow = signal(null, ...(ngDevMode ? [{ debugName: "loadingRow" }] : []));
|
|
1172
|
+
this.injector = inject(Injector);
|
|
1173
|
+
this.cdr = inject(ChangeDetectorRef);
|
|
1174
|
+
}
|
|
1175
|
+
get node() {
|
|
1176
|
+
return this._node;
|
|
1177
|
+
}
|
|
1178
|
+
set node(v) {
|
|
1179
|
+
this._node = v;
|
|
1180
|
+
}
|
|
1181
|
+
get renderFooterTemplate() {
|
|
1182
|
+
return this.footerTemplate ?? this._contentFooterTemplate;
|
|
1183
|
+
}
|
|
1184
|
+
get renderCellTemplate() {
|
|
1185
|
+
return this.cellTemplate ?? this._contentCellTemplate;
|
|
1186
|
+
}
|
|
1187
|
+
async handleExpandRow(row) {
|
|
1188
|
+
this.loadingRow.set(row);
|
|
1189
|
+
await this.grid.expandRow(row);
|
|
1190
|
+
this.loadingRow.set(null);
|
|
1191
|
+
// if (row.data?.__meta__?.expanded === undefined) {
|
|
1192
|
+
// this.width = `${parseInt(this.width as string) + 24}px`;
|
|
1193
|
+
// }
|
|
1194
|
+
}
|
|
1195
|
+
get renderHeaderTemplate() {
|
|
1196
|
+
return this.headerTemplate ?? this._contentHeaderTemplate;
|
|
1197
|
+
}
|
|
1198
|
+
get loadingEnabled() {
|
|
1199
|
+
return true;
|
|
1200
|
+
}
|
|
1201
|
+
get name() {
|
|
1202
|
+
return `col-${this.node.path}`;
|
|
1203
|
+
}
|
|
1204
|
+
async ngOnInit() {
|
|
1205
|
+
const widget = this.widgetRegistery.resolve(this.node.type);
|
|
1206
|
+
const mode = 'column';
|
|
1207
|
+
this.component = await widget?.components[mode]?.component();
|
|
1208
|
+
//
|
|
1209
|
+
const props = widget?.components[mode]?.properties
|
|
1210
|
+
?.filter((c) => c.schema.defaultValue)
|
|
1211
|
+
.map((c) => ({ [c.name]: c.schema.defaultValue }))
|
|
1212
|
+
.reduce((acc, curr) => {
|
|
1213
|
+
return { ...acc, ...curr };
|
|
1214
|
+
}, {});
|
|
1215
|
+
//
|
|
1216
|
+
this.mergedOptions.set(merge(props, this.node.options) || {});
|
|
1217
|
+
const tokenValue = {
|
|
1218
|
+
path: this.node.path,
|
|
1219
|
+
options: this.mergedOptions(),
|
|
1220
|
+
};
|
|
1221
|
+
this.widgetInjector = Injector.create({
|
|
1222
|
+
parent: this.injector,
|
|
1223
|
+
providers: [
|
|
1224
|
+
{
|
|
1225
|
+
provide: AXP_WIDGET_COLUMN_TOKEN,
|
|
1226
|
+
useValue: tokenValue,
|
|
1227
|
+
},
|
|
1228
|
+
],
|
|
1229
|
+
});
|
|
1230
|
+
this.width = this.customWidth ? this.customWidth : (this.mergedOptions().width ?? '200px');
|
|
1231
|
+
this.allowResizing = this.mergedOptions().allowResizing || true;
|
|
1232
|
+
this.cdr.detectChanges();
|
|
1233
|
+
}
|
|
1234
|
+
getInputs(data) {
|
|
1235
|
+
return {
|
|
1236
|
+
rawValue: getSmart(data, this.node.path),
|
|
1237
|
+
rowData: data,
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetColumnRendererComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
1241
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.4", type: AXPWidgetColumnRendererComponent, isStandalone: false, selector: "axp-widget-column-renderer", inputs: { caption: "caption", customExpandIcon: "customExpandIcon", customCollapseIcon: "customCollapseIcon", customWidth: "customWidth", node: "node", footerTemplate: "footerTemplate", expandHandler: "expandHandler", cellTemplate: "cellTemplate", headerTemplate: "headerTemplate" }, providers: [
|
|
1242
|
+
AXPWidgetCoreService,
|
|
1243
|
+
{ provide: AXDataTableColumnComponent, useExisting: AXPWidgetColumnRendererComponent },
|
|
1244
|
+
], viewQueries: [{ propertyName: "_contentFooterTemplate", first: true, predicate: ["footer"], descendants: true }, { propertyName: "_contentCellTemplate", first: true, predicate: ["cell"], descendants: true }, { propertyName: "_contentHeaderTemplate", first: true, predicate: ["header"], descendants: true }], usesInheritance: true, ngImport: i0, template: `
|
|
1245
|
+
<ng-template #header>{{ caption | translate | async }}</ng-template>
|
|
1246
|
+
<ng-template #cell let-row>
|
|
1247
|
+
<div class="ax-flex ax-gap-2 ax-items-center">
|
|
1248
|
+
@if (expandHandler) {
|
|
1249
|
+
<div
|
|
1250
|
+
(click)="handleExpandRow(row)"
|
|
1251
|
+
class="ax-expand-handler"
|
|
1252
|
+
[class.ax-invisible]="row.data.hasChild === false"
|
|
1253
|
+
id="ax-expand-handler-container"
|
|
1254
|
+
[style.padding-inline-start.rem]="row.data?.__meta__?.level * 2"
|
|
1255
|
+
>
|
|
1256
|
+
@if (loadingRow() === row) {
|
|
1257
|
+
<i class="fas fa-spinner-third ax-animate-twSpin ax-animate-infinite"></i>
|
|
1258
|
+
} @else {
|
|
1259
|
+
@if (row.data?.__meta__?.expanded) {
|
|
1260
|
+
<i [class]="customCollapseIcon || 'far fa-minus-square ax-text-md ax-opacity-75'"></i>
|
|
1261
|
+
} @else {
|
|
1262
|
+
<i [class]="customExpandIcon || 'far fa-plus-square ax-text-md ax-opacity-75'"></i>
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
</div>
|
|
1266
|
+
}
|
|
1267
|
+
@if (component && widgetInjector && row?.data) {
|
|
1268
|
+
<ng-container
|
|
1269
|
+
*ngComponentOutlet="component; injector: widgetInjector; inputs: getInputs(row.data)"
|
|
1270
|
+
></ng-container>
|
|
1271
|
+
}
|
|
1272
|
+
</div>
|
|
1273
|
+
</ng-template>
|
|
1274
|
+
<ng-template #footer></ng-template>
|
|
1275
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule", "ngComponentOutletNgModuleFactory"], exportAs: ["ngComponentOutlet"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "pipe", type: i2.AXTranslatorPipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1276
|
+
}
|
|
1277
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetColumnRendererComponent, decorators: [{
|
|
1278
|
+
type: Component,
|
|
1279
|
+
args: [{
|
|
1280
|
+
selector: 'axp-widget-column-renderer',
|
|
1281
|
+
template: `
|
|
1282
|
+
<ng-template #header>{{ caption | translate | async }}</ng-template>
|
|
1283
|
+
<ng-template #cell let-row>
|
|
1284
|
+
<div class="ax-flex ax-gap-2 ax-items-center">
|
|
1285
|
+
@if (expandHandler) {
|
|
1286
|
+
<div
|
|
1287
|
+
(click)="handleExpandRow(row)"
|
|
1288
|
+
class="ax-expand-handler"
|
|
1289
|
+
[class.ax-invisible]="row.data.hasChild === false"
|
|
1290
|
+
id="ax-expand-handler-container"
|
|
1291
|
+
[style.padding-inline-start.rem]="row.data?.__meta__?.level * 2"
|
|
1292
|
+
>
|
|
1293
|
+
@if (loadingRow() === row) {
|
|
1294
|
+
<i class="fas fa-spinner-third ax-animate-twSpin ax-animate-infinite"></i>
|
|
1295
|
+
} @else {
|
|
1296
|
+
@if (row.data?.__meta__?.expanded) {
|
|
1297
|
+
<i [class]="customCollapseIcon || 'far fa-minus-square ax-text-md ax-opacity-75'"></i>
|
|
1298
|
+
} @else {
|
|
1299
|
+
<i [class]="customExpandIcon || 'far fa-plus-square ax-text-md ax-opacity-75'"></i>
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
</div>
|
|
1303
|
+
}
|
|
1304
|
+
@if (component && widgetInjector && row?.data) {
|
|
1305
|
+
<ng-container
|
|
1306
|
+
*ngComponentOutlet="component; injector: widgetInjector; inputs: getInputs(row.data)"
|
|
1307
|
+
></ng-container>
|
|
1308
|
+
}
|
|
1309
|
+
</div>
|
|
1310
|
+
</ng-template>
|
|
1311
|
+
<ng-template #footer></ng-template>
|
|
1312
|
+
`,
|
|
1313
|
+
providers: [
|
|
1314
|
+
AXPWidgetCoreService,
|
|
1315
|
+
{ provide: AXDataTableColumnComponent, useExisting: AXPWidgetColumnRendererComponent },
|
|
1316
|
+
],
|
|
1317
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1318
|
+
inputs: ['caption'],
|
|
1319
|
+
standalone: false,
|
|
1320
|
+
}]
|
|
1321
|
+
}], propDecorators: { customExpandIcon: [{
|
|
1322
|
+
type: Input
|
|
1323
|
+
}], customCollapseIcon: [{
|
|
1324
|
+
type: Input
|
|
1325
|
+
}], customWidth: [{
|
|
1326
|
+
type: Input
|
|
1327
|
+
}], node: [{
|
|
1328
|
+
type: Input,
|
|
1329
|
+
args: [{ required: true }]
|
|
1330
|
+
}], footerTemplate: [{
|
|
1331
|
+
type: Input
|
|
1332
|
+
}], _contentFooterTemplate: [{
|
|
1333
|
+
type: ViewChild,
|
|
1334
|
+
args: ['footer']
|
|
1335
|
+
}], expandHandler: [{
|
|
1336
|
+
type: Input
|
|
1337
|
+
}], cellTemplate: [{
|
|
1338
|
+
type: Input
|
|
1339
|
+
}], _contentCellTemplate: [{
|
|
1340
|
+
type: ViewChild,
|
|
1341
|
+
args: ['cell']
|
|
1342
|
+
}], headerTemplate: [{
|
|
1343
|
+
type: Input
|
|
1344
|
+
}], _contentHeaderTemplate: [{
|
|
1345
|
+
type: ViewChild,
|
|
1346
|
+
args: ['header']
|
|
1347
|
+
}] } });
|
|
1348
|
+
|
|
1349
|
+
class AXPWidgetContainerComponent {
|
|
1350
|
+
set context(value) {
|
|
1351
|
+
this.contextService.set(value);
|
|
1352
|
+
}
|
|
1353
|
+
set functions(v) {
|
|
1354
|
+
this.builderService.setFunctions(v);
|
|
1355
|
+
}
|
|
1356
|
+
constructor() {
|
|
1357
|
+
this.contextService = inject(AXPWidgetCoreContextStore);
|
|
1358
|
+
this.builderService = inject(AXPWidgetCoreService);
|
|
1359
|
+
this.onContextChanged = new EventEmitter();
|
|
1360
|
+
this.status = computed(() => {
|
|
1361
|
+
return this.builderService.status();
|
|
1362
|
+
}, ...(ngDevMode ? [{ debugName: "status" }] : []));
|
|
1363
|
+
this.isBusy = computed(() => {
|
|
1364
|
+
return this.builderService.isBusy();
|
|
1365
|
+
}, ...(ngDevMode ? [{ debugName: "isBusy" }] : []));
|
|
1366
|
+
effect(() => {
|
|
1367
|
+
if (this.contextService.isChanged()) {
|
|
1368
|
+
this.onContextChanged.emit(this.contextService.changeEvent());
|
|
1369
|
+
}
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
refresh() {
|
|
1373
|
+
this.builderService.refresh();
|
|
1374
|
+
}
|
|
1375
|
+
find(name) {
|
|
1376
|
+
return this.builderService.waitForWidget(name);
|
|
1377
|
+
}
|
|
1378
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1379
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.4", type: AXPWidgetContainerComponent, isStandalone: false, selector: "axp-widgets-container", inputs: { context: "context", functions: "functions" }, outputs: { onContextChanged: "onContextChanged" }, host: { styleAttribute: "display: contents;" }, providers: [AXPWidgetCoreService, AXPWidgetCoreContextStore], ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1380
|
+
}
|
|
1381
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetContainerComponent, decorators: [{
|
|
1382
|
+
type: Component,
|
|
1383
|
+
args: [{
|
|
1384
|
+
selector: 'axp-widgets-container',
|
|
1385
|
+
template: `<ng-content></ng-content>`,
|
|
1386
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1387
|
+
host: { style: 'display: contents;' },
|
|
1388
|
+
providers: [AXPWidgetCoreService, AXPWidgetCoreContextStore],
|
|
1389
|
+
standalone: false,
|
|
1390
|
+
}]
|
|
1391
|
+
}], ctorParameters: () => [], propDecorators: { onContextChanged: [{
|
|
1392
|
+
type: Output
|
|
1393
|
+
}], context: [{
|
|
1394
|
+
type: Input
|
|
1395
|
+
}], functions: [{
|
|
1396
|
+
type: Input
|
|
1397
|
+
}] } });
|
|
1398
|
+
|
|
1399
|
+
class AXPWidgetPlaceholderComponent {
|
|
1400
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetPlaceholderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1401
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.4", type: AXPWidgetPlaceholderComponent, isStandalone: true, selector: "axp-widget-placeholder", ngImport: i0, template: `<div>
|
|
1402
|
+
<ax-skeleton class="ax-w-full ax-h-10 ax-rounded-md"></ax-skeleton>
|
|
1403
|
+
</div>`, isInline: true, dependencies: [{ kind: "ngmodule", type: AXSkeletonModule }, { kind: "component", type: i1$1.AXSkeletonComponent, selector: "ax-skeleton", inputs: ["animated"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1404
|
+
}
|
|
1405
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetPlaceholderComponent, decorators: [{
|
|
1406
|
+
type: Component,
|
|
1407
|
+
args: [{
|
|
1408
|
+
selector: 'axp-widget-placeholder',
|
|
1409
|
+
template: `<div>
|
|
1410
|
+
<ax-skeleton class="ax-w-full ax-h-10 ax-rounded-md"></ax-skeleton>
|
|
1411
|
+
</div>`,
|
|
1412
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1413
|
+
imports: [AXSkeletonModule],
|
|
1414
|
+
standalone: true,
|
|
1415
|
+
}]
|
|
1416
|
+
}] });
|
|
1417
|
+
|
|
1418
|
+
class AXPWidgetRendererDirective {
|
|
1419
|
+
//#endregion
|
|
1420
|
+
//#endregion
|
|
1421
|
+
constructor() {
|
|
1422
|
+
this.parentNode = input(...(ngDevMode ? [undefined, { debugName: "parentNode" }] : []));
|
|
1423
|
+
this.index = input(...(ngDevMode ? [undefined, { debugName: "index" }] : []));
|
|
1424
|
+
this.mode = input.required(...(ngDevMode ? [{ debugName: "mode" }] : []));
|
|
1425
|
+
this.node = input.required(...(ngDevMode ? [{ debugName: "node" }] : []));
|
|
1426
|
+
this._options = signal({}, ...(ngDevMode ? [{ debugName: "_options" }] : []));
|
|
1427
|
+
this.options = this._options.asReadonly();
|
|
1428
|
+
this.onOptionsChanged = output();
|
|
1429
|
+
this.onValueChanged = output();
|
|
1430
|
+
//#region ---- Properties ----
|
|
1431
|
+
this.mergedOptions = signal({}, ...(ngDevMode ? [{ debugName: "mergedOptions" }] : []));
|
|
1432
|
+
this.injector = inject(Injector);
|
|
1433
|
+
this.builderService = inject(AXPWidgetCoreService);
|
|
1434
|
+
this.contextService = inject(AXPWidgetCoreContextStore);
|
|
1435
|
+
this.widgetRegistery = inject(AXPWidgetRegistryService);
|
|
1436
|
+
this.unsubscriber = inject(AXUnsubscriber);
|
|
1437
|
+
this.translateService = inject(AXTranslationService);
|
|
1438
|
+
this.widgetService = inject(AXPWidgetRegistryService);
|
|
1439
|
+
this.expressionEvaluator = inject(AXPExpressionEvaluatorService);
|
|
1440
|
+
this.viewContainerRef = inject(ViewContainerRef);
|
|
1441
|
+
this.isLoading = signal(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : []));
|
|
1442
|
+
this.isVisible = signal(true, ...(ngDevMode ? [{ debugName: "isVisible" }] : []));
|
|
1443
|
+
this.expressionEvaluators = new Map();
|
|
1444
|
+
this.renderTimeoutId = null;
|
|
1445
|
+
this.hasInitialRender = false;
|
|
1446
|
+
this.onContextChanged = new Subject();
|
|
1447
|
+
//#region ---- Performance Optimization Properties ----
|
|
1448
|
+
this.contextUpdateQueue = new Set();
|
|
1449
|
+
this.contextUpdateTimeout = null;
|
|
1450
|
+
this.CONTEXT_UPDATE_DEBOUNCE_MS = 4; // ~250fps for large forms
|
|
1451
|
+
// Removed visibility detection - not needed for current implementation
|
|
1452
|
+
// Expression result caching
|
|
1453
|
+
this.expressionCache = new Map();
|
|
1454
|
+
this.EXPRESSION_CACHE_TTL = 500; // Cache for 500ms (increased for better hit rate)
|
|
1455
|
+
// Options change tracking
|
|
1456
|
+
this.lastAppliedOptions = null;
|
|
1457
|
+
// Expression result tracking
|
|
1458
|
+
this.lastExpressionResults = new Map();
|
|
1459
|
+
// Buffer for context changes that happen before initial render completes
|
|
1460
|
+
this.preRenderContextQueue = new Set();
|
|
1461
|
+
effect(async () => {
|
|
1462
|
+
const changed = this.contextService.changeEvent();
|
|
1463
|
+
// Don't trigger re-render during initial setup
|
|
1464
|
+
if (!this.hasInitialRender) {
|
|
1465
|
+
if (changed.path) {
|
|
1466
|
+
this.preRenderContextQueue.add(changed.path);
|
|
1467
|
+
// console.log(`📝 [${this.node().type}] Buffered pre-render context change: ${changed.path}`);
|
|
1468
|
+
}
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
// CRITICAL PERFORMANCE FIX: Only respond to relevant context changes
|
|
1472
|
+
if (changed.path && this.isRelevantContextChange(changed.path)) {
|
|
1473
|
+
// console.log(`🎯 [${this.node().type}] Context change detected: ${changed.path}`);
|
|
1474
|
+
this.queueContextUpdate(changed.path);
|
|
1475
|
+
}
|
|
1476
|
+
});
|
|
1477
|
+
this.builderService.onRefresh.pipe(this.unsubscriber.takeUntilDestroy).subscribe(async () => {
|
|
1478
|
+
await this.processBatchedUpdates();
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
//#region ---- Expression Caching Methods ----
|
|
1482
|
+
getCachedExpressionResult(expressionKey) {
|
|
1483
|
+
const cached = this.expressionCache.get(expressionKey);
|
|
1484
|
+
if (cached && performance.now() - cached.timestamp < this.EXPRESSION_CACHE_TTL) {
|
|
1485
|
+
// console.log(`💾 [${this.node().type}] Using cached expression result for '${expressionKey}'`);
|
|
1486
|
+
return cached.value;
|
|
1487
|
+
}
|
|
1488
|
+
return null;
|
|
1489
|
+
}
|
|
1490
|
+
setCachedExpressionResult(expressionKey, value) {
|
|
1491
|
+
this.expressionCache.set(expressionKey, {
|
|
1492
|
+
value,
|
|
1493
|
+
timestamp: performance.now(),
|
|
1494
|
+
});
|
|
1495
|
+
}
|
|
1496
|
+
clearExpressionCache() {
|
|
1497
|
+
this.expressionCache.clear();
|
|
1498
|
+
}
|
|
1499
|
+
isPathAffectingExpressions(changedPath) {
|
|
1500
|
+
// console.log(
|
|
1501
|
+
// `🔍 [${this.node().type}] Checking if path '${changedPath}' affects expressions. Expression count: ${this.expressionEvaluators.size}`,
|
|
1502
|
+
// );
|
|
1503
|
+
// If widget has no expressions, no need to clear cache
|
|
1504
|
+
if (this.expressionEvaluators.size === 0) {
|
|
1505
|
+
// console.log(`🔍 [${this.node().type}] Path '${changedPath}' - no expressions, keeping cache`);
|
|
1506
|
+
return false;
|
|
1507
|
+
}
|
|
1508
|
+
// Use the same logic as hasExpressionDependency to check for actual dependencies
|
|
1509
|
+
if (this.hasExpressionDependency(changedPath)) {
|
|
1510
|
+
// console.log(`🔍 [${this.node().type}] Path '${changedPath}' affects expressions - clearing cache`);
|
|
1511
|
+
return true;
|
|
1512
|
+
}
|
|
1513
|
+
// console.log(`🔍 [${this.node().type}] Path '${changedPath}' does not affect expressions - keeping cache`);
|
|
1514
|
+
return false;
|
|
1515
|
+
}
|
|
1516
|
+
//#endregion
|
|
1517
|
+
//#region ---- Context Batching Methods ----
|
|
1518
|
+
queueContextUpdate(path) {
|
|
1519
|
+
if (path) {
|
|
1520
|
+
// console.log(`🔄 [${this.node().type}] Queueing context update for path: ${path}`);
|
|
1521
|
+
this.contextUpdateQueue.add(path);
|
|
1522
|
+
// Clear existing timeout
|
|
1523
|
+
if (this.contextUpdateTimeout) {
|
|
1524
|
+
clearTimeout(this.contextUpdateTimeout);
|
|
1525
|
+
}
|
|
1526
|
+
// Debounce updates
|
|
1527
|
+
this.contextUpdateTimeout = setTimeout(() => {
|
|
1528
|
+
// console.log(`⚡ [${this.node().type}] Processing batched updates for ${this.contextUpdateQueue.size} paths`);
|
|
1529
|
+
this.processBatchedUpdates();
|
|
1530
|
+
}, this.CONTEXT_UPDATE_DEBOUNCE_MS);
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
async processBatchedUpdates() {
|
|
1534
|
+
if (this.contextUpdateQueue.size === 0)
|
|
1535
|
+
return;
|
|
1536
|
+
const startTime = performance.now();
|
|
1537
|
+
const paths = Array.from(this.contextUpdateQueue);
|
|
1538
|
+
this.contextUpdateQueue.clear();
|
|
1539
|
+
// console.log(`📊 [${this.node().type}] Processing ${paths.length} paths:`, paths);
|
|
1540
|
+
// Clear expression cache only if changed paths affect this widget's expressions
|
|
1541
|
+
const shouldClearCache = paths.some((path) => this.isPathAffectingExpressions(path));
|
|
1542
|
+
if (shouldClearCache) {
|
|
1543
|
+
// console.log(`🗑️ [${this.node().type}] Clearing expression cache due to expression-affecting path change`);
|
|
1544
|
+
this.clearExpressionCache();
|
|
1545
|
+
}
|
|
1546
|
+
// Process updates in batches
|
|
1547
|
+
const optionsStartTime = performance.now();
|
|
1548
|
+
const hasOptionsUpdate = await this.updateOptionsBasedOnContext();
|
|
1549
|
+
const optionsTime = performance.now() - optionsStartTime;
|
|
1550
|
+
if (typeof hasOptionsUpdate === 'number' && hasOptionsUpdate > 0) {
|
|
1551
|
+
// console.log(`🔧 [${this.node().type}] Options updated (${optionsTime.toFixed(2)}ms)`);
|
|
1552
|
+
this.applyOptions();
|
|
1553
|
+
}
|
|
1554
|
+
// Check formulas for any of the changed paths
|
|
1555
|
+
const formulaStartTime = performance.now();
|
|
1556
|
+
const formulaNeedsUpdate = paths.some((path) => this.checkFormulaForUpdate(this.node().formula, path));
|
|
1557
|
+
if (formulaNeedsUpdate) {
|
|
1558
|
+
// console.log(`🧮 [${this.node().type}] Formula needs update`);
|
|
1559
|
+
await this.updateValueBasedOnFormula();
|
|
1560
|
+
}
|
|
1561
|
+
const formulaTime = performance.now() - formulaStartTime;
|
|
1562
|
+
// Check visibility for any of the changed paths
|
|
1563
|
+
const visibilityStartTime = performance.now();
|
|
1564
|
+
const visibilityNeedsUpdate = paths.some((path) => this.hasVisibilityDependency(path));
|
|
1565
|
+
if (visibilityNeedsUpdate) {
|
|
1566
|
+
// console.log(`👁️ [${this.node().type}] Visibility needs update`);
|
|
1567
|
+
await this.updateVisibility();
|
|
1568
|
+
}
|
|
1569
|
+
const visibilityTime = performance.now() - visibilityStartTime;
|
|
1570
|
+
// Emit context changes
|
|
1571
|
+
paths.forEach((path) => {
|
|
1572
|
+
this.onContextChanged.next({ path });
|
|
1573
|
+
});
|
|
1574
|
+
const totalTime = performance.now() - startTime;
|
|
1575
|
+
// console.log(
|
|
1576
|
+
// `✅ [${this.node().type}] Batch processing completed in ${totalTime.toFixed(2)}ms (options: ${optionsTime.toFixed(2)}ms, formula: ${formulaTime.toFixed(2)}ms, visibility: ${visibilityTime.toFixed(2)}ms)`,
|
|
1577
|
+
// );
|
|
1578
|
+
}
|
|
1579
|
+
//#endregion
|
|
1580
|
+
//#region ---- Context Relevance Filtering ----
|
|
1581
|
+
isRelevantContextChange(changedPath) {
|
|
1582
|
+
const node = this.node();
|
|
1583
|
+
// 1. Direct path match - widget's own field
|
|
1584
|
+
if (node.path === changedPath) {
|
|
1585
|
+
return true;
|
|
1586
|
+
}
|
|
1587
|
+
// 2. Parent path match - widget is inside the changed container
|
|
1588
|
+
if (node.path && changedPath.startsWith(node.path + '.')) {
|
|
1589
|
+
return true;
|
|
1590
|
+
}
|
|
1591
|
+
// 3. Child path match - changed field is inside this widget's container
|
|
1592
|
+
if (node.path && node.path.startsWith(changedPath + '.')) {
|
|
1593
|
+
return true;
|
|
1594
|
+
}
|
|
1595
|
+
// 4. Expression dependency check - if widget has expressions that depend on this path
|
|
1596
|
+
if (this.hasExpressionDependency(changedPath)) {
|
|
1597
|
+
return true;
|
|
1598
|
+
}
|
|
1599
|
+
// 5. Formula dependency check - if widget's formula depends on this path
|
|
1600
|
+
if (node.formula && this.checkFormulaForUpdate(node.formula, changedPath)) {
|
|
1601
|
+
return true;
|
|
1602
|
+
}
|
|
1603
|
+
// 6. Trigger dependency check - if widget has triggers that depend on this path
|
|
1604
|
+
if (this.hasTriggerDependency(changedPath)) {
|
|
1605
|
+
return true;
|
|
1606
|
+
}
|
|
1607
|
+
// 7. Visibility dependency check - if widget's visibility depends on this path
|
|
1608
|
+
if (this.hasVisibilityDependency(changedPath)) {
|
|
1609
|
+
return true;
|
|
1610
|
+
}
|
|
1611
|
+
return false;
|
|
1612
|
+
}
|
|
1613
|
+
hasExpressionDependency(changedPath) {
|
|
1614
|
+
// Check if any cached expressions depend on the changed path
|
|
1615
|
+
for (const [path, evaluator] of this.expressionEvaluators) {
|
|
1616
|
+
// Check if the expression path itself contains the changed path
|
|
1617
|
+
if (path.includes(changedPath)) {
|
|
1618
|
+
return true;
|
|
1619
|
+
}
|
|
1620
|
+
// Parse the actual expression content to check for context.eval() calls
|
|
1621
|
+
// We need to get the original expression string to analyze it
|
|
1622
|
+
const node = this.node();
|
|
1623
|
+
const expressionValue = this.getExpressionValueFromNode(node, path);
|
|
1624
|
+
if (expressionValue && typeof expressionValue === 'string') {
|
|
1625
|
+
// Look for context.eval() calls that reference the changed path
|
|
1626
|
+
const contextEvalRegex = /context\.eval\(['"]([^'\"]+)['"]\)/g;
|
|
1627
|
+
let match;
|
|
1628
|
+
while ((match = contextEvalRegex.exec(expressionValue)) !== null) {
|
|
1629
|
+
const evalPath = match[1];
|
|
1630
|
+
// Normalize Id-suffixed segments to dot-id form (e.g., 'typeId' -> 'type.id', 'party.typeId' -> 'party.type.id')
|
|
1631
|
+
const normalizePath = (p) => {
|
|
1632
|
+
if (!p)
|
|
1633
|
+
return p;
|
|
1634
|
+
const parts = p.split('.');
|
|
1635
|
+
const last = parts[parts.length - 1];
|
|
1636
|
+
if (last && last.endsWith('Id')) {
|
|
1637
|
+
parts.splice(parts.length - 1, 1, last.slice(0, -2), 'id');
|
|
1638
|
+
}
|
|
1639
|
+
return parts.join('.');
|
|
1640
|
+
};
|
|
1641
|
+
const isSegmentSuffix = (a, b) => {
|
|
1642
|
+
if (!a || !b)
|
|
1643
|
+
return false;
|
|
1644
|
+
const pa = a.split('.');
|
|
1645
|
+
const pb = b.split('.');
|
|
1646
|
+
if (pb.length > pa.length)
|
|
1647
|
+
return false;
|
|
1648
|
+
for (let i = 1; i <= pb.length; i++) {
|
|
1649
|
+
if (pa[pa.length - i] !== pb[pb.length - i])
|
|
1650
|
+
return false;
|
|
1651
|
+
}
|
|
1652
|
+
return true;
|
|
1653
|
+
};
|
|
1654
|
+
const evalNorm = normalizePath(evalPath);
|
|
1655
|
+
const changedNorm = normalizePath(changedPath);
|
|
1656
|
+
// Debug log for dependency check
|
|
1657
|
+
// console.log(
|
|
1658
|
+
// `🧭 [${this.node().type}] dep-check expr='${path}', changed='${changedPath}', eval='${evalPath}', evalNorm='${evalNorm}', changedNorm='${changedNorm}'`,
|
|
1659
|
+
// );
|
|
1660
|
+
// Generic direct and hierarchical dependency checks (raw and normalized)
|
|
1661
|
+
const rawMatch = evalPath === changedPath ||
|
|
1662
|
+
evalPath.startsWith(changedPath + '.') ||
|
|
1663
|
+
changedPath.startsWith(evalPath + '.') ||
|
|
1664
|
+
isSegmentSuffix(evalPath, changedPath) ||
|
|
1665
|
+
isSegmentSuffix(changedPath, evalPath);
|
|
1666
|
+
const normMatch = evalNorm === changedNorm ||
|
|
1667
|
+
evalNorm.startsWith(changedNorm + '.') ||
|
|
1668
|
+
changedNorm.startsWith(evalNorm + '.') ||
|
|
1669
|
+
isSegmentSuffix(evalNorm, changedNorm) ||
|
|
1670
|
+
isSegmentSuffix(changedNorm, evalNorm);
|
|
1671
|
+
if (rawMatch || normMatch) {
|
|
1672
|
+
// console.log(
|
|
1673
|
+
// `🔍 [${this.node().type}] Expression '${path}' depends on '${changedPath}' via context.eval('${evalPath}') (generic match)`,
|
|
1674
|
+
// );
|
|
1675
|
+
return true;
|
|
1676
|
+
}
|
|
1677
|
+
// Check for path aliases/mappings (e.g., typeId.id <-> type.id)
|
|
1678
|
+
if (this.isPathAlias(evalPath, changedPath)) {
|
|
1679
|
+
// console.log(
|
|
1680
|
+
// `🔍 [${this.node().type}] Expression '${path}' depends on '${changedPath}' via context.eval('${evalPath}') (path alias)`,
|
|
1681
|
+
// );
|
|
1682
|
+
return true;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
return false;
|
|
1688
|
+
}
|
|
1689
|
+
isPathAlias(evalPath, changedPath) {
|
|
1690
|
+
// Dynamic path alias detection based on 'Id' suffix pattern
|
|
1691
|
+
// Examples: typeId.id <-> type.id, categoryId.name <-> category.name
|
|
1692
|
+
// Check if evalPath ends with 'Id' and has a property
|
|
1693
|
+
if (evalPath.endsWith('Id') && evalPath.includes('.')) {
|
|
1694
|
+
const basePath = evalPath.substring(0, evalPath.lastIndexOf('Id'));
|
|
1695
|
+
const property = evalPath.substring(evalPath.lastIndexOf('.') + 1);
|
|
1696
|
+
const mappedPath = `${basePath}.${property}`;
|
|
1697
|
+
if (changedPath === mappedPath) {
|
|
1698
|
+
// console.log(`🔍 [${this.node().type}] Path alias detected: '${evalPath}' <-> '${changedPath}'`);
|
|
1699
|
+
return true;
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
// Check if changedPath ends with 'Id' and has a property
|
|
1703
|
+
if (changedPath.endsWith('Id') && changedPath.includes('.')) {
|
|
1704
|
+
const basePath = changedPath.substring(0, changedPath.lastIndexOf('Id'));
|
|
1705
|
+
const property = changedPath.substring(changedPath.lastIndexOf('.') + 1);
|
|
1706
|
+
const mappedPath = `${basePath}.${property}`;
|
|
1707
|
+
if (evalPath === mappedPath) {
|
|
1708
|
+
// console.log(`🔍 [${this.node().type}] Path alias detected: '${evalPath}' <-> '${changedPath}'`);
|
|
1709
|
+
return true;
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
// Check for direct 'Id' suffix mapping (e.g., typeId <-> type.id)
|
|
1713
|
+
if (evalPath.endsWith('Id') && !evalPath.includes('.')) {
|
|
1714
|
+
const basePath = evalPath.substring(0, evalPath.lastIndexOf('Id'));
|
|
1715
|
+
const mappedPath = `${basePath}.id`;
|
|
1716
|
+
if (changedPath === mappedPath) {
|
|
1717
|
+
// console.log(`🔍 [${this.node().type}] Path alias detected: '${evalPath}' <-> '${changedPath}'`);
|
|
1718
|
+
return true;
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
if (changedPath.endsWith('Id') && !changedPath.includes('.')) {
|
|
1722
|
+
const basePath = changedPath.substring(0, changedPath.lastIndexOf('Id'));
|
|
1723
|
+
const mappedPath = `${basePath}.id`;
|
|
1724
|
+
if (evalPath === mappedPath) {
|
|
1725
|
+
// console.log(`🔍 [${this.node().type}] Path alias detected: '${evalPath}' <-> '${changedPath}'`);
|
|
1726
|
+
return true;
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
return false;
|
|
1730
|
+
}
|
|
1731
|
+
getExpressionValueFromNode(node, path) {
|
|
1732
|
+
try {
|
|
1733
|
+
// Navigate through the node structure to find the expression value
|
|
1734
|
+
const pathParts = path.split('.');
|
|
1735
|
+
let current = node.options || {};
|
|
1736
|
+
// Navigate through the path parts
|
|
1737
|
+
for (const part of pathParts) {
|
|
1738
|
+
if (current && typeof current === 'object' && part in current) {
|
|
1739
|
+
current = current[part];
|
|
1740
|
+
}
|
|
1741
|
+
else {
|
|
1742
|
+
return null;
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
return typeof current === 'string' ? current : null;
|
|
1746
|
+
}
|
|
1747
|
+
catch (error) {
|
|
1748
|
+
// console.error('Error extracting expression value from node:', error);
|
|
1749
|
+
return null;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
hasTriggerDependency(changedPath) {
|
|
1753
|
+
const node = this.node();
|
|
1754
|
+
const triggers = node.triggers || node.options?.['triggers'] || this.mergedOptions()?.triggers;
|
|
1755
|
+
if (!triggers)
|
|
1756
|
+
return false;
|
|
1757
|
+
// Check if any trigger event depends on the changed path
|
|
1758
|
+
for (const trigger of triggers) {
|
|
1759
|
+
if (trigger.event && trigger.event.includes(changedPath)) {
|
|
1760
|
+
return true;
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
return false;
|
|
1764
|
+
}
|
|
1765
|
+
hasVisibilityDependency(changedPath) {
|
|
1766
|
+
const node = this.node();
|
|
1767
|
+
const visibility = node.options?.['visible'] || this.mergedOptions()?.visible;
|
|
1768
|
+
if (!visibility || typeof visibility !== 'string')
|
|
1769
|
+
return false;
|
|
1770
|
+
// Check if visibility expression depends on the changed path
|
|
1771
|
+
if (this.expressionEvaluator.isExpression(visibility)) {
|
|
1772
|
+
// Parse the visibility expression to check for context.eval() calls
|
|
1773
|
+
const contextEvalRegex = /context\.eval\(['"]([^'\"]+)['"]\)/g;
|
|
1774
|
+
let match;
|
|
1775
|
+
while ((match = contextEvalRegex.exec(visibility)) !== null) {
|
|
1776
|
+
const evalPath = match[1];
|
|
1777
|
+
// Check for direct or hierarchical dependency
|
|
1778
|
+
if (evalPath === changedPath ||
|
|
1779
|
+
evalPath.startsWith(changedPath + '.') ||
|
|
1780
|
+
changedPath.startsWith(evalPath + '.')) {
|
|
1781
|
+
return true;
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
return false;
|
|
1786
|
+
}
|
|
1787
|
+
//#endregion
|
|
1788
|
+
// Removed visibility detection methods - not needed for current implementation
|
|
1789
|
+
// Detect input changes
|
|
1790
|
+
ngOnChanges(changes) {
|
|
1791
|
+
if (changes['mode'] || changes['node']) {
|
|
1792
|
+
// Check if either 'mode' or 'node' has changed
|
|
1793
|
+
this.rerenderComponent();
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
rerenderComponent() {
|
|
1797
|
+
// Clear any pending render operation to prevent double rendering
|
|
1798
|
+
if (this.renderTimeoutId) {
|
|
1799
|
+
clearTimeout(this.renderTimeoutId);
|
|
1800
|
+
this.renderTimeoutId = null;
|
|
1801
|
+
}
|
|
1802
|
+
// Reset loading state to allow re-rendering
|
|
1803
|
+
this.isLoading.set(false);
|
|
1804
|
+
// Schedule the component loading
|
|
1805
|
+
this.renderTimeoutId = setTimeout(async () => {
|
|
1806
|
+
await this.loadComponent();
|
|
1807
|
+
this.renderTimeoutId = null;
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
ngOnDestroy() {
|
|
1811
|
+
if (this.renderTimeoutId) {
|
|
1812
|
+
clearTimeout(this.renderTimeoutId);
|
|
1813
|
+
}
|
|
1814
|
+
if (this.contextUpdateTimeout) {
|
|
1815
|
+
clearTimeout(this.contextUpdateTimeout);
|
|
1816
|
+
}
|
|
1817
|
+
if (this.componentRef) {
|
|
1818
|
+
this.componentRef.destroy();
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
async loadComponent() {
|
|
1822
|
+
if (this.isLoading()) {
|
|
1823
|
+
return;
|
|
1824
|
+
}
|
|
1825
|
+
this.isLoading.set(true);
|
|
1826
|
+
try {
|
|
1827
|
+
// Destroy the existing component if it exists
|
|
1828
|
+
if (this.componentRef) {
|
|
1829
|
+
this.componentRef.destroy();
|
|
1830
|
+
}
|
|
1831
|
+
this.viewContainerRef.clear();
|
|
1832
|
+
//
|
|
1833
|
+
const widget = this.widgetRegistery.resolve(this.node().type);
|
|
1834
|
+
//
|
|
1835
|
+
const propertiesToProcess = [
|
|
1836
|
+
...(widget?.properties ?? []),
|
|
1837
|
+
...(widget?.components[this.mode()]?.properties ?? []),
|
|
1838
|
+
]?.filter((c) => c.schema.defaultValue != null);
|
|
1839
|
+
// Process default values (evaluate expressions if needed)
|
|
1840
|
+
const props = {};
|
|
1841
|
+
for (const property of propertiesToProcess) {
|
|
1842
|
+
const defaultValue = property.schema.defaultValue;
|
|
1843
|
+
if (typeof defaultValue === 'string' && this.expressionEvaluator.isExpression(defaultValue)) {
|
|
1844
|
+
// Evaluate expression for default value
|
|
1845
|
+
try {
|
|
1846
|
+
const evaluatedValue = await this.evaluateExpression(defaultValue);
|
|
1847
|
+
props[property.name] = evaluatedValue;
|
|
1848
|
+
}
|
|
1849
|
+
catch (error) {
|
|
1850
|
+
// console.error(`Error evaluating default value expression for property ${property.name}:`, error);
|
|
1851
|
+
props[property.name] = cloneDeep(defaultValue); // Fallback to original value
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
else {
|
|
1855
|
+
// Use static default value
|
|
1856
|
+
props[property.name] = cloneDeep(defaultValue);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
//
|
|
1860
|
+
this.mergedOptions.set(merge(props, widget?.options, this.node().options) || {});
|
|
1861
|
+
this.expressionEvaluators.clear();
|
|
1862
|
+
// Register expressions from widget defaults and node options to cover related-entity cases
|
|
1863
|
+
this.preprocessAndInitialOptions(cloneDeep(widget?.options));
|
|
1864
|
+
this.preprocessAndInitialOptions(cloneDeep(this.node().options));
|
|
1865
|
+
await this.updateOptionsBasedOnContext();
|
|
1866
|
+
//
|
|
1867
|
+
this._options.update((val) => ({ ...val, ...this.mergedOptions() }));
|
|
1868
|
+
// Evaluate default value
|
|
1869
|
+
let defaultValue = this.node().defaultValue;
|
|
1870
|
+
if (defaultValue && this.expressionEvaluator.isExpression(defaultValue)) {
|
|
1871
|
+
defaultValue = await this.evaluateExpression(defaultValue);
|
|
1872
|
+
}
|
|
1873
|
+
//
|
|
1874
|
+
const tokenValue = {
|
|
1875
|
+
node: this.node(),
|
|
1876
|
+
defaultValue: defaultValue,
|
|
1877
|
+
options: this.mergedOptions(),
|
|
1878
|
+
config: widget,
|
|
1879
|
+
};
|
|
1880
|
+
const token = Injector.create({
|
|
1881
|
+
parent: this.injector,
|
|
1882
|
+
providers: [
|
|
1883
|
+
{
|
|
1884
|
+
provide: AXP_WIDGET_TOKEN,
|
|
1885
|
+
useValue: tokenValue,
|
|
1886
|
+
},
|
|
1887
|
+
],
|
|
1888
|
+
});
|
|
1889
|
+
//
|
|
1890
|
+
const loadingRef = this.viewContainerRef.createComponent(AXPWidgetPlaceholderComponent);
|
|
1891
|
+
//
|
|
1892
|
+
const com = await widget?.components[this.mode()]?.component();
|
|
1893
|
+
if (!com) {
|
|
1894
|
+
// console.error(`${this.node().type} widget component not found with mode: ${this.mode()}`);
|
|
1895
|
+
return;
|
|
1896
|
+
}
|
|
1897
|
+
this.componentRef = this.viewContainerRef.createComponent(com, { injector: token });
|
|
1898
|
+
this.instance = this.componentRef.instance;
|
|
1899
|
+
this.instance.setStatus(AXPWidgetStatus.Rendering);
|
|
1900
|
+
this.instance.parent = this.parentNode();
|
|
1901
|
+
this.instance.index = this.index();
|
|
1902
|
+
this.instance.mode = this.mode();
|
|
1903
|
+
this.instance.setStatus(AXPWidgetStatus.Rendered);
|
|
1904
|
+
this.instance?.onOptionsChanged?.pipe(this.unsubscriber.takeUntilDestroy).subscribe((c) => {
|
|
1905
|
+
this.onOptionsChanged.emit({ sender: this, widget: c.sender });
|
|
1906
|
+
});
|
|
1907
|
+
this.instance?.onValueChanged?.pipe(this.unsubscriber.takeUntilDestroy).subscribe((c) => {
|
|
1908
|
+
this.onValueChanged.emit({ sender: this, widget: c.sender });
|
|
1909
|
+
});
|
|
1910
|
+
await this.updateValueBasedOnFormula();
|
|
1911
|
+
await this.updateVisibility();
|
|
1912
|
+
await this.assignTriggers();
|
|
1913
|
+
//
|
|
1914
|
+
loadingRef.destroy();
|
|
1915
|
+
// Mark that initial render is complete
|
|
1916
|
+
this.hasInitialRender = true;
|
|
1917
|
+
// Re-evaluate expressions after initial render to catch late-arriving related context
|
|
1918
|
+
if (this.expressionEvaluators.size > 0) {
|
|
1919
|
+
// console.log(`🔄 [${this.node().type}] Re-evaluating expressions after initial render`);
|
|
1920
|
+
await this.updateOptionsBasedOnContext();
|
|
1921
|
+
this.applyOptions();
|
|
1922
|
+
}
|
|
1923
|
+
// Re-evaluate visibility after initial render
|
|
1924
|
+
await this.updateVisibility();
|
|
1925
|
+
// Process any buffered pre-render context changes now that the component is ready
|
|
1926
|
+
if (this.preRenderContextQueue.size > 0) {
|
|
1927
|
+
// console.log(
|
|
1928
|
+
// `🚀 [${this.node().type}] Processing ${this.preRenderContextQueue.size} buffered pre-render changes`,
|
|
1929
|
+
// );
|
|
1930
|
+
this.preRenderContextQueue.forEach((p) => this.contextUpdateQueue.add(p));
|
|
1931
|
+
this.preRenderContextQueue.clear();
|
|
1932
|
+
await this.processBatchedUpdates();
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
catch (error) {
|
|
1936
|
+
// console.error('Error loading component:', error);
|
|
1937
|
+
}
|
|
1938
|
+
finally {
|
|
1939
|
+
this.isLoading.set(false);
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
applyOptions() {
|
|
1943
|
+
if (!this.instance)
|
|
1944
|
+
return;
|
|
1945
|
+
const currentOptions = this.mergedOptions();
|
|
1946
|
+
// Check if options have actually changed
|
|
1947
|
+
if (this.hasOptionsChanged(currentOptions)) {
|
|
1948
|
+
// console.log('applyOptions', this.node().path, '- options changed');
|
|
1949
|
+
this._options.update((val) => ({ ...val, ...currentOptions }));
|
|
1950
|
+
this.instance.setOptions(currentOptions);
|
|
1951
|
+
this.lastAppliedOptions = cloneDeep(currentOptions); // Deep clone using Lodash
|
|
1952
|
+
}
|
|
1953
|
+
else {
|
|
1954
|
+
// console.log('applyOptions', this.node().path, '- no changes, skipping');
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
hasOptionsChanged(newOptions) {
|
|
1958
|
+
if (!this.lastAppliedOptions) {
|
|
1959
|
+
return true; // First time, always apply
|
|
1960
|
+
}
|
|
1961
|
+
// Deep comparison of options using Lodash isEqual
|
|
1962
|
+
return !isEqual(newOptions, this.lastAppliedOptions);
|
|
1963
|
+
}
|
|
1964
|
+
// Removed deepCloneValue method - now using Lodash cloneDeep
|
|
1965
|
+
checkFormulaForUpdate(formula, path) {
|
|
1966
|
+
if (formula) {
|
|
1967
|
+
const regex = /context\.eval\('([^']+)'\)/g;
|
|
1968
|
+
const matches = formula.match(regex);
|
|
1969
|
+
const nodes = matches ? matches.map((match) => match.match(/'([^']+)'/)[1]) : [];
|
|
1970
|
+
return nodes.includes(path);
|
|
1971
|
+
}
|
|
1972
|
+
else
|
|
1973
|
+
return false;
|
|
1974
|
+
}
|
|
1975
|
+
preprocessAndInitialOptions(obj, pathPrefix = '') {
|
|
1976
|
+
if (!obj) {
|
|
1977
|
+
return;
|
|
1978
|
+
}
|
|
1979
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
1980
|
+
const currentPath = pathPrefix ? `${pathPrefix}.${key}` : key;
|
|
1981
|
+
// CRITICAL FIX: Skip trigger actions during options processing
|
|
1982
|
+
//
|
|
1983
|
+
// PROBLEM: Trigger actions were being evaluated immediately during widget setup/options processing,
|
|
1984
|
+
// causing them to execute before the actual trigger event occurred. This meant triggers would fire
|
|
1985
|
+
// during initialization instead of when the specified context path actually changed.
|
|
1986
|
+
//
|
|
1987
|
+
// ROOT CAUSE: The expression evaluator was processing trigger action expressions (like console.log
|
|
1988
|
+
// or widget.setValue calls) as part of the normal options preprocessing, treating them as dynamic
|
|
1989
|
+
// expressions that needed immediate evaluation.
|
|
1990
|
+
//
|
|
1991
|
+
// SOLUTION: Detect when we're processing trigger actions and store them as static values without
|
|
1992
|
+
// expression evaluation. This ensures trigger actions are only evaluated when the trigger's
|
|
1993
|
+
// subscription callback actually fires (when the event condition is met).
|
|
1994
|
+
//
|
|
1995
|
+
// RESULT: Triggers now only execute when their event filters pass (e.g., when the specified
|
|
1996
|
+
// context path changes), not during widget initialization.
|
|
1997
|
+
if (currentPath.includes('triggers') && (key === 'action' || currentPath.endsWith('.action'))) {
|
|
1998
|
+
// Apply static values directly without expression evaluation
|
|
1999
|
+
this.mergedOptions.update((currentOptions) => {
|
|
2000
|
+
return set(currentOptions, currentPath, value);
|
|
2001
|
+
});
|
|
2002
|
+
return;
|
|
2003
|
+
}
|
|
2004
|
+
if (typeof value === 'string' && this.expressionEvaluator.isExpression(value)) {
|
|
2005
|
+
// Cache dynamic expression for later evaluation
|
|
2006
|
+
this.expressionEvaluators.set(currentPath, () => this.evaluateExpression(value));
|
|
2007
|
+
}
|
|
2008
|
+
else if (typeof value === 'object' &&
|
|
2009
|
+
value !== null &&
|
|
2010
|
+
(value.constructor === Object || Array.isArray(value))) {
|
|
2011
|
+
// Recursively handle nested objects
|
|
2012
|
+
this.preprocessAndInitialOptions(value, currentPath);
|
|
2013
|
+
}
|
|
2014
|
+
else {
|
|
2015
|
+
// Apply static values directly
|
|
2016
|
+
this.mergedOptions.update((currentOptions) => {
|
|
2017
|
+
return set(currentOptions, currentPath, value);
|
|
2018
|
+
});
|
|
2019
|
+
}
|
|
2020
|
+
});
|
|
2021
|
+
}
|
|
2022
|
+
async updateOptionsBasedOnContext() {
|
|
2023
|
+
// Early return if no expressions to evaluate
|
|
2024
|
+
if (this.expressionEvaluators.size === 0) {
|
|
2025
|
+
return 0;
|
|
2026
|
+
}
|
|
2027
|
+
// console.log(`🔍 [${this.node().type}] Evaluating ${this.expressionEvaluators.size} expressions`);
|
|
2028
|
+
const updatePromises = Array.from(this.expressionEvaluators).map(async ([path, evaluator]) => {
|
|
2029
|
+
// Check cache first
|
|
2030
|
+
const cachedValue = this.getCachedExpressionResult(path);
|
|
2031
|
+
if (cachedValue !== null) {
|
|
2032
|
+
// console.log(`💾 [${this.node().type}] Using cached expression result for '${path}'`);
|
|
2033
|
+
return { path, newValue: cachedValue, fromCache: true };
|
|
2034
|
+
}
|
|
2035
|
+
// Evaluate expression if not cached
|
|
2036
|
+
const evalStartTime = performance.now();
|
|
2037
|
+
const newValue = await evaluator();
|
|
2038
|
+
const evalTime = performance.now() - evalStartTime;
|
|
2039
|
+
// Check if result has actually changed using Lodash isEqual
|
|
2040
|
+
const lastValue = this.lastExpressionResults.get(path);
|
|
2041
|
+
const hasChanged = !isEqual(newValue, lastValue);
|
|
2042
|
+
if (hasChanged) {
|
|
2043
|
+
// console.log(
|
|
2044
|
+
// `📝 [${this.node().type}] Expression '${path}' evaluated in ${evalTime.toFixed(2)}ms - value changed`,
|
|
2045
|
+
// );
|
|
2046
|
+
// Cache the result and track it
|
|
2047
|
+
this.setCachedExpressionResult(path, newValue);
|
|
2048
|
+
this.lastExpressionResults.set(path, cloneDeep(newValue));
|
|
2049
|
+
return { path, newValue, fromCache: false, hasChanged: true };
|
|
2050
|
+
}
|
|
2051
|
+
else {
|
|
2052
|
+
// console.log(
|
|
2053
|
+
// `📝 [${this.node().type}] Expression '${path}' evaluated in ${evalTime.toFixed(2)}ms - value unchanged, skipping update`,
|
|
2054
|
+
// );
|
|
2055
|
+
// Cache the result but don't update
|
|
2056
|
+
this.setCachedExpressionResult(path, newValue);
|
|
2057
|
+
this.lastExpressionResults.set(path, cloneDeep(newValue));
|
|
2058
|
+
return { path, newValue, fromCache: false, hasChanged: false };
|
|
2059
|
+
}
|
|
2060
|
+
});
|
|
2061
|
+
// Wait for all evaluators to complete
|
|
2062
|
+
const updates = await Promise.all(updatePromises);
|
|
2063
|
+
// Filter updates to only include those that have actually changed
|
|
2064
|
+
const changedUpdates = updates.filter((update) => update.hasChanged !== false);
|
|
2065
|
+
// Apply updates to mergedOptions only for changed values
|
|
2066
|
+
if (changedUpdates.length > 0) {
|
|
2067
|
+
this.mergedOptions.update((o) => {
|
|
2068
|
+
const updatedOptions = { ...o };
|
|
2069
|
+
changedUpdates.forEach(({ path, newValue }) => {
|
|
2070
|
+
set(updatedOptions, path, newValue);
|
|
2071
|
+
});
|
|
2072
|
+
return updatedOptions;
|
|
2073
|
+
});
|
|
2074
|
+
}
|
|
2075
|
+
const cacheHits = updates.filter((update) => update.fromCache).length;
|
|
2076
|
+
const skippedUpdates = updates.length - changedUpdates.length;
|
|
2077
|
+
// console.log(
|
|
2078
|
+
// `📋 [${this.node().type}] Applied ${changedUpdates.length} expression updates (${cacheHits} cache hits, ${skippedUpdates} skipped)`,
|
|
2079
|
+
// );
|
|
2080
|
+
return changedUpdates.length;
|
|
2081
|
+
}
|
|
2082
|
+
async updateValueBasedOnFormula() {
|
|
2083
|
+
if (this.node().formula) {
|
|
2084
|
+
const value = await this.evaluateExpression(this.node().formula);
|
|
2085
|
+
this.instance.setValue(value);
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
async updateVisibility() {
|
|
2089
|
+
const node = this.node();
|
|
2090
|
+
const visibility = node.options?.['visible'] || this.mergedOptions()?.visible;
|
|
2091
|
+
if (visibility === undefined || visibility === null) {
|
|
2092
|
+
// Default to visible if no visibility option is set
|
|
2093
|
+
this.show();
|
|
2094
|
+
return;
|
|
2095
|
+
}
|
|
2096
|
+
let shouldBeVisible;
|
|
2097
|
+
if (typeof visibility === 'boolean') {
|
|
2098
|
+
shouldBeVisible = visibility;
|
|
2099
|
+
}
|
|
2100
|
+
else if (typeof visibility === 'string' && this.expressionEvaluator.isExpression(visibility)) {
|
|
2101
|
+
// Evaluate expression for visibility
|
|
2102
|
+
try {
|
|
2103
|
+
const result = await this.evaluateExpression(visibility);
|
|
2104
|
+
shouldBeVisible = Boolean(result);
|
|
2105
|
+
}
|
|
2106
|
+
catch (error) {
|
|
2107
|
+
// console.error('Error evaluating visibility expression:', error);
|
|
2108
|
+
shouldBeVisible = true; // Default to visible on error
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
else {
|
|
2112
|
+
// Treat other values as truthy/falsy
|
|
2113
|
+
shouldBeVisible = Boolean(visibility);
|
|
2114
|
+
}
|
|
2115
|
+
if (shouldBeVisible) {
|
|
2116
|
+
this.show();
|
|
2117
|
+
}
|
|
2118
|
+
else {
|
|
2119
|
+
this.hide();
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
show() {
|
|
2123
|
+
if (!this.isVisible()) {
|
|
2124
|
+
this.isVisible.set(true);
|
|
2125
|
+
if (this.componentRef && this.componentRef.location) {
|
|
2126
|
+
this.componentRef.location.nativeElement.style.display = '';
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
hide() {
|
|
2131
|
+
if (this.isVisible()) {
|
|
2132
|
+
this.isVisible.set(false);
|
|
2133
|
+
if (this.componentRef && this.componentRef.location) {
|
|
2134
|
+
this.componentRef.location.nativeElement.style.display = 'none';
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
async evaluateExpression(templateExpression) {
|
|
2139
|
+
try {
|
|
2140
|
+
const scope = this.buildExpressionScope();
|
|
2141
|
+
return await this.expressionEvaluator.evaluate(templateExpression, scope);
|
|
2142
|
+
}
|
|
2143
|
+
catch (error) {
|
|
2144
|
+
// console.error('Error evaluating expression:', error);
|
|
2145
|
+
return false;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
buildExpressionScope() {
|
|
2149
|
+
return {
|
|
2150
|
+
context: this.getContextScope(),
|
|
2151
|
+
events: this.getEventScope(),
|
|
2152
|
+
widget: this.getWidgetScope(),
|
|
2153
|
+
methods: this.getFunctionScope(),
|
|
2154
|
+
vars: this.getVariablesScope(),
|
|
2155
|
+
};
|
|
2156
|
+
}
|
|
2157
|
+
getContextScope() {
|
|
2158
|
+
return {
|
|
2159
|
+
eval: (path) => {
|
|
2160
|
+
//TODO: Handle array index
|
|
2161
|
+
const fullPath = path.startsWith('>') ? `${this.instance?.parentPath()}.${path.substring(1)}` : path;
|
|
2162
|
+
const value = this.contextService.getValue(fullPath);
|
|
2163
|
+
return value;
|
|
2164
|
+
},
|
|
2165
|
+
set: (path, value) => {
|
|
2166
|
+
this.contextService.update(path, value);
|
|
2167
|
+
},
|
|
2168
|
+
data: () => {
|
|
2169
|
+
return this.contextService.data();
|
|
2170
|
+
},
|
|
2171
|
+
isDirty: () => {
|
|
2172
|
+
return this.contextService.isDirty();
|
|
2173
|
+
},
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
getEventScope() {
|
|
2177
|
+
return {
|
|
2178
|
+
context: (path) => {
|
|
2179
|
+
return this.onContextChanged.pipe(filter((c) => {
|
|
2180
|
+
// If no path filter specified, pass all events
|
|
2181
|
+
if (path == null || path === '') {
|
|
2182
|
+
return true;
|
|
2183
|
+
}
|
|
2184
|
+
// Ensure c.path exists
|
|
2185
|
+
if (!c.path) {
|
|
2186
|
+
return false;
|
|
2187
|
+
}
|
|
2188
|
+
// Pattern: "prefix*" - matches paths that start with prefix
|
|
2189
|
+
if (path.endsWith('*')) {
|
|
2190
|
+
const prefix = path.substring(0, path.length - 1);
|
|
2191
|
+
return c.path.startsWith(prefix);
|
|
2192
|
+
}
|
|
2193
|
+
// Pattern: "*suffix" - matches paths that end with suffix
|
|
2194
|
+
else if (path.startsWith('*')) {
|
|
2195
|
+
const suffix = path.substring(1);
|
|
2196
|
+
return c.path.endsWith(suffix);
|
|
2197
|
+
}
|
|
2198
|
+
// Exact match
|
|
2199
|
+
else {
|
|
2200
|
+
return c.path === path;
|
|
2201
|
+
}
|
|
2202
|
+
}));
|
|
2203
|
+
},
|
|
2204
|
+
from: (event) => get(this.instance.api(), event),
|
|
2205
|
+
};
|
|
2206
|
+
}
|
|
2207
|
+
getWidgetScope() {
|
|
2208
|
+
return {
|
|
2209
|
+
call: (name, ...args) => {
|
|
2210
|
+
this.instance.call(name, ...args);
|
|
2211
|
+
},
|
|
2212
|
+
setValue: (value) => {
|
|
2213
|
+
this.instance.setValue(value);
|
|
2214
|
+
},
|
|
2215
|
+
clear: () => {
|
|
2216
|
+
this.instance.setValue(undefined);
|
|
2217
|
+
},
|
|
2218
|
+
refresh: () => {
|
|
2219
|
+
const refresh = this.instance?.['refresh'];
|
|
2220
|
+
if (refresh && typeof refresh === 'function') {
|
|
2221
|
+
refresh.bind(this.instance)();
|
|
2222
|
+
}
|
|
2223
|
+
},
|
|
2224
|
+
output: (name) => {
|
|
2225
|
+
this.instance.output(name);
|
|
2226
|
+
},
|
|
2227
|
+
find: (id) => {
|
|
2228
|
+
return this.builderService.getWidget(id);
|
|
2229
|
+
},
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2232
|
+
getFunctionScope() {
|
|
2233
|
+
const scope = {
|
|
2234
|
+
sum: (values) => {
|
|
2235
|
+
return sum(values);
|
|
2236
|
+
},
|
|
2237
|
+
translate: (text, options) => {
|
|
2238
|
+
return this.translateService.translateAsync(text, options);
|
|
2239
|
+
},
|
|
2240
|
+
widgetInfo: (name) => {
|
|
2241
|
+
return this.widgetService.resolve(name);
|
|
2242
|
+
},
|
|
2243
|
+
};
|
|
2244
|
+
// Add custom functions from builder service
|
|
2245
|
+
Object.entries(this.builderService.functions).forEach(([key, fn]) => {
|
|
2246
|
+
scope[key] = (...args) => {
|
|
2247
|
+
return fn(...args);
|
|
2248
|
+
};
|
|
2249
|
+
});
|
|
2250
|
+
return scope;
|
|
2251
|
+
}
|
|
2252
|
+
getVariablesScope() {
|
|
2253
|
+
return {
|
|
2254
|
+
eval: (path) => get(this.builderService.variables, path),
|
|
2255
|
+
};
|
|
2256
|
+
}
|
|
2257
|
+
async assignTriggers() {
|
|
2258
|
+
const node = this.node();
|
|
2259
|
+
// Check multiple possible locations for triggers
|
|
2260
|
+
const triggers = node.triggers || node.options?.['triggers'] || this.mergedOptions()?.triggers;
|
|
2261
|
+
if (!triggers) {
|
|
2262
|
+
return;
|
|
2263
|
+
}
|
|
2264
|
+
for (const trigger of triggers) {
|
|
2265
|
+
try {
|
|
2266
|
+
const event = await this.evaluateTrigger(trigger.event);
|
|
2267
|
+
if (event) {
|
|
2268
|
+
event.pipe(this.unsubscriber.takeUntilDestroy).subscribe(() => {
|
|
2269
|
+
const exec = async (action) => {
|
|
2270
|
+
if (!isEmpty(action) && isString(action)) {
|
|
2271
|
+
await this.evaluateAction(action);
|
|
2272
|
+
}
|
|
2273
|
+
};
|
|
2274
|
+
const actions = Array.isArray(trigger.action) ? trigger.action : [trigger.action];
|
|
2275
|
+
actions.forEach(async (a) => await exec(a));
|
|
2276
|
+
});
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
catch (error) {
|
|
2280
|
+
// console.error('Error assigning trigger:', error);
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
async evaluateTrigger(templateExpression) {
|
|
2285
|
+
try {
|
|
2286
|
+
const scope = this.buildExpressionScope();
|
|
2287
|
+
const result = await this.expressionEvaluator.evaluate(templateExpression, scope);
|
|
2288
|
+
// Check if result is an Observable
|
|
2289
|
+
if (result && typeof result.subscribe === 'function') {
|
|
2290
|
+
return result;
|
|
2291
|
+
}
|
|
2292
|
+
else {
|
|
2293
|
+
return null;
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
catch (error) {
|
|
2297
|
+
// console.error('Error evaluating trigger expression:', error);
|
|
2298
|
+
return null;
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
async evaluateAction(templateExpression) {
|
|
2302
|
+
try {
|
|
2303
|
+
const scope = this.buildExpressionScope();
|
|
2304
|
+
await this.expressionEvaluator.evaluate(templateExpression, scope);
|
|
2305
|
+
}
|
|
2306
|
+
catch (error) {
|
|
2307
|
+
// console.error('Error evaluating action expression:', templateExpression, error);
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetRendererDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2311
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.4", type: AXPWidgetRendererDirective, isStandalone: false, selector: "[axp-widget-renderer]", inputs: { parentNode: { classPropertyName: "parentNode", publicName: "parentNode", isSignal: true, isRequired: false, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: true, transformFunction: null }, node: { classPropertyName: "node", publicName: "node", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { onOptionsChanged: "onOptionsChanged", onValueChanged: "onValueChanged" }, providers: [
|
|
2312
|
+
{
|
|
2313
|
+
provide: AXUnsubscriber,
|
|
2314
|
+
},
|
|
2315
|
+
], exportAs: ["widgetRenderer"], usesOnChanges: true, ngImport: i0 }); }
|
|
2316
|
+
}
|
|
2317
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetRendererDirective, decorators: [{
|
|
2318
|
+
type: Directive,
|
|
2319
|
+
args: [{
|
|
2320
|
+
selector: '[axp-widget-renderer]',
|
|
2321
|
+
exportAs: 'widgetRenderer',
|
|
2322
|
+
providers: [
|
|
2323
|
+
{
|
|
2324
|
+
provide: AXUnsubscriber,
|
|
2325
|
+
},
|
|
2326
|
+
],
|
|
2327
|
+
standalone: false,
|
|
2328
|
+
}]
|
|
2329
|
+
}], ctorParameters: () => [] });
|
|
2330
|
+
|
|
2331
|
+
const COMPONENTS = [AXPWidgetContainerComponent, AXPWidgetColumnRendererComponent, AXPWidgetRendererDirective];
|
|
2332
|
+
class AXPWidgetCoreModule {
|
|
2333
|
+
static forRoot(config) {
|
|
2334
|
+
return {
|
|
2335
|
+
ngModule: AXPWidgetCoreModule,
|
|
2336
|
+
providers: [
|
|
2337
|
+
{
|
|
2338
|
+
provide: 'AXPWidgetCoreModuleFactory',
|
|
2339
|
+
useFactory: (registry) => async () => {
|
|
2340
|
+
await Promise.all(config?.widgets?.map((w) => Promise.resolve(registry.register(w))) || []);
|
|
2341
|
+
await Promise.all(config?.extendedWidgets?.map((ew) => Promise.resolve(registry.extend(ew.parentName, ew.widget))) || []);
|
|
2342
|
+
},
|
|
2343
|
+
deps: [AXPWidgetRegistryService],
|
|
2344
|
+
multi: true,
|
|
2345
|
+
},
|
|
2346
|
+
],
|
|
2347
|
+
};
|
|
2348
|
+
}
|
|
2349
|
+
static forChild(config) {
|
|
2350
|
+
return {
|
|
2351
|
+
ngModule: AXPWidgetCoreModule,
|
|
2352
|
+
providers: [
|
|
2353
|
+
{
|
|
2354
|
+
provide: 'AXPWidgetCoreModuleFactory',
|
|
2355
|
+
useFactory: (registry) => async () => {
|
|
2356
|
+
await Promise.all(config?.widgets?.map((w) => Promise.resolve(registry.register(w))) || []);
|
|
2357
|
+
await Promise.all(config?.extendedWidgets?.map((ew) => Promise.resolve(registry.extend(ew.parentName, ew.widget))) || []);
|
|
2358
|
+
},
|
|
2359
|
+
deps: [AXPWidgetRegistryService],
|
|
2360
|
+
multi: true,
|
|
2361
|
+
},
|
|
2362
|
+
],
|
|
2363
|
+
};
|
|
2364
|
+
}
|
|
2365
|
+
/**
|
|
2366
|
+
* @ignore
|
|
2367
|
+
*/
|
|
2368
|
+
constructor(instances) {
|
|
2369
|
+
instances?.forEach((f) => {
|
|
2370
|
+
f();
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetCoreModule, deps: [{ token: 'AXPWidgetCoreModuleFactory', optional: true }], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
2374
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetCoreModule, declarations: [AXPWidgetContainerComponent, AXPWidgetColumnRendererComponent, AXPWidgetRendererDirective], imports: [CommonModule, PortalModule, AXSkeletonModule, CommonModule, AXTranslationModule], exports: [AXPWidgetContainerComponent, AXPWidgetColumnRendererComponent, AXPWidgetRendererDirective] }); }
|
|
2375
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetCoreModule, imports: [CommonModule, PortalModule, AXSkeletonModule, CommonModule, AXTranslationModule] }); }
|
|
2376
|
+
}
|
|
2377
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetCoreModule, decorators: [{
|
|
2378
|
+
type: NgModule,
|
|
2379
|
+
args: [{
|
|
2380
|
+
imports: [CommonModule, PortalModule, AXSkeletonModule, CommonModule, AXTranslationModule],
|
|
2381
|
+
exports: [...COMPONENTS],
|
|
2382
|
+
declarations: [...COMPONENTS],
|
|
2383
|
+
}]
|
|
2384
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2385
|
+
type: Optional
|
|
2386
|
+
}, {
|
|
2387
|
+
type: Inject,
|
|
2388
|
+
args: ['AXPWidgetCoreModuleFactory']
|
|
2389
|
+
}] }] });
|
|
2390
|
+
|
|
2391
|
+
class AXPPropertyEditorHelper {
|
|
2392
|
+
static expandShorthand(values) {
|
|
2393
|
+
switch (values.length) {
|
|
2394
|
+
case 1:
|
|
2395
|
+
return [values[0], values[0], values[0], values[0]];
|
|
2396
|
+
case 2:
|
|
2397
|
+
return [values[0], values[1], values[0], values[1]];
|
|
2398
|
+
case 3:
|
|
2399
|
+
return [values[0], values[1], values[2], values[1]];
|
|
2400
|
+
case 4:
|
|
2401
|
+
return values;
|
|
2402
|
+
default:
|
|
2403
|
+
throw new Error(`Invalid shorthand value count. Input: ${values}`);
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
static condenseShorthand(values) {
|
|
2407
|
+
if (values.length !== 4) {
|
|
2408
|
+
throw new Error('Expected 4 values for condensation.');
|
|
2409
|
+
}
|
|
2410
|
+
if (values[0] === values[1] && values[1] === values[2] && values[2] === values[3]) {
|
|
2411
|
+
return `${values[0]}`;
|
|
2412
|
+
}
|
|
2413
|
+
else if (values[0] === values[2] && values[1] === values[3]) {
|
|
2414
|
+
return `${values[0]} ${values[1]}`;
|
|
2415
|
+
}
|
|
2416
|
+
else if (values[1] === values[3]) {
|
|
2417
|
+
return `${values[0]} ${values[1]} ${values[2]}`;
|
|
2418
|
+
}
|
|
2419
|
+
else {
|
|
2420
|
+
return `${values[0]} ${values[1]} ${values[2]} ${values[3]}`;
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
static parseSides(input) {
|
|
2424
|
+
const values = this.expandShorthand(input.match(/(?:rgb\([^)]+\)|[^ ]+)/g)?.map((value) => value.trim()) || []);
|
|
2425
|
+
return { top: values[0], right: values[1], bottom: values[2], left: values[3] };
|
|
2426
|
+
}
|
|
2427
|
+
static parseSidesWithUnits(input) {
|
|
2428
|
+
const values = this.expandShorthand(input.match(/(?:rgb\([^)]+\)|[^ ]+)/g)?.map((value) => value.trim()) || []);
|
|
2429
|
+
return {
|
|
2430
|
+
top: AXPPropertyEditorHelper.getValueWithUnit(values[0]).value,
|
|
2431
|
+
right: AXPPropertyEditorHelper.getValueWithUnit(values[1]).value,
|
|
2432
|
+
bottom: AXPPropertyEditorHelper.getValueWithUnit(values[2]).value,
|
|
2433
|
+
left: AXPPropertyEditorHelper.getValueWithUnit(values[3]).value,
|
|
2434
|
+
};
|
|
2435
|
+
}
|
|
2436
|
+
static parseCorners(input) {
|
|
2437
|
+
const values = this.expandShorthand(input.split(' ').map((value) => value.trim()));
|
|
2438
|
+
return {
|
|
2439
|
+
'top-left': AXPPropertyEditorHelper.getValueWithUnit(values[0]).value,
|
|
2440
|
+
'top-right': AXPPropertyEditorHelper.getValueWithUnit(values[1]).value,
|
|
2441
|
+
'bottom-left': AXPPropertyEditorHelper.getValueWithUnit(values[2]).value,
|
|
2442
|
+
'bottom-right': AXPPropertyEditorHelper.getValueWithUnit(values[3]).value,
|
|
2443
|
+
};
|
|
2444
|
+
}
|
|
2445
|
+
static parseSpacingBox(input) {
|
|
2446
|
+
return {
|
|
2447
|
+
margin: this.parseSidesWithUnits(input.margin),
|
|
2448
|
+
padding: this.parseSidesWithUnits(input.padding),
|
|
2449
|
+
};
|
|
2450
|
+
}
|
|
2451
|
+
static parseBorderBox(input) {
|
|
2452
|
+
return {
|
|
2453
|
+
width: this.parseSidesWithUnits(input.width),
|
|
2454
|
+
radius: this.parseCorners(input.radius),
|
|
2455
|
+
color: this.parseSides(input.color),
|
|
2456
|
+
style: this.parseSides(input.style),
|
|
2457
|
+
};
|
|
2458
|
+
}
|
|
2459
|
+
static parseSpacingBoxReverse(input, units) {
|
|
2460
|
+
const format = (value, unit) => `${value}${unit}`;
|
|
2461
|
+
return {
|
|
2462
|
+
margin: AXPPropertyEditorHelper.condenseShorthand([
|
|
2463
|
+
format(input.margin.top, units.margin.top),
|
|
2464
|
+
format(input.margin.right, units.margin.right),
|
|
2465
|
+
format(input.margin.bottom, units.margin.bottom),
|
|
2466
|
+
format(input.margin.left, units.margin.left),
|
|
2467
|
+
]),
|
|
2468
|
+
padding: AXPPropertyEditorHelper.condenseShorthand([
|
|
2469
|
+
format(input.padding.top, units.padding.top),
|
|
2470
|
+
format(input.padding.right, units.padding.right),
|
|
2471
|
+
format(input.padding.bottom, units.padding.bottom),
|
|
2472
|
+
format(input.padding.left, units.padding.left),
|
|
2473
|
+
]),
|
|
2474
|
+
};
|
|
2475
|
+
}
|
|
2476
|
+
static parseBorderBoxReverse(input, units) {
|
|
2477
|
+
const format = (value, unit) => `${value}${unit}`;
|
|
2478
|
+
return {
|
|
2479
|
+
width: AXPPropertyEditorHelper.condenseShorthand([
|
|
2480
|
+
format(input.width.top, units.width.top),
|
|
2481
|
+
format(input.width.right, units.width.right),
|
|
2482
|
+
format(input.width.bottom, units.width.bottom),
|
|
2483
|
+
format(input.width.left, units.width.left),
|
|
2484
|
+
]),
|
|
2485
|
+
radius: AXPPropertyEditorHelper.condenseShorthand([
|
|
2486
|
+
format(input.radius['top-left'], units.radius['top-left']),
|
|
2487
|
+
format(input.radius['top-right'], units.radius['top-right']),
|
|
2488
|
+
format(input.radius['bottom-right'], units.radius['bottom-right']),
|
|
2489
|
+
format(input.radius['bottom-left'], units.radius['bottom-left']),
|
|
2490
|
+
]),
|
|
2491
|
+
color: AXPPropertyEditorHelper.condenseShorthand([
|
|
2492
|
+
`${input.color.top}${units.color.top}`,
|
|
2493
|
+
`${input.color.right}${units.color.right}`,
|
|
2494
|
+
`${input.color.bottom}${units.color.bottom}`,
|
|
2495
|
+
`${input.color.left}${units.color.left}`,
|
|
2496
|
+
]),
|
|
2497
|
+
style: AXPPropertyEditorHelper.condenseShorthand([
|
|
2498
|
+
`${input.style.top}${units.style.top}`,
|
|
2499
|
+
`${input.style.right}${units.style.right}`,
|
|
2500
|
+
`${input.style.bottom}${units.style.bottom}`,
|
|
2501
|
+
`${input.style.left}${units.style.left}`,
|
|
2502
|
+
]),
|
|
2503
|
+
};
|
|
2504
|
+
}
|
|
2505
|
+
static getValueWithUnit(input) {
|
|
2506
|
+
if (typeof input === 'number')
|
|
2507
|
+
return { value: input, unit: 'px' };
|
|
2508
|
+
if (input === 'auto')
|
|
2509
|
+
return { value: 0, unit: 'px' };
|
|
2510
|
+
const match = input.match(/^([0-9.]+)([a-z%]*)$/i);
|
|
2511
|
+
if (!match)
|
|
2512
|
+
throw new Error(`Invalid unit format: ${input}`);
|
|
2513
|
+
return { value: parseFloat(match[1]), unit: match[2] || '' };
|
|
2514
|
+
}
|
|
2515
|
+
static getValueFromUnit(value, unit) {
|
|
2516
|
+
return unit ? `${value}${unit}` : `${value}`;
|
|
2517
|
+
}
|
|
2518
|
+
static parseGap(gap) {
|
|
2519
|
+
const parts = gap.split(/\s+/);
|
|
2520
|
+
const match = parts[0].match(/^(\d+\.?\d*)([a-z%]+)$/);
|
|
2521
|
+
if (!match) {
|
|
2522
|
+
throw new Error('Invalid gap format');
|
|
2523
|
+
}
|
|
2524
|
+
const [, xValue, unit] = match;
|
|
2525
|
+
let yValue = parseFloat(xValue);
|
|
2526
|
+
if (parts.length === 2) {
|
|
2527
|
+
const secondMatch = parts[1].match(/^(\d+\.?\d*)[a-z%]+$/);
|
|
2528
|
+
if (!secondMatch) {
|
|
2529
|
+
throw new Error('Invalid gap format');
|
|
2530
|
+
}
|
|
2531
|
+
yValue = parseFloat(secondMatch[1]);
|
|
2532
|
+
}
|
|
2533
|
+
return {
|
|
2534
|
+
values: {
|
|
2535
|
+
x: parseFloat(xValue),
|
|
2536
|
+
y: yValue,
|
|
2537
|
+
},
|
|
2538
|
+
unit,
|
|
2539
|
+
};
|
|
2540
|
+
}
|
|
2541
|
+
static parseGridTemplate(gridTemplate) {
|
|
2542
|
+
const match = gridTemplate.match(/^repeat\((\d+),\s*(?:1fr|auto|minmax\([^)]*\))\)$/);
|
|
2543
|
+
if (!match) {
|
|
2544
|
+
throw new Error("Invalid grid template format. Expected 'repeat(N, 1fr|auto|minmax(...))'.");
|
|
2545
|
+
}
|
|
2546
|
+
return parseInt(match[1], 10);
|
|
2547
|
+
}
|
|
2548
|
+
static createGridTemplate(repetitionCount) {
|
|
2549
|
+
if (repetitionCount <= 0) {
|
|
2550
|
+
throw new Error('Repetition count must be a positive integer.');
|
|
2551
|
+
}
|
|
2552
|
+
return `repeat(${repetitionCount}, 1fr)`;
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
function findNonEmptyBreakpoints(values) {
|
|
2556
|
+
const breakpoints = ['default', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'];
|
|
2557
|
+
const nonEmptyBreakpoints = [];
|
|
2558
|
+
for (const breakpoint of breakpoints) {
|
|
2559
|
+
if (values[breakpoint] !== undefined) {
|
|
2560
|
+
nonEmptyBreakpoints.push(breakpoint);
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
return nonEmptyBreakpoints;
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
const AXP_WIDGETS_LAYOUT_CATEGORY = {
|
|
2567
|
+
name: 'layout',
|
|
2568
|
+
order: 1,
|
|
2569
|
+
title: 'Layout',
|
|
2570
|
+
};
|
|
2571
|
+
const AXP_WIDGETS_EDITOR_CATEGORY = {
|
|
2572
|
+
name: 'editor',
|
|
2573
|
+
order: 2,
|
|
2574
|
+
title: 'Editors',
|
|
2575
|
+
};
|
|
2576
|
+
const AXP_WIDGETS_ACTION_CATEGORY = {
|
|
2577
|
+
name: 'action',
|
|
2578
|
+
order: 3,
|
|
2579
|
+
title: 'Action',
|
|
2580
|
+
};
|
|
2581
|
+
const AXP_WIDGETS_ADVANCE_CATEGORY = {
|
|
2582
|
+
name: 'advance',
|
|
2583
|
+
order: 4,
|
|
2584
|
+
title: 'Advance',
|
|
2585
|
+
};
|
|
2586
|
+
const AXP_WIDGETS_CATEGORIES = [
|
|
2587
|
+
AXP_WIDGETS_LAYOUT_CATEGORY,
|
|
2588
|
+
AXP_WIDGETS_EDITOR_CATEGORY,
|
|
2589
|
+
AXP_WIDGETS_ACTION_CATEGORY,
|
|
2590
|
+
AXP_WIDGETS_ADVANCE_CATEGORY,
|
|
2591
|
+
];
|
|
2592
|
+
|
|
2593
|
+
var AXPWidgetGroupEnum;
|
|
2594
|
+
(function (AXPWidgetGroupEnum) {
|
|
2595
|
+
AXPWidgetGroupEnum["FormElement"] = "form-element";
|
|
2596
|
+
AXPWidgetGroupEnum["DashboardWidget"] = "dashboard-widget";
|
|
2597
|
+
AXPWidgetGroupEnum["FormTemplate"] = "form-template";
|
|
2598
|
+
AXPWidgetGroupEnum["PropertyEditor"] = "property-editor";
|
|
2599
|
+
AXPWidgetGroupEnum["MetaData"] = "meta-data";
|
|
2600
|
+
AXPWidgetGroupEnum["SettingWidget"] = "setting-widget";
|
|
2601
|
+
AXPWidgetGroupEnum["EntityWidget"] = "entity-widget";
|
|
2602
|
+
})(AXPWidgetGroupEnum || (AXPWidgetGroupEnum = {}));
|
|
2603
|
+
|
|
2604
|
+
class AXPWidgetStandaloneRendererHostComponent {
|
|
2605
|
+
constructor() {
|
|
2606
|
+
this.mode = 'edit';
|
|
2607
|
+
}
|
|
2608
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetStandaloneRendererHostComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2609
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.4", type: AXPWidgetStandaloneRendererHostComponent, isStandalone: true, selector: "axp-widget-standalone-renderer-host", inputs: { mode: "mode", node: "node", context: "context", functions: "functions" }, ngImport: i0, template: `
|
|
2610
|
+
<axp-widgets-container [context]="context" [functions]="functions">
|
|
2611
|
+
<ng-container axp-widget-renderer [mode]="mode" [node]="node"></ng-container>
|
|
2612
|
+
</axp-widgets-container>
|
|
2613
|
+
`, isInline: true, dependencies: [{ kind: "ngmodule", type: AXPWidgetCoreModule }, { kind: "component", type: AXPWidgetContainerComponent, selector: "axp-widgets-container", inputs: ["context", "functions"], outputs: ["onContextChanged"] }, { kind: "directive", type: AXPWidgetRendererDirective, selector: "[axp-widget-renderer]", inputs: ["parentNode", "index", "mode", "node"], outputs: ["onOptionsChanged", "onValueChanged"], exportAs: ["widgetRenderer"] }] }); }
|
|
2614
|
+
}
|
|
2615
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPWidgetStandaloneRendererHostComponent, decorators: [{
|
|
2616
|
+
type: Component,
|
|
2617
|
+
args: [{
|
|
2618
|
+
selector: 'axp-widget-standalone-renderer-host',
|
|
2619
|
+
template: `
|
|
2620
|
+
<axp-widgets-container [context]="context" [functions]="functions">
|
|
2621
|
+
<ng-container axp-widget-renderer [mode]="mode" [node]="node"></ng-container>
|
|
2622
|
+
</axp-widgets-container>
|
|
2623
|
+
`,
|
|
2624
|
+
standalone: true,
|
|
2625
|
+
imports: [AXPWidgetCoreModule]
|
|
2626
|
+
}]
|
|
2627
|
+
}], propDecorators: { mode: [{
|
|
2628
|
+
type: Input
|
|
2629
|
+
}], node: [{
|
|
2630
|
+
type: Input
|
|
2631
|
+
}], context: [{
|
|
2632
|
+
type: Input
|
|
2633
|
+
}], functions: [{
|
|
2634
|
+
type: Input
|
|
2635
|
+
}] } });
|
|
2636
|
+
|
|
2637
|
+
const LAYOUT_WIDGET_RENDER_ENGINE = new InjectionToken('LAYOUT_WIDGET_RENDER_ENGINE');
|
|
2638
|
+
class WidgetCoreRendererEngine {
|
|
2639
|
+
constructor(appRef, env) {
|
|
2640
|
+
this.appRef = appRef;
|
|
2641
|
+
this.env = env;
|
|
2642
|
+
}
|
|
2643
|
+
render(node, target, context, mode = 'edit') {
|
|
2644
|
+
const compRef = createComponent(AXPWidgetStandaloneRendererHostComponent, { environmentInjector: this.env });
|
|
2645
|
+
compRef.setInput('mode', mode);
|
|
2646
|
+
compRef.setInput('node', node);
|
|
2647
|
+
if (context) {
|
|
2648
|
+
compRef.setInput('context', context);
|
|
2649
|
+
}
|
|
2650
|
+
this.appRef.attachView(compRef.hostView);
|
|
2651
|
+
target.appendChild(compRef.location.nativeElement);
|
|
2652
|
+
return {
|
|
2653
|
+
element: compRef.location.nativeElement,
|
|
2654
|
+
destroy: () => {
|
|
2655
|
+
try {
|
|
2656
|
+
this.appRef.detachView(compRef.hostView);
|
|
2657
|
+
}
|
|
2658
|
+
catch { }
|
|
2659
|
+
compRef.destroy();
|
|
2660
|
+
},
|
|
2661
|
+
};
|
|
2662
|
+
}
|
|
2663
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: WidgetCoreRendererEngine, deps: [{ token: i0.ApplicationRef }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2664
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: WidgetCoreRendererEngine, providedIn: 'root' }); }
|
|
2665
|
+
}
|
|
2666
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: WidgetCoreRendererEngine, decorators: [{
|
|
2667
|
+
type: Injectable,
|
|
2668
|
+
args: [{ providedIn: 'root' }]
|
|
2669
|
+
}], ctorParameters: () => [{ type: i0.ApplicationRef }, { type: i0.EnvironmentInjector }] });
|
|
2670
|
+
class SimpleDomRendererEngine {
|
|
2671
|
+
render(node, target) {
|
|
2672
|
+
const element = this.createElement(node);
|
|
2673
|
+
target.appendChild(element);
|
|
2674
|
+
return {
|
|
2675
|
+
element,
|
|
2676
|
+
destroy: () => {
|
|
2677
|
+
if (element.parentElement) {
|
|
2678
|
+
element.parentElement.removeChild(element);
|
|
2679
|
+
}
|
|
2680
|
+
},
|
|
2681
|
+
};
|
|
2682
|
+
}
|
|
2683
|
+
createElement(node) {
|
|
2684
|
+
const container = document.createElement('div');
|
|
2685
|
+
container.className = `axp-widget axp-widget-${node.type}`;
|
|
2686
|
+
switch (String(node.type)) {
|
|
2687
|
+
case 'text-block-layout':
|
|
2688
|
+
case 'static-text':
|
|
2689
|
+
this.renderText(container, node);
|
|
2690
|
+
break;
|
|
2691
|
+
case 'tag':
|
|
2692
|
+
this.renderTag(container, node);
|
|
2693
|
+
break;
|
|
2694
|
+
case 'text-editor':
|
|
2695
|
+
this.renderTextBox(container, node);
|
|
2696
|
+
break;
|
|
2697
|
+
default:
|
|
2698
|
+
this.renderGeneric(container, node);
|
|
2699
|
+
break;
|
|
2700
|
+
}
|
|
2701
|
+
return container;
|
|
2702
|
+
}
|
|
2703
|
+
renderText(container, node) {
|
|
2704
|
+
const anyNode = node;
|
|
2705
|
+
const content = (anyNode.options && (anyNode.options.content || anyNode.options.label)) || '';
|
|
2706
|
+
container.innerHTML = typeof content === 'string' ? content : String(content);
|
|
2707
|
+
}
|
|
2708
|
+
renderTag(container, node) {
|
|
2709
|
+
const label = node.options?.label || 'Tag';
|
|
2710
|
+
const tone = node.options?.tone || 'primary';
|
|
2711
|
+
container.innerHTML = `<span class="tag tag-${tone}" style="
|
|
2712
|
+
display: inline-block;
|
|
2713
|
+
padding: 4px 12px;
|
|
2714
|
+
border-radius: 12px;
|
|
2715
|
+
font-size: 12px;
|
|
2716
|
+
font-weight: 500;
|
|
2717
|
+
background: ${tone === 'success' ? '#d4edda' : '#cce5ff'};
|
|
2718
|
+
color: ${tone === 'success' ? '#155724' : '#004085'};
|
|
2719
|
+
border: 1px solid ${tone === 'success' ? '#c3e6cb' : '#b8daff'};
|
|
2720
|
+
">${label}</span>`;
|
|
2721
|
+
}
|
|
2722
|
+
renderTextBox(container, node) {
|
|
2723
|
+
const placeholder = node.options?.placeholder || '';
|
|
2724
|
+
const input = document.createElement('input');
|
|
2725
|
+
input.type = 'text';
|
|
2726
|
+
input.placeholder = placeholder;
|
|
2727
|
+
input.style.cssText = `
|
|
2728
|
+
width: 100%;
|
|
2729
|
+
padding: 8px 12px;
|
|
2730
|
+
border: 1px solid #ddd;
|
|
2731
|
+
border-radius: 4px;
|
|
2732
|
+
font-size: 14px;
|
|
2733
|
+
`;
|
|
2734
|
+
container.appendChild(input);
|
|
2735
|
+
}
|
|
2736
|
+
renderGeneric(container, node) {
|
|
2737
|
+
const anyNode = node;
|
|
2738
|
+
if (anyNode.options?.content) {
|
|
2739
|
+
container.innerHTML = anyNode.options.content;
|
|
2740
|
+
}
|
|
2741
|
+
else {
|
|
2742
|
+
container.textContent = `[${String(node.type)}]`;
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
function provideWidgetCoreRenderer() {
|
|
2747
|
+
return [{ provide: LAYOUT_WIDGET_RENDER_ENGINE, useClass: WidgetCoreRendererEngine }];
|
|
2748
|
+
}
|
|
2749
|
+
function provideSimpleDomRenderer() {
|
|
2750
|
+
return [{ provide: LAYOUT_WIDGET_RENDER_ENGINE, useClass: SimpleDomRendererEngine }];
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
/**
|
|
2754
|
+
* Generated bundle index. Do not edit.
|
|
2755
|
+
*/
|
|
2756
|
+
|
|
2757
|
+
export { AXPBaseWidgetComponent, AXPBlockBaseLayoutWidgetComponent, AXPBoxModelLayoutWidgetComponent, AXPColumnWidgetComponent, AXPDataListWidgetComponent, AXPFlexBaseLayoutWidgetComponent, AXPFlexItemBaseLayoutWidgetComponent, AXPGridBaseLayoutWidgetComponent, AXPGridItemBaseLayoutWidgetComponent, AXPInlineBaseLayoutWidgetComponent, AXPLayoutBaseWidgetComponent, AXPPageStatus, AXPPropertyEditorHelper, AXPTableBaseLayoutWidgetComponent, AXPTableItemBaseLayoutWidgetComponent, AXPTableItemOpsBaseLayoutWidgetComponent, AXPValueWidgetComponent, AXPWidgetColumnRendererComponent, AXPWidgetContainerComponent, AXPWidgetCoreContextChangeEvent, AXPWidgetCoreContextStore, AXPWidgetCoreElement, AXPWidgetCoreModule, AXPWidgetCoreService, AXPWidgetGroupEnum, AXPWidgetRegistryService, AXPWidgetRendererDirective, AXPWidgetStandaloneRendererHostComponent, AXPWidgetStatus, AXPWidgetsCatalog, AXP_WIDGETS_ACTION_CATEGORY, AXP_WIDGETS_ADVANCE_CATEGORY, AXP_WIDGETS_CATEGORIES, AXP_WIDGETS_EDITOR_CATEGORY, AXP_WIDGETS_LAYOUT_CATEGORY, AXP_WIDGET_COLUMN_TOKEN, AXP_WIDGET_TOKEN, LAYOUT_WIDGET_RENDER_ENGINE, SimpleDomRendererEngine, WidgetCoreRendererEngine, cloneProperty, createBooleanProperty, createNumberProperty, createSelectProperty, createStringProperty, findNonEmptyBreakpoints, provideSimpleDomRenderer, provideWidgetCoreRenderer };
|
|
2758
|
+
//# sourceMappingURL=acorex-platform-layout-widget-core.mjs.map
|