cx 25.4.1 → 25.5.1
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/dist/charts.js +2 -2
- package/dist/data.js +17 -3
- package/dist/manifest.js +732 -732
- package/dist/ui.js +94 -61
- package/dist/widgets.js +25 -13
- package/package.json +1 -1
- package/src/charts/Legend.d.ts +45 -45
- package/src/charts/LegendEntry.js +128 -128
- package/src/charts/LegendEntry.scss +27 -27
- package/src/charts/PieChart.d.ts +92 -92
- package/src/charts/RangeMarker.js +6 -2
- package/src/charts/axis/Axis.d.ts +113 -113
- package/src/charts/axis/Axis.js +280 -280
- package/src/charts/axis/CategoryAxis.d.ts +30 -30
- package/src/charts/axis/CategoryAxis.js +241 -241
- package/src/charts/axis/NumericAxis.d.ts +46 -46
- package/src/charts/axis/NumericAxis.js +351 -351
- package/src/charts/axis/Stack.js +55 -55
- package/src/charts/axis/TimeAxis.d.ts +31 -28
- package/src/charts/axis/TimeAxis.js +611 -611
- package/src/charts/helpers/PointReducer.js +47 -47
- package/src/charts/helpers/SnapPointFinder.js +69 -69
- package/src/data/AugmentedViewBase.js +77 -75
- package/src/data/Binding.spec.js +69 -69
- package/src/data/ExposedRecordView.js +75 -70
- package/src/data/ExposedValueView.js +73 -72
- package/src/data/Expression.js +229 -229
- package/src/data/Expression.spec.js +229 -229
- package/src/data/Ref.d.ts +24 -24
- package/src/data/Ref.spec.js +79 -79
- package/src/data/StoreRef.spec.js +24 -24
- package/src/data/StringTemplate.js +92 -92
- package/src/data/StringTemplate.spec.js +132 -132
- package/src/data/StructuredDataAccessor.d.ts +7 -7
- package/src/data/StructuredSelector.js +132 -132
- package/src/data/SubscribableView.js +54 -54
- package/src/data/getAccessor.spec.js +11 -11
- package/src/data/getSelector.js +49 -49
- package/src/hooks/createLocalStorageRef.d.ts +3 -3
- package/src/hooks/createLocalStorageRef.js +20 -20
- package/src/index.scss +6 -6
- package/src/ui/Container.js +154 -183
- package/src/ui/Culture.d.ts +57 -57
- package/src/ui/Culture.js +139 -139
- package/src/ui/Cx.js +3 -3
- package/src/ui/DataProxy.js +45 -44
- package/src/ui/DetachedScope.js +98 -94
- package/src/ui/FocusManager.js +171 -171
- package/src/ui/Format.js +108 -108
- package/src/ui/HoverSync.js +147 -147
- package/src/ui/Instance.d.ts +1 -1
- package/src/ui/Instance.js +25 -16
- package/src/ui/IsolatedScope.js +30 -30
- package/src/ui/Repeater.d.ts +61 -61
- package/src/ui/Repeater.js +109 -102
- package/src/ui/Rescope.js +35 -31
- package/src/ui/Restate.js +167 -163
- package/src/ui/Widget.js +184 -200
- package/src/ui/adapter/ArrayAdapter.js +152 -142
- package/src/ui/adapter/TreeAdapter.js +101 -100
- package/src/ui/createFunctionalComponent.d.ts +1 -1
- package/src/ui/createFunctionalComponent.js +31 -36
- package/src/ui/layout/ContentPlaceholder.d.ts +19 -19
- package/src/ui/layout/ContentPlaceholder.js +105 -105
- package/src/ui/layout/ContentPlaceholder.spec.js +579 -579
- package/src/ui/layout/LabelsTopLayout.js +134 -134
- package/src/ui/layout/exploreChildren.d.ts +12 -15
- package/src/ui/layout/exploreChildren.js +27 -40
- package/src/util/Format.js +270 -270
- package/src/util/date/encodeDate.d.ts +1 -1
- package/src/util/date/encodeDate.js +8 -8
- package/src/util/date/encodeDateWithTimezoneOffset.d.ts +1 -1
- package/src/util/date/index.d.ts +11 -11
- package/src/util/date/index.js +11 -11
- package/src/util/date/parseDateInvariant.d.ts +3 -3
- package/src/util/date/parseDateInvariant.js +20 -20
- package/src/util/debounce.js +18 -18
- package/src/util/getSearchQueryPredicate.js +59 -59
- package/src/util/index.d.ts +51 -51
- package/src/util/index.js +54 -54
- package/src/util/isValidIdentifierName.d.ts +1 -1
- package/src/util/isValidIdentifierName.js +5 -5
- package/src/util/isValidIdentifierName.spec.js +33 -33
- package/src/util/scss/add-rules.scss +38 -38
- package/src/util/validatedDebounce.js +19 -19
- package/src/widgets/Button.js +118 -118
- package/src/widgets/CxCredit.scss +37 -37
- package/src/widgets/HighlightedSearchText.js +36 -36
- package/src/widgets/HighlightedSearchText.scss +18 -18
- package/src/widgets/List.js +594 -587
- package/src/widgets/List.scss +91 -91
- package/src/widgets/Sandbox.js +9 -8
- package/src/widgets/drag-drop/DropZone.js +214 -214
- package/src/widgets/form/Calendar.d.ts +86 -86
- package/src/widgets/form/Calendar.js +618 -618
- package/src/widgets/form/Calendar.scss +196 -196
- package/src/widgets/form/Checkbox.scss +127 -127
- package/src/widgets/form/ColorField.js +397 -397
- package/src/widgets/form/ColorField.scss +96 -96
- package/src/widgets/form/ColorPicker.scss +283 -283
- package/src/widgets/form/DateTimeField.js +576 -576
- package/src/widgets/form/DateTimePicker.js +392 -392
- package/src/widgets/form/LookupField.d.ts +179 -179
- package/src/widgets/form/LookupField.scss +219 -219
- package/src/widgets/form/MonthField.d.ts +99 -99
- package/src/widgets/form/MonthField.js +523 -523
- package/src/widgets/form/MonthPicker.d.ts +76 -76
- package/src/widgets/form/MonthPicker.js +641 -641
- package/src/widgets/form/MonthPicker.scss +118 -118
- package/src/widgets/form/NumberField.js +459 -459
- package/src/widgets/form/NumberField.scss +61 -61
- package/src/widgets/form/Radio.scss +121 -121
- package/src/widgets/form/Select.scss +99 -99
- package/src/widgets/form/Slider.scss +118 -118
- package/src/widgets/form/Switch.scss +140 -140
- package/src/widgets/form/TextArea.scss +43 -43
- package/src/widgets/form/TextField.js +290 -290
- package/src/widgets/form/TextField.scss +55 -55
- package/src/widgets/form/UploadButton.d.ts +34 -34
- package/src/widgets/form/variables.scss +353 -353
- package/src/widgets/grid/Grid.d.ts +442 -442
- package/src/widgets/grid/Grid.js +7 -0
- package/src/widgets/grid/GridRow.js +228 -228
- package/src/widgets/grid/TreeNode.d.ts +23 -23
- package/src/widgets/grid/TreeNode.scss +88 -88
- package/src/widgets/grid/variables.scss +133 -133
- package/src/widgets/nav/LinkButton.js +128 -128
- package/src/widgets/nav/Menu.scss +74 -74
- package/src/widgets/nav/Route.js +102 -106
- package/src/widgets/overlay/Dropdown.js +612 -612
- package/src/widgets/overlay/FlyweightTooltipTracker.js +39 -39
- package/src/widgets/overlay/Overlay.d.ts +73 -73
- package/src/widgets/overlay/Tooltip.js +1 -1
- package/src/widgets/overlay/Window.js +202 -202
- package/src/widgets/overlay/captureMouse.js +124 -124
- package/src/widgets/overlay/createHotPromiseWindowFactory.d.ts +18 -18
- package/src/widgets/overlay/createHotPromiseWindowFactory.js +56 -56
- package/src/widgets/overlay/index.d.ts +11 -11
- package/src/widgets/overlay/index.js +11 -11
- package/src/widgets/variables.scss +144 -144
|
@@ -1,142 +1,152 @@
|
|
|
1
|
-
import { DataAdapter } from "./DataAdapter";
|
|
2
|
-
import { ReadOnlyDataView } from "../../data/ReadOnlyDataView";
|
|
3
|
-
import { sorter } from "../../data/comparer";
|
|
4
|
-
import { isArray } from "../../util/isArray";
|
|
5
|
-
import { ArrayElementView } from "../../data/ArrayElementView";
|
|
6
|
-
import { getAccessor } from "../../data/getAccessor";
|
|
7
|
-
import { Culture } from "../Culture";
|
|
8
|
-
import { isDefined } from "../../util";
|
|
9
|
-
|
|
10
|
-
export class ArrayAdapter extends DataAdapter {
|
|
11
|
-
init() {
|
|
12
|
-
this.recordsAccessor = getAccessor(this.recordsBinding ? this.recordsBinding : this.recordsAccessor);
|
|
13
|
-
|
|
14
|
-
//resolve accessor chains
|
|
15
|
-
this.recordName = this.recordName.toString();
|
|
16
|
-
this.indexName = this.indexName.toString();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
initInstance(context, instance) {
|
|
20
|
-
if (!instance.recordStoreCache)
|
|
21
|
-
|
|
22
|
-
instance.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
recordStore
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
1
|
+
import { DataAdapter } from "./DataAdapter";
|
|
2
|
+
import { ReadOnlyDataView } from "../../data/ReadOnlyDataView";
|
|
3
|
+
import { sorter } from "../../data/comparer";
|
|
4
|
+
import { isArray } from "../../util/isArray";
|
|
5
|
+
import { ArrayElementView } from "../../data/ArrayElementView";
|
|
6
|
+
import { getAccessor } from "../../data/getAccessor";
|
|
7
|
+
import { Culture } from "../Culture";
|
|
8
|
+
import { isDefined, isObject } from "../../util";
|
|
9
|
+
|
|
10
|
+
export class ArrayAdapter extends DataAdapter {
|
|
11
|
+
init() {
|
|
12
|
+
this.recordsAccessor = getAccessor(this.recordsBinding ? this.recordsBinding : this.recordsAccessor);
|
|
13
|
+
|
|
14
|
+
//resolve accessor chains
|
|
15
|
+
this.recordName = this.recordName.toString();
|
|
16
|
+
this.indexName = this.indexName.toString();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
initInstance(context, instance) {
|
|
20
|
+
if (!instance.recordStoreCache) {
|
|
21
|
+
instance.recordStoreCache = new WeakMap();
|
|
22
|
+
instance.cacheByKey = {};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!instance.recordsAccessor && this.recordsAccessor) {
|
|
26
|
+
instance.recordsAccessor = this.recordsAccessor.bindInstance
|
|
27
|
+
? this.recordsAccessor.bindInstance(instance)
|
|
28
|
+
: this.recordsAccessor;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getRecords(context, instance, records, parentStore) {
|
|
33
|
+
if (!instance.recordStoreCache) this.initInstance(context, instance);
|
|
34
|
+
|
|
35
|
+
return this.mapRecords(context, instance, records, parentStore, instance.recordsAccessor);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
mapRecords(context, instance, records, parentStore, recordsAccessor) {
|
|
39
|
+
let result = [];
|
|
40
|
+
|
|
41
|
+
if (!instance.recordStoreCache) this.initInstance(context, instance);
|
|
42
|
+
|
|
43
|
+
if (isArray(records))
|
|
44
|
+
records.forEach((data, index) => {
|
|
45
|
+
if (this.filterFn && !this.filterFn(data)) return;
|
|
46
|
+
|
|
47
|
+
let record = this.mapRecord(context, instance, data, parentStore, recordsAccessor, index);
|
|
48
|
+
|
|
49
|
+
result.push(record);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (this.sorter) result = this.sorter(result);
|
|
53
|
+
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
mapRecord(context, instance, data, parentStore, recordsAccessor, index) {
|
|
58
|
+
let key = this.cacheByKeyField && this.keyField ? data[this.keyField] : null;
|
|
59
|
+
let recordStore = key != null ? instance.cacheByKey[key] : instance.recordStoreCache.get(data);
|
|
60
|
+
|
|
61
|
+
if (recordsAccessor) {
|
|
62
|
+
if (!recordStore)
|
|
63
|
+
recordStore = new ArrayElementView({
|
|
64
|
+
store: parentStore,
|
|
65
|
+
arrayAccessor: recordsAccessor,
|
|
66
|
+
itemIndex: index,
|
|
67
|
+
recordAlias: this.recordName,
|
|
68
|
+
indexAlias: this.indexName,
|
|
69
|
+
immutable: this.immutable,
|
|
70
|
+
sealed: this.sealed,
|
|
71
|
+
});
|
|
72
|
+
else {
|
|
73
|
+
recordStore.setStore(parentStore);
|
|
74
|
+
recordStore.setIndex(index);
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
if (!recordStore)
|
|
78
|
+
recordStore = new ReadOnlyDataView({
|
|
79
|
+
store: parentStore,
|
|
80
|
+
data: {
|
|
81
|
+
[this.recordName]: data,
|
|
82
|
+
[this.indexName]: index,
|
|
83
|
+
},
|
|
84
|
+
immutable: this.immutable,
|
|
85
|
+
sealed: this.sealed,
|
|
86
|
+
});
|
|
87
|
+
else {
|
|
88
|
+
recordStore.setStore(parentStore);
|
|
89
|
+
recordStore.setData(data);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// cache by the key or by data reference
|
|
94
|
+
if (key != null) instance.cacheByKey[key] = recordStore;
|
|
95
|
+
else if (isObject(data)) instance.recordStoreCache.set(data, recordStore);
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
store: recordStore,
|
|
99
|
+
index: index,
|
|
100
|
+
data: data,
|
|
101
|
+
type: "data",
|
|
102
|
+
key: this.keyField ? data[this.keyField] : index,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
setFilter(filterFn) {
|
|
107
|
+
this.filterFn = filterFn;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
getComparer(sortOptions) {
|
|
111
|
+
return sortOptions ? Culture.getComparer(sortOptions) : null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
buildSorter(sorters) {
|
|
115
|
+
if (isArray(sorters) && sorters.length > 0) {
|
|
116
|
+
let fieldValueMapper;
|
|
117
|
+
let dataAccessor;
|
|
118
|
+
|
|
119
|
+
//if all sorters are based on record fields access data directly (faster)
|
|
120
|
+
if (sorters.every((x) => x.field && x.value == null)) {
|
|
121
|
+
dataAccessor = (x) => x.data;
|
|
122
|
+
fieldValueMapper = (x) => ({ bind: x.field });
|
|
123
|
+
} else {
|
|
124
|
+
dataAccessor = (x) => x.store.getData();
|
|
125
|
+
fieldValueMapper = (x) => ({ bind: this.recordName + "." + x.field });
|
|
126
|
+
}
|
|
127
|
+
this.sorter = sorter(
|
|
128
|
+
sorters.map((x) => {
|
|
129
|
+
let s = Object.assign({}, x);
|
|
130
|
+
if (s.field && s.value == null) s.value = fieldValueMapper(s);
|
|
131
|
+
if (!s.comparer)
|
|
132
|
+
s.comparer = this.getComparer(isDefined(s.sortOptions) ? s.sortOptions : this.sortOptions);
|
|
133
|
+
return s;
|
|
134
|
+
}),
|
|
135
|
+
dataAccessor,
|
|
136
|
+
);
|
|
137
|
+
} else {
|
|
138
|
+
this.sorter = null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
sort(sorters) {
|
|
143
|
+
this.buildSorter(sorters);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
ArrayAdapter.prototype.immutable = false;
|
|
148
|
+
ArrayAdapter.prototype.sealed = false;
|
|
149
|
+
ArrayAdapter.prototype.keyField = null;
|
|
150
|
+
ArrayAdapter.prototype.cacheByKeyField = true;
|
|
151
|
+
|
|
152
|
+
ArrayAdapter.autoInit = true;
|
|
@@ -1,100 +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;
|
|
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 +1 @@
|
|
|
1
|
-
export function createFunctionalComponent<T, X>(factory: (props: T) => X): (props: T) => X;
|
|
1
|
+
export function createFunctionalComponent<T, X>(factory: (props: T) => X): (props: T) => X;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createComponentFactory, isComponentFactory } from
|
|
2
|
-
import { flattenProps } from
|
|
1
|
+
import { createComponentFactory, isComponentFactory } from "../util/Component";
|
|
2
|
+
import { flattenProps } from "../ui/flattenProps";
|
|
3
3
|
import { PureContainer } from "./PureContainer";
|
|
4
4
|
import { UseParentLayout } from "./layout/UseParentLayout";
|
|
5
5
|
import { StoreProxy } from "../data/StoreProxy";
|
|
@@ -9,6 +9,7 @@ let currentInstance = null;
|
|
|
9
9
|
|
|
10
10
|
class FunctionalComponent extends PureContainer {
|
|
11
11
|
initInstance(context, instance) {
|
|
12
|
+
instance.store = instance.parentStore;
|
|
12
13
|
this.clear();
|
|
13
14
|
currentInstance = instance;
|
|
14
15
|
this.add(this.childrenFactory(this.props));
|
|
@@ -18,49 +19,43 @@ class FunctionalComponent extends PureContainer {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
explore(context, instance) {
|
|
21
|
-
if (this.layout)
|
|
22
|
-
|
|
23
|
-
else
|
|
24
|
-
this.items = instance.content;
|
|
22
|
+
if (this.layout) this.layout.items = instance.content;
|
|
23
|
+
else this.items = instance.content;
|
|
25
24
|
this.exploreItems(context, instance, instance.content);
|
|
26
25
|
if (instance.computables) {
|
|
27
|
-
instance.computables.forEach(cb => cb(instance.store.getData()))
|
|
26
|
+
instance.computables.forEach((cb) => cb(instance.store.getData()));
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
export function createFunctionalComponent(factory) {
|
|
33
|
-
if (isComponentFactory(factory))
|
|
34
|
-
return factory;
|
|
32
|
+
if (isComponentFactory(factory)) return factory;
|
|
35
33
|
|
|
36
|
-
return createComponentFactory(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
delete innerProps.$type;
|
|
49
|
-
delete innerProps.vdomKey;
|
|
34
|
+
return createComponentFactory(factory, (props = {}) => {
|
|
35
|
+
let innerProps = flattenProps(props);
|
|
36
|
+
delete innerProps.visible;
|
|
37
|
+
delete innerProps.if;
|
|
38
|
+
delete innerProps.controller;
|
|
39
|
+
delete innerProps.layout;
|
|
40
|
+
delete innerProps.outerLayout;
|
|
41
|
+
delete innerProps.putInto;
|
|
42
|
+
delete innerProps.contentFor;
|
|
43
|
+
delete innerProps.jsxAttributes;
|
|
44
|
+
delete innerProps.$type;
|
|
45
|
+
delete innerProps.vdomKey;
|
|
50
46
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
)
|
|
47
|
+
return {
|
|
48
|
+
type: FunctionalComponent,
|
|
49
|
+
visible: isDefined(props.if) ? props.if : isDefined(props.visible) ? props.visible : true,
|
|
50
|
+
layout: props.layout || UseParentLayout,
|
|
51
|
+
controller: props.controller,
|
|
52
|
+
outerLayout: props.outerLayout,
|
|
53
|
+
putInto: props.contentFor || props.putInto,
|
|
54
|
+
vdomKey: props.vdomKey,
|
|
55
|
+
childrenFactory: factory,
|
|
56
|
+
props: innerProps,
|
|
57
|
+
};
|
|
58
|
+
});
|
|
64
59
|
}
|
|
65
60
|
|
|
66
61
|
export function getCurrentInstance() {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import * as Cx from "../../core";
|
|
2
|
-
import { RenderingContext } from "../RenderingContext";
|
|
3
|
-
|
|
4
|
-
interface ContentPlaceholderProps extends Cx.PureContainerProps {
|
|
5
|
-
name?: Cx.StringProp;
|
|
6
|
-
|
|
7
|
-
scoped?: boolean;
|
|
8
|
-
|
|
9
|
-
/* Set to true to allow all registered content elements to render inside the placeholder. Otherwise only one element is rendered. */
|
|
10
|
-
allowMultiple?: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class ContentPlaceholder extends Cx.Widget<ContentPlaceholderProps> {}
|
|
14
|
-
|
|
15
|
-
interface ContentPlaceholderScopeProps extends Cx.PureContainerProps {
|
|
16
|
-
name?: string | string[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export class ContentPlaceholderScope extends Cx.Widget<ContentPlaceholderScopeProps> {}
|
|
1
|
+
import * as Cx from "../../core";
|
|
2
|
+
import { RenderingContext } from "../RenderingContext";
|
|
3
|
+
|
|
4
|
+
interface ContentPlaceholderProps extends Cx.PureContainerProps {
|
|
5
|
+
name?: Cx.StringProp;
|
|
6
|
+
|
|
7
|
+
scoped?: boolean;
|
|
8
|
+
|
|
9
|
+
/* Set to true to allow all registered content elements to render inside the placeholder. Otherwise only one element is rendered. */
|
|
10
|
+
allowMultiple?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class ContentPlaceholder extends Cx.Widget<ContentPlaceholderProps> {}
|
|
14
|
+
|
|
15
|
+
interface ContentPlaceholderScopeProps extends Cx.PureContainerProps {
|
|
16
|
+
name?: string | string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class ContentPlaceholderScope extends Cx.Widget<ContentPlaceholderScopeProps> {}
|