@singularsystems/neo-react 1.0.0-alpha.3 → 1.0.0-beta.1
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/CHANGELOG.md +98 -0
- package/README.md +4 -0
- package/dist/Modules/NeoReactModule.d.ts +4 -4
- package/dist/Modules/NeoReactModule.js +28 -26
- package/dist/Modules/ReactSetup.d.ts +2 -2
- package/dist/Modules/ReactSetup.js +17 -17
- package/dist/Modules/Types.d.ts +63 -61
- package/dist/Modules/Types.js +13 -12
- package/dist/React/AutoRunner.d.ts +5 -5
- package/dist/React/AutoRunner.js +94 -92
- package/dist/React/DataView.d.ts +6 -6
- package/dist/React/DataView.js +11 -11
- package/dist/React/ReactModelCreator.d.ts +11 -11
- package/dist/React/ReactModelCreator.js +165 -162
- package/dist/ReactComponents/Button.d.ts +24 -23
- package/dist/ReactComponents/Button.js +132 -123
- package/dist/ReactComponents/Card.d.ts +24 -23
- package/dist/ReactComponents/Card.js +57 -54
- package/dist/ReactComponents/Collapsable.d.ts +23 -23
- package/dist/ReactComponents/Collapsable.js +38 -38
- package/dist/ReactComponents/CollapsableBase.d.ts +13 -13
- package/dist/ReactComponents/CollapsableBase.js +42 -42
- package/dist/ReactComponents/ColorPicker.d.ts +26 -26
- package/dist/ReactComponents/ColorPicker.js +67 -67
- package/dist/ReactComponents/ComponentBase.d.ts +17 -17
- package/dist/ReactComponents/ComponentBase.js +33 -33
- package/dist/ReactComponents/ContextMenu/ContextMenu.d.ts +25 -24
- package/dist/ReactComponents/ContextMenu/ContextMenu.js +91 -89
- package/dist/ReactComponents/ContextMenu/ContextMenuContainer.d.ts +14 -14
- package/dist/ReactComponents/ContextMenu/ContextMenuContainer.js +48 -48
- package/dist/ReactComponents/ContextMenu/ContextMenuState.d.ts +8 -8
- package/dist/ReactComponents/ContextMenu/ContextMenuState.js +23 -24
- package/dist/ReactComponents/DatePicker.d.ts +20 -19
- package/dist/ReactComponents/DatePicker.js +57 -53
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.d.ts +97 -83
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js +225 -188
- package/dist/ReactComponents/DropDown/DropDown.d.ts +44 -44
- package/dist/ReactComponents/DropDown/DropDown.js +138 -134
- package/dist/ReactComponents/DropDown/DropDownBase.d.ts +16 -15
- package/dist/ReactComponents/DropDown/DropDownBase.js +86 -108
- package/dist/ReactComponents/DropDown/LookupHelper.d.ts +13 -0
- package/dist/ReactComponents/DropDown/LookupHelper.js +45 -0
- package/dist/ReactComponents/ErrorHandler.d.ts +9 -9
- package/dist/ReactComponents/ErrorHandler.js +92 -93
- package/dist/ReactComponents/FileManager/FileBasicInput.d.ts +20 -20
- package/dist/ReactComponents/FileManager/FileBasicInput.js +70 -70
- package/dist/ReactComponents/FileManager/FileContext.d.ts +16 -16
- package/dist/ReactComponents/FileManager/FileContext.js +24 -24
- package/dist/ReactComponents/FileManager/FileDropArea.d.ts +19 -19
- package/dist/ReactComponents/FileManager/FileDropArea.js +66 -66
- package/dist/ReactComponents/FileManager/FileInput.d.ts +44 -43
- package/dist/ReactComponents/FileManager/FileInput.js +191 -191
- package/dist/ReactComponents/FileManager/FileUploadButton.d.ts +17 -17
- package/dist/ReactComponents/FileManager/FileUploadButton.js +49 -49
- package/dist/ReactComponents/FileManager/FileUploadProgress.d.ts +14 -14
- package/dist/ReactComponents/FileManager/FileUploadProgress.js +35 -35
- package/dist/ReactComponents/Form.d.ts +19 -19
- package/dist/ReactComponents/Form.js +90 -90
- package/dist/ReactComponents/FormContext.d.ts +33 -33
- package/dist/ReactComponents/FormContext.js +39 -40
- package/dist/ReactComponents/FormGroup/FormGroup.d.ts +37 -37
- package/dist/ReactComponents/FormGroup/FormGroup.js +83 -84
- package/dist/ReactComponents/FormGroup/FormGroupFloating.d.ts +19 -19
- package/dist/ReactComponents/FormGroup/FormGroupFloating.js +97 -97
- package/dist/ReactComponents/FormGroup/FormGroupInline.d.ts +11 -11
- package/dist/ReactComponents/FormGroup/FormGroupInline.js +43 -43
- package/dist/ReactComponents/Grid/ButtonColumn.d.ts +48 -47
- package/dist/ReactComponents/Grid/ButtonColumn.js +81 -82
- package/dist/ReactComponents/Grid/Column.d.ts +47 -47
- package/dist/ReactComponents/Grid/Column.js +205 -205
- package/dist/ReactComponents/Grid/ColumnHelper.d.ts +12 -12
- package/dist/ReactComponents/Grid/ColumnHelper.js +19 -19
- package/dist/ReactComponents/Grid/Grid.d.ts +95 -87
- package/dist/ReactComponents/Grid/Grid.js +218 -203
- package/dist/ReactComponents/Grid/Row.d.ts +81 -81
- package/dist/ReactComponents/Grid/Row.js +200 -202
- package/dist/ReactComponents/Grid/StickyTableHeader.d.ts +27 -0
- package/dist/ReactComponents/Grid/StickyTableHeader.js +107 -0
- package/dist/ReactComponents/Grid/_Exports.d.ts +5 -5
- package/dist/ReactComponents/Grid/_Exports.js +5 -5
- package/dist/ReactComponents/GridLayout.d.ts +20 -20
- package/dist/ReactComponents/GridLayout.js +38 -38
- package/dist/ReactComponents/Icons/FontAwesomeIconFactory.d.ts +23 -0
- package/dist/ReactComponents/Icons/FontAwesomeIconFactory.js +43 -0
- package/dist/ReactComponents/Icons/IIconFactory.d.ts +21 -0
- package/dist/ReactComponents/Icons/IIconFactory.js +1 -0
- package/dist/ReactComponents/Icons/IconFactory.d.ts +9 -0
- package/dist/ReactComponents/Icons/IconFactory.js +45 -0
- package/dist/ReactComponents/Icons/index.d.ts +3 -0
- package/dist/ReactComponents/Icons/index.js +2 -0
- package/dist/ReactComponents/Input.d.ts +45 -45
- package/dist/ReactComponents/Input.js +153 -153
- package/dist/ReactComponents/InputHelpers.d.ts +6 -5
- package/dist/ReactComponents/InputHelpers.js +29 -33
- package/dist/ReactComponents/Link.d.ts +13 -13
- package/dist/ReactComponents/Link.js +28 -28
- package/dist/ReactComponents/Loader.d.ts +18 -18
- package/dist/ReactComponents/Loader.js +57 -57
- package/dist/ReactComponents/Misc.d.ts +15 -15
- package/dist/ReactComponents/Misc.js +28 -28
- package/dist/ReactComponents/Modal/Modal.d.ts +11 -11
- package/dist/ReactComponents/Modal/Modal.js +133 -129
- package/dist/ReactComponents/Modal/ModalContainer.d.ts +17 -17
- package/dist/ReactComponents/Modal/ModalContainer.js +37 -37
- package/dist/ReactComponents/Modal/ModalPortal.d.ts +16 -16
- package/dist/ReactComponents/Modal/ModalPortal.js +27 -27
- package/dist/ReactComponents/Notifications/Alert.d.ts +7 -6
- package/dist/ReactComponents/Notifications/Alert.js +38 -35
- package/dist/ReactComponents/Notifications/Toast.d.ts +9 -8
- package/dist/ReactComponents/Notifications/Toast.js +47 -45
- package/dist/ReactComponents/Notifications/ToastContainer.d.ts +8 -8
- package/dist/ReactComponents/Notifications/ToastContainer.js +18 -18
- package/dist/ReactComponents/NumberInput.d.ts +57 -50
- package/dist/ReactComponents/NumberInput.js +267 -246
- package/dist/ReactComponents/Paging/BasicPagerControls.d.ts +26 -25
- package/dist/ReactComponents/Paging/BasicPagerControls.js +57 -55
- package/dist/ReactComponents/Paging/PageSizeControl.d.ts +11 -11
- package/dist/ReactComponents/Paging/PageSizeControl.js +21 -21
- package/dist/ReactComponents/Paging/Pager.d.ts +24 -24
- package/dist/ReactComponents/Paging/Pager.js +41 -41
- package/dist/ReactComponents/ProgressBar.d.ts +19 -19
- package/dist/ReactComponents/ProgressBar.js +52 -52
- package/dist/ReactComponents/PropTypes.d.ts +154 -161
- package/dist/ReactComponents/PropTypes.js +263 -236
- package/dist/ReactComponents/RadioList.d.ts +29 -29
- package/dist/ReactComponents/RadioList.js +59 -77
- package/dist/ReactComponents/Slider.d.ts +28 -28
- package/dist/ReactComponents/Slider.js +76 -76
- package/dist/ReactComponents/StateObserver.d.ts +15 -15
- package/dist/ReactComponents/StateObserver.js +35 -35
- package/dist/ReactComponents/Tabs/Tab.d.ts +42 -41
- package/dist/ReactComponents/Tabs/Tab.js +71 -72
- package/dist/ReactComponents/Tabs/TabContainer.d.ts +44 -44
- package/dist/ReactComponents/Tabs/TabContainer.js +98 -98
- package/dist/ReactComponents/Tabs/TabManager.d.ts +62 -62
- package/dist/ReactComponents/Tabs/TabManager.js +154 -154
- package/dist/ReactComponents/Tooltip.d.ts +20 -20
- package/dist/ReactComponents/Tooltip.js +51 -51
- package/dist/ReactComponents/TooltipHelper.d.ts +8 -8
- package/dist/ReactComponents/TooltipHelper.js +84 -84
- package/dist/ReactComponents/TooltipProvider.d.ts +30 -30
- package/dist/ReactComponents/TooltipProvider.js +111 -111
- package/dist/ReactComponents/ValidationSummary.d.ts +23 -22
- package/dist/ReactComponents/ValidationSummary.js +46 -43
- package/dist/ReactComponents/_Exports.d.ts +41 -41
- package/dist/ReactComponents/_Exports.js +41 -41
- package/dist/ReactComponents/_Managers.d.ts +4 -4
- package/dist/ReactComponents/_Managers.js +4 -4
- package/dist/Routing/BreadCrumbItem.d.ts +14 -14
- package/dist/Routing/BreadCrumbItem.js +12 -12
- package/dist/Routing/IRouteChangedProps.d.ts +31 -31
- package/dist/Routing/IRouteChangedProps.js +1 -1
- package/dist/Routing/IRouteParameter.d.ts +22 -22
- package/dist/Routing/IRouteParameter.js +9 -9
- package/dist/Routing/MenuRoute.d.ts +25 -24
- package/dist/Routing/MenuRoute.js +24 -24
- package/dist/Routing/NavigationHelper.d.ts +41 -40
- package/dist/Routing/NavigationHelper.js +61 -61
- package/dist/Routing/PageLeaveHandler.d.ts +13 -13
- package/dist/Routing/PageLeaveHandler.js +74 -75
- package/dist/Routing/RouteProvider.d.ts +31 -31
- package/dist/Routing/RouteProvider.js +92 -92
- package/dist/Routing/RouteView.d.ts +50 -50
- package/dist/Routing/RouteView.js +143 -143
- package/dist/Routing/RoutingState.d.ts +18 -18
- package/dist/Routing/RoutingState.js +45 -46
- package/dist/Routing/ViewParameter.d.ts +80 -58
- package/dist/Routing/ViewParameter.js +116 -96
- package/dist/Routing/ViewParameterList.d.ts +53 -53
- package/dist/Routing/ViewParameterList.js +163 -145
- package/dist/Routing/index.d.ts +9 -9
- package/dist/Routing/index.js +6 -6
- package/dist/Services/DisposeHelper.d.ts +15 -15
- package/dist/Services/DisposeHelper.js +40 -41
- package/dist/Services/IDisposeHelper.d.ts +12 -12
- package/dist/Services/IDisposeHelper.js +1 -1
- package/dist/Views/EmptyViewModel.d.ts +5 -5
- package/dist/Views/EmptyViewModel.js +14 -14
- package/dist/Views/IViewModel.d.ts +16 -16
- package/dist/Views/IViewModel.js +1 -1
- package/dist/Views/PersistentViewBase.d.ts +10 -10
- package/dist/Views/PersistentViewBase.js +21 -21
- package/dist/Views/ViewBase.d.ts +70 -70
- package/dist/Views/ViewBase.js +166 -155
- package/dist/Views/ViewComponentBase.d.ts +19 -13
- package/dist/Views/ViewComponentBase.js +24 -21
- package/dist/Views/ViewModelBase.d.ts +57 -56
- package/dist/Views/ViewModelBase.js +122 -118
- package/dist/Views/ViewState.d.ts +13 -13
- package/dist/Views/ViewState.js +9 -9
- package/dist/Views/index.d.ts +5 -5
- package/dist/Views/index.js +5 -5
- package/dist/index.d.ts +11 -10
- package/dist/index.js +10 -9
- package/package.json +18 -20
- package/styles/Card.scss +8 -1
- package/styles/DatePicker.scss +13 -2
- package/styles/Forms.scss +5 -0
- package/styles/Grid.scss +5 -0
- package/styles/Validation.scss +0 -9
|
@@ -1,188 +1,225 @@
|
|
|
1
|
-
import { __assign, __decorate, __extends, __metadata, __rest } from "tslib";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { EnumHelper, Misc, Utils } from '@singularsystems/neo-core';
|
|
4
|
-
import { observer } from 'mobx-react';
|
|
5
|
-
import { DropDownBase } from './DropDownBase';
|
|
6
|
-
import { BindPropsHelper } from '../PropTypes';
|
|
7
|
-
import { InputHelpers } from '../InputHelpers';
|
|
8
|
-
import { EditorParentType, FormContext } from '../FormContext';
|
|
9
|
-
import { Tooltip } from '../_Exports';
|
|
10
|
-
import { NeoReactTypes } from '../../Modules/Types';
|
|
11
|
-
var AutoCompleteDropDown = /** @class */ (function (_super) {
|
|
12
|
-
__extends(AutoCompleteDropDown, _super);
|
|
13
|
-
function AutoCompleteDropDown(props) {
|
|
14
|
-
var _this =
|
|
15
|
-
|
|
16
|
-
_this
|
|
17
|
-
_this.
|
|
18
|
-
_this.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
1
|
+
import { __assign, __decorate, __extends, __metadata, __rest } from "tslib";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { EnumHelper, Misc, Model, Utils } from '@singularsystems/neo-core';
|
|
4
|
+
import { observer } from 'mobx-react';
|
|
5
|
+
import { DropDownBase } from './DropDownBase';
|
|
6
|
+
import { BindPropsHelper } from '../PropTypes';
|
|
7
|
+
import { InputHelpers } from '../InputHelpers';
|
|
8
|
+
import { EditorParentType, FormContext } from '../FormContext';
|
|
9
|
+
import { Tooltip } from '../_Exports';
|
|
10
|
+
import { NeoReactTypes } from '../../Modules/Types';
|
|
11
|
+
var AutoCompleteDropDown = /** @class */ (function (_super) {
|
|
12
|
+
__extends(AutoCompleteDropDown, _super);
|
|
13
|
+
function AutoCompleteDropDown(props) {
|
|
14
|
+
var _this = this;
|
|
15
|
+
var _a;
|
|
16
|
+
_this = _super.call(this, props) || this;
|
|
17
|
+
_this.asyncSelectImplementation = Misc.Globals.appService.get(NeoReactTypes.Components.AsyncSelect);
|
|
18
|
+
_this.selectImplementation = Misc.Globals.appService.get(NeoReactTypes.Components.ReactSelect);
|
|
19
|
+
_this.onKeyPress = _this.onKeyPress.bind(_this);
|
|
20
|
+
_this.onItemSelected = _this.onItemSelected.bind(_this);
|
|
21
|
+
var singleProps = _this.props, multiProps = _this.props;
|
|
22
|
+
_this.bindProperty = (_a = singleProps.bind) !== null && _a !== void 0 ? _a : multiProps.bindItems;
|
|
23
|
+
_this.fieldInfoContainer = Model.ModelFieldInfo.asModelFieldInfoContainer(_this.bindProperty.attachedTo);
|
|
24
|
+
if (multiProps.bindIds) {
|
|
25
|
+
if (multiProps.bindIds.propertyInfo) {
|
|
26
|
+
var bindIdsProperty = multiProps.bindIds;
|
|
27
|
+
_this.bindIdsProperty = bindIdsProperty;
|
|
28
|
+
_this.bindIdsList = bindIdsProperty.value;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
_this.bindIdsList = multiProps.bindIds;
|
|
32
|
+
if (_this.fieldInfoContainer) {
|
|
33
|
+
console.error("Warning: Pass a property instance as 'bindIds', otherwise the display values will not be captured.");
|
|
34
|
+
_this.fieldInfoContainer = null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return _this;
|
|
39
|
+
}
|
|
40
|
+
AutoCompleteDropDown.getBindProp = function (props) {
|
|
41
|
+
var _a;
|
|
42
|
+
return (_a = props.bind) !== null && _a !== void 0 ? _a : props.bindItems;
|
|
43
|
+
};
|
|
44
|
+
AutoCompleteDropDown.prototype.onKeyPress = function (searchValue, dataReceived) {
|
|
45
|
+
var _this = this;
|
|
46
|
+
var _a, _b;
|
|
47
|
+
if (searchValue && searchValue.length >= ((_a = this.props.minCharacters) !== null && _a !== void 0 ? _a : 1)) {
|
|
48
|
+
Utils.debounce(this, function () {
|
|
49
|
+
_this.props.itemSource(searchValue).then(function (list) {
|
|
50
|
+
var items;
|
|
51
|
+
if (list.data) {
|
|
52
|
+
items = list.data;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
items = list;
|
|
56
|
+
}
|
|
57
|
+
dataReceived(_this.mapTArrayToOptions(items));
|
|
58
|
+
});
|
|
59
|
+
}, (_b = this.props.delayMs) !== null && _b !== void 0 ? _b : 500);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
dataReceived([]);
|
|
63
|
+
Utils.clearDebounce(this);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
AutoCompleteDropDown.prototype.mapTArrayToOptions = function (items) {
|
|
67
|
+
var _this = this;
|
|
68
|
+
if (items.length) {
|
|
69
|
+
this.findMembers(items[0]);
|
|
70
|
+
}
|
|
71
|
+
return items.map(function (item) { return (__assign(__assign({}, item), { item: item, value: item[_this.valueMember], label: item[_this.displayMember] })); });
|
|
72
|
+
};
|
|
73
|
+
AutoCompleteDropDown.prototype.onItemSelected = function (args, action) {
|
|
74
|
+
var _a;
|
|
75
|
+
var onItemSelected = this.props.onItemSelected, singleProps = this.props, multiProps = this.props;
|
|
76
|
+
if (multiProps.bindItems) {
|
|
77
|
+
var itemsProperty = multiProps.bindItems;
|
|
78
|
+
// Multi select
|
|
79
|
+
var itemList = itemsProperty.value;
|
|
80
|
+
if (action.action === "select-option") {
|
|
81
|
+
itemList.push({ id: action.option.value, display: action.option.label });
|
|
82
|
+
if (this.bindIdsList) {
|
|
83
|
+
this.bindIdsList.push(action.option.value);
|
|
84
|
+
}
|
|
85
|
+
if (onItemSelected) {
|
|
86
|
+
onItemSelected((_a = action.option) === null || _a === void 0 ? void 0 : _a.item);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (action.action === "remove-value") {
|
|
90
|
+
var removeItem = itemList.find(function (c) { return c.id === action.removedValue.value; });
|
|
91
|
+
if (removeItem) {
|
|
92
|
+
itemList.remove(removeItem);
|
|
93
|
+
if (this.bindIdsList) {
|
|
94
|
+
this.bindIdsList.remove(removeItem.id);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (onItemSelected) {
|
|
98
|
+
onItemSelected(undefined, removeItem);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else if (action.action === "clear") {
|
|
102
|
+
itemList.length = 0;
|
|
103
|
+
if (this.bindIdsList) {
|
|
104
|
+
this.bindIdsList.length = 0;
|
|
105
|
+
}
|
|
106
|
+
if (onItemSelected) {
|
|
107
|
+
onItemSelected(undefined);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
itemsProperty.attachedTo.isSelfDirty = true;
|
|
111
|
+
}
|
|
112
|
+
else if (singleProps.bind) {
|
|
113
|
+
// Single select
|
|
114
|
+
singleProps.bind.value = args ? args.value : null;
|
|
115
|
+
if (singleProps.bindDisplay) {
|
|
116
|
+
singleProps.bindDisplay.value = args ? args.label : "";
|
|
117
|
+
}
|
|
118
|
+
if (onItemSelected) {
|
|
119
|
+
onItemSelected(args === null || args === void 0 ? void 0 : args.item);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
AutoCompleteDropDown.prototype.render = function () {
|
|
124
|
+
var _this = this;
|
|
125
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
126
|
+
var _j = this.props, bind = _j.bind, bindDisplay = _j.bindDisplay, bindItems = _j.bindItems, bindIds = _j.bindIds, itemSource = _j.itemSource, items = _j.items, displayMember = _j.displayMember, valueMember = _j.valueMember, descriptionMember = _j.descriptionMember, option = _j.option, noRecordsPrompt = _j.noRecordsPrompt, typeToSearchPrompt = _j.typeToSearchPrompt, delayMs = _j.delayMs, minCharacters = _j.minCharacters, onItemSelected = _j.onItemSelected, fieldInfoLimit = _j.fieldInfoLimit, otherProps = __rest(_j, ["bind", "bindDisplay", "bindItems", "bindIds", "itemSource", "items", "displayMember", "valueMember", "descriptionMember", "option", "noRecordsPrompt", "typeToSearchPrompt", "delayMs", "minCharacters", "onItemSelected", "fieldInfoLimit"]);
|
|
127
|
+
var splitProps = BindPropsHelper.splitCommonEditorProps(otherProps);
|
|
128
|
+
var nativeProps = splitProps.rest;
|
|
129
|
+
var bindItemsProperty = bindItems;
|
|
130
|
+
var itemList = bindItemsProperty === null || bindItemsProperty === void 0 ? void 0 : bindItemsProperty.value;
|
|
131
|
+
var bindValue = bind;
|
|
132
|
+
var bindDisplayProperty = bindDisplay;
|
|
133
|
+
var displayInfo = this.bindProperty.validator.getDisplayState(this.context.validationDisplayMode);
|
|
134
|
+
displayInfo.applyToDom(nativeProps, this.context.parentType !== EditorParentType.FormGroup);
|
|
135
|
+
this.displayMember = (_a = this.props.displayMember) !== null && _a !== void 0 ? _a : "";
|
|
136
|
+
this.valueMember = (_b = this.props.valueMember) !== null && _b !== void 0 ? _b : "";
|
|
137
|
+
var defaultItems = undefined;
|
|
138
|
+
if (this.props.items) {
|
|
139
|
+
var items_1 = this.getItems(this.props.items);
|
|
140
|
+
if (this.props.filterPredicate !== undefined) {
|
|
141
|
+
items_1 = items_1.filter(this.props.filterPredicate);
|
|
142
|
+
}
|
|
143
|
+
defaultItems = this.mapTArrayToOptions(items_1);
|
|
144
|
+
if (descriptionMember === undefined && items_1.length > 0) {
|
|
145
|
+
if (EnumHelper.isEnumItem(items_1[0])) {
|
|
146
|
+
descriptionMember = "description";
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
var value = null;
|
|
151
|
+
if (bindItems) {
|
|
152
|
+
value = itemList.map(function (c) { return ({ value: c.id, label: c.display }); });
|
|
153
|
+
if (this.fieldInfoContainer && this.bindIdsProperty) {
|
|
154
|
+
var itemListString = "";
|
|
155
|
+
if (value.length > (fieldInfoLimit !== null && fieldInfoLimit !== void 0 ? fieldInfoLimit : 5)) {
|
|
156
|
+
itemListString = "".concat(value.length, " items selected");
|
|
157
|
+
}
|
|
158
|
+
else if (value.length > 0) {
|
|
159
|
+
itemListString = value.map(function (c) { return c.label; }).join(", ");
|
|
160
|
+
}
|
|
161
|
+
this.setFieldInfo(this.bindIdsProperty, itemListString, bindItemsProperty.propertyInfo.readableName);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
if (bindValue.value !== null) {
|
|
166
|
+
var displayValue = bindDisplayProperty === null || bindDisplayProperty === void 0 ? void 0 : bindDisplayProperty.value;
|
|
167
|
+
if (!bindDisplayProperty) {
|
|
168
|
+
if (defaultItems) {
|
|
169
|
+
displayValue = (_d = (_c = defaultItems.find(function (c) { return c.value === bindValue.value; })) === null || _c === void 0 ? void 0 : _c.label) !== null && _d !== void 0 ? _d : "";
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
throw "bindDisplay is required when the items prop is not set.";
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
value = { value: bindValue.value, label: displayValue };
|
|
176
|
+
}
|
|
177
|
+
this.setFieldInfo(bindValue, (_e = value === null || value === void 0 ? void 0 : value.label) !== null && _e !== void 0 ? _e : "");
|
|
178
|
+
}
|
|
179
|
+
var components = (_f = nativeProps.components) !== null && _f !== void 0 ? _f : {};
|
|
180
|
+
if (this.props.option) {
|
|
181
|
+
components.Option = this.getOption(this.props.option);
|
|
182
|
+
}
|
|
183
|
+
else if (components.Option) {
|
|
184
|
+
components.Option = this.getOption(components.Option);
|
|
185
|
+
}
|
|
186
|
+
else if (descriptionMember) {
|
|
187
|
+
components.Option = this.getOption(function (item) { return React.createElement(React.Fragment, null,
|
|
188
|
+
React.createElement("div", { className: "react-select-name" }, item[_this.displayMember]),
|
|
189
|
+
React.createElement("div", { className: "react-select-description" }, item[descriptionMember])); }, "with-description");
|
|
190
|
+
}
|
|
191
|
+
if (nativeProps.isClearable === undefined) {
|
|
192
|
+
nativeProps.isClearable = true;
|
|
193
|
+
}
|
|
194
|
+
if (BindPropsHelper.isReadOnly(splitProps.editor, this.context) || BindPropsHelper.isDisabled(splitProps.editor, this.context)) {
|
|
195
|
+
nativeProps.isDisabled = true;
|
|
196
|
+
}
|
|
197
|
+
nativeProps.className = Utils.joinWithSpaces("react-select-bs", nativeProps.className);
|
|
198
|
+
if (this.context.uniqueId) {
|
|
199
|
+
nativeProps.inputId = this.context.uniqueId;
|
|
200
|
+
}
|
|
201
|
+
var userOnBlur = nativeProps.onBlur;
|
|
202
|
+
nativeProps.onBlur = function (e) {
|
|
203
|
+
_this.bindProperty.validator.hasBlurred = true;
|
|
204
|
+
if (userOnBlur !== undefined) {
|
|
205
|
+
userOnBlur(e);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
if (this.props.itemSource !== undefined) {
|
|
209
|
+
return Tooltip.fromDataAttributes(InputHelpers.surroundWithInputGroup(React.createElement(this.asyncSelectImplementation, __assign({}, nativeProps, { placeholder: (_g = this.props.placeholder) !== null && _g !== void 0 ? _g : "", classNamePrefix: "react-select-bs", defaultOptions: defaultItems, loadOptions: this.onKeyPress, isMulti: bindItems !== undefined, noOptionsMessage: function (c) { var _a, _b; return c.inputValue && c.inputValue.length >= (minCharacters !== null && minCharacters !== void 0 ? minCharacters : 1) ? ((_a = _this.props.noRecordsPrompt) !== null && _a !== void 0 ? _a : "No records found") : ((_b = _this.props.typeToSearchPrompt) !== null && _b !== void 0 ? _b : "Type to search..."); }, value: value, onChange: this.onItemSelected, components: components })), splitProps.editor), nativeProps);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
return Tooltip.fromDataAttributes(InputHelpers.surroundWithInputGroup(React.createElement(this.selectImplementation, __assign({}, nativeProps, { placeholder: (_h = this.props.placeholder) !== null && _h !== void 0 ? _h : "", classNamePrefix: "react-select-bs", options: defaultItems, isLoading: this.isLoading, isMulti: bindItems !== undefined, noOptionsMessage: function (c) { var _a; return (_a = _this.props.noRecordsPrompt) !== null && _a !== void 0 ? _a : "No records found"; }, value: value, onChange: this.onItemSelected, components: components })), splitProps.editor), nativeProps);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
AutoCompleteDropDown.prototype.getOption = function (content, additionalClass) {
|
|
216
|
+
return function (item) { return (React.createElement("div", __assign({ ref: item.innerRef }, item.innerProps, { className: Utils.joinWithSpaces("react-select-row", additionalClass, item.isFocused ? "focused" : undefined, item.isSelected ? "selected" : undefined) }), content(item.data))); };
|
|
217
|
+
};
|
|
218
|
+
AutoCompleteDropDown.contextType = FormContext;
|
|
219
|
+
AutoCompleteDropDown = __decorate([
|
|
220
|
+
observer,
|
|
221
|
+
__metadata("design:paramtypes", [Object])
|
|
222
|
+
], AutoCompleteDropDown);
|
|
223
|
+
return AutoCompleteDropDown;
|
|
224
|
+
}(DropDownBase));
|
|
225
|
+
export default AutoCompleteDropDown;
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { IBindableEditorProps } from '../PropTypes';
|
|
3
|
-
import { Data } from '@singularsystems/neo-core';
|
|
4
|
-
import { DropDownBase } from './DropDownBase';
|
|
5
|
-
import { FormContext } from '../FormContext';
|
|
6
|
-
export interface IDropDownSpecificProps<T> {
|
|
7
|
-
items?: T[] | Promise<T[]>;
|
|
8
|
-
itemSource?: Data.IAsyncDataSource<T[]> | Data.IArrayCacheEntry<T>;
|
|
9
|
-
valueMember?: keyof T;
|
|
10
|
-
displayMember?: keyof T;
|
|
11
|
-
/**
|
|
12
|
-
* Set to true if your bind property is nullable, and you need to show a blank item in the list.
|
|
13
|
-
* If your property value is null, a blank item will automatically be shown.
|
|
14
|
-
*/
|
|
15
|
-
allowNulls?: boolean;
|
|
16
|
-
/** Function used to filter items out of the datasource. */
|
|
17
|
-
filterPredicate?: (item: T) => boolean;
|
|
18
|
-
/** Callback which fires when an item is selected. */
|
|
19
|
-
onItemSelected?: (item?: T) => void;
|
|
20
|
-
/**
|
|
21
|
-
* True if the display member of the selected item should display as plain text.
|
|
22
|
-
* Use this if you need a readonly display, and don't want a form control rendered.
|
|
23
|
-
*/
|
|
24
|
-
renderAsText?: boolean;
|
|
25
|
-
/** Text to display when the bound value is null, and there is no item with null as it's value member. */
|
|
26
|
-
nullText?: string;
|
|
27
|
-
/** Text to display as the first item in the drop down list when the user is allowed to select a blank item. */
|
|
28
|
-
deSelectText?: string;
|
|
29
|
-
}
|
|
30
|
-
export interface IDropDownProps<T> extends IBindableEditorProps<HTMLSelectElement> {
|
|
31
|
-
select: IDropDownSpecificProps<T>;
|
|
32
|
-
}
|
|
33
|
-
export default class DropDown<T> extends DropDownBase<T, IDropDownProps<T>> {
|
|
34
|
-
static contextType: React.Context<import("../FormContext").FormContextParams>;
|
|
35
|
-
context: React.ContextType<typeof FormContext>;
|
|
36
|
-
private selectedItem;
|
|
37
|
-
private listIndexSymbol;
|
|
38
|
-
constructor(props: IDropDownProps<T>);
|
|
39
|
-
private get items();
|
|
40
|
-
private createLookupIndex;
|
|
41
|
-
private getSelectedOption;
|
|
42
|
-
private onItemSelected;
|
|
43
|
-
render(): JSX.Element;
|
|
44
|
-
}
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { IBindableEditorProps } from '../PropTypes';
|
|
3
|
+
import { Data } from '@singularsystems/neo-core';
|
|
4
|
+
import { DropDownBase } from './DropDownBase';
|
|
5
|
+
import { FormContext } from '../FormContext';
|
|
6
|
+
export interface IDropDownSpecificProps<T> {
|
|
7
|
+
items?: T[] | Promise<T[]>;
|
|
8
|
+
itemSource?: Data.IAsyncDataSource<T[]> | Data.IArrayCacheEntry<T>;
|
|
9
|
+
valueMember?: keyof T;
|
|
10
|
+
displayMember?: keyof T;
|
|
11
|
+
/**
|
|
12
|
+
* Set to true if your bind property is nullable, and you need to show a blank item in the list.
|
|
13
|
+
* If your property value is null, a blank item will automatically be shown.
|
|
14
|
+
*/
|
|
15
|
+
allowNulls?: boolean;
|
|
16
|
+
/** Function used to filter items out of the datasource. */
|
|
17
|
+
filterPredicate?: (item: T) => boolean;
|
|
18
|
+
/** Callback which fires when an item is selected. */
|
|
19
|
+
onItemSelected?: (item?: T) => void;
|
|
20
|
+
/**
|
|
21
|
+
* True if the display member of the selected item should display as plain text.
|
|
22
|
+
* Use this if you need a readonly display, and don't want a form control rendered.
|
|
23
|
+
*/
|
|
24
|
+
renderAsText?: boolean;
|
|
25
|
+
/** Text to display when the bound value is null, and there is no item with null as it's value member. */
|
|
26
|
+
nullText?: string;
|
|
27
|
+
/** Text to display as the first item in the drop down list when the user is allowed to select a blank item. */
|
|
28
|
+
deSelectText?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface IDropDownProps<T> extends IBindableEditorProps<HTMLSelectElement> {
|
|
31
|
+
select: IDropDownSpecificProps<T>;
|
|
32
|
+
}
|
|
33
|
+
export default class DropDown<T> extends DropDownBase<T, IDropDownProps<T>> {
|
|
34
|
+
static contextType: React.Context<import("../FormContext").FormContextParams>;
|
|
35
|
+
context: React.ContextType<typeof FormContext>;
|
|
36
|
+
private selectedItem;
|
|
37
|
+
private listIndexSymbol;
|
|
38
|
+
constructor(props: IDropDownProps<T>);
|
|
39
|
+
private get items();
|
|
40
|
+
private createLookupIndex;
|
|
41
|
+
private getSelectedOption;
|
|
42
|
+
private onItemSelected;
|
|
43
|
+
render(): JSX.Element;
|
|
44
|
+
}
|