@acorex/platform 18.1.0 → 18.1.2

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 (98) hide show
  1. package/esm2022/common/lib/schema/widgets/rich-text/rich-text-widget-edit.component.mjs +1 -2
  2. package/esm2022/layout/builder/lib/builder/builder.module.mjs +4 -3
  3. package/esm2022/layout/builder/lib/builder/index.mjs +2 -1
  4. package/esm2022/layout/builder/lib/builder/widget-renderer.component.directive.mjs +280 -0
  5. package/esm2022/layout/builder/lib/builder/widget.types.mjs +60 -1
  6. package/esm2022/layout/designer/lib/designer/components/board/board.component.mjs +3 -3
  7. package/esm2022/layout/designer/lib/designer/components/header-menu/header-menu.component.mjs +3 -3
  8. package/esm2022/layout/designer/lib/designer/designer.component.mjs +9 -5
  9. package/esm2022/layout/designer/lib/designer/shared/designer.service.mjs +21 -21
  10. package/esm2022/layout/designer/lib/designer/shared/designer.typs.mjs +6 -2
  11. package/esm2022/themes/default/lib/layouts/entity-layouts/entity-master-single-view/comments/comment-list-view.component.mjs +208 -47
  12. package/esm2022/themes/default/lib/layouts/entity-layouts/entity-master-single-view/comments/comment-lookup-popup.component.mjs +56 -0
  13. package/esm2022/themes/default/lib/layouts/entity-layouts/entity-master-single-view/comments/comments.service.mjs +1 -1
  14. package/esm2022/themes/default/lib/layouts/entity-layouts/entity-master-single-view/comments/comments.type.mjs +2 -0
  15. package/esm2022/themes/default/lib/layouts/entity-layouts/entity-master-single-view/overview/entity-single-overview.component.mjs +3 -3
  16. package/esm2022/themes/default/lib/layouts/entity-layouts/index.mjs +2 -1
  17. package/esm2022/widgets/lib/properties/editors.props.mjs +102 -308
  18. package/esm2022/widgets/lib/properties/general.props.mjs +4 -13
  19. package/esm2022/widgets/lib/widgets/actions/button/button-widget-designer.component.mjs +3 -4
  20. package/esm2022/widgets/lib/widgets/actions/button/button-widget-view.component.mjs +3 -3
  21. package/esm2022/widgets/lib/widgets/advance/map/map-box-widget-edit.component.mjs +9 -4
  22. package/esm2022/widgets/lib/widgets/advance/map/map-box-widget-view.component.mjs +6 -6
  23. package/esm2022/widgets/lib/widgets/editors/checkbox/checkbox-widget-designer.component.mjs +4 -4
  24. package/esm2022/widgets/lib/widgets/editors/contact/contact-widget-edit.component.mjs +17 -24
  25. package/esm2022/widgets/lib/widgets/editors/contact/contact-widget-view.component.mjs +6 -6
  26. package/esm2022/widgets/lib/widgets/editors/date-time/date-time-box-widget.config.mjs +3 -3
  27. package/esm2022/widgets/lib/widgets/editors/rich-text/rich-text-widget-view.component.mjs +5 -3
  28. package/esm2022/widgets/lib/widgets/editors/select/select-box-widget-column.component.mjs +36 -6
  29. package/esm2022/widgets/lib/widgets/editors/selection-list/selection-list-widget-column.component.mjs +2 -1
  30. package/esm2022/widgets/lib/widgets/layout/block/block-widget-designer.component.mjs +3 -7
  31. package/esm2022/widgets/lib/widgets/layout/block/block-widget-view.component.mjs +4 -4
  32. package/esm2022/widgets/lib/widgets/layout/form-field/form-field-widget-view.component.mjs +26 -16
  33. package/esm2022/widgets/lib/widgets/layout/grid/grid-widget-designer.component.mjs +37 -31
  34. package/esm2022/widgets/lib/widgets/layout/grid/grid-widget-view.component.mjs +25 -6
  35. package/esm2022/widgets/lib/widgets/layout/grid-item/grid-item-widget-designer.component.mjs +32 -26
  36. package/esm2022/widgets/lib/widgets/layout/grid-item/grid-item-widget-view.component.mjs +78 -8
  37. package/esm2022/widgets/lib/widgets/layout/grid-row/grid-row-widget-view.component.mjs +25 -6
  38. package/esm2022/widgets/lib/widgets/layout/page/page-widget-view.component.mjs +4 -4
  39. package/esm2022/widgets/lib/widgets/layout/repeater/repeater-widget-designer.component.mjs +94 -19
  40. package/esm2022/widgets/lib/widgets/layout/repeater/repeater-widget-edit.component.mjs +119 -8
  41. package/esm2022/widgets/lib/widgets/layout/repeater/repeater-widget-print.component.mjs +3 -2
  42. package/esm2022/widgets/lib/widgets/layout/repeater/repeater-widget-view.component.mjs +14 -22
  43. package/esm2022/widgets/lib/widgets/layout/repeater/repeater-widget.config.mjs +16 -3
  44. package/fesm2022/{acorex-platform-common-rich-text-widget-edit.component-CnH3MjYz.mjs → acorex-platform-common-rich-text-widget-edit.component-Do3YcmKg.mjs} +1 -2
  45. package/fesm2022/acorex-platform-common-rich-text-widget-edit.component-Do3YcmKg.mjs.map +1 -0
  46. package/fesm2022/acorex-platform-common.mjs +1 -1
  47. package/fesm2022/acorex-platform-layout-builder.mjs +368 -38
  48. package/fesm2022/acorex-platform-layout-builder.mjs.map +1 -1
  49. package/fesm2022/acorex-platform-layout-designer.mjs +36 -28
  50. package/fesm2022/acorex-platform-layout-designer.mjs.map +1 -1
  51. package/fesm2022/{acorex-platform-themes-default-entity-master-create-view.component-Q8eTfAVx.mjs → acorex-platform-themes-default-entity-master-create-view.component-LyEomIA6.mjs} +3 -3
  52. package/fesm2022/{acorex-platform-themes-default-entity-master-create-view.component-Q8eTfAVx.mjs.map → acorex-platform-themes-default-entity-master-create-view.component-LyEomIA6.mjs.map} +1 -1
  53. package/fesm2022/{acorex-platform-themes-default-entity-master-list-view.component-CWXJxLS0.mjs → acorex-platform-themes-default-entity-master-list-view.component-CKRwvJTp.mjs} +3 -3
  54. package/fesm2022/{acorex-platform-themes-default-entity-master-list-view.component-CWXJxLS0.mjs.map → acorex-platform-themes-default-entity-master-list-view.component-CKRwvJTp.mjs.map} +1 -1
  55. package/fesm2022/{acorex-platform-themes-default-entity-master-modify-view.component-BijYXMme.mjs → acorex-platform-themes-default-entity-master-modify-view.component-CMRfspMB.mjs} +3 -3
  56. package/fesm2022/{acorex-platform-themes-default-entity-master-modify-view.component-BijYXMme.mjs.map → acorex-platform-themes-default-entity-master-modify-view.component-CMRfspMB.mjs.map} +1 -1
  57. package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-DhcKSyrX.mjs +457 -0
  58. package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-DhcKSyrX.mjs.map +1 -0
  59. package/fesm2022/acorex-platform-themes-default.mjs +134 -11
  60. package/fesm2022/acorex-platform-themes-default.mjs.map +1 -1
  61. package/fesm2022/{acorex-platform-widgets-button-widget-designer.component-COvuxaTt.mjs → acorex-platform-widgets-button-widget-designer.component-B9bfVuC4.mjs} +3 -4
  62. package/fesm2022/acorex-platform-widgets-button-widget-designer.component-B9bfVuC4.mjs.map +1 -0
  63. package/fesm2022/{acorex-platform-widgets-checkbox-widget-designer.component-DAGbdSTk.mjs → acorex-platform-widgets-checkbox-widget-designer.component-DzGg-uFi.mjs} +4 -4
  64. package/fesm2022/acorex-platform-widgets-checkbox-widget-designer.component-DzGg-uFi.mjs.map +1 -0
  65. package/fesm2022/acorex-platform-widgets.mjs +620 -498
  66. package/fesm2022/acorex-platform-widgets.mjs.map +1 -1
  67. package/layout/builder/lib/builder/builder.module.d.ts +5 -4
  68. package/layout/builder/lib/builder/index.d.ts +1 -0
  69. package/layout/builder/lib/builder/widget-renderer.component.directive.d.ts +42 -0
  70. package/layout/builder/lib/builder/widget.types.d.ts +30 -1
  71. package/layout/designer/lib/designer/designer.component.d.ts +1 -0
  72. package/layout/designer/lib/designer/shared/designer.service.d.ts +2 -1
  73. package/layout/designer/lib/designer/shared/designer.typs.d.ts +15 -0
  74. package/package.json +11 -11
  75. package/themes/default/lib/layouts/entity-layouts/entity-master-single-view/comments/comment-list-view.component.d.ts +37 -15
  76. package/themes/default/lib/layouts/entity-layouts/entity-master-single-view/comments/comment-lookup-popup.component.d.ts +10 -0
  77. package/themes/default/lib/layouts/entity-layouts/entity-master-single-view/comments/comments.service.d.ts +6 -9
  78. package/themes/default/lib/layouts/entity-layouts/entity-master-single-view/comments/comments.type.d.ts +70 -0
  79. package/themes/default/lib/layouts/entity-layouts/index.d.ts +1 -0
  80. package/widgets/lib/properties/editors.props.d.ts +3 -3
  81. package/widgets/lib/widgets/actions/button/button-widget-designer.component.d.ts +1 -1
  82. package/widgets/lib/widgets/actions/button/button-widget-view.component.d.ts +1 -1
  83. package/widgets/lib/widgets/advance/map/map-box-widget-edit.component.d.ts +1 -0
  84. package/widgets/lib/widgets/editors/contact/contact-widget-edit.component.d.ts +1 -0
  85. package/widgets/lib/widgets/editors/select/select-box-widget-column.component.d.ts +5 -0
  86. package/widgets/lib/widgets/layout/form-field/form-field-widget-view.component.d.ts +2 -1
  87. package/widgets/lib/widgets/layout/grid/grid-widget-view.component.d.ts +3 -0
  88. package/widgets/lib/widgets/layout/grid-item/grid-item-widget-view.component.d.ts +11 -2
  89. package/widgets/lib/widgets/layout/grid-row/grid-row-widget-view.component.d.ts +3 -0
  90. package/widgets/lib/widgets/layout/repeater/repeater-widget-designer.component.d.ts +4 -3
  91. package/widgets/lib/widgets/layout/repeater/repeater-widget-edit.component.d.ts +10 -2
  92. package/widgets/lib/widgets/layout/repeater/repeater-widget-print.component.d.ts +1 -1
  93. package/widgets/lib/widgets/layout/repeater/repeater-widget-view.component.d.ts +2 -4
  94. package/fesm2022/acorex-platform-common-rich-text-widget-edit.component-CnH3MjYz.mjs.map +0 -1
  95. package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-CGhOE3jO.mjs +0 -357
  96. package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-CGhOE3jO.mjs.map +0 -1
  97. package/fesm2022/acorex-platform-widgets-button-widget-designer.component-COvuxaTt.mjs.map +0 -1
  98. package/fesm2022/acorex-platform-widgets-checkbox-widget-designer.component-DAGbdSTk.mjs.map +0 -1
