@acorex/platform 20.4.0 → 20.4.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.
@@ -1,8 +1,8 @@
1
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';
2
+ import { computed, signal, 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
3
  import { convertArrayToDataSource, AXDataSource } from '@acorex/cdk/common';
4
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';
5
+ import { cloneDeep, isEqual, get, set, merge, isNil, isUndefined, isObjectLike, sum, isEmpty, isString } from 'lodash-es';
6
6
  import { Subject, BehaviorSubject, filter } from 'rxjs';
7
7
  import { signalStore, withState, withComputed, withMethods, patchState } from '@ngrx/signals';
8
8
  import * as i1$1 from '@acorex/components/skeleton';
@@ -15,6 +15,118 @@ import { CommonModule } from '@angular/common';
15
15
  import { AXDataTableColumnComponent, AXBaseDataTable } from '@acorex/components/data-table';
16
16
  import { AXUnsubscriber } from '@acorex/core/utils';
17
17
 
18
+ class AXPWidgetCoreContextChangeEvent {
19
+ }
20
+ const AXPWidgetCoreContextStore = signalStore(
21
+ // Initial State
22
+ withState(() => ({
23
+ data: {}, // Shared context data
24
+ state: 'initiated', // Current state
25
+ initialSnapshot: {}, // Snapshot of the first initialized state
26
+ previousSnapshot: {}, // Snapshot of the previous state
27
+ lastChange: {
28
+ state: 'initiated',
29
+ }, // Last change event
30
+ })),
31
+ // Computed Signals
32
+ withComputed(({ data, state, lastChange, initialSnapshot, previousSnapshot }) => ({
33
+ isChanged: computed(() => state() === 'changed'),
34
+ isReset: computed(() => state() === 'restored'),
35
+ isInitiated: computed(() => state() === 'initiated'),
36
+ isEmpty: computed(() => Object.keys(data()).length === 0),
37
+ isDirty: computed(() => !isEqual(data(), previousSnapshot())),
38
+ snapshot: computed(() => cloneDeep(data())), // Current data snapshot
39
+ initial: computed(() => cloneDeep(initialSnapshot())), // Initial snapshot
40
+ previous: computed(() => cloneDeep(previousSnapshot())), // Previous snapshot
41
+ changeEvent: computed(() => lastChange()), // Reactive last change event
42
+ })),
43
+ // Methods for State Management
44
+ withMethods((store) => ({
45
+ // Update a specific value
46
+ update(path, value) {
47
+ const currentData = cloneDeep(store.data());
48
+ const oldValue = get(currentData, path);
49
+ // Skip if the value hasn't changed
50
+ if (isEqual(oldValue, value)) {
51
+ return;
52
+ }
53
+ // Update the value and prepare the change event
54
+ const updatedData = setSmart(currentData, path, value);
55
+ const changeEvent = {
56
+ oldValue,
57
+ newValue: value,
58
+ path,
59
+ state: 'changed',
60
+ data: updatedData,
61
+ };
62
+ // Patch the state
63
+ patchState(store, {
64
+ previousSnapshot: store.snapshot(), // Save the previous state
65
+ data: updatedData,
66
+ state: 'changed',
67
+ lastChange: changeEvent,
68
+ });
69
+ },
70
+ patch(context) {
71
+ const currentData = cloneDeep(store.data());
72
+ // Update the value and prepare the change event
73
+ const updatedData = { ...currentData, ...context };
74
+ const changeEvent = {
75
+ state: 'patch',
76
+ data: updatedData,
77
+ };
78
+ // Patch the state
79
+ patchState(store, {
80
+ previousSnapshot: store.snapshot(), // Save the previous state
81
+ data: updatedData,
82
+ state: 'changed',
83
+ lastChange: changeEvent,
84
+ });
85
+ },
86
+ // Reset to the initial state
87
+ reset() {
88
+ const initialData = store.initial();
89
+ const changeEvent = {
90
+ oldValue: cloneDeep(store.data()), // Current data becomes old value
91
+ newValue: cloneDeep(initialData), // Reset to the initial state
92
+ path: '',
93
+ state: 'restored',
94
+ data: initialData,
95
+ };
96
+ patchState(store, {
97
+ previousSnapshot: store.snapshot(), // Save the previous state
98
+ data: initialData,
99
+ state: 'restored',
100
+ lastChange: changeEvent,
101
+ });
102
+ },
103
+ // Initialize the state
104
+ set(initialData) {
105
+ const currentData = store.data();
106
+ if (isEqual(currentData, initialData)) {
107
+ return; // Skip if the current state matches the initial state
108
+ }
109
+ const changeEvent = {
110
+ oldValue: null,
111
+ newValue: cloneDeep(initialData),
112
+ path: '',
113
+ state: 'initiated',
114
+ data: initialData,
115
+ };
116
+ patchState(store, {
117
+ initialSnapshot: cloneDeep(initialData), // Save the initial state
118
+ previousSnapshot: store.snapshot(), // Save the current state as the previous
119
+ data: initialData,
120
+ state: 'initiated',
121
+ lastChange: changeEvent,
122
+ });
123
+ },
124
+ // Get a specific value
125
+ getValue(path) {
126
+ return get(store.data(), path);
127
+ },
128
+ })));
129
+
18
130
  var AXPPageStatus;
19
131
  (function (AXPPageStatus) {
20
132
  // Idle statuses
@@ -165,118 +277,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImpor
165
277
  type: Injectable
166
278
  }] });
167
279
 
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
280
  const AXPWidgetsCatalog = {
281
281
  timeDuration: 'time-duration',
282
282
  timeDurationFilter: 'time-duration-filter',
@@ -676,8 +676,10 @@ class AXPDataListWidgetComponent extends AXPValueWidgetComponent {
676
676
  pageSize: 10,
677
677
  load: async (e) => {
678
678
  const raw = this.options()['dataSource'];
679
+ const skip = e.skip ?? 0;
680
+ const take = e.take ?? raw.length;
679
681
  return {
680
- items: raw,
682
+ items: raw.slice(skip, skip + take),
681
683
  total: raw.length,
682
684
  };
683
685
  },