@aemforms/af-core 0.22.18 → 0.22.20

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.
Files changed (120) hide show
  1. package/lib/browser/afb-events.js +151 -0
  2. package/lib/browser/afb-runtime.js +3620 -0
  3. package/lib/cjs/index.cjs +8886 -0
  4. package/lib/{BaseNode.d.ts → esm/BaseNode.d.ts} +11 -68
  5. package/lib/{BaseNode.js → esm/BaseNode.js} +86 -182
  6. package/lib/esm/Checkbox.d.ts +79 -0
  7. package/lib/esm/Checkbox.js +27 -0
  8. package/lib/{CheckboxGroup.d.ts → esm/CheckboxGroup.d.ts} +2 -14
  9. package/lib/esm/CheckboxGroup.js +23 -0
  10. package/lib/esm/Container.d.ts +53 -0
  11. package/lib/{Container.js → esm/Container.js} +76 -124
  12. package/lib/{DateField.d.ts → esm/DateField.d.ts} +1 -1
  13. package/lib/esm/DateField.js +21 -0
  14. package/lib/{Field.d.ts → esm/Field.d.ts} +44 -98
  15. package/lib/{Field.js → esm/Field.js} +172 -206
  16. package/lib/esm/Fieldset.d.ts +16 -0
  17. package/lib/esm/Fieldset.js +45 -0
  18. package/lib/{FileObject.d.ts → esm/FileObject.d.ts} +1 -4
  19. package/lib/esm/FileObject.js +26 -0
  20. package/lib/{FileUpload.d.ts → esm/FileUpload.d.ts} +3 -18
  21. package/lib/esm/FileUpload.js +108 -0
  22. package/lib/esm/Form.d.ts +113 -0
  23. package/lib/esm/Form.js +176 -0
  24. package/lib/esm/FormInstance.d.ts +13 -0
  25. package/lib/esm/FormInstance.js +81 -0
  26. package/lib/esm/FormMetaData.d.ts +7 -0
  27. package/lib/esm/FormMetaData.js +10 -0
  28. package/lib/esm/InstanceManager.d.ts +9 -0
  29. package/lib/esm/InstanceManager.js +31 -0
  30. package/lib/esm/Node.d.ts +7 -0
  31. package/lib/esm/Node.js +16 -0
  32. package/lib/esm/Scriptable.d.ts +17 -0
  33. package/lib/{Scriptable.js → esm/Scriptable.js} +12 -55
  34. package/lib/{controller → esm/controller}/EventQueue.d.ts +3 -11
  35. package/lib/{controller → esm/controller}/EventQueue.js +10 -26
  36. package/lib/esm/controller/Events.d.ts +85 -0
  37. package/lib/esm/controller/Events.js +149 -0
  38. package/lib/{controller → esm/controller}/Logger.d.ts +0 -6
  39. package/lib/{controller → esm/controller}/Logger.js +5 -11
  40. package/lib/{data → esm/data}/DataGroup.d.ts +1 -7
  41. package/lib/{data → esm/data}/DataGroup.js +20 -35
  42. package/lib/{data → esm/data}/DataValue.d.ts +2 -8
  43. package/lib/esm/data/DataValue.js +46 -0
  44. package/lib/{data → esm/data}/EmptyDataValue.d.ts +1 -1
  45. package/lib/esm/data/EmptyDataValue.js +29 -0
  46. package/lib/esm/index.d.ts +21 -0
  47. package/lib/esm/index.js +21 -0
  48. package/lib/{rules → esm/rules}/FunctionRuntime.d.ts +2 -24
  49. package/lib/{rules → esm/rules}/FunctionRuntime.js +44 -114
  50. package/lib/esm/rules/RuleEngine.d.ts +12 -0
  51. package/lib/esm/rules/RuleEngine.js +47 -0
  52. package/lib/{types → esm/types}/Json.d.ts +6 -22
  53. package/lib/esm/types/Json.js +7 -0
  54. package/lib/esm/types/Model.d.ts +131 -0
  55. package/lib/esm/types/Model.js +8 -0
  56. package/lib/esm/types/index.d.ts +2 -0
  57. package/lib/esm/types/index.js +2 -0
  58. package/lib/{utils → esm/utils}/DataRefParser.d.ts +2 -5
  59. package/lib/{utils → esm/utils}/DataRefParser.js +22 -49
  60. package/lib/{utils → esm/utils}/Fetch.d.ts +1 -0
  61. package/lib/esm/utils/Fetch.js +61 -0
  62. package/lib/esm/utils/FormCreationUtils.d.ts +9 -0
  63. package/lib/esm/utils/FormCreationUtils.js +74 -0
  64. package/lib/esm/utils/FormUtils.d.ts +12 -0
  65. package/lib/esm/utils/FormUtils.js +187 -0
  66. package/lib/esm/utils/JsonUtils.d.ts +11 -0
  67. package/lib/esm/utils/JsonUtils.js +76 -0
  68. package/lib/{utils → esm/utils}/LogUtils.d.ts +1 -4
  69. package/lib/esm/utils/LogUtils.js +6 -0
  70. package/lib/esm/utils/SchemaUtils.d.ts +3 -0
  71. package/lib/esm/utils/SchemaUtils.js +71 -0
  72. package/lib/esm/utils/TranslationUtils.d.ts +11 -0
  73. package/lib/esm/utils/TranslationUtils.js +115 -0
  74. package/lib/esm/utils/ValidationUtils.d.ts +19 -0
  75. package/lib/{utils → esm/utils}/ValidationUtils.js +29 -187
  76. package/package.json +17 -10
  77. package/lib/Checkbox.d.ts +0 -88
  78. package/lib/Checkbox.js +0 -49
  79. package/lib/CheckboxGroup.js +0 -43
  80. package/lib/Container.d.ts +0 -199
  81. package/lib/DateField.js +0 -35
  82. package/lib/Fieldset.d.ts +0 -34
  83. package/lib/Fieldset.js +0 -113
  84. package/lib/FileObject.js +0 -39
  85. package/lib/FileUpload.js +0 -155
  86. package/lib/Form.d.ts +0 -262
  87. package/lib/Form.js +0 -230
  88. package/lib/FormInstance.d.ts +0 -38
  89. package/lib/FormInstance.js +0 -119
  90. package/lib/FormMetaData.d.ts +0 -11
  91. package/lib/FormMetaData.js +0 -28
  92. package/lib/Node.d.ts +0 -12
  93. package/lib/Node.js +0 -27
  94. package/lib/Scriptable.d.ts +0 -31
  95. package/lib/controller/Controller.d.ts +0 -223
  96. package/lib/controller/Controller.js +0 -287
  97. package/lib/controller/index.d.ts +0 -1
  98. package/lib/controller/index.js +0 -24
  99. package/lib/data/DataValue.js +0 -52
  100. package/lib/data/EmptyDataValue.js +0 -46
  101. package/lib/index.d.ts +0 -28
  102. package/lib/index.js +0 -63
  103. package/lib/rules/RuleEngine.d.ts +0 -23
  104. package/lib/rules/RuleEngine.js +0 -62
  105. package/lib/types/Json.js +0 -19
  106. package/lib/types/Model.d.ts +0 -379
  107. package/lib/types/Model.js +0 -20
  108. package/lib/types/index.d.ts +0 -2
  109. package/lib/types/index.js +0 -25
  110. package/lib/utils/Fetch.js +0 -29
  111. package/lib/utils/FormUtils.d.ts +0 -47
  112. package/lib/utils/FormUtils.js +0 -257
  113. package/lib/utils/JsonUtils.d.ts +0 -62
  114. package/lib/utils/JsonUtils.js +0 -143
  115. package/lib/utils/LogUtils.js +0 -17
  116. package/lib/utils/SchemaUtils.d.ts +0 -16
  117. package/lib/utils/SchemaUtils.js +0 -92
  118. package/lib/utils/TranslationUtils.d.ts +0 -41
  119. package/lib/utils/TranslationUtils.js +0 -185
  120. package/lib/utils/ValidationUtils.d.ts +0 -170
