@bodynarf/react.components 1.4.19 → 1.4.21
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/components/form/component/index.d.ts +16 -0
- package/components/form/component/index.d.ts.map +1 -0
- package/components/form/component/index.js +13 -0
- package/components/form/component/styles.scss +33 -0
- package/components/form/components/cell/index.d.ts +13 -0
- package/components/form/components/cell/index.d.ts.map +1 -0
- package/components/form/components/cell/index.js +8 -0
- package/components/form/components/container/index.d.ts +24 -0
- package/components/form/components/container/index.d.ts.map +1 -0
- package/components/form/components/container/index.js +27 -0
- package/components/form/components/form/index.d.ts +10 -0
- package/components/form/components/form/index.d.ts.map +1 -0
- package/components/form/components/form/index.js +11 -0
- package/components/form/components/inputs/checkbox/index.d.ts +6 -0
- package/components/form/components/inputs/checkbox/index.d.ts.map +1 -0
- package/components/form/components/inputs/checkbox/index.js +19 -0
- package/components/form/components/inputs/date/index.d.ts +7 -0
- package/components/form/components/inputs/date/index.d.ts.map +1 -0
- package/components/form/components/inputs/date/index.js +19 -0
- package/components/form/components/inputs/lookup/index.d.ts +6 -0
- package/components/form/components/inputs/lookup/index.d.ts.map +1 -0
- package/components/form/components/inputs/lookup/index.js +19 -0
- package/components/form/components/inputs/multiline/index.d.ts +6 -0
- package/components/form/components/inputs/multiline/index.d.ts.map +1 -0
- package/components/form/components/inputs/multiline/index.js +19 -0
- package/components/form/components/inputs/number/index.d.ts +6 -0
- package/components/form/components/inputs/number/index.d.ts.map +1 -0
- package/components/form/components/inputs/number/index.js +19 -0
- package/components/form/components/inputs/password/index.d.ts +6 -0
- package/components/form/components/inputs/password/index.d.ts.map +1 -0
- package/components/form/components/inputs/password/index.js +19 -0
- package/components/form/components/inputs/text/index.d.ts +6 -0
- package/components/form/components/inputs/text/index.d.ts.map +1 -0
- package/components/form/components/inputs/text/index.js +23 -0
- package/components/form/components/item/index.d.ts +4 -0
- package/components/form/components/item/index.d.ts.map +1 -0
- package/components/form/components/item/index.js +28 -0
- package/components/form/components/row/index.d.ts +10 -0
- package/components/form/components/row/index.d.ts.map +1 -0
- package/components/form/components/row/index.js +27 -0
- package/components/form/index.d.ts +3 -0
- package/components/form/index.d.ts.map +1 -0
- package/components/form/index.js +2 -0
- package/components/form/redux/actionCreators/index.d.ts +7 -0
- package/components/form/redux/actionCreators/index.d.ts.map +1 -0
- package/components/form/redux/actionCreators/index.js +6 -0
- package/components/form/redux/actionCreators/initForm.d.ts +9 -0
- package/components/form/redux/actionCreators/initForm.d.ts.map +1 -0
- package/components/form/redux/actionCreators/initForm.js +12 -0
- package/components/form/redux/actionCreators/setFieldValue.d.ts +9 -0
- package/components/form/redux/actionCreators/setFieldValue.d.ts.map +1 -0
- package/components/form/redux/actionCreators/setFieldValue.js +18 -0
- package/components/form/redux/actionCreators/setFormState.d.ts +8 -0
- package/components/form/redux/actionCreators/setFormState.d.ts.map +1 -0
- package/components/form/redux/actionCreators/setFormState.js +14 -0
- package/components/form/redux/actionCreators/setValidationResult.d.ts +9 -0
- package/components/form/redux/actionCreators/setValidationResult.d.ts.map +1 -0
- package/components/form/redux/actionCreators/setValidationResult.js +14 -0
- package/components/form/redux/actionCreators/submitForm.d.ts +7 -0
- package/components/form/redux/actionCreators/submitForm.d.ts.map +1 -0
- package/components/form/redux/actionCreators/submitForm.js +10 -0
- package/components/form/redux/actionCreators/validateField.d.ts +8 -0
- package/components/form/redux/actionCreators/validateField.d.ts.map +1 -0
- package/components/form/redux/actionCreators/validateField.js +12 -0
- package/components/form/redux/actionTypes.d.ts +13 -0
- package/components/form/redux/actionTypes.d.ts.map +1 -0
- package/components/form/redux/actionTypes.js +12 -0
- package/components/form/redux/actions/index.d.ts +2 -0
- package/components/form/redux/actions/index.d.ts.map +1 -0
- package/components/form/redux/actions/index.js +1 -0
- package/components/form/redux/actions/submitForm.d.ts +9 -0
- package/components/form/redux/actions/submitForm.d.ts.map +1 -0
- package/components/form/redux/actions/submitForm.js +16 -0
- package/components/form/redux/index.d.ts +8 -0
- package/components/form/redux/index.d.ts.map +1 -0
- package/components/form/redux/index.js +7 -0
- package/components/form/redux/reducer.d.ts +4 -0
- package/components/form/redux/reducer.d.ts.map +1 -0
- package/components/form/redux/reducer.js +103 -0
- package/components/form/redux/store.d.ts +5 -0
- package/components/form/redux/store.d.ts.map +1 -0
- package/components/form/redux/store.js +4 -0
- package/components/form/redux/types/base/types.d.ts +9 -0
- package/components/form/redux/types/base/types.d.ts.map +1 -0
- package/components/form/redux/types/base/types.js +2 -0
- package/components/form/redux/types/fieldValue.d.ts +10 -0
- package/components/form/redux/types/fieldValue.d.ts.map +1 -0
- package/components/form/redux/types/fieldValue.js +1 -0
- package/components/form/redux/types/index.d.ts +4 -0
- package/components/form/redux/types/index.d.ts.map +1 -0
- package/components/form/redux/types/index.js +3 -0
- package/components/form/redux/types/state.d.ts +37 -0
- package/components/form/redux/types/state.d.ts.map +1 -0
- package/components/form/redux/types/state.js +12 -0
- package/components/form/redux/utils/index.d.ts +3 -0
- package/components/form/redux/utils/index.d.ts.map +1 -0
- package/components/form/redux/utils/index.js +2 -0
- package/components/form/redux/utils/mapper.d.ts +16 -0
- package/components/form/redux/utils/mapper.d.ts.map +1 -0
- package/components/form/redux/utils/mapper.js +107 -0
- package/components/form/redux/utils/validate.d.ts +9 -0
- package/components/form/redux/utils/validate.d.ts.map +1 -0
- package/components/form/redux/utils/validate.js +33 -0
- package/components/form/types/index.d.ts +3 -0
- package/components/form/types/index.d.ts.map +1 -0
- package/components/form/types/index.js +2 -0
- package/components/form/types/model/extensions/extendedField.d.ts +7 -0
- package/components/form/types/model/extensions/extendedField.d.ts.map +1 -0
- package/components/form/types/model/extensions/extendedField.js +1 -0
- package/components/form/types/model/extensions/extendedFormItem.d.ts +7 -0
- package/components/form/types/model/extensions/extendedFormItem.d.ts.map +1 -0
- package/components/form/types/model/extensions/extendedFormItem.js +2 -0
- package/components/form/types/model/extensions/index.d.ts +4 -0
- package/components/form/types/model/extensions/index.d.ts.map +1 -0
- package/components/form/types/model/extensions/index.js +3 -0
- package/components/form/types/model/extensions/items/checkbox.d.ts +17 -0
- package/components/form/types/model/extensions/items/checkbox.d.ts.map +1 -0
- package/components/form/types/model/extensions/items/checkbox.js +14 -0
- package/components/form/types/model/extensions/items/getExtension.d.ts +9 -0
- package/components/form/types/model/extensions/items/getExtension.d.ts.map +1 -0
- package/components/form/types/model/extensions/items/getExtension.js +18 -0
- package/components/form/types/model/extensions/items/index.d.ts +5 -0
- package/components/form/types/model/extensions/items/index.d.ts.map +1 -0
- package/components/form/types/model/extensions/items/index.js +4 -0
- package/components/form/types/model/extensions/items/lookup.d.ts +20 -0
- package/components/form/types/model/extensions/items/lookup.d.ts.map +1 -0
- package/components/form/types/model/extensions/items/lookup.js +15 -0
- package/components/form/types/model/extensions/items/multiline.d.ts +17 -0
- package/components/form/types/model/extensions/items/multiline.d.ts.map +1 -0
- package/components/form/types/model/extensions/items/multiline.js +14 -0
- package/components/form/types/model/form.config.d.ts +20 -0
- package/components/form/types/model/form.config.d.ts.map +1 -0
- package/components/form/types/model/form.config.js +2 -0
- package/components/form/types/model/form.submitButtonCfg.d.ts +26 -0
- package/components/form/types/model/form.submitButtonCfg.d.ts.map +1 -0
- package/components/form/types/model/form.submitButtonCfg.js +1 -0
- package/components/form/types/model/formItem.d.ts +12 -0
- package/components/form/types/model/formItem.d.ts.map +1 -0
- package/components/form/types/model/formItem.js +1 -0
- package/components/form/types/model/formItem.modelConfig.d.ts +20 -0
- package/components/form/types/model/formItem.modelConfig.d.ts.map +1 -0
- package/components/form/types/model/formItem.modelConfig.js +1 -0
- package/components/form/types/model/formItem.viewConfig.d.ts +15 -0
- package/components/form/types/model/formItem.viewConfig.d.ts.map +1 -0
- package/components/form/types/model/formItem.viewConfig.js +1 -0
- package/components/form/types/model/formItemValidationState.d.ts +10 -0
- package/components/form/types/model/formItemValidationState.d.ts.map +1 -0
- package/components/form/types/model/formItemValidationState.js +11 -0
- package/components/form/types/model/in/baseField.d.ts +21 -0
- package/components/form/types/model/in/baseField.d.ts.map +1 -0
- package/components/form/types/model/in/baseField.js +1 -0
- package/components/form/types/model/in/captionConfig.d.ts +14 -0
- package/components/form/types/model/in/captionConfig.d.ts.map +1 -0
- package/components/form/types/model/in/captionConfig.js +1 -0
- package/components/form/types/model/in/fieldType.d.ts +3 -0
- package/components/form/types/model/in/fieldType.d.ts.map +1 -0
- package/components/form/types/model/in/fieldType.js +1 -0
- package/components/form/types/model/in/fieldValidator.d.ts +3 -0
- package/components/form/types/model/in/fieldValidator.d.ts.map +1 -0
- package/components/form/types/model/in/fieldValidator.js +1 -0
- package/components/form/types/model/in/index.d.ts +6 -0
- package/components/form/types/model/in/index.d.ts.map +1 -0
- package/components/form/types/model/in/index.js +5 -0
- package/components/form/types/model/in/viewConfig.d.ts +24 -0
- package/components/form/types/model/in/viewConfig.d.ts.map +1 -0
- package/components/form/types/model/in/viewConfig.js +1 -0
- package/components/form/types/model/index.d.ts +10 -0
- package/components/form/types/model/index.d.ts.map +1 -0
- package/components/form/types/model/index.js +9 -0
- package/components/form/types/model/validationResult.d.ts +11 -0
- package/components/form/types/model/validationResult.d.ts.map +1 -0
- package/components/form/types/model/validationResult.js +2 -0
- package/components/form/types/view/gridCell.d.ts +15 -0
- package/components/form/types/view/gridCell.d.ts.map +1 -0
- package/components/form/types/view/gridCell.js +1 -0
- package/components/form/types/view/index.d.ts +2 -0
- package/components/form/types/view/index.d.ts.map +1 -0
- package/components/form/types/view/index.js +1 -0
- package/components/form/utils/component.d.ts +9 -0
- package/components/form/utils/component.d.ts.map +1 -0
- package/components/form/utils/component.js +16 -0
- package/components/form/utils/grid.d.ts +17 -0
- package/components/form/utils/grid.d.ts.map +1 -0
- package/components/form/utils/grid.js +75 -0
- package/components/form/utils/index.d.ts +4 -0
- package/components/form/utils/index.d.ts.map +1 -0
- package/components/form/utils/index.js +3 -0
- package/components/form/utils/validators/index.d.ts +4 -0
- package/components/form/utils/validators/index.d.ts.map +1 -0
- package/components/form/utils/validators/index.js +3 -0
- package/components/form/utils/validators/number/greaterThanZero.d.ts +7 -0
- package/components/form/utils/validators/number/greaterThanZero.d.ts.map +1 -0
- package/components/form/utils/validators/number/greaterThanZero.js +7 -0
- package/components/form/utils/validators/number/index.d.ts +4 -0
- package/components/form/utils/validators/number/index.d.ts.map +1 -0
- package/components/form/utils/validators/number/index.js +3 -0
- package/components/form/utils/validators/number/lessThanZero.d.ts +7 -0
- package/components/form/utils/validators/number/lessThanZero.d.ts.map +1 -0
- package/components/form/utils/validators/number/lessThanZero.js +7 -0
- package/components/form/utils/validators/number/notZero.d.ts +7 -0
- package/components/form/utils/validators/number/notZero.d.ts.map +1 -0
- package/components/form/utils/validators/number/notZero.js +7 -0
- package/components/form/utils/validators/required.d.ts +7 -0
- package/components/form/utils/validators/required.d.ts.map +1 -0
- package/components/form/utils/validators/required.js +8 -0
- package/components/form/utils/validators/string/index.d.ts +2 -0
- package/components/form/utils/validators/string/index.d.ts.map +1 -0
- package/components/form/utils/validators/string/index.js +1 -0
- package/components/form/utils/validators/string/length.d.ts +8 -0
- package/components/form/utils/validators/string/length.d.ts.map +1 -0
- package/components/form/utils/validators/string/length.js +12 -0
- package/components/primitives/date/index.d.ts +0 -1
- package/components/primitives/date/index.d.ts.map +1 -1
- package/components/primitives/multiline/components/multilineWithLabel/index.d.ts +0 -1
- package/components/primitives/multiline/components/multilineWithLabel/index.d.ts.map +1 -1
- package/components/primitives/multiline/components/multilineWithoutLabel/index.d.ts +0 -1
- package/components/primitives/multiline/components/multilineWithoutLabel/index.d.ts.map +1 -1
- package/components/primitives/multiline/index.d.ts +0 -1
- package/components/primitives/multiline/index.d.ts.map +1 -1
- package/components/primitives/number/components/withLabel/index.d.ts +0 -1
- package/components/primitives/number/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/number/components/withoutLabel/index.d.ts +0 -1
- package/components/primitives/number/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/number/index.d.ts +0 -1
- package/components/primitives/number/index.d.ts.map +1 -1
- package/components/primitives/password/components/withLabel/index.d.ts +0 -1
- package/components/primitives/password/components/withLabel/index.d.ts.map +1 -1
- package/components/primitives/password/components/withoutLabel/index.d.ts +0 -1
- package/components/primitives/password/components/withoutLabel/index.d.ts.map +1 -1
- package/components/primitives/password/index.d.ts +0 -1
- package/components/primitives/password/index.d.ts.map +1 -1
- package/components/primitives/text/components/textWithLabel/index.d.ts +0 -1
- package/components/primitives/text/components/textWithLabel/index.d.ts.map +1 -1
- package/components/primitives/text/components/textWithoutLabel/index.d.ts +0 -1
- package/components/primitives/text/components/textWithoutLabel/index.d.ts.map +1 -1
- package/components/primitives/text/index.d.ts +0 -1
- package/components/primitives/text/index.d.ts.map +1 -1
- package/package.json +5 -2
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { setFormStatus } from "../actionTypes";
|
|
2
|
+
/**
|
|
3
|
+
* Get redux action "Set form state status"
|
|
4
|
+
* @param newStatus New form state status
|
|
5
|
+
* @returns State updating action
|
|
6
|
+
*/
|
|
7
|
+
export const getSetFormStatus = (newStatus) => {
|
|
8
|
+
return ({
|
|
9
|
+
type: setFormStatus,
|
|
10
|
+
payload: {
|
|
11
|
+
newState: newStatus
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ActionWithPayload } from "../types";
|
|
2
|
+
import { ValidationResult } from "../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Get redux action "Set form validation result"
|
|
5
|
+
* @param validationResult Result of form fields validation
|
|
6
|
+
* @returns State updating action
|
|
7
|
+
*/
|
|
8
|
+
export declare const getSetValidationResultAction: (validationResult: Map<string, ValidationResult>) => ActionWithPayload;
|
|
9
|
+
//# sourceMappingURL=setValidationResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setValidationResult.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/redux/actionCreators/setValidationResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,qBAAsB,IAAI,MAAM,EAAE,gBAAgB,CAAC,KAAG,iBAO9F,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { setValidationResult } from "../actionTypes";
|
|
2
|
+
/**
|
|
3
|
+
* Get redux action "Set form validation result"
|
|
4
|
+
* @param validationResult Result of form fields validation
|
|
5
|
+
* @returns State updating action
|
|
6
|
+
*/
|
|
7
|
+
export const getSetValidationResultAction = (validationResult) => {
|
|
8
|
+
return ({
|
|
9
|
+
type: setValidationResult,
|
|
10
|
+
payload: {
|
|
11
|
+
validationResult
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submitForm.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/redux/actionCreators/submitForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG/B;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QAAO,OAAO,MAAM,CAInD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionWithPayload } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Get redux action "Validate field"
|
|
4
|
+
* @param {string} fieldName Name of field which should be validated
|
|
5
|
+
* @returns State updating action
|
|
6
|
+
*/
|
|
7
|
+
export declare const getValidateFieldAction: (fieldName: string) => ActionWithPayload;
|
|
8
|
+
//# sourceMappingURL=validateField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateField.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/redux/actionCreators/validateField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG7C;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,cAAe,MAAM,KAAG,iBAK1D,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { validateField } from "../actionTypes";
|
|
2
|
+
/**
|
|
3
|
+
* Get redux action "Validate field"
|
|
4
|
+
* @param {string} fieldName Name of field which should be validated
|
|
5
|
+
* @returns State updating action
|
|
6
|
+
*/
|
|
7
|
+
export const getValidateFieldAction = (fieldName) => {
|
|
8
|
+
return ({
|
|
9
|
+
type: validateField,
|
|
10
|
+
payload: { fieldName }
|
|
11
|
+
});
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Initialize form state with config */
|
|
2
|
+
export declare const initForm = "bbr-form/init";
|
|
3
|
+
/** Set single field value */
|
|
4
|
+
export declare const setFieldValue = "bbr-form/setFiedValue";
|
|
5
|
+
/** Validate specified field */
|
|
6
|
+
export declare const validateField = "bbr-form/validateField";
|
|
7
|
+
/** Submit form */
|
|
8
|
+
export declare const submitForm = "bbr-form/submit";
|
|
9
|
+
/** Set form state status */
|
|
10
|
+
export declare const setFormStatus = "bbr-form/setStatus";
|
|
11
|
+
/** Set form validation result */
|
|
12
|
+
export declare const setValidationResult = "bbr-form/setValidationResult";
|
|
13
|
+
//# sourceMappingURL=actionTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionTypes.d.ts","sourceRoot":"","sources":["../../../../src/components/form/redux/actionTypes.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,eAAO,MAAM,QAAQ,kBAAkB,CAAC;AAExC,6BAA6B;AAC7B,eAAO,MAAM,aAAa,0BAA0B,CAAC;AAErD,+BAA+B;AAC/B,eAAO,MAAM,aAAa,2BAA2B,CAAC;AAEtD,kBAAkB;AAClB,eAAO,MAAM,UAAU,oBAAoB,CAAC;AAE5C,4BAA4B;AAC5B,eAAO,MAAM,aAAa,uBAAuB,CAAC;AAElD,iCAAiC;AACjC,eAAO,MAAM,mBAAmB,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Initialize form state with config */
|
|
2
|
+
export const initForm = "bbr-form/init";
|
|
3
|
+
/** Set single field value */
|
|
4
|
+
export const setFieldValue = "bbr-form/setFiedValue";
|
|
5
|
+
/** Validate specified field */
|
|
6
|
+
export const validateField = "bbr-form/validateField";
|
|
7
|
+
/** Submit form */
|
|
8
|
+
export const submitForm = "bbr-form/submit";
|
|
9
|
+
/** Set form state status */
|
|
10
|
+
export const setFormStatus = "bbr-form/setStatus";
|
|
11
|
+
/** Set form validation result */
|
|
12
|
+
export const setValidationResult = "bbr-form/setValidationResult";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/redux/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./submitForm";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ThunkAction } from "redux-thunk";
|
|
2
|
+
import { ActionWithPayload, FormState } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Get action "submit form".
|
|
5
|
+
* Moves form to validating stage, validates fields.
|
|
6
|
+
* If form is valid - executes user callback. Otherwise - push form to previous state
|
|
7
|
+
*/
|
|
8
|
+
export declare const submitFormAsync: () => ThunkAction<void, FormState, unknown, ActionWithPayload>;
|
|
9
|
+
//# sourceMappingURL=submitForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submitForm.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/redux/actions/submitForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,aAAa,CAAC;AAIzD,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAoBxD;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAO,YAAY,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB,CAAqB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getSetFormStatus, getSetValidationResultAction } from "../actionCreators";
|
|
2
|
+
import { validateItem } from "../utils";
|
|
3
|
+
const submitFormAction = (dispatch, getState) => {
|
|
4
|
+
const { items } = getState();
|
|
5
|
+
dispatch(getSetFormStatus("validating"));
|
|
6
|
+
(async () => {
|
|
7
|
+
const validationResults = new Map(items.map(item => [item.name, validateItem(item, item.modelConfig.value)]));
|
|
8
|
+
dispatch(getSetValidationResultAction(validationResults));
|
|
9
|
+
})();
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Get action "submit form".
|
|
13
|
+
* Moves form to validating stage, validates fields.
|
|
14
|
+
* If form is valid - executes user callback. Otherwise - push form to previous state
|
|
15
|
+
*/
|
|
16
|
+
export const submitFormAsync = () => submitFormAction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/form/redux/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../../../src/components/form/redux/reducer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAmB,SAAS,EAAc,MAAM,SAAS,CAAC;AAapF,4BAA4B;AAC5B,MAAM,CAAC,OAAO,WAAW,KAAK,uBAAe,EAAE,MAAM,EAAE,iBAAiB,GAAG,SAAS,CA6GnF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { isNullOrUndefined } from "@bodynarf/utils";
|
|
2
|
+
import { FormItemValidationState } from "../types";
|
|
3
|
+
import { FormPurityState } from "./types";
|
|
4
|
+
import { initForm, setFieldValue, setFormStatus, setValidationResult } from "./actionTypes";
|
|
5
|
+
import { map as mapFormItems, validateItem } from "./utils";
|
|
6
|
+
/** Initial form state values */
|
|
7
|
+
const initialState = {
|
|
8
|
+
state: "init",
|
|
9
|
+
initialConfig: undefined,
|
|
10
|
+
items: [],
|
|
11
|
+
valuesStorage: [],
|
|
12
|
+
purityState: FormPurityState.Pure,
|
|
13
|
+
};
|
|
14
|
+
/** Form reducer function */
|
|
15
|
+
export default function (state = initialState, action) {
|
|
16
|
+
switch (action.type) {
|
|
17
|
+
case setFormStatus: {
|
|
18
|
+
const newStatus = action.payload["newState"];
|
|
19
|
+
if (isNullOrUndefined(newStatus)) {
|
|
20
|
+
return state;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
...state,
|
|
24
|
+
state: newStatus,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
case initForm: {
|
|
28
|
+
const config = action.payload["initialConfig"];
|
|
29
|
+
if (isNullOrUndefined(config)) {
|
|
30
|
+
return state;
|
|
31
|
+
}
|
|
32
|
+
const formConfig = mapFormItems(config.items);
|
|
33
|
+
return {
|
|
34
|
+
...state,
|
|
35
|
+
state: "idle",
|
|
36
|
+
initialConfig: config,
|
|
37
|
+
items: formConfig.map((x, i) => ({ ...x, order: i })),
|
|
38
|
+
valuesStorage: [],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
case setFieldValue: {
|
|
42
|
+
const { name, value } = action.payload["field"];
|
|
43
|
+
const item = state.items.find(item => item.name === name);
|
|
44
|
+
if (isNullOrUndefined(item)) {
|
|
45
|
+
return state;
|
|
46
|
+
}
|
|
47
|
+
item.modelConfig.value = value;
|
|
48
|
+
const purityState = state.purityState === FormPurityState.Pure && value !== item.modelConfig.defaultValue
|
|
49
|
+
? state.purityState
|
|
50
|
+
: FormPurityState.Dirty;
|
|
51
|
+
if (state.state === "validation errors") {
|
|
52
|
+
const validationResult = validateItem(item, value);
|
|
53
|
+
if (validationResult.state !== FormItemValidationState.Invalid) {
|
|
54
|
+
item.modelConfig.validationState = FormItemValidationState.None;
|
|
55
|
+
item.modelConfig.validationMessages = [];
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
item.modelConfig.validationMessages = validationResult.messages;
|
|
59
|
+
item.modelConfig.validationState = validationResult.state;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const updatedItems = [
|
|
63
|
+
...state.items.filter(({ name }) => name !== item.name),
|
|
64
|
+
item
|
|
65
|
+
].sort((x, y) => x.order - y.order);
|
|
66
|
+
return {
|
|
67
|
+
...state,
|
|
68
|
+
purityState: purityState,
|
|
69
|
+
items: updatedItems
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
case setValidationResult: {
|
|
73
|
+
const validationResult = action.payload["validationResult"];
|
|
74
|
+
state.valuesStorage.length = 0;
|
|
75
|
+
let currentState = FormItemValidationState.Valid;
|
|
76
|
+
const values = [];
|
|
77
|
+
for (let [key, value] of validationResult) {
|
|
78
|
+
const item = state.items.find(({ name }) => name === key);
|
|
79
|
+
item.modelConfig.validationState = value.state;
|
|
80
|
+
item.modelConfig.validationMessages.length = 0;
|
|
81
|
+
item.modelConfig.validationMessages.push(...value.messages);
|
|
82
|
+
if (value.state === FormItemValidationState.Invalid) {
|
|
83
|
+
currentState = FormItemValidationState.Invalid;
|
|
84
|
+
}
|
|
85
|
+
if (currentState !== FormItemValidationState.Invalid
|
|
86
|
+
&& value.state !== FormItemValidationState.Invalid) {
|
|
87
|
+
values.push({
|
|
88
|
+
key,
|
|
89
|
+
type: item.modelConfig.type,
|
|
90
|
+
value: item.modelConfig.value,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
...state,
|
|
96
|
+
state: currentState === FormItemValidationState.Valid ? "submited" : "validation errors",
|
|
97
|
+
valuesStorage: currentState === FormItemValidationState.Valid ? values : [],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
default:
|
|
101
|
+
return state;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/components/form/redux/store.ts"],"names":[],"mappings":";;;AAKA,wBAGE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/components/form/redux/types/base/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,2CAA2C;AAC3C,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAChD,0BAA0B;IAC1B,OAAO,EAAE;QACL,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;KACjC,CAAC;CACL"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldValue.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/redux/types/fieldValue.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,MAAM,WAAW,UAAU;IACvB,iBAAiB;IACjB,GAAG,EAAE,MAAM,CAAC;IAEZ,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IAEb,uBAAuB;IACvB,KAAK,EAAE,GAAG,CAAC;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/redux/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { FormConfig, ExtendedFormItem } from "../../types";
|
|
2
|
+
import { FieldValue } from "./fieldValue";
|
|
3
|
+
/**
|
|
4
|
+
* Form status
|
|
5
|
+
* @description Represents form current lifecycle stage
|
|
6
|
+
*/
|
|
7
|
+
export declare type FormStatus = "init" | "idle" | "validating" | "submited" | "validation errors";
|
|
8
|
+
/**
|
|
9
|
+
* Form purity state.
|
|
10
|
+
* Represent form state whenever user changed any field value
|
|
11
|
+
*/
|
|
12
|
+
export declare enum FormPurityState {
|
|
13
|
+
/** Form is pure, none fields was changed */
|
|
14
|
+
Pure = 0,
|
|
15
|
+
/** Form is dirty, some of fields was touched by user and value was changed */
|
|
16
|
+
Dirty = 1
|
|
17
|
+
}
|
|
18
|
+
/** Form state */
|
|
19
|
+
export interface FormState {
|
|
20
|
+
/** Current state */
|
|
21
|
+
state: FormStatus;
|
|
22
|
+
/** Form items */
|
|
23
|
+
items: Array<ExtendedFormItemInState<any, any>>;
|
|
24
|
+
/** Form configuration */
|
|
25
|
+
initialConfig: FormConfig | undefined;
|
|
26
|
+
/** Valid form values */
|
|
27
|
+
valuesStorage: Array<FieldValue>;
|
|
28
|
+
/** Current purity state */
|
|
29
|
+
purityState: FormPurityState;
|
|
30
|
+
}
|
|
31
|
+
/** Extension of form item to store order */
|
|
32
|
+
interface ExtendedFormItemInState<TValue, TExtension> extends ExtendedFormItem<TValue, TExtension> {
|
|
33
|
+
/** Order in initial config */
|
|
34
|
+
order: number;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/redux/types/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;EAGE;AACF,oBAAY,UAAU,GAChB,MAAM,GACN,MAAM,GACN,YAAY,GACZ,UAAU,GACV,mBAAmB,CACpB;AAEL;;;GAGG;AACH,oBAAY,eAAe;IACvB,4CAA4C;IAC5C,IAAI,IAAI;IAER,8EAA8E;IAC9E,KAAK,IAAI;CACZ;AAED,iBAAiB;AACjB,MAAM,WAAW,SAAS;IACtB,oBAAoB;IACpB,KAAK,EAAE,UAAU,CAAC;IAElB,iBAAiB;IACjB,KAAK,EAAE,KAAK,CAAC,uBAAuB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAEhD,yBAAyB;IACzB,aAAa,EAAE,UAAU,GAAG,SAAS,CAAC;IAEtC,wBAAwB;IACxB,aAAa,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAEjC,2BAA2B;IAC3B,WAAW,EAAE,eAAe,CAAC;CAChC;AAED,4CAA4C;AAC5C,UAAU,uBAAuB,CAAC,MAAM,EAAE,UAAU,CAAE,SAAQ,gBAAgB,CAAC,MAAM,EAAE,UAAU,CAAC;IAC9F,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form purity state.
|
|
3
|
+
* Represent form state whenever user changed any field value
|
|
4
|
+
*/
|
|
5
|
+
export var FormPurityState;
|
|
6
|
+
(function (FormPurityState) {
|
|
7
|
+
/** Form is pure, none fields was changed */
|
|
8
|
+
FormPurityState[FormPurityState["Pure"] = 0] = "Pure";
|
|
9
|
+
/** Form is dirty, some of fields was touched by user and value was changed */
|
|
10
|
+
FormPurityState[FormPurityState["Dirty"] = 1] = "Dirty";
|
|
11
|
+
})(FormPurityState || (FormPurityState = {}));
|
|
12
|
+
;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/redux/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Field, ExtendedFormItem } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
* Map external config to internal model
|
|
5
|
+
* @param items Form items from external config
|
|
6
|
+
* @returns Form items for internal use
|
|
7
|
+
*/
|
|
8
|
+
export declare const map: (items: Array<Field<any>>) => Array<ExtendedFormItem<any, any>>;
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
* Map external config to internal model
|
|
12
|
+
* @param item Form item from external config
|
|
13
|
+
* @returns Form item for internal use
|
|
14
|
+
*/
|
|
15
|
+
export declare const mapItem: (item: Field<any>) => ExtendedFormItem<any, any>;
|
|
16
|
+
//# sourceMappingURL=mapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/redux/utils/mapper.ts"],"names":[],"mappings":"AAEA,OAAO,EACQ,KAAK,EAAa,gBAAgB,EAEhD,MAAM,aAAa,CAAC;AAIrB;;;;;GAKG;AACH,eAAO,MAAM,GAAG,UAAW,MAAM,MAAM,GAAG,CAAC,CAAC,KAAG,MAAM,iBAAiB,GAAG,EAAE,GAAG,CAAC,CAE9E,CAAC;AAgCF;;;;;GAKG;AACH,eAAO,MAAM,OAAO,SAAU,MAAM,GAAG,CAAC,KAAG,iBAAiB,GAAG,EAAE,GAAG,CA0CnE,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { getClassName } from "@bodynarf/utils";
|
|
2
|
+
import { getLookupExt, getCheckboxExt, getMultilineExt, } from "../../types";
|
|
3
|
+
import { FormItemValidationState } from "../../types/model/formItemValidationState";
|
|
4
|
+
import { required } from "../../utils/validators";
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
* Map external config to internal model
|
|
8
|
+
* @param items Form items from external config
|
|
9
|
+
* @returns Form items for internal use
|
|
10
|
+
*/
|
|
11
|
+
export const map = (items) => {
|
|
12
|
+
return items.map(mapItem);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @private
|
|
16
|
+
* View item type (see FieldType) mapping to stringified data value type
|
|
17
|
+
*/
|
|
18
|
+
const viewItemTypeToDataTypeMap = new Map([
|
|
19
|
+
["text", "string"],
|
|
20
|
+
["multiline", "string"],
|
|
21
|
+
["checkbox", "boolean"],
|
|
22
|
+
["number", "number"],
|
|
23
|
+
["date", "date"],
|
|
24
|
+
["lookup", "selectItem"],
|
|
25
|
+
["password", "string"],
|
|
26
|
+
]);
|
|
27
|
+
/**
|
|
28
|
+
* BaseField model property names.
|
|
29
|
+
* Used for select extended configuration props in item config
|
|
30
|
+
*/
|
|
31
|
+
const defaultKeys = [
|
|
32
|
+
"name",
|
|
33
|
+
"type",
|
|
34
|
+
"viewConfig",
|
|
35
|
+
"label",
|
|
36
|
+
"validators",
|
|
37
|
+
"defaultValue",
|
|
38
|
+
"readonly",
|
|
39
|
+
"required"
|
|
40
|
+
]
|
|
41
|
+
.map(x => x);
|
|
42
|
+
/**
|
|
43
|
+
* @public
|
|
44
|
+
* Map external config to internal model
|
|
45
|
+
* @param item Form item from external config
|
|
46
|
+
* @returns Form item for internal use
|
|
47
|
+
*/
|
|
48
|
+
export const mapItem = (item) => {
|
|
49
|
+
const className = getClassName(item.viewConfig.classNames || []);
|
|
50
|
+
const isRequired = item.required === true;
|
|
51
|
+
const validators = item.validators ?? [];
|
|
52
|
+
if (isRequired) {
|
|
53
|
+
const hasValidator = validators.some(x => x === required);
|
|
54
|
+
if (!hasValidator) {
|
|
55
|
+
validators.push(required);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const keys = Object.keys(item);
|
|
59
|
+
const hasExtraKeys = keys.some(key => !defaultKeys.includes(key));
|
|
60
|
+
const extension = hasExtraKeys ? getExtension(item) : undefined;
|
|
61
|
+
const result = {
|
|
62
|
+
name: item.name,
|
|
63
|
+
viewConfig: {
|
|
64
|
+
className: className,
|
|
65
|
+
caption: item.label.caption,
|
|
66
|
+
layoutConfig: item.viewConfig.layout,
|
|
67
|
+
disabled: item.readonly === true,
|
|
68
|
+
type: item.type,
|
|
69
|
+
},
|
|
70
|
+
modelConfig: {
|
|
71
|
+
type: viewItemTypeToDataTypeMap.get(item.type),
|
|
72
|
+
defaultValue: item.defaultValue,
|
|
73
|
+
value: null,
|
|
74
|
+
validators: validators,
|
|
75
|
+
required: isRequired,
|
|
76
|
+
validationMessages: [],
|
|
77
|
+
validationState: FormItemValidationState.None,
|
|
78
|
+
},
|
|
79
|
+
extension: extension,
|
|
80
|
+
};
|
|
81
|
+
return result;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Get specific component extension if item has extended properties
|
|
85
|
+
* @param item Form item configuration
|
|
86
|
+
* @returns Custom extended configuration if extra props are found; otherwise `undefined`
|
|
87
|
+
*/
|
|
88
|
+
const getExtension = (item) => {
|
|
89
|
+
let extension = undefined;
|
|
90
|
+
switch (item.type) {
|
|
91
|
+
case "date":
|
|
92
|
+
case "number":
|
|
93
|
+
case "password":
|
|
94
|
+
case "text":
|
|
95
|
+
break;
|
|
96
|
+
case "checkbox":
|
|
97
|
+
extension = getCheckboxExt(item);
|
|
98
|
+
break;
|
|
99
|
+
case "lookup":
|
|
100
|
+
extension = getLookupExt(item);
|
|
101
|
+
break;
|
|
102
|
+
case "multiline":
|
|
103
|
+
extension = getMultilineExt(item);
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
return extension;
|
|
107
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FormItem, ValidationResult } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Validate form item by it's own validators
|
|
4
|
+
* @param item Form item to validate
|
|
5
|
+
* @param value Form item last value
|
|
6
|
+
* @returns Instance of @see ValidationResult with result of validation
|
|
7
|
+
*/
|
|
8
|
+
export declare const validateItem: (item: FormItem<any>, value: any) => ValidationResult;
|
|
9
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/redux/utils/validate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAA2B,MAAM,aAAa,CAAC;AAElF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,SAAU,SAAS,GAAG,CAAC,SAAS,GAAG,KAAG,gBA8B9D,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isNullOrUndefined, isStringEmpty } from "@bodynarf/utils";
|
|
2
|
+
import { FormItemValidationState } from "../../types";
|
|
3
|
+
/**
|
|
4
|
+
* Validate form item by it's own validators
|
|
5
|
+
* @param item Form item to validate
|
|
6
|
+
* @param value Form item last value
|
|
7
|
+
* @returns Instance of @see ValidationResult with result of validation
|
|
8
|
+
*/
|
|
9
|
+
export const validateItem = (item, value) => {
|
|
10
|
+
if (item.modelConfig.validators.length === 0) {
|
|
11
|
+
return {
|
|
12
|
+
fieldName: item.name,
|
|
13
|
+
messages: [],
|
|
14
|
+
state: FormItemValidationState.None,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const messages = [];
|
|
18
|
+
item.modelConfig.validators.forEach(validator => {
|
|
19
|
+
const error = validator(value);
|
|
20
|
+
if (isNullOrUndefined(error) || isStringEmpty(error)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
messages.push(error);
|
|
24
|
+
});
|
|
25
|
+
const status = messages.length > 0
|
|
26
|
+
? FormItemValidationState.Invalid
|
|
27
|
+
: FormItemValidationState.Valid;
|
|
28
|
+
return {
|
|
29
|
+
fieldName: item.name,
|
|
30
|
+
messages: messages,
|
|
31
|
+
state: status
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/form/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
|