cx 25.1.1 → 25.2.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.
- package/dist/data.js +3 -3
- package/dist/manifest.js +730 -730
- package/dist/widgets.js +3 -2
- package/package.json +1 -1
- package/src/data/StringTemplate.js +1 -1
- package/src/data/StringTemplate.spec.js +6 -1
- package/src/data/StructuredSelector.js +132 -131
- package/src/data/getSelector.js +49 -48
- package/src/widgets/form/MonthPicker.js +3 -2
- package/src/widgets/grid/Grid.scss +638 -637
package/dist/widgets.js
CHANGED
|
@@ -10805,8 +10805,9 @@ var MonthPicker = /*#__PURE__*/ (function (_Field) {
|
|
|
10805
10805
|
if (this.range) {
|
|
10806
10806
|
if (data.from) data.from = monthStart(parseDateInvariant(data.from));
|
|
10807
10807
|
if (data.to) {
|
|
10808
|
-
|
|
10809
|
-
if (this.inclusiveTo)
|
|
10808
|
+
var date = parseDateInvariant(data.to);
|
|
10809
|
+
if (this.inclusiveTo) date.setDate(date.getDate() + 1);
|
|
10810
|
+
data.to = monthStart(date);
|
|
10810
10811
|
}
|
|
10811
10812
|
}
|
|
10812
10813
|
if (data.refDate) data.refDate = monthStart(parseDateInvariant(data.refDate));
|
package/package.json
CHANGED
|
@@ -60,7 +60,7 @@ export function stringTemplate(str) {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
if (quoteStart < str.length) expr = plus(expr) + quoteStr(str.substring(quoteStart));
|
|
63
|
+
if (quoteStart < str.length || expr.length == 0) expr = plus(expr) + quoteStr(str.substring(quoteStart));
|
|
64
64
|
|
|
65
65
|
return (tplCache[str] = expression(expr));
|
|
66
66
|
}
|
|
@@ -13,6 +13,11 @@ describe("StringTemplate", function () {
|
|
|
13
13
|
assert.equal(e(state), "Hello Jim");
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
+
it("allows empty strings", function () {
|
|
17
|
+
let e = StringTemplate.compile("");
|
|
18
|
+
assert.equal(e(), "");
|
|
19
|
+
});
|
|
20
|
+
|
|
16
21
|
it("properly encodes ' and \"", function () {
|
|
17
22
|
var e = StringTemplate.compile('It\'s "working"!');
|
|
18
23
|
assert.equal(e({}), 'It\'s "working"!');
|
|
@@ -87,7 +92,7 @@ describe("StringTemplate", function () {
|
|
|
87
92
|
assert.equal(e(), "a\\b");
|
|
88
93
|
});
|
|
89
94
|
|
|
90
|
-
it
|
|
95
|
+
it("before a special character", function () {
|
|
91
96
|
var e = StringTemplate.compile("\\t");
|
|
92
97
|
assert.equal(e(), "\\t");
|
|
93
98
|
});
|
|
@@ -1,131 +1,132 @@
|
|
|
1
|
-
import { Binding } from "./Binding";
|
|
2
|
-
import { Expression } from "./Expression";
|
|
3
|
-
import { StringTemplate } from "./StringTemplate";
|
|
4
|
-
import { createStructuredSelector } from "../data/createStructuredSelector";
|
|
5
|
-
import { getSelector } from "../data/getSelector";
|
|
6
|
-
import { isFunction } from "../util/isFunction";
|
|
7
|
-
import { isUndefined } from "../util/isUndefined";
|
|
8
|
-
import { isDefined } from "../util/isDefined";
|
|
9
|
-
import { isArray } from "../util/isArray";
|
|
10
|
-
import { isAccessorChain } from "./createAccessorModelProxy";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
constants
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
constants
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
this.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return selector;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
1
|
+
import { Binding } from "./Binding";
|
|
2
|
+
import { Expression } from "./Expression";
|
|
3
|
+
import { StringTemplate } from "./StringTemplate";
|
|
4
|
+
import { createStructuredSelector } from "../data/createStructuredSelector";
|
|
5
|
+
import { getSelector } from "../data/getSelector";
|
|
6
|
+
import { isFunction } from "../util/isFunction";
|
|
7
|
+
import { isUndefined } from "../util/isUndefined";
|
|
8
|
+
import { isDefined } from "../util/isDefined";
|
|
9
|
+
import { isArray } from "../util/isArray";
|
|
10
|
+
import { isAccessorChain } from "./createAccessorModelProxy";
|
|
11
|
+
import { isString } from "../util/isString";
|
|
12
|
+
|
|
13
|
+
function defaultValue(pv) {
|
|
14
|
+
if (typeof pv == "object" && pv && pv.structured) return pv.defaultValue;
|
|
15
|
+
|
|
16
|
+
return pv;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getSelectorConfig(props, values, nameMap) {
|
|
20
|
+
let functions = {},
|
|
21
|
+
structures = {},
|
|
22
|
+
defaultValues = {},
|
|
23
|
+
constants,
|
|
24
|
+
p,
|
|
25
|
+
v,
|
|
26
|
+
pv,
|
|
27
|
+
constant = true;
|
|
28
|
+
|
|
29
|
+
for (p in props) {
|
|
30
|
+
v = values[p];
|
|
31
|
+
pv = props[p];
|
|
32
|
+
|
|
33
|
+
if (isUndefined(v) && pv && (pv.bind || pv.tpl || pv.expr)) v = pv;
|
|
34
|
+
|
|
35
|
+
if (v === null) {
|
|
36
|
+
if (!constants) constants = {};
|
|
37
|
+
constants[p] = null;
|
|
38
|
+
} else if (typeof v == "object") {
|
|
39
|
+
if (v.bind) {
|
|
40
|
+
if (isUndefined(v.defaultValue) && v != pv) v.defaultValue = defaultValue(pv);
|
|
41
|
+
if (isDefined(v.defaultValue)) defaultValues[v.bind] = v.defaultValue;
|
|
42
|
+
nameMap[p] = v.bind;
|
|
43
|
+
functions[p] = Binding.get(v.bind).value;
|
|
44
|
+
constant = false;
|
|
45
|
+
} else if (v.expr) {
|
|
46
|
+
functions[p] = Expression.get(v.expr);
|
|
47
|
+
constant = false;
|
|
48
|
+
} else if (v.get) {
|
|
49
|
+
functions[p] = v.get;
|
|
50
|
+
constant = false;
|
|
51
|
+
} else if (isString(v.tpl)) {
|
|
52
|
+
functions[p] = StringTemplate.get(v.tpl);
|
|
53
|
+
constant = false;
|
|
54
|
+
} else if (pv && typeof pv == "object" && pv.structured) {
|
|
55
|
+
if (isArray(v)) functions[p] = getSelector(v);
|
|
56
|
+
else {
|
|
57
|
+
let s = getSelectorConfig(v, v, {});
|
|
58
|
+
structures[p] = s;
|
|
59
|
+
Object.assign(defaultValues, s.defaultValues);
|
|
60
|
+
}
|
|
61
|
+
constant = false;
|
|
62
|
+
} else {
|
|
63
|
+
if (!constants) constants = {};
|
|
64
|
+
constants[p] = v;
|
|
65
|
+
}
|
|
66
|
+
} else if (isFunction(v)) {
|
|
67
|
+
if (isAccessorChain(v)) {
|
|
68
|
+
let path = v.toString();
|
|
69
|
+
nameMap[p] = path;
|
|
70
|
+
functions[p] = Binding.get(path).value;
|
|
71
|
+
} else functions[p] = v;
|
|
72
|
+
constant = false;
|
|
73
|
+
} else {
|
|
74
|
+
if (isUndefined(v)) {
|
|
75
|
+
if (isUndefined(pv)) continue;
|
|
76
|
+
v = defaultValue(pv);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (isUndefined(v)) continue;
|
|
80
|
+
|
|
81
|
+
if (!constants) constants = {};
|
|
82
|
+
|
|
83
|
+
constants[p] = v;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
functions,
|
|
89
|
+
structures,
|
|
90
|
+
defaultValues,
|
|
91
|
+
constants,
|
|
92
|
+
constant,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function createSelector({ functions, structures, constants, defaultValues }) {
|
|
97
|
+
let selector = {};
|
|
98
|
+
|
|
99
|
+
for (let n in functions) {
|
|
100
|
+
selector[n] = functions[n];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
for (let n in structures) selector[n] = createSelector(structures[n]);
|
|
104
|
+
|
|
105
|
+
return createStructuredSelector(selector, constants);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export class StructuredSelector {
|
|
109
|
+
constructor({ props, values }) {
|
|
110
|
+
this.nameMap = {};
|
|
111
|
+
this.config = getSelectorConfig(props, values, this.nameMap);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
init(store) {
|
|
115
|
+
store.init(this.config.defaultValues);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
create(memoize = true) {
|
|
119
|
+
let selector = createSelector(this.config);
|
|
120
|
+
if (memoize && selector.memoize) return selector.memoize();
|
|
121
|
+
return selector;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
createStoreSelector() {
|
|
125
|
+
if (this.config.constant) {
|
|
126
|
+
let result = { ...this.config.constants };
|
|
127
|
+
return () => result;
|
|
128
|
+
}
|
|
129
|
+
let selector = this.create();
|
|
130
|
+
return (store) => selector(store.getData());
|
|
131
|
+
}
|
|
132
|
+
}
|
package/src/data/getSelector.js
CHANGED
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
import { Binding } from "./Binding";
|
|
2
|
-
import { Expression } from "./Expression";
|
|
3
|
-
import { StringTemplate } from "./StringTemplate";
|
|
4
|
-
import { isArray } from "../util/isArray";
|
|
5
|
-
import { createStructuredSelector } from "./createStructuredSelector";
|
|
6
|
-
import { isSelector } from "./isSelector";
|
|
7
|
-
import { isAccessorChain } from "./createAccessorModelProxy";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (config ===
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return config;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
1
|
+
import { Binding } from "./Binding";
|
|
2
|
+
import { Expression } from "./Expression";
|
|
3
|
+
import { StringTemplate } from "./StringTemplate";
|
|
4
|
+
import { isArray } from "../util/isArray";
|
|
5
|
+
import { createStructuredSelector } from "./createStructuredSelector";
|
|
6
|
+
import { isSelector } from "./isSelector";
|
|
7
|
+
import { isAccessorChain } from "./createAccessorModelProxy";
|
|
8
|
+
import { isString } from "../util/isString";
|
|
9
|
+
|
|
10
|
+
var undefinedF = () => undefined;
|
|
11
|
+
var nullF = () => null;
|
|
12
|
+
|
|
13
|
+
export function getSelector(config) {
|
|
14
|
+
if (config === undefined) return undefinedF;
|
|
15
|
+
if (config === null) return nullF;
|
|
16
|
+
|
|
17
|
+
switch (typeof config) {
|
|
18
|
+
case "object":
|
|
19
|
+
if (isArray(config)) {
|
|
20
|
+
let selectors = config.map((x) => getSelector(x));
|
|
21
|
+
return (data) => selectors.map((elementSelector) => elementSelector(data));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//toString converts accessor chains to binding paths
|
|
25
|
+
if (config.bind) return Binding.get(config.bind.toString()).value;
|
|
26
|
+
|
|
27
|
+
if (isString(config.tpl)) return StringTemplate.get(config.tpl);
|
|
28
|
+
|
|
29
|
+
if (config.expr) return Expression.get(config.expr);
|
|
30
|
+
|
|
31
|
+
if (config.get) return config.get;
|
|
32
|
+
|
|
33
|
+
let selectors = {};
|
|
34
|
+
let constants = {};
|
|
35
|
+
|
|
36
|
+
for (let key in config) {
|
|
37
|
+
if (isSelector(config[key])) selectors[key] = getSelector(config[key]);
|
|
38
|
+
else constants[key] = config[key];
|
|
39
|
+
}
|
|
40
|
+
return createStructuredSelector(selectors, constants);
|
|
41
|
+
|
|
42
|
+
case "function":
|
|
43
|
+
if (isAccessorChain(config)) return Binding.get(config.toString()).value;
|
|
44
|
+
return config;
|
|
45
|
+
|
|
46
|
+
default:
|
|
47
|
+
return () => config;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -79,8 +79,9 @@ export class MonthPicker extends Field {
|
|
|
79
79
|
if (data.from) data.from = monthStart(parseDateInvariant(data.from));
|
|
80
80
|
|
|
81
81
|
if (data.to) {
|
|
82
|
-
|
|
83
|
-
if (this.inclusiveTo)
|
|
82
|
+
let date = parseDateInvariant(data.to);
|
|
83
|
+
if (this.inclusiveTo) date.setDate(date.getDate() + 1);
|
|
84
|
+
data.to = monthStart(date);
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
|