@aemforms/af-core 0.22.75 → 0.22.76

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.
@@ -2626,8 +2626,23 @@ class FunctionRuntimeImpl {
2626
2626
  },
2627
2627
  submitForm: (payload, validateForm, contentType) => {
2628
2628
  const submitAs = contentType || 'multipart/form-data';
2629
- const args = ['custom:submitSuccess', 'custom:submitError', submitAs, payload, validateForm];
2629
+ const args = [payload, validateForm, submitAs];
2630
2630
  return FunctionRuntimeImpl.getInstance().getFunctions().submitForm._func.call(undefined, args, data, interpreter);
2631
+ },
2632
+ markFieldAsInvalid: (fieldIdentifier, validationMessage, option) => {
2633
+ if (!option || option.useId) {
2634
+ interpreter.globals.form.getElement(fieldIdentifier)?.markAsInvalid(validationMessage);
2635
+ }
2636
+ else if (option && option.useDataRef) {
2637
+ interpreter.globals.form.visit(function callback(f) {
2638
+ if (f.dataRef === fieldIdentifier) {
2639
+ f.markAsInvalid(validationMessage);
2640
+ }
2641
+ });
2642
+ }
2643
+ else if (option && option.useQualifiedName) {
2644
+ interpreter.globals.form.resolveQualifiedName(fieldIdentifier)?.markAsInvalid(validationMessage);
2645
+ }
2631
2646
  }
2632
2647
  }
2633
2648
  };
@@ -2729,8 +2744,8 @@ class FunctionRuntimeImpl {
2729
2744
  },
