@singularsystems/neo-react 1.0.0-alpha.2 → 1.0.0-alpha.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.
Files changed (31) hide show
  1. package/dist/Modules/ReactSetup.js +2 -2
  2. package/dist/Modules/Types.d.ts +2 -2
  3. package/dist/ReactComponents/ContextMenu/ContextMenu.js +2 -1
  4. package/dist/ReactComponents/ContextMenu/ContextMenuState.d.ts +1 -0
  5. package/dist/ReactComponents/ContextMenu/ContextMenuState.js +2 -1
  6. package/dist/ReactComponents/DropDown/AutoCompleteDropDown.d.ts +4 -4
  7. package/dist/ReactComponents/DropDown/AutoCompleteDropDown.js +7 -7
  8. package/dist/ReactComponents/ErrorHandler.d.ts +1 -0
  9. package/dist/ReactComponents/ErrorHandler.js +5 -3
  10. package/dist/ReactComponents/FileManager/FileDropArea.d.ts +1 -0
  11. package/dist/ReactComponents/FileManager/FileDropArea.js +6 -4
  12. package/dist/ReactComponents/FileManager/FileInput.d.ts +1 -0
  13. package/dist/ReactComponents/FileManager/FileInput.js +6 -4
  14. package/dist/ReactComponents/Form.d.ts +3 -2
  15. package/dist/ReactComponents/FormContext.d.ts +3 -1
  16. package/dist/ReactComponents/Grid/Column.js +2 -2
  17. package/dist/ReactComponents/Grid/Grid.d.ts +3 -6
  18. package/dist/ReactComponents/Grid/Row.js +3 -2
  19. package/dist/ReactComponents/Input.js +2 -1
  20. package/dist/ReactComponents/InputHelpers.d.ts +2 -2
  21. package/dist/ReactComponents/Modal/ModalPortal.d.ts +1 -0
  22. package/dist/ReactComponents/Paging/Pager.d.ts +2 -2
  23. package/dist/ReactComponents/Tooltip.d.ts +1 -0
  24. package/dist/Routing/PageLeaveHandler.js +4 -3
  25. package/dist/Routing/RouteView.js +4 -5
  26. package/dist/Routing/RoutingState.d.ts +3 -0
  27. package/dist/Routing/RoutingState.js +13 -7
  28. package/dist/Routing/ViewParameter.js +2 -1
  29. package/dist/Views/ViewBase.d.ts +1 -2
  30. package/dist/Views/ViewBase.js +9 -7
  31. package/package.json +14 -12
@@ -1,7 +1,7 @@
1
1
  import { AppServices, Utils } from '@singularsystems/neo-core';
2
2
  import { configure, runInAction, untracked } from 'mobx';
3
- import ViewBase from '../Views/ViewBase';
4
3
  import React from 'react';
