@singularsystems/neo-react 1.0.4 → 1.0.6

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.
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Makes a list observable. Use this only when the property is not part of a NeoModel. E.g. it is defined directly on a component.
3
+ */
4
+ export declare function observableList(type: any, propertyKey: string): any;
@@ -0,0 +1,15 @@
1
+ import { createObservableList } from './Utils';
2
+ /**
3
+ * Makes a list observable. Use this only when the property is not part of a NeoModel. E.g. it is defined directly on a component.
4
+ */
5
+ export function observableList(type, propertyKey) {
6
+ var descriptor = arguments[2];
7
+ var initializer = descriptor.initializer;
8
+ return {
9
+ get: function () {
10
+ // Convert to observable list on first read. This will overwrite this getter, and the next read will call the overwritten get method.
11
+ createObservableList(this, propertyKey, initializer());
12
+ return this[propertyKey];
13
+ }
14
+ };
15
+ }
@@ -0,0 +1,2 @@
1
+ import { List } from '@singularsystems/neo-core';
2
+ export declare function createObservableList<T>(target: any, propertyKey: string, list: List<T>): void;
@@ -0,0 +1,15 @@
1
+ import { observable } from "mobx";
2
+ import { List } from '@singularsystems/neo-core';
3
+ export function createObservableList(target, propertyKey, list) {
4
+ if (list instanceof Array) {
5
+ // this overload is not part of the typescript typings. The true tells it to create the observable immediately
6
+ observable.shallow(target, propertyKey, { value: list }, true);
7
+ // add the original methods and values back to the mobx array.
8
+ var obsArray = target[propertyKey];
9
+ List.copyMethods(obsArray);
10
+ list.setupProxy(obsArray, target, propertyKey);
11
+ }
12
+ else {
13
+ throw "observableList can only be defined on arrays.";
14
+ }
15
+ }
@@ -43,6 +43,7 @@ var IconFactory = /** @class */ (function () {
43
43
  if (style === null || style === void 0 ? void 0 : style.size) {
44
44
  inlineStyle = { fontSize: style.size };
45
45
  }
46
+ className += " neo-icon";
46
47
  return React.createElement("i", { className: className, style: inlineStyle });
47
48
  };
48
49
  IconFactory.prototype.createIconComponent = function (iconDescriptor, style) {
@@ -27,7 +27,7 @@ var MaterialSymbolsFontFactory = /** @class */ (function (_super) {
27
27
  }
28
28
  MaterialSymbolsFontFactory.prototype.mapStringToIcon = function (iconName, style) {
29
29
  var _a;
30
- var className = "material-symbols-outlined";
30
+ var className = "material-symbols-outlined neo-icon";
31
31
  var isFilled = (_a = style === null || style === void 0 ? void 0 : style.solid) !== null && _a !== void 0 ? _a : this.filledByDefault;
32
32
  // TODO: copy spin animation from font-awesome
33
33
  if (style === null || style === void 0 ? void 0 : style.spin) {
@@ -3,6 +3,7 @@ import { Components } from "@singularsystems/neo-core";
3
3
  import CollapsableBase from '../CollapsableBase';
4
4
  interface IAlertProps {
5
5
  isOutline?: boolean;
6
+ iconPosition?: "body" | "left";
6
7
  }
7
8
  export default class Alert extends CollapsableBase<Components.INotificationOptions & IAlertProps & React.HTMLProps<HTMLDivElement>> {
8
9
  private iconFactory;
@@ -13,21 +13,36 @@ var Alert = /** @class */ (function (_super) {
13
13
  return _this;
14
14
  }
15
15
  Alert.prototype.render = function () {
16
- 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, isOutline = _a.isOutline, native = __rest(_a, ["variant", "heading", "show", "bindShow", "autoCloseTimeout", "animateInitial", "state", "onHidden", "refreshValue", "icon", "isOutline"]);
17
- var className = Utils.joinWithSpaces(native.className, "alert", "alert-" + variant, "collapsable" + (isOutline ? " alert-outline" : ""));
16
+ var _a, _b;
17
+ var _c = this.props, variant = _c.variant, heading = _c.heading, show = _c.show, bindShow = _c.bindShow, autoCloseTimeout = _c.autoCloseTimeout, animateInitial = _c.animateInitial, state = _c.state, onHidden = _c.onHidden, refreshValue = _c.refreshValue, icon = _c.icon, native = __rest(_c, ["variant", "heading", "show", "bindShow", "autoCloseTimeout", "animateInitial", "state", "onHidden", "refreshValue", "icon"]);
18
+ var isOutline = (_a = this.props.isOutline) !== null && _a !== void 0 ? _a : Misc.Settings.alerts.isOutline;
19
+ var iconPosition = (_b = this.props.iconPosition) !== null && _b !== void 0 ? _b : Misc.Settings.alerts.iconPosition;
20
+ var className = Utils.joinWithSpaces(native.className, "alert", "alert-" + variant, "collapsable" + (isOutline ? " alert-outline" : "") + (iconPosition === "left" ? " alert-left-icon" : ""));
18
21
  if (bindShow) {
19
22
  className += " alert-dismissible";
20
23
  }
24
+ if (heading) {
25
+ className += " with-heading";
26
+ }
21
27
  this.shouldShow = show !== false && (!bindShow || bindShow.value);
22
28
  return (React.createElement("div", __assign({}, native, { className: className, ref: this.containerRef }),
23
- heading &&
24
- React.createElement("h6", null, heading),
25
- icon &&
26
- React.createElement("div", { className: "notification-icon-container" },
27
- this.iconFactory.getIconComponent(icon),
28
- React.createElement("div", null, this.props.children)),
29
- !icon && this.props.children,
30
- bindShow && BootstrapUtils.getCloseButton(this.onClose)));
29
+ bindShow && BootstrapUtils.getCloseButton(this.onClose),
30
+ iconPosition === "body" &&
31
+ React.createElement(React.Fragment, null,
32
+ heading &&
33
+ React.createElement("h6", null, heading),
34
+ icon &&
35
+ React.createElement("div", { className: "notification-icon-container" },
36
+ this.iconFactory.getIconComponent(icon),
37
+ React.createElement("div", null, this.props.children)),
38
+ !icon && this.props.children),
39
+ iconPosition === "left" &&
40
+ React.createElement("div", null,
41
+ icon &&
42
+ React.createElement("div", { className: "notification-icon-container" }, this.iconFactory.getIconComponent(icon)),
43
+ React.createElement("div", null,
44
+ heading && React.createElement("h6", null, heading),
45
+ React.createElement("div", { className: "alert-body" }, this.props.children)))));
31
46
  };
32
47
  Alert = __decorate([
33
48
  observer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singularsystems/neo-react",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
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",
@@ -31,7 +31,7 @@
31
31
  "typescript": "5.4.2"
32
32
  },
33
33
  "dependencies": {
34
- "@singularsystems/neo-core": "1.0.2",
34
+ "@singularsystems/neo-core": "1.0.3",
35
35
  "@types/rc-slider": "^8.6.5",
36
36
  "@types/react-color": "^3.0.1",
37
37
  "axios": "1.6.7",
package/styles/Misc.scss CHANGED
@@ -141,4 +141,17 @@ div.tabs-header {
141
141
  .neo-file-progress-container {
142
142
  font-size: 0.9rem;
143
143
  margin-top: 0.5rem;
144
+ }
145
+
146
+ .alert.alert-left-icon {
147
+ >div {
148
+ display: flex;
149
+ align-items: flex-start;
150
+ }
151
+
152
+ .notification-icon-container {
153
+ position: relative;
154
+ left: -0.5rem;
155
+ font-size: 1.5rem;
156
+ }
144
157
  }