@singularsystems/neo-react 0.10.45 → 0.10.48
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/DropDown/DropDownBase.js +5 -26
- package/dist/ReactComponents/DropDown/LookupHelper.d.ts +13 -0
- package/dist/ReactComponents/DropDown/LookupHelper.js +45 -0
- package/dist/ReactComponents/NumberInput.js +5 -1
- package/dist/ReactComponents/RadioList.js +5 -23
- package/dist/ReactComponents/Tabs/TabManager.d.ts +5 -4
- package/dist/ReactComponents/Tabs/TabManager.js +10 -5
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __awaiter, __extends, __generator } from "tslib";
|
|
2
|
-
import { Data,
|
|
2
|
+
import { Data, Model } from '@singularsystems/neo-core';
|
|
3
3
|
import ComponentBase from '../ComponentBase';
|
|
4
|
+
import LookupHelper from './LookupHelper';
|
|
4
5
|
var DropDownBase = /** @class */ (function (_super) {
|
|
5
6
|
__extends(DropDownBase, _super);
|
|
6
7
|
function DropDownBase() {
|
|
@@ -12,31 +13,9 @@ var DropDownBase = /** @class */ (function (_super) {
|
|
|
12
13
|
return _this;
|
|
13
14
|
}
|
|
14
15
|
DropDownBase.prototype.findMembers = function (item) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.displayMember = "name";
|
|
19
|
-
}
|
|
20
|
-
if (!this.displayMember) {
|
|
21
|
-
var neoTypeInfo = item.constructor.neo;
|
|
22
|
-
if (neoTypeInfo && neoTypeInfo.displayMember) {
|
|
23
|
-
this.displayMember = neoTypeInfo.displayMember.propertyName;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
for (var propName in item) {
|
|
27
|
-
if (this.valueMember && this.displayMember)
|
|
28
|
-
break;
|
|
29
|
-
var value = item[propName];
|
|
30
|
-
if (value !== undefined && value !== null) {
|
|
31
|
-
if (typeof (value) === "number" && !this.valueMember) {
|
|
32
|
-
this.valueMember = propName;
|
|
33
|
-
}
|
|
34
|
-
if (typeof (value) === "string" && !this.displayMember && !propName.toLowerCase().endsWith("id") && propName !== "entityIdentifier") {
|
|
35
|
-
this.displayMember = propName;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
16
|
+
var members = LookupHelper.findMembers(item, this.valueMember, this.displayMember);
|
|
17
|
+
this.valueMember = members.valueMember;
|
|
18
|
+
this.displayMember = members.displayMember;
|
|
40
19
|
};
|
|
41
20
|
DropDownBase.prototype.getItems = function (itemSource) {
|
|
42
21
|
var _a;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ILookupMembers {
|
|
2
|
+
valueMember: string;
|
|
3
|
+
displayMember: string;
|
|
4
|
+
}
|
|
5
|
+
export default class LookupHelper {
|
|
6
|
+
/**
|
|
7
|
+
* Finds the value and display member of a class by convention.
|
|
8
|
+
* Also uses the displayMember attribute if defined on any of the properties.
|
|
9
|
+
* @param item An object instance
|
|
10
|
+
* @param booleanValuesAllowed True if boolean values are allowed in the value member.
|
|
11
|
+
*/
|
|
12
|
+
static findMembers(item: any, valueMember: string, displayMember: string, booleanValuesAllowed?: boolean): ILookupMembers;
|
|
13
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { EnumHelper } from "@singularsystems/neo-core";
|
|
2
|
+
var LookupHelper = /** @class */ (function () {
|
|
3
|
+
function LookupHelper() {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Finds the value and display member of a class by convention.
|
|
7
|
+
* Also uses the displayMember attribute if defined on any of the properties.
|
|
8
|
+
* @param item An object instance
|
|
9
|
+
* @param booleanValuesAllowed True if boolean values are allowed in the value member.
|
|
10
|
+
*/
|
|
11
|
+
LookupHelper.findMembers = function (item, valueMember, displayMember, booleanValuesAllowed) {
|
|
12
|
+
if (booleanValuesAllowed === void 0) { booleanValuesAllowed = false; }
|
|
13
|
+
if (!displayMember || !valueMember) {
|
|
14
|
+
if (EnumHelper.isEnumItem(item)) {
|
|
15
|
+
valueMember = "id";
|
|
16
|
+
displayMember = "name";
|
|
17
|
+
}
|
|
18
|
+
if (!displayMember) {
|
|
19
|
+
var neoTypeInfo = item.constructor.neo;
|
|
20
|
+
if (neoTypeInfo && neoTypeInfo.displayMember) {
|
|
21
|
+
displayMember = neoTypeInfo.displayMember.propertyName;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
for (var propName in item) {
|
|
25
|
+
if (valueMember && displayMember)
|
|
26
|
+
break;
|
|
27
|
+
var value = item[propName];
|
|
28
|
+
if (value !== undefined && value !== null) {
|
|
29
|
+
if ((typeof (value) === "number" || (booleanValuesAllowed && typeof (value) === "boolean")) && !valueMember) {
|
|
30
|
+
valueMember = propName;
|
|
31
|
+
}
|
|
32
|
+
if (typeof (value) === "string" && !displayMember && !propName.toLowerCase().endsWith("id") && propName !== "entityIdentifier") {
|
|
33
|
+
displayMember = propName;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (!valueMember || !displayMember) {
|
|
38
|
+
console.error("Could not find value and display member. Try specifying them explicitly.", item);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return { valueMember: valueMember, displayMember: displayMember };
|
|
42
|
+
};
|
|
43
|
+
return LookupHelper;
|
|
44
|
+
}());
|
|
45
|
+
export default LookupHelper;
|
|
@@ -85,7 +85,11 @@ var NumberInput = /** @class */ (function (_super) {
|
|
|
85
85
|
NumberInput.prototype.onChanged = function (e) {
|
|
86
86
|
var newValue;
|
|
87
87
|
if (e.target.value !== "") {
|
|
88
|
-
|
|
88
|
+
var testValue = e.target.value;
|
|
89
|
+
if (testValue[0] === "-") {
|
|
90
|
+
testValue = testValue.substring(1);
|
|
91
|
+
}
|
|
92
|
+
if (isNaN(parseFloat(testValue)) || !validDecimalRegex.test(testValue)) {
|
|
89
93
|
return;
|
|
90
94
|
}
|
|
91
95
|
}
|
|
@@ -5,6 +5,7 @@ import { observer } from 'mobx-react';
|
|
|
5
5
|
import { BindPropsHelper } from './PropTypes';
|
|
6
6
|
import ComponentBase from './ComponentBase';
|
|
7
7
|
import { FormContext } from './FormContext';
|
|
8
|
+
import LookupHelper from './DropDown/LookupHelper';
|
|
8
9
|
var RadioList = /** @class */ (function (_super) {
|
|
9
10
|
__extends(RadioList, _super);
|
|
10
11
|
function RadioList() {
|
|
@@ -25,27 +26,7 @@ var RadioList = /** @class */ (function (_super) {
|
|
|
25
26
|
RadioList.prototype.createEnumList = function (list) {
|
|
26
27
|
var _a, _b;
|
|
27
28
|
if (list.length) {
|
|
28
|
-
var
|
|
29
|
-
var displayMember_1 = (_b = this.props.radioList.displayMember, (_b !== null && _b !== void 0 ? _b : ""));
|
|
30
|
-
if (!displayMember_1) {
|
|
31
|
-
var neoTypeInfo = list[0].constructor.neo;
|
|
32
|
-
if (neoTypeInfo && neoTypeInfo.displayMember) {
|
|
33
|
-
displayMember_1 = neoTypeInfo.displayMember.propertyName;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
for (var propName in list[0]) {
|
|
37
|
-
if (valueMember_1 && displayMember_1)
|
|
38
|
-
break;
|
|
39
|
-
var value = list[0][propName];
|
|
40
|
-
if (value !== undefined && value !== null) {
|
|
41
|
-
if (!valueMember_1 && (typeof (value) === "number" || typeof (value) === "boolean")) {
|
|
42
|
-
valueMember_1 = propName;
|
|
43
|
-
}
|
|
44
|
-
if (!displayMember_1 && typeof (value) === "string" && !propName.toLowerCase().endsWith("id") && propName !== "entityIdentifier") {
|
|
45
|
-
displayMember_1 = propName;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
29
|
+
var _c = LookupHelper.findMembers(list[0], (_a = this.props.radioList.valueMember, (_a !== null && _a !== void 0 ? _a : "")), (_b = this.props.radioList.displayMember, (_b !== null && _b !== void 0 ? _b : "")), true), valueMember_1 = _c.valueMember, displayMember_1 = _c.displayMember;
|
|
49
30
|
if (valueMember_1 && displayMember_1) {
|
|
50
31
|
this.items = list.map(function (item) { return ({ id: item[valueMember_1], name: item[displayMember_1] }); });
|
|
51
32
|
}
|
|
@@ -63,9 +44,10 @@ var RadioList = /** @class */ (function (_super) {
|
|
|
63
44
|
var bindValue = this.props.bind.value;
|
|
64
45
|
var className = Utils.joinWithSpaces("neo-radio-list", (_a = splitProps.editorDom) === null || _a === void 0 ? void 0 : _a.className);
|
|
65
46
|
return React.createElement("div", { className: className }, this.items.map(function (item) {
|
|
47
|
+
var _a, _b;
|
|
66
48
|
return React.createElement("div", { className: "custom-control custom-radio " + (_this.props.radioList.inline ? "custom-control-inline" : "custom-control"), key: item.id },
|
|
67
|
-
React.createElement("input", { type: "radio", id: splitProps.uniqueID + item.id, name: splitProps.uniqueID, checked: bindValue === item.id, disabled: domProps.disabled || domProps.readOnly, onChange: function () { return _this.props.bind.value = item.id; }, className: "custom-control-input" }),
|
|
68
|
-
React.createElement("label", { className: "custom-control-label", htmlFor: splitProps.uniqueID + item.id }, item.name));
|
|
49
|
+
React.createElement("input", { type: "radio", id: splitProps.uniqueID + (_a = item.id, (_a !== null && _a !== void 0 ? _a : "")), name: splitProps.uniqueID, checked: bindValue === item.id, disabled: domProps.disabled || domProps.readOnly, onChange: function () { return _this.props.bind.value = item.id; }, className: "custom-control-input" }),
|
|
50
|
+
React.createElement("label", { className: "custom-control-label", htmlFor: splitProps.uniqueID + (_b = item.id, (_b !== null && _b !== void 0 ? _b : "")) }, item.name));
|
|
69
51
|
}));
|
|
70
52
|
};
|
|
71
53
|
RadioList.contextType = FormContext;
|
|
@@ -47,15 +47,16 @@ export declare class TabManager<T extends string = string> {
|
|
|
47
47
|
private getTab;
|
|
48
48
|
/**
|
|
49
49
|
* Marks the tab as 'initial'.
|
|
50
|
-
* @param
|
|
50
|
+
* @param reInitialise True if the tabs onInitialise() should be invoked.
|
|
51
51
|
*/
|
|
52
52
|
reset(tabKey: T, reInitialise?: boolean): void;
|
|
53
|
-
/** Calls
|
|
53
|
+
/** Calls onInitialise() if the tab has not yet initialised. */
|
|
54
54
|
initialiseTab(tabKey: T): void;
|
|
55
55
|
/**
|
|
56
|
-
* Marks all tabs as 'initial'.
|
|
56
|
+
* Marks all tabs as 'initial', causing onInitialise() to be called the next time each is displayed.
|
|
57
|
+
* @param reInitialise True if the onInitialise() should be called on the currently displayed tab.
|
|
57
58
|
*/
|
|
58
|
-
resetAll(): void;
|
|
59
|
+
resetAll(reInitialise?: boolean): void;
|
|
59
60
|
private tabs;
|
|
60
61
|
private onTabChanged;
|
|
61
62
|
}
|
|
@@ -92,7 +92,7 @@ var TabManager = /** @class */ (function () {
|
|
|
92
92
|
};
|
|
93
93
|
/**
|
|
94
94
|
* Marks the tab as 'initial'.
|
|
95
|
-
* @param
|
|
95
|
+
* @param reInitialise True if the tabs onInitialise() should be invoked.
|
|
96
96
|
*/
|
|
97
97
|
TabManager.prototype.reset = function (tabKey, reInitialise) {
|
|
98
98
|
if (reInitialise === void 0) { reInitialise = false; }
|
|
@@ -106,7 +106,7 @@ var TabManager = /** @class */ (function () {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
|
-
/** Calls
|
|
109
|
+
/** Calls onInitialise() if the tab has not yet initialised. */
|
|
110
110
|
TabManager.prototype.initialiseTab = function (tabKey) {
|
|
111
111
|
var tab = this.getTab(tabKey);
|
|
112
112
|
if (tab && !tab.hasFetched) {
|
|
@@ -114,10 +114,15 @@ var TabManager = /** @class */ (function () {
|
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
116
|
/**
|
|
117
|
-
* Marks all tabs as 'initial'.
|
|
117
|
+
* Marks all tabs as 'initial', causing onInitialise() to be called the next time each is displayed.
|
|
118
|
+
* @param reInitialise True if the onInitialise() should be called on the currently displayed tab.
|
|
118
119
|
*/
|
|
119
|
-
TabManager.prototype.resetAll = function () {
|
|
120
|
-
|
|
120
|
+
TabManager.prototype.resetAll = function (reInitialise) {
|
|
121
|
+
if (reInitialise === void 0) { reInitialise = false; }
|
|
122
|
+
var currentTabKey = this.observable.peek;
|
|
123
|
+
for (var tabKey in this.tabs) {
|
|
124
|
+
this.reset(tabKey, reInitialise && currentTabKey === tabKey);
|
|
125
|
+
}
|
|
121
126
|
};
|
|
122
127
|
TabManager.prototype.onTabChanged = function () {
|
|
123
128
|
var tab = this.getTab(this.observable.peek);
|