@singularsystems/neo-core 1.1.2 → 1.2.0

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.
@@ -63,7 +63,7 @@ export declare class CollapseAnimationHelper {
63
63
  private hasTransitioned;
64
64
  private afterTransitionedDelegate;
65
65
  private defaultOverflow;
66
- constructor(element: HTMLElement, shouldShow: boolean, state?: any, onHidden?: ((state: any) => void) | undefined);
66
+ constructor(element: HTMLElement, shouldShow: boolean, state?: any | undefined, onHidden?: ((state: any) => void) | undefined);
67
67
  /** Restores the element to its normal height. */
68
68
  restore(force?: boolean): void;
69
69
  /** Collapses the element, and then hides it. */
@@ -6,6 +6,7 @@ export type flexItemAlign = "start" | "end" | "center";
6
6
  export type flexJustifyContent = "start" | "end" | "center" | "between";
7
7
  export type breakpoint = "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
8
8
  export type ElementOrText = any;
9
+ export type BorderType = "standard" | "borderless" | "bordered";
9
10
  export interface IColumnWidthBreakpoints {
10
11
  /** Number of columns to span when the screen is extra small or bigger */
11
12
  xs?: columnWidth;
@@ -12,6 +12,8 @@ export interface IButtonOptions {
12
12
  size?: ("sm" | "lg");
13
13
  /** Bootstrap outline */
14
14
  isOutline?: boolean;
15
+ /** Causes the button to be rendered without a background or border. The variant will instead affect text color. */
16
+ isFlat?: boolean;
15
17
  onClick?: (event: any, data?: any) => void;
16
18
  /** Specify a string name if using font-awesome. No need to specify fa- */
17
19
  icon?: any;
@@ -147,7 +147,7 @@ var Deserialiser = /** @class */ (function () {
147
147
  if (to instanceof Array) {
148
148
  throw "Tried to deserialise object into an array type.";
149
149
  }
150
- var typeName = to.constructor.name;
150
+ var typeName = Utils.getTypeName(to.constructor);
151
151
  var propertyInfoList = this.beginObjectDeserialise(to);
152
152
  if (from.$id) {
153
153
  this.objectRefs[from.$id] = { from: from, to: to };
@@ -3,6 +3,7 @@ import { Deserialiser } from './Deserialiser';
3
3
  import ValueObject from '../Model/ValueObject';
4
4
  import DateUtils from '../Dates/DateUtils';
5
5
  import NumberUtils from "../NumberUtils";
6
+ import { Utils } from "../Utils";
6
7
  var referenceIdKey = Symbol("referenceId");
7
8
  var JSFormatter = /** @class */ (function () {
8
9
  function JSFormatter() {
@@ -158,7 +159,7 @@ var Serialiser = /** @class */ (function () {
158
159
  }
159
160
  }
160
161
  catch (error) {
161
- throw "Error serialising property '".concat(key, "' on type '").concat(from.constructor.name, "': ").concat(error);
162
+ throw "Error serialising property '".concat(key, "' on type '").concat(Utils.getTypeName(from.constructor), "': ").concat(error);
162
163
  }
163
164
  }
164
165
  }
@@ -1,5 +1,6 @@
1
1
  import { ensureTypeInfo } from './NeoTypeInfo';
2
2
  import { SerialiseType, RelationType, OnChangedOptions, DataType, TimeZoneFormat } from './Misc';
3
+ import { Utils } from "../Utils";
3
4
  function getOrAddPropertyInfo(type, propertyName) {
4
5
  return ensureTypeInfo(type.constructor).neo.getOrAddProperty(propertyName);
5
6
  }
@@ -101,7 +102,7 @@ export function ChildObject(childType, isValueObject) {
101
102
  return function (type, propertyKey) {
102
103
  var pi = getOrAddPropertyInfo(type, propertyKey);
103
104
  if (childType === undefined) {
104
- throw Error("Unknown child type on ".concat(type.constructor.name, ".").concat(propertyKey, ", you may have a circular dependency. Try use @Attributes.ChildObject(() => Type)"));
105
+ throw Error("Unknown child type on ".concat(Utils.getTypeName(type), ".").concat(propertyKey, ", you may have a circular dependency. Try use @Attributes.ChildObject(() => Type)"));
105
106
  }
106
107
  pi.setPropertyType(childType);
107
108
  if (pi.relationType === RelationType.None) {
@@ -101,6 +101,10 @@ export interface IModelBase extends INonObservableModelBase {
101
101
  readonly isDirty: boolean;
102
102
  readonly readyToSave: boolean;
103
103
  }
104
+ export interface IModelBaseStatic {
105
+ new (): IModelBase;
106
+ typeName: string;
107
+ }
104
108
  export type ObjectFactory = (rawData: object) => object;
105
109
  export interface IObjectFactoryOptions {
106
110
  /** Function that creates an instance of an object based on some input data. */
@@ -1,6 +1,7 @@
1
1
  import { __extends } from "tslib";
2
2
  import { RelationType } from './Misc';
3
3
  import ModelBase from "./ModelBase";
4
+ import { Utils } from "../Utils";
4
5
  var RecursionState = /** @class */ (function () {
5
6
  function RecursionState() {
6
7
  this.stop = false;
@@ -103,7 +104,7 @@ function invokeOnSelfAndChildren(model, state, callback, listCallback, relationT
103
104
  }
104
105
  }
105
106
  catch (error) {
106
- throw "Error on property '".concat(cpi.propertyName, "' on type '").concat(model.constructor.name, "': ").concat(error, ".");
107
+ throw "Error on property '".concat(cpi.propertyName, "' on type '").concat(Utils.getTypeName(model.constructor), "': ").concat(error, ".");
107
108
  }
108
109
  }
109
110
  }
@@ -8,6 +8,7 @@ import ModelProxy from '../Validation/ModelProxy';
8
8
  import NeoTypes from '../AppServices/NeoTypes';
9
9
  import { RelationType } from './Misc';
10
10
  import MethodInfo from './MethodInfo';
11
+ import { Utils } from "../Utils";
11
12
  var inversifyMetadataKey = "inversify:tagged";
12
13
  var hasConvertedSymbol = Symbol("hasConvertedModel");
13
14
  var NeoTypeInfo = /** @class */ (function () {
@@ -57,7 +58,7 @@ var NeoTypeInfo = /** @class */ (function () {
57
58
  });
58
59
  Object.defineProperty(NeoTypeInfo.prototype, "typeName", {
59
60
  get: function () {
60
- return this.objectConstructor.name;
61
+ return Utils.getTypeName(this.objectConstructor);
61
62
  },
62
63
  enumerable: false,
63
64
  configurable: true
@@ -143,7 +144,7 @@ var NeoTypeInfo = /** @class */ (function () {
143
144
  addRulesMethod.call(instance, validationRules);
144
145
  }
145
146
  if (validationRules.rules.some(function (c) { return c instanceof CallbackRule && c.hasArrowFunction; })) {
146
- console.error("Warning: ".concat(this.objectConstructor.name, " has rules which have been added using an arrow function."));
147
+ console.error("Warning: ".concat(this.typeName, " has rules which have been added using an arrow function."));
147
148
  }
148
149
  var modelProxy = new ModelProxy(instance);
149
150
  for (var _i = 0, _a = validationRules.rules; _i < _a.length; _i++) {
@@ -219,7 +220,7 @@ var NeoTypeInfo = /** @class */ (function () {
219
220
  var baseType = Object.getPrototypeOf(self.objectConstructor);
220
221
  if ((baseType === null || baseType === void 0 ? void 0 : baseType.name) === "neoConstructor") {
221
222
  return function () {
222
- throw Error(self.objectConstructor.name + " cannot inherit from a model decorated with @NeoModel.");
223
+ throw Error(self.typeName + " cannot inherit from a model decorated with @NeoModel.");
223
224
  };
224
225
  }
225
226
  var newConstructor = function neoConstructor() {
@@ -269,7 +270,7 @@ var NeoTypeInfo = /** @class */ (function () {
269
270
  options.makeObservable = this.inheritsModelBase;
270
271
  }
271
272
  if (instance[hasConvertedSymbol]) {
272
- throw Error("makeObservable() or makeBindable() has been called multiple times on type ".concat(this.objectConstructor.name, ". Make sure this is only called on the last derived type."));
273
+ throw Error("makeObservable() or makeBindable() has been called multiple times on type ".concat(this.typeName, ". Make sure this is only called on the last derived type."));
273
274
  }
274
275
  else {
275
276
  instance[hasConvertedSymbol] = true;
@@ -278,7 +279,7 @@ var NeoTypeInfo = /** @class */ (function () {
278
279
  return this.modelCreator.convertInstance(instance, options);
279
280
  }
280
281
  catch (e) {
281
- console.error("Error converting model type " + instance.constructor.name);
282
+ console.error("Error converting model type " + Utils.getTypeName(instance.constructor));
282
283
  throw e;
283
284
  }
284
285
  }
@@ -10,6 +10,7 @@ interface IBigDecimal extends IDecimal {
10
10
  round?(precision?: number, roundingType?: number): IBigDecimal;
11
11
  cmp(to: IBigDecimal | number | string): 0 | 1 | -1;
12
12
  plus(number: IBigDecimal | number | string): IBigDecimal;
13
+ minus(number: IBigDecimal | number | string): IBigDecimal;
13
14
  div(number: IBigDecimal | number | string): IBigDecimal;
14
15
  }
15
16
  /**
@@ -24,12 +25,14 @@ export declare class DecimalService<T extends IBigDecimal> implements IDecimalSe
24
25
  private roundFn;
25
26
  constructor(decimalType: IBigDecimalConstructor, roundHalfUpValue: number, roundDownValue: number);
26
27
  isDecimal(value: any): value is IBigDecimal;
27
- createDecimal(value: number | string): T;
28
+ createDecimal(value: number | string | T): T;
28
29
  toNumber(value: number | T): number;
29
30
  round(value: T, precision: number): T;
30
31
  truncate(value: T): T;
31
32
  compare(value1: T, value2: T): 0 | 1 | -1;
32
33
  sum(values: T[]): T;
33
34
  divideBy(value: T, divisor: number | T): T;
35
+ add(value: T, addend: number | T): T;
36
+ subtract(value: T, subtrahend: number | T): T;
34
37
  }
35
38
  export {};
@@ -23,7 +23,12 @@ var DecimalService = /** @class */ (function () {
23
23
  return value instanceof this.decimalType;
24
24
  };
25
25
  DecimalService.prototype.createDecimal = function (value) {
26
- return new this.decimalType(value);
26
+ if (this.isDecimal(value)) {
27
+ return value;
28
+ }
29
+ else {
30
+ return new this.decimalType(value);
31
+ }
27
32
  };
28
33
  DecimalService.prototype.toNumber = function (value) {
29
34
  if (this.isDecimal(value)) {
@@ -48,6 +53,12 @@ var DecimalService = /** @class */ (function () {
48
53
  DecimalService.prototype.divideBy = function (value, divisor) {
49
54
  return value.div(divisor);
50
55
  };
56
+ DecimalService.prototype.add = function (value, addend) {
57
+ return value.plus(addend);
58
+ };
59
+ DecimalService.prototype.subtract = function (value, subtrahend) {
60
+ return value.minus(subtrahend);
61
+ };
51
62
  return DecimalService;
52
63
  }());
53
64
  export { DecimalService };
@@ -4,8 +4,8 @@ export interface IDecimal {
4
4
  export interface IDecimalService<T = IDecimal> {
5
5
  /** Returns true if the provided value is a decimal instance. */
6
6
  isDecimal(value: any): value is IDecimal;
7
- /** Creates a decimal instance from a javascript number. */
8
- createDecimal(value: number | string): T;
7
+ /** Creates a decimal instance from a javascript number, or returns the decimal instance. */
8
+ createDecimal(value: number | string | T): T;
9
9
  /** If the provided value is a decimal, converts it to a number, otherwise returns the number passed in. */
10
10
  toNumber(value: number | T): number;
11
11
  /** Rounds a number using .net like midpoint away from zero rounding. */
@@ -22,4 +22,6 @@ export interface IDecimalService<T = IDecimal> {
22
22
  sum(values: T[]): T;
23
23
  /** Divides value by divisor and returns the result. */
24
24
  divideBy(value: T, divisor: number | T): T;
25
+ add(value: T, addend: number | T): T;
26
+ subtract(value: T, subtrahend: number | T): T;
25
27
  }
@@ -1,5 +1,6 @@
1
1
  import { ValidationDisplayMode } from './Validation/Misc';
2
2
  import { IButtonOptions } from './Components/ButtonOptions';
3
+ import { BorderType } from "./Components/BootstrapTypes";
3
4
  import { DataType } from './Model/Misc';
4
5
  export declare const Settings: {
5
6
  bootstrap: {
@@ -26,15 +27,27 @@ export declare const Settings: {
26
27
  sortDesc: any;
27
28
  /** Icon used in back buttons */
28
29
  backIcon: any;
30
+ shouldSuppress: (context: {
31
+ icon: any;
32
+ component: "button" | "card" | "tab";
33
+ props: any;
34
+ }) => boolean;
29
35
  };
30
36
  /** Grid default settings */
31
37
  grid: {
32
- /** Causes the table to have a border, cells will also have a left and right border. True by default. */
38
+ /** @deprecated Use `borderType` instead. */
33
39
  isBordered: boolean;
40
+ /** @deprecated Use `borderType` instead. */
41
+ isBorderless: boolean;
42
+ /**
43
+ * Specifies the bootstrap border type for neo grids.
44
+ * - Standard = Only horizontal borders.
45
+ * - Bordered = All borders.
46
+ * - Borderless = No borders.
47
+ */
48
+ borderType: BorderType | undefined;
34
49
  /** When specified, every alternating row will receive a slightly darker background color. */
35
50
  isStriped: boolean;
36
- /** Removes the default top and bottom borders from rows. */
37
- isBorderless: boolean;
38
51
  /** When specified, a background color will be applied on a row if it is being hovered over. */
39
52
  showHover: boolean;
40
53
  /** When specified, the table size will be reduced (by reducing the padding sizes in each cell by half). */
@@ -53,6 +66,10 @@ export declare const Settings: {
53
66
  * This will apply to all NeoGrids, but can be overridden per grid.
54
67
  */
55
68
  useStickyHeaders: boolean;
69
+ /**
70
+ * Default styles to apply to buttons added to a button column.
71
+ */
72
+ buttonColumnButtons: IButtonOptions;
56
73
  };
57
74
  modal: {
58
75
  /** Set to true if ModalUtils.showMessage() should show an accept button instead of close button. */
@@ -97,7 +114,7 @@ export declare const Settings: {
97
114
  iconPosition: "body" | "left";
98
115
  };
99
116
  buttons: {
100
- /** Will prevent icons from displaying in buttons if the buttons text content is not empty. */
117
+ /** @deprecated Use `settings.icons.shouldSuppress` instead. */
101
118
  suppressIcons: boolean;
102
119
  };
103
120
  };
package/dist/Settings.js CHANGED
@@ -25,15 +25,23 @@ export var Settings = {
25
25
  sortDesc: "sort-down",
26
26
  /** Icon used in back buttons */
27
27
  backIcon: "arrow-left",
28
+ shouldSuppress: function (context) { return false; },
28
29
  },
29
30
  /** Grid default settings */
30
31
  grid: {
31
- /** Causes the table to have a border, cells will also have a left and right border. True by default. */
32
+ /** @deprecated Use `borderType` instead. */
32
33
  isBordered: true,
34
+ /** @deprecated Use `borderType` instead. */
35
+ isBorderless: false,
36
+ /**
37
+ * Specifies the bootstrap border type for neo grids.
38
+ * - Standard = Only horizontal borders.
39
+ * - Bordered = All borders.
40
+ * - Borderless = No borders.
41
+ */
42
+ borderType: undefined,
33
43
  /** When specified, every alternating row will receive a slightly darker background color. */
34
44
  isStriped: false,
35
- /** Removes the default top and bottom borders from rows. */
36
- isBorderless: false,
37
45
  /** When specified, a background color will be applied on a row if it is being hovered over. */
38
46
  showHover: false,
39
47
  /** When specified, the table size will be reduced (by reducing the padding sizes in each cell by half). */
@@ -76,6 +84,10 @@ export var Settings = {
76
84
  * This will apply to all NeoGrids, but can be overridden per grid.
77
85
  */
78
86
  useStickyHeaders: false,
87
+ /**
88
+ * Default styles to apply to buttons added to a button column.
89
+ */
90
+ buttonColumnButtons: {}
79
91
  },
80
92
  modal: {
81
93
  /** Set to true if ModalUtils.showMessage() should show an accept button instead of close button. */
@@ -129,7 +141,7 @@ export var Settings = {
129
141
  iconPosition: "body",
130
142
  },
131
143
  buttons: {
132
- /** Will prevent icons from displaying in buttons if the buttons text content is not empty. */
144
+ /** @deprecated Use `settings.icons.shouldSuppress` instead. */
133
145
  suppressIcons: false,
134
146
  }
135
147
  };
@@ -3,7 +3,7 @@ import { IHubReceiver } from "./HubReceiver";
3
3
  import { AppServices } from '../';
4
4
  import { IConnection, ConnectionState } from '../ConnectionManager';
5
5
  import { IDisposable } from '../Misc';
6
- export interface IHubBase extends IConnection {
6
+ export interface IHubBase extends IConnection, IDisposable {
7
7
  /**
8
8
  * Connects to the server hub if the connection state is disconnected.
9
9
  * Returns false if the hub is already connected.
@@ -32,7 +32,7 @@ export interface IHubOptions {
32
32
  /** Log level in production. Defaults to Error. */
33
33
  releaseLogLevel: signalR.LogLevel;
34
34
  }
35
- export declare class HubBase implements IHubBase, IDisposable {
35
+ export declare class HubBase implements IHubBase {
36
36
  private url;
37
37
  private authenticationService;
38
38
  private connection;
package/dist/Utils.d.ts CHANGED
@@ -43,7 +43,7 @@ export declare class Utils {
43
43
  static suppressHtmlEncode(html: string): any;
44
44
  static XOR(condition1: boolean, condition2: boolean): boolean;
45
45
  static sameTypes(type1: Function, type2: Function): boolean;
46
- static getTypeName(type: Function): any;
46
+ static getTypeName(type: Function): string;
47
47
  /**
48
48
  * Creates an instance of a model decorated with @NeoModel. Use this in static methods on a model class that is compiled with babel (React projects).
49
49
  * @param type Type to create.
package/dist/Utils.js CHANGED
@@ -71,7 +71,9 @@ var Utils = /** @class */ (function () {
71
71
  return false;
72
72
  };
73
73
  Utils.getTypeName = function (type) {
74
- return type.prototype.constructor.name;
74
+ var _a;
75
+ var constructor = type.prototype.constructor;
76
+ return (_a = constructor.typeName) !== null && _a !== void 0 ? _a : constructor.name;
75
77
  };
76
78
  /**
77
79
  * Creates an instance of a model decorated with @NeoModel. Use this in static methods on a model class that is compiled with babel (React projects).
@@ -1,6 +1,5 @@
1
1
  import { RuleSeverity, ValidationState } from './ValidationState';
2
2
  import { variant } from '../Components';
3
- import React from 'react';
4
3
  export declare class ValidationDisplayInfo {
5
4
  additionalClassName: string;
6
5
  icon: any;
@@ -12,9 +11,6 @@ export declare class ValidationDisplayInfo {
12
11
  variant: variant;
13
12
  get displayText(): string;
14
13
  get editorClassName(): string;
15
- applyToDom(elementProps: React.HTMLProps<HTMLElement> & {
16
- [key: string]: any;
17
- }, addTooltip: boolean): void;
18
14
  }
19
15
  export default class ValidationDisplayHelper {
20
16
  static getDisplayInfo(ruleState: ValidationState, canDisplayAll: boolean): ValidationDisplayInfo;
@@ -1,5 +1,4 @@
1
1
  import { RuleSeverity } from './ValidationState';
2
- import { Utils } from '../Utils';
3
2
  import { Settings } from '../Settings';
4
3
  var ValidationDisplayInfo = /** @class */ (function () {
5
4
  function ValidationDisplayInfo() {
@@ -34,15 +33,6 @@ var ValidationDisplayInfo = /** @class */ (function () {
34
33
  enumerable: false,
35
34
  configurable: true
36
35
  });
37
- ValidationDisplayInfo.prototype.applyToDom = function (elementProps, addTooltip) {
38
- if (this.severity) {
39
- elementProps.className = Utils.joinWithSpaces(elementProps.className, this.editorClassName);
40
- if (addTooltip) {
41
- elementProps["data-tip"] = this.displayText;
42
- elementProps["data-tip-class"] = this.additionalClassName;
43
- }
44
- }
45
- };
46
36
  return ValidationDisplayInfo;
47
37
  }());
48
38
  export { ValidationDisplayInfo };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singularsystems/neo-core",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "Core functionality for the Neo client library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,24 +15,23 @@
15
15
  "author": "Singular Systems",
16
16
  "license": "ISC",
17
17
  "devDependencies": {
18
- "@types/jest": "29.5.13",
19
- "@types/node": "22.7.4",
20
- "@types/react": "18.3.11",
18
+ "@types/jest": "29.5.14",
19
+ "@types/node": "22.13.4",
21
20
  "decimal.js-light": "2.5.1",
22
21
  "jest": "29.7.0",
23
22
  "ts-jest": "29.2.5",
24
- "typescript": "5.6.2"
23
+ "typescript": "5.7.3"
25
24
  },
26
25
  "dependencies": {
27
26
  "@microsoft/signalr": "8.0.7",
28
- "axios": "1.7.7",
27
+ "axios": "1.7.9",
29
28
  "inversify": "6.0.2",
30
29
  "reflect-metadata": "0.2.2",
31
- "tslib": "2.7.0"
30
+ "tslib": "2.8.1"
32
31
  },
33
32
  "peerDependencies": {
34
33
  "axios": ">=1.4.0",
35
34
  "inversify": ">=5.0.1"
36
35
  },
37
- "packageManager": "yarn@4.5.0"
36
+ "packageManager": "yarn@4.6.0"
38
37
  }