@singularsystems/neo-core 0.10.57 → 0.10.59

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.
@@ -12,5 +12,5 @@ export declare class ReadApiClient<TModel, TKey extends string | number> extends
12
12
  /** Gets a list of entities */
13
13
  get(): AxiosPromise<PlainObject<TModel>[]>;
14
14
  /** Gets a single entity using the provided id. */
15
- getById(id: TKey): AxiosPromise<{ [P_1 in keyof Pick<TModel, Exclude<keyof TModel, "meta" | "update" | "entityIdentifier" | "isSelfDirty" | "isNew" | "isSelfValid" | "isValid" | "isDirty" | "readyToSave" | "isSuspended" | "validator" | "markOld" | "toJSObject" | "toQueryObject" | "toQueryObjectAuto" | "onAnyPropertyChanged" | "getIcon" | "set"> & { [P in keyof TModel]: TModel[P] extends Function ? never : P; }[keyof TModel]>]: Pick<TModel, Exclude<keyof TModel, "meta" | "update" | "entityIdentifier" | "isSelfDirty" | "isNew" | "isSelfValid" | "isValid" | "isDirty" | "readyToSave" | "isSuspended" | "validator" | "markOld" | "toJSObject" | "toQueryObject" | "toQueryObjectAuto" | "onAnyPropertyChanged" | "getIcon" | "set"> & { [P in keyof TModel]: TModel[P] extends Function ? never : P; }[keyof TModel]>[P_1] extends import("..").List<infer I> ? I[] : Pick<TModel, Exclude<keyof TModel, "meta" | "update" | "entityIdentifier" | "isSelfDirty" | "isNew" | "isSelfValid" | "isValid" | "isDirty" | "readyToSave" | "isSuspended" | "validator" | "markOld" | "toJSObject" | "toQueryObject" | "toQueryObjectAuto" | "onAnyPropertyChanged" | "getIcon" | "set"> & { [P in keyof TModel]: TModel[P] extends Function ? never : P; }[keyof TModel]>[P_1]; }>;
15
+ getById(id: TKey): AxiosPromise<{ [P_1 in keyof Pick<TModel, Exclude<keyof TModel, "meta" | "update" | "isSuspended" | "validator" | "markOld" | "toJSObject" | "toQueryObject" | "toQueryObjectAuto" | "onAnyPropertyChanged" | "getIcon" | "set" | "entityIdentifier" | "isSelfDirty" | "isNew" | "isSelfValid" | "isValid" | "isDirty" | "readyToSave"> & { [P in keyof TModel]: TModel[P] extends Function ? never : P; }[keyof TModel]>]: Pick<TModel, Exclude<keyof TModel, "meta" | "update" | "isSuspended" | "validator" | "markOld" | "toJSObject" | "toQueryObject" | "toQueryObjectAuto" | "onAnyPropertyChanged" | "getIcon" | "set" | "entityIdentifier" | "isSelfDirty" | "isNew" | "isSelfValid" | "isValid" | "isDirty" | "readyToSave"> & { [P in keyof TModel]: TModel[P] extends Function ? never : P; }[keyof TModel]>[P_1] extends import("..").List<infer I> ? I[] : Pick<TModel, Exclude<keyof TModel, "meta" | "update" | "isSuspended" | "validator" | "markOld" | "toJSObject" | "toQueryObject" | "toQueryObjectAuto" | "onAnyPropertyChanged" | "getIcon" | "set" | "entityIdentifier" | "isSelfDirty" | "isNew" | "isSelfValid" | "isValid" | "isDirty" | "readyToSave"> & { [P in keyof TModel]: TModel[P] extends Function ? never : P; }[keyof TModel]>[P_1]; }>;
16
16
  }
