cx 25.5.1 → 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,30 +1,30 @@
1
- import { PureContainer } from "./PureContainer";
2
- import { isArray } from "../util/isArray";
3
-
4
- export class IsolatedScope extends PureContainer {
5
- declareData() {
6
- return super.declareData(...arguments, {
7
- data: { structured: true },
8
- });
9
- }
10
-
11
- init() {
12
- if (typeof this.bind === "string") this.data = { bind: this.bind };
13
- else if (isArray(this.bind)) {
14
- this.data = {};
15
- this.bind.forEach((x, i) => {
16
- this.data[String(i)] = { bind: x };
17
- });
18
- }
19
- super.init();
20
- }
21
-
22
- explore(context, instance) {
23
- if (instance.shouldUpdate) {
24
- super.explore(context, instance);
25
- } else if (instance.children) {
26
- // mark children to prevent sweeping them away
27
- for (let i = 0; i < instance.children.length; i++) instance.instanceCache.addChild(instance.children[i]);
28
- }
29
- }
30
- }
1
+ import { PureContainer } from "./PureContainer";
2
+ import { isArray } from "../util/isArray";
3
+
4
+ export class IsolatedScope extends PureContainer {
5
+ declareData() {
6
+ return super.declareData(...arguments, {
7
+ data: { structured: true },
8
+ });
9
+ }
10
+
11
+ init() {
12
+ if (typeof this.bind === "string") this.data = { bind: this.bind };
13
+ else if (isArray(this.bind)) {
14
+ this.data = {};
15
+ this.bind.forEach((x, i) => {
16
+ this.data[String(i)] = { bind: x };
17
+ });
18
+ }
19
+ super.init();
20
+ }
21
+
22
+ explore(context, instance) {
23
+ if (instance.shouldUpdate) {
24
+ super.explore(context, instance);
25
+ } else if (instance.children) {
26
+ // mark children to prevent sweeping them away
27
+ for (let i = 0; i < instance.children.length; i++) instance.instanceCache.addChild(instance.children[i]);
28
+ }
29
+ }
30
+ }
@@ -1,109 +1,109 @@
1
- import { Widget } from "./Widget";
2
- import { PureContainer } from "./PureContainer";
3
- import { Container } from "./Container";
4
- import { ArrayAdapter } from "./adapter/ArrayAdapter";
5
- import { UseParentLayout } from "./layout/UseParentLayout";
6
- import { getAccessor } from "../data/getAccessor";
7
-
8
- export class Repeater extends Container {
9
- declareData() {
10
- super.declareData(
11
- {
12
- records: undefined,
13
- sorters: undefined,
14
- sortField: undefined,
15
- sortDirection: undefined,
16
- filterParams: {
17
- structured: true,
18
- },
19
- },
20
- ...arguments,
21
- );
22
- }
23
-
24
- init() {
25
- this.recordsAccessor = getAccessor(this.records);
26
-
27
- if (this.recordAlias) this.recordName = this.recordAlias;
28
-
29
- if (this.indexAlias) this.indexName = this.indexAlias;
30
-
31
- this.dataAdapter = ArrayAdapter.create({
32
- ...this.dataAdapter,
33
- recordName: this.recordName,
34
- indexName: this.indexName,
35
- keyField: this.keyField,
36
- immutable: this.immutable,
37
- sealed: this.sealed,
38
- recordsAccessor: this.recordsAccessor,
39
- sortOptions: this.sortOptions,
40
- });
41
-
42
- this.item = PureContainer.create({
43
- children: this.items || this.children,
44
- layout: UseParentLayout,
45
- });
46
-
47
- delete this.children;
48
- delete this.items;
49
-
50
- super.init();
51
- }
52
-
53
- initInstance(context, instance) {
54
- this.dataAdapter.initInstance(context, instance);
55
- }
56
-
57
- applyParentStore(instance) {
58
- super.applyParentStore(instance);
59
-
60
- // force prepareData to execute again and propagate the store change to the records
61
- if (instance.cached) delete instance.cached.rawData;
62
- }
63
-
64
- prepareData(context, instance) {
65
- let { data } = instance;
66
- if (data.sortField)
67
- data.sorters = [
68
- {
69
- field: data.sortField,
70
- direction: data.sortDirection || "ASC",
71
- },
72
- ];
73
- this.dataAdapter.sort(data.sorters);
74
- let filter = null;
75
- if (this.onCreateFilter) filter = instance.invoke("onCreateFilter", data.filterParams, instance);
76
- else if (this.filter) filter = (item) => this.filter(item, data.filterParams);
77
- this.dataAdapter.setFilter(filter);
78
- instance.mappedRecords = this.dataAdapter.getRecords(context, instance, data.records, instance.store);
79
-
80
- if (this.onTrackMappedRecords) {
81
- instance.invoke("onTrackMappedRecords", instance.mappedRecords, instance);
82
- }
83
-
84
- super.prepareData(context, instance);
85
- }
86
-
87
- explore(context, instance, data) {
88
- let instances = [];
89
- instance.mappedRecords.forEach((record) => {
90
- let subInstance = instance.getChild(context, this.item, record.key, record.store);
91
- let changed = subInstance.cache("recordData", record.data) || subInstance.cache("key", record.key);
92
- subInstance.record = record;
93
- if (this.cached && !changed && subInstance.visible && !subInstance.childStateDirty) {
94
- instances.push(subInstance);
95
- subInstance.shouldUpdate = false;
96
- } else if (subInstance.scheduleExploreIfVisible(context)) instances.push(subInstance);
97
- });
98
- instance.children = instances;
99
- }
100
- }
101
-
102
- Repeater.prototype.recordName = "$record";
103
- Repeater.prototype.indexName = "$index";
104
- Repeater.prototype.cached = false;
105
- Repeater.prototype.immutable = false;
106
- Repeater.prototype.sealed = false;
107
- Repeater.prototype.isPureContainer = true;
108
-
109
- Widget.alias("repeater", Repeater);
1
+ import { Widget } from "./Widget";
2
+ import { PureContainer } from "./PureContainer";
3
+ import { Container } from "./Container";
4
+ import { ArrayAdapter } from "./adapter/ArrayAdapter";
5
+ import { UseParentLayout } from "./layout/UseParentLayout";
6
+ import { getAccessor } from "../data/getAccessor";
7
+
8
+ export class Repeater extends Container {
9
+ declareData() {
10
+ super.declareData(
11
+ {
12
+ records: undefined,
13
+ sorters: undefined,
14
+ sortField: undefined,
15
+ sortDirection: undefined,
16
+ filterParams: {
17
+ structured: true,
18
+ },
19
+ },
20
+ ...arguments,
21
+ );
22
+ }
23
+
24
+ init() {
25
+ this.recordsAccessor = getAccessor(this.records);
26
+
27
+ if (this.recordAlias) this.recordName = this.recordAlias;
28
+
29
+ if (this.indexAlias) this.indexName = this.indexAlias;
30
+
31
+ this.dataAdapter = ArrayAdapter.create({
32
+ ...this.dataAdapter,
33
+ recordName: this.recordName,
34
+ indexName: this.indexName,
35
+ keyField: this.keyField,
36
+ immutable: this.immutable,
37
+ sealed: this.sealed,
38
+ recordsAccessor: this.recordsAccessor,
39
+ sortOptions: this.sortOptions,
40
+ });
41
+
42
+ this.item = PureContainer.create({
43
+ children: this.items || this.children,
44
+ layout: UseParentLayout,
45
+ });
46
+
47
+ delete this.children;
48
+ delete this.items;
49
+
50
+ super.init();
51
+ }
52
+
53
+ initInstance(context, instance) {
54
+ this.dataAdapter.initInstance(context, instance);
55
+ }
56
+
57
+ applyParentStore(instance) {
58
+ super.applyParentStore(instance);
59
+
60
+ // force prepareData to execute again and propagate the store change to the records
61
+ if (instance.cached) delete instance.cached.rawData;
62
+ }
63
+
64
+ prepareData(context, instance) {
65
+ let { data } = instance;
66
+ if (data.sortField)
67
+ data.sorters = [
68
+ {
69
+ field: data.sortField,
70
+ direction: data.sortDirection || "ASC",
71
+ },
72
+ ];
73
+ this.dataAdapter.sort(data.sorters);
74
+ let filter = null;
75
+ if (this.onCreateFilter) filter = instance.invoke("onCreateFilter", data.filterParams, instance);
76
+ else if (this.filter) filter = (item) => this.filter(item, data.filterParams);
77
+ this.dataAdapter.setFilter(filter);
78
+ instance.mappedRecords = this.dataAdapter.getRecords(context, instance, data.records, instance.store);
79
+
80
+ if (this.onTrackMappedRecords) {
81
+ instance.invoke("onTrackMappedRecords", instance.mappedRecords, instance);
82
+ }
83
+
84
+ super.prepareData(context, instance);
85
+ }
86
+
87
+ explore(context, instance, data) {
88
+ let instances = [];
89
+ instance.mappedRecords.forEach((record) => {
90
+ let subInstance = instance.getChild(context, this.item, record.key, record.store);
91
+ let changed = subInstance.cache("recordData", record.data) || subInstance.cache("key", record.key);
92
+ subInstance.record = record;
93
+ if (this.cached && !changed && subInstance.visible && !subInstance.childStateDirty) {
94
+ instances.push(subInstance);
95
+ subInstance.shouldUpdate = false;
96
+ } else if (subInstance.scheduleExploreIfVisible(context)) instances.push(subInstance);
97
+ });
98
+ instance.children = instances;
99
+ }
100
+ }
101
+
102
+ Repeater.prototype.recordName = "$record";
103
+ Repeater.prototype.indexName = "$index";
104
+ Repeater.prototype.cached = false;
105
+ Repeater.prototype.immutable = false;
106
+ Repeater.prototype.sealed = false;
107
+ Repeater.prototype.isPureContainer = true;
108
+
109
+ Widget.alias("repeater", Repeater);
package/src/ui/Rescope.js CHANGED
@@ -1,35 +1,35 @@
1
- import { Widget } from "./Widget";
2
- import { PureContainer } from "./PureContainer";
3
- import { Binding } from "../data/Binding";
4
- import { ZoomIntoPropertyView } from "../data/ZoomIntoPropertyView";
5
- import { StructuredInstanceDataAccessor } from "./StructuredInstanceDataAccessor";
6
- import { isObject } from "../util/isObject";
7
-
8
- export class Rescope extends PureContainer {
9
- init() {
10
- this.binding = Binding.get(this.bind);
11
- if (this.rootAlias) this.rootName = this.rootAlias;
12
- super.init();
13
- }
14
-
15
- initInstance(context, instance) {
16
- instance.store = new ZoomIntoPropertyView({
17
- store: instance.parentStore,
18
- binding: this.binding,
19
- rootName: this.rootName,
20
- nestedData: isObject(this.data)
21
- ? new StructuredInstanceDataAccessor({ instance, data: this.data, useParentStore: true })
22
- : null,
23
- });
24
- super.initInstance(context, instance);
25
- }
26
-
27
- applyParentStore(instance) {
28
- instance.store.setStore(instance.parentStore);
29
- }
30
- }
31
-
32
- Rescope.prototype.bind = "$page";
33
- Rescope.prototype.rootName = "$root";
34
-
35
- Widget.alias("rescope", Rescope);
1
+ import { Widget } from "./Widget";
2
+ import { PureContainer } from "./PureContainer";
3
+ import { Binding } from "../data/Binding";
4
+ import { ZoomIntoPropertyView } from "../data/ZoomIntoPropertyView";
5
+ import { StructuredInstanceDataAccessor } from "./StructuredInstanceDataAccessor";
6
+ import { isObject } from "../util/isObject";
7
+
8
+ export class Rescope extends PureContainer {
9
+ init() {
10
+ this.binding = Binding.get(this.bind);
11
+ if (this.rootAlias) this.rootName = this.rootAlias;
12
+ super.init();
13
+ }
14
+
15
+ initInstance(context, instance) {
16
+ instance.store = new ZoomIntoPropertyView({
17
+ store: instance.parentStore,
18
+ binding: this.binding,
19
+ rootName: this.rootName,
20
+ nestedData: isObject(this.data)
21
+ ? new StructuredInstanceDataAccessor({ instance, data: this.data, useParentStore: true })
22
+ : null,
23
+ });
24
+ super.initInstance(context, instance);
25
+ }
26
+
27
+ applyParentStore(instance) {
28
+ instance.store.setStore(instance.parentStore);
29
+ }
30
+ }
31
+
32
+ Rescope.prototype.bind = "$page";
33
+ Rescope.prototype.rootName = "$root";
34
+
35
+ Widget.alias("rescope", Rescope);