@bolttech/form-engine-core 0.0.3-beta.5 → 1.0.0-beta.1
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 +19 -1
- package/package.json +1 -1
- package/src/managers/formGroup.d.ts +6 -1
- package/src/types/event.d.ts +6 -1
package/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Subject, Subscription, combineLatest, startWith, groupBy, mergeMap, debounceTime, filter, map, distinctUntilKeyChanged, distinctUntilChanged } from 'rxjs';
|
|
1
|
+
import { Subject, Subscription, combineLatest, startWith, groupBy, mergeMap, debounceTime, filter, map, distinctUntilKeyChanged, distinctUntilChanged, skip } from 'rxjs';
|
|
2
2
|
import creditCardType from 'credit-card-type';
|
|
3
3
|
import { isNumber as isNumber$1, isFunction, cloneDeep, isEqual, get, isNil, set } from 'lodash';
|
|
4
4
|
import { getCurrencySymbol } from '@gaignoux/currency';
|
|
@@ -4130,6 +4130,7 @@ class FormGroup {
|
|
|
4130
4130
|
/**
|
|
4131
4131
|
* Prototype submit function to multiple forms
|
|
4132
4132
|
* @param {string[]} indexes form indexes to be submitted
|
|
4133
|
+
* @param callback
|
|
4133
4134
|
* @returns
|
|
4134
4135
|
*/
|
|
4135
4136
|
submitMultipleFormsByIndex(indexes, callback) {
|
|
@@ -4203,6 +4204,23 @@ class FormGroup {
|
|
|
4203
4204
|
}))).subscribe(callback);
|
|
4204
4205
|
return sub;
|
|
4205
4206
|
}
|
|
4207
|
+
onSubmitSubscription({
|
|
4208
|
+
ids,
|
|
4209
|
+
callback
|
|
4210
|
+
}) {
|
|
4211
|
+
const subs = ids.reduce((acc, formId) => {
|
|
4212
|
+
const form = this.forms.get(formId);
|
|
4213
|
+
const sub = form === null || form === void 0 ? void 0 : form.submitSubject$.pipe(map(() => form === null || form === void 0 ? void 0 : form.getFormValues()), startWith(undefined));
|
|
4214
|
+
if (sub) {
|
|
4215
|
+
acc[formId] = sub;
|
|
4216
|
+
} else {
|
|
4217
|
+
this.config.defaultLogVerbose && console.warn(`failed to register form id ${formId}`);
|
|
4218
|
+
}
|
|
4219
|
+
return acc;
|
|
4220
|
+
}, {});
|
|
4221
|
+
const sub = combineLatest(subs).pipe(skip(1)).subscribe(callback);
|
|
4222
|
+
return sub;
|
|
4223
|
+
}
|
|
4206
4224
|
}
|
|
4207
4225
|
|
|
4208
4226
|
export { FormCore, FormField, FormGroup, TMutationEnum };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { TFormValues } from '../types/form';
|
|
|
2
2
|
import { TMapper } from '../types/mapper';
|
|
3
3
|
import { TFormCore } from './form';
|
|
4
4
|
import { TSchemaFormConfig } from '../types/schema';
|
|
5
|
-
import { TFormGroupOnDataEventPayload, TFormGroupOnValidEventPayload } from '../types/event';
|
|
5
|
+
import { TFormGroupOnDataEventPayload, TFormGroupOnSubmitEventPayload, TFormGroupOnValidEventPayload } from '../types/event';
|
|
6
6
|
/**
|
|
7
7
|
* Represents a group that manages multiple forms.
|
|
8
8
|
*/
|
|
@@ -82,6 +82,7 @@ declare class FormGroup {
|
|
|
82
82
|
/**
|
|
83
83
|
* Prototype submit function to multiple forms
|
|
84
84
|
* @param {string[]} indexes form indexes to be submitted
|
|
85
|
+
* @param callback
|
|
85
86
|
* @returns
|
|
86
87
|
*/
|
|
87
88
|
submitMultipleFormsByIndex<T>(indexes: string[], callback?: (payload: TFormValues<T>) => void): void;
|
|
@@ -93,6 +94,10 @@ declare class FormGroup {
|
|
|
93
94
|
ids: string[];
|
|
94
95
|
callback: (payload: TFormGroupOnValidEventPayload) => void;
|
|
95
96
|
}): import("rxjs").Subscription;
|
|
97
|
+
onSubmitSubscription<T>({ ids, callback, }: {
|
|
98
|
+
ids: string[];
|
|
99
|
+
callback: (payload: TFormGroupOnSubmitEventPayload<T>) => void;
|
|
100
|
+
}): import("rxjs").Subscription;
|
|
96
101
|
destroy: () => void;
|
|
97
102
|
}
|
|
98
103
|
type TFormGroup = FormGroup;
|
package/src/types/event.d.ts
CHANGED
|
@@ -76,4 +76,9 @@ type TFormGroupOnValidEventPayload = {
|
|
|
76
76
|
groupValid: boolean;
|
|
77
77
|
forms: Record<string, boolean>;
|
|
78
78
|
};
|
|
79
|
-
|
|
79
|
+
/**
|
|
80
|
+
* @type TFormGroupOnSubmitEventPayload
|
|
81
|
+
* Form Group onSubmit event emitted payload on callback function parameter
|
|
82
|
+
*/
|
|
83
|
+
type TFormGroupOnSubmitEventPayload<T> = Record<string, TFormValues<T> | undefined>;
|
|
84
|
+
export { TEvents, TMutationEvents, TMutationEnum, TValueChangeEvent, TFieldEvent, TFormGroupOnDataEventPayload, TFormGroupOnValidEventPayload, TFormGroupOnSubmitEventPayload, TFormValidationPayload, };
|