@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.
- package/bundle/bundle.umd.js +34 -5
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/retail/components/NoConsentDialog/NoConsentDialog.d.ts +6 -0
- package/bundle/ui-kit/Foldable/FoldableSection.d.ts +1 -0
- package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +14 -1
- package/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
- package/dist/components/TariffsTable/TariffsTable.js +1 -1
- package/dist/components/TariffsTable/TariffsTable.js.map +1 -1
- package/dist/retail/components/NoConsentDialog/NoConsentDialog.d.ts +6 -0
- package/dist/retail/components/NoConsentDialog/NoConsentDialog.js +27 -0
- package/dist/retail/components/NoConsentDialog/NoConsentDialog.js.map +1 -0
- package/dist/ui-kit/Foldable/FoldableSection.d.ts +1 -0
- package/dist/ui-kit/Foldable/FoldableSection.js +2 -2
- package/dist/ui-kit/Foldable/FoldableSection.js.map +1 -1
- package/lib/common.css +1 -1
- package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +14 -1
- package/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
- package/lib/components/TariffsTable/TariffsTable.js +1 -1
- package/lib/components/TariffsTable/TariffsTable.js.map +1 -1
- package/lib/retail/components/NoConsentDialog/NoConsentDialog.d.ts +6 -0
- package/lib/retail/components/NoConsentDialog/NoConsentDialog.fixture.d.ts +5 -0
- package/lib/retail/components/NoConsentDialog/NoConsentDialog.js +25 -0
- package/lib/retail/components/NoConsentDialog/NoConsentDialog.js.map +1 -0
- package/lib/ui-kit/Foldable/FoldableSection.d.ts +1 -0
- package/lib/ui-kit/Foldable/FoldableSection.js +2 -2
- package/lib/ui-kit/Foldable/FoldableSection.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +34 -5
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/retail/components/NoConsentDialog/NoConsentDialog.d.ts +6 -0
- package/mobile/bundle/ui-kit/Foldable/FoldableSection.d.ts +1 -0
- package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js +14 -1
- package/mobile/dist/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
- package/mobile/dist/components/TariffsTable/TariffsTable.js +1 -1
- package/mobile/dist/components/TariffsTable/TariffsTable.js.map +1 -1
- package/mobile/dist/retail/components/NoConsentDialog/NoConsentDialog.d.ts +6 -0
- package/mobile/dist/retail/components/NoConsentDialog/NoConsentDialog.js +27 -0
- package/mobile/dist/retail/components/NoConsentDialog/NoConsentDialog.js.map +1 -0
- package/mobile/dist/ui-kit/Foldable/FoldableSection.d.ts +1 -0
- package/mobile/dist/ui-kit/Foldable/FoldableSection.js +2 -2
- package/mobile/dist/ui-kit/Foldable/FoldableSection.js.map +1 -1
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js +14 -1
- package/mobile/lib/components/ApplicationLeadForm/ApplicationLeadForm.js.map +1 -1
- package/mobile/lib/components/TariffsTable/TariffsTable.js +1 -1
- package/mobile/lib/components/TariffsTable/TariffsTable.js.map +1 -1
- package/mobile/lib/retail/components/NoConsentDialog/NoConsentDialog.d.ts +6 -0
- package/mobile/lib/retail/components/NoConsentDialog/NoConsentDialog.js +25 -0
- package/mobile/lib/retail/components/NoConsentDialog/NoConsentDialog.js.map +1 -0
- package/mobile/lib/ui-kit/Foldable/FoldableSection.d.ts +1 -0
- package/mobile/lib/ui-kit/Foldable/FoldableSection.js +2 -2
- package/mobile/lib/ui-kit/Foldable/FoldableSection.js.map +1 -1
- package/mobile/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +16 -1
- package/mobile/src/components/TariffsTable/TariffsTable.tsx +3 -1
- package/mobile/src/retail/components/NoConsentDialog/NoConsentDialog.tsx +55 -0
- package/mobile/src/ui-kit/Foldable/FoldableSection.tsx +33 -26
- package/package.json +1 -1
- package/src/components/ApplicationLeadForm/ApplicationLeadForm.tsx +16 -1
- package/src/components/TariffsTable/TariffsTable.tsx +3 -1
- package/src/retail/components/NoConsentDialog/NoConsentDialog.fixture.tsx +7 -0
- package/src/retail/components/NoConsentDialog/NoConsentDialog.tsx +55 -0
- 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={
|
|
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}
|
|
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>(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
containerRef.current
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
);
|
package/package.json
CHANGED
|
@@ -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={
|
|
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}
|
|
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>(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
containerRef.current
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
);
|