@dt-dds/react-stepper 1.0.0-beta.46 → 1.0.0-beta.48

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # @dt-ui/react-stepper
2
2
 
3
+ ## 1.0.0-beta.48
4
+
5
+ ### Minor Changes
6
+
7
+ - feat: increase dropdown z index
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @dt-dds/react-core@1.0.0-beta.55
13
+ - @dt-dds/react-tooltip@1.0.0-beta.64
14
+ - @dt-dds/react-icon@1.0.0-beta.58
15
+ - @dt-dds/react-typography@1.0.0-beta.46
16
+
17
+ ## 1.0.0-beta.47
18
+
19
+ ### Minor Changes
20
+
21
+ - feat: refactor stepper
22
+
3
23
  ## 1.0.0-beta.46
4
24
 
5
25
  ### Patch Changes
package/README.md CHANGED
@@ -1,44 +1,178 @@
1
1
  # Stepper Package
2
2
 
3
- Steppers convey progress through steps. These steps can be numbered or not. However, they are sequential.
3
+ Steppers convey progress through numbered, bullet, or icon-based sequential steps.
4
4
 
5
- By default, for screens smaller than our `theme.breakpoints.mq3d` the stepper orientation is always vertical.
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, Step } from '@dt-dds/react';
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
- {options.map((opt, idx) => (
21
- <Step
22
- key={option.value}
23
- isActive={currentStep === idx + 1}
24
- isCompleted={completed.includes(idx + 1)}
25
- >
26
- <Step.Counter>{idx + 1}</Step.Counter>
27
- <Step.Label>{opt}</Step.Label>
28
- </Step>
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
- | Property | Type | Default | Description |
38
- | ------------- | ---------------------------- | --------------- | ------------------------------------------------------------------------------- |
39
- | `children` | `ReactNode` | - | Child components to be rendered |
40
- | `dataTestId` | `string` | default-stepper | Customizable test identifier. This id is concatenated with the -stepper string. |
41
- | `orientation` | `"vertical" \| "horizontal"` | vertical | To specify the direction of the step bar. |
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 { Colors, CustomTheme } from '@dt-dds/themes';
2
- import * as react_jsx_runtime from 'react/jsx-runtime';
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
- declare const Stepper: ({ children, dataTestId, orientation, }: StepperProps) => react_jsx_runtime.JSX.Element;
9
-
10
- interface BaseStepProps extends Pick<BaseProps, 'children'> {
13
+ interface StepProps extends BaseProps {
14
+ index?: number;
15
+ title?: string;
16
+ description?: string;
17
+ state?: StepState;
11
18
  isActive?: boolean;
12
- isCompleted?: boolean;
13
- isDisabled?: boolean;
14
- isError?: boolean;
19
+ variant?: StepVariant;
20
+ icon?: ReactNode;
21
+ isLast?: boolean;
22
+ orientation?: Orientation;
15
23
  }
16
- declare const Step: {
17
- ({ children, isActive, isCompleted, isDisabled, isError, }: BaseStepProps): react_jsx_runtime.JSX.Element;
18
- Counter: ({ children, isActive, isCompleted, isDisabled, isError, }: BaseStepProps) => react_jsx_runtime.JSX.Element;
19
- Label({ children, isActive, isCompleted, isDisabled, isError, }: BaseStepProps): react_jsx_runtime.JSX.Element;
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
- interface CounterProps extends BaseProps {
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
- declare const useStepper: () => {
32
+ interface UseStepperOptions {
33
+ initialStep?: number;
34
+ totalSteps?: number;
35
+ }
36
+ interface UseStepperReturn {
30
37
  activeStep: number;
31
- handleChangeStep: (step: number) => void;
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 { Counter, type CounterProps, Step, Stepper, type StepperProps, useStepper };
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 { Colors, CustomTheme } from '@dt-dds/themes';
2
- import * as react_jsx_runtime from 'react/jsx-runtime';
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
- declare const Stepper: ({ children, dataTestId, orientation, }: StepperProps) => react_jsx_runtime.JSX.Element;
9
-
10
- interface BaseStepProps extends Pick<BaseProps, 'children'> {
13
+ interface StepProps extends BaseProps {
14
+ index?: number;
15
+ title?: string;
16
+ description?: string;
17
+ state?: StepState;
11
18
  isActive?: boolean;
12
- isCompleted?: boolean;
13
- isDisabled?: boolean;
14
- isError?: boolean;
19
+ variant?: StepVariant;
20
+ icon?: ReactNode;
21
+ isLast?: boolean;
22
+ orientation?: Orientation;
15
23
  }
16
- declare const Step: {
17
- ({ children, isActive, isCompleted, isDisabled, isError, }: BaseStepProps): react_jsx_runtime.JSX.Element;
18
- Counter: ({ children, isActive, isCompleted, isDisabled, isError, }: BaseStepProps) => react_jsx_runtime.JSX.Element;
19
- Label({ children, isActive, isCompleted, isDisabled, isError, }: BaseStepProps): react_jsx_runtime.JSX.Element;
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
- interface CounterProps extends BaseProps {
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
- declare const useStepper: () => {
32
+ interface UseStepperOptions {
33
+ initialStep?: number;
34
+ totalSteps?: number;
35
+ }
36
+ interface UseStepperReturn {
30
37
  activeStep: number;
31
- handleChangeStep: (step: number) => void;
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 { Counter, type CounterProps, Step, Stepper, type StepperProps, useStepper };
58
+ export { Step, type StepProps, type StepState, type StepVariant, Stepper, type StepperProps, useStepper };