@singularsystems/neo-react 0.10.37 → 0.10.40
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/React/AutoRunner.js +17 -2
- package/dist/ReactComponents/FileManager/FileUploadButton.js +4 -1
- package/dist/ReactComponents/Misc.d.ts +15 -0
- package/dist/ReactComponents/Misc.js +28 -0
- package/dist/ReactComponents/Modal/Modal.js +3 -0
- package/dist/ReactComponents/Tabs/Tab.d.ts +3 -0
- package/dist/ReactComponents/Tabs/Tab.js +1 -1
- package/dist/ReactComponents/Tabs/TabManager.d.ts +2 -2
- package/dist/ReactComponents/Tabs/TabManager.js +19 -11
- package/dist/ReactComponents/Tooltip.d.ts +4 -0
- package/dist/ReactComponents/Tooltip.js +1 -1
- package/dist/index.d.ts +1 -0
- package/package.json +2 -2
- package/styles/Modal.scss +3 -7
package/dist/React/AutoRunner.js
CHANGED
|
@@ -17,10 +17,11 @@ export { AutoRunnerFactory };
|
|
|
17
17
|
var AutoRunner = /** @class */ (function () {
|
|
18
18
|
function AutoRunner(model, callback, options) {
|
|
19
19
|
var _this = this;
|
|
20
|
+
this.isPaused = false;
|
|
20
21
|
this.propertyMap = {};
|
|
21
22
|
this.options = (options !== null && options !== void 0 ? options : {});
|
|
22
|
-
this.disposerDelayed = reaction(function () { return _this.accessAllValues(model, true, new Map(), ""); }, function () { var _a; return
|
|
23
|
-
this.disposerImmediate = reaction(function () { return _this.accessAllValues(model, false, new Map(), ""); }, function () { return
|
|
23
|
+
this.disposerDelayed = reaction(function () { return _this.accessAllValues(model, true, new Map(), ""); }, function () { var _a; return _this.runCallback(model, callback, (_a = _this.options.delayMs, (_a !== null && _a !== void 0 ? _a : 500))); });
|
|
24
|
+
this.disposerImmediate = reaction(function () { return _this.accessAllValues(model, false, new Map(), ""); }, function () { return _this.runCallback(model, callback, 0); });
|
|
24
25
|
}
|
|
25
26
|
AutoRunner.prototype.cancelPending = function () {
|
|
26
27
|
Utils.clearDebounce(this);
|
|
@@ -29,6 +30,20 @@ var AutoRunner = /** @class */ (function () {
|
|
|
29
30
|
this.disposerDelayed();
|
|
30
31
|
this.disposerImmediate();
|
|
31
32
|
};
|
|
33
|
+
AutoRunner.prototype.runCallback = function (model, callback, delay) {
|
|
34
|
+
var _this = this;
|
|
35
|
+
if (!this.isPaused) {
|
|
36
|
+
Utils.debounce(this, function () {
|
|
37
|
+
_this.isPaused = true;
|
|
38
|
+
try {
|
|
39
|
+
callback(model);
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
_this.isPaused = false;
|
|
43
|
+
}
|
|
44
|
+
}, delay);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
32
47
|
/**
|
|
33
48
|
* Access all the property values of a model including it's value objects properties.
|
|
34
49
|
* @param instance Instance to access.
|
|
@@ -32,8 +32,11 @@ var FileUploadButton = /** @class */ (function (_super) {
|
|
|
32
32
|
buttonProps = {};
|
|
33
33
|
if (!buttonProps.variant)
|
|
34
34
|
buttonProps.variant = "light";
|
|
35
|
+
if (this.fileManager.isUploading && !this.fileManager.options.allowConcurrent) {
|
|
36
|
+
buttonProps.disabled = true;
|
|
37
|
+
}
|
|
35
38
|
return (React.createElement(React.Fragment, null,
|
|
36
|
-
React.createElement(Button, __assign({}, buttonProps, {
|
|
39
|
+
React.createElement(Button, __assign({}, buttonProps, { onClick: this.browseButtonClicked }), this.props.children),
|
|
37
40
|
React.createElement(FileBasicInput, { fileManager: this.fileManager, isHidden: true, inputRef: this.fileInputRef })));
|
|
38
41
|
};
|
|
39
42
|
FileUploadButton.contextType = FileContext;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ICancellableEvent {
|
|
2
|
+
/** Informs the caller to cancel any further actions or processing. */
|
|
3
|
+
cancel(): void;
|
|
4
|
+
/** Continues with the original action. */
|
|
5
|
+
continue(): void;
|
|
6
|
+
}
|
|
7
|
+
export declare class CancellableEvent implements ICancellableEvent {
|
|
8
|
+
private canContinue;
|
|
9
|
+
private hasCancelled;
|
|
10
|
+
private cancelledAction?;
|
|
11
|
+
constructor(canContinue: () => boolean);
|
|
12
|
+
cancel(): void;
|
|
13
|
+
tryRunAction(action: () => void): void;
|
|
14
|
+
continue(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var CancellableEvent = /** @class */ (function () {
|
|
2
|
+
function CancellableEvent(canContinue) {
|
|
3
|
+
this.canContinue = canContinue;
|
|
4
|
+
this.hasCancelled = false;
|
|
5
|
+
}
|
|
6
|
+
CancellableEvent.prototype.cancel = function () {
|
|
7
|
+
this.hasCancelled = true;
|
|
8
|
+
};
|
|
9
|
+
CancellableEvent.prototype.tryRunAction = function (action) {
|
|
10
|
+
if (this.hasCancelled) {
|
|
11
|
+
this.cancelledAction = action;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
action();
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
CancellableEvent.prototype.continue = function () {
|
|
18
|
+
if (this.cancelledAction === undefined) {
|
|
19
|
+
throw Error("continue() cannot be called multiple times, or if the event was not cancelled.");
|
|
20
|
+
}
|
|
21
|
+
if (this.canContinue()) {
|
|
22
|
+
this.cancelledAction();
|
|
23
|
+
}
|
|
24
|
+
this.cancelledAction = undefined;
|
|
25
|
+
};
|
|
26
|
+
return CancellableEvent;
|
|
27
|
+
}());
|
|
28
|
+
export { CancellableEvent };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TabContext } from "./TabContainer";
|
|
3
|
+
import { ICancellableEvent } from "../Misc";
|
|
3
4
|
interface ITabProps {
|
|
4
5
|
/** Name to show in the tab header. */
|
|
5
6
|
header: string | JSX.Element;
|
|
@@ -19,6 +20,8 @@ interface ITabProps {
|
|
|
19
20
|
* Callback to run whenever this tab is displayed.
|
|
20
21
|
*/
|
|
21
22
|
onDisplayed?: () => void;
|
|
23
|
+
/** Callback to run when selecting a different tab. The event can be cancelled. */
|
|
24
|
+
onLeave?: (e: ICancellableEvent) => void;
|
|
22
25
|
}
|
|
23
26
|
export default class Tab extends React.Component<ITabProps> {
|
|
24
27
|
static contextType: React.Context<import("./TabContainer").TabContextParams>;
|
|
@@ -29,7 +29,7 @@ var Tab = /** @class */ (function (_super) {
|
|
|
29
29
|
if (this.props.onDisplayed) {
|
|
30
30
|
this.context.tabManager.onTabDisplayed(this.tabKey, this.props.onDisplayed);
|
|
31
31
|
}
|
|
32
|
-
this.context.tabManager.tabMounted(this.tabKey);
|
|
32
|
+
this.context.tabManager.tabMounted(this.tabKey, this.props.onLeave);
|
|
33
33
|
};
|
|
34
34
|
Tab.prototype.render = function () {
|
|
35
35
|
if (this.isHeader === undefined)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Model } from '@singularsystems/neo-core';
|
|
2
|
+
import { ICancellableEvent } from '../Misc';
|
|
2
3
|
export interface ITabManager {
|
|
3
4
|
selectedTab: string;
|
|
4
5
|
/**
|
|
@@ -12,7 +13,7 @@ export interface ITabManager {
|
|
|
12
13
|
}
|
|
13
14
|
export interface ITabManagerInternal extends ITabManager {
|
|
14
15
|
initialise(): void;
|
|
15
|
-
tabMounted(tabKey: string): void;
|
|
16
|
+
tabMounted(tabKey: string, onLeave?: (e: ICancellableEvent) => void): void;
|
|
16
17
|
destroy(): void;
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
@@ -21,7 +22,6 @@ export interface ITabManagerInternal extends ITabManager {
|
|
|
21
22
|
*/
|
|
22
23
|
export declare class TabManager<T extends string = string> {
|
|
23
24
|
private autoSelectFirstTab;
|
|
24
|
-
private reactionDisposer;
|
|
25
25
|
observable: Model.ObservableValue<T>;
|
|
26
26
|
/**
|
|
27
27
|
* Creates a tab manager used to bind to a tab container.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Model } from '@singularsystems/neo-core';
|
|
2
|
-
import {
|
|
2
|
+
import { CancellableEvent } from '../Misc';
|
|
3
3
|
/**
|
|
4
4
|
* Tab manager used to manage a tab component.
|
|
5
5
|
* @param T string union type of tab names.
|
|
@@ -14,31 +14,27 @@ var TabManager = /** @class */ (function () {
|
|
|
14
14
|
if (selectedTab === void 0) { selectedTab = ""; }
|
|
15
15
|
if (autoSelectFirstTab === void 0) { autoSelectFirstTab = false; }
|
|
16
16
|
this.autoSelectFirstTab = autoSelectFirstTab;
|
|
17
|
-
this.reactionDisposer = null;
|
|
18
17
|
this.observable = new Model.ObservableValue("");
|
|
19
18
|
this.tabs = {};
|
|
20
|
-
this.
|
|
19
|
+
this.observable.value = selectedTab;
|
|
21
20
|
this.onTabChanged = this.onTabChanged.bind(this);
|
|
22
21
|
}
|
|
23
22
|
/** Called by tab container. */
|
|
24
23
|
TabManager.prototype.initialise = function () {
|
|
25
|
-
var _this = this;
|
|
26
|
-
this.reactionDisposer = reaction(function () { return _this.selectedTab; }, this.onTabChanged);
|
|
27
24
|
if (this.selectedTab !== "") {
|
|
28
25
|
this.onTabChanged();
|
|
29
26
|
}
|
|
30
27
|
};
|
|
31
28
|
/** Called by tab container. */
|
|
32
29
|
TabManager.prototype.destroy = function () {
|
|
33
|
-
if (this.reactionDisposer) {
|
|
34
|
-
this.reactionDisposer();
|
|
35
|
-
}
|
|
36
30
|
};
|
|
37
31
|
Object.defineProperty(TabManager.prototype, "selectedTab", {
|
|
38
32
|
get: function () {
|
|
39
33
|
return this.observable.value;
|
|
40
34
|
},
|
|
41
35
|
set: function (value) {
|
|
36
|
+
var _this = this;
|
|
37
|
+
var _a;
|
|
42
38
|
if (!this.tabs[value]) {
|
|
43
39
|
// Probably different case, find the actual tab key.
|
|
44
40
|
var foundValue = Object.keys(this.tabs).find(function (t) { return t.toLowerCase() === value.toLowerCase(); });
|
|
@@ -46,7 +42,18 @@ var TabManager = /** @class */ (function () {
|
|
|
46
42
|
value = foundValue;
|
|
47
43
|
}
|
|
48
44
|
}
|
|
49
|
-
this.observable.
|
|
45
|
+
var currentTabKey = this.observable.peek;
|
|
46
|
+
if (value !== currentTabKey) {
|
|
47
|
+
var cancellableEvent = new CancellableEvent(function () { return currentTabKey === _this.observable.peek; });
|
|
48
|
+
var currentTab = this.tabs[currentTabKey];
|
|
49
|
+
if (((_a = currentTab) === null || _a === void 0 ? void 0 : _a.onLeave) !== undefined) {
|
|
50
|
+
currentTab.onLeave(cancellableEvent);
|
|
51
|
+
}
|
|
52
|
+
cancellableEvent.tryRunAction(function () {
|
|
53
|
+
_this.observable.value = value;
|
|
54
|
+
_this.onTabChanged();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
50
57
|
},
|
|
51
58
|
enumerable: true,
|
|
52
59
|
configurable: true
|
|
@@ -67,8 +74,9 @@ var TabManager = /** @class */ (function () {
|
|
|
67
74
|
tab.onDisplayed = callback;
|
|
68
75
|
return this;
|
|
69
76
|
};
|
|
70
|
-
TabManager.prototype.tabMounted = function (tabKey) {
|
|
71
|
-
|
|
77
|
+
TabManager.prototype.tabMounted = function (tabKey, onLeave) {
|
|
78
|
+
var tab = this.getTab(tabKey, true);
|
|
79
|
+
tab.onLeave = onLeave;
|
|
72
80
|
if (!this.selectedTab && this.autoSelectFirstTab) {
|
|
73
81
|
this.selectedTab = tabKey;
|
|
74
82
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Components } from '@singularsystems/neo-core';
|
|
2
2
|
import React, { HTMLProps } from 'react';
|
|
3
3
|
export interface ITooltipProps extends Components.Tooltip.ITooltipOptions<string | JSX.Element> {
|
|
4
|
+
/**
|
|
5
|
+
* True if the div wrapping the content must display inline.
|
|
6
|
+
*/
|
|
7
|
+
inline?: boolean;
|
|
4
8
|
}
|
|
5
9
|
export default class Tooltip extends React.Component<ITooltipProps> {
|
|
6
10
|
private divRef;
|
|
@@ -23,7 +23,7 @@ var Tooltip = /** @class */ (function (_super) {
|
|
|
23
23
|
TooltipHelper.hideTooltip();
|
|
24
24
|
};
|
|
25
25
|
Tooltip.prototype.render = function () {
|
|
26
|
-
return React.createElement("div", { ref: this.divRef, onMouseEnter: this.onMouseEnter, onMouseLeave: this.onMouseLeave },
|
|
26
|
+
return React.createElement("div", { ref: this.divRef, onMouseEnter: this.onMouseEnter, onMouseLeave: this.onMouseLeave, style: { display: this.props.inline ? "inline-block" : "" } },
|
|
27
27
|
React.createElement("div", { style: { display: "none" }, ref: this.contentRef }, this.props.content),
|
|
28
28
|
this.props.children);
|
|
29
29
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ import * as Views from './Views/';
|
|
|
7
7
|
import * as Managers from './ReactComponents/_Managers';
|
|
8
8
|
export * from './React/Decorators';
|
|
9
9
|
export { Managers, NeoReactModule, NeoReactTypes, Neo, NeoGrid, Routing, Views };
|
|
10
|
+
export { ICancellableEvent } from './ReactComponents/Misc';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularsystems/neo-react",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.40",
|
|
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",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@types/rc-slider": "^8.6.5",
|
|
34
34
|
"@types/react-color": "^3.0.1",
|
|
35
35
|
"@types/react-select": "3.1.0",
|
|
36
|
-
"@singularsystems/neo-core": "^0.10.
|
|
36
|
+
"@singularsystems/neo-core": "^0.10.47",
|
|
37
37
|
"axios": "^0.21.1",
|
|
38
38
|
"decimal.js-light": "2.5.1",
|
|
39
39
|
"history": "4.10.1",
|
package/styles/Modal.scss
CHANGED
|
@@ -14,16 +14,12 @@ body.has-modal-scroll-fix {
|
|
|
14
14
|
.modal-container {
|
|
15
15
|
position: relative;
|
|
16
16
|
outline: none;
|
|
17
|
+
transition: opacity .3s linear;
|
|
17
18
|
|
|
18
19
|
&.modal-container-additional {
|
|
19
|
-
transition: transform .3s ease-out, opacity .3s linear;
|
|
20
|
-
transform: translate(0, -50%);
|
|
20
|
+
transition: transform .3s ease-out, opacity .3s linear, margin .3s ease;
|
|
21
21
|
opacity: 0;
|
|
22
|
-
|
|
23
|
-
&.show {
|
|
24
|
-
transform: translate(0, 0);
|
|
25
|
-
|
|
26
|
-
}
|
|
22
|
+
|
|
27
23
|
&.show:not(.inactive) {
|
|
28
24
|
opacity: 1;
|
|
29
25
|
}
|