@redneckz/wildless-cms-uni-blocks 0.14.134 → 0.14.136

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 (222) hide show
  1. package/bundle/blocks.schema.json +1 -1
  2. package/bundle/bundle.umd.js +329 -236
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/components/ApplicationForm/ApplicationFormAntiFraud.d.ts +12 -0
  5. package/bundle/components/ApplicationForm/ApplicationFormContent.d.ts +8 -1
  6. package/bundle/components/ApplicationForm/ApplicationFormFeedback.d.ts +8 -12
  7. package/bundle/components/ApplicationForm/ApplicationFormIndividuals.d.ts +2 -2
  8. package/bundle/components/ApplicationForm/EmbeddableForms.d.ts +1 -0
  9. package/bundle/components/ApplicationForm/InputControl.d.ts +2 -9
  10. package/bundle/components/ApplicationForm/PhoneInputControl.d.ts +2 -2
  11. package/bundle/components/ApplicationForm/handleSubmit.d.ts +16 -0
  12. package/bundle/components/ApplicationForm/renderTextarea.d.ts +9 -1
  13. package/bundle/components/ApplicationForm/renderUserData.d.ts +8 -1
  14. package/bundle/ui-kit/Input/InputProps.d.ts +2 -1
  15. package/dist/components/ApplicationForm/ApplicationForm.js +1 -1
  16. package/dist/components/ApplicationForm/ApplicationForm.js.map +1 -1
  17. package/dist/components/ApplicationForm/ApplicationFormAntiFraud.d.ts +12 -0
  18. package/dist/components/ApplicationForm/ApplicationFormAntiFraud.js +49 -0
  19. package/dist/components/ApplicationForm/ApplicationFormAntiFraud.js.map +1 -0
  20. package/dist/components/ApplicationForm/ApplicationFormContent.d.ts +8 -1
  21. package/dist/components/ApplicationForm/ApplicationFormFeedback.d.ts +8 -12
  22. package/dist/components/ApplicationForm/ApplicationFormFeedback.js +21 -34
  23. package/dist/components/ApplicationForm/ApplicationFormFeedback.js.map +1 -1
  24. package/dist/components/ApplicationForm/ApplicationFormIndividuals.d.ts +2 -2
  25. package/dist/components/ApplicationForm/ApplicationFormIndividuals.js +9 -9
  26. package/dist/components/ApplicationForm/ApplicationFormIndividuals.js.map +1 -1
  27. package/dist/components/ApplicationForm/ApplicationFormWed.js +5 -1
  28. package/dist/components/ApplicationForm/ApplicationFormWed.js.map +1 -1
  29. package/dist/components/ApplicationForm/EmbeddableForms.d.ts +1 -0
  30. package/dist/components/ApplicationForm/EmbeddableForms.js +2 -0
  31. package/dist/components/ApplicationForm/EmbeddableForms.js.map +1 -1
  32. package/dist/components/ApplicationForm/InputControl.d.ts +2 -9
  33. package/dist/components/ApplicationForm/InputControl.js +1 -1
  34. package/dist/components/ApplicationForm/InputControl.js.map +1 -1
  35. package/dist/components/ApplicationForm/PhoneInputControl.d.ts +2 -2
  36. package/dist/components/ApplicationForm/PhoneInputControl.js.map +1 -1
  37. package/dist/components/ApplicationForm/feedbackTypes.js +1 -1
  38. package/dist/components/ApplicationForm/handleSubmit.d.ts +16 -0
  39. package/dist/components/ApplicationForm/handleSubmit.js +71 -0
  40. package/dist/components/ApplicationForm/handleSubmit.js.map +1 -0
  41. package/dist/components/ApplicationForm/renderAgreementWithSubmit.js +1 -1
  42. package/dist/components/ApplicationForm/renderAgreementWithSubmit.js.map +1 -1
  43. package/dist/components/ApplicationForm/renderIndividualsFields.js +1 -1
  44. package/dist/components/ApplicationForm/renderIndividualsFields.js.map +1 -1
  45. package/dist/components/ApplicationForm/renderTextarea.d.ts +9 -1
  46. package/dist/components/ApplicationForm/renderTextarea.js +2 -1
  47. package/dist/components/ApplicationForm/renderTextarea.js.map +1 -1
  48. package/dist/components/ApplicationForm/renderUserData.d.ts +8 -1
  49. package/dist/components/ApplicationForm/renderUserData.js +1 -1
  50. package/dist/components/ApplicationForm/renderUserData.js.map +1 -1
  51. package/dist/ui-kit/Input/Input.js +8 -5
  52. package/dist/ui-kit/Input/Input.js.map +1 -1
  53. package/dist/ui-kit/Input/InputProps.d.ts +2 -1
  54. package/lib/common.css +1 -1
  55. package/lib/components/ApplicationForm/ApplicationForm.fixture.d.ts +1 -0
  56. package/lib/components/ApplicationForm/ApplicationForm.js +1 -1
  57. package/lib/components/ApplicationForm/ApplicationForm.js.map +1 -1
  58. package/lib/components/ApplicationForm/ApplicationFormAntiFraud.d.ts +12 -0
  59. package/lib/components/ApplicationForm/ApplicationFormAntiFraud.js +47 -0
  60. package/lib/components/ApplicationForm/ApplicationFormAntiFraud.js.map +1 -0
  61. package/lib/components/ApplicationForm/ApplicationFormContent.d.ts +8 -1
  62. package/lib/components/ApplicationForm/ApplicationFormFeedback.d.ts +8 -12
  63. package/lib/components/ApplicationForm/ApplicationFormFeedback.js +22 -35
  64. package/lib/components/ApplicationForm/ApplicationFormFeedback.js.map +1 -1
  65. package/lib/components/ApplicationForm/ApplicationFormIndividuals.d.ts +2 -2
  66. package/lib/components/ApplicationForm/ApplicationFormIndividuals.js +9 -9
  67. package/lib/components/ApplicationForm/ApplicationFormIndividuals.js.map +1 -1
  68. package/lib/components/ApplicationForm/ApplicationFormWed.js +5 -1
  69. package/lib/components/ApplicationForm/ApplicationFormWed.js.map +1 -1
  70. package/lib/components/ApplicationForm/EmbeddableForms.d.ts +1 -0
  71. package/lib/components/ApplicationForm/EmbeddableForms.js +2 -0
  72. package/lib/components/ApplicationForm/EmbeddableForms.js.map +1 -1
  73. package/lib/components/ApplicationForm/InputControl.d.ts +2 -9
  74. package/lib/components/ApplicationForm/InputControl.js +1 -1
  75. package/lib/components/ApplicationForm/InputControl.js.map +1 -1
  76. package/lib/components/ApplicationForm/PhoneInputControl.d.ts +2 -2
  77. package/lib/components/ApplicationForm/PhoneInputControl.js.map +1 -1
  78. package/lib/components/ApplicationForm/feedbackTypes.js +1 -1
  79. package/lib/components/ApplicationForm/handleSubmit.d.ts +16 -0
  80. package/lib/components/ApplicationForm/handleSubmit.js +66 -0
  81. package/lib/components/ApplicationForm/handleSubmit.js.map +1 -0
  82. package/lib/components/ApplicationForm/renderAgreementWithSubmit.js +1 -1
  83. package/lib/components/ApplicationForm/renderAgreementWithSubmit.js.map +1 -1
  84. package/lib/components/ApplicationForm/renderIndividualsFields.js +1 -1
  85. package/lib/components/ApplicationForm/renderIndividualsFields.js.map +1 -1
  86. package/lib/components/ApplicationForm/renderTextarea.d.ts +9 -1
  87. package/lib/components/ApplicationForm/renderTextarea.js +2 -1
  88. package/lib/components/ApplicationForm/renderTextarea.js.map +1 -1
  89. package/lib/components/ApplicationForm/renderUserData.d.ts +8 -1
  90. package/lib/components/ApplicationForm/renderUserData.js +1 -1
  91. package/lib/components/ApplicationForm/renderUserData.js.map +1 -1
  92. package/lib/ui-kit/Input/Input.js +8 -5
  93. package/lib/ui-kit/Input/Input.js.map +1 -1
  94. package/lib/ui-kit/Input/InputProps.d.ts +2 -1
  95. package/mobile/bundle/bundle.umd.js +329 -236
  96. package/mobile/bundle/bundle.umd.min.js +1 -1
  97. package/mobile/bundle/components/ApplicationForm/ApplicationFormAntiFraud.d.ts +12 -0
  98. package/mobile/bundle/components/ApplicationForm/ApplicationFormContent.d.ts +8 -1
  99. package/mobile/bundle/components/ApplicationForm/ApplicationFormFeedback.d.ts +8 -12
  100. package/mobile/bundle/components/ApplicationForm/ApplicationFormIndividuals.d.ts +2 -2
  101. package/mobile/bundle/components/ApplicationForm/EmbeddableForms.d.ts +1 -0
  102. package/mobile/bundle/components/ApplicationForm/InputControl.d.ts +2 -9
  103. package/mobile/bundle/components/ApplicationForm/PhoneInputControl.d.ts +2 -2
  104. package/mobile/bundle/components/ApplicationForm/handleSubmit.d.ts +16 -0
  105. package/mobile/bundle/components/ApplicationForm/renderTextarea.d.ts +9 -1
  106. package/mobile/bundle/components/ApplicationForm/renderUserData.d.ts +8 -1
  107. package/mobile/bundle/ui-kit/Input/InputProps.d.ts +2 -1
  108. package/mobile/dist/components/ApplicationForm/ApplicationForm.js +1 -1
  109. package/mobile/dist/components/ApplicationForm/ApplicationForm.js.map +1 -1
  110. package/mobile/dist/components/ApplicationForm/ApplicationFormAntiFraud.d.ts +12 -0
  111. package/mobile/dist/components/ApplicationForm/ApplicationFormAntiFraud.js +49 -0
  112. package/mobile/dist/components/ApplicationForm/ApplicationFormAntiFraud.js.map +1 -0
  113. package/mobile/dist/components/ApplicationForm/ApplicationFormContent.d.ts +8 -1
  114. package/mobile/dist/components/ApplicationForm/ApplicationFormFeedback.d.ts +8 -12
  115. package/mobile/dist/components/ApplicationForm/ApplicationFormFeedback.js +21 -34
  116. package/mobile/dist/components/ApplicationForm/ApplicationFormFeedback.js.map +1 -1
  117. package/mobile/dist/components/ApplicationForm/ApplicationFormIndividuals.d.ts +2 -2
  118. package/mobile/dist/components/ApplicationForm/ApplicationFormIndividuals.js +9 -9
  119. package/mobile/dist/components/ApplicationForm/ApplicationFormIndividuals.js.map +1 -1
  120. package/mobile/dist/components/ApplicationForm/ApplicationFormWed.js +5 -1
  121. package/mobile/dist/components/ApplicationForm/ApplicationFormWed.js.map +1 -1
  122. package/mobile/dist/components/ApplicationForm/EmbeddableForms.d.ts +1 -0
  123. package/mobile/dist/components/ApplicationForm/EmbeddableForms.js +2 -0
  124. package/mobile/dist/components/ApplicationForm/EmbeddableForms.js.map +1 -1
  125. package/mobile/dist/components/ApplicationForm/InputControl.d.ts +2 -9
  126. package/mobile/dist/components/ApplicationForm/InputControl.js +1 -1
  127. package/mobile/dist/components/ApplicationForm/InputControl.js.map +1 -1
  128. package/mobile/dist/components/ApplicationForm/PhoneInputControl.d.ts +2 -2
  129. package/mobile/dist/components/ApplicationForm/PhoneInputControl.js.map +1 -1
  130. package/mobile/dist/components/ApplicationForm/feedbackTypes.js +1 -1
  131. package/mobile/dist/components/ApplicationForm/handleSubmit.d.ts +16 -0
  132. package/mobile/dist/components/ApplicationForm/handleSubmit.js +71 -0
  133. package/mobile/dist/components/ApplicationForm/handleSubmit.js.map +1 -0
  134. package/mobile/dist/components/ApplicationForm/renderAgreementWithSubmit.js +1 -1
  135. package/mobile/dist/components/ApplicationForm/renderAgreementWithSubmit.js.map +1 -1
  136. package/mobile/dist/components/ApplicationForm/renderIndividualsFields.js +1 -1
  137. package/mobile/dist/components/ApplicationForm/renderIndividualsFields.js.map +1 -1
  138. package/mobile/dist/components/ApplicationForm/renderTextarea.d.ts +9 -1
  139. package/mobile/dist/components/ApplicationForm/renderTextarea.js +2 -1
  140. package/mobile/dist/components/ApplicationForm/renderTextarea.js.map +1 -1
  141. package/mobile/dist/components/ApplicationForm/renderUserData.d.ts +8 -1
  142. package/mobile/dist/components/ApplicationForm/renderUserData.js +1 -1
  143. package/mobile/dist/components/ApplicationForm/renderUserData.js.map +1 -1
  144. package/mobile/dist/ui-kit/Input/Input.js +8 -5
  145. package/mobile/dist/ui-kit/Input/Input.js.map +1 -1
  146. package/mobile/dist/ui-kit/Input/InputProps.d.ts +2 -1
  147. package/mobile/lib/common.css +1 -1
  148. package/mobile/lib/components/ApplicationForm/ApplicationForm.js +1 -1
  149. package/mobile/lib/components/ApplicationForm/ApplicationForm.js.map +1 -1
  150. package/mobile/lib/components/ApplicationForm/ApplicationFormAntiFraud.d.ts +12 -0
  151. package/mobile/lib/components/ApplicationForm/ApplicationFormAntiFraud.js +47 -0
  152. package/mobile/lib/components/ApplicationForm/ApplicationFormAntiFraud.js.map +1 -0
  153. package/mobile/lib/components/ApplicationForm/ApplicationFormContent.d.ts +8 -1
  154. package/mobile/lib/components/ApplicationForm/ApplicationFormFeedback.d.ts +8 -12
  155. package/mobile/lib/components/ApplicationForm/ApplicationFormFeedback.js +22 -35
  156. package/mobile/lib/components/ApplicationForm/ApplicationFormFeedback.js.map +1 -1
  157. package/mobile/lib/components/ApplicationForm/ApplicationFormIndividuals.d.ts +2 -2
  158. package/mobile/lib/components/ApplicationForm/ApplicationFormIndividuals.js +9 -9
  159. package/mobile/lib/components/ApplicationForm/ApplicationFormIndividuals.js.map +1 -1
  160. package/mobile/lib/components/ApplicationForm/ApplicationFormWed.js +5 -1
  161. package/mobile/lib/components/ApplicationForm/ApplicationFormWed.js.map +1 -1
  162. package/mobile/lib/components/ApplicationForm/EmbeddableForms.d.ts +1 -0
  163. package/mobile/lib/components/ApplicationForm/EmbeddableForms.js +2 -0
  164. package/mobile/lib/components/ApplicationForm/EmbeddableForms.js.map +1 -1
  165. package/mobile/lib/components/ApplicationForm/InputControl.d.ts +2 -9
  166. package/mobile/lib/components/ApplicationForm/InputControl.js +1 -1
  167. package/mobile/lib/components/ApplicationForm/InputControl.js.map +1 -1
  168. package/mobile/lib/components/ApplicationForm/PhoneInputControl.d.ts +2 -2
  169. package/mobile/lib/components/ApplicationForm/PhoneInputControl.js.map +1 -1
  170. package/mobile/lib/components/ApplicationForm/feedbackTypes.js +1 -1
  171. package/mobile/lib/components/ApplicationForm/handleSubmit.d.ts +16 -0
  172. package/mobile/lib/components/ApplicationForm/handleSubmit.js +66 -0
  173. package/mobile/lib/components/ApplicationForm/handleSubmit.js.map +1 -0
  174. package/mobile/lib/components/ApplicationForm/renderAgreementWithSubmit.js +1 -1
  175. package/mobile/lib/components/ApplicationForm/renderAgreementWithSubmit.js.map +1 -1
  176. package/mobile/lib/components/ApplicationForm/renderIndividualsFields.js +1 -1
  177. package/mobile/lib/components/ApplicationForm/renderIndividualsFields.js.map +1 -1
  178. package/mobile/lib/components/ApplicationForm/renderTextarea.d.ts +9 -1
  179. package/mobile/lib/components/ApplicationForm/renderTextarea.js +2 -1
  180. package/mobile/lib/components/ApplicationForm/renderTextarea.js.map +1 -1
  181. package/mobile/lib/components/ApplicationForm/renderUserData.d.ts +8 -1
  182. package/mobile/lib/components/ApplicationForm/renderUserData.js +1 -1
  183. package/mobile/lib/components/ApplicationForm/renderUserData.js.map +1 -1
  184. package/mobile/lib/ui-kit/Input/Input.js +8 -5
  185. package/mobile/lib/ui-kit/Input/Input.js.map +1 -1
  186. package/mobile/lib/ui-kit/Input/InputProps.d.ts +2 -1
  187. package/mobile/src/components/ApplicationForm/ApplicationForm.tsx +6 -9
  188. package/mobile/src/components/ApplicationForm/ApplicationFormAntiFraud.tsx +86 -0
  189. package/mobile/src/components/ApplicationForm/ApplicationFormContent.ts +11 -1
  190. package/mobile/src/components/ApplicationForm/ApplicationFormFeedback.tsx +62 -85
  191. package/mobile/src/components/ApplicationForm/ApplicationFormIndividuals.tsx +13 -12
  192. package/mobile/src/components/ApplicationForm/ApplicationFormWed.tsx +5 -4
  193. package/mobile/src/components/ApplicationForm/EmbeddableForms.tsx +2 -0
  194. package/mobile/src/components/ApplicationForm/InputControl.tsx +5 -11
  195. package/mobile/src/components/ApplicationForm/PhoneInputControl.tsx +2 -2
  196. package/mobile/src/components/ApplicationForm/feedbackTypes.ts +1 -1
  197. package/mobile/src/components/ApplicationForm/handleSubmit.tsx +87 -0
  198. package/mobile/src/components/ApplicationForm/renderAgreementWithSubmit.tsx +1 -1
  199. package/mobile/src/components/ApplicationForm/renderIndividualsFields.tsx +2 -2
  200. package/mobile/src/components/ApplicationForm/renderTextarea.tsx +35 -23
  201. package/mobile/src/components/ApplicationForm/renderUserData.tsx +15 -5
  202. package/mobile/src/ui-kit/Input/Input.tsx +45 -31
  203. package/mobile/src/ui-kit/Input/InputProps.ts +2 -1
  204. package/package.json +2 -2
  205. package/src/components/ApplicationForm/ApplicationForm.fixture.tsx +14 -0
  206. package/src/components/ApplicationForm/ApplicationForm.tsx +6 -9
  207. package/src/components/ApplicationForm/ApplicationFormAntiFraud.tsx +86 -0
  208. package/src/components/ApplicationForm/ApplicationFormContent.ts +11 -1
  209. package/src/components/ApplicationForm/ApplicationFormFeedback.tsx +62 -85
  210. package/src/components/ApplicationForm/ApplicationFormIndividuals.tsx +13 -12
  211. package/src/components/ApplicationForm/ApplicationFormWed.tsx +5 -4
  212. package/src/components/ApplicationForm/EmbeddableForms.tsx +2 -0
  213. package/src/components/ApplicationForm/InputControl.tsx +5 -11
  214. package/src/components/ApplicationForm/PhoneInputControl.tsx +2 -2
  215. package/src/components/ApplicationForm/feedbackTypes.ts +1 -1
  216. package/src/components/ApplicationForm/handleSubmit.tsx +87 -0
  217. package/src/components/ApplicationForm/renderAgreementWithSubmit.tsx +1 -1
  218. package/src/components/ApplicationForm/renderIndividualsFields.tsx +2 -2
  219. package/src/components/ApplicationForm/renderTextarea.tsx +35 -23
  220. package/src/components/ApplicationForm/renderUserData.tsx +15 -5
  221. package/src/ui-kit/Input/Input.tsx +45 -31
  222. package/src/ui-kit/Input/InputProps.ts +2 -1
