@singularsystems/neo-react 0.10.58 → 0.10.62
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/ReactComponents/DatePicker.d.ts +1 -0
- package/dist/ReactComponents/DatePicker.js +6 -2
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.d.ts +4 -0
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js +3 -0
- package/dist/ReactComponents/DropDown/DropDown.js +4 -1
- package/dist/ReactComponents/Form.js +1 -1
- package/dist/ReactComponents/Grid/ButtonColumn.js +1 -1
- package/dist/ReactComponents/Grid/Column.js +2 -2
- package/dist/ReactComponents/Input.js +1 -1
- package/dist/ReactComponents/InputHelpers.d.ts +2 -2
- package/dist/ReactComponents/InputHelpers.js +3 -3
- package/dist/ReactComponents/NumberInput.d.ts +7 -3
- package/dist/ReactComponents/NumberInput.js +39 -20
- package/dist/Routing/ViewParameter.d.ts +20 -0
- package/dist/Routing/ViewParameter.js +11 -3
- package/dist/Routing/ViewParameterList.js +16 -0
- package/dist/Views/ViewBase.d.ts +1 -1
- package/dist/Views/ViewBase.js +16 -5
- package/package.json +2 -2
- package/styles/DatePicker.scss +11 -0
|
@@ -12,6 +12,7 @@ export default class DatePicker extends ComponentBase<INeoDatePickerProps> {
|
|
|
12
12
|
private container;
|
|
13
13
|
private datePicker?;
|
|
14
14
|
private isReadOnly;
|
|
15
|
+
private inputRef;
|
|
15
16
|
constructor(props: INeoDatePickerProps);
|
|
16
17
|
componentDidMount(): void;
|
|
17
18
|
componentWillUnmount(): void;
|
|
@@ -11,6 +11,7 @@ var DatePicker = /** @class */ (function (_super) {
|
|
|
11
11
|
function DatePicker(props) {
|
|
12
12
|
var _this = _super.call(this, props) || this;
|
|
13
13
|
_this.isReadOnly = false;
|
|
14
|
+
_this.inputRef = React.createRef();
|
|
14
15
|
_this.container = React.createRef();
|
|
15
16
|
return _this;
|
|
16
17
|
}
|
|
@@ -33,6 +34,9 @@ var DatePicker = /** @class */ (function (_super) {
|
|
|
33
34
|
this.isReadOnly = !!domProps.readOnly;
|
|
34
35
|
var displayInfo = this.props.bind.validator.getDisplayState(this.context.validationDisplayMode);
|
|
35
36
|
displayInfo.applyToDom(domProps, !splitProps.inGroup);
|
|
37
|
+
if (splitProps.editor.inputElement) {
|
|
38
|
+
this.inputRef = splitProps.editor.inputElement;
|
|
39
|
+
}
|
|
36
40
|
if (this.datePicker) {
|
|
37
41
|
this.datePicker.update(splitProps.dateProps, this.props.bind, this.isReadOnly);
|
|
38
42
|
}
|
|
@@ -40,8 +44,8 @@ var DatePicker = /** @class */ (function (_super) {
|
|
|
40
44
|
// Create dependency on bound value on initial render.
|
|
41
45
|
void this.props.bind.value;
|
|
42
46
|
}
|
|
43
|
-
return (React.createElement("div", { className: "neo-datepicker-container", ref: this.container },
|
|
44
|
-
InputHelpers.surroundWithInputGroup(React.createElement("input", __assign({ type: "text" }, domProps, { ref:
|
|
47
|
+
return (React.createElement("div", { className: "neo-datepicker-container", ref: this.container }, Components.DatePicker.mustShowInput(splitProps.dateProps) &&
|
|
48
|
+
InputHelpers.surroundWithInputGroup(React.createElement("input", __assign({ type: "text" }, domProps, { ref: this.inputRef })), splitProps.editor, this.inputRef)));
|
|
45
49
|
};
|
|
46
50
|
DatePicker.contextType = FormContext;
|
|
47
51
|
DatePicker = __decorate([
|
|
@@ -21,6 +21,10 @@ interface IAutoCompleteCommonProps<T> extends ICommonEditorProps, Props<IOption,
|
|
|
21
21
|
items?: ItemSource<T>;
|
|
22
22
|
valueMember?: keyof T;
|
|
23
23
|
displayMember?: keyof T;
|
|
24
|
+
/**
|
|
25
|
+
* Function used to filter items out of the datasource.
|
|
26
|
+
* **Note:** this will only apply to the `items` prop. */
|
|
27
|
+
filterPredicate?: (item: T) => boolean;
|
|
24
28
|
/**
|
|
25
29
|
* Property of an item to use as the description.
|
|
26
30
|
*
|
|
@@ -134,6 +134,9 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
|
|
|
134
134
|
var defaultItems = undefined;
|
|
135
135
|
if (this.props.items) {
|
|
136
136
|
var items_1 = this.getItems(this.props.items);
|
|
137
|
+
if (this.props.filterPredicate !== undefined) {
|
|
138
|
+
items_1 = items_1.filter(this.props.filterPredicate);
|
|
139
|
+
}
|
|
137
140
|
defaultItems = this.mapTArrayToOptions(items_1);
|
|
138
141
|
if (descriptionMember === undefined && items_1.length > 0) {
|
|
139
142
|
if (EnumHelper.isEnumItem(items_1[0])) {
|
|
@@ -118,9 +118,12 @@ var DropDown = /** @class */ (function (_super) {
|
|
|
118
118
|
}
|
|
119
119
|
var valueIsBlank = value === undefined || value === null;
|
|
120
120
|
var nullText = (valueIsBlank || ((_d = splitProps.select) === null || _d === void 0 ? void 0 : _d.deSelectText) === undefined) ? (_e = splitProps.select) === null || _e === void 0 ? void 0 : _e.nullText : (_f = splitProps.select) === null || _f === void 0 ? void 0 : _f.deSelectText;
|
|
121
|
+
if (valueIsBlank) {
|
|
122
|
+
domProps.className = Utils.joinWithSpaces(domProps.className, "select-no-value");
|
|
123
|
+
}
|
|
121
124
|
control =
|
|
122
125
|
React.createElement("select", __assign({ value: valueIsBlank ? "" : value, onChange: this.onItemSelected, ref: splitProps.editor.inputElement }, domProps),
|
|
123
|
-
addBlankItem && React.createElement("option",
|
|
126
|
+
addBlankItem && React.createElement("option", { className: "option-default" }, nullText),
|
|
124
127
|
items.map(function (item) { return (React.createElement("option", { value: item[_this.valueMember], key: item[_this.valueMember] }, item[_this.displayMember])); }));
|
|
125
128
|
}
|
|
126
129
|
return (InputHelpers.surroundWithInputGroup(control, splitProps.editor));
|
|
@@ -40,7 +40,7 @@ var Form = /** @class */ (function (_super) {
|
|
|
40
40
|
var onClose = this.disposeReaction.bind(this);
|
|
41
41
|
var codeModal_1 = ModalUtils.showModal(this.props.invalidSummaryTitle || "Invalid data", React.createElement(Observer, null, function () {
|
|
42
42
|
return React.createElement("div", null,
|
|
43
|
-
_this.props.invalidSummaryText || "Cannot continue due to the following
|
|
43
|
+
_this.props.invalidSummaryText || "Cannot continue due to the following issues:",
|
|
44
44
|
React.createElement(ValidationSummary, { graph: Validation.getValidationSummary(model), hideTopLevelTitle: !(model instanceof Array) }));
|
|
45
45
|
}), { onClose: onClose, closeButton: { text: "Ok", onClick: onClose } });
|
|
46
46
|
// Listen for when isValid changes to true, in case there is an async rule running.
|
|
@@ -72,7 +72,7 @@ var ButtonColumn = /** @class */ (function (_super) {
|
|
|
72
72
|
React.createElement("th", __assign({}, domProps), this.section === "header" && label) :
|
|
73
73
|
React.createElement("td", __assign({}, domProps),
|
|
74
74
|
childAlignment === "right" ? buttons : undefined,
|
|
75
|
-
this.props.children,
|
|
75
|
+
this.props.children instanceof Function ? this.props.children() : this.props.children,
|
|
76
76
|
childAlignment !== "right" ? buttons : undefined));
|
|
77
77
|
};
|
|
78
78
|
ButtonColumn.isColumnComponent = true;
|
|
@@ -163,7 +163,7 @@ var Column = /** @class */ (function (_super) {
|
|
|
163
163
|
if (editorProps.isReadOnly && !editorProps.requiresGroup) {
|
|
164
164
|
var rawValue = editorProps.bind.value;
|
|
165
165
|
if (this.controlType == ControlType.Number) {
|
|
166
|
-
displayValue = this.numFormatState(editorProps.bind.propertyInfo.propertyType, props.numProps).getFormattedValue(rawValue);
|
|
166
|
+
displayValue = this.numFormatState(editorProps.bind.propertyInfo, editorProps.bind.propertyInfo.propertyType, props.numProps).getFormattedValue(rawValue);
|
|
167
167
|
}
|
|
168
168
|
else if (this.controlType == ControlType.Date) {
|
|
169
169
|
displayValue = DateUtils.format(rawValue, props.dateProps ? props.dateProps.formatString : undefined);
|
|
@@ -197,7 +197,7 @@ var Column = /** @class */ (function (_super) {
|
|
|
197
197
|
var hasSummary = (colProps.sum && !!props.bind) || colProps.footerContent;
|
|
198
198
|
return (React.createElement("th", __assign({}, domProps), hasSummary &&
|
|
199
199
|
React.createElement(Observer, null, function () { return colProps.footerContent ? colProps.footerContent(_this.context.dataView.filteredItems) :
|
|
200
|
-
_this.numFormatState(props.bind.propertyInfo.propertyType, props.numProps).getFormattedValue(_this.context.dataView.filteredItems.sum(props.bind.propertyInfo)); })));
|
|
200
|
+
_this.numFormatState(props.bind.propertyInfo, props.bind.propertyInfo.propertyType, props.numProps).getFormattedValue(_this.context.dataView.filteredItems.sum(props.bind.propertyInfo)); })));
|
|
201
201
|
};
|
|
202
202
|
Column.isColumnComponent = true;
|
|
203
203
|
Column.contextType = GridContext;
|
|
@@ -106,7 +106,7 @@ var Input = /** @class */ (function (_super) {
|
|
|
106
106
|
splitProps.editor.append = this.props.bind.value ?
|
|
107
107
|
React.createElement(Button, __assign({ size: "sm" }, buttonOptions, { icon: !this.showPassword ? "far-eye fa-fw" : "far-eye-slash fa-fw", onClick: function () { return _this.showPassword = !_this.showPassword; } })) : null;
|
|
108
108
|
}
|
|
109
|
-
return (InputHelpers.surroundWithInputGroup(inputElement, splitProps.editor));
|
|
109
|
+
return (InputHelpers.surroundWithInputGroup(inputElement, splitProps.editor, this.domRef));
|
|
110
110
|
};
|
|
111
111
|
Input.contextType = FormContext;
|
|
112
112
|
__decorate([
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { ICommonEditorProps } from './PropTypes';
|
|
3
3
|
export declare class InputHelpers {
|
|
4
4
|
private static iconFactory?;
|
|
5
|
-
static surroundWithInputGroup<T>(element: T, props: ICommonEditorProps): JSX.Element | T;
|
|
5
|
+
static surroundWithInputGroup<T>(element: T, props: ICommonEditorProps, inputRef?: React.RefObject<HTMLElement>): JSX.Element | T;
|
|
6
6
|
}
|
|
@@ -4,7 +4,7 @@ import { NeoReactTypes } from '../Modules/Types';
|
|
|
4
4
|
var InputHelpers = /** @class */ (function () {
|
|
5
5
|
function InputHelpers() {
|
|
6
6
|
}
|
|
7
|
-
InputHelpers.surroundWithInputGroup = function (element, props) {
|
|
7
|
+
InputHelpers.surroundWithInputGroup = function (element, props, inputRef) {
|
|
8
8
|
if (!this.iconFactory) {
|
|
9
9
|
this.iconFactory = Misc.Globals.appService.get(NeoReactTypes.Components.IconFactory);
|
|
10
10
|
}
|
|
@@ -13,12 +13,12 @@ var InputHelpers = /** @class */ (function () {
|
|
|
13
13
|
(props.prependText || props.prepend) &&
|
|
14
14
|
React.createElement("div", { className: "input-group-prepend" },
|
|
15
15
|
props.prepend && (props.prepend instanceof Function ? props.prepend() : props.prepend),
|
|
16
|
-
props.prependText && React.createElement("span", { className: "input-group-text" }, this.iconFactory.textOrIcon(props.prependText))),
|
|
16
|
+
props.prependText && React.createElement("span", { className: "input-group-text", onClick: function () { var _a, _b; return (_b = (_a = inputRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.focus(); } }, this.iconFactory.textOrIcon(props.prependText))),
|
|
17
17
|
element,
|
|
18
18
|
(props.appendText || props.append) &&
|
|
19
19
|
React.createElement("div", { className: "input-group-append" },
|
|
20
20
|
props.append && (props.append instanceof Function ? props.append() : props.append),
|
|
21
|
-
props.appendText && React.createElement("span", { className: "input-group-text" }, this.iconFactory.textOrIcon(props.appendText)))));
|
|
21
|
+
props.appendText && React.createElement("span", { className: "input-group-text", onClick: function () { var _a, _b; return (_b = (_a = inputRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.focus(); } }, this.iconFactory.textOrIcon(props.appendText)))));
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
24
|
return element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { IBindableEditorProps } from './PropTypes';
|
|
3
3
|
import { FormContext } from './FormContext';
|
|
4
|
-
import { Misc } from '@singularsystems/neo-core';
|
|
4
|
+
import { Misc, Model } from '@singularsystems/neo-core';
|
|
5
5
|
import Decimal from 'decimal.js-light';
|
|
6
6
|
import ComponentBase from './ComponentBase';
|
|
7
7
|
export interface INumberInputSpecificProps {
|
|
@@ -25,10 +25,14 @@ export declare class FormatState {
|
|
|
25
25
|
isPercent: boolean;
|
|
26
26
|
hasExternalPercentSymbol: boolean;
|
|
27
27
|
formatString: string;
|
|
28
|
+
/** How many decimals the value is allowed. */
|
|
29
|
+
allowedDecimals: number;
|
|
28
30
|
zeroText?: string | undefined;
|
|
29
31
|
useNative?: boolean | undefined;
|
|
30
|
-
constructor(isPercent: boolean, hasExternalPercentSymbol: boolean, formatString: string,
|
|
31
|
-
|
|
32
|
+
constructor(isPercent: boolean, hasExternalPercentSymbol: boolean, formatString: string,
|
|
33
|
+
/** How many decimals the value is allowed. */
|
|
34
|
+
allowedDecimals: number, zeroText?: string | undefined, useNative?: boolean | undefined);
|
|
35
|
+
static create(propertyInfo: Model.PropertyInfo, numericType: Misc.DataType, numProps?: INumberInputSpecificProps, appendText?: string): FormatState;
|
|
32
36
|
getFormattedValue(value?: number | Decimal | null): string;
|
|
33
37
|
}
|
|
34
38
|
export default class NumberInput extends ComponentBase<INumberInputProps> {
|
|
@@ -9,37 +9,49 @@ import { observer } from 'mobx-react';
|
|
|
9
9
|
import memoize from 'memoize-one';
|
|
10
10
|
import ComponentBase from './ComponentBase';
|
|
11
11
|
var FormatState = /** @class */ (function () {
|
|
12
|
-
function FormatState(isPercent, hasExternalPercentSymbol, formatString,
|
|
12
|
+
function FormatState(isPercent, hasExternalPercentSymbol, formatString,
|
|
13
|
+
/** How many decimals the value is allowed. */
|
|
14
|
+
allowedDecimals, zeroText, useNative) {
|
|
13
15
|
this.isPercent = isPercent;
|
|
14
16
|
this.hasExternalPercentSymbol = hasExternalPercentSymbol;
|
|
15
17
|
this.formatString = formatString;
|
|
18
|
+
this.allowedDecimals = allowedDecimals;
|
|
16
19
|
this.zeroText = zeroText;
|
|
17
20
|
this.useNative = useNative;
|
|
18
21
|
}
|
|
19
|
-
FormatState.create = function (numericType, numProps, appendText) {
|
|
20
|
-
var _a, _b, _c, _d;
|
|
22
|
+
FormatState.create = function (propertyInfo, numericType, numProps, appendText) {
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
21
24
|
var isPercent = false;
|
|
22
25
|
var hasExternalPercentSymbol = false;
|
|
23
26
|
var formatString = numProps ? numProps.formatString : "";
|
|
27
|
+
var displayDecimals = 2;
|
|
28
|
+
if ((formatString && formatString.indexOf("%") >= 0)
|
|
29
|
+
|| appendText === "%"
|
|
30
|
+
|| ((_a = numProps) === null || _a === void 0 ? void 0 : _a.format) === Misc.NumberFormat.PercentDecimals || ((_b = numProps) === null || _b === void 0 ? void 0 : _b.format) === Misc.NumberFormat.PercentNoDecimals) {
|
|
31
|
+
isPercent = true;
|
|
32
|
+
}
|
|
33
|
+
if (propertyInfo.allowedDecimals !== undefined) {
|
|
34
|
+
displayDecimals = propertyInfo.allowedDecimals - (isPercent ? 2 : 0);
|
|
35
|
+
}
|
|
36
|
+
else if ((_c = numProps) === null || _c === void 0 ? void 0 : _c.formatString) {
|
|
37
|
+
displayDecimals = NumberUtils.getDecimalPlaces(numProps.formatString);
|
|
38
|
+
}
|
|
24
39
|
if (!formatString) {
|
|
25
40
|
if (numProps && numProps.format) {
|
|
26
|
-
formatString = NumberUtils.getFormatString(numProps.format, numProps.currencySymbol);
|
|
41
|
+
formatString = NumberUtils.getFormatString(numProps.format, numProps.currencySymbol, displayDecimals);
|
|
27
42
|
}
|
|
28
43
|
else {
|
|
29
44
|
var hasDecimals = numericType === Misc.DataType.Float || numericType === Misc.DataType.Decimal;
|
|
30
|
-
var format = ((
|
|
45
|
+
var format = ((_d = numProps) === null || _d === void 0 ? void 0 : _d.currencySymbol) ?
|
|
31
46
|
(hasDecimals ? Misc.NumberFormat.CurrencyDecimals : Misc.NumberFormat.CurrencyNoDecimals) :
|
|
32
47
|
(hasDecimals ? Misc.NumberFormat.Decimals : Misc.NumberFormat.NoDecimals);
|
|
33
|
-
formatString = NumberUtils.getFormatString(format, (
|
|
48
|
+
formatString = NumberUtils.getFormatString(format, (_e = numProps) === null || _e === void 0 ? void 0 : _e.currencySymbol, displayDecimals);
|
|
34
49
|
}
|
|
35
50
|
}
|
|
36
51
|
if (formatString.indexOf("%") < 0 && appendText === "%") {
|
|
37
52
|
hasExternalPercentSymbol = true;
|
|
38
53
|
}
|
|
39
|
-
|
|
40
|
-
isPercent = true;
|
|
41
|
-
}
|
|
42
|
-
return new FormatState(isPercent, hasExternalPercentSymbol, formatString, (_c = numProps) === null || _c === void 0 ? void 0 : _c.zeroText, (_d = numProps) === null || _d === void 0 ? void 0 : _d.native);
|
|
54
|
+
return new FormatState(isPercent, hasExternalPercentSymbol, formatString, displayDecimals + (isPercent ? 2 : 0), (_f = numProps) === null || _f === void 0 ? void 0 : _f.zeroText, (_g = numProps) === null || _g === void 0 ? void 0 : _g.native);
|
|
43
55
|
};
|
|
44
56
|
FormatState.prototype.getFormattedValue = function (value) {
|
|
45
57
|
if (!value && this.zeroText !== undefined) {
|
|
@@ -85,8 +97,15 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
85
97
|
}
|
|
86
98
|
NumberInput.prototype.onChanged = function (e) {
|
|
87
99
|
var newValue;
|
|
88
|
-
|
|
89
|
-
|
|
100
|
+
var stringValue = e.target.value;
|
|
101
|
+
if (stringValue !== "") {
|
|
102
|
+
if (NumberUtils.allowAsDecimalSeparator) {
|
|
103
|
+
var firstIndex = stringValue.indexOf(NumberUtils.allowAsDecimalSeparator), lastIndex = stringValue.lastIndexOf(NumberUtils.allowAsDecimalSeparator);
|
|
104
|
+
if (firstIndex >= 0 && firstIndex === lastIndex) {
|
|
105
|
+
stringValue = stringValue.replace(NumberUtils.allowAsDecimalSeparator, ".");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
var testValue = stringValue;
|
|
90
109
|
if (testValue[0] === "-") {
|
|
91
110
|
testValue = testValue.substring(1);
|
|
92
111
|
}
|
|
@@ -94,25 +113,25 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
94
113
|
return;
|
|
95
114
|
}
|
|
96
115
|
}
|
|
97
|
-
if (
|
|
116
|
+
if (stringValue == "") {
|
|
98
117
|
newValue = this.props.bind.propertyInfo.allowNulls ? null : new Decimal(0);
|
|
99
118
|
}
|
|
100
119
|
else if (this.formatState.isPercent && NumberUtils.transformPercent) {
|
|
101
|
-
newValue = new Decimal(
|
|
120
|
+
newValue = new Decimal(stringValue).dividedBy(100);
|
|
102
121
|
}
|
|
103
122
|
else if (this.numericType === Misc.DataType.Float || this.numericType === Misc.DataType.Decimal) {
|
|
104
|
-
newValue = new Decimal(
|
|
123
|
+
newValue = new Decimal(stringValue);
|
|
105
124
|
}
|
|
106
125
|
else {
|
|
107
126
|
// Rounds to zero.
|
|
108
|
-
newValue = new Decimal(
|
|
127
|
+
newValue = new Decimal(stringValue).toDecimalPlaces(0, Decimal.ROUND_DOWN);
|
|
109
128
|
}
|
|
110
129
|
if (newValue === null) {
|
|
111
130
|
this.props.bind.value = newValue;
|
|
112
131
|
}
|
|
113
132
|
else {
|
|
114
133
|
if (!this.props.numProps || this.props.numProps.autoRound !== false) {
|
|
115
|
-
newValue = NumberUtils.
|
|
134
|
+
newValue = NumberUtils.round(newValue, this.formatState.allowedDecimals);
|
|
116
135
|
}
|
|
117
136
|
if (this.numericType === Misc.DataType.Decimal) {
|
|
118
137
|
this.props.bind.value = newValue;
|
|
@@ -147,7 +166,7 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
147
166
|
}
|
|
148
167
|
else {
|
|
149
168
|
if (element.readOnly || !this.props.numProps || this.props.numProps.autoRound !== false) {
|
|
150
|
-
stringValue = NumberUtils.formatRaw(numberValue, this.formatState.formatString, this.formatState.hasExternalPercentSymbol);
|
|
169
|
+
stringValue = NumberUtils.formatRaw(numberValue, this.formatState.formatString, this.formatState.hasExternalPercentSymbol, this.formatState.allowedDecimals);
|
|
151
170
|
}
|
|
152
171
|
else {
|
|
153
172
|
if (this.formatState.isPercent && NumberUtils.transformPercent) {
|
|
@@ -222,7 +241,7 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
222
241
|
var useNative = (_a = splitProps.numProps) === null || _a === void 0 ? void 0 : _a.native;
|
|
223
242
|
var displayInfo = this.props.bind.validator.getDisplayState(this.context.validationDisplayMode);
|
|
224
243
|
displayInfo.applyToDom(domProps, !splitProps.inGroup);
|
|
225
|
-
this.formatState = this.recalcFormatState(this.numericType, splitProps.numProps, editorProps.appendText);
|
|
244
|
+
this.formatState = this.recalcFormatState(this.props.bind.propertyInfo, this.numericType, splitProps.numProps, editorProps.appendText);
|
|
226
245
|
this.isReadOnly = domProps.readOnly === true;
|
|
227
246
|
if (editorProps.inputElement) {
|
|
228
247
|
this.inputElement = editorProps.inputElement;
|
|
@@ -237,7 +256,7 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
237
256
|
var decimals = NumberUtils.getDecimalPlaces(this.formatState.formatString);
|
|
238
257
|
domProps.step = decimals === 0 ? "1" : "0." + "0".repeat(decimals - 1) + "1";
|
|
239
258
|
}
|
|
240
|
-
return (InputHelpers.surroundWithInputGroup(React.createElement("input", __assign({}, domProps, { defaultValue: this.formatState.getFormattedValue(editorProps.bind.value), type: useNative ? "number" : "text", onChange: this.onChanged, ref: this.inputElement })), editorProps));
|
|
259
|
+
return (InputHelpers.surroundWithInputGroup(React.createElement("input", __assign({}, domProps, { defaultValue: this.formatState.getFormattedValue(editorProps.bind.value), type: useNative ? "number" : "text", onChange: this.onChanged, ref: this.inputElement })), editorProps, this.inputElement));
|
|
241
260
|
};
|
|
242
261
|
NumberInput.contextType = FormContext;
|
|
243
262
|
NumberInput = __decorate([
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { IRouteParameter } from './IRouteParameter';
|
|
2
3
|
import { IViewParameterListInternal } from './ViewParameterList';
|
|
3
4
|
import { Model } from '@singularsystems/neo-core';
|
|
@@ -16,6 +17,12 @@ export interface IViewParameter {
|
|
|
16
17
|
* Used by the breadcrumb.
|
|
17
18
|
*/
|
|
18
19
|
description: string;
|
|
20
|
+
/**
|
|
21
|
+
* Sets the description, and an optional list of prefixes.
|
|
22
|
+
* @param description Description of the current value.
|
|
23
|
+
* @param prefixes Function that returns prefixes for this breadcrumb item. The previous prefixes are passed into the function.
|
|
24
|
+
*/
|
|
25
|
+
setDescription(description: string, getPrefixes?: (currentPrefixes: IViewParameterPrefix[]) => IViewParameterPrefix[]): void;
|
|
19
26
|
/**
|
|
20
27
|
* Returns value as a nullable int.
|
|
21
28
|
*/
|
|
@@ -41,6 +48,7 @@ export declare class ViewParameter implements IViewParameter {
|
|
|
41
48
|
private hasPendingValue;
|
|
42
49
|
private pendingValue;
|
|
43
50
|
private _value;
|
|
51
|
+
prefixes: IViewParameterPrefix[];
|
|
44
52
|
constructor(parent: IViewParameterListInternal, name: string, routeParameter: IRouteParameter);
|
|
45
53
|
bindTo(propertyOrCallback: Model.IPropertyInstance | (() => (string | number | null | undefined))): void;
|
|
46
54
|
get value(): number | string | null;
|
|
@@ -49,6 +57,7 @@ export declare class ViewParameter implements IViewParameter {
|
|
|
49
57
|
_description: string;
|
|
50
58
|
get description(): string;
|
|
51
59
|
set description(value: string);
|
|
60
|
+
setDescription(description: string, getPrefixes?: (currentPrefixes: IViewParameterPrefix[]) => IViewParameterPrefix[]): void;
|
|
52
61
|
asNullableInt(): number | null;
|
|
53
62
|
asString(): string;
|
|
54
63
|
/** Updates the current value, and returns true if the value changed. */
|
|
@@ -58,3 +67,14 @@ export declare class ViewParameter implements IViewParameter {
|
|
|
58
67
|
}): string;
|
|
59
68
|
get latestValue(): string | null;
|
|
60
69
|
}
|
|
70
|
+
interface IViewParameterPrefix {
|
|
71
|
+
/** Label to show on breadcrumb. */
|
|
72
|
+
label: string;
|
|
73
|
+
/** Value to use in the breadcrumb link. Clicking on the link will set the view parameter to this value. */
|
|
74
|
+
value?: number | string | null;
|
|
75
|
+
/** Custom link to use in the breadcrumb. */
|
|
76
|
+
link?: string;
|
|
77
|
+
/** Click event for the breadcrumb. */
|
|
78
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
79
|
+
}
|
|
80
|
+
export {};
|
|
@@ -8,6 +8,7 @@ var ViewParameter = /** @class */ (function () {
|
|
|
8
8
|
this.hasPendingValue = false;
|
|
9
9
|
this.pendingValue = null;
|
|
10
10
|
this._value = null;
|
|
11
|
+
this.prefixes = [];
|
|
11
12
|
this._description = "";
|
|
12
13
|
}
|
|
13
14
|
ViewParameter.prototype.bindTo = function (propertyOrCallback) {
|
|
@@ -28,7 +29,6 @@ var ViewParameter = /** @class */ (function () {
|
|
|
28
29
|
if (stringValue !== this._value) {
|
|
29
30
|
this.hasPendingValue = true;
|
|
30
31
|
this.pendingValue = stringValue;
|
|
31
|
-
this._description = "";
|
|
32
32
|
this.parent.setUrl(this);
|
|
33
33
|
}
|
|
34
34
|
},
|
|
@@ -55,6 +55,10 @@ var ViewParameter = /** @class */ (function () {
|
|
|
55
55
|
enumerable: true,
|
|
56
56
|
configurable: true
|
|
57
57
|
});
|
|
58
|
+
ViewParameter.prototype.setDescription = function (description, getPrefixes) {
|
|
59
|
+
this.prefixes = getPrefixes ? getPrefixes(this.prefixes) : [];
|
|
60
|
+
this.description = description;
|
|
61
|
+
};
|
|
58
62
|
ViewParameter.prototype.asNullableInt = function () {
|
|
59
63
|
if (this._value) {
|
|
60
64
|
return parseInt(this._value, 10);
|
|
@@ -66,13 +70,17 @@ var ViewParameter = /** @class */ (function () {
|
|
|
66
70
|
};
|
|
67
71
|
/** Updates the current value, and returns true if the value changed. */
|
|
68
72
|
ViewParameter.prototype.update = function (value) {
|
|
69
|
-
if (value)
|
|
73
|
+
if (value) {
|
|
70
74
|
value = decodeURIComponent(value);
|
|
75
|
+
}
|
|
71
76
|
if (value != this._value) {
|
|
72
77
|
this.hasPendingValue = false;
|
|
73
78
|
this.pendingValue = value;
|
|
74
|
-
this._description = "";
|
|
75
79
|
this._value = value;
|
|
80
|
+
if (!value) {
|
|
81
|
+
this._description = "";
|
|
82
|
+
this.prefixes = [];
|
|
83
|
+
}
|
|
76
84
|
return true;
|
|
77
85
|
}
|
|
78
86
|
return false;
|
|
@@ -28,6 +28,22 @@ var ViewParameterList = /** @class */ (function () {
|
|
|
28
28
|
for (var _i = 0, _b = this.params; _i < _b.length; _i++) {
|
|
29
29
|
var viewParam = _b[_i];
|
|
30
30
|
if (!viewParam.routeParameter.isQuery) {
|
|
31
|
+
if (!upTo) {
|
|
32
|
+
for (var _c = 0, _d = viewParam.prefixes; _c < _d.length; _c++) {
|
|
33
|
+
var prefix = _d[_c];
|
|
34
|
+
var breadcrumbItem = new BreadCrumbItem(prefix.label);
|
|
35
|
+
if (prefix.onClick) {
|
|
36
|
+
breadcrumbItem.onClick = prefix.onClick;
|
|
37
|
+
}
|
|
38
|
+
else if (prefix.link) {
|
|
39
|
+
breadcrumbItem.link = prefix.link;
|
|
40
|
+
}
|
|
41
|
+
else if (prefix.value) {
|
|
42
|
+
breadcrumbItem.link = paramPath + "/" + prefix.value;
|
|
43
|
+
}
|
|
44
|
+
breadCrumbs.push(breadcrumbItem);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
31
47
|
paramPath += viewParam.getParamString(state);
|
|
32
48
|
if ((_a = viewParam.routeParameter.selection, (_a !== null && _a !== void 0 ? _a : BreadCrumbSelectMode.Default)) === BreadCrumbSelectMode.Default) {
|
|
33
49
|
selectablePath = paramPath;
|
package/dist/Views/ViewBase.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export default abstract class ViewBase<TViewModel extends IViewModel = EmptyView
|
|
|
46
46
|
/**
|
|
47
47
|
* viewParamsUpdated() is called when the component is mounted, and whenever a route parameter or query parameter gets a changed value.
|
|
48
48
|
*/
|
|
49
|
-
protected viewParamsUpdated(): void
|
|
49
|
+
protected viewParamsUpdated(): void | Promise<void>;
|
|
50
50
|
/** Gets the parent breadcrumbs, and the breadcrumb for this view. */
|
|
51
51
|
protected getBreadCrumbStart(): BreadCrumbItem[];
|
|
52
52
|
/**
|
package/dist/Views/ViewBase.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { __decorate, __extends, __metadata } from "tslib";
|
|
1
|
+
import { __awaiter, __decorate, __extends, __generator, __metadata } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { observable } from 'mobx';
|
|
3
|
+
import { observable, runInAction } from 'mobx';
|
|
4
4
|
import { Misc } from '@singularsystems/neo-core';
|
|
5
5
|
import { ViewParameterList } from '../Routing/ViewParameterList';
|
|
6
6
|
import { ViewState } from './ViewState';
|
|
@@ -79,9 +79,20 @@ var ViewBase = /** @class */ (function (_super) {
|
|
|
79
79
|
this.disposeViewModel();
|
|
80
80
|
};
|
|
81
81
|
ViewBase.prototype.updateViewParams = function (match) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
var _this = this;
|
|
83
|
+
runInAction(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
if (!this.viewState.viewParams.update(match)) return [3 /*break*/, 2];
|
|
88
|
+
return [4 /*yield*/, Promise.resolve(this.viewParamsUpdated())];
|
|
89
|
+
case 1:
|
|
90
|
+
_a.sent();
|
|
91
|
+
_a.label = 2;
|
|
92
|
+
case 2: return [2 /*return*/];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}); });
|
|
85
96
|
};
|
|
86
97
|
/**
|
|
87
98
|
* viewParamsUpdated() is called when the component is mounted, and whenever a route parameter or query parameter gets a changed value.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularsystems/neo-react",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.62",
|
|
4
4
|
"description": "React application logic and components for the Neo client library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"react-router-dom": "5.1.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@singularsystems/neo-core": ">=0.10.
|
|
50
|
+
"@singularsystems/neo-core": ">=0.10.72",
|
|
51
51
|
"axios": ">=0.21.1",
|
|
52
52
|
"inversify": ">=5.0.1",
|
|
53
53
|
"react": ">=16.13.1",
|
package/styles/DatePicker.scss
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
position: relative;
|
|
4
4
|
width: 100%;
|
|
5
5
|
color: initial;
|
|
6
|
+
|
|
7
|
+
&.neo-datepicker-always-show {
|
|
8
|
+
width: max-content;
|
|
9
|
+
|
|
10
|
+
input {
|
|
11
|
+
text-align: center;
|
|
12
|
+
padding: 0.125rem 0;
|
|
13
|
+
height: auto;
|
|
14
|
+
margin-bottom: 0.25rem;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
6
17
|
}
|
|
7
18
|
|
|
8
19
|
.neo-datepicker-popup {
|