@redneckz/wildless-cms-uni-blocks 0.14.895 → 0.14.897

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 (203) hide show
  1. package/bundle/bundle.umd.js +48 -15
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/hooks/useForm/useForm.d.ts +2 -0
  4. package/bundle/ui-kit/DialogManager/Dialog.d.ts +2 -2
  5. package/bundle/ui-kit/FormField/RefWrapper.d.ts +7 -0
  6. package/bundle/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.d.ts +20 -0
  7. package/dist/components/CardTransfer/SubmitFailedDialog.js +1 -1
  8. package/dist/components/CardTransfer/SubmitFailedDialog.js.map +1 -1
  9. package/dist/hooks/useForm/useForm.d.ts +2 -0
  10. package/dist/hooks/useForm/useForm.js +17 -0
  11. package/dist/hooks/useForm/useForm.js.map +1 -1
  12. package/dist/retail/components/CaptchaDialog/CaptchaDialog.js +1 -1
  13. package/dist/retail/components/CaptchaDialog/CaptchaDialog.js.map +1 -1
  14. package/dist/retail/components/ConsentBkiDialog/ConsentBkiDialog.js +1 -1
  15. package/dist/retail/components/ConsentBkiDialog/ConsentBkiDialog.js.map +1 -1
  16. package/dist/retail/components/DocumentDialog/DocumentDialog.js +1 -1
  17. package/dist/retail/components/DocumentDialog/DocumentDialog.js.map +1 -1
  18. package/dist/retail/components/DraftDialog/DraftDialog.js +1 -1
  19. package/dist/retail/components/DraftDialog/DraftDialog.js.map +1 -1
  20. package/dist/retail/components/DraftDialog/EmptyDraftDialog.js +1 -1
  21. package/dist/retail/components/DraftDialog/EmptyDraftDialog.js.map +1 -1
  22. package/dist/retail/components/NoConsentDialog/NoConsentDialog.js +1 -1
  23. package/dist/retail/components/NoConsentDialog/NoConsentDialog.js.map +1 -1
  24. package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +1 -1
  25. package/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  26. package/dist/ui-kit/DialogManager/Dialog.d.ts +2 -2
  27. package/dist/ui-kit/DialogManager/Dialog.js +6 -1
  28. package/dist/ui-kit/DialogManager/Dialog.js.map +1 -1
  29. package/dist/ui-kit/FormField/RefWrapper.d.ts +7 -0
  30. package/dist/ui-kit/FormField/RefWrapper.js +16 -0
  31. package/dist/ui-kit/FormField/RefWrapper.js.map +1 -0
  32. package/dist/ui-kit/FormField/getField.js +2 -1
  33. package/dist/ui-kit/FormField/getField.js.map +1 -1
  34. package/dist/ui-kit/LocationDialog/LocationDialog.js +2 -1
  35. package/dist/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
  36. package/dist/ui-kit/ReportDialog/ReportDialog.js +1 -1
  37. package/dist/ui-kit/ReportDialog/ReportDialog.js.map +1 -1
  38. package/dist/ui-kit/ResponseTypeDialog/ResponseTypeDialog.js +1 -1
  39. package/dist/ui-kit/ResponseTypeDialog/ResponseTypeDialog.js.map +1 -1
  40. package/dist/ui-kit/SearchDialog/SearchDialog.js +1 -1
  41. package/dist/ui-kit/SearchDialog/SearchDialog.js.map +1 -1
  42. package/dist/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.d.ts +20 -0
  43. package/dist/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.js +24 -0
  44. package/dist/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.js.map +1 -0
  45. package/lib/common.css +1 -1
  46. package/lib/components/CardTransfer/SubmitFailedDialog.js +1 -1
  47. package/lib/components/CardTransfer/SubmitFailedDialog.js.map +1 -1
  48. package/lib/hooks/useForm/useForm.d.ts +2 -0
  49. package/lib/hooks/useForm/useForm.js +17 -0
  50. package/lib/hooks/useForm/useForm.js.map +1 -1
  51. package/lib/retail/components/CaptchaDialog/CaptchaDialog.js +1 -1
  52. package/lib/retail/components/CaptchaDialog/CaptchaDialog.js.map +1 -1
  53. package/lib/retail/components/ConsentBkiDialog/ConsentBkiDialog.js +1 -1
  54. package/lib/retail/components/ConsentBkiDialog/ConsentBkiDialog.js.map +1 -1
  55. package/lib/retail/components/DocumentDialog/DocumentDialog.js +1 -1
  56. package/lib/retail/components/DocumentDialog/DocumentDialog.js.map +1 -1
  57. package/lib/retail/components/DraftDialog/DraftDialog.js +1 -1
  58. package/lib/retail/components/DraftDialog/DraftDialog.js.map +1 -1
  59. package/lib/retail/components/DraftDialog/EmptyDraftDialog.js +1 -1
  60. package/lib/retail/components/DraftDialog/EmptyDraftDialog.js.map +1 -1
  61. package/lib/retail/components/NoConsentDialog/NoConsentDialog.js +1 -1
  62. package/lib/retail/components/NoConsentDialog/NoConsentDialog.js.map +1 -1
  63. package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +1 -1
  64. package/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  65. package/lib/ui-kit/DialogManager/Dialog.d.ts +2 -2
  66. package/lib/ui-kit/DialogManager/Dialog.js +6 -1
  67. package/lib/ui-kit/DialogManager/Dialog.js.map +1 -1
  68. package/lib/ui-kit/FormField/RefWrapper.d.ts +7 -0
  69. package/lib/ui-kit/FormField/RefWrapper.js +14 -0
  70. package/lib/ui-kit/FormField/RefWrapper.js.map +1 -0
  71. package/lib/ui-kit/FormField/getField.js +2 -1
  72. package/lib/ui-kit/FormField/getField.js.map +1 -1
  73. package/lib/ui-kit/LocationDialog/LocationDialog.js +2 -1
  74. package/lib/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
  75. package/lib/ui-kit/ReportDialog/ReportDialog.js +1 -1
  76. package/lib/ui-kit/ReportDialog/ReportDialog.js.map +1 -1
  77. package/lib/ui-kit/ResponseTypeDialog/ResponseTypeDialog.js +1 -1
  78. package/lib/ui-kit/ResponseTypeDialog/ResponseTypeDialog.js.map +1 -1
  79. package/lib/ui-kit/SearchDialog/SearchDialog.js +1 -1
  80. package/lib/ui-kit/SearchDialog/SearchDialog.js.map +1 -1
  81. package/lib/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.d.ts +20 -0
  82. package/lib/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.fixture.d.ts +5 -0
  83. package/lib/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.js +22 -0
  84. package/lib/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.js.map +1 -0
  85. package/mobile/bundle/bundle.umd.js +47 -14
  86. package/mobile/bundle/bundle.umd.min.js +1 -1
  87. package/mobile/bundle/hooks/useForm/useForm.d.ts +2 -0
  88. package/mobile/bundle/ui-kit/DialogManager/Dialog.d.ts +2 -2
  89. package/mobile/bundle/ui-kit/FormField/RefWrapper.d.ts +7 -0
  90. package/mobile/bundle/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.d.ts +20 -0
  91. package/mobile/dist/components/CardTransfer/SubmitFailedDialog.js +1 -1
  92. package/mobile/dist/components/CardTransfer/SubmitFailedDialog.js.map +1 -1
  93. package/mobile/dist/hooks/useForm/useForm.d.ts +2 -0
  94. package/mobile/dist/hooks/useForm/useForm.js +17 -0
  95. package/mobile/dist/hooks/useForm/useForm.js.map +1 -1
  96. package/mobile/dist/retail/components/CaptchaDialog/CaptchaDialog.js +1 -1
  97. package/mobile/dist/retail/components/CaptchaDialog/CaptchaDialog.js.map +1 -1
  98. package/mobile/dist/retail/components/ConsentBkiDialog/ConsentBkiDialog.js +1 -1
  99. package/mobile/dist/retail/components/ConsentBkiDialog/ConsentBkiDialog.js.map +1 -1
  100. package/mobile/dist/retail/components/DocumentDialog/DocumentDialog.js +1 -1
  101. package/mobile/dist/retail/components/DocumentDialog/DocumentDialog.js.map +1 -1
  102. package/mobile/dist/retail/components/DraftDialog/DraftDialog.js +1 -1
  103. package/mobile/dist/retail/components/DraftDialog/DraftDialog.js.map +1 -1
  104. package/mobile/dist/retail/components/DraftDialog/EmptyDraftDialog.js +1 -1
  105. package/mobile/dist/retail/components/DraftDialog/EmptyDraftDialog.js.map +1 -1
  106. package/mobile/dist/retail/components/NoConsentDialog/NoConsentDialog.js +1 -1
  107. package/mobile/dist/retail/components/NoConsentDialog/NoConsentDialog.js.map +1 -1
  108. package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +1 -1
  109. package/mobile/dist/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  110. package/mobile/dist/ui-kit/DialogManager/Dialog.d.ts +2 -2
  111. package/mobile/dist/ui-kit/DialogManager/Dialog.js +6 -1
  112. package/mobile/dist/ui-kit/DialogManager/Dialog.js.map +1 -1
  113. package/mobile/dist/ui-kit/FormField/RefWrapper.d.ts +7 -0
  114. package/mobile/dist/ui-kit/FormField/RefWrapper.js +16 -0
  115. package/mobile/dist/ui-kit/FormField/RefWrapper.js.map +1 -0
  116. package/mobile/dist/ui-kit/FormField/getField.js +2 -1
  117. package/mobile/dist/ui-kit/FormField/getField.js.map +1 -1
  118. package/mobile/dist/ui-kit/LocationDialog/LocationDialog.js +2 -1
  119. package/mobile/dist/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
  120. package/mobile/dist/ui-kit/ReportDialog/ReportDialog.js +1 -1
  121. package/mobile/dist/ui-kit/ReportDialog/ReportDialog.js.map +1 -1
  122. package/mobile/dist/ui-kit/ResponseTypeDialog/ResponseTypeDialog.js +1 -1
  123. package/mobile/dist/ui-kit/ResponseTypeDialog/ResponseTypeDialog.js.map +1 -1
  124. package/mobile/dist/ui-kit/SearchDialog/SearchDialog.js +1 -1
  125. package/mobile/dist/ui-kit/SearchDialog/SearchDialog.js.map +1 -1
  126. package/mobile/dist/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.d.ts +20 -0
  127. package/mobile/dist/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.js +24 -0
  128. package/mobile/dist/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.js.map +1 -0
  129. package/mobile/lib/common.css +1 -1
  130. package/mobile/lib/components/CardTransfer/SubmitFailedDialog.js +1 -1
  131. package/mobile/lib/components/CardTransfer/SubmitFailedDialog.js.map +1 -1
  132. package/mobile/lib/hooks/useForm/useForm.d.ts +2 -0
  133. package/mobile/lib/hooks/useForm/useForm.js +17 -0
  134. package/mobile/lib/hooks/useForm/useForm.js.map +1 -1
  135. package/mobile/lib/retail/components/CaptchaDialog/CaptchaDialog.js +1 -1
  136. package/mobile/lib/retail/components/CaptchaDialog/CaptchaDialog.js.map +1 -1
  137. package/mobile/lib/retail/components/ConsentBkiDialog/ConsentBkiDialog.js +1 -1
  138. package/mobile/lib/retail/components/ConsentBkiDialog/ConsentBkiDialog.js.map +1 -1
  139. package/mobile/lib/retail/components/DocumentDialog/DocumentDialog.js +1 -1
  140. package/mobile/lib/retail/components/DocumentDialog/DocumentDialog.js.map +1 -1
  141. package/mobile/lib/retail/components/DraftDialog/DraftDialog.js +1 -1
  142. package/mobile/lib/retail/components/DraftDialog/DraftDialog.js.map +1 -1
  143. package/mobile/lib/retail/components/DraftDialog/EmptyDraftDialog.js +1 -1
  144. package/mobile/lib/retail/components/DraftDialog/EmptyDraftDialog.js.map +1 -1
  145. package/mobile/lib/retail/components/NoConsentDialog/NoConsentDialog.js +1 -1
  146. package/mobile/lib/retail/components/NoConsentDialog/NoConsentDialog.js.map +1 -1
  147. package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js +1 -1
  148. package/mobile/lib/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.js.map +1 -1
  149. package/mobile/lib/ui-kit/DialogManager/Dialog.d.ts +2 -2
  150. package/mobile/lib/ui-kit/DialogManager/Dialog.js +6 -1
  151. package/mobile/lib/ui-kit/DialogManager/Dialog.js.map +1 -1
  152. package/mobile/lib/ui-kit/FormField/RefWrapper.d.ts +7 -0
  153. package/mobile/lib/ui-kit/FormField/RefWrapper.js +14 -0
  154. package/mobile/lib/ui-kit/FormField/RefWrapper.js.map +1 -0
  155. package/mobile/lib/ui-kit/FormField/getField.js +2 -1
  156. package/mobile/lib/ui-kit/FormField/getField.js.map +1 -1
  157. package/mobile/lib/ui-kit/LocationDialog/LocationDialog.js +2 -1
  158. package/mobile/lib/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
  159. package/mobile/lib/ui-kit/ReportDialog/ReportDialog.js +1 -1
  160. package/mobile/lib/ui-kit/ReportDialog/ReportDialog.js.map +1 -1
  161. package/mobile/lib/ui-kit/ResponseTypeDialog/ResponseTypeDialog.js +1 -1
  162. package/mobile/lib/ui-kit/ResponseTypeDialog/ResponseTypeDialog.js.map +1 -1
  163. package/mobile/lib/ui-kit/SearchDialog/SearchDialog.js +1 -1
  164. package/mobile/lib/ui-kit/SearchDialog/SearchDialog.js.map +1 -1
  165. package/mobile/lib/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.d.ts +20 -0
  166. package/mobile/lib/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.js +22 -0
  167. package/mobile/lib/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.js.map +1 -0
  168. package/mobile/src/components/CardTransfer/SubmitFailedDialog.tsx +1 -1
  169. package/mobile/src/hooks/useForm/useForm.ts +31 -2
  170. package/mobile/src/retail/components/CaptchaDialog/CaptchaDialog.tsx +1 -5
  171. package/mobile/src/retail/components/ConsentBkiDialog/ConsentBkiDialog.tsx +1 -4
  172. package/mobile/src/retail/components/DocumentDialog/DocumentDialog.tsx +1 -1
  173. package/mobile/src/retail/components/DraftDialog/DraftDialog.tsx +1 -1
  174. package/mobile/src/retail/components/DraftDialog/EmptyDraftDialog.tsx +1 -4
  175. package/mobile/src/retail/components/NoConsentDialog/NoConsentDialog.tsx +1 -4
  176. package/mobile/src/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.tsx +1 -4
  177. package/mobile/src/ui-kit/DialogManager/Dialog.tsx +15 -6
  178. package/mobile/src/ui-kit/FormField/RefWrapper.tsx +20 -0
  179. package/mobile/src/ui-kit/FormField/getField.tsx +3 -2
  180. package/mobile/src/ui-kit/LocationDialog/LocationDialog.tsx +11 -13
  181. package/mobile/src/ui-kit/ReportDialog/ReportDialog.tsx +1 -1
  182. package/mobile/src/ui-kit/ResponseTypeDialog/ResponseTypeDialog.tsx +1 -1
  183. package/mobile/src/ui-kit/SearchDialog/SearchDialog.tsx +4 -1
  184. package/mobile/src/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.tsx +83 -0
  185. package/package.json +1 -1
  186. package/src/components/CardTransfer/SubmitFailedDialog.tsx +1 -1
  187. package/src/hooks/useForm/useForm.ts +31 -2
  188. package/src/retail/components/CaptchaDialog/CaptchaDialog.tsx +1 -5
  189. package/src/retail/components/ConsentBkiDialog/ConsentBkiDialog.tsx +1 -4
  190. package/src/retail/components/DocumentDialog/DocumentDialog.tsx +1 -1
  191. package/src/retail/components/DraftDialog/DraftDialog.tsx +1 -1
  192. package/src/retail/components/DraftDialog/EmptyDraftDialog.tsx +1 -4
  193. package/src/retail/components/NoConsentDialog/NoConsentDialog.tsx +1 -4
  194. package/src/retail/components/VerifyPhoneDialog/VerifyPhoneDialog.tsx +1 -4
  195. package/src/ui-kit/DialogManager/Dialog.tsx +15 -6
  196. package/src/ui-kit/FormField/RefWrapper.tsx +20 -0
  197. package/src/ui-kit/FormField/getField.tsx +3 -2
  198. package/src/ui-kit/LocationDialog/LocationDialog.tsx +11 -13
  199. package/src/ui-kit/ReportDialog/ReportDialog.tsx +1 -1
  200. package/src/ui-kit/ResponseTypeDialog/ResponseTypeDialog.tsx +1 -1
  201. package/src/ui-kit/SearchDialog/SearchDialog.tsx +4 -1
  202. package/src/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.fixture.tsx +32 -0
  203. package/src/ui-kit/SnowplowPopupDialog/SnowplowPopupDialog.tsx +83 -0
