@bolttech/form-engine-core 1.0.0-beta.16 → 1.0.0-beta.18
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 +20 -15
- package/package.json +1 -1
- package/src/managers/field.d.ts +0 -1
- package/src/types/event.d.ts +2 -0
package/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Subject, Subscription, groupBy, mergeMap, debounceTime, filter, combineLatest, startWith, map, distinctUntilKeyChanged } from 'rxjs';
|
|
2
2
|
import creditCardType from 'credit-card-type';
|
|
3
|
-
import { isNumber as isNumber$1, isFunction, cloneDeep,
|
|
3
|
+
import { isNumber as isNumber$1, isFunction, cloneDeep, isEqual, get, isNil, set } from 'lodash';
|
|
4
4
|
import { getCurrencySymbol } from '@gaignoux/currency';
|
|
5
5
|
|
|
6
6
|
var TMutationEnum;
|
|
@@ -2504,7 +2504,7 @@ class FormField {
|
|
|
2504
2504
|
submitEvent,
|
|
2505
2505
|
visibility
|
|
2506
2506
|
}) {
|
|
2507
|
-
var _a, _b, _c, _d, _e, _f
|
|
2507
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2508
2508
|
this.valueSubscription$ = new Subscription();
|
|
2509
2509
|
this.fieldStateSubscription$ = new Subscription();
|
|
2510
2510
|
this.formIndex = formIndex;
|
|
@@ -2520,7 +2520,6 @@ class FormField {
|
|
|
2520
2520
|
this.path = path;
|
|
2521
2521
|
this.children = children;
|
|
2522
2522
|
this.validations = cloneDeep(schemaComponent.validations);
|
|
2523
|
-
this.errorMessages = cloneDeep((_a = schemaComponent.validations) === null || _a === void 0 ? void 0 : _a.messages);
|
|
2524
2523
|
this.visibilityConditions = cloneDeep(schemaComponent.visibilityConditions);
|
|
2525
2524
|
this.resetValues = cloneDeep(schemaComponent.resetValues);
|
|
2526
2525
|
this.resetPropertyValues = cloneDeep(schemaComponent.resetPropertyValues);
|
|
@@ -2528,7 +2527,7 @@ class FormField {
|
|
|
2528
2527
|
this.formatters = cloneDeep(schemaComponent.formatters);
|
|
2529
2528
|
this.masks = cloneDeep(schemaComponent.masks);
|
|
2530
2529
|
if (mapper.valueChangeEvent) this.valueChangeEvent = mapper.valueChangeEvent;
|
|
2531
|
-
if ((
|
|
2530
|
+
if ((_a = mapper.events) === null || _a === void 0 ? void 0 : _a.setValue) this.valuePropName = mapper.events.setValue;
|
|
2532
2531
|
this.mapper = mapper;
|
|
2533
2532
|
this.validateVisibility = validateVisibility;
|
|
2534
2533
|
this.resetValue = resetValue;
|
|
@@ -2547,10 +2546,10 @@ class FormField {
|
|
|
2547
2546
|
this._visibility = typeof visibility === 'boolean' ? visibility : true;
|
|
2548
2547
|
this._api = {
|
|
2549
2548
|
default: {
|
|
2550
|
-
response: ((
|
|
2549
|
+
response: ((_d = (_c = (_b = this.apiSchema) === null || _b === void 0 ? void 0 : _b.defaultConfig) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.fallbackValue) || '',
|
|
2551
2550
|
status: null
|
|
2552
2551
|
},
|
|
2553
|
-
named: ((
|
|
2552
|
+
named: ((_e = this.apiSchema) === null || _e === void 0 ? void 0 : _e.configs) && Object.keys((_f = this.apiSchema) === null || _f === void 0 ? void 0 : _f.configs).reduce((acc, curr) => {
|
|
2554
2553
|
var _a, _b;
|
|
2555
2554
|
acc[curr] = {
|
|
2556
2555
|
response: ((_b = (_a = this.apiSchema) === null || _a === void 0 ? void 0 : _a.configs) === null || _b === void 0 ? void 0 : _b[curr].config.fallbackValue) || '',
|
|
@@ -2611,9 +2610,8 @@ class FormField {
|
|
|
2611
2610
|
* @param {Record<string, unknown>} props - The new properties to be set.
|
|
2612
2611
|
*/
|
|
2613
2612
|
set props(props) {
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
this._props = diffProps;
|
|
2613
|
+
if (typeof props === 'undefined' || isEqual(props, this.props)) return;
|
|
2614
|
+
this._props = props;
|
|
2617
2615
|
this.propsSubject$.next(this.props);
|
|
2618
2616
|
this.templateSubject$.next({
|
|
2619
2617
|
scope: 'fields',
|
|
@@ -2632,6 +2630,7 @@ class FormField {
|
|
|
2632
2630
|
return props.filter(el => typeof el === 'string' && el.includes('${') ? false : true).map(el => FormField.filterProps(el));
|
|
2633
2631
|
}
|
|
2634
2632
|
if (typeof props === 'object' && props !== null) {
|
|
2633
|
+
if (props instanceof Date) return props;
|
|
2635
2634
|
return Object.keys(props).reduce((acc, curr) => {
|
|
2636
2635
|
const propValue = props[curr];
|
|
2637
2636
|
if (typeof propValue === 'string' && propValue.includes('${')) {
|
|
@@ -2947,16 +2946,17 @@ class FormField {
|
|
|
2947
2946
|
const errors = {};
|
|
2948
2947
|
const schemaValidations = (_a = this.validations) === null || _a === void 0 ? void 0 : _a.methods;
|
|
2949
2948
|
schemaValidations && Object.keys(schemaValidations).forEach(validationKey => {
|
|
2949
|
+
var _a;
|
|
2950
2950
|
const error = handleValidation(this.value, schemaValidations, validations, validationKey);
|
|
2951
2951
|
// setting valid flag
|
|
2952
2952
|
valid = !error && valid;
|
|
2953
2953
|
// setting error messages
|
|
2954
|
-
if (error && this.
|
|
2955
|
-
if (validationKey in this.
|
|
2956
|
-
const messages = this.
|
|
2954
|
+
if (error && ((_a = this.validations) === null || _a === void 0 ? void 0 : _a.messages)) {
|
|
2955
|
+
if (validationKey in this.validations.messages) {
|
|
2956
|
+
const messages = this.validations.messages;
|
|
2957
2957
|
errors[validationKey] = messages[validationKey];
|
|
2958
|
-
} else if ('default' in this.
|
|
2959
|
-
errors[validationKey] = this.
|
|
2958
|
+
} else if ('default' in this.validations.messages) {
|
|
2959
|
+
errors[validationKey] = this.validations.messages.default;
|
|
2960
2960
|
}
|
|
2961
2961
|
} else {
|
|
2962
2962
|
delete errors[validationKey];
|
|
@@ -4367,10 +4367,15 @@ class FormGroup {
|
|
|
4367
4367
|
}) => ids.includes(formIndex)), groupBy(({
|
|
4368
4368
|
event,
|
|
4369
4369
|
formIndex
|
|
4370
|
-
}) => `${event}.${formIndex}`), mergeMap(group$ => group$.pipe(debounceTime(this.config.defaultStateRefreshTimeMS))), map((
|
|
4370
|
+
}) => `${event}.${formIndex}`), mergeMap(group$ => group$.pipe(debounceTime(this.config.defaultStateRefreshTimeMS))), map(({
|
|
4371
|
+
fieldIndex,
|
|
4372
|
+
formIndex
|
|
4373
|
+
}) => ids.reduce((acc, curr) => {
|
|
4371
4374
|
const formInstance = this.forms.get(curr);
|
|
4372
4375
|
if (formInstance) {
|
|
4373
4376
|
acc[curr] = {
|
|
4377
|
+
formId: formIndex,
|
|
4378
|
+
formField: fieldIndex,
|
|
4374
4379
|
values: formInstance.getFormValues()
|
|
4375
4380
|
};
|
|
4376
4381
|
}
|
package/package.json
CHANGED
package/src/managers/field.d.ts
CHANGED
package/src/types/event.d.ts
CHANGED