@bolttech/form-engine-core 1.0.3 → 1.0.4
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.d.ts +21 -5
- package/index.esm.js +15 -4
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -226,12 +226,21 @@ interface IFormSchema {
|
|
|
226
226
|
stopEventsOnSubmit?: boolean;
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
+
/**
|
|
230
|
+
* @type TFieldBinding
|
|
231
|
+
* settings from the field's location and value when valid.
|
|
232
|
+
*/
|
|
233
|
+
type TFieldBinding = {
|
|
234
|
+
path?: string;
|
|
235
|
+
value?: unknown;
|
|
236
|
+
};
|
|
229
237
|
/**
|
|
230
238
|
* @type TFormValues<T>
|
|
231
239
|
* Represents the values and state of a form. It has a generic type that allows the importer to determine which type values key will return.
|
|
232
240
|
*
|
|
233
241
|
* @property {Generic Type} values - The current values of the form fields.
|
|
234
242
|
* @property {string[]} erroredFields - A list of field names that have errors.
|
|
243
|
+
* @property {TFieldBinding} bindFields - A list of field names that have bind values with their path to submit.
|
|
235
244
|
* @property {boolean} isValid - Indicates whether the form is valid.
|
|
236
245
|
*
|
|
237
246
|
* @example
|
|
@@ -239,6 +248,7 @@ interface IFormSchema {
|
|
|
239
248
|
* const formValues: TFormValues = {
|
|
240
249
|
* values: { name: 'John', age: 30 },
|
|
241
250
|
* erroredFields: ['email'],
|
|
251
|
+
* bindFields: { path: 'field/name', value: 'John' },
|
|
242
252
|
* isValid: false
|
|
243
253
|
* };
|
|
244
254
|
* ```
|
|
@@ -247,6 +257,7 @@ type TFormValues<T> = {
|
|
|
247
257
|
values: T;
|
|
248
258
|
metadata: unknown;
|
|
249
259
|
erroredFields: string[];
|
|
260
|
+
bindFields?: TFieldBinding;
|
|
250
261
|
isValid: boolean;
|
|
251
262
|
};
|
|
252
263
|
/**
|
|
@@ -2019,10 +2030,7 @@ declare class FormCore {
|
|
|
2019
2030
|
*
|
|
2020
2031
|
* @param {(payload: { field: string; data: TFormValues }) => void} callback callback function to call onData
|
|
2021
2032
|
*/
|
|
2022
|
-
subscribeData<T>(callback: (payload:
|
|
2023
|
-
field: string;
|
|
2024
|
-
data: TFormValues<T>;
|
|
2025
|
-
}) => void): Subscription;
|
|
2033
|
+
subscribeData<T>(callback: (payload: TFormOnDataEventPayload<T>) => void): Subscription;
|
|
2026
2034
|
/**
|
|
2027
2035
|
* method to register a callback function to be called when the form is valid
|
|
2028
2036
|
*
|
|
@@ -2309,6 +2317,14 @@ type TFormDataValues<T> = {
|
|
|
2309
2317
|
* Form Group onData event emitted payload on callback function parameter
|
|
2310
2318
|
*/
|
|
2311
2319
|
type TFormGroupOnDataEventPayload<T> = Record<string, TFormDataValues<T>>;
|
|
2320
|
+
/**
|
|
2321
|
+
* @type TFormOnDataEventPayload
|
|
2322
|
+
* Form onData event emitted payload on callback function parameter
|
|
2323
|
+
*/
|
|
2324
|
+
type TFormOnDataEventPayload<T> = {
|
|
2325
|
+
field: string;
|
|
2326
|
+
data: TFormValues<T>;
|
|
2327
|
+
};
|
|
2312
2328
|
/**
|
|
2313
2329
|
* @type TFormGroupOnValidEventPayload
|
|
2314
2330
|
* Form Group onValid event emitted payload on callback function parameter
|
|
@@ -2324,4 +2340,4 @@ type TFormGroupOnValidEventPayload = {
|
|
|
2324
2340
|
type TFormGroupOnSubmitEventPayload<T> = Record<string, TFormValues<T> | undefined>;
|
|
2325
2341
|
|
|
2326
2342
|
export { FormCore, FormField, FormGroup, TMutationEnum };
|
|
2327
|
-
export type { AllowOnly, IComponentSchema, IComponentSchemaAsFormField, IFormField, IFormSchema, IState, OneOf, TAllowedResetPropsMutationsEnum, TApiConfig, TApiEvent, TApiResponse, TApiResponsePayload, TAvailableValidations, TBetweenDatesValidation, TBetweenValidation, TCallbackValidation, TComponentPropsMapping, TConditionsValidation, TConditionsValidationSet, TCreditCardMatch, TCurrencyMask, TDateFormatsValidation, TDateInterval, TDateOperatorsValidation, TDateValidation, TDocumentValidation, TErrorMessages, TEvent, TEventDataProps, TEventDataPropsEnum, TEventEnum, TEventMessages, TEventMessagesValidationMethods, TEventProps, TEventPropsEnum, TEvents, TFieldEvent, TFieldValidationPayload, TFormCore, TFormDataPayload, TFormDataValues, TFormEntry, TFormGroup, TFormGroupOnDataEventPayload, TFormGroupOnSubmitEventPayload, TFormGroupOnValidEventPayload, TFormSubmitPayload, TFormValidationPayload, TFormValues, TFormatters, TGenericValidationRule, TLengthValidation, TMapper, TMaskGeneric, TMasks, TMultipleValidation, TMutationEvents, TProps, TResetPathMethods, TResetValueMethods, TSchemaFormConfig, TSchemaValidation, TSplitterFormatterValue, TSubscribedTemplates, TTemplateAvaliableScopes, TTemplateAvaliableScopesEnum, TTemplateEvent, TValidationHandler, TValidationMethods, TValidations, TValueChangeEvent, TVisibility };
|
|
2343
|
+
export type { AllowOnly, IComponentSchema, IComponentSchemaAsFormField, IFormField, IFormSchema, IState, OneOf, TAllowedResetPropsMutationsEnum, TApiConfig, TApiEvent, TApiResponse, TApiResponsePayload, TAvailableValidations, TBetweenDatesValidation, TBetweenValidation, TCallbackValidation, TComponentPropsMapping, TConditionsValidation, TConditionsValidationSet, TCreditCardMatch, TCurrencyMask, TDateFormatsValidation, TDateInterval, TDateOperatorsValidation, TDateValidation, TDocumentValidation, TErrorMessages, TEvent, TEventDataProps, TEventDataPropsEnum, TEventEnum, TEventMessages, TEventMessagesValidationMethods, TEventProps, TEventPropsEnum, TEvents, TFieldEvent, TFieldValidationPayload, TFormCore, TFormDataPayload, TFormDataValues, TFormEntry, TFormGroup, TFormGroupOnDataEventPayload, TFormGroupOnSubmitEventPayload, TFormGroupOnValidEventPayload, TFormOnDataEventPayload, TFormSubmitPayload, TFormValidationPayload, TFormValues, TFormatters, TGenericValidationRule, TLengthValidation, TMapper, TMaskGeneric, TMasks, TMultipleValidation, TMutationEvents, TProps, TResetPathMethods, TResetValueMethods, TSchemaFormConfig, TSchemaValidation, TSplitterFormatterValue, TSubscribedTemplates, TTemplateAvaliableScopes, TTemplateAvaliableScopesEnum, TTemplateEvent, TValidationHandler, TValidationMethods, TValidations, TValueChangeEvent, TVisibility };
|
package/index.esm.js
CHANGED
|
@@ -4110,7 +4110,9 @@ class FormCore {
|
|
|
4110
4110
|
const values = {};
|
|
4111
4111
|
const metadata = {};
|
|
4112
4112
|
const erroredFields = [];
|
|
4113
|
+
const bindFields = {};
|
|
4113
4114
|
this.fields.forEach((val, key) => {
|
|
4115
|
+
var _a;
|
|
4114
4116
|
if (!(typeof val.value === 'string' && val.value.length === 0) && typeof val.value !== 'undefined' && val.value !== null) {
|
|
4115
4117
|
set(values, val.nameToSubmit || key, val.value);
|
|
4116
4118
|
metadata[key] = val.metadata;
|
|
@@ -4118,11 +4120,18 @@ class FormCore {
|
|
|
4118
4120
|
if (!val.valid) {
|
|
4119
4121
|
erroredFields.push(key);
|
|
4120
4122
|
}
|
|
4123
|
+
if (val.nameToSubmit) {
|
|
4124
|
+
bindFields[key] = {
|
|
4125
|
+
path: (_a = val.nameToSubmit) === null || _a === void 0 ? void 0 : _a.replace('.', '/'),
|
|
4126
|
+
value: val.value
|
|
4127
|
+
};
|
|
4128
|
+
}
|
|
4121
4129
|
});
|
|
4122
4130
|
return {
|
|
4123
4131
|
values,
|
|
4124
4132
|
metadata,
|
|
4125
4133
|
erroredFields,
|
|
4134
|
+
bindFields,
|
|
4126
4135
|
isValid: this.valid
|
|
4127
4136
|
};
|
|
4128
4137
|
}
|
|
@@ -4161,10 +4170,12 @@ class FormCore {
|
|
|
4161
4170
|
formIndex
|
|
4162
4171
|
}) => this.index === formIndex && this.submitChecker()), groupBy(payload => payload.event), mergeMap(group$ => group$.pipe(debounceTime(this.config.defaultStateRefreshTimeMS))), map(({
|
|
4163
4172
|
fieldIndex
|
|
4164
|
-
}) =>
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4173
|
+
}) => {
|
|
4174
|
+
return {
|
|
4175
|
+
field: fieldIndex,
|
|
4176
|
+
data: this.getFormValues()
|
|
4177
|
+
};
|
|
4178
|
+
})).subscribe({
|
|
4168
4179
|
next: callback
|
|
4169
4180
|
});
|
|
4170
4181
|
return sub;
|