@campxdev/react-blueprint 2.3.0 → 2.3.2
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/cjs/index.js +1 -1
- package/dist/cjs/types/src/components/Layout/AppHeader/AppHeader.d.ts +2 -1
- package/dist/cjs/types/src/components/Layout/AppLayout/components/AppBar.d.ts +2 -0
- package/dist/cjs/types/src/components/Layout/AppLayout/types.d.ts +2 -0
- package/dist/cjs/types/src/components/Navigation/Stepper/Stepper.d.ts +37 -1
- package/dist/cjs/types/src/components/Navigation/Stepper/StepperComponents.d.ts +3 -1
- package/dist/cjs/types/src/stories/Navigation/Stepper.stories.d.ts +3 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/types/src/components/Layout/AppHeader/AppHeader.d.ts +2 -1
- package/dist/esm/types/src/components/Layout/AppLayout/components/AppBar.d.ts +2 -0
- package/dist/esm/types/src/components/Layout/AppLayout/types.d.ts +2 -0
- package/dist/esm/types/src/components/Navigation/Stepper/Stepper.d.ts +37 -1
- package/dist/esm/types/src/components/Navigation/Stepper/StepperComponents.d.ts +3 -1
- package/dist/esm/types/src/stories/Navigation/Stepper.stories.d.ts +3 -0
- package/dist/index.d.ts +41 -2
- package/package.json +1 -1
- package/src/components/Layout/AppHeader/AppHeader.tsx +9 -0
- package/src/components/Layout/AppLayout/AppLayout.tsx +6 -1
- package/src/components/Layout/AppLayout/components/AppBar.tsx +27 -1
- package/src/components/Layout/AppLayout/types.ts +3 -0
- package/src/components/Navigation/Stepper/Stepper.tsx +60 -1
- package/src/components/Navigation/Stepper/StepperComponents.tsx +21 -8
- package/src/stories/Navigation/Stepper.stories.tsx +68 -1
|
@@ -4,6 +4,7 @@ export type AppHeaderProps = {
|
|
|
4
4
|
actions?: ReactNode[];
|
|
5
5
|
profileActions?: ReactNode[];
|
|
6
6
|
appsMenu?: ReactNode;
|
|
7
|
+
centerContent?: ReactNode;
|
|
7
8
|
clientLogoUrl?: string;
|
|
8
9
|
clientName?: string;
|
|
9
10
|
userFullName: string;
|
|
@@ -19,4 +20,4 @@ export type AppHeaderProps = {
|
|
|
19
20
|
onChangeInstitutionClick?: () => void;
|
|
20
21
|
onAvatarClick?: () => void;
|
|
21
22
|
};
|
|
22
|
-
export declare const AppHeader: ({ actions, profileActions, profileSx, clientLogoUrl, onLogoutClick, designation, clientName, userFullName, collapsed, institutionsData, showActiveDevices, headerSx, onAccountClick, onActiveDevicesClick, onChangeInstitutionClick, onAvatarClick, }: AppHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare const AppHeader: ({ actions, profileActions, profileSx, clientLogoUrl, onLogoutClick, designation, clientName, userFullName, collapsed, institutionsData, showActiveDevices, headerSx, centerContent, onAccountClick, onActiveDevicesClick, onChangeInstitutionClick, onAvatarClick, }: AppHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,6 +3,8 @@ import { SideMenuItemProps } from './Sidebar/interfaces';
|
|
|
3
3
|
interface AppBarProps {
|
|
4
4
|
/** Right section component (actions, profile, etc.) */
|
|
5
5
|
rightSection?: React.ReactNode;
|
|
6
|
+
/** Center section component (workspace switcher, etc.) */
|
|
7
|
+
centerSection?: React.ReactNode;
|
|
6
8
|
/** Menu items for mobile drawer */
|
|
7
9
|
menu?: SideMenuItemProps[];
|
|
8
10
|
/** Custom className for the AppBar */
|
|
@@ -17,6 +17,8 @@ export interface AppLayoutProps {
|
|
|
17
17
|
menu: SideMenuItemProps[];
|
|
18
18
|
/** AppBar customization - Primary approach */
|
|
19
19
|
rightSection?: ReactNode;
|
|
20
|
+
/** AppBar center section customization */
|
|
21
|
+
centerSection?: ReactNode;
|
|
20
22
|
/** Layout customization */
|
|
21
23
|
mainContainerSx?: any;
|
|
22
24
|
/** Help documentation configuration for route-based contextual help */
|
|
@@ -1,13 +1,49 @@
|
|
|
1
1
|
import { SxProps } from '@mui/material';
|
|
2
2
|
interface StepperProps {
|
|
3
|
+
/** Orientation of the stepper */
|
|
3
4
|
orientation: 'vertical' | 'horizontal';
|
|
5
|
+
/** Current active step index (0-based) */
|
|
4
6
|
activeStep: number;
|
|
7
|
+
/** Array of step items with labels and optional descriptions */
|
|
5
8
|
steps: StepItem[];
|
|
9
|
+
/** Additional styles for the container */
|
|
6
10
|
containerSx: SxProps;
|
|
11
|
+
/** Callback function called when a step is clicked. Receives the step index as parameter */
|
|
12
|
+
onStepClick?: (stepIndex: number) => void;
|
|
13
|
+
/** Whether to allow navigation by clicking on steps. Defaults to true */
|
|
14
|
+
allowNavigation?: boolean;
|
|
7
15
|
}
|
|
8
16
|
interface StepItem {
|
|
17
|
+
/** The label text for the step */
|
|
9
18
|
label: string;
|
|
19
|
+
/** Optional description text shown below the label */
|
|
10
20
|
description?: string;
|
|
11
21
|
}
|
|
12
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Enhanced Stepper component with navigation capabilities
|
|
24
|
+
*
|
|
25
|
+
* Features:
|
|
26
|
+
* - Click on any step to navigate to it (when allowNavigation is true)
|
|
27
|
+
* - Supports both vertical and horizontal orientations
|
|
28
|
+
* - Customizable styling through containerSx prop
|
|
29
|
+
* - Optional step descriptions
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* const [activeStep, setActiveStep] = useState(0);
|
|
34
|
+
*
|
|
35
|
+
* <Stepper
|
|
36
|
+
* orientation="vertical"
|
|
37
|
+
* activeStep={activeStep}
|
|
38
|
+
* steps={[
|
|
39
|
+
* { label: "Step 1", description: "First step" },
|
|
40
|
+
* { label: "Step 2", description: "Second step" }
|
|
41
|
+
* ]}
|
|
42
|
+
* onStepClick={(stepIndex) => setActiveStep(stepIndex)}
|
|
43
|
+
* allowNavigation={true}
|
|
44
|
+
* containerSx={{}}
|
|
45
|
+
* />
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare const Stepper: ({ orientation, steps, activeStep, containerSx, onStepClick, allowNavigation, }: StepperProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
49
|
export {};
|
|
@@ -9,5 +9,7 @@ interface ConnectorProps {
|
|
|
9
9
|
isVertical: boolean;
|
|
10
10
|
}
|
|
11
11
|
export declare const Connector: import("@mui/styled-engine").StyledComponent<import("@mui/material").StepConnectorProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & ConnectorProps, {}, {}>;
|
|
12
|
-
export declare function StepIcon(props: StepIconProps
|
|
12
|
+
export declare function StepIcon(props: StepIconProps & {
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
13
15
|
export {};
|
|
@@ -4,6 +4,9 @@ declare const meta: Meta<typeof Stepper>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof Stepper>;
|
|
6
6
|
export declare const VerticalStepper: Story;
|
|
7
|
+
export declare const InteractiveVerticalStepper: Story;
|
|
7
8
|
export declare const VerticalStepperWithNoDescription: Story;
|
|
8
9
|
export declare const HorizontalStepper: Story;
|
|
10
|
+
export declare const InteractiveHorizontalStepper: Story;
|
|
11
|
+
export declare const NonNavigableStepper: Story;
|
|
9
12
|
export declare const HorizontalStepperWithNoDescription: Story;
|
package/dist/index.d.ts
CHANGED
|
@@ -941,6 +941,8 @@ interface AppLayoutProps {
|
|
|
941
941
|
menu: SideMenuItemProps$1[];
|
|
942
942
|
/** AppBar customization - Primary approach */
|
|
943
943
|
rightSection?: ReactNode;
|
|
944
|
+
/** AppBar center section customization */
|
|
945
|
+
centerSection?: ReactNode;
|
|
944
946
|
/** Layout customization */
|
|
945
947
|
mainContainerSx?: any;
|
|
946
948
|
/** Help documentation configuration for route-based contextual help */
|
|
@@ -1056,6 +1058,7 @@ type AppHeaderProps = {
|
|
|
1056
1058
|
actions?: ReactNode[];
|
|
1057
1059
|
profileActions?: ReactNode[];
|
|
1058
1060
|
appsMenu?: ReactNode;
|
|
1061
|
+
centerContent?: ReactNode;
|
|
1059
1062
|
clientLogoUrl?: string;
|
|
1060
1063
|
clientName?: string;
|
|
1061
1064
|
userFullName: string;
|
|
@@ -1071,7 +1074,7 @@ type AppHeaderProps = {
|
|
|
1071
1074
|
onChangeInstitutionClick?: () => void;
|
|
1072
1075
|
onAvatarClick?: () => void;
|
|
1073
1076
|
};
|
|
1074
|
-
declare const AppHeader: ({ actions, profileActions, profileSx, clientLogoUrl, onLogoutClick, designation, clientName, userFullName, collapsed, institutionsData, showActiveDevices, headerSx, onAccountClick, onActiveDevicesClick, onChangeInstitutionClick, onAvatarClick, }: AppHeaderProps) => react_jsx_runtime.JSX.Element;
|
|
1077
|
+
declare const AppHeader: ({ actions, profileActions, profileSx, clientLogoUrl, onLogoutClick, designation, clientName, userFullName, collapsed, institutionsData, showActiveDevices, headerSx, centerContent, onAccountClick, onActiveDevicesClick, onChangeInstitutionClick, onAvatarClick, }: AppHeaderProps) => react_jsx_runtime.JSX.Element;
|
|
1075
1078
|
|
|
1076
1079
|
declare const Sidebar: ({ menu, collapsed, setCollapsed, }: {
|
|
1077
1080
|
menu: SideMenuItemProps[];
|
|
@@ -1432,16 +1435,52 @@ type PreviewFilesProps = {
|
|
|
1432
1435
|
declare const PreviewFiles: ({ files, label, onChange, showDownload, hideDelete, sx, ...props }: PreviewFilesProps) => react_jsx_runtime.JSX.Element;
|
|
1433
1436
|
|
|
1434
1437
|
interface StepperProps {
|
|
1438
|
+
/** Orientation of the stepper */
|
|
1435
1439
|
orientation: 'vertical' | 'horizontal';
|
|
1440
|
+
/** Current active step index (0-based) */
|
|
1436
1441
|
activeStep: number;
|
|
1442
|
+
/** Array of step items with labels and optional descriptions */
|
|
1437
1443
|
steps: StepItem[];
|
|
1444
|
+
/** Additional styles for the container */
|
|
1438
1445
|
containerSx: SxProps;
|
|
1446
|
+
/** Callback function called when a step is clicked. Receives the step index as parameter */
|
|
1447
|
+
onStepClick?: (stepIndex: number) => void;
|
|
1448
|
+
/** Whether to allow navigation by clicking on steps. Defaults to true */
|
|
1449
|
+
allowNavigation?: boolean;
|
|
1439
1450
|
}
|
|
1440
1451
|
interface StepItem {
|
|
1452
|
+
/** The label text for the step */
|
|
1441
1453
|
label: string;
|
|
1454
|
+
/** Optional description text shown below the label */
|
|
1442
1455
|
description?: string;
|
|
1443
1456
|
}
|
|
1444
|
-
|
|
1457
|
+
/**
|
|
1458
|
+
* Enhanced Stepper component with navigation capabilities
|
|
1459
|
+
*
|
|
1460
|
+
* Features:
|
|
1461
|
+
* - Click on any step to navigate to it (when allowNavigation is true)
|
|
1462
|
+
* - Supports both vertical and horizontal orientations
|
|
1463
|
+
* - Customizable styling through containerSx prop
|
|
1464
|
+
* - Optional step descriptions
|
|
1465
|
+
*
|
|
1466
|
+
* @example
|
|
1467
|
+
* ```tsx
|
|
1468
|
+
* const [activeStep, setActiveStep] = useState(0);
|
|
1469
|
+
*
|
|
1470
|
+
* <Stepper
|
|
1471
|
+
* orientation="vertical"
|
|
1472
|
+
* activeStep={activeStep}
|
|
1473
|
+
* steps={[
|
|
1474
|
+
* { label: "Step 1", description: "First step" },
|
|
1475
|
+
* { label: "Step 2", description: "Second step" }
|
|
1476
|
+
* ]}
|
|
1477
|
+
* onStepClick={(stepIndex) => setActiveStep(stepIndex)}
|
|
1478
|
+
* allowNavigation={true}
|
|
1479
|
+
* containerSx={{}}
|
|
1480
|
+
* />
|
|
1481
|
+
* ```
|
|
1482
|
+
*/
|
|
1483
|
+
declare const Stepper: ({ orientation, steps, activeStep, containerSx, onStepClick, allowNavigation, }: StepperProps) => react_jsx_runtime.JSX.Element;
|
|
1445
1484
|
|
|
1446
1485
|
interface CustomTabProps extends Omit<TabProps, 'component'> {
|
|
1447
1486
|
key: string | number;
|
package/package.json
CHANGED
|
@@ -8,6 +8,7 @@ export type AppHeaderProps = {
|
|
|
8
8
|
actions?: ReactNode[];
|
|
9
9
|
profileActions?: ReactNode[];
|
|
10
10
|
appsMenu?: ReactNode;
|
|
11
|
+
centerContent?: ReactNode;
|
|
11
12
|
clientLogoUrl?: string;
|
|
12
13
|
clientName?: string;
|
|
13
14
|
userFullName: string;
|
|
@@ -38,6 +39,7 @@ export const AppHeader = ({
|
|
|
38
39
|
institutionsData,
|
|
39
40
|
showActiveDevices = true,
|
|
40
41
|
headerSx,
|
|
42
|
+
centerContent,
|
|
41
43
|
// Destructuring the new onClick props
|
|
42
44
|
onAccountClick,
|
|
43
45
|
onActiveDevicesClick,
|
|
@@ -57,6 +59,13 @@ export const AppHeader = ({
|
|
|
57
59
|
{clientName}
|
|
58
60
|
</Typography>
|
|
59
61
|
|
|
62
|
+
{/* Center Content Section */}
|
|
63
|
+
{centerContent && (
|
|
64
|
+
<Stack alignItems={'center'} justifyContent={'center'} flex={1}>
|
|
65
|
+
{centerContent}
|
|
66
|
+
</Stack>
|
|
67
|
+
)}
|
|
68
|
+
|
|
60
69
|
<Stack alignItems={'center'} gap={'12px'} flexDirection={'row'}>
|
|
61
70
|
{actions.map((action) => action)}
|
|
62
71
|
|
|
@@ -8,6 +8,7 @@ export const AppLayout: React.FC<AppLayoutProps> = ({
|
|
|
8
8
|
children,
|
|
9
9
|
menu,
|
|
10
10
|
rightSection,
|
|
11
|
+
centerSection,
|
|
11
12
|
mainContainerSx = {},
|
|
12
13
|
helpDocsConfig,
|
|
13
14
|
}) => {
|
|
@@ -30,7 +31,11 @@ export const AppLayout: React.FC<AppLayoutProps> = ({
|
|
|
30
31
|
return (
|
|
31
32
|
<AppLayoutContainer>
|
|
32
33
|
{/* AppBar - Full width at the top */}
|
|
33
|
-
<AppBar
|
|
34
|
+
<AppBar
|
|
35
|
+
rightSection={rightSection}
|
|
36
|
+
centerSection={centerSection}
|
|
37
|
+
menu={menu}
|
|
38
|
+
/>
|
|
34
39
|
|
|
35
40
|
{/* Main Content - Single column, centered with max-width */}
|
|
36
41
|
<MainContent
|
|
@@ -17,6 +17,7 @@ const AppBarContainer = styled('header')(({ theme }: { theme?: any }) => ({
|
|
|
17
17
|
flexDirection: 'row',
|
|
18
18
|
alignItems: 'center',
|
|
19
19
|
justifyContent: 'space-between',
|
|
20
|
+
position: 'relative', // Add relative positioning for absolute center positioning
|
|
20
21
|
width: '100%',
|
|
21
22
|
height: '64px',
|
|
22
23
|
minHeight: '64px',
|
|
@@ -39,6 +40,8 @@ const AppBarContainer = styled('header')(({ theme }: { theme?: any }) => ({
|
|
|
39
40
|
interface AppBarProps {
|
|
40
41
|
/** Right section component (actions, profile, etc.) */
|
|
41
42
|
rightSection?: React.ReactNode;
|
|
43
|
+
/** Center section component (workspace switcher, etc.) */
|
|
44
|
+
centerSection?: React.ReactNode;
|
|
42
45
|
/** Menu items for mobile drawer */
|
|
43
46
|
menu?: SideMenuItemProps[];
|
|
44
47
|
/** Custom className for the AppBar */
|
|
@@ -49,6 +52,7 @@ interface AppBarProps {
|
|
|
49
52
|
|
|
50
53
|
export const AppBar: React.FC<AppBarProps> = ({
|
|
51
54
|
rightSection,
|
|
55
|
+
centerSection,
|
|
52
56
|
menu = [],
|
|
53
57
|
className = 'appHeaderV2',
|
|
54
58
|
sx = {},
|
|
@@ -79,9 +83,31 @@ export const AppBar: React.FC<AppBarProps> = ({
|
|
|
79
83
|
{isMobile ? <CampxIconV2 /> : <CampxFullLogoIconV2 size={28} />}
|
|
80
84
|
</Stack>
|
|
81
85
|
|
|
86
|
+
{/* Center section - Custom content from props */}
|
|
87
|
+
{centerSection && (
|
|
88
|
+
<Stack
|
|
89
|
+
direction="row"
|
|
90
|
+
alignItems="center"
|
|
91
|
+
gap="12px"
|
|
92
|
+
sx={{
|
|
93
|
+
position: 'absolute',
|
|
94
|
+
left: '50%',
|
|
95
|
+
transform: 'translateX(-50%)',
|
|
96
|
+
zIndex: 1,
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
{centerSection}
|
|
100
|
+
</Stack>
|
|
101
|
+
)}
|
|
102
|
+
|
|
82
103
|
{/* Right section - Custom content from props */}
|
|
83
104
|
{rightSection && (
|
|
84
|
-
<Stack
|
|
105
|
+
<Stack
|
|
106
|
+
direction="row"
|
|
107
|
+
alignItems="center"
|
|
108
|
+
gap="12px"
|
|
109
|
+
sx={{ zIndex: 2 }}
|
|
110
|
+
>
|
|
85
111
|
{rightSection}
|
|
86
112
|
</Stack>
|
|
87
113
|
)}
|
|
@@ -9,25 +9,70 @@ import {
|
|
|
9
9
|
import { Connector, StepIcon, StyledStepContent } from './StepperComponents';
|
|
10
10
|
|
|
11
11
|
interface StepperProps {
|
|
12
|
+
/** Orientation of the stepper */
|
|
12
13
|
orientation: 'vertical' | 'horizontal';
|
|
14
|
+
/** Current active step index (0-based) */
|
|
13
15
|
activeStep: number;
|
|
16
|
+
/** Array of step items with labels and optional descriptions */
|
|
14
17
|
steps: StepItem[];
|
|
18
|
+
/** Additional styles for the container */
|
|
15
19
|
containerSx: SxProps;
|
|
20
|
+
/** Callback function called when a step is clicked. Receives the step index as parameter */
|
|
21
|
+
onStepClick?: (stepIndex: number) => void;
|
|
22
|
+
/** Whether to allow navigation by clicking on steps. Defaults to true */
|
|
23
|
+
allowNavigation?: boolean;
|
|
16
24
|
}
|
|
17
25
|
|
|
18
26
|
interface StepItem {
|
|
27
|
+
/** The label text for the step */
|
|
19
28
|
label: string;
|
|
29
|
+
/** Optional description text shown below the label */
|
|
20
30
|
description?: string;
|
|
21
31
|
}
|
|
22
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Enhanced Stepper component with navigation capabilities
|
|
35
|
+
*
|
|
36
|
+
* Features:
|
|
37
|
+
* - Click on any step to navigate to it (when allowNavigation is true)
|
|
38
|
+
* - Supports both vertical and horizontal orientations
|
|
39
|
+
* - Customizable styling through containerSx prop
|
|
40
|
+
* - Optional step descriptions
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* const [activeStep, setActiveStep] = useState(0);
|
|
45
|
+
*
|
|
46
|
+
* <Stepper
|
|
47
|
+
* orientation="vertical"
|
|
48
|
+
* activeStep={activeStep}
|
|
49
|
+
* steps={[
|
|
50
|
+
* { label: "Step 1", description: "First step" },
|
|
51
|
+
* { label: "Step 2", description: "Second step" }
|
|
52
|
+
* ]}
|
|
53
|
+
* onStepClick={(stepIndex) => setActiveStep(stepIndex)}
|
|
54
|
+
* allowNavigation={true}
|
|
55
|
+
* containerSx={{}}
|
|
56
|
+
* />
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
|
|
23
60
|
export const Stepper = ({
|
|
24
61
|
orientation,
|
|
25
62
|
steps,
|
|
26
63
|
activeStep = 0,
|
|
27
64
|
containerSx,
|
|
65
|
+
onStepClick,
|
|
66
|
+
allowNavigation = true,
|
|
28
67
|
}: StepperProps) => {
|
|
29
68
|
const isVertical = orientation === 'vertical';
|
|
30
69
|
|
|
70
|
+
const handleStepClick = (stepIndex: number) => {
|
|
71
|
+
if (allowNavigation && onStepClick) {
|
|
72
|
+
onStepClick(stepIndex);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
31
76
|
return (
|
|
32
77
|
<Box
|
|
33
78
|
sx={{
|
|
@@ -43,7 +88,21 @@ export const Stepper = ({
|
|
|
43
88
|
>
|
|
44
89
|
{steps?.map((item, index) => (
|
|
45
90
|
<Step key={index} expanded>
|
|
46
|
-
<StepLabel
|
|
91
|
+
<StepLabel
|
|
92
|
+
StepIconComponent={(props) => (
|
|
93
|
+
<StepIcon {...props} onClick={() => handleStepClick(index)} />
|
|
94
|
+
)}
|
|
95
|
+
onClick={() => handleStepClick(index)}
|
|
96
|
+
sx={{
|
|
97
|
+
cursor: allowNavigation && onStepClick ? 'pointer' : 'default',
|
|
98
|
+
'& .MuiStepLabel-label': {
|
|
99
|
+
cursor:
|
|
100
|
+
allowNavigation && onStepClick ? 'pointer' : 'default',
|
|
101
|
+
},
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
{item?.label}
|
|
105
|
+
</StepLabel>
|
|
47
106
|
<StyledStepContent
|
|
48
107
|
isVertical={isVertical}
|
|
49
108
|
activeStep={index < activeStep}
|
|
@@ -40,14 +40,16 @@ export const Connector = styled(StepConnector)<ConnectorProps>(
|
|
|
40
40
|
({ theme, isVertical }) => ({
|
|
41
41
|
[`&.${stepConnectorClasses.active}`]: {
|
|
42
42
|
[`& .${stepConnectorClasses.line}`]: {
|
|
43
|
-
[isVertical
|
|
44
|
-
|
|
43
|
+
[isVertical
|
|
44
|
+
? 'borderLeft'
|
|
45
|
+
: 'border']: `1px solid ${theme.palette.primary.light}`,
|
|
45
46
|
},
|
|
46
47
|
},
|
|
47
48
|
[`&.${stepConnectorClasses.completed}`]: {
|
|
48
49
|
[`& .${stepConnectorClasses.line}`]: {
|
|
49
|
-
[isVertical
|
|
50
|
-
|
|
50
|
+
[isVertical
|
|
51
|
+
? 'borderLeft'
|
|
52
|
+
: 'border']: `1px solid ${theme.palette.primary.light}`,
|
|
51
53
|
},
|
|
52
54
|
},
|
|
53
55
|
...(isVertical
|
|
@@ -66,8 +68,8 @@ export const Connector = styled(StepConnector)<ConnectorProps>(
|
|
|
66
68
|
}),
|
|
67
69
|
);
|
|
68
70
|
|
|
69
|
-
export function StepIcon(props: StepIconProps) {
|
|
70
|
-
const { active, completed, className } = props;
|
|
71
|
+
export function StepIcon(props: StepIconProps & { onClick?: () => void }) {
|
|
72
|
+
const { active, completed, className, onClick } = props;
|
|
71
73
|
|
|
72
74
|
const getIcon = () => {
|
|
73
75
|
if (completed) return <CompletedStateIcon />;
|
|
@@ -75,12 +77,23 @@ export function StepIcon(props: StepIconProps) {
|
|
|
75
77
|
return <UnCheckedRadioIcon />;
|
|
76
78
|
};
|
|
77
79
|
|
|
78
|
-
return
|
|
80
|
+
return (
|
|
81
|
+
<StepIconRoot
|
|
82
|
+
className={className}
|
|
83
|
+
onClick={onClick}
|
|
84
|
+
sx={{
|
|
85
|
+
cursor: onClick ? 'pointer' : 'default',
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
{getIcon()}
|
|
89
|
+
</StepIconRoot>
|
|
90
|
+
);
|
|
79
91
|
}
|
|
80
92
|
|
|
81
|
-
const StepIconRoot = styled('div')<{}>(({ theme }) => ({
|
|
93
|
+
const StepIconRoot = styled('div')<{ sx?: any }>(({ theme, sx }) => ({
|
|
82
94
|
width: 20,
|
|
83
95
|
display: 'flex',
|
|
84
96
|
justifyContent: 'center',
|
|
85
97
|
alignItems: 'center',
|
|
98
|
+
...sx,
|
|
86
99
|
}));
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react/*';
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import { Stepper } from '../../components/Navigation/Stepper/Stepper';
|
|
3
4
|
|
|
4
5
|
const meta: Meta<typeof Stepper> = {
|
|
5
6
|
title: 'Navigation/Stepper',
|
|
6
7
|
component: Stepper,
|
|
7
|
-
argTypes: {
|
|
8
|
+
argTypes: {
|
|
9
|
+
allowNavigation: {
|
|
10
|
+
control: 'boolean',
|
|
11
|
+
description: 'Allow clicking on steps to navigate',
|
|
12
|
+
},
|
|
13
|
+
onStepClick: {
|
|
14
|
+
action: 'step-clicked',
|
|
15
|
+
description: 'Callback when a step is clicked',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
8
18
|
};
|
|
9
19
|
|
|
10
20
|
export default meta;
|
|
@@ -42,6 +52,30 @@ export const VerticalStepper: Story = {
|
|
|
42
52
|
orientation: 'vertical',
|
|
43
53
|
steps,
|
|
44
54
|
activeStep: 2,
|
|
55
|
+
allowNavigation: true,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// Interactive Stepper with navigation
|
|
60
|
+
export const InteractiveVerticalStepper: Story = {
|
|
61
|
+
render: (args) => {
|
|
62
|
+
const [activeStep, setActiveStep] = useState(0);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<Stepper
|
|
66
|
+
{...args}
|
|
67
|
+
activeStep={activeStep}
|
|
68
|
+
onStepClick={(stepIndex) => {
|
|
69
|
+
setActiveStep(stepIndex);
|
|
70
|
+
args.onStepClick?.(stepIndex);
|
|
71
|
+
}}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
args: {
|
|
76
|
+
orientation: 'vertical',
|
|
77
|
+
steps,
|
|
78
|
+
allowNavigation: true,
|
|
45
79
|
},
|
|
46
80
|
};
|
|
47
81
|
|
|
@@ -61,6 +95,39 @@ export const HorizontalStepper: Story = {
|
|
|
61
95
|
},
|
|
62
96
|
};
|
|
63
97
|
|
|
98
|
+
// Interactive Horizontal Stepper with navigation
|
|
99
|
+
export const InteractiveHorizontalStepper: Story = {
|
|
100
|
+
render: (args) => {
|
|
101
|
+
const [activeStep, setActiveStep] = useState(1);
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<Stepper
|
|
105
|
+
{...args}
|
|
106
|
+
activeStep={activeStep}
|
|
107
|
+
onStepClick={(stepIndex) => {
|
|
108
|
+
setActiveStep(stepIndex);
|
|
109
|
+
args.onStepClick?.(stepIndex);
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
},
|
|
114
|
+
args: {
|
|
115
|
+
orientation: 'horizontal',
|
|
116
|
+
steps,
|
|
117
|
+
allowNavigation: true,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// Stepper with navigation disabled
|
|
122
|
+
export const NonNavigableStepper: Story = {
|
|
123
|
+
args: {
|
|
124
|
+
orientation: 'vertical',
|
|
125
|
+
steps,
|
|
126
|
+
activeStep: 2,
|
|
127
|
+
allowNavigation: false,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
|
|
64
131
|
export const HorizontalStepperWithNoDescription: Story = {
|
|
65
132
|
args: {
|
|
66
133
|
...HorizontalStepper.args,
|