@aemforms/af-core 0.22.81 → 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.
@@ -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) {
@@ -2284,9 +2287,14 @@ class FormMetaData extends Node {
2284
2287
  class SubmitMetaData {
2285
2288
  lang;
2286
2289
  captchaInfo;
2287
- constructor(lang = '', captchaInfo) {
2288
- this.lang = lang;
2289
- this.captchaInfo = captchaInfo;
2290
+ constructor(options = {}) {
2291
+ this.lang = options.lang || 'en';
2292
+ this.captchaInfo = options.captchaInfo || {};
2293
+ Object.keys(options).forEach(key => {
2294
+ if (key !== 'lang' && key !== 'captchaInfo') {
2295
+ this[key] = options[key];
2296
+ }
2297
+ });
2290
2298
  }
2291
2299
  }
2292
2300
 
@@ -2650,12 +2658,17 @@ class FunctionRuntimeImpl {
2650
2658
  const eventName = 'reset';
2651
2659
  target = target || 'reset';
2652
2660
  const args = [target, eventName];
2661
+ interpreter.globals.form.logger.warn('This usage of reset is deprecated. Please see the documentation and update.');
2653
2662
  return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
2654
2663
  },
2655
2664
  validate: (target) => {
2656
2665
  const args = [target];
2657
2666
  return FunctionRuntimeImpl.getInstance().getFunctions().validate._func.call(undefined, args, data, interpreter);
2658
2667
  },
2668
+ importData: (inputData) => {
2669
+ const args = [inputData];
2670
+ return FunctionRuntimeImpl.getInstance().getFunctions().importData._func.call(undefined, args, data, interpreter);
2671
+ },
2659
2672
  exportData: () => {
2660
2673
  return FunctionRuntimeImpl.getInstance().getFunctions().exportData._func.call(undefined, args, data, interpreter);
2661
2674
  },
@@ -2678,6 +2691,14 @@ class FunctionRuntimeImpl {
2678
2691
  else if (option && option.useQualifiedName) {
2679
2692
  interpreter.globals.form.resolveQualifiedName(fieldIdentifier)?.markAsInvalid(validationMessage);
2680
2693
  }
2694
+ },
2695
+ setFocus: (target, flag) => {
2696
+ const args = [target, flag];
2697
+ return FunctionRuntimeImpl.getInstance().getFunctions().setFocus._func.call(undefined, args, data, interpreter);
2698
+ },
2699
+ dispatchEvent: (target, eventName, payload) => {
2700
+ const args = [target, eventName, payload];
2701
+ return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
2681
2702
  }
2682
2703
  }
2683
2704
  };
@@ -2734,7 +2755,7 @@ class FunctionRuntimeImpl {
2734
2755
  validation = interpreter.globals.form.getElement(element.$id).validate();
2735
2756
  }
2736
2757
  if (Array.isArray(validation) && validation.length) {
2737
- interpreter.globals.form.logger.error('Form Validation Error');
2758
+ interpreter.globals.form.logger.warn('Form Validation Error');
2738
2759
  }
2739
2760
  return validation;
2740
2761
  },
@@ -2956,6 +2977,7 @@ const changeEventVersion = new Version('0.13');
2956
2977
  class Form extends Container {
2957
2978
  _ruleEngine;
2958
2979
  _eventQueue;
2980
+ additionalSubmitMetadata = {};
2959
2981
  _fields = {};
2960
2982
  _ids;
2961
2983
  _invalidFields = [];
@@ -2990,6 +3012,15 @@ class Form extends Container {
2990
3012
  }
2991
3013
  }
2992
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
+ }
2993
3024
  get logger() {
2994
3025
  return this._logger;
2995
3026
  }
