@redneckz/wildless-cms-uni-blocks 0.14.871 → 0.14.873

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 (61) hide show
  1. package/bundle/bundle.umd.js +34 -5
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/retail/components/NoConsentDialog/NoConsentDialog.d.ts +6 -0
  4. package/bundle/ui-kit/Foldable/FoldableSection.d.ts +1 -0
  5. package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +14 -1
  6. package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  7. package/dist/components/TariffsTable/TariffsTable.js +1 -1
  8. package/dist/components/TariffsTable/TariffsTable.js.map +1 -1
  9. package/dist/retail/components/NoConsentDialog/NoConsentDialog.d.ts +6 -0
  10. package/dist/retail/components/NoConsentDialog/NoConsentDialog.js +27 -0
  11. package/dist/retail/components/NoConsentDialog/NoConsentDialog.js.map +1 -0
  12. package/dist/ui-kit/Foldable/FoldableSection.d.ts +1 -0
  13. package/dist/ui-kit/Foldable/FoldableSection.js +2 -2
  14. package/dist/ui-kit/Foldable/FoldableSection.js.map +1 -1
  15. package/lib/common.css +1 -1
  16. package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +14 -1
  17. package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  18. package/lib/components/TariffsTable/TariffsTable.js +1 -1
  19. package/lib/components/TariffsTable/TariffsTable.js.map +1 -1
  20. package/lib/retail/components/NoConsentDialog/NoConsentDialog.d.ts +6 -0
  21. package/lib/retail/components/NoConsentDialog/NoConsentDialog.fixture.d.ts +5 -0
  22. package/lib/retail/components/NoConsentDialog/NoConsentDialog.js +25 -0
  23. package/lib/retail/components/NoConsentDialog/NoConsentDialog.js.map +1 -0
  24. package/lib/ui-kit/Foldable/FoldableSection.d.ts +1 -0
  25. package/lib/ui-kit/Foldable/FoldableSection.js +2 -2
  26. package/lib/ui-kit/Foldable/FoldableSection.js.map +1 -1
  27. package/mobile/bundle/bundle.umd.js +34 -5
  28. package/mobile/bundle/bundle.umd.min.js +1 -1
  29. package/mobile/bundle/retail/components/NoConsentDialog/NoConsentDialog.d.ts +6 -0
  30. package/mobile/bundle/ui-kit/Foldable/FoldableSection.d.ts +1 -0
  31. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +14 -1
  32. package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  33. package/mobile/dist/components/TariffsTable/TariffsTable.js +1 -1
  34. package/mobile/dist/components/TariffsTable/TariffsTable.js.map +1 -1
  35. package/mobile/dist/retail/components/NoConsentDialog/NoConsentDialog.d.ts +6 -0
  36. package/mobile/dist/retail/components/NoConsentDialog/NoConsentDialog.js +27 -0
  37. package/mobile/dist/retail/components/NoConsentDialog/NoConsentDialog.js.map +1 -0
  38. package/mobile/dist/ui-kit/Foldable/FoldableSection.d.ts +1 -0
  39. package/mobile/dist/ui-kit/Foldable/FoldableSection.js +2 -2
  40. package/mobile/dist/ui-kit/Foldable/FoldableSection.js.map +1 -1
  41. package/mobile/lib/common.css +1 -1
  42. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +14 -1
  43. package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
  44. package/mobile/lib/components/TariffsTable/TariffsTable.js +1 -1
  45. package/mobile/lib/components/TariffsTable/TariffsTable.js.map +1 -1
  46. package/mobile/lib/retail/components/NoConsentDialog/NoConsentDialog.d.ts +6 -0
  47. package/mobile/lib/retail/components/NoConsentDialog/NoConsentDialog.js +25 -0
  48. package/mobile/lib/retail/components/NoConsentDialog/NoConsentDialog.js.map +1 -0
  49. package/mobile/lib/ui-kit/Foldable/FoldableSection.d.ts +1 -0
  50. package/mobile/lib/ui-kit/Foldable/FoldableSection.js +2 -2
  51. package/mobile/lib/ui-kit/Foldable/FoldableSection.js.map +1 -1
  52. package/mobile/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +16 -1
  53. package/mobile/src/components/TariffsTable/TariffsTable.tsx +3 -1
  54. package/mobile/src/retail/components/NoConsentDialog/NoConsentDialog.tsx +55 -0
  55. package/mobile/src/ui-kit/Foldable/FoldableSection.tsx +33 -26
  56. package/package.json +1 -1
  57. package/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +16 -1
  58. package/src/components/TariffsTable/TariffsTable.tsx +3 -1
  59. package/src/retail/components/NoConsentDialog/NoConsentDialog.fixture.tsx +7 -0
  60. package/src/retail/components/NoConsentDialog/NoConsentDialog.tsx +55 -0
  61. package/src/ui-kit/Foldable/FoldableSection.tsx +33 -26
