cx 25.5.1 → 25.6.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 (45) hide show
  1. package/dist/charts.js +40 -21
  2. package/dist/manifest.js +771 -771
  3. package/dist/ui.js +0 -15
  4. package/dist/widgets.js +34 -25
  5. package/package.json +1 -1
  6. package/src/charts/LineGraph.js +1 -1
  7. package/src/charts/axis/NumericAxis.d.ts +46 -46
  8. package/src/charts/helpers/PointReducer.d.ts +9 -0
  9. package/src/charts/helpers/PointReducer.js +36 -22
  10. package/src/data/AugmentedViewBase.js +77 -77
  11. package/src/data/ExposedRecordView.js +75 -75
  12. package/src/data/ExposedValueView.js +73 -73
  13. package/src/data/Ref.d.ts +24 -24
  14. package/src/data/Ref.spec.js +79 -79
  15. package/src/data/StoreRef.spec.js +24 -24
  16. package/src/data/StructuredDataAccessor.d.ts +7 -7
  17. package/src/data/SubscribableView.js +54 -54
  18. package/src/ui/Container.js +154 -154
  19. package/src/ui/DataProxy.js +31 -45
  20. package/src/ui/DetachedScope.js +98 -98
  21. package/src/ui/Instance.d.ts +72 -72
  22. package/src/ui/Instance.js +623 -623
  23. package/src/ui/IsolatedScope.js +30 -30
  24. package/src/ui/Repeater.js +109 -109
  25. package/src/ui/Rescope.js +35 -35
  26. package/src/ui/Restate.js +167 -167
  27. package/src/ui/Widget.js +184 -184
  28. package/src/ui/adapter/ArrayAdapter.js +152 -152
  29. package/src/ui/adapter/TreeAdapter.js +101 -101
  30. package/src/ui/createFunctionalComponent.d.ts +1 -1
  31. package/src/ui/index.d.ts +42 -42
  32. package/src/ui/layout/exploreChildren.d.ts +12 -12
  33. package/src/ui/layout/exploreChildren.js +27 -27
  34. package/src/util/debounce.js +18 -18
  35. package/src/util/validatedDebounce.js +19 -19
  36. package/src/widgets/Button.js +118 -118
  37. package/src/widgets/List.js +594 -594
  38. package/src/widgets/form/Calendar.d.ts +86 -86
  39. package/src/widgets/form/Checkbox.js +5 -2
  40. package/src/widgets/form/MonthField.d.ts +5 -0
  41. package/src/widgets/form/MonthField.js +1 -0
  42. package/src/widgets/form/MonthPicker.d.ts +13 -0
  43. package/src/widgets/form/MonthPicker.js +25 -21
  44. package/src/widgets/grid/Grid.js +3421 -3421
  45. package/src/widgets/nav/Route.js +102 -102
