@thecb/components 4.2.8 → 4.2.9
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/dist/index.cjs.js
CHANGED
|
@@ -34466,6 +34466,12 @@ const set$2 = fieldName => value => ({
|
|
|
34466
34466
|
const CLEAR = "form/CLEAR";
|
|
34467
34467
|
const clear = () => ({ type: CLEAR });
|
|
34468
34468
|
|
|
34469
|
+
const ADD_VALIDATOR = "field/ADD_VALIDATOR";
|
|
34470
|
+
const addValidator = fieldName => validator => ({
|
|
34471
|
+
type: ADD_VALIDATOR,
|
|
34472
|
+
payload: { fieldName, validator }
|
|
34473
|
+
});
|
|
34474
|
+
|
|
34469
34475
|
const createFormReducer = formConfig => (
|
|
34470
34476
|
state = createInitialState(formConfig),
|
|
34471
34477
|
action
|
|
@@ -34497,6 +34503,23 @@ const createFormReducer = formConfig => (
|
|
|
34497
34503
|
});
|
|
34498
34504
|
case CLEAR:
|
|
34499
34505
|
return createInitialState(formConfig);
|
|
34506
|
+
case ADD_VALIDATOR:
|
|
34507
|
+
const fieldWithOverride = action.payload.fieldName;
|
|
34508
|
+
const newValidator = action.payload.validator;
|
|
34509
|
+
|
|
34510
|
+
return produce(state, draftState => {
|
|
34511
|
+
draftState[fieldWithOverride].validators.push(newValidator);
|
|
34512
|
+
const fields = Object.entries(draftState);
|
|
34513
|
+
for (let entry of fields) {
|
|
34514
|
+
let fieldName = entry[0];
|
|
34515
|
+
let field = entry[1];
|
|
34516
|
+
let errors = computeErrors(fieldName, draftState);
|
|
34517
|
+
let dirty = field.dirty;
|
|
34518
|
+
draftState[fieldName].errors = errors;
|
|
34519
|
+
draftState[fieldName].dirty = dirty;
|
|
34520
|
+
draftState[fieldName].hasErrors = errors.length > 0;
|
|
34521
|
+
}
|
|
34522
|
+
});
|
|
34500
34523
|
default:
|
|
34501
34524
|
return state;
|
|
34502
34525
|
}
|
|
@@ -34515,7 +34538,8 @@ const createMapDispatchToProps = formConfig => {
|
|
|
34515
34538
|
const keys = Object.keys(formConfig);
|
|
34516
34539
|
for (let fieldName of keys) {
|
|
34517
34540
|
dispatchObj.fields[fieldName] = {
|
|
34518
|
-
set: value => dispatch(set$2(fieldName)(value))
|
|
34541
|
+
set: value => dispatch(set$2(fieldName)(value)),
|
|
34542
|
+
addValidator: validator => dispatch(addValidator(fieldName)(validator))
|
|
34519
34543
|
};
|
|
34520
34544
|
}
|
|
34521
34545
|
dispatchObj.form = { clear: () => dispatch(clear()) };
|
|
@@ -39739,11 +39763,11 @@ var formConfig$7 = {
|
|
|
39739
39763
|
constraints: [validateWhen(onlyIntegers(), matchesRegex("US"), "country"), validateWhen(hasLength(0, 9), matchesRegex("US"), "country")]
|
|
39740
39764
|
}
|
|
39741
39765
|
};
|
|
39742
|
-
|
|
39743
|
-
|
|
39744
|
-
|
|
39745
|
-
mapStateToProps$8 =
|
|
39746
|
-
mapDispatchToProps$7 =
|
|
39766
|
+
var formState = createFormState(formConfig$7);
|
|
39767
|
+
console.log("form state is", formState);
|
|
39768
|
+
var reducer$7 = formState.reducer,
|
|
39769
|
+
mapStateToProps$8 = formState.mapStateToProps,
|
|
39770
|
+
mapDispatchToProps$7 = formState.mapDispatchToProps;
|
|
39747
39771
|
|
|
39748
39772
|
PaymentFormCard.reducer = reducer$7;
|
|
39749
39773
|
PaymentFormCard.mapStateToProps = mapStateToProps$8;
|
|
@@ -39803,10 +39827,10 @@ var formConfig$8 = {
|
|
|
39803
39827
|
}
|
|
39804
39828
|
};
|
|
39805
39829
|
|
|
39806
|
-
var _createFormState$
|
|
39807
|
-
reducer$8 = _createFormState$
|
|
39808
|
-
mapStateToProps$9 = _createFormState$
|
|
39809
|
-
mapDispatchToProps$8 = _createFormState$
|
|
39830
|
+
var _createFormState$7 = createFormState(formConfig$8),
|
|
39831
|
+
reducer$8 = _createFormState$7.reducer,
|
|
39832
|
+
mapStateToProps$9 = _createFormState$7.mapStateToProps,
|
|
39833
|
+
mapDispatchToProps$8 = _createFormState$7.mapDispatchToProps;
|
|
39810
39834
|
|
|
39811
39835
|
PhoneForm.reducer = reducer$8;
|
|
39812
39836
|
PhoneForm.mapStateToProps = mapStateToProps$9;
|
|
@@ -40148,10 +40172,10 @@ var formConfig$9 = {
|
|
|
40148
40172
|
}
|
|
40149
40173
|
};
|
|
40150
40174
|
|
|
40151
|
-
var _createFormState$
|
|
40152
|
-
reducer$9 = _createFormState$
|
|
40153
|
-
mapStateToProps$a = _createFormState$
|
|
40154
|
-
mapDispatchToProps$9 = _createFormState$
|
|
40175
|
+
var _createFormState$8 = createFormState(formConfig$9),
|
|
40176
|
+
reducer$9 = _createFormState$8.reducer,
|
|
40177
|
+
mapStateToProps$a = _createFormState$8.mapStateToProps,
|
|
40178
|
+
mapDispatchToProps$9 = _createFormState$8.mapDispatchToProps;
|
|
40155
40179
|
|
|
40156
40180
|
RegistrationForm.reducer = reducer$9;
|
|
40157
40181
|
RegistrationForm.mapStateToProps = mapStateToProps$a;
|
|
@@ -40269,10 +40293,10 @@ var formConfig$a = {
|
|
|
40269
40293
|
}
|
|
40270
40294
|
};
|
|
40271
40295
|
|
|
40272
|
-
var _createFormState$
|
|
40273
|
-
reducer$a = _createFormState$
|
|
40274
|
-
mapStateToProps$b = _createFormState$
|
|
40275
|
-
mapDispatchToProps$a = _createFormState$
|
|
40296
|
+
var _createFormState$9 = createFormState(formConfig$a),
|
|
40297
|
+
reducer$a = _createFormState$9.reducer,
|
|
40298
|
+
mapStateToProps$b = _createFormState$9.mapStateToProps,
|
|
40299
|
+
mapDispatchToProps$a = _createFormState$9.mapDispatchToProps;
|
|
40276
40300
|
|
|
40277
40301
|
ResetPasswordForm.reducer = reducer$a;
|
|
40278
40302
|
ResetPasswordForm.mapStateToProps = mapStateToProps$b;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thecb/components",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.9",
|
|
4
4
|
"description": "Common lib for CityBase react components",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -80,6 +80,6 @@
|
|
|
80
80
|
"ramda": "^0.27.0",
|
|
81
81
|
"react-aria-modal": "^4.0.0",
|
|
82
82
|
"react-pose": "^4.0.10",
|
|
83
|
-
"redux-freeform": "^5.0.
|
|
83
|
+
"redux-freeform": "^5.0.1"
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -54,6 +54,7 @@ const formConfig = {
|
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
const formState = createFormState(formConfig);
|
|
58
|
+
console.log("form state is", formState);
|
|
59
|
+
|
|
60
|
+
export const { reducer, mapStateToProps, mapDispatchToProps } = formState;
|