@@ -2,6 +2,7 @@
2
2
  import { JSX } from '@redneckz/uni-jsx';
3
3
  import { useEffect, useMemo, useRef, useState } from '@redneckz/uni-jsx/lib/hooks';
4
4
  import { useForm } from '../../hooks/useForm/useForm';
5
+ import { NoConsentDialog } from '../../retail/components/NoConsentDialog/NoConsentDialog';
5
6
  import { type SectionsRetailProps } from '../../retail/model/InputSectionsType';
6
7
  import { type FieldRetailDef } from '../../retail/model/RetailFormContent';
7
8
  import { getLimitedBirthdayValidation } from '../../retail/validator/getLimitedBirthdayValidation';
@@ -12,6 +13,7 @@ import { getFormValidator } from '../../ui-kit/FormField/getObjectValidator';
12
13
  import { inputColumnStyles } from '../../ui-kit/FormField/inputColumnStyle';
13
14
  import { renderTitle } from '../../ui-kit/FormField/renderTitle';
14
15
  import { Loader } from '../../ui-kit/Loader/Loader';
16
+ import { type PreventableEvent } from '../../ui-kit/PreventableEvent';
15
17
  import { ResponseTypeDialog } from '../../ui-kit/ResponseTypeDialog/ResponseTypeDialog';
16
18
  import { Text } from '../../ui-kit/Text/Text';
17
19
  import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
