@singularsystems/neo-react 1.1.2 → 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/FileManager/FileInput.d.ts +1 -0
- 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
|
@@ -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
|
/**
|
|
@@ -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",
|