@npm_leadtech/legal-lib-components 7.56.1 → 7.56.11
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/dist/src/components/molecules/AccordionItem/AccordionItem.d.ts +1 -1
- package/dist/src/components/molecules/AccordionItem/AccordionItem.js +23 -3
- package/dist/src/components/molecules/AccordionItem/AccordionItem.tsx +23 -2
- package/dist/src/components/molecules/AccordionItem/AccordionItemProps.types.d.ts +1 -0
- package/dist/src/components/molecules/AccordionItem/AccordionItemProps.types.ts +1 -0
- package/dist/src/components/molecules/InfoBarFooter/InfoBarFooter.js +2 -2
- package/dist/src/components/molecules/InfoBarFooter/InfoBarFooter.tsx +4 -9
- package/dist/src/components/organisms/Accordion/Accordion.d.ts +1 -1
- package/dist/src/components/organisms/Accordion/Accordion.js +2 -2
- package/dist/src/components/organisms/Accordion/Accordion.tsx +7 -1
- package/dist/src/components/organisms/Accordion/AccordionProps.types.d.ts +1 -0
- package/dist/src/components/organisms/Accordion/AccordionProps.types.ts +1 -0
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type AccordionItemProps } from './AccordionItemProps.types';
|
|
3
|
-
export declare const AccordionItem: ({ accordionRightContent, children, defaultHeightItem, index, isOpen, onClick, title }: AccordionItemProps) => React.JSX.Element;
|
|
3
|
+
export declare const AccordionItem: ({ accordionRightContent, children, defaultHeightItem, index, isOpen, onClick, title, heightAutoChange }: AccordionItemProps) => React.JSX.Element;
|
|
@@ -1,21 +1,41 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
3
|
-
import { useEffect, useRef } from 'react';
|
|
3
|
+
import React, { useEffect, useRef } from 'react';
|
|
4
4
|
import { useDispatchDataAccordionItem, useStateDataAccordionItem } from '../../organisms/Accordion/Accordion.context';
|
|
5
5
|
import { AccordionItemStyled } from './AccordionItem.styled';
|
|
6
|
-
export const AccordionItem = ({ accordionRightContent, children, defaultHeightItem = 416, index, isOpen, onClick, title }) => {
|
|
6
|
+
export const AccordionItem = ({ accordionRightContent, children, defaultHeightItem = 416, index, isOpen, onClick, title, heightAutoChange = false }) => {
|
|
7
7
|
const contenReftHeight = useRef(null);
|
|
8
8
|
const { state } = useStateDataAccordionItem(index);
|
|
9
9
|
const { dispatch } = useDispatchDataAccordionItem();
|
|
10
|
+
const [heightAccordionItem, setHeightAccordionItem] = React.useState(defaultHeightItem);
|
|
10
11
|
useEffect(() => {
|
|
11
12
|
if (state.locked.actionType === 'unlocked') {
|
|
12
13
|
onClick();
|
|
13
14
|
dispatch({ type: 'unlocked', accordionItem: index, resetAction: 'default' });
|
|
14
15
|
}
|
|
15
16
|
}, [state.locked.actionType]);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
let intervalId;
|
|
19
|
+
if (heightAutoChange) {
|
|
20
|
+
intervalId = setInterval(() => {
|
|
21
|
+
const height = contenReftHeight.current?.children[0].getBoundingClientRect().height ?? defaultHeightItem;
|
|
22
|
+
if (heightAccordionItem !== height) {
|
|
23
|
+
setHeightAccordionItem(height);
|
|
24
|
+
}
|
|
25
|
+
}, 500);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
setHeightAccordionItem(contenReftHeight?.current?.scrollHeight ?? defaultHeightItem);
|
|
29
|
+
}
|
|
30
|
+
return () => {
|
|
31
|
+
if (intervalId !== undefined) {
|
|
32
|
+
clearInterval(intervalId);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
16
36
|
return (_jsxs(AccordionItemStyled, { className: 'accordion__container', children: [_jsxs("button", { className: `accordion__button
|
|
17
37
|
${state.handler === 'success' ? '--success' : ''}
|
|
18
38
|
${state.locked.isLocked ? '--locked' : ''}`, onClick: () => {
|
|
19
39
|
!state.locked.isLocked && onClick();
|
|
20
|
-
}, children: [_jsx("p", { className: `accordion__title ${state.locked.isLocked ? '--locked' : ''}`, children: title }), accordionRightContent] }), _jsx("div", { ref: contenReftHeight, className: `accordion__content ${!isOpen ? '--closed' : ''}`, style: isOpen ? { height:
|
|
40
|
+
}, children: [_jsx("p", { className: `accordion__title ${state.locked.isLocked ? '--locked' : ''}`, children: title }), accordionRightContent] }), _jsx("div", { ref: contenReftHeight, className: `accordion__content ${!isOpen ? '--closed' : ''}`, style: isOpen ? { height: heightAccordionItem } : { height: '0px' }, children: children })] }));
|
|
21
41
|
};
|
|
@@ -12,11 +12,13 @@ export const AccordionItem = ({
|
|
|
12
12
|
index,
|
|
13
13
|
isOpen,
|
|
14
14
|
onClick,
|
|
15
|
-
title
|
|
15
|
+
title,
|
|
16
|
+
heightAutoChange = false
|
|
16
17
|
}: AccordionItemProps): React.JSX.Element => {
|
|
17
18
|
const contenReftHeight = useRef<HTMLInputElement>(null)
|
|
18
19
|
const { state } = useStateDataAccordionItem(index)
|
|
19
20
|
const { dispatch } = useDispatchDataAccordionItem()
|
|
21
|
+
const [heightAccordionItem, setHeightAccordionItem] = React.useState<number>(defaultHeightItem)
|
|
20
22
|
|
|
21
23
|
useEffect(() => {
|
|
22
24
|
if (state.locked.actionType === 'unlocked') {
|
|
@@ -25,6 +27,25 @@ export const AccordionItem = ({
|
|
|
25
27
|
}
|
|
26
28
|
}, [state.locked.actionType])
|
|
27
29
|
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
let intervalId: ReturnType<typeof setInterval> | undefined
|
|
32
|
+
if (heightAutoChange) {
|
|
33
|
+
intervalId = setInterval(() => {
|
|
34
|
+
const height = contenReftHeight.current?.children[0].getBoundingClientRect().height ?? defaultHeightItem
|
|
35
|
+
if (heightAccordionItem !== height) {
|
|
36
|
+
setHeightAccordionItem(height)
|
|
37
|
+
}
|
|
38
|
+
}, 500)
|
|
39
|
+
} else {
|
|
40
|
+
setHeightAccordionItem(contenReftHeight?.current?.scrollHeight ?? defaultHeightItem)
|
|
41
|
+
}
|
|
42
|
+
return () => {
|
|
43
|
+
if (intervalId !== undefined) {
|
|
44
|
+
clearInterval(intervalId)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}, [])
|
|
48
|
+
|
|
28
49
|
return (
|
|
29
50
|
<AccordionItemStyled className='accordion__container'>
|
|
30
51
|
<button
|
|
@@ -42,7 +63,7 @@ export const AccordionItem = ({
|
|
|
42
63
|
<div
|
|
43
64
|
ref={contenReftHeight}
|
|
44
65
|
className={`accordion__content ${!isOpen ? '--closed' : ''}`}
|
|
45
|
-
style={isOpen ? { height:
|
|
66
|
+
style={isOpen ? { height: heightAccordionItem } : { height: '0px' }}
|
|
46
67
|
>
|
|
47
68
|
{children}
|
|
48
69
|
</div>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { ContactBarWrapperStyled, ContactBarWrapperText, ScheduleWrapper } from './InfoBarFooter.styled';
|
|
3
3
|
import { IconWeb } from '../../../../images/componentsSvg/IconWeb';
|
|
4
4
|
import { WideInfoBar } from '../../atoms/WideInfoBar';
|
|
5
5
|
export const InfoBarFooter = ({ sitePhone, siteSchedule, securityText, guaranteeText, securityIconBlack, guaranteeIconGrey, isJonSnow = false, isAnonymousPayment = false }) => {
|
|
6
|
-
return (_jsx(WideInfoBar, { children: _jsxs(_Fragment, { children: [_jsxs(ContactBarWrapperStyled, { className: `${(isJonSnow || isAnonymousPayment) && 'hidden'}`, children: [sitePhone && _jsx(IconWeb, {}), _jsxs(ScheduleWrapper, { children: [_jsxs("div", { className: 'is-mobile', children: [
|
|
6
|
+
return (_jsx(WideInfoBar, { children: _jsxs(_Fragment, { children: [_jsxs(ContactBarWrapperStyled, { className: `${(isJonSnow || isAnonymousPayment) && 'hidden'}`, children: [sitePhone && _jsx(IconWeb, {}), _jsxs(ScheduleWrapper, { children: [_jsxs("div", { className: 'is-mobile', children: [_jsx("a", { className: 'phone', href: `tel:${sitePhone}`, children: _jsx("strong", { children: sitePhone }) }), sitePhone ? `${sitePhone} - ${siteSchedule}` : siteSchedule] }), _jsx("div", { className: 'no-mobile', children: sitePhone ? (_jsxs(_Fragment, { children: [_jsx("strong", { children: sitePhone }), " - ", siteSchedule] })) : (siteSchedule) })] })] }), _jsxs(ContactBarWrapperStyled, { children: [_jsx("img", { src: securityIconBlack, alt: 'security-icon' }), _jsx(ContactBarWrapperText, { children: securityText })] }), _jsxs(ContactBarWrapperStyled, { children: [_jsx("img", { src: guaranteeIconGrey, alt: 'guarantee-icon' }), _jsx(ContactBarWrapperText, { children: guaranteeText })] })] }) }));
|
|
7
7
|
};
|
|
8
8
|
export default InfoBarFooter;
|
|
@@ -21,15 +21,10 @@ export const InfoBarFooter: React.FC<InfoBarFooterProps> = ({
|
|
|
21
21
|
{sitePhone && <IconWeb />}
|
|
22
22
|
<ScheduleWrapper>
|
|
23
23
|
<div className='is-mobile'>
|
|
24
|
-
{sitePhone
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
</a>
|
|
29
|
-
{' - '}
|
|
30
|
-
</>
|
|
31
|
-
)}
|
|
32
|
-
{siteSchedule}
|
|
24
|
+
<a className='phone' href={`tel:${sitePhone}`}>
|
|
25
|
+
<strong>{sitePhone}</strong>
|
|
26
|
+
</a>
|
|
27
|
+
{sitePhone ? `${sitePhone} - ${siteSchedule}` : siteSchedule}
|
|
33
28
|
</div>
|
|
34
29
|
<div className='no-mobile'>
|
|
35
30
|
{sitePhone ? (
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type AccordionProps } from './AccordionProps.types';
|
|
3
|
-
export declare const Accordion: ({ data, defaultActiveIndex, defaultHeightItem }: AccordionProps) => React.JSX.Element;
|
|
3
|
+
export declare const Accordion: ({ data, defaultActiveIndex, defaultHeightItem, heightAutoChange }: AccordionProps) => React.JSX.Element;
|
|
@@ -3,12 +3,12 @@ import { useState } from 'react';
|
|
|
3
3
|
import { AccordionItem } from '../../molecules';
|
|
4
4
|
import { AccordionProvider } from './Accordion.context';
|
|
5
5
|
import { AccordionStyled } from './Accordion.styled';
|
|
6
|
-
export const Accordion = ({ data, defaultActiveIndex = 0, defaultHeightItem }) => {
|
|
6
|
+
export const Accordion = ({ data, defaultActiveIndex = 0, defaultHeightItem, heightAutoChange = false }) => {
|
|
7
7
|
const [activeIndex, setActiveIndex] = useState(defaultActiveIndex);
|
|
8
8
|
const handleItemClick = (index) => {
|
|
9
9
|
setActiveIndex((prevIndex) => (prevIndex === index ? -1 : index));
|
|
10
10
|
};
|
|
11
|
-
return (_jsx(AccordionProvider, { elements: data.length, children: _jsx(AccordionStyled, { children: data.map((item, index) => (_jsx(AccordionItem, { accordionRightContent: item?.accordionRightContent, defaultHeightItem: defaultHeightItem, index: index, isOpen: activeIndex === index, onClick: () => {
|
|
11
|
+
return (_jsx(AccordionProvider, { elements: data.length, children: _jsx(AccordionStyled, { children: data.map((item, index) => (_jsx(AccordionItem, { accordionRightContent: item?.accordionRightContent, defaultHeightItem: defaultHeightItem, heightAutoChange: heightAutoChange, index: index, isOpen: activeIndex === index, onClick: () => {
|
|
12
12
|
handleItemClick(index);
|
|
13
13
|
}, title: item.title, children: item.children }, index))) }) }));
|
|
14
14
|
};
|
|
@@ -4,7 +4,12 @@ import { type AccordionProps } from './AccordionProps.types'
|
|
|
4
4
|
import { AccordionProvider } from './Accordion.context'
|
|
5
5
|
import { AccordionStyled } from './Accordion.styled'
|
|
6
6
|
|
|
7
|
-
export const Accordion = ({
|
|
7
|
+
export const Accordion = ({
|
|
8
|
+
data,
|
|
9
|
+
defaultActiveIndex = 0,
|
|
10
|
+
defaultHeightItem,
|
|
11
|
+
heightAutoChange = false
|
|
12
|
+
}: AccordionProps): React.JSX.Element => {
|
|
8
13
|
const [activeIndex, setActiveIndex] = useState(defaultActiveIndex)
|
|
9
14
|
|
|
10
15
|
const handleItemClick = (index: number): void => {
|
|
@@ -18,6 +23,7 @@ export const Accordion = ({ data, defaultActiveIndex = 0, defaultHeightItem }: A
|
|
|
18
23
|
<AccordionItem
|
|
19
24
|
accordionRightContent={item?.accordionRightContent}
|
|
20
25
|
defaultHeightItem={defaultHeightItem}
|
|
26
|
+
heightAutoChange={heightAutoChange}
|
|
21
27
|
index={index}
|
|
22
28
|
isOpen={activeIndex === index}
|
|
23
29
|
key={index}
|