cx 24.6.3 → 24.6.5

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 (38) hide show
  1. package/dist/charts.js +27 -29
  2. package/dist/data.js +26 -29
  3. package/dist/manifest.js +748 -742
  4. package/dist/svg.js +59 -56
  5. package/dist/ui.js +51 -52
  6. package/dist/util.js +56 -10
  7. package/dist/widgets.js +69 -69
  8. package/package.json +1 -1
  9. package/src/charts/Legend.js +151 -151
  10. package/src/charts/Marker.d.ts +96 -96
  11. package/src/charts/Marker.js +299 -299
  12. package/src/charts/axis/Axis.d.ts +96 -96
  13. package/src/charts/axis/NumericAxis.js +347 -347
  14. package/src/charts/axis/Stack.js +55 -55
  15. package/src/charts/axis/TimeAxis.js +7 -6
  16. package/src/data/Binding.spec.js +69 -69
  17. package/src/data/StringTemplate.spec.js +105 -105
  18. package/src/data/getAccessor.spec.js +11 -11
  19. package/src/ui/Controller.d.ts +182 -182
  20. package/src/ui/FocusManager.js +171 -171
  21. package/src/ui/Format.js +3 -3
  22. package/src/ui/Instance.d.ts +72 -72
  23. package/src/ui/index.d.ts +42 -42
  24. package/src/util/Format.js +6 -5
  25. package/src/util/date/index.d.ts +10 -9
  26. package/src/util/date/index.js +10 -9
  27. package/src/util/date/parseDateInvariant.d.ts +3 -0
  28. package/src/util/date/parseDateInvariant.js +20 -0
  29. package/src/widgets/drag-drop/DropZone.js +214 -214
  30. package/src/widgets/form/Calendar.js +7 -6
  31. package/src/widgets/form/DateTimeField.js +8 -5
  32. package/src/widgets/form/DateTimePicker.js +9 -8
  33. package/src/widgets/form/MonthField.js +8 -8
  34. package/src/widgets/form/MonthPicker.js +17 -16
  35. package/src/widgets/form/TextField.js +1 -0
  36. package/src/widgets/form/UploadButton.d.ts +34 -34
  37. package/src/widgets/grid/variables.scss +88 -88
  38. package/src/widgets/overlay/Dropdown.js +612 -612
@@ -1,55 +1,55 @@
1
- export class Stack {
2
- constructor() {
3
- this.reset();
4
- }
5
-
6
- reset() {
7
- this.stacks = {};
8
- this.values = {};
9
- this.normalized = false;
10
- this.invalid = {};
11
- }
12
-
13
- acknowledge(ordinal, value) {
14
- if (value != null) {
15
- let s = this.stacks[ordinal];
16
- if (!s) this.stacks[ordinal] = s = { total: 0, min: 0, max: 0 };
17
- s.total += value;
18
- if (s.total < s.min) s.min = s.total;
19
- if (s.total > s.max) s.max = s.total;
20
- } else {
21
- this.invalid[ordinal] = true;
22
- }
23
- }
24
-
25
- measure(normalized) {
26
- if (normalized) {
27
- this.normalized = true;
28
- return [0, 1];
29
- }
30
-
31
- let max = 0,
32
- min = 0;
33
- for (let key in this.stacks) {
34
- if (this.stacks[key].max > max) max = this.stacks[key].max;
35
- if (this.stacks[key].min < min) min = this.stacks[key].min;
36
- }
37
- return [min, max];
38
- }
39
-
40
- stack(ordinal, value) {
41
- if (value == null || this.invalid[ordinal]) return null;
42
-
43
- let base = this.values[ordinal] || 0;
44
-
45
- let result = (this.values[ordinal] = base + value);
46
-
47
- if (!this.normalized) return result;
48
-
49
- let total = this.stacks[ordinal].total;
50
-
51
- if (total > 0) return result / total;
52
-
53
- return null;
54
- }
55
- }
1
+ export class Stack {
2
+ constructor() {
3
+ this.reset();
4
+ }
5
+
6
+ reset() {
7
+ this.stacks = {};
8
+ this.values = {};
9
+ this.normalized = false;
10
+ this.invalid = {};
11
+ }
12
+
13
+ acknowledge(ordinal, value) {
14
+ if (value != null) {
15
+ let s = this.stacks[ordinal];
16
+ if (!s) this.stacks[ordinal] = s = { total: 0, min: 0, max: 0 };
17
+ s.total += value;
18
+ if (s.total < s.min) s.min = s.total;
19
+ if (s.total > s.max) s.max = s.total;
20
+ } else {
21
+ this.invalid[ordinal] = true;
22
+ }
23
+ }
24
+
25
+ measure(normalized) {
26
+ if (normalized) {
27
+ this.normalized = true;
28
+ return [0, 1];
29
+ }
30
+
31
+ let max = 0,
32
+ min = 0;
33
+ for (let key in this.stacks) {
34
+ if (this.stacks[key].max > max) max = this.stacks[key].max;
35
+ if (this.stacks[key].min < min) min = this.stacks[key].min;
36
+ }
37
+ return [min, max];
38
+ }
39
+
40
+ stack(ordinal, value) {
41
+ if (value == null || this.invalid[ordinal]) return null;
42
+
43
+ let base = this.values[ordinal] || 0;
44
+
45
+ let result = (this.values[ordinal] = base + value);
46
+
47
+ if (!this.normalized) return result;
48
+
49
+ let total = this.stacks[ordinal].total;
50
+
51
+ if (total > 0) return result / total;
52
+
53
+ return null;
54
+ }
55
+ }
@@ -4,12 +4,13 @@ import { Stack } from "./Stack";
4
4
  import { Format } from "../../ui/Format";