2730
2745
  submitForm: {
2731
2746
  _func: (args, data, interpreter) => {
2732
- let success = 'custom:submitSuccess';
2733
- let error = 'custom:submitError';
2747
+ let success = null;
2748
+ let error = null;
2734
2749
  let submit_data;
2735
2750
  let validate_form;
2736
2751
  let submit_as;
@@ -3412,6 +3427,9 @@ class Field extends Scriptable {
3412
3427
  get displayFormat() {
3413
3428
  return this.withCategory(this._jsonModel.displayFormat);
3414
3429
  }
3430
+ get displayValueExpression() {
3431
+ return this._jsonModel.displayValueExpression;
3432
+ }
3415
3433
  get placeholder() {
3416
3434
  return this._jsonModel.placeholder;
3417
3435
  }
@@ -3529,6 +3547,9 @@ class Field extends Scriptable {
3529
3547
  }
3530
3548
  }
3531
3549
  get displayValue() {
3550
+ if (this.displayValueExpression && typeof this.displayValueExpression === 'string' && this.displayValueExpression.length !== 0) {
3551
+ return this.executeExpression(this.displayValueExpression);
3552
+ }
3532
3553
  const df = this.displayFormat;
3533
3554
  if (df && this.isNotEmpty(this.value) && this.valid !== false) {
3534
3555
  try {
@@ -141,6 +141,7 @@ declare class Checkbox extends Field {
141
141
  validationMessage?: string | undefined;
142
142
  default?: any;
143
143
  value?: any;
144
+ displayValueExpression?: string | undefined;
144
145
  emptyValue?: "" | "undefined" | "null" | undefined;
145
146
  _dependents?: string[] | undefined;
146
147
  allowedComponents?: undefined;
@@ -28,6 +28,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
28
28
  private coerceParam;
29
29
  get editFormat(): string | undefined;
30
30
  get displayFormat(): string | undefined;
31
+ get displayValueExpression(): string | undefined;
31
32
  get placeholder(): string | undefined;
32
33
  get readOnly(): boolean | undefined;
33
34
  set readOnly(e: boolean | undefined);
@@ -208,6 +209,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
208
209
  validationMessage?: string | undefined;
209
210
  default?: any;
210
211
  value?: any;
212
+ displayValueExpression?: string | undefined;
211
213
  emptyValue?: "" | "undefined" | "null" | undefined;
212
214
  checked?: boolean | undefined;
213
215
  _dependents?: string[] | undefined;
@@ -99,6 +99,7 @@ export type FieldJson = BaseJson & TranslationFieldJson & {
99
99
  editFormat?: string;
100
100
  editValue?: string;
101
101
  displayValue?: string;
102
+ displayValueExpression?: string;
102
103
  emptyValue?: 'null' | 'undefined' | '';
103
104
  checked?: boolean;
104
105
  };
@@ -78,6 +78,7 @@ export interface FieldModel extends BaseModel, ScriptableField, WithState<FieldJ
78
78
  readonly editFormat?: string;
79
79
  readonly displayFormat?: string;
80
80
  readonly displayValue?: string;
81
+ readonly displayValueExpression?: string;
81
82
  readonly editValue?: string;
82
83
  }
83
84
  export interface FormMetaDataModel {
package/lib/Checkbox.d.ts CHANGED
@@ -141,6 +141,7 @@ declare class Checkbox extends Field {
141
141
  validationMessage?: string | undefined;
142
142
  default?: any;
143
143
  value?: any;
144
+ displayValueExpression?: string | undefined;
144
145
  emptyValue?: "" | "undefined" | "null" | undefined;
145
146
  _dependents?: string[] | undefined;
146
147
  allowedComponents?: undefined;
package/lib/Field.d.ts CHANGED
@@ -28,6 +28,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
28
28
  private coerceParam;
29
29
  get editFormat(): string | undefined;
30
30
  get displayFormat(): string | undefined;
31
+ get displayValueExpression(): string | undefined;
31
32
  get placeholder(): string | undefined;
32
33
  get readOnly(): boolean | undefined;
33
34
  set readOnly(e: boolean | undefined);
@@ -208,6 +209,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
208
209
  validationMessage?: string | undefined;
209
210
  default?: any;
210
211
  value?: any;
212
+ displayValueExpression?: string | undefined;
211
213
  emptyValue?: "" | "undefined" | "null" | undefined;
212
214
  checked?: boolean | undefined;
213
215
  _dependents?: string[] | undefined;
package/lib/Field.js CHANGED
@@ -177,6 +177,9 @@ class Field extends Scriptable_1.default {
177
177
  get displayFormat() {
178
178
  return this.withCategory(this._jsonModel.displayFormat);
179
179
  }
180
+ get displayValueExpression() {
181
+ return this._jsonModel.displayValueExpression;
182
+ }
180
183
  get placeholder() {
181
184
  return this._jsonModel.placeholder;
182
185
  }
@@ -295,6 +298,9 @@ class Field extends Scriptable_1.default {
295
298
  }
296
299
  }
297
300
  get displayValue() {
301
+ if (this.displayValueExpression && typeof this.displayValueExpression === 'string' && this.displayValueExpression.length !== 0) {
302
+ return this.executeExpression(this.displayValueExpression);
303
+ }
298
304
  const df = this.displayFormat;
299
305
  if (df && this.isNotEmpty(this.value) && this.valid !== false) {
300
306
  try {
@@ -205,8 +205,24 @@ class FunctionRuntimeImpl {
205
205
  },
206
206
  submitForm: (payload, validateForm, contentType) => {
207
207
  const submitAs = contentType || 'multipart/form-data';
208
- const args = ['custom:submitSuccess', 'custom:submitError', submitAs, payload, validateForm];
208
+ const args = [payload, validateForm, submitAs];
209
209
  return FunctionRuntimeImpl.getInstance().getFunctions().submitForm._func.call(undefined, args, data, interpreter);
210
+ },
211
+ markFieldAsInvalid: (fieldIdentifier, validationMessage, option) => {
212
+ var _a, _b;
213
+ if (!option || option.useId) {
214
+ (_a = interpreter.globals.form.getElement(fieldIdentifier)) === null || _a === void 0 ? void 0 : _a.markAsInvalid(validationMessage);
215
+ }
216
+ else if (option && option.useDataRef) {
217
+ interpreter.globals.form.visit(function callback(f) {
218
+ if (f.dataRef === fieldIdentifier) {
219
+ f.markAsInvalid(validationMessage);
220
+ }
221
+ });
222
+ }
223
+ else if (option && option.useQualifiedName) {
224
+ (_b = interpreter.globals.form.resolveQualifiedName(fieldIdentifier)) === null || _b === void 0 ? void 0 : _b.markAsInvalid(validationMessage);
225
+ }
210
226
  }
211
227
  }
212
228
  };
@@ -308,8 +324,8 @@ class FunctionRuntimeImpl {
308
324
  },
309
325
  submitForm: {
310
326
  _func: (args, data, interpreter) => {
311
- let success = 'custom:submitSuccess';
312
- let error = 'custom:submitError';
327
+ let success = null;
328
+ let error = null;
313
329
  let submit_data;
314
330
  let validate_form;
315
331
  let submit_as;
@@ -99,6 +99,7 @@ export declare type FieldJson = BaseJson & TranslationFieldJson & {
99
99
  editFormat?: string;
100
100
  editValue?: string;
101
101
  displayValue?: string;
102
+ displayValueExpression?: string;
102
103
  emptyValue?: 'null' | 'undefined' | '';
103
104
  checked?: boolean;
104
105
  };
@@ -78,6 +78,7 @@ export interface FieldModel extends BaseModel, ScriptableField, WithState<FieldJ
78
78
  readonly editFormat?: string;
79
79
  readonly displayFormat?: string;
80
80
  readonly displayValue?: string;
81
+ readonly displayValueExpression?: string;
81
82
  readonly editValue?: string;
82
83
  }
83
84
  export interface FormMetaDataModel {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.75",
3
+ "version": "0.22.76",
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.75"
40
+ "@aemforms/af-formatters": "^0.22.76"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",