@aemforms/af-core 0.22.36 → 0.22.38
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/lib/EmailInput.d.ts +16 -0
- package/lib/EmailInput.js +12 -0
- package/lib/Field.js +4 -1
- package/lib/utils/FormCreationUtils.js +5 -1
- package/lib/utils/FormUtils.js +4 -9
- package/lib/utils/JsonUtils.d.ts +1 -0
- package/lib/utils/JsonUtils.js +6 -1
- package/lib/utils/ValidationUtils.d.ts +1 -0
- package/lib/utils/ValidationUtils.js +6 -1
- package/package.json +2 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Field from './Field';
|
|
2
|
+
declare class EmailInput extends Field {
|
|
3
|
+
protected _getDefaults(): {
|
|
4
|
+
format: string;
|
|
5
|
+
readOnly: boolean;
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
visible: boolean;
|
|
8
|
+
label: {
|
|
9
|
+
visible: boolean;
|
|
10
|
+
richText: boolean;
|
|
11
|
+
};
|
|
12
|
+
required: boolean;
|
|
13
|
+
type: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export default EmailInput;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Field_1 = __importDefault(require("./Field"));
|
|
7
|
+
class EmailInput extends Field_1.default {
|
|
8
|
+
_getDefaults() {
|
|
9
|
+
return Object.assign(Object.assign({}, super._getDefaults()), { format: 'email' });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = EmailInput;
|
package/lib/Field.js
CHANGED
|
@@ -74,6 +74,7 @@ class Field extends Scriptable_1.default {
|
|
|
74
74
|
'multiline-input': 'string',
|
|
75
75
|
'number-input': 'number',
|
|
76
76
|
'date-input': 'string',
|
|
77
|
+
'email': 'string',
|
|
77
78
|
'plain-text': 'string',
|
|
78
79
|
'image': 'string',
|
|
79
80
|
'checkbox': 'boolean'
|
|
@@ -457,6 +458,8 @@ class Field extends Scriptable_1.default {
|
|
|
457
458
|
switch (this.format) {
|
|
458
459
|
case 'date':
|
|
459
460
|
return ValidationUtils_1.ValidConstraints.date;
|
|
461
|
+
case 'email':
|
|
462
|
+
return ValidationUtils_1.ValidConstraints.email;
|
|
460
463
|
case 'binary':
|
|
461
464
|
return ValidationUtils_1.ValidConstraints.file;
|
|
462
465
|
case 'data-url':
|
|
@@ -660,7 +663,7 @@ __decorate([
|
|
|
660
663
|
(0, BaseNode_1.dependencyTracked)()
|
|
661
664
|
], Field.prototype, "value", null);
|
|
662
665
|
__decorate([
|
|
663
|
-
(0, BaseNode_1.include)('text-input', 'date-input', 'file-input')
|
|
666
|
+
(0, BaseNode_1.include)('text-input', 'date-input', 'file-input', 'email')
|
|
664
667
|
], Field.prototype, "format", null);
|
|
665
668
|
__decorate([
|
|
666
669
|
(0, BaseNode_1.include)('text-input')
|
|
@@ -12,10 +12,11 @@ const Checkbox_1 = __importDefault(require("../Checkbox"));
|
|
|
12
12
|
const CheckboxGroup_1 = __importDefault(require("../CheckboxGroup"));
|
|
13
13
|
const DateField_1 = __importDefault(require("../DateField"));
|
|
14
14
|
const Field_1 = __importDefault(require("../Field"));
|
|
15
|
+
const EmailInput_1 = __importDefault(require("../EmailInput"));
|
|
15
16
|
const alternateFieldTypeMapping = {
|
|
16
17
|
'text': 'text-input',
|
|
17
18
|
'number': 'number-input',
|
|
18
|
-
'email': '
|
|
19
|
+
'email': 'email',
|
|
19
20
|
'file': 'file-input',
|
|
20
21
|
'range': 'range',
|
|
21
22
|
'textarea': 'multiline-input'
|
|
@@ -54,6 +55,9 @@ class FormFieldFactoryImpl {
|
|
|
54
55
|
else if ((0, JsonUtils_1.isCheckboxGroup)(child)) {
|
|
55
56
|
retVal = new CheckboxGroup_1.default(child, options);
|
|
56
57
|
}
|
|
58
|
+
else if ((0, JsonUtils_1.isEmailInput)(child)) {
|
|
59
|
+
retVal = new EmailInput_1.default(child, options);
|
|
60
|
+
}
|
|
57
61
|
else if ((0, JsonUtils_1.isDateField)(child)) {
|
|
58
62
|
retVal = new DateField_1.default(child, options);
|
|
59
63
|
}
|
package/lib/utils/FormUtils.js
CHANGED
|
@@ -202,24 +202,19 @@ const dataURItoBlob = (dataURI) => {
|
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
204
|
exports.dataURItoBlob = dataURItoBlob;
|
|
205
|
-
const
|
|
206
|
-
return (':items' in model || 'cqItems' in model) && (':itemsOrder' in model || 'cqItemsOrder' in model)
|
|
205
|
+
const isFormOrSiteContainer = (model) => {
|
|
206
|
+
return (':items' in model || 'cqItems' in model) && (':itemsOrder' in model || 'cqItemsOrder' in model);
|
|
207
207
|
};
|
|
208
208
|
const sitesModelToFormModel = (sitesModel) => {
|
|
209
209
|
if (!sitesModel || !Object.keys(sitesModel).length) {
|
|
210
210
|
return sitesModel;
|
|
211
211
|
}
|
|
212
|
-
if (
|
|
212
|
+
if (isFormOrSiteContainer(sitesModel)) {
|
|
213
213
|
const itemsArr = [];
|
|
214
214
|
const itemsOrder = sitesModel[':itemsOrder'] || sitesModel.cqItemsOrder;
|
|
215
215
|
const items = sitesModel[':items'] || sitesModel.cqItems;
|
|
216
216
|
itemsOrder.forEach((elemName) => {
|
|
217
|
-
|
|
218
|
-
itemsArr.push((0, exports.sitesModelToFormModel)(items[elemName]));
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
itemsArr.push(items[elemName]);
|
|
222
|
-
}
|
|
217
|
+
itemsArr.push((0, exports.sitesModelToFormModel)(items[elemName]));
|
|
223
218
|
});
|
|
224
219
|
sitesModel.items = itemsArr;
|
|
225
220
|
}
|
package/lib/utils/JsonUtils.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const isFile: (item: FieldsetJson | FieldJson) => boolean;
|
|
|
4
4
|
export declare const checkIfConstraintsArePresent: (item: FieldsetJson | FieldJson) => boolean;
|
|
5
5
|
export declare const isCheckbox: (item: FieldsetJson | FieldJson) => boolean;
|
|
6
6
|
export declare const isCheckboxGroup: (item: FieldsetJson | FieldJson) => boolean;
|
|
7
|
+
export declare const isEmailInput: (item: FieldsetJson | FieldJson) => boolean;
|
|
7
8
|
export declare const isDateField: (item: FieldsetJson | FieldJson) => boolean;
|
|
8
9
|
export declare function deepClone(obj: any, idGenerator?: () => string): any;
|
|
9
10
|
export declare function checkIfKeyAdded(currentObj: any, prevObj: any, objKey: string): boolean;
|
package/lib/utils/JsonUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRepeatable = exports.jsonString = exports.checkIfKeyAdded = exports.deepClone = exports.isDateField = exports.isCheckboxGroup = exports.isCheckbox = exports.checkIfConstraintsArePresent = exports.isFile = exports.getProperty = void 0;
|
|
3
|
+
exports.isRepeatable = exports.jsonString = exports.checkIfKeyAdded = exports.deepClone = exports.isDateField = exports.isEmailInput = exports.isCheckboxGroup = exports.isCheckbox = exports.checkIfConstraintsArePresent = exports.isFile = exports.getProperty = void 0;
|
|
4
4
|
const index_1 = require("../types/index");
|
|
5
5
|
const SchemaUtils_1 = require("./SchemaUtils");
|
|
6
6
|
const getProperty = (data, key, def) => {
|
|
@@ -36,6 +36,11 @@ const isCheckboxGroup = function (item) {
|
|
|
36
36
|
return fieldType === 'checkbox-group';
|
|
37
37
|
};
|
|
38
38
|
exports.isCheckboxGroup = isCheckboxGroup;
|
|
39
|
+
const isEmailInput = function (item) {
|
|
40
|
+
const fieldType = (item === null || item === void 0 ? void 0 : item.fieldType) || (0, SchemaUtils_1.defaultFieldTypes)(item);
|
|
41
|
+
return (fieldType === 'text-input' && (item === null || item === void 0 ? void 0 : item.format) === 'email') || fieldType === 'email';
|
|
42
|
+
};
|
|
43
|
+
exports.isEmailInput = isEmailInput;
|
|
39
44
|
const isDateField = function (item) {
|
|
40
45
|
const fieldType = (item === null || item === void 0 ? void 0 : item.fieldType) || (0, SchemaUtils_1.defaultFieldTypes)(item);
|
|
41
46
|
return (fieldType === 'text-input' && (item === null || item === void 0 ? void 0 : item.format) === 'date') || fieldType === 'date-input';
|
|
@@ -9,6 +9,7 @@ declare type ValidConstraintsType = {
|
|
|
9
9
|
number: ValidationConstraints[];
|
|
10
10
|
array: ValidationConstraints[];
|
|
11
11
|
file: ValidationConstraints[];
|
|
12
|
+
email: ValidationConstraints[];
|
|
12
13
|
};
|
|
13
14
|
export declare const ValidConstraints: ValidConstraintsType;
|
|
14
15
|
export declare type ValidationConstraints = 'type' | 'format' | 'minimum' | 'maximum' | 'exclusiveMinimum' | 'exclusiveMaximum' | 'minItems' | 'maxItems' | 'uniqueItems' | 'minLength' | 'maxLength' | 'pattern' | 'required' | 'enum' | 'accept' | 'maxFileSize';
|
|
@@ -4,6 +4,7 @@ exports.Constraints = exports.ValidConstraints = exports.coerceType = void 0;
|
|
|
4
4
|
const FormUtils_1 = require("./FormUtils");
|
|
5
5
|
const FileObject_1 = require("../FileObject");
|
|
6
6
|
const dateRegex = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
|
|
7
|
+
const emailRegex = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
|
|
7
8
|
const days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
8
9
|
const daysInMonth = (leapYear, month) => {
|
|
9
10
|
if (leapYear && month == 2) {
|
|
@@ -114,7 +115,8 @@ exports.ValidConstraints = {
|
|
|
114
115
|
string: ['minLength', 'maxLength', 'pattern'],
|
|
115
116
|
number: ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum'],
|
|
116
117
|
array: ['minItems', 'maxItems', 'uniqueItems'],
|
|
117
|
-
file: ['accept', 'maxFileSize']
|
|
118
|
+
file: ['accept', 'maxFileSize'],
|
|
119
|
+
email: ['minLength', 'maxLength', 'format', 'pattern']
|
|
118
120
|
};
|
|
119
121
|
exports.Constraints = {
|
|
120
122
|
type: (constraint, inputVal) => {
|
|
@@ -201,6 +203,9 @@ exports.Constraints = {
|
|
|
201
203
|
valid = false;
|
|
202
204
|
}
|
|
203
205
|
break;
|
|
206
|
+
case 'email':
|
|
207
|
+
valid = new RegExp(emailRegex).test((input || '').trim());
|
|
208
|
+
break;
|
|
204
209
|
case 'data-url':
|
|
205
210
|
valid = true;
|
|
206
211
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.38",
|
|
4
4
|
"description": "Core Module for Forms Runtime",
|
|
5
5
|
"author": "Adobe Systems",
|
|
6
6
|
"license": "Adobe Proprietary",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@adobe/json-formula": "0.1.50",
|
|
38
|
-
"@aemforms/af-formatters": "^0.22.
|
|
38
|
+
"@aemforms/af-formatters": "^0.22.38"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@babel/preset-env": "^7.20.2",
|