@aemforms/af-core 0.22.31 → 0.22.33

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 (98) hide show
  1. package/lib/{esm/BaseNode.d.ts → BaseNode.d.ts} +6 -6
  2. package/lib/{esm/BaseNode-f84b22c6.js → BaseNode.js} +58 -94
  3. package/lib/{esm/Checkbox.d.ts → Checkbox.d.ts} +1 -1
  4. package/lib/Checkbox.js +29 -0
  5. package/lib/{esm/CheckboxGroup.d.ts → CheckboxGroup.d.ts} +2 -2
  6. package/lib/CheckboxGroup.js +24 -0
  7. package/lib/{esm/Container.d.ts → Container.d.ts} +4 -4
  8. package/lib/{esm/Container.js → Container.js} +51 -77
  9. package/lib/{esm/DateField.d.ts → DateField.d.ts} +1 -1
  10. package/lib/DateField.js +26 -0
  11. package/lib/{esm/Field.d.ts → Field.d.ts} +7 -7
  12. package/lib/{esm/Field.js → Field.js} +84 -104
  13. package/lib/{esm/Fieldset.d.ts → Fieldset.d.ts} +7 -7
  14. package/lib/{esm/Fieldset.js → Fieldset.js} +14 -43
  15. package/lib/{esm/FileObject.d.ts → FileObject.d.ts} +1 -1
  16. package/lib/FileObject.js +29 -0
  17. package/lib/{esm/FileUpload.d.ts → FileUpload.d.ts} +3 -3
  18. package/lib/FileUpload.js +124 -0
  19. package/lib/{esm/Form.d.ts → Form.d.ts} +12 -12
  20. package/lib/{esm/Form.js → Form.js} +34 -65
  21. package/lib/{esm/FormInstance.d.ts → FormInstance.d.ts} +3 -3
  22. package/lib/FormInstance.js +94 -0
  23. package/lib/{esm/FormMetaData.d.ts → FormMetaData.d.ts} +2 -2
  24. package/lib/FormMetaData.js +15 -0
  25. package/lib/{esm/InstanceManager.d.ts → InstanceManager.d.ts} +2 -2
  26. package/lib/InstanceManager.js +35 -0
  27. package/lib/Node.js +15 -0
  28. package/lib/{esm/Scriptable.d.ts → Scriptable.d.ts} +3 -3
  29. package/lib/{esm/Scriptable.js → Scriptable.js} +17 -38
  30. package/lib/{esm/controller → controller}/EventQueue.d.ts +3 -3
  31. package/lib/{esm/controller → controller}/EventQueue.js +8 -32
  32. package/lib/{esm/controller → controller}/Events.d.ts +2 -2
  33. package/lib/{esm/controller → controller}/Events.js +22 -26
  34. package/lib/{esm/controller → controller}/Logger.d.ts +2 -2
  35. package/lib/controller/Logger.js +33 -0
  36. package/lib/{esm/data → data}/DataGroup.d.ts +1 -1
  37. package/lib/{esm/data → data}/DataGroup.js +20 -38
  38. package/lib/{esm/data → data}/DataValue.d.ts +1 -1
  39. package/lib/{esm/data → data}/DataValue.js +4 -26
  40. package/lib/{esm/data → data}/EmptyDataValue.d.ts +1 -1
  41. package/lib/data/EmptyDataValue.js +34 -0
  42. package/lib/index.d.ts +21 -0
  43. package/lib/index.js +57 -0
  44. package/lib/{esm/rules → rules}/FunctionRuntime.d.ts +3 -3
  45. package/lib/{esm/rules → rules}/FunctionRuntime.js +52 -63
  46. package/lib/{esm/rules → rules}/RuleEngine.d.ts +1 -1
  47. package/lib/rules/RuleEngine.js +51 -0
  48. package/lib/{esm/types → types}/Json.d.ts +16 -16
  49. package/lib/types/Json.js +10 -0
  50. package/lib/{esm/types → types}/Model.d.ts +9 -9
  51. package/lib/types/Model.js +10 -0
  52. package/lib/types/index.d.ts +2 -0
  53. package/lib/types/index.js +18 -0
  54. package/lib/{esm/utils → utils}/DataRefParser.d.ts +4 -4
  55. package/lib/{esm/utils → utils}/DataRefParser.js +30 -45
  56. package/lib/{esm/utils → utils}/Fetch.d.ts +1 -1
  57. package/lib/utils/Fetch.js +74 -0
  58. package/lib/{esm/utils → utils}/FormCreationUtils.d.ts +1 -1
  59. package/lib/utils/FormCreationUtils.js +67 -0
  60. package/lib/{esm/utils → utils}/FormUtils.d.ts +2 -1
  61. package/lib/{esm/utils → utils}/FormUtils.js +62 -46
  62. package/lib/{esm/utils → utils}/JsonUtils.d.ts +1 -1
  63. package/lib/utils/JsonUtils.js +89 -0
  64. package/lib/{esm/utils → utils}/LogUtils.d.ts +1 -1
  65. package/lib/utils/LogUtils.js +10 -0
  66. package/lib/{esm/utils → utils}/SchemaUtils.d.ts +1 -1
  67. package/lib/{esm/utils → utils}/SchemaUtils.js +9 -29
  68. package/lib/{esm/utils → utils}/TranslationUtils.d.ts +2 -2
  69. package/lib/utils/TranslationUtils.js +125 -0
  70. package/lib/{esm/utils → utils}/ValidationUtils.d.ts +4 -4
  71. package/lib/{esm/utils → utils}/ValidationUtils.js +13 -35
  72. package/package.json +8 -13
  73. package/lib/cjs/index.cjs +0 -7426
  74. package/lib/esm/BaseNode.js +0 -26
  75. package/lib/esm/Checkbox.js +0 -63
  76. package/lib/esm/CheckboxGroup.js +0 -60
  77. package/lib/esm/DateField.js +0 -57
  78. package/lib/esm/FileObject.js +0 -48
  79. package/lib/esm/FileUpload.js +0 -141
  80. package/lib/esm/FormInstance.js +0 -129
  81. package/lib/esm/FormMetaData.js +0 -35
  82. package/lib/esm/InstanceManager.js +0 -58
  83. package/lib/esm/Node.js +0 -40
  84. package/lib/esm/controller/Logger.js +0 -52
  85. package/lib/esm/data/EmptyDataValue.js +0 -51
  86. package/lib/esm/index.d.ts +0 -21
  87. package/lib/esm/index.js +0 -55
  88. package/lib/esm/rules/RuleEngine.js +0 -76
  89. package/lib/esm/types/Json.js +0 -29
  90. package/lib/esm/types/Model.js +0 -30
  91. package/lib/esm/types/index.d.ts +0 -2
  92. package/lib/esm/types/index.js +0 -22
  93. package/lib/esm/utils/Fetch.js +0 -83
  94. package/lib/esm/utils/FormCreationUtils.js +0 -112
  95. package/lib/esm/utils/JsonUtils.js +0 -99
  96. package/lib/esm/utils/LogUtils.js +0 -28
  97. package/lib/esm/utils/TranslationUtils.js +0 -138
  98. /package/lib/{esm/Node.d.ts → Node.d.ts} +0 -0