4
+ import { NeoReactTypes } from './Types';
5
5
  export function runReactSetup(container) {
6
6
  Utils.peek = function (target, propertyName) {
7
7
  return untracked(function () { return target[propertyName]; });
@@ -11,7 +11,7 @@ export function runReactSetup(container) {
11
11
  };
12
12
  Utils.batchUpdate = runInAction;
13
13
  window.addEventListener("beforeunload", function (e) {
14
- container.get(AppServices.NeoTypes.Routing.PageLeaveHandler).onWindowUnload(ViewBase.currentView, e);
14
+ container.get(AppServices.NeoTypes.Routing.PageLeaveHandler).onWindowUnload(container.get(NeoReactTypes.Routing.GlobalRoutingState).currentView, e);
15
15
  });
16
16
  configure({ enforceActions: "never", useProxies: "never" });
17
17
  }
@@ -13,8 +13,8 @@ declare const NeoReactTypes: {
13
13
  Slider: AppServices.ServiceIdentifier<typeof Slider>;
14
14
  Range: AppServices.ServiceIdentifier<typeof Range>;
15
15
  SketchPicker: AppServices.ServiceIdentifier<typeof SketchPicker>;
16
- ReactSelect: AppServices.ServiceIdentifier<typeof Select>;
17
- AsyncSelect: AppServices.ServiceIdentifier<typeof AsyncSelect>;
16
+ ReactSelect: AppServices.ServiceIdentifier<Select>;
17
+ AsyncSelect: AppServices.ServiceIdentifier<AsyncSelect>;
18
18
  };
19
19
  Routing: {
20
20
  NavigationHelper: AppServices.ServiceIdentifier<INavigationHelper>;
@@ -1,6 +1,6 @@
1
1
  import { __decorate, __extends, __metadata } from "tslib";
2
2
  import React from 'react';
3
- import { observable } from 'mobx';
3
+ import { makeObservable, observable } from 'mobx';
4
4
  import { observer } from 'mobx-react';
5
5
  import { Utils } from '@singularsystems/neo-core';
6
6
  import ComponentBase from '../ComponentBase';
@@ -11,6 +11,7 @@ var ContextMenu = /** @class */ (function (_super) {
11
11
  _this.menuRef = React.createRef();
12
12
  _this.hoverItem = null;
13
13
  _this.mouseEnter = _this.mouseEnter.bind(_this);
14
+ makeObservable(_this);
14
15
  return _this;
15
16
  }
16
17
  ContextMenu_1 = ContextMenu;
@@ -1,6 +1,7 @@
1
1
  import { Components } from "@singularsystems/neo-core";
2
2
  import { IPosition } from "@singularsystems/neo-core/dist/Components/ContextMenu/ContextMenu";
3
3
  export declare class ContextMenuState {
4
+ constructor();
4
5
  show: boolean;
5
6
  items: Components.IMenuItem[];
6
7
  position: IPosition | null;
@@ -1,10 +1,11 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
- import { observable } from "mobx";
2
+ import { makeObservable, observable } from "mobx";
3
3
  var ContextMenuState = /** @class */ (function () {
4
4
  function ContextMenuState() {
5
5
  this.show = false;
6
6
  this.items = [];
7
7
  this.position = null;
8
+ makeObservable(this);
8
9
  }
9
10
  __decorate([
10
11
  observable.ref,
@@ -54,11 +54,11 @@ interface IAutoCompleteCommonProps<T> extends ICommonEditorProps, Props<IOption,
54
54
  */
55
55
  minCharacters?: number;
56
56
  }
57
- export interface IAutoCompleteProps<T> extends IAutoCompleteCommonProps<T> {
57
+ export interface IAutoCompleteProps {
58
58
  bind: Model.IPropertyInstance;
59
59
  bindDisplay?: Model.IPropertyInstance;
60
60
  }
61
- export interface IAutoCompleteMultiSelectProps<T> extends IAutoCompleteCommonProps<T> {
61
+ export interface IAutoCompleteMultiSelectProps {
62
62
  /**
63
63
  * A list of ids and labels to use as the selected list.
64
64
  */
@@ -68,12 +68,12 @@ export interface IAutoCompleteMultiSelectProps<T> extends IAutoCompleteCommonPro
68
68
  */
69
69
  bindIds?: (string | number)[];
70
70
  }
71
- export default class AutoCompleteDropDown<T> extends DropDownBase<T, IAutoCompleteProps<T> | IAutoCompleteMultiSelectProps<T>> {
71
+ export default class AutoCompleteDropDown<T> extends DropDownBase<T, IAutoCompleteCommonProps<T> & (IAutoCompleteProps | IAutoCompleteMultiSelectProps)> {
72
72
  static contextType: React.Context<import("../FormContext").FormContextParams>;
73
73
  context: React.ContextType<typeof FormContext>;
74
74
  private asyncSelectImplementation;
75
75
  private selectImplementation;
76
- constructor(props: IAutoCompleteProps<T> | IAutoCompleteMultiSelectProps<T>);
76
+ constructor(props: IAutoCompleteCommonProps<T> & (IAutoCompleteProps | IAutoCompleteMultiSelectProps));
77
77
  private onKeyPress;
78
78
  private mapTArrayToOptions;
79
79
  private onItemSelected;
@@ -48,11 +48,11 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
48
48
  return items.map(function (item) { return (__assign(__assign({}, item), { value: item[_this.valueMember], label: item[_this.displayMember] })); });
49
49
  };
50
50
  AutoCompleteDropDown.prototype.onItemSelected = function (args, action) {
51
- var onItemSelected = this.props.onItemSelected;
52
- if (this.props.bindItems) {
51
+ var onItemSelected = this.props.onItemSelected, singleProps = this.props, multiProps = this.props;
52
+ if (multiProps.bindItems) {
53
53
  // Multi select
54
- var itemList = this.props.bindItems.value;
55
- var bindIdsList = this.props.bindIds;
54
+ var itemList = multiProps.bindItems.value;
55
+ var bindIdsList = multiProps.bindIds;
56
56
  if (action.action === "select-option") {
57
57
  itemList.push({ id: action.option.value, display: action.option.label });
58
58
  if (bindIdsList) {
@@ -86,9 +86,9 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
86
86
  }
87
87
  else if (this.props.bind) {
88
88
  // Single select
89
- this.props.bind.value = args ? args.value : null;
90
- if (this.props.bindDisplay) {
91
- this.props.bindDisplay.value = args ? args.label : "";
89
+ singleProps.bind.value = args ? args.value : null;
90
+ if (singleProps.bindDisplay) {
91
+ singleProps.bindDisplay.value = args ? args.label : "";
92
92
  }
93
93
  if (onItemSelected) {
94
94
  onItemSelected(args);
@@ -2,6 +2,7 @@ import { Components } from '@singularsystems/neo-core';
2
2
  export declare class ErrorHandler extends Components.ErrorHandler {
3
3
  private errorList;
4
4
  private hidingErrorList;
5
+ constructor(notifications: Components.INotificationHelper);
5
6
  protected displayError(displayType: Components.ErrorDisplayType, error: any, errorDisplay: Components.IErrorDisplay): void;
6
7
  protected displayModal(error: any, errorDisplay: Components.IErrorDisplay): void;
7
8
  private getIcon;
@@ -2,11 +2,12 @@ import { __decorate, __extends, __metadata } from "tslib";
2
2
  import React from 'react';
3
3
  import { Components, ModalUtils } from '@singularsystems/neo-core';
4
4
  import { Observer } from 'mobx-react';
5
- import { observable } from 'mobx';
5
+ import { makeObservable, observable } from 'mobx';
6
6
  var ErrorGroup = /** @class */ (function () {
7
7
  function ErrorGroup(errorDisplay) {
8
8
  this.errorDisplay = errorDisplay;
9
9
  this.count = 1;
10
+ makeObservable(this);
10
11
  }
11
12
  __decorate([
12
13
  observable,
@@ -16,10 +17,11 @@ var ErrorGroup = /** @class */ (function () {
16
17
  }());
17
18
  var ErrorHandler = /** @class */ (function (_super) {
18
19
  __extends(ErrorHandler, _super);
19
- function ErrorHandler() {
20
- var _this = _super !== null && _super.apply(this, arguments) || this;
20
+ function ErrorHandler(notifications) {
21
+ var _this = _super.call(this, notifications) || this;
21
22
  _this.errorList = [];
22
23
  _this.hidingErrorList = null;
24
+ makeObservable(_this);
23
25
  return _this;
24
26
  }
25
27
  ErrorHandler.prototype.displayError = function (displayType, error, errorDisplay) {
@@ -10,6 +10,7 @@ export default class FileDropArea extends React.Component<IFileDropAreaProps> {
10
10
  private fileManager;
11
11
  private isDragging;
12
12
  private dropDiv;
13
+ constructor(props: IFileDropAreaProps);
13
14
  private dragEnter;
14
15
  private dragLeave;
15
16
  private drop;
@@ -1,15 +1,16 @@
1
1
  import { __assign, __decorate, __extends, __metadata, __rest } from "tslib";
2
2
  import React from 'react';
3
3
  import { Utils } from '@singularsystems/neo-core';
4
- import { observable } from 'mobx';
4
+ import { makeObservable, observable } from 'mobx';
5
5
  import { observer } from 'mobx-react';
6
6
  import { FileContext } from './FileContext';
7
7
  var FileDropArea = /** @class */ (function (_super) {
8
8
  __extends(FileDropArea, _super);
9
- function FileDropArea() {
10
- var _this = _super !== null && _super.apply(this, arguments) || this;
9
+ function FileDropArea(props) {
10
+ var _this = _super.call(this, props) || this;
11
11
  _this.isDragging = false;
12
12
  _this.dropDiv = React.createRef();
13
+ makeObservable(_this);
13
14
  return _this;
14
15
  }
15
16
  FileDropArea.prototype.dragEnter = function (e) {
@@ -57,7 +58,8 @@ var FileDropArea = /** @class */ (function (_super) {
57
58
  __metadata("design:type", Object)
58
59
  ], FileDropArea.prototype, "isDragging", void 0);
59
60
  FileDropArea = __decorate([
60
- observer
61
+ observer,
62
+ __metadata("design:paramtypes", [Object])
61
63
  ], FileDropArea);
62
64
  return FileDropArea;
63
65
  }(React.Component));
@@ -30,6 +30,7 @@ export default class FileInput extends ComponentBase<IFileEditorProps> {
30
30
  context: React.ContextType<typeof FileContext>;
31
31
  private fileManager;
32
32
  private gettingDownloadUrl;
33
+ constructor(props: IFileEditorProps);
33
34
  render(): JSX.Element;
34
35
  private getFileDisplayComponent;
35
36
  /** Renders when the file is busy uploading. */
@@ -7,15 +7,16 @@ import { FileContext } from './FileContext';
7
7
  import { ProgressBar, Button, FileDropArea } from '../_Exports';
8
8
  import ComponentBase from '../ComponentBase';
9
9
  import { BindPropsHelper } from '../PropTypes';
10
- import { observable } from 'mobx';
10
+ import { makeObservable, observable } from 'mobx';
11
11
  /**
12
12
  * The file manager component manages uploading, and binding of files to a model.
13
13
  */
14
14
  var FileInput = /** @class */ (function (_super) {
15
15
  __extends(FileInput, _super);
16
- function FileInput() {
17
- var _this = _super !== null && _super.apply(this, arguments) || this;
16
+ function FileInput(props) {
17
+ var _this = _super.call(this, props) || this;
18
18
  _this.gettingDownloadUrl = false;
19
+ makeObservable(_this);
19
20
  return _this;
20
21
  }
21
22
  FileInput.prototype.render = function () {
@@ -182,7 +183,8 @@ var FileInput = /** @class */ (function (_super) {
182
183
  __metadata("design:type", Boolean)
183
184
  ], FileInput.prototype, "gettingDownloadUrl", void 0);
184
185
  FileInput = __decorate([
185
- observer
186
+ observer,
187
+ __metadata("design:paramtypes", [Object])
186
188
  ], FileInput);
187
189
  return FileInput;
188
190
  }(ComponentBase));
@@ -1,12 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { Components, Model } from '@singularsystems/neo-core';
3
- export interface IFormProps<T extends Model.IModelBase> extends React.FormHTMLAttributes<HTMLElement>, Components.IFormOptions<T> {
3
+ interface IFormProps<T extends Model.IModelBase> extends Omit<React.FormHTMLAttributes<HTMLElement>, "children">, Components.IFormOptions<T> {
4
4
  /**
5
5
  * Called when the form is submitted, but the model is not valid.
6
6
  * The justValidated parameter will be true if the validationDisplayMode is 'AfterSubmit', and this is the first submit attempt.
7
7
  */
8
8
  onInvalid?: (e: React.FormEvent, justValidated?: boolean) => void;
9
- children: React.ReactNode;
9
+ children: React.ReactNode | ((item: T, meta: Model.TransformMetaType<T>) => React.ReactNode);
10
10
  }
11
11
  export default class Form<T extends Model.IModelBase> extends React.Component<IFormProps<T>> {
12
12
  private reactionDisposer?;
@@ -16,3 +16,4 @@ export default class Form<T extends Model.IModelBase> extends React.Component<IF
16
16
  componentWillUnmount(): void;
17
17
  render(): JSX.Element;
18
18
  }
19
+ export {};
@@ -24,7 +24,9 @@ export declare const FormContext: React.Context<FormContextParams>;
24
24
  /**
25
25
  * Allows the attributes of multiple child form controls to be set at a parent level.
26
26
  */
27
- export declare class FormContextProvider extends React.Component<Components.IFormContextOptions> {
27
+ export declare class FormContextProvider extends React.Component<Components.IFormContextOptions & {
28
+ children: React.ReactNode;
29
+ }> {
28
30
  static contextType: React.Context<FormContextParams>;
29
31
  context: React.ContextType<typeof FormContext>;
30
32
  render(): JSX.Element;
@@ -186,9 +186,9 @@ var Column = /** @class */ (function (_super) {
186
186
  !containerProps.suppressDefaultContent && (editor !== undefined ?
187
187
  editor :
188
188
  editorProps.bind ? displayValue : undefined),
189
- !containerProps.bindContext && (this.props.children instanceof Function ? this.props.children() : this.props.children),
189
+ !containerProps.bindContext && this.props.children,
190
190
  containerProps.bindContext &&
191
- React.createElement(FormContext.Consumer, null, function (value) { return (React.createElement(FormContext.Provider, { value: __assign(__assign({}, value), { parentType: EditorParentType.Column, bindProperty: containerProps.bindContext }) }, _this.props.children instanceof Function ? _this.props.children() : _this.props.children)); })));
191
+ React.createElement(FormContext.Consumer, null, function (value) { return (React.createElement(FormContext.Provider, { value: __assign(__assign({}, value), { parentType: EditorParentType.Column, bindProperty: containerProps.bindContext }) }, _this.props.children)); })));
192
192
  };
193
193
  Column.prototype.renderFooter = function (props, domProps) {
194
194
  var _this = this;
@@ -17,7 +17,7 @@ export declare class GridContextParams<T> {
17
17
  get inBody(): boolean;
18
18
  }
19
19
  export declare const GridContext: React.Context<GridContextParams<unknown>>;
20
- interface IGridProps<T> extends React.HTMLProps<HTMLTableElement> {
20
+ interface IGridProps<T> extends Omit<React.HTMLProps<HTMLTableElement>, "children"> {
21
21
  /**
22
22
  * Datasource of the Grid. Usually a neo List, but can be a js array. This is not required if the grid is nested in
23
23
  * a DataViewProvider like a Pager or DataScroller
@@ -72,18 +72,15 @@ interface IGridProps<T> extends React.HTMLProps<HTMLTableElement> {
72
72
  * Set `showAddButton = false` if you don't want the default button.
73
73
  */
74
74
  footerButtons?: () => React.ReactNode;
75
- children: any;
76
- }
77
- interface GridPropsWithChildren<T> extends IGridProps<T> {
78
75
  children: ItemCallback<T>;
79
76
  }
80
- export default class Grid<T> extends React.Component<GridPropsWithChildren<T>> {
77
+ export default class Grid<T> extends React.Component<IGridProps<T>> {
81
78
  static contextType: React.Context<import("../../React/DataView").DataViewContextParams<unknown>>;
82
79
  context: React.ContextType<typeof DataViewContext>;
83
80
  private gridContext;
84
81
  private prevItems?;
85
82
  private headerItem;
86
- constructor(props: GridPropsWithChildren<T>);
83
+ constructor(props: IGridProps<T>);
87
84
  render(): JSX.Element;
88
85
  private setInitialSort;
89
86
  }
@@ -21,8 +21,9 @@ var Row = /** @class */ (function (_super) {
21
21
  this.context.doneStaticSetup = true;
22
22
  React.Children.forEach(this.props.children, function (child) {
23
23
  if (child) {
24
- _this.context.columnCount += (child.props ? child.props.colSpan || 1 : 1);
25
- if (child.props && (child.props.sum || child.props.footerContent)) {
24
+ var childProps = child.props;
25
+ _this.context.columnCount += (childProps ? childProps.colSpan || 1 : 1);
26
+ if (childProps && (childProps.sum || childProps.footerContent)) {
26
27
  _this.context.hasSummaries = true;
27
28
  }
28
29
  }
@@ -7,7 +7,7 @@ import { Misc, Utils } from '@singularsystems/neo-core';
7
7
  import ComponentBase from './ComponentBase';
8
8
  import { FormContext } from './FormContext';
9
9
  import { Button } from './_Exports';
10
- import { observable } from 'mobx';
10
+ import { makeObservable, observable } from 'mobx';
11
11
  var Input = /** @class */ (function (_super) {
12
12
  __extends(Input, _super);
13
13
  function Input(props) {
@@ -15,6 +15,7 @@ var Input = /** @class */ (function (_super) {
15
15
  _this.domRef = React.createRef();
16
16
  _this.showPassword = false;
17
17
  _this.onChanged = _this.onChanged.bind(_this);
18
+ makeObservable(_this);
18
19
  return _this;
19
20
  }
20
21
  Input.prototype.determineType = function () {
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { ICommonEditorProps } from './PropTypes';
3
3
  export declare class InputHelpers {
4
- static surroundWithInputGroup<T>(element: T, props: ICommonEditorProps): JSX.Element | T;
4
+ static surroundWithInputGroup<T extends React.ReactNode>(element: T, props: ICommonEditorProps): JSX.Element | T;
5
5
  }
@@ -4,6 +4,7 @@ export interface IModalPortalProps {
4
4
  show: boolean;
5
5
  onDismiss: (e: any) => void;
6
6
  options: IModalOptionsBase;
7
+ children: React.ReactNode;
7
8
  }
8
9
  export default class ModalPortal extends React.Component<IModalPortalProps> {
9
10
  private modalContainer;
@@ -2,11 +2,11 @@ import React from 'react';
2
2
  import { Data, Model, ValueObject } from '@singularsystems/neo-core';
3
3
  import { IPagerControlsProps } from './BasicPagerControls';
4
4
  import { DataViewContextParams } from '../../React/DataView';
5
- export interface IPagerBaseProps<TCriteria extends ValueObject, TModel extends Model.IBindableBase> extends React.HTMLProps<HTMLDivElement> {
5
+ export interface IPagerBaseProps<TCriteria extends ValueObject, TModel extends Model.IBindableBase> extends Omit<React.HTMLProps<HTMLDivElement>, "children"> {
6
6
  /** Page manager which controls this component. */
7
7
  pageManager: Data.PageManager<TCriteria, TModel>;
8
8
  /** Child can either be a component which works with a dataview (like Neo.Grid), or a callback which will be passed the items of the current page. */
9
- children: React.ReactNode;
9
+ children: React.ReactNode | ((items: TModel[]) => React.ReactNode);
10
10
  /** Where to put the page controls? */
11
11
  pageControls?: "none" | "top" | "bottom" | "topAndBottom";
12
12
  /** True if the built in loader component should be hidden. */
@@ -5,6 +5,7 @@ export interface ITooltipProps extends Components.Tooltip.ITooltipOptions<string
5
5
  * True if the div wrapping the content must display inline.
6
6
  */
7
7
  inline?: boolean;
8
+ children: React.ReactNode;
8
9
  }
9
10
  export default class Tooltip extends React.Component<ITooltipProps> {
10
11
  private divRef;
@@ -1,6 +1,5 @@
1
1
  import { __awaiter, __decorate, __generator, __metadata, __param } from "tslib";
2
2
  import { Routing, ModalUtils, Misc, AppServices } from '@singularsystems/neo-core';
3
- import ViewBase from '../Views/ViewBase';
4
3
  import { inject, injectable } from 'inversify';
5
4
  import { NeoReactTypes } from '../Modules/Types';
6
5
  import { RoutingState } from './RoutingState';
@@ -13,10 +12,12 @@ var PageLeaveHandler = /** @class */ (function () {
13
12
  */
14
13
  PageLeaveHandler.showNavigationConfirmation = function (prompt, callback) {
15
14
  return __awaiter(this, void 0, void 0, function () {
16
- var result;
15
+ var pageLeaveHandler, routingState, result;
17
16
  return __generator(this, function (_a) {
18
17
  switch (_a.label) {
19
- case 0: return [4 /*yield*/, Misc.Globals.appService.get(AppServices.NeoTypes.Routing.PageLeaveHandler).onLeavePage(ViewBase.currentView, prompt, Routing.NavigateLocation.Internal)];
18
+ case 0:
19
+ pageLeaveHandler = Misc.Globals.appService.get(AppServices.NeoTypes.Routing.PageLeaveHandler), routingState = Misc.Globals.appService.get(NeoReactTypes.Routing.GlobalRoutingState);
20
+ return [4 /*yield*/, pageLeaveHandler.onLeavePage(routingState.currentView, prompt, Routing.NavigateLocation.Internal)];
20
21
  case 1:
21
22
  result = _a.sent();
22
23
  callback(result);
@@ -2,7 +2,6 @@ import { __extends } from "tslib";
2
2
  import * as React from 'react';
3
3
  import { matchPath } from 'react-router';
4
4
  import { AppServices, Misc } from '@singularsystems/neo-core';
5
- import ViewBase from '../Views/ViewBase';
6
5
  import { NeoReactTypes } from '../Modules/Types';
7
6
  import { Observer } from 'mobx-react';
8
7
  var RouteView = /** @class */ (function (_super) {
@@ -49,14 +48,14 @@ var RouteView = /** @class */ (function (_super) {
49
48
  var changeProps = {
50
49
  isNewView: !currentRoute || !match || match.route !== currentRoute,
51
50
  isUnload: isUnload !== null && isUnload !== void 0 ? isUnload : false,
52
- currentView: (_a = ViewBase.currentView) !== null && _a !== void 0 ? _a : undefined,
51
+ currentView: (_a = this.routingState.currentView) !== null && _a !== void 0 ? _a : undefined,
53
52
  newRoute: match === null || match === void 0 ? void 0 : match.route,
54
53
  match: match === null || match === void 0 ? void 0 : match.match
55
54
  };
56
- if (ViewBase.currentView) {
57
- ViewBase.currentView.beforeRouteChanged(changeProps);
55
+ if (this.routingState.currentView) {
56
+ this.routingState.currentView.beforeRouteChanged(changeProps);
58
57
  if (changeProps.leavePrompt === undefined && (changeProps.isNewView || changeProps.isUnload)) {
59
- changeProps.leavePrompt = ViewBase.currentView.onLeave();
58
+ changeProps.leavePrompt = this.routingState.currentView.onLeave();
60
59
  }
61
60
  }
62
61
  this.beforeRouteChanged(changeProps);
@@ -1,5 +1,6 @@
1
1
  import { Misc } from '@singularsystems/neo-core';
2
2
  import { RouteComponentProps } from 'react-router-dom';
3
+ import { IViewBase } from '../Views/ViewBase';
3
4
  import RouteProvider, { IProcessedRoute } from './RouteProvider';
4
5
  import RouteView from './RouteView';
5
6
  export declare class RoutingState {
@@ -9,6 +10,8 @@ export declare class RoutingState {
9
10
  currentRouteView?: RouteView;
10
11
  leavePromise?: Promise<boolean> | Promise<Misc.ModalResult> | Promise<void>;
11
12
  observableRoute: IProcessedRoute | null;
13
+ currentView: IViewBase | null;
14
+ constructor();
12
15
  setCurrentRoute(routeProps: RouteComponentProps, route: IProcessedRoute): void;
13
16
  private previousRoute?;
14
17
  onRouteChanged(): void;
@@ -1,10 +1,11 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import { injectable } from 'inversify';
3
- import { observable } from 'mobx';
4
- import { ViewBase } from '../Views';
3
+ import { makeObservable, observable } from 'mobx';
5
4
  var RoutingState = /** @class */ (function () {
6
5
  function RoutingState() {
7
6
  this.observableRoute = null;
7
+ this.currentView = null;
8
+ makeObservable(this);
8
9
  }
9
10
  RoutingState.prototype.setCurrentRoute = function (routeProps, route) {
10
11
  this.currentRouteProps = routeProps;
@@ -15,16 +16,16 @@ var RoutingState = /** @class */ (function () {
15
16
  if (this.previousRoute !== this.currentRoute) {
16
17
  this.previousRoute = this.currentRoute;
17
18
  this.observableRoute = (_a = this.currentRoute) !== null && _a !== void 0 ? _a : null;
18
- if (((_b = ViewBase.currentView) === null || _b === void 0 ? void 0 : _b.constructor) !== this.currentRoute.component) {
19
- ViewBase.currentView = null;
19
+ if (((_b = this.currentView) === null || _b === void 0 ? void 0 : _b.constructor) !== this.currentRoute.component) {
20
+ this.currentView = null;
20
21
  }
21
22
  // Scroll back to top as if the browser had actually loaded a new page.
22
23
  window.scrollTo(0, 0);
23
24
  }
24
25
  else {
25
26
  // Same route, but parameters must have changed.
26
- if (ViewBase.currentView) {
27
- ViewBase.currentView.updateViewParams(this.currentRouteProps.match);
27
+ if (this.currentView) {
28
+ this.currentView.updateViewParams(this.currentRouteProps.match);
28
29
  }
29
30
  }
30
31
  };
@@ -32,8 +33,13 @@ var RoutingState = /** @class */ (function () {
32
33
  observable.ref,
33
34
  __metadata("design:type", Object)
34
35
  ], RoutingState.prototype, "observableRoute", void 0);
36
+ __decorate([
37
+ observable.ref,
38
+ __metadata("design:type", Object)
39
+ ], RoutingState.prototype, "currentView", void 0);
35
40
  RoutingState = __decorate([
36
- injectable()
41
+ injectable(),
42
+ __metadata("design:paramtypes", [])
37
43
  ], RoutingState);
38
44
  return RoutingState;
39
45
  }());
@@ -1,5 +1,5 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
- import { observable } from 'mobx';
2
+ import { makeObservable, observable } from 'mobx';
3
3
  var ViewParameter = /** @class */ (function () {
4
4
  function ViewParameter(parent, name, routeParameter) {
5
5
  this.parent = parent;
@@ -9,6 +9,7 @@ var ViewParameter = /** @class */ (function () {
9
9
  this.pendingValue = null;
10
10
  this._value = null;
11
11
  this.description = "";
12
+ makeObservable(this);
12
13
  }
13
14
  ViewParameter.prototype.bindTo = function (propertyOrCallback) {
14
15
  var _this = this;
@@ -21,9 +21,8 @@ export interface IViewBaseConstructor {
21
21
  params?: RouteParameterObject<any>;
22
22
  }
23
23
  export default abstract class ViewBase<TViewModel extends IViewModel = EmptyViewModel, TParams extends RouteParameterObject<TParams> = {}> extends React.Component implements IViewBase {
24
- /** Represents the view that is currently being displayed */
25
- static currentView: IViewBase | null;
26
24
  viewName: string;
25
+ static get currentView(): IViewBase | null;
27
26
  private routingState;
28
27
  navigation: import("../Routing").INavigationHelper;
29
28
  private breadCrumbStartItems?;
@@ -25,9 +25,17 @@ var ViewBase = /** @class */ (function (_super) {
25
25
  }
26
26
  _this.viewName = viewName;
27
27
  _this.viewState = _this.getStoredViewState(viewModel);
28
- ViewBase.currentView = _this;
28
+ _this.routingState.currentView = _this;
29
29
  return _this;
30
30
  }
31
+ Object.defineProperty(ViewBase, "currentView", {
32
+ // For backwards compatibility
33
+ get: function () {
34
+ return Misc.Globals.appService.get(NeoReactTypes.Routing.GlobalRoutingState).currentView;
35
+ },
36
+ enumerable: false,
37
+ configurable: true
38
+ });
31
39
  Object.defineProperty(ViewBase.prototype, "viewModel", {
32
40
  get: function () {
33
41
  return this.viewState.viewModel;
@@ -138,16 +146,10 @@ var ViewBase = /** @class */ (function (_super) {
138
146
  */
139
147
  ViewBase.prototype.beforeRouteChanged = function (props) {
140
148
  };
141
- /** Represents the view that is currently being displayed */
142
- ViewBase.currentView = null;
143
149
  __decorate([
144
150
  observable.ref,
145
151
  __metadata("design:type", String)
146
152
  ], ViewBase.prototype, "viewName", void 0);
147
- __decorate([
148
- observable.ref,
149
- __metadata("design:type", Object)
150
- ], ViewBase, "currentView", void 0);
151
153
  return ViewBase;
152
154
  }(React.Component));
153
155
  export default ViewBase;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singularsystems/neo-react",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.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",
@@ -20,11 +20,11 @@
20
20
  "@types/jest": "^28.1.1",
21
21
  "@types/memoize-one": "5.1.2",
22
22
  "@types/node": "17.0.15",
23
- "@types/react": "17.0.39",
23
+ "@types/react": "18.0.15",
24
24
  "@types/react-custom-scrollbars": "^4.0.6",
25
- "@types/react-dom": "17.0.11",
26
- "@types/react-router": "^5.1.17",
27
- "@types/react-router-dom": "^5.3.3",
25
+ "@types/react-dom": "18.0.6",
26
+ "@types/react-router": "5.1.18",
27
+ "@types/react-router-dom": "5.3.3",
28
28
  "jest": "28.1.1",
29
29
  "react-scripts": "5.0.1",
30
30
  "ts-jest": "28.0.4",
@@ -34,7 +34,6 @@
34
34
  "@singularsystems/neo-core": "^1.0.0-alpha.2",
35
35
  "@types/rc-slider": "^8.6.5",
36
36
  "@types/react-color": "^3.0.1",
37
- "@types/react-select": "3.1.0",
38
37
  "axios": "^0.27.2",
39
38
  "decimal.js-light": "^2.5.1",
40
39
  "history": "4.10.1",
@@ -42,19 +41,22 @@
42
41
  "memoize-one": "6.0.0",
43
42
  "mobx": "6.6.1",
44
43
  "mobx-react": "7.5.2",
45
- "react": "^17.0.2",
44
+ "react": "18.2.0",
46
45
  "react-custom-scrollbars": "^4.2.1",
47
- "react-dom": "^17.0.2",
48
- "react-router": "^5.2.1",
49
- "react-router-dom": "^5.3.0",
46
+ "react-dom": "18.2.0",
47
+ "react-router": "5.3.3",
48
+ "react-router-dom": "5.3.3",
49
+ "react-select": "5.4.0",
50
50
  "tslib": "2.3.1"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@singularsystems/neo-core": ">=1.0.0",
54
54
  "axios": ">=0.21.1",
55
55
  "inversify": ">=5.0.1",
56
- "react": ">=16.8.0",
57
- "react-dom": ">=16.8.0",
56
+ "mobx": ">=6.6.1",
57
+ "mobx-react": ">=7.5.2",
58
+ "react": ">=18.2.0",
59
+ "react-dom": ">=18.2.0",
58
60
  "react-router": "^5.0.0",
59
61
  "react-router-dom": "^5.0.0"
60
62
  },