@@ -0,0 +1,87 @@
1
+ import { objectValidator } from '../../validation/objectValidator';
2
+ import { isValidationSuccess } from '../../validation/validator';
3
+ import { type FeedbackFormState } from './ApplicationFormFeedback';
4
+ import { type ApplicationFormsProps } from './ApplicationFormsProps';
5
+ import {
6
+ consentDataProcessingValidator,
7
+ defaultValidator,
8
+ innValidator,
9
+ nameValidator,
10
+ phoneValidator,
11
+ } from './validators';
12
+
13
+ export const feedbackValidatorDefaultObject = {
14
+ typeForm: defaultValidator,
15
+ region: defaultValidator,
16
+ surname: defaultValidator,
17
+ name: nameValidator,
18
+ feedbackMethod: defaultValidator,
19
+ phone: phoneValidator,
20
+ email: defaultValidator,
21
+ comment: defaultValidator,
22
+ consentDataProcessing: consentDataProcessingValidator,
23
+ };
24
+
25
+ export const handleSubmitIndividual = (
26
+ formState: FeedbackFormState,
27
+ onSubmit: ApplicationFormsProps['onSubmit'],
28
+ ) => {
29
+ const feedbackValidator = objectValidator({
30
+ ...feedbackValidatorDefaultObject,
31
+ addressBranch: defaultValidator,
32
+ });
33
+ const { region, phone, secondaryPhone } = formState;
34
+
35
+ const submitData = {
36
+ ...formState,
37
+ typeForm: formState.typeForm.key,
38
+ addressBranch: formState.addressBranch?.text || '',
39
+ feedbackMethod: formState.feedbackMethod.text,
40
+ regionBranch: region?.text,
41
+ phoneNumber: phone.replace(/[^+\d]/g, ''),
42
+ secondaryPhoneNumber: secondaryPhone,
43
+ };
44
+ isValidationSuccess(feedbackValidator(formState)) && onSubmit(submitData);
45
+ };
46
+
47
+ export const handleSubmitLegal = (
48
+ formState: FeedbackFormState,
49
+ onSubmit: ApplicationFormsProps['onSubmit'],
50
+ ) => {
51
+ const feedbackValidator = objectValidator({
52
+ ...feedbackValidatorDefaultObject,
53
+ addressBranch: defaultValidator,
54
+ inn: innValidator,
55
+ });
56
+ const { secondaryPhone, email } = formState;
57
+ const submitData = {
58
+ ...formState,
59
+ typeForm: formState.typeForm.key,
60
+ region: formState.region?.text,
61
+ addressBranch: formState.addressBranch?.text || '',
62
+ feedbackMethod: formState.feedbackMethod.text,
63
+ phone: formState.phone.replace(/[^+\d]/g, ''),
64
+ secondaryPhoneNumber: secondaryPhone,
65
+ mail: email,
66
+ };
67
+ isValidationSuccess(feedbackValidator(formState)) && onSubmit(submitData, true);
68
+ };
69
+
70
+ export const handleSubmitQuestion = (
71
+ formState: FeedbackFormState,
72
+ onSubmit: ApplicationFormsProps['onSubmit'],
73
+ ) => {
74
+ const feedbackValidator = objectValidator({
75
+ ...feedbackValidatorDefaultObject,
76
+ birthday: defaultValidator,
77
+ });
78
+ const { region, phone } = formState;
79
+ const submitData = {
80
+ ...formState,
81
+ typeForm: formState.typeForm.key,
82
+ feedbackMethod: formState.feedbackMethod.text,
83
+ regionBranch: region?.text,
84
+ phoneNumber: phone.replace(/[^+\d]/g, ''),
85
+ };
86
+ isValidationSuccess(feedbackValidator(formState)) && onSubmit(submitData);
87
+ };
@@ -13,7 +13,7 @@ export const renderAgreementWithSubmit = (
13
13
  link?: LinkProps,
14
14
  button?: SubmitButtonProps,
15
15
  ) => (
16
- <div className="flex w-full justify-between items-baseline">
16
+ <div className="flex flex-col lg:flex-row w-full justify-between items-baseline">
17
17
  <div>
18
18
  <div className="flex gap-3">
19
19
  <Checkbox {...consentDataProcessing} />
@@ -21,11 +21,11 @@ export const renderIndividualsFields = (field: FormFieldRegisterer<IndividualsFo
21
21
  <InputControl label="Имя" {...withValidator(field('name'), nameValidator)} />
22
22
  <DatePickerControl
23
23
  label="Дата рождения*"
24
- {...withValidator(field('date'), defaultValidator)}
24
+ {...withValidator(field('birthday'), defaultValidator)}
25
25
  />
26
26
  <InputControl
27
27
  label="Электронная почта"
28
- {...withValidator(field('mail'), defaultValidator)}
28
+ {...withValidator(field('email'), defaultValidator)}
29
29
  />
30
30
  </div>
31
31
  }
@@ -1,30 +1,42 @@
1
1
  import { type FieldProps } from '../../hooks/useForm';
2
2
  import { Text } from '../../ui-kit/Text/Text';
3
3
  import { style } from '../../utils/style';
4
+ import { renderErrorText } from './renderErrorText';
5
+
6
+ interface TextFieldProps {
7
+ textField: FieldProps<string>;
8
+ text?: string;
9
+ placeholder?: string;
10
+ value?: string;
11
+ error?: string;
12
+ }
4
13
 
5
14
  const activeTextareaStyles =
6
15
  'hover:border-primary-hover active:focus:border-primary-text focus:border-primary-text';
7
- export const renderTextarea = (textField: FieldProps<string>, text?: string, placeholder = '') => (
8
- <label className="space-y-xs" htmlFor="textarea">
9
- {text ? (
10
- <div>
11
- <Text size="text-m" font="font-light">
12
- {text}
13
- </Text>
14
- </div>
15
- ) : null}
16
- <textarea
17
- id="textarea"
18
- placeholder={placeholder}
19
- className={style(
20
- 'block w-full resize-y min-h-24 p-m outline-none border rounded-md border-gray',
21
- activeTextareaStyles,
22
- )}
23
- value={textField.value}
24
- onInput={
25
- ((e: { target?: { value?: string } }) =>
26
- textField.onChange && textField.onChange(e.target?.value || '')) as any
27
- }
28
- />
29
- </label>
16
+ export const renderTextarea = ({ textField, text, placeholder = '', error }: TextFieldProps) => (
17
+ <div>
18
+ <label className="space-y-xs" htmlFor="textarea">
19
+ {text ? (
20
+ <div>
21
+ <Text size="text-m" font="font-light">
22
+ {text}
23
+ </Text>
24
+ </div>
25
+ ) : null}
26
+ <textarea
27
+ id="textarea"
28
+ placeholder={placeholder}
29
+ className={style(
30
+ 'block w-full resize-y min-h-24 p-m outline-none border rounded-md border-gray',
31
+ activeTextareaStyles,
32
+ )}
33
+ value={textField.value}
34
+ onInput={
35
+ ((e: { target?: { value?: string } }) =>
36
+ textField.onChange && textField.onChange(e.target?.value || '')) as any
37
+ }
38
+ />
39
+ </label>
40
+ {renderErrorText(error)}
41
+ </div>
30
42
  );
@@ -1,18 +1,28 @@
1
1
  import { type FormFieldRegisterer } from '../../hooks/useForm';
2
2
  import { withValidator } from '../../validation/withValidator';
3
+ import { type AntiFraudFormState } from './ApplicationFormAntiFraud';
3
4
  import { type FeedbackFormState } from './ApplicationFormFeedback';
4
5
  import { DatePickerControl } from './DatePickerControl';
5
6
  import { InputControl } from './InputControl';
6
7
  import { defaultValidator, nameValidator } from './validators';
7
8
 
8
- export const renderUserData = (field: FormFieldRegisterer<FeedbackFormState>) => (
9
+ export interface UserDataState {
10
+ surname: string;
11
+ name: string;
12
+ middleName?: string;
13
+ birthday: Date | undefined;
14
+ }
15
+
16
+ export const renderUserData = <T extends AntiFraudFormState | FeedbackFormState>(
17
+ field: FormFieldRegisterer<T>,
18
+ ) => (
9
19
  <div>
10
20
  <InputControl label="Фамилия*" {...withValidator(field('surname'), nameValidator)} />
11
21
  <InputControl label="Имя*" {...withValidator(field('name'), nameValidator)} />
12
- <InputControl
13
- label="Отчество (Обязательно, при наличии)"
14
- {...withValidator(field('middleName'), nameValidator)}
22
+ <InputControl label="Отчество (Обязательно, при наличии)" {...field('middleName')} />
23
+ <DatePickerControl
24
+ label="Дата рождения*"
25
+ {...withValidator(field('birthday'), defaultValidator)}
15
26
  />
16
- <DatePickerControl label="Дата рождения*" {...withValidator(field('date'), defaultValidator)} />
17
27
  </div>
18
28
  );
@@ -8,7 +8,6 @@ export const Input = JSX<InputProps>(
8
8
  ({
9
9
  key,
10
10
  className = '',
11
- inputClassName = '',
12
11
  id,
13
12
  name,
14
13
  type = 'text',
@@ -22,6 +21,7 @@ export const Input = JSX<InputProps>(
22
21
  onBlur,
23
22
  pattern,
24
23
  autoFocus = false,
24
+ isTextarea = false,
25
25
  }) => {
26
26
  const inputRef = useRef<HTMLInputElement | null>(null);
27
27
  const handleChange = useCallback(
@@ -36,44 +36,58 @@ export const Input = JSX<InputProps>(
36
36
  inputRef.current?.focus();
37
37
  }
38
38
  }, [autoFocus, inputRef]);
39
-
39
+ const defaultStyle = 'w-full border rounded-md text-primary-text outline-none p-m';
40
40
  const paddingStyle = children ? 'pr-3xl' : '';
41
- const validStyle = valid
42
- ? 'border-gray hover:border-primary-hover active:border-primary-text focus:border-primary-text'
43
- : 'border-error';
41
+ const validStyle = getValidStyle(valid);
44
42
 
45
43
  return (
46
44
  <div className={style('relative', className)}>
47
45
  <label>
48
- {label ? (
49
- <div className="mb-xs">
50
- <Text size="text-m" font="font-light">
51
- {label}
52
- </Text>
53
- </div>
54
- ) : null}
55
- <input
56
- ref={inputRef}
57
- key={key}
58
- className={style(
59
- 'w-full h-14 border rounded-md text-primary-text outline-none p-m',
60
- paddingStyle,
61
- validStyle,
62
- inputClassName,
63
- )}
64
- id={id}
65
- name={name || id}
66
- placeholder={placeholder}
67
- type={type}
68
- value={value}
69
- onInput={handleChange as any}
70
- onFocus={onFocus}
71
- onBlur={onBlur}
72
- pattern={pattern}
73
- />
46
+ {label ? renderLabel(label) : null}
47
+ {isTextarea ? (
48
+ <textarea
49
+ className={style('block resize-y min-h-24', defaultStyle, validStyle)}
50
+ key={key}
51
+ id={style('textarea', id)}
52
+ name={name || id}
53
+ placeholder={placeholder}
54
+ value={value}
55
+ onInput={handleChange as any}
56
+ onFocus={onFocus}
57
+ onBlur={onBlur}
58
+ />
59
+ ) : (
60
+ <input
61
+ type={type}
62
+ className={style('h-14', defaultStyle, paddingStyle, validStyle)}
63
+ ref={inputRef}
64
+ key={key}
65
+ id={id}
66
+ name={name || id}
67
+ placeholder={placeholder}
68
+ value={value}
69
+ onInput={handleChange as any}
70
+ onFocus={onFocus}
71
+ onBlur={onBlur}
72
+ pattern={pattern}
73
+ />
74
+ )}
74
75
  </label>
75
76
  {children}
76
77
  </div>
77
78
  );
78
79
  },
79
80
  );
81
+
82
+ const renderLabel = (label: string) => (
83
+ <div className="mb-xs">
84
+ <Text size="text-m" font="font-light">
85
+ {label}
86
+ </Text>
87
+ </div>
88
+ );
89
+
90
+ const getValidStyle = (valid: boolean) =>
91
+ valid
92
+ ? 'border-gray hover:border-primary-hover active:border-primary-text focus:border-primary-text'
93
+ : 'border-error';
@@ -4,7 +4,6 @@ import { type ControlProps } from '../ControlProps';
4
4
 
5
5
  export interface InputProps<V = string> extends ControlProps<V>, LabelProps {
6
6
  className?: string;
7
- inputClassName?: string;
8
7
  id?: string;
9
8
  name?: string;
10
9
  type?: InputTypes;
@@ -15,4 +14,6 @@ export interface InputProps<V = string> extends ControlProps<V>, LabelProps {
15
14
  valid?: boolean;
16
15
  disabled?: boolean;
17
16
  autoFocus?: boolean;
17
+ isTextarea?: boolean;
18
+ error?: string;
18
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.134",
3
+ "version": "0.14.136",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -206,7 +206,7 @@
206
206
  "path": "lib/common.css"
207
207
  },
208
208
  {
209
- "limit": "62 kB",
209
+ "limit": "63 kB",
210
210
  "path": "bundle/bundle.umd.min.js"
211
211
  }
212
212
  ],
@@ -60,6 +60,14 @@ const ApplicationFormFeedback: ApplicationFormContent = {
60
60
  formBlock: { ...formBlockProps, formType: 'ApplicationFormFeedback', title: 'Обратная связь' },
61
61
  };
62
62
 
63
+ const ApplicationFormAntiFraud: ApplicationFormContent = {
64
+ formBlock: {
65
+ ...formBlockProps,
66
+ formType: 'ApplicationFormAntiFraud',
67
+ title: 'Предупреждение о мошенничестве',
68
+ },
69
+ };
70
+
63
71
  export default {
64
72
  credit: (
65
73
  <div className="container grid grid-cols-12">
@@ -109,4 +117,10 @@ export default {
109
117
  <PopupManager />
110
118
  </div>
111
119
  ),
120
+ 'anti-fraud': (
121
+ <div className="container grid grid-cols-12">
122
+ <ApplicationForm className="col-span-12" {...ApplicationFormAntiFraud} />
123
+ <PopupManager />
124
+ </div>
125
+ ),
112
126
  };
@@ -20,15 +20,12 @@ export const ApplicationForm = JSX<ApplicationFormProps>((props) => {
20
20
 
21
21
  const [responseType, setResponseType] = useState<'OK' | 'Fail' | ''>('');
22
22
 
23
- const handleSubmit = useCallback(
24
- async (data: Record<string, any>, isIndividualType?: boolean) => {
25
- const status = (await API.send(data, isIndividualType)) ? 'OK' : 'Fail';
26
- setResponseType(status);
27
-
28
- return status;
29
- },
30
- [],
31
- );
23
+ const handleSubmit = useCallback(async (data: Record<string, any>, isIndividualType = false) => {
24
+ const status = (await API.send(data, isIndividualType)) ? 'OK' : 'Fail';
25
+ setResponseType(status);
26
+
27
+ return status;
28
+ }, []);
32
29
 
33
30
  return (
34
31
  <BlockWrapper className={className} defaultPadding="p-6xl" {...rest}>
@@ -0,0 +1,86 @@
1
+ /* eslint-disable max-lines-per-function,max-lines */
2
+
3
+ import { JSX } from '@redneckz/uni-jsx';
4
+ import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
5
+ import { useForm } from '../../hooks/useForm';
6
+ import { type Option } from '../../ui-kit/Select/Option';
7
+ import { objectValidator } from '../../validation/objectValidator';
8
+ import { isValidationSuccess } from '../../validation/validator';
9
+ import { withValidator } from '../../validation/withValidator';
10
+ import { ApplicationFieldsetLayout } from './ApplicationFieldsetLayout';
11
+ import { type ApplicationFormsProps } from './ApplicationFormsProps';
12
+ import { formStyle } from './formStyle';
13
+ import { PhoneInputControl } from './PhoneInputControl';
14
+ import { renderAgreementWithSubmit } from './renderAgreementWithSubmit';
15
+ import { renderUserData, type UserDataState } from './renderUserData';
16
+ import {
17
+ consentDataProcessingValidator,
18
+ defaultValidator,
19
+ nameValidator,
20
+ phoneValidator,
21
+ } from './validators';
22
+
23
+ export type AntiFraudFormState = UserDataState & {
24
+ typeForm: Option;
25
+ phone: string;
26
+ birthday: Date | undefined;
27
+ isClient: boolean;
28
+ comment?: string;
29
+ consentDataProcessing: boolean;
30
+ };
31
+
32
+ const initialFormState: AntiFraudFormState = {
33
+ typeForm: { key: 'ANTIFRAUD', text: 'Предупреждение о мошенничестве' },
34
+ surname: '',
35
+ name: '',
36
+ middleName: '',
37
+ phone: '',
38
+ birthday: undefined,
39
+ isClient: false,
40
+ comment: '',
41
+ consentDataProcessing: false,
42
+ };
43
+
44
+ const feedbackValidator = objectValidator({
45
+ typeForm: defaultValidator,
46
+ surname: defaultValidator,
47
+ name: nameValidator,
48
+ birthday: defaultValidator,
49
+ phone: phoneValidator,
50
+ consentDataProcessing: consentDataProcessingValidator,
51
+ });
52
+
53
+ export const ApplicationFormAntiFraud = JSX<ApplicationFormsProps>(({ button, link, onSubmit }) => {
54
+ const handleSubmit = useCallback(
55
+ (formState: AntiFraudFormState) => {
56
+ const { typeForm, phone, ...usedFields } = formState;
57
+
58
+ const submitData = {
59
+ ...usedFields,
60
+ typeForm: typeForm.key,
61
+ phone: phone.replace(/[^+\d]/g, ''),
62
+ };
63
+ isValidationSuccess(feedbackValidator(formState)) && onSubmit(submitData);
64
+ },
65
+ [onSubmit],
66
+ );
67
+
68
+ const [, { field, ...formProps }] = useForm(initialFormState, handleSubmit);
69
+
70
+ return (
71
+ <form className={formStyle} onSubmit={formProps.onSubmit}>
72
+ <ApplicationFieldsetLayout
73
+ firstChildren={
74
+ <div className="w-full max-w-xl space-y-s m-auto">
75
+ {renderUserData<AntiFraudFormState>(field)}
76
+ <PhoneInputControl
77
+ label="Телефон*"
78
+ {...withValidator(field('phone'), phoneValidator)}
79
+ />
80
+ {renderAgreementWithSubmit(field('consentDataProcessing'), link, button)}
81
+ </div>
82
+ }
83
+ />
84
+ </form>
85
+ );
86
+ });
@@ -94,6 +94,15 @@ export type FeedbackFormParamsDef = TitleProps &
94
94
  formType: 'ApplicationFormFeedback';
95
95
  };
96
96
 
97
+ /**
98
+ * @title Сообщить о мошенничестве
99
+ */
100
+ export type AntiFraudFormParamsDef = TitleProps &
101
+ CommonApplicationFormProps & {
102
+ /** @default ApplicationFormAntiFraud */
103
+ formType: 'ApplicationFormAntiFraud';
104
+ };
105
+
97
106
  /**
98
107
  * @title Настройки формы
99
108
  */
@@ -105,7 +114,8 @@ export type ApplicationFormBlockDef =
105
114
  | AcquiringFormParamsDef
106
115
  | GrantSupportFormParamsDef
107
116
  | IndividualsFormParamsDef
108
- | FeedbackFormParamsDef;
117
+ | FeedbackFormParamsDef
118
+ | AntiFraudFormParamsDef;
109
119
 
110
120
  /**
111
121
  * @title Форма заявки