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