@aemforms/af-core 0.22.77 → 0.22.79

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-events.js CHANGED
@@ -3,6 +3,7 @@ class ActionImpl {
3
3
  _type;
4
4
  _payload;
5
5
  _target;
6
+ _currentTarget;
6
7
  constructor(payload, type, _metadata) {
7
8
  this._metadata = _metadata;
8
9
  this._payload = payload;
@@ -20,6 +21,9 @@ class ActionImpl {
20
21
  get target() {
21
22
  return this._target;
22
23
  }
24
+ get currentTarget() {
25
+ return this._currentTarget;
26
+ }
23
27
  get isCustomEvent() {
24
28
  return false;
25
29
  }
@@ -1131,9 +1131,17 @@ const staticFields = ['plain-text', 'image'];
1131
1131
  class ActionImplWithTarget {
1132
1132
  _action;
1133
1133
  _target;
1134
+ _currentTarget;
1134
1135
  constructor(_action, _target) {
1135
1136
  this._action = _action;
1136
- this._target = _target;
1137
+ if (_action.target) {
1138
+ this._currentTarget = _target;
1139
+ this._target = _action.target;
1140
+ }
1141
+ else {
1142
+ this._target = _target;
1143
+ this._currentTarget = _target;
1144
+ }
1137
1145
  }
1138
1146
  get type() {
1139
1147
  return this._action.type;
@@ -1147,6 +1155,9 @@ class ActionImplWithTarget {
1147
1155
  get target() {
1148
1156
  return this._target;
1149
1157
  }
1158
+ get currentTarget() {
1159
+ return this._currentTarget;
1160
+ }
1150
1161
  get isCustomEvent() {
1151
1162
  return this._action.isCustomEvent;
1152
1163
  }
@@ -1331,9 +1342,12 @@ class BaseNode {
1331
1342
  return this._jsonModel.uniqueItems;
1332
1343
  }
1333
1344
  isTransparent() {
1334
- const isNonTransparent = this.parent?._jsonModel.type === 'array';
1345
+ const isNonTransparent = this.parent?._jsonModel?.type === 'array';
1335
1346
  return !this._jsonModel.name && !isNonTransparent;
1336
1347
  }
1348
+ getDependents() {
1349
+ return this._dependents.map(x => x.node.id);
1350
+ }
1337
1351
  getState(forRestore = false) {
1338
1352
  return {
1339
1353
  ...this._jsonModel,
@@ -1348,7 +1362,7 @@ class BaseNode {
1348
1362
  } : {}),
1349
1363
  ':type': this[':type'],
1350
1364
  ...(forRestore ? {
1351
- _dependents: this._dependents.length ? this._dependents.map(x => x.node.id) : undefined,
1365
+ _dependents: this._dependents.length ? this.getDependents() : undefined,
1352
1366
  allowedComponents: undefined,
1353
1367
  columnClassNames: undefined,
1354
1368
  columnCount: undefined,
@@ -1374,7 +1388,12 @@ class BaseNode {
1374
1388
  return propsToLook.indexOf(x.propertyName) > -1;
1375
1389
  }) > -1;
1376
1390
  if (isPropChanged) {
1377
- dependent.dispatch(new ExecuteRule());
1391
+ if (this.form.changeEventBehaviour === 'deps') {
1392
+ dependent.dispatch(change);
1393
+ }
1394
+ else {
1395
+ dependent.dispatch(new ExecuteRule());
1396
+ }
1378
1397
  }
1379
1398
  });
1380
1399
  this._dependents.push({ node: dependent, subscription });
@@ -1651,16 +1670,23 @@ class Scriptable extends BaseNode {
1651
1670
  return this._events[eName] || [];
1652
1671
  }
1653
1672
  applyUpdates(updates) {
1654
- Object.entries(updates).forEach(([key, value]) => {
1655
- if (key in editableProperties || (key in this && typeof this[key] !== 'function')) {
1656
- try {
1657
- this[key] = value;
1658
- }
1659
- catch (e) {
1660
- console.error(e);
1661
- }
1673
+ if (typeof updates === 'object') {
1674
+ if (updates !== null) {
1675
+ Object.entries(updates).forEach(([key, value]) => {
1676
+ if (key in editableProperties || (key in this && typeof this[key] !== 'function')) {
1677
+ try {
1678
+ this[key] = value;
1679
+ }
1680
+ catch (e) {
1681
+ console.error(e);
1682
+ }
1683
+ }
1684
+ });
1662
1685
  }
1663
- });
1686
+ }
1687
+ else if (typeof updates !== 'undefined') {
1688
+ this.value = updates;
1689
+ }
1664
1690
  }
1665
1691
  executeAllRules(context) {
1666
1692
  const entries = Object.entries(this.getRules());
@@ -1748,6 +1774,11 @@ class Scriptable extends BaseNode {
1748
1774
  const node = this.ruleEngine.compileRule(expr, this.lang);
1749
1775
  return this.ruleEngine.execute(node, this.getExpressionScope(), ruleContext);
1750
1776
  }
1777
+ change(event, context) {
1778
+ if (this.form.changeEventBehaviour === 'deps') {
1779
+ this.executeAllRules(context);
1780
+ }
1781
+ }
1751
1782
  executeAction(action) {
1752
1783
  const context = {
1753
1784
  'form': this.form,
@@ -1767,7 +1798,9 @@ class Scriptable extends BaseNode {
1767
1798
  this[funcName](action, context);
1768
1799
  }
1769
1800
  node.forEach((n) => this.executeEvent(context, n));
1770
- this.notifyDependents(action);
1801
+ if (action.target === this) {
1802
+ this.notifyDependents(action);
1803
+ }
1771
1804
  }
1772
1805
  }
1773
1806
 
@@ -2860,6 +2893,52 @@ class FunctionRuntimeImpl {
2860
2893
  }
2861
2894
  const FunctionRuntime = FunctionRuntimeImpl.getInstance();
2862
2895
 
2896
+ class Version {
2897
+ #minor;
2898
+ #major;
2899
+ #subVersion;
2900
+ #invalid = true;
2901
+ constructor(n) {
2902
+ const match = n.match(/([^.]+)\.([^.]+)(?:\.(.+))?/);
2903
+ if (match) {
2904
+ this.#major = +match[1];
2905
+ this.#minor = +match[2];
2906
+ this.#subVersion = match[3] ? +match[3] : 0;
2907
+ if (isNaN(this.#major) || isNaN(this.#minor) || isNaN(this.#subVersion)) {
2908
+ throw new Error('Invalid version string ' + n);
2909
+ }
2910
+ }
2911
+ else {
2912
+ throw new Error('Invalid version string ' + n);
2913
+ }
2914
+ }
2915
+ get major() {
2916
+ return this.#major;
2917
+ }
2918
+ get minor() {
2919
+ return this.#minor;
2920
+ }
2921
+ get subversion() {
2922
+ return this.#subVersion;
2923
+ }
2924
+ completeMatch(v) {
2925
+ return this.major === v.major &&
2926
+ this.minor === v.minor &&
2927
+ this.#subVersion === v.subversion;
2928
+ }
2929
+ lessThan(v) {
2930
+ return this.major < v.major || (this.major === v.major && (this.minor < v.minor)) || (this.major === v.major && this.minor === v.minor && this.#subVersion < v.subversion);
2931
+ }
2932
+ toString() {
2933
+ return `${this.major}.${this.minor}.${this.subversion}`;
2934
+ }
2935
+ valueOf() {
2936
+ return this.toString();
2937
+ }
2938
+ }
2939
+
2940
+ const currentVersion = new Version('0.13');
2941
+ const changeEventVersion = new Version('0.13');
2863
2942
  class Form extends Container {
2864
2943
  _ruleEngine;
2865
2944
  _eventQueue;
@@ -2871,9 +2950,15 @@ class Form extends Container {
2871
2950
  this._ruleEngine = _ruleEngine;
2872
2951
  this._eventQueue = _eventQueue;
2873
2952
  this._logger = new Logger(logLevel);
2953
+ this._applyDefaultsInModel();
2874
2954
  if (mode === 'create') {
2875
2955
  this.queueEvent(new Initialize());
2876
- this.queueEvent(new ExecuteRule());
2956
+ if (this.changeEventBehaviour === 'deps') {
2957
+ this.queueEvent(new Change({ changes: [] }));
2958
+ }
2959
+ else {
2960
+ this.queueEvent(new ExecuteRule());
2961
+ }
2877
2962
  }
2878
2963
  this._ids = IdGenerator();
2879
2964
  this._bindToDataModel(new DataGroup('$form', {}));
@@ -2882,10 +2967,21 @@ class Form extends Container {
2882
2967
  this.queueEvent(new FormLoad());
2883
2968
  }
2884
2969
  }
2970
+ _applyDefaultsInModel() {
2971
+ const current = this.specVersion;
2972
+ this._jsonModel.properties = this._jsonModel.properties || {};
2973
+ if (current.lessThan(changeEventVersion) ||
2974
+ typeof this._jsonModel.properties['fd:changeEventBehaviour'] !== 'string') {
2975
+ this._jsonModel.properties['fd:changeEventBehaviour'] = 'self';
2976
+ }
2977
+ }
2885
2978
  _logger;
2886
2979
  get logger() {
2887
2980
  return this._logger;
2888
2981
  }
2982
+ get changeEventBehaviour() {
2983
+ return this.properties['fd:changeEventBehaviour'] === 'deps' ? 'deps' : 'self';
2984
+ }
2889
2985
  dataRefRegex = /("[^"]+?"|[^.]+?)(?:\.|$)/g;
2890
2986
  get metaData() {
2891
2987
  const metaData = this._jsonModel.metadata || {};
@@ -2902,6 +2998,21 @@ class Form extends Container {
2902
2998
  exportData() {
2903
2999
  return this.getDataNode()?.$value;
2904
3000
  }
3001
+ get specVersion() {
3002
+ if (typeof this._jsonModel.adaptiveform === 'string') {
3003
+ try {
3004
+ return new Version(this._jsonModel.adaptiveform);
3005
+ }
3006
+ catch (e) {
3007
+ console.log(e);
3008
+ console.log('Falling back to default version' + currentVersion.toString());
3009
+ return currentVersion;
3010
+ }
3011
+ }
3012
+ else {
3013
+ return currentVersion;
3014
+ }
3015
+ }
2905
3016
  resolveQualifiedName(qualifiedName) {
2906
3017
  let foundFormElement = null;
2907
3018
  this.visit(formElement => {
@@ -3041,7 +3152,7 @@ class Form extends Container {
3041
3152
  }, 'valid');
3042
3153
  field.subscribe((action) => {
3043
3154
  const field = action.target.getState();
3044
- if (field) {
3155
+ if (action.payload.changes.length > 0 && field) {
3045
3156
  const shallowClone = (obj) => {
3046
3157
  if (obj && typeof obj === 'object') {
3047
3158
  if (Array.isArray(obj)) {
@@ -3277,7 +3388,12 @@ class Field extends Scriptable {
3277
3388
  if (_options.mode !== 'restore') {
3278
3389
  this._applyDefaults();
3279
3390
  this.queueEvent(new Initialize());
3280
- this.queueEvent(new ExecuteRule());
3391
+ if (this.form.changeEventBehaviour === 'deps') {
3392
+ this.queueEvent(new Change({ changes: [] }));
3393
+ }
3394
+ else {
3395
+ this.queueEvent(new ExecuteRule());
3396
+ }
3281
3397
  }
3282
3398
  }
3283
3399
  _ruleNodeReference = [];
@@ -3898,12 +4014,15 @@ class Field extends Scriptable {
3898
4014
  }
3899
4015
  triggerValidationEvent(changes) {
3900
4016
  if (changes.validity) {
3901
- if (this.validity.valid) {
3902
- this.dispatch(new Valid());
3903
- }
3904
- else {
3905
- this.dispatch(new Invalid());
3906
- }
4017
+ this.#triggerValidationEvent();
4018
+ }
4019
+ }
4020
+ #triggerValidationEvent() {
4021
+ if (this.validity.valid) {
4022
+ this.dispatch(new Valid());
4023
+ }
4024
+ else {
4025
+ this.dispatch(new Invalid());
3907
4026
  }
3908
4027
  }
3909
4028
  validate() {
@@ -3911,8 +4030,8 @@ class Field extends Scriptable {
3911
4030
  return [];
3912
4031
  }
3913
4032
  const changes = this.evaluateConstraints();
4033
+ this.#triggerValidationEvent();
3914
4034
  if (changes.validity) {
3915
- this.triggerValidationEvent(changes);
3916
4035
  this.notifyDependents(new Change({ changes: Object.values(changes) }));
3917
4036
  }
3918
4037
  return this.valid ? [] : [new ValidationError(this.id, [this._jsonModel.errorMessage])];
@@ -4333,9 +4452,11 @@ const FormFieldFactory = new FormFieldFactoryImpl();
4333
4452
  const createFormInstance = (formModel, callback, logLevel = 'error', fModel = undefined) => {
4334
4453
  try {
4335
4454
  let f = fModel;
4336
- if (f == null) {
4337
- formModel = sitesModelToFormModel(formModel);
4338
- f = new Form({ ...formModel }, FormFieldFactory, new RuleEngine(), new EventQueue(new Logger(logLevel)), logLevel);
4455
+ {
4456
+ if (f == null) {
4457
+ formModel = sitesModelToFormModel(formModel);
4458
+ f = new Form({ ...formModel }, FormFieldFactory, new RuleEngine(), new EventQueue(new Logger(logLevel)), logLevel);
4459
+ }
4339
4460
  }
4340
4461
  const formData = formModel?.data;
4341
4462
  if (formData) {
@@ -4352,6 +4473,7 @@ const createFormInstance = (formModel, callback, logLevel = 'error', fModel = un
4352
4473
  throw new Error(e);
4353
4474
  }
4354
4475
  };
4476
+ createFormInstance.currentVersion = currentVersion;
4355
4477
  const defaultOptions = {
4356
4478
  logLevel: 'error'
4357
4479
  };
@@ -50,6 +50,7 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
50
50
  set label(l: import("./types/Json").Label | undefined);
51
51
  get uniqueItems(): boolean | undefined;
52
52
  isTransparent(): boolean;
53
+ getDependents(): string[];
53
54
  getState(forRestore?: boolean): T & {
54
55
  _dependents?: string[] | undefined;
55
56
  allowedComponents?: undefined;
@@ -3,6 +3,7 @@ import Scriptable from './Scriptable';
3
3
  import DataValue from './data/DataValue';
4
4
  import DataGroup from './data/DataGroup';
5
5
  declare class Field extends Scriptable<FieldJson> implements FieldModel {
6
+ #private;
6
7
  constructor(params: FieldJson, _options: {
7
8
  form: FormModel;
8
9
  parent: ContainerModel;
@@ -5,6 +5,8 @@ import SubmitMetaData from './SubmitMetaData';
5
5
  import EventQueue from './controller/EventQueue';
6
6
  import { Logger, LogLevel } from './controller/Logger';
7
7
  import RuleEngine from './rules/RuleEngine';
8
+ import { Version } from './utils/Version';
9
+ export declare const currentVersion: Version;
8
10
  declare class Form extends Container<FormJson> implements FormModel {
9
11
  #private;
10
12
  private _ruleEngine;
@@ -13,13 +15,16 @@ declare class Form extends Container<FormJson> implements FormModel {
13
15
  _ids: Generator<string, void, string>;
14
16
  private _invalidFields;
15
17
  constructor(n: FormJson, fieldFactory: IFormFieldFactory, _ruleEngine: RuleEngine, _eventQueue?: EventQueue, logLevel?: LogLevel, mode?: FormCreationMode);
18
+ protected _applyDefaultsInModel(): void;
16
19
  private _logger;
17
20
  get logger(): Logger;
21
+ get changeEventBehaviour(): "deps" | "self";
18
22
  private dataRefRegex;
19
23
  get metaData(): FormMetaData;
20
24
  get action(): string | undefined;
21
25
  importData(dataModel: any): void;
22
26
  exportData(): any;
27
+ get specVersion(): Version;
23
28
  resolveQualifiedName(qualifiedName: string): FieldModel | FieldsetModel | null;
24
29
  exportSubmitMetaData(): SubmitMetaData;
25
30
  setFocus(field: BaseModel, focusOption: FocusOption): void;
@@ -78,7 +83,7 @@ declare class Form extends Container<FormJson> implements FormModel {
78
83
  data?: any;
79
84
  title?: string | undefined;
80
85
  action?: string | undefined;
81
- adaptiveForm?: string | undefined;
86
+ adaptiveform?: string | undefined;
82
87
  lang?: string | undefined;
83
88
  } & {
84
89
  items: any[];
@@ -1,7 +1,10 @@
1
1
  import { FormModel } from './types/index';
2
2
  import { LogLevel } from './controller/Logger';
3
3
  import { CustomFunction, FunctionDefinition } from './rules/FunctionRuntime';
4
- export declare const createFormInstance: (formModel: any, callback?: ((f: FormModel) => any) | undefined, logLevel?: LogLevel, fModel?: any) => FormModel;
4
+ export declare const createFormInstance: {
5
+ (formModel: any, callback?: ((f: FormModel) => any) | undefined, logLevel?: LogLevel, fModel?: any): FormModel;
6
+ currentVersion: import("./utils/Version").Version;
7
+ };
5
8
  export declare const restoreFormInstance: (formModel: any, data?: any, { logLevel }?: {
6
9
  logLevel: LogLevel;
7
10
  }) => FormModel;
@@ -12,6 +12,7 @@ declare abstract class Scriptable<T extends RulesJson> extends BaseNode<T> imple
12
12
  private executeEvent;
13
13
  executeRule(event: Action, context: any): void;
14
14
  executeExpression(expr: string): any;
15
+ change(event: Action, context: any): void;
15
16
  executeAction(action: Action): void;
16
17
  }
17
18
  export default Scriptable;
@@ -4,11 +4,13 @@ declare class ActionImpl implements Action {
4
4
  protected _type: string;
5
5
  private _payload?;
6
6
  private _target;
7
+ private _currentTarget;
7
8
  constructor(payload: any, type: string, _metadata?: any);
8
9
  get type(): string;
9
10
  get payload(): any;
10
11
  get metadata(): any;
11
12
  get target(): FormModel | FieldModel | FieldsetModel;
13
+ get currentTarget(): FormModel | FieldModel | FieldsetModel;
12
14
  get isCustomEvent(): boolean;
13
15
  protected payloadToJson(): any;
14
16
  toJson(): {
@@ -117,7 +117,7 @@ export type FormJson = ContainerJson & {
117
117
  data?: any;
118
118
  title?: string;
119
119
  action?: string;
120
- adaptiveForm?: string;
120
+ adaptiveform?: string;
121
121
  lang?: string;
122
122
  };
123
123
  export type TranslationJson = TranslationBaseJson & TranslationFieldJson & TranslationConstraintsJson;
@@ -3,6 +3,7 @@ import RuleEngine from '../rules/RuleEngine';
3
3
  import EventQueue from '../controller/EventQueue';
4
4
  import DataGroup from '../data/DataGroup';
5
5
  import { Logger } from '../controller/Logger';
6
+ import { Version } from '../utils/Version';
6
7
  export interface ScriptableField {
7
8
  rules?: {
8
9
  [key: string]: string;
@@ -10,7 +11,7 @@ export interface ScriptableField {
10
11
  events?: {
11
12
  [key: string]: string;
12
13
  };
13
- ruleEngine: RuleEngine;
14
+ readonly ruleEngine: RuleEngine;
14
15
  }
15
16
  interface WithState<T> {
16
17
  getState: () => any;
@@ -33,6 +34,7 @@ export interface Action {
33
34
  readonly isCustomEvent: boolean;
34
35
  readonly target: FormModel | FieldModel | FieldsetModel;
35
36
  readonly originalAction?: Action;
37
+ readonly currentTarget: FormModel | FieldModel | FieldsetModel;
36
38
  }
37
39
  export type callbackFn = (action: Action) => void;
38
40
  export interface WithController {
@@ -82,7 +84,7 @@ export interface FieldModel extends BaseModel, ScriptableField, WithState<FieldJ
82
84
  readonly editValue?: string;
83
85
  }
84
86
  export interface FormMetaDataModel {
85
- readonly version: string;
87
+ readonly version?: string;
86
88
  readonly grammar: string;
87
89
  }
88
90
  export interface SubmitMetaDataModel {
@@ -105,6 +107,7 @@ export interface FormModel extends ContainerModel, WithState<FormJson> {
105
107
  readonly metadata?: MetaDataJson;
106
108
  readonly title: string;
107
109
  readonly logger: Logger;
110
+ readonly specVersion: Version;
108
111
  importData(data: any): any;
109
112
  exportData(): any;
110
113
  getElement(id: string): FieldModel | FormModel | FieldsetModel;
@@ -113,6 +116,7 @@ export interface FormModel extends ContainerModel, WithState<FormJson> {
113
116
  visit(callBack: (field: FieldModel | FieldsetModel) => void): void;
114
117
  resolveQualifiedName(qualifiedName: string): FieldModel | FieldsetModel | null;
115
118
  fieldAdded(field: FieldModel | FieldsetModel): void;
119
+ readonly changeEventBehaviour: 'deps' | 'self';
116
120
  }
117
121
  export interface IFormFieldFactory {
118
122
  createField(child: FieldsetJson | FieldJson, options: {
@@ -0,0 +1,11 @@
1
+ export declare class Version {
2
+ #private;
3
+ constructor(n: string);
4
+ get major(): number;
5
+ get minor(): number;
6
+ get subversion(): number;
7
+ completeMatch(v: Version): boolean;
8
+ lessThan(v: Version): boolean;
9
+ toString(): string;
10
+ valueOf(): string;
11
+ }
package/lib/BaseNode.d.ts CHANGED
@@ -50,6 +50,7 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
50
50
  set label(l: import("./types/Json").Label | undefined);
51
51
  get uniqueItems(): boolean | undefined;
52
52
  isTransparent(): boolean;
53
+ getDependents(): string[];
53
54
  getState(forRestore?: boolean): T & {
54
55
  _dependents?: string[] | undefined;
55
56
  allowedComponents?: undefined;
package/lib/BaseNode.js CHANGED
@@ -44,7 +44,14 @@ exports.staticFields = ['plain-text', 'image'];
44
44
  class ActionImplWithTarget {
45
45
  constructor(_action, _target) {
46
46
  this._action = _action;
47
- this._target = _target;
47
+ if (_action.target) {
48
+ this._currentTarget = _target;
49
+ this._target = _action.target;
50
+ }
51
+ else {
52
+ this._target = _target;
53
+ this._currentTarget = _target;
54
+ }
48
55
  }
49
56
  get type() {
50
57
  return this._action.type;
@@ -58,6 +65,9 @@ class ActionImplWithTarget {
58
65
  get target() {
59
66
  return this._target;
60
67
  }
68
+ get currentTarget() {
69
+ return this._currentTarget;
70
+ }
61
71
  get isCustomEvent() {
62
72
  return this._action.isCustomEvent;
63
73
  }
@@ -236,17 +246,20 @@ class BaseNode {
236
246
  return this._jsonModel.uniqueItems;
237
247
  }
238
248
  isTransparent() {
239
- var _a;
240
- const isNonTransparent = ((_a = this.parent) === null || _a === void 0 ? void 0 : _a._jsonModel.type) === 'array';
249
+ var _a, _b;
250
+ const isNonTransparent = ((_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a._jsonModel) === null || _b === void 0 ? void 0 : _b.type) === 'array';
241
251
  return !this._jsonModel.name && !isNonTransparent;
242
252
  }
253
+ getDependents() {
254
+ return this._dependents.map(x => x.node.id);
255
+ }
243
256
  getState(forRestore = false) {
244
257
  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
258
  repeatable: true,
246
259
  minOccur: this.parent.minItems,
247
260
  maxOccur: this.parent.maxItems
248
261
  } : {})), { ':type': this[':type'] }), (forRestore ? {
249
- _dependents: this._dependents.length ? this._dependents.map(x => x.node.id) : undefined,
262
+ _dependents: this._dependents.length ? this.getDependents() : undefined,
250
263
  allowedComponents: undefined,
251
264
  columnClassNames: undefined,
252
265
  columnCount: undefined,
@@ -271,7 +284,12 @@ class BaseNode {
271
284
  return propsToLook.indexOf(x.propertyName) > -1;
272
285
  }) > -1;
273
286
  if (isPropChanged) {
274
- dependent.dispatch(new Events_1.ExecuteRule());
287
+ if (this.form.changeEventBehaviour === 'deps') {
288
+ dependent.dispatch(change);
289
+ }
290
+ else {
291
+ dependent.dispatch(new Events_1.ExecuteRule());
292
+ }
275
293
  }
276
294
  });
277
295
  this._dependents.push({ node: dependent, subscription });
package/lib/Field.d.ts CHANGED
@@ -3,6 +3,7 @@ import Scriptable from './Scriptable';
3
3
  import DataValue from './data/DataValue';
4
4
  import DataGroup from './data/DataGroup';
5
5
  declare class Field extends Scriptable<FieldJson> implements FieldModel {
6
+ #private;
6
7
  constructor(params: FieldJson, _options: {
7
8
  form: FormModel;
8
9
  parent: ContainerModel;
package/lib/Field.js CHANGED
@@ -5,9 +5,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
8
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
10
15
  };
16
+ var _Field_instances, _Field_triggerValidationEvent;
11
17
  Object.defineProperty(exports, "__esModule", { value: true });
12
18
  const types_1 = require("./types");
13
19
  const ValidationUtils_1 = require("./utils/ValidationUtils");
@@ -23,11 +29,17 @@ const validTypes = ['string', 'number', 'integer', 'boolean', 'file', 'string[]'
23
29
  class Field extends Scriptable_1.default {
24
30
  constructor(params, _options) {
25
31
  super(params, _options);
32
+ _Field_instances.add(this);
26
33
  this._ruleNodeReference = [];
27
34
  if (_options.mode !== 'restore') {
28
35
  this._applyDefaults();
29
36
  this.queueEvent(new Events_1.Initialize());
30
- this.queueEvent(new Events_1.ExecuteRule());
37
+ if (this.form.changeEventBehaviour === 'deps') {
38
+ this.queueEvent(new Events_1.Change({ changes: [] }));
39
+ }
40
+ else {
41
+ this.queueEvent(new Events_1.ExecuteRule());
42
+ }
31
43
  }
32
44
  }
33
45
  _initialize() {
@@ -642,12 +654,7 @@ class Field extends Scriptable_1.default {
642
654
  }
643
655
  triggerValidationEvent(changes) {
644
656
  if (changes.validity) {
645
- if (this.validity.valid) {
646
- this.dispatch(new Events_1.Valid());
647
- }
648
- else {
649
- this.dispatch(new Events_1.Invalid());
650
- }
657
+ __classPrivateFieldGet(this, _Field_instances, "m", _Field_triggerValidationEvent).call(this);
651
658
  }
652
659
  }
653
660
  validate() {
@@ -655,8 +662,8 @@ class Field extends Scriptable_1.default {
655
662
  return [];
656
663
  }
657
664
  const changes = this.evaluateConstraints();
665
+ __classPrivateFieldGet(this, _Field_instances, "m", _Field_triggerValidationEvent).call(this);
658
666
  if (changes.validity) {
659
- this.triggerValidationEvent(changes);
660
667
  this.notifyDependents(new Events_1.Change({ changes: Object.values(changes) }));
661
668
  }
662
669
  return this.valid ? [] : [new types_1.ValidationError(this.id, [this._jsonModel.errorMessage])];
@@ -692,6 +699,14 @@ class Field extends Scriptable_1.default {
692
699
  }
693
700
  }
694
701
  }
702
+ _Field_instances = new WeakSet(), _Field_triggerValidationEvent = function _Field_triggerValidationEvent() {
703
+ if (this.validity.valid) {
704
+ this.dispatch(new Events_1.Valid());
705
+ }
706
+ else {
707
+ this.dispatch(new Events_1.Invalid());
708
+ }
709
+ };
695
710
  __decorate([
696
711
  (0, BaseNode_1.dependencyTracked)(),
697
712
  (0, BaseNode_1.exclude)('button', 'image', 'plain-text')
package/lib/Form.d.ts CHANGED
@@ -5,6 +5,8 @@ import SubmitMetaData from './SubmitMetaData';
5
5
  import EventQueue from './controller/EventQueue';
6
6
  import { Logger, LogLevel } from './controller/Logger';
7
7
  import RuleEngine from './rules/RuleEngine';
8
+ import { Version } from './utils/Version';
9
+ export declare const currentVersion: Version;
8
10
  declare class Form extends Container<FormJson> implements FormModel {
9
11
  #private;
10
12
  private _ruleEngine;
@@ -13,13 +15,16 @@ declare class Form extends Container<FormJson> implements FormModel {
13
15
  _ids: Generator<string, void, string>;
14
16
  private _invalidFields;
15
17
  constructor(n: FormJson, fieldFactory: IFormFieldFactory, _ruleEngine: RuleEngine, _eventQueue?: EventQueue, logLevel?: LogLevel, mode?: FormCreationMode);
18
+ protected _applyDefaultsInModel(): void;
16
19
  private _logger;
17
20
  get logger(): Logger;
21
+ get changeEventBehaviour(): "deps" | "self";
18
22
  private dataRefRegex;
19
23
  get metaData(): FormMetaData;
20
24
  get action(): string | undefined;
21
25
  importData(dataModel: any): void;
22
26
  exportData(): any;
27
+ get specVersion(): Version;
23
28
  resolveQualifiedName(qualifiedName: string): FieldModel | FieldsetModel | null;
24
29
  exportSubmitMetaData(): SubmitMetaData;
25
30
  setFocus(field: BaseModel, focusOption: FocusOption): void;
@@ -78,7 +83,7 @@ declare class Form extends Container<FormJson> implements FormModel {
78
83
  data?: any;
79
84
  title?: string | undefined;
80
85
  action?: string | undefined;
81
- adaptiveForm?: string | undefined;
86
+ adaptiveform?: string | undefined;
82
87
  lang?: string | undefined;
83
88
  } & {
84
89
  items: any[];
package/lib/Form.js CHANGED
@@ -9,6 +9,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  };
10
10
  var _Form_instances, _Form_getNavigableChildren, _Form_getFirstNavigableChild, _Form_setActiveFirstDeepChild, _Form_getNextItem, _Form_getPreviousItem, _Form_clearCurrentFocus;
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.currentVersion = void 0;
12
13
  const Container_1 = __importDefault(require("./Container"));
13
14
  const index_1 = require("./types/index");
14
15
  const FormMetaData_1 = __importDefault(require("./FormMetaData"));
@@ -19,6 +20,9 @@ const FormUtils_1 = require("./utils/FormUtils");
19
20
  const DataGroup_1 = __importDefault(require("./data/DataGroup"));
20
21
  const FunctionRuntime_1 = require("./rules/FunctionRuntime");
21
22
  const Events_1 = require("./controller/Events");
23
+ const Version_1 = require("./utils/Version");
24
+ exports.currentVersion = new Version_1.Version('0.13');
25
+ const changeEventVersion = new Version_1.Version('0.13');
22
26
  class Form extends Container_1.default {
23
27
  constructor(n, fieldFactory, _ruleEngine, _eventQueue = new EventQueue_1.default(), logLevel = 'off', mode = 'create') {
24
28
  super(n, { fieldFactory: fieldFactory, mode });
@@ -29,9 +33,15 @@ class Form extends Container_1.default {
29
33
  this._invalidFields = [];
30
34
  this.dataRefRegex = /("[^"]+?"|[^.]+?)(?:\.|$)/g;
31
35
  this._logger = new Logger_1.Logger(logLevel);
36
+ this._applyDefaultsInModel();
32
37
  if (mode === 'create') {
33
38
  this.queueEvent(new Events_1.Initialize());
34
- this.queueEvent(new Events_1.ExecuteRule());
39
+ if (this.changeEventBehaviour === 'deps') {
40
+ this.queueEvent(new Events_1.Change({ changes: [] }));
41
+ }
42
+ else {
43
+ this.queueEvent(new Events_1.ExecuteRule());
44
+ }
35
45
  }
36
46
  this._ids = (0, FormUtils_1.IdGenerator)();
37
47
  this._bindToDataModel(new DataGroup_1.default('$form', {}));
@@ -40,9 +50,20 @@ class Form extends Container_1.default {
40
50
  this.queueEvent(new Events_1.FormLoad());
41
51
  }
42
52
  }
53
+ _applyDefaultsInModel() {
54
+ const current = this.specVersion;
55
+ this._jsonModel.properties = this._jsonModel.properties || {};
56
+ if (current.lessThan(changeEventVersion) ||
57
+ typeof this._jsonModel.properties['fd:changeEventBehaviour'] !== 'string') {
58
+ this._jsonModel.properties['fd:changeEventBehaviour'] = 'self';
59
+ }
60
+ }
43
61
  get logger() {
44
62
  return this._logger;
45
63
  }
64
+ get changeEventBehaviour() {
65
+ return this.properties['fd:changeEventBehaviour'] === 'deps' ? 'deps' : 'self';
66
+ }
46
67
  get metaData() {
47
68
  const metaData = this._jsonModel.metadata || {};
48
69
  return new FormMetaData_1.default(metaData);
@@ -59,6 +80,21 @@ class Form extends Container_1.default {
59
80
  var _a;
60
81
  return (_a = this.getDataNode()) === null || _a === void 0 ? void 0 : _a.$value;
61
82
  }
83
+ get specVersion() {
84
+ if (typeof this._jsonModel.adaptiveform === 'string') {
85
+ try {
86
+ return new Version_1.Version(this._jsonModel.adaptiveform);
87
+ }
88
+ catch (e) {
89
+ console.log(e);
90
+ console.log('Falling back to default version' + exports.currentVersion.toString());
91
+ return exports.currentVersion;
92
+ }
93
+ }
94
+ else {
95
+ return exports.currentVersion;
96
+ }
97
+ }
62
98
  resolveQualifiedName(qualifiedName) {
63
99
  let foundFormElement = null;
64
100
  this.visit(formElement => {
@@ -159,7 +195,7 @@ class Form extends Container_1.default {
159
195
  }, 'valid');
160
196
  field.subscribe((action) => {
161
197
  const field = action.target.getState();
162
- if (field) {
198
+ if (action.payload.changes.length > 0 && field) {
163
199
  const shallowClone = (obj) => {
164
200
  if (obj && typeof obj === 'object') {
165
201
  if (Array.isArray(obj)) {
@@ -1,7 +1,10 @@
1
1
  import { FormModel } from './types/index';
2
2
  import { LogLevel } from './controller/Logger';
3
3
  import { CustomFunction, FunctionDefinition } from './rules/FunctionRuntime';
4
- export declare const createFormInstance: (formModel: any, callback?: ((f: FormModel) => any) | undefined, logLevel?: LogLevel, fModel?: any) => FormModel;
4
+ export declare const createFormInstance: {
5
+ (formModel: any, callback?: ((f: FormModel) => any) | undefined, logLevel?: LogLevel, fModel?: any): FormModel;
6
+ currentVersion: import("./utils/Version").Version;
7
+ };
5
8
  export declare const restoreFormInstance: (formModel: any, data?: any, { logLevel }?: {
6
9
  logLevel: LogLevel;
7
10
  }) => FormModel;
@@ -1,10 +1,33 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.registerFunctions = exports.fetchForm = exports.validateFormData = exports.validateFormInstance = exports.restoreFormInstance = exports.createFormInstance = void 0;
7
- const Form_1 = __importDefault(require("./Form"));
30
+ const Form_1 = __importStar(require("./Form"));
8
31
  const JsonUtils_1 = require("./utils/JsonUtils");
9
32
  const Fetch_1 = require("./utils/Fetch");
10
33
  const RuleEngine_1 = __importDefault(require("./rules/RuleEngine"));
@@ -17,9 +40,11 @@ const DataGroup_1 = __importDefault(require("./data/DataGroup"));
17
40
  const createFormInstance = (formModel, callback, logLevel = 'error', fModel = undefined) => {
18
41
  try {
19
42
  let f = fModel;
20
- if (f == null) {
21
- formModel = (0, FormUtils_1.sitesModelToFormModel)(formModel);
22
- f = new Form_1.default(Object.assign({}, formModel), FormCreationUtils_1.FormFieldFactory, new RuleEngine_1.default(), new EventQueue_1.default(new Logger_1.Logger(logLevel)), logLevel);
43
+ {
44
+ if (f == null) {
45
+ formModel = (0, FormUtils_1.sitesModelToFormModel)(formModel);
46
+ f = new Form_1.default(Object.assign({}, formModel), FormCreationUtils_1.FormFieldFactory, new RuleEngine_1.default(), new EventQueue_1.default(new Logger_1.Logger(logLevel)), logLevel);
47
+ }
23
48
  }
24
49
  const formData = formModel === null || formModel === void 0 ? void 0 : formModel.data;
25
50
  if (formData) {
@@ -37,6 +62,7 @@ const createFormInstance = (formModel, callback, logLevel = 'error', fModel = un
37
62
  }
38
63
  };
39
64
  exports.createFormInstance = createFormInstance;
65
+ exports.createFormInstance.currentVersion = Form_1.currentVersion;
40
66
  const defaultOptions = {
41
67
  logLevel: 'error'
42
68
  };
@@ -12,6 +12,7 @@ declare abstract class Scriptable<T extends RulesJson> extends BaseNode<T> imple
12
12
  private executeEvent;
13
13
  executeRule(event: Action, context: any): void;
14
14
  executeExpression(expr: string): any;
15
+ change(event: Action, context: any): void;
15
16
  executeAction(action: Action): void;
16
17
  }
17
18
  export default Scriptable;
package/lib/Scriptable.js CHANGED
@@ -49,16 +49,23 @@ class Scriptable extends BaseNode_1.BaseNode {
49
49
  return this._events[eName] || [];
50
50
  }
51
51
  applyUpdates(updates) {
52
- Object.entries(updates).forEach(([key, value]) => {
53
- if (key in BaseNode_1.editableProperties || (key in this && typeof this[key] !== 'function')) {
54
- try {
55
- this[key] = value;
56
- }
57
- catch (e) {
58
- console.error(e);
59
- }
52
+ if (typeof updates === 'object') {
53
+ if (updates !== null) {
54
+ Object.entries(updates).forEach(([key, value]) => {
55
+ if (key in BaseNode_1.editableProperties || (key in this && typeof this[key] !== 'function')) {
56
+ try {
57
+ this[key] = value;
58
+ }
59
+ catch (e) {
60
+ console.error(e);
61
+ }
62
+ }
63
+ });
60
64
  }
61
- });
65
+ }
66
+ else if (typeof updates !== 'undefined') {
67
+ this.value = updates;
68
+ }
62
69
  }
63
70
  executeAllRules(context) {
64
71
  const entries = Object.entries(this.getRules());
@@ -146,6 +153,11 @@ class Scriptable extends BaseNode_1.BaseNode {
146
153
  const node = this.ruleEngine.compileRule(expr, this.lang);
147
154
  return this.ruleEngine.execute(node, this.getExpressionScope(), ruleContext);
148
155
  }
156
+ change(event, context) {
157
+ if (this.form.changeEventBehaviour === 'deps') {
158
+ this.executeAllRules(context);
159
+ }
160
+ }
149
161
  executeAction(action) {
150
162
  const context = {
151
163
  'form': this.form,
@@ -165,7 +177,9 @@ class Scriptable extends BaseNode_1.BaseNode {
165
177
  this[funcName](action, context);
166
178
  }
167
179
  node.forEach((n) => this.executeEvent(context, n));
168
- this.notifyDependents(action);
180
+ if (action.target === this) {
181
+ this.notifyDependents(action);
182
+ }
169
183
  }
170
184
  }
171
185
  exports.default = Scriptable;
@@ -4,11 +4,13 @@ declare class ActionImpl implements Action {
4
4
  protected _type: string;
5
5
  private _payload?;
6
6
  private _target;
7
+ private _currentTarget;
7
8
  constructor(payload: any, type: string, _metadata?: any);
8
9
  get type(): string;
9
10
  get payload(): any;
10
11
  get metadata(): any;
11
12
  get target(): FormModel | FieldModel | FieldsetModel;
13
+ get currentTarget(): FormModel | FieldModel | FieldsetModel;
12
14
  get isCustomEvent(): boolean;
13
15
  protected payloadToJson(): any;
14
16
  toJson(): {
@@ -19,6 +19,9 @@ class ActionImpl {
19
19
  get target() {
20
20
  return this._target;
21
21
  }
22
+ get currentTarget() {
23
+ return this._currentTarget;
24
+ }
22
25
  get isCustomEvent() {
23
26
  return false;
24
27
  }
@@ -117,7 +117,7 @@ export declare type FormJson = ContainerJson & {
117
117
  data?: any;
118
118
  title?: string;
119
119
  action?: string;
120
- adaptiveForm?: string;
120
+ adaptiveform?: string;
121
121
  lang?: string;
122
122
  };
123
123
  export declare type TranslationJson = TranslationBaseJson & TranslationFieldJson & TranslationConstraintsJson;
@@ -3,6 +3,7 @@ import RuleEngine from '../rules/RuleEngine';
3
3
  import EventQueue from '../controller/EventQueue';
4
4
  import DataGroup from '../data/DataGroup';
5
5
  import { Logger } from '../controller/Logger';
6
+ import { Version } from '../utils/Version';
6
7
  export interface ScriptableField {
7
8
  rules?: {
8
9
  [key: string]: string;
@@ -10,7 +11,7 @@ export interface ScriptableField {
10
11
  events?: {
11
12
  [key: string]: string;
12
13
  };
13
- ruleEngine: RuleEngine;
14
+ readonly ruleEngine: RuleEngine;
14
15
  }
15
16
  interface WithState<T> {
16
17
  getState: () => any;
@@ -33,6 +34,7 @@ export interface Action {
33
34
  readonly isCustomEvent: boolean;
34
35
  readonly target: FormModel | FieldModel | FieldsetModel;
35
36
  readonly originalAction?: Action;
37
+ readonly currentTarget: FormModel | FieldModel | FieldsetModel;
36
38
  }
37
39
  export declare type callbackFn = (action: Action) => void;
38
40
  export interface WithController {
@@ -82,7 +84,7 @@ export interface FieldModel extends BaseModel, ScriptableField, WithState<FieldJ
82
84
  readonly editValue?: string;
83
85
  }
84
86
  export interface FormMetaDataModel {
85
- readonly version: string;
87
+ readonly version?: string;
86
88
  readonly grammar: string;
87
89
  }
88
90
  export interface SubmitMetaDataModel {
@@ -105,6 +107,7 @@ export interface FormModel extends ContainerModel, WithState<FormJson> {
105
107
  readonly metadata?: MetaDataJson;
106
108
  readonly title: string;
107
109
  readonly logger: Logger;
110
+ readonly specVersion: Version;
108
111
  importData(data: any): any;
109
112
  exportData(): any;
110
113
  getElement(id: string): FieldModel | FormModel | FieldsetModel;
@@ -113,6 +116,7 @@ export interface FormModel extends ContainerModel, WithState<FormJson> {
113
116
  visit(callBack: (field: FieldModel | FieldsetModel) => void): void;
114
117
  resolveQualifiedName(qualifiedName: string): FieldModel | FieldsetModel | null;
115
118
  fieldAdded(field: FieldModel | FieldsetModel): void;
119
+ readonly changeEventBehaviour: 'deps' | 'self';
116
120
  }
117
121
  export interface IFormFieldFactory {
118
122
  createField(child: FieldsetJson | FieldJson, options: {
@@ -0,0 +1,11 @@
1
+ export declare class Version {
2
+ #private;
3
+ constructor(n: string);
4
+ get major(): number;
5
+ get minor(): number;
6
+ get subversion(): number;
7
+ completeMatch(v: Version): boolean;
8
+ lessThan(v: Version): boolean;
9
+ toString(): string;
10
+ valueOf(): string;
11
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _Version_minor, _Version_major, _Version_subVersion, _Version_invalid;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Version = void 0;
16
+ class Version {
17
+ constructor(n) {
18
+ _Version_minor.set(this, void 0);
19
+ _Version_major.set(this, void 0);
20
+ _Version_subVersion.set(this, void 0);
21
+ _Version_invalid.set(this, true);
22
+ const match = n.match(/([^.]+)\.([^.]+)(?:\.(.+))?/);
23
+ if (match) {
24
+ __classPrivateFieldSet(this, _Version_major, +match[1], "f");
25
+ __classPrivateFieldSet(this, _Version_minor, +match[2], "f");
26
+ __classPrivateFieldSet(this, _Version_subVersion, match[3] ? +match[3] : 0, "f");
27
+ if (isNaN(__classPrivateFieldGet(this, _Version_major, "f")) || isNaN(__classPrivateFieldGet(this, _Version_minor, "f")) || isNaN(__classPrivateFieldGet(this, _Version_subVersion, "f"))) {
28
+ throw new Error('Invalid version string ' + n);
29
+ }
30
+ }
31
+ else {
32
+ throw new Error('Invalid version string ' + n);
33
+ }
34
+ }
35
+ get major() {
36
+ return __classPrivateFieldGet(this, _Version_major, "f");
37
+ }
38
+ get minor() {
39
+ return __classPrivateFieldGet(this, _Version_minor, "f");
40
+ }
41
+ get subversion() {
42
+ return __classPrivateFieldGet(this, _Version_subVersion, "f");
43
+ }
44
+ completeMatch(v) {
45
+ return this.major === v.major &&
46
+ this.minor === v.minor &&
47
+ __classPrivateFieldGet(this, _Version_subVersion, "f") === v.subversion;
48
+ }
49
+ lessThan(v) {
50
+ return this.major < v.major || (this.major === v.major && (this.minor < v.minor)) || (this.major === v.major && this.minor === v.minor && __classPrivateFieldGet(this, _Version_subVersion, "f") < v.subversion);
51
+ }
52
+ toString() {
53
+ return `${this.major}.${this.minor}.${this.subversion}`;
54
+ }
55
+ valueOf() {
56
+ return this.toString();
57
+ }
58
+ }
59
+ exports.Version = Version;
60
+ _Version_minor = new WeakMap(), _Version_major = new WeakMap(), _Version_subVersion = new WeakMap(), _Version_invalid = new WeakMap();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.77",
3
+ "version": "0.22.79",
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.77"
40
+ "@aemforms/af-formatters": "^0.22.79"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/preset-env": "^7.20.2",