@singularsystems/neo-react 1.0.21 → 1.1.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 +15 -1
- package/README.md +1 -1
- package/dist/Modules/NeoReactModule.js +1 -1
- package/dist/Modules/ReactSetup.js +1 -5
- package/dist/Modules/Types.d.ts +3 -2
- package/dist/Modules/Types.js +1 -1
- package/dist/React/ReactModelCreator.js +1 -1
- package/dist/ReactComponents/Button.js +3 -1
- package/dist/ReactComponents/FileManager/FileInput.js +3 -1
- package/dist/ReactComponents/Form.js +3 -5
- package/dist/ReactComponents/Grid/Column.d.ts +2 -2
- package/dist/ReactComponents/Grid/Column.js +3 -2
- package/dist/ReactComponents/Grid/Grid.js +7 -9
- package/dist/ReactComponents/Grid/StickyTableHeader.js +4 -0
- package/dist/ReactComponents/GridLayout.d.ts +3 -0
- package/dist/ReactComponents/GridLayout.js +22 -9
- package/dist/ReactComponents/IColorPicker.d.ts +0 -1
- package/dist/ReactComponents/Icons/IIconFactory.d.ts +0 -1
- package/dist/ReactComponents/Icons/Icon.js +1 -1
- package/dist/ReactComponents/Link.d.ts +7 -0
- package/dist/ReactComponents/Link.js +39 -6
- package/dist/ReactComponents/Modal/Modal.js +2 -2
- package/dist/ReactComponents/StateObserver.d.ts +0 -1
- package/dist/ReactComponents/Tabs/Tab.js +5 -1
- package/dist/ReactComponents/Tabs/TabContainer.d.ts +6 -2
- package/dist/ReactComponents/Tabs/TabContainer.js +25 -17
- package/dist/ReactComponents/Tabs/TabManager.d.ts +0 -12
- package/dist/ReactComponents/Tabs/TabManager.js +3 -3
- package/dist/ReactComponents/Transitions/Transition.d.ts +10 -0
- package/dist/ReactComponents/Transitions/Transition.js +13 -0
- package/dist/ReactComponents/Transitions/TransitionContainer.d.ts +22 -0
- package/dist/ReactComponents/Transitions/TransitionContainer.js +34 -0
- package/dist/ReactComponents/Transitions/TransitionController.d.ts +33 -0
- package/dist/ReactComponents/Transitions/TransitionController.js +231 -0
- package/dist/ReactComponents/Transitions/TransitionPanel.d.ts +37 -0
- package/dist/ReactComponents/Transitions/TransitionPanel.js +64 -0
- package/dist/ReactComponents/Transitions/TransitionReplacer.d.ts +15 -0
- package/dist/ReactComponents/Transitions/TransitionReplacer.js +52 -0
- package/dist/ReactComponents/Transitions/TransitionSwitcher.d.ts +15 -0
- package/dist/ReactComponents/Transitions/TransitionSwitcher.js +55 -0
- package/dist/ReactComponents/Transitions/_Exports.d.ts +2 -0
- package/dist/ReactComponents/Transitions/_Exports.js +2 -0
- package/dist/ReactComponents/_Exports.d.ts +3 -1
- package/dist/ReactComponents/_Exports.js +3 -1
- package/dist/Routing/BreadCrumbItem.d.ts +0 -1
- package/dist/Routing/IRouteChangedProps.d.ts +5 -3
- package/dist/Routing/NavigationHelper.d.ts +9 -8
- package/dist/Routing/NavigationHelper.js +121 -25
- package/dist/Routing/PageLeaveHandler.d.ts +26 -9
- package/dist/Routing/PageLeaveHandler.js +16 -39
- package/dist/Routing/RouteProvider.d.ts +28 -7
- package/dist/Routing/RouteProvider.js +81 -42
- package/dist/Routing/RouteView.d.ts +5 -27
- package/dist/Routing/RouteView.js +18 -92
- package/dist/Routing/RoutingState.d.ts +10 -13
- package/dist/Routing/RoutingState.js +35 -18
- package/dist/Routing/ViewParameter.d.ts +0 -1
- package/dist/Routing/ViewParameterList.d.ts +0 -7
- package/dist/Routing/ViewParameterList.js +3 -5
- package/dist/Views/ViewBase.d.ts +4 -4
- package/dist/Views/ViewBase.js +6 -5
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/package.json +21 -28
- package/styles/Button.scss +13 -0
- package/styles/DatePicker.scss +3 -1
- package/styles/Forms.scss +3 -1
- package/styles/Grid.scss +4 -0
- package/styles/Misc.scss +25 -1
|
@@ -26,13 +26,13 @@ var TabManager = /** @class */ (function () {
|
|
|
26
26
|
this.onTabChanged = this.onTabChanged.bind(this);
|
|
27
27
|
this.reactionDisposer = reaction(function () { return _this.observable.value; }, function () { return _this.onTabChanged(); });
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
29
|
+
/** @internal */
|
|
30
30
|
TabManager.prototype.initialise = function () {
|
|
31
31
|
if (this.selectedTab !== "") {
|
|
32
32
|
this.onTabChanged();
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
/**
|
|
35
|
+
/** @internal */
|
|
36
36
|
TabManager.prototype.onUnmount = function () {
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(TabManager.prototype, "selectedTab", {
|
|
@@ -79,7 +79,7 @@ var TabManager = /** @class */ (function () {
|
|
|
79
79
|
tab.onDisplayed = callback;
|
|
80
80
|
return this;
|
|
81
81
|
};
|
|
82
|
-
/**
|
|
82
|
+
/** @internal */
|
|
83
83
|
TabManager.prototype.tabMounted = function (tabKey, onLeave) {
|
|
84
84
|
var tab = this.getTab(tabKey, true);
|
|
85
85
|
tab.onLeave = onLeave;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class Transition {
|
|
2
|
+
setBeforeStyles: (element: HTMLElement, out: boolean, toLeft: boolean) => void;
|
|
3
|
+
setAfterStyles: (element: HTMLElement, out: boolean, toLeft: boolean) => void;
|
|
4
|
+
cleanup: (element: HTMLElement) => void;
|
|
5
|
+
constructor(setBeforeStyles: (element: HTMLElement, out: boolean, toLeft: boolean) => void, setAfterStyles: (element: HTMLElement, out: boolean, toLeft: boolean) => void, cleanup: (element: HTMLElement) => void);
|
|
6
|
+
static leftRight: Transition;
|
|
7
|
+
static upDown: Transition;
|
|
8
|
+
static inOut: Transition;
|
|
9
|
+
static fadeOnly: Transition;
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var Transition = /** @class */ (function () {
|
|
2
|
+
function Transition(setBeforeStyles, setAfterStyles, cleanup) {
|
|
3
|
+
this.setBeforeStyles = setBeforeStyles;
|
|
4
|
+
this.setAfterStyles = setAfterStyles;
|
|
5
|
+
this.cleanup = cleanup;
|
|
6
|
+
}
|
|
7
|
+
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
|
+
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 = ""; });
|
|
10
|
+
Transition.fadeOnly = new Transition(function () { }, function () { }, function () { });
|
|
11
|
+
return Transition;
|
|
12
|
+
}());
|
|
13
|
+
export { Transition };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TransitionController } from "./TransitionController";
|
|
3
|
+
import { Transition } from "./Transition";
|
|
4
|
+
export interface ITransitionContextState {
|
|
5
|
+
controller: TransitionController;
|
|
6
|
+
}
|
|
7
|
+
export declare const TransitionContext: React.Context<ITransitionContextState>;
|
|
8
|
+
interface ITransitionContainerProps {
|
|
9
|
+
controller?: TransitionController;
|
|
10
|
+
transition?: Transition;
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export default class TransitionContainer extends React.Component<ITransitionContainerProps> {
|
|
14
|
+
private controller;
|
|
15
|
+
private containerRef;
|
|
16
|
+
private contextState;
|
|
17
|
+
constructor(props: ITransitionContainerProps);
|
|
18
|
+
componentDidMount(): void;
|
|
19
|
+
componentWillUnmount(): void;
|
|
20
|
+
render(): React.JSX.Element;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { __extends } from "tslib";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { TransitionController } from "./TransitionController";
|
|
4
|
+
export var TransitionContext = React.createContext({ controller: new TransitionController() });
|
|
5
|
+
var TransitionContainer = /** @class */ (function (_super) {
|
|
6
|
+
__extends(TransitionContainer, _super);
|
|
7
|
+
function TransitionContainer(props) {
|
|
8
|
+
var _this = _super.call(this, props) || this;
|
|
9
|
+
_this.containerRef = React.createRef();
|
|
10
|
+
if (!_this.props.controller) {
|
|
11
|
+
_this.controller = new TransitionController(undefined, _this.props.transition);
|
|
12
|
+
_this.controller.wasAutoCreated = true;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
_this.controller = _this.props.controller;
|
|
16
|
+
}
|
|
17
|
+
_this.contextState = { controller: _this.controller };
|
|
18
|
+
return _this;
|
|
19
|
+
}
|
|
20
|
+
TransitionContainer.prototype.componentDidMount = function () {
|
|
21
|
+
if (this.containerRef.current) {
|
|
22
|
+
this.controller.registerContainer(this.containerRef.current);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
TransitionContainer.prototype.componentWillUnmount = function () {
|
|
26
|
+
this.controller.disposeContainer();
|
|
27
|
+
};
|
|
28
|
+
TransitionContainer.prototype.render = function () {
|
|
29
|
+
return (React.createElement(TransitionContext.Provider, { value: this.contextState },
|
|
30
|
+
React.createElement("div", { className: "neo-transition-container", ref: this.containerRef }, this.props.children)));
|
|
31
|
+
};
|
|
32
|
+
return TransitionContainer;
|
|
33
|
+
}(React.Component));
|
|
34
|
+
export default TransitionContainer;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Transition } from "./Transition";
|
|
2
|
+
export declare class TransitionController {
|
|
3
|
+
/** Global default transition. */
|
|
4
|
+
static transition: Transition;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a transition controller.
|
|
7
|
+
* @param initialName Name of the panel to display initially. Not required if `isVisible` props are defined on the panels.
|
|
8
|
+
* @param transition Transition type to use by default on all panels.
|
|
9
|
+
*/
|
|
10
|
+
constructor(initialName?: string, transition?: Transition);
|
|
11
|
+
private _selectedName;
|
|
12
|
+
private defaultTransition;
|
|
13
|
+
private direction;
|
|
14
|
+
private isFirstTransition;
|
|
15
|
+
private isTransitioning;
|
|
16
|
+
private panels;
|
|
17
|
+
private panelStates;
|
|
18
|
+
private containerElement?;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the name of the selected panel.
|
|
21
|
+
*/
|
|
22
|
+
get selectedPanel(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Begins a transition to the specified panel.
|
|
25
|
+
* @param waitFor A promise on which to wait before showing the to panel. Use if data needs to be loaded.
|
|
26
|
+
*/
|
|
27
|
+
transition(toPanelName: string, waitFor?: Promise<any>): void;
|
|
28
|
+
forward(toPanelName?: string, waitFor?: Promise<any>): void;
|
|
29
|
+
back(toPanelName?: string, waitFor?: Promise<any>): void;
|
|
30
|
+
private doTransition;
|
|
31
|
+
private beginRemove;
|
|
32
|
+
private transitionElement;
|
|
33
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { __awaiter, __decorate, __generator, __metadata } from "tslib";
|
|
2
|
+
import { Components } from "@singularsystems/neo-core";
|
|
3
|
+
import { Transition } from "./Transition";
|
|
4
|
+
import { makeObservable, observable } from "mobx";
|
|
5
|
+
var TransitionController = /** @class */ (function () {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a transition controller.
|
|
8
|
+
* @param initialName Name of the panel to display initially. Not required if `isVisible` props are defined on the panels.
|
|
9
|
+
* @param transition Transition type to use by default on all panels.
|
|
10
|
+
*/
|
|
11
|
+
function TransitionController(initialName, transition) {
|
|
12
|
+
this._selectedName = "";
|
|
13
|
+
this.direction = 1;
|
|
14
|
+
this.isFirstTransition = true;
|
|
15
|
+
this.isTransitioning = false;
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
this.wasAutoCreated = false;
|
|
20
|
+
this.panels = [];
|
|
21
|
+
this.panelStates = [];
|
|
22
|
+
this._selectedName = initialName !== null && initialName !== void 0 ? initialName : "";
|
|
23
|
+
makeObservable(this);
|
|
24
|
+
this.defaultTransition = transition !== null && transition !== void 0 ? transition : TransitionController.transition;
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(TransitionController.prototype, "selectedPanel", {
|
|
27
|
+
/**
|
|
28
|
+
* Returns the name of the selected panel.
|
|
29
|
+
*/
|
|
30
|
+
get: function () {
|
|
31
|
+
return this._selectedName;
|
|
32
|
+
},
|
|
33
|
+
enumerable: false,
|
|
34
|
+
configurable: true
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Begins a transition to the specified panel.
|
|
38
|
+
* @param waitFor A promise on which to wait before showing the to panel. Use if data needs to be loaded.
|
|
39
|
+
*/
|
|
40
|
+
TransitionController.prototype.transition = function (toPanelName, waitFor) {
|
|
41
|
+
if (!this.isTransitioning) {
|
|
42
|
+
var currentIndex = this.panels.indexOf(this._selectedName);
|
|
43
|
+
var newIndex = this.panels.indexOf(toPanelName);
|
|
44
|
+
this.doTransition(toPanelName, newIndex - currentIndex, waitFor);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
TransitionController.prototype.forward = function (toPanelName, waitFor) {
|
|
48
|
+
this.doTransition(toPanelName !== null && toPanelName !== void 0 ? toPanelName : "", 1, waitFor);
|
|
49
|
+
};
|
|
50
|
+
TransitionController.prototype.back = function (toPanelName, waitFor) {
|
|
51
|
+
this.doTransition(toPanelName !== null && toPanelName !== void 0 ? toPanelName : "", -1, waitFor);
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* @internal
|
|
55
|
+
* Called by the container on mount.
|
|
56
|
+
*/
|
|
57
|
+
TransitionController.prototype.registerContainer = function (element) {
|
|
58
|
+
this.containerElement = element;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* @internal
|
|
62
|
+
* Called by the container on unmount.
|
|
63
|
+
*/
|
|
64
|
+
TransitionController.prototype.disposeContainer = function () {
|
|
65
|
+
this.containerElement = undefined;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* @internal
|
|
69
|
+
* Called by each panel on mount.
|
|
70
|
+
*/
|
|
71
|
+
TransitionController.prototype.registerPanel = function (name, hasVisibleProp) {
|
|
72
|
+
if (this.wasAutoCreated && !hasVisibleProp) {
|
|
73
|
+
throw "Panel with name ".concat(name, " must specify the isVisible prop, or you must pass a TransitionController to the TransitionContainer.");
|
|
74
|
+
}
|
|
75
|
+
if (this.panels.indexOf(name) < 0) {
|
|
76
|
+
this.panels.push(name);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* @internal
|
|
81
|
+
* Called by each panel on unmount.
|
|
82
|
+
*/
|
|
83
|
+
TransitionController.prototype.disposePanel = function (name) {
|
|
84
|
+
this.panels.remove(name);
|
|
85
|
+
var panelState = this.panelStates.find(function (c) { return c.name === name; });
|
|
86
|
+
if (panelState) {
|
|
87
|
+
clearTimeout(panelState.inTimer);
|
|
88
|
+
clearTimeout(panelState.outTimer);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* @internal
|
|
93
|
+
* Called by each panel after render.
|
|
94
|
+
*/
|
|
95
|
+
TransitionController.prototype.afterUpdate = function (name, element, transition) {
|
|
96
|
+
if (this._selectedName === name && !this.isTransitioning) {
|
|
97
|
+
var panelState_1 = this.panelStates.find(function (c) { return c.name === name; });
|
|
98
|
+
var transitionIn = false;
|
|
99
|
+
if (!panelState_1) {
|
|
100
|
+
panelState_1 = { name: name, element: element, transition: transition };
|
|
101
|
+
this.panelStates.push(panelState_1);
|
|
102
|
+
transitionIn = true;
|
|
103
|
+
}
|
|
104
|
+
if (panelState_1.outTimer) {
|
|
105
|
+
clearTimeout(panelState_1.outTimer);
|
|
106
|
+
panelState_1.outTimer = undefined;
|
|
107
|
+
transitionIn = true;
|
|
108
|
+
}
|
|
109
|
+
if (transitionIn && !this.isFirstTransition) {
|
|
110
|
+
panelState_1.inTimer = this.transitionElement(panelState_1.element, panelState_1.transition, this.direction > 0, false, function () {
|
|
111
|
+
panelState_1.inTimer = undefined;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
this.isFirstTransition = false;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* @internal
|
|
119
|
+
* If the panel is selected, or is busy transitioning.
|
|
120
|
+
*/
|
|
121
|
+
TransitionController.prototype.isPanelVisible = function (name) {
|
|
122
|
+
return this._selectedName === name ||
|
|
123
|
+
this.panelStates.find(function (c) { return c.name === name; }) !== undefined;
|
|
124
|
+
};
|
|
125
|
+
TransitionController.prototype.doTransition = function (toName, direction, waitFor) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
127
|
+
var e_1, oldKey;
|
|
128
|
+
return __generator(this, function (_a) {
|
|
129
|
+
switch (_a.label) {
|
|
130
|
+
case 0:
|
|
131
|
+
if (!(this._selectedName !== toName)) return [3 /*break*/, 5];
|
|
132
|
+
this.direction = direction;
|
|
133
|
+
this.isTransitioning = true;
|
|
134
|
+
this.beginRemove();
|
|
135
|
+
if (!waitFor) return [3 /*break*/, 4];
|
|
136
|
+
_a.label = 1;
|
|
137
|
+
case 1:
|
|
138
|
+
_a.trys.push([1, 3, , 4]);
|
|
139
|
+
return [4 /*yield*/, waitFor];
|
|
140
|
+
case 2:
|
|
141
|
+
_a.sent();
|
|
142
|
+
return [3 /*break*/, 4];
|
|
143
|
+
case 3:
|
|
144
|
+
e_1 = _a.sent();
|
|
145
|
+
this.isTransitioning = false;
|
|
146
|
+
oldKey = this._selectedName;
|
|
147
|
+
this._selectedName = "";
|
|
148
|
+
this._selectedName = oldKey;
|
|
149
|
+
return [3 /*break*/, 4];
|
|
150
|
+
case 4:
|
|
151
|
+
// This will cause the panel to render, and call registerPanel().
|
|
152
|
+
this._selectedName = toName;
|
|
153
|
+
this.isTransitioning = false;
|
|
154
|
+
_a.label = 5;
|
|
155
|
+
case 5: return [2 /*return*/];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
TransitionController.prototype.beginRemove = function () {
|
|
161
|
+
var _this = this;
|
|
162
|
+
var _loop_1 = function (panelState) {
|
|
163
|
+
if (panelState.inTimer) {
|
|
164
|
+
clearTimeout(panelState.inTimer);
|
|
165
|
+
panelState.inTimer = undefined;
|
|
166
|
+
}
|
|
167
|
+
if (!panelState.outTimer) {
|
|
168
|
+
panelState.outTimer = this_1.transitionElement(panelState.element, panelState.transition, this_1.direction > 0, true, function () {
|
|
169
|
+
_this.panelStates.remove(panelState);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var this_1 = this;
|
|
174
|
+
for (var _i = 0, _a = this.panelStates; _i < _a.length; _i++) {
|
|
175
|
+
var panelState = _a[_i];
|
|
176
|
+
_loop_1(panelState);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
TransitionController.prototype.transitionElement = function (element, transition, toLeft, out, onComplete) {
|
|
180
|
+
var _this = this;
|
|
181
|
+
transition !== null && transition !== void 0 ? transition : (transition = this.defaultTransition);
|
|
182
|
+
element.style.overflow = "hidden";
|
|
183
|
+
var elementHeight = element.getBoundingClientRect().height;
|
|
184
|
+
if (this.containerElement && !this.containerElement.classList.contains("transitioning")) {
|
|
185
|
+
this.containerElement.style.height = elementHeight + "px";
|
|
186
|
+
this.containerElement.classList.add("transitioning");
|
|
187
|
+
}
|
|
188
|
+
element.style.opacity = out ? "1" : "0";
|
|
189
|
+
transition.setBeforeStyles(element, out, toLeft);
|
|
190
|
+
Components.AnimationHelper.triggerReflow(element);
|
|
191
|
+
element.classList.add("animate-".concat(out ? "out" : "in"));
|
|
192
|
+
Components.AnimationHelper.triggerReflow(element);
|
|
193
|
+
if (!out && this.containerElement) {
|
|
194
|
+
Components.AnimationHelper.triggerReflow(this.containerElement);
|
|
195
|
+
this.containerElement.style.height = elementHeight + "px";
|
|
196
|
+
}
|
|
197
|
+
element.style.opacity = out ? "0" : "1";
|
|
198
|
+
transition.setAfterStyles(element, out, toLeft);
|
|
199
|
+
var duration = parseFloat(window.getComputedStyle(element).transitionDuration) * 1000;
|
|
200
|
+
return setTimeout(function () {
|
|
201
|
+
if (out) {
|
|
202
|
+
// Element will be removed from the dom, no need to cleanup props.
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
element.classList.remove("animate-in");
|
|
206
|
+
element.style.opacity = "";
|
|
207
|
+
element.style.overflow = "";
|
|
208
|
+
transition.cleanup(element);
|
|
209
|
+
}
|
|
210
|
+
onComplete();
|
|
211
|
+
if (_this.containerElement && !_this.panelStates.some(function (c) { return c.inTimer; })) {
|
|
212
|
+
_this.containerElement.classList.remove("transitioning");
|
|
213
|
+
if (_this.panelStates.length > 0) {
|
|
214
|
+
_this.containerElement.style.height = "";
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}, duration);
|
|
218
|
+
};
|
|
219
|
+
/** Global default transition. */
|
|
220
|
+
TransitionController.transition = Transition.leftRight;
|
|
221
|
+
__decorate([
|
|
222
|
+
observable.ref,
|
|
223
|
+
__metadata("design:type", String)
|
|
224
|
+
], TransitionController.prototype, "_selectedName", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
observable.shallow,
|
|
227
|
+
__metadata("design:type", Array)
|
|
228
|
+
], TransitionController.prototype, "panelStates", void 0);
|
|
229
|
+
return TransitionController;
|
|
230
|
+
}());
|
|
231
|
+
export { TransitionController };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Transition } from "./Transition";
|
|
3
|
+
import { TransitionContext } from "./TransitionContainer";
|
|
4
|
+
interface ITransitionPanelProps<T> {
|
|
5
|
+
/**
|
|
6
|
+
* The panel name unique within a transition container.
|
|
7
|
+
*/
|
|
8
|
+
name?: string;
|
|
9
|
+
children: React.ReactNode | ((value: T) => React.ReactNode);
|
|
10
|
+
/**
|
|
11
|
+
* Data which will be passed into a child callback method.
|
|
12
|
+
* Use this to temporarily keep a reference to the data used in the panel while it is transitioned out.
|
|
13
|
+
*/
|
|
14
|
+
data?: T | null;
|
|
15
|
+
/**
|
|
16
|
+
* Controls whether the panel is visible.
|
|
17
|
+
* If the value is an object, then it is also used as the `data` prop and will be passed into a child callback method.
|
|
18
|
+
* Not recommended when more than 2 panels are used. In that case, manually control the selected panel using a TransitionController. */
|
|
19
|
+
isVisible?: boolean | T | null;
|
|
20
|
+
/** Override the transition for this panel only. */
|
|
21
|
+
transition?: Transition;
|
|
22
|
+
}
|
|
23
|
+
export default class TransitionPanel<T = any> extends React.Component<ITransitionPanelProps<T>> {
|
|
24
|
+
static contextType: React.Context<import("./TransitionContainer").ITransitionContextState>;
|
|
25
|
+
context: React.ContextType<typeof TransitionContext>;
|
|
26
|
+
constructor(props: ITransitionPanelProps<T>);
|
|
27
|
+
private name;
|
|
28
|
+
private currentData?;
|
|
29
|
+
private panelRef;
|
|
30
|
+
componentDidMount(): void;
|
|
31
|
+
componentDidUpdate(): void;
|
|
32
|
+
private afterRender;
|
|
33
|
+
componentWillUnmount(): void;
|
|
34
|
+
get isVisible(): boolean;
|
|
35
|
+
render(): React.JSX.Element | undefined;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { __decorate, __extends, __metadata } from "tslib";
|
|
2
|
+
import { computed, makeObservable } from "mobx";
|
|
3
|
+
import { observer } from "mobx-react";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { TransitionContext } from "./TransitionContainer";
|
|
6
|
+
import { Utils } from "@singularsystems/neo-core";
|
|
7
|
+
var TransitionPanel = /** @class */ (function (_super) {
|
|
8
|
+
__extends(TransitionPanel, _super);
|
|
9
|
+
function TransitionPanel(props) {
|
|
10
|
+
var _a;
|
|
11
|
+
var _this = _super.call(this, props) || this;
|
|
12
|
+
_this.panelRef = React.createRef();
|
|
13
|
+
makeObservable(_this);
|
|
14
|
+
_this.name = (_a = _this.props.name) !== null && _a !== void 0 ? _a : Utils.uuidv4();
|
|
15
|
+
return _this;
|
|
16
|
+
}
|
|
17
|
+
TransitionPanel.prototype.componentDidMount = function () {
|
|
18
|
+
this.context.controller.registerPanel(this.name, this.props.isVisible !== undefined);
|
|
19
|
+
this.afterRender();
|
|
20
|
+
};
|
|
21
|
+
TransitionPanel.prototype.componentDidUpdate = function () {
|
|
22
|
+
this.afterRender();
|
|
23
|
+
};
|
|
24
|
+
TransitionPanel.prototype.afterRender = function () {
|
|
25
|
+
if (this.props.isVisible) {
|
|
26
|
+
this.context.controller.transition(this.name);
|
|
27
|
+
}
|
|
28
|
+
if (this.panelRef.current) {
|
|
29
|
+
this.context.controller.afterUpdate(this.name, this.panelRef.current, this.props.transition);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
TransitionPanel.prototype.componentWillUnmount = function () {
|
|
33
|
+
this.context.controller.disposePanel(this.name);
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(TransitionPanel.prototype, "isVisible", {
|
|
36
|
+
get: function () {
|
|
37
|
+
return this.context.controller.isPanelVisible(this.name);
|
|
38
|
+
},
|
|
39
|
+
enumerable: false,
|
|
40
|
+
configurable: true
|
|
41
|
+
});
|
|
42
|
+
TransitionPanel.prototype.render = function () {
|
|
43
|
+
var _a = this.props, name = _a.name, data = _a.data, isVisible = _a.isVisible, children = _a.children;
|
|
44
|
+
if (data) {
|
|
45
|
+
this.currentData = data;
|
|
46
|
+
}
|
|
47
|
+
else if (isVisible && typeof isVisible === "object") {
|
|
48
|
+
this.currentData = isVisible;
|
|
49
|
+
}
|
|
50
|
+
return this.context.controller.isPanelVisible(this.name) ? (React.createElement("div", { ref: this.panelRef, className: "neo-transition-panel" }, typeof children === "function" ? (this.currentData ? children(this.currentData) : undefined) : children)) : undefined;
|
|
51
|
+
};
|
|
52
|
+
TransitionPanel.contextType = TransitionContext;
|
|
53
|
+
__decorate([
|
|
54
|
+
computed,
|
|
55
|
+
__metadata("design:type", Object),
|
|
56
|
+
__metadata("design:paramtypes", [])
|
|
57
|
+
], TransitionPanel.prototype, "isVisible", null);
|
|
58
|
+
TransitionPanel = __decorate([
|
|
59
|
+
observer,
|
|
60
|
+
__metadata("design:paramtypes", [Object])
|
|
61
|
+
], TransitionPanel);
|
|
62
|
+
return TransitionPanel;
|
|
63
|
+
}(React.Component));
|
|
64
|
+
export default TransitionPanel;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Transition } from "./Transition";
|
|
3
|
+
interface ITransitionReplacerProps {
|
|
4
|
+
children: JSX.Element | null;
|
|
5
|
+
forward?: boolean;
|
|
6
|
+
transition?: Transition;
|
|
7
|
+
}
|
|
8
|
+
export declare class TransitionReplacer extends React.Component<ITransitionReplacerProps> {
|
|
9
|
+
private componentA;
|
|
10
|
+
private componentB;
|
|
11
|
+
private transitionController;
|
|
12
|
+
render(): React.JSX.Element;
|
|
13
|
+
private transitionTo;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { __extends } from "tslib";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { TransitionController } from "./TransitionController";
|
|
4
|
+
import TransitionContainer from "./TransitionContainer";
|
|
5
|
+
import TransitionPanel from "./TransitionPanel";
|
|
6
|
+
var TransitionReplacer = /** @class */ (function (_super) {
|
|
7
|
+
__extends(TransitionReplacer, _super);
|
|
8
|
+
function TransitionReplacer() {
|
|
9
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
10
|
+
_this.componentA = null;
|
|
11
|
+
_this.componentB = null;
|
|
12
|
+
_this.transitionController = new TransitionController("A", _this.props.transition);
|
|
13
|
+
return _this;
|
|
14
|
+
}
|
|
15
|
+
TransitionReplacer.prototype.render = function () {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
var component = this.props.children;
|
|
18
|
+
if (component && component.type === ((_a = this.componentA) === null || _a === void 0 ? void 0 : _a.type)) {
|
|
19
|
+
if (this.transitionController.selectedPanel === "B") {
|
|
20
|
+
this.transitionTo("A");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else if (component && component.type === ((_b = this.componentB) === null || _b === void 0 ? void 0 : _b.type)) {
|
|
24
|
+
if (this.transitionController.selectedPanel === "A") {
|
|
25
|
+
this.transitionTo("B");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
if (this.transitionController.selectedPanel === "A") {
|
|
30
|
+
this.componentB = component;
|
|
31
|
+
this.transitionTo("B");
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.componentA = component;
|
|
35
|
+
this.transitionTo("A");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return React.createElement(TransitionContainer, { controller: this.transitionController },
|
|
39
|
+
React.createElement(TransitionPanel, { name: "A" }, this.componentA),
|
|
40
|
+
React.createElement(TransitionPanel, { name: "B" }, this.componentB));
|
|
41
|
+
};
|
|
42
|
+
TransitionReplacer.prototype.transitionTo = function (panel) {
|
|
43
|
+
if (this.props.forward !== false) {
|
|
44
|
+
this.transitionController.forward(panel);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.transitionController.back(panel);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return TransitionReplacer;
|
|
51
|
+
}(React.Component));
|
|
52
|
+
export { TransitionReplacer };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Transition } from "./Transition";
|
|
3
|
+
interface ITransitionSwitcherProps {
|
|
4
|
+
children: JSX.Element | null;
|
|
5
|
+
forward?: boolean;
|
|
6
|
+
transition?: Transition;
|
|
7
|
+
}
|
|
8
|
+
export default class TransitionSwitcher extends React.Component<ITransitionSwitcherProps> {
|
|
9
|
+
private componentA;
|
|
10
|
+
private componentB;
|
|
11
|
+
private transitionController;
|
|
12
|
+
render(): React.JSX.Element;
|
|
13
|
+
private transitionTo;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { __extends } from "tslib";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { TransitionController } from "./TransitionController";
|
|
4
|
+
import TransitionContainer from "./TransitionContainer";
|
|
5
|
+
import TransitionPanel from "./TransitionPanel";
|
|
6
|
+
var TransitionSwitcher = /** @class */ (function (_super) {
|
|
7
|
+
__extends(TransitionSwitcher, _super);
|
|
8
|
+
function TransitionSwitcher() {
|
|
9
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
10
|
+
_this.componentA = null;
|
|
11
|
+
_this.componentB = null;
|
|
12
|
+
_this.transitionController = new TransitionController("A", _this.props.transition);
|
|
13
|
+
return _this;
|
|
14
|
+
}
|
|
15
|
+
TransitionSwitcher.prototype.render = function () {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
var component = this.props.children;
|
|
18
|
+
if (typeof (component === null || component === void 0 ? void 0 : component.type) === "string") {
|
|
19
|
+
throw "TransitionSwitcher can only have components as children.";
|
|
20
|
+
}
|
|
21
|
+
if (component && component.type === ((_a = this.componentA) === null || _a === void 0 ? void 0 : _a.type)) {
|
|
22
|
+
if (this.transitionController.selectedPanel === "B") {
|
|
23
|
+
this.transitionTo("A");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else if (component && component.type === ((_b = this.componentB) === null || _b === void 0 ? void 0 : _b.type)) {
|
|
27
|
+
if (this.transitionController.selectedPanel === "A") {
|
|
28
|
+
this.transitionTo("B");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
if (this.transitionController.selectedPanel === "A") {
|
|
33
|
+
this.componentB = component;
|
|
34
|
+
this.transitionTo("B");
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.componentA = component;
|
|
38
|
+
this.transitionTo("A");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return React.createElement(TransitionContainer, { controller: this.transitionController },
|
|
42
|
+
React.createElement(TransitionPanel, { name: "A" }, this.componentA),
|
|
43
|
+
React.createElement(TransitionPanel, { name: "B" }, this.componentB));
|
|
44
|
+
};
|
|
45
|
+
TransitionSwitcher.prototype.transitionTo = function (panel) {
|
|
46
|
+
if (this.props.forward !== false) {
|
|
47
|
+
this.transitionController.forward(panel);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.transitionController.back(panel);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return TransitionSwitcher;
|
|
54
|
+
}(React.Component));
|
|
55
|
+
export default TransitionSwitcher;
|
|
@@ -33,6 +33,8 @@ import PageSizeControl from './Paging/PageSizeControl';
|
|
|
33
33
|
import ProgressBar from './ProgressBar';
|
|
34
34
|
import RadioList from './RadioList';
|
|
35
35
|
import Slider from './Slider';
|
|
36
|
+
import TransitionContainer from "./Transitions/TransitionContainer";
|
|
37
|
+
import TransitionPanel from "./Transitions/TransitionPanel";
|
|
36
38
|
import TabContainer from './Tabs/TabContainer';
|
|
37
39
|
import Tab from './Tabs/Tab';
|
|
38
40
|
import Toast from './Notifications/Toast';
|
|
@@ -40,4 +42,4 @@ import ToastContainer from './Notifications/ToastContainer';
|
|
|
40
42
|
import Tooltip from './Tooltip';
|
|
41
43
|
import TooltipProvider from './TooltipProvider';
|
|
42
44
|
import ValidationSummary from './ValidationSummary';
|
|
43
|
-
export { Alert, AutoCompleteDropDown, Badge, Button, Card, Checkbox, Collapsable, ColorPicker, ContextMenuContainer, DatePicker, DropDown, FileBasicInput, FileContext, FileDropArea, FileInput, FileUploadButton, FileUploadProgress, Form, FormContext, FormGroup, FormGroupFloating, FormGroupInline, GridLayout, Icon, Input, Link, Loader, Modal, ModalContainer, NumberInput, Pager, PagerControlsBasic, PageSizeControl, Passwordbox, ProgressBar, RadioList, Slider, TabContainer, Tab, Textbox, Toast, ToastContainer, Tooltip, TooltipProvider, ValidationSummary };
|
|
45
|
+
export { Alert, AutoCompleteDropDown, Badge, Button, Card, Checkbox, Collapsable, ColorPicker, ContextMenuContainer, DatePicker, DropDown, FileBasicInput, FileContext, FileDropArea, FileInput, FileUploadButton, FileUploadProgress, Form, FormContext, FormGroup, FormGroupFloating, FormGroupInline, GridLayout, Icon, Input, Link, Loader, Modal, ModalContainer, NumberInput, Pager, PagerControlsBasic, PageSizeControl, Passwordbox, ProgressBar, RadioList, Slider, TabContainer, Tab, Textbox, TransitionContainer, TransitionPanel, Toast, ToastContainer, Tooltip, TooltipProvider, ValidationSummary };
|
|
@@ -33,6 +33,8 @@ import PageSizeControl from './Paging/PageSizeControl';
|
|
|
33
33
|
import ProgressBar from './ProgressBar';
|
|
34
34
|
import RadioList from './RadioList';
|
|
35
35
|
import Slider from './Slider';
|
|
36
|
+
import TransitionContainer from "./Transitions/TransitionContainer";
|
|
37
|
+
import TransitionPanel from "./Transitions/TransitionPanel";
|
|
36
38
|
import TabContainer from './Tabs/TabContainer';
|
|
37
39
|
import Tab from './Tabs/Tab';
|
|
38
40
|
import Toast from './Notifications/Toast';
|
|
@@ -40,4 +42,4 @@ import ToastContainer from './Notifications/ToastContainer';
|
|
|
40
42
|
import Tooltip from './Tooltip';
|
|
41
43
|
import TooltipProvider from './TooltipProvider';
|
|
42
44
|
import ValidationSummary from './ValidationSummary';
|
|
43
|
-
export { Alert, AutoCompleteDropDown, Badge, Button, Card, Checkbox, Collapsable, ColorPicker, ContextMenuContainer, DatePicker, DropDown, FileBasicInput, FileContext, FileDropArea, FileInput, FileUploadButton, FileUploadProgress, Form, FormContext, FormGroup, FormGroupFloating, FormGroupInline, GridLayout, Icon, Input, Link, Loader, Modal, ModalContainer, NumberInput, Pager, PagerControlsBasic, PageSizeControl, Passwordbox, ProgressBar, RadioList, Slider, TabContainer, Tab, Textbox, Toast, ToastContainer, Tooltip, TooltipProvider, ValidationSummary };
|
|
45
|
+
export { Alert, AutoCompleteDropDown, Badge, Button, Card, Checkbox, Collapsable, ColorPicker, ContextMenuContainer, DatePicker, DropDown, FileBasicInput, FileContext, FileDropArea, FileInput, FileUploadButton, FileUploadProgress, Form, FormContext, FormGroup, FormGroupFloating, FormGroupInline, GridLayout, Icon, Input, Link, Loader, Modal, ModalContainer, NumberInput, Pager, PagerControlsBasic, PageSizeControl, Passwordbox, ProgressBar, RadioList, Slider, TabContainer, Tab, Textbox, TransitionContainer, TransitionPanel, Toast, ToastContainer, Tooltip, TooltipProvider, ValidationSummary };
|