@bodynarf/react.components 1.4.18 → 1.4.20

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.
Files changed (237) hide show
  1. package/components/dropdown/index.d.ts +1 -1
  2. package/components/dropdown/index.d.ts.map +1 -1
  3. package/components/form/component/index.d.ts +16 -0
  4. package/components/form/component/index.d.ts.map +1 -0
  5. package/components/form/component/index.js +13 -0
  6. package/components/form/component/styles.scss +33 -0
  7. package/components/form/components/cell/index.d.ts +13 -0
  8. package/components/form/components/cell/index.d.ts.map +1 -0
  9. package/components/form/components/cell/index.js +8 -0
  10. package/components/form/components/container/index.d.ts +24 -0
  11. package/components/form/components/container/index.d.ts.map +1 -0
  12. package/components/form/components/container/index.js +26 -0
  13. package/components/form/components/form/index.d.ts +11 -0
  14. package/components/form/components/form/index.d.ts.map +1 -0
  15. package/components/form/components/form/index.js +11 -0
  16. package/components/form/components/inputs/checkbox/index.d.ts +6 -0
  17. package/components/form/components/inputs/checkbox/index.d.ts.map +1 -0
  18. package/components/form/components/inputs/checkbox/index.js +19 -0
  19. package/components/form/components/inputs/date/index.d.ts +7 -0
  20. package/components/form/components/inputs/date/index.d.ts.map +1 -0
  21. package/components/form/components/inputs/date/index.js +19 -0
  22. package/components/form/components/inputs/lookup/index.d.ts +6 -0
  23. package/components/form/components/inputs/lookup/index.d.ts.map +1 -0
  24. package/components/form/components/inputs/lookup/index.js +19 -0
  25. package/components/form/components/inputs/multiline/index.d.ts +6 -0
  26. package/components/form/components/inputs/multiline/index.d.ts.map +1 -0
  27. package/components/form/components/inputs/multiline/index.js +19 -0
  28. package/components/form/components/inputs/number/index.d.ts +6 -0
  29. package/components/form/components/inputs/number/index.d.ts.map +1 -0
  30. package/components/form/components/inputs/number/index.js +19 -0
  31. package/components/form/components/inputs/password/index.d.ts +6 -0
  32. package/components/form/components/inputs/password/index.d.ts.map +1 -0
  33. package/components/form/components/inputs/password/index.js +19 -0
  34. package/components/form/components/inputs/text/index.d.ts +6 -0
  35. package/components/form/components/inputs/text/index.d.ts.map +1 -0
  36. package/components/form/components/inputs/text/index.js +23 -0
  37. package/components/form/components/item/index.d.ts +4 -0
  38. package/components/form/components/item/index.d.ts.map +1 -0
  39. package/components/form/components/item/index.js +28 -0
  40. package/components/form/components/row/index.d.ts +10 -0
  41. package/components/form/components/row/index.d.ts.map +1 -0
  42. package/components/form/components/row/index.js +27 -0
  43. package/components/form/index.d.ts +3 -0
  44. package/components/form/index.d.ts.map +1 -0
  45. package/components/form/index.js +2 -0
  46. package/components/form/redux/actionCreators/index.d.ts +7 -0
  47. package/components/form/redux/actionCreators/index.d.ts.map +1 -0
  48. package/components/form/redux/actionCreators/index.js +6 -0
  49. package/components/form/redux/actionCreators/initForm.d.ts +9 -0
  50. package/components/form/redux/actionCreators/initForm.d.ts.map +1 -0
  51. package/components/form/redux/actionCreators/initForm.js +12 -0
  52. package/components/form/redux/actionCreators/setFieldValue.d.ts +9 -0
  53. package/components/form/redux/actionCreators/setFieldValue.d.ts.map +1 -0
  54. package/components/form/redux/actionCreators/setFieldValue.js +18 -0
  55. package/components/form/redux/actionCreators/setFormState.d.ts +8 -0
  56. package/components/form/redux/actionCreators/setFormState.d.ts.map +1 -0
  57. package/components/form/redux/actionCreators/setFormState.js +14 -0
  58. package/components/form/redux/actionCreators/setValidationResult.d.ts +9 -0
  59. package/components/form/redux/actionCreators/setValidationResult.d.ts.map +1 -0
  60. package/components/form/redux/actionCreators/setValidationResult.js +14 -0
  61. package/components/form/redux/actionCreators/submitForm.d.ts +7 -0
  62. package/components/form/redux/actionCreators/submitForm.d.ts.map +1 -0
  63. package/components/form/redux/actionCreators/submitForm.js +10 -0
  64. package/components/form/redux/actionCreators/validateField.d.ts +8 -0
  65. package/components/form/redux/actionCreators/validateField.d.ts.map +1 -0
  66. package/components/form/redux/actionCreators/validateField.js +12 -0
  67. package/components/form/redux/actionTypes.d.ts +13 -0
  68. package/components/form/redux/actionTypes.d.ts.map +1 -0
  69. package/components/form/redux/actionTypes.js +12 -0
  70. package/components/form/redux/actions/index.d.ts +2 -0
  71. package/components/form/redux/actions/index.d.ts.map +1 -0
  72. package/components/form/redux/actions/index.js +1 -0
  73. package/components/form/redux/actions/submitForm.d.ts +9 -0
  74. package/components/form/redux/actions/submitForm.d.ts.map +1 -0
  75. package/components/form/redux/actions/submitForm.js +16 -0
  76. package/components/form/redux/index.d.ts +8 -0
  77. package/components/form/redux/index.d.ts.map +1 -0
  78. package/components/form/redux/index.js +7 -0
  79. package/components/form/redux/reducer.d.ts +4 -0
  80. package/components/form/redux/reducer.d.ts.map +1 -0
  81. package/components/form/redux/reducer.js +103 -0
  82. package/components/form/redux/store.d.ts +5 -0
  83. package/components/form/redux/store.d.ts.map +1 -0
  84. package/components/form/redux/store.js +4 -0
  85. package/components/form/redux/types/base/types.d.ts +9 -0
  86. package/components/form/redux/types/base/types.d.ts.map +1 -0
  87. package/components/form/redux/types/base/types.js +2 -0
  88. package/components/form/redux/types/fieldValue.d.ts +10 -0
  89. package/components/form/redux/types/fieldValue.d.ts.map +1 -0
  90. package/components/form/redux/types/fieldValue.js +1 -0
  91. package/components/form/redux/types/index.d.ts +4 -0
  92. package/components/form/redux/types/index.d.ts.map +1 -0
  93. package/components/form/redux/types/index.js +3 -0
  94. package/components/form/redux/types/state.d.ts +37 -0
  95. package/components/form/redux/types/state.d.ts.map +1 -0
  96. package/components/form/redux/types/state.js +12 -0
  97. package/components/form/redux/utils/index.d.ts +3 -0
  98. package/components/form/redux/utils/index.d.ts.map +1 -0
  99. package/components/form/redux/utils/index.js +2 -0
  100. package/components/form/redux/utils/mapper.d.ts +16 -0
  101. package/components/form/redux/utils/mapper.d.ts.map +1 -0
  102. package/components/form/redux/utils/mapper.js +107 -0
  103. package/components/form/redux/utils/validate.d.ts +9 -0
  104. package/components/form/redux/utils/validate.d.ts.map +1 -0
  105. package/components/form/redux/utils/validate.js +33 -0
  106. package/components/form/types/index.d.ts +3 -0
  107. package/components/form/types/index.d.ts.map +1 -0
  108. package/components/form/types/index.js +2 -0
  109. package/components/form/types/model/extensions/extendedField.d.ts +7 -0
  110. package/components/form/types/model/extensions/extendedField.d.ts.map +1 -0
  111. package/components/form/types/model/extensions/extendedField.js +1 -0
  112. package/components/form/types/model/extensions/extendedFormItem.d.ts +7 -0
  113. package/components/form/types/model/extensions/extendedFormItem.d.ts.map +1 -0
  114. package/components/form/types/model/extensions/extendedFormItem.js +2 -0
  115. package/components/form/types/model/extensions/index.d.ts +4 -0
  116. package/components/form/types/model/extensions/index.d.ts.map +1 -0
  117. package/components/form/types/model/extensions/index.js +3 -0
  118. package/components/form/types/model/extensions/items/checkbox.d.ts +17 -0
  119. package/components/form/types/model/extensions/items/checkbox.d.ts.map +1 -0
  120. package/components/form/types/model/extensions/items/checkbox.js +14 -0
  121. package/components/form/types/model/extensions/items/getExtension.d.ts +9 -0
  122. package/components/form/types/model/extensions/items/getExtension.d.ts.map +1 -0
  123. package/components/form/types/model/extensions/items/getExtension.js +18 -0
  124. package/components/form/types/model/extensions/items/index.d.ts +5 -0
  125. package/components/form/types/model/extensions/items/index.d.ts.map +1 -0
  126. package/components/form/types/model/extensions/items/index.js +4 -0
  127. package/components/form/types/model/extensions/items/lookup.d.ts +20 -0
  128. package/components/form/types/model/extensions/items/lookup.d.ts.map +1 -0
  129. package/components/form/types/model/extensions/items/lookup.js +15 -0
  130. package/components/form/types/model/extensions/items/multiline.d.ts +17 -0
  131. package/components/form/types/model/extensions/items/multiline.d.ts.map +1 -0
  132. package/components/form/types/model/extensions/items/multiline.js +14 -0
  133. package/components/form/types/model/form.config.d.ts +16 -0
  134. package/components/form/types/model/form.config.d.ts.map +1 -0
  135. package/components/form/types/model/form.config.js +2 -0
  136. package/components/form/types/model/formItem.d.ts +12 -0
  137. package/components/form/types/model/formItem.d.ts.map +1 -0
  138. package/components/form/types/model/formItem.js +1 -0
  139. package/components/form/types/model/formItem.modelConfig.d.ts +20 -0
  140. package/components/form/types/model/formItem.modelConfig.d.ts.map +1 -0
  141. package/components/form/types/model/formItem.modelConfig.js +1 -0
  142. package/components/form/types/model/formItem.viewConfig.d.ts +15 -0
  143. package/components/form/types/model/formItem.viewConfig.d.ts.map +1 -0
  144. package/components/form/types/model/formItem.viewConfig.js +1 -0
  145. package/components/form/types/model/formItemValidationState.d.ts +10 -0
  146. package/components/form/types/model/formItemValidationState.d.ts.map +1 -0
  147. package/components/form/types/model/formItemValidationState.js +11 -0
  148. package/components/form/types/model/in/baseField.d.ts +21 -0
  149. package/components/form/types/model/in/baseField.d.ts.map +1 -0
  150. package/components/form/types/model/in/baseField.js +1 -0
  151. package/components/form/types/model/in/captionConfig.d.ts +14 -0
  152. package/components/form/types/model/in/captionConfig.d.ts.map +1 -0
  153. package/components/form/types/model/in/captionConfig.js +1 -0
  154. package/components/form/types/model/in/fieldType.d.ts +3 -0
  155. package/components/form/types/model/in/fieldType.d.ts.map +1 -0
  156. package/components/form/types/model/in/fieldType.js +1 -0
  157. package/components/form/types/model/in/fieldValidator.d.ts +3 -0
  158. package/components/form/types/model/in/fieldValidator.d.ts.map +1 -0
  159. package/components/form/types/model/in/fieldValidator.js +1 -0
  160. package/components/form/types/model/in/index.d.ts +6 -0
  161. package/components/form/types/model/in/index.d.ts.map +1 -0
  162. package/components/form/types/model/in/index.js +5 -0
  163. package/components/form/types/model/in/viewConfig.d.ts +24 -0
  164. package/components/form/types/model/in/viewConfig.d.ts.map +1 -0
  165. package/components/form/types/model/in/viewConfig.js +1 -0
  166. package/components/form/types/model/index.d.ts +9 -0
  167. package/components/form/types/model/index.d.ts.map +1 -0
  168. package/components/form/types/model/index.js +8 -0
  169. package/components/form/types/model/validationResult.d.ts +11 -0
  170. package/components/form/types/model/validationResult.d.ts.map +1 -0
  171. package/components/form/types/model/validationResult.js +2 -0
  172. package/components/form/types/view/gridCell.d.ts +15 -0
  173. package/components/form/types/view/gridCell.d.ts.map +1 -0
  174. package/components/form/types/view/gridCell.js +1 -0
  175. package/components/form/types/view/index.d.ts +2 -0
  176. package/components/form/types/view/index.d.ts.map +1 -0
  177. package/components/form/types/view/index.js +1 -0
  178. package/components/form/utils/component.d.ts +9 -0
  179. package/components/form/utils/component.d.ts.map +1 -0
  180. package/components/form/utils/component.js +16 -0
  181. package/components/form/utils/grid.d.ts +17 -0
  182. package/components/form/utils/grid.d.ts.map +1 -0
  183. package/components/form/utils/grid.js +75 -0
  184. package/components/form/utils/index.d.ts +4 -0
  185. package/components/form/utils/index.d.ts.map +1 -0
  186. package/components/form/utils/index.js +3 -0
  187. package/components/form/utils/validators/index.d.ts +4 -0
  188. package/components/form/utils/validators/index.d.ts.map +1 -0
  189. package/components/form/utils/validators/index.js +3 -0
  190. package/components/form/utils/validators/number/greaterThanZero.d.ts +7 -0
  191. package/components/form/utils/validators/number/greaterThanZero.d.ts.map +1 -0
  192. package/components/form/utils/validators/number/greaterThanZero.js +7 -0
  193. package/components/form/utils/validators/number/index.d.ts +4 -0
  194. package/components/form/utils/validators/number/index.d.ts.map +1 -0
  195. package/components/form/utils/validators/number/index.js +3 -0
  196. package/components/form/utils/validators/number/lessThanZero.d.ts +7 -0
  197. package/components/form/utils/validators/number/lessThanZero.d.ts.map +1 -0
  198. package/components/form/utils/validators/number/lessThanZero.js +7 -0
  199. package/components/form/utils/validators/number/notZero.d.ts +7 -0
  200. package/components/form/utils/validators/number/notZero.d.ts.map +1 -0
  201. package/components/form/utils/validators/number/notZero.js +7 -0
  202. package/components/form/utils/validators/required.d.ts +7 -0
  203. package/components/form/utils/validators/required.d.ts.map +1 -0
  204. package/components/form/utils/validators/required.js +8 -0
  205. package/components/form/utils/validators/string/index.d.ts +2 -0
  206. package/components/form/utils/validators/string/index.d.ts.map +1 -0
  207. package/components/form/utils/validators/string/index.js +1 -0
  208. package/components/form/utils/validators/string/length.d.ts +8 -0
  209. package/components/form/utils/validators/string/length.d.ts.map +1 -0
  210. package/components/form/utils/validators/string/length.js +12 -0
  211. package/components/primitives/date/index.d.ts +0 -1
  212. package/components/primitives/date/index.d.ts.map +1 -1
  213. package/components/primitives/multiline/components/multilineWithLabel/index.d.ts +0 -1
  214. package/components/primitives/multiline/components/multilineWithLabel/index.d.ts.map +1 -1
  215. package/components/primitives/multiline/components/multilineWithoutLabel/index.d.ts +0 -1
  216. package/components/primitives/multiline/components/multilineWithoutLabel/index.d.ts.map +1 -1
  217. package/components/primitives/multiline/index.d.ts +0 -1
  218. package/components/primitives/multiline/index.d.ts.map +1 -1
  219. package/components/primitives/number/components/withLabel/index.d.ts +0 -1
  220. package/components/primitives/number/components/withLabel/index.d.ts.map +1 -1
  221. package/components/primitives/number/components/withoutLabel/index.d.ts +0 -1
  222. package/components/primitives/number/components/withoutLabel/index.d.ts.map +1 -1
  223. package/components/primitives/number/index.d.ts +0 -1
  224. package/components/primitives/number/index.d.ts.map +1 -1
  225. package/components/primitives/password/components/withLabel/index.d.ts +0 -1
  226. package/components/primitives/password/components/withLabel/index.d.ts.map +1 -1
  227. package/components/primitives/password/components/withoutLabel/index.d.ts +0 -1
  228. package/components/primitives/password/components/withoutLabel/index.d.ts.map +1 -1
  229. package/components/primitives/password/index.d.ts +0 -1
  230. package/components/primitives/password/index.d.ts.map +1 -1
  231. package/components/primitives/text/components/textWithLabel/index.d.ts +0 -1
  232. package/components/primitives/text/components/textWithLabel/index.d.ts.map +1 -1
  233. package/components/primitives/text/components/textWithoutLabel/index.d.ts +0 -1
  234. package/components/primitives/text/components/textWithoutLabel/index.d.ts.map +1 -1
  235. package/components/primitives/text/index.d.ts +0 -1
  236. package/components/primitives/text/index.d.ts.map +1 -1
  237. package/package.json +5 -2
