@npm_leadtech/legal-lib-components 5.65.2 → 5.67.0
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/images/jpg/aboutus-img-core-values.jpg +0 -0
- package/dist/images/jpg/aboutus-img-our-mission.jpg +0 -0
- package/dist/src/components/atoms/CardStoryItem/CardStoryItem.d.ts +4 -0
- package/dist/src/components/atoms/CardStoryItem/CardStoryItem.js +6 -0
- package/dist/src/components/atoms/CardStoryItem/CardStoryItem.styled.d.ts +1 -0
- package/dist/src/components/atoms/CardStoryItem/CardStoryItem.styled.js +91 -0
- package/dist/src/components/atoms/CardStoryItem/CardStoryItem.styled.ts +92 -0
- package/dist/src/components/atoms/CardStoryItem/CardStoryItem.tsx +23 -0
- package/dist/src/components/atoms/CardStoryItem/CardStoryItemProps.types.d.ts +5 -0
- package/dist/src/components/atoms/CardStoryItem/CardStoryItemProps.types.js +1 -0
- package/dist/src/components/atoms/CardStoryItem/CardStoryItemProps.types.ts +5 -0
- package/dist/src/components/atoms/CardStoryItem/index.d.ts +2 -0
- package/dist/src/components/atoms/CardStoryItem/index.js +1 -0
- package/dist/src/components/atoms/CardStoryItem/index.ts +2 -0
- package/dist/src/components/atoms/Video/Video.d.ts +1 -1
- package/dist/src/components/atoms/Video/Video.js +2 -2
- package/dist/src/components/atoms/Video/Video.tsx +2 -13
- package/dist/src/components/atoms/Video/VideoProps.types.d.ts +0 -2
- package/dist/src/components/atoms/Video/VideoProps.types.ts +0 -2
- package/dist/src/components/molecules/CardStory/CardStory.d.ts +4 -0
- package/dist/src/components/molecules/CardStory/CardStory.js +7 -0
- package/dist/src/components/molecules/CardStory/CardStory.styled.d.ts +1 -0
- package/dist/src/components/molecules/CardStory/CardStory.styled.js +24 -0
- package/dist/src/components/molecules/CardStory/CardStory.styled.ts +25 -0
- package/dist/src/components/molecules/CardStory/CardStory.tsx +17 -0
- package/dist/src/components/molecules/CardStory/CardStoryProps.types.d.ts +4 -0
- package/dist/src/components/molecules/CardStory/CardStoryProps.types.js +1 -0
- package/dist/src/components/molecules/CardStory/CardStoryProps.types.ts +5 -0
- package/dist/src/components/molecules/CardStory/index.d.ts +2 -0
- package/dist/src/components/molecules/CardStory/index.js +1 -0
- package/dist/src/components/molecules/CardStory/index.ts +2 -0
- package/dist/src/components/organisms/AboutUsContent/AboutUsContent.styled.js +24 -6
- package/dist/src/components/organisms/AboutUsContent/AboutUsContent.styled.ts +24 -6
- package/dist/src/components/organisms/TryOurFreeLegalBlogsContent/TryOurFreeLegalBlogsContent.js +9 -2
- package/dist/src/components/organisms/TryOurFreeLegalBlogsContent/TryOurFreeLegalBlogsContent.styled.js +50 -0
- package/dist/src/components/organisms/TryOurFreeLegalBlogsContent/TryOurFreeLegalBlogsContent.styled.ts +50 -0
- package/dist/src/components/organisms/TryOurFreeLegalBlogsContent/TryOurFreeLegalBlogsContent.tsx +18 -3
- package/dist/src/components/organisms/TryOurFreeLegalBlogsContent/TryOurFreeLegalBlogsContentProps.types.d.ts +6 -0
- package/dist/src/components/organisms/TryOurFreeLegalBlogsContent/TryOurFreeLegalBlogsContentProps.types.js +6 -1
- package/dist/src/components/organisms/TryOurFreeLegalBlogsContent/TryOurFreeLegalBlogsContentProps.types.ts +7 -0
- package/dist/src/components/organisms/TryOurFreeLegalBlogsContent/index.d.ts +1 -1
- package/dist/src/components/organisms/TryOurFreeLegalBlogsContent/index.js +1 -0
- package/dist/src/components/organisms/TryOurFreeLegalBlogsContent/index.ts +4 -1
- package/dist/src/components/organisms/Wizard/Wizard.d.ts +3 -0
- package/dist/src/components/organisms/Wizard/Wizard.js +41 -0
- package/dist/src/components/organisms/Wizard/Wizard.tsx +64 -0
- package/dist/src/components/organisms/Wizard/WizardProps.types.d.ts +5 -0
- package/dist/src/components/organisms/Wizard/WizardProps.types.js +1 -0
- package/dist/src/components/organisms/Wizard/WizardProps.types.ts +5 -0
- package/dist/src/components/organisms/Wizard/components/Footer.d.ts +6 -0
- package/dist/src/components/organisms/Wizard/components/Footer.js +4 -0
- package/dist/src/components/organisms/Wizard/components/Footer.tsx +10 -0
- package/dist/src/components/organisms/Wizard/components/Header.d.ts +6 -0
- package/dist/src/components/organisms/Wizard/components/Header.js +4 -0
- package/dist/src/components/organisms/Wizard/components/Header.tsx +10 -0
- package/dist/src/components/organisms/Wizard/components/index.d.ts +2 -0
- package/dist/src/components/organisms/Wizard/components/index.js +2 -0
- package/dist/src/components/organisms/Wizard/components/index.ts +2 -0
- package/dist/src/components/organisms/Wizard/constants/index.d.ts +2 -0
- package/dist/src/components/organisms/Wizard/constants/index.js +2 -0
- package/dist/src/components/organisms/Wizard/constants/index.ts +2 -0
- package/dist/src/components/organisms/Wizard/context/WizardContext.d.ts +9 -0
- package/dist/src/components/organisms/Wizard/context/WizardContext.js +8 -0
- package/dist/src/components/organisms/Wizard/context/WizardContext.tsx +17 -0
- package/dist/src/components/organisms/Wizard/context/index.d.ts +1 -0
- package/dist/src/components/organisms/Wizard/context/index.js +1 -0
- package/dist/src/components/organisms/Wizard/context/index.ts +1 -0
- package/dist/src/components/organisms/Wizard/controls/navigation.d.ts +14 -0
- package/dist/src/components/organisms/Wizard/controls/navigation.js +27 -0
- package/dist/src/components/organisms/Wizard/controls/navigation.ts +50 -0
- package/dist/src/components/organisms/Wizard/hooks/index.d.ts +1 -0
- package/dist/src/components/organisms/Wizard/hooks/index.js +1 -0
- package/dist/src/components/organisms/Wizard/hooks/index.ts +1 -0
- package/dist/src/components/organisms/Wizard/hooks/useHash.d.ts +12 -0
- package/dist/src/components/organisms/Wizard/hooks/useHash.js +59 -0
- package/dist/src/components/organisms/Wizard/hooks/useHash.tsx +87 -0
- package/dist/src/components/organisms/Wizard/index.d.ts +4 -0
- package/dist/src/components/organisms/Wizard/index.js +3 -0
- package/dist/src/components/organisms/Wizard/index.ts +4 -0
- package/dist/src/components/organisms/index.d.ts +1 -0
- package/dist/src/components/organisms/index.js +1 -0
- package/dist/src/components/organisms/index.ts +1 -0
- package/dist/src/components/pages/AboutUsPage/AboutUsPage.js +3 -3
- package/dist/src/components/pages/AboutUsPage/AboutUsPage.tsx +7 -4
- package/dist/src/components/pages/AboutUsPage/AboutUsPageProps.d.ts +4 -2
- package/dist/src/components/pages/AboutUsPage/AboutUsPageProps.ts +4 -1
- package/dist/src/components/sections/AboutUsSection/AboutUsSection.styled.js +9 -13
- package/dist/src/components/sections/AboutUsSection/AboutUsSection.styled.ts +9 -13
- package/dist/src/components/sections/CardStorySection/CardStorySection.d.ts +4 -0
- package/dist/src/components/sections/CardStorySection/CardStorySection.js +7 -0
- package/dist/src/components/sections/CardStorySection/CardStorySection.styled.d.ts +1 -0
- package/dist/src/components/sections/CardStorySection/CardStorySection.styled.js +42 -0
- package/dist/src/components/sections/CardStorySection/CardStorySection.styled.ts +43 -0
- package/dist/src/components/sections/CardStorySection/CardStorySection.tsx +19 -0
- package/dist/src/components/sections/CardStorySection/CardStorySectionProps.types.d.ts +7 -0
- package/dist/src/components/sections/CardStorySection/CardStorySectionProps.types.js +1 -0
- package/dist/src/components/sections/CardStorySection/CardStorySectionProps.types.ts +8 -0
- package/dist/src/components/sections/CardStorySection/index.d.ts +2 -0
- package/dist/src/components/sections/CardStorySection/index.js +1 -0
- package/dist/src/components/sections/CardStorySection/index.ts +2 -0
- package/dist/src/components/sections/GuidelinesSection/GuidelinesSection.styled.js +0 -1
- package/dist/src/components/sections/GuidelinesSection/GuidelinesSection.styled.ts +0 -1
- package/dist/src/components/sections/StepsRatafiaSection/StepsRatafiaSection.js +2 -2
- package/dist/src/components/sections/StepsRatafiaSection/StepsRatafiaSection.tsx +2 -9
- package/dist/src/components/sections/StepsRatafiaSection/StepsRatafiaSectionProps.types.d.ts +0 -1
- package/dist/src/components/sections/StepsRatafiaSection/StepsRatafiaSectionProps.types.ts +0 -1
- package/dist/src/components/sections/TryOurFreeLegalBlogsSection/TryOurFreeLegalBlogsSection.js +1 -1
- package/dist/src/components/sections/TryOurFreeLegalBlogsSection/TryOurFreeLegalBlogsSection.tsx +5 -1
- package/dist/src/components/sections/index.d.ts +1 -0
- package/dist/src/components/sections/index.js +1 -0
- package/dist/src/components/sections/index.ts +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/dist/src/components/organisms/TryOurFreeLegalBlogsContent/TryOurFreeLegalBlogsContent.scss +0 -50
|
@@ -7,6 +7,56 @@ export const TryOurFreeLegalBlogsContentStyled = styled.div`
|
|
|
7
7
|
@media ${device['landscape-tablets']} {
|
|
8
8
|
flex-direction: row;
|
|
9
9
|
}
|
|
10
|
+
|
|
11
|
+
&.try-our-free-legal-blogs-section-content--our-mission {
|
|
12
|
+
margin-top: 1.5rem;
|
|
13
|
+
margin-bottom: 1.5rem;
|
|
14
|
+
align-items: center;
|
|
15
|
+
@media ${device['landscape-tablets']} {
|
|
16
|
+
margin-top: 3rem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.try-our-free-legal-blogs-section__texts {
|
|
20
|
+
margin-bottom: 2rem;
|
|
21
|
+
@media ${device['landscape-tablets']} {
|
|
22
|
+
margin-bottom: 1rem;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&__title {
|
|
26
|
+
font-family: var(--font-sans);
|
|
27
|
+
font-size: 28px;
|
|
28
|
+
font-weight: 700;
|
|
29
|
+
text-align: left;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&.try-our-free-legal-blogs-section-content--our-mission-first-image {
|
|
35
|
+
margin-top: 1.5rem;
|
|
36
|
+
margin-bottom: 1.5rem;
|
|
37
|
+
align-items: center;
|
|
38
|
+
@media ${device['landscape-tablets']} {
|
|
39
|
+
margin-bottom: 3rem;
|
|
40
|
+
flex-direction: row-reverse;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.try-our-free-legal-blogs-section__texts {
|
|
44
|
+
margin-bottom: 2rem;
|
|
45
|
+
@media ${device['landscape-tablets']} {
|
|
46
|
+
margin-bottom: 1rem;
|
|
47
|
+
margin-right: 0rem;
|
|
48
|
+
margin-left: 3rem;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&__title {
|
|
52
|
+
font-family: var(--font-sans);
|
|
53
|
+
font-size: 28px;
|
|
54
|
+
font-weight: 700;
|
|
55
|
+
text-align: left;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
10
60
|
.try-our-free-legal-blogs-section__texts {
|
|
11
61
|
flex-basis: 50%;
|
|
12
62
|
display: flex;
|
package/dist/src/components/organisms/TryOurFreeLegalBlogsContent/TryOurFreeLegalBlogsContent.tsx
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import React, { type FC } from 'react'
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
type TryOurFreeLegalBlogsContentProps,
|
|
5
|
+
TryOurFreeLegalBlogsContentType
|
|
6
|
+
} from './TryOurFreeLegalBlogsContentProps.types'
|
|
3
7
|
import { RichTextInner } from '../../atoms'
|
|
4
|
-
import { type TryOurFreeLegalBlogsContentProps } from './TryOurFreeLegalBlogsContentProps.types'
|
|
5
8
|
import { TryOurFreeLegalBlogsContentStyled } from './TryOurFreeLegalBlogsContent.styled'
|
|
9
|
+
import classNames from 'classnames'
|
|
6
10
|
|
|
7
|
-
const TryOurFreeLegalBlogsContent: FC<TryOurFreeLegalBlogsContentProps> = ({
|
|
11
|
+
const TryOurFreeLegalBlogsContent: FC<TryOurFreeLegalBlogsContentProps> = ({
|
|
12
|
+
title,
|
|
13
|
+
image,
|
|
14
|
+
children,
|
|
15
|
+
type = TryOurFreeLegalBlogsContentType.default
|
|
16
|
+
}) => {
|
|
17
|
+
const classTry = classNames({
|
|
18
|
+
'try-our-free-legal-blogs-section-content': true,
|
|
19
|
+
'try-our-free-legal-blogs-section-content--our-mission': TryOurFreeLegalBlogsContentType.ourMission === type,
|
|
20
|
+
'try-our-free-legal-blogs-section-content--our-mission-first-image':
|
|
21
|
+
TryOurFreeLegalBlogsContentType.ourMissionFirstImage === type
|
|
22
|
+
})
|
|
8
23
|
return (
|
|
9
|
-
<TryOurFreeLegalBlogsContentStyled>
|
|
24
|
+
<TryOurFreeLegalBlogsContentStyled className={classTry}>
|
|
10
25
|
<div className='try-our-free-legal-blogs-section__texts'>
|
|
11
26
|
<h2 className='try-our-free-legal-blogs-section__texts__title'>{title}</h2>
|
|
12
27
|
<RichTextInner customClass='try-our-free-legal-blogs-section__texts__body'>{children}</RichTextInner>
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
export declare enum TryOurFreeLegalBlogsContentType {
|
|
2
|
+
default = "Default",
|
|
3
|
+
ourMission = "Our Mission",
|
|
4
|
+
ourMissionFirstImage = "Our Mission First Image"
|
|
5
|
+
}
|
|
1
6
|
export interface TryOurFreeLegalBlogsContentProps {
|
|
2
7
|
title: string;
|
|
3
8
|
image: React.ReactNode;
|
|
4
9
|
children: React.ReactNode;
|
|
10
|
+
type?: TryOurFreeLegalBlogsContentType;
|
|
5
11
|
}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var TryOurFreeLegalBlogsContentType;
|
|
2
|
+
(function (TryOurFreeLegalBlogsContentType) {
|
|
3
|
+
TryOurFreeLegalBlogsContentType["default"] = "Default";
|
|
4
|
+
TryOurFreeLegalBlogsContentType["ourMission"] = "Our Mission";
|
|
5
|
+
TryOurFreeLegalBlogsContentType["ourMissionFirstImage"] = "Our Mission First Image";
|
|
6
|
+
})(TryOurFreeLegalBlogsContentType || (TryOurFreeLegalBlogsContentType = {}));
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
export enum TryOurFreeLegalBlogsContentType {
|
|
2
|
+
default = 'Default',
|
|
3
|
+
ourMission = 'Our Mission',
|
|
4
|
+
ourMissionFirstImage = 'Our Mission First Image'
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
export interface TryOurFreeLegalBlogsContentProps {
|
|
2
8
|
title: string
|
|
3
9
|
image: React.ReactNode
|
|
4
10
|
children: React.ReactNode
|
|
11
|
+
type?: TryOurFreeLegalBlogsContentType
|
|
5
12
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as TryOurFreeLegalBlogsContent } from './TryOurFreeLegalBlogsContent';
|
|
2
|
-
export { type TryOurFreeLegalBlogsContentProps } from './TryOurFreeLegalBlogsContentProps.types';
|
|
2
|
+
export { TryOurFreeLegalBlogsContentType, type TryOurFreeLegalBlogsContentProps } from './TryOurFreeLegalBlogsContentProps.types';
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { default as TryOurFreeLegalBlogsContent } from './TryOurFreeLegalBlogsContent'
|
|
2
|
-
export {
|
|
2
|
+
export {
|
|
3
|
+
TryOurFreeLegalBlogsContentType,
|
|
4
|
+
type TryOurFreeLegalBlogsContentProps
|
|
5
|
+
} from './TryOurFreeLegalBlogsContentProps.types'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FOOTER, HEADER } from './constants';
|
|
3
|
+
import React, { useMemo, useState } from 'react';
|
|
4
|
+
import { WizardContext } from './context';
|
|
5
|
+
import { useHash } from './hooks';
|
|
6
|
+
import { wizardNavigationControls } from './controls/navigation';
|
|
7
|
+
export const Wizard = ({ children, isHashEnabled = false, classNames }) => {
|
|
8
|
+
const [step, setStep] = useState(0);
|
|
9
|
+
const childrenToArray = React.Children.toArray(children);
|
|
10
|
+
const filteredChilds = childrenToArray
|
|
11
|
+
.filter((child) => {
|
|
12
|
+
if (!React.isValidElement(child))
|
|
13
|
+
return false;
|
|
14
|
+
const type = child.type;
|
|
15
|
+
return Boolean(type.displayName !== FOOTER && type.displayName !== HEADER);
|
|
16
|
+
})
|
|
17
|
+
.map((child, index) => React.isValidElement(child)
|
|
18
|
+
? React.cloneElement(child, { index })
|
|
19
|
+
: child);
|
|
20
|
+
const { updateHash, setStepByHash } = useHash({ children: filteredChilds, isHashEnabled, setStep });
|
|
21
|
+
const { goToStepByIndex, nextStep, previousStep } = wizardNavigationControls({
|
|
22
|
+
lastStep: filteredChilds.length - 1,
|
|
23
|
+
updateHash,
|
|
24
|
+
isHashEnabled,
|
|
25
|
+
setStep,
|
|
26
|
+
step
|
|
27
|
+
});
|
|
28
|
+
const currentStep = filteredChilds[step];
|
|
29
|
+
const getSpecificComponentByDisplayName = (displayName) => {
|
|
30
|
+
return childrenToArray.find((child) => {
|
|
31
|
+
if (!React.isValidElement(child))
|
|
32
|
+
return false;
|
|
33
|
+
const type = child.type;
|
|
34
|
+
return type.displayName === displayName;
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const footer = getSpecificComponentByDisplayName(FOOTER);
|
|
38
|
+
const header = getSpecificComponentByDisplayName(HEADER);
|
|
39
|
+
const memoizedNavigationControls = useMemo(() => ({ goToStepByIndex, nextStep, previousStep, setStepByHash, currentStep: step }), [goToStepByIndex, nextStep, previousStep, setStepByHash, step]);
|
|
40
|
+
return (_jsxs(WizardContext.Provider, { value: memoizedNavigationControls, children: [header, _jsxs("div", { className: classNames, children: [currentStep, footer] })] }));
|
|
41
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { FOOTER, HEADER } from './constants'
|
|
2
|
+
import React, { useMemo, useState } from 'react'
|
|
3
|
+
import { WizardContext } from './context'
|
|
4
|
+
import { type WizardProps } from './WizardProps.types'
|
|
5
|
+
import { useHash } from './hooks'
|
|
6
|
+
import { wizardNavigationControls } from './controls/navigation'
|
|
7
|
+
|
|
8
|
+
interface IndexedChildProps {
|
|
9
|
+
index: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Wizard: React.FC<WizardProps> = ({ children, isHashEnabled = false, classNames }): React.ReactElement => {
|
|
13
|
+
const [step, setStep] = useState(0)
|
|
14
|
+
const childrenToArray = React.Children.toArray(children)
|
|
15
|
+
const filteredChilds = childrenToArray
|
|
16
|
+
.filter((child) => {
|
|
17
|
+
if (!React.isValidElement(child)) return false
|
|
18
|
+
const type = child.type as React.FunctionComponent
|
|
19
|
+
return Boolean(type.displayName !== FOOTER && type.displayName !== HEADER)
|
|
20
|
+
})
|
|
21
|
+
.map((child, index) =>
|
|
22
|
+
React.isValidElement(child)
|
|
23
|
+
? React.cloneElement(child as React.ReactElement<IndexedChildProps>, { index })
|
|
24
|
+
: child
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
const { updateHash, setStepByHash } = useHash({ children: filteredChilds, isHashEnabled, setStep })
|
|
28
|
+
|
|
29
|
+
const { goToStepByIndex, nextStep, previousStep } = wizardNavigationControls({
|
|
30
|
+
lastStep: filteredChilds.length - 1,
|
|
31
|
+
updateHash,
|
|
32
|
+
isHashEnabled,
|
|
33
|
+
setStep,
|
|
34
|
+
step
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const currentStep = filteredChilds[step]
|
|
38
|
+
const getSpecificComponentByDisplayName = (displayName: string): React.ReactNode => {
|
|
39
|
+
return childrenToArray.find((child) => {
|
|
40
|
+
if (!React.isValidElement(child)) return false
|
|
41
|
+
|
|
42
|
+
const type = child.type as React.FunctionComponent
|
|
43
|
+
return type.displayName === displayName
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const footer = getSpecificComponentByDisplayName(FOOTER)
|
|
48
|
+
const header = getSpecificComponentByDisplayName(HEADER)
|
|
49
|
+
|
|
50
|
+
const memoizedNavigationControls = useMemo(
|
|
51
|
+
() => ({ goToStepByIndex, nextStep, previousStep, setStepByHash, currentStep: step }),
|
|
52
|
+
[goToStepByIndex, nextStep, previousStep, setStepByHash, step]
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<WizardContext.Provider value={memoizedNavigationControls}>
|
|
57
|
+
{header}
|
|
58
|
+
<div className={classNames}>
|
|
59
|
+
{currentStep}
|
|
60
|
+
{footer}
|
|
61
|
+
</div>
|
|
62
|
+
</WizardContext.Provider>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FOOTER } from '../constants'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
interface FooterProps {
|
|
5
|
+
children: React.ReactNode | React.ReactNode[]
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const Footer: React.FC<FooterProps> = ({ children }) => <>{children}</>
|
|
9
|
+
|
|
10
|
+
Footer.displayName = FOOTER
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HEADER } from '../constants'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
interface HeaderProps {
|
|
5
|
+
children: React.ReactNode | React.ReactNode[]
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const Header: React.FC<HeaderProps> = ({ children }) => <>{children}</>
|
|
9
|
+
|
|
10
|
+
Header.displayName = HEADER
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface WizardContextInterFace {
|
|
2
|
+
previousStep: () => void;
|
|
3
|
+
nextStep: () => void;
|
|
4
|
+
goToStepByIndex: (step: number) => void;
|
|
5
|
+
setStepByHash: (hash: string) => void;
|
|
6
|
+
currentStep: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const WizardContext: import("react").Context<WizardContextInterFace>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createContext } from 'react'
|
|
2
|
+
|
|
3
|
+
interface WizardContextInterFace {
|
|
4
|
+
previousStep: () => void
|
|
5
|
+
nextStep: () => void
|
|
6
|
+
goToStepByIndex: (step: number) => void
|
|
7
|
+
setStepByHash: (hash: string) => void
|
|
8
|
+
currentStep: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const WizardContext = createContext<WizardContextInterFace>({
|
|
12
|
+
previousStep: () => {},
|
|
13
|
+
nextStep: () => {},
|
|
14
|
+
goToStepByIndex: () => {},
|
|
15
|
+
setStepByHash: () => {},
|
|
16
|
+
currentStep: 0
|
|
17
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WizardContext } from './WizardContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WizardContext } from './WizardContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WizardContext } from './WizardContext'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface WizardNavigation {
|
|
2
|
+
lastStep: number;
|
|
3
|
+
updateHash: (step: number) => void;
|
|
4
|
+
isHashEnabled: boolean;
|
|
5
|
+
setStep: (step: number) => void;
|
|
6
|
+
step: number;
|
|
7
|
+
}
|
|
8
|
+
interface WizardControls {
|
|
9
|
+
nextStep: () => void;
|
|
10
|
+
previousStep: () => void;
|
|
11
|
+
goToStepByIndex: (step: number) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const wizardNavigationControls: ({ lastStep, updateHash, isHashEnabled, setStep, step }: WizardNavigation) => WizardControls;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const wizardNavigationControls = ({ lastStep, updateHash, isHashEnabled, setStep, step }) => {
|
|
2
|
+
const nextStep = () => {
|
|
3
|
+
const _step = step === lastStep ? lastStep : step + 1;
|
|
4
|
+
setStep(_step);
|
|
5
|
+
if (isHashEnabled) {
|
|
6
|
+
updateHash(_step);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
const previousStep = () => {
|
|
10
|
+
const _step = step <= 0 ? 0 : step - 1;
|
|
11
|
+
setStep(_step);
|
|
12
|
+
if (isHashEnabled) {
|
|
13
|
+
updateHash(_step);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const goToStepByIndex = (step) => {
|
|
17
|
+
setStep(step);
|
|
18
|
+
if (isHashEnabled) {
|
|
19
|
+
updateHash(step);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
nextStep,
|
|
24
|
+
previousStep,
|
|
25
|
+
goToStepByIndex
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
interface WizardNavigation {
|
|
2
|
+
lastStep: number
|
|
3
|
+
updateHash: (step: number) => void
|
|
4
|
+
isHashEnabled: boolean
|
|
5
|
+
setStep: (step: number) => void
|
|
6
|
+
step: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface WizardControls {
|
|
10
|
+
nextStep: () => void
|
|
11
|
+
previousStep: () => void
|
|
12
|
+
goToStepByIndex: (step: number) => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const wizardNavigationControls = ({
|
|
16
|
+
lastStep,
|
|
17
|
+
updateHash,
|
|
18
|
+
isHashEnabled,
|
|
19
|
+
setStep,
|
|
20
|
+
step
|
|
21
|
+
}: WizardNavigation): WizardControls => {
|
|
22
|
+
const nextStep = (): void => {
|
|
23
|
+
const _step = step === lastStep ? lastStep : step + 1
|
|
24
|
+
setStep(_step)
|
|
25
|
+
if (isHashEnabled) {
|
|
26
|
+
updateHash(_step)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const previousStep = (): void => {
|
|
31
|
+
const _step = step <= 0 ? 0 : step - 1
|
|
32
|
+
setStep(_step)
|
|
33
|
+
if (isHashEnabled) {
|
|
34
|
+
updateHash(_step)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const goToStepByIndex = (step: number): void => {
|
|
39
|
+
setStep(step)
|
|
40
|
+
if (isHashEnabled) {
|
|
41
|
+
updateHash(step)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
nextStep,
|
|
47
|
+
previousStep,
|
|
48
|
+
goToStepByIndex
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useHash } from './useHash';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useHash } from './useHash';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useHash } from './useHash'
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface UseHashProps {
|
|
3
|
+
children: React.ReactNode[];
|
|
4
|
+
isHashEnabled: boolean;
|
|
5
|
+
setStep: (step: number) => void;
|
|
6
|
+
}
|
|
7
|
+
interface UseHashReturn {
|
|
8
|
+
updateHash: (step: number) => void;
|
|
9
|
+
setStepByHash: (hash: string) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const useHash: ({ children, isHashEnabled, setStep }: UseHashProps) => UseHashReturn;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
export const useHash = ({ children, isHashEnabled, setStep }) => {
|
|
3
|
+
const hasInitialized = useRef(false);
|
|
4
|
+
const getHash = () => typeof window === 'object' ? decodeURIComponent(window.location.hash.replace(/^#/, '')) : '';
|
|
5
|
+
const { hashKeys, hashKeysURL } = useMemo(() => {
|
|
6
|
+
const localHashKeys = {};
|
|
7
|
+
const localHashKeysURL = {};
|
|
8
|
+
children.forEach((child, index) => {
|
|
9
|
+
if (React.isValidElement(child)) {
|
|
10
|
+
const element = child;
|
|
11
|
+
const hashKey = element.props.hashKey ?? `step${index + 1}`;
|
|
12
|
+
localHashKeysURL[index] = hashKey;
|
|
13
|
+
localHashKeys[hashKey] = index;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
hashKeys: localHashKeys,
|
|
18
|
+
hashKeysURL: localHashKeysURL
|
|
19
|
+
};
|
|
20
|
+
}, [children]);
|
|
21
|
+
const updateHash = (step) => {
|
|
22
|
+
const newHash = hashKeysURL[step];
|
|
23
|
+
if (newHash && window.location.hash !== `#${newHash}`) {
|
|
24
|
+
window.location.hash = newHash;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const setStepByHash = (hash) => {
|
|
28
|
+
if (hash in hashKeys) {
|
|
29
|
+
setStep(hashKeys[hash]);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!isHashEnabled)
|
|
34
|
+
return;
|
|
35
|
+
const onHashChange = () => {
|
|
36
|
+
const hash = getHash();
|
|
37
|
+
if (hash in hashKeys) {
|
|
38
|
+
setStep(hashKeys[hash]);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
window.addEventListener('hashchange', onHashChange);
|
|
42
|
+
return () => {
|
|
43
|
+
window.removeEventListener('hashchange', onHashChange);
|
|
44
|
+
};
|
|
45
|
+
}, [isHashEnabled, hashKeys, setStep]);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!isHashEnabled || hasInitialized.current)
|
|
48
|
+
return;
|
|
49
|
+
const initialHash = getHash();
|
|
50
|
+
if (initialHash && hashKeys[initialHash] !== undefined) {
|
|
51
|
+
setStep(hashKeys[initialHash]);
|
|
52
|
+
hasInitialized.current = true;
|
|
53
|
+
}
|
|
54
|
+
}, [hashKeys, isHashEnabled, setStep]);
|
|
55
|
+
return {
|
|
56
|
+
updateHash,
|
|
57
|
+
setStepByHash
|
|
58
|
+
};
|
|
59
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
interface UseHashProps {
|
|
4
|
+
children: React.ReactNode[]
|
|
5
|
+
isHashEnabled: boolean
|
|
6
|
+
setStep: (step: number) => void
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface UseHashReturn {
|
|
10
|
+
updateHash: (step: number) => void
|
|
11
|
+
setStepByHash: (hash: string) => void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type HashKeys = Record<string, number>
|
|
15
|
+
type HashKeysURL = Record<number, string>
|
|
16
|
+
|
|
17
|
+
export const useHash = ({ children, isHashEnabled, setStep }: UseHashProps): UseHashReturn => {
|
|
18
|
+
const hasInitialized = useRef(false)
|
|
19
|
+
|
|
20
|
+
const getHash = (): string =>
|
|
21
|
+
typeof window === 'object' ? decodeURIComponent(window.location.hash.replace(/^#/, '')) : ''
|
|
22
|
+
|
|
23
|
+
const { hashKeys, hashKeysURL } = useMemo(() => {
|
|
24
|
+
const localHashKeys: HashKeys = {}
|
|
25
|
+
const localHashKeysURL: HashKeysURL = {}
|
|
26
|
+
|
|
27
|
+
children.forEach((child, index) => {
|
|
28
|
+
if (React.isValidElement(child)) {
|
|
29
|
+
const element = child as React.ReactElement<{ hashKey?: string }>
|
|
30
|
+
const hashKey = element.props.hashKey ?? `step${index + 1}`
|
|
31
|
+
localHashKeysURL[index] = hashKey
|
|
32
|
+
localHashKeys[hashKey] = index
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
hashKeys: localHashKeys,
|
|
38
|
+
hashKeysURL: localHashKeysURL
|
|
39
|
+
}
|
|
40
|
+
}, [children])
|
|
41
|
+
|
|
42
|
+
const updateHash = (step: number): void => {
|
|
43
|
+
const newHash = hashKeysURL[step]
|
|
44
|
+
if (newHash && window.location.hash !== `#${newHash}`) {
|
|
45
|
+
window.location.hash = newHash
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const setStepByHash = (hash: string): void => {
|
|
50
|
+
if (hash in hashKeys) {
|
|
51
|
+
setStep(hashKeys[hash])
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (!isHashEnabled) return
|
|
57
|
+
|
|
58
|
+
const onHashChange = (): void => {
|
|
59
|
+
const hash = getHash()
|
|
60
|
+
if (hash in hashKeys) {
|
|
61
|
+
setStep(hashKeys[hash])
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
window.addEventListener('hashchange', onHashChange)
|
|
66
|
+
|
|
67
|
+
return () => {
|
|
68
|
+
window.removeEventListener('hashchange', onHashChange)
|
|
69
|
+
}
|
|
70
|
+
}, [isHashEnabled, hashKeys, setStep])
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!isHashEnabled || hasInitialized.current) return
|
|
74
|
+
|
|
75
|
+
const initialHash = getHash()
|
|
76
|
+
|
|
77
|
+
if (initialHash && hashKeys[initialHash] !== undefined) {
|
|
78
|
+
setStep(hashKeys[initialHash])
|
|
79
|
+
hasInitialized.current = true
|
|
80
|
+
}
|
|
81
|
+
}, [hashKeys, isHashEnabled, setStep])
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
updateHash,
|
|
85
|
+
setStepByHash
|
|
86
|
+
}
|
|
87
|
+
}
|