@@ -4,7 +4,7 @@ import { type ControlProps } from '../../model/ControlProps';
4
4
  import { type PreventableEvent } from '../../ui-kit/PreventableEvent';
5
5
  import { type ValidationInfo } from '../../validation/validator';
6
6
  import { type FieldOptions } from './FieldOptions';
7
- import { type FormOptions } from './FormOptions';
7
+ import { type FieldValidatorsMap, type FormOptions } from './FormOptions';
8
8
  import { useFormValidator } from './useFormValidator';
9
9
  import { useNormalizedFormState } from './useNormalizedFormState';
10
10
 
@@ -12,6 +12,8 @@ export interface FieldProps<V> extends ControlProps<V> {
12
12
  isDirty?: boolean;
13
13
  errors?: ValidationInfo;
14
14
  error?: ValidationInfo[0];
15
+ setFieldRef?: (_: HTMLDivElement) => void;
16
+ fieldRef?: HTMLDivElement | null;
15
17
  }
16
18
 
17
19
  export type FormFieldRegisterer<FormState> = <N extends keyof FormState, V = FormState[N]>(
@@ -37,9 +39,9 @@ export function useForm<FormState extends Record<string, any>>(
37
39
  onChange,
38
40
  );
39
41
 
42
+ const fieldRefs = useRef(getRefsObject<FormState>(initialState));
40
43
  const [isDirtyForm, { setTrue: markAsDirty, setFalse: markAsClean }] = useBool(false);
41
44
  const dirtyFieldsMap = useRef<Record<string, boolean>>({});
42
-
43
45
  const [fieldValidatorsMap, { isValid, errors }] = useFormValidator(formState, formValidator);
44
46
 
45
47
  const field: FormFieldRegisterer<FormState> = useCallback(
@@ -51,6 +53,12 @@ export function useForm<FormState extends Record<string, any>>(
51
53
  const fieldErrors: ValidationInfo = isDirty && fieldValidator ? fieldValidator(value) : [];
52
54
 
53
55
  return {
56
+ setFieldRef: (_: HTMLDivElement) => {
57
+ if (fieldRefs.current) {
58
+ fieldRefs.current[fieldName] = _;
59
+ }
60
+ },
61
+ fieldRef: fieldRefs.current?.[fieldName],
54
62
  value: format ? (format(value) as FormState[any]) : value,
55
63
  isDirty,
56
64
  errors: fieldValidator && fieldErrors, // TODO Костыль
@@ -88,7 +96,9 @@ export function useForm<FormState extends Record<string, any>>(
88
96
  resetOnSubmit && reset();
89
97
  onSubmit?.(formState, ev);
90
98
  } else {
99
+ const errorFieldName = getErrorFieldName(formState, fieldValidatorsMap);
91
100
  markAsDirty();
101
+ field(errorFieldName).fieldRef?.scrollIntoView({ behavior: 'smooth' });
92
102
  }
93
103
  },
94
104
  [resetOnSubmit, formState, isValid, reset, onSubmit],
@@ -96,3 +106,22 @@ export function useForm<FormState extends Record<string, any>>(
96
106
 
97
107
  return [formState, { errors, field, update, reset, onSubmit: handleSubmit }];
98
108
  }
109
+
110
+ const getRefsObject = <FormState extends Record<string, any>>(initialState: FormState) =>
111
+ Object.keys(initialState).reduce(
112
+ (acc, key) => ({ ...acc, [key]: null }),
113
+ {} as Record<keyof FormState, HTMLDivElement | null>,
114
+ );
115
+
116
+ const getErrorFieldName = <FormState extends Record<string, any>>(
117
+ formState: FormState,
118
+ fieldValidatorsMap: FieldValidatorsMap<FormState> = {},
119
+ ) => {
120
+ const [errorFieldName = ''] =
121
+ Object.entries(formState).find(([fieldName, value]) => {
122
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
123
+ return fieldValidatorsMap[fieldName]?.(value)?.length;
124
+ }) ?? [];
125
+
126
+ return errorFieldName;
127
+ };
@@ -46,11 +46,7 @@ export const CaptchaDialog = JSX<CaptchaDialogProps>(({ phoneNumber, sendCode, o
46
46
  useEffect(handleCreateCaptcha, []);
47
47
 
48
48
  return (
49
- <Dialog
50
- className="my-6xl max-w-lg w-full min-h-fit mx-auto rounded-lg"
51
- head={<Logo />}
52
- onClose={closeAll}
53
- >
49
+ <Dialog head={<Logo />} onClose={onClose}>
54
50
  <div className="flex flex-col gap-lg items-center">
55
51
  <div className="flex">
56
52
  <img className="grow" src={captcha}></img>
@@ -49,10 +49,7 @@ export const ConsentBkiDialog = JSX<ConsentBkiDialogProps>(
49
49
  const consentText = showRefuseContent ? refuseConsentText : defaultConsentText;
50
50
 
51
51
  return (
52
- <Dialog
53
- className="my-6xl max-w-3xl w-full min-h-fit mx-auto rounded-lg px-5xl"
54
- onClose={onClose}
55
- >
52
+ <Dialog onClose={onClose}>
56
53
  <div className="flex flex-col gap-xl items-center">
57
54
  <div role="button" onClick={openDocument}>
58
55
  <Heading
@@ -13,7 +13,7 @@ export const DocumentDialog = JSX<DocumentDialogProps>(({ src, onClose, onDocume
13
13
  const isMobileMode = useMobileMode();
14
14
 
15
15
  return (
16
- <Dialog className="mt-xl max-w-4xl mx-auto px-0 min-h-0 pb-0" onClose={onClose}>
16
+ <Dialog onClose={onClose}>
17
17
  {isMobileMode ? (
18
18
  <img src={src} />
19
19
  ) : (
@@ -57,7 +57,7 @@ export const DraftDialog = JSX<DraftDialogProps>(function ({
57
57
  }, []);
58
58
 
59
59
  return (
60
- <Dialog className="my-6xl max-w-4xl w-full min-h-fit mx-auto rounded-xl py-0" onClose={onClose}>
60
+ <Dialog onClose={onClose}>
61
61
  <div className="flex flex-col gap-lg items-center mt-xs mx-6xl">
62
62
  <Heading
63
63
  className="whitespace-pre-wrap text-center"
@@ -26,10 +26,7 @@ export const EmptyDraftDialog = JSX<EmptyDraftDialogProps>(function ({ isDebit,
26
26
  }, []);
27
27
 
28
28
  return (
29
- <Dialog
30
- className="my-6xl max-w-3xl w-full min-h-fit mx-auto rounded-lg py-0 px-5xl"
31
- onClose={onClose}
32
- >
29
+ <Dialog onClose={onClose}>
33
30
  <div className="flex flex-col gap-lg">
34
31
  <Heading className="text-center" title="Заявки не найдены" headingType="h3" />
35
32
  <Paragraph size="text-l" align="text-center">
@@ -30,10 +30,7 @@ export const NoConsentDialog = JSX<NoConsentDialogProps>(({ attempts, onClose =
30
30
  }, [isMaxAttempts]);
31
31
 
32
32
  return (
33
- <Dialog
34
- className="my-6xl max-w-3xl w-full min-h-fit mx-auto rounded-lg px-5xl"
35
- onClose={handleClose}
36
- >
33
+ <Dialog onClose={handleClose}>
37
34
  <div className="flex flex-col gap-xl items-center">
38
35
  <Paragraph align="text-center">Уважаемый клиент!</Paragraph>
39
36
  <Paragraph align="text-center">
@@ -108,10 +108,7 @@ export const VerifyPhoneDialog = JSX<VerifyPhoneDialogProps>(
108
108
  }, []);
109
109
 
110
110
  return (
111
- <Dialog
112
- className="my-6xl max-w-3xl w-full min-h-fit mx-auto rounded-xl p-m"
113
- onClose={onClose}
114
- >
111
+ <Dialog maxWidth="lg" onClose={onClose}>
115
112
  <div className="flex flex-col gap-xl items-center rounded-md">
116
113
  <Headline
117
114
  className="w-full"
@@ -1,26 +1,35 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { type ComponentType } from '../../model/ComponentType';
3
2
  import { type OnClickPreventableProps } from '../../model/OnClickProps';
4
3
  import type { OnCloseProps } from '../../model/OnCloseProps';
5
4
  import { type VNode } from '../../model/VNode';
6
5
  import { style } from '../../utils/style';
7
6
  import { CloseButton } from './CloseButton';
8
7
 
9
- export interface DialogProps extends ComponentType, OnCloseProps, OnClickPreventableProps {
8
+ export interface DialogProps extends OnCloseProps, OnClickPreventableProps {
10
9
  head?: VNode;
10
+ maxWidth?: 'sm' | '4xl' | 'lg';
11
11
  }
12
12
 
13
- export const Dialog = JSX<DialogProps>(({ className, head, children, onClose, onClick }) => (
13
+ const MAX_WIDTH_STYLE = {
14
+ sm: 'max-w-sm top-1/3',
15
+ lg: 'max-w-lg',
16
+ '4xl': 'max-w-4xl',
17
+ };
18
+
19
+ export const Dialog = JSX<DialogProps>(({ head, maxWidth = '4xl', children, onClose, onClick }) => (
14
20
  <div
15
- className={style('relative bg-white pt-0 p-lg', className)}
21
+ className={style(
22
+ 'relative bg-white p-lg pb-6xl my-6xl mx-auto rounded-lg w-full',
23
+ MAX_WIDTH_STYLE[maxWidth],
24
+ )}
16
25
  role="dialog"
17
26
  title="Диалог"
18
27
  onClick={onClick}
19
28
  >
20
29
  <div className="sticky py-xl top-0 bg-white z-10">
21
- <CloseButton className="absolute top-0 right-0" onClose={onClose} />
30
+ <CloseButton className="absolute top-0 right-0 z-10" onClose={onClose} />
22
31
  <div className="container">{head}</div>
23
32
  </div>
24
- <div className="container pb-m mb-[74px] lg:mb-0">{children}</div>
33
+ <div className="container">{children}</div>
25
34
  </div>
26
35
  ));
@@ -0,0 +1,20 @@
1
+ import { JSX } from '@redneckz/uni-jsx';
2
+ import { useEffect, useRef } from '@redneckz/uni-jsx/lib/hooks';
3
+ import type { VNode } from '../../model/VNode';
4
+ import { noop } from '../../utils/noop';
5
+
6
+ type RefWrapperProps = {
7
+ onFieldRef?: (_: HTMLDivElement) => void;
8
+ children?: VNode;
9
+ };
10
+
11
+ export const RefWrapper = JSX<RefWrapperProps>(({ onFieldRef = noop, children }) => {
12
+ const ref = useRef<HTMLDivElement | null>(null);
13
+ useEffect(() => {
14
+ if (ref.current) {
15
+ onFieldRef(ref.current);
16
+ }
17
+ }, []);
18
+
19
+ return <div ref={ref}>{children}</div>;
20
+ });
@@ -44,6 +44,7 @@ import { UltraPremiumField } from './Fields/UltraPremiumField';
44
44
  import { VedField } from './Fields/VedField';
45
45
  import { ConsentToReceiveMaterialsField } from './Fields/СonsentToReceiveMaterialsField';
46
46
  import { getPremium } from './getPremium';
47
+ import { RefWrapper } from './RefWrapper';
47
48
  import { shouldRenderField } from './shouldRenderField';
48
49
 
49
50
  const PRODUCT_REF = {
@@ -119,8 +120,8 @@ export const getField =
119
120
  const Component = fieldsRegister[String(input.name)];
120
121
 
121
122
  return shouldRenderField({ input, field }) && Component ? (
122
- <div key={i}>
123
+ <RefWrapper onFieldRef={field(input.name ?? '').setFieldRef} key={String(i)}>
123
124
  <Component field={field} input={input} params={params} />
124
- </div>
125
+ </RefWrapper>
125
126
  ) : null;
126
127
  };
@@ -45,19 +45,7 @@ export const LocationDialog = JSX<LocationDialogProps>(({ foreignOffices, branch
45
45
  );
46
46
 
47
47
  return (
48
- <Dialog
49
- className="pb-20"
50
- head={
51
- <div>
52
- <Text size="text-h4" color="text-primary-text">
53
- Выберите филиал
54
- </Text>
55
- <SelectedLocation defaultLocation={branches?.default} />
56
- <SearchBar onSearch={setQuery} searchTerm={query} />
57
- </div>
58
- }
59
- onClose={onClose}
60
- >
48
+ <Dialog head={renderHead(query, setQuery, branches)} onClose={onClose}>
61
49
  {query && query.length >= SEARCH_TERM_MIN_LENGTH ? (
62
50
  <div>
63
51
  {regions
@@ -79,6 +67,16 @@ export const LocationDialog = JSX<LocationDialogProps>(({ foreignOffices, branch
79
67
  );
80
68
  });
81
69
 
70
+ const renderHead = (query: string, setQuery: (_: string) => void, branches?: BranchesHeader) => (
71
+ <div>
72
+ <Text size="text-h4" color="text-primary-text">
73
+ Выберите филиал
74
+ </Text>
75
+ <SelectedLocation defaultLocation={branches?.default} />
76
+ <SearchBar onSearch={setQuery} searchTerm={query} />
77
+ </div>
78
+ );
79
+
82
80
  const regionFirstLetter = (region: Region) => region.name?.charAt(0) ?? '';
83
81
 
84
82
  const cleanUpRegions = (regions: Region[]) =>
@@ -13,7 +13,7 @@ export interface ReportDialogProps extends LinkDoc, OnCloseProps {
13
13
  }
14
14
 
15
15
  export const ReportDialog = JSX<ReportDialogProps>(({ href, __html, target, onClose }) => (
16
- <Dialog className="my-6xl min-h-fit w-fit mx-auto" onClose={onClose}>
16
+ <Dialog maxWidth="lg" onClose={onClose}>
17
17
  {__html ? <RichText __html={__html} /> : null}
18
18
  <div className="flex flex-row mx-auto w-fit gap-lg py-lg">
19
19
  <Link
@@ -21,7 +21,7 @@ export const ResponseTypeDialog = JSX<ResponseNotificationProps>(({ ok, typeForm
21
21
  : 'Совсем скоро мы с вами свяжемся';
22
22
 
23
23
  return (
24
- <Dialog className="my-6xl max-w-lg w-full min-h-fit mx-auto" onClose={onClose}>
24
+ <Dialog maxWidth="lg" onClose={onClose}>
25
25
  <div className="flex flex-col gap-lg items-center rounded-md space-x-m">
26
26
  <Img image={{ icon: statusIcon, iconVersion: 'normal' }} width="136" height="136" />
27
27
  <Headline
@@ -28,7 +28,10 @@ export const SearchDialog = JSX<SearchDialogProps>(({ initialQuery, navigationIt
28
28
  );
29
29
 
30
30
  return (
31
- <Dialog head={<SearchInput autoFocus={true} {...searchInputProps} />} onClose={onClose}>
31
+ <Dialog
32
+ head={<SearchInput className="mt-s" autoFocus={true} {...searchInputProps} />}
33
+ onClose={onClose}
34
+ >
32
35
  <Sitemap navigationItems={searchItems} />
33
36
  </Dialog>
34
37
  );
@@ -0,0 +1,32 @@
1
+ import '../../setup-fixture';
2
+ import { noop } from '../../utils/noop';
3
+
4
+ import { SnowplowPopupDialog, type SnowplowPopupDialogProps } from './SnowplowPopupDialog';
5
+
6
+ const PROPS: SnowplowPopupDialogProps = {
7
+ aspects: {},
8
+ onClose: () => noop(),
9
+ handleAspects: () => noop(),
10
+ title: 'Заголовок',
11
+ description:
12
+ 'Описание, но не короткое, а длинное описание, так что бы много слов и в несколько строк',
13
+ align: 'text-center',
14
+ img: {
15
+ src: 'chair.png',
16
+ size: {
17
+ width: 180,
18
+ height: 80,
19
+ },
20
+ },
21
+ buttons: [
22
+ {
23
+ version: 'primary',
24
+ text: 'Подробнее',
25
+ },
26
+ ],
27
+ __html: '<ul><li>Список 1</li></ul>',
28
+ };
29
+
30
+ export default {
31
+ default: <SnowplowPopupDialog {...PROPS} />,
32
+ };
@@ -0,0 +1,83 @@
1
+ import { JSX } from '@redneckz/uni-jsx';
2
+ import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
3
+ import { Headline } from '../../components/Headline/Headline';
4
+ import { type HandleAspectsProps } from '../../hooks/useAspects/handleAspects';
5
+ import { type Aspects } from '../../hooks/useAspects/useAspects';
6
+ import { type AspectsDef } from '../../model/AspectsProps';
7
+ import { type HeadlineCommonProps } from '../../model/HeadlineType';
8
+ import { type Picture } from '../../model/Picture';
9
+ import { Dialog } from '../DialogManager/Dialog';
10
+ import { Img } from '../Img/Img';
11
+ import { type LinkButtonContent } from '../LinkButton/LinkButtonContent';
12
+ import { renderButtonsSection } from '../LinkButton/renderButtonsSection';
13
+ import { type PreventableEventWithTarget } from '../PreventableEvent';
14
+ import { RichText } from '../RichText/RichText';
15
+ import { type RichTextProps } from '../RichText/RichTextProps';
16
+ export interface SnowplowPopupDialogContent extends HeadlineCommonProps, RichTextProps {
17
+ img?: Picture;
18
+ buttons?: LinkButtonContent[];
19
+ dataShow?: AspectsDef[];
20
+ dataClose?: AspectsDef[];
21
+ delay?: number;
22
+ }
23
+
24
+ export interface SnowplowPopupDialogProps extends SnowplowPopupDialogContent {
25
+ onClose?: () => void;
26
+ aspects: Aspects;
27
+ handleAspects: (props: HandleAspectsProps) => void;
28
+ }
29
+
30
+ export const SnowplowPopupDialog = JSX<SnowplowPopupDialogProps>(
31
+ ({
32
+ title,
33
+ description,
34
+ buttons,
35
+ img,
36
+ dataClose,
37
+ onClose,
38
+ align,
39
+ isDotted,
40
+ __html,
41
+ itemSize,
42
+ richVersion,
43
+ aspects,
44
+ handleAspects,
45
+ }) => {
46
+ const handleClose = useCallback(() => {
47
+ if (dataClose) {
48
+ handleAspects({
49
+ aspectsAttributes: dataClose,
50
+ aspects,
51
+ ev: {} as PreventableEventWithTarget,
52
+ });
53
+ }
54
+
55
+ onClose?.();
56
+ }, [aspects, dataClose, onClose, handleAspects]);
57
+
58
+ return (
59
+ <Dialog maxWidth="sm" onClose={handleClose}>
60
+ <div className="flex flex-col gap-lg items-center rounded-md">
61
+ <Img image={img} />
62
+ {title || description ? (
63
+ <Headline
64
+ align={align}
65
+ className="w-full"
66
+ title={title}
67
+ description={description}
68
+ headlineVersion="XS"
69
+ isEmbedded={true}
70
+ />
71
+ ) : null}
72
+ <RichText
73
+ __html={__html}
74
+ isDotted={isDotted}
75
+ itemSize={itemSize}
76
+ richVersion={richVersion}
77
+ />
78
+ {renderButtonsSection(buttons, { isVertical: true })}
79
+ </div>
80
+ </Dialog>
81
+ );
82
+ },
83
+ );