@@ -3012,6 +3043,9 @@ class Form extends Container {
3012
3043
  exportData() {
3013
3044
  return this.getDataNode()?.$value;
3014
3045
  }
3046
+ setAdditionalSubmitMetadata(metadata) {
3047
+ this.additionalSubmitMetadata = { ...this.additionalSubmitMetadata, ...metadata };
3048
+ }
3015
3049
  get specVersion() {
3016
3050
  if (typeof this._jsonModel.adaptiveform === 'string') {
3017
3051
  try {
@@ -3037,21 +3071,18 @@ class Form extends Container {
3037
3071
  return foundFormElement;
3038
3072
  }
3039
3073
  exportSubmitMetaData() {
3040
- let submitMetaInstance = null;
3041
3074
  const captchaInfoObj = {};
3042
- function addCaptchaField(fieldName, fieldValue) {
3043
- if (captchaInfoObj[fieldName]) {
3044
- return;
3045
- }
3046
- captchaInfoObj[fieldName] = fieldValue;
3047
- }
3048
3075
  this.visit(field => {
3049
3076
  if (field.fieldType === 'captcha') {
3050
- addCaptchaField(field.qualifiedName, field.value);
3077
+ captchaInfoObj[field.qualifiedName] = field.value;
3051
3078
  }
3052
3079
  });
3053
- submitMetaInstance = new SubmitMetaData(this.form.lang, captchaInfoObj);
3054
- return submitMetaInstance;
3080
+ const options = {
3081
+ lang: this.lang,
3082
+ captchaInfo: captchaInfoObj,
3083
+ additionalSubmitMetadata: { ...this.additionalSubmitMetadata }
3084
+ };
3085
+ return new SubmitMetaData(options);
3055
3086
  }
3056
3087
  #getNavigableChildren(children) {
3057
3088
  return children.filter(child => child.visible === true);
@@ -3618,7 +3649,8 @@ class Field extends Scriptable {
3618
3649
  }
3619
3650
  set valid(e) {
3620
3651
  const validity = {
3621
- valid: e
3652
+ valid: e,
3653
+ ...(e ? {} : { customConstraint: true })
3622
3654
  };
3623
3655
  this._setProperty('valid', e);
3624
3656
  this._setProperty('validity', validity);
@@ -4112,7 +4144,7 @@ class Field extends Scriptable {
4112
4144
  'validationMessage': message,
4113
4145
  'validity': {
4114
4146
  valid: false,
4115
- ...(constraint != null ? { [constraintKeys[constraint]]: true } : {})
4147
+ ...(constraint != null ? { [constraintKeys[constraint]]: true } : { customConstraint: true })
4116
4148
  }
4117
4149
  };
4118
4150
  const updates = this._applyUpdates(['valid', 'errorMessage', 'validationMessage', 'validity'], changes);
@@ -4421,6 +4453,20 @@ class Captcha extends Field {
4421
4453
  }
4422
4454
  }
4423
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
+
4424
4470
  const alternateFieldTypeMapping = {
4425
4471
  'text': 'text-input',
4426
4472
  'number': 'number-input',
@@ -4485,6 +4531,9 @@ class FormFieldFactoryImpl {
4485
4531
  else if (isCaptcha(child)) {
4486
4532
  retVal = new Captcha(child, options);
4487
4533
  }
4534
+ else if (isButton(child)) {
4535
+ retVal = new Button(child, options);
4536
+ }
4488
4537
  else {
4489
4538
  retVal = new Field(child, options);
4490
4539
  }
@@ -0,0 +1,5 @@
1
+ import Field from './Field';
2
+ declare class Button extends Field {
3
+ click(): void;
4
+ }
5
+ export default Button;
@@ -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;
@@ -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;
@@ -11,12 +11,15 @@ declare class Form extends Container<FormJson> implements FormModel {
11
11
  #private;
12
12
  private _ruleEngine;
13
13
  private _eventQueue;
14
+ private additionalSubmitMetadata;
14
15
  private _fields;
15
16
  _ids: Generator<string, void, string>;
16
17
  private _invalidFields;
17
18
  constructor(n: FormJson, fieldFactory: IFormFieldFactory, _ruleEngine: RuleEngine, _eventQueue?: EventQueue, logLevel?: LogLevel, mode?: FormCreationMode);
18
19
  protected _applyDefaultsInModel(): void;
19
20
  private _logger;
21
+ get activeField(): FieldModel;
22
+ _findActiveField(field: FieldsetModel | FieldModel | null): any;
20
23
  get logger(): Logger;
21
24
  get changeEventBehaviour(): "deps" | "self";
22
25
  private dataRefRegex;
@@ -24,6 +27,7 @@ declare class Form extends Container<FormJson> implements FormModel {
24
27
  get action(): string | undefined;
25
28
  importData(dataModel: any): void;
26
29
  exportData(): any;
30
+ setAdditionalSubmitMetadata(metadata: Record<string, any>): void;
27
31
  get specVersion(): Version;
28
32
  resolveQualifiedName(qualifiedName: string): FieldModel | FieldsetModel | null;
29
33
  exportSubmitMetaData(): SubmitMetaData;
@@ -74,6 +78,7 @@ declare class Form extends Container<FormJson> implements FormModel {
74
78
  tooltip?: string | undefined;
75
79
  altText?: string | undefined;
76
80
  viewType?: string | undefined;
81
+ buttonType?: string | undefined;
77
82
  } & {
78
83
  items: (import("./types/Json").FieldJson | import("./types/Json").ContainerJson)[];
79
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
- private _events;
4
+ protected _events: {
5
+ [key: string]: any;
6
+ };
5
7
  private _rules;
6
8
  getRules(): import("./types/Json").Items<string>;
7
9
  private getCompiledRule;
@@ -1,7 +1,8 @@
1
1
  import { SubmitMetaDataModel } from './types/index';
2
2
  declare class SubmitMetaData implements SubmitMetaDataModel {
3
3
  lang: string;
4
- captchaInfo: Record<string, any>;
5
- constructor(lang: string | undefined, captchaInfo: Record<string, any>);
4
+ captchaInfo: Record<string, string>;
5
+ [key: string]: any;
6
+ constructor(options?: Record<string, any>);
6
7
  }
7
8
  export default SubmitMetaData;
@@ -80,6 +80,7 @@ export type BaseJson = TranslationBaseJson & RulesJson & ConstraintsJson & {
80
80
  tooltip?: string;
81
81
  altText?: string;
82
82
  viewType?: string;
83
+ buttonType?: string;
83
84
  };
84
85
  type TranslationFieldJson = {
85
86
  placeholder?: string;
@@ -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;
@@ -0,0 +1,5 @@
1
+ import Field from './Field';
2
+ declare class Button extends Field {
3
+ click(): void;
4
+ }
5
+ export default Button;
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/Field.js CHANGED
@@ -222,9 +222,7 @@ class Field extends Scriptable_1.default {
222
222
  return (_b = (_a = this._jsonModel) === null || _a === void 0 ? void 0 : _a.validity) === null || _b === void 0 ? void 0 : _b.valid;
223
223
  }
224
224
  set valid(e) {
225
- const validity = {
226
- valid: e
227
- };
225
+ const validity = Object.assign({ valid: e }, (e ? {} : { customConstraint: true }));
228
226
  this._setProperty('valid', e);
229
227
  this._setProperty('validity', validity);
230
228
  }
@@ -692,7 +690,7 @@ class Field extends Scriptable_1.default {
692
690
  'valid': false,
693
691
  'errorMessage': message,
694
692
  'validationMessage': message,
695
- 'validity': Object.assign({ valid: false }, (constraint != null ? { [types_1.constraintKeys[constraint]]: true } : {}))
693
+ 'validity': Object.assign({ valid: false }, (constraint != null ? { [types_1.constraintKeys[constraint]]: true } : { customConstraint: true }))
696
694
  };
697
695
  const updates = this._applyUpdates(['valid', 'errorMessage', 'validationMessage', 'validity'], changes);
698
696
  const changeAction = new Events_1.Change({ changes: [].concat(Object.values(updates)) });
package/lib/Form.d.ts CHANGED
@@ -11,12 +11,15 @@ declare class Form extends Container<FormJson> implements FormModel {
11
11
  #private;
12
12
  private _ruleEngine;
13
13
  private _eventQueue;
14
+ private additionalSubmitMetadata;
14
15
  private _fields;
15
16
  _ids: Generator<string, void, string>;
16
17
  private _invalidFields;
17
18
  constructor(n: FormJson, fieldFactory: IFormFieldFactory, _ruleEngine: RuleEngine, _eventQueue?: EventQueue, logLevel?: LogLevel, mode?: FormCreationMode);
18
19
  protected _applyDefaultsInModel(): void;
19
20
  private _logger;
21
+ get activeField(): FieldModel;
22
+ _findActiveField(field: FieldsetModel | FieldModel | null): any;
20
23
  get logger(): Logger;
21
24
  get changeEventBehaviour(): "deps" | "self";
22
25
  private dataRefRegex;
@@ -24,6 +27,7 @@ declare class Form extends Container<FormJson> implements FormModel {
24
27
  get action(): string | undefined;
25
28
  importData(dataModel: any): void;
26
29
  exportData(): any;
30
+ setAdditionalSubmitMetadata(metadata: Record<string, any>): void;
27
31
  get specVersion(): Version;
28
32
  resolveQualifiedName(qualifiedName: string): FieldModel | FieldsetModel | null;
29
33
  exportSubmitMetaData(): SubmitMetaData;
@@ -74,6 +78,7 @@ declare class Form extends Container<FormJson> implements FormModel {
74
78
  tooltip?: string | undefined;
75
79
  altText?: string | undefined;
76
80
  viewType?: string | undefined;
81
+ buttonType?: string | undefined;
77
82
  } & {
78
83
  items: (import("./types/Json").FieldJson | import("./types/Json").ContainerJson)[];
79
84
  initialItems?: number | undefined;
package/lib/Form.js CHANGED
@@ -29,6 +29,7 @@ class Form extends Container_1.default {
29
29
  this._ruleEngine = _ruleEngine;
30
30
  this._eventQueue = _eventQueue;
31
31
  _Form_instances.add(this);
32
+ this.additionalSubmitMetadata = {};
32
33
  this._fields = {};
33
34
  this._invalidFields = [];
34
35
  this.dataRefRegex = /("[^"]+?"|[^.]+?)(?:\.|$)/g;
@@ -58,6 +59,15 @@ class Form extends Container_1.default {
58
59
  this._jsonModel.properties['fd:changeEventBehaviour'] = 'self';
59
60
  }
60
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
+ }
61
71
  get logger() {
62
72
  return this._logger;
63
73
  }
@@ -80,6 +90,9 @@ class Form extends Container_1.default {
80
90
  var _a;
81
91
  return (_a = this.getDataNode()) === null || _a === void 0 ? void 0 : _a.$value;
82
92
  }
93
+ setAdditionalSubmitMetadata(metadata) {
94
+ this.additionalSubmitMetadata = Object.assign(Object.assign({}, this.additionalSubmitMetadata), metadata);
95
+ }
83
96
  get specVersion() {
84
97
  if (typeof this._jsonModel.adaptiveform === 'string') {
85
98
  try {
@@ -105,21 +118,18 @@ class Form extends Container_1.default {
105
118
  return foundFormElement;
106
119
  }
107
120
  exportSubmitMetaData() {
108
- let submitMetaInstance = null;
109
121
  const captchaInfoObj = {};
110
- function addCaptchaField(fieldName, fieldValue) {
111
- if (captchaInfoObj[fieldName]) {
112
- return;
113
- }
114
- captchaInfoObj[fieldName] = fieldValue;
115
- }
116
122
  this.visit(field => {
117
123
  if (field.fieldType === 'captcha') {
118
- addCaptchaField(field.qualifiedName, field.value);
124
+ captchaInfoObj[field.qualifiedName] = field.value;
119
125
  }
120
126
  });
121
- submitMetaInstance = new SubmitMetaData_1.default(this.form.lang, captchaInfoObj);
122
- return submitMetaInstance;
127
+ const options = {
128
+ lang: this.lang,
129
+ captchaInfo: captchaInfoObj,
130
+ additionalSubmitMetadata: Object.assign({}, this.additionalSubmitMetadata)
131
+ };
132
+ return new SubmitMetaData_1.default(options);
123
133
  }
124
134
  setFocus(field, focusOption) {
125
135
  if (!focusOption) {
@@ -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
- private _events;
4
+ protected _events: {
5
+ [key: string]: any;
6
+ };
5
7
  private _rules;
6
8
  getRules(): import("./types/Json").Items<string>;
7
9
  private getCompiledRule;
@@ -1,7 +1,8 @@
1
1
  import { SubmitMetaDataModel } from './types/index';
2
2
  declare class SubmitMetaData implements SubmitMetaDataModel {
3
3
  lang: string;
4
- captchaInfo: Record<string, any>;
5
- constructor(lang: string | undefined, captchaInfo: Record<string, any>);
4
+ captchaInfo: Record<string, string>;
5
+ [key: string]: any;
6
+ constructor(options?: Record<string, any>);
6
7
  }
7
8
  export default SubmitMetaData;
@@ -1,9 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  class SubmitMetaData {
4
- constructor(lang = '', captchaInfo) {
5
- this.lang = lang;
6
- this.captchaInfo = captchaInfo;
4
+ constructor(options = {}) {
5
+ this.lang = options.lang || 'en';
6
+ this.captchaInfo = options.captchaInfo || {};
7
+ Object.keys(options).forEach(key => {
8
+ if (key !== 'lang' && key !== 'captchaInfo') {
9
+ this[key] = options[key];
10
+ }
11
+ });
7
12
  }
8
13
  }
9
14
  exports.default = SubmitMetaData;
@@ -196,12 +196,17 @@ class FunctionRuntimeImpl {
196
196
  const eventName = 'reset';
197
197
  target = target || 'reset';
198
198
  const args = [target, eventName];
199
+ interpreter.globals.form.logger.warn('This usage of reset is deprecated. Please see the documentation and update.');
199
200
  return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
200
201
  },
201
202
  validate: (target) => {
202
203
  const args = [target];
203
204
  return FunctionRuntimeImpl.getInstance().getFunctions().validate._func.call(undefined, args, data, interpreter);
204
205
  },
206
+ importData: (inputData) => {
207
+ const args = [inputData];
208
+ return FunctionRuntimeImpl.getInstance().getFunctions().importData._func.call(undefined, args, data, interpreter);
209
+ },
205
210
  exportData: () => {
206
211
  return FunctionRuntimeImpl.getInstance().getFunctions().exportData._func.call(undefined, args, data, interpreter);
207
212
  },
@@ -225,6 +230,14 @@ class FunctionRuntimeImpl {
225
230
  else if (option && option.useQualifiedName) {
226
231
  (_b = interpreter.globals.form.resolveQualifiedName(fieldIdentifier)) === null || _b === void 0 ? void 0 : _b.markAsInvalid(validationMessage);
227
232
  }
233
+ },
234
+ setFocus: (target, flag) => {
235
+ const args = [target, flag];
236
+ return FunctionRuntimeImpl.getInstance().getFunctions().setFocus._func.call(undefined, args, data, interpreter);
237
+ },
238
+ dispatchEvent: (target, eventName, payload) => {
239
+ const args = [target, eventName, payload];
240
+ return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
228
241
  }
229
242
  }
230
243
  };
@@ -281,7 +294,7 @@ class FunctionRuntimeImpl {
281
294
  validation = interpreter.globals.form.getElement(element.$id).validate();
282
295
  }
283
296
  if (Array.isArray(validation) && validation.length) {
284
- interpreter.globals.form.logger.error('Form Validation Error');
297
+ interpreter.globals.form.logger.warn('Form Validation Error');
285
298
  }
286
299
  return validation;
287
300
  },
@@ -80,6 +80,7 @@ export declare type BaseJson = TranslationBaseJson & RulesJson & ConstraintsJson
80
80
  tooltip?: string;
81
81
  altText?: string;
82
82
  viewType?: string;
83
+ buttonType?: string;
83
84
  };
84
85
  declare type TranslationFieldJson = {
85
86
  placeholder?: string;
@@ -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
  }
@@ -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;
@@ -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.81",
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.81"
40
+ "@aemforms/af-formatters": "^0.22.83"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",