cx 23.12.1 → 23.12.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "23.12.1",
3
+ "version": "23.12.2",
4
4
  "description": "Advanced JavaScript UI framework for admin and dashboard applications with ready to use grid, form and chart components.",
5
5
  "main": "index.js",
6
6
  "jsnext:main": "src/index.js",
@@ -1,20 +1,20 @@
1
- interface Aggregator {
2
- process(value: number, weight?: number);
3
- getResult(): number;
4
- }
5
-
6
- export class AggregateFunction {
7
- static sum(): Aggregator;
8
-
9
- static avg(): Aggregator;
10
-
11
- static count(): Aggregator;
12
-
13
- static distinct(): Aggregator;
14
-
15
- static min(): Aggregator;
16
-
17
- static max(): Aggregator;
18
-
19
- static last(): Aggregator;
20
- }
1
+ interface Aggregator {
2
+ process(value: number, weight?: number);
3
+ getResult(): number;
4
+ }
5
+
6
+ export class AggregateFunction {
7
+ static sum(): Aggregator;
8
+
9
+ static avg(): Aggregator;
10
+
11
+ static count(): Aggregator;
12
+
13
+ static distinct(): Aggregator;
14
+
15
+ static min(): Aggregator;
16
+
17
+ static max(): Aggregator;
18
+
19
+ static last(): Aggregator;
20
+ }
@@ -1,145 +1,145 @@
1
- export class AggregateFunction {
2
- static sum() {
3
- return new Sum();
4
- }
5
-
6
- static avg() {
7
- return new Avg();
8
- }
9
-
10
- static count() {
11
- return new Count();
12
- }
13
-
14
- static distinct() {
15
- return new Distinct();
16
- }
17
-
18
- static min() {
19
- return new Min();
20
- }
21
-
22
- static max() {
23
- return new Max();
24
- }
25
-
26
- static last() {
27
- return new LastValue();
28
- }
29
- }
30
-
31
- class Sum {
32
- process(value) {
33
- this.empty = false;
34
- if (!isNaN(value)) this.result += value;
35
- else this.invalid = true;
36
- }
37
-
38
- getResult() {
39
- if (this.invalid) return null;
40
- return this.result;
41
- }
42
- }
43
-
44
- Sum.prototype.result = 0;
45
- Sum.prototype.empty = true;
46
-
47
- class Avg {
48
- process(value, count = 1) {
49
- this.empty = false;
50
- if (!isNaN(value) && !isNaN(count)) {
51
- this.result += value * count;
52
- this.count += count;
53
- } else this.invalid = true;
54
- }
55
-
56
- getResult() {
57
- if (this.empty || this.invalid || this.count == 0) return null;
58
- return this.result / this.count;
59
- }
60
- }
61
-
62
- Avg.prototype.result = 0;
63
- Avg.prototype.count = 0;
64
- Avg.prototype.empty = true;
65
-
66
- class Count {
67
- process(value) {
68
- if (value != null) this.result++;
69
- }
70
-
71
- getResult() {
72
- return this.result;
73
- }
74
- }
75
-
76
- Count.prototype.result = 0;
77
-
78
- class Distinct {
79
- constructor() {
80
- this.values = {};
81
- }
82
-
83
- process(value) {
84
- if (value == null || this.values[value]) return;
85
- this.values[value] = true;
86
- this.empty = false;
87
- this.result++;
88
- }
89
-
90
- getResult() {
91
- if (this.empty || this.invalid) return null;
92
- return this.result;
93
- }
94
- }
95
-
96
- Distinct.prototype.result = 0;
97
- Distinct.prototype.empty = true;
98
-
99
- class Max {
100
- process(value) {
101
- if (!isNaN(value)) {
102
- if (this.empty) this.result = value;
103
- else if (value > this.result) this.result = value;
104
- this.empty = false;
105
- } else if (value != null) this.invalid = true;
106
- }
107
-
108
- getResult() {
109
- if (this.empty || this.invalid) return null;
110
- return this.result;
111
- }
112
- }
113
-
114
- Max.prototype.result = 0;
115
- Max.prototype.empty = true;
116
-
117
- class Min {
118
- process(value) {
119
- if (!isNaN(value)) {
120
- if (this.empty) this.result = value;
121
- else if (value < this.result) this.result = value;
122
- this.empty = false;
123
- } else if (value != null) this.invalid = true;
124
- }
125
-
126
- getResult() {
127
- if (this.empty || this.invalid) return null;
128
- return this.result;
129
- }
130
- }
131
-
132
- Min.prototype.result = 0;
133
- Min.prototype.empty = true;
134
-
135
- class LastValue {
136
- process(value) {
137
- this.result = value;
138
- }
139
-
140
- getResult() {
141
- return this.result;
142
- }
143
- }
144
-
145
- LastValue.prototype.result = null;
1
+ export class AggregateFunction {
2
+ static sum() {
3
+ return new Sum();
4
+ }
5
+
6
+ static avg() {
7
+ return new Avg();
8
+ }
9
+
10
+ static count() {
11
+ return new Count();
12
+ }
13
+
14
+ static distinct() {
15
+ return new Distinct();
16
+ }
17
+
18
+ static min() {
19
+ return new Min();
20
+ }
21
+
22
+ static max() {
23
+ return new Max();
24
+ }
25
+
26
+ static last() {
27
+ return new LastValue();
28
+ }
29
+ }
30
+
31
+ class Sum {
32
+ process(value) {
33
+ this.empty = false;
34
+ if (!isNaN(value)) this.result += value;
35
+ else this.invalid = true;
36
+ }
37
+
38
+ getResult() {
39
+ if (this.invalid) return null;
40
+ return this.result;
41
+ }
42
+ }
43
+
44
+ Sum.prototype.result = 0;
45
+ Sum.prototype.empty = true;
46
+
47
+ class Avg {
48
+ process(value, count = 1) {
49
+ this.empty = false;
50
+ if (!isNaN(value) && !isNaN(count)) {
51
+ this.result += value * count;
52
+ this.count += count;
53
+ } else this.invalid = true;
54
+ }
55
+
56
+ getResult() {
57
+ if (this.empty || this.invalid || this.count == 0) return null;
58
+ return this.result / this.count;
59
+ }
60
+ }
61
+
62
+ Avg.prototype.result = 0;
63
+ Avg.prototype.count = 0;
64
+ Avg.prototype.empty = true;
65
+
66
+ class Count {
67
+ process(value) {
68
+ if (value != null) this.result++;
69
+ }
70
+
71
+ getResult() {
72
+ return this.result;
73
+ }
74
+ }
75
+
76
+ Count.prototype.result = 0;
77
+
78
+ class Distinct {
79
+ constructor() {
80
+ this.values = {};
81
+ }
82
+
83
+ process(value) {
84
+ if (value == null || this.values[value]) return;
85
+ this.values[value] = true;
86
+ this.empty = false;
87
+ this.result++;
88
+ }
89
+
90
+ getResult() {
91
+ if (this.empty || this.invalid) return null;
92
+ return this.result;
93
+ }
94
+ }
95
+
96
+ Distinct.prototype.result = 0;
97
+ Distinct.prototype.empty = true;
98
+
99
+ class Max {
100
+ process(value) {
101
+ if (!isNaN(value)) {
102
+ if (this.empty) this.result = value;
103
+ else if (value > this.result) this.result = value;
104
+ this.empty = false;
105
+ } else if (value != null) this.invalid = true;
106
+ }
107
+
108
+ getResult() {
109
+ if (this.empty || this.invalid) return null;
110
+ return this.result;
111
+ }
112
+ }
113
+
114
+ Max.prototype.result = 0;
115
+ Max.prototype.empty = true;
116
+
117
+ class Min {
118
+ process(value) {
119
+ if (!isNaN(value)) {
120
+ if (this.empty) this.result = value;
121
+ else if (value < this.result) this.result = value;
122
+ this.empty = false;
123
+ } else if (value != null) this.invalid = true;
124
+ }
125
+
126
+ getResult() {
127
+ if (this.empty || this.invalid) return null;
128
+ return this.result;
129
+ }
130
+ }
131
+
132
+ Min.prototype.result = 0;
133
+ Min.prototype.empty = true;
134
+
135
+ class LastValue {
136
+ process(value) {
137
+ this.result = value;
138
+ }
139
+
140
+ getResult() {
141
+ return this.result;
142
+ }
143
+ }
144
+
145
+ LastValue.prototype.result = null;
@@ -82,7 +82,12 @@ interface MonthFieldProps extends FieldProps {
82
82
  * Set to `true` to display the clear button even if `required` is set. Default is `false`.
83
83
  */
84
84
  alwaysShowClear?: boolean,
85
-
85
+
86
+ /** The function that will be used to convert Date objects before writing data to the store.
87
+ * Default implementation is Date.toISOString.
88
+ * See also Culture.setDefaultDateEncoding.
89
+ */
90
+ encoding?: (date: Date) => any;
86
91
  }
