@bolttech/form-engine-core 0.0.1-beta.41 → 0.0.1-beta.43

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/index.esm.js CHANGED
@@ -140,45 +140,31 @@ function extractFieldKeys(expression) {
140
140
  * // expressions will contain an array of objects with origin expressions, field keys, and destination paths.
141
141
  * ```
142
142
  */
143
- function traverseObject(obj, path) {
143
+ function traverseObject(element, path) {
144
144
  const result = [];
145
- for (const key in obj) {
146
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
147
- const value = obj[key];
148
- if (Array.isArray(value)) {
149
- value.forEach((item, index) => {
150
- if (typeof item === 'object') {
151
- result.push(...traverseObject(item, `${path ? `${path}.` : ``}${key}.${index}`));
152
- } else if (typeof item === 'string') {
153
- if (String(item).includes('${')) {
154
- // const extractedPath = item.replace(/\$|{|}/g, '').split('.');
155
- const extractedOriginPath = `${path ? `${path}.` : ``}${key}`.split('.');
156
- result.push(Object.assign(Object.assign({
157
- originExpression: item
158
- }, extractFieldKeys(item)), {
159
- destinationKey: extractedOriginPath[0],
160
- destinationProperty: extractedOriginPath[1],
161
- destinationPath: extractedOriginPath.slice(2)
162
- }));
163
- }
164
- }
165
- });
166
- } else if (typeof value === 'object') {
145
+ if (Array.isArray(element)) {
146
+ element.forEach((item, index) => {
147
+ result.push(...traverseObject(item, `${path ? `${path}.` : ``}${index}`));
148
+ });
149
+ } else if (typeof element === 'object') {
150
+ for (const key in element) {
151
+ if (Object.prototype.hasOwnProperty.call(element, key)) {
152
+ const value = element[key];
167
153
  result.push(...traverseObject(value, `${path ? `${path}.` : ``}${key}`));
168
- } else if (typeof value === 'string') {
169
- if (value.includes('${')) {
170
- // const extractedPath = value.replace(/\$|{|}/g, '').split('.');
171
- const destinationPath = `${path ? `${path}.` : ``}${key}`.split('.');
172
- result.push(Object.assign(Object.assign({
173
- originExpression: value
174
- }, extractFieldKeys(value)), {
175
- destinationKey: destinationPath[0],
176
- destinationProperty: destinationPath[1],
177
- destinationPath: destinationPath.slice(2)
178
- }));
179
- }
180
154
  }
181
155
  }
156
+ } else if (typeof element === 'string') {
157
+ if (element.includes('${')) {
158
+ // const extractedPath = value.replace(/\$|{|}/g, '').split('.');
159
+ const destinationPath = (path ? path : '').split('.');
160
+ result.push(Object.assign(Object.assign({
161
+ originExpression: element
162
+ }, extractFieldKeys(element)), {
163
+ destinationKey: destinationPath[0],
164
+ destinationProperty: destinationPath[1],
165
+ destinationPath: destinationPath.slice(2)
166
+ }));
167
+ }
182
168
  }
183
169
  return result;
184
170
  }
@@ -2448,6 +2434,7 @@ class FormField {
2448
2434
  mapper
2449
2435
  }) {
2450
2436
  var _a, _b, _c, _d, _e, _f, _g;
2437
+ this.valueSubscription$ = new Subscription();
2451
2438
  this.fieldStateSubscription$ = new Subscription();
2452
2439
  this.originalSchema = schemaComponent;
2453
2440
  this.config = {
@@ -3014,6 +3001,7 @@ class FormCore {
3014
3001
  */
3015
3002
  constructor(entry) {
3016
3003
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3004
+ this.templateSubscription$ = new Subscription();
3017
3005
  this.mappers = new Map();
3018
3006
  this.schema = entry.schema;
3019
3007
  this.fields = new Map();
@@ -3037,7 +3025,7 @@ class FormCore {
3037
3025
  this.subscribedTemplates = [];
3038
3026
  this.schema && this.serializeStructure(this.schema.components);
3039
3027
  this.schema && this.subscribeTemplates();
3040
- this.templateSubscription = this.templateSubject$.subscribe(this.refreshTemplates.bind(this));
3028
+ this.templateSubscription$ = this.templateSubject$.subscribe(this.refreshTemplates.bind(this));
3041
3029
  this.templateSubject$.next({
3042
3030
  key: IVARPROPNAME,
3043
3031
  event: 'ON_IVARS'
@@ -3673,7 +3661,7 @@ class FormCore {
3673
3661
  }
3674
3662
  destroy() {
3675
3663
  this.submitSubject$.unsubscribe();
3676
- this.templateSubscription.unsubscribe();
3664
+ this.templateSubscription$.unsubscribe();
3677
3665
  this.fieldEventSubject$.unsubscribe();
3678
3666
  this.dataSubject$.unsubscribe();
3679
3667
  this.fields.forEach(field => field.destroyField());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolttech/form-engine-core",
3
- "version": "0.0.1-beta.41",
3
+ "version": "0.0.1-beta.43",
4
4
  "module": "./index.esm.js",
5
5
  "type": "module",
6
6
  "main": "./index.esm.js",
@@ -60,5 +60,5 @@ declare function extractFieldKeys(expression: string): {
60
60
  * // expressions will contain an array of objects with origin expressions, field keys, and destination paths.
61
61
  * ```
62
62
  */
63
- declare function traverseObject(obj: any, path?: string): TSubscribedTemplates[];
63
+ declare function traverseObject(element: any, path?: string): TSubscribedTemplates[];
64
64
  export { makeRequest, traverseObject, extractFieldKeys };
@@ -18,7 +18,7 @@ declare class FormCore {
18
18
  key: string;
19
19
  event: TMutationEvents;
20
20
  }>;
21
- templateSubscription: Subscription;
21
+ templateSubscription$: Subscription;
22
22
  submitSubject$: Subject<TFormValues<any>>;
23
23
  mountSubject$: Subject<TFormValues<any>>;
24
24
  fieldEventSubject$: Subject<TFieldEvent>;