@@ -0,0 +1,8 @@
1
+ import { ActionWithPayload, FormStatus } from "../types";
2
+ /**
3
+ * Get redux action "Set form state status"
4
+ * @param newStatus New form state status
5
+ * @returns State updating action
6
+ */
7
+ export declare const getSetFormStatus: (newStatus: FormStatus) => ActionWithPayload;
8
+ //# sourceMappingURL=setFormState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setFormState.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/redux/actionCreators/setFormState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGzD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,cAAe,UAAU,KAAG,iBAOxD,CAAC"}
@@ -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,7 @@
1
+ import { Action } from "redux";
2
+ /**
3
+ * Get redux action "Submit form"
4
+ * @returns State updating action
5
+ */
6
+ export declare const getSubmitFormAction: () => Action<string>;
7
+ //# sourceMappingURL=submitForm.d.ts.map
@@ -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,10 @@
1
+ import { submitForm } from "../actionTypes";
2
+ /**
3
+ * Get redux action "Submit form"
4
+ * @returns State updating action
5
+ */
6
+ export const getSubmitFormAction = () => {
7
+ return ({
8
+ type: submitForm,
9
+ });
10
+ };
@@ -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,2 @@
1
+ export * from "./submitForm";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -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,8 @@
1
+ export * from "./actionCreators";
2
+ export * from "./reducer";
3
+ export * from "./utils";
4
+ export * from "./actionTypes";
5
+ export * from "./store";
6
+ export * from "./types";
7
+ export * from "./actions";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -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,7 @@
1
+ export * from "./actionCreators";
2
+ export * from "./reducer";
3
+ export * from "./utils";
4
+ export * from "./actionTypes";
5
+ export * from "./store";
6
+ export * from "./types";
7
+ export * from "./actions";
@@ -0,0 +1,4 @@
1
+ import { ActionWithPayload, FormState } from "./types";
2
+ /** Form reducer function */
3
+ export default function (state: FormState | undefined, action: ActionWithPayload): FormState;
4
+ //# sourceMappingURL=reducer.d.ts.map
@@ -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,5 @@
1
+ declare const _default: import("redux").Store<import("./types").FormState, import("./types").ActionWithPayload> & {
2
+ dispatch: unknown;
3
+ };
4
+ export default _default;
5
+ //# sourceMappingURL=store.d.ts.map
@@ -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,4 @@
1
+ import { createStore, applyMiddleware } from "redux";
2
+ import thunkMiddleware from 'redux-thunk';
3
+ import rootReducer from "./reducer";
4
+ export default createStore(rootReducer, applyMiddleware(thunkMiddleware));
@@ -0,0 +1,9 @@
1
+ import { AnyAction } from "redux";
2
+ /** Redux action with some extra payload */
3
+ export interface ActionWithPayload extends AnyAction {
4
+ /** Action payload data */
5
+ payload: {
6
+ [extraProps: string]: unknown;
7
+ };
8
+ }
9
+ //# sourceMappingURL=types.d.ts.map
@@ -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,2 @@
1
+ ;
2
+ export {};
@@ -0,0 +1,10 @@
1
+ /** Form field value */
2
+ export interface FieldValue {
3
+ /** Field name */
4
+ key: string;
5
+ /** Field value data type */
6
+ type: string;
7
+ /** Last field value */
8
+ value: any;
9
+ }
10
+ //# sourceMappingURL=fieldValue.d.ts.map
@@ -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,4 @@
1
+ export * from "./state";
2
+ export * from "./base/types";
3
+ export * from "./fieldValue";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -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,3 @@
1
+ export * from "./state";
2
+ export * from "./base/types";
3
+ export * from "./fieldValue";
@@ -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,3 @@
1
+ export * from "./mapper";
2
+ export * from "./validate";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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,2 @@
1
+ export * from "./mapper";
2
+ export * from "./validate";
@@ -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
+ };