@campxdev/react-blueprint 2.3.0 → 2.3.1
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/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/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 +37 -1
- package/package.json +1 -1
- 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
|
@@ -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
|
@@ -1432,16 +1432,52 @@ type PreviewFilesProps = {
|
|
|
1432
1432
|
declare const PreviewFiles: ({ files, label, onChange, showDownload, hideDelete, sx, ...props }: PreviewFilesProps) => react_jsx_runtime.JSX.Element;
|
|
1433
1433
|
|
|
1434
1434
|
interface StepperProps {
|
|
1435
|
+
/** Orientation of the stepper */
|
|
1435
1436
|
orientation: 'vertical' | 'horizontal';
|
|
1437
|
+
/** Current active step index (0-based) */
|
|
1436
1438
|
activeStep: number;
|
|
1439
|
+
/** Array of step items with labels and optional descriptions */
|
|
1437
1440
|
steps: StepItem[];
|
|
1441
|
+
/** Additional styles for the container */
|
|
1438
1442
|
containerSx: SxProps;
|
|
1443
|
+
/** Callback function called when a step is clicked. Receives the step index as parameter */
|
|
1444
|
+
onStepClick?: (stepIndex: number) => void;
|
|
1445
|
+
/** Whether to allow navigation by clicking on steps. Defaults to true */
|
|
1446
|
+
allowNavigation?: boolean;
|
|
1439
1447
|
}
|
|
1440
1448
|
interface StepItem {
|
|
1449
|
+
/** The label text for the step */
|
|
1441
1450
|
label: string;
|
|
1451
|
+
/** Optional description text shown below the label */
|
|
1442
1452
|
description?: string;
|
|
1443
1453
|
}
|
|
1444
|
-
|
|
1454
|
+
/**
|
|
1455
|
+
* Enhanced Stepper component with navigation capabilities
|
|
1456
|
+
*
|
|
1457
|
+
* Features:
|
|
1458
|
+
* - Click on any step to navigate to it (when allowNavigation is true)
|
|
1459
|
+
* - Supports both vertical and horizontal orientations
|
|
1460
|
+
* - Customizable styling through containerSx prop
|
|
1461
|
+
* - Optional step descriptions
|
|
1462
|
+
*
|
|
1463
|
+
* @example
|
|
1464
|
+
* ```tsx
|
|
1465
|
+
* const [activeStep, setActiveStep] = useState(0);
|
|
1466
|
+
*
|
|
1467
|
+
* <Stepper
|
|
1468
|
+
* orientation="vertical"
|
|
1469
|
+
* activeStep={activeStep}
|
|
1470
|
+
* steps={[
|
|
1471
|
+
* { label: "Step 1", description: "First step" },
|
|
1472
|
+
* { label: "Step 2", description: "Second step" }
|
|
1473
|
+
* ]}
|
|
1474
|
+
* onStepClick={(stepIndex) => setActiveStep(stepIndex)}
|
|
1475
|
+
* allowNavigation={true}
|
|
1476
|
+
* containerSx={{}}
|
|
1477
|
+
* />
|
|
1478
|
+
* ```
|
|
1479
|
+
*/
|
|
1480
|
+
declare const Stepper: ({ orientation, steps, activeStep, containerSx, onStepClick, allowNavigation, }: StepperProps) => react_jsx_runtime.JSX.Element;
|
|
1445
1481
|
|
|
1446
1482
|
interface CustomTabProps extends Omit<TabProps, 'component'> {
|
|
1447
1483
|
key: string | number;
|
package/package.json
CHANGED
|
@@ -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,
|