@acorex/platform 19.1.3 → 19.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/index.d.ts +1 -0
- package/common/lib/app/application.types.d.ts +2 -2
- package/common/lib/file-storage/file-storage.service.d.ts +13 -0
- package/common/lib/file-storage/file-storage.types.d.ts +143 -0
- package/common/lib/file-storage/index.d.ts +2 -0
- package/common/lib/filters/filters.types.d.ts +2 -1
- package/common/lib/settings/setting-definition.provider.d.ts +12 -5
- package/common/lib/settings/setting.builder.d.ts +4 -3
- package/common/lib/settings/settings.provider.d.ts +2 -7
- package/common/lib/settings/settings.service.d.ts +19 -7
- package/common/lib/settings/settings.types.d.ts +15 -2
- package/core/utils/highlighter.d.ts +1 -1
- package/fesm2022/acorex-platform-common.mjs +194 -74
- package/fesm2022/acorex-platform-common.mjs.map +1 -1
- package/fesm2022/acorex-platform-core.mjs +2 -2
- package/fesm2022/acorex-platform-core.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-builder.mjs +245 -444
- package/fesm2022/acorex-platform-layout-builder.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-designer.mjs +13 -13
- package/fesm2022/acorex-platform-layout-designer.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-entity.mjs +59 -54
- package/fesm2022/acorex-platform-layout-entity.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-filters.mjs +82 -5
- package/fesm2022/acorex-platform-layout-filters.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-setting.mjs +73 -91
- package/fesm2022/acorex-platform-layout-setting.mjs.map +1 -1
- package/fesm2022/acorex-platform-layouts.mjs +3 -4
- package/fesm2022/acorex-platform-layouts.mjs.map +1 -1
- package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-K9B_-q_K.mjs +108 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-K9B_-q_K.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-DAmHq1bt.mjs +369 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-DAmHq1bt.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-Cd2gxLZt.mjs +87 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-Cd2gxLZt.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-6sZdw013.mjs +130 -0
- package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-6sZdw013.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default-setting-page.component-BYpCgHZb.mjs +74 -0
- package/fesm2022/acorex-platform-themes-default-setting-page.component-BYpCgHZb.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default-setting-view.component-CdmIphX1.mjs +73 -0
- package/fesm2022/acorex-platform-themes-default-setting-view.component-CdmIphX1.mjs.map +1 -0
- package/fesm2022/acorex-platform-themes-default.mjs +20 -20
- package/fesm2022/acorex-platform-themes-default.mjs.map +1 -1
- package/fesm2022/acorex-platform-themes-shared.mjs +288 -81
- package/fesm2022/acorex-platform-themes-shared.mjs.map +1 -1
- package/fesm2022/{acorex-platform-widgets-checkbox-widget-column.component-05nKV-UV.mjs → acorex-platform-widgets-checkbox-widget-column.component-jeZBOEhl.mjs} +18 -14
- package/fesm2022/acorex-platform-widgets-checkbox-widget-column.component-jeZBOEhl.mjs.map +1 -0
- package/fesm2022/{acorex-platform-widgets-checkbox-widget-designer.component-B_Gec5Qf.mjs → acorex-platform-widgets-checkbox-widget-designer.component-RCi5IJOR.mjs} +4 -4
- package/fesm2022/{acorex-platform-widgets-checkbox-widget-designer.component-B_Gec5Qf.mjs.map → acorex-platform-widgets-checkbox-widget-designer.component-RCi5IJOR.mjs.map} +1 -1
- package/fesm2022/acorex-platform-widgets-checkbox-widget-view.component-DU1niJES.mjs +64 -0
- package/fesm2022/acorex-platform-widgets-checkbox-widget-view.component-DU1niJES.mjs.map +1 -0
- package/fesm2022/{acorex-platform-widgets-color-box-widget-designer.component-B2g0ct24.mjs → acorex-platform-widgets-color-box-widget-designer.component-CWhbgmDV.mjs} +4 -4
- package/fesm2022/acorex-platform-widgets-color-box-widget-designer.component-CWhbgmDV.mjs.map +1 -0
- package/fesm2022/acorex-platform-widgets.mjs +1309 -334
- package/fesm2022/acorex-platform-widgets.mjs.map +1 -1
- package/fesm2022/acorex-platform-workflow.mjs +9 -3
- package/fesm2022/acorex-platform-workflow.mjs.map +1 -1
- package/layout/builder/lib/builder/builder.module.d.ts +6 -7
- package/layout/builder/lib/builder/builder.service.d.ts +9 -10
- package/layout/builder/lib/builder/context-store.service.d.ts +33 -0
- package/layout/builder/lib/builder/index.d.ts +4 -2
- package/layout/builder/lib/builder/widget-catalog.d.ts +1 -1
- package/layout/builder/lib/builder/widget-container.component.d.ts +34 -9
- package/layout/builder/lib/builder/widget-groups.d.ts +1 -0
- package/layout/builder/lib/builder/widget-map.d.ts +43 -0
- package/layout/builder/lib/builder/{widget-renderer.component.directive.d.ts → widget-renderer.directive.d.ts} +26 -0
- package/layout/builder/lib/builder/widget-status.types.d.ts +14 -0
- package/layout/builder/lib/builder/widget.types.d.ts +41 -55
- package/layout/designer/lib/preview/preview-viewer.component.d.ts +2 -2
- package/layout/designer/lib/property-viewer/widget-property-viewer.component.d.ts +2 -2
- package/layout/entity/lib/entity-master-list.viewmodel.d.ts +7 -2
- package/layout/entity/lib/widgets/lookup-widget/lookup-widget-edit.component.d.ts +0 -1
- package/layout/filters/lib/filters.viewmodel.d.ts +13 -3
- package/layout/setting/lib/convert-setting-data.d.ts +0 -20
- package/layout/setting/lib/setting.viewmodel.d.ts +65 -4
- package/layouts/lib/admin/entity-layout/entity-details-view/entity-details-view.component.d.ts +15 -5
- package/package.json +15 -15
- package/themes/default/lib/layouts/base/simple-page/simple-page.layout.d.ts +15 -5
- package/themes/default/lib/layouts/entity-layouts/entity-detail-list-view/entity-detail-list-view.component.d.ts +15 -5
- package/themes/default/lib/layouts/entity-layouts/entity-master-create-view/entity-master-create-view.component.d.ts +2 -1
- package/themes/default/lib/layouts/entity-layouts/entity-master-list-view/entity-master-list-view.component.d.ts +17 -6
- package/themes/default/lib/layouts/entity-layouts/entity-master-list-view/list-view-option-filters/list-view-option-filters.component.d.ts +6 -3
- package/themes/default/lib/layouts/entity-layouts/entity-master-modify-view/entity-master-modify-view.component.d.ts +2 -1
- package/themes/default/lib/layouts/entity-layouts/entity-master-single-view/entity-master-single-view.component.d.ts +15 -5
- package/themes/default/lib/layouts/filters-layout/simple-filter-builder/filters-view.component.d.ts +6 -5
- package/themes/default/lib/layouts/root-layout/components/header/header.component.d.ts +15 -5
- package/themes/default/lib/layouts/root-layout/root-layout.component.d.ts +15 -5
- package/themes/default/lib/layouts/setting-layout/setting-page/setting-page.component.d.ts +0 -47
- package/themes/default/lib/layouts/setting-layout/setting-view/setting-view.component.d.ts +19 -5
- package/themes/shared/index.d.ts +3 -1
- package/themes/shared/lib/components/theme-slot.component.d.ts +23 -13
- package/themes/shared/lib/palette.provider.d.ts +9 -0
- package/themes/shared/lib/setting.keys.d.ts +7 -2
- package/themes/shared/lib/setting.provider.d.ts +1 -0
- package/themes/shared/lib/shared.module.d.ts +2 -1
- package/themes/shared/lib/{services/theme.service.d.ts → theme.service.d.ts} +16 -24
- package/themes/shared/lib/theme.types.d.ts +25 -0
- package/themes/shared/lib/widgets/theme-color-selection/index.d.ts +2 -0
- package/themes/shared/lib/widgets/theme-color-selection/theme-color-selection-widget-edit.component.d.ts +6 -0
- package/themes/shared/lib/widgets/theme-color-selection/theme-color-selection-widget.config.d.ts +7 -0
- package/widgets/lib/properties/layout.props.d.ts +1 -0
- package/widgets/lib/widgets/advance/avatar/avatar-widget-column.component.d.ts +6 -0
- package/widgets/lib/widgets/advance/avatar/avatar-widget-designer.component.d.ts +6 -0
- package/widgets/lib/widgets/advance/avatar/avatar-widget-edit.component.d.ts +18 -0
- package/widgets/lib/widgets/advance/avatar/avatar-widget-print.component.d.ts +6 -0
- package/widgets/lib/widgets/advance/avatar/avatar-widget-view.component.d.ts +6 -0
- package/widgets/lib/widgets/advance/avatar/avatar-widget.config.d.ts +7 -0
- package/widgets/lib/widgets/advance/avatar/index.d.ts +6 -0
- package/widgets/lib/widgets/advance/map/map-box-widget-edit.component.d.ts +9 -5
- package/widgets/lib/widgets/advance/map/map-box-widget-view.component.d.ts +6 -4
- package/widgets/lib/widgets/editors/number/number-box-widget-edit.component.d.ts +1 -7
- package/widgets/lib/widgets/editors/toggle/toggle-widget-edit.component.d.ts +0 -2
- package/widgets/lib/widgets/filters/operations/operations.component.d.ts +9 -0
- package/widgets/lib/widgets/filters/string-filter/index.d.ts +2 -0
- package/widgets/lib/widgets/filters/string-filter/string-filter-widget-edit.component.d.ts +11 -0
- package/widgets/lib/widgets/filters/string-filter/string-filter-widget.config.d.ts +7 -0
- package/widgets/lib/widgets/index.d.ts +5 -1
- package/widgets/lib/widgets/property-editors/border/border-widget-editor.component.d.ts +29 -7
- package/widgets/lib/widgets/property-editors/border/index.d.ts +0 -1
- package/widgets/lib/widgets/property-editors/flex-options/flex-options-widget-editor.component.d.ts +31 -0
- package/widgets/lib/widgets/property-editors/flex-options/flex-options-widget.config.d.ts +7 -0
- package/widgets/lib/widgets/property-editors/flex-options/flex-options-widget.type.d.ts +15 -0
- package/widgets/lib/widgets/property-editors/flex-options/index.d.ts +3 -0
- package/widgets/lib/widgets/property-editors/property-editor-helper.d.ts +72 -0
- package/widgets/lib/widgets/property-editors/property-editor.type.d.ts +35 -0
- package/widgets/lib/widgets/property-editors/spacing/index.d.ts +0 -1
- package/widgets/lib/widgets/property-editors/spacing/spacing-widget-editor.component.d.ts +11 -9
- package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-CSyR4pYp.mjs +0 -108
- package/fesm2022/acorex-platform-themes-default-entity-master-create-view.component-CSyR4pYp.mjs.map +0 -1
- package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-xHWp2Lk-.mjs +0 -368
- package/fesm2022/acorex-platform-themes-default-entity-master-list-view.component-xHWp2Lk-.mjs.map +0 -1
- package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-n7mYNduJ.mjs +0 -87
- package/fesm2022/acorex-platform-themes-default-entity-master-modify-view.component-n7mYNduJ.mjs.map +0 -1
- package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-DjyYU0Gy.mjs +0 -130
- package/fesm2022/acorex-platform-themes-default-entity-master-single-view.component-DjyYU0Gy.mjs.map +0 -1
- package/fesm2022/acorex-platform-themes-default-setting-page.component-6Dd8MGqr.mjs +0 -78
- package/fesm2022/acorex-platform-themes-default-setting-page.component-6Dd8MGqr.mjs.map +0 -1
- package/fesm2022/acorex-platform-themes-default-setting-view.component-BgiMClew.mjs +0 -58
- package/fesm2022/acorex-platform-themes-default-setting-view.component-BgiMClew.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-checkbox-widget-column.component-05nKV-UV.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-checkbox-widget-view.component-BkWcZ4K9.mjs +0 -72
- package/fesm2022/acorex-platform-widgets-checkbox-widget-view.component-BkWcZ4K9.mjs.map +0 -1
- package/fesm2022/acorex-platform-widgets-color-box-widget-designer.component-B2g0ct24.mjs.map +0 -1
- package/layout/builder/lib/builder/widget-renderer.component.d.ts +0 -48
- package/widgets/lib/widgets/property-editors/border/border-widget-type.d.ts +0 -18
- package/widgets/lib/widgets/property-editors/spacing/spacing-widget-type.d.ts +0 -16
|
@@ -1,16 +1,39 @@
|
|
|
1
|
-
import * as i3 from '@acorex/components/skeleton';
|
|
2
1
|
import { AXSkeletonModule } from '@acorex/components/skeleton';
|
|
3
|
-
import
|
|
4
|
-
import { ComponentPortal, PortalModule } from '@angular/cdk/portal';
|
|
2
|
+
import { PortalModule } from '@angular/cdk/portal';
|
|
5
3
|
import * as i1 from '@angular/common';
|
|
6
4
|
import { CommonModule } from '@angular/common';
|
|
7
5
|
import * as i0 from '@angular/core';
|
|
8
|
-
import { signal,
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { convertArrayToDataSource, AXDataSource } from '@acorex/components/common';
|
|
6
|
+
import { signal, computed, Injectable, inject, EventEmitter, effect, Component, ChangeDetectionStrategy, Output, Input, InjectionToken, ElementRef, Injector, ChangeDetectorRef, ViewChild, input, ViewContainerRef, Directive, NgModule, Optional, Inject } from '@angular/core';
|
|
7
|
+
import { set, cloneDeep, get, isEqual, merge, isNil, isUndefined, sum } from 'lodash-es';
|
|
8
|
+
import { Subject, BehaviorSubject, filter } from 'rxjs';
|
|
9
|
+
import { signalStore, withState, withComputed, withMethods, patchState } from '@ngrx/signals';
|
|
13
10
|
import { AXDataTableColumnComponent, AXBaseDataTable } from '@acorex/components/data-table';
|
|
11
|
+
import { convertArrayToDataSource, AXDataSource } from '@acorex/components/common';
|
|
12
|
+
import { AXUnsubscriber } from '@acorex/core/utils';
|
|
13
|
+
|
|
14
|
+
var AXPPageStatus;
|
|
15
|
+
(function (AXPPageStatus) {
|
|
16
|
+
// Rendering statuses
|
|
17
|
+
AXPPageStatus["Rendering"] = "rendering";
|
|
18
|
+
AXPPageStatus["Rendered"] = "rendered";
|
|
19
|
+
// Processing statuses
|
|
20
|
+
AXPPageStatus["Processing"] = "processing";
|
|
21
|
+
// Submission statuses
|
|
22
|
+
AXPPageStatus["Submitting"] = "submitting";
|
|
23
|
+
AXPPageStatus["Submitted"] = "submitted";
|
|
24
|
+
// Error handling
|
|
25
|
+
AXPPageStatus["Error"] = "error";
|
|
26
|
+
})(AXPPageStatus || (AXPPageStatus = {}));
|
|
27
|
+
var AXPWidgetStatus;
|
|
28
|
+
(function (AXPWidgetStatus) {
|
|
29
|
+
// Rendering statuses
|
|
30
|
+
AXPWidgetStatus["Rendering"] = "rendering";
|
|
31
|
+
AXPWidgetStatus["Rendered"] = "rendered";
|
|
32
|
+
// Processing statuses
|
|
33
|
+
AXPWidgetStatus["Processing"] = "processing";
|
|
34
|
+
// Error handling
|
|
35
|
+
AXPWidgetStatus["Error"] = "error";
|
|
36
|
+
})(AXPWidgetStatus || (AXPWidgetStatus = {}));
|
|
14
37
|
|
|
15
38
|
class AXPLayoutElement {
|
|
16
39
|
api() {
|
|
@@ -19,15 +42,15 @@ class AXPLayoutElement {
|
|
|
19
42
|
}
|
|
20
43
|
class AXPLayoutBuilderService {
|
|
21
44
|
constructor() {
|
|
22
|
-
this.context$ = signal({});
|
|
23
45
|
this.variables$ = signal({});
|
|
24
46
|
this.functions$ = signal({});
|
|
25
|
-
this.onChanged = new Subject();
|
|
26
47
|
this.onRefresh = new Subject();
|
|
27
|
-
this.debouncers = {};
|
|
28
|
-
this.debouncerSubscriptions = {};
|
|
29
48
|
this.widgets = new Map();
|
|
30
|
-
this.
|
|
49
|
+
this.status$ = signal(AXPPageStatus.Rendering);
|
|
50
|
+
this.status = this.status$.asReadonly();
|
|
51
|
+
this.isBusy = computed(() => {
|
|
52
|
+
return [AXPPageStatus.Processing, AXPPageStatus.Submitting, AXPPageStatus.Rendering].includes(this.status());
|
|
53
|
+
});
|
|
31
54
|
}
|
|
32
55
|
get variables() {
|
|
33
56
|
return this.variables$();
|
|
@@ -35,15 +58,36 @@ class AXPLayoutBuilderService {
|
|
|
35
58
|
get functions() {
|
|
36
59
|
return this.functions$();
|
|
37
60
|
}
|
|
38
|
-
|
|
39
|
-
this.
|
|
40
|
-
|
|
61
|
+
updateStatus() {
|
|
62
|
+
this.status$.update(() => this.detectStatus());
|
|
63
|
+
}
|
|
64
|
+
detectStatus() {
|
|
65
|
+
const statuses = Array.from(this.widgets.values()).map(c => c.status());
|
|
66
|
+
// Rendering statuses
|
|
67
|
+
if (statuses.some((status) => status === AXPWidgetStatus.Rendering)) {
|
|
68
|
+
return AXPPageStatus.Rendering;
|
|
69
|
+
}
|
|
70
|
+
if (statuses.every((status) => status === AXPWidgetStatus.Rendered)) {
|
|
71
|
+
return AXPPageStatus.Rendered;
|
|
72
|
+
}
|
|
73
|
+
// Processing statuses
|
|
74
|
+
if (statuses.some((status) => status === AXPWidgetStatus.Processing)) {
|
|
75
|
+
return AXPPageStatus.Processing;
|
|
76
|
+
}
|
|
77
|
+
// Error handling
|
|
78
|
+
if (statuses.some((status) => status === AXPWidgetStatus.Error)) {
|
|
79
|
+
return AXPPageStatus.Error;
|
|
80
|
+
}
|
|
81
|
+
return AXPPageStatus.Rendered; // Default to Loaded when all widgets are in a completed state
|
|
41
82
|
}
|
|
42
83
|
refresh() {
|
|
43
84
|
setTimeout(() => {
|
|
44
85
|
this.onRefresh.next();
|
|
45
86
|
}, 0);
|
|
46
87
|
}
|
|
88
|
+
setStatus(status) {
|
|
89
|
+
this.status$.set(status);
|
|
90
|
+
}
|
|
47
91
|
setVariables(...args) {
|
|
48
92
|
if (args.length == 0)
|
|
49
93
|
return;
|
|
@@ -62,57 +106,13 @@ class AXPLayoutBuilderService {
|
|
|
62
106
|
this.functions$.update((v) => set(v, args[0], args[1]));
|
|
63
107
|
}
|
|
64
108
|
}
|
|
65
|
-
setValue(path, value, init = false) {
|
|
66
|
-
const oldValue = get(this.context$(), path);
|
|
67
|
-
if (isEqual(oldValue, value)) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
// if (!this.debouncers[path]) {
|
|
71
|
-
// // Create a new Subject for debouncing if it doesn't exist
|
|
72
|
-
// this.debouncers[path] = new Subject<{ path: string; value: any; init: boolean }>();
|
|
73
|
-
// // Subscribe to the subject with debounceTime
|
|
74
|
-
// this.debouncerSubscriptions[path] = this.debouncers[path].pipe(debounceTime(150)).subscribe(({ value, init }) => {
|
|
75
|
-
// // Only emit onChanged event after debounce time
|
|
76
|
-
// this.onChanged.next({
|
|
77
|
-
// oldValue: oldValue,
|
|
78
|
-
// newValue: value,
|
|
79
|
-
// data: this.context(),
|
|
80
|
-
// path,
|
|
81
|
-
// init,
|
|
82
|
-
// });
|
|
83
|
-
// });
|
|
84
|
-
// }
|
|
85
|
-
// Update context immediately
|
|
86
|
-
this.context$.update((ctx) => set(clone(ctx), path, value));
|
|
87
|
-
//
|
|
88
|
-
this.onChanged.next({
|
|
89
|
-
oldValue: oldValue,
|
|
90
|
-
newValue: value,
|
|
91
|
-
data: this.context(),
|
|
92
|
-
path,
|
|
93
|
-
init,
|
|
94
|
-
});
|
|
95
|
-
// Emit value through the debouncer subject
|
|
96
|
-
//this.debouncers[path].next({ path, value, init });
|
|
97
|
-
}
|
|
98
|
-
getValue(path) {
|
|
99
|
-
return get(this.context(), path);
|
|
100
|
-
}
|
|
101
109
|
registerWidget(id, widget) {
|
|
102
110
|
this.widgets.set(id, widget);
|
|
103
111
|
}
|
|
104
112
|
getWidget(id) {
|
|
105
113
|
return this.widgets.get(id);
|
|
106
114
|
}
|
|
107
|
-
unsubscribeDebouncers() {
|
|
108
|
-
Object.keys(this.debouncerSubscriptions).forEach((path) => {
|
|
109
|
-
this.debouncerSubscriptions[path].unsubscribe();
|
|
110
|
-
delete this.debouncerSubscriptions[path]; // Clean up the reference
|
|
111
|
-
delete this.debouncers[path]; // Also clean up the debouncer subject
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
115
|
ngOnDestroy() {
|
|
115
|
-
this.unsubscribeDebouncers();
|
|
116
116
|
}
|
|
117
117
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPLayoutBuilderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
118
118
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPLayoutBuilderService }); }
|
|
@@ -121,6 +121,145 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
|
|
|
121
121
|
type: Injectable
|
|
122
122
|
}] });
|
|
123
123
|
|
|
124
|
+
class AXPLayoutContextChangeEvent {
|
|
125
|
+
}
|
|
126
|
+
const AXPLayoutBuilderContextStore = signalStore(
|
|
127
|
+
// Initial State
|
|
128
|
+
withState(() => ({
|
|
129
|
+
data: {}, // Shared context data
|
|
130
|
+
state: 'initiated', // Current state
|
|
131
|
+
initialSnapshot: {}, // Snapshot of the first initialized state
|
|
132
|
+
previousSnapshot: {}, // Snapshot of the previous state
|
|
133
|
+
lastChange: {
|
|
134
|
+
state: 'initiated',
|
|
135
|
+
}, // Last change event
|
|
136
|
+
})),
|
|
137
|
+
// Computed Signals
|
|
138
|
+
withComputed(({ data, state, lastChange, initialSnapshot, previousSnapshot }) => ({
|
|
139
|
+
isChanged: computed(() => state() === 'changed'),
|
|
140
|
+
isReset: computed(() => state() === 'restored'),
|
|
141
|
+
isInitiated: computed(() => state() === 'initiated'),
|
|
142
|
+
isEmpty: computed(() => Object.keys(data()).length === 0),
|
|
143
|
+
snapshot: computed(() => cloneDeep(data())), // Current data snapshot
|
|
144
|
+
initial: computed(() => cloneDeep(initialSnapshot())), // Initial snapshot
|
|
145
|
+
previous: computed(() => cloneDeep(previousSnapshot())), // Previous snapshot
|
|
146
|
+
changeEvent: computed(() => lastChange()), // Reactive last change event
|
|
147
|
+
})),
|
|
148
|
+
// Methods for State Management
|
|
149
|
+
withMethods((store) => ({
|
|
150
|
+
// Update a specific value
|
|
151
|
+
update(path, value) {
|
|
152
|
+
const currentData = cloneDeep(store.data());
|
|
153
|
+
const oldValue = get(currentData, path);
|
|
154
|
+
// Skip if the value hasn't changed
|
|
155
|
+
if (isEqual(oldValue, value)) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
// Update the value and prepare the change event
|
|
159
|
+
const updatedData = set(currentData, path, value);
|
|
160
|
+
const changeEvent = {
|
|
161
|
+
oldValue,
|
|
162
|
+
newValue: value,
|
|
163
|
+
path,
|
|
164
|
+
state: 'changed',
|
|
165
|
+
data: updatedData,
|
|
166
|
+
};
|
|
167
|
+
// Patch the state
|
|
168
|
+
patchState(store, {
|
|
169
|
+
previousSnapshot: store.snapshot(), // Save the previous state
|
|
170
|
+
data: updatedData,
|
|
171
|
+
state: 'changed',
|
|
172
|
+
lastChange: changeEvent,
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
// Reset to the initial state
|
|
176
|
+
reset() {
|
|
177
|
+
const initialData = store.initial();
|
|
178
|
+
const changeEvent = {
|
|
179
|
+
oldValue: cloneDeep(store.data()), // Current data becomes old value
|
|
180
|
+
newValue: cloneDeep(initialData), // Reset to the initial state
|
|
181
|
+
path: '',
|
|
182
|
+
state: 'restored',
|
|
183
|
+
data: initialData,
|
|
184
|
+
};
|
|
185
|
+
patchState(store, {
|
|
186
|
+
previousSnapshot: store.snapshot(), // Save the previous state
|
|
187
|
+
data: initialData,
|
|
188
|
+
state: 'restored',
|
|
189
|
+
lastChange: changeEvent,
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
// Initialize the state
|
|
193
|
+
set(initialData) {
|
|
194
|
+
const currentData = store.data();
|
|
195
|
+
if (isEqual(currentData, initialData)) {
|
|
196
|
+
return; // Skip if the current state matches the initial state
|
|
197
|
+
}
|
|
198
|
+
const changeEvent = {
|
|
199
|
+
oldValue: null,
|
|
200
|
+
newValue: cloneDeep(initialData),
|
|
201
|
+
path: '',
|
|
202
|
+
state: 'initiated',
|
|
203
|
+
data: initialData,
|
|
204
|
+
};
|
|
205
|
+
patchState(store, {
|
|
206
|
+
initialSnapshot: cloneDeep(initialData), // Save the initial state
|
|
207
|
+
previousSnapshot: store.snapshot(), // Save the current state as the previous
|
|
208
|
+
data: initialData,
|
|
209
|
+
state: 'initiated',
|
|
210
|
+
lastChange: changeEvent,
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
// Get a specific value
|
|
214
|
+
getValue(path) {
|
|
215
|
+
return get(store.data(), path);
|
|
216
|
+
},
|
|
217
|
+
})));
|
|
218
|
+
|
|
219
|
+
class AXPWidgetContainerComponent {
|
|
220
|
+
set context(value) {
|
|
221
|
+
this.contextService.set(value);
|
|
222
|
+
}
|
|
223
|
+
set functions(v) {
|
|
224
|
+
this.builderService.setFunctions(v);
|
|
225
|
+
}
|
|
226
|
+
constructor() {
|
|
227
|
+
this.contextService = inject(AXPLayoutBuilderContextStore);
|
|
228
|
+
this.builderService = inject(AXPLayoutBuilderService);
|
|
229
|
+
this.onContextChanged = new EventEmitter();
|
|
230
|
+
this.status = computed(() => {
|
|
231
|
+
return this.builderService.status();
|
|
232
|
+
});
|
|
233
|
+
this.isBusy = computed(() => {
|
|
234
|
+
return this.builderService.isBusy();
|
|
235
|
+
});
|
|
236
|
+
effect(() => {
|
|
237
|
+
if (this.contextService.isChanged()) {
|
|
238
|
+
this.onContextChanged.emit(this.contextService.changeEvent());
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPWidgetContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
243
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.3", type: AXPWidgetContainerComponent, isStandalone: false, selector: "axp-widgets-container", inputs: { context: "context", functions: "functions" }, outputs: { onContextChanged: "onContextChanged" }, host: { styleAttribute: "display: contents;" }, providers: [AXPLayoutBuilderService, AXPLayoutBuilderContextStore], ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
244
|
+
}
|
|
245
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPWidgetContainerComponent, decorators: [{
|
|
246
|
+
type: Component,
|
|
247
|
+
args: [{
|
|
248
|
+
selector: 'axp-widgets-container',
|
|
249
|
+
template: `<ng-content></ng-content>`,
|
|
250
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
251
|
+
host: { style: 'display: contents;' },
|
|
252
|
+
providers: [AXPLayoutBuilderService, AXPLayoutBuilderContextStore],
|
|
253
|
+
standalone: false,
|
|
254
|
+
}]
|
|
255
|
+
}], ctorParameters: () => [], propDecorators: { onContextChanged: [{
|
|
256
|
+
type: Output
|
|
257
|
+
}], context: [{
|
|
258
|
+
type: Input
|
|
259
|
+
}], functions: [{
|
|
260
|
+
type: Input
|
|
261
|
+
}] } });
|
|
262
|
+
|
|
124
263
|
class AXPWidgetRegistryService {
|
|
125
264
|
constructor() {
|
|
126
265
|
this.types = new Map();
|
|
@@ -217,6 +356,10 @@ const AXPWidgetsCatalog = {
|
|
|
217
356
|
cronJob: 'cron-job',
|
|
218
357
|
spacing: 'spacing',
|
|
219
358
|
border: 'border',
|
|
359
|
+
avatar: 'avatar',
|
|
360
|
+
stringFilter: 'string-filter',
|
|
361
|
+
themeColorSelection: 'theme-color-selection',
|
|
362
|
+
flexOptions: 'flex-options',
|
|
220
363
|
};
|
|
221
364
|
|
|
222
365
|
function objectKeyValueTransforms(keyName) {
|
|
@@ -230,7 +373,7 @@ function objectKeyValueTransforms(keyName) {
|
|
|
230
373
|
if (isNil(value))
|
|
231
374
|
return undefined;
|
|
232
375
|
return typeof value == 'object' ? value[keyName] : value;
|
|
233
|
-
}
|
|
376
|
+
},
|
|
234
377
|
};
|
|
235
378
|
}
|
|
236
379
|
function cloneProperty(property, values) {
|
|
@@ -310,22 +453,16 @@ class AXPWidgetComponent extends AXPLayoutElement {
|
|
|
310
453
|
this.children = this._children.asReadonly();
|
|
311
454
|
this._options = signal(this.token.options ?? {});
|
|
312
455
|
this.options = this._options.asReadonly();
|
|
313
|
-
this.
|
|
314
|
-
this.
|
|
315
|
-
this.isRendered = false;
|
|
456
|
+
this.layoutService = inject(AXPLayoutBuilderService);
|
|
457
|
+
this.contextService = inject(AXPLayoutBuilderContextStore);
|
|
316
458
|
this._isValueWidget = false;
|
|
317
459
|
this.isValueWidget = () => this._isValueWidget;
|
|
460
|
+
this._status = signal(AXPWidgetStatus.Rendering);
|
|
461
|
+
this.status = this._status.asReadonly();
|
|
462
|
+
this.onStatusChanged = new BehaviorSubject(this._status());
|
|
463
|
+
this.#statusEffect = effect(() => { this.onStatusChanged.next(this.status()); });
|
|
464
|
+
this.isBusy = computed(() => [AXPWidgetStatus.Rendering, AXPWidgetStatus.Processing].includes(this.status()));
|
|
318
465
|
this.fullPath = signal(null);
|
|
319
|
-
this.nextRender = afterNextRender(() => {
|
|
320
|
-
//
|
|
321
|
-
if (!this.isRendered) {
|
|
322
|
-
this.detectFullPath();
|
|
323
|
-
//
|
|
324
|
-
this.onReady.next();
|
|
325
|
-
//
|
|
326
|
-
this.isRendered = true;
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
466
|
this.getValue = computed(() => {
|
|
330
467
|
return this.fullPath() ? this.extractValue(this.fullPath()) : null;
|
|
331
468
|
});
|
|
@@ -333,33 +470,32 @@ class AXPWidgetComponent extends AXPLayoutElement {
|
|
|
333
470
|
get id() {
|
|
334
471
|
return this._id;
|
|
335
472
|
}
|
|
473
|
+
#statusEffect;
|
|
336
474
|
outputs() {
|
|
337
475
|
return [];
|
|
338
476
|
}
|
|
339
477
|
ngOnInit() {
|
|
340
|
-
this.initRender();
|
|
341
|
-
}
|
|
342
|
-
initRender() {
|
|
343
478
|
this._isValueWidget = this.config.properties?.some((c) => c.name == 'path') ?? false;
|
|
344
479
|
if (this.isValueWidget()) {
|
|
345
480
|
this.detectFullPath();
|
|
346
481
|
if (!isNil(this.defaultValue) && isNil(this.getValue())) {
|
|
347
|
-
this.setValue(this.defaultValue
|
|
482
|
+
this.setValue(this.defaultValue);
|
|
348
483
|
}
|
|
349
484
|
}
|
|
350
485
|
//
|
|
351
486
|
if (get(this.node, '__meta__.added')) {
|
|
352
487
|
this.onAdded();
|
|
353
488
|
}
|
|
489
|
+
this.setStatus(AXPWidgetStatus.Rendered);
|
|
354
490
|
}
|
|
355
491
|
extractValue(path) {
|
|
356
|
-
const rawValue =
|
|
492
|
+
const rawValue = this.contextService.getValue(path);
|
|
357
493
|
if (this.node.valueTransforms?.getter) {
|
|
358
494
|
return this.node.valueTransforms?.getter(rawValue);
|
|
359
495
|
}
|
|
360
496
|
return rawValue;
|
|
361
497
|
}
|
|
362
|
-
setValue(value
|
|
498
|
+
setValue(value) {
|
|
363
499
|
if (this.node.valueTransforms?.setter) {
|
|
364
500
|
value = this.node.valueTransforms?.setter(value);
|
|
365
501
|
}
|
|
@@ -372,9 +508,12 @@ class AXPWidgetComponent extends AXPLayoutElement {
|
|
|
372
508
|
return;
|
|
373
509
|
}
|
|
374
510
|
if (this.fullPath()) {
|
|
375
|
-
this.contextService.
|
|
511
|
+
this.contextService.update(this.fullPath(), value);
|
|
376
512
|
}
|
|
377
|
-
|
|
513
|
+
}
|
|
514
|
+
setStatus(status) {
|
|
515
|
+
this._status.set(status);
|
|
516
|
+
this.layoutService.updateStatus();
|
|
378
517
|
}
|
|
379
518
|
setOptions(values) {
|
|
380
519
|
this._options.set({ ...this.options(), ...values });
|
|
@@ -397,7 +536,6 @@ class AXPWidgetComponent extends AXPLayoutElement {
|
|
|
397
536
|
setChildren(children) {
|
|
398
537
|
this._children.set([...children]);
|
|
399
538
|
}
|
|
400
|
-
onValueChanged(oldValue, newValue, init = false) { }
|
|
401
539
|
onAdded() { }
|
|
402
540
|
detectFullPath() {
|
|
403
541
|
const sections = [];
|
|
@@ -427,7 +565,7 @@ class AXPWidgetComponent extends AXPLayoutElement {
|
|
|
427
565
|
this.fullPath.set(sections.reverse().join('.'));
|
|
428
566
|
this._id = this.name || this.parent ? ids.reverse().join('_') : null;
|
|
429
567
|
if (this._id) {
|
|
430
|
-
this.
|
|
568
|
+
this.layoutService.registerWidget(this._id, this);
|
|
431
569
|
}
|
|
432
570
|
}
|
|
433
571
|
handleValueChanged(e) {
|
|
@@ -508,358 +646,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
|
|
|
508
646
|
type: Injectable
|
|
509
647
|
}] });
|
|
510
648
|
|
|
511
|
-
class AXPWidgetRendererComponent {
|
|
512
|
-
get node() {
|
|
513
|
-
return this._node;
|
|
514
|
-
}
|
|
515
|
-
set node(v) {
|
|
516
|
-
this._node = v;
|
|
517
|
-
this.loadComponent();
|
|
518
|
-
}
|
|
519
|
-
get mode() {
|
|
520
|
-
return this._mode;
|
|
521
|
-
}
|
|
522
|
-
set mode(v) {
|
|
523
|
-
this._mode = v;
|
|
524
|
-
}
|
|
525
|
-
constructor() {
|
|
526
|
-
this._mode = 'edit';
|
|
527
|
-
this.mergedOptions = signal({});
|
|
528
|
-
this.injector = inject(Injector);
|
|
529
|
-
this.builderService = inject(AXPLayoutBuilderService);
|
|
530
|
-
this.widgetRegistery = inject(AXPWidgetRegistryService);
|
|
531
|
-
this.unsubscriber = inject(AXUnsubscriber);
|
|
532
|
-
this.isLoading = signal(true);
|
|
533
|
-
this.expressionCache = new Map();
|
|
534
|
-
this.expressionEvaluators = new Map();
|
|
535
|
-
this.scope = null;
|
|
536
|
-
this.builderService.onChanged.pipe(this.unsubscriber.takeUntilDestroy).subscribe(async (e) => {
|
|
537
|
-
if ((await this.updateOptionsBasedOnContext()) > 0) {
|
|
538
|
-
this.applyOptions();
|
|
539
|
-
}
|
|
540
|
-
if (this.checkFormulaForUpdate(this.node.formula, e.path)) {
|
|
541
|
-
await this.updateValueBasedOnFormula();
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
async loadComponent() {
|
|
546
|
-
this.isLoading.set(true);
|
|
547
|
-
const widget = this.widgetRegistery.resolve(this.node.type);
|
|
548
|
-
//
|
|
549
|
-
const props = widget?.components[this.mode]?.properties
|
|
550
|
-
?.filter((c) => c.schema.defaultValue != null)
|
|
551
|
-
.map((c) => ({ [c.name]: c.schema.defaultValue }))
|
|
552
|
-
.reduce((acc, curr) => {
|
|
553
|
-
return { ...acc, ...curr };
|
|
554
|
-
}, {});
|
|
555
|
-
//
|
|
556
|
-
this.mergedOptions.set(merge(props, this.node.options) || {});
|
|
557
|
-
this.preprocessAndInitialOptions(cloneDeep(this.node.options));
|
|
558
|
-
await this.updateOptionsBasedOnContext();
|
|
559
|
-
const tokenValue = {
|
|
560
|
-
node: this.node,
|
|
561
|
-
options: this.mergedOptions(),
|
|
562
|
-
config: widget,
|
|
563
|
-
};
|
|
564
|
-
const token = Injector.create({
|
|
565
|
-
parent: this.injector,
|
|
566
|
-
providers: [
|
|
567
|
-
{
|
|
568
|
-
provide: AXP_WIDGET_TOKEN,
|
|
569
|
-
useValue: tokenValue,
|
|
570
|
-
},
|
|
571
|
-
],
|
|
572
|
-
});
|
|
573
|
-
var com = await widget?.components[this.mode]?.component();
|
|
574
|
-
this.portal = new ComponentPortal(com, null, token);
|
|
575
|
-
this.isLoading.set(false);
|
|
576
|
-
}
|
|
577
|
-
async handleAttached(portalOutletRef) {
|
|
578
|
-
portalOutletRef = portalOutletRef;
|
|
579
|
-
this.instance = portalOutletRef.instance;
|
|
580
|
-
this.instance.parent = this.parentNode;
|
|
581
|
-
this.instance.index = this.index;
|
|
582
|
-
this.instance.mode = this.mode;
|
|
583
|
-
await this.updateValueBasedOnFormula();
|
|
584
|
-
await this.assignTriggers();
|
|
585
|
-
}
|
|
586
|
-
applyOptions() {
|
|
587
|
-
if (!this.instance)
|
|
588
|
-
return;
|
|
589
|
-
this.instance.setOptions(this.mergedOptions());
|
|
590
|
-
}
|
|
591
|
-
checkFormulaForUpdate(formula, path) {
|
|
592
|
-
if (formula) {
|
|
593
|
-
const regex = /context\.eval\('([^']+)'\)/g;
|
|
594
|
-
const matches = formula.match(regex);
|
|
595
|
-
const nodes = matches ? matches.map((match) => match.match(/'([^']+)'/)[1]) : [];
|
|
596
|
-
return nodes.includes(path);
|
|
597
|
-
}
|
|
598
|
-
else
|
|
599
|
-
return false;
|
|
600
|
-
}
|
|
601
|
-
preprocessAndInitialOptions(obj, pathPrefix = '') {
|
|
602
|
-
if (!obj)
|
|
603
|
-
return;
|
|
604
|
-
Object.entries(obj).forEach(([key, value]) => {
|
|
605
|
-
const currentPath = pathPrefix ? `${pathPrefix}.${key}` : key;
|
|
606
|
-
if (typeof value === 'string' && value.includes('{{')) {
|
|
607
|
-
// Cache dynamic expression for later evaluation
|
|
608
|
-
this.expressionEvaluators.set(currentPath, () => this.evaluateExpression(value));
|
|
609
|
-
}
|
|
610
|
-
else if (typeof value === 'object' &&
|
|
611
|
-
value !== null &&
|
|
612
|
-
(value.constructor === Object || Array.isArray(value))) {
|
|
613
|
-
// Recursively handle nested objects
|
|
614
|
-
this.preprocessAndInitialOptions(value, currentPath);
|
|
615
|
-
}
|
|
616
|
-
else {
|
|
617
|
-
// Apply static values directly
|
|
618
|
-
this.mergedOptions.update((currentOptions) => {
|
|
619
|
-
return set(currentOptions, currentPath, value);
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
async updateOptionsBasedOnContext() {
|
|
625
|
-
const updates = [];
|
|
626
|
-
for (let [path, evaluator] of this.expressionEvaluators) {
|
|
627
|
-
const newValue = await evaluator();
|
|
628
|
-
updates.push({ path, newValue });
|
|
629
|
-
}
|
|
630
|
-
// Apply updates to mergedOptions
|
|
631
|
-
if (updates.length > 0) {
|
|
632
|
-
this.mergedOptions.update((o) => {
|
|
633
|
-
const updatedOptions = { ...o };
|
|
634
|
-
updates.forEach(({ path, newValue }) => {
|
|
635
|
-
// Set the new value in the updatedOptions object by path
|
|
636
|
-
set(updatedOptions, path, newValue); // Assuming 'set' can handle paths like 'property.subproperty'
|
|
637
|
-
});
|
|
638
|
-
return updatedOptions;
|
|
639
|
-
});
|
|
640
|
-
}
|
|
641
|
-
return updates.length;
|
|
642
|
-
}
|
|
643
|
-
async updateValueBasedOnFormula() {
|
|
644
|
-
if (this.node.formula) {
|
|
645
|
-
const value = await this.evaluateExpression(this.node.formula);
|
|
646
|
-
this.instance.setValue(value);
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
async evaluateExpression(templateExpression) {
|
|
650
|
-
try {
|
|
651
|
-
// Check cache first, but cache the function for evaluation, not the evaluated value
|
|
652
|
-
if (!this.expressionCache.has(templateExpression)) {
|
|
653
|
-
const expressionMatch = templateExpression.match(/\{\{\s*(.*?)\s*\}\}/);
|
|
654
|
-
if (!expressionMatch) {
|
|
655
|
-
throw Error(`No valid expression found in "${templateExpression}"`);
|
|
656
|
-
}
|
|
657
|
-
const expression = expressionMatch[1];
|
|
658
|
-
// Cache the evaluation function instead of the result
|
|
659
|
-
const scope = this.getGlobalScope();
|
|
660
|
-
const evaluationFunction = async () => {
|
|
661
|
-
const sandbox = new Function('scope', `with (scope) { return (async function() { return ${expression}; })(); }`);
|
|
662
|
-
return await sandbox(scope);
|
|
663
|
-
};
|
|
664
|
-
this.expressionCache.set(templateExpression, evaluationFunction);
|
|
665
|
-
}
|
|
666
|
-
// Retrieve the function from the cache and call it to evaluate the expression
|
|
667
|
-
const evaluate = this.expressionCache.get(templateExpression);
|
|
668
|
-
if (evaluate) {
|
|
669
|
-
const result = await evaluate();
|
|
670
|
-
return result;
|
|
671
|
-
}
|
|
672
|
-
else {
|
|
673
|
-
throw Error(`Failed to retrieve evaluation function for expression: "${templateExpression}"`);
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
catch (error) {
|
|
677
|
-
console.error('Error evaluating expression:', error);
|
|
678
|
-
return false;
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
getGlobalScope() {
|
|
682
|
-
if (this.scope)
|
|
683
|
-
return this.scope;
|
|
684
|
-
this.scope = {};
|
|
685
|
-
set(this.scope, 'context', this.getContextScope());
|
|
686
|
-
set(this.scope, 'events', this.getEventScope());
|
|
687
|
-
set(this.scope, 'widget', this.getWidgetScope());
|
|
688
|
-
set(this.scope, 'methods', this.getFunctionScope());
|
|
689
|
-
set(this.scope, 'vars', this.getVariablesScope());
|
|
690
|
-
return this.scope;
|
|
691
|
-
}
|
|
692
|
-
getContextScope() {
|
|
693
|
-
const scope = {};
|
|
694
|
-
set(scope, 'eval', (path) => this.builderService.getValue(path));
|
|
695
|
-
return scope;
|
|
696
|
-
}
|
|
697
|
-
getEventScope() {
|
|
698
|
-
const scope = {};
|
|
699
|
-
set(scope, 'context', (path) => this.builderService.onChanged.pipe(filter((c) => c.path == path)));
|
|
700
|
-
set(scope, 'from', (event) => get(this.instance.api(), event));
|
|
701
|
-
return scope;
|
|
702
|
-
}
|
|
703
|
-
getWidgetScope() {
|
|
704
|
-
const scope = {};
|
|
705
|
-
set(scope, 'call', (name, ...args) => {
|
|
706
|
-
this.instance.call(name, ...args);
|
|
707
|
-
});
|
|
708
|
-
set(scope, 'find', (id) => {
|
|
709
|
-
return this.builderService.getWidget(id)?.api();
|
|
710
|
-
});
|
|
711
|
-
return scope;
|
|
712
|
-
}
|
|
713
|
-
getFunctionScope() {
|
|
714
|
-
const scope = {};
|
|
715
|
-
set(scope, 'sum', (values) => {
|
|
716
|
-
return sum(values);
|
|
717
|
-
});
|
|
718
|
-
Object.entries(this.builderService.functions).forEach((i) => {
|
|
719
|
-
set(scope, i[0], (...args) => {
|
|
720
|
-
return i[1](...args);
|
|
721
|
-
});
|
|
722
|
-
});
|
|
723
|
-
return scope;
|
|
724
|
-
}
|
|
725
|
-
getVariablesScope() {
|
|
726
|
-
const scope = {};
|
|
727
|
-
set(scope, 'eval', (path) => get(this.builderService.variables, path));
|
|
728
|
-
return scope;
|
|
729
|
-
}
|
|
730
|
-
async assignTriggers() {
|
|
731
|
-
this.node.triggers?.forEach((t) => {
|
|
732
|
-
const event = this.evaluateTrigger(t.event);
|
|
733
|
-
event?.pipe(this.unsubscriber.takeUntilDestroy).subscribe((c) => {
|
|
734
|
-
this.evaluateAction(t.action);
|
|
735
|
-
});
|
|
736
|
-
});
|
|
737
|
-
}
|
|
738
|
-
evaluateTrigger(templateExpression) {
|
|
739
|
-
try {
|
|
740
|
-
const expressionMatch = templateExpression.match(/\{\{\s*(.*?)\s*\}\}/);
|
|
741
|
-
if (!expressionMatch) {
|
|
742
|
-
throw Error(`No valid expression found in "${templateExpression}"`);
|
|
743
|
-
}
|
|
744
|
-
const expression = expressionMatch[1];
|
|
745
|
-
// Cache the evaluation function instead of the result
|
|
746
|
-
const scope = this.getGlobalScope();
|
|
747
|
-
const sandbox = new Function('scope', `with (scope) { return ( function() { return ${expression}; })(); }`);
|
|
748
|
-
return sandbox(scope);
|
|
749
|
-
}
|
|
750
|
-
catch (error) {
|
|
751
|
-
console.error('Error evaluating expression:', error);
|
|
752
|
-
return null;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
evaluateAction(templateExpression) {
|
|
756
|
-
try {
|
|
757
|
-
const expressionMatch = templateExpression.match(/\{\{\s*(.*?)\s*\}\}/);
|
|
758
|
-
if (!expressionMatch) {
|
|
759
|
-
throw Error(`No valid expression found in "${templateExpression}"`);
|
|
760
|
-
}
|
|
761
|
-
const expression = expressionMatch[1];
|
|
762
|
-
// Cache the evaluation function instead of the result
|
|
763
|
-
const scope = this.getGlobalScope();
|
|
764
|
-
const sandbox = new Function('scope', `with (scope) { ${expression} }`);
|
|
765
|
-
sandbox(scope);
|
|
766
|
-
}
|
|
767
|
-
catch (error) {
|
|
768
|
-
console.error('Error evaluating expression:', error);
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPWidgetRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
772
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: AXPWidgetRendererComponent, isStandalone: false, selector: "axp-widget-renderer", inputs: { node: "node", mode: "mode", parentNode: "parentNode", index: "index" }, providers: [
|
|
773
|
-
{
|
|
774
|
-
provide: AXUnsubscriber,
|
|
775
|
-
},
|
|
776
|
-
], ngImport: i0, template: `
|
|
777
|
-
@if(mergedOptions().isVisible!=false) { @if(isLoading()){
|
|
778
|
-
<ax-skeleton [animated]="true" class="ax-w-full lg:ax-w-[50%] ax-h-8 ax-rounded"></ax-skeleton>
|
|
779
|
-
} @else {
|
|
780
|
-
<ng-container *ngTemplateOutlet="tt"></ng-container>
|
|
781
|
-
} }
|
|
782
|
-
<ng-template #tt>
|
|
783
|
-
<ng-template [cdkPortalOutlet]="portal" (attached)="handleAttached($event)"></ng-template>
|
|
784
|
-
</ng-template>
|
|
785
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { kind: "component", type: i3.AXSkeletonComponent, selector: "ax-skeleton", inputs: ["animated"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
786
|
-
}
|
|
787
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPWidgetRendererComponent, decorators: [{
|
|
788
|
-
type: Component,
|
|
789
|
-
args: [{
|
|
790
|
-
selector: 'axp-widget-renderer',
|
|
791
|
-
template: `
|
|
792
|
-
@if(mergedOptions().isVisible!=false) { @if(isLoading()){
|
|
793
|
-
<ax-skeleton [animated]="true" class="ax-w-full lg:ax-w-[50%] ax-h-8 ax-rounded"></ax-skeleton>
|
|
794
|
-
} @else {
|
|
795
|
-
<ng-container *ngTemplateOutlet="tt"></ng-container>
|
|
796
|
-
} }
|
|
797
|
-
<ng-template #tt>
|
|
798
|
-
<ng-template [cdkPortalOutlet]="portal" (attached)="handleAttached($event)"></ng-template>
|
|
799
|
-
</ng-template>
|
|
800
|
-
`,
|
|
801
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
802
|
-
providers: [
|
|
803
|
-
{
|
|
804
|
-
provide: AXUnsubscriber,
|
|
805
|
-
},
|
|
806
|
-
],
|
|
807
|
-
standalone: false
|
|
808
|
-
}]
|
|
809
|
-
}], ctorParameters: () => [], propDecorators: { node: [{
|
|
810
|
-
type: Input,
|
|
811
|
-
args: [{ required: true }]
|
|
812
|
-
}], mode: [{
|
|
813
|
-
type: Input
|
|
814
|
-
}], parentNode: [{
|
|
815
|
-
type: Input
|
|
816
|
-
}], index: [{
|
|
817
|
-
type: Input
|
|
818
|
-
}] } });
|
|
819
|
-
|
|
820
|
-
class AXPWidgetContainerComponent {
|
|
821
|
-
constructor() {
|
|
822
|
-
this.onChanged = new EventEmitter();
|
|
823
|
-
this.context = model({});
|
|
824
|
-
this.unsubscriber = inject(AXUnsubscriber);
|
|
825
|
-
this.builderService = inject(AXPLayoutBuilderService);
|
|
826
|
-
this.ef = effect(() => {
|
|
827
|
-
this.builderService.initial(this.context());
|
|
828
|
-
});
|
|
829
|
-
}
|
|
830
|
-
set variables(v) {
|
|
831
|
-
this.builderService.setVariables(v);
|
|
832
|
-
}
|
|
833
|
-
set functions(v) {
|
|
834
|
-
this.builderService.setFunctions(v);
|
|
835
|
-
}
|
|
836
|
-
ngOnInit() {
|
|
837
|
-
this.builderService.onChanged.pipe(this.unsubscriber.takeUntilDestroy).subscribe((e) => {
|
|
838
|
-
this.context.set(e.data);
|
|
839
|
-
this.onChanged.emit(e);
|
|
840
|
-
});
|
|
841
|
-
}
|
|
842
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPWidgetContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
843
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.3", type: AXPWidgetContainerComponent, isStandalone: false, selector: "axp-widgets-container", inputs: { context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: false, transformFunction: null }, variables: { classPropertyName: "variables", publicName: "variables", isSignal: false, isRequired: false, transformFunction: null }, functions: { classPropertyName: "functions", publicName: "functions", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { onChanged: "onChanged", context: "contextChange" }, host: { styleAttribute: "display: contents;" }, providers: [AXPLayoutBuilderService, AXUnsubscriber], ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
844
|
-
}
|
|
845
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPWidgetContainerComponent, decorators: [{
|
|
846
|
-
type: Component,
|
|
847
|
-
args: [{
|
|
848
|
-
selector: 'axp-widgets-container',
|
|
849
|
-
template: `<ng-content></ng-content>`,
|
|
850
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
851
|
-
host: { style: 'display: contents;' },
|
|
852
|
-
providers: [AXPLayoutBuilderService, AXUnsubscriber],
|
|
853
|
-
standalone: false
|
|
854
|
-
}]
|
|
855
|
-
}], propDecorators: { onChanged: [{
|
|
856
|
-
type: Output
|
|
857
|
-
}], variables: [{
|
|
858
|
-
type: Input
|
|
859
|
-
}], functions: [{
|
|
860
|
-
type: Input
|
|
861
|
-
}] } });
|
|
862
|
-
|
|
863
649
|
class AXPWidgetColumnRendererComponent extends AXDataTableColumnComponent {
|
|
864
650
|
constructor() {
|
|
865
651
|
super(...arguments);
|
|
@@ -1038,6 +824,7 @@ class AXPWidgetRendererDirective {
|
|
|
1038
824
|
this.mergedOptions = signal({});
|
|
1039
825
|
this.injector = inject(Injector);
|
|
1040
826
|
this.builderService = inject(AXPLayoutBuilderService);
|
|
827
|
+
this.contextService = inject(AXPLayoutBuilderContextStore);
|
|
1041
828
|
this.widgetRegistery = inject(AXPWidgetRegistryService);
|
|
1042
829
|
this.unsubscriber = inject(AXUnsubscriber);
|
|
1043
830
|
this.viewContainerRef = inject(ViewContainerRef);
|
|
@@ -1045,13 +832,19 @@ class AXPWidgetRendererDirective {
|
|
|
1045
832
|
this.expressionCache = new Map();
|
|
1046
833
|
this.expressionEvaluators = new Map();
|
|
1047
834
|
this.scope = null;
|
|
1048
|
-
this.
|
|
835
|
+
this.onContextChanged = new Subject();
|
|
836
|
+
effect(async () => {
|
|
837
|
+
const changed = this.contextService.changeEvent();
|
|
1049
838
|
if ((await this.updateOptionsBasedOnContext()) > 0) {
|
|
1050
839
|
this.applyOptions();
|
|
1051
840
|
}
|
|
1052
|
-
if (this.checkFormulaForUpdate(this.node().formula,
|
|
841
|
+
if (this.checkFormulaForUpdate(this.node().formula, changed.path)) {
|
|
1053
842
|
await this.updateValueBasedOnFormula();
|
|
1054
843
|
}
|
|
844
|
+
//
|
|
845
|
+
if (changed.path) {
|
|
846
|
+
this.onContextChanged.next({ path: changed.path });
|
|
847
|
+
}
|
|
1055
848
|
});
|
|
1056
849
|
this.builderService.onRefresh.pipe(this.unsubscriber.takeUntilDestroy).subscribe(async () => {
|
|
1057
850
|
if ((await this.updateOptionsBasedOnContext()) > 0) {
|
|
@@ -1123,9 +916,11 @@ class AXPWidgetRendererDirective {
|
|
|
1123
916
|
const com = await widget?.components[this.mode()]?.component();
|
|
1124
917
|
this.componentRef = this.viewContainerRef.createComponent(com, { injector: token });
|
|
1125
918
|
this.instance = this.componentRef.instance;
|
|
919
|
+
this.instance.setStatus(AXPWidgetStatus.Rendering);
|
|
1126
920
|
this.instance.parent = this.parentNode();
|
|
1127
921
|
this.instance.index = this.index();
|
|
1128
922
|
this.instance.mode = this.mode();
|
|
923
|
+
this.instance.setStatus(AXPWidgetStatus.Rendered);
|
|
1129
924
|
await this.updateValueBasedOnFormula();
|
|
1130
925
|
await this.assignTriggers();
|
|
1131
926
|
//
|
|
@@ -1242,15 +1037,15 @@ class AXPWidgetRendererDirective {
|
|
|
1242
1037
|
}
|
|
1243
1038
|
getContextScope() {
|
|
1244
1039
|
const scope = {};
|
|
1245
|
-
set(scope, 'eval', (path) => this.
|
|
1040
|
+
set(scope, 'eval', (path) => this.contextService.getValue(path));
|
|
1246
1041
|
set(scope, 'set', (path, value) => {
|
|
1247
|
-
this.
|
|
1042
|
+
this.contextService.update(path, value);
|
|
1248
1043
|
});
|
|
1249
1044
|
return scope;
|
|
1250
1045
|
}
|
|
1251
1046
|
getEventScope() {
|
|
1252
1047
|
const scope = {};
|
|
1253
|
-
set(scope, 'context', (path) => this.
|
|
1048
|
+
set(scope, 'context', (path) => this.onContextChanged.pipe(filter((c) => c.path == path)));
|
|
1254
1049
|
set(scope, 'from', (event) => get(this.instance.api(), event));
|
|
1255
1050
|
return scope;
|
|
1256
1051
|
}
|
|
@@ -1349,7 +1144,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
|
|
|
1349
1144
|
}]
|
|
1350
1145
|
}], ctorParameters: () => [] });
|
|
1351
1146
|
|
|
1352
|
-
const COMPONENTS = [AXPWidgetContainerComponent,
|
|
1147
|
+
const COMPONENTS = [AXPWidgetContainerComponent, AXPWidgetColumnRendererComponent, AXPWidgetRendererDirective];
|
|
1353
1148
|
class AXPLayoutBuilderModule {
|
|
1354
1149
|
static forRoot(config) {
|
|
1355
1150
|
return {
|
|
@@ -1390,7 +1185,7 @@ class AXPLayoutBuilderModule {
|
|
|
1390
1185
|
});
|
|
1391
1186
|
}
|
|
1392
1187
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPLayoutBuilderModule, deps: [{ token: 'AXPLayoutBuilderModuleFactory', optional: true }], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
1393
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.3", ngImport: i0, type: AXPLayoutBuilderModule, declarations: [AXPWidgetContainerComponent,
|
|
1188
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.3", ngImport: i0, type: AXPLayoutBuilderModule, declarations: [AXPWidgetContainerComponent, AXPWidgetColumnRendererComponent, AXPWidgetRendererDirective], imports: [CommonModule, PortalModule, AXSkeletonModule, CommonModule], exports: [AXPWidgetContainerComponent, AXPWidgetColumnRendererComponent, AXPWidgetRendererDirective] }); }
|
|
1394
1189
|
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPLayoutBuilderModule, imports: [CommonModule, PortalModule, AXSkeletonModule, CommonModule] }); }
|
|
1395
1190
|
}
|
|
1396
1191
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPLayoutBuilderModule, decorators: [{
|
|
@@ -1427,16 +1222,22 @@ const AXP_WIDGETS_ADVANCE_GROUP = {
|
|
|
1427
1222
|
order: 4,
|
|
1428
1223
|
title: 'Advance',
|
|
1429
1224
|
};
|
|
1225
|
+
const AXP_WIDGETS_FILTER_GROUP = {
|
|
1226
|
+
name: 'filter',
|
|
1227
|
+
order: 5,
|
|
1228
|
+
title: 'Filters',
|
|
1229
|
+
};
|
|
1430
1230
|
const AXP_WIDGETS_GROUPS = [
|
|
1431
1231
|
AXP_WIDGETS_EDITOR_GROUP,
|
|
1432
1232
|
AXP_WIDGETS_ACTION_GROUP,
|
|
1433
1233
|
AXP_WIDGETS_LAYOUT_GROUP,
|
|
1434
1234
|
AXP_WIDGETS_ADVANCE_GROUP,
|
|
1235
|
+
AXP_WIDGETS_FILTER_GROUP,
|
|
1435
1236
|
];
|
|
1436
1237
|
|
|
1437
1238
|
/**
|
|
1438
1239
|
* Generated bundle index. Do not edit.
|
|
1439
1240
|
*/
|
|
1440
1241
|
|
|
1441
|
-
export { AXPColumnWidgetComponent, AXPDataListWidgetComponent, AXPLayoutBuilderModule, AXPLayoutBuilderService, AXPLayoutElement, AXPWidgetColumnRendererComponent, AXPWidgetComponent, AXPWidgetContainerComponent, AXPWidgetDataSourceProviderService, AXPWidgetRegistryService,
|
|
1242
|
+
export { AXPColumnWidgetComponent, AXPDataListWidgetComponent, AXPLayoutBuilderContextStore, AXPLayoutBuilderModule, AXPLayoutBuilderService, AXPLayoutContextChangeEvent, AXPLayoutElement, AXPPageStatus, AXPWidgetColumnRendererComponent, AXPWidgetComponent, AXPWidgetContainerComponent, AXPWidgetDataSourceProviderService, AXPWidgetRegistryService, AXPWidgetRendererDirective, AXPWidgetStatus, AXPWidgetsCatalog, AXP_WIDGETS_ACTION_GROUP, AXP_WIDGETS_ADVANCE_GROUP, AXP_WIDGETS_EDITOR_GROUP, AXP_WIDGETS_FILTER_GROUP, AXP_WIDGETS_GROUPS, AXP_WIDGETS_LAYOUT_GROUP, AXP_WIDGET_COLUMN_TOKEN, AXP_WIDGET_DATASOURCE_PROVIDER, AXP_WIDGET_TOKEN, cloneProperty, createBooleanProperty, createSelectProperty, createStringProperty, objectKeyValueTransforms };
|
|
1442
1243
|
//# sourceMappingURL=acorex-platform-layout-builder.mjs.map
|