package/src/ui/Restate.js CHANGED
@@ -1,167 +1,167 @@
1
- import { PureContainer } from "./PureContainer";
2
- import { Store } from "../data/Store";
3
- import { Cx } from "./Cx";
4
- import { VDOM } from "./VDOM";
5
- import { isObject } from "../util/isObject";
6
- import { isUndefined } from "../util/isUndefined";
7
- import { Binding } from "../data/Binding";
8
- import { StructuredSelector } from "../data/StructuredSelector";
9
- import { getCurrentCulture } from "./Culture";
10
-
11
- let persistenceCache = {};
12
-
13
- export class Restate extends PureContainer {
14
- declareData() {
15
- return super.declareData(...arguments, {
16
- deferredUntilIdle: undefined,
17
- idleTimeout: undefined,
18
- cacheKey: undefined,
19
- });
20
- }
21
-
22
- init() {
23
- this.container = PureContainer.create({
24
- type: PureContainer,
25
- items: this.children || this.items,
26
- layout: this.layout,
27
- controller: this.controller,
28
- outerLayout: this.outerLayout,
29
- useParentLayout: !this.detached,
30
- ws: this.ws,
31
- });
32
- this.privateDataSelector = new StructuredSelector({
33
- props: this.data || {},
34
- values: this.data,
35
- });
36
- delete this.items;
37
- delete this.children;
38
- delete this.controller;
39
- delete this.outerLayout;
40
- delete this.layout;
41
- if (this.useParentLayout == null) this.useParentLayout = !this.detached;
42
- super.init();
43
- }
44
-
45
- initSubStore(context, instance) {
46
- let { cacheKey } = instance.data;
47
- this.privateDataSelector.init(instance.store);
48
- instance.subStore = new RestateStore({
49
- store: instance.store,
50
- detached: this.detached,
51
- privateData: this.data || {},
52
- data: cacheKey ? persistenceCache[cacheKey] || {} : {},
53
- dataSelector: this.privateDataSelector.create(),
54
- onSet: (path, value) => instance.nestedDataSet(path, value, this.data),
55
- });
56
-
57
- if (cacheKey) {
58
- instance.subscribeOnDestroy(() => {
59
- persistenceCache[cacheKey] = instance.subStore.getData();
60
- });
61
- }
62
- }
63
-
64
- applyParentStore(instance) {
65
- if (instance.subStore) instance.subStore.setStore(instance.parentStore);
66
- }
67
-
68
- explore(context, instance) {
69
- if (!instance.subStore) this.initSubStore(context, instance);
70
- if (instance.subStore.parentDataCheck()) instance.markShouldUpdate();
71
- instance.cultureInfo = this.culture ?? getCurrentCulture();
72
- if (instance.cache("cultureInfo", instance.culture)) instance.markShouldUpdate();
73
- super.explore(context, instance);
74
- }
75
-
76
- exploreItems(context, instance, items) {
77
- if (!this.detached) {
78
- instance.container = instance.getChild(context, this.container, "container", instance.subStore);
79
- instance.container.scheduleExploreIfVisible(context);
80
- instance.children = [instance.container];
81
- }
82
- }
83
-
84
- render(context, instance, key) {
85
- if (!this.detached) return instance.container.render(context);
86
-
87
- return (
88
- <Cx
89
- key={key}
90
- widget={this.container}
91
- parentInstance={instance}
92
- store={instance.subStore}
93
- subscribe
94
- options={this.options}
95
- onError={this.onError}
96
- deferredUntilIdle={instance.data.deferredUntilIdle}
97
- idleTimeout={instance.data.idleTimeout}
98
- immediate={this.immediate}
99
- cultureInfo={instance.cultureInfo}
100
- />
101
- );
102
- }
103
- }
104
-
105
- Restate.prototype.detached = false;
106
- Restate.prototype.waitForIdle = false;
107
- Restate.prototype.immediate = false;
108
- Restate.prototype.culture = null;
109
-
110
- export const PrivateStore = Restate;
111
-
112
- class RestateStore extends Store {
113
- constructor(config) {
114
- super(config);
115
- this.parentDataVersion = -1;
116
- }
117
-
118
- getData() {
119
- this.silently(() => {
120
- this.parentDataCheck();
121
- });
122
- return super.getData();
123
- }
124
-
125
- parentDataCheck() {
126
- if (this.parentDataVersion == this.store.meta.version) return false;
127
- this.parentDataVersion = this.store.meta.version;
128
- this.parentData = this.dataSelector(this.store.getData());
129
- return this.batch(() => {
130
- for (let key in this.parentData) {
131
- super.setItem(key, this.parentData[key]);
132
- }
133
- });
134
- }
135
-
136
- setItem(path, value) {
137
- let binding = Binding.get(path);
138
- let bindingRoot = binding.parts[0];
139
- if (!isObject(this.privateData) || !this.privateData.hasOwnProperty(bindingRoot)) {
140
- let changed = isUndefined(value) ? super.deleteItem(path) : super.setItem(path, value);
141
- return changed;
142
- }
143
-
144
- let newValue = value;
145
- if (binding.parts.length > 1) newValue = binding.set(this.getData(), value)[bindingRoot];
146
- this.onSet(bindingRoot, newValue);
147
- this.batch(() => {
148
- super.setItem(bindingRoot, newValue);
149
- this.parentDataCheck();
150
- });
151
- return true;
152
- }
153
-
154
- deleteItem(path) {
155
- return this.setItem(path, undefined);
156
- }
157
-
158
- doNotify() {
159
- if (!this.detached) this.store.notify();
160
- super.doNotify();
161
- }
162
-
163
- // override the default implementation to avoid meta overwrites
164
- setStore(store) {
165
- this.store = store;
166
- }
167
- }
1
+ import { PureContainer } from "./PureContainer";
2
+ import { Store } from "../data/Store";
3
+ import { Cx } from "./Cx";
4
+ import { VDOM } from "./VDOM";
5
+ import { isObject } from "../util/isObject";
6
+ import { isUndefined } from "../util/isUndefined";
7
+ import { Binding } from "../data/Binding";
8
+ import { StructuredSelector } from "../data/StructuredSelector";
9
+ import { getCurrentCulture } from "./Culture";
10
+
11
+ let persistenceCache = {};
12
+
13
+ export class Restate extends PureContainer {
14
+ declareData() {
15
+ return super.declareData(...arguments, {
16
+ deferredUntilIdle: undefined,
17
+ idleTimeout: undefined,
18
+ cacheKey: undefined,
19
+ });
20
+ }
21
+
22
+ init() {
23
+ this.container = PureContainer.create({
24
+ type: PureContainer,
25
+ items: this.children || this.items,
26
+ layout: this.layout,
27
+ controller: this.controller,
28
+ outerLayout: this.outerLayout,
29
+ useParentLayout: !this.detached,
30
+ ws: this.ws,
31
+ });
32
+ this.privateDataSelector = new StructuredSelector({
33
+ props: this.data || {},
34
+ values: this.data,
35
+ });
36
+ delete this.items;
37
+ delete this.children;
38
+ delete this.controller;
39
+ delete this.outerLayout;
40
+ delete this.layout;
41
+ if (this.useParentLayout == null) this.useParentLayout = !this.detached;
42
+ super.init();
43
+ }
44
+
45
+ initSubStore(context, instance) {
46
+ let { cacheKey } = instance.data;
47
+ this.privateDataSelector.init(instance.store);
48
+ instance.subStore = new RestateStore({
49
+ store: instance.store,
50
+ detached: this.detached,
51
+ privateData: this.data || {},
52
+ data: cacheKey ? persistenceCache[cacheKey] || {} : {},
53
+ dataSelector: this.privateDataSelector.create(),
54
+ onSet: (path, value) => instance.nestedDataSet(path, value, this.data),
55
+ });
56
+
57
+ if (cacheKey) {
58
+ instance.subscribeOnDestroy(() => {
59
+ persistenceCache[cacheKey] = instance.subStore.getData();
60
+ });
61
+ }
62
+ }
63
+
64
+ applyParentStore(instance) {
65
+ if (instance.subStore) instance.subStore.setStore(instance.parentStore);
66
+ }
67
+
68
+ explore(context, instance) {
69
+ if (!instance.subStore) this.initSubStore(context, instance);
70
+ if (instance.subStore.parentDataCheck()) instance.markShouldUpdate();
71
+ instance.cultureInfo = this.culture ?? getCurrentCulture();
72
+ if (instance.cache("cultureInfo", instance.culture)) instance.markShouldUpdate();
73
+ super.explore(context, instance);
74
+ }
75
+
76
+ exploreItems(context, instance, items) {
77
+ if (!this.detached) {
78
+ instance.container = instance.getChild(context, this.container, "container", instance.subStore);
79
+ instance.container.scheduleExploreIfVisible(context);
80
+ instance.children = [instance.container];
81
+ }
82
+ }
83
+
84
+ render(context, instance, key) {
85
+ if (!this.detached) return instance.container.render(context);
86
+
87
+ return (
88
+ <Cx
89
+ key={key}
90
+ widget={this.container}
91
+ parentInstance={instance}
92
+ store={instance.subStore}
93
+ subscribe
94
+ options={this.options}
95
+ onError={this.onError}
96
+ deferredUntilIdle={instance.data.deferredUntilIdle}
97
+ idleTimeout={instance.data.idleTimeout}
98
+ immediate={this.immediate}
99
+ cultureInfo={instance.cultureInfo}
100
+ />
101
+ );
102
+ }
103
+ }
104
+
105
+ Restate.prototype.detached = false;
106
+ Restate.prototype.waitForIdle = false;
107
+ Restate.prototype.immediate = false;
108
+ Restate.prototype.culture = null;
109
+
110
+ export const PrivateStore = Restate;
111
+
112
+ class RestateStore extends Store {
113
+ constructor(config) {
114
+ super(config);
115
+ this.parentDataVersion = -1;
116
+ }
117
+
118
+ getData() {
119
+ this.silently(() => {
120
+ this.parentDataCheck();
121
+ });
122
+ return super.getData();
123
+ }
124
+
125
+ parentDataCheck() {
126
+ if (this.parentDataVersion == this.store.meta.version) return false;
127
+ this.parentDataVersion = this.store.meta.version;
128
+ this.parentData = this.dataSelector(this.store.getData());
129
+ return this.batch(() => {
130
+ for (let key in this.parentData) {
131
+ super.setItem(key, this.parentData[key]);
132
+ }
133
+ });
134
+ }
135
+
136
+ setItem(path, value) {
137
+ let binding = Binding.get(path);
138
+ let bindingRoot = binding.parts[0];
139
+ if (!isObject(this.privateData) || !this.privateData.hasOwnProperty(bindingRoot)) {
140
+ let changed = isUndefined(value) ? super.deleteItem(path) : super.setItem(path, value);
141
+ return changed;
142
+ }
143
+
144
+ let newValue = value;
145
+ if (binding.parts.length > 1) newValue = binding.set(this.getData(), value)[bindingRoot];
146
+ this.onSet(bindingRoot, newValue);
147
+ this.batch(() => {
148
+ super.setItem(bindingRoot, newValue);
149
+ this.parentDataCheck();
150
+ });
151
+ return true;
152
+ }
153
+
154
+ deleteItem(path) {
155
+ return this.setItem(path, undefined);
156
+ }
157
+
158
+ doNotify() {
159
+ if (!this.detached) this.store.notify();
160
+ super.doNotify();
161
+ }
162
+
163
+ // override the default implementation to avoid meta overwrites
164
+ setStore(store) {
165
+ this.store = store;
166
+ }
167
+ }