@singularsystems/neo-react 0.10.32 → 0.10.35
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/Modules/NeoReactModule.js +0 -1
- package/dist/Modules/ReactSetup.js +0 -1
- package/dist/Modules/Types.js +0 -1
- package/dist/React/AutoRunner.js +0 -1
- package/dist/React/DataView.js +0 -1
- package/dist/React/Decorators.js +0 -1
- package/dist/React/ReactModelCreator.js +0 -2
- package/dist/React/Utils.js +0 -1
- package/dist/ReactComponents/Button.js +0 -1
- package/dist/ReactComponents/Card.js +0 -1
- package/dist/ReactComponents/Collapsable.js +0 -1
- package/dist/ReactComponents/CollapsableBase.js +0 -1
- package/dist/ReactComponents/ColorPicker.js +0 -1
- package/dist/ReactComponents/ComponentBase.js +0 -1
- package/dist/ReactComponents/ContextMenu/ContextMenu.js +0 -1
- package/dist/ReactComponents/ContextMenu/ContextMenuContainer.js +0 -1
- package/dist/ReactComponents/ContextMenu/ContextMenuState.js +0 -1
- package/dist/ReactComponents/DatePicker.js +0 -1
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js +0 -1
- package/dist/ReactComponents/DropDown/DropDown.js +0 -1
- package/dist/ReactComponents/DropDown/DropDownBase.js +0 -1
- package/dist/ReactComponents/ErrorHandler.js +0 -1
- package/dist/ReactComponents/FileManager/FileBasicInput.js +0 -1
- package/dist/ReactComponents/FileManager/FileContext.js +0 -1
- package/dist/ReactComponents/FileManager/FileDropArea.js +0 -1
- package/dist/ReactComponents/FileManager/FileInput.js +0 -1
- package/dist/ReactComponents/FileManager/FileUploadButton.js +0 -1
- package/dist/ReactComponents/FileManager/FileUploadProgress.js +0 -1
- package/dist/ReactComponents/Form.js +0 -1
- package/dist/ReactComponents/FormContext.js +0 -1
- package/dist/ReactComponents/FormGroup/FormGroup.js +0 -1
- package/dist/ReactComponents/FormGroup/FormGroupFloating.js +0 -1
- package/dist/ReactComponents/FormGroup/FormGroupInline.js +0 -1
- package/dist/ReactComponents/Grid/ButtonColumn.js +0 -1
- package/dist/ReactComponents/Grid/Column.js +0 -1
- package/dist/ReactComponents/Grid/ColumnHelper.js +0 -1
- package/dist/ReactComponents/Grid/Grid.d.ts +2 -0
- package/dist/ReactComponents/Grid/Grid.js +3 -3
- package/dist/ReactComponents/Grid/Row.js +0 -1
- package/dist/ReactComponents/Grid/_Exports.js +0 -1
- package/dist/ReactComponents/GridLayout.js +0 -1
- package/dist/ReactComponents/Input.js +0 -1
- package/dist/ReactComponents/InputHelpers.js +0 -1
- package/dist/ReactComponents/Link.d.ts +13 -0
- package/dist/ReactComponents/Link.js +28 -0
- package/dist/ReactComponents/Loader.js +0 -1
- package/dist/ReactComponents/Modal/Modal.js +0 -1
- package/dist/ReactComponents/Modal/ModalContainer.js +0 -1
- package/dist/ReactComponents/Modal/ModalPortal.js +0 -1
- package/dist/ReactComponents/Notifications/Alert.js +0 -1
- package/dist/ReactComponents/Notifications/Toast.js +0 -1
- package/dist/ReactComponents/Notifications/ToastContainer.js +0 -1
- package/dist/ReactComponents/NumberInput.d.ts +3 -1
- package/dist/ReactComponents/NumberInput.js +75 -41
- package/dist/ReactComponents/Paging/BasicPagerControls.js +0 -1
- package/dist/ReactComponents/Paging/PageSizeControl.js +0 -1
- package/dist/ReactComponents/Paging/Pager.js +0 -1
- package/dist/ReactComponents/ProgressBar.js +0 -1
- package/dist/ReactComponents/PropTypes.js +3 -3
- package/dist/ReactComponents/RadioList.js +0 -1
- package/dist/ReactComponents/ReactHelpers.js +0 -1
- package/dist/ReactComponents/Slider.js +0 -1
- package/dist/ReactComponents/StateObserver.js +0 -1
- package/dist/ReactComponents/Tabs/Tab.js +0 -1
- package/dist/ReactComponents/Tabs/TabContainer.js +0 -1
- package/dist/ReactComponents/Tabs/TabManager.js +0 -1
- package/dist/ReactComponents/Tooltip.js +0 -1
- package/dist/ReactComponents/TooltipHelper.js +0 -1
- package/dist/ReactComponents/TooltipProvider.js +0 -1
- package/dist/ReactComponents/ValidationSummary.js +0 -1
- package/dist/ReactComponents/_Exports.d.ts +2 -1
- package/dist/ReactComponents/_Exports.js +2 -2
- package/dist/ReactComponents/_Managers.js +0 -1
- package/dist/Routing/BreadCrumbItem.js +0 -1
- package/dist/Routing/IRouteChangedProps.js +0 -1
- package/dist/Routing/IRouteParameter.js +0 -1
- package/dist/Routing/MenuRoute.js +0 -1
- package/dist/Routing/NavigationHelper.js +0 -1
- package/dist/Routing/PageLeaveHandler.js +0 -1
- package/dist/Routing/RouteProvider.js +0 -1
- package/dist/Routing/RouteView.js +0 -1
- package/dist/Routing/RoutingState.js +0 -1
- package/dist/Routing/ViewParameter.js +0 -1
- package/dist/Routing/ViewParameterList.js +0 -1
- package/dist/Routing/index.js +0 -1
- package/dist/Services/DisposeHelper.js +0 -1
- package/dist/Services/IDisposeHelper.js +0 -1
- package/dist/Views/EmptyViewModel.js +0 -1
- package/dist/Views/IViewModel.js +0 -1
- package/dist/Views/PersistentViewBase.js +0 -1
- package/dist/Views/ViewBase.js +0 -1
- package/dist/Views/ViewComponentBase.js +0 -1
- package/dist/Views/ViewModelBase.js +0 -1
- package/dist/Views/ViewState.js +0 -1
- package/dist/Views/index.js +0 -1
- package/dist/index.js +0 -1
- package/package.json +6 -5
- package/dist/Modules/NeoReactModule.js.map +0 -1
- package/dist/Modules/ReactSetup.js.map +0 -1
- package/dist/Modules/Types.js.map +0 -1
- package/dist/React/AutoRunner.js.map +0 -1
- package/dist/React/DataView.js.map +0 -1
- package/dist/React/Decorators.js.map +0 -1
- package/dist/React/ReactModelCreator.js.map +0 -1
- package/dist/React/Utils.js.map +0 -1
- package/dist/ReactComponents/Button.js.map +0 -1
- package/dist/ReactComponents/Card.js.map +0 -1
- package/dist/ReactComponents/Collapsable.js.map +0 -1
- package/dist/ReactComponents/CollapsableBase.js.map +0 -1
- package/dist/ReactComponents/ColorPicker.js.map +0 -1
- package/dist/ReactComponents/ComponentBase.js.map +0 -1
- package/dist/ReactComponents/ContextMenu/ContextMenu.js.map +0 -1
- package/dist/ReactComponents/ContextMenu/ContextMenuContainer.js.map +0 -1
- package/dist/ReactComponents/ContextMenu/ContextMenuState.js.map +0 -1
- package/dist/ReactComponents/DatePicker.js.map +0 -1
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js.map +0 -1
- package/dist/ReactComponents/DropDown/DropDown.js.map +0 -1
- package/dist/ReactComponents/DropDown/DropDownBase.js.map +0 -1
- package/dist/ReactComponents/ErrorHandler.js.map +0 -1
- package/dist/ReactComponents/FileManager/FileBasicInput.js.map +0 -1
- package/dist/ReactComponents/FileManager/FileContext.js.map +0 -1
- package/dist/ReactComponents/FileManager/FileDropArea.js.map +0 -1
- package/dist/ReactComponents/FileManager/FileInput.js.map +0 -1
- package/dist/ReactComponents/FileManager/FileUploadButton.js.map +0 -1
- package/dist/ReactComponents/FileManager/FileUploadProgress.js.map +0 -1
- package/dist/ReactComponents/Form.js.map +0 -1
- package/dist/ReactComponents/FormContext.js.map +0 -1
- package/dist/ReactComponents/FormGroup/FormGroup.js.map +0 -1
- package/dist/ReactComponents/FormGroup/FormGroupFloating.js.map +0 -1
- package/dist/ReactComponents/FormGroup/FormGroupInline.js.map +0 -1
- package/dist/ReactComponents/Grid/ButtonColumn.js.map +0 -1
- package/dist/ReactComponents/Grid/Column.js.map +0 -1
- package/dist/ReactComponents/Grid/ColumnHelper.js.map +0 -1
- package/dist/ReactComponents/Grid/Grid.js.map +0 -1
- package/dist/ReactComponents/Grid/Row.js.map +0 -1
- package/dist/ReactComponents/Grid/_Exports.js.map +0 -1
- package/dist/ReactComponents/GridLayout.js.map +0 -1
- package/dist/ReactComponents/Input.js.map +0 -1
- package/dist/ReactComponents/InputHelpers.js.map +0 -1
- package/dist/ReactComponents/Loader.js.map +0 -1
- package/dist/ReactComponents/Modal/Modal.js.map +0 -1
- package/dist/ReactComponents/Modal/ModalContainer.js.map +0 -1
- package/dist/ReactComponents/Modal/ModalPortal.js.map +0 -1
- package/dist/ReactComponents/Notifications/Alert.js.map +0 -1
- package/dist/ReactComponents/Notifications/Toast.js.map +0 -1
- package/dist/ReactComponents/Notifications/ToastContainer.js.map +0 -1
- package/dist/ReactComponents/NumberInput.js.map +0 -1
- package/dist/ReactComponents/Paging/BasicPagerControls.js.map +0 -1
- package/dist/ReactComponents/Paging/PageSizeControl.js.map +0 -1
- package/dist/ReactComponents/Paging/Pager.js.map +0 -1
- package/dist/ReactComponents/ProgressBar.js.map +0 -1
- package/dist/ReactComponents/PropTypes.js.map +0 -1
- package/dist/ReactComponents/RadioList.js.map +0 -1
- package/dist/ReactComponents/ReactHelpers.js.map +0 -1
- package/dist/ReactComponents/Slider.js.map +0 -1
- package/dist/ReactComponents/StateObserver.js.map +0 -1
- package/dist/ReactComponents/Tabs/Tab.js.map +0 -1
- package/dist/ReactComponents/Tabs/TabContainer.js.map +0 -1
- package/dist/ReactComponents/Tabs/TabManager.js.map +0 -1
- package/dist/ReactComponents/Tooltip.js.map +0 -1
- package/dist/ReactComponents/TooltipHelper.js.map +0 -1
- package/dist/ReactComponents/TooltipProvider.js.map +0 -1
- package/dist/ReactComponents/ValidationSummary.js.map +0 -1
- package/dist/ReactComponents/_Exports.js.map +0 -1
- package/dist/ReactComponents/_Managers.js.map +0 -1
- package/dist/Routing/BreadCrumbItem.js.map +0 -1
- package/dist/Routing/IRouteChangedProps.js.map +0 -1
- package/dist/Routing/IRouteParameter.js.map +0 -1
- package/dist/Routing/MenuRoute.js.map +0 -1
- package/dist/Routing/NavigationHelper.js.map +0 -1
- package/dist/Routing/PageLeaveHandler.js.map +0 -1
- package/dist/Routing/RouteProvider.js.map +0 -1
- package/dist/Routing/RouteView.js.map +0 -1
- package/dist/Routing/RoutingState.js.map +0 -1
- package/dist/Routing/ViewParameter.js.map +0 -1
- package/dist/Routing/ViewParameterList.js.map +0 -1
- package/dist/Routing/index.js.map +0 -1
- package/dist/Services/DisposeHelper.js.map +0 -1
- package/dist/Services/IDisposeHelper.js.map +0 -1
- package/dist/Views/EmptyViewModel.js.map +0 -1
- package/dist/Views/IViewModel.js.map +0 -1
- package/dist/Views/PersistentViewBase.js.map +0 -1
- package/dist/Views/ViewBase.js.map +0 -1
- package/dist/Views/ViewComponentBase.js.map +0 -1
- package/dist/Views/ViewModelBase.js.map +0 -1
- package/dist/Views/ViewState.js.map +0 -1
- package/dist/Views/index.js.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/Modules/Types.js
CHANGED
package/dist/React/AutoRunner.js
CHANGED
package/dist/React/DataView.js
CHANGED
package/dist/React/Decorators.js
CHANGED
|
@@ -89,7 +89,6 @@ var ReactModelCreator = /** @class */ (function (_super) {
|
|
|
89
89
|
if (typeof onChange.newValue === "string") {
|
|
90
90
|
throw "Error: tried to assign a string to a date property.";
|
|
91
91
|
}
|
|
92
|
-
propertyInstance.sortValue = onChange.newValue ? onChange.newValue.getTime() : 0;
|
|
93
92
|
}
|
|
94
93
|
}
|
|
95
94
|
observable.previousValue = observable.value;
|
|
@@ -122,4 +121,3 @@ var ReactModelCreator = /** @class */ (function (_super) {
|
|
|
122
121
|
return ReactModelCreator;
|
|
123
122
|
}(ModelCreatorBase));
|
|
124
123
|
export { ReactModelCreator };
|
|
125
|
-
//# sourceMappingURL=ReactModelCreator.js.map
|
package/dist/React/Utils.js
CHANGED
|
@@ -65,6 +65,8 @@ export interface IGridProps<T> extends React.HTMLProps<HTMLTableElement> {
|
|
|
65
65
|
showHover?: boolean;
|
|
66
66
|
/** When specified, the table size will be reduced (by reducing the padding sizes in each cell by half). */
|
|
67
67
|
isSmallTable?: boolean;
|
|
68
|
+
/** Additional footer row(s) to display below the main footer row. */
|
|
69
|
+
footerContent?: (data: T[]) => React.ReactNode;
|
|
68
70
|
}
|
|
69
71
|
export default class Grid<T> extends React.Component<IGridProps<T>> {
|
|
70
72
|
static contextType: React.Context<import("../../React/DataView").DataViewContextParams<unknown>>;
|
|
@@ -32,7 +32,7 @@ var Grid = /** @class */ (function (_super) {
|
|
|
32
32
|
}
|
|
33
33
|
Grid.prototype.render = function () {
|
|
34
34
|
var _this = this;
|
|
35
|
-
var _a = this.props, items = _a.items, showAddButton = _a.showAddButton, addButton = _a.addButton, filterPredicate = _a.filterPredicate, keyProperty = _a.keyProperty, allowSort = _a.allowSort, expandAll = _a.expandAll, collapseAll = _a.collapseAll, initialSort = _a.initialSort, initialSortAscending = _a.initialSortAscending, isBordered = _a.isBordered, isStriped = _a.isStriped, isBorderless = _a.isBorderless, showHover = _a.showHover, isSmallTable = _a.isSmallTable, domProps = __rest(_a, ["items", "showAddButton", "addButton", "filterPredicate", "keyProperty", "allowSort", "expandAll", "collapseAll", "initialSort", "initialSortAscending", "isBordered", "isStriped", "isBorderless", "showHover", "isSmallTable"]);
|
|
35
|
+
var _a = this.props, items = _a.items, showAddButton = _a.showAddButton, addButton = _a.addButton, filterPredicate = _a.filterPredicate, keyProperty = _a.keyProperty, allowSort = _a.allowSort, expandAll = _a.expandAll, collapseAll = _a.collapseAll, initialSort = _a.initialSort, initialSortAscending = _a.initialSortAscending, isBordered = _a.isBordered, isStriped = _a.isStriped, isBorderless = _a.isBorderless, showHover = _a.showHover, isSmallTable = _a.isSmallTable, footerContent = _a.footerContent, domProps = __rest(_a, ["items", "showAddButton", "addButton", "filterPredicate", "keyProperty", "allowSort", "expandAll", "collapseAll", "initialSort", "initialSortAscending", "isBordered", "isStriped", "isBorderless", "showHover", "isSmallTable", "footerContent"]);
|
|
36
36
|
if (expandAll === true) {
|
|
37
37
|
this.gridContext.expandAll = true;
|
|
38
38
|
}
|
|
@@ -90,9 +90,10 @@ var Grid = /** @class */ (function (_super) {
|
|
|
90
90
|
React.createElement(GridContext.Provider, { value: this.gridContext },
|
|
91
91
|
React.createElement(TableSection, { type: "header" }, this.headerItem && this.props.children(this.headerItem, this.headerItem.meta)),
|
|
92
92
|
React.createElement(TableSection, { type: "body" }, this.gridContext.dataView.getItems().map(function (item) { return (React.createElement(ItemGroup, { item: item, key: keyProperty ? item[keyProperty] : item.entityIdentifier, template: _this.props.children })); })),
|
|
93
|
-
React.createElement(Observer, null, function () { return (showAddButton || addButton || _this.gridContext.hasSummaries) &&
|
|
93
|
+
React.createElement(Observer, null, function () { return (showAddButton || addButton || _this.gridContext.hasSummaries || footerContent) &&
|
|
94
94
|
React.createElement(TableSection, { type: "footer" },
|
|
95
95
|
_this.gridContext.hasSummaries && _this.headerItem && _this.props.children(_this.headerItem, _this.headerItem.meta),
|
|
96
|
+
footerContent && footerContent(_this.gridContext.dataView.getItems()),
|
|
96
97
|
(showAddButton || addButton) && React.createElement(AddButtonRow, { addButton: addButton })); }))));
|
|
97
98
|
};
|
|
98
99
|
Grid.prototype.setInitialSort = function (initialSort, initialSortAscending) {
|
|
@@ -196,4 +197,3 @@ var ItemGroup = /** @class */ (function (_super) {
|
|
|
196
197
|
], ItemGroup);
|
|
197
198
|
return ItemGroup;
|
|
198
199
|
}(React.Component));
|
|
199
|
-
//# sourceMappingURL=Grid.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ILinkProps extends React.HTMLProps<HTMLAnchorElement> {
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Renders an anchor tag with an href of '/' unless otherwise specified.
|
|
6
|
+
* The onClick event will call preventDefault() so that the anchor acts like a button instead of a link to a url.
|
|
7
|
+
*/
|
|
8
|
+
export default class Link extends React.Component<ILinkProps> {
|
|
9
|
+
constructor(props: ILinkProps);
|
|
10
|
+
private onClick;
|
|
11
|
+
render(): JSX.Element;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { __assign, __extends } from "tslib";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Renders an anchor tag with an href of '/' unless otherwise specified.
|
|
5
|
+
* The onClick event will call preventDefault() so that the anchor acts like a button instead of a link to a url.
|
|
6
|
+
*/
|
|
7
|
+
var Link = /** @class */ (function (_super) {
|
|
8
|
+
__extends(Link, _super);
|
|
9
|
+
function Link(props) {
|
|
10
|
+
var _this = _super.call(this, props) || this;
|
|
11
|
+
_this.onClick = _this.onClick.bind(_this);
|
|
12
|
+
return _this;
|
|
13
|
+
}
|
|
14
|
+
Link.prototype.onClick = function (e) {
|
|
15
|
+
e.preventDefault();
|
|
16
|
+
if (this.props.onClick) {
|
|
17
|
+
this.props.onClick(e);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
Link.prototype.render = function () {
|
|
21
|
+
var _a;
|
|
22
|
+
var props = this.props;
|
|
23
|
+
var href = (_a = props.href, (_a !== null && _a !== void 0 ? _a : "/"));
|
|
24
|
+
return React.createElement("a", __assign({}, props, { href: href, onClick: this.onClick }), this.props.children);
|
|
25
|
+
};
|
|
26
|
+
return Link;
|
|
27
|
+
}(React.Component));
|
|
28
|
+
export default Link;
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { IBindableEditorProps } from './PropTypes';
|
|
3
3
|
import { FormContext } from './FormContext';
|
|
4
4
|
import { Misc } from '@singularsystems/neo-core';
|
|
5
|
+
import Decimal from 'decimal.js-light';
|
|
5
6
|
import ComponentBase from './ComponentBase';
|
|
6
7
|
export interface INumberInputSpecificProps {
|
|
7
8
|
/** Format string of number */
|
|
@@ -25,7 +26,7 @@ export declare class FormatState {
|
|
|
25
26
|
zeroText?: string | undefined;
|
|
26
27
|
constructor(isPercent: boolean, hasExternalPercentSymbol: boolean, formatString: string, zeroText?: string | undefined);
|
|
27
28
|
static create(numericType: Misc.DataType, numProps?: INumberInputSpecificProps, appendText?: string): FormatState;
|
|
28
|
-
getFormattedValue(value?: number): string;
|
|
29
|
+
getFormattedValue(value?: number | Decimal | null): string;
|
|
29
30
|
}
|
|
30
31
|
export default class NumberInput extends ComponentBase<INumberInputProps> {
|
|
31
32
|
static contextType: React.Context<import("./FormContext").FormContextParams>;
|
|
@@ -39,6 +40,7 @@ export default class NumberInput extends ComponentBase<INumberInputProps> {
|
|
|
39
40
|
constructor(props: INumberInputProps);
|
|
40
41
|
private onChanged;
|
|
41
42
|
private onFocus;
|
|
43
|
+
private getBindValueAsNumber;
|
|
42
44
|
private setFocusedText;
|
|
43
45
|
private onBlur;
|
|
44
46
|
private onKeyDown;
|
|
@@ -3,6 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { BindPropsHelper } from './PropTypes';
|
|
4
4
|
import { FormContext } from './FormContext';
|
|
5
5
|
import { Misc, NumberUtils, Utils } from '@singularsystems/neo-core';
|
|
6
|
+
import Decimal from 'decimal.js-light';
|
|
6
7
|
import { InputHelpers } from './InputHelpers';
|
|
7
8
|
import { observer } from 'mobx-react';
|
|
8
9
|
import memoize from 'memoize-one';
|
|
@@ -24,9 +25,10 @@ var FormatState = /** @class */ (function () {
|
|
|
24
25
|
formatString = NumberUtils.getFormatString(numProps.format, numProps.currencySymbol);
|
|
25
26
|
}
|
|
26
27
|
else {
|
|
28
|
+
var hasDecimals = numericType === Misc.DataType.Float || numericType === Misc.DataType.Decimal;
|
|
27
29
|
var format = ((_a = numProps) === null || _a === void 0 ? void 0 : _a.currencySymbol) ?
|
|
28
|
-
(
|
|
29
|
-
(
|
|
30
|
+
(hasDecimals ? Misc.NumberFormat.CurrencyDecimals : Misc.NumberFormat.CurrencyNoDecimals) :
|
|
31
|
+
(hasDecimals ? Misc.NumberFormat.Decimals : Misc.NumberFormat.NoDecimals);
|
|
30
32
|
formatString = NumberUtils.getFormatString(format, (_b = numProps) === null || _b === void 0 ? void 0 : _b.currencySymbol);
|
|
31
33
|
}
|
|
32
34
|
}
|
|
@@ -43,6 +45,9 @@ var FormatState = /** @class */ (function () {
|
|
|
43
45
|
return this.zeroText;
|
|
44
46
|
}
|
|
45
47
|
if (value !== undefined && value !== null) {
|
|
48
|
+
if (value instanceof Decimal) {
|
|
49
|
+
value = value.toNumber();
|
|
50
|
+
}
|
|
46
51
|
if (typeof value === "number") {
|
|
47
52
|
if (this.hasExternalPercentSymbol) {
|
|
48
53
|
value *= 100;
|
|
@@ -77,23 +82,35 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
77
82
|
}
|
|
78
83
|
NumberInput.prototype.onChanged = function (e) {
|
|
79
84
|
var newValue;
|
|
85
|
+
if (e.target.value !== "" && isNaN(parseFloat(e.target.value))) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
80
88
|
if (e.target.value == "") {
|
|
81
|
-
newValue = this.props.bind.propertyInfo.allowNulls ? null : 0;
|
|
89
|
+
newValue = this.props.bind.propertyInfo.allowNulls ? null : new Decimal(0);
|
|
82
90
|
}
|
|
83
91
|
else if (this.formatState.isPercent && NumberUtils.transformPercent) {
|
|
84
|
-
newValue =
|
|
92
|
+
newValue = new Decimal(e.target.value).dividedBy(100);
|
|
85
93
|
}
|
|
86
|
-
else if (this.numericType
|
|
87
|
-
newValue =
|
|
94
|
+
else if (this.numericType === Misc.DataType.Float || this.numericType === Misc.DataType.Decimal) {
|
|
95
|
+
newValue = new Decimal(e.target.value);
|
|
88
96
|
}
|
|
89
97
|
else {
|
|
90
|
-
|
|
98
|
+
// Rounds to zero.
|
|
99
|
+
newValue = new Decimal(e.target.value).toDecimalPlaces(0, Decimal.ROUND_DOWN);
|
|
100
|
+
}
|
|
101
|
+
if (newValue === null) {
|
|
102
|
+
this.props.bind.value = newValue;
|
|
91
103
|
}
|
|
92
|
-
|
|
93
|
-
if (
|
|
104
|
+
else {
|
|
105
|
+
if (!this.props.numProps || this.props.numProps.autoRound !== false) {
|
|
94
106
|
newValue = NumberUtils.roundUsingFormat(newValue, this.formatState.formatString, this.formatState.hasExternalPercentSymbol);
|
|
95
107
|
}
|
|
96
|
-
this.
|
|
108
|
+
if (this.numericType === Misc.DataType.Decimal) {
|
|
109
|
+
this.props.bind.value = newValue;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
this.props.bind.value = newValue.toNumber();
|
|
113
|
+
}
|
|
97
114
|
}
|
|
98
115
|
};
|
|
99
116
|
NumberInput.prototype.onFocus = function () {
|
|
@@ -103,12 +120,21 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
103
120
|
element.select();
|
|
104
121
|
}
|
|
105
122
|
};
|
|
123
|
+
NumberInput.prototype.getBindValueAsNumber = function () {
|
|
124
|
+
var propertyValue = this.props.bind.value;
|
|
125
|
+
if (propertyValue instanceof Decimal) {
|
|
126
|
+
return propertyValue.toNumber();
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return propertyValue;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
106
132
|
NumberInput.prototype.setFocusedText = function (element) {
|
|
107
133
|
this.hasFocus = true;
|
|
108
|
-
var
|
|
134
|
+
var numberValue = this.getBindValueAsNumber();
|
|
109
135
|
var stringValue;
|
|
110
|
-
if (!
|
|
111
|
-
if ((this.props.bind.propertyInfo.allowNulls || element.readOnly) &&
|
|
136
|
+
if (!numberValue) {
|
|
137
|
+
if ((this.props.bind.propertyInfo.allowNulls || element.readOnly) && numberValue === 0) {
|
|
112
138
|
stringValue = "0";
|
|
113
139
|
}
|
|
114
140
|
else {
|
|
@@ -117,13 +143,13 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
117
143
|
}
|
|
118
144
|
else {
|
|
119
145
|
if (element.readOnly || !this.props.numProps || this.props.numProps.autoRound !== false) {
|
|
120
|
-
stringValue = NumberUtils.formatRaw(
|
|
146
|
+
stringValue = NumberUtils.formatRaw(numberValue, this.formatState.formatString, this.formatState.hasExternalPercentSymbol);
|
|
121
147
|
}
|
|
122
148
|
else {
|
|
123
149
|
if (this.formatState.isPercent && NumberUtils.transformPercent) {
|
|
124
|
-
|
|
150
|
+
numberValue *= 100;
|
|
125
151
|
}
|
|
126
|
-
stringValue =
|
|
152
|
+
stringValue = numberValue.toString();
|
|
127
153
|
}
|
|
128
154
|
}
|
|
129
155
|
element.value = stringValue;
|
|
@@ -137,31 +163,40 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
137
163
|
NumberInput.prototype.onKeyDown = function (e) {
|
|
138
164
|
var element = this.inputElement.current;
|
|
139
165
|
if (!this.isReadOnly && element && (e.keyCode === 38 || e.keyCode === 40)) {
|
|
140
|
-
var
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
decimalIndex = element.value.indexOf("
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
166
|
+
var value = this.getBindValueAsNumber();
|
|
167
|
+
if (value !== null) {
|
|
168
|
+
var selectionIndex = element.selectionEnd;
|
|
169
|
+
var deltaValue = 1;
|
|
170
|
+
var decimalIndex = element.value.indexOf(".");
|
|
171
|
+
if (decimalIndex < 0) {
|
|
172
|
+
decimalIndex = element.value.indexOf(",");
|
|
173
|
+
}
|
|
174
|
+
if (decimalIndex > 0 && selectionIndex && selectionIndex > decimalIndex) {
|
|
175
|
+
deltaValue = 0.01;
|
|
176
|
+
}
|
|
177
|
+
if (this.formatState.isPercent && NumberUtils.transformPercent) {
|
|
178
|
+
deltaValue /= 100;
|
|
179
|
+
}
|
|
180
|
+
if (e.keyCode === 38) {
|
|
181
|
+
// Up
|
|
182
|
+
value += deltaValue;
|
|
183
|
+
}
|
|
184
|
+
else if (e.keyCode === 40) {
|
|
185
|
+
// Down
|
|
186
|
+
value -= deltaValue;
|
|
187
|
+
}
|
|
188
|
+
if (this.numericType === Misc.DataType.Decimal) {
|
|
189
|
+
this.props.bind.value = new Decimal(value);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
this.props.bind.value = value;
|
|
193
|
+
}
|
|
194
|
+
this.setFocusedText(element);
|
|
195
|
+
if (selectionIndex !== null) {
|
|
196
|
+
element.selectionStart = element.selectionEnd = selectionIndex;
|
|
197
|
+
}
|
|
198
|
+
e.preventDefault();
|
|
163
199
|
}
|
|
164
|
-
e.preventDefault();
|
|
165
200
|
}
|
|
166
201
|
};
|
|
167
202
|
NumberInput.prototype.componentDidMount = function () {
|
|
@@ -202,4 +237,3 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
202
237
|
return NumberInput;
|
|
203
238
|
}(ComponentBase));
|
|
204
239
|
export default NumberInput;
|
|
205
|
-
//# sourceMappingURL=NumberInput.js.map
|