@aemforms/af-core 0.22.23 → 0.22.25

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 (75) hide show
  1. package/package.json +2 -14
  2. package/lib/cjs/index.cjs +0 -7277
  3. package/lib/esm/BaseNode-dc59ab07.js +0 -478
  4. package/lib/esm/BaseNode.d.ts +0 -93
  5. package/lib/esm/BaseNode.js +0 -26
  6. package/lib/esm/Checkbox.d.ts +0 -79
  7. package/lib/esm/Checkbox.js +0 -63
  8. package/lib/esm/CheckboxGroup.d.ts +0 -18
  9. package/lib/esm/CheckboxGroup.js +0 -60
  10. package/lib/esm/Container.d.ts +0 -53
  11. package/lib/esm/Container.js +0 -311
  12. package/lib/esm/DateField.d.ts +0 -5
  13. package/lib/esm/DateField.js +0 -57
  14. package/lib/esm/Field.d.ts +0 -206
  15. package/lib/esm/Field.js +0 -692
  16. package/lib/esm/Fieldset.d.ts +0 -16
  17. package/lib/esm/Fieldset.js +0 -78
  18. package/lib/esm/FileObject.d.ts +0 -16
  19. package/lib/esm/FileObject.js +0 -48
  20. package/lib/esm/FileUpload.d.ts +0 -22
  21. package/lib/esm/FileUpload.js +0 -141
  22. package/lib/esm/Form.d.ts +0 -113
  23. package/lib/esm/Form.js +0 -208
  24. package/lib/esm/FormInstance.d.ts +0 -13
  25. package/lib/esm/FormInstance.js +0 -129
  26. package/lib/esm/FormMetaData.d.ts +0 -7
  27. package/lib/esm/FormMetaData.js +0 -35
  28. package/lib/esm/InstanceManager.d.ts +0 -9
  29. package/lib/esm/InstanceManager.js +0 -58
  30. package/lib/esm/Node.d.ts +0 -7
  31. package/lib/esm/Node.js +0 -40
  32. package/lib/esm/Scriptable.d.ts +0 -17
  33. package/lib/esm/Scriptable.js +0 -190
  34. package/lib/esm/controller/EventQueue.d.ts +0 -17
  35. package/lib/esm/controller/EventQueue.js +0 -108
  36. package/lib/esm/controller/Events.d.ts +0 -85
  37. package/lib/esm/controller/Events.js +0 -171
  38. package/lib/esm/controller/Logger.d.ts +0 -11
  39. package/lib/esm/controller/Logger.js +0 -52
  40. package/lib/esm/data/DataGroup.d.ts +0 -20
  41. package/lib/esm/data/DataGroup.js +0 -100
  42. package/lib/esm/data/DataValue.d.ts +0 -16
  43. package/lib/esm/data/DataValue.js +0 -68
  44. package/lib/esm/data/EmptyDataValue.d.ts +0 -14
  45. package/lib/esm/data/EmptyDataValue.js +0 -51
  46. package/lib/esm/index.d.ts +0 -21
  47. package/lib/esm/index.js +0 -55
  48. package/lib/esm/rules/FunctionRuntime.d.ts +0 -51
  49. package/lib/esm/rules/FunctionRuntime.js +0 -345
  50. package/lib/esm/rules/RuleEngine.d.ts +0 -12
  51. package/lib/esm/rules/RuleEngine.js +0 -76
  52. package/lib/esm/types/Json.d.ts +0 -119
  53. package/lib/esm/types/Json.js +0 -29
  54. package/lib/esm/types/Model.d.ts +0 -131
  55. package/lib/esm/types/Model.js +0 -30
  56. package/lib/esm/types/index.d.ts +0 -2
  57. package/lib/esm/types/index.js +0 -22
  58. package/lib/esm/utils/DataRefParser.d.ts +0 -27
  59. package/lib/esm/utils/DataRefParser.js +0 -247
  60. package/lib/esm/utils/Fetch.d.ts +0 -8
  61. package/lib/esm/utils/Fetch.js +0 -83
  62. package/lib/esm/utils/FormCreationUtils.d.ts +0 -9
  63. package/lib/esm/utils/FormCreationUtils.js +0 -112
  64. package/lib/esm/utils/FormUtils.d.ts +0 -12
  65. package/lib/esm/utils/FormUtils.js +0 -212
  66. package/lib/esm/utils/JsonUtils.d.ts +0 -11
  67. package/lib/esm/utils/JsonUtils.js +0 -99
  68. package/lib/esm/utils/LogUtils.d.ts +0 -4
  69. package/lib/esm/utils/LogUtils.js +0 -28
  70. package/lib/esm/utils/SchemaUtils.d.ts +0 -3
  71. package/lib/esm/utils/SchemaUtils.js +0 -93
  72. package/lib/esm/utils/TranslationUtils.d.ts +0 -11
  73. package/lib/esm/utils/TranslationUtils.js +0 -138
  74. package/lib/esm/utils/ValidationUtils.d.ts +0 -19
  75. package/lib/esm/utils/ValidationUtils.js +0 -300