@@ -42,9 +44,11 @@ export const ApplicationLeadForm = JSX<ApplicationLeadFormProps>(
42
44
  ...rest
43
45
  }) => {
44
46
  const [esiaStatus, setEsiaStatus] = useState<EsiaStatuses>();
47
+ const [attemptsWithoutConsents, setAttemptsWithoutConsents] = useState(0);
45
48
  const leadForm = useRef<HTMLFormElement | null>(null);
46
49
  const applicationFormData = useMemo(() => getApplicationFormData(productType), [productType]);
47
50
  const inputs = useMemo(() => getInputs(applicationFormData), [applicationFormData]);
51
+ const noConsentDialog = useDialog(NoConsentDialog);
48
52
 
49
53
  const extendedValidatorObj = useMemo(() => getExtendedValidatorObj(productType), [productType]);
50
54
  const formValidator = useMemo(
@@ -71,6 +75,17 @@ export const ApplicationLeadForm = JSX<ApplicationLeadFormProps>(
71
75
  onSubmit: handleSubmit,
72
76
  });
73
77
 
78
+ const onSubmitWithPrecondition = (ev: PreventableEvent) => {
79
+ if (!field('processPersonalDataFlg')?.value) {
80
+ setAttemptsWithoutConsents((prev) => prev + 1);
81
+ attemptsWithoutConsents > 0 &&
82
+ noConsentDialog.open({
83
+ attempts: attemptsWithoutConsents,
84
+ });
85
+ }
86
+ onSubmit?.(ev);
87
+ };
88
+
74
89
  const responseTypeDialog = useDialog(ResponseTypeDialog);
75
90
  useEffect(() => {
76
91
  if (ok !== undefined) {
@@ -97,7 +112,7 @@ export const ApplicationLeadForm = JSX<ApplicationLeadFormProps>(
97
112
  {...rest}
98
113
  >
99
114
  {!esiaStatus ? <EsiaLoginBanner onChangeEsiaStatus={setEsiaStatus} /> : null}
100
- <form onSubmit={onSubmit} className="space-y-m relative" ref={leadForm}>
115
+ <form onSubmit={onSubmitWithPrecondition} className="space-y-m relative" ref={leadForm}>
101
116
  {esiaStatus === EsiaStatuses.Pending ? <Loader blur={false} /> : null}
102
117
  {applicationFormData.map((_, i) => (
103
118
  <div
@@ -54,7 +54,9 @@ export const TariffsTable = UniBlock<TariffsTableProps>(
54
54
  <Foldable>
55
55
  <TariffsTableWrapper>
56
56
  {visibleRows}
57
- <FoldableSection isUnfolded={isUnfolded}>{hiddenRows}</FoldableSection>
57
+ <FoldableSection isUnfolded={isUnfolded} isOverflowVisible={true}>
58
+ {hiddenRows}
59
+ </FoldableSection>
58
60
  </TariffsTableWrapper>
59
61
  <DefaultFoldButton className="text-h4" isUnfolded={isUnfolded} onClick={toggle} />
60
62
  </Foldable>
@@ -0,0 +1,55 @@
1
+ import { JSX } from '@redneckz/uni-jsx';
2
+ import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
3
+ import type { OnCloseProps } from '../../../model/OnCloseProps';
4
+
5
+ import { locationNavigator } from '../../../external/locationNavigator';
6
+ import { Button } from '../../../ui-kit/Button/Button';
7
+ import { Dialog } from '../../../ui-kit/DialogManager/Dialog';
8
+ import { Paragraph } from '../../../ui-kit/Paragraph/Paragraph';
9
+ import { noop } from '../../../utils/noop';
10
+
11
+ export interface NoConsentDialogProps extends OnCloseProps {
12
+ attempts: number;
13
+ onSubmit?: (confirmStatus: string) => void;
14
+ }
15
+
16
+ export const NoConsentDialog = JSX<NoConsentDialogProps>(({ attempts, onClose = noop }) => {
17
+ const navigator = locationNavigator();
18
+ const isMaxAttempts = attempts > 1;
19
+
20
+ const returnToMainPage = useCallback(() => {
21
+ navigator.assign('/natural');
22
+ }, []);
23
+
24
+ const handleClose = useCallback(() => {
25
+ if (isMaxAttempts) {
26
+ returnToMainPage();
27
+ } else {
28
+ onClose();
29
+ }
30
+ }, [isMaxAttempts]);
31
+
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
+ >
37
+ <div className="flex flex-col gap-xl items-center">
38
+ <Paragraph align="text-center">Уважаемый клиент!</Paragraph>
39
+ <Paragraph align="text-center">
40
+ Для получения кредита Вам необходимо обратиться в офис Банка
41
+ </Paragraph>
42
+ <div className="flex flex-col sm:flex-row gap-xl items-center">
43
+ <Button type="button" version="secondary" onClick={returnToMainPage}>
44
+ Завершить
45
+ </Button>
46
+ {isMaxAttempts ? null : (
47
+ <Button type="button" onClick={onClose}>
48
+ Продолжить
49
+ </Button>
50
+ )}
51
+ </div>
52
+ </div>
53
+ </Dialog>
54
+ );
55
+ });
@@ -6,33 +6,40 @@ import { style } from '../../utils/style';
6
6
 
7
7
  export interface FoldableSectionProps extends ComponentType {
8
8
  isUnfolded?: boolean;
9
+ isOverflowVisible?: boolean;
9
10
  }
10
11
 
11
- export const FoldableSection = JSX<FoldableSectionProps>(({ className, isUnfolded, children }) => {
12
- const containerRef = useRef<HTMLDivElement | null>(null);
13
- const childrenWrapperRef = useResizeObserver(
14
- (childrenWrapperEl) => {
15
- if (containerRef.current) {
16
- containerRef.current.style.maxHeight = isUnfolded
17
- ? `${childrenWrapperEl.scrollHeight}px`
18
- : '';
19
- }
20
- },
21
- [isUnfolded],
22
- );
12
+ export const FoldableSection = JSX<FoldableSectionProps>(
13
+ ({ className, isUnfolded, isOverflowVisible = false, children }) => {
14
+ const containerRef = useRef<HTMLDivElement | null>(null);
15
+ const childrenWrapperRef = useResizeObserver(
16
+ (childrenWrapperEl) => {
17
+ if (containerRef.current) {
18
+ containerRef.current.style.maxHeight = isUnfolded
19
+ ? `${childrenWrapperEl.scrollHeight}px`
20
+ : '';
21
+ }
22
+ },
23
+ [isUnfolded],
24
+ );
23
25
 
24
- return (
25
- <div
26
- ref={containerRef}
27
- className={style('transition-max-h duration-300 overflow-hidden', {
28
- 'max-h-0': Boolean(containerRef.current || !isUnfolded),
29
- })}
30
- role="tabpanel"
31
- aria-label="Сворачивающаяся секция"
32
- >
33
- <div className={className} ref={childrenWrapperRef}>
34
- {children}
26
+ return (
27
+ <div
28
+ ref={containerRef}
29
+ className={style(
30
+ 'transition-max-h duration-300',
31
+ isOverflowVisible && isUnfolded ? 'overflow-clip' : 'overflow-hidden',
32
+ {
33
+ 'max-h-0': Boolean(containerRef.current || !isUnfolded),
34
+ },
35
+ )}
36
+ role="tabpanel"
37
+ aria-label="Сворачивающаяся секция"
38
+ >
39
+ <div className={className} ref={childrenWrapperRef}>
40
+ {children}
41
+ </div>
35
42
  </div>
36
- </div>
37
- );
38
- });
43
+ );
44
+ },
45
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.871",
3
+ "version": "0.14.873",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -2,6 +2,7 @@
2
2
  import { JSX } from '@redneckz/uni-jsx';
3
3
  import { useEffect, useMemo, useRef, useState } from '@redneckz/uni-jsx/lib/hooks';
4
4
  import { useForm } from '../../hooks/useForm/useForm';
5
+ import { NoConsentDialog } from '../../retail/components/NoConsentDialog/NoConsentDialog';
5
6
  import { type SectionsRetailProps } from '../../retail/model/InputSectionsType';
6
7
  import { type FieldRetailDef } from '../../retail/model/RetailFormContent';
7
8
  import { getLimitedBirthdayValidation } from '../../retail/validator/getLimitedBirthdayValidation';
@@ -12,6 +13,7 @@ import { getFormValidator } from '../../ui-kit/FormField/getObjectValidator';
12
13
  import { inputColumnStyles } from '../../ui-kit/FormField/inputColumnStyle';
13
14
  import { renderTitle } from '../../ui-kit/FormField/renderTitle';
14
15
  import { Loader } from '../../ui-kit/Loader/Loader';
16
+ import { type PreventableEvent } from '../../ui-kit/PreventableEvent';
15
17
  import { ResponseTypeDialog } from '../../ui-kit/ResponseTypeDialog/ResponseTypeDialog';
16
18
  import { Text } from '../../ui-kit/Text/Text';
17
19
  import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
@@ -42,9 +44,11 @@ export const ApplicationLeadForm = JSX<ApplicationLeadFormProps>(
42
44
  ...rest
43
45
  }) => {
44
46
  const [esiaStatus, setEsiaStatus] = useState<EsiaStatuses>();
47
+ const [attemptsWithoutConsents, setAttemptsWithoutConsents] = useState(0);
45
48
  const leadForm = useRef<HTMLFormElement | null>(null);
46
49
  const applicationFormData = useMemo(() => getApplicationFormData(productType), [productType]);
47
50
  const inputs = useMemo(() => getInputs(applicationFormData), [applicationFormData]);
51
+ const noConsentDialog = useDialog(NoConsentDialog);
48
52
 
49
53
  const extendedValidatorObj = useMemo(() => getExtendedValidatorObj(productType), [productType]);
50
54
  const formValidator = useMemo(
@@ -71,6 +75,17 @@ export const ApplicationLeadForm = JSX<ApplicationLeadFormProps>(
71
75
  onSubmit: handleSubmit,
72
76
  });
73
77
 
78
+ const onSubmitWithPrecondition = (ev: PreventableEvent) => {
79
+ if (!field('processPersonalDataFlg')?.value) {
80
+ setAttemptsWithoutConsents((prev) => prev + 1);
81
+ attemptsWithoutConsents > 0 &&
82
+ noConsentDialog.open({
83
+ attempts: attemptsWithoutConsents,
84
+ });
85
+ }
86
+ onSubmit?.(ev);
87
+ };
88
+
74
89
  const responseTypeDialog = useDialog(ResponseTypeDialog);
75
90
  useEffect(() => {
76
91
  if (ok !== undefined) {
@@ -97,7 +112,7 @@ export const ApplicationLeadForm = JSX<ApplicationLeadFormProps>(
97
112
  {...rest}
98
113
  >
99
114
  {!esiaStatus ? <EsiaLoginBanner onChangeEsiaStatus={setEsiaStatus} /> : null}
100
- <form onSubmit={onSubmit} className="space-y-m relative" ref={leadForm}>
115
+ <form onSubmit={onSubmitWithPrecondition} className="space-y-m relative" ref={leadForm}>
101
116
  {esiaStatus === EsiaStatuses.Pending ? <Loader blur={false} /> : null}
102
117
  {applicationFormData.map((_, i) => (
103
118
  <div
@@ -54,7 +54,9 @@ export const TariffsTable = UniBlock<TariffsTableProps>(
54
54
  <Foldable>
55
55
  <TariffsTableWrapper>
56
56
  {visibleRows}
57
- <FoldableSection isUnfolded={isUnfolded}>{hiddenRows}</FoldableSection>
57
+ <FoldableSection isUnfolded={isUnfolded} isOverflowVisible={true}>
58
+ {hiddenRows}
59
+ </FoldableSection>
58
60
  </TariffsTableWrapper>
59
61
  <DefaultFoldButton className="text-h4" isUnfolded={isUnfolded} onClick={toggle} />
60
62
  </Foldable>
@@ -0,0 +1,7 @@
1
+ import '../../../setup-fixture';
2
+
3
+ import { NoConsentDialog } from './NoConsentDialog';
4
+
5
+ export default {
6
+ default: <NoConsentDialog attempts={1} />,
7
+ };
@@ -0,0 +1,55 @@
1
+ import { JSX } from '@redneckz/uni-jsx';
2
+ import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
3
+ import type { OnCloseProps } from '../../../model/OnCloseProps';
4
+
5
+ import { locationNavigator } from '../../../external/locationNavigator';
6
+ import { Button } from '../../../ui-kit/Button/Button';
7
+ import { Dialog } from '../../../ui-kit/DialogManager/Dialog';
8
+ import { Paragraph } from '../../../ui-kit/Paragraph/Paragraph';
9
+ import { noop } from '../../../utils/noop';
10
+
11
+ export interface NoConsentDialogProps extends OnCloseProps {
12
+ attempts: number;
13
+ onSubmit?: (confirmStatus: string) => void;
14
+ }
15
+
16
+ export const NoConsentDialog = JSX<NoConsentDialogProps>(({ attempts, onClose = noop }) => {
17
+ const navigator = locationNavigator();
18
+ const isMaxAttempts = attempts > 1;
19
+
20
+ const returnToMainPage = useCallback(() => {
21
+ navigator.assign('/natural');
22
+ }, []);
23
+
24
+ const handleClose = useCallback(() => {
25
+ if (isMaxAttempts) {
26
+ returnToMainPage();
27
+ } else {
28
+ onClose();
29
+ }
30
+ }, [isMaxAttempts]);
31
+
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
+ >
37
+ <div className="flex flex-col gap-xl items-center">
38
+ <Paragraph align="text-center">Уважаемый клиент!</Paragraph>
39
+ <Paragraph align="text-center">
40
+ Для получения кредита Вам необходимо обратиться в офис Банка
41
+ </Paragraph>
42
+ <div className="flex flex-col sm:flex-row gap-xl items-center">
43
+ <Button type="button" version="secondary" onClick={returnToMainPage}>
44
+ Завершить
45
+ </Button>
46
+ {isMaxAttempts ? null : (
47
+ <Button type="button" onClick={onClose}>
48
+ Продолжить
49
+ </Button>
50
+ )}
51
+ </div>
52
+ </div>
53
+ </Dialog>
54
+ );
55
+ });
@@ -6,33 +6,40 @@ import { style } from '../../utils/style';
6
6
 
7
7
  export interface FoldableSectionProps extends ComponentType {
8
8
  isUnfolded?: boolean;
9
+ isOverflowVisible?: boolean;
9
10
  }
10
11
 
11
- export const FoldableSection = JSX<FoldableSectionProps>(({ className, isUnfolded, children }) => {
12
- const containerRef = useRef<HTMLDivElement | null>(null);
13
- const childrenWrapperRef = useResizeObserver(
14
- (childrenWrapperEl) => {
15
- if (containerRef.current) {
16
- containerRef.current.style.maxHeight = isUnfolded
17
- ? `${childrenWrapperEl.scrollHeight}px`
18
- : '';
19
- }
20
- },
21
- [isUnfolded],
22
- );
12
+ export const FoldableSection = JSX<FoldableSectionProps>(
13
+ ({ className, isUnfolded, isOverflowVisible = false, children }) => {
14
+ const containerRef = useRef<HTMLDivElement | null>(null);
15
+ const childrenWrapperRef = useResizeObserver(
16
+ (childrenWrapperEl) => {
17
+ if (containerRef.current) {
18
+ containerRef.current.style.maxHeight = isUnfolded
19
+ ? `${childrenWrapperEl.scrollHeight}px`
20
+ : '';
21
+ }
22
+ },
23
+ [isUnfolded],
24
+ );
23
25
 
24
- return (
25
- <div
26
- ref={containerRef}
27
- className={style('transition-max-h duration-300 overflow-hidden', {
28
- 'max-h-0': Boolean(containerRef.current || !isUnfolded),
29
- })}
30
- role="tabpanel"
31
- aria-label="Сворачивающаяся секция"
32
- >
33
- <div className={className} ref={childrenWrapperRef}>
34
- {children}
26
+ return (
27
+ <div
28
+ ref={containerRef}
29
+ className={style(
30
+ 'transition-max-h duration-300',
31
+ isOverflowVisible && isUnfolded ? 'overflow-clip' : 'overflow-hidden',
32
+ {
33
+ 'max-h-0': Boolean(containerRef.current || !isUnfolded),
34
+ },
35
+ )}
36
+ role="tabpanel"
37
+ aria-label="Сворачивающаяся секция"
38
+ >
39
+ <div className={className} ref={childrenWrapperRef}>
40
+ {children}
41
+ </div>
35
42
  </div>
36
- </div>
37
- );
38
- });
43
+ );
44
+ },
45
+ );