87
92
 
88
93
  export class MonthField extends Cx.Widget<MonthFieldProps> {}
@@ -1,32 +1,32 @@
1
- import { Widget, VDOM, getContent } from "../../ui/Widget";
2
- import { Cx } from "../../ui/Cx";
3
- import { Field, getFieldTooltip } from "./Field";
4
- import { MonthPicker } from "./MonthPicker";
5
1
  import { DateTimeCulture } from "intl-io";
6
- import { Format } from "../../util/Format";
7
- import { Dropdown } from "../overlay/Dropdown";
8
- import { Console } from "../../util/Console";
9
2
  import { StringTemplate } from "../../data/StringTemplate";
10
- import { monthStart } from "../../util/date/monthStart";
3
+ import { Culture } from "../../ui";
4
+ import { Cx } from "../../ui/Cx";
5
+ import { Localization } from "../../ui/Localization";
6
+ import { VDOM, Widget, getContent } from "../../ui/Widget";
7
+ import { Console } from "../../util/Console";
8
+ import { Format } from "../../util/Format";
9
+ import { KeyCode } from "../../util/KeyCode";
11
10
  import { dateDiff } from "../../util/date/dateDiff";
11
+ import { monthStart } from "../../util/date/monthStart";
12
+ import { stopPropagation } from "../../util/eventCallbacks";
13
+ import { isDefined } from "../../util/isDefined";
14
+ import { isTouchDevice } from "../../util/isTouchDevice";
15
+ import { isTouchEvent } from "../../util/isTouchEvent";
16
+ import { Icon } from "../Icon";
17
+ import { autoFocus } from "../autoFocus";
18
+ import ClearIcon from "../icons/clear";
19
+ import DropdownIcon from "../icons/drop-down";
20
+ import { Dropdown } from "../overlay/Dropdown";
12
21
  import {
13
- tooltipParentWillReceiveProps,
14
- tooltipParentWillUnmount,
15
- tooltipMouseMove,
16
22
  tooltipMouseLeave,
23
+ tooltipMouseMove,
17
24
  tooltipParentDidMount,
25
+ tooltipParentWillReceiveProps,
26
+ tooltipParentWillUnmount,
18
27
  } from "../overlay/tooltip-ops";
