@aemforms/af-core 0.22.82 → 0.22.83
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 +29 -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 +9 -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) {
|
|
@@ -3009,6 +3012,15 @@ class Form extends Container {
|
|
|
3009
3012
|
}
|
|
3010
3013
|
}
|
|
3011
3014
|
_logger;
|
|
3015
|
+
get activeField() {
|
|
3016
|
+
return this._findActiveField(this);
|
|
3017
|
+
}
|
|
3018
|
+
_findActiveField(field) {
|
|
3019
|
+
if (!field?.isContainer) {
|
|
3020
|
+
return field;
|
|
3021
|
+
}
|
|
3022
|
+
return this._findActiveField(field?.activeChild);
|
|
3023
|
+
}
|
|
3012
3024
|
get logger() {
|
|
3013
3025
|
return this._logger;
|
|
3014
3026
|
}
|
|
@@ -4441,6 +4453,20 @@ class Captcha extends Field {
|
|
|
4441
4453
|
}
|
|
4442
4454
|
}
|
|
4443
4455
|
|
|
4456
|
+
class Button extends Field {
|
|
4457
|
+
click() {
|
|
4458
|
+
if (this._events?.click || !this._jsonModel.buttonType) {
|
|
4459
|
+
return;
|
|
4460
|
+
}
|
|
4461
|
+
if (this._jsonModel.buttonType === 'submit') {
|
|
4462
|
+
return this.form.dispatch(new Submit());
|
|
4463
|
+
}
|
|
4464
|
+
if (this._jsonModel.buttonType === 'reset') {
|
|
4465
|
+
return this.form.dispatch(new Reset());
|
|
4466
|
+
}
|
|
4467
|
+
}
|
|
4468
|
+
}
|
|
4469
|
+
|
|
4444
4470
|
const alternateFieldTypeMapping = {
|
|
4445
4471
|
'text': 'text-input',
|
|
4446
4472
|
'number': 'number-input',
|
|
@@ -4505,6 +4531,9 @@ class FormFieldFactoryImpl {
|
|
|
4505
4531
|
else if (isCaptcha(child)) {
|
|
4506
4532
|
retVal = new Captcha(child, options);
|
|
4507
4533
|
}
|
|
4534
|
+
else if (isButton(child)) {
|
|
4535
|
+
retVal = new Button(child, options);
|
|
4536
|
+
}
|
|
4508
4537
|
else {
|
|
4509
4538
|
retVal = new Field(child, options);
|
|
4510
4539
|
}
|
|
@@ -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
|
@@ -59,6 +59,15 @@ class Form extends Container_1.default {
|
|
|
59
59
|
this._jsonModel.properties['fd:changeEventBehaviour'] = 'self';
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
get activeField() {
|
|
63
|
+
return this._findActiveField(this);
|
|
64
|
+
}
|
|
65
|
+
_findActiveField(field) {
|
|
66
|
+
if (!(field === null || field === void 0 ? void 0 : field.isContainer)) {
|
|
67
|
+
return field;
|
|
68
|
+
}
|
|
69
|
+
return this._findActiveField(field === null || field === void 0 ? void 0 : field.activeChild);
|
|
70
|
+
}
|
|
62
71
|
get logger() {
|
|
63
72
|
return this._logger;
|
|
64
73
|
}
|
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.83",
|
|
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.83"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|