@singularsystems/neo-core 1.1.1 → 1.1.3

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.
@@ -18,12 +18,14 @@ var AnimationHelper = /** @class */ (function () {
18
18
  * @param resizeContainer If true, resizes the container to be the same size as the child.
19
19
  */
20
20
  AnimationHelper.prototype.addChild = function (child, resizeContainer) {
21
- child.style.position = "absolute";
22
- child.style.zIndex = this.zIndex++;
23
- if (resizeContainer) {
24
- var computedStyle = window.getComputedStyle(child);
25
- this.container.style.width = (child.offsetWidth + parseFloat(computedStyle.marginLeft || "0") + parseFloat(computedStyle.marginRight || "0")) + "px";
26
- this.container.style.height = (child.offsetHeight + parseFloat(computedStyle.marginTop || "0") + parseFloat(computedStyle.marginBottom || "0")) + "px";
21
+ if (child.offsetWidth) {
22
+ child.style.position = "absolute";
23
+ child.style.zIndex = this.zIndex++;
24
+ if (resizeContainer) {
25
+ var computedStyle = window.getComputedStyle(child);
26
+ this.container.style.width = (child.offsetWidth + parseFloat(computedStyle.marginLeft || "0") + parseFloat(computedStyle.marginRight || "0")) + "px";
27
+ this.container.style.height = (child.offsetHeight + parseFloat(computedStyle.marginTop || "0") + parseFloat(computedStyle.marginBottom || "0")) + "px";
28
+ }
27
29
  }
28
30
  this.previousChild = this.currentChild;
29
31
  this.currentChild = child;
@@ -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;
@@ -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
  }
@@ -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: {
@@ -29,12 +30,19 @@ export declare const Settings: {
29
30
  };
30
31
  /** Grid default settings */
31
32
  grid: {
32
- /** Causes the table to have a border, cells will also have a left and right border. True by default. */
33
+ /** @deprecated Use `borderType` instead. */
33
34
  isBordered: boolean;
35
+ /** @deprecated Use `borderType` instead. */
36
+ isBorderless: boolean;
37
+ /**
38
+ * Specifies the bootstrap border type for neo grids.
39
+ * - Standard = Only horizontal borders.
40
+ * - Bordered = All borders.
41
+ * - Borderless = No borders.
42
+ */
43
+ borderType: BorderType | undefined;
34
44
  /** When specified, every alternating row will receive a slightly darker background color. */
35
45
  isStriped: boolean;
36
- /** Removes the default top and bottom borders from rows. */
37
- isBorderless: boolean;
38
46
  /** When specified, a background color will be applied on a row if it is being hovered over. */
39
47
  showHover: boolean;
40
48
  /** When specified, the table size will be reduced (by reducing the padding sizes in each cell by half). */
package/dist/Settings.js CHANGED
@@ -28,12 +28,19 @@ export var Settings = {
28
28
  },
29
29
  /** Grid default settings */
30
30
  grid: {
31
- /** Causes the table to have a border, cells will also have a left and right border. True by default. */
31
+ /** @deprecated Use `borderType` instead. */
32
32
  isBordered: true,
33
+ /** @deprecated Use `borderType` instead. */
34
+ isBorderless: false,
35
+ /**
36
+ * Specifies the bootstrap border type for neo grids.
37
+ * - Standard = Only horizontal borders.
38
+ * - Bordered = All borders.
39
+ * - Borderless = No borders.
40
+ */
41
+ borderType: undefined,
33
42
  /** When specified, every alternating row will receive a slightly darker background color. */
34
43
  isStriped: false,
35
- /** Removes the default top and bottom borders from rows. */
36
- isBorderless: false,
37
44
  /** When specified, a background color will be applied on a row if it is being hovered over. */
38
45
  showHover: false,
39
46
  /** When specified, the table size will be reduced (by reducing the padding sizes in each cell by half). */
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).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singularsystems/neo-core",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Core functionality for the Neo client library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",