@aemforms/af-core 0.22.74 → 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.
@@ -56,14 +56,16 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
56
56
  columnClassNames?: undefined;
57
57
  columnCount?: undefined;
58
58
  gridClassNames?: undefined;
59
+ ':type': string;
60
+ repeatable?: boolean | undefined;
61
+ minOccur?: number | undefined;
62
+ maxOccur?: number | undefined;
59
63
  properties: {
60
64
  [key: string]: any;
61
65
  };
62
66
  index: number;
63
67
  parent: undefined;
64
68
  qualifiedName: any;
65
- repeatable: boolean | undefined;
66
- ':type': string;
67
69
  id: string;
68
70
  };
69
71
  subscribe(callback: callbackFn, eventName?: string): {
@@ -130,7 +130,7 @@ declare class Checkbox extends Field {
130
130
  properties: {
131
131
  [key: string]: any;
132
132
  };
133
- repeatable: boolean | undefined;
133
+ repeatable?: boolean | undefined;
134
134
  screenReaderText?: string | undefined;
135
135
  tooltip?: string | undefined;
136
136
  altText?: string | undefined;
@@ -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;
@@ -37,14 +37,16 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
37
37
  columnClassNames?: undefined;
38
38
  columnCount?: undefined;
39
39
  gridClassNames?: undefined;
40
+ ':type': string;
41
+ repeatable?: boolean | undefined;
42
+ minOccur?: number | undefined;
43
+ maxOccur?: number | undefined;
40
44
  properties: {
41
45
  [key: string]: any;
42
46
  };
43
47
  index: number;
44
48
  parent: undefined;
45
49
  qualifiedName: any;
46
- repeatable: boolean | undefined;
47
- ':type': string;
48
50
  id: string;
49
51
  };
50
52
  private _createChild;
@@ -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);
@@ -197,7 +198,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
197
198
  properties: {
198
199
  [key: string]: any;
199
200
  };
200
- repeatable: boolean | undefined;
201
+ repeatable?: boolean | undefined;
201
202
  screenReaderText?: string | undefined;
202
203
  tooltip?: string | undefined;
203
204
  altText?: string | 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;
@@ -91,14 +91,16 @@ declare class Form extends Container<FormJson> implements FormModel {
91
91
  columnClassNames?: undefined;
92
92
  columnCount?: undefined;
93
93
  gridClassNames?: undefined;
94
+ ':type': string;
95
+ repeatable?: boolean | undefined;
96
+ minOccur?: number | undefined;
97
+ maxOccur?: number | undefined;
94
98
  properties: {
95
99
  [key: string]: any;
96
100
  };
97
101
  index: number;
98
102
  parent: undefined;
99
103
  qualifiedName: any;
100
- repeatable: boolean | undefined;
101
- ':type': string;
102
104
  id: string;
103
105
  };
104
106
  get type(): string;
@@ -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 {
@@ -12,7 +12,8 @@ type ValidConstraintsType = {
12
12
  email: ValidationConstraints[];
13
13
  };
14
14
  export declare const ValidConstraints: ValidConstraintsType;
15
- export type ValidationConstraints = 'type' | 'format' | 'minimum' | 'maximum' | 'exclusiveMinimum' | 'exclusiveMaximum' | 'minItems' | 'maxItems' | 'uniqueItems' | 'minLength' | 'maxLength' | 'pattern' | 'required' | 'enum' | 'accept' | 'maxFileSize';
15
+ export declare const validationConstraintsList: readonly ["type", "format", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "minItems", "maxItems", "uniqueItems", "minLength", "maxLength", "pattern", "required", "enum", "accept", "maxFileSize"];
16
+ export type ValidationConstraints = typeof validationConstraintsList[number];
16
17
  type ConstraintsObject = {
17
18
  [key in ValidationConstraints]: (constraint: any, inputVal: any) => ValidationResult;
18
19
  };
package/lib/BaseNode.d.ts CHANGED
@@ -56,14 +56,16 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
56
56
  columnClassNames?: undefined;
57
57
  columnCount?: undefined;
58
58
  gridClassNames?: undefined;
59
+ ':type': string;
60
+ repeatable?: boolean | undefined;
61
+ minOccur?: number | undefined;
62
+ maxOccur?: number | undefined;
59
63
  properties: {
60
64
  [key: string]: any;
61
65
  };
62
66
  index: number;
63
67
  parent: undefined;
64
68
  qualifiedName: any;
65
- repeatable: boolean | undefined;
66
- ':type': string;
67
69
  id: string;
68
70
  };