19
- import { stopPropagation } from "../../util/eventCallbacks";
20
- import { Icon } from "../Icon";
21
- import CalendarIcon from "../icons/calendar";
22
- import DropdownIcon from "../icons/drop-down";
23
- import ClearIcon from "../icons/clear";
24
- import { KeyCode } from "../../util/KeyCode";
25
- import { isTouchEvent } from "../../util/isTouchEvent";
26
- import { isTouchDevice } from "../../util/isTouchDevice";
27
- import { Localization } from "../../ui/Localization";
28
- import { isDefined } from "../../util/isDefined";
29
- import { autoFocus } from "../autoFocus";
28
+ import { Field, getFieldTooltip } from "./Field";
29
+ import { MonthPicker } from "./MonthPicker";
30
30
 
31
31
  export class MonthField extends Field {
32
32
  declareData() {
@@ -179,16 +179,18 @@ export class MonthField extends Field {
179
179
  }
180
180
 
181
181
  handleSelect(instance, date1, date2) {
182
+ let { widget } = instance;
183
+ let encode = widget.encoding || Culture.getDefaultDateEncoding();
182
184
  instance.setState({
183
185
  inputError: false,
184
186
  });
185
187
  if (this.range) {
186
- let d1 = date1 ? date1.toISOString() : this.emptyValue;
187
- let d2 = date2 ? date2.toISOString() : this.emptyValue;
188
+ let d1 = date1 ? encode(date1) : this.emptyValue;
189
+ let d2 = date2 ? encode(date2) : this.emptyValue;
188
190
  instance.set("from", d1);
189
191
  instance.set("to", d2);
190
192
  } else {
191
- let value = date1 ? date1.toISOString() : this.emptyValue;
193
+ let value = date1 ? encode(date1) : this.emptyValue;
192
194
  instance.set("value", value);
193
195
  }
194
196
  }
@@ -238,6 +240,7 @@ class MonthInput extends VDOM.Component {
238
240
  items: {
239
241
  type: MonthPicker,
240
242
  ...this.props.monthPicker,
243
+ encoding: widget.encoding,
241
244
  autoFocus: true,
242
245
  onFocusOut: (e) => {
243
246
  this.closeDropdown(e);
@@ -63,6 +63,12 @@ interface MonthPickerProps extends FieldProps {
63
63
  /** Minimum exclusive value error text. */
64
64
  minExclusiveErrorText?: string,
65
65
 
66
+ /** The function that will be used to convert Date objects before writing data to the store.
67
+ * Default implementation is Date.toISOString.
68
+ * See also Culture.setDefaultDateEncoding.
69
+ */
70
+ encoding?: (date: Date) => any;
71
+
66
72
  }
67
73
 
68
74
  export class MonthPicker extends Cx.Widget<MonthPickerProps> {}
@@ -124,7 +124,8 @@ export class MonthPicker extends Field {
124
124
  }
125
125
 
126
126
  handleSelect(e, instance, date1, date2) {
127
- let { data } = instance;
127
+ let { data, widget } = instance;
128
+ let encode = widget.encoding || Culture.getDefaultDateEncoding();
128
129
 
129
130
  if (data.disabled) return;
130
131
 
@@ -133,9 +134,9 @@ export class MonthPicker extends Field {
133
134
  if (this.onBeforeSelect && instance.invoke("onBeforeSelect", e, instance, date1, date2) === false) return;
134
135
 
135
136
  if (this.range) {
136
- instance.set("from", date1.toISOString());
137
- instance.set("to", date2.toISOString());
138
- } else instance.set("value", date1.toISOString());
137
+ instance.set("from", encode(date1));
138
+ instance.set("to", encode(date2));
139
+ } else instance.set("value", encode(date1));
139
140
 
140
141
  if (this.onSelect) instance.invoke("onSelect", instance, date1, date2);
141
142
  }
@@ -348,13 +348,11 @@ export class OverlayComponent extends VDOM.Component {
348
348
  })}
349
349
  style={parseStyle(data.shadowStyle)}
350
350
  >
351
- {widget.backdrop && (
352
- <div
353
- key="backdrop"
354
- className={CSS.element("overlay", "modal-backdrop")}
355
- onClick={this.onBackdropClick.bind(this)}
356
- />
357
- )}
351
+ <div
352
+ key="backdrop"
353
+ className={CSS.element("overlay", "modal-backdrop")}
354
+ onClick={this.onBackdropClick.bind(this)}
355
+ />
358
356
  {content}
359
357
  </div>
360
358
  );
@@ -459,6 +457,8 @@ export class OverlayComponent extends VDOM.Component {
459
457
 
460
458
  if (widget.backdrop) {
461
459
  if (instance.dismiss) instance.dismiss();
460
+ } else if (widget.modal) {
461
+ FocusManager.focus(this.el);
462
462
  }
463
463
  }
464
464
 
@@ -168,7 +168,7 @@ class WindowComponent extends OverlayComponent {
168
168
  super.onFocusIn();
169
169
  if (!this.state.active) {
170
170
  if (this.containerEl.contains(document.activeElement)) this.setZIndex(ZIndexManager.next());
171
- this.setState({ active: true, });
171
+ this.setState({ active: true });
172
172
  }
173
173
  }
174
174