@singularsystems/neo-react 0.10.49 → 0.10.50

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 (35) hide show
  1. package/dist/Modules/NeoReactModule.js +2 -0
  2. package/dist/Modules/Types.d.ts +2 -0
  3. package/dist/Modules/Types.js +1 -0
  4. package/dist/ReactComponents/Button.d.ts +1 -0
  5. package/dist/ReactComponents/Button.js +12 -4
  6. package/dist/ReactComponents/Card.d.ts +1 -0
  7. package/dist/ReactComponents/Card.js +4 -2
  8. package/dist/ReactComponents/ContextMenu/ContextMenu.d.ts +1 -0
  9. package/dist/ReactComponents/ContextMenu/ContextMenu.js +5 -3
  10. package/dist/ReactComponents/IconFactory.d.ts +27 -0
  11. package/dist/ReactComponents/IconFactory.js +46 -0
  12. package/dist/ReactComponents/Icons/FontAwesomeIconFactory.d.ts +11 -0
  13. package/dist/ReactComponents/Icons/FontAwesomeIconFactory.js +35 -0
  14. package/dist/ReactComponents/Icons/IIconFactory.d.ts +21 -0
  15. package/dist/ReactComponents/Icons/IIconFactory.js +0 -0
  16. package/dist/ReactComponents/Icons/IconFactory.d.ts +9 -0
  17. package/dist/ReactComponents/Icons/IconFactory.js +47 -0
  18. package/dist/ReactComponents/Icons/index.d.ts +3 -0
  19. package/dist/ReactComponents/Icons/index.js +2 -0
  20. package/dist/ReactComponents/InputHelpers.d.ts +1 -0
  21. package/dist/ReactComponents/InputHelpers.js +7 -11
  22. package/dist/ReactComponents/Notifications/Alert.d.ts +1 -0
  23. package/dist/ReactComponents/Notifications/Alert.js +6 -3
  24. package/dist/ReactComponents/Notifications/Toast.d.ts +1 -0
  25. package/dist/ReactComponents/Notifications/Toast.js +4 -2
  26. package/dist/ReactComponents/Paging/BasicPagerControls.d.ts +1 -0
  27. package/dist/ReactComponents/Paging/BasicPagerControls.js +8 -6
  28. package/dist/ReactComponents/Tabs/Tab.d.ts +1 -0
  29. package/dist/ReactComponents/Tabs/Tab.js +6 -7
  30. package/dist/ReactComponents/ValidationSummary.d.ts +1 -0
  31. package/dist/ReactComponents/ValidationSummary.js +7 -4
  32. package/dist/index.d.ts +2 -1
  33. package/dist/index.js +2 -1
  34. package/package.json +3 -2
  35. package/styles/Validation.scss +0 -9
@@ -11,6 +11,7 @@ import { RoutingState } from '../Routing/RoutingState';
11
11
  import { ContextMenuState } from '../ReactComponents/ContextMenu/ContextMenuState';
12
12
  import { DisposeHelper } from '../Services/DisposeHelper';
13
13
  import Decimal from 'decimal.js-light';
