cx 25.4.1 → 25.5.0

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