@singularsystems/neo-core 1.1.3 → 1.2.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.
@@ -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. */
@@ -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
+ inline?: 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;
@@ -64,6 +64,7 @@ var Deserialiser = /** @class */ (function () {
64
64
  });
65
65
  };
66
66
  Deserialiser.prototype.deserialiseArray = function (from, to, type, itemFactory) {
67
+ var _a;
67
68
  if (!to) {
68
69
  throw "Cannot deserialise array into a non initialised property.";
69
70
  }
@@ -72,6 +73,7 @@ var Deserialiser = /** @class */ (function () {
72
73
  }
73
74
  //create an index of the to objects
74
75
  var toIndex = {};
76
+ var deletedItems = [];
75
77
  for (var i = 0; i < to.length; i++) {
76
78
  toIndex[to[i].entityIdentifier] = to[i];
77
79
  }
@@ -113,7 +115,12 @@ var Deserialiser = /** @class */ (function () {
113
115
  if (deserialise)
114
116
  this.deserialiseObject(fromItem, toItem, addToList);
115
117
  if (addToList || this.options.removeOldItems) {
116
- to.push(toItem);
118
+ if (fromItem.trackingState === TrackingState.Deleted) {
119
+ deletedItems.push(toItem);
120
+ }
121
+ else {
122
+ to.push(toItem);
123
+ }
117
124
  if (hasIdentifier) {
118
125
  toIndex[fromItem.entityIdentifier] = toItem;
119
126
  }
@@ -123,6 +130,9 @@ var Deserialiser = /** @class */ (function () {
123
130
  if (list.deletedList) {
124
131
  list.clearDeletedList();
125
132
  }
133
+ if (deletedItems) {
134
+ (_a = list.deletedList).push.apply(_a, deletedItems);
135
+ }
126
136
  };
127
137
  Deserialiser.prototype.deserialiseDictionary = function (from, to, parentProperty) {
128
138
  for (var key in from) {
@@ -237,7 +247,7 @@ var Deserialiser = /** @class */ (function () {
237
247
  toModel.isNew = false;
238
248
  }
239
249
  else if (from.trackingState === TrackingState.Deleted) {
240
- //TODO: handle deleted objects coming from server?
250
+ toModel.isNew = false;
241
251
  }
242
252
  else {
243
253
  toModel.isSelfDirty = true;
@@ -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
  }
@@ -27,6 +27,11 @@ export declare const Settings: {
27
27
  sortDesc: any;
28
28
  /** Icon used in back buttons */
29
29
  backIcon: any;
30
+ shouldSuppress: (context: {
31
+ icon: any;
32
+ component: "button" | "card" | "tab";
33
+ props: any;
34
+ }) => boolean;
30
35
  };
31
36
  /** Grid default settings */
32
37
  grid: {
@@ -61,6 +66,10 @@ export declare const Settings: {
61
66
  * This will apply to all NeoGrids, but can be overridden per grid.
62
67
  */
63
68
  useStickyHeaders: boolean;
69
+ /**
70
+ * Default styles to apply to buttons added to a button column.
71
+ */
72
+ buttonColumnButtons: IButtonOptions;
64
73
  };
65
74
  modal: {
66
75
  /** Set to true if ModalUtils.showMessage() should show an accept button instead of close button. */
@@ -105,7 +114,7 @@ export declare const Settings: {
105
114
  iconPosition: "body" | "left";
106
115
  };
107
116
  buttons: {
108
- /** Will prevent icons from displaying in buttons if the buttons text content is not empty. */
117
+ /** @deprecated Use `settings.icons.shouldSuppress` instead. */
109
118
  suppressIcons: boolean;
110
119
  };
111
120
  };
package/dist/Settings.js CHANGED
@@ -25,6 +25,7 @@ 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: {
@@ -83,6 +84,10 @@ export var Settings = {
83
84
  * This will apply to all NeoGrids, but can be overridden per grid.
84
85
  */
85
86
  useStickyHeaders: false,
87
+ /**
88
+ * Default styles to apply to buttons added to a button column.
89
+ */
90
+ buttonColumnButtons: {}
86
91
  },
87
92
  modal: {
88
93
  /** Set to true if ModalUtils.showMessage() should show an accept button instead of close button. */
@@ -136,7 +141,7 @@ export var Settings = {
136
141
  iconPosition: "body",
137
142
  },
138
143
  buttons: {
139
- /** Will prevent icons from displaying in buttons if the buttons text content is not empty. */
144
+ /** @deprecated Use `settings.icons.shouldSuppress` instead. */
140
145
  suppressIcons: false,
141
146
  }
142
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;
@@ -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.3",
3
+ "version": "1.2.1",
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
  }
@@ -1,23 +0,0 @@
1
- import { IViewBase } from '../Views/IViewBase';
2
- export declare enum NavigateLocation {
3
- /** Navigating within the app. */
4
- Internal = 0,
5
- /** Navigating to another site / closing the browser. */
6
- External = 1
7
- }
8
- export interface IPageLeaveHandler {
9
- /**
10
- * Called when the windows beforeunload event fires.
11
- * @param view The currently active view.
12
- * @param e beforeunload event.
13
- */
14
- onWindowUnload(view: IViewBase | null, e: BeforeUnloadEvent): void;
15
- /**
16
- * Called when the user tries to leave the page, and viewbase has returned a message prompting the user if they want to leave.
17
- * @param view The currently active view.
18
- * @param prompt The prompt to display to the user.
19
- * @param location If the user is nagivating within the app, or externally.
20
- * @returns A boolean promise with a value indicating whether the user wants to leave the page.
21
- */
22
- onLeavePage(view: IViewBase | null, prompt: string, location: NavigateLocation): Promise<boolean>;
23
- }
@@ -1,7 +0,0 @@
1
- export var NavigateLocation;
2
- (function (NavigateLocation) {
3
- /** Navigating within the app. */
4
- NavigateLocation[NavigateLocation["Internal"] = 0] = "Internal";
5
- /** Navigating to another site / closing the browser. */
6
- NavigateLocation[NavigateLocation["External"] = 1] = "External";
7
- })(NavigateLocation || (NavigateLocation = {}));