cx 24.0.3 → 24.3.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/charts.js +104 -34
- package/dist/manifest.js +626 -626
- package/dist/ui.js +1 -1
- package/dist/widgets.js +64 -40
- package/package.json +1 -1
- package/src/charts/ColorMap.js +4 -6
- package/src/charts/PieChart.d.ts +3 -0
- package/src/charts/PieChart.js +115 -36
- package/src/ui/Cx.d.ts +3 -3
- package/src/ui/app/startAppLoop.js +3 -3
- package/src/ui/keyboardShortcuts.js +4 -5
- package/src/ui/selection/KeySelection.d.ts +1 -1
- package/src/ui/selection/PropertySelection.d.ts +1 -1
- package/src/ui/selection/PropertySelection.js +2 -4
- package/src/ui/selection/Selection.d.ts +1 -1
- package/src/widgets/form/ColorField.js +14 -9
- package/src/widgets/form/DateTimeField.js +10 -6
- package/src/widgets/form/LookupField.d.ts +8 -9
- package/src/widgets/form/MonthField.js +10 -6
- package/src/widgets/form/NumberField.js +8 -4
- package/src/widgets/form/TextArea.js +10 -6
- package/src/widgets/form/TextField.js +11 -9
- package/src/widgets/form/index.js +1 -2
- package/src/widgets/grid/Grid.d.ts +11 -8
package/dist/ui.js
CHANGED
|
@@ -2895,7 +2895,7 @@ var subscribers$1,
|
|
|
2895
2895
|
eventBan = 0;
|
|
2896
2896
|
function executeKeyboardShortcuts(e) {
|
|
2897
2897
|
if (Date.now() < eventBan) return;
|
|
2898
|
-
//Avoid duplicate executions as event.stopPropagation() for React events does not stop native events
|
|
2898
|
+
// Avoid duplicate executions as event.stopPropagation() for React events does not stop native events
|
|
2899
2899
|
eventBan = Date.now() + 5;
|
|
2900
2900
|
subscribers$1 && subscribers$1.notify(e);
|
|
2901
2901
|
}
|
package/dist/widgets.js
CHANGED
|
@@ -6974,7 +6974,7 @@ var Input$2 = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
6974
6974
|
className: CSS.element(baseClass, "left-icon"),
|
|
6975
6975
|
onMouseDown: preventDefault,
|
|
6976
6976
|
onClick: function onClick(e) {
|
|
6977
|
-
return _this2.onChange(e, "enter");
|
|
6977
|
+
return _this2.onChange(e.target.value, "enter");
|
|
6978
6978
|
},
|
|
6979
6979
|
children: iconVDOM,
|
|
6980
6980
|
});
|
|
@@ -7038,10 +7038,10 @@ var Input$2 = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
7038
7038
|
onMouseMove: this.onMouseMove.bind(this),
|
|
7039
7039
|
onMouseLeave: this.onMouseLeave.bind(this),
|
|
7040
7040
|
onInput: function onInput(e) {
|
|
7041
|
-
return _this2.onChange(e, "input");
|
|
7041
|
+
return _this2.onChange(e.target.value, "input");
|
|
7042
7042
|
},
|
|
7043
7043
|
onChange: function onChange(e) {
|
|
7044
|
-
return _this2.onChange(e, "change");
|
|
7044
|
+
return _this2.onChange(e.target.value, "change");
|
|
7045
7045
|
},
|
|
7046
7046
|
onKeyDown: this.onKeyDown.bind(this),
|
|
7047
7047
|
onFocus: this.onFocus.bind(this),
|
|
@@ -7080,7 +7080,7 @@ var Input$2 = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
7080
7080
|
});
|
|
7081
7081
|
this.props.instance.set("focused", false);
|
|
7082
7082
|
}
|
|
7083
|
-
this.onChange(e, "blur");
|
|
7083
|
+
this.onChange(e.target.value, "blur");
|
|
7084
7084
|
};
|
|
7085
7085
|
_proto2.onClearClick = function onClearClick(e) {
|
|
7086
7086
|
this.props.instance.set("value", this.props.instance.widget.emptyValue, {
|
|
@@ -7101,6 +7101,7 @@ var Input$2 = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
7101
7101
|
autoFocus(this.input, this);
|
|
7102
7102
|
};
|
|
7103
7103
|
_proto2.componentWillUnmount = function componentWillUnmount() {
|
|
7104
|
+
if (this.input == getActiveElement()) this.onChange(this.input.value, "blur");
|
|
7104
7105
|
tooltipParentWillUnmount$1(this.props.instance);
|
|
7105
7106
|
};
|
|
7106
7107
|
_proto2.onKeyDown = function onKeyDown(e) {
|
|
@@ -7108,7 +7109,7 @@ var Input$2 = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
7108
7109
|
if (instance.widget.handleKeyDown(e, instance) === false) return;
|
|
7109
7110
|
switch (e.keyCode) {
|
|
7110
7111
|
case KeyCode.enter:
|
|
7111
|
-
this.onChange(e, "enter");
|
|
7112
|
+
this.onChange(e.target.value, "enter");
|
|
7112
7113
|
break;
|
|
7113
7114
|
case KeyCode.left:
|
|
7114
7115
|
case KeyCode.right:
|
|
@@ -7118,12 +7119,12 @@ var Input$2 = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
7118
7119
|
};
|
|
7119
7120
|
_proto2.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(props) {
|
|
7120
7121
|
var data = props.data;
|
|
7121
|
-
//
|
|
7122
|
-
//and update may be caused by some other property, i.e. visited
|
|
7122
|
+
// The second check is required for debouncing, sometimes the value in the store lags after the input
|
|
7123
|
+
// and update may be caused by some other property, i.e. visited
|
|
7123
7124
|
if (data.value != this.input.value && data.value != this.props.data.value) this.input.value = data.value || "";
|
|
7124
7125
|
tooltipParentWillReceiveProps$1.apply(void 0, [this.input].concat(getFieldTooltip(props.instance)));
|
|
7125
7126
|
};
|
|
7126
|
-
_proto2.onChange = function onChange(
|
|
7127
|
+
_proto2.onChange = function onChange(textValue, change) {
|
|
7127
7128
|
var _this$props3 = this.props,
|
|
7128
7129
|
instance = _this$props3.instance,
|
|
7129
7130
|
data = _this$props3.data;
|
|
@@ -7135,7 +7136,7 @@ var Input$2 = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
7135
7136
|
}
|
|
7136
7137
|
var widget = instance.widget;
|
|
7137
7138
|
if (widget.reactOn.indexOf(change) != -1) {
|
|
7138
|
-
var text = this.trimmed(
|
|
7139
|
+
var text = this.trimmed(textValue);
|
|
7139
7140
|
if (data.maxLength != null && text.length > data.maxLength) {
|
|
7140
7141
|
text = text.substring(0, data.maxLength);
|
|
7141
7142
|
this.input.value = text;
|
|
@@ -10000,6 +10001,16 @@ var Input$1 = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
10000
10001
|
autoFocus(this.input, this);
|
|
10001
10002
|
};
|
|
10002
10003
|
_proto2.componentWillUnmount = function componentWillUnmount() {
|
|
10004
|
+
if (this.input == getActiveElement()) {
|
|
10005
|
+
this.onChange(
|
|
10006
|
+
{
|
|
10007
|
+
target: {
|
|
10008
|
+
value: this.input.value,
|
|
10009
|
+
},
|
|
10010
|
+
},
|
|
10011
|
+
"blur",
|
|
10012
|
+
);
|
|
10013
|
+
}
|
|
10003
10014
|
tooltipParentWillUnmount$1(this.props.instance);
|
|
10004
10015
|
};
|
|
10005
10016
|
_proto2.getPreCursorDigits = function getPreCursorDigits(text, cursor, decimalSeparator) {
|
|
@@ -10143,12 +10154,12 @@ var Input$1 = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
10143
10154
|
var fmt = data.format;
|
|
10144
10155
|
var decimalSeparator = this.getDecimalSeparator(fmt) || Format.value(1.1, "n;1")[1];
|
|
10145
10156
|
var formatted = Format.value(value, fmt);
|
|
10146
|
-
//
|
|
10157
|
+
// Re-parse to avoid differences between formatted value and value in the store
|
|
10147
10158
|
|
|
10148
10159
|
value = widget.parseValue(formatted, instance) * data.scale + data.offset;
|
|
10149
10160
|
|
|
10150
|
-
//
|
|
10151
|
-
//
|
|
10161
|
+
// Allow users to type numbers like 100.0003 or -0.05 without interruptions
|
|
10162
|
+
// If the last typed character is zero or dot (decimal separator), skip processing it
|
|
10152
10163
|
if (
|
|
10153
10164
|
change == "change" &&
|
|
10154
10165
|
this.input.selectionStart == this.input.selectionEnd &&
|
|
@@ -10159,7 +10170,7 @@ var Input$1 = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
10159
10170
|
)
|
|
10160
10171
|
return;
|
|
10161
10172
|
if (change != "blur") {
|
|
10162
|
-
//
|
|
10173
|
+
// Format, but keep the correct cursor position
|
|
10163
10174
|
var preCursorText = this.getPreCursorDigits(this.input.value, this.input.selectionStart, decimalSeparator);
|
|
10164
10175
|
this.input.value = formatted;
|
|
10165
10176
|
this.updateCursorPosition(preCursorText);
|
|
@@ -10290,13 +10301,13 @@ var Input = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
10290
10301
|
data.inputAttrs,
|
|
10291
10302
|
{
|
|
10292
10303
|
onInput: function onInput(e) {
|
|
10293
|
-
return _this2.onChange(e, "input");
|
|
10304
|
+
return _this2.onChange(e.target.value, "input");
|
|
10294
10305
|
},
|
|
10295
10306
|
onChange: function onChange(e) {
|
|
10296
|
-
return _this2.onChange(e, "change");
|
|
10307
|
+
return _this2.onChange(e.target.value, "change");
|
|
10297
10308
|
},
|
|
10298
10309
|
onBlur: function onBlur(e) {
|
|
10299
|
-
_this2.onChange(e, "blur");
|
|
10310
|
+
_this2.onChange(e.target.value, "blur");
|
|
10300
10311
|
},
|
|
10301
10312
|
onFocus: function onFocus(e) {
|
|
10302
10313
|
return _this2.onFocus();
|
|
@@ -10320,6 +10331,9 @@ var Input = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
10320
10331
|
});
|
|
10321
10332
|
};
|
|
10322
10333
|
_proto2.componentWillUnmount = function componentWillUnmount() {
|
|
10334
|
+
if (this.input == getActiveElement()) {
|
|
10335
|
+
this.onChange(this.input.value, "blur");
|
|
10336
|
+
}
|
|
10323
10337
|
tooltipParentWillUnmount$1(this.props.instance);
|
|
10324
10338
|
};
|
|
10325
10339
|
_proto2.componentDidMount = function componentDidMount() {
|
|
@@ -10349,7 +10363,7 @@ var Input = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
10349
10363
|
}
|
|
10350
10364
|
tooltipParentWillReceiveProps$1.apply(void 0, [this.input].concat(getFieldTooltip(instance)));
|
|
10351
10365
|
};
|
|
10352
|
-
_proto2.onChange = function onChange(
|
|
10366
|
+
_proto2.onChange = function onChange(inputValue, change) {
|
|
10353
10367
|
var _this$props2 = this.props,
|
|
10354
10368
|
instance = _this$props2.instance,
|
|
10355
10369
|
data = _this$props2.data;
|
|
@@ -10365,11 +10379,11 @@ var Input = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
10365
10379
|
}
|
|
10366
10380
|
if (data.required) {
|
|
10367
10381
|
instance.setState({
|
|
10368
|
-
empty: !
|
|
10382
|
+
empty: !inputValue,
|
|
10369
10383
|
});
|
|
10370
10384
|
}
|
|
10371
10385
|
if (instance.widget.reactOn.indexOf(change) != -1) {
|
|
10372
|
-
var value =
|
|
10386
|
+
var value = inputValue || widget.emptyValue;
|
|
10373
10387
|
instance.set("value", value);
|
|
10374
10388
|
}
|
|
10375
10389
|
};
|
|
@@ -12111,10 +12125,10 @@ var MonthInput = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
12111
12125
|
tabIndex: data.tabIndex,
|
|
12112
12126
|
placeholder: data.placeholder,
|
|
12113
12127
|
onInput: function onInput(e) {
|
|
12114
|
-
return _this3.onChange(e, "input");
|
|
12128
|
+
return _this3.onChange(e.target.value, "input");
|
|
12115
12129
|
},
|
|
12116
12130
|
onChange: function onChange(e) {
|
|
12117
|
-
return _this3.onChange(e, "change");
|
|
12131
|
+
return _this3.onChange(e.target.value, "change");
|
|
12118
12132
|
},
|
|
12119
12133
|
onKeyDown: function onKeyDown(e) {
|
|
12120
12134
|
return _this3.onKeyDown(e);
|
|
@@ -12171,7 +12185,7 @@ var MonthInput = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
12171
12185
|
switch (e.keyCode) {
|
|
12172
12186
|
case KeyCode.enter:
|
|
12173
12187
|
e.stopPropagation();
|
|
12174
|
-
this.onChange(e, "enter");
|
|
12188
|
+
this.onChange(e.target.value, "enter");
|
|
12175
12189
|
break;
|
|
12176
12190
|
case KeyCode.esc:
|
|
12177
12191
|
if (this.state.dropdownOpen) {
|
|
@@ -12201,7 +12215,7 @@ var MonthInput = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
12201
12215
|
this.setState({
|
|
12202
12216
|
focus: false,
|
|
12203
12217
|
});
|
|
12204
|
-
this.onChange(e, "blur");
|
|
12218
|
+
this.onChange(e.target.value, "blur");
|
|
12205
12219
|
};
|
|
12206
12220
|
_proto2.closeDropdown = function closeDropdown(e, callback) {
|
|
12207
12221
|
var _this5 = this;
|
|
@@ -12257,13 +12271,16 @@ var MonthInput = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
12257
12271
|
autoFocus(this.input, this);
|
|
12258
12272
|
};
|
|
12259
12273
|
_proto2.componentWillUnmount = function componentWillUnmount() {
|
|
12274
|
+
if (this.input == getActiveElement()) {
|
|
12275
|
+
this.onChange(this.input.value, "blur");
|
|
12276
|
+
}
|
|
12260
12277
|
tooltipParentWillUnmount$1(this.props.instance);
|
|
12261
12278
|
};
|
|
12262
|
-
_proto2.onChange = function onChange(
|
|
12279
|
+
_proto2.onChange = function onChange(inputValue, eventType) {
|
|
12263
12280
|
var instance = this.props.instance;
|
|
12264
12281
|
var widget = instance.widget;
|
|
12265
12282
|
if (widget.reactOn.indexOf(eventType) == -1) return;
|
|
12266
|
-
var parts =
|
|
12283
|
+
var parts = inputValue.split("-");
|
|
12267
12284
|
var date1 = widget.parseDate(parts[0]);
|
|
12268
12285
|
var date2 = widget.parseDate(parts[1]) || date1;
|
|
12269
12286
|
if ((date1 != null && isNaN(date1)) || (date2 != null && isNaN(date2))) {
|
|
@@ -12503,10 +12520,10 @@ var ColorInput = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
12503
12520
|
data.inputAttrs,
|
|
12504
12521
|
{
|
|
12505
12522
|
onInput: function onInput(e) {
|
|
12506
|
-
return _this3.onChange(e, "input");
|
|
12523
|
+
return _this3.onChange(e.target.value, "input");
|
|
12507
12524
|
},
|
|
12508
12525
|
onChange: function onChange(e) {
|
|
12509
|
-
return _this3.onChange(e, "change");
|
|
12526
|
+
return _this3.onChange(e.target.value, "change");
|
|
12510
12527
|
},
|
|
12511
12528
|
onKeyDown: function onKeyDown(e) {
|
|
12512
12529
|
return _this3.onKeyDown(e);
|
|
@@ -12565,7 +12582,7 @@ var ColorInput = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
12565
12582
|
switch (e.keyCode) {
|
|
12566
12583
|
case KeyCode.enter:
|
|
12567
12584
|
e.stopPropagation();
|
|
12568
|
-
this.onChange(e, "enter");
|
|
12585
|
+
this.onChange(e.target.value, "enter");
|
|
12569
12586
|
break;
|
|
12570
12587
|
case KeyCode.esc:
|
|
12571
12588
|
if (this.state.dropdownOpen) {
|
|
@@ -12591,7 +12608,7 @@ var ColorInput = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
12591
12608
|
this.setState({
|
|
12592
12609
|
focus: false,
|
|
12593
12610
|
});
|
|
12594
|
-
this.onChange(e, "blur");
|
|
12611
|
+
this.onChange(e.target.value, "blur");
|
|
12595
12612
|
};
|
|
12596
12613
|
_proto2.closeDropdown = function closeDropdown(e, callback) {
|
|
12597
12614
|
var _this5 = this;
|
|
@@ -12639,6 +12656,9 @@ var ColorInput = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
12639
12656
|
if (this.props.instance.widget.autoFocus && !isTouchDevice()) this.input.focus();
|
|
12640
12657
|
};
|
|
12641
12658
|
_proto2.componentWillUnmount = function componentWillUnmount() {
|
|
12659
|
+
if (this.input == getActiveElement()) {
|
|
12660
|
+
this.onChange(this.input.value, "blur");
|
|
12661
|
+
}
|
|
12642
12662
|
tooltipParentWillUnmount$1(this.props.instance);
|
|
12643
12663
|
};
|
|
12644
12664
|
_proto2.onClearClick = function onClearClick(e) {
|
|
@@ -12650,25 +12670,25 @@ var ColorInput = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
12650
12670
|
e.stopPropagation();
|
|
12651
12671
|
e.preventDefault();
|
|
12652
12672
|
};
|
|
12653
|
-
_proto2.onChange = function onChange(
|
|
12673
|
+
_proto2.onChange = function onChange(inputValue, eventType) {
|
|
12654
12674
|
var _this$props2 = this.props,
|
|
12655
12675
|
instance = _this$props2.instance,
|
|
12656
12676
|
data = _this$props2.data;
|
|
12657
12677
|
var widget = instance.widget;
|
|
12658
|
-
if (eventType == "blur")
|
|
12678
|
+
if (eventType == "blur") {
|
|
12659
12679
|
instance.setState({
|
|
12660
12680
|
visited: true,
|
|
12661
12681
|
});
|
|
12662
|
-
|
|
12682
|
+
}
|
|
12663
12683
|
var isValid;
|
|
12664
12684
|
try {
|
|
12665
|
-
parseColor(
|
|
12685
|
+
parseColor(inputValue);
|
|
12666
12686
|
isValid = true;
|
|
12667
12687
|
} catch (e) {
|
|
12668
12688
|
isValid = false;
|
|
12669
12689
|
}
|
|
12670
12690
|
if (eventType == "blur" || eventType == "enter") {
|
|
12671
|
-
var value =
|
|
12691
|
+
var value = inputValue || widget.emptyValue;
|
|
12672
12692
|
if (isValid && value !== data.value) instance.set("value", value);
|
|
12673
12693
|
instance.setState({
|
|
12674
12694
|
inputError: !isValid && "Invalid color entered.",
|
|
@@ -14631,10 +14651,10 @@ var DateTimeInput = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
14631
14651
|
data.inputAttrs,
|
|
14632
14652
|
{
|
|
14633
14653
|
onInput: function onInput(e) {
|
|
14634
|
-
return _this3.onChange(e, "input");
|
|
14654
|
+
return _this3.onChange(e.target.value, "input");
|
|
14635
14655
|
},
|
|
14636
14656
|
onChange: function onChange(e) {
|
|
14637
|
-
return _this3.onChange(e, "change");
|
|
14657
|
+
return _this3.onChange(e.target.value, "change");
|
|
14638
14658
|
},
|
|
14639
14659
|
onKeyDown: function onKeyDown(e) {
|
|
14640
14660
|
return _this3.onKeyDown(e);
|
|
@@ -14696,7 +14716,7 @@ var DateTimeInput = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
14696
14716
|
if (instance.widget.handleKeyDown(e, instance) === false) return;
|
|
14697
14717
|
switch (e.keyCode) {
|
|
14698
14718
|
case KeyCode.enter:
|
|
14699
|
-
this.onChange(e, "enter");
|
|
14719
|
+
this.onChange(e.target.value, "enter");
|
|
14700
14720
|
break;
|
|
14701
14721
|
case KeyCode.esc:
|
|
14702
14722
|
if (this.state.dropdownOpen) {
|
|
@@ -14727,7 +14747,7 @@ var DateTimeInput = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
14727
14747
|
this.setState({
|
|
14728
14748
|
focus: false,
|
|
14729
14749
|
});
|
|
14730
|
-
this.onChange(e, "blur");
|
|
14750
|
+
this.onChange(e.target.value, "blur");
|
|
14731
14751
|
};
|
|
14732
14752
|
_proto2.closeDropdown = function closeDropdown(e, callback) {
|
|
14733
14753
|
var _this5 = this;
|
|
@@ -14783,9 +14803,12 @@ var DateTimeInput = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
14783
14803
|
autoFocus(this.input, this);
|
|
14784
14804
|
};
|
|
14785
14805
|
_proto2.componentWillUnmount = function componentWillUnmount() {
|
|
14806
|
+
if (this.input == getActiveElement()) {
|
|
14807
|
+
this.onChange(this.input.value, "blur");
|
|
14808
|
+
}
|
|
14786
14809
|
tooltipParentWillUnmount$1(this.props.instance);
|
|
14787
14810
|
};
|
|
14788
|
-
_proto2.onChange = function onChange(
|
|
14811
|
+
_proto2.onChange = function onChange(inputValue, eventType) {
|
|
14789
14812
|
var _this$props2 = this.props,
|
|
14790
14813
|
instance = _this$props2.instance,
|
|
14791
14814
|
data = _this$props2.data;
|
|
@@ -14796,7 +14819,7 @@ var DateTimeInput = /*#__PURE__*/ (function (_VDOM$Component) {
|
|
|
14796
14819
|
instance.setState({
|
|
14797
14820
|
visited: true,
|
|
14798
14821
|
});
|
|
14799
|
-
this.setValue(
|
|
14822
|
+
this.setValue(inputValue, data.value);
|
|
14800
14823
|
};
|
|
14801
14824
|
_proto2.setValue = function setValue(text, baseValue) {
|
|
14802
14825
|
var _this$props3 = this.props,
|
|
@@ -19218,6 +19241,7 @@ export {
|
|
|
19218
19241
|
HighlightedSearchText,
|
|
19219
19242
|
HtmlElement,
|
|
19220
19243
|
Icon,
|
|
19244
|
+
Label,
|
|
19221
19245
|
LabeledContainer,
|
|
19222
19246
|
Link,
|
|
19223
19247
|
LinkButton,
|
package/package.json
CHANGED
package/src/charts/ColorMap.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {Widget} from '../ui/Widget';
|
|
2
|
-
import {PureContainer} from '../ui/PureContainer';
|
|
1
|
+
import { Widget } from '../ui/Widget';
|
|
2
|
+
import { PureContainer } from '../ui/PureContainer';
|
|
3
3
|
|
|
4
4
|
export class ColorMap extends Widget {
|
|
5
5
|
declareData() {
|
|
@@ -21,7 +21,7 @@ export class ColorMap extends Widget {
|
|
|
21
21
|
let cache = this.onGetCache ? instance.invoke("onGetCache") : {};
|
|
22
22
|
map = cache[colorMap];
|
|
23
23
|
if (!map) {
|
|
24
|
-
let {data} = instance;
|
|
24
|
+
let { data } = instance;
|
|
25
25
|
map = context.colorMaps[colorMap] = cache[colorMap] = new ColorIndex({
|
|
26
26
|
offset: data.offset,
|
|
27
27
|
step: data.step,
|
|
@@ -67,7 +67,7 @@ ColorMap.Scope = ColorMapScope;
|
|
|
67
67
|
Widget.alias('color-map', ColorMap);
|
|
68
68
|
|
|
69
69
|
export class ColorIndex {
|
|
70
|
-
constructor({offset, step, size}) {
|
|
70
|
+
constructor({ offset, step, size }) {
|
|
71
71
|
this.colorMap = {};
|
|
72
72
|
this.dirty = true;
|
|
73
73
|
this.offset = offset;
|
|
@@ -83,7 +83,6 @@ export class ColorIndex {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
map(name) {
|
|
86
|
-
|
|
87
86
|
if (this.dirty) {
|
|
88
87
|
this.dirty = false;
|
|
89
88
|
if (!this.step) {
|
|
@@ -94,6 +93,5 @@ export class ColorIndex {
|
|
|
94
93
|
|
|
95
94
|
let index = this.colorMap[name] || 0;
|
|
96
95
|
return Math.round(this.offset + this.step * index + this.size) % this.size;
|
|
97
|
-
|
|
98
96
|
}
|
|
99
97
|
}
|
package/src/charts/PieChart.d.ts
CHANGED
|
@@ -75,6 +75,9 @@ interface PieSliceProps extends Cx.StyledContainerProps {
|
|
|
75
75
|
|
|
76
76
|
/** A value used to uniquely identify the record within the hover sync group. */
|
|
77
77
|
hoverId?: Cx.StringProp;
|
|
78
|
+
|
|
79
|
+
/** Border radius of the slice. Default is 0. */
|
|
80
|
+
borderRadius?: Cx.NumberProp;
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
export class PieSlice extends Cx.Widget<PieSliceProps> {}
|
package/src/charts/PieChart.js
CHANGED
|
@@ -102,50 +102,110 @@ class PieCalculator {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function createSvgArc(x, y, r0, r,
|
|
106
|
-
if (
|
|
107
|
-
var s =
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
function createSvgArc(x, y, r0 = 0, r, startAngleRadian, endAngleRadian, br = 0) {
|
|
106
|
+
if (startAngleRadian > endAngleRadian) {
|
|
107
|
+
var s = startAngleRadian;
|
|
108
|
+
startAngleRadian = endAngleRadian;
|
|
109
|
+
endAngleRadian = s;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
let path = [];
|
|
113
|
+
// limit br size based on r and r0
|
|
114
|
+
if (br > (r - r0) / 2) br = (r - r0) / 2;
|
|
115
|
+
|
|
116
|
+
let largeArc = endAngleRadian - startAngleRadian > Math.PI ? 1 : 0;
|
|
117
|
+
|
|
118
|
+
if (br > 0) {
|
|
119
|
+
if (r0 > 0) {
|
|
120
|
+
let innerBr = br;
|
|
121
|
+
let innerSmallArcAngle = Math.asin(br / (r0 + br));
|
|
122
|
+
if (innerSmallArcAngle > (endAngleRadian - startAngleRadian) / 2) {
|
|
123
|
+
innerSmallArcAngle = (endAngleRadian - startAngleRadian) / 2;
|
|
124
|
+
let sin = Math.sin(innerSmallArcAngle);
|
|
125
|
+
// correct br according to newly calculated border radius angle
|
|
126
|
+
innerBr = (r0 * sin) / (1 - sin);
|
|
127
|
+
}
|
|
128
|
+
let innerHip = Math.cos(innerSmallArcAngle) * (r0 + innerBr);
|
|
129
|
+
|
|
130
|
+
let innerSmallArc1XFrom = x + Math.cos(endAngleRadian) * innerHip;
|
|
131
|
+
let innerSmallArc1YFrom = y - Math.sin(endAngleRadian) * innerHip;
|
|
132
|
+
|
|
133
|
+
// move from the first small inner arc
|
|
134
|
+
path.push(move(innerSmallArc1XFrom, innerSmallArc1YFrom));
|
|
135
|
+
|
|
136
|
+
let innerSmallArc1XTo = x + Math.cos(endAngleRadian - innerSmallArcAngle) * r0;
|
|
137
|
+
let innerSmallArc1YTo = y - Math.sin(endAngleRadian - innerSmallArcAngle) * r0;
|
|
113
138
|
|
|
114
|
-
|
|
139
|
+
// add first small inner arc
|
|
140
|
+
path.push(arc(innerBr, innerBr, 0, 0, 0, innerSmallArc1XTo, innerSmallArc1YTo));
|
|
115
141
|
|
|
116
|
-
|
|
142
|
+
let innerArcXTo = x + Math.cos(startAngleRadian + innerSmallArcAngle) * r0;
|
|
143
|
+
let innerArcYTo = y - Math.sin(startAngleRadian + innerSmallArcAngle) * r0;
|
|
117
144
|
|
|
118
|
-
|
|
145
|
+
// add large inner arc
|
|
146
|
+
path.push(arc(r0, r0, 0, largeArc, 1, innerArcXTo, innerArcYTo));
|
|
119
147
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
148
|
+
let innerSmallArc2XTo = x + Math.cos(startAngleRadian) * innerHip;
|
|
149
|
+
let innerSmallArc2YTo = y - Math.sin(startAngleRadian) * innerHip;
|
|
150
|
+
// add second small inner arc
|
|
151
|
+
path.push(arc(innerBr, innerBr, 0, 0, 0, innerSmallArc2XTo, innerSmallArc2YTo));
|
|
152
|
+
} else {
|
|
153
|
+
path.push(move(x, y));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let outerBr = br;
|
|
157
|
+
let outerSmallArcAngle = Math.asin(br / (r - br));
|
|
158
|
+
if (outerSmallArcAngle > (endAngleRadian - startAngleRadian) / 2) {
|
|
159
|
+
outerSmallArcAngle = (endAngleRadian - startAngleRadian) / 2;
|
|
160
|
+
let sin = Math.sin(outerSmallArcAngle);
|
|
161
|
+
// correct br according to newly calculated border radius angle
|
|
162
|
+
outerBr = (r * sin) / (1 + sin);
|
|
163
|
+
}
|
|
164
|
+
let outerHip = Math.cos(outerSmallArcAngle) * (r - outerBr);
|
|
124
165
|
|
|
125
|
-
|
|
166
|
+
let outerSmallArc1XFrom = x + Math.cos(startAngleRadian) * outerHip;
|
|
167
|
+
let outerSmallArc1YFrom = y - Math.sin(startAngleRadian) * outerHip;
|
|
168
|
+
|
|
169
|
+
let outerSmallArc1XTo = x + Math.cos(startAngleRadian + outerSmallArcAngle) * r;
|
|
170
|
+
let outerSmallArc1YTo = y - Math.sin(startAngleRadian + outerSmallArcAngle) * r;
|
|
171
|
+
|
|
172
|
+
let outerLargeArcXTo = x + Math.cos(endAngleRadian - outerSmallArcAngle) * r;
|
|
173
|
+
let outerLargeArcYTo = y - Math.sin(endAngleRadian - outerSmallArcAngle) * r;
|
|
174
|
+
|
|
175
|
+
let outerSmallArc2XTo = x + Math.cos(endAngleRadian) * outerHip;
|
|
176
|
+
let outerSmallArc2YTo = y - Math.sin(endAngleRadian) * outerHip;
|
|
177
|
+
|
|
178
|
+
path.push(
|
|
179
|
+
line(outerSmallArc1XFrom, outerSmallArc1YFrom),
|
|
180
|
+
arc(outerBr, outerBr, 0, 0, 0, outerSmallArc1XTo, outerSmallArc1YTo),
|
|
181
|
+
arc(r, r, 0, largeArc, 0, outerLargeArcXTo, outerLargeArcYTo),
|
|
182
|
+
arc(outerBr, outerBr, 0, 0, 0, outerSmallArc2XTo, outerSmallArc2YTo)
|
|
183
|
+
);
|
|
126
184
|
} else {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
185
|
+
if (r0 > 0) {
|
|
186
|
+
let startX = x + Math.cos(endAngleRadian) * r0;
|
|
187
|
+
let startY = y - Math.sin(endAngleRadian) * r0;
|
|
188
|
+
path.push(move(startX, startY));
|
|
189
|
+
|
|
190
|
+
let innerArcToX = x + Math.cos(startAngleRadian) * r0;
|
|
191
|
+
let innerArcToY = y - Math.sin(startAngleRadian) * r0;
|
|
192
|
+
|
|
193
|
+
path.push(arc(r0, r0, 0, largeArc, 1, innerArcToX, innerArcToY));
|
|
194
|
+
} else {
|
|
195
|
+
path.push(move(x, y));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
let lineToX = x + Math.cos(startAngleRadian) * r;
|
|
199
|
+
let lineToY = y - Math.sin(startAngleRadian) * r;
|
|
200
|
+
path.push(line(lineToX, lineToY));
|
|
201
|
+
|
|
202
|
+
let arcToX = x + Math.cos(endAngleRadian) * r;
|
|
203
|
+
let arcToY = y - Math.sin(endAngleRadian) * r;
|
|
204
|
+
path.push(arc(r, r, 0, largeArc, 0, arcToX, arcToY));
|
|
130
205
|
}
|
|
131
206
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
x + Math.cos(startAngle) * r,
|
|
135
|
-
y - Math.sin(startAngle) * r,
|
|
136
|
-
"A",
|
|
137
|
-
r,
|
|
138
|
-
r,
|
|
139
|
-
0,
|
|
140
|
-
largeArc,
|
|
141
|
-
0,
|
|
142
|
-
x + Math.cos(endAngle) * r,
|
|
143
|
-
y - Math.sin(endAngle) * r,
|
|
144
|
-
"L",
|
|
145
|
-
startX,
|
|
146
|
-
startY
|
|
147
|
-
);
|
|
148
|
-
return result.join(" ");
|
|
207
|
+
path.push(z());
|
|
208
|
+
return path.join(" ");
|
|
149
209
|
}
|
|
150
210
|
|
|
151
211
|
PieChart.prototype.anchors = "0 1 1 0";
|
|
@@ -155,6 +215,7 @@ Widget.alias("pie-slice");
|
|
|
155
215
|
export class PieSlice extends Container {
|
|
156
216
|
init() {
|
|
157
217
|
this.selection = Selection.create(this.selection);
|
|
218
|
+
if (this.borderRadius) this.br = this.borderRadius;
|
|
158
219
|
super.init();
|
|
159
220
|
}
|
|
160
221
|
|
|
@@ -176,6 +237,7 @@ export class PieSlice extends Container {
|
|
|
176
237
|
stack: undefined,
|
|
177
238
|
legend: undefined,
|
|
178
239
|
hoverId: undefined,
|
|
240
|
+
br: undefined,
|
|
179
241
|
});
|
|
180
242
|
}
|
|
181
243
|
|
|
@@ -307,13 +369,14 @@ export class PieSlice extends Container {
|
|
|
307
369
|
hover,
|
|
308
370
|
};
|
|
309
371
|
|
|
310
|
-
|
|
372
|
+
let d = createSvgArc(
|
|
311
373
|
segment.ox,
|
|
312
374
|
segment.oy,
|
|
313
375
|
data.r0 * segment.radiusMultiplier,
|
|
314
376
|
data.r * segment.radiusMultiplier,
|
|
315
377
|
segment.startAngle,
|
|
316
|
-
segment.endAngle
|
|
378
|
+
segment.endAngle,
|
|
379
|
+
data.br
|
|
317
380
|
);
|
|
318
381
|
|
|
319
382
|
return (
|
|
@@ -352,6 +415,22 @@ export class PieSlice extends Container {
|
|
|
352
415
|
}
|
|
353
416
|
}
|
|
354
417
|
|
|
418
|
+
function move(x, y) {
|
|
419
|
+
return `M ${x} ${y}`;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function line(x, y) {
|
|
423
|
+
return `L ${x} ${y}`;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function z() {
|
|
427
|
+
return "Z";
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function arc(rx, ry, xRotation, largeArc, sweep, x, y) {
|
|
431
|
+
return `A ${rx} ${ry} ${xRotation} ${largeArc} ${sweep} ${x} ${y}`;
|
|
432
|
+
}
|
|
433
|
+
|
|
355
434
|
PieSlice.prototype.offset = 0;
|
|
356
435
|
PieSlice.prototype.r0 = 0;
|
|
357
436
|
PieSlice.prototype.r = 50;
|
package/src/ui/Cx.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {View} from "../data/View";
|
|
3
|
-
import {Instance} from "./Instance";
|
|
2
|
+
import { View } from "../data/View";
|
|
3
|
+
import { Instance } from "./Instance";
|
|
4
4
|
|
|
5
5
|
interface CxProps {
|
|
6
6
|
widget?: Cx.Config,
|
|
@@ -15,4 +15,4 @@ interface CxProps {
|
|
|
15
15
|
onError?: (error: Error, instance: Instance, info: any) => void
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export class Cx extends React.Component<CxProps, any> {}
|
|
18
|
+
export class Cx extends React.Component<CxProps, any> { }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {Widget, VDOM} from '../Widget';
|
|
2
|
-
import {Store} from '../../data/Store';
|
|
3
|
-
import {Cx} from '../Cx';
|
|
1
|
+
import { Widget, VDOM } from '../Widget';
|
|
2
|
+
import { Store } from '../../data/Store';
|
|
3
|
+
import { Cx } from '../Cx';
|
|
4
4
|
|
|
5
5
|
export function startAppLoop(parentDOMElement, storeOrInstance, widget, options = {}) {
|
|
6
6
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {SubscriberList} from "../util/SubscriberList";
|
|
2
|
-
import {isObject} from "../util/isObject";
|
|
1
|
+
import { SubscriberList } from "../util/SubscriberList";
|
|
2
|
+
import { isObject } from "../util/isObject";
|
|
3
3
|
|
|
4
4
|
let subscribers, eventBan = 0;
|
|
5
5
|
|
|
6
6
|
export function executeKeyboardShortcuts(e) {
|
|
7
|
-
if (Date.now() < eventBan)
|
|
8
|
-
|
|
9
|
-
//Avoid duplicate executions as event.stopPropagation() for React events does not stop native events
|
|
7
|
+
if (Date.now() < eventBan) return;
|
|
8
|
+
// Avoid duplicate executions as event.stopPropagation() for React events does not stop native events
|
|
10
9
|
eventBan = Date.now() + 5;
|
|
11
10
|
subscribers && subscribers.notify(e);
|
|
12
11
|
}
|