@@ -1,13 +1,7 @@
1
- import { Action, BaseJson, BaseModel, callbackFn, ContainerModel, FormModel, Primitives, ValidationError } from './types';
2
- import DataGroup from './data/DataGroup';
3
- import DataValue from './data/DataValue';
4
- /**
5
- * Defines the properties that are editable. These properties can be modified during rule execution.
6
- */
1
+ import { Action, BaseJson, BaseModel, callbackFn, ContainerModel, FormModel, Primitives, ValidationError } from './types/index.js';
2
+ import DataGroup from './data/DataGroup.js';
3
+ import DataValue from './data/DataValue.js';
7
4
  export declare const editableProperties: string[];
8
- /**
9
- * Defines props that are dynamic and can be changed at runtime.
10
- */
11
5
  export declare const dynamicProps: string[];
12
6
  export declare const staticFields: string[];
13
7
  export declare const target: unique symbol;
@@ -15,13 +9,10 @@ export declare const qualifiedName: unique symbol;
15
9
  export declare function dependencyTracked(): (target: BaseNode<any>, propertyKey: string, descriptor: PropertyDescriptor) => void;
16
10
  export declare const include: (...fieldTypes: string[]) => (target: BaseNode<any>, propertyKey: string, descriptor: PropertyDescriptor) => void;