@@ -1,78 +0,0 @@
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,16 +0,0 @@
1
- import { IFileObject } from './types/index.js';
2
- export declare class FileObject implements IFileObject {
3
- data: any;
4
- mediaType: string;
5
- name: string;
6
- size: number;
7
- constructor(init?: Partial<FileObject>);
8
- get type(): string;
9
- toJSON(): {
10
- name: string;
11
- size: number;
12
- mediaType: string;
13
- data: any;
14
- };
15
- equals(obj: IFileObject): boolean;
16
- }
@@ -1,48 +0,0 @@
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,22 +0,0 @@
1
- import Field from './Field.js';
2
- import { FieldModel } from './types/index.js';
3
- import DataGroup from './data/DataGroup.js';
4
- declare class FileUpload extends Field implements FieldModel {
5
- protected _getDefaults(): {
6
- accept: string[];
7
- maxFileSize: string;
8
- readOnly: boolean;
9
- enabled: boolean;
10
- visible: boolean;
11
- type: string | undefined;
12
- };
13
- protected _getFallbackType(): string | undefined;
14
- get maxFileSize(): number;
15
- get accept(): string[] | undefined;
16
- protected _applyUpdates(propNames: string[], updates: any): any;
17
- protected getInternalType(): "file" | "file[]";
18
- protected getDataNodeValue(typedValue: any): any;
19
- private _serialize;
20
- importData(dataModel: DataGroup): void;
21
- }
22
- export default FileUpload;
@@ -1,141 +0,0 @@
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 };
package/lib/esm/Form.d.ts DELETED
@@ -1,113 +0,0 @@
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';
7
- declare class Form extends Container<FormJson> implements FormModel {
8
- private _ruleEngine;
9
- private _eventQueue;
10
- private _fields;
11
- _ids: Generator<string, void, string>;
12
- private _invalidFields;
13
- private _logger;
14
- constructor(n: FormJson, fieldFactory: IFormFieldFactory, _ruleEngine: RuleEngine, _eventQueue?: EventQueue, logLevel?: LogLevel);
15
- get logger(): Logger;
16
- private dataRefRegex;
17
- get metaData(): FormMetaData;
18
- get action(): string | undefined;
19
- get lang(): string;
20
- importData(dataModel: any): void;
21
- exportData(): any;
22
- setFocus(field: BaseModel): void;
23
- getState(): {
24
- description?: string | undefined;
25
- } & import("./types/Json.js").RulesJson & {
26
- enumNames?: string[] | undefined;
27
- enum?: any[] | undefined;
28
- } & {
29
- accept?: string[] | undefined;
30
- enforceEnum?: boolean | undefined;
31
- exclusiveMinimum?: number | undefined;
32
- exclusiveMaximum?: number | undefined;
33
- format?: string | undefined;
34
- maxFileSize?: string | number | undefined;
35
- maxLength?: number | undefined;
36
- maximum?: number | undefined;
37
- maxItems?: number | undefined;
38
- minOccur?: number | undefined;
39
- maxOccur?: number | undefined;
40
- minLength?: number | undefined;
41
- minimum?: number | undefined;
42
- minItems?: number | undefined;
43
- pattern?: string | undefined;
44
- required?: boolean | undefined;
45
- step?: number | undefined;
46
- type?: string | undefined;
47
- validationExpression?: string | undefined;
48
- uniqueItems?: boolean | undefined;
49
- } & {
50
- dataRef?: string | null | undefined;
51
- ':type'?: string | undefined;
52
- label?: import("./types/Json.js").Label | undefined;
53
- enabled?: boolean | undefined;
54
- visible?: boolean | undefined;
55
- name?: string | undefined;
56
- constraintMessages?: import("./types/Json.js").ConstraintsMessages | undefined;
57
- fieldType?: string | undefined;
58
- errorMessage?: string | undefined;
59
- properties?: {
60
- [key: string]: any;
61
- } | undefined;
62
- repeatable?: boolean | undefined;
63
- screenReaderText?: string | undefined;
64
- tooltip?: string | undefined;
65
- altText?: string | undefined;
66
- viewType?: string | undefined;
67
- } & {
68
- items: (import("./types/Json.js").FieldJson | import("./types/Json.js").ContainerJson)[];
69
- initialItems?: number | undefined;
70
- activeChild?: string | undefined;
71
- } & {
72
- metadata?: import("./types/Json.js").MetaDataJson | undefined;
73
- data?: any;
74
- title?: string | undefined;
75
- action?: string | undefined;
76
- adaptiveForm?: string | undefined;
77
- lang?: string | undefined;
78
- } & {
79
- items: any[];
80
- properties: {
81
- [key: string]: any;
82
- };
83
- index: number;
84
- parent: undefined;
85
- qualifiedName: any;
86
- events: {};
87
- rules: {};
88
- repeatable: boolean | undefined;
89
- ':type': string;
90
- id: string;
91
- };
92
- get type(): string;
93
- isTransparent(): boolean;
94
- get form(): FormModel;
95
- get ruleEngine(): RuleEngine;
96
- getUniqueId(): string;
97
- fieldAdded(field: FieldModel | FieldsetModel): void;
98
- visit(callBack: (field: FieldModel | FieldsetModel) => void): void;
99
- traverseChild(container: Container<any>, callBack: (field: FieldModel | FieldsetModel) => void): void;
100
- validate(): import("./types/Model.js").ValidationError[];
101
- isValid(): boolean;
102
- dispatch(action: Action): void;
103
- submit(action: Action, context: any): void;
104
- reset(): void;
105
- getElement(id: string): FieldModel | FieldsetModel | this;
106
- get qualifiedName(): string;
107
- getEventQueue(): EventQueue;
108
- get name(): string;
109
- get value(): null;
110
- get id(): string;
111
- get title(): string;
112
- }
113
- export default Form;
package/lib/esm/Form.js DELETED
@@ -1,208 +0,0 @@
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 FormMetaData from './FormMetaData.js';
23
- import EventQueue from './controller/EventQueue.js';
24
- import { Logger } from './controller/Logger.js';
25
- import { IdGenerator, getAttachments } from './utils/FormUtils.js';
26
- import DataGroup from './data/DataGroup.js';
27
- import { submit } from './rules/FunctionRuntime.js';
28
- import { Initialize, ExecuteRule, FormLoad, FieldChanged, ValidationComplete } from './controller/Events.js';
29
- import './BaseNode-dc59ab07.js';
30
- import './utils/DataRefParser.js';
31
- import './data/DataValue.js';
32
- import './data/EmptyDataValue.js';
33
- import './utils/JsonUtils.js';
34
- import './types/Json.js';
35
- import './utils/SchemaUtils.js';
36
- import './Scriptable.js';
37
- import './Node.js';
38
- import './FileObject.js';
39
- import './utils/Fetch.js';
40
-
41
- class Form extends Container {
42
- _ruleEngine;
43
- _eventQueue;
44
- _fields = {};
45
- _ids;
46
- _invalidFields = [];
47
- _logger;
48
- constructor(n, fieldFactory, _ruleEngine, _eventQueue = new EventQueue(), logLevel = 'off') {
49
- super(n, { fieldFactory: fieldFactory });
50
- this._ruleEngine = _ruleEngine;
51
- this._eventQueue = _eventQueue;
52
- this._logger = new Logger(logLevel);
53
- this.queueEvent(new Initialize());
54
- this.queueEvent(new ExecuteRule());
55
- this._ids = IdGenerator();
56
- this._bindToDataModel(new DataGroup('$form', {}));
57
- this._initialize();
58
- this.queueEvent(new FormLoad());
59
- }
60
- get logger() {
61
- return this._logger;
62
- }
63
- dataRefRegex = /("[^"]+?"|[^.]+?)(?:\.|$)/g;
64
- get metaData() {
65
- const metaData = this._jsonModel.metadata || {};
66
- return new FormMetaData(metaData);
67
- }
68
- get action() {
69
- return this._jsonModel.action;
70
- }
71
- get lang() {
72
- return this._jsonModel.lang || 'en';
73
- }
74
- importData(dataModel) {
75
- this._bindToDataModel(new DataGroup('$form', dataModel));
76
- this.syncDataAndFormModel(this.getDataNode());
77
- this._eventQueue.runPendingQueue();
78
- }
79
- exportData() {
80
- return this.getDataNode()?.$value;
81
- }
82
- setFocus(field) {
83
- const parent = field.parent;
84
- const currentField = field;
85
- while (parent != null && parent.activeChild != currentField) {
86
- parent.activeChild = currentField;
87
- }
88
- }
89
- getState() {
90
- const self = this;
91
- const res = super.getState();
92
- res.id = '$form';
93
- Object.defineProperty(res, 'data', {
94
- get: function () {
95
- return self.exportData();
96
- }
97
- });
98
- Object.defineProperty(res, 'attachments', {
99
- get: function () {
100
- return getAttachments(self);
101
- }
102
- });
103
- return res;
104
- }
105
- get type() {
106
- return 'object';
107
- }
108
- isTransparent() {
109
- return false;
110
- }
111
- get form() {
112
- return this;
113
- }
114
- get ruleEngine() {
115
- return this._ruleEngine;
116
- }
117
- getUniqueId() {
118
- if (this._ids == null) {
119
- return '';
120
- }
121
- return this._ids.next().value;
122
- }
123
- fieldAdded(field) {
124
- this._fields[field.id] = field;
125
- field.subscribe((action) => {
126
- if (this._invalidFields.indexOf(action.target.id) === -1) {
127
- this._invalidFields.push(action.target.id);
128
- }
129
- }, 'invalid');
130
- field.subscribe((action) => {
131
- const index = this._invalidFields.indexOf(action.target.id);
132
- if (index > -1) {
133
- this._invalidFields.splice(index, 1);
134
- }
135
- }, 'valid');
136
- field.subscribe((action) => {
137
- const field = action.target.getState();
138
- if (field) {
139
- const fieldChangedAction = new FieldChanged(action.payload.changes, field);
140
- this.dispatch(fieldChangedAction);
141
- }
142
- });
143
- }
144
- visit(callBack) {
145
- this.traverseChild(this, callBack);
146
- }
147
- traverseChild(container, callBack) {
148
- container.items.forEach((field) => {
149
- if (field.isContainer) {
150
- this.traverseChild(field, callBack);
151
- }
152
- callBack(field);
153
- });
154
- }
155
- validate() {
156
- const validationErrors = super.validate();
157
- this.dispatch(new ValidationComplete(validationErrors));
158
- return validationErrors;
159
- }
160
- isValid() {
161
- return this._invalidFields.length === 0;
162
- }
163
- dispatch(action) {
164
- if (action.type === 'submit') {
165
- super.queueEvent(action);
166
- this._eventQueue.runPendingQueue();
167
- }
168
- else {
169
- super.dispatch(action);
170
- }
171
- }
172
- submit(action, context) {
173
- if (this.validate().length === 0) {
174
- const payload = action?.payload || {};
175
- submit(context, payload?.success, payload?.error, payload?.submit_as, payload?.data);
176
- }
177
- }
178
- reset() {
179
- super.reset();
180
- this._invalidFields = [];
181
- }
182
- getElement(id) {
183
- if (id == this.id) {
184
- return this;
185
- }
186
- return this._fields[id];
187
- }
188
- get qualifiedName() {
189
- return '$form';
190
- }
191
- getEventQueue() {
192
- return this._eventQueue;
193
- }
194
- get name() {
195
- return '$form';
196
- }
197
- get value() {
198
- return null;
199
- }
200
- get id() {
201
- return '$form';
202
- }
203
- get title() {
204
- return this._jsonModel.title || '';
205
- }
206
- }
207
-
208
- export { Form as default };
@@ -1,13 +0,0 @@
1
- import { FormModel } from './types/index.js';
2
- import { LogLevel } from './controller/Logger.js';
3
- import { CustomFunction, FunctionDefinition } from './rules/FunctionRuntime.js';
4
- export declare const createFormInstance: (formModel: any, callback?: ((f: FormModel) => any) | undefined, logLevel?: LogLevel, fModel?: any) => FormModel;
5
- export declare const validateFormInstance: (formModel: any, data: any) => boolean;
6
- export declare const validateFormData: (formModel: any, data: any) => {
7
- messages: any[];
8
- valid: boolean;
9
- };
10
- export declare const fetchForm: (url: string, headers?: any) => Promise<string>;
11
- export declare const registerFunctions: (functions: {
12
- [key: string]: Function | FunctionDefinition;
13
- }) => void;