@singularsystems/neo-react 1.0.0-alpha.2 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +131 -123
- package/dist/ReactComponents/Card.d.ts +24 -23
- package/dist/ReactComponents/Card.js +56 -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 -88
- 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 -7
- package/dist/ReactComponents/ContextMenu/ContextMenuState.js +23 -23
- package/dist/ReactComponents/DatePicker.d.ts +19 -19
- package/dist/ReactComponents/DatePicker.js +53 -53
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.d.ts +93 -83
- package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js +222 -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 -8
- package/dist/ReactComponents/ErrorHandler.js +92 -91
- 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 -18
- package/dist/ReactComponents/FileManager/FileDropArea.js +66 -64
- package/dist/ReactComponents/FileManager/FileInput.d.ts +44 -42
- package/dist/ReactComponents/FileManager/FileInput.js +191 -189
- 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 -18
- package/dist/ReactComponents/Form.js +90 -90
- package/dist/ReactComponents/FormContext.d.ts +33 -31
- 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 +47 -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 +87 -90
- package/dist/ReactComponents/Grid/Grid.js +203 -203
- package/dist/ReactComponents/Grid/Row.d.ts +81 -81
- package/dist/ReactComponents/Grid/Row.js +200 -201
- 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 -152
- 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 +129 -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 -15
- 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 +260 -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 +161 -161
- package/dist/ReactComponents/PropTypes.js +253 -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 -19
- 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 -74
- 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 -144
- package/dist/Routing/RoutingState.d.ts +18 -15
- package/dist/Routing/RoutingState.js +45 -40
- package/dist/Routing/ViewParameter.d.ts +80 -58
- package/dist/Routing/ViewParameter.js +116 -95
- 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 -71
- package/dist/Views/ViewBase.js +166 -153
- 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 +26 -26
- package/styles/DatePicker.scss +2 -2
- package/styles/Forms.scss +5 -0
- package/styles/Validation.scss +0 -9
|
@@ -1,205 +1,205 @@
|
|
|
1
|
-
import { __assign, __extends, __rest } from "tslib";
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { GridContext } from './Grid';
|
|
4
|
-
import { BindPropsHelper, ControlType, CheckboxType } from '../PropTypes';
|
|
5
|
-
import { StateObserver } from '../StateObserver';
|
|
6
|
-
import memoize from 'memoize-one';
|
|
7
|
-
import { FormatState } from '../NumberInput';
|
|
8
|
-
import { DateUtils, Utils, Misc } from '@singularsystems/neo-core';
|
|
9
|
-
import ComponentBase from '../ComponentBase';
|
|
10
|
-
import { Observer } from 'mobx-react';
|
|
11
|
-
import { EditorParentType, FormContext } from '../FormContext';
|
|
12
|
-
import { ColumnHelper } from './ColumnHelper';
|
|
13
|
-
var editableColumnClassName = "editable-column";
|
|
14
|
-
var Column = /** @class */ (function (_super) {
|
|
15
|
-
__extends(Column, _super);
|
|
16
|
-
function Column() {
|
|
17
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
18
|
-
_this.numFormatState = memoize(FormatState.create);
|
|
19
|
-
_this.suppressSort = false;
|
|
20
|
-
return _this;
|
|
21
|
-
}
|
|
22
|
-
Column.getHeaderText = function (props) {
|
|
23
|
-
if (props.container.label) {
|
|
24
|
-
return props.container.label;
|
|
25
|
-
}
|
|
26
|
-
else if (props.editor.bind) {
|
|
27
|
-
return props.editor.bind.propertyInfo.readableName;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return "";
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
Column.prototype.onFirstRender = function () {
|
|
34
|
-
this.isHeader = this.context.section === "header";
|
|
35
|
-
this.isFooter = this.context.section === "footer";
|
|
36
|
-
};
|
|
37
|
-
Column.prototype.getSortProperty = function () {
|
|
38
|
-
if (this.props.sort !== false && this.context.dataView.allowSort) {
|
|
39
|
-
if (this.props.sort) {
|
|
40
|
-
return this.props.sort;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
var sortProperty = BindPropsHelper.getBindProperty(this.props);
|
|
44
|
-
if (sortProperty && !(sortProperty.propertyInfo.isReadOnly && this.context.dataView.performsRemoteSorting)) {
|
|
45
|
-
return sortProperty;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return undefined;
|
|
50
|
-
};
|
|
51
|
-
Column.prototype.headerClick = function (e) {
|
|
52
|
-
if (this.props.onHeaderClick) {
|
|
53
|
-
this.props.onHeaderClick(e);
|
|
54
|
-
}
|
|
55
|
-
if (!e.defaultPrevented && !this.suppressSort) {
|
|
56
|
-
var sortProperty = this.getSortProperty();
|
|
57
|
-
if (sortProperty) {
|
|
58
|
-
if (e.shiftKey && this.context.dataView.sortInfo.length) {
|
|
59
|
-
this.context.dataView.addSort(sortProperty.propertyInfo);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
this.context.dataView.resetSort(sortProperty.propertyInfo);
|
|
63
|
-
}
|
|
64
|
-
if (e.shiftKey) {
|
|
65
|
-
// Stop text selection.
|
|
66
|
-
e.preventDefault();
|
|
67
|
-
e.stopPropagation();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
Column.prototype.refreshStateObserver = function (props) {
|
|
73
|
-
var _this = this;
|
|
74
|
-
if (this.isHeader || props.isReadOnly) {
|
|
75
|
-
if (!this.stateObserver) {
|
|
76
|
-
this.stateObserver = new StateObserver(this, function () {
|
|
77
|
-
return {
|
|
78
|
-
sortInfo: _this.isHeader ? _this.context.dataView.sortInfo : null,
|
|
79
|
-
displayValue: !_this.isHeader && !_this.isFooter ? props.bind.value : null
|
|
80
|
-
};
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
this.stateObserver.observe();
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
Column.prototype.componentWillUnmount = function () {
|
|
87
|
-
if (this.stateObserver)
|
|
88
|
-
this.stateObserver.dispose();
|
|
89
|
-
};
|
|
90
|
-
Column.prototype.render = function () {
|
|
91
|
-
this.onRender();
|
|
92
|
-
var allProps = BindPropsHelper.normaliseContainerProps(this, this.props, false);
|
|
93
|
-
var _a = allProps.containerDom, width = _a.width, hideBelow = _a.hideBelow, hideAbove = _a.hideAbove, headerTooltip = _a.headerTooltip, cellTooltip = _a.cellTooltip, alignment = _a.alignment, sort = _a.sort, sum = _a.sum, footerContent = _a.footerContent, headerClassName = _a.headerClassName, cellClassName = _a.cellClassName, onHeaderClick = _a.onHeaderClick, domProps = __rest(_a, ["width", "hideBelow", "hideAbove", "headerTooltip", "cellTooltip", "alignment", "sort", "sum", "footerContent", "headerClassName", "cellClassName", "onHeaderClick"]);
|
|
94
|
-
if (allProps.bind !== undefined) {
|
|
95
|
-
if (!this.controlType || this.isHeader) {
|
|
96
|
-
this.controlType = BindPropsHelper.getControlType(allProps);
|
|
97
|
-
var items = this.context.dataView.rawItems;
|
|
98
|
-
this.checkboxType = BindPropsHelper.getCheckBoxType(allProps, this.isHeader && (items === null || items === void 0 ? void 0 : items.length) && items[0]);
|
|
99
|
-
if (this.isHeader) {
|
|
100
|
-
// Prevent sorting if the bind property is not on the root object. E.g. item.child.meta.property
|
|
101
|
-
this.suppressSort = items.length === 0 || items[0].meta[allProps.bind.propertyInfo.propertyName] === undefined;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (!allProps.editor.isReadOnly) {
|
|
105
|
-
domProps.className = Utils.joinWithSpaces(domProps.className, editableColumnClassName);
|
|
106
|
-
}
|
|
107
|
-
if (this.controlType === ControlType.Number) {
|
|
108
|
-
domProps.className = Utils.joinWithSpaces(domProps.className, "number-col");
|
|
109
|
-
}
|
|
110
|
-
else if (this.controlType === ControlType.Date) {
|
|
111
|
-
domProps.className = Utils.joinWithSpaces(domProps.className, "date-col");
|
|
112
|
-
}
|
|
113
|
-
else if (this.checkboxType !== CheckboxType.None) {
|
|
114
|
-
domProps.className = Utils.joinWithSpaces(domProps.className, "boolean-col");
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
domProps.className = ColumnHelper.addCommonClasses(domProps.className, allProps.containerDom);
|
|
118
|
-
if (width) {
|
|
119
|
-
if (!domProps) {
|
|
120
|
-
domProps = { style: {} };
|
|
121
|
-
}
|
|
122
|
-
if (!domProps.style) {
|
|
123
|
-
domProps.style = {};
|
|
124
|
-
}
|
|
125
|
-
if (width instanceof Number) {
|
|
126
|
-
domProps.style.width = width + "px";
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
domProps.style.width = width;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
this.refreshStateObserver(allProps.editor);
|
|
133
|
-
return this.isHeader ? this.renderHeader(allProps, domProps, headerTooltip, headerClassName) :
|
|
134
|
-
this.isFooter ? this.renderFooter(allProps, domProps) :
|
|
135
|
-
this.renderBody(allProps, domProps, cellTooltip, cellClassName);
|
|
136
|
-
};
|
|
137
|
-
Column.prototype.renderHeader = function (props, domProps, tooltip, headerClassName) {
|
|
138
|
-
var _this = this;
|
|
139
|
-
var sortIcon = null;
|
|
140
|
-
var sortProperty = this.getSortProperty();
|
|
141
|
-
domProps.className = Utils.joinWithSpaces(domProps.className, headerClassName);
|
|
142
|
-
if (sortProperty && !this.suppressSort) {
|
|
143
|
-
var sortInfo = this.context.dataView.sortInfo.find(function (c) { return c.column === sortProperty.propertyInfo; });
|
|
144
|
-
if (sortInfo) {
|
|
145
|
-
sortIcon = sortInfo.sortAscending ?
|
|
146
|
-
domProps.className = Utils.joinWithSpaces(domProps.className, "column-is-sorted");
|
|
147
|
-
}
|
|
148
|
-
domProps.className = Utils.joinWithSpaces(domProps.className, "column-sortable");
|
|
149
|
-
}
|
|
150
|
-
return (React.createElement("th", __assign({ "data-tip": tooltip }, domProps, { onClick: function (e) { return _this.headerClick(e); } }),
|
|
151
|
-
Column.getHeaderText(props),
|
|
152
|
-
sortIcon &&
|
|
153
|
-
React.createElement("i", { className: "column-sort-icon fa fa-" + sortIcon })));
|
|
154
|
-
};
|
|
155
|
-
Column.prototype.renderBody = function (props, domProps, cellTooltip, cellClassName) {
|
|
156
|
-
var _this = this;
|
|
157
|
-
var editorProps = props.editor;
|
|
158
|
-
var containerProps = props.container;
|
|
159
|
-
var displayValue = "";
|
|
160
|
-
var editor = undefined;
|
|
161
|
-
if (!containerProps.suppressDefaultContent) {
|
|
162
|
-
if (editorProps.isReadOnly && !editorProps.requiresGroup) {
|
|
163
|
-
var rawValue = editorProps.bind.value;
|
|
164
|
-
if (this.controlType == ControlType.Number) {
|
|
165
|
-
displayValue = this.numFormatState(editorProps.bind.propertyInfo.propertyType, props.numProps).getFormattedValue(rawValue);
|
|
166
|
-
}
|
|
167
|
-
else if (this.controlType == ControlType.Date) {
|
|
168
|
-
displayValue = DateUtils.format(rawValue, props.dateProps ? props.dateProps.formatString : undefined);
|
|
169
|
-
}
|
|
170
|
-
else if (this.checkboxType !== CheckboxType.None) {
|
|
171
|
-
editor = React.createElement("i", { className: rawValue ? Misc.Settings.grid.boolTrueClass : Misc.Settings.grid.boolFalseClass });
|
|
172
|
-
}
|
|
173
|
-
else if (this.controlType === ControlType.DropDown) {
|
|
174
|
-
editor = BindPropsHelper.getFormControl(props);
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
displayValue = (rawValue !== undefined && rawValue !== null) ? rawValue.toString() : "";
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
else if (props.bind) {
|
|
181
|
-
editor = BindPropsHelper.getFormControl(props);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
domProps.className = Utils.joinWithSpaces(domProps.className, cellClassName);
|
|
185
|
-
return (React.createElement("td", __assign({ "data-tip": cellTooltip }, domProps),
|
|
186
|
-
!containerProps.suppressDefaultContent && (editor !== undefined ?
|
|
187
|
-
editor :
|
|
188
|
-
editorProps.bind ? displayValue : undefined),
|
|
189
|
-
!containerProps.bindContext &&
|
|
190
|
-
containerProps.bindContext &&
|
|
191
|
-
React.createElement(FormContext.Consumer, null, function (value) { return (React.createElement(FormContext.Provider, { value: __assign(__assign({}, value), { parentType: EditorParentType.Column, bindProperty: containerProps.bindContext }) }, _this.props.children
|
|
192
|
-
};
|
|
193
|
-
Column.prototype.renderFooter = function (props, domProps) {
|
|
194
|
-
var _this = this;
|
|
195
|
-
var colProps = props.containerDom;
|
|
196
|
-
var hasSummary = (colProps.sum && !!props.bind) || colProps.footerContent;
|
|
197
|
-
return (React.createElement("th", __assign({}, domProps), hasSummary &&
|
|
198
|
-
React.createElement(Observer, null, function () { return colProps.footerContent ? colProps.footerContent(_this.context.dataView.filteredItems) :
|
|
199
|
-
_this.numFormatState(props.bind.propertyInfo.propertyType, props.numProps).getFormattedValue(_this.context.dataView.filteredItems.sum(props.bind.propertyInfo)); })));
|
|
200
|
-
};
|
|
201
|
-
Column.isColumnComponent = true;
|
|
202
|
-
Column.contextType = GridContext;
|
|
203
|
-
return Column;
|
|
204
|
-
}(ComponentBase));
|
|
205
|
-
export default Column;
|
|
1
|
+
import { __assign, __extends, __rest } from "tslib";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { GridContext } from './Grid';
|
|
4
|
+
import { BindPropsHelper, ControlType, CheckboxType } from '../PropTypes';
|
|
5
|
+
import { StateObserver } from '../StateObserver';
|
|
6
|
+
import memoize from 'memoize-one';
|
|
7
|
+
import { FormatState } from '../NumberInput';
|
|
8
|
+
import { DateUtils, Utils, Misc } from '@singularsystems/neo-core';
|
|
9
|
+
import ComponentBase from '../ComponentBase';
|
|
10
|
+
import { Observer } from 'mobx-react';
|
|
11
|
+
import { EditorParentType, FormContext } from '../FormContext';
|
|
12
|
+
import { ColumnHelper } from './ColumnHelper';
|
|
13
|
+
var editableColumnClassName = "editable-column";
|
|
14
|
+
var Column = /** @class */ (function (_super) {
|
|
15
|
+
__extends(Column, _super);
|
|
16
|
+
function Column() {
|
|
17
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
18
|
+
_this.numFormatState = memoize(FormatState.create);
|
|
19
|
+
_this.suppressSort = false;
|
|
20
|
+
return _this;
|
|
21
|
+
}
|
|
22
|
+
Column.getHeaderText = function (props) {
|
|
23
|
+
if (props.container.label) {
|
|
24
|
+
return props.container.label;
|
|
25
|
+
}
|
|
26
|
+
else if (props.editor.bind) {
|
|
27
|
+
return props.editor.bind.propertyInfo.readableName;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return "";
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
Column.prototype.onFirstRender = function () {
|
|
34
|
+
this.isHeader = this.context.section === "header";
|
|
35
|
+
this.isFooter = this.context.section === "footer";
|
|
36
|
+
};
|
|
37
|
+
Column.prototype.getSortProperty = function () {
|
|
38
|
+
if (this.props.sort !== false && this.context.dataView.allowSort) {
|
|
39
|
+
if (this.props.sort) {
|
|
40
|
+
return this.props.sort;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
var sortProperty = BindPropsHelper.getBindProperty(this.props);
|
|
44
|
+
if (sortProperty && !(sortProperty.propertyInfo.isReadOnly && this.context.dataView.performsRemoteSorting)) {
|
|
45
|
+
return sortProperty;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
};
|
|
51
|
+
Column.prototype.headerClick = function (e) {
|
|
52
|
+
if (this.props.onHeaderClick) {
|
|
53
|
+
this.props.onHeaderClick(e);
|
|
54
|
+
}
|
|
55
|
+
if (!e.defaultPrevented && !this.suppressSort) {
|
|
56
|
+
var sortProperty = this.getSortProperty();
|
|
57
|
+
if (sortProperty) {
|
|
58
|
+
if (e.shiftKey && this.context.dataView.sortInfo.length) {
|
|
59
|
+
this.context.dataView.addSort(sortProperty.propertyInfo);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.context.dataView.resetSort(sortProperty.propertyInfo);
|
|
63
|
+
}
|
|
64
|
+
if (e.shiftKey) {
|
|
65
|
+
// Stop text selection.
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
e.stopPropagation();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
Column.prototype.refreshStateObserver = function (props) {
|
|
73
|
+
var _this = this;
|
|
74
|
+
if (this.isHeader || props.isReadOnly) {
|
|
75
|
+
if (!this.stateObserver) {
|
|
76
|
+
this.stateObserver = new StateObserver(this, function () {
|
|
77
|
+
return {
|
|
78
|
+
sortInfo: _this.isHeader ? _this.context.dataView.sortInfo : null,
|
|
79
|
+
displayValue: !_this.isHeader && !_this.isFooter ? props.bind.value : null
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
this.stateObserver.observe();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
Column.prototype.componentWillUnmount = function () {
|
|
87
|
+
if (this.stateObserver)
|
|
88
|
+
this.stateObserver.dispose();
|
|
89
|
+
};
|
|
90
|
+
Column.prototype.render = function () {
|
|
91
|
+
this.onRender();
|
|
92
|
+
var allProps = BindPropsHelper.normaliseContainerProps(this, this.props, false);
|
|
93
|
+
var _a = allProps.containerDom, width = _a.width, hideBelow = _a.hideBelow, hideAbove = _a.hideAbove, headerTooltip = _a.headerTooltip, cellTooltip = _a.cellTooltip, alignment = _a.alignment, sort = _a.sort, sum = _a.sum, footerContent = _a.footerContent, headerClassName = _a.headerClassName, cellClassName = _a.cellClassName, onHeaderClick = _a.onHeaderClick, domProps = __rest(_a, ["width", "hideBelow", "hideAbove", "headerTooltip", "cellTooltip", "alignment", "sort", "sum", "footerContent", "headerClassName", "cellClassName", "onHeaderClick"]);
|
|
94
|
+
if (allProps.bind !== undefined) {
|
|
95
|
+
if (!this.controlType || this.isHeader) {
|
|
96
|
+
this.controlType = BindPropsHelper.getControlType(allProps);
|
|
97
|
+
var items = this.context.dataView.rawItems;
|
|
98
|
+
this.checkboxType = BindPropsHelper.getCheckBoxType(allProps, this.isHeader && (items === null || items === void 0 ? void 0 : items.length) && items[0]);
|
|
99
|
+
if (this.isHeader) {
|
|
100
|
+
// Prevent sorting if the bind property is not on the root object. E.g. item.child.meta.property
|
|
101
|
+
this.suppressSort = items.length === 0 || items[0].meta[allProps.bind.propertyInfo.propertyName] === undefined;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (!allProps.editor.isReadOnly) {
|
|
105
|
+
domProps.className = Utils.joinWithSpaces(domProps.className, editableColumnClassName);
|
|
106
|
+
}
|
|
107
|
+
if (this.controlType === ControlType.Number) {
|
|
108
|
+
domProps.className = Utils.joinWithSpaces(domProps.className, "number-col");
|
|
109
|
+
}
|
|
110
|
+
else if (this.controlType === ControlType.Date) {
|
|
111
|
+
domProps.className = Utils.joinWithSpaces(domProps.className, "date-col");
|
|
112
|
+
}
|
|
113
|
+
else if (this.checkboxType !== CheckboxType.None) {
|
|
114
|
+
domProps.className = Utils.joinWithSpaces(domProps.className, "boolean-col");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
domProps.className = ColumnHelper.addCommonClasses(domProps.className, allProps.containerDom);
|
|
118
|
+
if (width) {
|
|
119
|
+
if (!domProps) {
|
|
120
|
+
domProps = { style: {} };
|
|
121
|
+
}
|
|
122
|
+
if (!domProps.style) {
|
|
123
|
+
domProps.style = {};
|
|
124
|
+
}
|
|
125
|
+
if (width instanceof Number) {
|
|
126
|
+
domProps.style.width = width + "px";
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
domProps.style.width = width;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
this.refreshStateObserver(allProps.editor);
|
|
133
|
+
return this.isHeader ? this.renderHeader(allProps, domProps, headerTooltip, headerClassName) :
|
|
134
|
+
this.isFooter ? this.renderFooter(allProps, domProps) :
|
|
135
|
+
this.renderBody(allProps, domProps, cellTooltip, cellClassName);
|
|
136
|
+
};
|
|
137
|
+
Column.prototype.renderHeader = function (props, domProps, tooltip, headerClassName) {
|
|
138
|
+
var _this = this;
|
|
139
|
+
var sortIcon = null;
|
|
140
|
+
var sortProperty = this.getSortProperty();
|
|
141
|
+
domProps.className = Utils.joinWithSpaces(domProps.className, headerClassName);
|
|
142
|
+
if (sortProperty && !this.suppressSort) {
|
|
143
|
+
var sortInfo = this.context.dataView.sortInfo.find(function (c) { return c.column === sortProperty.propertyInfo; });
|
|
144
|
+
if (sortInfo) {
|
|
145
|
+
sortIcon = sortInfo.sortAscending ? Misc.Settings.icons.sortAsc : Misc.Settings.icons.sortDesc;
|
|
146
|
+
domProps.className = Utils.joinWithSpaces(domProps.className, "column-is-sorted");
|
|
147
|
+
}
|
|
148
|
+
domProps.className = Utils.joinWithSpaces(domProps.className, "column-sortable");
|
|
149
|
+
}
|
|
150
|
+
return (React.createElement("th", __assign({ "data-tip": tooltip }, domProps, { onClick: function (e) { return _this.headerClick(e); } }),
|
|
151
|
+
Column.getHeaderText(props),
|
|
152
|
+
sortIcon &&
|
|
153
|
+
React.createElement("i", { className: "column-sort-icon fa fa-" + sortIcon })));
|
|
154
|
+
};
|
|
155
|
+
Column.prototype.renderBody = function (props, domProps, cellTooltip, cellClassName) {
|
|
156
|
+
var _this = this;
|
|
157
|
+
var editorProps = props.editor;
|
|
158
|
+
var containerProps = props.container;
|
|
159
|
+
var displayValue = "";
|
|
160
|
+
var editor = undefined;
|
|
161
|
+
if (!containerProps.suppressDefaultContent) {
|
|
162
|
+
if (editorProps.isReadOnly && !editorProps.requiresGroup) {
|
|
163
|
+
var rawValue = editorProps.bind.value;
|
|
164
|
+
if (this.controlType == ControlType.Number) {
|
|
165
|
+
displayValue = this.numFormatState(editorProps.bind.propertyInfo, editorProps.bind.propertyInfo.propertyType, props.numProps).getFormattedValue(rawValue);
|
|
166
|
+
}
|
|
167
|
+
else if (this.controlType == ControlType.Date) {
|
|
168
|
+
displayValue = DateUtils.format(rawValue, props.dateProps ? props.dateProps.formatString : undefined);
|
|
169
|
+
}
|
|
170
|
+
else if (this.checkboxType !== CheckboxType.None) {
|
|
171
|
+
editor = React.createElement("i", { className: rawValue ? Misc.Settings.grid.boolTrueClass : Misc.Settings.grid.boolFalseClass });
|
|
172
|
+
}
|
|
173
|
+
else if (this.controlType === ControlType.DropDown) {
|
|
174
|
+
editor = BindPropsHelper.getFormControl(props);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
displayValue = (rawValue !== undefined && rawValue !== null) ? rawValue.toString() : "";
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else if (props.bind) {
|
|
181
|
+
editor = BindPropsHelper.getFormControl(props);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
domProps.className = Utils.joinWithSpaces(domProps.className, cellClassName);
|
|
185
|
+
return (React.createElement("td", __assign({ "data-tip": cellTooltip }, domProps),
|
|
186
|
+
!containerProps.suppressDefaultContent && (editor !== undefined ?
|
|
187
|
+
editor :
|
|
188
|
+
editorProps.bind ? displayValue : undefined),
|
|
189
|
+
!containerProps.bindContext && this.props.children,
|
|
190
|
+
containerProps.bindContext &&
|
|
191
|
+
React.createElement(FormContext.Consumer, null, function (value) { return (React.createElement(FormContext.Provider, { value: __assign(__assign({}, value), { parentType: EditorParentType.Column, bindProperty: containerProps.bindContext }) }, _this.props.children)); })));
|
|
192
|
+
};
|
|
193
|
+
Column.prototype.renderFooter = function (props, domProps) {
|
|
194
|
+
var _this = this;
|
|
195
|
+
var colProps = props.containerDom;
|
|
196
|
+
var hasSummary = (colProps.sum && !!props.bind) || colProps.footerContent;
|
|
197
|
+
return (React.createElement("th", __assign({}, domProps), hasSummary &&
|
|
198
|
+
React.createElement(Observer, null, function () { return colProps.footerContent ? colProps.footerContent(_this.context.dataView.filteredItems) :
|
|
199
|
+
_this.numFormatState(props.bind.propertyInfo, props.bind.propertyInfo.propertyType, props.numProps).getFormattedValue(_this.context.dataView.filteredItems.sum(props.bind.propertyInfo)); })));
|
|
200
|
+
};
|
|
201
|
+
Column.isColumnComponent = true;
|
|
202
|
+
Column.contextType = GridContext;
|
|
203
|
+
return Column;
|
|
204
|
+
}(ComponentBase));
|
|
205
|
+
export default Column;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Components } from "@singularsystems/neo-core";
|
|
2
|
-
export interface INeoCommonColumnProps {
|
|
3
|
-
/** Hide the column when the screen size is smaller than the specified breakpoint. */
|
|
4
|
-
hideBelow?: Components.breakpoint;
|
|
5
|
-
/** Hide the column when the screen size is equal to, or larger than the specified breakpoint. */
|
|
6
|
-
hideAbove?: Components.breakpoint;
|
|
7
|
-
/** Set the alignment of the column. */
|
|
8
|
-
alignment?: "left" | "center" | "right";
|
|
9
|
-
}
|
|
10
|
-
export declare class ColumnHelper {
|
|
11
|
-
static addCommonClasses(className: string | undefined, props: INeoCommonColumnProps): string | undefined;
|
|
12
|
-
}
|
|
1
|
+
import { Components } from "@singularsystems/neo-core";
|
|
2
|
+
export interface INeoCommonColumnProps {
|
|
3
|
+
/** Hide the column when the screen size is smaller than the specified breakpoint. */
|
|
4
|
+
hideBelow?: Components.breakpoint;
|
|
5
|
+
/** Hide the column when the screen size is equal to, or larger than the specified breakpoint. */
|
|
6
|
+
hideAbove?: Components.breakpoint;
|
|
7
|
+
/** Set the alignment of the column. */
|
|
8
|
+
alignment?: "left" | "center" | "right";
|
|
9
|
+
}
|
|
10
|
+
export declare class ColumnHelper {
|
|
11
|
+
static addCommonClasses(className: string | undefined, props: INeoCommonColumnProps): string | undefined;
|
|
12
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Utils } from "@singularsystems/neo-core";
|
|
2
|
-
var ColumnHelper = /** @class */ (function () {
|
|
3
|
-
function ColumnHelper() {
|
|
4
|
-
}
|
|
5
|
-
ColumnHelper.addCommonClasses = function (className, props) {
|
|
6
|
-
if (props.hideBelow) {
|
|
7
|
-
className = Utils.joinWithSpaces(className, "d-none d-".concat(props.hideBelow, "-table-cell"));
|
|
8
|
-
}
|
|
9
|
-
if (props.hideAbove) {
|
|
10
|
-
className = Utils.joinWithSpaces(className, "d-table-cell d-".concat(props.hideAbove, "-none"));
|
|
11
|
-
}
|
|
12
|
-
if (props.alignment) {
|
|
13
|
-
className = Utils.joinWithSpaces(className, "col-align-".concat(props.alignment));
|
|
14
|
-
}
|
|
15
|
-
return className;
|
|
16
|
-
};
|
|
17
|
-
return ColumnHelper;
|
|
18
|
-
}());
|
|
19
|
-
export { ColumnHelper };
|
|
1
|
+
import { Utils } from "@singularsystems/neo-core";
|
|
2
|
+
var ColumnHelper = /** @class */ (function () {
|
|
3
|
+
function ColumnHelper() {
|
|
4
|
+
}
|
|
5
|
+
ColumnHelper.addCommonClasses = function (className, props) {
|
|
6
|
+
if (props.hideBelow) {
|
|
7
|
+
className = Utils.joinWithSpaces(className, "d-none d-".concat(props.hideBelow, "-table-cell"));
|
|
8
|
+
}
|
|
9
|
+
if (props.hideAbove) {
|
|
10
|
+
className = Utils.joinWithSpaces(className, "d-table-cell d-".concat(props.hideAbove, "-none"));
|
|
11
|
+
}
|
|
12
|
+
if (props.alignment) {
|
|
13
|
+
className = Utils.joinWithSpaces(className, "col-align-".concat(props.alignment));
|
|
14
|
+
}
|
|
15
|
+
return className;
|
|
16
|
+
};
|
|
17
|
+
return ColumnHelper;
|
|
18
|
+
}());
|
|
19
|
+
export { ColumnHelper };
|