@aemforms/af-core 0.22.19 → 0.22.22
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/LICENSE +18 -4
- package/lib/cjs/index.cjs +7277 -0
- package/lib/{BaseNode.js → esm/BaseNode-dc59ab07.js} +108 -184
- package/lib/{BaseNode.d.ts → esm/BaseNode.d.ts} +10 -69
- package/lib/esm/BaseNode.js +26 -0
- package/lib/esm/Checkbox.d.ts +79 -0
- package/lib/esm/Checkbox.js +63 -0
- package/lib/{CheckboxGroup.d.ts → esm/CheckboxGroup.d.ts} +2 -14
- package/lib/esm/CheckboxGroup.js +60 -0
- package/lib/{Container.d.ts → esm/Container.d.ts} +12 -59
- package/lib/{Container.js → esm/Container.js} +81 -122
- package/lib/{DateField.d.ts → esm/DateField.d.ts} +1 -1
- package/lib/esm/DateField.js +57 -0
- package/lib/{Field.d.ts → esm/Field.d.ts} +41 -106
- package/lib/{Field.js → esm/Field.js} +186 -216
- package/lib/esm/Fieldset.d.ts +16 -0
- package/lib/esm/Fieldset.js +78 -0
- package/lib/{FileObject.d.ts → esm/FileObject.d.ts} +1 -4
- package/lib/esm/FileObject.js +48 -0
- package/lib/{FileUpload.d.ts → esm/FileUpload.d.ts} +3 -18
- package/lib/esm/FileUpload.js +141 -0
- package/lib/{Form.d.ts → esm/Form.d.ts} +20 -86
- package/lib/esm/Form.js +208 -0
- package/lib/esm/FormInstance.d.ts +13 -0
- package/lib/esm/FormInstance.js +129 -0
- package/lib/esm/FormMetaData.d.ts +7 -0
- package/lib/esm/FormMetaData.js +35 -0
- package/lib/esm/InstanceManager.d.ts +9 -0
- package/lib/esm/InstanceManager.js +58 -0
- package/lib/esm/Node.d.ts +7 -0
- package/lib/esm/Node.js +40 -0
- package/lib/esm/Scriptable.d.ts +17 -0
- package/lib/{Scriptable.js → esm/Scriptable.js} +38 -54
- package/lib/{controller → esm/controller}/EventQueue.d.ts +3 -11
- package/lib/{controller → esm/controller}/EventQueue.js +32 -26
- package/lib/esm/controller/Events.d.ts +85 -0
- package/lib/esm/controller/Events.js +171 -0
- package/lib/{controller → esm/controller}/Logger.d.ts +2 -8
- package/lib/esm/controller/Logger.js +52 -0
- package/lib/{data → esm/data}/DataGroup.d.ts +1 -7
- package/lib/{data → esm/data}/DataGroup.js +38 -34
- package/lib/{data → esm/data}/DataValue.d.ts +1 -7
- package/lib/esm/data/DataValue.js +68 -0
- package/lib/{data → esm/data}/EmptyDataValue.d.ts +1 -1
- package/lib/esm/data/EmptyDataValue.js +51 -0
- package/lib/esm/index.d.ts +21 -0
- package/lib/esm/index.js +55 -0
- package/lib/{rules → esm/rules}/FunctionRuntime.d.ts +3 -25
- package/lib/{rules → esm/rules}/FunctionRuntime.js +66 -117
- package/lib/esm/rules/RuleEngine.d.ts +12 -0
- package/lib/esm/rules/RuleEngine.js +76 -0
- package/lib/esm/types/Json.d.ts +119 -0
- package/lib/esm/types/Json.js +29 -0
- package/lib/esm/types/Model.d.ts +131 -0
- package/lib/esm/types/Model.js +30 -0
- package/lib/esm/types/index.d.ts +2 -0
- package/lib/esm/types/index.js +22 -0
- package/lib/{utils → esm/utils}/DataRefParser.d.ts +4 -7
- package/lib/{utils → esm/utils}/DataRefParser.js +42 -44
- package/lib/{utils → esm/utils}/Fetch.d.ts +1 -7
- package/lib/esm/utils/Fetch.js +83 -0
- package/lib/esm/utils/FormCreationUtils.d.ts +9 -0
- package/lib/esm/utils/FormCreationUtils.js +112 -0
- package/lib/esm/utils/FormUtils.d.ts +12 -0
- package/lib/esm/utils/FormUtils.js +212 -0
- package/lib/esm/utils/JsonUtils.d.ts +11 -0
- package/lib/esm/utils/JsonUtils.js +99 -0
- package/lib/{utils → esm/utils}/LogUtils.d.ts +1 -4
- package/lib/esm/utils/LogUtils.js +28 -0
- package/lib/esm/utils/SchemaUtils.d.ts +3 -0
- package/lib/esm/utils/SchemaUtils.js +93 -0
- package/lib/esm/utils/TranslationUtils.d.ts +11 -0
- package/lib/esm/utils/TranslationUtils.js +138 -0
- package/lib/esm/utils/ValidationUtils.d.ts +19 -0
- package/lib/{utils → esm/utils}/ValidationUtils.js +55 -187
- package/package.json +18 -10
- package/lib/Checkbox.d.ts +0 -88
- package/lib/Checkbox.js +0 -49
- package/lib/CheckboxGroup.js +0 -43
- package/lib/DateField.js +0 -35
- package/lib/Fieldset.d.ts +0 -24
- package/lib/Fieldset.js +0 -74
- package/lib/FileObject.js +0 -39
- package/lib/FileUpload.js +0 -155
- package/lib/Form.js +0 -252
- package/lib/FormInstance.d.ts +0 -38
- package/lib/FormInstance.js +0 -127
- package/lib/FormMetaData.d.ts +0 -11
- package/lib/FormMetaData.js +0 -28
- package/lib/InstanceManager.d.ts +0 -16
- package/lib/InstanceManager.js +0 -53
- package/lib/Node.d.ts +0 -12
- package/lib/Node.js +0 -27
- package/lib/Scriptable.d.ts +0 -31
- package/lib/controller/Controller.d.ts +0 -255
- package/lib/controller/Controller.js +0 -328
- package/lib/controller/Logger.js +0 -36
- package/lib/controller/index.d.ts +0 -1
- package/lib/controller/index.js +0 -24
- package/lib/data/DataValue.js +0 -56
- package/lib/data/EmptyDataValue.js +0 -46
- package/lib/index.d.ts +0 -28
- package/lib/index.js +0 -63
- package/lib/rules/RuleEngine.d.ts +0 -23
- package/lib/rules/RuleEngine.js +0 -62
- package/lib/types/Json.d.ts +0 -138
- package/lib/types/Json.js +0 -19
- package/lib/types/Model.d.ts +0 -393
- package/lib/types/Model.js +0 -20
- package/lib/types/index.d.ts +0 -2
- package/lib/types/index.js +0 -25
- package/lib/utils/Fetch.js +0 -87
- package/lib/utils/FormCreationUtils.d.ts +0 -11
- package/lib/utils/FormCreationUtils.js +0 -83
- package/lib/utils/FormUtils.d.ts +0 -47
- package/lib/utils/FormUtils.js +0 -257
- package/lib/utils/JsonUtils.d.ts +0 -63
- package/lib/utils/JsonUtils.js +0 -157
- package/lib/utils/LogUtils.js +0 -17
- package/lib/utils/SchemaUtils.d.ts +0 -16
- package/lib/utils/SchemaUtils.js +0 -92
- package/lib/utils/TranslationUtils.d.ts +0 -41
- package/lib/utils/TranslationUtils.js +0 -185
- package/lib/utils/ValidationUtils.d.ts +0 -170
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Container from './Container.js';
|
|
2
|
+
import { ContainerModel, FieldsetJson, FieldsetModel, FormModel, IFormFieldFactory } from './types/index.js';
|
|
3
|
+
export declare class Fieldset extends Container<FieldsetJson> implements FieldsetModel {
|
|
4
|
+
constructor(params: FieldsetJson, _options: {
|
|
5
|
+
form: FormModel;
|
|
6
|
+
parent: ContainerModel;
|
|
7
|
+
fieldFactory: IFormFieldFactory;
|
|
8
|
+
});
|
|
9
|
+
private _applyDefaults;
|
|
10
|
+
get type(): "array" | "object" | undefined;
|
|
11
|
+
get items(): (import("./types/Model.js").FieldModel | FieldsetModel)[];
|
|
12
|
+
get value(): null;
|
|
13
|
+
get fieldType(): string;
|
|
14
|
+
get enabled(): boolean | undefined;
|
|
15
|
+
set enabled(e: boolean | undefined);
|
|
16
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/*************************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* ___________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2022 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
|
|
17
|
+
* Adobe permits you to use and modify this file solely in accordance with
|
|
18
|
+
* the terms of the Adobe license agreement accompanying it.
|
|
19
|
+
*************************************************************************/
|
|
20
|
+
|
|
21
|
+
import Container from './Container.js';
|
|
22
|
+
import { Initialize, ExecuteRule } from './controller/Events.js';
|
|
23
|
+
import './BaseNode-dc59ab07.js';
|
|
24
|
+
import './utils/DataRefParser.js';
|
|
25
|
+
import './data/DataGroup.js';
|
|
26
|
+
import './data/DataValue.js';
|
|
27
|
+
import './data/EmptyDataValue.js';
|
|
28
|
+
import './utils/JsonUtils.js';
|
|
29
|
+
import './types/Json.js';
|
|
30
|
+
import './utils/SchemaUtils.js';
|
|
31
|
+
import './Scriptable.js';
|
|
32
|
+
|
|
33
|
+
const defaults = {
|
|
34
|
+
visible: true,
|
|
35
|
+
enabled: true
|
|
36
|
+
};
|
|
37
|
+
class Fieldset extends Container {
|
|
38
|
+
constructor(params, _options) {
|
|
39
|
+
super(params, _options);
|
|
40
|
+
this._applyDefaults();
|
|
41
|
+
this.queueEvent(new Initialize());
|
|
42
|
+
this.queueEvent(new ExecuteRule());
|
|
43
|
+
}
|
|
44
|
+
_applyDefaults() {
|
|
45
|
+
Object.entries(defaults).map(([key, value]) => {
|
|
46
|
+
if (this._jsonModel[key] === undefined) {
|
|
47
|
+
this._jsonModel[key] = value;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (this._jsonModel.dataRef && this._jsonModel.type === undefined) {
|
|
51
|
+
this._jsonModel.type = 'object';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
get type() {
|
|
55
|
+
const ret = super.type;
|
|
56
|
+
if (ret === 'array' || ret === 'object') {
|
|
57
|
+
return ret;
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
get items() {
|
|
62
|
+
return super.items;
|
|
63
|
+
}
|
|
64
|
+
get value() {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
get fieldType() {
|
|
68
|
+
return 'panel';
|
|
69
|
+
}
|
|
70
|
+
get enabled() {
|
|
71
|
+
return this._jsonModel.enabled;
|
|
72
|
+
}
|
|
73
|
+
set enabled(e) {
|
|
74
|
+
this._setProperty('enabled', e);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { Fieldset };
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { IFileObject } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Defines a file object which implements the {@link IFileObject | file object interface}
|
|
4
|
-
*/
|
|
1
|
+
import { IFileObject } from './types/index.js';
|
|
5
2
|
export declare class FileObject implements IFileObject {
|
|
6
3
|
data: any;
|
|
7
4
|
mediaType: string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*************************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* ___________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2022 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
|
|
17
|
+
* Adobe permits you to use and modify this file solely in accordance with
|
|
18
|
+
* the terms of the Adobe license agreement accompanying it.
|
|
19
|
+
*************************************************************************/
|
|
20
|
+
|
|
21
|
+
class FileObject {
|
|
22
|
+
data;
|
|
23
|
+
mediaType = 'application/octet-stream';
|
|
24
|
+
name = 'unknown';
|
|
25
|
+
size = 0;
|
|
26
|
+
constructor(init) {
|
|
27
|
+
Object.assign(this, init);
|
|
28
|
+
}
|
|
29
|
+
get type() {
|
|
30
|
+
return this.mediaType;
|
|
31
|
+
}
|
|
32
|
+
toJSON() {
|
|
33
|
+
return {
|
|
34
|
+
'name': this.name,
|
|
35
|
+
'size': this.size,
|
|
36
|
+
'mediaType': this.mediaType,
|
|
37
|
+
'data': this.data.toString()
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
equals(obj) {
|
|
41
|
+
return (this.data === obj.data &&
|
|
42
|
+
this.mediaType === obj.mediaType &&
|
|
43
|
+
this.name === obj.name &&
|
|
44
|
+
this.size === obj.size);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { FileObject };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import Field from './Field';
|
|
2
|
-
import { FieldModel } from './types';
|
|
3
|
-
import DataGroup from './data/DataGroup';
|
|
4
|
-
/**
|
|
5
|
-
* Implementation of FileUpload runtime model which extends from {@link Field | field}
|
|
6
|
-
*/
|
|
1
|
+
import Field from './Field.js';
|
|
2
|
+
import { FieldModel } from './types/index.js';
|
|
3
|
+
import DataGroup from './data/DataGroup.js';
|
|
7
4
|
declare class FileUpload extends Field implements FieldModel {
|
|
8
5
|
protected _getDefaults(): {
|
|
9
6
|
accept: string[];
|
|
@@ -14,20 +11,8 @@ declare class FileUpload extends Field implements FieldModel {
|
|
|
14
11
|
type: string | undefined;
|
|
15
12
|
};
|
|
16
13
|
protected _getFallbackType(): string | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Returns the max file size in bytes as per IEC specification
|
|
19
|
-
*/
|
|
20
14
|
get maxFileSize(): number;
|
|
21
|
-
/**
|
|
22
|
-
* Returns the list of mime types which file attachment can accept
|
|
23
|
-
*/
|
|
24
15
|
get accept(): string[] | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Checks whether there are any updates in the properties
|
|
27
|
-
* @param propNames
|
|
28
|
-
* @param updates
|
|
29
|
-
* @private
|
|
30
|
-
*/
|
|
31
16
|
protected _applyUpdates(propNames: string[], updates: any): any;
|
|
32
17
|
protected getInternalType(): "file" | "file[]";
|
|
33
18
|
protected getDataNodeValue(typedValue: any): any;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/*************************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* ___________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2022 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
|
|
17
|
+
* Adobe permits you to use and modify this file solely in accordance with
|
|
18
|
+
* the terms of the Adobe license agreement accompanying it.
|
|
19
|
+
*************************************************************************/
|
|
20
|
+
|
|
21
|
+
import { propertyChange } from './controller/Events.js';
|
|
22
|
+
import Field from './Field.js';
|
|
23
|
+
import { getFileSizeInBytes } from './utils/FormUtils.js';
|
|
24
|
+
import { FileObject } from './FileObject.js';
|
|
25
|
+
import { Constraints } from './utils/ValidationUtils.js';
|
|
26
|
+
import './BaseNode-dc59ab07.js';
|
|
27
|
+
import './utils/DataRefParser.js';
|
|
28
|
+
import './data/DataGroup.js';
|
|
29
|
+
import './data/DataValue.js';
|
|
30
|
+
import './data/EmptyDataValue.js';
|
|
31
|
+
import './types/Model.js';
|
|
32
|
+
import './Scriptable.js';
|
|
33
|
+
import './utils/SchemaUtils.js';
|
|
34
|
+
import '@aemforms/af-formatters';
|
|
35
|
+
import './utils/JsonUtils.js';
|
|
36
|
+
import './types/Json.js';
|
|
37
|
+
|
|
38
|
+
function addNameToDataURL(dataURL, name) {
|
|
39
|
+
return dataURL.replace(';base64', `;name=${encodeURIComponent(name)};base64`);
|
|
40
|
+
}
|
|
41
|
+
function processFiles(files) {
|
|
42
|
+
return Promise.all([].map.call(files, processFile));
|
|
43
|
+
}
|
|
44
|
+
async function processFile(file) {
|
|
45
|
+
const { name, size, type } = file;
|
|
46
|
+
const fileObj = await new Promise((resolve, reject) => {
|
|
47
|
+
const reader = new FileReader();
|
|
48
|
+
reader.onload = event => {
|
|
49
|
+
resolve(new FileObject({
|
|
50
|
+
data: addNameToDataURL(event.target.result, name),
|
|
51
|
+
type,
|
|
52
|
+
name,
|
|
53
|
+
size
|
|
54
|
+
}));
|
|
55
|
+
};
|
|
56
|
+
reader.readAsDataURL(file.data);
|
|
57
|
+
});
|
|
58
|
+
return fileObj;
|
|
59
|
+
}
|
|
60
|
+
class FileUpload extends Field {
|
|
61
|
+
_getDefaults() {
|
|
62
|
+
return {
|
|
63
|
+
...super._getDefaults(),
|
|
64
|
+
accept: ['audio/*', 'video/*', 'image/*', 'text/*', 'application/pdf'],
|
|
65
|
+
maxFileSize: '2MB'
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
_getFallbackType() {
|
|
69
|
+
return 'file';
|
|
70
|
+
}
|
|
71
|
+
get maxFileSize() {
|
|
72
|
+
return getFileSizeInBytes(this._jsonModel.maxFileSize);
|
|
73
|
+
}
|
|
74
|
+
get accept() {
|
|
75
|
+
return this._jsonModel.accept;
|
|
76
|
+
}
|
|
77
|
+
_applyUpdates(propNames, updates) {
|
|
78
|
+
return propNames.reduce((acc, propertyName) => {
|
|
79
|
+
const prevValue = this._jsonModel[propertyName];
|
|
80
|
+
const currentValue = updates[propertyName];
|
|
81
|
+
if (currentValue !== prevValue) {
|
|
82
|
+
acc[propertyName] = {
|
|
83
|
+
propertyName,
|
|
84
|
+
currentValue,
|
|
85
|
+
prevValue
|
|
86
|
+
};
|
|
87
|
+
if (prevValue instanceof FileObject && typeof currentValue === 'object' && propertyName === 'value') {
|
|
88
|
+
this._jsonModel[propertyName] = new FileObject({ ...prevValue, ...{ 'data': currentValue.data } });
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
this._jsonModel[propertyName] = currentValue;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return acc;
|
|
95
|
+
}, {});
|
|
96
|
+
}
|
|
97
|
+
getInternalType() {
|
|
98
|
+
return this.type?.endsWith('[]') ? 'file[]' : 'file';
|
|
99
|
+
}
|
|
100
|
+
getDataNodeValue(typedValue) {
|
|
101
|
+
let dataNodeValue = typedValue;
|
|
102
|
+
if (dataNodeValue != null) {
|
|
103
|
+
if (this.type === 'string') {
|
|
104
|
+
dataNodeValue = dataNodeValue.data?.toString();
|
|
105
|
+
}
|
|
106
|
+
else if (this.type === 'string[]') {
|
|
107
|
+
dataNodeValue = dataNodeValue instanceof Array ? dataNodeValue : [dataNodeValue];
|
|
108
|
+
dataNodeValue = dataNodeValue.map((_) => _?.data?.toString());
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return dataNodeValue;
|
|
112
|
+
}
|
|
113
|
+
async _serialize() {
|
|
114
|
+
const val = this._jsonModel.value;
|
|
115
|
+
if (val === undefined) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const filesInfo = await processFiles(val instanceof Array ? val : [val]);
|
|
119
|
+
return filesInfo;
|
|
120
|
+
}
|
|
121
|
+
importData(dataModel) {
|
|
122
|
+
this._bindToDataModel(dataModel);
|
|
123
|
+
const dataNode = this.getDataNode();
|
|
124
|
+
if (dataNode !== undefined) {
|
|
125
|
+
const value = dataNode?.$value;
|
|
126
|
+
if (value != null) {
|
|
127
|
+
const res = Constraints.type(this.getInternalType(), value);
|
|
128
|
+
if (!res.valid) {
|
|
129
|
+
this.form.logger.error(`unable to bind ${this.name} to data`);
|
|
130
|
+
}
|
|
131
|
+
this.form.getEventQueue().queue(this, propertyChange('value', res.value, this._jsonModel.value));
|
|
132
|
+
this._jsonModel.value = res.value;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this._jsonModel.value = null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export { FileUpload as default };
|
|
@@ -1,57 +1,28 @@
|
|
|
1
|
-
import Container from './Container';
|
|
2
|
-
import { Action, BaseModel,
|
|
3
|
-
import FormMetaData from './FormMetaData';
|
|
4
|
-
import EventQueue from './controller/EventQueue';
|
|
5
|
-
import { Logger, LogLevel } from './controller/Logger';
|
|
6
|
-
import RuleEngine from './rules/RuleEngine';
|
|
7
|
-
/**
|
|
8
|
-
* Defines `form model` which implements {@link FormModel | form model}
|
|
9
|
-
*/
|
|
1
|
+
import Container from './Container.js';
|
|
2
|
+
import { Action, BaseModel, FieldModel, FieldsetModel, FormJson, FormModel, IFormFieldFactory } from './types/index.js';
|
|
3
|
+
import FormMetaData from './FormMetaData.js';
|
|
4
|
+
import EventQueue from './controller/EventQueue.js';
|
|
5
|
+
import { Logger, LogLevel } from './controller/Logger.js';
|
|
6
|
+
import RuleEngine from './rules/RuleEngine.js';
|
|
10
7
|
declare class Form extends Container<FormJson> implements FormModel {
|
|
11
8
|
private _ruleEngine;
|
|
12
9
|
private _eventQueue;
|
|
13
|
-
/**
|
|
14
|
-
* @private
|
|
15
|
-
*/
|
|
16
10
|
private _fields;
|
|
17
|
-
/**
|
|
18
|
-
* @private
|
|
19
|
-
*/
|
|
20
11
|
_ids: Generator<string, void, string>;
|
|
21
|
-
/**
|
|
22
|
-
* @private
|
|
23
|
-
*/
|
|
24
12
|
private _invalidFields;
|
|
25
13
|
private _logger;
|
|
26
|
-
|
|
27
|
-
* @param n
|
|
28
|
-
* @param _ruleEngine
|
|
29
|
-
* @param _eventQueue
|
|
30
|
-
* @param logLevel
|
|
31
|
-
* @private
|
|
32
|
-
*/
|
|
33
|
-
constructor(n: FormJson, _ruleEngine: RuleEngine, _eventQueue?: EventQueue, logLevel?: LogLevel);
|
|
14
|
+
constructor(n: FormJson, fieldFactory: IFormFieldFactory, _ruleEngine: RuleEngine, _eventQueue?: EventQueue, logLevel?: LogLevel);
|
|
34
15
|
get logger(): Logger;
|
|
35
16
|
private dataRefRegex;
|
|
36
17
|
get metaData(): FormMetaData;
|
|
37
18
|
get action(): string | undefined;
|
|
38
|
-
|
|
19
|
+
get lang(): string;
|
|
39
20
|
importData(dataModel: any): void;
|
|
40
21
|
exportData(): any;
|
|
41
22
|
setFocus(field: BaseModel): void;
|
|
42
|
-
/**
|
|
43
|
-
* Returns the current state of the form
|
|
44
|
-
*
|
|
45
|
-
* To access the form data and attachments, one needs to use the `data` and `attachments` property.
|
|
46
|
-
* For example,
|
|
47
|
-
* ```
|
|
48
|
-
* const data = form.getState().data
|
|
49
|
-
* const attachments = form.getState().attachments
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
23
|
getState(): {
|
|
53
24
|
description?: string | undefined;
|
|
54
|
-
} & import("./types").RulesJson & {
|
|
25
|
+
} & import("./types/Json.js").RulesJson & {
|
|
55
26
|
enumNames?: string[] | undefined;
|
|
56
27
|
enum?: any[] | undefined;
|
|
57
28
|
} & {
|
|
@@ -63,9 +34,7 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
63
34
|
maxFileSize?: string | number | undefined;
|
|
64
35
|
maxLength?: number | undefined;
|
|
65
36
|
maximum?: number | undefined;
|
|
66
|
-
maxItems?: number | undefined;
|
|
67
|
-
* @private
|
|
68
|
-
*/
|
|
37
|
+
maxItems?: number | undefined;
|
|
69
38
|
minOccur?: number | undefined;
|
|
70
39
|
maxOccur?: number | undefined;
|
|
71
40
|
minLength?: number | undefined;
|
|
@@ -80,11 +49,11 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
80
49
|
} & {
|
|
81
50
|
dataRef?: string | null | undefined;
|
|
82
51
|
':type'?: string | undefined;
|
|
83
|
-
label?: import("./types").Label | undefined;
|
|
52
|
+
label?: import("./types/Json.js").Label | undefined;
|
|
84
53
|
enabled?: boolean | undefined;
|
|
85
54
|
visible?: boolean | undefined;
|
|
86
55
|
name?: string | undefined;
|
|
87
|
-
constraintMessages?: import("./types").ConstraintsMessages | undefined;
|
|
56
|
+
constraintMessages?: import("./types/Json.js").ConstraintsMessages | undefined;
|
|
88
57
|
fieldType?: string | undefined;
|
|
89
58
|
errorMessage?: string | undefined;
|
|
90
59
|
properties?: {
|
|
@@ -94,19 +63,18 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
94
63
|
screenReaderText?: string | undefined;
|
|
95
64
|
tooltip?: string | undefined;
|
|
96
65
|
altText?: string | undefined;
|
|
66
|
+
viewType?: string | undefined;
|
|
97
67
|
} & {
|
|
98
|
-
items: (FieldJson | import("./types").ContainerJson)[];
|
|
68
|
+
items: (import("./types/Json.js").FieldJson | import("./types/Json.js").ContainerJson)[];
|
|
99
69
|
initialItems?: number | undefined;
|
|
100
70
|
activeChild?: string | undefined;
|
|
101
71
|
} & {
|
|
102
|
-
metadata?: import("./types").MetaDataJson | undefined;
|
|
72
|
+
metadata?: import("./types/Json.js").MetaDataJson | undefined;
|
|
103
73
|
data?: any;
|
|
104
74
|
title?: string | undefined;
|
|
105
75
|
action?: string | undefined;
|
|
106
|
-
adaptiveForm?: string | undefined;
|
|
107
|
-
|
|
108
|
-
* @private
|
|
109
|
-
*/
|
|
76
|
+
adaptiveForm?: string | undefined;
|
|
77
|
+
lang?: string | undefined;
|
|
110
78
|
} & {
|
|
111
79
|
items: any[];
|
|
112
80
|
properties: {
|
|
@@ -117,6 +85,7 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
117
85
|
qualifiedName: any;
|
|
118
86
|
events: {};
|
|
119
87
|
rules: {};
|
|
88
|
+
repeatable: boolean | undefined;
|
|
120
89
|
':type': string;
|
|
121
90
|
id: string;
|
|
122
91
|
};
|
|
@@ -125,51 +94,16 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
125
94
|
get form(): FormModel;
|
|
126
95
|
get ruleEngine(): RuleEngine;
|
|
127
96
|
getUniqueId(): string;
|
|
128
|
-
/**
|
|
129
|
-
* @param field
|
|
130
|
-
* @private
|
|
131
|
-
*/
|
|
132
97
|
fieldAdded(field: FieldModel | FieldsetModel): void;
|
|
133
|
-
/**
|
|
134
|
-
* visits each element in the form
|
|
135
|
-
* @param callBack a function which is invoked on each form element
|
|
136
|
-
* (including container type elements) visited
|
|
137
|
-
*/
|
|
138
98
|
visit(callBack: (field: FieldModel | FieldsetModel) => void): void;
|
|
139
|
-
/**
|
|
140
|
-
*
|
|
141
|
-
* @param container
|
|
142
|
-
* @param callBack
|
|
143
|
-
* @private
|
|
144
|
-
*/
|
|
145
99
|
traverseChild(container: Container<any>, callBack: (field: FieldModel | FieldsetModel) => void): void;
|
|
146
|
-
validate(): import("./types").ValidationError[];
|
|
147
|
-
/**
|
|
148
|
-
* Checks if the given form is valid or not
|
|
149
|
-
* @returns `true`, if form is valid, `false` otherwise
|
|
150
|
-
*/
|
|
100
|
+
validate(): import("./types/Model.js").ValidationError[];
|
|
151
101
|
isValid(): boolean;
|
|
152
|
-
/**
|
|
153
|
-
* @param field
|
|
154
|
-
* @private
|
|
155
|
-
*/
|
|
156
102
|
dispatch(action: Action): void;
|
|
157
|
-
/**
|
|
158
|
-
* @param action
|
|
159
|
-
* @private
|
|
160
|
-
*/
|
|
161
|
-
executeAction(action: Action): void;
|
|
162
|
-
/**
|
|
163
|
-
* @param action
|
|
164
|
-
* @param context
|
|
165
|
-
* @private
|
|
166
|
-
*/
|
|
167
103
|
submit(action: Action, context: any): void;
|
|
104
|
+
reset(): void;
|
|
168
105
|
getElement(id: string): FieldModel | FieldsetModel | this;
|
|
169
106
|
get qualifiedName(): string;
|
|
170
|
-
/**
|
|
171
|
-
* @private
|
|
172
|
-
*/
|
|
173
107
|
getEventQueue(): EventQueue;
|
|
174
108
|
get name(): string;
|
|
175
109
|
get value(): null;
|