@@ -133,6 +133,9 @@ var DatePicker = /** @class */ (function () {
133
133
  this.bindProperty.value = dateValue;
134
134
  if (suspend)
135
135
  Utils.nextTick(function () { return _this.suspendLayout = false; });
136
+ if (this.options.onDateSelected !== undefined) {
137
+ this.options.onDateSelected(!suspend);
138
+ }
136
139
  };
137
140
  DatePicker.prototype.setInputValue = function () {
138
141
  if (!this.options.alwaysShow) {
@@ -21,6 +21,11 @@ export default class DatePickerOptions {
21
21
  yearsBeforeInYearView: number;
22
22
  /** True if the date picker must close when the input loses focus. True by default. */
23
23
  autoClose: boolean;
24
+ /**
25
+ * Callback to invoke when a new date is selected.
26
+ * `isClosing` will be false during scrolling with `autoChangeDate` set.
27
+ * */
28
+ onDateSelected?: (isClosing: boolean) => void;
24
29
  }
25
30
  export declare class ProcessedDatePickerOptions extends DatePickerOptions {
26
31
  minDateNoTime: Date;
@@ -1,6 +1,13 @@
1
+ import { IDeserialiseOptions } from '../Data/Deserialiser';
1
2
  import { BindableBase } from './BindableBase';
2
- import { IBindableBase } from './IModelBase';
3
+ import { IBindableBase, PartialPlainObject } from './IModelBase';
3
4
  export interface ILookupBase extends IBindableBase {
4
5
  }
5
6
  export declare abstract class LookupBase extends BindableBase implements ILookupBase {
7
+ /**
8
+ * @deprecated Models that extend LookupBase are designed to be immutable.
9
+ * Calling set() on an instance that is already being observed will not cause the ui to update.
10
+ * Rather deserialise on create using `MyLookup.fromJSObject<MyLookup>(data)`.
11
+ * */
12
+ set(jsObject: PartialPlainObject<this>, options?: IDeserialiseOptions): void;
6
13
  }
@@ -5,6 +5,15 @@ var LookupBase = /** @class */ (function (_super) {
5
5
  function LookupBase() {
6
6
  return _super !== null && _super.apply(this, arguments) || this;
7
7
  }
8
+ /**
9
+ * @deprecated Models that extend LookupBase are designed to be immutable.
10
+ * Calling set() on an instance that is already being observed will not cause the ui to update.
11
+ * Rather deserialise on create using `MyLookup.fromJSObject<MyLookup>(data)`.
12
+ * */
13
+ LookupBase.prototype.set = function (jsObject, options) {
14
+ console.warn("Do not use the set() method on lookup models. Rather use the static fromJSObject().");
15
+ _super.prototype.set.call(this, jsObject, options);
16
+ };
8
17
  return LookupBase;
9
18
  }(BindableBase));
10
19
  export { LookupBase };
@@ -83,5 +83,6 @@ export default abstract class ModelBase extends BindableBase implements IModelBa
83
83
  * Add custom business rules. Note, this will be called once per type and should be treated as static.
84
84
  */
85
85
  protected addBusinessRules(validationRules: ValidationRules<this>): void;
86
+ /** The server side full type name used to find this type. */
86
87
  static typeName: string | null;
87
88
  }
@@ -147,6 +147,7 @@ var ModelBase = /** @class */ (function (_super) {
147
147
  */
148
148
  ModelBase.prototype.addBusinessRules = function (validationRules) {
149
149
  };
150
+ /** The server side full type name used to find this type. */
150
151
  ModelBase.typeName = null;
151
152
  __decorate([
152
153
  NoTracking(SerialiseType.Never),
@@ -30,7 +30,13 @@ export default class NumberUtils {
30
30
  * @param hasExternalPercentSymbol True if this is a percent, but the format string doesn't contain a % symbol.
31
31
  */
32
32
  static roundUsingFormat<T extends number | Decimal>(number: T, formatString: string, hasExternalPercentSymbol?: boolean): T;
33
- private static getDecimals;
33
+ /**
34
+ * Returns the number of decimal places in a format string.
35
+ * @param formatString Format string.
36
+ * @param value Value if the negative format string is different to positive.
37
+ */
38
+ static getDecimalPlaces<T extends number | Decimal>(formatString: string, value?: T): number;
39
+ private static getDecimalsFormatPart;
34
40
  /**
35
41
  * Converts a number to a string using the specified format.
36
42
  * E.g. #,##0.00;(#,##0.00)
@@ -42,7 +42,7 @@ var NumberUtils = /** @class */ (function () {
42
42
  number *= 100;
43
43
  isPercent = false; //Don't allow extra precision below.
44
44
  }
45
- var positive = "#0" + NumberUtils.getDecimals(parts[0], isPercent), negative = "-#0" + NumberUtils.getDecimals(parts[1] ? parts[1] : parts[0], isPercent);
45
+ var positive = "#0" + NumberUtils.getDecimalsFormatPart(parts[0], isPercent), negative = "-#0" + NumberUtils.getDecimalsFormatPart(parts[1] ? parts[1] : parts[0], isPercent);
46
46
  return NumberUtils.format(number, positive + ";" + negative);
47
47
  };
48
48
  /**
@@ -50,9 +50,10 @@ var NumberUtils = /** @class */ (function () {
50
50
  * @param hasExternalPercentSymbol True if this is a percent, but the format string doesn't contain a % symbol.
51
51
  */
52
52
  NumberUtils.roundUsingFormat = function (number, formatString, hasExternalPercentSymbol) {
53
- var parts = formatString.split(";");
54
- var part = number > 0 || parts.length == 1 ? parts[0] : parts[1];
55
- var decimals = Math.max(0, NumberUtils.getDecimals(part, part.indexOf("%") >= 0 || hasExternalPercentSymbol).length - 1);
53
+ var decimals = this.getDecimalPlaces(formatString, number);
54
+ if (formatString.indexOf("%") >= 0 || hasExternalPercentSymbol) {
55
+ decimals += 2;
56
+ }
56
57
  if (number instanceof Globals.decimalType) {
57
58
  // Round away from zero.
58
59
  return number.toDecimalPlaces(decimals, Decimal.ROUND_HALF_UP);
@@ -66,7 +67,22 @@ var NumberUtils = /** @class */ (function () {
66
67
  }
67
68
  }
68
69
  };
69
- NumberUtils.getDecimals = function (formatString, isPercent) {
70
+ /**
71
+ * Returns the number of decimal places in a format string.
72
+ * @param formatString Format string.
73
+ * @param value Value if the negative format string is different to positive.
74
+ */
75
+ NumberUtils.getDecimalPlaces = function (formatString, value) {
76
+ var parts = formatString.split(";");
77
+ var part = value === undefined || value >= 0 || parts.length == 1 ? parts[0] : parts[1];
78
+ var startIndex = part.indexOf(".");
79
+ var endIndex = Math.max(part.lastIndexOf("0"), part.lastIndexOf("#"));
80
+ if (startIndex >= 0 && endIndex > 0) {
81
+ return endIndex - startIndex;
82
+ }
83
+ return 0;
84
+ };
85
+ NumberUtils.getDecimalsFormatPart = function (formatString, isPercent) {
70
86
  if (isPercent === void 0) { isPercent = false; }
71
87
  if (formatString) {
72
88
  var startIndex = formatString.indexOf(".");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singularsystems/neo-core",
3
- "version": "0.10.57",
3
+ "version": "0.10.59",
4
4
  "description": "Core functionality for the Neo client library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,5 +27,9 @@
27
27
  "inversify": "5.0.1",
28
28
  "reflect-metadata": "0.1.13",
29
29
  "tslib": "2.3.1"
30
+ },
31
+ "peerDependencies": {
32
+ "axios": ">=0.21.1",
33
+ "inversify": ">=5.0.1"
30
34
  }
31
35
  }