@aemforms/af-core 0.22.103 → 0.22.105
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-events.js +186 -1
- package/esm/afb-runtime.js +101 -6
- package/esm/types/src/controller/Events.d.ts +5 -1
- package/lib/controller/Events.d.ts +5 -1
- package/lib/controller/Events.js +6 -2
- package/lib/rules/FunctionRuntime.js +11 -5
- package/package.json +2 -2
- package/esm/Events-f062426b.js +0 -270
package/esm/afb-events.js
CHANGED
|
@@ -1 +1,186 @@
|
|
|
1
|
-
|
|
1
|
+
var EventSource;
|
|
2
|
+
(function (EventSource) {
|
|
3
|
+
EventSource["CODE"] = "code";
|
|
4
|
+
EventSource["UI"] = "ui";
|
|
5
|
+
})(EventSource || (EventSource = {}));
|
|
6
|
+
class ActionImpl {
|
|
7
|
+
_metadata;
|
|
8
|
+
_type;
|
|
9
|
+
_payload;
|
|
10
|
+
_target;
|
|
11
|
+
_currentTarget;
|
|
12
|
+
constructor(payload, type, _metadata) {
|
|
13
|
+
this._metadata = _metadata;
|
|
14
|
+
this._payload = payload;
|
|
15
|
+
this._type = type;
|
|
16
|
+
}
|
|
17
|
+
get type() {
|
|
18
|
+
return this._type;
|
|
19
|
+
}
|
|
20
|
+
get payload() {
|
|
21
|
+
return this._payload;
|
|
22
|
+
}
|
|
23
|
+
get metadata() {
|
|
24
|
+
return this._metadata;
|
|
25
|
+
}
|
|
26
|
+
get target() {
|
|
27
|
+
return this._target;
|
|
28
|
+
}
|
|
29
|
+
get currentTarget() {
|
|
30
|
+
return this._currentTarget;
|
|
31
|
+
}
|
|
32
|
+
get isCustomEvent() {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
payloadToJson() {
|
|
36
|
+
return this.payload;
|
|
37
|
+
}
|
|
38
|
+
toJson() {
|
|
39
|
+
return {
|
|
40
|
+
payload: this.payloadToJson(),
|
|
41
|
+
type: this.type,
|
|
42
|
+
isCustomEvent: this.isCustomEvent
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
toString() {
|
|
46
|
+
return JSON.stringify(this.toJson());
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
class Change extends ActionImpl {
|
|
50
|
+
constructor(payload, dispatch = false) {
|
|
51
|
+
super(payload, 'change', { dispatch });
|
|
52
|
+
}
|
|
53
|
+
withAdditionalChange(change) {
|
|
54
|
+
return new Change(this.payload.changes.concat(change.payload.changes), this.metadata);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
class UIChange extends ActionImpl {
|
|
58
|
+
constructor(payload, dispatch = false) {
|
|
59
|
+
super(payload, 'uiChange', { dispatch });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
class Invalid extends ActionImpl {
|
|
63
|
+
constructor(payload = {}) {
|
|
64
|
+
super(payload, 'invalid', {});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
class Valid extends ActionImpl {
|
|
68
|
+
constructor(payload = {}) {
|
|
69
|
+
super(payload, 'valid', {});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
class ExecuteRule extends ActionImpl {
|
|
73
|
+
constructor(payload = {}, dispatch = false) {
|
|
74
|
+
super(payload, 'executeRule', { dispatch });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const propertyChange = (propertyName, currentValue, prevValue) => {
|
|
78
|
+
return new Change({
|
|
79
|
+
changes: [
|
|
80
|
+
{
|
|
81
|
+
propertyName,
|
|
82
|
+
currentValue,
|
|
83
|
+
prevValue
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
class Initialize extends ActionImpl {
|
|
89
|
+
constructor(payload, dispatch = false) {
|
|
90
|
+
super(payload, 'initialize', { dispatch });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
class FormLoad extends ActionImpl {
|
|
94
|
+
constructor() {
|
|
95
|
+
super({}, 'load', { dispatch: false });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
class Click extends ActionImpl {
|
|
99
|
+
constructor(payload, dispatch = false) {
|
|
100
|
+
super(payload, 'click', { dispatch });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
class Blur extends ActionImpl {
|
|
104
|
+
constructor(payload, dispatch = false) {
|
|
105
|
+
super(payload, 'blur', { dispatch });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
class ValidationComplete extends ActionImpl {
|
|
109
|
+
constructor(payload, dispatch = false) {
|
|
110
|
+
super(payload, 'validationComplete', { dispatch });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
class Focus extends ActionImpl {
|
|
114
|
+
constructor() {
|
|
115
|
+
super({}, 'focus', { dispatch: false });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
class Submit extends ActionImpl {
|
|
119
|
+
constructor(payload, dispatch = false) {
|
|
120
|
+
super(payload, 'submit', { dispatch });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
class Save extends ActionImpl {
|
|
124
|
+
constructor(payload, dispatch = false) {
|
|
125
|
+
super(payload, 'save', { dispatch });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
class SubmitSuccess extends ActionImpl {
|
|
129
|
+
constructor(payload, dispatch = false) {
|
|
130
|
+
super(payload, 'submitSuccess', { dispatch });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
class SubmitFailure extends ActionImpl {
|
|
134
|
+
constructor(payload, dispatch = false) {
|
|
135
|
+
super(payload, 'submitFailure', { dispatch });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
class SubmitError extends ActionImpl {
|
|
139
|
+
constructor(payload, dispatch = false) {
|
|
140
|
+
super(payload, 'submitError', { dispatch });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
class Reset extends ActionImpl {
|
|
144
|
+
constructor(payload, dispatch = false) {
|
|
145
|
+
super(payload, 'reset', { dispatch });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
class FieldChanged extends ActionImpl {
|
|
149
|
+
constructor(changes, field, eventSource = EventSource.CODE) {
|
|
150
|
+
super({
|
|
151
|
+
field,
|
|
152
|
+
changes,
|
|
153
|
+
eventSource
|
|
154
|
+
}, 'fieldChanged');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
class CustomEvent extends ActionImpl {
|
|
158
|
+
constructor(eventName, payload = {}, dispatch = false) {
|
|
159
|
+
super(payload, eventName, { dispatch });
|
|
160
|
+
}
|
|
161
|
+
get isCustomEvent() {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
class AddItem extends ActionImpl {
|
|
166
|
+
constructor(payload) {
|
|
167
|
+
super(payload, 'addItem');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
class RemoveItem extends ActionImpl {
|
|
171
|
+
constructor(payload) {
|
|
172
|
+
super(payload, 'removeItem');
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
class AddInstance extends ActionImpl {
|
|
176
|
+
constructor(payload) {
|
|
177
|
+
super(payload, 'addInstance');
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
class RemoveInstance extends ActionImpl {
|
|
181
|
+
constructor(payload) {
|
|
182
|
+
super(payload, 'removeInstance');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export { AddInstance, AddItem, Blur, Change, Click, CustomEvent, ExecuteRule, FieldChanged, Focus, FormLoad, Initialize, Invalid, RemoveInstance, RemoveItem, Reset, Save, Submit, SubmitError, SubmitFailure, SubmitSuccess, UIChange, Valid, ValidationComplete, propertyChange };
|
package/esm/afb-runtime.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { propertyChange, ExecuteRule, Initialize, RemoveItem, SubmitSuccess, CustomEvent, SubmitError, SubmitFailure, Submit, Save, Valid, Invalid, RemoveInstance, AddInstance, Reset, AddItem, Click, Change, FormLoad, FieldChanged, ValidationComplete } from './afb-events.js';
|
|
2
2
|
import Formula from '@adobe/json-formula';
|
|
3
3
|
import { parseDefaultDate, datetimeToNumber, format, parseDateSkeleton, numberToDatetime, formatDate, parseDate } from '@aemforms/af-formatters';
|
|
4
4
|
|
|
@@ -9,6 +9,95 @@ function __decorate(decorators, target, key, desc) {
|
|
|
9
9
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
const ConstraintType = Object.freeze({
|
|
13
|
+
PATTERN_MISMATCH: 'patternMismatch',
|
|
14
|
+
TOO_SHORT: 'tooShort',
|
|
15
|
+
TOO_LONG: 'tooLong',
|
|
16
|
+
RANGE_OVERFLOW: 'rangeOverflow',
|
|
17
|
+
RANGE_UNDERFLOW: 'rangeUnderflow',
|
|
18
|
+
TYPE_MISMATCH: 'typeMismatch',
|
|
19
|
+
VALUE_MISSING: 'valueMissing',
|
|
20
|
+
STEP_MISMATCH: 'stepMismatch',
|
|
21
|
+
FORMAT_MISMATCH: 'formatMismatch',
|
|
22
|
+
ACCEPT_MISMATCH: 'acceptMismatch',
|
|
23
|
+
FILE_SIZE_MISMATCH: 'fileSizeMismatch',
|
|
24
|
+
UNIQUE_ITEMS_MISMATCH: 'uniqueItemsMismatch',
|
|
25
|
+
MIN_ITEMS_MISMATCH: 'minItemsMismatch',
|
|
26
|
+
MAX_ITEMS_MISMATCH: 'maxItemsMismatch',
|
|
27
|
+
EXPRESSION_MISMATCH: 'expressionMismatch',
|
|
28
|
+
EXCLUSIVE_MAXIMUM_MISMATCH: 'exclusiveMaximumMismatch',
|
|
29
|
+
EXCLUSIVE_MINIMUM_MISMATCH: 'exclusiveMinimumMismatch'
|
|
30
|
+
});
|
|
31
|
+
const constraintKeys = Object.freeze({
|
|
32
|
+
pattern: ConstraintType.PATTERN_MISMATCH,
|
|
33
|
+
minLength: ConstraintType.TOO_SHORT,
|
|
34
|
+
maxLength: ConstraintType.TOO_LONG,
|
|
35
|
+
maximum: ConstraintType.RANGE_OVERFLOW,
|
|
36
|
+
minimum: ConstraintType.RANGE_UNDERFLOW,
|
|
37
|
+
type: ConstraintType.TYPE_MISMATCH,
|
|
38
|
+
required: ConstraintType.VALUE_MISSING,
|
|
39
|
+
step: ConstraintType.STEP_MISMATCH,
|
|
40
|
+
format: ConstraintType.FORMAT_MISMATCH,
|
|
41
|
+
accept: ConstraintType.ACCEPT_MISMATCH,
|
|
42
|
+
maxFileSize: ConstraintType.FILE_SIZE_MISMATCH,
|
|
43
|
+
uniqueItems: ConstraintType.UNIQUE_ITEMS_MISMATCH,
|
|
44
|
+
minItems: ConstraintType.MIN_ITEMS_MISMATCH,
|
|
45
|
+
maxItems: ConstraintType.MAX_ITEMS_MISMATCH,
|
|
46
|
+
validationExpression: ConstraintType.EXPRESSION_MISMATCH,
|
|
47
|
+
exclusiveMinimum: ConstraintType.EXCLUSIVE_MINIMUM_MISMATCH,
|
|
48
|
+
exclusiveMaximum: ConstraintType.EXCLUSIVE_MAXIMUM_MISMATCH
|
|
49
|
+
});
|
|
50
|
+
const defaultConstraintTypeMessages = Object.freeze({
|
|
51
|
+
[ConstraintType.PATTERN_MISMATCH]: 'Please match the format requested.',
|
|
52
|
+
[ConstraintType.TOO_SHORT]: 'Please lengthen this text to ${0} characters or more.',
|
|
53
|
+
[ConstraintType.TOO_LONG]: 'Please shorten this text to ${0} characters or less.',
|
|
54
|
+
[ConstraintType.RANGE_OVERFLOW]: 'Value must be less than or equal to ${0}.',
|
|
55
|
+
[ConstraintType.RANGE_UNDERFLOW]: 'Value must be greater than or equal to ${0}.',
|
|
56
|
+
[ConstraintType.TYPE_MISMATCH]: 'Please enter a valid value.',
|
|
57
|
+
[ConstraintType.VALUE_MISSING]: 'Please fill in this field.',
|
|
58
|
+
[ConstraintType.STEP_MISMATCH]: 'Please enter a valid value.',
|
|
59
|
+
[ConstraintType.FORMAT_MISMATCH]: 'Specify the value in allowed format : ${0}.',
|
|
60
|
+
[ConstraintType.ACCEPT_MISMATCH]: 'The specified file type not supported.',
|
|
61
|
+
[ConstraintType.FILE_SIZE_MISMATCH]: 'File too large. Reduce size and try again.',
|
|
62
|
+
[ConstraintType.UNIQUE_ITEMS_MISMATCH]: 'All the items must be unique.',
|
|
63
|
+
[ConstraintType.MIN_ITEMS_MISMATCH]: 'Specify a number of items equal to or greater than ${0}.',
|
|
64
|
+
[ConstraintType.MAX_ITEMS_MISMATCH]: 'Specify a number of items equal to or less than ${0}.',
|
|
65
|
+
[ConstraintType.EXPRESSION_MISMATCH]: 'Please enter a valid value.',
|
|
66
|
+
[ConstraintType.EXCLUSIVE_MINIMUM_MISMATCH]: 'Value must be greater than ${0}.',
|
|
67
|
+
[ConstraintType.EXCLUSIVE_MAXIMUM_MISMATCH]: 'Value must be less than ${0}.'
|
|
68
|
+
});
|
|
69
|
+
let customConstraintTypeMessages = {};
|
|
70
|
+
const getConstraintTypeMessages = () => {
|
|
71
|
+
return {
|
|
72
|
+
...defaultConstraintTypeMessages,
|
|
73
|
+
...customConstraintTypeMessages
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
var EventSource;
|
|
78
|
+
(function (EventSource) {
|
|
79
|
+
EventSource["CODE"] = "code";
|
|
80
|
+
EventSource["UI"] = "ui";
|
|
81
|
+
})(EventSource || (EventSource = {}));
|
|
82
|
+
class ValidationError {
|
|
83
|
+
fieldName;
|
|
84
|
+
errorMessages;
|
|
85
|
+
constructor(fieldName = '', errorMessages = []) {
|
|
86
|
+
this.errorMessages = errorMessages;
|
|
87
|
+
this.fieldName = fieldName;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
var FocusOption;
|
|
91
|
+
(function (FocusOption) {
|
|
92
|
+
FocusOption["NEXT_ITEM"] = "nextItem";
|
|
93
|
+
FocusOption["PREVIOUS_ITEM"] = "previousItem";
|
|
94
|
+
})(FocusOption || (FocusOption = {}));
|
|
95
|
+
var CaptchaDisplayMode;
|
|
96
|
+
(function (CaptchaDisplayMode) {
|
|
97
|
+
CaptchaDisplayMode["INVISIBLE"] = "invisible";
|
|
98
|
+
CaptchaDisplayMode["VISIBLE"] = "visible";
|
|
99
|
+
})(CaptchaDisplayMode || (CaptchaDisplayMode = {}));
|
|
100
|
+
|
|
12
101
|
const objToMap = (o) => new Map(Object.entries(o));
|
|
13
102
|
const stringViewTypes = objToMap({ 'date': 'date-input', 'data-url': 'file-input', 'binary': 'file-input' });
|
|
14
103
|
const typeToViewTypes = objToMap({
|
|
@@ -2615,7 +2704,7 @@ const multipartFormData = (data, attachments) => {
|
|
|
2615
2704
|
}
|
|
2616
2705
|
return formData;
|
|
2617
2706
|
};
|
|
2618
|
-
const createAction = (name, payload = {}) => {
|
|
2707
|
+
const createAction = (name, payload = {}, dispatch = false) => {
|
|
2619
2708
|
switch (name) {
|
|
2620
2709
|
case 'change':
|
|
2621
2710
|
return new Change(payload);
|
|
@@ -2635,6 +2724,12 @@ const createAction = (name, payload = {}) => {
|
|
|
2635
2724
|
return new AddInstance(payload);
|
|
2636
2725
|
case 'removeInstance':
|
|
2637
2726
|
return new RemoveInstance(payload);
|
|
2727
|
+
case 'invalid':
|
|
2728
|
+
return new Invalid(payload);
|
|
2729
|
+
case 'valid':
|
|
2730
|
+
return new Valid(payload);
|
|
2731
|
+
case 'initialize':
|
|
2732
|
+
return new Initialize(payload);
|
|
2638
2733
|
default:
|
|
2639
2734
|
console.error('invalid action');
|
|
2640
2735
|
}
|
|
@@ -2708,8 +2803,8 @@ class FunctionRuntimeImpl {
|
|
|
2708
2803
|
const args = [target, flag];
|
|
2709
2804
|
return FunctionRuntimeImpl.getInstance().getFunctions().setFocus._func.call(undefined, args, data, interpreter);
|
|
2710
2805
|
},
|
|
2711
|
-
dispatchEvent: (target, eventName, payload) => {
|
|
2712
|
-
const args = [target, eventName, payload];
|
|
2806
|
+
dispatchEvent: (target, eventName, payload, dispatch) => {
|
|
2807
|
+
const args = [target, eventName, payload, dispatch];
|
|
2713
2808
|
return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
|
|
2714
2809
|
},
|
|
2715
2810
|
getFiles: (qualifiedName) => {
|
|
@@ -2974,7 +3069,7 @@ class FunctionRuntimeImpl {
|
|
|
2974
3069
|
}
|
|
2975
3070
|
let eventName = valueOf(args[1]);
|
|
2976
3071
|
let payload = args.length > 2 ? valueOf(args[2]) : undefined;
|
|
2977
|
-
let dispatch = false;
|
|
3072
|
+
let dispatch = args.length > 3 ? valueOf(args[3]) : false;
|
|
2978
3073
|
if (typeof element === 'string') {
|
|
2979
3074
|
payload = eventName;
|
|
2980
3075
|
eventName = element;
|
|
@@ -2985,7 +3080,7 @@ class FunctionRuntimeImpl {
|
|
|
2985
3080
|
event = new CustomEvent(eventName.substring('custom:'.length), payload, dispatch);
|
|
2986
3081
|
}
|
|
2987
3082
|
else {
|
|
2988
|
-
event = createAction(eventName, payload);
|
|
3083
|
+
event = createAction(eventName, payload, dispatch);
|
|
2989
3084
|
}
|
|
2990
3085
|
if (event != null) {
|
|
2991
3086
|
if (typeof element === 'string') {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { Action, BaseJson, FieldModel, FieldsetModel, FormModel, ValidationError
|
|
1
|
+
import { Action, BaseJson, FieldModel, FieldsetModel, FormModel, ValidationError } from '../types/index';
|
|
2
|
+
declare enum EventSource {
|
|
3
|
+
CODE = "code",
|
|
4
|
+
UI = "ui"
|
|
5
|
+
}
|
|
2
6
|
declare class ActionImpl implements Action {
|
|
3
7
|
private _metadata?;
|
|
4
8
|
protected _type: string;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { Action, BaseJson, FieldModel, FieldsetModel, FormModel, ValidationError
|
|
1
|
+
import { Action, BaseJson, FieldModel, FieldsetModel, FormModel, ValidationError } from '../types/index';
|
|
2
|
+
declare enum EventSource {
|
|
3
|
+
CODE = "code",
|
|
4
|
+
UI = "ui"
|
|
5
|
+
}
|
|
2
6
|
declare class ActionImpl implements Action {
|
|
3
7
|
private _metadata?;
|
|
4
8
|
protected _type: string;
|
package/lib/controller/Events.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RemoveInstance = exports.AddInstance = exports.RemoveItem = exports.AddItem = exports.CustomEvent = exports.FieldChanged = exports.Reset = exports.SubmitError = exports.SubmitFailure = exports.SubmitSuccess = exports.Save = exports.Submit = exports.Focus = exports.ValidationComplete = exports.Blur = exports.Click = exports.FormLoad = exports.Initialize = exports.propertyChange = exports.ExecuteRule = exports.Valid = exports.Invalid = exports.UIChange = exports.Change = void 0;
|
|
4
|
-
|
|
4
|
+
var EventSource;
|
|
5
|
+
(function (EventSource) {
|
|
6
|
+
EventSource["CODE"] = "code";
|
|
7
|
+
EventSource["UI"] = "ui";
|
|
8
|
+
})(EventSource || (EventSource = {}));
|
|
5
9
|
class ActionImpl {
|
|
6
10
|
constructor(payload, type, _metadata) {
|
|
7
11
|
this._metadata = _metadata;
|
|
@@ -158,7 +162,7 @@ class Reset extends ActionImpl {
|
|
|
158
162
|
}
|
|
159
163
|
exports.Reset = Reset;
|
|
160
164
|
class FieldChanged extends ActionImpl {
|
|
161
|
-
constructor(changes, field, eventSource =
|
|
165
|
+
constructor(changes, field, eventSource = EventSource.CODE) {
|
|
162
166
|
super({
|
|
163
167
|
field,
|
|
164
168
|
changes,
|
|
@@ -143,7 +143,7 @@ const multipartFormData = (data, attachments) => {
|
|
|
143
143
|
}
|
|
144
144
|
return formData;
|
|
145
145
|
};
|
|
146
|
-
const createAction = (name, payload = {}) => {
|
|
146
|
+
const createAction = (name, payload = {}, dispatch = false) => {
|
|
147
147
|
switch (name) {
|
|
148
148
|
case 'change':
|
|
149
149
|
return new Events_1.Change(payload);
|
|
@@ -163,6 +163,12 @@ const createAction = (name, payload = {}) => {
|
|
|
163
163
|
return new Events_1.AddInstance(payload);
|
|
164
164
|
case 'removeInstance':
|
|
165
165
|
return new Events_1.RemoveInstance(payload);
|
|
166
|
+
case 'invalid':
|
|
167
|
+
return new Events_1.Invalid(payload);
|
|
168
|
+
case 'valid':
|
|
169
|
+
return new Events_1.Valid(payload);
|
|
170
|
+
case 'initialize':
|
|
171
|
+
return new Events_1.Initialize(payload);
|
|
166
172
|
default:
|
|
167
173
|
console.error('invalid action');
|
|
168
174
|
}
|
|
@@ -236,8 +242,8 @@ class FunctionRuntimeImpl {
|
|
|
236
242
|
const args = [target, flag];
|
|
237
243
|
return FunctionRuntimeImpl.getInstance().getFunctions().setFocus._func.call(undefined, args, data, interpreter);
|
|
238
244
|
},
|
|
239
|
-
dispatchEvent: (target, eventName, payload) => {
|
|
240
|
-
const args = [target, eventName, payload];
|
|
245
|
+
dispatchEvent: (target, eventName, payload, dispatch) => {
|
|
246
|
+
const args = [target, eventName, payload, dispatch];
|
|
241
247
|
return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
|
|
242
248
|
},
|
|
243
249
|
getFiles: (qualifiedName) => {
|
|
@@ -503,7 +509,7 @@ class FunctionRuntimeImpl {
|
|
|
503
509
|
}
|
|
504
510
|
let eventName = valueOf(args[1]);
|
|
505
511
|
let payload = args.length > 2 ? valueOf(args[2]) : undefined;
|
|
506
|
-
let dispatch = false;
|
|
512
|
+
let dispatch = args.length > 3 ? valueOf(args[3]) : false;
|
|
507
513
|
if (typeof element === 'string') {
|
|
508
514
|
payload = eventName;
|
|
509
515
|
eventName = element;
|
|
@@ -514,7 +520,7 @@ class FunctionRuntimeImpl {
|
|
|
514
520
|
event = new Events_1.CustomEvent(eventName.substring('custom:'.length), payload, dispatch);
|
|
515
521
|
}
|
|
516
522
|
else {
|
|
517
|
-
event = createAction(eventName, payload);
|
|
523
|
+
event = createAction(eventName, payload, dispatch);
|
|
518
524
|
}
|
|
519
525
|
if (event != null) {
|
|
520
526
|
if (typeof element === 'string') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.105",
|
|
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.105"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|
package/esm/Events-f062426b.js
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
const ConstraintType = Object.freeze({
|
|
2
|
-
PATTERN_MISMATCH: 'patternMismatch',
|
|
3
|
-
TOO_SHORT: 'tooShort',
|
|
4
|
-
TOO_LONG: 'tooLong',
|
|
5
|
-
RANGE_OVERFLOW: 'rangeOverflow',
|
|
6
|
-
RANGE_UNDERFLOW: 'rangeUnderflow',
|
|
7
|
-
TYPE_MISMATCH: 'typeMismatch',
|
|
8
|
-
VALUE_MISSING: 'valueMissing',
|
|
9
|
-
STEP_MISMATCH: 'stepMismatch',
|
|
10
|
-
FORMAT_MISMATCH: 'formatMismatch',
|
|
11
|
-
ACCEPT_MISMATCH: 'acceptMismatch',
|
|
12
|
-
FILE_SIZE_MISMATCH: 'fileSizeMismatch',
|
|
13
|
-
UNIQUE_ITEMS_MISMATCH: 'uniqueItemsMismatch',
|
|
14
|
-
MIN_ITEMS_MISMATCH: 'minItemsMismatch',
|
|
15
|
-
MAX_ITEMS_MISMATCH: 'maxItemsMismatch',
|
|
16
|
-
EXPRESSION_MISMATCH: 'expressionMismatch',
|
|
17
|
-
EXCLUSIVE_MAXIMUM_MISMATCH: 'exclusiveMaximumMismatch',
|
|
18
|
-
EXCLUSIVE_MINIMUM_MISMATCH: 'exclusiveMinimumMismatch'
|
|
19
|
-
});
|
|
20
|
-
const constraintKeys = Object.freeze({
|
|
21
|
-
pattern: ConstraintType.PATTERN_MISMATCH,
|
|
22
|
-
minLength: ConstraintType.TOO_SHORT,
|
|
23
|
-
maxLength: ConstraintType.TOO_LONG,
|
|
24
|
-
maximum: ConstraintType.RANGE_OVERFLOW,
|
|
25
|
-
minimum: ConstraintType.RANGE_UNDERFLOW,
|
|
26
|
-
type: ConstraintType.TYPE_MISMATCH,
|
|
27
|
-
required: ConstraintType.VALUE_MISSING,
|
|
28
|
-
step: ConstraintType.STEP_MISMATCH,
|
|
29
|
-
format: ConstraintType.FORMAT_MISMATCH,
|
|
30
|
-
accept: ConstraintType.ACCEPT_MISMATCH,
|
|
31
|
-
maxFileSize: ConstraintType.FILE_SIZE_MISMATCH,
|
|
32
|
-
uniqueItems: ConstraintType.UNIQUE_ITEMS_MISMATCH,
|
|
33
|
-
minItems: ConstraintType.MIN_ITEMS_MISMATCH,
|
|
34
|
-
maxItems: ConstraintType.MAX_ITEMS_MISMATCH,
|
|
35
|
-
validationExpression: ConstraintType.EXPRESSION_MISMATCH,
|
|
36
|
-
exclusiveMinimum: ConstraintType.EXCLUSIVE_MINIMUM_MISMATCH,
|
|
37
|
-
exclusiveMaximum: ConstraintType.EXCLUSIVE_MAXIMUM_MISMATCH
|
|
38
|
-
});
|
|
39
|
-
const defaultConstraintTypeMessages = Object.freeze({
|
|
40
|
-
[ConstraintType.PATTERN_MISMATCH]: 'Please match the format requested.',
|
|
41
|
-
[ConstraintType.TOO_SHORT]: 'Please lengthen this text to ${0} characters or more.',
|
|
42
|
-
[ConstraintType.TOO_LONG]: 'Please shorten this text to ${0} characters or less.',
|
|
43
|
-
[ConstraintType.RANGE_OVERFLOW]: 'Value must be less than or equal to ${0}.',
|
|
44
|
-
[ConstraintType.RANGE_UNDERFLOW]: 'Value must be greater than or equal to ${0}.',
|
|
45
|
-
[ConstraintType.TYPE_MISMATCH]: 'Please enter a valid value.',
|
|
46
|
-
[ConstraintType.VALUE_MISSING]: 'Please fill in this field.',
|
|
47
|
-
[ConstraintType.STEP_MISMATCH]: 'Please enter a valid value.',
|
|
48
|
-
[ConstraintType.FORMAT_MISMATCH]: 'Specify the value in allowed format : ${0}.',
|
|
49
|
-
[ConstraintType.ACCEPT_MISMATCH]: 'The specified file type not supported.',
|
|
50
|
-
[ConstraintType.FILE_SIZE_MISMATCH]: 'File too large. Reduce size and try again.',
|
|
51
|
-
[ConstraintType.UNIQUE_ITEMS_MISMATCH]: 'All the items must be unique.',
|
|
52
|
-
[ConstraintType.MIN_ITEMS_MISMATCH]: 'Specify a number of items equal to or greater than ${0}.',
|
|
53
|
-
[ConstraintType.MAX_ITEMS_MISMATCH]: 'Specify a number of items equal to or less than ${0}.',
|
|
54
|
-
[ConstraintType.EXPRESSION_MISMATCH]: 'Please enter a valid value.',
|
|
55
|
-
[ConstraintType.EXCLUSIVE_MINIMUM_MISMATCH]: 'Value must be greater than ${0}.',
|
|
56
|
-
[ConstraintType.EXCLUSIVE_MAXIMUM_MISMATCH]: 'Value must be less than ${0}.'
|
|
57
|
-
});
|
|
58
|
-
let customConstraintTypeMessages = {};
|
|
59
|
-
const getConstraintTypeMessages = () => {
|
|
60
|
-
return {
|
|
61
|
-
...defaultConstraintTypeMessages,
|
|
62
|
-
...customConstraintTypeMessages
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
var EventSource;
|
|
67
|
-
(function (EventSource) {
|
|
68
|
-
EventSource["CODE"] = "code";
|
|
69
|
-
EventSource["UI"] = "ui";
|
|
70
|
-
})(EventSource || (EventSource = {}));
|
|
71
|
-
class ValidationError {
|
|
72
|
-
fieldName;
|
|
73
|
-
errorMessages;
|
|
74
|
-
constructor(fieldName = '', errorMessages = []) {
|
|
75
|
-
this.errorMessages = errorMessages;
|
|
76
|
-
this.fieldName = fieldName;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
var FocusOption;
|
|
80
|
-
(function (FocusOption) {
|
|
81
|
-
FocusOption["NEXT_ITEM"] = "nextItem";
|
|
82
|
-
FocusOption["PREVIOUS_ITEM"] = "previousItem";
|
|
83
|
-
})(FocusOption || (FocusOption = {}));
|
|
84
|
-
var CaptchaDisplayMode;
|
|
85
|
-
(function (CaptchaDisplayMode) {
|
|
86
|
-
CaptchaDisplayMode["INVISIBLE"] = "invisible";
|
|
87
|
-
CaptchaDisplayMode["VISIBLE"] = "visible";
|
|
88
|
-
})(CaptchaDisplayMode || (CaptchaDisplayMode = {}));
|
|
89
|
-
|
|
90
|
-
class ActionImpl {
|
|
91
|
-
_metadata;
|
|
92
|
-
_type;
|
|
93
|
-
_payload;
|
|
94
|
-
_target;
|
|
95
|
-
_currentTarget;
|
|
96
|
-
constructor(payload, type, _metadata) {
|
|
97
|
-
this._metadata = _metadata;
|
|
98
|
-
this._payload = payload;
|
|
99
|
-
this._type = type;
|
|
100
|
-
}
|
|
101
|
-
get type() {
|
|
102
|
-
return this._type;
|
|
103
|
-
}
|
|
104
|
-
get payload() {
|
|
105
|
-
return this._payload;
|
|
106
|
-
}
|
|
107
|
-
get metadata() {
|
|
108
|
-
return this._metadata;
|
|
109
|
-
}
|
|
110
|
-
get target() {
|
|
111
|
-
return this._target;
|
|
112
|
-
}
|
|
113
|
-
get currentTarget() {
|
|
114
|
-
return this._currentTarget;
|
|
115
|
-
}
|
|
116
|
-
get isCustomEvent() {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
payloadToJson() {
|
|
120
|
-
return this.payload;
|
|
121
|
-
}
|
|
122
|
-
toJson() {
|
|
123
|
-
return {
|
|
124
|
-
payload: this.payloadToJson(),
|
|
125
|
-
type: this.type,
|
|
126
|
-
isCustomEvent: this.isCustomEvent
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
toString() {
|
|
130
|
-
return JSON.stringify(this.toJson());
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
class Change extends ActionImpl {
|
|
134
|
-
constructor(payload, dispatch = false) {
|
|
135
|
-
super(payload, 'change', { dispatch });
|
|
136
|
-
}
|
|
137
|
-
withAdditionalChange(change) {
|
|
138
|
-
return new Change(this.payload.changes.concat(change.payload.changes), this.metadata);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
class UIChange extends ActionImpl {
|
|
142
|
-
constructor(payload, dispatch = false) {
|
|
143
|
-
super(payload, 'uiChange', { dispatch });
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
class Invalid extends ActionImpl {
|
|
147
|
-
constructor(payload = {}) {
|
|
148
|
-
super(payload, 'invalid', {});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
class Valid extends ActionImpl {
|
|
152
|
-
constructor(payload = {}) {
|
|
153
|
-
super(payload, 'valid', {});
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
class ExecuteRule extends ActionImpl {
|
|
157
|
-
constructor(payload = {}, dispatch = false) {
|
|
158
|
-
super(payload, 'executeRule', { dispatch });
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
const propertyChange = (propertyName, currentValue, prevValue) => {
|
|
162
|
-
return new Change({
|
|
163
|
-
changes: [
|
|
164
|
-
{
|
|
165
|
-
propertyName,
|
|
166
|
-
currentValue,
|
|
167
|
-
prevValue
|
|
168
|
-
}
|
|
169
|
-
]
|
|
170
|
-
});
|
|
171
|
-
};
|
|
172
|
-
class Initialize extends ActionImpl {
|
|
173
|
-
constructor(payload, dispatch = false) {
|
|
174
|
-
super(payload, 'initialize', { dispatch });
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
class FormLoad extends ActionImpl {
|
|
178
|
-
constructor() {
|
|
179
|
-
super({}, 'load', { dispatch: false });
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
class Click extends ActionImpl {
|
|
183
|
-
constructor(payload, dispatch = false) {
|
|
184
|
-
super(payload, 'click', { dispatch });
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
class Blur extends ActionImpl {
|
|
188
|
-
constructor(payload, dispatch = false) {
|
|
189
|
-
super(payload, 'blur', { dispatch });
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
class ValidationComplete extends ActionImpl {
|
|
193
|
-
constructor(payload, dispatch = false) {
|
|
194
|
-
super(payload, 'validationComplete', { dispatch });
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
class Focus extends ActionImpl {
|
|
198
|
-
constructor() {
|
|
199
|
-
super({}, 'focus', { dispatch: false });
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
class Submit extends ActionImpl {
|
|
203
|
-
constructor(payload, dispatch = false) {
|
|
204
|
-
super(payload, 'submit', { dispatch });
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
class Save extends ActionImpl {
|
|
208
|
-
constructor(payload, dispatch = false) {
|
|
209
|
-
super(payload, 'save', { dispatch });
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
class SubmitSuccess extends ActionImpl {
|
|
213
|
-
constructor(payload, dispatch = false) {
|
|
214
|
-
super(payload, 'submitSuccess', { dispatch });
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
class SubmitFailure extends ActionImpl {
|
|
218
|
-
constructor(payload, dispatch = false) {
|
|
219
|
-
super(payload, 'submitFailure', { dispatch });
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
class SubmitError extends ActionImpl {
|
|
223
|
-
constructor(payload, dispatch = false) {
|
|
224
|
-
super(payload, 'submitError', { dispatch });
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
class Reset extends ActionImpl {
|
|
228
|
-
constructor(payload, dispatch = false) {
|
|
229
|
-
super(payload, 'reset', { dispatch });
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
class FieldChanged extends ActionImpl {
|
|
233
|
-
constructor(changes, field, eventSource = EventSource.CODE) {
|
|
234
|
-
super({
|
|
235
|
-
field,
|
|
236
|
-
changes,
|
|
237
|
-
eventSource
|
|
238
|
-
}, 'fieldChanged');
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
class CustomEvent extends ActionImpl {
|
|
242
|
-
constructor(eventName, payload = {}, dispatch = false) {
|
|
243
|
-
super(payload, eventName, { dispatch });
|
|
244
|
-
}
|
|
245
|
-
get isCustomEvent() {
|
|
246
|
-
return true;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
class AddItem extends ActionImpl {
|
|
250
|
-
constructor(payload) {
|
|
251
|
-
super(payload, 'addItem');
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
class RemoveItem extends ActionImpl {
|
|
255
|
-
constructor(payload) {
|
|
256
|
-
super(payload, 'removeItem');
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
class AddInstance extends ActionImpl {
|
|
260
|
-
constructor(payload) {
|
|
261
|
-
super(payload, 'addInstance');
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
class RemoveInstance extends ActionImpl {
|
|
265
|
-
constructor(payload) {
|
|
266
|
-
super(payload, 'removeInstance');
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export { AddInstance as A, Blur as B, CustomEvent as C, EventSource as E, FormLoad as F, Initialize as I, RemoveItem as R, SubmitSuccess as S, UIChange as U, ValidationComplete as V, ExecuteRule as a, SubmitError as b, SubmitFailure as c, CaptchaDisplayMode as d, Submit as e, Save as f, RemoveInstance as g, Reset as h, AddItem as i, Click as j, Change as k, FocusOption as l, FieldChanged as m, constraintKeys as n, getConstraintTypeMessages as o, propertyChange as p, Valid as q, Invalid as r, ValidationError as s, Focus as t };
|