@aemforms/af-core 0.22.88 → 0.22.90
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/Events-a66f7a2c.js +259 -0
- package/esm/afb-events.js +1 -175
- package/esm/afb-runtime.js +24 -78
- package/esm/types/src/BaseNode.d.ts +2 -1
- package/esm/types/src/Captcha.d.ts +13 -2
- package/esm/types/src/controller/Events.d.ts +3 -2
- package/esm/types/src/types/Json.d.ts +6 -0
- package/esm/types/src/types/Model.d.ts +14 -0
- package/lib/BaseNode.d.ts +2 -1
- package/lib/BaseNode.js +2 -0
- package/lib/Captcha.d.ts +13 -2
- package/lib/Captcha.js +15 -0
- package/lib/Field.js +1 -1
- package/lib/Form.js +1 -1
- package/lib/controller/Events.d.ts +3 -2
- package/lib/controller/Events.js +4 -2
- package/lib/rules/FunctionRuntime.js +5 -4
- package/lib/types/Json.d.ts +6 -0
- package/lib/types/Model.d.ts +14 -0
- package/lib/types/Model.js +11 -1
- package/package.json +2 -2
|
@@ -0,0 +1,259 @@
|
|
|
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
|
+
});
|
|
18
|
+
const constraintKeys = Object.freeze({
|
|
19
|
+
pattern: ConstraintType.PATTERN_MISMATCH,
|
|
20
|
+
minLength: ConstraintType.TOO_SHORT,
|
|
21
|
+
maxLength: ConstraintType.TOO_LONG,
|
|
22
|
+
maximum: ConstraintType.RANGE_OVERFLOW,
|
|
23
|
+
minimum: ConstraintType.RANGE_UNDERFLOW,
|
|
24
|
+
type: ConstraintType.TYPE_MISMATCH,
|
|
25
|
+
required: ConstraintType.VALUE_MISSING,
|
|
26
|
+
step: ConstraintType.STEP_MISMATCH,
|
|
27
|
+
format: ConstraintType.FORMAT_MISMATCH,
|
|
28
|
+
accept: ConstraintType.ACCEPT_MISMATCH,
|
|
29
|
+
maxFileSize: ConstraintType.FILE_SIZE_MISMATCH,
|
|
30
|
+
uniqueItems: ConstraintType.UNIQUE_ITEMS_MISMATCH,
|
|
31
|
+
minItems: ConstraintType.MIN_ITEMS_MISMATCH,
|
|
32
|
+
maxItems: ConstraintType.MAX_ITEMS_MISMATCH,
|
|
33
|
+
validationExpression: ConstraintType.EXPRESSION_MISMATCH
|
|
34
|
+
});
|
|
35
|
+
const defaultConstraintTypeMessages = Object.freeze({
|
|
36
|
+
[ConstraintType.PATTERN_MISMATCH]: 'Please match the format requested.',
|
|
37
|
+
[ConstraintType.TOO_SHORT]: 'Please lengthen this text to ${0} characters or more.',
|
|
38
|
+
[ConstraintType.TOO_LONG]: 'Please shorten this text to ${0} characters or less.',
|
|
39
|
+
[ConstraintType.RANGE_OVERFLOW]: 'Value must be less than or equal to ${0}.',
|
|
40
|
+
[ConstraintType.RANGE_UNDERFLOW]: 'Value must be greater than or equal to ${0}.',
|
|
41
|
+
[ConstraintType.TYPE_MISMATCH]: 'Please enter a valid value.',
|
|
42
|
+
[ConstraintType.VALUE_MISSING]: 'Please fill in this field.',
|
|
43
|
+
[ConstraintType.STEP_MISMATCH]: 'Please enter a valid value.',
|
|
44
|
+
[ConstraintType.FORMAT_MISMATCH]: 'Specify the value in allowed format : ${0}.',
|
|
45
|
+
[ConstraintType.ACCEPT_MISMATCH]: 'The specified file type not supported.',
|
|
46
|
+
[ConstraintType.FILE_SIZE_MISMATCH]: 'File too large. Reduce size and try again.',
|
|
47
|
+
[ConstraintType.UNIQUE_ITEMS_MISMATCH]: 'All the items must be unique.',
|
|
48
|
+
[ConstraintType.MIN_ITEMS_MISMATCH]: 'Specify a number of items equal to or greater than ${0}.',
|
|
49
|
+
[ConstraintType.MAX_ITEMS_MISMATCH]: 'Specify a number of items equal to or less than ${0}.',
|
|
50
|
+
[ConstraintType.EXPRESSION_MISMATCH]: 'Please enter a valid value.'
|
|
51
|
+
});
|
|
52
|
+
let customConstraintTypeMessages = {};
|
|
53
|
+
const getConstraintTypeMessages = () => {
|
|
54
|
+
return {
|
|
55
|
+
...defaultConstraintTypeMessages,
|
|
56
|
+
...customConstraintTypeMessages
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
var EventSource;
|
|
61
|
+
(function (EventSource) {
|
|
62
|
+
EventSource["CODE"] = "code";
|
|
63
|
+
EventSource["UI"] = "ui";
|
|
64
|
+
})(EventSource || (EventSource = {}));
|
|
65
|
+
class ValidationError {
|
|
66
|
+
fieldName;
|
|
67
|
+
errorMessages;
|
|
68
|
+
constructor(fieldName = '', errorMessages = []) {
|
|
69
|
+
this.errorMessages = errorMessages;
|
|
70
|
+
this.fieldName = fieldName;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
var FocusOption;
|
|
74
|
+
(function (FocusOption) {
|
|
75
|
+
FocusOption["NEXT_ITEM"] = "nextItem";
|
|
76
|
+
FocusOption["PREVIOUS_ITEM"] = "previousItem";
|
|
77
|
+
})(FocusOption || (FocusOption = {}));
|
|
78
|
+
var CaptchaDisplayMode;
|
|
79
|
+
(function (CaptchaDisplayMode) {
|
|
80
|
+
CaptchaDisplayMode["INVISIBLE"] = "invisible";
|
|
81
|
+
CaptchaDisplayMode["VISIBLE"] = "visible";
|
|
82
|
+
})(CaptchaDisplayMode || (CaptchaDisplayMode = {}));
|
|
83
|
+
|
|
84
|
+
class ActionImpl {
|
|
85
|
+
_metadata;
|
|
86
|
+
_type;
|
|
87
|
+
_payload;
|
|
88
|
+
_target;
|
|
89
|
+
_currentTarget;
|
|
90
|
+
constructor(payload, type, _metadata) {
|
|
91
|
+
this._metadata = _metadata;
|
|
92
|
+
this._payload = payload;
|
|
93
|
+
this._type = type;
|
|
94
|
+
}
|
|
95
|
+
get type() {
|
|
96
|
+
return this._type;
|
|
97
|
+
}
|
|
98
|
+
get payload() {
|
|
99
|
+
return this._payload;
|
|
100
|
+
}
|
|
101
|
+
get metadata() {
|
|
102
|
+
return this._metadata;
|
|
103
|
+
}
|
|
104
|
+
get target() {
|
|
105
|
+
return this._target;
|
|
106
|
+
}
|
|
107
|
+
get currentTarget() {
|
|
108
|
+
return this._currentTarget;
|
|
109
|
+
}
|
|
110
|
+
get isCustomEvent() {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
payloadToJson() {
|
|
114
|
+
return this.payload;
|
|
115
|
+
}
|
|
116
|
+
toJson() {
|
|
117
|
+
return {
|
|
118
|
+
payload: this.payloadToJson(),
|
|
119
|
+
type: this.type,
|
|
120
|
+
isCustomEvent: this.isCustomEvent
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
toString() {
|
|
124
|
+
return JSON.stringify(this.toJson());
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
class Change extends ActionImpl {
|
|
128
|
+
constructor(payload, dispatch = false) {
|
|
129
|
+
super(payload, 'change', { dispatch });
|
|
130
|
+
}
|
|
131
|
+
withAdditionalChange(change) {
|
|
132
|
+
return new Change(this.payload.changes.concat(change.payload.changes), this.metadata);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
class Invalid extends ActionImpl {
|
|
136
|
+
constructor(payload = {}) {
|
|
137
|
+
super(payload, 'invalid', {});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
class Valid extends ActionImpl {
|
|
141
|
+
constructor(payload = {}) {
|
|
142
|
+
super(payload, 'valid', {});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
class ExecuteRule extends ActionImpl {
|
|
146
|
+
constructor(payload = {}, dispatch = false) {
|
|
147
|
+
super(payload, 'executeRule', { dispatch });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const propertyChange = (propertyName, currentValue, prevValue) => {
|
|
151
|
+
return new Change({
|
|
152
|
+
changes: [
|
|
153
|
+
{
|
|
154
|
+
propertyName,
|
|
155
|
+
currentValue,
|
|
156
|
+
prevValue
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
class Initialize extends ActionImpl {
|
|
162
|
+
constructor(payload, dispatch = false) {
|
|
163
|
+
super(payload, 'initialize', { dispatch });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
class FormLoad extends ActionImpl {
|
|
167
|
+
constructor() {
|
|
168
|
+
super({}, 'load', { dispatch: false });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
class Click extends ActionImpl {
|
|
172
|
+
constructor(payload, dispatch = false) {
|
|
173
|
+
super(payload, 'click', { dispatch });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
class Blur extends ActionImpl {
|
|
177
|
+
constructor(payload, dispatch = false) {
|
|
178
|
+
super(payload, 'blur', { dispatch });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
class ValidationComplete extends ActionImpl {
|
|
182
|
+
constructor(payload, dispatch = false) {
|
|
183
|
+
super(payload, 'validationComplete', { dispatch });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
class Focus extends ActionImpl {
|
|
187
|
+
constructor() {
|
|
188
|
+
super({}, 'focus', { dispatch: false });
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
class Submit extends ActionImpl {
|
|
192
|
+
constructor(payload, dispatch = false) {
|
|
193
|
+
super(payload, 'submit', { dispatch });
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
class Save extends ActionImpl {
|
|
197
|
+
constructor(payload, dispatch = false) {
|
|
198
|
+
super(payload, 'save', { dispatch });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
class SubmitSuccess extends ActionImpl {
|
|
202
|
+
constructor(payload, dispatch = false) {
|
|
203
|
+
super(payload, 'submitSuccess', { dispatch });
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
class SubmitFailure extends ActionImpl {
|
|
207
|
+
constructor(payload, dispatch = false) {
|
|
208
|
+
super(payload, 'submitFailure', { dispatch });
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
class SubmitError extends ActionImpl {
|
|
212
|
+
constructor(payload, dispatch = false) {
|
|
213
|
+
super(payload, 'submitError', { dispatch });
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
class Reset extends ActionImpl {
|
|
217
|
+
constructor(payload, dispatch = false) {
|
|
218
|
+
super(payload, 'reset', { dispatch });
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
class FieldChanged extends ActionImpl {
|
|
222
|
+
constructor(changes, field, eventSource = EventSource.CODE) {
|
|
223
|
+
super({
|
|
224
|
+
field,
|
|
225
|
+
changes,
|
|
226
|
+
eventSource
|
|
227
|
+
}, 'fieldChanged');
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
class CustomEvent extends ActionImpl {
|
|
231
|
+
constructor(eventName, payload = {}, dispatch = false) {
|
|
232
|
+
super(payload, eventName, { dispatch });
|
|
233
|
+
}
|
|
234
|
+
get isCustomEvent() {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
class AddItem extends ActionImpl {
|
|
239
|
+
constructor(payload) {
|
|
240
|
+
super(payload, 'addItem');
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
class RemoveItem extends ActionImpl {
|
|
244
|
+
constructor(payload) {
|
|
245
|
+
super(payload, 'removeItem');
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
class AddInstance extends ActionImpl {
|
|
249
|
+
constructor(payload) {
|
|
250
|
+
super(payload, 'addInstance');
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
class RemoveInstance extends ActionImpl {
|
|
254
|
+
constructor(payload) {
|
|
255
|
+
super(payload, 'removeInstance');
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
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, 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 };
|
package/esm/afb-events.js
CHANGED
|
@@ -1,175 +1 @@
|
|
|
1
|
-
|
|
2
|
-
_metadata;
|
|
3
|
-
_type;
|
|
4
|
-
_payload;
|
|
5
|
-
_target;
|
|
6
|
-
_currentTarget;
|
|
7
|
-
constructor(payload, type, _metadata) {
|
|
8
|
-
this._metadata = _metadata;
|
|
9
|
-
this._payload = payload;
|
|
10
|
-
this._type = type;
|
|
11
|
-
}
|
|
12
|
-
get type() {
|
|
13
|
-
return this._type;
|
|
14
|
-
}
|
|
15
|
-
get payload() {
|
|
16
|
-
return this._payload;
|
|
17
|
-
}
|
|
18
|
-
get metadata() {
|
|
19
|
-
return this._metadata;
|
|
20
|
-
}
|
|
21
|
-
get target() {
|
|
22
|
-
return this._target;
|
|
23
|
-
}
|
|
24
|
-
get currentTarget() {
|
|
25
|
-
return this._currentTarget;
|
|
26
|
-
}
|
|
27
|
-
get isCustomEvent() {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
payloadToJson() {
|
|
31
|
-
return this.payload;
|
|
32
|
-
}
|
|
33
|
-
toJson() {
|
|
34
|
-
return {
|
|
35
|
-
payload: this.payloadToJson(),
|
|
36
|
-
type: this.type,
|
|
37
|
-
isCustomEvent: this.isCustomEvent
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
toString() {
|
|
41
|
-
return JSON.stringify(this.toJson());
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
class Change extends ActionImpl {
|
|
45
|
-
constructor(payload, dispatch = false) {
|
|
46
|
-
super(payload, 'change', { dispatch });
|
|
47
|
-
}
|
|
48
|
-
withAdditionalChange(change) {
|
|
49
|
-
return new Change(this.payload.changes.concat(change.payload.changes), this.metadata);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
class Invalid extends ActionImpl {
|
|
53
|
-
constructor(payload = {}) {
|
|
54
|
-
super(payload, 'invalid', {});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
class Valid extends ActionImpl {
|
|
58
|
-
constructor(payload = {}) {
|
|
59
|
-
super(payload, 'valid', {});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
class ExecuteRule extends ActionImpl {
|
|
63
|
-
constructor(payload = {}, dispatch = false) {
|
|
64
|
-
super(payload, 'executeRule', { dispatch });
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const propertyChange = (propertyName, currentValue, prevValue) => {
|
|
68
|
-
return new Change({
|
|
69
|
-
changes: [
|
|
70
|
-
{
|
|
71
|
-
propertyName,
|
|
72
|
-
currentValue,
|
|
73
|
-
prevValue
|
|
74
|
-
}
|
|
75
|
-
]
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
class Initialize extends ActionImpl {
|
|
79
|
-
constructor(payload, dispatch = false) {
|
|
80
|
-
super(payload, 'initialize', { dispatch });
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
class FormLoad extends ActionImpl {
|
|
84
|
-
constructor() {
|
|
85
|
-
super({}, 'load', { dispatch: false });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
class Click extends ActionImpl {
|
|
89
|
-
constructor(payload, dispatch = false) {
|
|
90
|
-
super(payload, 'click', { dispatch });
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
class Blur extends ActionImpl {
|
|
94
|
-
constructor(payload, dispatch = false) {
|
|
95
|
-
super(payload, 'blur', { dispatch });
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
class ValidationComplete extends ActionImpl {
|
|
99
|
-
constructor(payload, dispatch = false) {
|
|
100
|
-
super(payload, 'validationComplete', { dispatch });
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
class Focus extends ActionImpl {
|
|
104
|
-
constructor() {
|
|
105
|
-
super({}, 'focus', { dispatch: false });
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
class Submit extends ActionImpl {
|
|
109
|
-
constructor(payload, dispatch = false) {
|
|
110
|
-
super(payload, 'submit', { dispatch });
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
class Save extends ActionImpl {
|
|
114
|
-
constructor(payload, dispatch = false) {
|
|
115
|
-
super(payload, 'save', { dispatch });
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
class SubmitSuccess extends ActionImpl {
|
|
119
|
-
constructor(payload, dispatch = false) {
|
|
120
|
-
super(payload, 'submitSuccess', { dispatch });
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
class SubmitFailure extends ActionImpl {
|
|
124
|
-
constructor(payload, dispatch = false) {
|
|
125
|
-
super(payload, 'submitFailure', { dispatch });
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
class SubmitError extends ActionImpl {
|
|
129
|
-
constructor(payload, dispatch = false) {
|
|
130
|
-
super(payload, 'submitError', { dispatch });
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
class Reset extends ActionImpl {
|
|
134
|
-
constructor(payload, dispatch = false) {
|
|
135
|
-
super(payload, 'reset', { dispatch });
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
class FieldChanged extends ActionImpl {
|
|
139
|
-
constructor(changes, field) {
|
|
140
|
-
super({
|
|
141
|
-
field,
|
|
142
|
-
changes
|
|
143
|
-
}, 'fieldChanged');
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
class CustomEvent extends ActionImpl {
|
|
147
|
-
constructor(eventName, payload = {}, dispatch = false) {
|
|
148
|
-
super(payload, eventName, { dispatch });
|
|
149
|
-
}
|
|
150
|
-
get isCustomEvent() {
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
class AddItem extends ActionImpl {
|
|
155
|
-
constructor(payload) {
|
|
156
|
-
super(payload, 'addItem');
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
class RemoveItem extends ActionImpl {
|
|
160
|
-
constructor(payload) {
|
|
161
|
-
super(payload, 'removeItem');
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
class AddInstance extends ActionImpl {
|
|
165
|
-
constructor(payload) {
|
|
166
|
-
super(payload, 'addInstance');
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
class RemoveInstance extends ActionImpl {
|
|
170
|
-
constructor(payload) {
|
|
171
|
-
super(payload, 'removeInstance');
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export { AddInstance, AddItem, Blur, Change, Click, CustomEvent, ExecuteRule, FieldChanged, Focus, FormLoad, Initialize, Invalid, RemoveInstance, RemoveItem, Reset, Save, Submit, SubmitError, SubmitFailure, SubmitSuccess, Valid, ValidationComplete, propertyChange };
|
|
1
|
+
export { A as AddInstance, i as AddItem, B as Blur, k as Change, j as Click, C as CustomEvent, a as ExecuteRule, m as FieldChanged, t as Focus, F as FormLoad, I as Initialize, r as Invalid, g as RemoveInstance, R as RemoveItem, h as Reset, f as Save, e as Submit, b as SubmitError, c as SubmitFailure, S as SubmitSuccess, q as Valid, V as ValidationComplete, p as propertyChange } from './Events-a66f7a2c.js';
|
package/esm/afb-runtime.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { propertyChange, ExecuteRule, Initialize, RemoveItem, SubmitSuccess, CustomEvent, SubmitError, SubmitFailure, Submit, Save, RemoveInstance, AddInstance, Reset, AddItem, Click, Change, FormLoad, FieldChanged, ValidationComplete, Valid, Invalid } from './
|
|
1
|
+
import { E as EventSource, p as propertyChange, a as ExecuteRule, I as Initialize, R as RemoveItem, S as SubmitSuccess, C as CustomEvent, b as SubmitError, c as SubmitFailure, d as CaptchaDisplayMode, e as Submit, f as Save, g as RemoveInstance, A as AddInstance, h as Reset, i as AddItem, j as Click, k as Change, F as FormLoad, l as FocusOption, m as FieldChanged, V as ValidationComplete, n as constraintKeys, o as getConstraintTypeMessages, q as Valid, r as Invalid, s as ValidationError } from './Events-a66f7a2c.js';
|
|
2
2
|
import Formula from '@adobe/json-formula';
|
|
3
3
|
import { parseDefaultDate, datetimeToNumber, format, parseDateSkeleton, formatDate, numberToDatetime } from '@aemforms/af-formatters';
|
|
4
4
|
|
|
@@ -9,79 +9,6 @@ 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
|
-
});
|
|
29
|
-
const constraintKeys = Object.freeze({
|
|
30
|
-
pattern: ConstraintType.PATTERN_MISMATCH,
|
|
31
|
-
minLength: ConstraintType.TOO_SHORT,
|
|
32
|
-
maxLength: ConstraintType.TOO_LONG,
|
|
33
|
-
maximum: ConstraintType.RANGE_OVERFLOW,
|
|
34
|
-
minimum: ConstraintType.RANGE_UNDERFLOW,
|
|
35
|
-
type: ConstraintType.TYPE_MISMATCH,
|
|
36
|
-
required: ConstraintType.VALUE_MISSING,
|
|
37
|
-
step: ConstraintType.STEP_MISMATCH,
|
|
38
|
-
format: ConstraintType.FORMAT_MISMATCH,
|
|
39
|
-
accept: ConstraintType.ACCEPT_MISMATCH,
|
|
40
|
-
maxFileSize: ConstraintType.FILE_SIZE_MISMATCH,
|
|
41
|
-
uniqueItems: ConstraintType.UNIQUE_ITEMS_MISMATCH,
|
|
42
|
-
minItems: ConstraintType.MIN_ITEMS_MISMATCH,
|
|
43
|
-
maxItems: ConstraintType.MAX_ITEMS_MISMATCH,
|
|
44
|
-
validationExpression: ConstraintType.EXPRESSION_MISMATCH
|
|
45
|
-
});
|
|
46
|
-
const defaultConstraintTypeMessages = Object.freeze({
|
|
47
|
-
[ConstraintType.PATTERN_MISMATCH]: 'Please match the format requested.',
|
|
48
|
-
[ConstraintType.TOO_SHORT]: 'Please lengthen this text to ${0} characters or more.',
|
|
49
|
-
[ConstraintType.TOO_LONG]: 'Please shorten this text to ${0} characters or less.',
|
|
50
|
-
[ConstraintType.RANGE_OVERFLOW]: 'Value must be less than or equal to ${0}.',
|
|
51
|
-
[ConstraintType.RANGE_UNDERFLOW]: 'Value must be greater than or equal to ${0}.',
|
|
52
|
-
[ConstraintType.TYPE_MISMATCH]: 'Please enter a valid value.',
|
|
53
|
-
[ConstraintType.VALUE_MISSING]: 'Please fill in this field.',
|
|
54
|
-
[ConstraintType.STEP_MISMATCH]: 'Please enter a valid value.',
|
|
55
|
-
[ConstraintType.FORMAT_MISMATCH]: 'Specify the value in allowed format : ${0}.',
|
|
56
|
-
[ConstraintType.ACCEPT_MISMATCH]: 'The specified file type not supported.',
|
|
57
|
-
[ConstraintType.FILE_SIZE_MISMATCH]: 'File too large. Reduce size and try again.',
|
|
58
|
-
[ConstraintType.UNIQUE_ITEMS_MISMATCH]: 'All the items must be unique.',
|
|
59
|
-
[ConstraintType.MIN_ITEMS_MISMATCH]: 'Specify a number of items equal to or greater than ${0}.',
|
|
60
|
-
[ConstraintType.MAX_ITEMS_MISMATCH]: 'Specify a number of items equal to or less than ${0}.',
|
|
61
|
-
[ConstraintType.EXPRESSION_MISMATCH]: 'Please enter a valid value.'
|
|
62
|
-
});
|
|
63
|
-
let customConstraintTypeMessages = {};
|
|
64
|
-
const getConstraintTypeMessages = () => {
|
|
65
|
-
return {
|
|
66
|
-
...defaultConstraintTypeMessages,
|
|
67
|
-
...customConstraintTypeMessages
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
|
|
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
|
-
|
|
85
12
|
const objToMap = (o) => new Map(Object.entries(o));
|
|
86
13
|
const stringViewTypes = objToMap({ 'date': 'date-input', 'data-url': 'file-input', 'binary': 'file-input' });
|
|
87
14
|
const typeToViewTypes = objToMap({
|
|
@@ -1216,6 +1143,7 @@ class BaseNode {
|
|
|
1216
1143
|
_dependents = [];
|
|
1217
1144
|
_jsonModel;
|
|
1218
1145
|
_tokens = [];
|
|
1146
|
+
_eventSource = EventSource.CODE;
|
|
1219
1147
|
get isContainer() {
|
|
1220
1148
|
return false;
|
|
1221
1149
|
}
|
|
@@ -2837,8 +2765,8 @@ class FunctionRuntimeImpl {
|
|
|
2837
2765
|
validate_form = args.length > 4 ? valueOf(args[4]) : true;
|
|
2838
2766
|
}
|
|
2839
2767
|
const form = interpreter.globals.form;
|
|
2840
|
-
if (form.captcha && form.captcha.
|
|
2841
|
-
&& form.captcha.properties['fd:captcha']
|
|
2768
|
+
if (form.captcha && (form.captcha.captchaDisplayMode === CaptchaDisplayMode.INVISIBLE ||
|
|
2769
|
+
(form.captcha.properties['fd:captcha']?.config?.version === 'enterprise' && form.captcha.properties['fd:captcha']?.config?.keyType === 'score'))) {
|
|
2842
2770
|
if (typeof interpreter.runtime.functionTable.fetchCaptchaToken?._func !== 'function') {
|
|
2843
2771
|
interpreter.globals.form.logger.error('fetchCaptchaToken is not defined');
|
|
2844
2772
|
interpreter.globals.form.dispatch(new SubmitError({ type: 'FetchCaptchaTokenNotDefined' }));
|
|
@@ -3257,7 +3185,7 @@ class Form extends Container {
|
|
|
3257
3185
|
prevValue: shallowClone(prevValue)
|
|
3258
3186
|
};
|
|
3259
3187
|
});
|
|
3260
|
-
const fieldChangedAction = new FieldChanged(changes, field);
|
|
3188
|
+
const fieldChangedAction = new FieldChanged(changes, field, action.payload.eventSource);
|
|
3261
3189
|
this.notifyDependents(fieldChangedAction);
|
|
3262
3190
|
}
|
|
3263
3191
|
});
|
|
@@ -3856,7 +3784,7 @@ class Field extends Scriptable {
|
|
|
3856
3784
|
if (updates.valid) {
|
|
3857
3785
|
this.triggerValidationEvent(updates);
|
|
3858
3786
|
}
|
|
3859
|
-
const changeAction = new Change({ changes: changes.concat(Object.values(updates)) });
|
|
3787
|
+
const changeAction = new Change({ changes: changes.concat(Object.values(updates)), eventSource: this._eventSource });
|
|
3860
3788
|
this.dispatch(changeAction);
|
|
3861
3789
|
}
|
|
3862
3790
|
}
|
|
@@ -4492,12 +4420,30 @@ class EmailInput extends Field {
|
|
|
4492
4420
|
}
|
|
4493
4421
|
|
|
4494
4422
|
class Captcha extends Field {
|
|
4423
|
+
_captchaDisplayMode;
|
|
4424
|
+
_captchaProvider;
|
|
4425
|
+
_captchaSiteKey;
|
|
4426
|
+
constructor(params, _options) {
|
|
4427
|
+
super(params, _options);
|
|
4428
|
+
this._captchaDisplayMode = params.captchaDisplayMode;
|
|
4429
|
+
this._captchaProvider = params.captchaProvider;
|
|
4430
|
+
this._captchaSiteKey = params.siteKey;
|
|
4431
|
+
}
|
|
4495
4432
|
getDataNode() {
|
|
4496
4433
|
return undefined;
|
|
4497
4434
|
}
|
|
4498
4435
|
custom_setProperty(action) {
|
|
4499
4436
|
this.applyUpdates(action.payload);
|
|
4500
4437
|
}
|
|
4438
|
+
get captchaDisplayMode() {
|
|
4439
|
+
return this._captchaDisplayMode;
|
|
4440
|
+
}
|
|
4441
|
+
get captchaProvider() {
|
|
4442
|
+
return this._captchaProvider;
|
|
4443
|
+
}
|
|
4444
|
+
get captchaSiteKey() {
|
|
4445
|
+
return this._captchaSiteKey;
|
|
4446
|
+
}
|
|
4501
4447
|
}
|
|
4502
4448
|
|
|
4503
4449
|
class Button extends Field {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Action, BaseJson, BaseModel, callbackFn, ContainerModel, FormCreationMode, FormModel, Primitives, ValidationError } from './types/index';
|
|
1
|
+
import { Action, BaseJson, BaseModel, callbackFn, ContainerModel, FormCreationMode, FormModel, Primitives, ValidationError, EventSource } from './types/index';
|
|
2
2
|
import DataGroup from './data/DataGroup';
|
|
3
3
|
import DataValue from './data/DataValue';
|
|
4
4
|
export declare const editableProperties: string[];
|
|
@@ -19,6 +19,7 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
19
19
|
id: string;
|
|
20
20
|
};
|
|
21
21
|
private _tokens;
|
|
22
|
+
_eventSource: EventSource;
|
|
22
23
|
get isContainer(): boolean;
|
|
23
24
|
constructor(params: T, _options: {
|
|
24
25
|
form: FormModel;
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import Field from './Field';
|
|
2
|
-
import { Action } from './types';
|
|
3
|
-
declare class Captcha extends Field {
|
|
2
|
+
import { Action, CaptchaDisplayMode, CaptchaJson, CaptchaModel, ContainerModel, FormModel } from './types';
|
|
3
|
+
declare class Captcha extends Field implements CaptchaModel {
|
|
4
|
+
private _captchaDisplayMode;
|
|
5
|
+
private _captchaProvider;
|
|
6
|
+
private _captchaSiteKey;
|
|
7
|
+
constructor(params: CaptchaJson, _options: {
|
|
8
|
+
form: FormModel;
|
|
9
|
+
parent: ContainerModel;
|
|
10
|
+
mode?: 'create' | 'restore';
|
|
11
|
+
});
|
|
4
12
|
getDataNode(): undefined;
|
|
5
13
|
custom_setProperty(action: Action): void;
|
|
14
|
+
get captchaDisplayMode(): CaptchaDisplayMode | undefined;
|
|
15
|
+
get captchaProvider(): string | undefined;
|
|
16
|
+
get captchaSiteKey(): string | undefined;
|
|
6
17
|
}
|
|
7
18
|
export default Captcha;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Action, BaseJson, FieldModel, FieldsetModel, FormModel, ValidationError } from '../types/index';
|
|
1
|
+
import { Action, BaseJson, FieldModel, FieldsetModel, FormModel, ValidationError, EventSource } from '../types/index';
|
|
2
2
|
declare class ActionImpl implements Action {
|
|
3
3
|
private _metadata?;
|
|
4
4
|
protected _type: string;
|
|
@@ -26,6 +26,7 @@ export type ChangePayload = {
|
|
|
26
26
|
prevValue?: any;
|
|
27
27
|
currentValue: any;
|
|
28
28
|
}>;
|
|
29
|
+
eventSource?: EventSource;
|
|
29
30
|
};
|
|
30
31
|
export declare class Change extends ActionImpl {
|
|
31
32
|
constructor(payload: ChangePayload, dispatch?: boolean);
|
|
@@ -78,7 +79,7 @@ export declare class Reset extends ActionImpl {
|
|
|
78
79
|
constructor(payload?: any, dispatch?: boolean);
|
|
79
80
|
}
|
|
80
81
|
export declare class FieldChanged extends ActionImpl {
|
|
81
|
-
constructor(changes: ChangePayload, field: BaseJson);
|
|
82
|
+
constructor(changes: ChangePayload, field: BaseJson, eventSource?: EventSource);
|
|
82
83
|
}
|
|
83
84
|
export declare class CustomEvent extends ActionImpl {
|
|
84
85
|
constructor(eventName: string, payload?: any, dispatch?: boolean);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CaptchaDisplayMode } from './Model';
|
|
1
2
|
export type Items<T> = {
|
|
2
3
|
[key: string]: T;
|
|
3
4
|
};
|
|
@@ -100,6 +101,11 @@ export type FieldJson = BaseJson & TranslationFieldJson & {
|
|
|
100
101
|
emptyValue?: 'null' | 'undefined' | '';
|
|
101
102
|
checked?: boolean;
|
|
102
103
|
};
|
|
104
|
+
export type CaptchaJson = FieldJson & {
|
|
105
|
+
captchaDisplayMode?: CaptchaDisplayMode | undefined;
|
|
106
|
+
captchaProvider?: string | undefined;
|
|
107
|
+
siteKey?: string | undefined;
|
|
108
|
+
};
|
|
103
109
|
export type ContainerJson = BaseJson & {
|
|
104
110
|
items: Array<FieldJson | ContainerJson>;
|
|
105
111
|
initialItems?: number;
|
|
@@ -42,6 +42,10 @@ export interface WithController {
|
|
|
42
42
|
dispatch(action: Action): void;
|
|
43
43
|
}
|
|
44
44
|
export type FormCreationMode = 'create' | 'restore';
|
|
45
|
+
export declare enum EventSource {
|
|
46
|
+
CODE = "code",
|
|
47
|
+
UI = "ui"
|
|
48
|
+
}
|
|
45
49
|
export interface BaseModel extends ConstraintsJson, WithController {
|
|
46
50
|
readonly lang?: string;
|
|
47
51
|
readonly name?: string;
|
|
@@ -74,6 +78,7 @@ export interface BaseModel extends ConstraintsJson, WithController {
|
|
|
74
78
|
ruleNodeReference(): any;
|
|
75
79
|
_initialize(mode?: FormCreationMode): any;
|
|
76
80
|
_addDependent(dependent: BaseModel): any;
|
|
81
|
+
_eventSource: EventSource;
|
|
77
82
|
}
|
|
78
83
|
export interface FieldModel extends BaseModel, ScriptableField, WithState<FieldJson> {
|
|
79
84
|
parent: ContainerModel;
|
|
@@ -83,6 +88,11 @@ export interface FieldModel extends BaseModel, ScriptableField, WithState<FieldJ
|
|
|
83
88
|
readonly displayValueExpression?: string;
|
|
84
89
|
readonly editValue?: string;
|
|
85
90
|
}
|
|
91
|
+
export interface CaptchaModel extends FieldModel {
|
|
92
|
+
captchaDisplayMode: CaptchaDisplayMode | undefined;
|
|
93
|
+
captchaProvider: string | undefined;
|
|
94
|
+
captchaSiteKey: string | undefined;
|
|
95
|
+
}
|
|
86
96
|
export interface FormMetaDataModel {
|
|
87
97
|
readonly version?: string;
|
|
88
98
|
readonly grammar: string;
|
|
@@ -144,4 +154,8 @@ export declare enum FocusOption {
|
|
|
144
154
|
NEXT_ITEM = "nextItem",
|
|
145
155
|
PREVIOUS_ITEM = "previousItem"
|
|
146
156
|
}
|
|
157
|
+
export declare enum CaptchaDisplayMode {
|
|
158
|
+
INVISIBLE = "invisible",
|
|
159
|
+
VISIBLE = "visible"
|
|
160
|
+
}
|
|
147
161
|
export {};
|
package/lib/BaseNode.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Action, BaseJson, BaseModel, callbackFn, ContainerModel, FormCreationMode, FormModel, Primitives, ValidationError } from './types/index';
|
|
1
|
+
import { Action, BaseJson, BaseModel, callbackFn, ContainerModel, FormCreationMode, FormModel, Primitives, ValidationError, EventSource } from './types/index';
|
|
2
2
|
import DataGroup from './data/DataGroup';
|
|
3
3
|
import DataValue from './data/DataValue';
|
|
4
4
|
export declare const editableProperties: string[];
|
|
@@ -19,6 +19,7 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
19
19
|
id: string;
|
|
20
20
|
};
|
|
21
21
|
private _tokens;
|
|
22
|
+
_eventSource: EventSource;
|
|
22
23
|
get isContainer(): boolean;
|
|
23
24
|
constructor(params: T, _options: {
|
|
24
25
|
form: FormModel;
|
package/lib/BaseNode.js
CHANGED
|
@@ -10,6 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BaseNode = exports.exclude = exports.include = exports.dependencyTracked = exports.qualifiedName = exports.target = exports.staticFields = exports.dynamicProps = exports.editableProperties = void 0;
|
|
13
|
+
const index_1 = require("./types/index");
|
|
13
14
|
const Events_1 = require("./controller/Events");
|
|
14
15
|
const DataRefParser_1 = require("./utils/DataRefParser");
|
|
15
16
|
const EmptyDataValue_1 = __importDefault(require("./data/EmptyDataValue"));
|
|
@@ -120,6 +121,7 @@ class BaseNode {
|
|
|
120
121
|
this._callbacks = {};
|
|
121
122
|
this._dependents = [];
|
|
122
123
|
this._tokens = [];
|
|
124
|
+
this._eventSource = index_1.EventSource.CODE;
|
|
123
125
|
this[exports.qualifiedName] = null;
|
|
124
126
|
this._jsonModel = Object.assign(Object.assign({}, params), { id: 'id' in params ? params.id : this.form.getUniqueId() });
|
|
125
127
|
}
|
package/lib/Captcha.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import Field from './Field';
|
|
2
|
-
import { Action } from './types';
|
|
3
|
-
declare class Captcha extends Field {
|
|
2
|
+
import { Action, CaptchaDisplayMode, CaptchaJson, CaptchaModel, ContainerModel, FormModel } from './types';
|
|
3
|
+
declare class Captcha extends Field implements CaptchaModel {
|
|
4
|
+
private _captchaDisplayMode;
|
|
5
|
+
private _captchaProvider;
|
|
6
|
+
private _captchaSiteKey;
|
|
7
|
+
constructor(params: CaptchaJson, _options: {
|
|
8
|
+
form: FormModel;
|
|
9
|
+
parent: ContainerModel;
|
|
10
|
+
mode?: 'create' | 'restore';
|
|
11
|
+
});
|
|
4
12
|
getDataNode(): undefined;
|
|
5
13
|
custom_setProperty(action: Action): void;
|
|
14
|
+
get captchaDisplayMode(): CaptchaDisplayMode | undefined;
|
|
15
|
+
get captchaProvider(): string | undefined;
|
|
16
|
+
get captchaSiteKey(): string | undefined;
|
|
6
17
|
}
|
|
7
18
|
export default Captcha;
|
package/lib/Captcha.js
CHANGED
|
@@ -5,11 +5,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const Field_1 = __importDefault(require("./Field"));
|
|
7
7
|
class Captcha extends Field_1.default {
|
|
8
|
+
constructor(params, _options) {
|
|
9
|
+
super(params, _options);
|
|
10
|
+
this._captchaDisplayMode = params.captchaDisplayMode;
|
|
11
|
+
this._captchaProvider = params.captchaProvider;
|
|
12
|
+
this._captchaSiteKey = params.siteKey;
|
|
13
|
+
}
|
|
8
14
|
getDataNode() {
|
|
9
15
|
return undefined;
|
|
10
16
|
}
|
|
11
17
|
custom_setProperty(action) {
|
|
12
18
|
this.applyUpdates(action.payload);
|
|
13
19
|
}
|
|
20
|
+
get captchaDisplayMode() {
|
|
21
|
+
return this._captchaDisplayMode;
|
|
22
|
+
}
|
|
23
|
+
get captchaProvider() {
|
|
24
|
+
return this._captchaProvider;
|
|
25
|
+
}
|
|
26
|
+
get captchaSiteKey() {
|
|
27
|
+
return this._captchaSiteKey;
|
|
28
|
+
}
|
|
14
29
|
}
|
|
15
30
|
exports.default = Captcha;
|
package/lib/Field.js
CHANGED
|
@@ -379,7 +379,7 @@ class Field extends Scriptable_1.default {
|
|
|
379
379
|
if (updates.valid) {
|
|
380
380
|
this.triggerValidationEvent(updates);
|
|
381
381
|
}
|
|
382
|
-
const changeAction = new Events_1.Change({ changes: changes.concat(Object.values(updates)) });
|
|
382
|
+
const changeAction = new Events_1.Change({ changes: changes.concat(Object.values(updates)), eventSource: this._eventSource });
|
|
383
383
|
this.dispatch(changeAction);
|
|
384
384
|
}
|
|
385
385
|
}
|
package/lib/Form.js
CHANGED
|
@@ -225,7 +225,7 @@ class Form extends Container_1.default {
|
|
|
225
225
|
prevValue: shallowClone(prevValue)
|
|
226
226
|
};
|
|
227
227
|
});
|
|
228
|
-
const fieldChangedAction = new Events_1.FieldChanged(changes, field);
|
|
228
|
+
const fieldChangedAction = new Events_1.FieldChanged(changes, field, action.payload.eventSource);
|
|
229
229
|
this.notifyDependents(fieldChangedAction);
|
|
230
230
|
}
|
|
231
231
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Action, BaseJson, FieldModel, FieldsetModel, FormModel, ValidationError } from '../types/index';
|
|
1
|
+
import { Action, BaseJson, FieldModel, FieldsetModel, FormModel, ValidationError, EventSource } from '../types/index';
|
|
2
2
|
declare class ActionImpl implements Action {
|
|
3
3
|
private _metadata?;
|
|
4
4
|
protected _type: string;
|
|
@@ -26,6 +26,7 @@ export declare type ChangePayload = {
|
|
|
26
26
|
prevValue?: any;
|
|
27
27
|
currentValue: any;
|
|
28
28
|
}>;
|
|
29
|
+
eventSource?: EventSource;
|
|
29
30
|
};
|
|
30
31
|
export declare class Change extends ActionImpl {
|
|
31
32
|
constructor(payload: ChangePayload, dispatch?: boolean);
|
|
@@ -78,7 +79,7 @@ export declare class Reset extends ActionImpl {
|
|
|
78
79
|
constructor(payload?: any, dispatch?: boolean);
|
|
79
80
|
}
|
|
80
81
|
export declare class FieldChanged extends ActionImpl {
|
|
81
|
-
constructor(changes: ChangePayload, field: BaseJson);
|
|
82
|
+
constructor(changes: ChangePayload, field: BaseJson, eventSource?: EventSource);
|
|
82
83
|
}
|
|
83
84
|
export declare class CustomEvent extends ActionImpl {
|
|
84
85
|
constructor(eventName: string, payload?: any, dispatch?: boolean);
|
package/lib/controller/Events.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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.Change = void 0;
|
|
4
|
+
const index_1 = require("../types/index");
|
|
4
5
|
class ActionImpl {
|
|
5
6
|
constructor(payload, type, _metadata) {
|
|
6
7
|
this._metadata = _metadata;
|
|
@@ -151,10 +152,11 @@ class Reset extends ActionImpl {
|
|
|
151
152
|
}
|
|
152
153
|
exports.Reset = Reset;
|
|
153
154
|
class FieldChanged extends ActionImpl {
|
|
154
|
-
constructor(changes, field) {
|
|
155
|
+
constructor(changes, field, eventSource = index_1.EventSource.CODE) {
|
|
155
156
|
super({
|
|
156
157
|
field,
|
|
157
|
-
changes
|
|
158
|
+
changes,
|
|
159
|
+
eventSource
|
|
158
160
|
}, 'fieldChanged');
|
|
159
161
|
}
|
|
160
162
|
}
|
|
@@ -15,6 +15,7 @@ const Fetch_1 = require("../utils/Fetch");
|
|
|
15
15
|
const FileObject_1 = require("../FileObject");
|
|
16
16
|
const FormUtils_1 = require("../utils/FormUtils");
|
|
17
17
|
const JsonUtils_1 = require("../utils/JsonUtils");
|
|
18
|
+
const types_1 = require("../types");
|
|
18
19
|
const getCustomEventName = (name) => {
|
|
19
20
|
const eName = name;
|
|
20
21
|
if (eName.length > 0 && eName.startsWith('custom:')) {
|
|
@@ -354,7 +355,7 @@ class FunctionRuntimeImpl {
|
|
|
354
355
|
},
|
|
355
356
|
submitForm: {
|
|
356
357
|
_func: (args, data, interpreter) => __awaiter(this, void 0, void 0, function* () {
|
|
357
|
-
var _a;
|
|
358
|
+
var _a, _b, _c, _d, _e;
|
|
358
359
|
let success = null;
|
|
359
360
|
let error = null;
|
|
360
361
|
let submit_data;
|
|
@@ -374,9 +375,9 @@ class FunctionRuntimeImpl {
|
|
|
374
375
|
validate_form = args.length > 4 ? valueOf(args[4]) : true;
|
|
375
376
|
}
|
|
376
377
|
const form = interpreter.globals.form;
|
|
377
|
-
if (form.captcha && form.captcha.
|
|
378
|
-
&& form.captcha.properties['fd:captcha'].config.keyType === 'score') {
|
|
379
|
-
if (typeof ((
|
|
378
|
+
if (form.captcha && (form.captcha.captchaDisplayMode === types_1.CaptchaDisplayMode.INVISIBLE ||
|
|
379
|
+
(((_b = (_a = form.captcha.properties['fd:captcha']) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.version) === 'enterprise' && ((_d = (_c = form.captcha.properties['fd:captcha']) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.keyType) === 'score'))) {
|
|
380
|
+
if (typeof ((_e = interpreter.runtime.functionTable.fetchCaptchaToken) === null || _e === void 0 ? void 0 : _e._func) !== 'function') {
|
|
380
381
|
interpreter.globals.form.logger.error('fetchCaptchaToken is not defined');
|
|
381
382
|
interpreter.globals.form.dispatch(new Events_1.SubmitError({ type: 'FetchCaptchaTokenNotDefined' }));
|
|
382
383
|
return {};
|
package/lib/types/Json.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CaptchaDisplayMode } from './Model';
|
|
1
2
|
export declare type Items<T> = {
|
|
2
3
|
[key: string]: T;
|
|
3
4
|
};
|
|
@@ -100,6 +101,11 @@ export declare type FieldJson = BaseJson & TranslationFieldJson & {
|
|
|
100
101
|
emptyValue?: 'null' | 'undefined' | '';
|
|
101
102
|
checked?: boolean;
|
|
102
103
|
};
|
|
104
|
+
export declare type CaptchaJson = FieldJson & {
|
|
105
|
+
captchaDisplayMode?: CaptchaDisplayMode | undefined;
|
|
106
|
+
captchaProvider?: string | undefined;
|
|
107
|
+
siteKey?: string | undefined;
|
|
108
|
+
};
|
|
103
109
|
export declare type ContainerJson = BaseJson & {
|
|
104
110
|
items: Array<FieldJson | ContainerJson>;
|
|
105
111
|
initialItems?: number;
|
package/lib/types/Model.d.ts
CHANGED
|
@@ -42,6 +42,10 @@ export interface WithController {
|
|
|
42
42
|
dispatch(action: Action): void;
|
|
43
43
|
}
|
|
44
44
|
export declare type FormCreationMode = 'create' | 'restore';
|
|
45
|
+
export declare enum EventSource {
|
|
46
|
+
CODE = "code",
|
|
47
|
+
UI = "ui"
|
|
48
|
+
}
|
|
45
49
|
export interface BaseModel extends ConstraintsJson, WithController {
|
|
46
50
|
readonly lang?: string;
|
|
47
51
|
readonly name?: string;
|
|
@@ -74,6 +78,7 @@ export interface BaseModel extends ConstraintsJson, WithController {
|
|
|
74
78
|
ruleNodeReference(): any;
|
|
75
79
|
_initialize(mode?: FormCreationMode): any;
|
|
76
80
|
_addDependent(dependent: BaseModel): any;
|
|
81
|
+
_eventSource: EventSource;
|
|
77
82
|
}
|
|
78
83
|
export interface FieldModel extends BaseModel, ScriptableField, WithState<FieldJson> {
|
|
79
84
|
parent: ContainerModel;
|
|
@@ -83,6 +88,11 @@ export interface FieldModel extends BaseModel, ScriptableField, WithState<FieldJ
|
|
|
83
88
|
readonly displayValueExpression?: string;
|
|
84
89
|
readonly editValue?: string;
|
|
85
90
|
}
|
|
91
|
+
export interface CaptchaModel extends FieldModel {
|
|
92
|
+
captchaDisplayMode: CaptchaDisplayMode | undefined;
|
|
93
|
+
captchaProvider: string | undefined;
|
|
94
|
+
captchaSiteKey: string | undefined;
|
|
95
|
+
}
|
|
86
96
|
export interface FormMetaDataModel {
|
|
87
97
|
readonly version?: string;
|
|
88
98
|
readonly grammar: string;
|
|
@@ -144,4 +154,8 @@ export declare enum FocusOption {
|
|
|
144
154
|
NEXT_ITEM = "nextItem",
|
|
145
155
|
PREVIOUS_ITEM = "previousItem"
|
|
146
156
|
}
|
|
157
|
+
export declare enum CaptchaDisplayMode {
|
|
158
|
+
INVISIBLE = "invisible",
|
|
159
|
+
VISIBLE = "visible"
|
|
160
|
+
}
|
|
147
161
|
export {};
|
package/lib/types/Model.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FocusOption = exports.ValidationError = void 0;
|
|
3
|
+
exports.CaptchaDisplayMode = exports.FocusOption = exports.ValidationError = exports.EventSource = void 0;
|
|
4
|
+
var EventSource;
|
|
5
|
+
(function (EventSource) {
|
|
6
|
+
EventSource["CODE"] = "code";
|
|
7
|
+
EventSource["UI"] = "ui";
|
|
8
|
+
})(EventSource = exports.EventSource || (exports.EventSource = {}));
|
|
4
9
|
class ValidationError {
|
|
5
10
|
constructor(fieldName = '', errorMessages = []) {
|
|
6
11
|
this.errorMessages = errorMessages;
|
|
@@ -13,3 +18,8 @@ var FocusOption;
|
|
|
13
18
|
FocusOption["NEXT_ITEM"] = "nextItem";
|
|
14
19
|
FocusOption["PREVIOUS_ITEM"] = "previousItem";
|
|
15
20
|
})(FocusOption = exports.FocusOption || (exports.FocusOption = {}));
|
|
21
|
+
var CaptchaDisplayMode;
|
|
22
|
+
(function (CaptchaDisplayMode) {
|
|
23
|
+
CaptchaDisplayMode["INVISIBLE"] = "invisible";
|
|
24
|
+
CaptchaDisplayMode["VISIBLE"] = "visible";
|
|
25
|
+
})(CaptchaDisplayMode = exports.CaptchaDisplayMode || (exports.CaptchaDisplayMode = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.90",
|
|
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.90"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|