@singularsystems/neo-react 1.0.5 → 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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singularsystems/neo-react",
3
- "version": "1.0.5",
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.4",
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",