14
+ import { IconFactory } from '../ReactComponents/Icons/IconFactory';
14
15
  var neoReactModule = new AppServices.Module("neo-react", function (container) {
15
16
  container.bind(AppServices.NeoTypes.Core.AutoRunnerFactory).to(AutoRunnerFactory).inSingletonScope();
16
17
  container.bind(AppServices.NeoTypes.Core.ModelCreator).to(ReactModelCreator).inTransientScope();
@@ -18,6 +19,7 @@ var neoReactModule = new AppServices.Module("neo-react", function (container) {
18
19
  container.bind(AppServices.NeoTypes.UI.ErrorHandler).to(ErrorHandler).inSingletonScope();
19
20
  container.bind(AppServices.NeoTypes.UI.GlobalContextMenuState).toConstantValue(new ContextMenuState());
20
21
  container.bind(AppServices.NeoTypes.Routing.PageLeaveHandler).to(PageLeaveHandler).inSingletonScope();
22
+ container.bind(NeoReactTypes.Components.IconFactory).to(IconFactory).inSingletonScope();
21
23
  container.bind(NeoReactTypes.Routing.GlobalRoutingState).to(RoutingState).inSingletonScope();
22
24
  container.bind(NeoReactTypes.Routing.NavigationHelper).to(NavigationHelper).inSingletonScope();
23
25
  container.bind(NeoReactTypes.Services.DisposeHelper).to(DisposeHelper).inTransientScope();
@@ -8,6 +8,7 @@ import { AxiosStatic } from 'axios';
8
8
  import Decimal from 'decimal.js-light';
9
9
  import Select from 'react-select';
10
10
  import { IDisposeHelper } from '../Services/IDisposeHelper';
11
+ import { IIconFactory } from '../ReactComponents/Icons/IIconFactory';
11
12
  declare const NeoReactTypes: {
12
13
  Components: {
13
14
  Slider: AppServices.ServiceIdentifier<typeof Slider>;
@@ -15,6 +16,7 @@ declare const NeoReactTypes: {
15
16
  SketchPicker: AppServices.ServiceIdentifier<typeof SketchPicker>;
16
17
  ReactSelect: AppServices.ServiceIdentifier<typeof Select>;
17
18
  AsyncSelect: AppServices.ServiceIdentifier<typeof AsyncSelect>;
19
+ IconFactory: AppServices.ServiceIdentifier<IIconFactory>;
18
20
  };
19
21
  Routing: {
20
22
  NavigationHelper: AppServices.ServiceIdentifier<INavigationHelper>;
@@ -6,6 +6,7 @@ var NeoReactTypes = __assign(__assign({}, AppServices.NeoTypes), { Components: {
6
6
  SketchPicker: new AppServices.ServiceIdentifier("NeoReact.SketchPicker"),
7
7
  ReactSelect: new AppServices.ServiceIdentifier("NeoReact.ReactSelect"),
8
8
  AsyncSelect: new AppServices.ServiceIdentifier("NeoReact.AsyncSelect"),
9
+ IconFactory: new AppServices.ServiceIdentifier("NeoReact.IconFactory")
9
10
  }, Routing: __assign(__assign({}, AppServices.NeoTypes.Routing), { NavigationHelper: AppServices.NeoTypes.Routing.NavigationHelper.asType(), GlobalRoutingState: new AppServices.ServiceIdentifier("NeoReact.GlobalRoutingState") }), Services: {
10
11
  DisposeHelper: new AppServices.ServiceIdentifier("NeoReact.DisposeHelper")
11
12
  } });
@@ -11,6 +11,7 @@ export default class Button extends ComponentBase<IButtonProps, IButtonState> {
11
11
  };
12
12
  btnGroupDom: React.RefObject<HTMLDivElement>;
13
13
  menuDom: React.RefObject<HTMLDivElement>;
14
+ private iconFactory;
14
15
  private windowClickHandler;
15
16
  constructor(props: IButtonProps);
16
17
  private showMenu;
@@ -1,9 +1,10 @@
1
1
  import { __decorate, __extends, __metadata, __rest, __spreadArrays } from "tslib";
2
2
  import * as React from 'react';
3
3
  import ComponentBase from './ComponentBase';
4
- import { Components, Utils } from '@singularsystems/neo-core';
4
+ import { Components, Misc, Utils } from '@singularsystems/neo-core';
5
5
  import Tooltip from './Tooltip';
6
6
  import { observer } from 'mobx-react';
7
+ import { NeoReactTypes } from '../Modules/Types';
7
8
  var Button = /** @class */ (function (_super) {
8
9
  __extends(Button, _super);
9
10
  function Button(props) {
@@ -11,6 +12,7 @@ var Button = /** @class */ (function (_super) {
11
12
  _this.state = { isExpanded: false };
12
13
  _this.btnGroupDom = React.createRef();
13
14
  _this.menuDom = React.createRef();
15
+ _this.iconFactory = Misc.Globals.appService.get(NeoReactTypes.Components.IconFactory);
14
16
  _this.windowClickHandler = _this.windowClicked.bind(_this);
15
17
  _this.showMenu = _this.showMenu.bind(_this);
16
18
  return _this;
@@ -60,8 +62,14 @@ var Button = /** @class */ (function (_super) {
60
62
  buttonClasses += " dropdown-toggle";
61
63
  native.onClick = this.showMenu;
62
64
  }
65
+ var iconStyle = {};
66
+ if (isBusy !== undefined || task !== undefined) {
67
+ iconStyle = { fixedWidth: true };
68
+ }
63
69
  if (isBusy || ((_a = task) === null || _a === void 0 ? void 0 : _a.isBusy)) {
64
- icon = "fa-circle-notch fa-spin";
70
+ iconStyle.fixedWidth = true;
71
+ iconStyle.spin = true;
72
+ icon = Misc.Settings.icons.loadingIcon;
65
73
  native.disabled = true;
66
74
  }
67
75
  if (pulse) {
@@ -74,7 +82,7 @@ var Button = /** @class */ (function (_super) {
74
82
  innerText = text;
75
83
  var iconSpace = icon && innerText ? " " : "";
76
84
  // Icon
77
- var iconElement = icon ? React.createElement("i", { className: Utils.getFontAwesomeClass(icon) }) : undefined;
85
+ var iconElement = this.iconFactory.getIconComponent(icon, iconStyle);
78
86
  // Tooltip
79
87
  if (tooltip) {
80
88
  Tooltip.setDomProperties(native, tooltip);
@@ -101,7 +109,7 @@ var Button = /** @class */ (function (_super) {
101
109
  var menu = React.createElement("div", { className: "dropdown-menu" + (this.state.isExpanded ? " show" : ""), ref: this.menuDom }, menuItems.map(function (item, index) { return (item.header ? React.createElement("h6", { key: index, className: "dropdown-header" }, item.header)
102
110
  : item.isDivider ? React.createElement("div", { key: index, className: "dropdown-divider" })
103
111
  : React.createElement("div", { key: index, className: "dropdown-item", onClick: function (e) { return _this.menuItemClicked(e, item.data, item.onClick); } },
104
- item.icon && React.createElement("i", { className: Utils.getFontAwesomeClass(item.icon) + " fa-fw" }),
112
+ _this.iconFactory.getIconComponent(item.icon, { fixedWidth: true }),
105
113
  " ",
106
114
  item.text)); }));
107
115
  root =
@@ -17,6 +17,7 @@ interface ICardProps {
17
17
  isExpanded?: Model.IObservableValue<boolean>;
18
18
  }
19
19
  export default class Card extends React.Component<ICardProps & React.HTMLProps<HTMLDivElement>> {
20
+ private iconFactory;
20
21
  private expandState;
21
22
  render(): JSX.Element;
22
23
  }
@@ -1,13 +1,15 @@
1
1
  import { __assign, __decorate, __extends, __rest } from "tslib";
2
2
  import React from 'react';
3
- import { Model, Utils } from '@singularsystems/neo-core';
3
+ import { Misc, Model, Utils } from '@singularsystems/neo-core';
4
4
  import { observer } from 'mobx-react';
5
5
  import Scrollbar from 'react-custom-scrollbars';
6
6
  import Collapsable from './Collapsable';
7
+ import { NeoReactTypes } from '../Modules/Types';
7
8
  var Card = /** @class */ (function (_super) {
8
9
  __extends(Card, _super);
9
10
  function Card() {
10
11
  var _this = _super !== null && _super.apply(this, arguments) || this;
12
+ _this.iconFactory = Misc.Globals.appService.get(NeoReactTypes.Components.IconFactory);
11
13
  _this.expandState = new Model.ObservableValue(_this.props.initiallyCollapsed === undefined ? true : !_this.props.initiallyCollapsed);
12
14
  return _this;
13
15
  }
@@ -41,7 +43,7 @@ var Card = /** @class */ (function (_super) {
41
43
  (icon || title) &&
42
44
  React.createElement("div", { className: "card-header" },
43
45
  React.createElement("div", { className: "card-header-title" },
44
- icon && React.createElement("i", { className: Utils.getFontAwesomeClass(icon) }),
46
+ this.iconFactory.getIconComponent(icon),
45
47
  React.createElement("span", null, title)),
46
48
  headerElements && React.createElement("div", { className: "card-header-right-section" }, headerElements)),
47
49
  body));
@@ -16,6 +16,7 @@ export interface IContextMenuProps {
16
16
  }
17
17
  export default class ContextMenu extends ComponentBase<IContextMenuProps> {
18
18
  constructor(props: IContextMenuProps);
19
+ private iconFactory;
19
20
  private menuRef;
20
21
  private hoverItem;
21
22
  mouseEnter(e: React.MouseEvent<HTMLDivElement>, item: Components.IMenuItem): void;
@@ -2,12 +2,14 @@ import { __decorate, __extends, __metadata } from "tslib";
2
2
  import React from 'react';
3
3
  import { observable } from 'mobx';
4
4
  import { observer } from 'mobx-react';
5
- import { Utils } from '@singularsystems/neo-core';
5
+ import { Misc } from '@singularsystems/neo-core';
6
6
  import ComponentBase from '../ComponentBase';
7
+ import { NeoReactTypes } from '../../Modules/Types';
7
8
  var ContextMenu = /** @class */ (function (_super) {
8
9
  __extends(ContextMenu, _super);
9
10
  function ContextMenu(props) {
10
11
  var _this = _super.call(this, props) || this;
12
+ _this.iconFactory = Misc.Globals.appService.get(NeoReactTypes.Components.IconFactory);
11
13
  _this.menuRef = React.createRef();
12
14
  _this.hoverItem = null;
13
15
  _this.mouseEnter = _this.mouseEnter.bind(_this);
@@ -67,8 +69,8 @@ var ContextMenu = /** @class */ (function (_super) {
67
69
  } },
68
70
  item.isDivider && React.createElement("hr", null),
69
71
  !item.isDivider && React.createElement(React.Fragment, null,
70
- !item.icon && React.createElement("i", { className: "fa fa-fw" }),
71
- item.icon && React.createElement("i", { className: "fa-fw " + Utils.getFontAwesomeClass(item.icon) }),
72
+ !item.icon && _this.iconFactory.getIconComponent("", { fixedWidth: true }),
73
+ item.icon && _this.iconFactory.getIconComponent(item.icon, { fixedWidth: true }),
72
74
  item.text && React.createElement("span", { className: "neo-context-menu-text" }, item.text),
73
75
  item.header && React.createElement("span", { className: "neo-context-menu-text" }, item.header),
74
76
  item.items && React.createElement("i", { className: "fa-fw fa fa-angle-right child-indicator" }),
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+ export interface IconStyle {
3
+ fixedWidth?: boolean;
4
+ spin?: boolean;
5
+ }
6
+ export interface IIconFactory {
7
+ /**
8
+ * Returns a component that renders an icon.
9
+ * @param iconOrName If this is a string, it is treated as an icon name. Otherwise it is treated as the icon component.
10
+ *
11
+ * The default neo icon factory maps icon names to font-awesome icons.
12
+ */
13
+ getIconComponent(iconOrName: any, style?: IconStyle): React.ReactNode | undefined;
14
+ /**
15
+ * Returns the original text, or an icon for specific prefixes.
16
+ * @param textOrIcon If textOrIcon starts with a specific prefix, this will return an icon component, otherwise it will return text.
17
+ *
18
+ * By default the neo icon factory will return a font-awesome icon if the prefix is fa- or far-
19
+ */
20
+ textOrIcon(textOrIcon: string, style?: IconStyle): React.ReactNode | string;
21
+ }
22
+ export declare class IconFactory implements IIconFactory {
23
+ getIconComponent(iconOrName: any, style?: IconStyle): import("history").History.PoorMansUnknown;
24
+ textOrIcon(textOrIcon: string, style?: IconStyle): import("history").History.PoorMansUnknown;
25
+ protected mapStringToIcon(iconName: string, style?: IconStyle): React.ReactNode;
26
+ protected createIconComponent(iconDescriptor: any, style?: IconStyle): React.ReactNode;
27
+ }
@@ -0,0 +1,46 @@
1
+ import { __decorate } from "tslib";
2
+ import { Utils } from "@singularsystems/neo-core";
3
+ import React from "react";
4
+ import { injectable } from 'inversify';
5
+ var IconFactory = /** @class */ (function () {
6
+ function IconFactory() {
7
+ }
8
+ IconFactory.prototype.getIconComponent = function (iconOrName, style) {
9
+ if (iconOrName) {
10
+ if (typeof iconOrName === "string") {
11
+ return this.mapStringToIcon(iconOrName, style);
12
+ }
13
+ else {
14
+ return this.createIconComponent(iconOrName, style);
15
+ }
16
+ }
17
+ return undefined;
18
+ };
19
+ IconFactory.prototype.textOrIcon = function (textOrIcon, style) {
20
+ if (textOrIcon.indexOf("fa-") === 0 || textOrIcon.indexOf("far-") === 0) {
21
+ return this.getIconComponent(textOrIcon, style);
22
+ }
23
+ else {
24
+ return textOrIcon;
25
+ }
26
+ };
27
+ IconFactory.prototype.mapStringToIcon = function (iconName, style) {
28
+ var _a, _b;
29
+ var className = Utils.getFontAwesomeClass(iconName);
30
+ if ((_a = style) === null || _a === void 0 ? void 0 : _a.fixedWidth) {
31
+ className += " fa-fw";
32
+ }
33
+ if ((_b = style) === null || _b === void 0 ? void 0 : _b.spin) {
34
+ className += " fa-spin";
35
+ }
36
+ return React.createElement("i", { className: className });
37
+ };
38
+ IconFactory.prototype.createIconComponent = function (iconDescriptor, style) {
39
+ return iconDescriptor;
40
+ };
41
+ IconFactory = __decorate([
42
+ injectable()
43
+ ], IconFactory);
44
+ return IconFactory;
45
+ }());
46
+ export { IconFactory };
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { IconFactory } from "./IconFactory";
3
+ import { IconStyle } from "./IIconFactory";
4
+ interface IconDefinition {
5
+ icon: string;
6
+ }
7
+ /** Icon factory supporting font-awesome string, as well as the font-awesome icon definition and component. */
8
+ export declare class FontAwesomeIconFactory extends IconFactory {
9
+ protected createIconComponent(iconComponent: IconDefinition | JSX.Element, iconStyle?: IconStyle): React.ReactNode;
10
+ }
11
+ export {};
@@ -0,0 +1,35 @@
1
+ import { __assign, __decorate, __extends } from "tslib";
2
+ import React from "react";
3
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
4
+ import { injectable } from "inversify";
5
+ import { IconFactory } from "./IconFactory";
6
+ /** Icon factory supporting font-awesome string, as well as the font-awesome icon definition and component. */
7
+ var FontAwesomeIconFactory = /** @class */ (function (_super) {
8
+ __extends(FontAwesomeIconFactory, _super);
9
+ function FontAwesomeIconFactory() {
10
+ return _super !== null && _super.apply(this, arguments) || this;
11
+ }
12
+ FontAwesomeIconFactory.prototype.createIconComponent = function (iconComponent, iconStyle) {
13
+ var _a, _b, _c, _d;
14
+ if (iconComponent.icon) {
15
+ // Icon was specified using a font-awesome icon descriptor, return the font-awesome icon component.
16
+ return React.createElement(FontAwesomeIcon, { icon: iconComponent, fixedWidth: (_a = iconStyle) === null || _a === void 0 ? void 0 : _a.fixedWidth, spin: (_b = iconStyle) === null || _b === void 0 ? void 0 : _b.spin });
17
+ }
18
+ else {
19
+ // Icon was specified as a font-awesome component. Extract the props, and override using the requested style.
20
+ var props = __assign({}, iconComponent.props);
21
+ if ((_c = iconStyle) === null || _c === void 0 ? void 0 : _c.fixedWidth) {
22
+ props.fixedWidth = iconStyle.fixedWidth;
23
+ }
24
+ if ((_d = iconStyle) === null || _d === void 0 ? void 0 : _d.spin) {
25
+ props.spin = iconStyle.spin;
26
+ }
27
+ return React.createElement(iconComponent.type, props);
28
+ }
29
+ };
30
+ FontAwesomeIconFactory = __decorate([
31
+ injectable()
32
+ ], FontAwesomeIconFactory);
33
+ return FontAwesomeIconFactory;
34
+ }(IconFactory));
35
+ export { FontAwesomeIconFactory };
@@ -0,0 +1,21 @@
1
+ /// <reference types="react" />
2
+ export interface IconStyle {
3
+ fixedWidth?: boolean;
4
+ spin?: boolean;
5
+ }
6
+ export interface IIconFactory {
7
+ /**
8
+ * Returns a component that renders an icon.
9
+ * @param iconOrName If this is a string, it is treated as an icon name. Otherwise it is treated as the icon component.
10
+ *
11
+ * The default neo icon factory maps icon names to font-awesome icons.
12
+ */
13
+ getIconComponent(iconOrName: any, style?: IconStyle): React.ReactNode | undefined;
14
+ /**
15
+ * Returns the original text, or an icon for specific prefixes.
16
+ * @param textOrIcon If textOrIcon starts with a specific prefix, this will return an icon component, otherwise it will return text.
17
+ *
18
+ * By default the neo icon factory will return a font-awesome icon if the prefix is fa- or far-
19
+ */
20
+ textOrIcon(textOrIcon: string, style?: IconStyle): React.ReactNode | string;
21
+ }
File without changes
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { IconStyle, IIconFactory } from "./IIconFactory";
3
+ /** Default icon factory supporting font-awesome strings. */
4
+ export declare class IconFactory implements IIconFactory {
5
+ getIconComponent(iconOrName: any, style?: IconStyle): import("history").History.PoorMansUnknown;
6
+ textOrIcon(textOrIcon: string, style?: IconStyle): import("history").History.PoorMansUnknown;
7
+ protected mapStringToIcon(iconName: string, style?: IconStyle): React.ReactNode;
8
+ protected createIconComponent(iconDescriptor: any, style?: IconStyle): React.ReactNode;
9
+ }
@@ -0,0 +1,47 @@
1
+ import { __decorate } from "tslib";
2
+ import { Utils } from "@singularsystems/neo-core";
3
+ import React from "react";
4
+ import { injectable } from 'inversify';
5
+ /** Default icon factory supporting font-awesome strings. */
6
+ var IconFactory = /** @class */ (function () {
7
+ function IconFactory() {
8
+ }
9
+ IconFactory.prototype.getIconComponent = function (iconOrName, style) {
10
+ if (iconOrName !== undefined) {
11
+ if (typeof iconOrName === "string") {
12
+ return this.mapStringToIcon(iconOrName, style);
13
+ }
14
+ else {
15
+ return this.createIconComponent(iconOrName, style);
16
+ }
17
+ }
18
+ return undefined;
19
+ };
20
+ IconFactory.prototype.textOrIcon = function (textOrIcon, style) {
21
+ if (textOrIcon.indexOf("fa-") === 0 || textOrIcon.indexOf("far-") === 0) {
22
+ return this.getIconComponent(textOrIcon, style);
23
+ }
24
+ else {
25
+ return textOrIcon;
26
+ }
27
+ };
28
+ IconFactory.prototype.mapStringToIcon = function (iconName, style) {
29
+ var _a, _b;
30
+ var className = Utils.getFontAwesomeClass(iconName);
31
+ if ((_a = style) === null || _a === void 0 ? void 0 : _a.fixedWidth) {
32
+ className += " fa-fw";
33
+ }
34
+ if ((_b = style) === null || _b === void 0 ? void 0 : _b.spin) {
35
+ className += " fa-spin";
36
+ }
37
+ return React.createElement("i", { className: className });
38
+ };
39
+ IconFactory.prototype.createIconComponent = function (iconDescriptor, style) {
40
+ return iconDescriptor;
41
+ };
42
+ IconFactory = __decorate([
43
+ injectable()
44
+ ], IconFactory);
45
+ return IconFactory;
46
+ }());
47
+ export { IconFactory };
@@ -0,0 +1,3 @@
1
+ export { IIconFactory, IconStyle } from './IIconFactory';
2
+ export { IconFactory } from './IconFactory';
3
+ export { FontAwesomeIconFactory } from './FontAwesomeIconFactory';
@@ -0,0 +1,2 @@
1
+ export { IconFactory } from './IconFactory';
2
+ export { FontAwesomeIconFactory } from './FontAwesomeIconFactory';
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { ICommonEditorProps } from './PropTypes';
3
3
  export declare class InputHelpers {
4
+ private static iconFactory?;
4
5
  static surroundWithInputGroup<T>(element: T, props: ICommonEditorProps): JSX.Element | T;
5
6
  }
@@ -1,28 +1,24 @@
1
1
  import * as React from 'react';
2
- import { Utils } from '@singularsystems/neo-core';
2
+ import { Misc } from '@singularsystems/neo-core';
3
+ import { NeoReactTypes } from '../Modules/Types';
3
4
  var InputHelpers = /** @class */ (function () {
4
5
  function InputHelpers() {
5
6
  }
6
7
  InputHelpers.surroundWithInputGroup = function (element, props) {
8
+ if (!this.iconFactory) {
9
+ this.iconFactory = Misc.Globals.appService.get(NeoReactTypes.Components.IconFactory);
10
+ }
7
11
  if (props.requiresGroup) {
8
- var preIcon = void 0;
9
- var appendIcon = void 0;
10
- if (props.prependText && (props.prependText.startsWith("fa-") || props.prependText.startsWith("far-"))) {
11
- preIcon = Utils.getFontAwesomeClass(props.prependText);
12
- }
13
- if (props.appendText && (props.appendText.startsWith("fa-") || props.appendText.startsWith("far-"))) {
14
- appendIcon = Utils.getFontAwesomeClass(props.appendText);
15
- }
16
12
  return (React.createElement("div", { className: "input-group" },
17
13
  (props.prependText || props.prepend) &&
18
14
  React.createElement("div", { className: "input-group-prepend" },
19
15
  props.prepend && (props.prepend instanceof Function ? props.prepend() : props.prepend),
20
- props.prependText && React.createElement("span", { className: "input-group-text" }, preIcon ? React.createElement("i", { className: preIcon }) : props.prependText)),
16
+ props.prependText && React.createElement("span", { className: "input-group-text" }, this.iconFactory.textOrIcon(props.prependText))),
21
17
  element,
22
18
  (props.appendText || props.append) &&
23
19
  React.createElement("div", { className: "input-group-append" },
24
20
  props.append && (props.append instanceof Function ? props.append() : props.append),
25
- props.appendText && React.createElement("span", { className: "input-group-text" }, appendIcon ? React.createElement("i", { className: appendIcon }) : props.appendText))));
21
+ props.appendText && React.createElement("span", { className: "input-group-text" }, this.iconFactory.textOrIcon(props.appendText)))));
26
22
  }
27
23
  else {
28
24
  return element;
@@ -2,5 +2,6 @@ import React from "react";
2
2
  import { Components } from "@singularsystems/neo-core";
3
3
  import CollapsableBase from '../CollapsableBase';
4
4
  export default class Alert extends CollapsableBase<Components.INotificationOptions & React.HTMLProps<HTMLDivElement>> {
5
+ private iconFactory;
5
6
  render(): JSX.Element;
6
7
  }
@@ -1,12 +1,15 @@
1
1
  import { __assign, __decorate, __extends, __rest } from "tslib";
2
2
  import React from "react";
3
- import { Utils } from "@singularsystems/neo-core";
3
+ import { Misc, Utils } from "@singularsystems/neo-core";
4
4
  import { observer } from 'mobx-react';
5
5
  import CollapsableBase from '../CollapsableBase';
6
+ import { NeoReactTypes } from "../../Modules/Types";
6
7
  var Alert = /** @class */ (function (_super) {
7
8
  __extends(Alert, _super);
8
9
  function Alert() {
9
- return _super !== null && _super.apply(this, arguments) || this;
10
+ var _this = _super !== null && _super.apply(this, arguments) || this;
11
+ _this.iconFactory = Misc.Globals.appService.get(NeoReactTypes.Components.IconFactory);
12
+ return _this;
10
13
  }
11
14
  Alert.prototype.render = function () {
12
15
  var _a = this.props, variant = _a.variant, heading = _a.heading, show = _a.show, bindShow = _a.bindShow, autoCloseTimeout = _a.autoCloseTimeout, animateInitial = _a.animateInitial, state = _a.state, onHidden = _a.onHidden, refreshValue = _a.refreshValue, icon = _a.icon, native = __rest(_a, ["variant", "heading", "show", "bindShow", "autoCloseTimeout", "animateInitial", "state", "onHidden", "refreshValue", "icon"]);
@@ -20,7 +23,7 @@ var Alert = /** @class */ (function (_super) {
20
23
  React.createElement("h6", null, heading),
21
24
  icon &&
22
25
  React.createElement("div", { className: "notification-icon-container" },
23
- React.createElement("i", { className: Utils.getFontAwesomeClass(icon) }),
26
+ this.iconFactory.getIconComponent(icon),
24
27
  React.createElement("div", null, this.props.children)),
25
28
  !icon && this.props.children,
26
29
  bindShow &&
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import CollapsableBase from '../CollapsableBase';
3
3
  import { Components } from '@singularsystems/neo-core';
4
4
  export default class Toast extends CollapsableBase<Components.INotificationOptions & React.HTMLProps<HTMLDivElement>> {
5
+ private iconFactory;
5
6
  countDownRef: React.RefObject<HTMLDivElement>;
6
7
  afterRender(isInitial: boolean): void;
7
8
  render(): JSX.Element;
@@ -2,11 +2,13 @@ import { __decorate, __extends } from "tslib";
2
2
  import React from 'react';
3
3
  import CollapsableBase from '../CollapsableBase';
4
4
  import { observer } from 'mobx-react';
5
- import { Components, Utils } from '@singularsystems/neo-core';
5
+ import { Components, Misc } from '@singularsystems/neo-core';
6
+ import { NeoReactTypes } from '../../Modules/Types';
6
7
  var Toast = /** @class */ (function (_super) {
7
8
  __extends(Toast, _super);
8
9
  function Toast() {
9
10
  var _this = _super !== null && _super.apply(this, arguments) || this;
11
+ _this.iconFactory = Misc.Globals.appService.get(NeoReactTypes.Components.IconFactory);
10
12
  _this.countDownRef = React.createRef();
11
13
  return _this;
12
14
  }
@@ -33,7 +35,7 @@ var Toast = /** @class */ (function (_super) {
33
35
  this.props.autoCloseTimeout && React.createElement("div", { className: "toast-count-down toast-count-down-" + variant, ref: this.countDownRef }),
34
36
  React.createElement("div", { className: "toast-body" },
35
37
  icon && React.createElement("div", { className: "notification-icon-container" },
36
- React.createElement("i", { className: Utils.getFontAwesomeClass(icon) }),
38
+ this.iconFactory.getIconComponent(icon),
37
39
  React.createElement("div", null, this.props.children)),
38
40
  !icon && this.props.children)));
39
41
  };
@@ -21,5 +21,6 @@ export interface IPagerControlsProps extends React.HTMLProps<HTMLUListElement> {
21
21
  pageSizeLabel?: string | JSX.Element;
22
22
  }
23
23
  export default class SimplePagerControls extends React.Component<IPagerControlsProps> {
24
+ private iconFactory;
24
25
  render(): false | JSX.Element;
25
26
  }
@@ -1,13 +1,15 @@
1
1
  import { __assign, __decorate, __extends, __rest } from "tslib";
2
2
  import React from 'react';
3
3
  import { Misc, Utils } from "@singularsystems/neo-core";
4
- import { ReactHelpers } from '../ReactHelpers';
5
4
  import { observer } from "mobx-react";
6
5
  import PageSizeControl from './PageSizeControl';
6
+ import { NeoReactTypes } from '../../Modules/Types';
7
7
  var SimplePagerControls = /** @class */ (function (_super) {
8
8
  __extends(SimplePagerControls, _super);
9
9
  function SimplePagerControls() {
10
- return _super !== null && _super.apply(this, arguments) || this;
10
+ var _this = _super !== null && _super.apply(this, arguments) || this;
11
+ _this.iconFactory = Misc.Globals.appService.get(NeoReactTypes.Components.IconFactory);
12
+ return _this;
11
13
  }
12
14
  SimplePagerControls.prototype.render = function () {
13
15
  var _a = this.props, pageManager = _a.pageManager, noOfButtons = _a.noOfButtons, alignment = _a.alignment, firstText = _a.firstText, prevText = _a.prevText, nextText = _a.nextText, lastText = _a.lastText, autoHide = _a.autoHide, pageSizeLabel = _a.pageSizeLabel, domProps = __rest(_a, ["pageManager", "noOfButtons", "alignment", "firstText", "prevText", "nextText", "lastText", "autoHide", "pageSizeLabel"]);
@@ -38,14 +40,14 @@ var SimplePagerControls = /** @class */ (function (_super) {
38
40
  pageSizeLabel && React.createElement(PageSizeControl, { pageManager: this.props.pageManager, label: pageSizeLabel }),
39
41
  React.createElement("ul", __assign({}, domProps, { className: "pagination" }),
40
42
  React.createElement("li", { className: "page-item" + (pageManager.pageNo === 1 ? " disabled" : "") },
41
- React.createElement("a", { className: "page-link", href: "#", onClick: function (e) { e.preventDefault(); pageManager.firstPage(); } }, ReactHelpers.textOrIcon(firstText))),
43
+ React.createElement("a", { className: "page-link", href: "#", onClick: function (e) { e.preventDefault(); pageManager.firstPage(); } }, this.iconFactory.textOrIcon(firstText))),
42
44
  React.createElement("li", { className: "page-item" + (pageManager.pageNo === 1 ? " disabled" : "") },
43
- React.createElement("a", { className: "page-link", href: "#", onClick: function (e) { e.preventDefault(); pageManager.previousPage(); } }, ReactHelpers.textOrIcon(prevText))),
45
+ React.createElement("a", { className: "page-link", href: "#", onClick: function (e) { e.preventDefault(); pageManager.previousPage(); } }, this.iconFactory.textOrIcon(prevText))),
44
46
  buttons,
45
47
  React.createElement("li", { className: "page-item" + (pageManager.pageNo === pageManager.totalPages ? " disabled" : "") },
46
- React.createElement("a", { className: "page-link", href: "#", onClick: function (e) { e.preventDefault(); pageManager.nextPage(); } }, ReactHelpers.textOrIcon(nextText))),
48
+ React.createElement("a", { className: "page-link", href: "#", onClick: function (e) { e.preventDefault(); pageManager.nextPage(); } }, this.iconFactory.textOrIcon(nextText))),
47
49
  React.createElement("li", { className: "page-item" + (pageManager.pageNo === pageManager.totalPages ? " disabled" : "") },
48
- React.createElement("a", { className: "page-link", href: "#", onClick: function (e) { e.preventDefault(); pageManager.lastPage(); } }, ReactHelpers.textOrIcon(lastText))))));
50
+ React.createElement("a", { className: "page-link", href: "#", onClick: function (e) { e.preventDefault(); pageManager.lastPage(); } }, this.iconFactory.textOrIcon(lastText))))));
49
51
  };
50
52
  SimplePagerControls = __decorate([
51
53
  observer
@@ -29,6 +29,7 @@ export default class Tab extends React.Component<ITabProps> {
29
29
  private isHeader?;
30
30
  private tabKey;
31
31
  private hasRenderedContents;
32
+ private iconFactory;
32
33
  constructor(props: ITabProps);
33
34
  componentDidMount(): void;
34
35
  render(): false | JSX.Element;
@@ -2,13 +2,15 @@ import { __decorate, __extends, __metadata } from "tslib";
2
2
  import React from "react";
3
3
  import { observer } from "mobx-react";
4
4
  import { TabContext } from "./TabContainer";
5
- import { Utils } from "@singularsystems/neo-core";
5
+ import { Misc } from "@singularsystems/neo-core";
6
+ import { NeoReactTypes } from "../../Modules/Types";
6
7
  var Tab = /** @class */ (function (_super) {
7
8
  __extends(Tab, _super);
8
9
  function Tab(props) {
9
10
  var _a;
10
11
  var _this = _super.call(this, props) || this;
11
12
  _this.hasRenderedContents = false;
13
+ _this.iconFactory = Misc.Globals.appService.get(NeoReactTypes.Components.IconFactory);
12
14
  _this.onClick = _this.onClick.bind(_this);
13
15
  var tabKey = (_a = _this.props.id, (_a !== null && _a !== void 0 ? _a : _this.props.name));
14
16
  if (!tabKey) {
@@ -44,14 +46,11 @@ var Tab = /** @class */ (function (_super) {
44
46
  }
45
47
  };
46
48
  Tab.prototype.renderHeader = function (isSelected) {
47
- var iconClass = "";
48
- if (this.props.icon) {
49
- iconClass = Utils.getFontAwesomeClass(this.props.icon);
50
- }
49
+ var hasIcon = this.props.icon !== undefined;
51
50
  return (React.createElement("li", { className: "nav-item" },
52
51
  React.createElement("a", { className: "nav-link" + (isSelected ? " active" : "") + (this.props.disabled ? " disabled" : ""), href: "#", onClick: this.onClick },
53
- iconClass && React.createElement("i", { className: iconClass }),
54
- iconClass && " ",
52
+ hasIcon && this.iconFactory.getIconComponent(this.props.icon),
53
+ hasIcon && " ",
55
54
  this.props.header)));
56
55
  };
57
56
  Tab.prototype.renderBody = function (isSelected) {
@@ -17,6 +17,7 @@ export interface IValidationSummaryProps {
17
17
  hideTopLevelTitle?: boolean;
18
18
  }
19
19
  export default class ValidationSummary extends React.Component<IValidationSummaryProps> {
20
+ private iconFactory;
20
21
  private getRules;
21
22
  render(): JSX.Element;
22
23
  }
@@ -1,10 +1,13 @@
1
1
  import { __extends } from "tslib";
2
2
  import React from 'react';
3
- import { Validation, Utils } from '@singularsystems/neo-core';
3
+ import { Validation, Misc } from '@singularsystems/neo-core';
4
+ import { NeoReactTypes } from '../Modules/Types';
4
5
  var ValidationSummary = /** @class */ (function (_super) {
5
6
  __extends(ValidationSummary, _super);
6
7
  function ValidationSummary() {
7
- return _super !== null && _super.apply(this, arguments) || this;
8
+ var _this = _super !== null && _super.apply(this, arguments) || this;
9
+ _this.iconFactory = Misc.Globals.appService.get(NeoReactTypes.Components.IconFactory);
10
+ return _this;
8
11
  }
9
12
  ValidationSummary.prototype.getRules = function (modelInfo) {
10
13
  return modelInfo.objectDisplayInfo.concat(modelInfo.propertyRules)
@@ -26,12 +29,12 @@ var ValidationSummary = /** @class */ (function (_super) {
26
29
  return (React.createElement("div", { className: "validation-summary" }, graph && models.map(function (modelInfo, index) { return (React.createElement("div", { key: index, className: "validation-summary-model" },
27
30
  _this.props.hideTopLevelTitle !== true &&
28
31
  React.createElement("div", { className: "validation-summary-model-title" },
29
- React.createElement("i", { className: Utils.getFontAwesomeClass(modelInfo.model.getIcon()) }),
32
+ _this.iconFactory.getIconComponent(modelInfo.model.getIcon()),
30
33
  " ",
31
34
  modelInfo.model.toString()),
32
35
  React.createElement("div", { className: "validation-summary-model-body" + (_this.props.hideTopLevelTitle === true ? " no-title" : "") },
33
36
  React.createElement("div", { className: "validation-summary-model-rules" }, _this.getRules(modelInfo).map(function (rule, index) { return (React.createElement("div", { key: index, className: rule.displayInfo.additionalClassName },
34
- React.createElement("i", { className: rule.displayInfo.iconClass }),
37
+ _this.iconFactory.getIconComponent(rule.displayInfo.icon, { fixedWidth: true, spin: !!rule.displayInfo.asyncBusyText }),
35
38
  " ",
36
39
  rule.displayInfo.displayText)); })),
37
40
  React.createElement(ValidationSummary, { graph: modelInfo.valueObjects }),
package/dist/index.d.ts CHANGED
@@ -5,7 +5,8 @@ import * as NeoGrid from './ReactComponents/Grid/_Exports';
5
5
  import * as Routing from './Routing';
6
6
  import * as Views from './Views/';
7
7
  import * as Managers from './ReactComponents/_Managers';
8
+ import * as Icons from './ReactComponents/Icons';
8
9
  import { TooltipHelper } from './ReactComponents/TooltipHelper';
9
10
  export * from './React/Decorators';
10
- export { Managers, NeoReactModule, NeoReactTypes, Neo, NeoGrid, Routing, Views, TooltipHelper, };
11
+ export { Icons, Managers, NeoReactModule, NeoReactTypes, Neo, NeoGrid, Routing, Views, TooltipHelper, };
11
12
  export { ICancellableEvent } from './ReactComponents/Misc';
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ import * as NeoGrid from './ReactComponents/Grid/_Exports';
5
5
  import * as Routing from './Routing';
6
6
  import * as Views from './Views/';
7
7
  import * as Managers from './ReactComponents/_Managers';
8
+ import * as Icons from './ReactComponents/Icons';
8
9
  import { TooltipHelper } from './ReactComponents/TooltipHelper';
9
10
  export * from './React/Decorators';
10
- export { Managers, NeoReactModule, NeoReactTypes, Neo, NeoGrid, Routing, Views, TooltipHelper, };
11
+ export { Icons, Managers, NeoReactModule, NeoReactTypes, Neo, NeoGrid, Routing, Views, TooltipHelper, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singularsystems/neo-react",
3
- "version": "0.10.49",
3
+ "version": "0.10.50",
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",
@@ -30,10 +30,11 @@
30
30
  "tslib": "2.3.1"
31
31
  },
32
32
  "dependencies": {
33
+ "@fortawesome/react-fontawesome": "0.2.0",
33
34
  "@types/rc-slider": "^8.6.5",
34
35
  "@types/react-color": "^3.0.1",
35
36
  "@types/react-select": "3.1.0",
36
- "@singularsystems/neo-core": "^0.10.53",
37
+ "@singularsystems/neo-core": "^0.10.54",
37
38
  "axios": "^0.21.1",
38
39
  "decimal.js-light": "2.5.1",
39
40
  "history": "4.10.1",
@@ -147,15 +147,6 @@ select.form-control.is-invalid {
147
147
  color: $validation-color-info;
148
148
  }
149
149
  }
150
- i {
151
- width: 1rem;
152
- height: 1rem;
153
- text-align: center;
154
-
155
- &.spinner-grow {
156
- animation: spinner-grow 1s linear infinite;
157
- }
158
- }
159
150
  }
160
151
 
161
152
  .neo-error-modal-body {