@aemforms/af-core 0.22.70 → 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.
@@ -1163,8 +1163,7 @@ class Scriptable extends BaseNode {
1163
1163
  if (prop === Symbol.toStringTag) {
1164
1164
  return 'Object';
1165
1165
  }
1166
- prop = prop;
1167
- if (prop.startsWith('$')) {
1166
+ if (typeof prop === 'string' && prop.startsWith('$')) {
1168
1167
  const retValue = target.self[prop];
1169
1168
  if (retValue instanceof BaseNode) {
1170
1169
  return retValue.getRuleNode();
@@ -2314,9 +2313,28 @@ class FunctionRuntimeImpl {
2314
2313
  finalFunction = {
2315
2314
  _func: (args, data, interpreter) => {
2316
2315
  const globals = {
2317
- form: interpreter.globals.form,
2318
- invoke: (funcName, ...args) => {
2319
- return FunctionRuntimeImpl.getInstance().customFunctions[funcName]._func.call(undefined, args, data, interpreter);
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
+ }
2320
2338
  }
2321
2339
  };
2322
2340
  return funcDef(...args, globals);
@@ -2421,10 +2439,12 @@ class FunctionRuntimeImpl {
2421
2439
  const error = toString(args[1]);
2422
2440
  const submit_as = args.length > 2 ? toString(args[2]) : 'multipart/form-data';
2423
2441
  const submit_data = args.length > 3 ? valueOf(args[3]) : null;
2442
+ const validate_form = args.length > 4 ? valueOf(args[4]) : true;
2424
2443
  interpreter.globals.form.dispatch(new Submit({
2425
2444
  success,
2426
2445
  error,
2427
2446
  submit_as,
2447
+ validate_form: validate_form,
2428
2448
  data: submit_data
2429
2449
  }));
2430
2450
  return {};
@@ -2752,7 +2772,8 @@ class Form extends Container {
2752
2772
  }
2753
2773
  }
2754
2774
  submit(action, context) {
2755
- if (this.validate().length === 0) {
2775
+ const validate_form = action?.payload?.validate_form;
2776
+ if (!validate_form || this.validate().length === 0) {
2756
2777
  const payload = action?.payload || {};
2757
2778
  const successEventName = payload?.success ? payload?.success : 'submitSuccess';
2758
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
- if (this.validate().length === 0) {
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';
package/lib/Scriptable.js CHANGED
@@ -92,8 +92,7 @@ class Scriptable extends BaseNode_1.BaseNode {
92
92
  if (prop === Symbol.toStringTag) {
93
93
  return 'Object';
94
94
  }
95
- prop = prop;
96
- if (prop.startsWith('$')) {
95
+ if (typeof prop === 'string' && prop.startsWith('$')) {
97
96
  const retValue = target.self[prop];
98
97
  if (retValue instanceof BaseNode_1.BaseNode) {
99
98
  return retValue.getRuleNode();
@@ -180,9 +180,28 @@ class FunctionRuntimeImpl {
180
180
  finalFunction = {
181
181
  _func: (args, data, interpreter) => {
182
182
  const globals = {
183
- form: interpreter.globals.form,
184
- invoke: (funcName, ...args) => {
185
- return FunctionRuntimeImpl.getInstance().customFunctions[funcName]._func.call(undefined, args, data, interpreter);
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.70",
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.70"
40
+ "@aemforms/af-formatters": "^0.22.72"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",