@singularsystems/neo-core 1.3.9 → 1.4.1
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 +13 -0
- package/dist/Components/ButtonOptions.d.ts +4 -0
- package/dist/Data/Serialiser.d.ts +4 -4
- package/dist/Data/Serialiser.js +10 -9
- package/dist/Dates/DateUtils.js +1 -1
- package/dist/Misc.d.ts +1 -1
- package/dist/Misc.js +1 -1
- package/dist/Model/Decorators.d.ts +10 -2
- package/dist/Model/Decorators.js +10 -2
- package/dist/Model/Misc.d.ts +14 -0
- package/dist/Model/Misc.js +15 -0
- package/dist/Model/PropertyInfo.d.ts +2 -1
- package/dist/Model/PropertyInfo.js +1 -0
- package/dist/Routing/INavigationHelper.d.ts +21 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Neo core changelog
|
|
2
2
|
|
|
3
|
+
## Version 1.4.1 (20 April 2026)
|
|
4
|
+
|
|
5
|
+
- Navigation helper
|
|
6
|
+
- Changed `openWindow` and `readOpenerState` to store state as string.
|
|
7
|
+
|
|
8
|
+
## Version 1.4.0 (16 April 2026)
|
|
9
|
+
|
|
10
|
+
- Dates decorated with `TimeZoneFormat.None` will now correctly deserialise into `DateOnly` properties on the server.
|
|
11
|
+
See [Breaking Changes](./BREAKING.md).
|
|
12
|
+
- Can now specify the observable type using the `Observable` attribute. Useful for dictionaries.
|
|
13
|
+
- Navigation helper
|
|
14
|
+
- Added `openWindow` and `readOpenerState` methods to allow opening a view in a new window, and to allow passing state to the new window.
|
|
15
|
+
|
|
3
16
|
## Version 1.3.9 (4 March 2026)
|
|
4
17
|
|
|
5
18
|
- Made `IDataCacheEntry.expire` method awaitable.
|
|
@@ -25,6 +25,8 @@ export interface IButtonOptions {
|
|
|
25
25
|
menuItems?: IButtonDropDownItem[];
|
|
26
26
|
/** True if the dropdown menu must be split from the button. Set this if you want the button to have its own click event. */
|
|
27
27
|
splitMenu?: boolean;
|
|
28
|
+
/** Callback for the when the menu is opened. */
|
|
29
|
+
onMenuOpened?: () => void;
|
|
28
30
|
/** Callback for the when the menu is closed without an item being selected. */
|
|
29
31
|
onMenuClosed?: () => void;
|
|
30
32
|
menuAlignment?: "left" | "right";
|
|
@@ -54,6 +56,8 @@ export interface IButtonOptions {
|
|
|
54
56
|
* Set a custom variant for when a standard variant is not provided.
|
|
55
57
|
*/
|
|
56
58
|
customVariant?: string;
|
|
59
|
+
/** Makes the button appear toggled. */
|
|
60
|
+
isActive?: boolean;
|
|
57
61
|
}
|
|
58
62
|
export interface IButtonDropDownItem {
|
|
59
63
|
/** Menu item text or component */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import List from '../Model/List';
|
|
2
|
-
import {
|
|
2
|
+
import { IBindableBase } from '../Model/IModelBase';
|
|
3
3
|
import { IDeserialiseOptions } from './Deserialiser';
|
|
4
4
|
export interface ISerialiseOptions {
|
|
5
5
|
/**
|
|
@@ -16,7 +16,7 @@ export interface ISerialiseOptions {
|
|
|
16
16
|
suppressChildren?: boolean;
|
|
17
17
|
}
|
|
18
18
|
export declare abstract class JSFormatter {
|
|
19
|
-
static serialise(object:
|
|
19
|
+
static serialise(object: IBindableBase | IBindableBase[] | List<IBindableBase>, options?: ISerialiseOptions): any;
|
|
20
20
|
/**
|
|
21
21
|
* Deserialises a plain javascript object into a NeoModel instance
|
|
22
22
|
* @param from plain javascript object
|
|
@@ -25,13 +25,13 @@ export declare abstract class JSFormatter {
|
|
|
25
25
|
* @param options Deserialise options
|
|
26
26
|
* @param justCreated True if the object being deserialised was just created (for its onDeserialise method).
|
|
27
27
|
*/
|
|
28
|
-
static deserialise(from: any, to: IBindableBase | IBindableBase[] | List<
|
|
28
|
+
static deserialise(from: any, to: IBindableBase | IBindableBase[] | List<IBindableBase>, rootType?: any, options?: IDeserialiseOptions, justCreated?: boolean): void;
|
|
29
29
|
}
|
|
30
30
|
export declare class Serialiser {
|
|
31
31
|
private objectRefs;
|
|
32
32
|
private options;
|
|
33
33
|
private currentID;
|
|
34
|
-
serialise(fromObject:
|
|
34
|
+
serialise(fromObject: IBindableBase | IBindableBase[] | List<IBindableBase>, options?: ISerialiseOptions): any;
|
|
35
35
|
/**
|
|
36
36
|
* removes the temporary ids from the from objects.
|
|
37
37
|
*/
|
package/dist/Data/Serialiser.js
CHANGED
|
@@ -88,27 +88,28 @@ var Serialiser = /** @class */ (function () {
|
|
|
88
88
|
this.objectRefs[referenceId] = { from: from, to: to };
|
|
89
89
|
to.$id = referenceId.toString();
|
|
90
90
|
}
|
|
91
|
+
var typeInfo = from.constructor.neo;
|
|
92
|
+
if (!typeInfo && !isDictionary) {
|
|
93
|
+
throw "Object is not decorated with @NeoModel. Either add @NeoModel, suppress serialisation on the property, or add @Attributes.Raw() to the property.";
|
|
94
|
+
}
|
|
91
95
|
//Set tracking state
|
|
92
|
-
|
|
93
|
-
|
|
96
|
+
var modelBase = from;
|
|
97
|
+
if (!isDictionary && typeInfo.inheritsModelBase && !this.options.suppressTrackingState) {
|
|
98
|
+
if (modelBase.isSelfDeleting) {
|
|
94
99
|
to.trackingState = TrackingState.Deleted;
|
|
95
100
|
}
|
|
96
|
-
else if (
|
|
101
|
+
else if (modelBase.isNew) {
|
|
97
102
|
to.trackingState = TrackingState.Added;
|
|
98
103
|
}
|
|
99
|
-
else if (
|
|
104
|
+
else if (modelBase.isSelfDirty) {
|
|
100
105
|
to.trackingState = TrackingState.Modified;
|
|
101
106
|
}
|
|
102
107
|
else {
|
|
103
108
|
to.trackingState = TrackingState.Unchanged;
|
|
104
109
|
}
|
|
105
|
-
to.entityIdentifier =
|
|
110
|
+
to.entityIdentifier = modelBase.entityIdentifier;
|
|
106
111
|
}
|
|
107
112
|
//Loop through serialisable properties
|
|
108
|
-
var typeInfo = from.constructor.neo;
|
|
109
|
-
if (!typeInfo && !isDictionary) {
|
|
110
|
-
throw "Object is not decorated with @NeoModel. Either add @NeoModel, suppress serialisation on the property, or add @Attributes.Raw() to the property.";
|
|
111
|
-
}
|
|
112
113
|
var propertyMap = isDictionary ? {} : typeInfo.propertyMap;
|
|
113
114
|
for (var key in from) {
|
|
114
115
|
if (from.hasOwnProperty(key) && key.indexOf("__") !== 0) {
|
package/dist/Dates/DateUtils.js
CHANGED
package/dist/Misc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { DataType, RelationType, SerialiseType, TrackingState, RemoveItemBehavior, IDisposable, IAutoRunner, IAutoRunnerOptions, TimeZoneFormat } from './Model/Misc';
|
|
1
|
+
export { DataType, RelationType, SerialiseType, TrackingState, RemoveItemBehavior, IDisposable, IAutoRunner, IAutoRunnerOptions, TimeZoneFormat, ObservableType } from './Model/Misc';
|
|
2
2
|
export { default as Globals } from './Globals';
|
|
3
3
|
export { NumberFormat } from './NumberUtils';
|
|
4
4
|
export { Settings } from './Settings';
|
package/dist/Misc.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { DataType, RelationType, SerialiseType, TrackingState, RemoveItemBehavior, TimeZoneFormat } from './Model/Misc';
|
|
1
|
+
export { DataType, RelationType, SerialiseType, TrackingState, RemoveItemBehavior, TimeZoneFormat, ObservableType } from './Model/Misc';
|
|
2
2
|
export { default as Globals } from './Globals';
|
|
3
3
|
export { NumberFormat } from './NumberUtils';
|
|
4
4
|
export { Settings } from './Settings';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SerialiseType, DataType, TimeZoneFormat } from './Misc';
|
|
1
|
+
import { SerialiseType, DataType, TimeZoneFormat, ObservableType } from './Misc';
|
|
2
2
|
import { IObjectFactoryOptions, ItemConstructor } from './IModelBase';
|
|
3
3
|
export declare function Display(name: string): (type: any, propertyKey: string) => void;
|
|
4
4
|
/** Indicates that this is a date property. Json strings will be converted to date objects on deserialisation. */
|
|
@@ -16,7 +16,15 @@ export declare function Decimal(): (type: any, propertyKey: string) => void;
|
|
|
16
16
|
export declare function NullableBoolean(): (type: any, propertyKey: string) => void;
|
|
17
17
|
/** Indicates that this property accepts nulls from user input controls that do not normally accept nulls. E.g. numeric editors. */
|
|
18
18
|
export declare function Nullable(dataType?: DataType): (type: any, propertyKey: string) => void;
|
|
19
|
-
|
|
19
|
+
/** Indicates that the property should be observable.
|
|
20
|
+
* E.g. to make a property in a lookup class observable.
|
|
21
|
+
* Or to make a property in a model non-observable by passing `false`. */
|
|
22
|
+
export declare function Observable(isObservable?: boolean): Function;
|
|
23
|
+
/**
|
|
24
|
+
* Sets the observable type of this property.
|
|
25
|
+
* E.g. to make the values of a dictionary observable, use `@Attributes.Observable(Misc.ObservableType.Shallow)`
|
|
26
|
+
*/
|
|
27
|
+
export declare function Observable(observableType: ObservableType): Function;
|
|
20
28
|
/** Indicates that changes to this property will not cause the object to become dirty. It will also not be serialised */
|
|
21
29
|
export declare function NoTracking(serialisation?: SerialiseType): (type: any, propertyKey: string) => void;
|
|
22
30
|
export declare function Serialisation(serialisation: SerialiseType): (type: any, propertyKey: string) => void;
|
package/dist/Model/Decorators.js
CHANGED
|
@@ -59,10 +59,18 @@ export function Nullable(dataType) {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
export function Observable(isObservable) {
|
|
62
|
-
if (isObservable === void 0) { isObservable = true; }
|
|
63
62
|
return function (type, propertyKey) {
|
|
64
63
|
var pi = getOrAddPropertyInfo(type, propertyKey);
|
|
65
|
-
|
|
64
|
+
if (isObservable === undefined) {
|
|
65
|
+
pi.isObservable = true;
|
|
66
|
+
}
|
|
67
|
+
else if (typeof isObservable === "boolean") {
|
|
68
|
+
pi.isObservable = isObservable;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
pi.isObservable = true;
|
|
72
|
+
pi.observableType = isObservable;
|
|
73
|
+
}
|
|
66
74
|
};
|
|
67
75
|
}
|
|
68
76
|
/** Indicates that changes to this property will not cause the object to become dirty. It will also not be serialised */
|
package/dist/Model/Misc.d.ts
CHANGED
|
@@ -38,6 +38,20 @@ export declare enum DataType {
|
|
|
38
38
|
NullableBoolean = 7,
|
|
39
39
|
Decimal = 8
|
|
40
40
|
}
|
|
41
|
+
export declare enum ObservableType {
|
|
42
|
+
Default = 0,
|
|
43
|
+
/**
|
|
44
|
+
* Observers will only react when the value of this property changes by reference.
|
|
45
|
+
* E.g. `obj.Nested = newObject`. Not `obj.Nested.property1 = 1`.
|
|
46
|
+
*/
|
|
47
|
+
Reference = 1,
|
|
48
|
+
/**
|
|
49
|
+
* Observers will react to reference changes, *and* to changes in the direct properties of this object.
|
|
50
|
+
* Use this for dictionaries, where you want to react to changes in the values.
|
|
51
|
+
* **Do not** use for regular child objects that extend ModelBase / BindableBase.
|
|
52
|
+
*/
|
|
53
|
+
Shallow = 2
|
|
54
|
+
}
|
|
41
55
|
export declare class OnChangedOptions {
|
|
42
56
|
onChangedFn: (oldValue: any, newValue: any) => void;
|
|
43
57
|
requiresOldValue: boolean;
|
package/dist/Model/Misc.js
CHANGED
|
@@ -41,6 +41,21 @@ export var DataType;
|
|
|
41
41
|
DataType[DataType["NullableBoolean"] = 7] = "NullableBoolean";
|
|
42
42
|
DataType[DataType["Decimal"] = 8] = "Decimal";
|
|
43
43
|
})(DataType || (DataType = {}));
|
|
44
|
+
export var ObservableType;
|
|
45
|
+
(function (ObservableType) {
|
|
46
|
+
ObservableType[ObservableType["Default"] = 0] = "Default";
|
|
47
|
+
/**
|
|
48
|
+
* Observers will only react when the value of this property changes by reference.
|
|
49
|
+
* E.g. `obj.Nested = newObject`. Not `obj.Nested.property1 = 1`.
|
|
50
|
+
*/
|
|
51
|
+
ObservableType[ObservableType["Reference"] = 1] = "Reference";
|
|
52
|
+
/**
|
|
53
|
+
* Observers will react to reference changes, *and* to changes in the direct properties of this object.
|
|
54
|
+
* Use this for dictionaries, where you want to react to changes in the values.
|
|
55
|
+
* **Do not** use for regular child objects that extend ModelBase / BindableBase.
|
|
56
|
+
*/
|
|
57
|
+
ObservableType[ObservableType["Shallow"] = 2] = "Shallow";
|
|
58
|
+
})(ObservableType || (ObservableType = {}));
|
|
44
59
|
var OnChangedOptions = /** @class */ (function () {
|
|
45
60
|
function OnChangedOptions(onChangedFn, requiresOldValue, delayMs) {
|
|
46
61
|
this.onChangedFn = onChangedFn;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SerialiseType, RelationType, OnChangedOptions, DataType, TimeZoneFormat } from './Misc';
|
|
1
|
+
import { SerialiseType, RelationType, OnChangedOptions, DataType, TimeZoneFormat, ObservableType } from './Misc';
|
|
2
2
|
import { Nullable } from '../Utils';
|
|
3
3
|
import { INonObservableModelBase, ItemConstructor, ItemConstructorOptions, ObjectFactory } from './IModelBase';
|
|
4
4
|
import { Rule } from '../Validation/Rules';
|
|
@@ -22,6 +22,7 @@ export default class PropertyInfo {
|
|
|
22
22
|
* True when defining observables on types that don't extend ModelBase.
|
|
23
23
|
*/
|
|
24
24
|
isObservable: Nullable<boolean>;
|
|
25
|
+
observableType: Nullable<ObservableType>;
|
|
25
26
|
/** See SerialiseType */
|
|
26
27
|
serialise: SerialiseType;
|
|
27
28
|
timeZoneSerialisation: TimeZoneFormat;
|
|
@@ -15,6 +15,7 @@ var PropertyInfo = /** @class */ (function () {
|
|
|
15
15
|
* True when defining observables on types that don't extend ModelBase.
|
|
16
16
|
*/
|
|
17
17
|
this.isObservable = null;
|
|
18
|
+
this.observableType = null;
|
|
18
19
|
/** See SerialiseType */
|
|
19
20
|
this.serialise = SerialiseType.Always;
|
|
20
21
|
/** Type of parent / child if this property is related to another model. 'type' property must be set if this is not 'none'. */
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
export interface INavigationHelper {
|
|
2
2
|
/**
|
|
3
3
|
* Navigates to an internal url using the router.
|
|
4
|
+
* @param path The url to navigate to. This should be a relative url, and should not include the base path of the application. For example, use "/home" instead of "/myapp/home".
|
|
4
5
|
* @param replace Replace the url instead of adding to the history. This prevents the back button returning the params to the current state.
|
|
5
6
|
* @returns True if the navigation event occurred. False if it was blocked by the view / page leave handler.
|
|
6
7
|
* */
|
|
7
|
-
navigateInternal(
|
|
8
|
+
navigateInternal(path: string, replace?: boolean): Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* Opens a new window with the base url of the current application.
|
|
11
|
+
* @param path The url to navigate to. This should be a relative url, and should not include the base path of the application. For example, use "/home" instead of "/myapp/home".
|
|
12
|
+
* @param state Optional state to pass to the new window. This must be a serialized object, which can be read using `readOpenerState`.
|
|
13
|
+
* @param options Optional window features and target.
|
|
14
|
+
*/
|
|
15
|
+
openWindow(path: string, state?: {
|
|
16
|
+
name: string;
|
|
17
|
+
value: any;
|
|
18
|
+
}, options?: {
|
|
19
|
+
target?: string;
|
|
20
|
+
features?: string;
|
|
21
|
+
}): Window | null;
|
|
22
|
+
/**
|
|
23
|
+
* Reads the state passed from the opener to the current window. If an object was passed to `openWindow`, you will need to parse the stored value using JSON.parse.
|
|
24
|
+
* @param name The name of the state to read. This should match the name provided in the state parameter of `openWindow`.
|
|
25
|
+
* @param reset Whether to remove the state after read. Defaults to true.
|
|
26
|
+
*/
|
|
27
|
+
readOpenerState(name: string, reset?: boolean): string | undefined;
|
|
8
28
|
}
|