@vixoniccom/modules 2.11.0 → 2.12.0-dev.2
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.
- package/.vscode/settings.json +2 -2
- package/CHANGELOG.md +289 -264
- package/dist/index.d.ts +6 -6
- package/dist/index.js +32 -31
- package/dist/lib/base.d.ts +28 -36
- package/dist/lib/base.js +63 -58
- package/dist/lib/containers/dynamic-matrix.d.ts +48 -48
- package/dist/lib/containers/dynamic-matrix.js +85 -76
- package/dist/lib/containers/group.d.ts +21 -21
- package/dist/lib/containers/group.js +56 -47
- package/dist/lib/containers/index.d.ts +6 -6
- package/dist/lib/containers/index.js +14 -13
- package/dist/lib/containers/list.d.ts +66 -66
- package/dist/lib/containers/list.js +114 -105
- package/dist/lib/errors.d.ts +22 -22
- package/dist/lib/errors.js +24 -23
- package/dist/lib/index.d.ts +29 -29
- package/dist/lib/index.js +136 -128
- package/dist/lib/inputs/autocomplete.d.ts +31 -31
- package/dist/lib/inputs/autocomplete.js +55 -49
- package/dist/lib/inputs/color-picker.d.ts +23 -23
- package/dist/lib/inputs/color-picker.js +48 -42
- package/dist/lib/inputs/date-input.d.ts +35 -35
- package/dist/lib/inputs/date-input.js +87 -78
- package/dist/lib/inputs/index.d.ts +24 -24
- package/dist/lib/inputs/index.js +52 -49
- package/dist/lib/inputs/number-input.d.ts +29 -29
- package/dist/lib/inputs/number-input.js +62 -53
- package/dist/lib/inputs/select-asset-kna.d.ts +34 -34
- package/dist/lib/inputs/select-asset-kna.js +56 -50
- package/dist/lib/inputs/select-input.d.ts +18 -18
- package/dist/lib/inputs/select-input.js +35 -29
- package/dist/lib/inputs/service-input.d.ts +27 -27
- package/dist/lib/inputs/service-input.js +47 -41
- package/dist/lib/inputs/slider.d.ts +33 -33
- package/dist/lib/inputs/slider.js +57 -51
- package/dist/lib/inputs/switch.d.ts +21 -21
- package/dist/lib/inputs/switch.js +45 -39
- package/dist/lib/inputs/text-area.d.ts +20 -20
- package/dist/lib/inputs/text-area.js +46 -37
- package/dist/lib/inputs/text-format.d.ts +28 -28
- package/dist/lib/inputs/text-format.js +43 -37
- package/dist/lib/inputs/text-input.d.ts +34 -34
- package/dist/lib/inputs/text-input.js +73 -64
- package/dist/lib/ui/index.d.ts +4 -4
- package/dist/lib/ui/index.js +6 -5
- package/dist/lib/ui/label.d.ts +18 -18
- package/dist/lib/ui/label.js +36 -30
- package/dist/lib/utils/index.d.ts +2 -1
- package/dist/lib/utils/index.js +28 -22
- package/dist/lib/utils/typeDefs.d.ts +7 -7
- package/dist/lib/utils/typeDefs.js +19 -18
- package/dist/lib/utils/validation.d.ts +7 -7
- package/dist/lib/utils/validation.js +27 -26
- package/dist/lib/values.d.ts +21 -21
- package/dist/lib/values.js +92 -86
- package/dist/lib/visibility.d.ts +2 -2
- package/dist/lib/visibility.js +21 -20
- package/package.json +23 -22
|
@@ -1,47 +1,56 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
extendStatics(d, b);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
Group.
|
|
45
|
-
|
|
46
|
-
}(
|
|
47
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.Group = void 0;
|
|
30
|
+
var base_1 = require("../base");
|
|
31
|
+
var inputs_1 = require("../inputs");
|
|
32
|
+
var typeDefs_1 = require("../utils/typeDefs");
|
|
33
|
+
var Group = /** @class */ (function (_super) {
|
|
34
|
+
__extends(Group, _super);
|
|
35
|
+
function Group(options) {
|
|
36
|
+
var _this = _super.call(this, options) || this;
|
|
37
|
+
_this.type = Group.type;
|
|
38
|
+
_this.valueTypeDef = function () {
|
|
39
|
+
return typeDefs_1.getDefsFromInputs(_this.items.filter(inputs_1.isInput));
|
|
40
|
+
};
|
|
41
|
+
_this.items = options.items;
|
|
42
|
+
return _this;
|
|
43
|
+
}
|
|
44
|
+
Group.fromJSON = function (value) {
|
|
45
|
+
var createComponentFromJSON = require('../utils').default;
|
|
46
|
+
return new Group(__assign(__assign({}, value), { items: value.items.map(function (i) {
|
|
47
|
+
return createComponentFromJSON(i.type, i);
|
|
48
|
+
}) }));
|
|
49
|
+
};
|
|
50
|
+
Group.isInstance = function (instance) {
|
|
51
|
+
return instance.type === Group.type;
|
|
52
|
+
};
|
|
53
|
+
Group.type = 'group';
|
|
54
|
+
return Group;
|
|
55
|
+
}(base_1.BaseElement));
|
|
56
|
+
exports.Group = Group;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Group } from './group';
|
|
2
|
-
import { List } from './list';
|
|
3
|
-
import { DynamicMatrix } from './dynamic-matrix';
|
|
4
|
-
export { Group, List, DynamicMatrix };
|
|
5
|
-
export declare type ContainerComponent = Group | List;
|
|
6
|
-
export declare const allContainer: (typeof Group | typeof List | typeof DynamicMatrix)[];
|
|
1
|
+
import { Group } from './group';
|
|
2
|
+
import { List } from './list';
|
|
3
|
+
import { DynamicMatrix } from './dynamic-matrix';
|
|
4
|
+
export { Group, List, DynamicMatrix };
|
|
5
|
+
export declare type ContainerComponent = Group | List;
|
|
6
|
+
export declare const allContainer: (typeof Group | typeof List | typeof DynamicMatrix)[];
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allContainer = exports.DynamicMatrix = exports.List = exports.Group = void 0;
|
|
4
|
+
var group_1 = require("./group");
|
|
5
|
+
Object.defineProperty(exports, "Group", { enumerable: true, get: function () { return group_1.Group; } });
|
|
6
|
+
var list_1 = require("./list");
|
|
7
|
+
Object.defineProperty(exports, "List", { enumerable: true, get: function () { return list_1.List; } });
|
|
8
|
+
var dynamic_matrix_1 = require("./dynamic-matrix");
|
|
9
|
+
Object.defineProperty(exports, "DynamicMatrix", { enumerable: true, get: function () { return dynamic_matrix_1.DynamicMatrix; } });
|
|
10
|
+
exports.allContainer = [
|
|
11
|
+
group_1.Group,
|
|
12
|
+
list_1.List,
|
|
13
|
+
dynamic_matrix_1.DynamicMatrix
|
|
14
|
+
];
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RangeValue } from '../values';
|
|
3
|
-
import { InputComponent } from '../inputs';
|
|
4
|
-
import { UIComponent } from '../ui';
|
|
5
|
-
import { TypeDefMap } from '../utils/typeDefs';
|
|
6
|
-
import { ErrorsMap, Errors } from '../errors';
|
|
7
|
-
import { Configuration } from '..';
|
|
8
|
-
export declare type DisplayClass = '2-lines' | '1-line';
|
|
9
|
-
export declare type DisplayAttributes = {
|
|
10
|
-
title: string;
|
|
11
|
-
subtitle?: string;
|
|
12
|
-
};
|
|
13
|
-
export interface IList extends IBaseElement {
|
|
14
|
-
id: string;
|
|
15
|
-
label: string;
|
|
16
|
-
itemSchema: (InputComponent | UIComponent)[];
|
|
17
|
-
itemDisplayClass: DisplayClass;
|
|
18
|
-
itemDisplayAttributes: DisplayAttributes;
|
|
19
|
-
description?: string;
|
|
20
|
-
range?: RangeValue;
|
|
21
|
-
sortable?: boolean;
|
|
22
|
-
showItemId?: boolean;
|
|
23
|
-
}
|
|
24
|
-
export interface ListJSON extends Omit<IList, 'itemSchema' | 'range'> {
|
|
25
|
-
range?: string;
|
|
26
|
-
itemSchema: {
|
|
27
|
-
type: string;
|
|
28
|
-
}[];
|
|
29
|
-
}
|
|
30
|
-
export declare type ListItem = {
|
|
31
|
-
[key: string]: any;
|
|
32
|
-
__id: string | undefined;
|
|
33
|
-
};
|
|
34
|
-
export declare namespace List {
|
|
35
|
-
type Value = ListItem[];
|
|
36
|
-
type ItemValue = ListItem;
|
|
37
|
-
type Error = {
|
|
38
|
-
type: 'ItemHasNoUniqueId';
|
|
39
|
-
} | {
|
|
40
|
-
type: 'InvalidListValue';
|
|
41
|
-
} | {
|
|
42
|
-
type: 'Min';
|
|
43
|
-
payload: number;
|
|
44
|
-
} | {
|
|
45
|
-
type: 'Max';
|
|
46
|
-
payload: number;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export declare class List extends BaseElement {
|
|
50
|
-
static readonly type
|
|
51
|
-
type: string;
|
|
52
|
-
readonly itemSchema: (InputComponent | UIComponent)[];
|
|
53
|
-
readonly itemDisplayClass: DisplayClass;
|
|
54
|
-
readonly itemDisplayAttributes: DisplayAttributes;
|
|
55
|
-
readonly description?: string;
|
|
56
|
-
readonly range?: RangeValue;
|
|
57
|
-
readonly sortable?: boolean;
|
|
58
|
-
readonly showItemId?: boolean;
|
|
59
|
-
constructor(options: IList);
|
|
60
|
-
validate(value: List.Value | undefined, ctx: Configuration.Value): ErrorsMap | List.Error[];
|
|
61
|
-
validateItem(value: List.ItemValue, ctx: Configuration.Value): Errors<List.Error>;
|
|
62
|
-
isValidValue(v: any): v is List.Value;
|
|
63
|
-
valueTypeDef: () => TypeDefMap;
|
|
64
|
-
static fromJSON(value: ListJSON): List;
|
|
65
|
-
static isInstance(instance: any): instance is List;
|
|
66
|
-
}
|
|
1
|
+
import { BaseElement, IBaseElement } from '../base';
|
|
2
|
+
import { RangeValue } from '../values';
|
|
3
|
+
import { InputComponent } from '../inputs';
|
|
4
|
+
import { UIComponent } from '../ui';
|
|
5
|
+
import { TypeDefMap } from '../utils/typeDefs';
|
|
6
|
+
import { ErrorsMap, Errors } from '../errors';
|
|
7
|
+
import { Configuration } from '..';
|
|
8
|
+
export declare type DisplayClass = '2-lines' | '1-line';
|
|
9
|
+
export declare type DisplayAttributes = {
|
|
10
|
+
title: string;
|
|
11
|
+
subtitle?: string;
|
|
12
|
+
};
|
|
13
|
+
export interface IList extends IBaseElement {
|
|
14
|
+
id: string;
|
|
15
|
+
label: string;
|
|
16
|
+
itemSchema: (InputComponent | UIComponent)[];
|
|
17
|
+
itemDisplayClass: DisplayClass;
|
|
18
|
+
itemDisplayAttributes: DisplayAttributes;
|
|
19
|
+
description?: string;
|
|
20
|
+
range?: RangeValue;
|
|
21
|
+
sortable?: boolean;
|
|
22
|
+
showItemId?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface ListJSON extends Omit<IList, 'itemSchema' | 'range'> {
|
|
25
|
+
range?: string;
|
|
26
|
+
itemSchema: {
|
|
27
|
+
type: string;
|
|
28
|
+
}[];
|
|
29
|
+
}
|
|
30
|
+
export declare type ListItem = {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
__id: string | undefined;
|
|
33
|
+
};
|
|
34
|
+
export declare namespace List {
|
|
35
|
+
type Value = ListItem[];
|
|
36
|
+
type ItemValue = ListItem;
|
|
37
|
+
type Error = {
|
|
38
|
+
type: 'ItemHasNoUniqueId';
|
|
39
|
+
} | {
|
|
40
|
+
type: 'InvalidListValue';
|
|
41
|
+
} | {
|
|
42
|
+
type: 'Min';
|
|
43
|
+
payload: number;
|
|
44
|
+
} | {
|
|
45
|
+
type: 'Max';
|
|
46
|
+
payload: number;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export declare class List extends BaseElement {
|
|
50
|
+
static readonly type = "list";
|
|
51
|
+
type: string;
|
|
52
|
+
readonly itemSchema: (InputComponent | UIComponent)[];
|
|
53
|
+
readonly itemDisplayClass: DisplayClass;
|
|
54
|
+
readonly itemDisplayAttributes: DisplayAttributes;
|
|
55
|
+
readonly description?: string;
|
|
56
|
+
readonly range?: RangeValue;
|
|
57
|
+
readonly sortable?: boolean;
|
|
58
|
+
readonly showItemId?: boolean;
|
|
59
|
+
constructor(options: IList);
|
|
60
|
+
validate(value: List.Value | undefined, ctx: Configuration.Value): ErrorsMap | List.Error[];
|
|
61
|
+
validateItem(value: List.ItemValue, ctx: Configuration.Value): Errors<List.Error>;
|
|
62
|
+
isValidValue(v: any): v is List.Value;
|
|
63
|
+
valueTypeDef: () => TypeDefMap;
|
|
64
|
+
static fromJSON(value: ListJSON): List;
|
|
65
|
+
static isInstance(instance: any): instance is List;
|
|
66
|
+
}
|
|
@@ -1,105 +1,114 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
extendStatics(d, b);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
_this.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
};
|
|
99
|
-
List.
|
|
100
|
-
return
|
|
101
|
-
};
|
|
102
|
-
List.
|
|
103
|
-
|
|
104
|
-
}(
|
|
105
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.List = void 0;
|
|
30
|
+
var base_1 = require("../base");
|
|
31
|
+
var values_1 = require("../values");
|
|
32
|
+
var inputs_1 = require("../inputs");
|
|
33
|
+
var typeDefs_1 = require("../utils/typeDefs");
|
|
34
|
+
var List = /** @class */ (function (_super) {
|
|
35
|
+
__extends(List, _super);
|
|
36
|
+
function List(options) {
|
|
37
|
+
var _this = _super.call(this, options) || this;
|
|
38
|
+
_this.type = List.type;
|
|
39
|
+
_this.valueTypeDef = function () {
|
|
40
|
+
var declarations = [];
|
|
41
|
+
declarations = declarations.concat(typeDefs_1.getDefsFromInputs(_this.itemSchema.filter(inputs_1.isInput)));
|
|
42
|
+
return {
|
|
43
|
+
id: _this.id,
|
|
44
|
+
typeDef: "{" + typeDefs_1.defsMapToString(declarations) + ", __id: string | undefined}[]"
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
_this.itemSchema = options.itemSchema;
|
|
48
|
+
_this.description = options.description;
|
|
49
|
+
_this.range = options.range;
|
|
50
|
+
_this.itemDisplayClass = options.itemDisplayClass;
|
|
51
|
+
_this.itemDisplayAttributes = options.itemDisplayAttributes;
|
|
52
|
+
_this.sortable = options.sortable;
|
|
53
|
+
_this.showItemId = options.showItemId;
|
|
54
|
+
return _this;
|
|
55
|
+
}
|
|
56
|
+
List.prototype.validate = function (value, ctx) {
|
|
57
|
+
var _this = this;
|
|
58
|
+
// Min
|
|
59
|
+
if (this.range && this.range.min) {
|
|
60
|
+
if (!value || value.length < this.range.min) {
|
|
61
|
+
return [{ type: 'Min', payload: this.range.min }];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Max
|
|
65
|
+
if (this.range && this.range.max) {
|
|
66
|
+
if (value && value.length > this.range.max) {
|
|
67
|
+
return [{ type: 'Max', payload: this.range.max }];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// No value, then is valid.
|
|
71
|
+
if (!value)
|
|
72
|
+
return {};
|
|
73
|
+
// Not a valid value.
|
|
74
|
+
if (!this.isValidValue(value))
|
|
75
|
+
return [{ type: 'InvalidListValue' }];
|
|
76
|
+
var itemsErrors = {};
|
|
77
|
+
value && value.map(function (item, index) {
|
|
78
|
+
var itemErrors = _this.validateItem(item, ctx);
|
|
79
|
+
var itemId = item.__id || index;
|
|
80
|
+
itemsErrors[itemId] = itemErrors;
|
|
81
|
+
});
|
|
82
|
+
return itemsErrors;
|
|
83
|
+
};
|
|
84
|
+
List.prototype.validateItem = function (value, ctx) {
|
|
85
|
+
var itemError = {};
|
|
86
|
+
if (value.__id) {
|
|
87
|
+
var itemErrors_1 = {};
|
|
88
|
+
this.itemSchema.forEach(function (input) {
|
|
89
|
+
if (inputs_1.isInput(input)) {
|
|
90
|
+
itemErrors_1[input.id] = input.validate(value[input.id], ctx);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return itemErrors_1;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return [{ type: 'ItemHasNoUniqueId' }];
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
List.prototype.isValidValue = function (v) {
|
|
100
|
+
return v && Array.isArray(v);
|
|
101
|
+
};
|
|
102
|
+
List.fromJSON = function (value) {
|
|
103
|
+
var createComponentFromJSON = require('../utils').default;
|
|
104
|
+
return new List(__assign(__assign({}, value), { range: value.range && values_1.RangeValue.fromJSON(value.range) || undefined, itemSchema: value.itemSchema.map(function (i) {
|
|
105
|
+
return createComponentFromJSON(i.type, i);
|
|
106
|
+
}) }));
|
|
107
|
+
};
|
|
108
|
+
List.isInstance = function (instance) {
|
|
109
|
+
return instance.type === List.type;
|
|
110
|
+
};
|
|
111
|
+
List.type = 'list';
|
|
112
|
+
return List;
|
|
113
|
+
}(base_1.BaseElement));
|
|
114
|
+
exports.List = List;
|
package/dist/lib/errors.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
export declare namespace ValueError {
|
|
2
|
-
type Required = SimpleValueError<'required'>;
|
|
3
|
-
type Min = PayloadValueError<'min', number>;
|
|
4
|
-
type Max = PayloadValueError<'max', number>;
|
|
5
|
-
type InvalidValue = SimpleValueError<'invalidValue'>;
|
|
6
|
-
}
|
|
7
|
-
export interface SimpleValueError<E extends string> {
|
|
8
|
-
type: E;
|
|
9
|
-
}
|
|
10
|
-
export interface PayloadValueError<E extends string, P> extends SimpleValueError<E> {
|
|
11
|
-
payload: P;
|
|
12
|
-
}
|
|
13
|
-
export declare type ValueError<E extends string = string, P = {}> = SimpleValueError<E> | PayloadValueError<E, P>;
|
|
14
|
-
export declare namespace Errors {
|
|
15
|
-
const isMap: (errors: Errors
|
|
16
|
-
const isArray: (errors: Errors
|
|
17
|
-
const any: (errors:
|
|
18
|
-
}
|
|
19
|
-
export declare type Errors<E extends ValueError = ValueError> = E[] | ErrorsMap;
|
|
20
|
-
export interface ErrorsMap<E extends ValueError = ValueError> {
|
|
21
|
-
[id: string]: Errors | undefined;
|
|
22
|
-
}
|
|
1
|
+
export declare namespace ValueError {
|
|
2
|
+
type Required = SimpleValueError<'required'>;
|
|
3
|
+
type Min = PayloadValueError<'min', number>;
|
|
4
|
+
type Max = PayloadValueError<'max', number>;
|
|
5
|
+
type InvalidValue = SimpleValueError<'invalidValue'>;
|
|
6
|
+
}
|
|
7
|
+
export interface SimpleValueError<E extends string> {
|
|
8
|
+
type: E;
|
|
9
|
+
}
|
|
10
|
+
export interface PayloadValueError<E extends string, P> extends SimpleValueError<E> {
|
|
11
|
+
payload: P;
|
|
12
|
+
}
|
|
13
|
+
export declare type ValueError<E extends string = string, P = {}> = SimpleValueError<E> | PayloadValueError<E, P>;
|
|
14
|
+
export declare namespace Errors {
|
|
15
|
+
const isMap: (errors: Errors) => errors is ErrorsMap<ValueError<string, {}>>;
|
|
16
|
+
const isArray: (errors: Errors) => errors is ValueError<string, {}>[];
|
|
17
|
+
const any: (errors: Errors | undefined) => boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare type Errors<E extends ValueError = ValueError> = E[] | ErrorsMap;
|
|
20
|
+
export interface ErrorsMap<E extends ValueError = ValueError> {
|
|
21
|
+
[id: string]: Errors | undefined;
|
|
22
|
+
}
|
package/dist/lib/errors.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Errors = void 0;
|
|
4
|
+
var Errors;
|
|
5
|
+
(function (Errors) {
|
|
6
|
+
Errors.isMap = function (errors) {
|
|
7
|
+
return !Array.isArray(errors);
|
|
8
|
+
};
|
|
9
|
+
Errors.isArray = function (errors) {
|
|
10
|
+
return Array.isArray(errors);
|
|
11
|
+
};
|
|
12
|
+
Errors.any = function (errors) {
|
|
13
|
+
if (!errors)
|
|
14
|
+
return false;
|
|
15
|
+
if (Array.isArray(errors)) {
|
|
16
|
+
return errors.length > 0;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return Object.keys(errors).some(function (k) {
|
|
20
|
+
return Errors.any(errors[k]);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
})(Errors = exports.Errors || (exports.Errors = {}));
|