17
11
  export declare const exclude: (...fieldTypes: string[]) => (target: BaseNode<any>, propertyKey: string, descriptor: PropertyDescriptor) => void;
18
- /**
19
- * Defines a generic base class which all objects of form runtime model should extend from.
20
- * @typeparam T type of the form object which extends from {@link BaseJson | base type}
21
- */
22
12
  export declare abstract class BaseNode<T extends BaseJson> implements BaseModel {
23
13
  private _options;
24
14
  private _ruleNode;
15
+ private _lang?;
25
16
  private _callbacks;
26
17
  private _dependents;
27
18
  protected _jsonModel: T & {
@@ -29,31 +20,21 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
29
20
  };
30
21
  private _tokens;
31
22
  get isContainer(): boolean;
32
- /**
33
- * @constructor
34
- * @param params
35
- * @param _options
36
- * @private
37
- */
38
23
  constructor(params: T, _options: {
39
24
  form: FormModel;
40
25
  parent: ContainerModel;
41
26
  });
42
27
  abstract value: Primitives;
28
+ abstract reset(): any;
43
29
  protected setupRuleNode(): void;
44
- /**
45
- * @private
46
- */
47
30
  ruleNodeReference(): this;
48
- /**
49
- * @private
50
- */
51
31
  getRuleNode(): any;
52
32
  private getFromRule;
53
33
  get id(): string;
54
34
  get index(): number;
55
35
  get parent(): ContainerModel;
56
36
  get type(): string | undefined;
37
+ get repeatable(): any;
57
38
  get fieldType(): string;
58
39
  get ':type'(): string;
59
40
  get name(): string | undefined;
@@ -63,13 +44,10 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
63
44
  get visible(): boolean | undefined;
64
45
  set visible(v: boolean | undefined);
65
46
  get form(): FormModel;
66
- get ruleEngine(): import("./rules/RuleEngine").default;
67
- get label(): import("./types").Label | undefined;
68
- set label(l: import("./types").Label | undefined);
47
+ get ruleEngine(): import("./rules/RuleEngine.js").default;
48
+ get label(): import("./types/Json.js").Label | undefined;
49
+ set label(l: import("./types/Json.js").Label | undefined);
69
50
  get uniqueItems(): boolean | undefined;
70
- /**
71
- * Transparent form fields are meant only for creation of view. They are also not part of data
72
- */
73
51
  isTransparent(): boolean;
74
52
  getState(): T & {
75
53
  properties: {
@@ -80,49 +58,25 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
80
58
  qualifiedName: any;
81
59
  events: {};
82
60
  rules: {};
61
+ repeatable: boolean | undefined;
83
62
  ':type': string;
84
63
  id: string;
85
64
  };
86
- /**
87
- * @private
88
- */
89
65
  subscribe(callback: callbackFn, eventName?: string): {
90
66
  unsubscribe: () => void;
91
67
  };
92
- /**
93
- * @private
94
- */
95
68
  _addDependent(dependent: BaseModel): void;
96
- /**
97
- * @private
98
- */
99
69
  removeDependent(dependent: BaseModel): void;
100
70
  abstract validate(): Array<ValidationError>;
101
71
  abstract executeAction(action: Action): any;
102
- /**
103
- * @private
104
- */
105
72
  queueEvent(action: Action): void;
106
73
  dispatch(action: Action): void;
107
- /**
108
- * @private
109
- */
110
74
  notifyDependents(action: Action): void;
111
- /**
112
- * @param prop
113
- * @param newValue
114
- * @private
115
- */
116
75
  _setProperty<T>(prop: string, newValue: T, notify?: boolean): any;
117
- /**
118
- * @private
119
- */
120
76
  _bindToDataModel(contextualDataModel: DataGroup): void;
121
77
  private _data?;
122
- /**
123
- * @private
124
- */
125
78
  getDataNode(): DataValue | undefined;
79
+ get language(): string | undefined;
126
80
  get properties(): {
127
81
  [key: string]: any;
128
82
  };
@@ -132,18 +86,7 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
132
86
  abstract defaultDataModel(name: string | number): DataValue | undefined;
133
87
  abstract importData(a: DataGroup): any;
134
88
  getNonTransparentParent(): ContainerModel;
135
- /**
136
- * called after the node is inserted in the parent
137
- * @private
138
- */
139
89
  _initialize(): void;
140
- /**
141
- * Checks whether there are any updates in the properties. If there are applies them to the
142
- * json model as well.
143
- * @param propNames
144
- * @param updates
145
- * @private
146
- */
147
90
  protected _applyUpdates(propNames: string[], updates: any): any;
148
91
  get qualifiedName(): any;
149
92
  focus(): void;
@@ -1,29 +1,13 @@
1
- "use strict";
2
- /*
3
- * Copyright 2022 Adobe, Inc.
4
- *
5
- * Your access and use of this software is governed by the Adobe Customer Feedback Program Terms and Conditions or other Beta License Agreement signed by your employer and Adobe, Inc.. This software is NOT open source and may not be used without one of the foregoing licenses. Even with a foregoing license, your access and use of this file is limited to the earlier of (a) 180 days, (b) general availability of the product(s) which utilize this software (i.e. AEM Forms), (c) January 1, 2023, (d) Adobe providing notice to you that you may no longer use the software or that your beta trial has otherwise ended.
6
- *
7
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ADOBE NOR ITS THIRD PARTY PROVIDERS AND PARTNERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
- */
9
1
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
10
2
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
11
3
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
12
4
  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;
13
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
14
6
  };
15
- var __importDefault = (this && this.__importDefault) || function (mod) {
16
- return (mod && mod.__esModule) ? mod : { "default": mod };
17
- };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.BaseNode = exports.exclude = exports.include = exports.dependencyTracked = exports.qualifiedName = exports.target = exports.staticFields = exports.dynamicProps = exports.editableProperties = void 0;
20
- const controller_1 = require("./controller");
21
- const DataRefParser_1 = require("./utils/DataRefParser");
22
- const EmptyDataValue_1 = __importDefault(require("./data/EmptyDataValue"));
23
- /**
24
- * Defines the properties that are editable. These properties can be modified during rule execution.
25
- */
26
- exports.editableProperties = [
7
+ import { ExecuteRule, propertyChange } from './controller/Events.js';
8
+ import { resolveData, TOK_GLOBAL, tokenize } from './utils/DataRefParser.js';
9
+ import NullDataValue from './data/EmptyDataValue.js';
10
+ export const editableProperties = [
27
11
  'value',
28
12
  'label',
29
13
  'description',
@@ -34,39 +18,23 @@ exports.editableProperties = [
34
18
  'enumNames',
35
19
  'required',
36
20
  'properties',
37
- // 'enforceEnum', // not exposed for now
38
21
  'exclusiveMinimum',
39
22
  'exclusiveMaximum',
40
- // 'maxLength',
41
23
  'maximum',
42
24
  'maxItems',
43
- // 'minLength',
44
25
  'minimum',
45
26
  'minItems'
46
- // 'step'
47
- // 'placeholder' // not exposed for now.
48
27
  ];
49
- /**
50
- * Defines props that are dynamic and can be changed at runtime.
51
- */
52
- exports.dynamicProps = [
53
- ...exports.editableProperties,
28
+ export const dynamicProps = [
29
+ ...editableProperties,
54
30
  'valid',
55
31
  'index',
56
32
  'activeChild'
57
33
  ];
58
- exports.staticFields = ['plain-text', 'image'];
59
- /**
60
- * Implementation of action with target
61
- * @private
62
- */
34
+ export const staticFields = ['plain-text', 'image'];
63
35
  class ActionImplWithTarget {
64
- /**
65
- * @constructor
66
- * @param _action
67
- * @param _target
68
- * @private
69
- */
36
+ _action;
37
+ _target;
70
38
  constructor(_action, _target) {
71
39
  this._action = _action;
72
40
  this._target = _target;
@@ -93,26 +61,23 @@ class ActionImplWithTarget {
93
61
  return this._action.toString();
94
62
  }
95
63
  }
96
- exports.target = Symbol('target');
97
- exports.qualifiedName = Symbol('qualifiedName');
98
- function dependencyTracked() {
64
+ export const target = Symbol('target');
65
+ export const qualifiedName = Symbol('qualifiedName');
66
+ export function dependencyTracked() {
99
67
  return function (target, propertyKey, descriptor) {
100
68
  const get = descriptor.get;
101
69
  if (get != undefined) {
102
70
  descriptor.get = function () {
103
- // @ts-ignore
104
71
  this.ruleEngine.trackDependency(this);
105
72
  return get.call(this);
106
73
  };
107
74
  }
108
75
  };
109
76
  }
110
- exports.dependencyTracked = dependencyTracked;
111
77
  const addOnly = (includeOrExclude) => (...fieldTypes) => (target, propertyKey, descriptor) => {
112
78
  const get = descriptor.get;
113
79
  if (get != undefined) {
114
80
  descriptor.get = function () {
115
- // @ts-ignore
116
81
  if (fieldTypes.indexOf(this.fieldType) > -1 === includeOrExclude) {
117
82
  return get.call(this);
118
83
  }
@@ -122,44 +87,34 @@ const addOnly = (includeOrExclude) => (...fieldTypes) => (target, propertyKey, d
122
87
  const set = descriptor.set;
123
88
  if (set != undefined) {
124
89
  descriptor.set = function (value) {
125
- // @ts-ignore
126
90
  if (fieldTypes.indexOf(this.fieldType) > -1 === includeOrExclude) {
127
91
  set.call(this, value);
128
92
  }
129
93
  };
130
94
  }
131
95
  };
132
- exports.include = addOnly(true);
133
- exports.exclude = addOnly(false);
134
- /**
135
- * Defines a generic base class which all objects of form runtime model should extend from.
136
- * @typeparam T type of the form object which extends from {@link BaseJson | base type}
137
- */
138
- class BaseNode {
139
- /**
140
- * @constructor
141
- * @param params
142
- * @param _options
143
- * @private
144
- */
145
- constructor(params,
146
- //@ts_ignore
147
- _options) {
148
- this._options = _options;
149
- this._callbacks = {};
150
- this._dependents = [];
151
- this._tokens = [];
152
- //@ts-ignore
153
- this[exports.qualifiedName] = null;
154
- this._jsonModel = Object.assign(Object.assign({}, params), {
155
- //@ts-ignore
156
- id: 'id' in params ? params.id : this.form.getUniqueId() });
157
- }
96
+ export const include = addOnly(true);
97
+ export const exclude = addOnly(false);
98
+ export class BaseNode {
99
+ _options;
100
+ _ruleNode;
101
+ _lang = '';
102
+ _callbacks = {};
103
+ _dependents = [];
104
+ _jsonModel;
105
+ _tokens = [];
158
106
  get isContainer() {
159
107
  return false;
160
108
  }
109
+ constructor(params, _options) {
110
+ this._options = _options;
111
+ this[qualifiedName] = null;
112
+ this._jsonModel = {
113
+ ...params,
114
+ id: 'id' in params ? params.id : this.form.getUniqueId()
115
+ };
116
+ }
161
117
  setupRuleNode() {
162
- // eslint-disable-next-line @typescript-eslint/no-this-alias
163
118
  const self = this;
164
119
  this._ruleNode = new Proxy(this.ruleNodeReference(), {
165
120
  get: (ruleNodeReference, prop) => {
@@ -167,15 +122,9 @@ class BaseNode {
167
122
  }
168
123
  });
169
124
  }
170
- /**
171
- * @private
172
- */
173
125
  ruleNodeReference() {
174
126
  return this;
175
127
  }
176
- /**
177
- * @private
178
- */
179
128
  getRuleNode() {
180
129
  return this._ruleNode;
181
130
  }
@@ -183,26 +132,18 @@ class BaseNode {
183
132
  if (prop === Symbol.toPrimitive || (prop === 'valueOf' && !ruleNodeReference.hasOwnProperty('valueOf'))) {
184
133
  return this.valueOf;
185
134
  }
186
- else if (prop === exports.target) {
135
+ else if (prop === target) {
187
136
  return this;
188
137
  }
189
138
  else if (typeof (prop) === 'string') {
190
- //look for property
191
139
  if (prop.startsWith('$')) {
192
140
  prop = prop.substr(1);
193
- //@ts-ignore
194
- //@todo: create a list of properties that are allowed
195
- //@ts-ignore
196
- // return only non functional properties in this object
197
141
  if (typeof this[prop] !== 'function') {
198
- //@ts-ignore
199
142
  const retValue = this[prop];
200
143
  if (retValue instanceof BaseNode) {
201
- //$parent
202
144
  return retValue.getRuleNode();
203
145
  }
204
146
  else if (retValue instanceof Array) {
205
- //$items
206
147
  return retValue.map(r => r instanceof BaseNode ? r.getRuleNode() : r);
207
148
  }
208
149
  else {
@@ -211,12 +152,10 @@ class BaseNode {
211
152
  }
212
153
  }
213
154
  else {
214
- //look in the items
215
155
  if (ruleNodeReference.hasOwnProperty(prop)) {
216
156
  return ruleNodeReference[prop];
217
157
  }
218
- else if (typeof ruleNodeReference[prop] === 'function') { //todo : create allow list of functions
219
- //to support panel instanceof Array panel1.map(..)
158
+ else if (typeof ruleNodeReference[prop] === 'function') {
220
159
  return ruleNodeReference[prop];
221
160
  }
222
161
  }
@@ -237,6 +176,9 @@ class BaseNode {
237
176
  get type() {
238
177
  return this._jsonModel.type;
239
178
  }
179
+ get repeatable() {
180
+ return this.parent?.hasDynamicItems();
181
+ }
240
182
  get fieldType() {
241
183
  return this._jsonModel.fieldType || 'text-input';
242
184
  }
@@ -260,7 +202,7 @@ class BaseNode {
260
202
  }
261
203
  set visible(v) {
262
204
  if (v !== this._jsonModel.visible) {
263
- const changeAction = (0, controller_1.propertyChange)('visible', v, this._jsonModel.visible);
205
+ const changeAction = propertyChange('visible', v, this._jsonModel.visible);
264
206
  this._jsonModel.visible = v;
265
207
  this.notifyDependents(changeAction);
266
208
  }
@@ -276,64 +218,58 @@ class BaseNode {
276
218
  }
277
219
  set label(l) {
278
220
  if (l !== this._jsonModel.label) {
279
- const changeAction = (0, controller_1.propertyChange)('label', l, this._jsonModel.label);
280
- this._jsonModel = Object.assign(Object.assign({}, this._jsonModel), { label: l });
221
+ const changeAction = propertyChange('label', l, this._jsonModel.label);
222
+ this._jsonModel = {
223
+ ...this._jsonModel,
224
+ label: l
225
+ };
281
226
  this.notifyDependents(changeAction);
282
227
  }
283
228
  }
284
229
  get uniqueItems() {
285
230
  return this._jsonModel.uniqueItems;
286
231
  }
287
- /**
288
- * Transparent form fields are meant only for creation of view. They are also not part of data
289
- */
290
232
  isTransparent() {
291
- var _a;
292
- // named form fields are not transparent
293
- // @ts-ignore
294
- // handling array use-case as items of array can be unnamed
295
- const isNonTransparent = ((_a = this.parent) === null || _a === void 0 ? void 0 : _a._jsonModel.type) === 'array';
233
+ const isNonTransparent = this.parent?._jsonModel.type === 'array';
296
234
  return !this._jsonModel.name && !isNonTransparent;
297
235
  }
298
236
  getState() {
299
- return Object.assign(Object.assign({}, this._jsonModel), { properties: this.properties, index: this.index, parent: undefined, qualifiedName: this.qualifiedName, events: {}, rules: {}, ':type': this[':type'] });
237
+ return {
238
+ ...this._jsonModel,
239
+ properties: this.properties,
240
+ index: this.index,
241
+ parent: undefined,
242
+ qualifiedName: this.qualifiedName,
243
+ events: {},
244
+ rules: {},
245
+ repeatable: this.repeatable === true ? true : undefined,
246
+ ':type': this[':type']
247
+ };
300
248
  }
301
- /**
302
- * @private
303
- */
304
249
  subscribe(callback, eventName = 'change') {
305
250
  this._callbacks[eventName] = this._callbacks[eventName] || [];
306
251
  this._callbacks[eventName].push(callback);
307
- //console.log(`subscription added : ${this._elem.id}, count : ${this._callbacks[eventName].length}`);
308
252
  return {
309
253
  unsubscribe: () => {
310
254
  this._callbacks[eventName] = this._callbacks[eventName].filter(x => x !== callback);
311
- //console.log(`subscription removed : ${this._elem.id}, count : ${this._callbacks[eventName].length}`);
312
255
  }
313
256
  };
314
257
  }
315
- /**
316
- * @private
317
- */
318
258
  _addDependent(dependent) {
319
259
  if (this._dependents.find(({ node }) => node === dependent) === undefined) {
320
260
  const subscription = this.subscribe((change) => {
321
261
  const changes = change.payload.changes;
322
- const propsToLook = [...exports.dynamicProps, 'items'];
323
- // @ts-ignore
262
+ const propsToLook = [...dynamicProps, 'items'];
324
263
  const isPropChanged = changes.findIndex(x => {
325
264
  return propsToLook.indexOf(x.propertyName) > -1;
326
265
  }) > -1;
327
266
  if (isPropChanged) {
328
- dependent.dispatch(new controller_1.ExecuteRule());
267
+ dependent.dispatch(new ExecuteRule());
329
268
  }
330
269
  });
331
270
  this._dependents.push({ node: dependent, subscription });
332
271
  }
333
272
  }
334
- /**
335
- * @private
336
- */
337
273
  removeDependent(dependent) {
338
274
  const index = this._dependents.findIndex(({ node }) => node === dependent);
339
275
  if (index > -1) {
@@ -341,9 +277,6 @@ class BaseNode {
341
277
  this._dependents.splice(index, 1);
342
278
  }
343
279
  }
344
- /**
345
- * @private
346
- */
347
280
  queueEvent(action) {
348
281
  const actionWithTarget = new ActionImplWithTarget(action, this);
349
282
  this.form.getEventQueue().queue(this, actionWithTarget, ['valid', 'invalid'].indexOf(actionWithTarget.type) > -1);
@@ -352,22 +285,13 @@ class BaseNode {
352
285
  this.queueEvent(action);
353
286
  this.form.getEventQueue().runPendingQueue();
354
287
  }
355
- /**
356
- * @private
357
- */
358
288
  notifyDependents(action) {
359
289
  const handlers = this._callbacks[action.type] || [];
360
290
  handlers.forEach(x => {
361
291
  x(new ActionImplWithTarget(action, this));
362
292
  });
363
293
  }
364
- /**
365
- * @param prop
366
- * @param newValue
367
- * @private
368
- */
369
294
  _setProperty(prop, newValue, notify = true) {
370
- //@ts-ignore
371
295
  const oldValue = this._jsonModel[prop];
372
296
  let isValueSame = false;
373
297
  if (newValue !== null && oldValue !== null &&
@@ -375,13 +299,11 @@ class BaseNode {
375
299
  isValueSame = JSON.stringify(newValue) === JSON.stringify(oldValue);
376
300
  }
377
301
  else {
378
- // @ts-ignore
379
302
  isValueSame = oldValue === newValue;
380
303
  }
381
304
  if (!isValueSame) {
382
- //@ts-ignore
383
305
  this._jsonModel[prop] = newValue;
384
- const changeAction = (0, controller_1.propertyChange)(prop, newValue, oldValue);
306
+ const changeAction = propertyChange(prop, newValue, oldValue);
385
307
  if (notify) {
386
308
  this.notifyDependents(changeAction);
387
309
  }
@@ -389,9 +311,6 @@ class BaseNode {
389
311
  }
390
312
  return [];
391
313
  }
392
- /**
393
- * @private
394
- */
395
314
  _bindToDataModel(contextualDataModel) {
396
315
  if (this.id === '$form') {
397
316
  this._data = contextualDataModel;
@@ -399,30 +318,27 @@ class BaseNode {
399
318
  }
400
319
  const dataRef = this._jsonModel.dataRef;
401
320
  let _data, _parent = contextualDataModel, _key = '';
402
- if (dataRef === null) { // null data binding
403
- _data = EmptyDataValue_1.default;
321
+ if (dataRef === null) {
322
+ _data = NullDataValue;
404
323
  }
405
- else if (dataRef !== undefined) { // explicit data binding
324
+ else if (dataRef !== undefined) {
406
325
  if (this._tokens.length === 0) {
407
- this._tokens = (0, DataRefParser_1.tokenize)(dataRef);
326
+ this._tokens = tokenize(dataRef);
408
327
  }
409
328
  let searchData = contextualDataModel;
410
- if (this._tokens[0].type === DataRefParser_1.TOK_GLOBAL) {
329
+ if (this._tokens[0].type === TOK_GLOBAL) {
411
330
  searchData = this.form.getDataNode();
412
331
  }
413
332
  if (typeof searchData !== 'undefined') {
414
333
  const name = this._tokens[this._tokens.length - 1].value;
415
334
  const create = this.defaultDataModel(name);
416
- _data = (0, DataRefParser_1.resolveData)(searchData, this._tokens, create);
417
- // @ts-ignore
418
- _parent = (0, DataRefParser_1.resolveData)(searchData, this._tokens.slice(0, -1));
335
+ _data = resolveData(searchData, this._tokens, create);
336
+ _parent = resolveData(searchData, this._tokens.slice(0, -1));
419
337
  _key = name;
420
338
  }
421
339
  }
422
- else { // name data binding
423
- // static fields do not have name bindings
424
- if ( //@ts-ignore
425
- contextualDataModel !== EmptyDataValue_1.default && exports.staticFields.indexOf(this.fieldType) === -1) {
340
+ else {
341
+ if (contextualDataModel !== NullDataValue && staticFields.indexOf(this.fieldType) === -1) {
426
342
  _parent = contextualDataModel;
427
343
  const name = this._jsonModel.name || '';
428
344
  const key = contextualDataModel.$type === 'array' ? this.index : name;
@@ -443,26 +359,34 @@ class BaseNode {
443
359
  }
444
360
  }
445
361
  if (_data) {
446
- //@ts-ignore
447
- if (!this.isContainer && _parent !== EmptyDataValue_1.default && _data !== EmptyDataValue_1.default) {
448
- _data = _data === null || _data === void 0 ? void 0 : _data.$convertToDataValue();
362
+ if (!this.isContainer && _parent !== NullDataValue && _data !== NullDataValue) {
363
+ _data = _data?.$convertToDataValue();
449
364
  _parent.$addDataNode(_key, _data, true);
450
365
  }
451
- _data === null || _data === void 0 ? void 0 : _data.$bindToField(this);
366
+ _data?.$bindToField(this);
452
367
  this._data = _data;
453
368
  }
454
369
  }
455
- /**
456
- * @private
457
- */
370
+ _data;
458
371
  getDataNode() {
459
372
  return this._data;
460
373
  }
374
+ get language() {
375
+ if (!this._lang) {
376
+ if (this.parent) {
377
+ this._lang = this.parent.language;
378
+ }
379
+ else {
380
+ this._lang = Intl.DateTimeFormat().resolvedOptions().locale;
381
+ }
382
+ }
383
+ return this._lang;
384
+ }
461
385
  get properties() {
462
386
  return this._jsonModel.properties || {};
463
387
  }
464
388
  set properties(p) {
465
- this._setProperty('properties', Object.assign({}, p));
389
+ this._setProperty('properties', { ...p });
466
390
  }
467
391
  getNonTransparentParent() {
468
392
  let nonTransparentParent = this.parent;
@@ -471,31 +395,18 @@ class BaseNode {
471
395
  }
472
396
  return nonTransparentParent;
473
397
  }
474
- /**
475
- * called after the node is inserted in the parent
476
- * @private
477
- */
478
398
  _initialize() {
479
399
  if (typeof this._data === 'undefined') {
480
400
  let dataNode, parent = this.parent;
481
401
  do {
482
- //@ts-ignore
483
402
  dataNode = parent.getDataNode();
484
403
  parent = parent.parent;
485
404
  } while (dataNode === undefined);
486
405
  this._bindToDataModel(dataNode);
487
406
  }
488
407
  }
489
- /**
490
- * Checks whether there are any updates in the properties. If there are applies them to the
491
- * json model as well.
492
- * @param propNames
493
- * @param updates
494
- * @private
495
- */
496
408
  _applyUpdates(propNames, updates) {
497
409
  return propNames.reduce((acc, propertyName) => {
498
- //@ts-ignore
499
410
  const currentValue = updates[propertyName];
500
411
  const changes = this._setProperty(propertyName, currentValue, false);
501
412
  if (changes.length > 0) {
@@ -508,23 +419,17 @@ class BaseNode {
508
419
  if (this.isTransparent()) {
509
420
  return null;
510
421
  }
511
- // @ts-ignore
512
- if (this[exports.qualifiedName] !== null) {
513
- // @ts-ignore
514
- return this[exports.qualifiedName];
422
+ if (this[qualifiedName] !== null) {
423
+ return this[qualifiedName];
515
424
  }
516
- // use qualified name
517
425
  const parent = this.getNonTransparentParent();
518
426
  if (parent && parent.type === 'array') {
519
- //@ts-ignore
520
- this[exports.qualifiedName] = `${parent.qualifiedName}[${this.index}]`;
427
+ this[qualifiedName] = `${parent.qualifiedName}[${this.index}]`;
521
428
  }
522
429
  else {
523
- //@ts-ignore
524
- this[exports.qualifiedName] = `${parent.qualifiedName}.${this.name}`;
430
+ this[qualifiedName] = `${parent.qualifiedName}.${this.name}`;
525
431
  }
526
- //@ts-ignore
527
- return this[exports.qualifiedName];
432
+ return this[qualifiedName];
528
433
  }
529
434
  focus() {
530
435
  if (this.parent) {
@@ -547,4 +452,3 @@ __decorate([
547
452
  __decorate([
548
453
  dependencyTracked()
549
454
  ], BaseNode.prototype, "properties", null);
550
- exports.BaseNode = BaseNode;