69
71
  subscribe(callback: callbackFn, eventName?: string): {
package/lib/BaseNode.js CHANGED
@@ -13,6 +13,7 @@ exports.BaseNode = exports.exclude = exports.include = exports.dependencyTracked
13
13
  const Events_1 = require("./controller/Events");
14
14
  const DataRefParser_1 = require("./utils/DataRefParser");
15
15
  const EmptyDataValue_1 = __importDefault(require("./data/EmptyDataValue"));
16
+ const ValidationUtils_1 = require("./utils/ValidationUtils");
16
17
  exports.editableProperties = [
17
18
  'value',
18
19
  'label',
@@ -240,7 +241,11 @@ class BaseNode {
240
241
  return !this._jsonModel.name && !isNonTransparent;
241
242
  }
242
243
  getState(forRestore = false) {
243
- return Object.assign(Object.assign(Object.assign({}, this._jsonModel), { properties: this.properties, index: this.index, parent: undefined, qualifiedName: this.qualifiedName, repeatable: this.repeatable === true ? true : undefined, ':type': this[':type'] }), (forRestore ? {
244
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, this._jsonModel), { properties: this.properties, index: this.index, parent: undefined, qualifiedName: this.qualifiedName }), (this.repeatable === true ? {
245
+ repeatable: true,
246
+ minOccur: this.parent.minItems,
247
+ maxOccur: this.parent.maxItems
248
+ } : {})), { ':type': this[':type'] }), (forRestore ? {
244
249
  _dependents: this._dependents.length ? this._dependents.map(x => x.node.id) : undefined,
245
250
  allowedComponents: undefined,
246
251
  columnClassNames: undefined,
@@ -323,6 +328,9 @@ class BaseNode {
323
328
  this.notifyDependents(changeAction);
324
329
  }
325
330
  notifyChildren.call(this, changeAction);
331
+ if (ValidationUtils_1.validationConstraintsList.includes(prop)) {
332
+ this.validate();
333
+ }
326
334
  return changeAction.payload.changes;
327
335
  }
328
336
  return [];
package/lib/Checkbox.d.ts CHANGED
@@ -130,7 +130,7 @@ declare class Checkbox extends Field {
130
130
  properties: {
131
131
  [key: string]: any;
132
132
  };
133
- repeatable: boolean | undefined;
133
+ repeatable?: boolean | undefined;
134
134
  screenReaderText?: string | undefined;
135
135
  tooltip?: string | undefined;
136
136
  altText?: string | undefined;
@@ -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;
@@ -37,14 +37,16 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
37
37
  columnClassNames?: undefined;
38
38
  columnCount?: undefined;
39
39
  gridClassNames?: undefined;
40
+ ':type': string;
41
+ repeatable?: boolean | undefined;
42
+ minOccur?: number | undefined;
43
+ maxOccur?: number | undefined;
40
44
  properties: {
41
45
  [key: string]: any;
42
46
  };
43
47
  index: number;
44
48
  parent: undefined;
45
49
  qualifiedName: any;
46
- repeatable: boolean | undefined;
47
- ':type': string;
48
50
  id: string;
49
51
  };
50
52
  private _createChild;
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);
@@ -197,7 +198,7 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
197
198
  properties: {
198
199
  [key: string]: any;
199
200
  };
200
- repeatable: boolean | undefined;
201
+ repeatable?: boolean | undefined;
201
202
  screenReaderText?: string | undefined;
202
203
  tooltip?: string | undefined;
203
204
  altText?: string | 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
  }
@@ -244,7 +247,6 @@ class Field extends Scriptable_1.default {
244
247
  }
245
248
  set required(r) {
246
249
  this._setProperty('required', r);
247
- this.validate();
248
250
  }
249
251
  get maximum() {
250
252
  if (this.type === 'number' || this.format === 'date' || this.type === 'integer') {
@@ -296,6 +298,9 @@ class Field extends Scriptable_1.default {
296
298
  }
297
299
  }
298
300
  get displayValue() {
301
+ if (this.displayValueExpression && typeof this.displayValueExpression === 'string' && this.displayValueExpression.length !== 0) {
302
+ return this.executeExpression(this.displayValueExpression);
303
+ }
299
304
  const df = this.displayFormat;
300
305
  if (df && this.isNotEmpty(this.value) && this.valid !== false) {
301
306
  try {
package/lib/Form.d.ts CHANGED
@@ -91,14 +91,16 @@ declare class Form extends Container<FormJson> implements FormModel {
91
91
  columnClassNames?: undefined;
92
92
  columnCount?: undefined;
93
93
  gridClassNames?: undefined;
94
+ ':type': string;
95
+ repeatable?: boolean | undefined;
96
+ minOccur?: number | undefined;
97
+ maxOccur?: number | undefined;
94
98
  properties: {
95
99
  [key: string]: any;
96
100
  };
97
101
  index: number;
98
102
  parent: undefined;
99
103
  qualifiedName: any;
100
- repeatable: boolean | undefined;
101
- ':type': string;
102
104
  id: string;
103
105
  };
104
106
  get type(): string;
@@ -202,6 +202,27 @@ class FunctionRuntimeImpl {
202
202
  },
203
203
  exportData: () => {
204
204
  return FunctionRuntimeImpl.getInstance().getFunctions().exportData._func.call(undefined, args, data, interpreter);
205
+ },
206
+ submitForm: (payload, validateForm, contentType) => {
207
+ const submitAs = contentType || 'multipart/form-data';
208
+ const args = [payload, validateForm, submitAs];
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
+ }
205
226
  }
206
227
  }
207
228
  };
@@ -303,11 +324,24 @@ class FunctionRuntimeImpl {
303
324
  },
304
325
  submitForm: {
305
326
  _func: (args, data, interpreter) => {
306
- const success = toString(args[0]);
307
- const error = toString(args[1]);
308
- const submit_as = args.length > 2 ? toString(args[2]) : 'multipart/form-data';
309
- const submit_data = args.length > 3 ? valueOf(args[3]) : null;
310
- const validate_form = args.length > 4 ? valueOf(args[4]) : true;
327
+ let success = null;
328
+ let error = null;
329
+ let submit_data;
330
+ let validate_form;
331
+ let submit_as;
332
+ if (args.length > 0 && typeof valueOf(args[0]) === 'object') {
333
+ submit_data = args.length > 0 ? valueOf(args[0]) : null;
334
+ validate_form = args.length > 1 ? valueOf(args[1]) : true;
335
+ submit_as = args.length > 2 ? toString(args[2]) : 'multipart/form-data';
336
+ }
337
+ else {
338
+ interpreter.globals.form.logger.warn('This usage of submitForm is deprecated. Please see the documentation and update');
339
+ success = toString(args[0]);
340
+ error = toString(args[1]);
341
+ submit_as = args.length > 2 ? toString(args[2]) : 'multipart/form-data';
342
+ submit_data = args.length > 3 ? valueOf(args[3]) : null;
343
+ validate_form = args.length > 4 ? valueOf(args[4]) : true;
344
+ }
311
345
  interpreter.globals.form.dispatch(new Events_1.Submit({
312
346
  success,
313
347
  error,
@@ -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 {
@@ -12,7 +12,8 @@ declare type ValidConstraintsType = {
12
12
  email: ValidationConstraints[];
13
13
  };
14
14
  export declare const ValidConstraints: ValidConstraintsType;
15
- export declare type ValidationConstraints = 'type' | 'format' | 'minimum' | 'maximum' | 'exclusiveMinimum' | 'exclusiveMaximum' | 'minItems' | 'maxItems' | 'uniqueItems' | 'minLength' | 'maxLength' | 'pattern' | 'required' | 'enum' | 'accept' | 'maxFileSize';
15
+ export declare const validationConstraintsList: readonly ["type", "format", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "minItems", "maxItems", "uniqueItems", "minLength", "maxLength", "pattern", "required", "enum", "accept", "maxFileSize"];
16
+ export declare type ValidationConstraints = typeof validationConstraintsList[number];
16
17
  declare type ConstraintsObject = {
17
18
  [key in ValidationConstraints]: (constraint: any, inputVal: any) => ValidationResult;
18
19
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Constraints = exports.ValidConstraints = exports.coerceType = void 0;
3
+ exports.Constraints = exports.validationConstraintsList = exports.ValidConstraints = exports.coerceType = void 0;
4
4
  const FormUtils_1 = require("./FormUtils");
5
5
  const FileObject_1 = require("../FileObject");
6
6
  const dateRegex = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
@@ -118,6 +118,8 @@ exports.ValidConstraints = {
118
118
  file: ['accept', 'maxFileSize'],
119
119
  email: ['minLength', 'maxLength', 'format', 'pattern']
120
120
  };
121
+ exports.validationConstraintsList = ['type', 'format', 'minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum', 'minItems',
122
+ 'maxItems', 'uniqueItems', 'minLength', 'maxLength', 'pattern', 'required', 'enum', 'accept', 'maxFileSize'];
121
123
  exports.Constraints = {
122
124
  type: (constraint, inputVal) => {
123
125
  let value = inputVal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.74",
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.74"
40
+ "@aemforms/af-formatters": "^0.22.76"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",