@vixoniccom/modules 2.11.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.
Files changed (59) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/CHANGELOG.md +264 -0
  3. package/dist/index.d.ts +6 -0
  4. package/dist/index.js +31 -0
  5. package/dist/lib/base.d.ts +36 -0
  6. package/dist/lib/base.js +58 -0
  7. package/dist/lib/containers/dynamic-matrix.d.ts +48 -0
  8. package/dist/lib/containers/dynamic-matrix.js +76 -0
  9. package/dist/lib/containers/group.d.ts +21 -0
  10. package/dist/lib/containers/group.js +47 -0
  11. package/dist/lib/containers/index.d.ts +6 -0
  12. package/dist/lib/containers/index.js +13 -0
  13. package/dist/lib/containers/list.d.ts +66 -0
  14. package/dist/lib/containers/list.js +105 -0
  15. package/dist/lib/errors.d.ts +22 -0
  16. package/dist/lib/errors.js +23 -0
  17. package/dist/lib/index.d.ts +29 -0
  18. package/dist/lib/index.js +128 -0
  19. package/dist/lib/inputs/autocomplete.d.ts +31 -0
  20. package/dist/lib/inputs/autocomplete.js +49 -0
  21. package/dist/lib/inputs/color-picker.d.ts +23 -0
  22. package/dist/lib/inputs/color-picker.js +42 -0
  23. package/dist/lib/inputs/date-input.d.ts +35 -0
  24. package/dist/lib/inputs/date-input.js +78 -0
  25. package/dist/lib/inputs/index.d.ts +24 -0
  26. package/dist/lib/inputs/index.js +49 -0
  27. package/dist/lib/inputs/number-input.d.ts +29 -0
  28. package/dist/lib/inputs/number-input.js +53 -0
  29. package/dist/lib/inputs/select-asset-kna.d.ts +34 -0
  30. package/dist/lib/inputs/select-asset-kna.js +50 -0
  31. package/dist/lib/inputs/select-input.d.ts +18 -0
  32. package/dist/lib/inputs/select-input.js +29 -0
  33. package/dist/lib/inputs/service-input.d.ts +27 -0
  34. package/dist/lib/inputs/service-input.js +41 -0
  35. package/dist/lib/inputs/slider.d.ts +33 -0
  36. package/dist/lib/inputs/slider.js +51 -0
  37. package/dist/lib/inputs/switch.d.ts +21 -0
  38. package/dist/lib/inputs/switch.js +39 -0
  39. package/dist/lib/inputs/text-area.d.ts +20 -0
  40. package/dist/lib/inputs/text-area.js +37 -0
  41. package/dist/lib/inputs/text-format.d.ts +28 -0
  42. package/dist/lib/inputs/text-format.js +37 -0
  43. package/dist/lib/inputs/text-input.d.ts +34 -0
  44. package/dist/lib/inputs/text-input.js +64 -0
  45. package/dist/lib/ui/index.d.ts +4 -0
  46. package/dist/lib/ui/index.js +5 -0
  47. package/dist/lib/ui/label.d.ts +18 -0
  48. package/dist/lib/ui/label.js +30 -0
  49. package/dist/lib/utils/index.d.ts +1 -0
  50. package/dist/lib/utils/index.js +22 -0
  51. package/dist/lib/utils/typeDefs.d.ts +7 -0
  52. package/dist/lib/utils/typeDefs.js +18 -0
  53. package/dist/lib/utils/validation.d.ts +7 -0
  54. package/dist/lib/utils/validation.js +26 -0
  55. package/dist/lib/values.d.ts +21 -0
  56. package/dist/lib/values.js +86 -0
  57. package/dist/lib/visibility.d.ts +2 -0
  58. package/dist/lib/visibility.js +20 -0
  59. package/package.json +22 -0
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return function (d, b) {
7
+ extendStatics(d, b);
8
+ function __() { this.constructor = d; }
9
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10
+ };
11
+ })();
12
+ var __assign = (this && this.__assign) || Object.assign || function(t) {
13
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
14
+ s = arguments[i];
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
16
+ t[p] = s[p];
17
+ }
18
+ return t;
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ var base_1 = require("../base");
22
+ var values_1 = require("../values");
23
+ var validation_1 = require("../utils/validation");
24
+ var TextInput = (function (_super) {
25
+ __extends(TextInput, _super);
26
+ function TextInput(options) {
27
+ var _this = _super.call(this, options) || this;
28
+ _this.type = TextInput.type;
29
+ _this.valueTypeDef = function () { return 'string'; };
30
+ _this.description = options.description;
31
+ _this.required = options.required;
32
+ _this.pattern = options.pattern;
33
+ _this.displayFormat = options.displayFormat;
34
+ _this.range = options.range;
35
+ return _this;
36
+ }
37
+ TextInput.prototype.validateInput = function (value) {
38
+ var errors = [];
39
+ errors = errors.concat(validation_1.Validator.required(value, this.required));
40
+ if (this.pattern && value) {
41
+ var reg = new RegExp(this.pattern);
42
+ if (!reg.exec(value))
43
+ errors = errors.concat({ type: 'pattern' });
44
+ }
45
+ if (this.range) {
46
+ var length = value && value.length || 0;
47
+ errors = errors.concat(validation_1.Validator.min(length, this.range.min));
48
+ errors = errors.concat(validation_1.Validator.max(length, this.range.max));
49
+ }
50
+ return errors;
51
+ };
52
+ TextInput.prototype.isValidValue = function (v) {
53
+ return typeof v === 'string';
54
+ };
55
+ TextInput.fromJSON = function (value) {
56
+ return new TextInput(this.parseJSON(value));
57
+ };
58
+ TextInput.parseJSON = function (value) {
59
+ return __assign({}, value, { range: value.range && values_1.RangeValue.fromJSON(value.range) || undefined });
60
+ };
61
+ TextInput.type = 'text-input';
62
+ return TextInput;
63
+ }(base_1.Input));
64
+ exports.TextInput = TextInput;
@@ -0,0 +1,4 @@
1
+ import { Label } from './label';
2
+ export declare const allUIComponents: typeof Label[];
3
+ export declare type UIComponent = Label;
4
+ export { Label };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var label_1 = require("./label");
4
+ exports.Label = label_1.Label;
5
+ exports.allUIComponents = [label_1.Label];
@@ -0,0 +1,18 @@
1
+ import { ConfigurationElement } from '../base';
2
+ export declare class Label extends ConfigurationElement {
3
+ static type: string;
4
+ type: string;
5
+ readonly label: string;
6
+ readonly description?: string;
7
+ readonly show?: string;
8
+ constructor(options: {
9
+ label: string;
10
+ description?: string;
11
+ show?: string;
12
+ });
13
+ static fromJSON(value: {
14
+ label: string;
15
+ description?: string;
16
+ show?: string;
17
+ }): Label;
18
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return function (d, b) {
7
+ extendStatics(d, b);
8
+ function __() { this.constructor = d; }
9
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10
+ };
11
+ })();
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ var base_1 = require("../base");
14
+ var Label = (function (_super) {
15
+ __extends(Label, _super);
16
+ function Label(options) {
17
+ var _this = _super.call(this) || this;
18
+ _this.type = Label.type;
19
+ _this.label = options.label;
20
+ _this.description = options.description;
21
+ _this.show = options.show;
22
+ return _this;
23
+ }
24
+ Label.fromJSON = function (value) {
25
+ return new Label(value);
26
+ };
27
+ Label.type = 'label';
28
+ return Label;
29
+ }(base_1.ConfigurationElement));
30
+ exports.Label = Label;
@@ -0,0 +1 @@
1
+ export declare const createComponentFromJSON: (type: string, value: any) => any;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var ui_1 = require("../ui");
4
+ var inputs_1 = require("../inputs");
5
+ var containers_1 = require("../containers");
6
+ var allComponents = inputs_1.allInputs.concat(ui_1.allUIComponents, containers_1.allContainer);
7
+ exports.createComponentFromJSON = function (type, value) {
8
+ var component = allComponents.find(function (i) {
9
+ return (i.type === type);
10
+ });
11
+ if (component) {
12
+ if (component.fromJSON) {
13
+ return component.fromJSON(value);
14
+ }
15
+ else {
16
+ throw new Error("Component \"" + type + "\" does not implement fromJSON");
17
+ }
18
+ }
19
+ else {
20
+ throw new Error("Invalid component \"" + type + "\"");
21
+ }
22
+ };
@@ -0,0 +1,7 @@
1
+ import { InputComponent } from "../index";
2
+ export declare type TypeDefMap = {
3
+ id: string;
4
+ typeDef: string;
5
+ };
6
+ export declare function getDefsFromInputs(inputs: InputComponent[]): TypeDefMap[];
7
+ export declare function defsMapToString(defsMap: TypeDefMap[]): string;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function getDefsFromInputs(inputs) {
4
+ return inputs.map(function (i) { return ({ id: i.id, typeDef: i.valueTypeDef() }); });
5
+ }
6
+ exports.getDefsFromInputs = getDefsFromInputs;
7
+ function defsMapToString(defsMap) {
8
+ var reduced = [];
9
+ return defsMap.reduce(function (pV, e) {
10
+ var exist = pV.findIndex(function (iE) { return iE.id === e.id; });
11
+ if (exist !== -1) {
12
+ pV[exist].typeDef = pV[exist].typeDef + " | " + e.typeDef;
13
+ return pV;
14
+ }
15
+ return pV.concat(e);
16
+ }, reduced).map(function (e) { return e.id + ": " + e.typeDef; }).join(', ');
17
+ }
18
+ exports.defsMapToString = defsMapToString;
@@ -0,0 +1,7 @@
1
+ import { SimpleValueError, PayloadValueError } from "../errors";
2
+ export declare namespace Validator {
3
+ const required: (value: any, required: boolean | undefined, onlyUndefined?: boolean) => SimpleValueError<"required">[];
4
+ const min: (value: number, min: number | undefined) => PayloadValueError<"min", number>[];
5
+ const max: (value: number, max: number | undefined) => PayloadValueError<"max", number>[];
6
+ const invalidValue: () => SimpleValueError<"invalidValue">[];
7
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var Validator;
4
+ (function (Validator) {
5
+ Validator.required = function (value, required, onlyUndefined) {
6
+ if (onlyUndefined === void 0) { onlyUndefined = false; }
7
+ if ((value === undefined
8
+ || (!onlyUndefined && (typeof value === 'string' && value === '')))
9
+ && required)
10
+ return [{ type: 'required' }];
11
+ return [];
12
+ };
13
+ Validator.min = function (value, min) {
14
+ if (min && value < min)
15
+ return [{ type: 'min', payload: min }];
16
+ return [];
17
+ };
18
+ Validator.max = function (value, max) {
19
+ if (max && value > max)
20
+ return [{ type: 'max', payload: max }];
21
+ return [];
22
+ };
23
+ Validator.invalidValue = function () {
24
+ return [{ type: 'invalidValue' }];
25
+ };
26
+ })(Validator = exports.Validator || (exports.Validator = {}));
@@ -0,0 +1,21 @@
1
+ export declare class RangeValue {
2
+ readonly min: number | undefined;
3
+ readonly max: number | undefined;
4
+ constructor(min?: number | undefined, max?: number | undefined);
5
+ static fromJSON(value: string): RangeValue;
6
+ protected static parseNumber(value: string): number | undefined;
7
+ toJSON(): string;
8
+ }
9
+ export declare class NumberRangeValue extends RangeValue {
10
+ readonly step: number | undefined;
11
+ constructor(min?: number, max?: number, step?: number | undefined);
12
+ static fromJSON(value: string): NumberRangeValue;
13
+ toJSON(): string;
14
+ }
15
+ export declare class DateRangeValue {
16
+ readonly min: string | undefined;
17
+ readonly max: string | undefined;
18
+ constructor(min?: string | undefined, max?: string | undefined);
19
+ static fromJSON(value: string): DateRangeValue;
20
+ toJSON(): string;
21
+ }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return function (d, b) {
7
+ extendStatics(d, b);
8
+ function __() { this.constructor = d; }
9
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10
+ };
11
+ })();
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ var RangeValue = (function () {
14
+ function RangeValue(min, max) {
15
+ this.min = min;
16
+ this.max = max;
17
+ }
18
+ RangeValue.fromJSON = function (value) {
19
+ var reg = new RegExp(/\[(.*):(.*)]/g);
20
+ var match = reg.exec(value);
21
+ var min;
22
+ var max;
23
+ if (match && match.length > 1) {
24
+ min = this.parseNumber(match[1]);
25
+ max = this.parseNumber(match[2]);
26
+ }
27
+ return new RangeValue(min, max);
28
+ };
29
+ RangeValue.parseNumber = function (value) {
30
+ var p = value !== '' ? Number(value) : undefined;
31
+ return p !== undefined && !isNaN(p) ? p : undefined;
32
+ };
33
+ RangeValue.prototype.toJSON = function () {
34
+ return "[" + (this.min !== undefined ? this.min : '') + ":" + (this.max !== undefined ? this.max : '') + "]";
35
+ };
36
+ return RangeValue;
37
+ }());
38
+ exports.RangeValue = RangeValue;
39
+ var NumberRangeValue = (function (_super) {
40
+ __extends(NumberRangeValue, _super);
41
+ function NumberRangeValue(min, max, step) {
42
+ var _this = _super.call(this, min, max) || this;
43
+ _this.step = step;
44
+ return _this;
45
+ }
46
+ NumberRangeValue.fromJSON = function (value) {
47
+ var reg = new RegExp(/\[(.*):(.*):(.*)]/g);
48
+ var match = reg.exec(value);
49
+ var min;
50
+ var max;
51
+ var step;
52
+ if (match && match.length > 2) {
53
+ min = this.parseNumber(match[1]);
54
+ max = this.parseNumber(match[2]);
55
+ step = this.parseNumber(match[3]);
56
+ }
57
+ return new NumberRangeValue(min, max, step);
58
+ };
59
+ NumberRangeValue.prototype.toJSON = function () {
60
+ return "[" + (this.min !== undefined ? this.min : '') + ":" + (this.max !== undefined ? this.max : '') + ":" + (this.step !== undefined ? this.step : '') + "]";
61
+ };
62
+ return NumberRangeValue;
63
+ }(RangeValue));
64
+ exports.NumberRangeValue = NumberRangeValue;
65
+ var DateRangeValue = (function () {
66
+ function DateRangeValue(min, max) {
67
+ this.min = min;
68
+ this.max = max;
69
+ }
70
+ DateRangeValue.fromJSON = function (value) {
71
+ var reg = new RegExp(/\[(.*):(.*)]/g);
72
+ var match = reg.exec(value);
73
+ var min;
74
+ var max;
75
+ if (match && match.length > 2) {
76
+ min = match[1];
77
+ max = match[2];
78
+ }
79
+ return new DateRangeValue(min, max);
80
+ };
81
+ DateRangeValue.prototype.toJSON = function () {
82
+ return "[" + (this.min !== undefined ? this.min : '') + ":" + (this.max !== undefined ? this.max : '') + "]";
83
+ };
84
+ return DateRangeValue;
85
+ }());
86
+ exports.DateRangeValue = DateRangeValue;
@@ -0,0 +1,2 @@
1
+ import { Configuration } from ".";
2
+ export declare function shouldBeVisible(item: any, _values: Configuration.Value): boolean;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function shouldBeVisible(item, _values) {
4
+ if (!item.show)
5
+ return true;
6
+ var jsEval = item.show;
7
+ try {
8
+ var regexp = new RegExp('{{(.*?)}}', 'ig');
9
+ jsEval = jsEval.replace(regexp, "_values.$1");
10
+ // tslint:disable-next-line
11
+ var show = eval(jsEval);
12
+ return show === true;
13
+ }
14
+ catch (e) {
15
+ console.warn('Unable to parse expression:', jsEval);
16
+ console.warn(e);
17
+ return true;
18
+ }
19
+ }
20
+ exports.shouldBeVisible = shouldBeVisible;
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@vixoniccom/modules",
3
+ "version": "2.11.0",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "prepublishOnly": "npm run build",
9
+ "build": "tsc",
10
+ "release": "standard-version",
11
+ "test": "ts-node ./test/index.ts"
12
+ },
13
+ "author": "",
14
+ "license": "ISC",
15
+ "devDependencies": {
16
+ "@types/node": "^8.0.51",
17
+ "jest": "^23.6.0",
18
+ "standard-version": "^4.4.0",
19
+ "ts-node": "^7.0.1",
20
+ "typescript": "^2.4.2"
21
+ }
22
+ }