@aemforms/af-core 0.22.71 → 0.22.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/afb-runtime.js +26 -4
- package/lib/Form.js +3 -1
- package/lib/rules/FunctionRuntime.js +24 -3
- package/package.json +2 -2
package/esm/afb-runtime.js
CHANGED
|
@@ -2313,9 +2313,28 @@ class FunctionRuntimeImpl {
|
|
|
2313
2313
|
finalFunction = {
|
|
2314
2314
|
_func: (args, data, interpreter) => {
|
|
2315
2315
|
const globals = {
|
|
2316
|
-
form: interpreter.globals
|
|
2317
|
-
|
|
2318
|
-
|
|
2316
|
+
form: interpreter.globals.$form,
|
|
2317
|
+
field: interpreter.globals.$field,
|
|
2318
|
+
event: interpreter.globals.$event,
|
|
2319
|
+
functions: {
|
|
2320
|
+
setProperty: (target, payload) => {
|
|
2321
|
+
const eventName = 'custom:setProperty';
|
|
2322
|
+
const args = [target, eventName, payload];
|
|
2323
|
+
return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
|
|
2324
|
+
},
|
|
2325
|
+
reset: (target) => {
|
|
2326
|
+
const eventName = 'reset';
|
|
2327
|
+
target = target || 'reset';
|
|
2328
|
+
const args = [target, eventName];
|
|
2329
|
+
return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
|
|
2330
|
+
},
|
|
2331
|
+
validate: (target) => {
|
|
2332
|
+
const args = [target];
|
|
2333
|
+
return FunctionRuntimeImpl.getInstance().getFunctions().validate._func.call(undefined, args, data, interpreter);
|
|
2334
|
+
},
|
|
2335
|
+
exportData: () => {
|
|
2336
|
+
return FunctionRuntimeImpl.getInstance().getFunctions().exportData._func.call(undefined, args, data, interpreter);
|
|
2337
|
+
}
|
|
2319
2338
|
}
|
|
2320
2339
|
};
|
|
2321
2340
|
return funcDef(...args, globals);
|
|
@@ -2420,10 +2439,12 @@ class FunctionRuntimeImpl {
|
|
|
2420
2439
|
const error = toString(args[1]);
|
|
2421
2440
|
const submit_as = args.length > 2 ? toString(args[2]) : 'multipart/form-data';
|
|
2422
2441
|
const submit_data = args.length > 3 ? valueOf(args[3]) : null;
|
|
2442
|
+
const validate_form = args.length > 4 ? valueOf(args[4]) : true;
|
|
2423
2443
|
interpreter.globals.form.dispatch(new Submit({
|
|
2424
2444
|
success,
|
|
2425
2445
|
error,
|
|
2426
2446
|
submit_as,
|
|
2447
|
+
validate_form: validate_form,
|
|
2427
2448
|
data: submit_data
|
|
2428
2449
|
}));
|
|
2429
2450
|
return {};
|
|
@@ -2751,7 +2772,8 @@ class Form extends Container {
|
|
|
2751
2772
|
}
|
|
2752
2773
|
}
|
|
2753
2774
|
submit(action, context) {
|
|
2754
|
-
|
|
2775
|
+
const validate_form = action?.payload?.validate_form;
|
|
2776
|
+
if (!validate_form || this.validate().length === 0) {
|
|
2755
2777
|
const payload = action?.payload || {};
|
|
2756
2778
|
const successEventName = payload?.success ? payload?.success : 'submitSuccess';
|
|
2757
2779
|
const failureEventName = payload?.error ? payload?.error : 'submitFailure';
|
package/lib/Form.js
CHANGED
|
@@ -212,7 +212,9 @@ class Form extends Container_1.default {
|
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
submit(action, context) {
|
|
215
|
-
|
|
215
|
+
var _a;
|
|
216
|
+
const validate_form = (_a = action === null || action === void 0 ? void 0 : action.payload) === null || _a === void 0 ? void 0 : _a.validate_form;
|
|
217
|
+
if (!validate_form || this.validate().length === 0) {
|
|
216
218
|
const payload = (action === null || action === void 0 ? void 0 : action.payload) || {};
|
|
217
219
|
const successEventName = (payload === null || payload === void 0 ? void 0 : payload.success) ? payload === null || payload === void 0 ? void 0 : payload.success : 'submitSuccess';
|
|
218
220
|
const failureEventName = (payload === null || payload === void 0 ? void 0 : payload.error) ? payload === null || payload === void 0 ? void 0 : payload.error : 'submitFailure';
|
|
@@ -180,9 +180,28 @@ class FunctionRuntimeImpl {
|
|
|
180
180
|
finalFunction = {
|
|
181
181
|
_func: (args, data, interpreter) => {
|
|
182
182
|
const globals = {
|
|
183
|
-
form: interpreter.globals
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
form: interpreter.globals.$form,
|
|
184
|
+
field: interpreter.globals.$field,
|
|
185
|
+
event: interpreter.globals.$event,
|
|
186
|
+
functions: {
|
|
187
|
+
setProperty: (target, payload) => {
|
|
188
|
+
const eventName = 'custom:setProperty';
|
|
189
|
+
const args = [target, eventName, payload];
|
|
190
|
+
return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
|
|
191
|
+
},
|
|
192
|
+
reset: (target) => {
|
|
193
|
+
const eventName = 'reset';
|
|
194
|
+
target = target || 'reset';
|
|
195
|
+
const args = [target, eventName];
|
|
196
|
+
return FunctionRuntimeImpl.getInstance().getFunctions().dispatchEvent._func.call(undefined, args, data, interpreter);
|
|
197
|
+
},
|
|
198
|
+
validate: (target) => {
|
|
199
|
+
const args = [target];
|
|
200
|
+
return FunctionRuntimeImpl.getInstance().getFunctions().validate._func.call(undefined, args, data, interpreter);
|
|
201
|
+
},
|
|
202
|
+
exportData: () => {
|
|
203
|
+
return FunctionRuntimeImpl.getInstance().getFunctions().exportData._func.call(undefined, args, data, interpreter);
|
|
204
|
+
}
|
|
186
205
|
}
|
|
187
206
|
};
|
|
188
207
|
return funcDef(...args, globals);
|
|
@@ -287,10 +306,12 @@ class FunctionRuntimeImpl {
|
|
|
287
306
|
const error = toString(args[1]);
|
|
288
307
|
const submit_as = args.length > 2 ? toString(args[2]) : 'multipart/form-data';
|
|
289
308
|
const submit_data = args.length > 3 ? valueOf(args[3]) : null;
|
|
309
|
+
const validate_form = args.length > 4 ? valueOf(args[4]) : true;
|
|
290
310
|
interpreter.globals.form.dispatch(new Events_1.Submit({
|
|
291
311
|
success,
|
|
292
312
|
error,
|
|
293
313
|
submit_as,
|
|
314
|
+
validate_form: validate_form,
|
|
294
315
|
data: submit_data
|
|
295
316
|
}));
|
|
296
317
|
return {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.72",
|
|
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.72"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|