5
5
  import { isNumber } from "../../util/isNumber";
6
6
  import { zeroTime } from "../../util/date/zeroTime";
7
+ import { parseDateInvariant } from "../../util";
7
8
 
8
9
  Format.registerFactory("yearOrMonth", (format) => {
9
10
  let year = Format.parse("datetime;yyyy");
10
11
  let month = Format.parse("datetime;MMM");
11
12
  return function (date) {
12
- let d = new Date(date);
13
+ let d = parseDateInvariant(date);
13
14
  if (d.getMonth() == 0) return year(d);
14
15
  else return month(d);
15
16
  };
@@ -19,7 +20,7 @@ Format.registerFactory("monthOrDay", (format) => {
19
20
  let month = Format.parse("datetime;MMM");
20
21
  let day = Format.parse("datetime;dd");
21
22
  return function (date) {
22
- let d = new Date(date);
23
+ let d = parseDateInvariant(date);
23
24
  if (d.getDate() == 1) return month(d);
24
25
  else return day(d);
25
26
  };
@@ -69,7 +70,7 @@ export class TimeAxis extends Axis {
69
70
  this.minTickUnit,
70
71
  lowerDeadZone,
71
72
  upperDeadZone,
72
- this.decode
73
+ this.decode,
73
74
  );
74
75
  }
75
76
 
@@ -149,7 +150,7 @@ class TimeScale {
149
150
  minTickUnit,
150
151
  lowerDeadZone,
151
152
  upperDeadZone,
152
- decode
153
+ decode,
153
154
  ) {
154
155
  this.dateCache = {};
155
156
  this.min = min != null ? this.decodeValue(min) : null;
@@ -180,12 +181,12 @@ class TimeScale {
180
181
  let v = this.dateCache[date];
181
182
  if (!v) {
182
183
  if (this.decode) date = this.decode(date);
183
- v = this.dateCache[date] = Date.parse(date);
184
+ v = this.dateCache[date] = parseDateInvariant(date).getTime();
184
185
  }
185
186
  return v;
186
187
 
187
188
  case "number":
188
- return date;
189
+ return parseDateInvariant(date).getTime();
189
190
  }
190
191
  }
191
192
 
@@ -1,69 +1,69 @@
1
- import { Binding } from "./Binding";
2
- import assert from "assert";
3
- import { createAccessorModelProxy } from "./createAccessorModelProxy";
4
-
5
- describe("Binding", function () {
6
- describe("#get()", function () {
7
- it("should get value if value is defined", function () {
8
- var state = { person: { name: "Joe" } };
9
- var b = Binding.get("person.name");
10
- assert.equal(b.value(state), "Joe");
11
- });
12
-
13
- it("allows non-standard property identifiers", function () {
14
- var state = { person: { "@schema": "Person" } };
15
- var b = Binding.get("person.@schema");
16
- assert.equal(b.path, "person.@schema");
17
- assert.equal(b.value(state), "Person");
18
- });
19
-
20
- it("properly resolves accessor models", function () {
21
- var state = { person: { schema: "Person" } };
22
- var b = Binding.get(createAccessorModelProxy("person.schema"));
23
- assert.equal(b.value(state), "Person");
24
- });
25
- });
26
-
27
- describe("#set()", function () {
28
- it("produces new objects along the binding path", function () {
29
- var state = { person: { name: "Joe" } };
30
- var b = Binding.get("person.name");
31
- var ns = b.set(state, "Jack");
32
- assert.equal(ns.person.name, "Jack");
33
- assert.notEqual(state, ns);
34
- assert.notEqual(state.person, ns.person);
35
- assert.notEqual(state.person.name, ns.person.name);
36
- });
37
-
38
- it("returns same state object if value does not change", function () {
39
- var state = { person: { name: "Joe" } };
40
- var b = Binding.get("person.name");
41
- var ns = b.set(state, "Joe");
42
- assert.equal(state, ns);
43
- });
44
-
45
- it("allows non-standard property identifiers", function () {
46
- var state = { person: { "@schema": "Person" } };
47
- var b = Binding.get("person.@schema");
48
- var ns = b.set(state, "Test");
49
- assert.equal(ns.person["@schema"], "Test");
50
- });
51
- });
52
-
53
- describe(".delete()", function () {
54
- it("correctly removes pointed properties", function () {
55
- var state = { person: { name: "Joe" } };
56
- var b = Binding.get("person.name");
57
- var ns = b.delete(state);
58
- assert("person" in ns);
59
- assert(!("name" in ns.person));
60
- });
61
-
62
- it("does not change state if property is non-existent", function () {
63
- var state = { person: { name: "Joe" } };
64
- var b = Binding.get("person.name2");
65
- var ns = b.delete(state);
66
- assert(ns == state);
67
- });
68
- });
69
- });
1
+ import { Binding } from "./Binding";
2
+ import assert from "assert";
3
+ import { createAccessorModelProxy } from "./createAccessorModelProxy";
4
+
5
+ describe("Binding", function () {
6
+ describe("#get()", function () {
7
+ it("should get value if value is defined", function () {
8
+ var state = { person: { name: "Joe" } };
9
+ var b = Binding.get("person.name");
10
+ assert.equal(b.value(state), "Joe");
11
+ });
12
+
13
+ it("allows non-standard property identifiers", function () {
14
+ var state = { person: { "@schema": "Person" } };
15
+ var b = Binding.get("person.@schema");
16
+ assert.equal(b.path, "person.@schema");
17
+ assert.equal(b.value(state), "Person");
18
+ });
19
+
20
+ it("properly resolves accessor models", function () {
21
+ var state = { person: { schema: "Person" } };
22
+ var b = Binding.get(createAccessorModelProxy("person.schema"));
23
+ assert.equal(b.value(state), "Person");
24
+ });
25
+ });
26
+
27
+ describe("#set()", function () {
28
+ it("produces new objects along the binding path", function () {
29
+ var state = { person: { name: "Joe" } };
30
+ var b = Binding.get("person.name");
31
+ var ns = b.set(state, "Jack");
32
+ assert.equal(ns.person.name, "Jack");
33
+ assert.notEqual(state, ns);
34
+ assert.notEqual(state.person, ns.person);
35
+ assert.notEqual(state.person.name, ns.person.name);
36
+ });
37
+
38
+ it("returns same state object if value does not change", function () {
39
+ var state = { person: { name: "Joe" } };
40
+ var b = Binding.get("person.name");
41
+ var ns = b.set(state, "Joe");
42
+ assert.equal(state, ns);
43
+ });
44
+
45
+ it("allows non-standard property identifiers", function () {
46
+ var state = { person: { "@schema": "Person" } };
47
+ var b = Binding.get("person.@schema");
48
+ var ns = b.set(state, "Test");
49
+ assert.equal(ns.person["@schema"], "Test");
50
+ });
51
+ });
52
+
53
+ describe(".delete()", function () {
54
+ it("correctly removes pointed properties", function () {
55
+ var state = { person: { name: "Joe" } };
56
+ var b = Binding.get("person.name");
57
+ var ns = b.delete(state);
58
+ assert("person" in ns);
59
+ assert(!("name" in ns.person));
60
+ });
61
+
62
+ it("does not change state if property is non-existent", function () {
63
+ var state = { person: { name: "Joe" } };
64
+ var b = Binding.get("person.name2");
65
+ var ns = b.delete(state);
66
+ assert(ns == state);
67
+ });
68
+ });
69
+ });
@@ -1,105 +1,105 @@
1
- import { StringTemplate } from "./StringTemplate";
2
- import assert from "assert";
3
-
4
- describe("StringTemplate", function () {
5
- describe("#compile()", function () {
6
- it("returns a selector", function () {
7
- var e = StringTemplate.compile("Hello {person.name}");
8
- var state = {
9
- person: {
10
- name: "Jim",
11
- },
12
- };
13
- assert.equal(e(state), "Hello Jim");
14
- });
15
-
16
- it("properly encodes ' and \"", function () {
17
- var e = StringTemplate.compile('It\'s "working"!');
18
- assert.equal(e({}), 'It\'s "working"!');
19
- });
20
-
21
- it("supports multi-line strings", function () {
22
- var e = StringTemplate.compile("a\nb");
23
- assert.equal(e(), "a\nb");
24
-
25
- var e = StringTemplate.compile("a\r\nb");
26
- assert.equal(e(), "a\r\nb");
27
- });
28
- });
29
-
30
- describe("double brackets are used to escape brackets", function () {
31
- it("double brackets are preserved", function () {
32
- var e = StringTemplate.compile("Hello {{person.name}}");
33
- var state = {
34
- person: {
35
- name: "Jim",
36
- },
37
- };
38
- assert.equal(e(state), "Hello {person.name}");
39
- });
40
-
41
- it("triple brackets are converted to single brackets and a binding", function () {
42
- var e = StringTemplate.compile("Hello {{{person.name}}}");
43
- var state = {
44
- person: {
45
- name: "Jim",
46
- },
47
- };
48
- assert.equal(e(state), "Hello {Jim}");
49
- });
50
- });
51
-
52
- describe("supports formatting", function () {
53
- it("with colon", function () {
54
- var e = StringTemplate.compile("{str:suffix;kg}");
55
- assert.equal(e({ str: "5" }), "5kg");
56
- });
57
-
58
- it("with multiple formats", function () {
59
- var e = StringTemplate.compile("{str:suffix;kg:wrap;(;)}");
60
- assert.equal(e({ str: "5" }), "(5kg)");
61
- });
62
-
63
- it("with null values", function () {
64
- var e = StringTemplate.compile("{str:suffix;kg:|N/A}");
65
- assert.equal(e({ str: null }), "N/A");
66
- });
67
-
68
- it("of null values", function () {
69
- var e = StringTemplate.compile("{str|N/A}");
70
- assert.equal(e({ str: null }), "N/A");
71
- });
72
- });
73
-
74
- describe("supports expressions", function () {
75
- it("using []", function () {
76
- var e = StringTemplate.compile("1 + 2 = {[1+2]}");
77
- assert.equal(e(), "1 + 2 = 3");
78
- });
79
-
80
- it("using %", function () {
81
- var e = StringTemplate.compile("1 + 2 = %{1+2}");
82
- assert.equal(e(), "1 + 2 = 3");
83
- });
84
-
85
- it("with subexpressions", function () {
86
- var e = StringTemplate.compile("1 + 2 = {[%{1+2}]}");
87
- assert.equal(e(), "1 + 2 = 3");
88
- });
89
-
90
- it("with a conditional operator", function () {
91
- var e = StringTemplate.compile("1 + 2 = {[true ? 3 : 2]:s}");
92
- assert.equal(e(), "1 + 2 = 3");
93
- });
94
-
95
- it("with sub-expression formatting", function () {
96
- var e = StringTemplate.compile("{[!!{person.age} ? {person.age:suffix; years old} : 'Age unknown']}");
97
- var state = {
98
- person: {
99
- age: 32,
100
- },
101
- };
102
- assert.equal(e(state), "32 years old");
103
- });
104
- });
105
- });
1
+ import { StringTemplate } from "./StringTemplate";
2
+ import assert from "assert";
3
+
4
+ describe("StringTemplate", function () {
5
+ describe("#compile()", function () {
6
+ it("returns a selector", function () {
7
+ var e = StringTemplate.compile("Hello {person.name}");
8
+ var state = {
9
+ person: {
10
+ name: "Jim",
11
+ },
12
+ };
13
+ assert.equal(e(state), "Hello Jim");
14
+ });
15
+
16
+ it("properly encodes ' and \"", function () {
17
+ var e = StringTemplate.compile('It\'s "working"!');
18
+ assert.equal(e({}), 'It\'s "working"!');
19
+ });
20
+
21
+ it("supports multi-line strings", function () {
22
+ var e = StringTemplate.compile("a\nb");
23
+ assert.equal(e(), "a\nb");
24
+
25
+ var e = StringTemplate.compile("a\r\nb");
26
+ assert.equal(e(), "a\r\nb");
27
+ });
28
+ });
29
+
30
+ describe("double brackets are used to escape brackets", function () {
31
+ it("double brackets are preserved", function () {
32
+ var e = StringTemplate.compile("Hello {{person.name}}");
33
+ var state = {
34
+ person: {
35
+ name: "Jim",
36
+ },
37
+ };
38
+ assert.equal(e(state), "Hello {person.name}");
39
+ });
40
+
41
+ it("triple brackets are converted to single brackets and a binding", function () {
42
+ var e = StringTemplate.compile("Hello {{{person.name}}}");
43
+ var state = {
44
+ person: {
45
+ name: "Jim",
46
+ },
47
+ };
48
+ assert.equal(e(state), "Hello {Jim}");
49
+ });
50
+ });
51
+
52
+ describe("supports formatting", function () {
53
+ it("with colon", function () {
54
+ var e = StringTemplate.compile("{str:suffix;kg}");
55
+ assert.equal(e({ str: "5" }), "5kg");
56
+ });
57
+
58
+ it("with multiple formats", function () {
59
+ var e = StringTemplate.compile("{str:suffix;kg:wrap;(;)}");
60
+ assert.equal(e({ str: "5" }), "(5kg)");
61
+ });
62
+
63
+ it("with null values", function () {
64
+ var e = StringTemplate.compile("{str:suffix;kg:|N/A}");
65
+ assert.equal(e({ str: null }), "N/A");
66
+ });
67
+
68
+ it("of null values", function () {
69
+ var e = StringTemplate.compile("{str|N/A}");
70
+ assert.equal(e({ str: null }), "N/A");
71
+ });
72
+ });
73
+
74
+ describe("supports expressions", function () {
75
+ it("using []", function () {
76
+ var e = StringTemplate.compile("1 + 2 = {[1+2]}");
77
+ assert.equal(e(), "1 + 2 = 3");
78
+ });
79
+
80
+ it("using %", function () {
81
+ var e = StringTemplate.compile("1 + 2 = %{1+2}");
82
+ assert.equal(e(), "1 + 2 = 3");
83
+ });
84
+
85
+ it("with subexpressions", function () {
86
+ var e = StringTemplate.compile("1 + 2 = {[%{1+2}]}");
87
+ assert.equal(e(), "1 + 2 = 3");
88
+ });
89
+
90
+ it("with a conditional operator", function () {
91
+ var e = StringTemplate.compile("1 + 2 = {[true ? 3 : 2]:s}");
92
+ assert.equal(e(), "1 + 2 = 3");
93
+ });
94
+
95
+ it("with sub-expression formatting", function () {
96
+ var e = StringTemplate.compile("{[!!{person.age} ? {person.age:suffix; years old} : 'Age unknown']}");
97
+ var state = {
98
+ person: {
99
+ age: 32,
100
+ },
101
+ };
102
+ assert.equal(e(state), "32 years old");
103
+ });
104
+ });
105
+ });
@@ -1,11 +1,11 @@
1
- import assert from "assert";
2
- import { createAccessorModelProxy } from "./createAccessorModelProxy";
3
- import { getAccessor } from "./getAccessor";
4
-
5
- describe("getAccessor", function () {
6
- it("works with accessor chains", function () {
7
- let m = createAccessorModelProxy();
8
- let accessor = getAccessor(m.a.b);
9
- assert(typeof accessor.set == "function");
10
- });
11
- });
1
+ import assert from "assert";
2
+ import { createAccessorModelProxy } from "./createAccessorModelProxy";
3
+ import { getAccessor } from "./getAccessor";
4
+
5
+ describe("getAccessor", function () {
6
+ it("works with accessor chains", function () {
7
+ let m = createAccessorModelProxy();
8
+ let accessor = getAccessor(m.a.b);
9
+ assert(typeof accessor.set == "function");
10
+ });
11
+ });