cx 25.5.0 → 25.5.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,101 +1,101 @@
1
- import { getAccessor } from "../../data/getAccessor";
2
- import { isArray } from "../../util/isArray";
3
- import { ArrayAdapter } from "./ArrayAdapter";
4
-
5
- export class TreeAdapter extends ArrayAdapter {
6
- init() {
7
- super.init();
8
- this.childrenAccessor = getAccessor({ bind: `${this.recordName}.${this.childrenField}` });
9
-
10
- if (this.restoreExpandedNodesOnLoad) {
11
- if (!this.keyField)
12
- throw new Error(
13
- "Stateful tree adapter requires keyField property to be specified on either Grid or data adapter.",
14
- );
15
-
16
- this.expandedState = {
17
- next: new Set(),
18
- };
19
- }
20
- }
21
-
22
- mapRecords(context, instance, data, parentStore, recordsAccessor) {
23
- let nodes = super.mapRecords(context, instance, data, parentStore, recordsAccessor);
24
- let result = [];
25
-
26
- if (this.restoreExpandedNodesOnLoad) {
27
- this.expandedState = {
28
- current: this.expandedState.next,
29
- next: new Set(),
30
- };
31
- }
32
-
33
- this.processList(context, instance, 0, "", nodes, result);
34
-
35
- return result;
36
- }
37
-
38
- processList(context, instance, level, parentKey, nodes, result) {
39
- nodes.forEach((record) => {
40
- record.key = parentKey + record.key;
41
- this.processNode(context, instance, level, result, record);
42
- });
43
- }
44
-
45
- processNode(context, instance, level, result, record) {
46
- let isHiddenRootNode = level == 0 && this.hideRootNodes;
47
- if (!isHiddenRootNode) result.push(record);
48
- let { data, store } = record;
49
- data.$level = this.hideRootNodes ? level - 1 : level;
50
- if (!data[this.leafField]) {
51
- if (this.restoreExpandedNodesOnLoad && data[this.expandedField] == null)
52
- data[this.expandedField] = this.expandedState.current.has(data[this.keyField]);
53
-
54
- if (data[this.expandedField] || isHiddenRootNode) {
55
- if (this.restoreExpandedNodesOnLoad) this.expandedState.next.add(data[this.keyField]);
56
-
57
- if (data[this.childrenField]) {
58
- let childNodes = super.mapRecords(
59
- context,
60
- instance,
61
- data[this.childrenField],
62
- store,
63
- this.childrenAccessor,
64
- );
65
- this.processList(context, instance, level + 1, record.key + ":", childNodes, result);
66
- } else if (this.load && !data[this.loadedField] && !data[this.loadingField]) {
67
- store.set(`${this.recordName}.${this.loadingField}`, true);
68
- let response = this.load(context, instance, data);
69
- Promise.resolve(response)
70
- .then((children) => {
71
- store.set(`${this.recordName}.${this.childrenField}`, children);
72
- store.set(`${this.recordName}.${this.loadedField}`, true);
73
- store.set(`${this.recordName}.${this.loadingField}`, false);
74
- })
75
- .catch((response) => {
76
- store.set(`${this.recordName}.${this.loadingField}`, false);
77
- if (this.onLoadError) this.onLoadError(response);
78
- });
79
- }
80
- } else data[this.expandedField] = false;
81
- }
82
- }
83
-
84
- sort(sorters) {
85
- if (this.foldersFirst) {
86
- if (!sorters || !isArray(sorters)) sorters = [];
87
- sorters = [{ field: this.leafField, direction: "ASC" }, ...sorters];
88
- }
89
- super.sort(sorters);
90
- }
91
- }
92
-
93
- TreeAdapter.prototype.childrenField = "$children";
94
- TreeAdapter.prototype.expandedField = "$expanded";
95
- TreeAdapter.prototype.leafField = "$leaf";
96
- TreeAdapter.prototype.loadingField = "$loading";
97
- TreeAdapter.prototype.loadedField = "$loaded";
98
- TreeAdapter.prototype.foldersFirst = true;
99
- TreeAdapter.prototype.isTreeAdapter = true;
100
- TreeAdapter.prototype.hideRootNodes = false;
101
- TreeAdapter.prototype.cacheByKeyField = false;
1
+ import { getAccessor } from "../../data/getAccessor";
2
+ import { isArray } from "../../util/isArray";
3
+ import { ArrayAdapter } from "./ArrayAdapter";
4
+
5
+ export class TreeAdapter extends ArrayAdapter {
6
+ init() {
7
+ super.init();
8
+ this.childrenAccessor = getAccessor({ bind: `${this.recordName}.${this.childrenField}` });
9
+
10
+ if (this.restoreExpandedNodesOnLoad) {
11
+ if (!this.keyField)
12
+ throw new Error(
13
+ "Stateful tree adapter requires keyField property to be specified on either Grid or data adapter.",
14
+ );
15
+
16
+ this.expandedState = {
17
+ next: new Set(),
18
+ };
19
+ }
20
+ }
21
+
22
+ mapRecords(context, instance, data, parentStore, recordsAccessor) {
23
+ let nodes = super.mapRecords(context, instance, data, parentStore, recordsAccessor);
24
+ let result = [];
25
+
26
+ if (this.restoreExpandedNodesOnLoad) {
27
+ this.expandedState = {
28
+ current: this.expandedState.next,
29
+ next: new Set(),
30
+ };
31
+ }
32
+
33
+ this.processList(context, instance, 0, "", nodes, result);
34
+
35
+ return result;
36
+ }
37
+
38
+ processList(context, instance, level, parentKey, nodes, result) {
39
+ nodes.forEach((record) => {
40
+ record.key = parentKey + record.key;
41
+ this.processNode(context, instance, level, result, record);
42
+ });
43
+ }
44
+
45
+ processNode(context, instance, level, result, record) {
46
+ let isHiddenRootNode = level == 0 && this.hideRootNodes;
47
+ if (!isHiddenRootNode) result.push(record);
48
+ let { data, store } = record;
49
+ data.$level = this.hideRootNodes ? level - 1 : level;
50
+ if (!data[this.leafField]) {
51
+ if (this.restoreExpandedNodesOnLoad && data[this.expandedField] == null)
52
+ data[this.expandedField] = this.expandedState.current.has(data[this.keyField]);
53
+
54
+ if (data[this.expandedField] || isHiddenRootNode) {
55
+ if (this.restoreExpandedNodesOnLoad) this.expandedState.next.add(data[this.keyField]);
56
+
57
+ if (data[this.childrenField]) {
58
+ let childNodes = super.mapRecords(
59
+ context,
60
+ instance,
61
+ data[this.childrenField],
62
+ store,
63
+ this.childrenAccessor,
64
+ );
65
+ this.processList(context, instance, level + 1, record.key + ":", childNodes, result);
66
+ } else if (this.load && !data[this.loadedField] && !data[this.loadingField]) {
67
+ store.set(`${this.recordName}.${this.loadingField}`, true);
68
+ let response = this.load(context, instance, data);
69
+ Promise.resolve(response)
70
+ .then((children) => {
71
+ store.set(`${this.recordName}.${this.childrenField}`, children);
72
+ store.set(`${this.recordName}.${this.loadedField}`, true);
73
+ store.set(`${this.recordName}.${this.loadingField}`, false);
74
+ })
75
+ .catch((response) => {
76
+ store.set(`${this.recordName}.${this.loadingField}`, false);
77
+ if (this.onLoadError) this.onLoadError(response);
78
+ });
79
+ }
80
+ } else data[this.expandedField] = false;
81
+ }
82
+ }
83
+
84
+ sort(sorters) {
85
+ if (this.foldersFirst) {
86
+ if (!sorters || !isArray(sorters)) sorters = [];
87
+ sorters = [{ field: this.leafField, direction: "ASC" }, ...sorters];
88
+ }
89
+ super.sort(sorters);
90
+ }
91
+ }
92
+
93
+ TreeAdapter.prototype.childrenField = "$children";
94
+ TreeAdapter.prototype.expandedField = "$expanded";
95
+ TreeAdapter.prototype.leafField = "$leaf";
96
+ TreeAdapter.prototype.loadingField = "$loading";
97
+ TreeAdapter.prototype.loadedField = "$loaded";
98
+ TreeAdapter.prototype.foldersFirst = true;
99
+ TreeAdapter.prototype.isTreeAdapter = true;
100
+ TreeAdapter.prototype.hideRootNodes = false;
101
+ TreeAdapter.prototype.cacheByKeyField = false;
@@ -1,12 +1,12 @@
1
- import { View } from "../../data/View";
2
- import { Instance } from "../Instance";
3
- import { RenderingContext } from "../RenderingContext";
4
-
5
- export function exploreChildren(
6
- context: RenderingContext,
7
- instance: Instance,
8
- children: Instance[],
9
- previousResult: Instance[],
10
- key?: string,
11
- store?: View,
12
- ): Instance[];
1
+ import { View } from "../../data/View";
2
+ import { Instance } from "../Instance";
3
+ import { RenderingContext } from "../RenderingContext";
4
+
5
+ export function exploreChildren(
6
+ context: RenderingContext,
7
+ instance: Instance,
8
+ children: Instance[],
9
+ previousResult: Instance[],
10
+ key?: string,
11
+ store?: View,
12
+ ): Instance[];
@@ -1,27 +1,27 @@
1
- export function exploreChildren(context, instance, children, previousResult, key, store) {
2
- let newChildren = previousResult || [];
3
- let oldChildren = previousResult || newChildren;
4
- let identical = previousResult ? 0 : -1;
5
-
6
- for (let c = 0; c < children.length; c++) {
7
- let cell = instance.getChild(context, children[c], key, store);
8
-
9
- if (cell.checkVisible(context)) {
10
- if (identical >= 0) {
11
- if (cell == oldChildren[identical]) identical++;
12
- else {
13
- newChildren = newChildren.slice(0, identical);
14
- identical = -1;
15
- newChildren.push(cell);
16
- }
17
- } else newChildren.push(cell);
18
-
19
- context.exploreStack.push(cell);
20
- if (cell.needsExploreCleanup) context.exploreStack.push(cell);
21
- }
22
- }
23
-
24
- if (identical >= 0 && identical != newChildren.length) newChildren = newChildren.slice(0, identical);
25
-
26
- return newChildren;
27
- }
1
+ export function exploreChildren(context, instance, children, previousResult, key, store) {
2
+ let newChildren = previousResult || [];
3
+ let oldChildren = previousResult || newChildren;
4
+ let identical = previousResult ? 0 : -1;
5
+
6
+ for (let c = 0; c < children.length; c++) {
7
+ let cell = instance.getChild(context, children[c], key, store);
8
+
9
+ if (cell.checkVisible(context)) {
10
+ if (identical >= 0) {
11
+ if (cell == oldChildren[identical]) identical++;
12
+ else {
13
+ newChildren = newChildren.slice(0, identical);
14
+ identical = -1;
15
+ newChildren.push(cell);
16
+ }
17
+ } else newChildren.push(cell);
18
+
19
+ context.exploreStack.push(cell);
20
+ if (cell.needsExploreCleanup) context.exploreStack.push(cell);
21
+ }
22
+ }
23
+
24
+ if (identical >= 0 && identical != newChildren.length) newChildren = newChildren.slice(0, identical);
25
+
26
+ return newChildren;
27
+ }
@@ -82,7 +82,7 @@ export class List extends Widget {
82
82
  emptyText: undefined,
83
83
  tabIndex: undefined,
84
84
  },
85
- ...arguments
85
+ ...arguments,
86
86
  );
87
87
  }
88
88
 
@@ -112,6 +112,13 @@ export class List extends Widget {
112
112
  super.prepareData(context, instance);
113
113
  }
114
114
 
115
+ applyParentStore(instance) {
116
+ super.applyParentStore(instance);
117
+
118
+ // force prepareData to execute again and propagate the store change to the records
119
+ if (instance.cached) delete instance.cached.rawData;
120
+ }
121
+
115
122
  explore(context, instance, data) {
116
123
  let instances = [];
117
124
  let isSelected = this.selection.getIsSelectedDelegate(instance.store);
@@ -239,7 +246,7 @@ class ListComponent extends VDOM.Component {
239
246
  (event) => {
240
247
  instance.invoke("onScroll", event, instance);
241
248
  },
242
- { passive: true }
249
+ { passive: true },
243
250
  );
244
251
  }
245
252