@@ -5,7 +5,7 @@ import { ComponentPortal, PortalModule } from '@angular/cdk/portal';
5
5
  import * as i1 from '@angular/common';
6
6
  import { CommonModule } from '@angular/common';
7
7
  import * as i0 from '@angular/core';
8
- import { signal, Injectable, InjectionToken, inject, ElementRef, computed, afterNextRender, Injector, Component, ChangeDetectionStrategy, Input, EventEmitter, model, effect, Output, ChangeDetectorRef, ViewChild, NgModule, Optional, Inject } from '@angular/core';
8
+ import { signal, Injectable, InjectionToken, inject, ElementRef, computed, afterNextRender, Injector, Component, ChangeDetectionStrategy, Input, EventEmitter, model, effect, Output, ChangeDetectorRef, ViewChild, input, ViewContainerRef, Directive, NgModule, Optional, Inject } from '@angular/core';
9
9
  import { AXUnsubscriber } from '@acorex/core/utils';
10
10
  import { set, get, isEqual, clone, merge, cloneDeep, isUndefined, sum } from 'lodash-es';
11
11
  import { Subject, debounceTime, filter } from 'rxjs';
@@ -143,9 +143,101 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImpor
143
143
  }]
144
144
  }] });
145
145
 
146
+ const AXPWidgetsCatalog = {
147
+ checkbox: 'checkbox-editor',
148
+ color: 'color-editor',
149
+ contact: 'contact-editor',
150
+ dateTime: 'date-time-editor',
151
+ email: 'email-editor',
152
+ largeText: 'large-text-editor',
153
+ link: 'link-editor',
154
+ number: 'number-editor',
155
+ password: 'password-editor',
156
+ phone: 'phone-editor',
157
+ richText: 'rich-text-editor',
158
+ select: 'select-editor',
159
+ selectionList: 'selection-list-editor',
160
+ text: 'text-editor',
161
+ toggle: 'toggle-editor',
162
+ blockLayout: 'block-layout',
163
+ pageLayout: 'page-layout',
164
+ repeaterLayout: 'repeater-layout',
165
+ textBlockLayout: 'text-block-layout',
166
+ file: 'file',
167
+ map: 'map',
168
+ gallery: 'gallery',
169
+ signature: 'signature',
170
+ buttonAction: 'button-action',
171
+ document: 'document-layout',
172
+ lookup: 'lookup-editor',
173
+ formField: 'form-field',
174
+ qrcode: 'qrcode',
175
+ grid: 'grid-layout',
176
+ gridItem: 'grid-item-layout',
177
+ gridRow: 'grid-row-layout',
178
+ };
179
+
146
180
  function cloneProperty(property, values) {
147
181
  return merge(cloneDeep(property), values);
148
182
  }
