@acorex/platform 20.3.0-next.2 → 20.3.0-next.20

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