@singularsystems/neo-react 1.1.0 → 1.1.2
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/Button.js +5 -4
- package/dist/ReactComponents/Grid/Column.js +6 -1
- package/dist/ReactComponents/Grid/Grid.js +12 -10
- package/dist/ReactComponents/Input.d.ts +2 -0
- package/dist/ReactComponents/Input.js +11 -2
- package/dist/ReactComponents/RadioList.d.ts +4 -0
- package/dist/ReactComponents/RadioList.js +14 -7
- package/dist/Routing/NavigationHelper.js +1 -1
- package/dist/Routing/ViewParameterList.js +1 -1
- package/package.json +1 -1
- package/styles/Button.scss +5 -1
- package/styles/DatePicker.scss +2 -2
- package/styles/Forms.scss +4 -0
|
@@ -64,6 +64,7 @@ var Button = /** @class */ (function (_super) {
|
|
|
64
64
|
var _b = this.props, isSubmit = _b.isSubmit, variant = _b.variant, size = _b.size, isOutline = _b.isOutline, icon = _b.icon, iconAlignment = _b.iconAlignment, text = _b.text, menuItems = _b.menuItems, splitMenu = _b.splitMenu, menuAlignment = _b.menuAlignment, buttonGroupClassName = _b.buttonGroupClassName, tooltip = _b.tooltip, task = _b.task, isBusy = _b.isBusy, pulse = _b.pulse, customVariant = _b.customVariant, native = __rest(_b, ["isSubmit", "variant", "size", "isOutline", "icon", "iconAlignment", "text", "menuItems", "splitMenu", "menuAlignment", "buttonGroupClassName", "tooltip", "task", "isBusy", "pulse", "customVariant"]);
|
|
65
65
|
native.type = isSubmit ? "submit" : "button";
|
|
66
66
|
var variantClassName = ((_a = customVariant !== null && customVariant !== void 0 ? customVariant : variant) !== null && _a !== void 0 ? _a : "primary");
|
|
67
|
+
var isLoading = isBusy || (task === null || task === void 0 ? void 0 : task.isBusy);
|
|
67
68
|
var isDropDown = menuItems && menuItems.length;
|
|
68
69
|
var buttonClasses = "btn btn-" + (isOutline ? "outline-" : "") + variantClassName;
|
|
69
70
|
if (size)
|
|
@@ -76,7 +77,7 @@ var Button = /** @class */ (function (_super) {
|
|
|
76
77
|
if (isBusy !== undefined || task !== undefined) {
|
|
77
78
|
iconStyle = { fixedWidth: true };
|
|
78
79
|
}
|
|
79
|
-
if (
|
|
80
|
+
if (isLoading) {
|
|
80
81
|
iconStyle.fixedWidth = true;
|
|
81
82
|
iconStyle.spin = true;
|
|
82
83
|
icon = Misc.Settings.icons.loadingIcon;
|
|
@@ -92,7 +93,7 @@ var Button = /** @class */ (function (_super) {
|
|
|
92
93
|
innerText = text;
|
|
93
94
|
var iconSpace = icon && innerText ? " " : "";
|
|
94
95
|
// Icon
|
|
95
|
-
var iconElement = this.iconFactory.getIconComponent(icon, iconStyle);
|
|
96
|
+
var iconElement = (isLoading || !innerText || !Misc.Settings.buttons.suppressIcons) ? this.iconFactory.getIconComponent(icon, iconStyle) : undefined;
|
|
96
97
|
// Tooltip
|
|
97
98
|
if (tooltip) {
|
|
98
99
|
Tooltip.setDomProperties(native, tooltip);
|
|
@@ -100,13 +101,13 @@ var Button = /** @class */ (function (_super) {
|
|
|
100
101
|
var root;
|
|
101
102
|
// Main button
|
|
102
103
|
var buttonChildren = [];
|
|
103
|
-
if (
|
|
104
|
+
if (iconElement && iconAlignment !== "right")
|
|
104
105
|
buttonChildren.push(iconElement, iconSpace);
|
|
105
106
|
buttonChildren.push(innerText);
|
|
106
107
|
if (isDropDown && !splitMenu) {
|
|
107
108
|
buttonChildren.push(" ");
|
|
108
109
|
}
|
|
109
|
-
if (
|
|
110
|
+
if (iconElement && iconAlignment === "right")
|
|
110
111
|
buttonChildren.push(iconSpace, iconElement);
|
|
111
112
|
var mainButton = React.createElement.apply(React, __spreadArray(["button", native], buttonChildren, false));
|
|
112
113
|
var buttonGroupClasses = "btn-group";
|
|
@@ -169,7 +169,12 @@ var Column = /** @class */ (function (_super) {
|
|
|
169
169
|
displayValue = DateUtils.format(rawValue, props.dateProps ? props.dateProps.formatString : undefined);
|
|
170
170
|
}
|
|
171
171
|
else if (this.checkboxType !== CheckboxType.None) {
|
|
172
|
-
|
|
172
|
+
if (Misc.Settings.grid.boolTrueIcon) {
|
|
173
|
+
editor = rawValue ? Misc.Settings.grid.boolTrueIcon : Misc.Settings.grid.boolFalseIcon;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
editor = React.createElement("i", { className: rawValue ? Misc.Settings.grid.boolTrueClass : Misc.Settings.grid.boolFalseClass });
|
|
177
|
+
}
|
|
173
178
|
}
|
|
174
179
|
else if (this.controlType === ControlType.DropDown) {
|
|
175
180
|
editor = BindPropsHelper.getFormControl(props);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __assign, __decorate, __extends, __metadata, __rest } from "tslib";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { Data, Utils, Misc } from '@singularsystems/neo-core';
|
|
4
|
-
import { observer } from 'mobx-react';
|
|
4
|
+
import { observer, Observer } from 'mobx-react';
|
|
5
5
|
import NeoButton from '../Button';
|
|
6
6
|
import { DataViewContext } from '../../React/DataView';
|
|
7
7
|
import { StickyTableHeader } from './StickyTableHeader';
|
|
@@ -45,7 +45,7 @@ var Grid = /** @class */ (function (_super) {
|
|
|
45
45
|
};
|
|
46
46
|
Grid.prototype.render = function () {
|
|
47
47
|
var _this = this;
|
|
48
|
-
var _a = this.props, items = _a.items, showAddButton = _a.showAddButton, addButton = _a.addButton, filterPredicate = _a.filterPredicate, keyProperty = _a.keyProperty, allowSort = _a.allowSort, expandAll = _a.expandAll, collapseAll = _a.collapseAll, initialSort = _a.initialSort, initialSortAscending = _a.initialSortAscending, isBordered = _a.isBordered, isStriped = _a.isStriped, isBorderless = _a.isBorderless, showHover = _a.showHover, isSmallTable = _a.isSmallTable, footerContent = _a.footerContent, footerButtons = _a.footerButtons, stickyHeader = _a.stickyHeader, enableRowIndexes = _a.enableRowIndexes, domProps = __rest(_a, ["items", "showAddButton", "addButton", "filterPredicate", "keyProperty", "allowSort", "expandAll", "collapseAll", "initialSort", "initialSortAscending", "isBordered", "isStriped", "isBorderless", "showHover", "isSmallTable", "footerContent", "footerButtons", "stickyHeader", "enableRowIndexes"]);
|
|
48
|
+
var _a = this.props, items = _a.items, showAddButton = _a.showAddButton, addButton = _a.addButton, filterPredicate = _a.filterPredicate, keyProperty = _a.keyProperty, allowSort = _a.allowSort, expandAll = _a.expandAll, collapseAll = _a.collapseAll, initialSort = _a.initialSort, initialSortAscending = _a.initialSortAscending, isBordered = _a.isBordered, isStriped = _a.isStriped, isBorderless = _a.isBorderless, showHover = _a.showHover, isSmallTable = _a.isSmallTable, footerContent = _a.footerContent, footerButtons = _a.footerButtons, stickyHeader = _a.stickyHeader, enableRowIndexes = _a.enableRowIndexes, children = _a.children, domProps = __rest(_a, ["items", "showAddButton", "addButton", "filterPredicate", "keyProperty", "allowSort", "expandAll", "collapseAll", "initialSort", "initialSortAscending", "isBordered", "isStriped", "isBorderless", "showHover", "isSmallTable", "footerContent", "footerButtons", "stickyHeader", "enableRowIndexes", "children"]);
|
|
49
49
|
if (expandAll === true) {
|
|
50
50
|
this.gridContext.expandAll = true;
|
|
51
51
|
}
|
|
@@ -101,14 +101,16 @@ var Grid = /** @class */ (function (_super) {
|
|
|
101
101
|
}
|
|
102
102
|
return (React.createElement("table", __assign({}, domProps, { className: className, ref: this.domRef }),
|
|
103
103
|
React.createElement(GridContext.Provider, { value: this.gridContext },
|
|
104
|
-
React.createElement(TableSection, { type: "header" }, this.headerItem &&
|
|
105
|
-
React.createElement(TableSection, { type: "body" }, this.gridContext.dataView.getItems().map(function (item, index) { return (React.createElement(ItemGroup, { index: enableRowIndexes ? index : 0, item: item, key: keyProperty ? item[keyProperty] : item.entityIdentifier, template:
|
|
106
|
-
(
|
|
107
|
-
React.createElement(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
React.createElement(TableSection, { type: "header" }, this.headerItem && children(this.headerItem, this.headerItem.meta, true, -1)),
|
|
105
|
+
React.createElement(TableSection, { type: "body" }, this.gridContext.dataView.getItems().map(function (item, index) { return (React.createElement(ItemGroup, { index: enableRowIndexes ? index : 0, item: item, key: keyProperty ? item[keyProperty] : item.entityIdentifier, template: children })); })),
|
|
106
|
+
React.createElement(Observer, null, function () {
|
|
107
|
+
return React.createElement(React.Fragment, null, (showAddButton || addButton || footerButtons || _this.gridContext.hasSummaries || footerContent !== undefined) &&
|
|
108
|
+
React.createElement(TableSection, { type: "footer" },
|
|
109
|
+
_this.gridContext.hasSummaries && _this.headerItem && children(_this.headerItem, _this.headerItem.meta, true, -1),
|
|
110
|
+
footerContent !== undefined && footerContent(_this.gridContext.dataView.getItems()),
|
|
111
|
+
(showAddButton || addButton || footerButtons) &&
|
|
112
|
+
React.createElement(AddButtonRow, { addButton: addButton, showAddButton: showAddButton, additionalContent: footerButtons })));
|
|
113
|
+
}))));
|
|
112
114
|
};
|
|
113
115
|
Grid.prototype.setInitialSort = function (initialSort, initialSortAscending) {
|
|
114
116
|
var _a;
|
|
@@ -16,6 +16,8 @@ export interface IInputSpecificProps {
|
|
|
16
16
|
* Automatically sets type to 'password'.
|
|
17
17
|
*/
|
|
18
18
|
showPasswordButton?: boolean | Components.IButtonOptions;
|
|
19
|
+
/** Alternate label, currently only used to provide a left label for the switch component. */
|
|
20
|
+
altLabel?: string | JSX.Element;
|
|
19
21
|
}
|
|
20
22
|
export interface IInputProps extends IBindableEditorProps<HTMLInputElement> {
|
|
21
23
|
input?: IInputSpecificProps;
|
|
@@ -96,12 +96,21 @@ var Input = /** @class */ (function (_super) {
|
|
|
96
96
|
inputElement = React.createElement("textarea", __assign({}, domProps, { ref: this.domRef, rows: inputProps.rows }));
|
|
97
97
|
}
|
|
98
98
|
if (this.type === "checkbox") {
|
|
99
|
+
var isSwitch = (inputProps === null || inputProps === void 0 ? void 0 : inputProps.type) === "switch";
|
|
99
100
|
var wrapperClassName = isBsPre5 ?
|
|
100
|
-
"custom-control custom-".concat(
|
|
101
|
-
"form-check".concat(
|
|
101
|
+
"custom-control custom-".concat(isSwitch ? "switch" : "checkbox") :
|
|
102
|
+
"form-check".concat(isSwitch ? " form-switch" : "");
|
|
103
|
+
if (isSwitch && inputProps.altLabel) {
|
|
104
|
+
wrapperClassName += " form-switch-inline";
|
|
105
|
+
}
|
|
102
106
|
inputElement = React.createElement("div", { className: wrapperClassName },
|
|
103
107
|
inputElement,
|
|
104
108
|
React.createElement("label", { htmlFor: domProps.id, className: isBsPre5 ? "custom-control-label" : "form-check-label" }, (inputProps.label ? inputProps.label : "")));
|
|
109
|
+
if (isSwitch && inputProps.altLabel) {
|
|
110
|
+
inputElement = React.createElement(React.Fragment, null,
|
|
111
|
+
React.createElement("label", { htmlFor: domProps.id, className: isBsPre5 ? "custom-control-label" : "form-check-label" }, inputProps.altLabel),
|
|
112
|
+
inputElement);
|
|
113
|
+
}
|
|
105
114
|
}
|
|
106
115
|
if (showPasswordButton) {
|
|
107
116
|
var buttonOptions = { variant: "primary", isOutline: true };
|
|
@@ -13,6 +13,9 @@ export interface IRadioListSpecificProps<T> {
|
|
|
13
13
|
valueMember?: keyof T;
|
|
14
14
|
/** Property name to use for the radio button text. Only applies when using items. */
|
|
15
15
|
displayMember?: keyof T;
|
|
16
|
+
onItemSelected?: (item: T) => void;
|
|
17
|
+
/** An array of tooltips, one per item in the order of the items. */
|
|
18
|
+
tooltips?: (string | undefined)[];
|
|
16
19
|
}
|
|
17
20
|
export interface IRadioListProps<T> extends IBindableEditorProps<HTMLSelectElement> {
|
|
18
21
|
radioList: IRadioListSpecificProps<T>;
|
|
@@ -25,5 +28,6 @@ export default class RadioList<T> extends ComponentBase<IRadioListProps<T>> {
|
|
|
25
28
|
private items;
|
|
26
29
|
private preRender;
|
|
27
30
|
private createEnumList;
|
|
31
|
+
private onItemSelected;
|
|
28
32
|
render(): React.JSX.Element;
|
|
29
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __decorate, __extends } from "tslib";
|
|
1
|
+
import { __assign, __decorate, __extends } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { EnumHelper, Utils } from '@singularsystems/neo-core';
|
|
4
4
|
import { observer } from 'mobx-react';
|
|
@@ -21,7 +21,7 @@ var RadioList = /** @class */ (function (_super) {
|
|
|
21
21
|
}
|
|
22
22
|
else if (this.props.radioList.enumType && this.props.radioList.enumType !== this.previousEnumType) {
|
|
23
23
|
this.previousEnumType = this.props.radioList.enumType;
|
|
24
|
-
this.items = EnumHelper.asList(this.props.radioList.enumType);
|
|
24
|
+
this.items = EnumHelper.asList(this.props.radioList.enumType).map(function (item) { return (__assign(__assign({}, item), { _item: item })); });
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
RadioList.prototype.createEnumList = function (list) {
|
|
@@ -29,27 +29,34 @@ var RadioList = /** @class */ (function (_super) {
|
|
|
29
29
|
if (list.length) {
|
|
30
30
|
var _c = LookupHelper.findMembers(list[0], (_a = this.props.radioList.valueMember) !== null && _a !== void 0 ? _a : "", (_b = this.props.radioList.displayMember) !== null && _b !== void 0 ? _b : "", true), valueMember_1 = _c.valueMember, displayMember_1 = _c.displayMember;
|
|
31
31
|
if (valueMember_1 && displayMember_1) {
|
|
32
|
-
this.items = list.map(function (item) { return ({ id: item[valueMember_1], name: item[displayMember_1] }); });
|
|
32
|
+
this.items = list.map(function (item) { return ({ id: item[valueMember_1], name: item[displayMember_1], _item: item }); });
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
+
RadioList.prototype.onItemSelected = function (item) {
|
|
37
|
+
this.props.bind.value = item.id;
|
|
38
|
+
if (this.props.radioList.onItemSelected !== undefined) {
|
|
39
|
+
this.props.radioList.onItemSelected(item._item);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
36
42
|
RadioList.prototype.render = function () {
|
|
37
43
|
var _this = this;
|
|
38
44
|
var _a;
|
|
39
45
|
this.preRender();
|
|
40
46
|
var splitProps = BindPropsHelper.normaliseEditorProps(this, this.props);
|
|
41
47
|
var domProps = BindPropsHelper.autoSetDomProperties(splitProps, this.context);
|
|
48
|
+
var radioProps = this.props.radioList, tooltips = radioProps.tooltips;
|
|
42
49
|
// TODO, how must validation show if not in form group?
|
|
43
50
|
//const displayInfo = this.props.bind.validator.getDisplayState(this.context.validationDisplayMode);
|
|
44
51
|
//displayInfo.applyToDom(domProps, !splitProps.inGroup);
|
|
45
52
|
var isBsPre5 = BootstrapUtils.isPre5, prefix = isBsPre5 ? "custom-control" : "form-check";
|
|
46
53
|
var bindValue = this.props.bind.value;
|
|
47
54
|
var className = Utils.joinWithSpaces("neo-radio-list", (_a = splitProps.editorDom) === null || _a === void 0 ? void 0 : _a.className);
|
|
48
|
-
return React.createElement("div", { className: className }, this.items.map(function (item) {
|
|
55
|
+
return React.createElement("div", { className: className }, this.items.map(function (item, index) {
|
|
49
56
|
var _a, _b;
|
|
50
|
-
return React.createElement("div", { className: "custom-radio " + prefix + (
|
|
51
|
-
React.createElement("input", { type: "radio", id: splitProps.uniqueID + ((_a = item.id) !== null && _a !== void 0 ? _a : ""), name: splitProps.uniqueID, checked: bindValue === item.id, disabled: domProps.disabled || domProps.readOnly, onChange: function () { return _this.
|
|
52
|
-
React.createElement("label", { className: "".concat(prefix, "-label"), htmlFor: splitProps.uniqueID + ((_b = item.id) !== null && _b !== void 0 ? _b : "") }, item.name));
|
|
57
|
+
return React.createElement("div", { className: "custom-radio " + prefix + (radioProps.inline ? " ".concat(prefix, "-inline") : ""), key: item.id },
|
|
58
|
+
React.createElement("input", { type: "radio", id: splitProps.uniqueID + ((_a = item.id) !== null && _a !== void 0 ? _a : ""), name: splitProps.uniqueID, checked: bindValue === item.id, disabled: domProps.disabled || domProps.readOnly, onChange: function () { return _this.onItemSelected(item); }, className: "".concat(prefix, "-input") }),
|
|
59
|
+
React.createElement("label", { className: "".concat(prefix, "-label"), htmlFor: splitProps.uniqueID + ((_b = item.id) !== null && _b !== void 0 ? _b : ""), "data-tip": tooltips && index < tooltips.length ? tooltips[index] : undefined }, item.name));
|
|
53
60
|
}));
|
|
54
61
|
};
|
|
55
62
|
RadioList.contextType = FormContext;
|
|
@@ -51,7 +51,6 @@ var NavigationHelper = /** @class */ (function () {
|
|
|
51
51
|
this.isPrompting = false;
|
|
52
52
|
return [7 /*endfinally*/];
|
|
53
53
|
case 4:
|
|
54
|
-
this.routingState.updateRoute(route);
|
|
55
54
|
if (replace) {
|
|
56
55
|
if (this.prevUrls.length > 0) {
|
|
57
56
|
this.prevUrls[this.prevUrls.length - 1] = url;
|
|
@@ -62,6 +61,7 @@ var NavigationHelper = /** @class */ (function () {
|
|
|
62
61
|
this.prevUrls.push(url);
|
|
63
62
|
window.history.pushState(null, "", url);
|
|
64
63
|
}
|
|
64
|
+
this.routingState.updateRoute(route);
|
|
65
65
|
_a.label = 5;
|
|
66
66
|
case 5: return [2 /*return*/, true];
|
|
67
67
|
}
|
|
@@ -58,7 +58,7 @@ var ViewParameterList = /** @class */ (function () {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
if (breadCrumbs.length === 0 && state.hasQuery) {
|
|
61
|
-
breadCrumbs.push(new BreadCrumbItem("", queryPath));
|
|
61
|
+
breadCrumbs.push(new BreadCrumbItem("", basePath + queryPath));
|
|
62
62
|
}
|
|
63
63
|
return breadCrumbs;
|
|
64
64
|
};
|
package/package.json
CHANGED
package/styles/Button.scss
CHANGED
package/styles/DatePicker.scss
CHANGED
|
@@ -30,7 +30,7 @@ $neo-include-datepicker: true !default;
|
|
|
30
30
|
text-align: center;
|
|
31
31
|
font-size: 14px;
|
|
32
32
|
transform-origin: center top;
|
|
33
|
-
z-index:
|
|
33
|
+
z-index: 5; /* value of 5 to appear above bootstrap focus outline. */
|
|
34
34
|
|
|
35
35
|
&.neo-datepicker-inline {
|
|
36
36
|
position: static;
|
|
@@ -125,7 +125,7 @@ $neo-include-datepicker: true !default;
|
|
|
125
125
|
|
|
126
126
|
&.selectable:hover {
|
|
127
127
|
cursor: pointer;
|
|
128
|
-
background-color: color
|
|
128
|
+
background-color: adjust-color($form-focused-border, $lightness: 15%);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
&.today {
|