@dt-dds/react-stepper 1.0.0-beta.46 → 1.0.0-beta.47
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/CHANGELOG.md +6 -0
- package/README.md +157 -23
- package/dist/index.d.mts +39 -22
- package/dist/index.d.ts +39 -22
- package/dist/index.js +463 -157
- package/dist/index.mjs +465 -158
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,44 +1,178 @@
|
|
|
1
1
|
# Stepper Package
|
|
2
2
|
|
|
3
|
-
Steppers convey progress through
|
|
3
|
+
Steppers convey progress through numbered, bullet, or icon-based sequential steps.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
They support various states including completed, incomplete, warning, error, and disabled.
|
|
6
6
|
|
|
7
7
|
## Stepper Usage
|
|
8
8
|
|
|
9
9
|
```jsx
|
|
10
|
-
import { Stepper
|
|
10
|
+
import { Stepper } from '@dt-dds/react-stepper';
|
|
11
11
|
|
|
12
12
|
export const App = () => {
|
|
13
|
-
const options = ['API version definition', 'Specifications', 'Review'];
|
|
14
|
-
|
|
15
|
-
const currentStep = 3;
|
|
16
|
-
const completed = [1, 2];
|
|
17
|
-
|
|
18
13
|
return (
|
|
19
14
|
<Stepper>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
15
|
+
<Stepper.Step
|
|
16
|
+
title="Completed Step"
|
|
17
|
+
description="This step is done"
|
|
18
|
+
state="completed"
|
|
19
|
+
/>
|
|
20
|
+
<Stepper.Step
|
|
21
|
+
title="Current Step"
|
|
22
|
+
description="Working on this"
|
|
23
|
+
state="incomplete"
|
|
24
|
+
isActive={true}
|
|
25
|
+
/>
|
|
26
|
+
<Stepper.Step
|
|
27
|
+
title="Warning Step"
|
|
28
|
+
description="Needs attention"
|
|
29
|
+
state="warning"
|
|
30
|
+
/>
|
|
31
|
+
<Stepper.Step
|
|
32
|
+
title="Error Step"
|
|
33
|
+
description="Something went wrong"
|
|
34
|
+
state="error"
|
|
35
|
+
/>
|
|
36
|
+
<Stepper.Step
|
|
37
|
+
title="Disabled Step"
|
|
38
|
+
description="Not available yet"
|
|
39
|
+
state="disabled"
|
|
40
|
+
/>
|
|
30
41
|
</Stepper>
|
|
31
42
|
);
|
|
32
43
|
};
|
|
33
44
|
```
|
|
34
45
|
|
|
46
|
+
## Variants
|
|
47
|
+
|
|
48
|
+
### Number Variant (Default)
|
|
49
|
+
|
|
50
|
+
```jsx
|
|
51
|
+
<Stepper variant="number">
|
|
52
|
+
<Stepper.Step title="Step 1" />
|
|
53
|
+
<Stepper.Step title="Step 2" />
|
|
54
|
+
<Stepper.Step title="Step 3" />
|
|
55
|
+
</Stepper>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Bullet Variant
|
|
59
|
+
|
|
60
|
+
```jsx
|
|
61
|
+
<Stepper variant="bullet">
|
|
62
|
+
<Stepper.Step title="Step 1" />
|
|
63
|
+
<Stepper.Step title="Step 2" />
|
|
64
|
+
<Stepper.Step title="Step 3" />
|
|
65
|
+
</Stepper>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Icon Variant
|
|
69
|
+
|
|
70
|
+
```jsx
|
|
71
|
+
import { Icon } from '@dt-dds/react-icon';
|
|
72
|
+
|
|
73
|
+
<Stepper variant="icon">
|
|
74
|
+
<Stepper.Step
|
|
75
|
+
title="Upload"
|
|
76
|
+
icon={<Icon code="upload" size="small" />}
|
|
77
|
+
/>
|
|
78
|
+
<Stepper.Step
|
|
79
|
+
title="Process"
|
|
80
|
+
icon={<Icon code="settings" size="small" />}
|
|
81
|
+
/>
|
|
82
|
+
<Stepper.Step
|
|
83
|
+
title="Complete"
|
|
84
|
+
icon={<Icon code="check_circle" size="small" />}
|
|
85
|
+
/>
|
|
86
|
+
</Stepper>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Using the useStepper Hook
|
|
90
|
+
|
|
91
|
+
The useStepper hook provides a complete state management solution for steppers, including navigation, completion tracking, and boundary checks.
|
|
92
|
+
|
|
93
|
+
```jsx
|
|
94
|
+
import { useStepper } from '@dt-dds/react-stepper';
|
|
95
|
+
|
|
96
|
+
export const ControlledStepper = () => {
|
|
97
|
+
const {
|
|
98
|
+
activeStep,
|
|
99
|
+
handleNext,
|
|
100
|
+
handleBack,
|
|
101
|
+
canGoNext,
|
|
102
|
+
canGoBack,
|
|
103
|
+
} = useStepper({
|
|
104
|
+
initialStep: 0,
|
|
105
|
+
totalSteps: 3,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<>
|
|
110
|
+
<Stepper activeStep={activeStep}>
|
|
111
|
+
<Stepper.Step title="Step 1" description="First step" />
|
|
112
|
+
<Stepper.Step title="Step 2" description="Second step" />
|
|
113
|
+
<Stepper.Step title="Step 3" description="Third step" />
|
|
114
|
+
</Stepper>
|
|
115
|
+
|
|
116
|
+
<button onClick={handleBack} disabled={!canGoBack}>
|
|
117
|
+
Back
|
|
118
|
+
</button>
|
|
119
|
+
<button onClick={handleNext} disabled={!canGoNext}>
|
|
120
|
+
Next
|
|
121
|
+
</button>
|
|
122
|
+
</>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## useStepper Hook API
|
|
128
|
+
|
|
129
|
+
### Options
|
|
130
|
+
|
|
131
|
+
| Option | Type | Default | Description |
|
|
132
|
+
|-----------------|----------|---------|---------------------------------------|
|
|
133
|
+
| `initialStep` | `number` | `0` | The initial active step (0-based) |
|
|
134
|
+
| `totalSteps` | `number` | — | Total number of steps (for boundary checks) |
|
|
135
|
+
|
|
136
|
+
### useStepper Return Values
|
|
137
|
+
|
|
138
|
+
| Property | Type | Description |
|
|
139
|
+
|-----------------------------|----------------------------------------|--------------------------------------------------|
|
|
140
|
+
| `activeStep` | `number` | Current active step index |
|
|
141
|
+
| `isFirstStep` | `boolean` | Whether currently on the first step |
|
|
142
|
+
| `isLastStep` | `boolean` | Whether currently on the last step |
|
|
143
|
+
| `canGoNext` | `boolean` | Whether navigation to the next step is allowed |
|
|
144
|
+
| `canGoBack` | `boolean` | Whether navigation to the previous step is allowed |
|
|
145
|
+
| `completedSteps` | `Set<number>` | Set of completed step indices |
|
|
146
|
+
| `handleNext` | `() => void` | Navigate to the next step |
|
|
147
|
+
| `handleBack` | `() => void` | Navigate to the previous step |
|
|
148
|
+
| `handleChangeStep` | `(step: number) => void` | Navigate to a specific step |
|
|
149
|
+
| `handleReset` | `() => void` | Reset to initial step and clear completed steps |
|
|
150
|
+
| `markStepComplete` | `(step: number) => void` | Mark a specific step as completed |
|
|
151
|
+
| `markStepIncomplete` | `(step: number) => void` | Mark a specific step as incomplete |
|
|
152
|
+
| `isStepComplete` | `(step: number) => boolean` | Check if a specific step is completed |
|
|
153
|
+
|
|
35
154
|
## Properties
|
|
36
155
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
| `
|
|
156
|
+
### Stepper Props
|
|
157
|
+
|
|
158
|
+
| Property | Type | Default | Description |
|
|
159
|
+
| ------------- | -------------------------------- | --------- | ---------------------------------------- |
|
|
160
|
+
| `children` | `ReactNode` | — | Step components to be rendered |
|
|
161
|
+
| `orientation` | `"vertical" \| "horizontal"` | `vertical`| Direction of the stepper |
|
|
162
|
+
| `variant` | `"number" \| "bullet" \| "icon"` | `number` | Visual style of step indicators |
|
|
163
|
+
| `activeStep` | `number` | — | Index of the active step (0-based) |
|
|
164
|
+
| `dataTestId` | `string` | `stepper` | Test identifier for the stepper container|
|
|
165
|
+
|
|
166
|
+
### Step Props
|
|
167
|
+
|
|
168
|
+
| Property | Type | Default | Description |
|
|
169
|
+
|--------------|-----------------------------------------------------------------|----------------|----------------------------------------------|
|
|
170
|
+
| `title` | `string` | — | Title text for the step |
|
|
171
|
+
| `description`| `string` | — | Description text for the step |
|
|
172
|
+
| `state` | `"completed" \| "warning" \| "error" \| "disabled" \| "incomplete"` | `incomplete` | Visual state of the step |
|
|
173
|
+
| `isActive` | `boolean` | `false` | Whether the step is currently active |
|
|
174
|
+
| `icon` | `ReactNode` | — | Custom icon for the icon variant |
|
|
175
|
+
| `dataTestId` | `string` | `step-{index}` | Test identifier for the step |
|
|
42
176
|
|
|
43
177
|
## Stack
|
|
44
178
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,41 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { CustomTheme } from '@dt-dds/themes';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
3
|
import { BaseProps, Orientation } from '@dt-dds/react-core';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
5
|
|
|
6
|
+
type StepVariant = 'number' | 'bullet' | 'icon';
|
|
7
|
+
type StepState = 'completed' | 'warning' | 'error' | 'disabled' | 'incomplete';
|
|
5
8
|
interface StepperProps extends BaseProps {
|
|
6
9
|
orientation?: Orientation;
|
|
10
|
+
variant?: StepVariant;
|
|
11
|
+
activeStep?: number;
|
|
7
12
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
interface StepProps extends BaseProps {
|
|
14
|
+
index?: number;
|
|
15
|
+
title?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
state?: StepState;
|
|
11
18
|
isActive?: boolean;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
variant?: StepVariant;
|
|
20
|
+
icon?: ReactNode;
|
|
21
|
+
isLast?: boolean;
|
|
22
|
+
orientation?: Orientation;
|
|
15
23
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
|
|
25
|
+
declare const Stepper: {
|
|
26
|
+
({ children, orientation, variant, activeStep, dataTestId, }: StepperProps): react_jsx_runtime.JSX.Element;
|
|
27
|
+
Step: ({ index, title, description, state, isActive, variant, icon, isLast, orientation, dataTestId, }: StepProps) => react_jsx_runtime.JSX.Element;
|
|
20
28
|
};
|
|
21
29
|
|
|
22
|
-
|
|
23
|
-
color?: Colors | 'disabled';
|
|
24
|
-
outlined?: boolean;
|
|
25
|
-
isLarge?: boolean;
|
|
26
|
-
}
|
|
27
|
-
declare const Counter: ({ children, color, dataTestId, style, outlined, isLarge, }: CounterProps) => react_jsx_runtime.JSX.Element;
|
|
30
|
+
declare const Step: ({ index, title, description, state, isActive, variant, icon, isLast, orientation, dataTestId, }: StepProps) => react_jsx_runtime.JSX.Element;
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
interface UseStepperOptions {
|
|
33
|
+
initialStep?: number;
|
|
34
|
+
totalSteps?: number;
|
|
35
|
+
}
|
|
36
|
+
interface UseStepperReturn {
|
|
30
37
|
activeStep: number;
|
|
31
|
-
|
|
38
|
+
isFirstStep: boolean;
|
|
39
|
+
isLastStep: boolean;
|
|
40
|
+
canGoNext: boolean;
|
|
41
|
+
canGoBack: boolean;
|
|
42
|
+
completedSteps: Set<number>;
|
|
32
43
|
handleNext: () => void;
|
|
33
44
|
handleBack: () => void;
|
|
34
|
-
|
|
45
|
+
handleChangeStep: (step: number) => void;
|
|
46
|
+
handleReset: () => void;
|
|
47
|
+
markStepComplete: (step: number) => void;
|
|
48
|
+
markStepIncomplete: (step: number) => void;
|
|
49
|
+
isStepComplete: (step: number) => boolean;
|
|
50
|
+
}
|
|
51
|
+
declare const useStepper: (options?: UseStepperOptions) => UseStepperReturn;
|
|
35
52
|
|
|
36
53
|
declare module '@emotion/react' {
|
|
37
54
|
interface Theme extends CustomTheme {
|
|
38
55
|
}
|
|
39
56
|
}
|
|
40
57
|
|
|
41
|
-
export {
|
|
58
|
+
export { Step, type StepProps, type StepState, type StepVariant, Stepper, type StepperProps, useStepper };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,41 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { CustomTheme } from '@dt-dds/themes';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
3
|
import { BaseProps, Orientation } from '@dt-dds/react-core';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
5
|
|
|
6
|
+
type StepVariant = 'number' | 'bullet' | 'icon';
|
|
7
|
+
type StepState = 'completed' | 'warning' | 'error' | 'disabled' | 'incomplete';
|
|
5
8
|
interface StepperProps extends BaseProps {
|
|
6
9
|
orientation?: Orientation;
|
|
10
|
+
variant?: StepVariant;
|
|
11
|
+
activeStep?: number;
|
|
7
12
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
interface StepProps extends BaseProps {
|
|
14
|
+
index?: number;
|
|
15
|
+
title?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
state?: StepState;
|
|
11
18
|
isActive?: boolean;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
variant?: StepVariant;
|
|
20
|
+
icon?: ReactNode;
|
|
21
|
+
isLast?: boolean;
|
|
22
|
+
orientation?: Orientation;
|
|
15
23
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
|
|
25
|
+
declare const Stepper: {
|
|
26
|
+
({ children, orientation, variant, activeStep, dataTestId, }: StepperProps): react_jsx_runtime.JSX.Element;
|
|
27
|
+
Step: ({ index, title, description, state, isActive, variant, icon, isLast, orientation, dataTestId, }: StepProps) => react_jsx_runtime.JSX.Element;
|
|
20
28
|
};
|
|
21
29
|
|
|
22
|
-
|
|
23
|
-
color?: Colors | 'disabled';
|
|
24
|
-
outlined?: boolean;
|
|
25
|
-
isLarge?: boolean;
|
|
26
|
-
}
|
|
27
|
-
declare const Counter: ({ children, color, dataTestId, style, outlined, isLarge, }: CounterProps) => react_jsx_runtime.JSX.Element;
|
|
30
|
+
declare const Step: ({ index, title, description, state, isActive, variant, icon, isLast, orientation, dataTestId, }: StepProps) => react_jsx_runtime.JSX.Element;
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
interface UseStepperOptions {
|
|
33
|
+
initialStep?: number;
|
|
34
|
+
totalSteps?: number;
|
|
35
|
+
}
|
|
36
|
+
interface UseStepperReturn {
|
|
30
37
|
activeStep: number;
|
|
31
|
-
|
|
38
|
+
isFirstStep: boolean;
|
|
39
|
+
isLastStep: boolean;
|
|
40
|
+
canGoNext: boolean;
|
|
41
|
+
canGoBack: boolean;
|
|
42
|
+
completedSteps: Set<number>;
|
|
32
43
|
handleNext: () => void;
|
|
33
44
|
handleBack: () => void;
|
|
34
|
-
|
|
45
|
+
handleChangeStep: (step: number) => void;
|
|
46
|
+
handleReset: () => void;
|
|
47
|
+
markStepComplete: (step: number) => void;
|
|
48
|
+
markStepIncomplete: (step: number) => void;
|
|
49
|
+
isStepComplete: (step: number) => boolean;
|
|
50
|
+
}
|
|
51
|
+
declare const useStepper: (options?: UseStepperOptions) => UseStepperReturn;
|
|
35
52
|
|
|
36
53
|
declare module '@emotion/react' {
|
|
37
54
|
interface Theme extends CustomTheme {
|
|
38
55
|
}
|
|
39
56
|
}
|
|
40
57
|
|
|
41
|
-
export {
|
|
58
|
+
export { Step, type StepProps, type StepState, type StepVariant, Stepper, type StepperProps, useStepper };
|