@singularsystems/neo-react 1.1.1 → 1.1.3
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/FileManager/FileInput.d.ts +1 -0
- 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/ReactComponents/Transitions/Transition.d.ts +5 -1
- package/dist/ReactComponents/Transitions/Transition.js +6 -2
- package/dist/ReactComponents/Transitions/TransitionContainer.d.ts +2 -0
- package/dist/ReactComponents/Transitions/TransitionContainer.js +7 -1
- package/dist/ReactComponents/Transitions/TransitionController.d.ts +6 -2
- package/dist/ReactComponents/Transitions/TransitionController.js +41 -25
- package/dist/ReactComponents/Transitions/TransitionPanel.d.ts +4 -0
- package/dist/ReactComponents/Transitions/TransitionPanel.js +2 -2
- package/package.json +3 -3
- 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";
|
|
@@ -13,6 +13,7 @@ export interface IFileEditorProps extends IFileComponentProps, Partial<Component
|
|
|
13
13
|
downloadLinkText?: string;
|
|
14
14
|
/**
|
|
15
15
|
* Path of API endpoint which will handle downloading a file. Only required if downloadLinkText is specified.
|
|
16
|
+
* Use `downloadEndpointAsync` when asynchronously returning a download link with sas token.
|
|
16
17
|
*/
|
|
17
18
|
downloadEndpoint?: string | ((fileID: any) => string);
|
|
18
19
|
/**
|
|
@@ -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;
|
|
@@ -2,7 +2,11 @@ export declare class Transition {
|
|
|
2
2
|
setBeforeStyles: (element: HTMLElement, out: boolean, toLeft: boolean) => void;
|
|
3
3
|
setAfterStyles: (element: HTMLElement, out: boolean, toLeft: boolean) => void;
|
|
4
4
|
cleanup: (element: HTMLElement) => void;
|
|
5
|
-
|
|
5
|
+
/** Set to true if the animation causes the elements height to change. E.g. zoom type transitions */
|
|
6
|
+
changesHeight: boolean;
|
|
7
|
+
constructor(setBeforeStyles: (element: HTMLElement, out: boolean, toLeft: boolean) => void, setAfterStyles: (element: HTMLElement, out: boolean, toLeft: boolean) => void, cleanup: (element: HTMLElement) => void,
|
|
8
|
+
/** Set to true if the animation causes the elements height to change. E.g. zoom type transitions */
|
|
9
|
+
changesHeight?: boolean);
|
|
6
10
|
static leftRight: Transition;
|
|
7
11
|
static upDown: Transition;
|
|
8
12
|
static inOut: Transition;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
var Transition = /** @class */ (function () {
|
|
2
|
-
function Transition(setBeforeStyles, setAfterStyles, cleanup
|
|
2
|
+
function Transition(setBeforeStyles, setAfterStyles, cleanup,
|
|
3
|
+
/** Set to true if the animation causes the elements height to change. E.g. zoom type transitions */
|
|
4
|
+
changesHeight) {
|
|
5
|
+
if (changesHeight === void 0) { changesHeight = false; }
|
|
3
6
|
this.setBeforeStyles = setBeforeStyles;
|
|
4
7
|
this.setAfterStyles = setAfterStyles;
|
|
5
8
|
this.cleanup = cleanup;
|
|
9
|
+
this.changesHeight = changesHeight;
|
|
6
10
|
}
|
|
7
11
|
Transition.leftRight = new Transition(function (element, out, toLeft) { return element.style.left = ((toLeft ? 1 : -1) * (out ? 0 : 150)) + "px"; }, function (element, out, toLeft) { return element.style.left = ((toLeft ? -1 : 1) * (out ? 150 : 0)) + "px"; }, function (element) { return element.style.left = ""; });
|
|
8
12
|
Transition.upDown = new Transition(function (element, out, toLeft) { return element.style.top = ((toLeft ? 1 : -1) * (out ? 0 : 100)) + "px"; }, function (element, out, toLeft) { return element.style.top = ((toLeft ? -1 : 1) * (out ? 100 : 0)) + "px"; }, function (element) { return element.style.top = ""; });
|
|
9
|
-
Transition.inOut = new Transition(function (element, out, toLeft) { return element.style.transform = out ? "scale(1)" : (toLeft ? "scale(0.8)" : "scale(1.2)"); }, function (element, out, toLeft) { return element.style.transform = out ? (toLeft ? "scale(1.2)" : "scale(0.8)") : "scale(1)"; }, function (element) { return element.style.transform = ""; });
|
|
13
|
+
Transition.inOut = new Transition(function (element, out, toLeft) { return element.style.transform = out ? "scale(1)" : (toLeft ? "scale(0.8)" : "scale(1.2)"); }, function (element, out, toLeft) { return element.style.transform = out ? (toLeft ? "scale(1.2)" : "scale(0.8)") : "scale(1)"; }, function (element) { return element.style.transform = ""; }, true);
|
|
10
14
|
Transition.fadeOnly = new Transition(function () { }, function () { }, function () { });
|
|
11
15
|
return Transition;
|
|
12
16
|
}());
|
|
@@ -8,6 +8,8 @@ export declare const TransitionContext: React.Context<ITransitionContextState>;
|
|
|
8
8
|
interface ITransitionContainerProps {
|
|
9
9
|
controller?: TransitionController;
|
|
10
10
|
transition?: Transition;
|
|
11
|
+
/** Transition to use when going backwards. */
|
|
12
|
+
backTransition?: Transition;
|
|
11
13
|
children: React.ReactNode;
|
|
12
14
|
}
|
|
13
15
|
export default class TransitionContainer extends React.Component<ITransitionContainerProps> {
|
|
@@ -8,11 +8,17 @@ var TransitionContainer = /** @class */ (function (_super) {
|
|
|
8
8
|
var _this = _super.call(this, props) || this;
|
|
9
9
|
_this.containerRef = React.createRef();
|
|
10
10
|
if (!_this.props.controller) {
|
|
11
|
-
_this.controller = new TransitionController(undefined, _this.props.transition);
|
|
11
|
+
_this.controller = new TransitionController(undefined, _this.props.transition, _this.props.backTransition);
|
|
12
12
|
_this.controller.wasAutoCreated = true;
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
15
|
_this.controller = _this.props.controller;
|
|
16
|
+
if (_this.props.transition) {
|
|
17
|
+
_this.controller.defaultTransition = _this.props.transition;
|
|
18
|
+
}
|
|
19
|
+
if (_this.props.backTransition) {
|
|
20
|
+
_this.controller.defaultBackTransition = _this.props.backTransition;
|
|
21
|
+
}
|
|
16
22
|
}
|
|
17
23
|
_this.contextState = { controller: _this.controller };
|
|
18
24
|
return _this;
|
|
@@ -2,14 +2,18 @@ import { Transition } from "./Transition";
|
|
|
2
2
|
export declare class TransitionController {
|
|
3
3
|
/** Global default transition. */
|
|
4
4
|
static transition: Transition;
|
|
5
|
+
/** Allows transitions to be disabled for the whole app. */
|
|
6
|
+
static disableTransitions: boolean;
|
|
5
7
|
/**
|
|
6
8
|
* Creates a transition controller.
|
|
7
9
|
* @param initialName Name of the panel to display initially. Not required if `isVisible` props are defined on the panels.
|
|
8
10
|
* @param transition Transition type to use by default on all panels.
|
|
11
|
+
* @param backTransition Transition type to use when going backwards.
|
|
9
12
|
*/
|
|
10
|
-
constructor(initialName?: string, transition?: Transition);
|
|
13
|
+
constructor(initialName?: string, transition?: Transition, backTransition?: Transition);
|
|
11
14
|
private _selectedName;
|
|
12
|
-
|
|
15
|
+
defaultTransition: Transition;
|
|
16
|
+
defaultBackTransition: Transition;
|
|
13
17
|
private direction;
|
|
14
18
|
private isFirstTransition;
|
|
15
19
|
private isTransitioning;
|
|
@@ -7,8 +7,9 @@ var TransitionController = /** @class */ (function () {
|
|
|
7
7
|
* Creates a transition controller.
|
|
8
8
|
* @param initialName Name of the panel to display initially. Not required if `isVisible` props are defined on the panels.
|
|
9
9
|
* @param transition Transition type to use by default on all panels.
|
|
10
|
+
* @param backTransition Transition type to use when going backwards.
|
|
10
11
|
*/
|
|
11
|
-
function TransitionController(initialName, transition) {
|
|
12
|
+
function TransitionController(initialName, transition, backTransition) {
|
|
12
13
|
this._selectedName = "";
|
|
13
14
|
this.direction = 1;
|
|
14
15
|
this.isFirstTransition = true;
|
|
@@ -22,6 +23,7 @@ var TransitionController = /** @class */ (function () {
|
|
|
22
23
|
this._selectedName = initialName !== null && initialName !== void 0 ? initialName : "";
|
|
23
24
|
makeObservable(this);
|
|
24
25
|
this.defaultTransition = transition !== null && transition !== void 0 ? transition : TransitionController.transition;
|
|
26
|
+
this.defaultBackTransition = backTransition !== null && backTransition !== void 0 ? backTransition : this.defaultTransition;
|
|
25
27
|
}
|
|
26
28
|
Object.defineProperty(TransitionController.prototype, "selectedPanel", {
|
|
27
29
|
/**
|
|
@@ -92,7 +94,7 @@ var TransitionController = /** @class */ (function () {
|
|
|
92
94
|
* @internal
|
|
93
95
|
* Called by each panel after render.
|
|
94
96
|
*/
|
|
95
|
-
TransitionController.prototype.afterUpdate = function (name, element, transition) {
|
|
97
|
+
TransitionController.prototype.afterUpdate = function (name, element, transition, animateHeight) {
|
|
96
98
|
if (this._selectedName === name && !this.isTransitioning) {
|
|
97
99
|
var panelState_1 = this.panelStates.find(function (c) { return c.name === name; });
|
|
98
100
|
var transitionIn = false;
|
|
@@ -107,7 +109,7 @@ var TransitionController = /** @class */ (function () {
|
|
|
107
109
|
transitionIn = true;
|
|
108
110
|
}
|
|
109
111
|
if (transitionIn && !this.isFirstTransition) {
|
|
110
|
-
panelState_1.inTimer = this.transitionElement(panelState_1.element, panelState_1.transition, this.direction > 0, false, function () {
|
|
112
|
+
panelState_1.inTimer = this.transitionElement(panelState_1.element, panelState_1.transition, this.direction > 0, false, animateHeight !== null && animateHeight !== void 0 ? animateHeight : true, function () {
|
|
111
113
|
panelState_1.inTimer = undefined;
|
|
112
114
|
});
|
|
113
115
|
}
|
|
@@ -165,7 +167,7 @@ var TransitionController = /** @class */ (function () {
|
|
|
165
167
|
panelState.inTimer = undefined;
|
|
166
168
|
}
|
|
167
169
|
if (!panelState.outTimer) {
|
|
168
|
-
panelState.outTimer = this_1.transitionElement(panelState.element, panelState.transition, this_1.direction > 0, true, function () {
|
|
170
|
+
panelState.outTimer = this_1.transitionElement(panelState.element, panelState.transition, this_1.direction > 0, true, true, function () {
|
|
169
171
|
_this.panelStates.remove(panelState);
|
|
170
172
|
});
|
|
171
173
|
}
|
|
@@ -176,28 +178,32 @@ var TransitionController = /** @class */ (function () {
|
|
|
176
178
|
_loop_1(panelState);
|
|
177
179
|
}
|
|
178
180
|
};
|
|
179
|
-
TransitionController.prototype.transitionElement = function (element, transition, toLeft, out, onComplete) {
|
|
181
|
+
TransitionController.prototype.transitionElement = function (element, transition, toLeft, out, animateHeight, onComplete) {
|
|
180
182
|
var _this = this;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
this.containerElement.classList.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
Components.AnimationHelper.triggerReflow(
|
|
195
|
-
|
|
183
|
+
var canAnimate = !TransitionController.disableTransitions;
|
|
184
|
+
transition !== null && transition !== void 0 ? transition : (transition = toLeft ? this.defaultTransition : this.defaultBackTransition);
|
|
185
|
+
if (canAnimate) {
|
|
186
|
+
element.style.overflow = "hidden";
|
|
187
|
+
var elementHeight_1 = element.getBoundingClientRect().height;
|
|
188
|
+
if (this.containerElement && !this.containerElement.classList.contains("transitioning")) {
|
|
189
|
+
this.containerElement.style.height = elementHeight_1 + "px";
|
|
190
|
+
this.containerElement.classList.add("transitioning");
|
|
191
|
+
}
|
|
192
|
+
element.style.opacity = out ? "1" : "0";
|
|
193
|
+
transition.setBeforeStyles(element, out, toLeft);
|
|
194
|
+
Components.AnimationHelper.triggerReflow(element);
|
|
195
|
+
element.classList.add("animate-".concat(out ? "out" : "in"));
|
|
196
|
+
Components.AnimationHelper.triggerReflow(element);
|
|
197
|
+
element.style.opacity = out ? "0" : "1";
|
|
198
|
+
transition.setAfterStyles(element, out, toLeft);
|
|
199
|
+
// Timeout needed to give time for child elements to render, in order to correctly calculate height.
|
|
200
|
+
setTimeout(function () {
|
|
201
|
+
if (!out && _this.containerElement) {
|
|
202
|
+
_this.containerElement.style.height = animateHeight ? (transition.changesHeight ? elementHeight_1 : element.getBoundingClientRect().height) + "px" : "";
|
|
203
|
+
}
|
|
204
|
+
}, 0);
|
|
196
205
|
}
|
|
197
|
-
|
|
198
|
-
transition.setAfterStyles(element, out, toLeft);
|
|
199
|
-
var duration = parseFloat(window.getComputedStyle(element).transitionDuration) * 1000;
|
|
200
|
-
return setTimeout(function () {
|
|
206
|
+
var cleanup = function () {
|
|
201
207
|
if (out) {
|
|
202
208
|
// Element will be removed from the dom, no need to cleanup props.
|
|
203
209
|
}
|
|
@@ -214,10 +220,20 @@ var TransitionController = /** @class */ (function () {
|
|
|
214
220
|
_this.containerElement.style.height = "";
|
|
215
221
|
}
|
|
216
222
|
}
|
|
217
|
-
}
|
|
223
|
+
};
|
|
224
|
+
if (canAnimate) {
|
|
225
|
+
var transitionDuration = parseFloat(window.getComputedStyle(element).transitionDuration) * 1000;
|
|
226
|
+
return setTimeout(cleanup, transitionDuration);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
cleanup();
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
218
232
|
};
|
|
219
233
|
/** Global default transition. */
|
|
220
234
|
TransitionController.transition = Transition.leftRight;
|
|
235
|
+
/** Allows transitions to be disabled for the whole app. */
|
|
236
|
+
TransitionController.disableTransitions = false;
|
|
221
237
|
__decorate([
|
|
222
238
|
observable.ref,
|
|
223
239
|
__metadata("design:type", String)
|
|
@@ -19,6 +19,10 @@ interface ITransitionPanelProps<T> {
|
|
|
19
19
|
isVisible?: boolean | T | null;
|
|
20
20
|
/** Override the transition for this panel only. */
|
|
21
21
|
transition?: Transition;
|
|
22
|
+
/** Indicates whether the container height is set during a transition. Transitions going from small height to a very large height may look better without height animation.
|
|
23
|
+
* `True` by default.
|
|
24
|
+
*/
|
|
25
|
+
animateHeight?: boolean;
|
|
22
26
|
}
|
|
23
27
|
export default class TransitionPanel<T = any> extends React.Component<ITransitionPanelProps<T>> {
|
|
24
28
|
static contextType: React.Context<import("./TransitionContainer").ITransitionContextState>;
|
|
@@ -26,7 +26,7 @@ var TransitionPanel = /** @class */ (function (_super) {
|
|
|
26
26
|
this.context.controller.transition(this.name);
|
|
27
27
|
}
|
|
28
28
|
if (this.panelRef.current) {
|
|
29
|
-
this.context.controller.afterUpdate(this.name, this.panelRef.current, this.props.transition);
|
|
29
|
+
this.context.controller.afterUpdate(this.name, this.panelRef.current, this.props.transition, this.props.animateHeight);
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
TransitionPanel.prototype.componentWillUnmount = function () {
|
|
@@ -40,7 +40,7 @@ var TransitionPanel = /** @class */ (function (_super) {
|
|
|
40
40
|
configurable: true
|
|
41
41
|
});
|
|
42
42
|
TransitionPanel.prototype.render = function () {
|
|
43
|
-
var _a = this.props, name = _a.name, data = _a.data, isVisible = _a.isVisible, children = _a.children;
|
|
43
|
+
var _a = this.props, name = _a.name, data = _a.data, isVisible = _a.isVisible, animateHeight = _a.animateHeight, children = _a.children;
|
|
44
44
|
if (data) {
|
|
45
45
|
this.currentData = data;
|
|
46
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularsystems/neo-react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "React application logic and components for the Neo client library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"typescript": "5.5.2"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@singularsystems/neo-core": "1.1.
|
|
32
|
+
"@singularsystems/neo-core": "1.1.1",
|
|
33
33
|
"@types/rc-slider": "^8.6.5",
|
|
34
34
|
"@types/react-color": "^3.0.1",
|
|
35
35
|
"axios": "1.7.7",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"tslib": "2.7.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@singularsystems/neo-core": ">=1.1.
|
|
47
|
+
"@singularsystems/neo-core": ">=1.1.1",
|
|
48
48
|
"axios": ">=1.6.2",
|
|
49
49
|
"inversify": ">=5.0.1",
|
|
50
50
|
"mobx": ">=6.9.0",
|
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 {
|