183
+ function createStringProperty(ctor) {
184
+ return {
185
+ name: ctor.name,
186
+ title: ctor.title,
187
+ group: ctor.group,
188
+ schema: {
189
+ dataType: 'string',
190
+ defaultValue: ctor.defaultValue,
191
+ interface: {
192
+ name: ctor.name,
193
+ path: ctor.path ?? ctor.name,
194
+ type: AXPWidgetsCatalog.text,
195
+ },
196
+ },
197
+ visible: ctor.visible ?? true,
198
+ };
199
+ }
200
+ function createBooleanProperty(ctor) {
201
+ return {
202
+ name: ctor.name,
203
+ title: ctor.title,
204
+ group: ctor.group,
205
+ schema: {
206
+ dataType: 'boolean',
207
+ defaultValue: ctor.defaultValue ?? false,
208
+ interface: {
209
+ name: ctor.name,
210
+ path: ctor.path ?? ctor.name,
211
+ type: AXPWidgetsCatalog.toggle,
212
+ },
213
+ },
214
+ visible: ctor.visible ?? true,
215
+ };
216
+ }
217
+ function createSelectProperty(ctor) {
218
+ return {
219
+ name: ctor.name,
220
+ title: ctor.title,
221
+ group: ctor.group,
222
+ schema: {
223
+ dataType: 'string',
224
+ defaultValue: Array.isArray(ctor.defaultValue)
225
+ ? ctor.defaultValue.map((item) => (typeof item === 'string' ? { id: item } : item))
226
+ : typeof ctor.defaultValue === 'string'
227
+ ? { id: ctor.defaultValue, title: ctor.defaultValue }
228
+ : ctor.defaultValue,
229
+ interface: {
230
+ name: ctor.name,
231
+ path: ctor.path ?? ctor.name,
232
+ type: AXPWidgetsCatalog.select,
233
+ options: {
234
+ dataSource: ctor.dataSource.map((item) => (typeof item === 'string' ? { id: item, title: item } : item)),
235
+ },
236
+ },
237
+ },
238
+ visible: ctor.visible ?? true,
239
+ };
240
+ }
149
241
  const AXP_WIDGET_TOKEN = new InjectionToken('AXP_WIDGET_TOKEN');
