@sonardigital/carbon-ui 1.1.56 → 1.1.59
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/package.json +2 -2
- package/src/components/form/fields/FormDatePicker.tsx +7 -2
- package/src/components/layout/drawer/components/DrawerContent.tsx +13 -0
- package/src/components/layout/{Drawer_ → drawer}/components/DrawerTrigger.tsx +3 -11
- package/src/components/layout/{Drawer_ → drawer}/components/index.ts +0 -1
- package/src/components/layout/{Drawer_ → drawer}/hooks/useDrawer.ts +7 -7
- package/src/components/layout/{Drawer_ → drawer}/hooks/useDrawerContext.ts +1 -1
- package/src/components/layout/{Drawer_ → drawer}/index.ts +1 -1
- package/src/components/layout/{Drawer_/context → drawer/provider}/DrawerContext.ts +6 -6
- package/src/components/layout/{Drawer_/components → drawer/provider}/DrawerProvider.tsx +2 -2
- package/src/components/layout/drawer/provider/index.ts +2 -0
- package/src/components/layout/index.ts +2 -1
- package/src/components/layout/multisteps/components/MultistepsBar.tsx +29 -0
- package/src/components/layout/multisteps/components/MultistepsBottomSteps.tsx +12 -0
- package/src/components/layout/multisteps/components/MultistepsContent.tsx +13 -0
- package/src/components/layout/multisteps/components/MultistepsStep.tsx +28 -0
- package/src/components/layout/multisteps/components/MultistepsStepper.tsx +61 -0
- package/src/components/layout/multisteps/components/index.ts +5 -0
- package/src/components/layout/multisteps/hooks/index.ts +2 -0
- package/src/components/layout/multisteps/hooks/useMultisteps.ts +58 -0
- package/src/components/layout/multisteps/hooks/useMultistepsContext.ts +12 -0
- package/src/components/layout/multisteps/index.ts +3 -0
- package/src/components/layout/multisteps/provider/MultistepsContext.ts +22 -0
- package/src/components/layout/multisteps/provider/MultistepsProvider.tsx +22 -0
- package/src/components/layout/multisteps/provider/index.ts +1 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useAccordion.ts +15 -0
- package/src/index.ts +1 -0
- package/src/components/layout/Drawer_/components/DrawerContent.tsx +0 -13
- package/src/components/layout/Drawer_/context/index.ts +0 -1
- package/src/components/widgets/index.ts +0 -0
- /package/src/components/layout/{Drawer_ → drawer}/hooks/index.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonardigital/carbon-ui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.59",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"files": [
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"react": "^19.1.0",
|
|
58
58
|
"react-hook-form": "^7.63.0",
|
|
59
59
|
"react-icons": "^5.5.0",
|
|
60
|
-
"react-router": "^7.
|
|
60
|
+
"react-router": "^7.9.4",
|
|
61
61
|
"react-router-dom": "^7.6.0",
|
|
62
62
|
"typescript": "^5.4.5"
|
|
63
63
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { Stack } from '@mui/material';
|
|
1
2
|
import { Controller } from 'react-hook-form';
|
|
2
3
|
import { FormLabel } from '../layout';
|
|
4
|
+
import { FormError } from '../layout/FormError';
|
|
3
5
|
import { DatePicker, DatePickerProps } from '../../inputs/DatePicker';
|
|
4
6
|
|
|
5
7
|
interface FormDatePickerProps extends Omit<DatePickerProps, 'value' | 'onChange'> {
|
|
@@ -11,9 +13,12 @@ export function FormDatePicker({ name, label, ...props }: FormDatePickerProps):
|
|
|
11
13
|
return (
|
|
12
14
|
<Controller
|
|
13
15
|
name={name}
|
|
14
|
-
render={({ field }) => (
|
|
16
|
+
render={({ field, fieldState }) => (
|
|
15
17
|
<FormLabel label={label}>
|
|
16
|
-
<
|
|
18
|
+
<Stack gap={0.8}>
|
|
19
|
+
<DatePicker {...field} {...props} />
|
|
20
|
+
{fieldState.error && <FormError label={fieldState.error?.message ?? ''} />}
|
|
21
|
+
</Stack>
|
|
17
22
|
</FormLabel>
|
|
18
23
|
)}
|
|
19
24
|
/>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DrawerProps, Drawer as MuiDrawer } from '@mui/material';
|
|
3
|
+
import { useDrawerContext } from '../hooks/useDrawerContext';
|
|
4
|
+
|
|
5
|
+
export function DrawerContent({ children, ...props }: DrawerProps): React.ReactElement {
|
|
6
|
+
const { isOpen, close } = useDrawerContext();
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<MuiDrawer open={isOpen} onClose={close} {...props}>
|
|
10
|
+
{children}
|
|
11
|
+
</MuiDrawer>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -8,19 +8,11 @@ interface DialogTriggerProps {
|
|
|
8
8
|
closeIcon?: React.ReactNode;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
openIcon,
|
|
14
|
-
closeIcon,
|
|
15
|
-
}: DialogTriggerProps): React.ReactElement {
|
|
16
|
-
const { isOpen, toggleDrawer } = useDrawerContext();
|
|
11
|
+
export function DrawerTrigger({ children, openIcon, closeIcon }: DialogTriggerProps): React.ReactElement {
|
|
12
|
+
const { isOpen, toggle } = useDrawerContext();
|
|
17
13
|
|
|
18
14
|
return (
|
|
19
|
-
<ButtonBase
|
|
20
|
-
sx={{ posiion: 'relative', alignSelf: 'center' }}
|
|
21
|
-
disableRipple
|
|
22
|
-
onClick={() => toggleDrawer()}
|
|
23
|
-
>
|
|
15
|
+
<ButtonBase sx={{ posiion: 'relative', alignSelf: 'center' }} disableRipple onClick={() => toggle()}>
|
|
24
16
|
{children}
|
|
25
17
|
{!isOpen ? openIcon : closeIcon}
|
|
26
18
|
</ButtonBase>
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { DrawerContextType } from '../
|
|
2
|
+
import { DrawerContextType } from '../provider/DrawerContext';
|
|
3
3
|
|
|
4
4
|
export const useDrawer = (): DrawerContextType => {
|
|
5
5
|
const [isOpen, setIsOpen] = useState(false);
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const open = (): void => {
|
|
8
8
|
setIsOpen(true);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const close = (): void => {
|
|
12
12
|
setIsOpen(false);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const toggle = (): void => {
|
|
16
16
|
setIsOpen((prevState) => !prevState);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
return {
|
|
20
20
|
isOpen,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
open,
|
|
22
|
+
close,
|
|
23
|
+
toggle,
|
|
24
24
|
};
|
|
25
25
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
|
-
import DrawerContext, { DrawerContextType } from '../
|
|
2
|
+
import DrawerContext, { DrawerContextType } from '../provider/DrawerContext';
|
|
3
3
|
|
|
4
4
|
export const useDrawerContext = (): DrawerContextType => {
|
|
5
5
|
const context = useContext(DrawerContext);
|
|
@@ -2,16 +2,16 @@ import { Context, createContext } from 'react';
|
|
|
2
2
|
|
|
3
3
|
export interface DrawerContextType {
|
|
4
4
|
isOpen: boolean;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
open: () => void;
|
|
6
|
+
close: () => void;
|
|
7
|
+
toggle: () => void;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
const DrawerContext: Context<DrawerContextType> = createContext<DrawerContextType>({
|
|
11
11
|
isOpen: false,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
open: () => {},
|
|
13
|
+
close: () => {},
|
|
14
|
+
toggle: () => {},
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
export default DrawerContext;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Stack } from '@mui/material';
|
|
3
3
|
import { useDrawer } from '../hooks/useDrawer';
|
|
4
|
-
import DrawerContext, { DrawerContextType } from '
|
|
4
|
+
import DrawerContext, { DrawerContextType } from './DrawerContext';
|
|
5
5
|
|
|
6
6
|
interface DrawerProviderProps {
|
|
7
7
|
children: React.ReactNode;
|
|
8
8
|
methods?: DrawerContextType;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export function DrawerProvider({
|
|
12
12
|
methods,
|
|
13
13
|
children,
|
|
14
14
|
}: DrawerProviderProps): React.ReactElement<DrawerProviderProps> {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './drawer';
|
|
2
2
|
export * from './Dropdown';
|
|
3
3
|
export * from './ScrollToTop/ScrollToTop';
|
|
4
4
|
export * from './error-boundary';
|
|
5
5
|
export * from './delay';
|
|
6
6
|
export * from './Modal';
|
|
7
7
|
export * from './bottom-navigation/BottomNavigation';
|
|
8
|
+
export * from './multisteps';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Grid, Stack } from '@mui/material';
|
|
2
|
+
import Step from './MultistepsStep';
|
|
3
|
+
import { useMultistepsContext } from '../hooks';
|
|
4
|
+
|
|
5
|
+
export default function MultistepsBar(): React.ReactElement {
|
|
6
|
+
const { steps, jump, setHover, currentStepIndex } = useMultistepsContext();
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<Stack flexDirection="row" justifyContent="space-between" height="auto" paddingY={2} gap={2}>
|
|
10
|
+
<Grid container width="100%" spacing={1}>
|
|
11
|
+
{steps.map((_, i) => (
|
|
12
|
+
<Grid size={{ xs: 12 / steps.length }} key={i}>
|
|
13
|
+
<Stack
|
|
14
|
+
flexDirection="column"
|
|
15
|
+
gap={2}
|
|
16
|
+
height="auto"
|
|
17
|
+
paddingBottom={{ xs: 0 }}
|
|
18
|
+
onMouseEnter={() => setHover(i + 1)}
|
|
19
|
+
onMouseLeave={() => setHover(null)}
|
|
20
|
+
onClick={() => jump(i + 1)}
|
|
21
|
+
>
|
|
22
|
+
<Step key={i} index={i + 1} isActive={i <= currentStepIndex - 1} />
|
|
23
|
+
</Stack>
|
|
24
|
+
</Grid>
|
|
25
|
+
))}
|
|
26
|
+
</Grid>
|
|
27
|
+
</Stack>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Stack } from '@mui/material';
|
|
2
|
+
import { BottomNavigation } from '../../bottom-navigation/BottomNavigation';
|
|
3
|
+
|
|
4
|
+
export function MultistepsBottomNavigation({ children }: { children: React.ReactNode }): React.ReactElement {
|
|
5
|
+
return (
|
|
6
|
+
<BottomNavigation>
|
|
7
|
+
<Stack direction="row" width="100%" gap={2} justifyContent="end">
|
|
8
|
+
{children}
|
|
9
|
+
</Stack>
|
|
10
|
+
</BottomNavigation>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useMultistepsContext } from '../hooks/useMultistepsContext';
|
|
2
|
+
|
|
3
|
+
export function MultistepsContent({
|
|
4
|
+
step,
|
|
5
|
+
children,
|
|
6
|
+
}: {
|
|
7
|
+
step: number;
|
|
8
|
+
children: React.ReactElement;
|
|
9
|
+
}): React.ReactElement {
|
|
10
|
+
const { currentStepIndex } = useMultistepsContext();
|
|
11
|
+
|
|
12
|
+
return step === currentStepIndex ? children : <></>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Stack } from '@mui/material';
|
|
2
|
+
import { useMultistepsContext } from '../hooks';
|
|
3
|
+
import { Cursor } from '../../../atoms';
|
|
4
|
+
|
|
5
|
+
export default function MultistepsStep({
|
|
6
|
+
index,
|
|
7
|
+
isActive,
|
|
8
|
+
}: {
|
|
9
|
+
index: number;
|
|
10
|
+
isActive: boolean;
|
|
11
|
+
}): React.ReactElement {
|
|
12
|
+
const { hover } = useMultistepsContext();
|
|
13
|
+
return (
|
|
14
|
+
<Cursor>
|
|
15
|
+
<Stack
|
|
16
|
+
height={9}
|
|
17
|
+
sx={{
|
|
18
|
+
borderRadius: 100,
|
|
19
|
+
transition: '0.2s',
|
|
20
|
+
'&:hover': {
|
|
21
|
+
bgcolor: isActive ? 'primary.main' : 'primary.main',
|
|
22
|
+
},
|
|
23
|
+
}}
|
|
24
|
+
bgcolor={isActive || index < (hover || 0) ? 'primary.main' : 'grey.200'}
|
|
25
|
+
/>
|
|
26
|
+
</Cursor>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { KeyboardArrowRight } from '@mui/icons-material';
|
|
2
|
+
import { CheckOutlined } from '@mui/icons-material';
|
|
3
|
+
import { KeyboardArrowLeft } from '@mui/icons-material';
|
|
4
|
+
import { IconButton, MobileStepper, MobileStepperProps } from '@mui/material';
|
|
5
|
+
import { useMultistepsContext } from '../hooks';
|
|
6
|
+
|
|
7
|
+
interface StepperProps
|
|
8
|
+
extends Omit<MobileStepperProps, 'backButton' | 'nextButton' | 'steps' | 'activeStep'> {
|
|
9
|
+
value?: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function MultistepsStepper({ position, ...props }: StepperProps): React.ReactElement {
|
|
13
|
+
const { steps, currentStepIndex, goNext, goBack } = useMultistepsContext();
|
|
14
|
+
|
|
15
|
+
const handleNext = (): void => {
|
|
16
|
+
goNext();
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const handleBack = (): void => {
|
|
20
|
+
goBack();
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const isLastStep = currentStepIndex === steps.length;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<MobileStepper
|
|
27
|
+
variant="progress"
|
|
28
|
+
steps={steps.length}
|
|
29
|
+
position={position || 'static'}
|
|
30
|
+
activeStep={currentStepIndex - 1}
|
|
31
|
+
sx={{
|
|
32
|
+
boxShadow: 0,
|
|
33
|
+
padding: 0,
|
|
34
|
+
}}
|
|
35
|
+
slotProps={{
|
|
36
|
+
progress: {
|
|
37
|
+
sx: {
|
|
38
|
+
width: { xs: '50%', sm: '60%', md: '85%' },
|
|
39
|
+
borderRadius: 100,
|
|
40
|
+
height: 6.5,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}}
|
|
44
|
+
backButton={
|
|
45
|
+
<IconButton size="large" onClick={handleBack} disabled={currentStepIndex - 1 === 0}>
|
|
46
|
+
<KeyboardArrowLeft sx={{ width: 23, height: 23, color: 'grey.700' }} />
|
|
47
|
+
</IconButton>
|
|
48
|
+
}
|
|
49
|
+
nextButton={
|
|
50
|
+
<IconButton size="large" onClick={handleNext} disabled={isLastStep}>
|
|
51
|
+
{isLastStep ? (
|
|
52
|
+
<CheckOutlined sx={{ width: 22, height: 22, color: 'grey.700' }} />
|
|
53
|
+
) : (
|
|
54
|
+
<KeyboardArrowRight sx={{ width: 23, height: 23, color: 'grey.700' }} />
|
|
55
|
+
)}
|
|
56
|
+
</IconButton>
|
|
57
|
+
}
|
|
58
|
+
{...props}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useLocation, useNavigate } from 'react-router';
|
|
3
|
+
import { useMultistepsProps } from '../provider/MultistepsProvider';
|
|
4
|
+
import { MultistepsContextType } from '../provider/MultistepsContext';
|
|
5
|
+
|
|
6
|
+
export const useMultisteps = ({ steps }: useMultistepsProps): MultistepsContextType => {
|
|
7
|
+
const location = useLocation();
|
|
8
|
+
const queries = new URLSearchParams(location.search);
|
|
9
|
+
const navigate = useNavigate();
|
|
10
|
+
|
|
11
|
+
const index =
|
|
12
|
+
Number(queries.get('step')) > 0 && Number(queries.get('step')) <= steps?.length
|
|
13
|
+
? Number(queries.get('step'))
|
|
14
|
+
: 1;
|
|
15
|
+
|
|
16
|
+
const [hover, setHover] = useState<number | null>(null);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
queries.set('step', String(index));
|
|
20
|
+
navigate(`${location.pathname}?${queries.toString()}`, {
|
|
21
|
+
replace: true,
|
|
22
|
+
});
|
|
23
|
+
}, []);
|
|
24
|
+
|
|
25
|
+
const goNext = (): void => {
|
|
26
|
+
if (index === steps.length) return;
|
|
27
|
+
queries.set('step', String(index + 1));
|
|
28
|
+
navigate(`${location.pathname}?${queries.toString()}`, {
|
|
29
|
+
replace: true,
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const goBack = (): void => {
|
|
34
|
+
const newIndex = index - 1 < 1 ? 1 : index - 1;
|
|
35
|
+
queries.set('step', String(newIndex));
|
|
36
|
+
navigate(`${location.pathname}?${queries.toString()}`, {
|
|
37
|
+
replace: true,
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const jump = (index: number): void => {
|
|
42
|
+
if (index < 0 && index === steps.length) return;
|
|
43
|
+
queries.set('step', String(index));
|
|
44
|
+
navigate(`${location.pathname}?${queries.toString()}`, {
|
|
45
|
+
replace: true,
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
steps,
|
|
51
|
+
currentStepIndex: index,
|
|
52
|
+
hover,
|
|
53
|
+
setHover,
|
|
54
|
+
goBack,
|
|
55
|
+
jump,
|
|
56
|
+
goNext,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Context, ContextType, useContext } from 'react';
|
|
2
|
+
import { MultistepsContext, MultistepsContextType } from '../provider/MultistepsContext';
|
|
3
|
+
|
|
4
|
+
export const useMultistepsContext = (): ContextType<Context<MultistepsContextType>> => {
|
|
5
|
+
const context = useContext(MultistepsContext);
|
|
6
|
+
|
|
7
|
+
if (!context) {
|
|
8
|
+
throw new Error('useMultisteps must be used within a MultistepsWrapper');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return context;
|
|
12
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Context, createContext } from 'react';
|
|
2
|
+
import { Step } from './MultistepsProvider';
|
|
3
|
+
|
|
4
|
+
export interface MultistepsContextType {
|
|
5
|
+
steps: Step[];
|
|
6
|
+
currentStepIndex: number;
|
|
7
|
+
hover: number | null;
|
|
8
|
+
setHover: (index: number | null) => void;
|
|
9
|
+
goNext: () => void;
|
|
10
|
+
goBack: () => void;
|
|
11
|
+
jump: (index: number) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const MultistepsContext: Context<MultistepsContextType> = createContext<MultistepsContextType>({
|
|
15
|
+
steps: [],
|
|
16
|
+
currentStepIndex: 1,
|
|
17
|
+
hover: null,
|
|
18
|
+
setHover: () => {},
|
|
19
|
+
goBack: () => {},
|
|
20
|
+
jump: () => {},
|
|
21
|
+
goNext: () => {},
|
|
22
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MultistepsContext, MultistepsContextType } from './MultistepsContext';
|
|
3
|
+
|
|
4
|
+
export interface Step {
|
|
5
|
+
title: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface useMultistepsProps {
|
|
9
|
+
steps: Step[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface MultistepsProviderProps {
|
|
13
|
+
methods: MultistepsContextType;
|
|
14
|
+
children: React.ReactElement | React.ReactElement[] | false | (React.ReactElement | false)[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function MultistepsProvider({
|
|
18
|
+
methods,
|
|
19
|
+
children,
|
|
20
|
+
}: MultistepsProviderProps): React.ReactElement<MultistepsContextType> {
|
|
21
|
+
return <MultistepsContext.Provider value={methods}>{children}</MultistepsContext.Provider>;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MultistepsProvider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useAccordion';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
interface UseAccordionReturn {
|
|
4
|
+
index: number | false;
|
|
5
|
+
setIndex: (value: number) => void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const useAccordion = (): UseAccordionReturn => {
|
|
9
|
+
const [index, setIndex] = useState<number>(0);
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
index,
|
|
13
|
+
setIndex,
|
|
14
|
+
};
|
|
15
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { DrawerProps, Drawer as MuiDrawer } from '@mui/material';
|
|
3
|
-
import { useDrawerContext } from '../hooks/useDrawerContext';
|
|
4
|
-
|
|
5
|
-
export default function DrawerContent({ children, ...props }: DrawerProps): React.ReactElement {
|
|
6
|
-
const { isOpen, closeDrawer } = useDrawerContext();
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<MuiDrawer open={isOpen} onClose={closeDrawer} {...props}>
|
|
10
|
-
{children}
|
|
11
|
-
</MuiDrawer>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './DrawerContext';
|
|
File without changes
|
|
File without changes
|