cx 26.1.0 → 26.1.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/build/ui/Widget.js +0 -5
- package/build/util/Component.js +5 -0
- package/build/util/test/createTestRenderer.d.ts +3 -1
- package/build/util/test/createTestRenderer.js +8 -2
- package/build/widgets/icons/calendar.js +4 -3
- package/build/widgets/icons/check.js +2 -2
- package/build/widgets/icons/clear.js +2 -2
- package/build/widgets/icons/close.js +2 -2
- package/build/widgets/icons/cx.js +2 -2
- package/build/widgets/icons/drop-down.js +2 -2
- package/build/widgets/icons/file.js +2 -2
- package/build/widgets/icons/folder-open.js +2 -2
- package/build/widgets/icons/folder.js +2 -2
- package/build/widgets/icons/forward.js +2 -2
- package/build/widgets/icons/loading.js +2 -2
- package/build/widgets/icons/menu.js +2 -2
- package/build/widgets/icons/pixel-picker.js +2 -2
- package/build/widgets/icons/search.js +2 -2
- package/build/widgets/icons/sort-asc.js +2 -2
- package/build/widgets/icons/square.js +2 -2
- package/dist/manifest.js +896 -896
- package/dist/ui.js +1 -8
- package/dist/util.js +4 -0
- package/dist/widgets.js +377 -313
- package/package.json +3 -1
- package/src/core.d.ts +182 -182
- package/src/data/ArrayElementView.ts +90 -90
- package/src/data/AugmentedViewBase.ts +88 -88
- package/src/data/Binding.ts +104 -104
- package/src/data/ExposedRecordView.ts +95 -95
- package/src/data/ExposedValueView.ts +89 -89
- package/src/data/Grouper.spec.ts +57 -57
- package/src/data/NestedDataView.ts +43 -43
- package/src/data/ReadOnlyDataView.ts +39 -39
- package/src/data/Ref.ts +104 -104
- package/src/data/Store.ts +52 -52
- package/src/data/StoreProxy.ts +19 -19
- package/src/data/StoreRef.ts +66 -66
- package/src/data/StringTemplate.ts +93 -93
- package/src/data/StructuredSelector.spec.ts +113 -113
- package/src/data/SubscribableView.ts +63 -63
- package/src/data/ZoomIntoPropertyView.ts +45 -45
- package/src/data/comparer.ts +78 -78
- package/src/data/ops/updateArray.ts +31 -31
- package/src/hooks/invokeCallback.spec.tsx +4 -4
- package/src/hooks/resolveCallback.spec.tsx +4 -4
- package/src/hooks/store.spec.tsx +15 -15
- package/src/hooks/useTrigger.spec.tsx +16 -10
- package/src/jsx-dev-runtime.ts +4 -4
- package/src/jsx-runtime.ts +79 -79
- package/src/ui/CSS.ts +87 -87
- package/src/ui/ContentResolver.spec.tsx +31 -29
- package/src/ui/Controller.spec.tsx +47 -39
- package/src/ui/Cx.spec.tsx +10 -8
- package/src/ui/DataProxy.spec.tsx +18 -18
- package/src/ui/DataProxy.ts +55 -55
- package/src/ui/FocusManager.ts +171 -171
- package/src/ui/IsolatedScope.spec.tsx +16 -9
- package/src/ui/PureContainer.spec.tsx +20 -18
- package/src/ui/Repeater.spec.tsx +8 -6
- package/src/ui/Rescope.spec.tsx +13 -13
- package/src/ui/Rescope.ts +49 -49
- package/src/ui/Restate.spec.tsx +31 -27
- package/src/ui/VDOM.ts +1 -1
- package/src/ui/Widget.tsx +0 -7
- package/src/ui/adapter/ArrayAdapter.spec.ts +55 -55
- package/src/ui/createFunctionalComponent.spec.tsx +20 -18
- package/src/ui/layout/Content.ts +30 -30
- package/src/ui/layout/ContentPlaceholder.spec.tsx +46 -34
- package/src/ui/layout/FirstVisibleChildLayout.spec.tsx +31 -19
- package/src/ui/selection/PropertySelection.ts +87 -87
- package/src/util/Component.spec.ts +30 -0
- package/src/util/Component.ts +301 -296
- package/src/util/DOM.ts +88 -88
- package/src/util/Format.spec.ts +69 -69
- package/src/util/Format.ts +267 -267
- package/src/util/addEventListenerWithOptions.ts +41 -41
- package/src/util/browserSupportsPassiveEventHandlers.ts +20 -20
- package/src/util/color/rgbToHsl.ts +35 -35
- package/src/util/getActiveElement.ts +4 -4
- package/src/util/innerTextTrim.ts +10 -10
- package/src/util/isDataRecord.ts +5 -5
- package/src/util/test/createTestRenderer.tsx +9 -2
- package/src/widgets/AccessorBindings.spec.tsx +4 -4
- package/src/widgets/HtmlElement.spec.tsx +6 -6
- package/src/widgets/ReactElementWrapper.spec.tsx +37 -37
- package/src/widgets/Sandbox.ts +103 -103
- package/src/widgets/form/ValidationGroup.spec.tsx +12 -12
- package/src/widgets/grid/GridCell.ts +143 -143
- package/src/widgets/icons/calendar.tsx +22 -17
- package/src/widgets/icons/check.tsx +14 -13
- package/src/widgets/icons/clear.tsx +16 -15
- package/src/widgets/icons/close.tsx +20 -20
- package/src/widgets/icons/cx.tsx +39 -38
- package/src/widgets/icons/drop-down.tsx +16 -15
- package/src/widgets/icons/file.tsx +14 -13
- package/src/widgets/icons/folder-open.tsx +16 -15
- package/src/widgets/icons/folder.tsx +14 -13
- package/src/widgets/icons/forward.tsx +23 -22
- package/src/widgets/icons/loading.tsx +25 -24
- package/src/widgets/icons/menu.tsx +18 -17
- package/src/widgets/icons/pixel-picker.tsx +18 -18
- package/src/widgets/icons/search.tsx +14 -13
- package/src/widgets/icons/sort-asc.tsx +15 -14
- package/src/widgets/icons/square.tsx +19 -18
- package/src/widgets/nav/Route.spec.tsx +2 -2
- package/src/widgets/nav/Route.ts +142 -142
- package/src/widgets/overlay/Dropdown.tsx +762 -762
- package/src/widgets/overlay/MsgBox.tsx +141 -141
- package/src/widgets/overlay/Toast.ts +111 -111
- package/src/widgets/overlay/Window.tsx +299 -299
- package/src/widgets/overlay/alerts.ts +46 -46
- package/src/widgets/overlay/index.ts +11 -11
package/src/widgets/nav/Route.ts
CHANGED
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
import { Widget } from "../../ui/Widget";
|
|
2
|
-
import { PureContainerBase, PureContainerConfig } from "../../ui/PureContainer";
|
|
3
|
-
import RouteMatcher from "route-parser";
|
|
4
|
-
import { ReadOnlyDataView } from "../../data/ReadOnlyDataView";
|
|
5
|
-
import { routeAppend } from "../../util/routeAppend";
|
|
6
|
-
import { StringProp, BooleanProp, Prop } from "../../ui/Prop";
|
|
7
|
-
import { RenderingContext } from "../../ui/RenderingContext";
|
|
8
|
-
import { Instance } from "../../ui/Instance";
|
|
9
|
-
|
|
10
|
-
export interface RouteConfig extends PureContainerConfig {
|
|
11
|
-
/** Url binding. Bind this to the global `url` variable. */
|
|
12
|
-
url?: StringProp;
|
|
13
|
-
|
|
14
|
-
/** Target route, e.g. `~/user/:userId`. All routes should start with `~/`. */
|
|
15
|
-
route?: string;
|
|
16
|
-
|
|
17
|
-
/** Target route, e.g. `~/user/:userId`. All routes should start with `~/`. */
|
|
18
|
-
path?: string;
|
|
19
|
-
|
|
20
|
-
/** Name used to expose local data. Defaults to `$route`. */
|
|
21
|
-
recordName?: string;
|
|
22
|
-
|
|
23
|
-
/** Match route even if given `route` is only a prefix of the current `url`. */
|
|
24
|
-
prefix?: BooleanProp;
|
|
25
|
-
|
|
26
|
-
/** Parameters mapping */
|
|
27
|
-
params?: Prop<any>;
|
|
28
|
-
|
|
29
|
-
/** Parameter name mapping */
|
|
30
|
-
map?: Record<string, string>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Base class for extending with custom Config types
|
|
34
|
-
export class RouteBase<Config extends RouteConfig = RouteConfig> extends PureContainerBase<Config> {
|
|
35
|
-
declare url?: string;
|
|
36
|
-
declare route: string;
|
|
37
|
-
declare path?: string;
|
|
38
|
-
declare prefix?: boolean;
|
|
39
|
-
declare recordName: string;
|
|
40
|
-
declare params?: Prop<any>;
|
|
41
|
-
declare map?: Record<string, string>;
|
|
42
|
-
declare matcher?: any;
|
|
43
|
-
init() {
|
|
44
|
-
if (this.path) this.route = this.path;
|
|
45
|
-
|
|
46
|
-
super.init();
|
|
47
|
-
|
|
48
|
-
if (this.route && this.route[0] !== "+")
|
|
49
|
-
this.matcher = new RouteMatcher(this.route + (this.prefix ? "(*remainder)" : ""));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
initInstance(context: RenderingContext, instance: Instance) {
|
|
53
|
-
instance.store = new ReadOnlyDataView({
|
|
54
|
-
store: instance.parentStore,
|
|
55
|
-
});
|
|
56
|
-
super.initInstance(context, instance);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
applyParentStore(instance: Instance) {
|
|
60
|
-
instance.store.setStore(instance.parentStore);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
declareData(...args: any[]): void {
|
|
64
|
-
super.declareData(...args, {
|
|
65
|
-
url: undefined,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
checkVisible(context: RenderingContext, instance: Instance, data: any) {
|
|
70
|
-
if (!data.visible) return false;
|
|
71
|
-
|
|
72
|
-
if (data.url !== instance.cached.url) {
|
|
73
|
-
instance.cached.url = data.url;
|
|
74
|
-
let matcher = this.matcher;
|
|
75
|
-
let route = this.route;
|
|
76
|
-
if (this.route[0] === "+") {
|
|
77
|
-
route = routeAppend(context.lastRoute.route, this.route.substring(1));
|
|
78
|
-
if (!instance.cached.matcher || instance.cached.route !== route)
|
|
79
|
-
instance.cached.matcher = new RouteMatcher(route + (this.prefix ? "(*remainder)" : ""));
|
|
80
|
-
matcher = instance.cached.matcher;
|
|
81
|
-
}
|
|
82
|
-
instance.cached.result = matcher.match(data.url);
|
|
83
|
-
instance.cached.matcher = matcher;
|
|
84
|
-
instance.cached.route = data.route = route;
|
|
85
|
-
}
|
|
86
|
-
if (!instance.cached.result) return false;
|
|
87
|
-
|
|
88
|
-
return super.checkVisible(context, instance, data);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
prepareData(context: RenderingContext, instance: Instance) {
|
|
92
|
-
super.prepareData(context, instance);
|
|
93
|
-
|
|
94
|
-
const { store, cached } = instance;
|
|
95
|
-
|
|
96
|
-
(store as ReadOnlyDataView).setData({
|
|
97
|
-
[this.recordName]: cached.result,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
//TODO: Replace comparison with deepEquals
|
|
101
|
-
if (this.params && this.params.bind) {
|
|
102
|
-
var params = store.get(this.params.bind);
|
|
103
|
-
if (JSON.stringify(params) != JSON.stringify(cached.result)) {
|
|
104
|
-
store.set(this.params.bind, cached.result);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (this.map) {
|
|
109
|
-
for (var key in cached.result) {
|
|
110
|
-
var binding = this.map[key];
|
|
111
|
-
if (binding) store.set(binding, cached.result[key]);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
explore(context: RenderingContext, instance: Instance) {
|
|
117
|
-
context.push("lastRoute", {
|
|
118
|
-
route: instance.cached.route,
|
|
119
|
-
result: instance.cached.result,
|
|
120
|
-
reverse: function (data: any) {
|
|
121
|
-
return instance.cached.matcher.reverse({
|
|
122
|
-
...instance.cached.result,
|
|
123
|
-
remainder: "",
|
|
124
|
-
...data,
|
|
125
|
-
});
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
super.explore(context, instance);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
exploreCleanup(context: RenderingContext, instance: Instance) {
|
|
132
|
-
context.pop("lastRoute");
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
RouteBase.prototype.recordName = "$route";
|
|
137
|
-
RouteBase.prototype.prefix = false;
|
|
138
|
-
|
|
139
|
-
// Closed type for direct usage
|
|
140
|
-
export class Route extends RouteBase<RouteConfig> {}
|
|
141
|
-
|
|
142
|
-
Widget.alias("route", Route);
|
|
1
|
+
import { Widget } from "../../ui/Widget";
|
|
2
|
+
import { PureContainerBase, PureContainerConfig } from "../../ui/PureContainer";
|
|
3
|
+
import RouteMatcher from "route-parser";
|
|
4
|
+
import { ReadOnlyDataView } from "../../data/ReadOnlyDataView";
|
|
5
|
+
import { routeAppend } from "../../util/routeAppend";
|
|
6
|
+
import { StringProp, BooleanProp, Prop } from "../../ui/Prop";
|
|
7
|
+
import { RenderingContext } from "../../ui/RenderingContext";
|
|
8
|
+
import { Instance } from "../../ui/Instance";
|
|
9
|
+
|
|
10
|
+
export interface RouteConfig extends PureContainerConfig {
|
|
11
|
+
/** Url binding. Bind this to the global `url` variable. */
|
|
12
|
+
url?: StringProp;
|
|
13
|
+
|
|
14
|
+
/** Target route, e.g. `~/user/:userId`. All routes should start with `~/`. */
|
|
15
|
+
route?: string;
|
|
16
|
+
|
|
17
|
+
/** Target route, e.g. `~/user/:userId`. All routes should start with `~/`. */
|
|
18
|
+
path?: string;
|
|
19
|
+
|
|
20
|
+
/** Name used to expose local data. Defaults to `$route`. */
|
|
21
|
+
recordName?: string;
|
|
22
|
+
|
|
23
|
+
/** Match route even if given `route` is only a prefix of the current `url`. */
|
|
24
|
+
prefix?: BooleanProp;
|
|
25
|
+
|
|
26
|
+
/** Parameters mapping */
|
|
27
|
+
params?: Prop<any>;
|
|
28
|
+
|
|
29
|
+
/** Parameter name mapping */
|
|
30
|
+
map?: Record<string, string>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Base class for extending with custom Config types
|
|
34
|
+
export class RouteBase<Config extends RouteConfig = RouteConfig> extends PureContainerBase<Config> {
|
|
35
|
+
declare url?: string;
|
|
36
|
+
declare route: string;
|
|
37
|
+
declare path?: string;
|
|
38
|
+
declare prefix?: boolean;
|
|
39
|
+
declare recordName: string;
|
|
40
|
+
declare params?: Prop<any>;
|
|
41
|
+
declare map?: Record<string, string>;
|
|
42
|
+
declare matcher?: any;
|
|
43
|
+
init() {
|
|
44
|
+
if (this.path) this.route = this.path;
|
|
45
|
+
|
|
46
|
+
super.init();
|
|
47
|
+
|
|
48
|
+
if (this.route && this.route[0] !== "+")
|
|
49
|
+
this.matcher = new RouteMatcher(this.route + (this.prefix ? "(*remainder)" : ""));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
initInstance(context: RenderingContext, instance: Instance) {
|
|
53
|
+
instance.store = new ReadOnlyDataView({
|
|
54
|
+
store: instance.parentStore,
|
|
55
|
+
});
|
|
56
|
+
super.initInstance(context, instance);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
applyParentStore(instance: Instance) {
|
|
60
|
+
instance.store.setStore(instance.parentStore);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declareData(...args: any[]): void {
|
|
64
|
+
super.declareData(...args, {
|
|
65
|
+
url: undefined,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
checkVisible(context: RenderingContext, instance: Instance, data: any) {
|
|
70
|
+
if (!data.visible) return false;
|
|
71
|
+
|
|
72
|
+
if (data.url !== instance.cached.url) {
|
|
73
|
+
instance.cached.url = data.url;
|
|
74
|
+
let matcher = this.matcher;
|
|
75
|
+
let route = this.route;
|
|
76
|
+
if (this.route[0] === "+") {
|
|
77
|
+
route = routeAppend(context.lastRoute.route, this.route.substring(1));
|
|
78
|
+
if (!instance.cached.matcher || instance.cached.route !== route)
|
|
79
|
+
instance.cached.matcher = new RouteMatcher(route + (this.prefix ? "(*remainder)" : ""));
|
|
80
|
+
matcher = instance.cached.matcher;
|
|
81
|
+
}
|
|
82
|
+
instance.cached.result = matcher.match(data.url);
|
|
83
|
+
instance.cached.matcher = matcher;
|
|
84
|
+
instance.cached.route = data.route = route;
|
|
85
|
+
}
|
|
86
|
+
if (!instance.cached.result) return false;
|
|
87
|
+
|
|
88
|
+
return super.checkVisible(context, instance, data);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
prepareData(context: RenderingContext, instance: Instance) {
|
|
92
|
+
super.prepareData(context, instance);
|
|
93
|
+
|
|
94
|
+
const { store, cached } = instance;
|
|
95
|
+
|
|
96
|
+
(store as ReadOnlyDataView).setData({
|
|
97
|
+
[this.recordName]: cached.result,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
//TODO: Replace comparison with deepEquals
|
|
101
|
+
if (this.params && this.params.bind) {
|
|
102
|
+
var params = store.get(this.params.bind);
|
|
103
|
+
if (JSON.stringify(params) != JSON.stringify(cached.result)) {
|
|
104
|
+
store.set(this.params.bind, cached.result);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (this.map) {
|
|
109
|
+
for (var key in cached.result) {
|
|
110
|
+
var binding = this.map[key];
|
|
111
|
+
if (binding) store.set(binding, cached.result[key]);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
explore(context: RenderingContext, instance: Instance) {
|
|
117
|
+
context.push("lastRoute", {
|
|
118
|
+
route: instance.cached.route,
|
|
119
|
+
result: instance.cached.result,
|
|
120
|
+
reverse: function (data: any) {
|
|
121
|
+
return instance.cached.matcher.reverse({
|
|
122
|
+
...instance.cached.result,
|
|
123
|
+
remainder: "",
|
|
124
|
+
...data,
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
super.explore(context, instance);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
exploreCleanup(context: RenderingContext, instance: Instance) {
|
|
132
|
+
context.pop("lastRoute");
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
RouteBase.prototype.recordName = "$route";
|
|
137
|
+
RouteBase.prototype.prefix = false;
|
|
138
|
+
|
|
139
|
+
// Closed type for direct usage
|
|
140
|
+
export class Route extends RouteBase<RouteConfig> {}
|
|
141
|
+
|
|
142
|
+
Widget.alias("route", Route);
|