150
242
  const AXP_WIDGET_COLUMN_TOKEN = new InjectionToken('AXP_WIDGET_COLUMN_TOKEN');
151
243
  class AXPWidgetComponent extends AXPLayoutElement {
@@ -741,7 +833,279 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImpor
741
833
  args: ['header']
742
834
  }] } });
743
835
 
744
- const COMPONENTS = [AXPWidgetContainerComponent, AXPWidgetRendererComponent, AXPWidgetColumnRendererComponent];
836
+ class AXPWidgetRendererDirective {
837
+ constructor() {
838
+ this.parentNode = input();
839
+ this.index = input();
840
+ this.mode = input.required();
841
+ this.node = input.required();
842
+ this.mergedOptions = signal({});
843
+ this.injector = inject(Injector);
844
+ this.builderService = inject(AXPLayoutBuilderService);
845
+ this.widgetRegistery = inject(AXPWidgetRegistryService);
846
+ this.unsubscriber = inject(AXUnsubscriber);
847
+ this.viewContainerRef = inject(ViewContainerRef);
848
+ this.isLoading = signal(true);
849
+ this.expressionCache = new Map();
850
+ this.expressionEvaluators = new Map();
851
+ this.scope = null;
852
+ this.builderService.onChanged.pipe(this.unsubscriber.takeUntilDestroy).subscribe(async (e) => {
853
+ if ((await this.updateOptionsBasedOnContext()) > 0) {
854
+ this.applyOptions();
855
+ }
856
+ if (this.checkFormulaForUpdate(this.node().formula, e.path)) {
857
+ await this.updateValueBasedOnFormula();
858
+ }
859
+ });
860
+ //
861
+ effect(async () => {
862
+ await this.loadComponent();
863
+ }, { allowSignalWrites: true });
864
+ }
865
+ async loadComponent() {
866
+ this.isLoading.set(true);
867
+ this.viewContainerRef.clear();
868
+ const widget = this.widgetRegistery.resolve(this.node().type);
869
+ //
870
+ const props = widget?.components[this.mode()]?.properties
871
+ ?.filter((c) => c.schema.defaultValue)
872
+ .map((c) => ({ [c.name]: c.schema.defaultValue }))
873
+ .reduce((acc, curr) => {
874
+ return { ...acc, ...curr };
875
+ }, {});
876
+ //
877
+ this.mergedOptions.set(merge(props, this.node().options) || {});
878
+ this.preprocessAndInitialOptions(cloneDeep(this.node().options));
879
+ await this.updateOptionsBasedOnContext();
880
+ //
881
+ const tokenValue = {
882
+ node: this.node(),
883
+ options: this.mergedOptions(),
884
+ config: widget,
885
+ };
886
+ const token = Injector.create({
887
+ parent: this.injector,
888
+ providers: [
889
+ {
890
+ provide: AXP_WIDGET_TOKEN,
891
+ useValue: tokenValue,
892
+ },
893
+ ],
894
+ });
895
+ //
896
+ var com = await widget?.components[this.mode()]?.component();
897
+ this.instance = this.viewContainerRef.createComponent(com, { injector: token }).instance;
898
+ this.instance.parent = this.parentNode();
899
+ this.instance.index = this.index();
900
+ this.instance.mode = this.mode();
901
+ await this.updateValueBasedOnFormula();
902
+ await this.assignTriggers();
903
+ //
904
+ this.isLoading.set(false);
905
+ }
906
+ applyOptions() {
907
+ if (!this.instance)
908
+ return;
909
+ this.instance.setOptions(this.mergedOptions());
910
+ }
911
+ checkFormulaForUpdate(formula, path) {
912
+ if (formula) {
913
+ const regex = /context\.eval\('([^']+)'\)/g;
914
+ const matches = formula.match(regex);
915
+ const nodes = matches ? matches.map((match) => match.match(/'([^']+)'/)[1]) : [];
916
+ return nodes.includes(path);
917
+ }
918
+ else
919
+ return false;
920
+ }
921
+ preprocessAndInitialOptions(obj, pathPrefix = '') {
922
+ if (!obj)
923
+ return;
924
+ Object.entries(obj).forEach(([key, value]) => {
925
+ const currentPath = pathPrefix ? `${pathPrefix}.${key}` : key;
926
+ if (typeof value === 'string' && value.includes('{{')) {
927
+ // Cache dynamic expression for later evaluation
928
+ this.expressionEvaluators.set(currentPath, () => this.evaluateExpression(value));
929
+ }
930
+ else if (typeof value === 'object' && value !== null && (value.constructor === Object || Array.isArray(value))) {
931
+ // Recursively handle nested objects
932
+ this.preprocessAndInitialOptions(value, currentPath);
933
+ }
934
+ else {
935
+ // Apply static values directly
936
+ this.mergedOptions.update((currentOptions) => {
937
+ return set(currentOptions, currentPath, value);
938
+ });
939
+ }
940
+ });
941
+ }
942
+ async updateOptionsBasedOnContext() {
943
+ const updates = [];
944
+ for (let [path, evaluator] of this.expressionEvaluators) {
945
+ const newValue = await evaluator();
946
+ updates.push({ path, newValue });
947
+ }
948
+ // Apply updates to mergedOptions
949
+ if (updates.length > 0) {
950
+ this.mergedOptions.update((o) => {
951
+ const updatedOptions = { ...o };
952
+ updates.forEach(({ path, newValue }) => {
953
+ // Set the new value in the updatedOptions object by path
954
+ set(updatedOptions, path, newValue); // Assuming 'set' can handle paths like 'property.subproperty'
955
+ });
956
+ return updatedOptions;
957
+ });
958
+ }
959
+ return updates.length;
960
+ }
961
+ async updateValueBasedOnFormula() {
962
+ if (this.node().formula) {
963
+ const value = await this.evaluateExpression(this.node().formula);
964
+ this.instance.setValue(value);
965
+ }
966
+ }
967
+ async evaluateExpression(templateExpression) {
968
+ try {
969
+ // Check cache first, but cache the function for evaluation, not the evaluated value
970
+ if (!this.expressionCache.has(templateExpression)) {
971
+ const expressionMatch = templateExpression.match(/\{\{\s*(.*?)\s*\}\}/);
972
+ if (!expressionMatch) {
973
+ throw Error(`No valid expression found in "${templateExpression}"`);
974
+ }
975
+ const expression = expressionMatch[1];
976
+ // Cache the evaluation function instead of the result
977
+ const scope = this.getGlobalScope();
978
+ const evaluationFunction = async () => {
979
+ const sandbox = new Function('scope', `with (scope) { return (async function() { return ${expression}; })(); }`);
980
+ return await sandbox(scope);
981
+ };
982
+ this.expressionCache.set(templateExpression, evaluationFunction);
983
+ }
984
+ // Retrieve the function from the cache and call it to evaluate the expression
985
+ const evaluate = this.expressionCache.get(templateExpression);
986
+ if (evaluate) {
987
+ const result = await evaluate();
988
+ return result;
989
+ }
990
+ else {
991
+ throw Error(`Failed to retrieve evaluation function for expression: "${templateExpression}"`);
992
+ }
993
+ }
994
+ catch (error) {
995
+ console.error('Error evaluating expression:', error);
996
+ return false;
997
+ }
998
+ }
999
+ getGlobalScope() {
1000
+ if (this.scope)
1001
+ return this.scope;
1002
+ this.scope = {};
1003
+ set(this.scope, 'context', this.getContextScope());
1004
+ set(this.scope, 'events', this.getEventScope());
1005
+ set(this.scope, 'widget', this.getWidgetScope());
1006
+ set(this.scope, 'methods', this.getFunctionScope());
1007
+ set(this.scope, 'vars', this.getVariablesScope());
1008
+ return this.scope;
1009
+ }
1010
+ getContextScope() {
1011
+ const scope = {};
1012
+ set(scope, 'eval', (path) => this.builderService.getValue(path));
1013
+ return scope;
1014
+ }
1015
+ getEventScope() {
1016
+ const scope = {};
1017
+ set(scope, 'context', (path) => this.builderService.onChanged.pipe(filter((c) => c.path == path)));
1018
+ set(scope, 'from', (event) => get(this.instance.api(), event));
1019
+ return scope;
1020
+ }
1021
+ getWidgetScope() {
1022
+ const scope = {};
1023
+ set(scope, 'call', (name, ...args) => {
1024
+ this.instance.call(name, ...args);
1025
+ });
1026
+ set(scope, 'find', (id) => {
1027
+ return this.builderService.getWidget(id)?.api();
1028
+ });
1029
+ return scope;
1030
+ }
1031
+ getFunctionScope() {
1032
+ const scope = {};
1033
+ set(scope, 'sum', (values) => {
1034
+ return sum(values);
1035
+ });
1036
+ Object.entries(this.builderService.functions).forEach((i) => {
1037
+ set(scope, i[0], (...args) => {
1038
+ return i[1](...args);
1039
+ });
1040
+ });
1041
+ return scope;
1042
+ }
1043
+ getVariablesScope() {
1044
+ const scope = {};
1045
+ set(scope, 'eval', (path) => get(this.builderService.variables, path));
1046
+ return scope;
1047
+ }
1048
+ async assignTriggers() {
1049
+ this.node().triggers?.forEach((t) => {
1050
+ const event = this.evaluateTrigger(t.event);
1051
+ event?.pipe(this.unsubscriber.takeUntilDestroy).subscribe((c) => {
1052
+ this.evaluateAction(t.action);
1053
+ });
1054
+ });
1055
+ }
1056
+ evaluateTrigger(templateExpression) {
1057
+ try {
1058
+ const expressionMatch = templateExpression.match(/\{\{\s*(.*?)\s*\}\}/);
1059
+ if (!expressionMatch) {
1060
+ throw Error(`No valid expression found in "${templateExpression}"`);
1061
+ }
1062
+ const expression = expressionMatch[1];
1063
+ // Cache the evaluation function instead of the result
1064
+ const scope = this.getGlobalScope();
1065
+ const sandbox = new Function('scope', `with (scope) { return ( function() { return ${expression}; })(); }`);
1066
+ return sandbox(scope);
1067
+ }
1068
+ catch (error) {
1069
+ console.error('Error evaluating expression:', error);
1070
+ return null;
1071
+ }
1072
+ }
1073
+ evaluateAction(templateExpression) {
1074
+ try {
1075
+ const expressionMatch = templateExpression.match(/\{\{\s*(.*?)\s*\}\}/);
1076
+ if (!expressionMatch) {
1077
+ throw Error(`No valid expression found in "${templateExpression}"`);
1078
+ }
1079
+ const expression = expressionMatch[1];
1080
+ // Cache the evaluation function instead of the result
1081
+ const scope = this.getGlobalScope();
1082
+ const sandbox = new Function('scope', `with (scope) { ${expression} }`);
1083
+ sandbox(scope);
1084
+ }
1085
+ catch (error) {
1086
+ console.error('Error evaluating expression:', error);
1087
+ }
1088
+ }
1089
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPWidgetRendererDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1090
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.0", type: AXPWidgetRendererDirective, 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 } }, providers: [
1091
+ {
1092
+ provide: AXUnsubscriber,
1093
+ },
1094
+ ], ngImport: i0 }); }
1095
+ }
1096
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPWidgetRendererDirective, decorators: [{
1097
+ type: Directive,
1098
+ args: [{
1099
+ selector: '[axp-widget-renderer]',
1100
+ providers: [
1101
+ {
1102
+ provide: AXUnsubscriber,
1103
+ },
1104
+ ],
1105
+ }]
1106
+ }], ctorParameters: () => [] });
1107
+
1108
+ const COMPONENTS = [AXPWidgetContainerComponent, AXPWidgetRendererComponent, AXPWidgetColumnRendererComponent, AXPWidgetRendererDirective];
745
1109
  class AXPLayoutBuilderModule {
746
1110
  static forRoot(config) {
747
1111
  return {
@@ -782,7 +1146,7 @@ class AXPLayoutBuilderModule {
782
1146
  });
783
1147
  }
784
1148
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPLayoutBuilderModule, deps: [{ token: 'AXPLayoutBuilderModuleFactory', optional: true }], target: i0.ɵɵFactoryTarget.NgModule }); }
785
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.0", ngImport: i0, type: AXPLayoutBuilderModule, declarations: [AXPWidgetContainerComponent, AXPWidgetRendererComponent, AXPWidgetColumnRendererComponent], imports: [CommonModule, PortalModule, AXSkeletonModule, CommonModule], exports: [AXPWidgetContainerComponent, AXPWidgetRendererComponent, AXPWidgetColumnRendererComponent] }); }
1149
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.0", ngImport: i0, type: AXPLayoutBuilderModule, declarations: [AXPWidgetContainerComponent, AXPWidgetRendererComponent, AXPWidgetColumnRendererComponent, AXPWidgetRendererDirective], imports: [CommonModule, PortalModule, AXSkeletonModule, CommonModule], exports: [AXPWidgetContainerComponent, AXPWidgetRendererComponent, AXPWidgetColumnRendererComponent, AXPWidgetRendererDirective] }); }
786
1150
  static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPLayoutBuilderModule, imports: [CommonModule, PortalModule, AXSkeletonModule, CommonModule] }); }
