@singularsystems/neo-react 1.0.22 → 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/FileManager/FileInput.js +3 -1
- package/dist/ReactComponents/Form.js +3 -5
- package/dist/ReactComponents/Grid/Grid.js +7 -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 +19 -26
- package/styles/Button.scss +6 -0
- package/styles/DatePicker.scss +3 -1
- package/styles/Forms.scss +3 -1
- package/styles/Grid.scss +4 -0
- package/styles/Misc.scss +25 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
# Version 1.
|
|
1
|
+
# Version 1.1
|
|
2
|
+
|
|
3
|
+
Version 1.1 removes the `react-router` dependency. This requires updates to your project which are explained in [this guide](./docs/RemoveReactRouter.md).
|
|
4
|
+
|
|
5
|
+
It also fixes some issues preventing projects from upgrading to `mobx-react` v9.x.
|
|
6
|
+
|
|
7
|
+
## Version 1.0.22
|
|
8
|
+
|
|
9
|
+
React-select dependency was updated which has a breaking change in its types. You will need to update the version of this package in your project to at least:
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
"react-select": "5.8.1",
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
# Version 1.0
|
|
2
16
|
|
|
3
17
|
Version 1 of neo-react upgrades react to version 18, and mobX to version 6. Both of these are major updates and will require you to make code changes to your project.
|
|
4
18
|
|
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ var neoReactModule = new AppServices.Module("neo-react", function (container) {
|
|
|
16
16
|
container.bind(AppServices.NeoTypes.Core.ModelCreator).to(ReactModelCreator).inTransientScope();
|
|
17
17
|
container.bind(AppServices.NeoTypes.UI.ErrorHandler).to(ErrorHandler).inSingletonScope();
|
|
18
18
|
container.bind(AppServices.NeoTypes.UI.GlobalContextMenuState).toConstantValue(new ContextMenuState());
|
|
19
|
-
container.bind(
|
|
19
|
+
container.bind(NeoReactTypes.Routing.PageLeaveHandler).to(PageLeaveHandler).inSingletonScope();
|
|
20
20
|
container.bind(NeoReactTypes.Components.IconFactory).to(IconFactory).inSingletonScope();
|
|
21
21
|
container.bind(NeoReactTypes.Routing.GlobalRoutingState).to(RoutingState).inSingletonScope();
|
|
22
22
|
container.bind(NeoReactTypes.Routing.NavigationHelper).to(NavigationHelper).inSingletonScope();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Utils } from '@singularsystems/neo-core';
|
|
2
2
|
import { configure, isObservableArray, runInAction, untracked } from 'mobx';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { NeoReactTypes } from './Types';
|
|
5
4
|
export function runReactSetup(container) {
|
|
6
5
|
Utils.peek = function (target, propertyName) {
|
|
7
6
|
return untracked(function () { return target[propertyName]; });
|
|
@@ -16,8 +15,5 @@ export function runReactSetup(container) {
|
|
|
16
15
|
}
|
|
17
16
|
return array;
|
|
18
17
|
};
|
|
19
|
-
window.addEventListener("beforeunload", function (e) {
|
|
20
|
-
container.get(AppServices.NeoTypes.Routing.PageLeaveHandler).onWindowUnload(container.get(NeoReactTypes.Routing.GlobalRoutingState).currentView, e);
|
|
21
|
-
});
|
|
22
18
|
configure({ enforceActions: "never", useProxies: "never" });
|
|
23
19
|
}
|
package/dist/Modules/Types.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { AxiosStatic } from 'axios';
|
|
|
9
9
|
import type Select from 'react-select';
|
|
10
10
|
import { IDisposeHelper } from '../Services/IDisposeHelper';
|
|
11
11
|
import { IIconFactory } from '../ReactComponents/Icons/IIconFactory';
|
|
12
|
+
import { IPageLeaveHandler } from "../Routing/PageLeaveHandler";
|
|
12
13
|
declare const NeoReactTypes: {
|
|
13
14
|
Components: {
|
|
14
15
|
Slider: AppServices.ServiceIdentifier<typeof Slider>;
|
|
@@ -27,16 +28,16 @@ declare const NeoReactTypes: {
|
|
|
27
28
|
IconFactory: AppServices.ServiceIdentifier<IIconFactory>;
|
|
28
29
|
};
|
|
29
30
|
Routing: {
|
|
31
|
+
PageLeaveHandler: AppServices.ServiceIdentifier<IPageLeaveHandler>;
|
|
30
32
|
NavigationHelper: AppServices.ServiceIdentifier<INavigationHelper>;
|
|
31
33
|
GlobalRoutingState: AppServices.ServiceIdentifier<RoutingState>;
|
|
32
34
|
MenuItemProvider: AppServices.ServiceIdentifier<import("@singularsystems/neo-core/dist/Routing").IMenuItemProvider<import("@singularsystems/neo-core/dist/Routing").IMenuRoute>>;
|
|
33
|
-
PageLeaveHandler: AppServices.ServiceIdentifier<import("@singularsystems/neo-core/dist/Routing").IPageLeaveHandler>;
|
|
34
35
|
RouteSecurityService: AppServices.ServiceIdentifier<import("@singularsystems/neo-core/dist/Routing").IRouteSecurityService>;
|
|
35
36
|
};
|
|
36
37
|
Services: {
|
|
37
38
|
DisposeHelper: AppServices.ServiceIdentifier<IDisposeHelper>;
|
|
38
39
|
};
|
|
39
|
-
Axios: AppServices.ServiceIdentifier<AxiosStatic>;
|
|
40
|
+
Axios: AppServices.ServiceIdentifier<import("axios").AxiosStatic>;
|
|
40
41
|
Config: {
|
|
41
42
|
ConfigModel: AppServices.ServiceIdentifier<AppServices.IConfigModel>;
|
|
42
43
|
ConfigService: AppServices.ServiceIdentifier<import("@singularsystems/neo-core/dist/AppServices/Config/ConfigService").IConfigService>;
|
package/dist/Modules/Types.js
CHANGED
|
@@ -15,7 +15,7 @@ var NeoReactTypes = __assign(__assign({}, AppServices.NeoTypes), { Components: {
|
|
|
15
15
|
ReactSelect: new AppServices.ServiceIdentifier("NeoReact.ReactSelect"),
|
|
16
16
|
AsyncSelect: new AppServices.ServiceIdentifier("NeoReact.AsyncSelect"),
|
|
17
17
|
IconFactory: new AppServices.ServiceIdentifier("NeoReact.IconFactory")
|
|
18
|
-
}, Routing: __assign(__assign({}, AppServices.NeoTypes.Routing), { NavigationHelper: AppServices.NeoTypes.Routing.NavigationHelper.asType(), GlobalRoutingState: new AppServices.ServiceIdentifier("NeoReact.GlobalRoutingState") }), Services: {
|
|
18
|
+
}, Routing: __assign(__assign({}, AppServices.NeoTypes.Routing), { PageLeaveHandler: new AppServices.ServiceIdentifier("NeoReact.PageLeaveHandler"), NavigationHelper: AppServices.NeoTypes.Routing.NavigationHelper.asType(), GlobalRoutingState: new AppServices.ServiceIdentifier("NeoReact.GlobalRoutingState") }), Services: {
|
|
19
19
|
DisposeHelper: new AppServices.ServiceIdentifier("NeoReact.DisposeHelper")
|
|
20
20
|
} });
|
|
21
21
|
export { NeoReactTypes };
|
|
@@ -63,7 +63,7 @@ var ReactModelCreator = /** @class */ (function (_super) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
// Run mobx's setup for this instance.
|
|
66
|
-
makeObservable(object, annotations
|
|
66
|
+
makeObservable(object, annotations);
|
|
67
67
|
// Setup once properties have been converted to observables.
|
|
68
68
|
for (var propertyKey in observables) {
|
|
69
69
|
try {
|
|
@@ -4,10 +4,12 @@ import { Components, Utils, Misc, Validation } from '@singularsystems/neo-core';
|
|
|
4
4
|
import { observer } from 'mobx-react';
|
|
5
5
|
import FileUploadButton from './FileUploadButton';
|
|
6
6
|
import { FileContext } from './FileContext';
|
|
7
|
-
import { ProgressBar, Button, FileDropArea } from '../_Exports';
|
|
8
7
|
import ComponentBase from '../ComponentBase';
|
|
9
8
|
import { BindPropsHelper } from '../PropTypes';
|
|
10
9
|
import { makeObservable, observable } from 'mobx';
|
|
10
|
+
import ProgressBar from "../ProgressBar";
|
|
11
|
+
import FileDropArea from "./FileDropArea";
|
|
12
|
+
import Button from "../Button";
|
|
11
13
|
/**
|
|
12
14
|
* The file manager component manages uploading, and binding of files to a model.
|
|
13
15
|
*/
|
|
@@ -80,11 +80,9 @@ var Form = /** @class */ (function (_super) {
|
|
|
80
80
|
if (closeButton) {
|
|
81
81
|
closeButton.onClick = onClose;
|
|
82
82
|
}
|
|
83
|
-
codeModal_1 = ModalUtils.showModal(_this.props.invalidSummaryTitle || "Invalid data", React.createElement(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
React.createElement(ValidationSummary, { graph: Validation.getValidationSummary(modelOrModels), hideTopLevelTitle: !(modelOrModels instanceof Array) }));
|
|
87
|
-
}), { onClose: onClose, closeButton: closeButton });
|
|
83
|
+
codeModal_1 = ModalUtils.showModal(_this.props.invalidSummaryTitle || "Invalid data", React.createElement("div", null,
|
|
84
|
+
_this.props.invalidSummaryText || "Cannot continue due to the following issues:",
|
|
85
|
+
React.createElement(Observer, null, function () { return React.createElement(ValidationSummary, { graph: Validation.getValidationSummary(modelOrModels), hideTopLevelTitle: !(modelOrModels instanceof Array) }); })), { onClose: onClose, closeButton: closeButton });
|
|
88
86
|
}
|
|
89
87
|
if (someBusy()) {
|
|
90
88
|
// Async rule is busy, listen for when isBusy changes to false.
|
|
@@ -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
|
|
4
|
+
import { observer } from 'mobx-react';
|
|
5
5
|
import NeoButton from '../Button';
|
|
6
6
|
import { DataViewContext } from '../../React/DataView';
|
|
7
7
|
import { StickyTableHeader } from './StickyTableHeader';
|
|
@@ -103,14 +103,12 @@ var Grid = /** @class */ (function (_super) {
|
|
|
103
103
|
React.createElement(GridContext.Provider, { value: this.gridContext },
|
|
104
104
|
React.createElement(TableSection, { type: "header" }, this.headerItem && this.props.children(this.headerItem, this.headerItem.meta, true, -1)),
|
|
105
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: _this.props.children })); })),
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
(
|
|
112
|
-
React.createElement(AddButtonRow, { addButton: addButton, showAddButton: showAddButton, additionalContent: footerButtons })));
|
|
113
|
-
}))));
|
|
106
|
+
(showAddButton || addButton || footerButtons || this.gridContext.hasSummaries || footerContent !== undefined) &&
|
|
107
|
+
React.createElement(TableSection, { type: "footer" },
|
|
108
|
+
this.gridContext.hasSummaries && this.headerItem && this.props.children(this.headerItem, this.headerItem.meta, true, -1),
|
|
109
|
+
footerContent !== undefined && footerContent(this.gridContext.dataView.getItems()),
|
|
110
|
+
(showAddButton || addButton || footerButtons) &&
|
|
111
|
+
React.createElement(AddButtonRow, { addButton: addButton, showAddButton: showAddButton, additionalContent: footerButtons })))));
|
|
114
112
|
};
|
|
115
113
|
Grid.prototype.setInitialSort = function (initialSort, initialSortAscending) {
|
|
116
114
|
var _a;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __extends, __rest } from "tslib";
|
|
2
2
|
import { Misc } from "@singularsystems/neo-core";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { NeoReactTypes } from "
|
|
4
|
+
import { NeoReactTypes } from "../../Modules/Types";
|
|
5
5
|
/** Renders an icon using the icon factory specified at startup. */
|
|
6
6
|
var Icon = /** @class */ (function (_super) {
|
|
7
7
|
__extends(Icon, _super);
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface ILinkProps extends React.HTMLProps<HTMLAnchorElement> {
|
|
3
|
+
/** Internal path to navigate to. */
|
|
4
|
+
to?: string;
|
|
5
|
+
/** Indicates that this link is part of a navigation structure, and will be active if it matches the current url. */
|
|
6
|
+
isNav?: boolean;
|
|
7
|
+
/** If `isNav` is set, then this will cause the url to match exactly instead of using startswith. */
|
|
8
|
+
exact?: boolean;
|
|
3
9
|
}
|
|
4
10
|
/**
|
|
5
11
|
* Renders an anchor tag with an href of '/' unless otherwise specified.
|
|
6
12
|
* The onClick event will call preventDefault() so that the anchor acts like a button instead of a link to a url.
|
|
7
13
|
*/
|
|
8
14
|
export default class Link extends React.Component<ILinkProps> {
|
|
15
|
+
private basePath;
|
|
9
16
|
constructor(props: ILinkProps);
|
|
10
17
|
private onClick;
|
|
11
18
|
render(): React.JSX.Element;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { __assign, __extends } from "tslib";
|
|
1
|
+
import { __assign, __decorate, __extends, __metadata, __rest } from "tslib";
|
|
2
|
+
import { AppServices, Misc, Utils } from "@singularsystems/neo-core";
|
|
2
3
|
import React from 'react';
|
|
4
|
+
import { NeoReactTypes } from "../Modules/Types";
|
|
5
|
+
import { observer } from "mobx-react";
|
|
3
6
|
/**
|
|
4
7
|
* Renders an anchor tag with an href of '/' unless otherwise specified.
|
|
5
8
|
* The onClick event will call preventDefault() so that the anchor acts like a button instead of a link to a url.
|
|
@@ -9,20 +12,50 @@ var Link = /** @class */ (function (_super) {
|
|
|
9
12
|
function Link(props) {
|
|
10
13
|
var _this = _super.call(this, props) || this;
|
|
11
14
|
_this.onClick = _this.onClick.bind(_this);
|
|
15
|
+
_this.basePath = Misc.Globals.appService.get(NeoReactTypes.Routing.GlobalRoutingState).basePath;
|
|
12
16
|
return _this;
|
|
13
17
|
}
|
|
14
18
|
Link.prototype.onClick = function (e) {
|
|
15
|
-
e.preventDefault();
|
|
16
19
|
if (this.props.onClick) {
|
|
17
20
|
this.props.onClick(e);
|
|
18
21
|
}
|
|
22
|
+
if (!e.defaultPrevented) {
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
if (this.props.to) {
|
|
25
|
+
Misc.Globals.appService.get(AppServices.NeoTypes.Routing.NavigationHelper).navigateInternal(this.props.to);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
19
28
|
};
|
|
20
29
|
Link.prototype.render = function () {
|
|
21
|
-
var _a;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
var _a = this.props, to = _a.to, href = _a.href, isNav = _a.isNav, exact = _a.exact, rest = __rest(_a, ["to", "href", "isNav", "exact"]);
|
|
31
|
+
href !== null && href !== void 0 ? href : (href = "/");
|
|
32
|
+
if (to) {
|
|
33
|
+
if (to.startsWith("/") && !to.startsWith(this.basePath)) {
|
|
34
|
+
to = this.basePath + to;
|
|
35
|
+
}
|
|
36
|
+
href = to;
|
|
37
|
+
if (isNav) {
|
|
38
|
+
// Cause re-render if current route changes.
|
|
39
|
+
void Misc.Globals.appService.get(NeoReactTypes.Routing.GlobalRoutingState).currentRoute;
|
|
40
|
+
var path = window.location.pathname.toLowerCase();
|
|
41
|
+
var toLc = to.toLowerCase();
|
|
42
|
+
if (path.endsWith("/")) {
|
|
43
|
+
path = path.substring(0, path.length - 1);
|
|
44
|
+
}
|
|
45
|
+
var isMatch = exact === true ?
|
|
46
|
+
toLc === path :
|
|
47
|
+
path.startsWith(toLc);
|
|
48
|
+
if (isMatch) {
|
|
49
|
+
rest.className = Utils.joinWithSpaces(rest.className, "active");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return React.createElement("a", __assign({}, rest, { href: href, onClick: this.onClick }), this.props.children);
|
|
25
54
|
};
|
|
55
|
+
Link = __decorate([
|
|
56
|
+
observer,
|
|
57
|
+
__metadata("design:paramtypes", [Object])
|
|
58
|
+
], Link);
|
|
26
59
|
return Link;
|
|
27
60
|
}(React.Component));
|
|
28
61
|
export default Link;
|
|
@@ -4,9 +4,9 @@ import ModalPortal from './ModalPortal';
|
|
|
4
4
|
import { Misc, Utils } from '@singularsystems/neo-core';
|
|
5
5
|
import Button from '../Button';
|
|
6
6
|
import { Settings } from '@singularsystems/neo-core/dist/Settings';
|
|
7
|
-
import { Neo } from '../..';
|
|
8
7
|
import { observer } from 'mobx-react';
|
|
9
8
|
import BootstrapUtils from "../BootstrapUtils";
|
|
9
|
+
import Form from "../Form";
|
|
10
10
|
var Modal = /** @class */ (function (_super) {
|
|
11
11
|
__extends(Modal, _super);
|
|
12
12
|
function Modal() {
|
|
@@ -114,7 +114,7 @@ var Modal = /** @class */ (function (_super) {
|
|
|
114
114
|
container = React.createElement(React.Fragment, null, content);
|
|
115
115
|
}
|
|
116
116
|
else {
|
|
117
|
-
container = React.createElement(
|
|
117
|
+
container = React.createElement(Form, __assign({}, formProps, { onSubmit: function (e) { _this.onSubmit && _this.onSubmit(e); } }), content);
|
|
118
118
|
}
|
|
119
119
|
return (this.visible &&
|
|
120
120
|
React.createElement(ModalPortal, { show: show, onDismiss: onClose, options: this.props },
|
|
@@ -4,6 +4,7 @@ import { observer } from "mobx-react";
|
|
|
4
4
|
import { TabContext } from "./TabContainer";
|
|
5
5
|
import { Misc } from "@singularsystems/neo-core";
|
|
6
6
|
import { NeoReactTypes } from "../../Modules/Types";
|
|
7
|
+
import TransitionPanel from "../Transitions/TransitionPanel";
|
|
7
8
|
var Tab = /** @class */ (function (_super) {
|
|
8
9
|
__extends(Tab, _super);
|
|
9
10
|
function Tab(props) {
|
|
@@ -58,7 +59,10 @@ var Tab = /** @class */ (function (_super) {
|
|
|
58
59
|
if (isSelected) {
|
|
59
60
|
this.hasRenderedContents = true;
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
+
var tabPane = React.createElement("div", { className: "tab-pane" + (isSelected ? " show active" : "") }, this.props.children);
|
|
63
|
+
return this.context.animate ?
|
|
64
|
+
React.createElement(TransitionPanel, { isVisible: isSelected }, tabPane) :
|
|
65
|
+
(isSelected || forceRender) && tabPane;
|
|
62
66
|
};
|
|
63
67
|
Tab.contextType = TabContext;
|
|
64
68
|
Tab = __decorate([
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Components } from "@singularsystems/neo-core";
|
|
3
3
|
import { IObservableValue } from "@singularsystems/neo-core/dist/Model/ObservableValue";
|
|
4
|
-
import { TabManager
|
|
4
|
+
import { TabManager } from './TabManager';
|
|
5
|
+
import { Transition } from "../Transitions/Transition";
|
|
5
6
|
export interface ITabContainerProps {
|
|
6
7
|
/**
|
|
7
8
|
* Optional tab manager for managing selected tab / tab change events.
|
|
@@ -23,15 +24,18 @@ export interface ITabContainerProps {
|
|
|
23
24
|
* Use this if you want ui state e.g. scroll positions to remain on switch of tabs.
|
|
24
25
|
*/
|
|
25
26
|
keepMounted?: boolean;
|
|
27
|
+
/** True if switching tabs should animate. */
|
|
28
|
+
animate?: boolean | Transition;
|
|
26
29
|
}
|
|
27
30
|
export declare class TabContextParams {
|
|
28
|
-
tabManager:
|
|
31
|
+
tabManager: TabManager;
|
|
29
32
|
/**
|
|
30
33
|
* True if the tab manager was passed in to the tab container.
|
|
31
34
|
*/
|
|
32
35
|
isUserTabManager: boolean;
|
|
33
36
|
inHeader: boolean;
|
|
34
37
|
keepMounted?: boolean;
|
|
38
|
+
animate?: boolean;
|
|
35
39
|
}
|
|
36
40
|
export declare const TabContext: React.Context<TabContextParams>;
|
|
37
41
|
export default class TabContainer extends React.Component<ITabContainerProps & React.HTMLProps<HTMLDivElement>> {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { __assign, __extends, __rest } from "tslib";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { Components, Utils } from "@singularsystems/neo-core";
|
|
3
|
+
import { Components, Misc, Utils } from "@singularsystems/neo-core";
|
|
4
4
|
import { TabManager } from './TabManager';
|
|
5
|
+
import { TransitionContainer } from "../_Exports";
|
|
6
|
+
import { Transition } from "../Transitions/Transition";
|
|
5
7
|
var TabContextParams = /** @class */ (function () {
|
|
6
8
|
function TabContextParams() {
|
|
7
9
|
/**
|
|
@@ -19,15 +21,13 @@ var TabContainer = /** @class */ (function (_super) {
|
|
|
19
21
|
function TabContainer(props) {
|
|
20
22
|
var _this = _super.call(this, props) || this;
|
|
21
23
|
_this.tabContext = new TabContextParams();
|
|
22
|
-
var tabManager;
|
|
23
24
|
if (_this.props.tabManager) {
|
|
24
|
-
tabManager = _this.props.tabManager;
|
|
25
|
+
_this.tabManager = _this.props.tabManager;
|
|
25
26
|
_this.tabContext.isUserTabManager = true;
|
|
26
27
|
}
|
|
27
28
|
else {
|
|
28
|
-
tabManager = new TabManager("", true, _this.props.selectedTab);
|
|
29
|
+
_this.tabManager = new TabManager("", true, _this.props.selectedTab);
|
|
29
30
|
}
|
|
30
|
-
_this.tabManager = tabManager;
|
|
31
31
|
_this.tabContext.tabManager = _this.tabManager;
|
|
32
32
|
return _this;
|
|
33
33
|
}
|
|
@@ -38,24 +38,22 @@ var TabContainer = /** @class */ (function (_super) {
|
|
|
38
38
|
this.tabManager.onUnmount();
|
|
39
39
|
};
|
|
40
40
|
TabContainer.prototype.render = function () {
|
|
41
|
-
var _a = this.props, tabManager = _a.tabManager, selectedTab = _a.selectedTab, variant = _a.variant, fillMode = _a.fillMode, align = _a.align, verticalSizes = _a.verticalSizes, keepMounted = _a.keepMounted, domProps = __rest(_a, ["tabManager", "selectedTab", "variant", "fillMode", "align", "verticalSizes", "keepMounted"]);
|
|
41
|
+
var _a = this.props, tabManager = _a.tabManager, selectedTab = _a.selectedTab, variant = _a.variant, fillMode = _a.fillMode, align = _a.align, verticalSizes = _a.verticalSizes, keepMounted = _a.keepMounted, animate = _a.animate, domProps = __rest(_a, ["tabManager", "selectedTab", "variant", "fillMode", "align", "verticalSizes", "keepMounted", "animate"]);
|
|
42
42
|
this.tabContext.keepMounted = keepMounted;
|
|
43
|
+
this.tabContext.animate = (animate !== null && animate !== void 0 ? animate : Misc.Settings.tabs.animate) !== false;
|
|
43
44
|
if (!verticalSizes)
|
|
44
45
|
verticalSizes = {};
|
|
45
46
|
if (!verticalSizes.xs)
|
|
46
47
|
verticalSizes.xs = 12;
|
|
47
48
|
var isCardMode = (variant === "tabs" || !variant);
|
|
48
|
-
if (variant === "flat") {
|
|
49
|
-
variant = "tabs";
|
|
50
|
-
}
|
|
51
49
|
var _b = Components.BootstrapHelpers.getInverseBreakpointClasses(verticalSizes), cols = _b.cols, inverseCols = _b.inverseCols;
|
|
52
50
|
domProps.className = Utils.joinWithSpaces(domProps.className, "row neo-tab-container", isCardMode ? "neo-tab-card-mode" : undefined);
|
|
53
51
|
return (React.createElement(TabContext.Provider, { value: this.tabContext },
|
|
54
52
|
React.createElement("div", __assign({}, domProps),
|
|
55
53
|
React.createElement("div", { className: "tabs-header " + cols },
|
|
56
|
-
React.createElement(TabSection, { isHeader: true, containerProps:
|
|
54
|
+
React.createElement(TabSection, { isHeader: true, containerProps: this.props }, this.props.children)),
|
|
57
55
|
React.createElement("div", { className: inverseCols },
|
|
58
|
-
React.createElement(TabSection, { isHeader: false }, this.props.children)))));
|
|
56
|
+
React.createElement(TabSection, { isHeader: false, containerProps: this.props }, this.props.children)))));
|
|
59
57
|
};
|
|
60
58
|
return TabContainer;
|
|
61
59
|
}(React.Component));
|
|
@@ -66,17 +64,21 @@ var TabSection = /** @class */ (function (_super) {
|
|
|
66
64
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
67
65
|
}
|
|
68
66
|
TabSection.prototype.render = function () {
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
var _a = this.props, isHeader = _a.isHeader, containerProps = _a.containerProps;
|
|
68
|
+
this.context.inHeader = isHeader;
|
|
69
|
+
var headerClassName = "nav";
|
|
71
70
|
if (this.props.isHeader) {
|
|
72
|
-
var
|
|
71
|
+
var variant = containerProps.variant;
|
|
72
|
+
if (variant === "flat") {
|
|
73
|
+
variant = "tabs";
|
|
74
|
+
}
|
|
73
75
|
if (containerProps.verticalSizes) {
|
|
74
76
|
var breakpoint = Components.BootstrapHelpers.getFirstBreakpoint(containerProps.verticalSizes);
|
|
75
77
|
if (breakpoint)
|
|
76
78
|
headerClassName += " flex-" + breakpoint + "-column";
|
|
77
79
|
}
|
|
78
|
-
if (
|
|
79
|
-
headerClassName += " nav-" + (
|
|
80
|
+
if (variant !== "none") {
|
|
81
|
+
headerClassName += " nav-" + (variant || "tabs");
|
|
80
82
|
}
|
|
81
83
|
if (containerProps.fillMode) {
|
|
82
84
|
headerClassName += " nav-" + containerProps.fillMode;
|
|
@@ -85,9 +87,15 @@ var TabSection = /** @class */ (function (_super) {
|
|
|
85
87
|
headerClassName += " justify-content-" + containerProps.align;
|
|
86
88
|
}
|
|
87
89
|
}
|
|
90
|
+
var transition = typeof containerProps.animate === "object" ? containerProps.animate : undefined;
|
|
91
|
+
if (!transition && containerProps.verticalSizes) {
|
|
92
|
+
transition = Transition.upDown;
|
|
93
|
+
}
|
|
88
94
|
return (this.props.isHeader ?
|
|
89
95
|
React.createElement("ul", { className: headerClassName }, this.props.children) :
|
|
90
|
-
React.createElement("div", { className: "tab-content" }, this.
|
|
96
|
+
React.createElement("div", { className: "tab-content" }, this.context.animate ?
|
|
97
|
+
React.createElement(TransitionContainer, { transition: transition }, this.props.children) :
|
|
98
|
+
this.props.children));
|
|
91
99
|
};
|
|
92
100
|
TabSection.contextType = TabContext;
|
|
93
101
|
return TabSection;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Misc, Model } from '@singularsystems/neo-core';
|
|
2
|
-
import { ICancellableEvent } from '../Misc';
|
|
3
2
|
export interface ITabManager {
|
|
4
3
|
selectedTab: string;
|
|
5
4
|
/**
|
|
@@ -11,11 +10,6 @@ export interface ITabManager {
|
|
|
11
10
|
*/
|
|
12
11
|
onTabDisplayed(tabKey: string, callback: () => void): ITabManager;
|
|
13
12
|
}
|
|
14
|
-
export interface ITabManagerInternal extends ITabManager {
|
|
15
|
-
initialise(): void;
|
|
16
|
-
tabMounted(tabKey: string, onLeave?: (e: ICancellableEvent) => void): void;
|
|
17
|
-
onUnmount(): void;
|
|
18
|
-
}
|
|
19
13
|
/**
|
|
20
14
|
* Tab manager used to manage a tab component.
|
|
21
15
|
* @param T string union type of tab names.
|
|
@@ -30,10 +24,6 @@ export declare class TabManager<T extends string = string> implements Misc.IDisp
|
|
|
30
24
|
* @param autoSelectFirstTab Set to true if the first child tab should become selected.
|
|
31
25
|
*/
|
|
32
26
|
constructor(selectedTab?: T, autoSelectFirstTab?: boolean, observable?: Model.IObservableValue<T>);
|
|
33
|
-
/** Called by tab container. */
|
|
34
|
-
private initialise;
|
|
35
|
-
/** Called by tab container. */
|
|
36
|
-
private onUnmount;
|
|
37
27
|
get selectedTab(): T;
|
|
38
28
|
set selectedTab(value: T);
|
|
39
29
|
/**
|
|
@@ -44,8 +34,6 @@ export declare class TabManager<T extends string = string> implements Misc.IDisp
|
|
|
44
34
|
* Registers a callback to run whenever the tab with this tab key is displayed.
|
|
45
35
|
*/
|
|
46
36
|
onTabDisplayed(tabKey: T, callback: () => void): this;
|
|
47
|
-
/** Called by tab container. */
|
|
48
|
-
private tabMounted;
|
|
49
37
|
private getTab;
|
|
50
38
|
/**
|
|
51
39
|
* Marks the tab as 'initial'.
|
|
@@ -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;
|