@@ -1,26 +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
- export { B as BaseNode, d as dependencyTracked, b as dynamicProps, a as editableProperties, e as exclude, i as include, q as qualifiedName, s as staticFields, t as target } from './BaseNode-f84b22c6.js';
22
- import './controller/Events.js';
23
- import './utils/DataRefParser.js';
24
- import './data/EmptyDataValue.js';
25
- import './data/DataGroup.js';
26
- import './data/DataValue.js';
@@ -1,63 +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 Field from './Field.js';
22
- import { Constraints } from './utils/ValidationUtils.js';
23
- import './BaseNode-f84b22c6.js';
24
- import './controller/Events.js';
25
- import './utils/DataRefParser.js';
26
- import './data/DataGroup.js';
27
- import './data/DataValue.js';
28
- import './data/EmptyDataValue.js';
29
- import './types/Model.js';
30
- import './Scriptable.js';
31
- import './utils/SchemaUtils.js';
32
- import '@aemforms/af-formatters';
33
- import './utils/FormUtils.js';
34
- import './utils/JsonUtils.js';
35
- import './types/Json.js';
36
- import './FileObject.js';
37
-
38
- const requiredConstraint = (offValue) => (constraint, value) => {
39
- const valid = Constraints.required(constraint, value).valid && (!constraint || value != offValue);
40
- return { valid, value };
41
- };
42
- class Checkbox extends Field {
43
- offValue() {
44
- const opts = this.enum;
45
- return opts.length > 1 ? opts[1] : null;
46
- }
47
- _getConstraintObject() {
48
- const baseConstraints = { ...super._getConstraintObject() };
49
- baseConstraints.required = requiredConstraint(this.offValue());
50
- return baseConstraints;
51
- }
52
- _getDefaults() {
53
- return {
54
- ...super._getDefaults(),
55
- enforceEnum: true
56
- };
57
- }
58
- get enum() {
59
- return this._jsonModel.enum || [];
60
- }
61
- }
62
-
63
- export { Checkbox as default };
@@ -1,60 +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 Field from './Field.js';
22
- import './BaseNode-f84b22c6.js';
23
- import './controller/Events.js';
24
- import './utils/DataRefParser.js';
25
- import './data/DataGroup.js';
26
- import './data/DataValue.js';
27
- import './data/EmptyDataValue.js';
28
- import './types/Model.js';
29
- import './utils/ValidationUtils.js';
30
- import './utils/FormUtils.js';
31
- import './utils/JsonUtils.js';
32
- import './types/Json.js';
33
- import './utils/SchemaUtils.js';
34
- import './FileObject.js';
35
- import './Scriptable.js';
36
- import '@aemforms/af-formatters';
37
-
38
- class CheckboxGroup extends Field {
39
- constructor(params, _options) {
40
- super(params, _options);
41
- }
42
- _getFallbackType() {
43
- const fallbackType = super._getFallbackType();
44
- if (typeof fallbackType === 'string') {
45
- return `${fallbackType}[]`;
46
- }
47
- else {
48
- return 'string[]';
49
- }
50
- }
51
- _getDefaults() {
52
- return {
53
- ...super._getDefaults(),
54
- enforceEnum: true,
55
- enum: []
56
- };
57
- }
58
- }
59
-
60
- export { CheckboxGroup as default };
@@ -1,57 +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 Field from './Field.js';
22
- import { parseDateSkeleton, formatDate } from '@aemforms/af-formatters';
23
- import './BaseNode-f84b22c6.js';
24
- import './controller/Events.js';
25
- import './utils/DataRefParser.js';
26
- import './data/DataGroup.js';
27
- import './data/DataValue.js';
28
- import './data/EmptyDataValue.js';
29
- import './types/Model.js';
30
- import './utils/ValidationUtils.js';
31
- import './utils/FormUtils.js';
32
- import './utils/JsonUtils.js';
33
- import './types/Json.js';
34
- import './utils/SchemaUtils.js';
35
- import './FileObject.js';
36
- import './Scriptable.js';
37
-
38
- class DateField extends Field {
39
- _applyDefaults() {
40
- super._applyDefaults();
41
- const locale = new Intl.DateTimeFormat().resolvedOptions().locale;
42
- if (!this._jsonModel.editFormat) {
43
- this._jsonModel.editFormat = 'short';
44
- }
45
- if (!this._jsonModel.displayFormat) {
46
- this._jsonModel.displayFormat = this._jsonModel.editFormat;
47
- }
48
- if (!this._jsonModel.placeholder) {
49
- this._jsonModel.placeholder = parseDateSkeleton(this._jsonModel.editFormat, locale);
50
- }
51
- if (!this._jsonModel.description) {
52
- this._jsonModel.description = `To enter today's date use ${formatDate(new Date(), locale, this._jsonModel.editFormat)}`;
53
- }
54
- }
55
- }
56
-
57
- export { DateField as default };
@@ -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,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-f84b22c6.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.debug(`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,129 +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 Form from './Form.js';
22
- import { jsonString } from './utils/JsonUtils.js';
23
- import { request } from './utils/Fetch.js';
24
- import RuleEngine from './rules/RuleEngine.js';
25
- import EventQueue from './controller/EventQueue.js';
26
- import { Logger } from './controller/Logger.js';
27
- import { FormFieldFactory } from './utils/FormCreationUtils.js';
28
- import { FunctionRuntime } from './rules/FunctionRuntime.js';
29
- import './Container.js';
30
- import './BaseNode-f84b22c6.js';
31
- import './controller/Events.js';
32
- import './utils/DataRefParser.js';
33
- import './data/DataGroup.js';
34
- import './data/DataValue.js';
35
- import './data/EmptyDataValue.js';
36
- import './Scriptable.js';
37
- import './types/Json.js';
38
- import './utils/SchemaUtils.js';
39
- import './FormMetaData.js';
40
- import './Node.js';
41
- import './utils/FormUtils.js';
42
- import './FileObject.js';
43
- import '@adobe/json-formula';
44
- import './InstanceManager.js';
45
- import './Fieldset.js';
46
- import './FileUpload.js';
47
- import './Field.js';
48
- import './types/Model.js';
49
- import './utils/ValidationUtils.js';
50
- import '@aemforms/af-formatters';
51
- import './Checkbox.js';
52
- import './CheckboxGroup.js';
53
- import './DateField.js';
54
-
55
- const createFormInstance = (formModel, callback, logLevel = 'error', fModel = undefined) => {
56
- try {
57
- let f = fModel;
58
- if (f == null) {
59
- f = new Form({ ...formModel }, FormFieldFactory, new RuleEngine(), new EventQueue(new Logger(logLevel)), logLevel);
60
- }
61
- const formData = formModel?.data;
62
- if (formData) {
63
- f.importData(formData);
64
- }
65
- if (typeof callback === 'function') {
66
- callback(f);
67
- }
68
- f.getEventQueue().runPendingQueue();
69
- return f;
70
- }
71
- catch (e) {
72
- console.error(`Unable to create an instance of the Form ${e}`);
73
- throw new Error(e);
74
- }
75
- };
76
- const validateFormInstance = (formModel, data) => {
77
- try {
78
- const f = new Form({ ...formModel }, FormFieldFactory, new RuleEngine());
79
- if (data) {
80
- f.importData(data);
81
- }
82
- return f.validate().length === 0;
83
- }
84
- catch (e) {
85
- throw new Error(e);
86
- }
87
- };
88
- const validateFormData = (formModel, data) => {
89
- try {
90
- const f = new Form({ ...formModel }, FormFieldFactory, new RuleEngine());
91
- if (data) {
92
- f.importData(data);
93
- }
94
- const res = f.validate();
95
- return {
96
- messages: res,
97
- valid: res.length === 0
98
- };
99
- }
100
- catch (e) {
101
- throw new Error(e);
102
- }
103
- };
104
- const fetchForm = (url, headers = {}) => {
105
- const headerObj = new Headers();
106
- Object.entries(headers).forEach(([key, value]) => {
107
- headerObj.append(key, value);
108
- });
109
- return new Promise((resolve, reject) => {
110
- request(`${url}.model.json`, null, { headers }).then((response) => {
111
- if (response.status !== 200) {
112
- reject('Not Found');
113
- }
114
- else {
115
- let formObj = response.body;
116
- if ('model' in formObj) {
117
- const { model } = formObj;
118
- formObj = model;
119
- }
120
- resolve(jsonString(formObj));
121
- }
122
- });
123
- });
124
- };
125
- const registerFunctions = (functions) => {
126
- FunctionRuntime.registerFunctions(functions);
127
- };
128
-
129
- export { createFormInstance, fetchForm, registerFunctions, validateFormData, validateFormInstance };
@@ -1,35 +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 Node from './Node.js';
22
- import './utils/JsonUtils.js';
23
- import './types/Json.js';
24
- import './utils/SchemaUtils.js';
25
-
26
- class FormMetaData extends Node {
27
- get version() {
28
- return this.getP('version', '');
29
- }
30
- get grammar() {
31
- return this.getP('grammar', '');
32
- }
33
- }
34
-
35
- export { FormMetaData as default };
@@ -1,58 +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 { _ as __decorate, d as dependencyTracked } from './BaseNode-f84b22c6.js';
22
- import { Fieldset } from './Fieldset.js';
23
- import './controller/Events.js';
24
- import './utils/DataRefParser.js';
25
- import './data/DataGroup.js';
26
- import './data/DataValue.js';
27
- import './data/EmptyDataValue.js';
28
- import './Container.js';
29
- import './utils/JsonUtils.js';
30
- import './types/Json.js';
31
- import './utils/SchemaUtils.js';
32
- import './Scriptable.js';
33
-
34
- class InstanceManager extends Fieldset {
35
- get maxOccur() {
36
- return this._jsonModel.maxItems;
37
- }
38
- set maxOccur(m) {
39
- this.maxItems = m;
40
- }
41
- get minOccur() {
42
- return this.minItems;
43
- }
44
- addInstance(action) {
45
- return this.addItem(action);
46
- }
47
- removeInstance(action) {
48
- return this.removeItem(action);
49
- }
50
- }
51
- __decorate([
52
- dependencyTracked()
53
- ], InstanceManager.prototype, "maxOccur", null);
54
- __decorate([
55
- dependencyTracked()
56
- ], InstanceManager.prototype, "minOccur", null);
57
-
58
- export { InstanceManager };
package/lib/esm/Node.js DELETED
@@ -1,40 +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 { getProperty } from './utils/JsonUtils.js';
22
- import './types/Json.js';
23
- import './utils/SchemaUtils.js';
24
-
25
- class Node {
26
- _jsonModel;
27
- constructor(inputModel) {
28
- this._jsonModel = {
29
- ...inputModel
30
- };
31
- }
32
- getP(key, def) {
33
- return getProperty(this._jsonModel, key, def);
34
- }
35
- get isContainer() {
36
- return false;
37
- }
38
- }
39
-
40
- export { Node as default };