787
1151
  }
788
1152
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXPLayoutBuilderModule, decorators: [{
@@ -799,40 +1163,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImpor
799
1163
  args: ['AXPLayoutBuilderModuleFactory']
800
1164
  }] }] });
801
1165
 
802
- const AXPWidgetsCatalog = {
803
- checkbox: 'checkbox-editor',
804
- color: 'color-editor',
805
- contact: 'contact-editor',
806
- dateTime: 'date-time-editor',
807
- email: 'email-editor',
808
- largeText: 'large-text-editor',
809
- link: 'link-editor',
810
- number: 'number-editor',
811
- password: 'password-editor',
812
- phone: 'phone-editor',
813
- richText: 'rich-text-editor',
814
- select: 'select-editor',
815
- selectionList: 'selection-list-editor',
816
- text: 'text-editor',
817
- toggle: 'toggle-editor',
818
- blockLayout: 'block-layout',
819
- pageLayout: 'page-layout',
820
- repeaterLayout: 'repeater-layout',
821
- textBlockLayout: 'text-block-layout',
822
- file: 'file',
823
- map: 'map',
824
- gallery: 'gallery',
825
- signature: 'signature',
826
- buttonAction: 'button-action',
827
- document: 'document-layout',
828
- lookup: 'lookup-editor',
829
- formField: 'form-field',
830
- qrcode: 'qrcode',
831
- grid: 'grid-layout',
832
- gridItem: 'grid-item-layout',
833
- gridRow: 'grid-row-layout',
834
- };
835
-
836
1166
  const AXP_WIDGETS_EDITOR_GROUP = {
837
1167
  name: 'editor',
838
1168
  order: 2,
@@ -864,5 +1194,5 @@ const AXP_WIDGETS_GROUPS = [
864
1194
  * Generated bundle index. Do not edit.
865
1195
  */
866
1196
 
867
- export { AXPColumnWidgetComponent, AXPContainerWidgetComponent, AXPLayoutBuilderModule, AXPLayoutBuilderService, AXPLayoutElement, AXPWidgetColumnRendererComponent, AXPWidgetComponent, AXPWidgetContainerComponent, AXPWidgetRegistryService, AXPWidgetRendererComponent, AXPWidgetsCatalog, AXP_WIDGETS_ACTION_GROUP, AXP_WIDGETS_ADVANCE_GROUP, AXP_WIDGETS_EDITOR_GROUP, AXP_WIDGETS_GROUPS, AXP_WIDGETS_LAYOUT_GROUP, AXP_WIDGET_COLUMN_TOKEN, AXP_WIDGET_TOKEN, cloneProperty };
1197
+ export { AXPColumnWidgetComponent, AXPContainerWidgetComponent, AXPLayoutBuilderModule, AXPLayoutBuilderService, AXPLayoutElement, AXPWidgetColumnRendererComponent, AXPWidgetComponent, AXPWidgetContainerComponent, AXPWidgetRegistryService, AXPWidgetRendererComponent, AXPWidgetRendererDirective, AXPWidgetsCatalog, AXP_WIDGETS_ACTION_GROUP, AXP_WIDGETS_ADVANCE_GROUP, AXP_WIDGETS_EDITOR_GROUP, AXP_WIDGETS_GROUPS, AXP_WIDGETS_LAYOUT_GROUP, AXP_WIDGET_COLUMN_TOKEN, AXP_WIDGET_TOKEN, cloneProperty, createBooleanProperty, createSelectProperty, createStringProperty };
868
1198
  //# sourceMappingURL=acorex-platform-layout-builder.mjs.map