@aemforms/af-core 0.22.82 → 0.22.84
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/esm/afb-runtime.js +30 -0
- package/esm/types/src/Button.d.ts +5 -0
- package/esm/types/src/Checkbox.d.ts +1 -0
- package/esm/types/src/Field.d.ts +1 -0
- package/esm/types/src/Form.d.ts +3 -0
- package/esm/types/src/Scriptable.d.ts +3 -1
- package/esm/types/src/types/Json.d.ts +1 -0
- package/esm/types/src/types/Model.d.ts +1 -0
- package/esm/types/src/utils/JsonUtils.d.ts +1 -0
- package/lib/Button.d.ts +5 -0
- package/lib/Button.js +22 -0
- package/lib/Checkbox.d.ts +1 -0
- package/lib/Field.d.ts +1 -0
- package/lib/Form.d.ts +3 -0
- package/lib/Form.js +10 -0
- package/lib/Scriptable.d.ts +3 -1
- package/lib/types/Json.d.ts +1 -0
- package/lib/types/Model.d.ts +1 -0
- package/lib/utils/FormCreationUtils.js +4 -0
- package/lib/utils/JsonUtils.d.ts +1 -0
- package/lib/utils/JsonUtils.js +5 -1
- package/package.json +2 -2
package/esm/afb-runtime.js
CHANGED
|
@@ -147,6 +147,9 @@ const isCaptcha = function (item) {
|
|
|
147
147
|
const fieldType = item?.fieldType || defaultFieldTypes(item);
|
|
148
148
|
return fieldType === 'captcha';
|
|
149
149
|
};
|
|
150
|
+
const isButton = function (item) {
|
|
151
|
+
return item?.fieldType === 'button';
|
|
152
|
+
};
|
|
150
153
|
function deepClone(obj, idGenerator) {
|
|
151
154
|
let result;
|
|
152
155
|
if (obj instanceof Array) {
|
|
@@ -3003,12 +3006,22 @@ class Form extends Container {
|
|
|
3003
3006
|
_applyDefaultsInModel() {
|
|
3004
3007
|
const current = this.specVersion;
|
|
3005
3008
|
this._jsonModel.properties = this._jsonModel.properties || {};
|
|
3009
|
+
this._jsonModel.fieldType = this._jsonModel.fieldType || 'form';
|
|
3006
3010
|
if (current.lessThan(changeEventVersion) ||
|
|
3007
3011
|
typeof this._jsonModel.properties['fd:changeEventBehaviour'] !== 'string') {
|
|
3008
3012
|
this._jsonModel.properties['fd:changeEventBehaviour'] = 'self';
|
|
3009
3013
|
}
|
|
3010
3014
|
}
|
|
3011
3015
|
_logger;
|
|
3016
|
+
get activeField() {
|
|
3017
|
+
return this._findActiveField(this);
|
|
3018
|
+
}
|
|
3019
|
+
_findActiveField(field) {
|
|
3020
|
+
if (!field?.isContainer) {
|
|
3021
|
+
return field;
|
|
3022
|
+
}
|
|
3023
|
+
return this._findActiveField(field?.activeChild);
|
|
3024
|
+
}
|
|
3012
3025
|
get logger() {
|
|
3013
3026
|
return this._logger;
|
|
3014
3027
|
}
|
|
@@ -4441,6 +4454,20 @@ class Captcha extends Field {
|
|
|
4441
4454
|
}
|
|
4442
4455
|
}
|
|
4443
4456
|
|
|
4457
|
+
class Button extends Field {
|
|
4458
|
+
click() {
|
|
4459
|
+
if (this._events?.click || !this._jsonModel.buttonType) {
|
|
4460
|
+
return;
|
|
4461
|
+
}
|
|
4462
|
+
if (this._jsonModel.buttonType === 'submit') {
|
|
4463
|
+
return this.form.dispatch(new Submit());
|
|
4464
|
+
}
|
|
4465
|
+
if (this._jsonModel.buttonType === 'reset') {
|
|
4466
|
+
return this.form.dispatch(new Reset());
|
|
4467
|
+
}
|
|
4468
|
+
}
|
|
4469
|
+
}
|
|
4470
|
+
|
|
4444
4471
|
const alternateFieldTypeMapping = {
|
|
4445
4472
|
'text': 'text-input',
|
|
4446
4473
|
'number': 'number-input',
|
|
@@ -4505,6 +4532,9 @@ class FormFieldFactoryImpl {
|
|
|
4505
4532
|
else if (isCaptcha(child)) {
|
|
4506
4533
|
retVal = new Captcha(child, options);
|
|
4507
4534
|
}
|
|
4535
|
+
else if (isButton(child)) {
|
|
4536
|
+
retVal = new Button(child, options);
|
|
4537
|
+
}
|
|
4508
4538
|
else {
|
|
4509
4539
|
retVal = new Field(child, options);
|
|
4510
4540
|
}
|
|
@@ -135,6 +135,7 @@ declare class Checkbox extends Field {
|
|
|
135
135
|
tooltip?: string | undefined;
|
|
136
136
|
altText?: string | undefined;
|
|
137
137
|
viewType?: string | undefined;
|
|
138
|
+
buttonType?: string | undefined;
|
|
138
139
|
placeholder?: string | undefined;
|
|
139
140
|
valid?: boolean | undefined;
|
|
140
141
|
validity?: any;
|
package/esm/types/src/Field.d.ts
CHANGED
|
@@ -204,6 +204,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
204
204
|
tooltip?: string | undefined;
|
|
205
205
|
altText?: string | undefined;
|
|
206
206
|
viewType?: string | undefined;
|
|
207
|
+
buttonType?: string | undefined;
|
|
207
208
|
placeholder?: string | undefined;
|
|
208
209
|
valid?: boolean | undefined;
|
|
209
210
|
validity?: any;
|
package/esm/types/src/Form.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
18
18
|
constructor(n: FormJson, fieldFactory: IFormFieldFactory, _ruleEngine: RuleEngine, _eventQueue?: EventQueue, logLevel?: LogLevel, mode?: FormCreationMode);
|
|
19
19
|
protected _applyDefaultsInModel(): void;
|
|
20
20
|
private _logger;
|
|
21
|
+
get activeField(): FieldModel;
|
|
22
|
+
_findActiveField(field: FieldsetModel | FieldModel | null): any;
|
|
21
23
|
get logger(): Logger;
|
|
22
24
|
get changeEventBehaviour(): "deps" | "self";
|
|
23
25
|
private dataRefRegex;
|
|
@@ -76,6 +78,7 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
76
78
|
tooltip?: string | undefined;
|
|
77
79
|
altText?: string | undefined;
|
|
78
80
|
viewType?: string | undefined;
|
|
81
|
+
buttonType?: string | undefined;
|
|
79
82
|
} & {
|
|
80
83
|
items: (import("./types/Json").FieldJson | import("./types/Json").ContainerJson)[];
|
|
81
84
|
initialItems?: number | undefined;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Action, RulesJson, ScriptableField } from './types/index';
|
|
2
2
|
import { BaseNode } from './BaseNode';
|
|
3
3
|
declare abstract class Scriptable<T extends RulesJson> extends BaseNode<T> implements ScriptableField {
|
|
4
|
-
|
|
4
|
+
protected _events: {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
};
|
|
5
7
|
private _rules;
|
|
6
8
|
getRules(): import("./types/Json").Items<string>;
|
|
7
9
|
private getCompiledRule;
|
|
@@ -102,6 +102,7 @@ export interface FieldsetModel extends ContainerModel, WithState<FieldsetJson> {
|
|
|
102
102
|
type?: 'array' | 'object';
|
|
103
103
|
}
|
|
104
104
|
export interface FormModel extends ContainerModel, WithState<FormJson> {
|
|
105
|
+
activeField: FieldModel;
|
|
105
106
|
readonly id: string;
|
|
106
107
|
readonly data?: any;
|
|
107
108
|
readonly metadata?: MetaDataJson;
|
|
@@ -7,6 +7,7 @@ export declare const isCheckboxGroup: (item: FieldsetJson | FieldJson) => boolea
|
|
|
7
7
|
export declare const isEmailInput: (item: FieldsetJson | FieldJson) => boolean;
|
|
8
8
|
export declare const isDateField: (item: FieldsetJson | FieldJson) => boolean;
|
|
9
9
|
export declare const isCaptcha: (item: FieldsetJson | FieldJson) => boolean;
|
|
10
|
+
export declare const isButton: (item: FieldsetJson | FieldJson) => boolean;
|
|
10
11
|
export declare function deepClone(obj: any, idGenerator?: () => string): any;
|
|
11
12
|
export declare function checkIfKeyAdded(currentObj: any, prevObj: any, objKey: string): boolean;
|
|
12
13
|
export declare const jsonString: (obj: any) => string;
|
package/lib/Button.d.ts
ADDED
package/lib/Button.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
const Events_1 = require("./controller/Events");
|
|
8
|
+
class Button extends Field_1.default {
|
|
9
|
+
click() {
|
|
10
|
+
var _a;
|
|
11
|
+
if (((_a = this._events) === null || _a === void 0 ? void 0 : _a.click) || !this._jsonModel.buttonType) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (this._jsonModel.buttonType === 'submit') {
|
|
15
|
+
return this.form.dispatch(new Events_1.Submit());
|
|
16
|
+
}
|
|
17
|
+
if (this._jsonModel.buttonType === 'reset') {
|
|
18
|
+
return this.form.dispatch(new Events_1.Reset());
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = Button;
|
package/lib/Checkbox.d.ts
CHANGED
|
@@ -135,6 +135,7 @@ declare class Checkbox extends Field {
|
|
|
135
135
|
tooltip?: string | undefined;
|
|
136
136
|
altText?: string | undefined;
|
|
137
137
|
viewType?: string | undefined;
|
|
138
|
+
buttonType?: string | undefined;
|
|
138
139
|
placeholder?: string | undefined;
|
|
139
140
|
valid?: boolean | undefined;
|
|
140
141
|
validity?: any;
|
package/lib/Field.d.ts
CHANGED
|
@@ -204,6 +204,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
204
204
|
tooltip?: string | undefined;
|
|
205
205
|
altText?: string | undefined;
|
|
206
206
|
viewType?: string | undefined;
|
|
207
|
+
buttonType?: string | undefined;
|
|
207
208
|
placeholder?: string | undefined;
|
|
208
209
|
valid?: boolean | undefined;
|
|
209
210
|
validity?: any;
|
package/lib/Form.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
18
18
|
constructor(n: FormJson, fieldFactory: IFormFieldFactory, _ruleEngine: RuleEngine, _eventQueue?: EventQueue, logLevel?: LogLevel, mode?: FormCreationMode);
|
|
19
19
|
protected _applyDefaultsInModel(): void;
|
|
20
20
|
private _logger;
|
|
21
|
+
get activeField(): FieldModel;
|
|
22
|
+
_findActiveField(field: FieldsetModel | FieldModel | null): any;
|
|
21
23
|
get logger(): Logger;
|
|
22
24
|
get changeEventBehaviour(): "deps" | "self";
|
|
23
25
|
private dataRefRegex;
|
|
@@ -76,6 +78,7 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
76
78
|
tooltip?: string | undefined;
|
|
77
79
|
altText?: string | undefined;
|
|
78
80
|
viewType?: string | undefined;
|
|
81
|
+
buttonType?: string | undefined;
|
|
79
82
|
} & {
|
|
80
83
|
items: (import("./types/Json").FieldJson | import("./types/Json").ContainerJson)[];
|
|
81
84
|
initialItems?: number | undefined;
|
package/lib/Form.js
CHANGED
|
@@ -54,11 +54,21 @@ class Form extends Container_1.default {
|
|
|
54
54
|
_applyDefaultsInModel() {
|
|
55
55
|
const current = this.specVersion;
|
|
56
56
|
this._jsonModel.properties = this._jsonModel.properties || {};
|
|
57
|
+
this._jsonModel.fieldType = this._jsonModel.fieldType || 'form';
|
|
57
58
|
if (current.lessThan(changeEventVersion) ||
|
|
58
59
|
typeof this._jsonModel.properties['fd:changeEventBehaviour'] !== 'string') {
|
|
59
60
|
this._jsonModel.properties['fd:changeEventBehaviour'] = 'self';
|
|
60
61
|
}
|
|
61
62
|
}
|
|
63
|
+
get activeField() {
|
|
64
|
+
return this._findActiveField(this);
|
|
65
|
+
}
|
|
66
|
+
_findActiveField(field) {
|
|
67
|
+
if (!(field === null || field === void 0 ? void 0 : field.isContainer)) {
|
|
68
|
+
return field;
|
|
69
|
+
}
|
|
70
|
+
return this._findActiveField(field === null || field === void 0 ? void 0 : field.activeChild);
|
|
71
|
+
}
|
|
62
72
|
get logger() {
|
|
63
73
|
return this._logger;
|
|
64
74
|
}
|
package/lib/Scriptable.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Action, RulesJson, ScriptableField } from './types/index';
|
|
2
2
|
import { BaseNode } from './BaseNode';
|
|
3
3
|
declare abstract class Scriptable<T extends RulesJson> extends BaseNode<T> implements ScriptableField {
|
|
4
|
-
|
|
4
|
+
protected _events: {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
};
|
|
5
7
|
private _rules;
|
|
6
8
|
getRules(): import("./types/Json").Items<string>;
|
|
7
9
|
private getCompiledRule;
|
package/lib/types/Json.d.ts
CHANGED
package/lib/types/Model.d.ts
CHANGED
|
@@ -102,6 +102,7 @@ export interface FieldsetModel extends ContainerModel, WithState<FieldsetJson> {
|
|
|
102
102
|
type?: 'array' | 'object';
|
|
103
103
|
}
|
|
104
104
|
export interface FormModel extends ContainerModel, WithState<FormJson> {
|
|
105
|
+
activeField: FieldModel;
|
|
105
106
|
readonly id: string;
|
|
106
107
|
readonly data?: any;
|
|
107
108
|
readonly metadata?: MetaDataJson;
|
|
@@ -14,6 +14,7 @@ const DateField_1 = __importDefault(require("../DateField"));
|
|
|
14
14
|
const Field_1 = __importDefault(require("../Field"));
|
|
15
15
|
const EmailInput_1 = __importDefault(require("../EmailInput"));
|
|
16
16
|
const Captcha_1 = __importDefault(require("../Captcha"));
|
|
17
|
+
const Button_1 = __importDefault(require("../Button"));
|
|
17
18
|
const alternateFieldTypeMapping = {
|
|
18
19
|
'text': 'text-input',
|
|
19
20
|
'number': 'number-input',
|
|
@@ -65,6 +66,9 @@ class FormFieldFactoryImpl {
|
|
|
65
66
|
else if ((0, JsonUtils_1.isCaptcha)(child)) {
|
|
66
67
|
retVal = new Captcha_1.default(child, options);
|
|
67
68
|
}
|
|
69
|
+
else if ((0, JsonUtils_1.isButton)(child)) {
|
|
70
|
+
retVal = new Button_1.default(child, options);
|
|
71
|
+
}
|
|
68
72
|
else {
|
|
69
73
|
retVal = new Field_1.default(child, options);
|
|
70
74
|
}
|
package/lib/utils/JsonUtils.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare const isCheckboxGroup: (item: FieldsetJson | FieldJson) => boolea
|
|
|
7
7
|
export declare const isEmailInput: (item: FieldsetJson | FieldJson) => boolean;
|
|
8
8
|
export declare const isDateField: (item: FieldsetJson | FieldJson) => boolean;
|
|
9
9
|
export declare const isCaptcha: (item: FieldsetJson | FieldJson) => boolean;
|
|
10
|
+
export declare const isButton: (item: FieldsetJson | FieldJson) => boolean;
|
|
10
11
|
export declare function deepClone(obj: any, idGenerator?: () => string): any;
|
|
11
12
|
export declare function checkIfKeyAdded(currentObj: any, prevObj: any, objKey: string): boolean;
|
|
12
13
|
export declare const jsonString: (obj: any) => string;
|
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.isCaptcha = exports.isDateField = exports.isEmailInput = exports.isCheckboxGroup = exports.isCheckbox = exports.checkIfConstraintsArePresent = exports.isFile = exports.getProperty = void 0;
|
|
3
|
+
exports.isRepeatable = exports.jsonString = exports.checkIfKeyAdded = exports.deepClone = exports.isButton = exports.isCaptcha = 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) => {
|
|
@@ -51,6 +51,10 @@ const isCaptcha = function (item) {
|
|
|
51
51
|
return fieldType === 'captcha';
|
|
52
52
|
};
|
|
53
53
|
exports.isCaptcha = isCaptcha;
|
|
54
|
+
const isButton = function (item) {
|
|
55
|
+
return (item === null || item === void 0 ? void 0 : item.fieldType) === 'button';
|
|
56
|
+
};
|
|
57
|
+
exports.isButton = isButton;
|
|
54
58
|
function deepClone(obj, idGenerator) {
|
|
55
59
|
let result;
|
|
56
60
|
if (obj instanceof Array) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.84",
|
|
4
4
|
"description": "Core Module for Forms Runtime",
|
|
5
5
|
"author": "Adobe Systems",
|
|
6
6
|
"license": "Adobe Proprietary",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@adobe/json-formula": "0.1.50",
|
|
40
|
-
"@aemforms/af-formatters": "^0.22.
|
|
40
|
+
"@aemforms/af-formatters": "^0.22.84"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|